Skip to contentSkip to conversation

PHY: for 3.14

GIT PULL New Kishon Vijay Abraham I 2 participants 9 messages Dec 26, 2013 – Jan 9, 2014 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

Hi Greg,

here's the patches for 3.14. It contains few fixes on phy-core and added a new PHY driver used by SATA in Marvell SoCs.

Let me know if you need any changes.

Thanks
Kishon

The following changes since commit 413541dd66d51f791a0b169d9b9014e4f56be13c:

Linux 3.13-rc5 (2013-12-22 13:08:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/for_3.14

for you to fetch changes up to e3eae85773ebd2165d19ca8661cca3b9c60b2ba1:

Phy: Add a PHY driver for Marvell MVEBU SATA PHY. (2013-12-24 23:52:58 +0530)

----------------------------------------------------------------
Pull request for PHY subsystem contains few fixes in PHY-CORE mostly w.r.t PM and reference counting and also a new PHY driver used by SATA in Marvell SoC.

----------------------------------------------------------------
Andrew Lunn (1):
Phy: Add a PHY driver for Marvell MVEBU SATA PHY.

Felipe Balbi (1):
phy: core: properly handle failure of pm_runtime_get functions

Kishon Vijay Abraham I (2):
phy: phy-core: increment refcounting variables only on 'success'
phy: phy-core.c: remove unnecessary initialization of local variables

 drivers/phy/Kconfig          |    6 ++++++
 drivers/phy/Makefile         |    1 +
 drivers/phy/phy-core.c       |   44 +++++++++++++++++++++++++++++-------------
 drivers/phy/phy-mvebu-sata.c |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 175 insertions(+), 13 deletions(-)
 create mode 100644 drivers/phy/phy-mvebu-sata.c
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/4 phy: core: properly handle failure of pm_runtime_get functions

From: Felipe Balbi <[email protected]>

In case pm_runtime_get*() fails, it still increments pm usage counter, so we *must* make sure to pm_runtime_put() even in those cases.

This patch fixes that mistake the same way usbcore treats those possible failures.

---
 drivers/phy/phy-core.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/phy/phy-core.c +14 -2
index 58e0e97..8797bb7 100644
@@ -94,19 +94,31 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
 
 int phy_pm_runtime_get(struct phy *phy)
 {
+	int ret;
+
 	if (!pm_runtime_enabled(&phy->dev))
 		return -ENOTSUPP;
 
-	return pm_runtime_get(&phy->dev);
+	ret = pm_runtime_get(&phy->dev);
+	if (ret < 0 && ret != -EINPROGRESS)
+		pm_runtime_put_noidle(&phy->dev);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
 
 int phy_pm_runtime_get_sync(struct phy *phy)
 {
+	int ret;
+
 	if (!pm_runtime_enabled(&phy->dev))
 		return -ENOTSUPP;
 
-	return pm_runtime_get_sync(&phy->dev);
+	ret = pm_runtime_get_sync(&phy->dev);
+	if (ret < 0)
+		pm_runtime_put_sync(&phy->dev);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/4 phy: phy-core: increment refcounting variables only on 'success'

In reply to Kishon Vijay Abraham I

Increment 'init_count' only if the 'init' callback succeeded and decrement 'init_count' only if the 'exit' callback succeded. Increment 'power_count' only if 'power_on' callback succeded and if it failed disable the clocks using phy_pm_runtime_put_sync(). Also decrement 'power_count' only if 'power_off' callback succeded and if it failed do not disable the clocks.

---
 drivers/phy/phy-core.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/phy/phy-core.c +14 -8
index 8797bb7..33fcbcc 100644
@@ -167,13 +167,14 @@ int phy_init(struct phy *phy)
 		return ret;
 
 	mutex_lock(&phy->mutex);
-	if (phy->init_count++ == 0 && phy->ops->init) {
+	if (phy->init_count == 0 && phy->ops->init) {
 		ret = phy->ops->init(phy);
 		if (ret < 0) {
 			dev_err(&phy->dev, "phy init failed --> %d\n", ret);
 			goto out;
 		}
 	}
+	++phy->init_count;
 
 out:
 	mutex_unlock(&phy->mutex);
@@ -191,13 +192,14 @@ int phy_exit(struct phy *phy)
 		return ret;
 
 	mutex_lock(&phy->mutex);
-	if (--phy->init_count == 0 && phy->ops->exit) {
+	if (phy->init_count == 1 && phy->ops->exit) {
 		ret = phy->ops->exit(phy);
 		if (ret < 0) {
 			dev_err(&phy->dev, "phy exit failed --> %d\n", ret);
 			goto out;
 		}
 	}
+	--phy->init_count;
 
 out:
 	mutex_unlock(&phy->mutex);
@@ -215,16 +217,20 @@ int phy_power_on(struct phy *phy)
 		return ret;
 
 	mutex_lock(&phy->mutex);
-	if (phy->power_count++ == 0 && phy->ops->power_on) {
+	if (phy->power_count == 0 && phy->ops->power_on) {
 		ret = phy->ops->power_on(phy);
 		if (ret < 0) {
 			dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
 			goto out;
 		}
 	}
+	++phy->power_count;
+	mutex_unlock(&phy->mutex);
+	return 0;
 
 out:
 	mutex_unlock(&phy->mutex);
+	phy_pm_runtime_put_sync(phy);
 
 	return ret;
 }
@@ -235,19 +241,19 @@ int phy_power_off(struct phy *phy)
 	int ret = -ENOTSUPP;
 
 	mutex_lock(&phy->mutex);
-	if (--phy->power_count == 0 && phy->ops->power_off) {
+	if (phy->power_count == 1 && phy->ops->power_off) {
 		ret =  phy->ops->power_off(phy);
 		if (ret < 0) {
 			dev_err(&phy->dev, "phy poweroff failed --> %d\n", ret);
-			goto out;
+			mutex_unlock(&phy->mutex);
+			return ret;
 		}
 	}
-
-out:
+	--phy->power_count;
 	mutex_unlock(&phy->mutex);
 	phy_pm_runtime_put(phy);
 
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(phy_power_off);
 
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/4 phy: phy-core.c: remove unnecessary initialization of local variables

In reply to Kishon Vijay Abraham I

There were a few places where variables are initialized unncessarily. Remove those initializations.

---
 drivers/phy/phy-core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/phy-core.c +3 -3
index 33fcbcc..645c867 100644
@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(phy_exit);
 
 int phy_power_on(struct phy *phy)
 {
-	int ret = -ENOTSUPP;
+	int ret;
 
 	ret = phy_pm_runtime_get_sync(phy);
 	if (ret < 0 && ret != -ENOTSUPP)
@@ -238,7 +238,7 @@ EXPORT_SYMBOL_GPL(phy_power_on);
 
 int phy_power_off(struct phy *phy)
 {
-	int ret = -ENOTSUPP;
+	int ret;
 
 	mutex_lock(&phy->mutex);
 	if (phy->power_count == 1 && phy->ops->power_off) {
@@ -378,7 +378,7 @@ EXPORT_SYMBOL_GPL(of_phy_simple_xlate);
 struct phy *phy_get(struct device *dev, const char *string)
 {
 	int index = 0;
-	struct phy *phy = NULL;
+	struct phy *phy;
 
 	if (string == NULL) {
 		dev_WARN(dev, "missing string\n");
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/4 Phy: Add a PHY driver for Marvell MVEBU SATA PHY.

In reply to Kishon Vijay Abraham I

From: Andrew Lunn <[email protected]>

Kirkwood and Dove can turn the SATA phy on and off. Add a PHY driver to control this.

---
 drivers/phy/Kconfig          |    6 ++
 drivers/phy/Makefile         |    1 +
 drivers/phy/phy-mvebu-sata.c |  137 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+)
 create mode 100644 drivers/phy/phy-mvebu-sata.c
drivers/phy/Kconfig +6 -0
index 330ef2d..d0611b8 100644
@@ -21,6 +21,12 @@ config PHY_EXYNOS_MIPI_VIDEO
 	  Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung S5P
 	  and EXYNOS SoCs.
 
+config PHY_MVEBU_SATA
+	def_bool y
+	depends on ARCH_KIRKWOOD || ARCH_DOVE
+	depends on OF
+	select GENERIC_PHY
+
 config OMAP_USB2
 	tristate "OMAP USB2 PHY Driver"
 	depends on ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index d0caae9..4e4adc9 100644
@@ -5,5 +5,6 @@
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
+obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
 obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)		+= phy-twl4030-usb.o
drivers/phy/phy-mvebu-sata.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Kishon Vijay Abraham I

Hi Greg,

Quoted 31 lines · Kishon Vijay Abraham I

Hi Greg,

here's the patches for 3.14. It contains few fixes on phy-core and added a new PHY driver used by SATA in Marvell SoCs.

Let me know if you need any changes.

Thanks
Kishon

The following changes since commit 413541dd66d51f791a0b169d9b9014e4f56be13c:

Linux 3.13-rc5 (2013-12-22 13:08:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/for_3.14

for you to fetch changes up to e3eae85773ebd2165d19ca8661cca3b9c60b2ba1:

Phy: Add a PHY driver for Marvell MVEBU SATA PHY. (2013-12-24 23:52:58 +0530)

----------------------------------------------------------------
Pull request for PHY subsystem contains few fixes in PHY-CORE mostly w.r.t PM and reference counting and also a new PHY driver used by SATA in Marvell SoC.

----------------------------------------------------------------
Andrew Lunn (1):
Phy: Add a PHY driver for Marvell MVEBU SATA PHY.

Quoted 6 lines

Felipe Balbi (1):
phy: core: properly handle failure of pm_runtime_get functions

Kishon Vijay Abraham I (2):
phy: phy-core: increment refcounting variables only on 'success'
phy: phy-core.c: remove unnecessary initialization of local variables\

Will you be taking these patches?

Thanks
Kishon

Quoted 8 lines
 drivers/phy/Kconfig          |    6 ++++++
 drivers/phy/Makefile         |    1 +
 drivers/phy/phy-core.c       |   44 +++++++++++++++++++++++++++++-------------
 drivers/phy/phy-mvebu-sata.c |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 175 insertions(+), 13 deletions(-)
 create mode 100644 drivers/phy/phy-mvebu-sata.c
#6 lore raw
Quoted 37 lines · Kishon Vijay Abraham I

Hi Greg,

Quoted 34 lines · Kishon Vijay Abraham I

Hi Greg,

here's the patches for 3.14. It contains few fixes on phy-core and added a new PHY driver used by SATA in Marvell SoCs.

Let me know if you need any changes.

Thanks
Kishon

The following changes since commit 413541dd66d51f791a0b169d9b9014e4f56be13c:

Linux 3.13-rc5 (2013-12-22 13:08:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/for_3.14

for you to fetch changes up to e3eae85773ebd2165d19ca8661cca3b9c60b2ba1:

Phy: Add a PHY driver for Marvell MVEBU SATA PHY. (2013-12-24 23:52:58 +0530)

----------------------------------------------------------------
Pull request for PHY subsystem contains few fixes in PHY-CORE mostly w.r.t PM and reference counting and also a new PHY driver used by SATA in Marvell SoC.

----------------------------------------------------------------
Andrew Lunn (1):
Phy: Add a PHY driver for Marvell MVEBU SATA PHY.

Felipe Balbi (1):
phy: core: properly handle failure of pm_runtime_get functions

Quoted 6 lines
Quoted 3 lines

Kishon Vijay Abraham I (2):
phy: phy-core: increment refcounting variables only on 'success'
phy: phy-core.c: remove unnecessary initialization of local variables\

Will you be taking these patches?

Yes, sorry, catching up from my vacation backlog...

greg k-h

#7 lore raw
Quoted 38 lines · Greg KH
Quoted 37 lines · Kishon Vijay Abraham I

Hi Greg,

Quoted 34 lines · Kishon Vijay Abraham I

Hi Greg,

here's the patches for 3.14. It contains few fixes on phy-core and added a new PHY driver used by SATA in Marvell SoCs.

Let me know if you need any changes.

Thanks
Kishon

The following changes since commit 413541dd66d51f791a0b169d9b9014e4f56be13c:

Linux 3.13-rc5 (2013-12-22 13:08:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/for_3.14

for you to fetch changes up to e3eae85773ebd2165d19ca8661cca3b9c60b2ba1:

Phy: Add a PHY driver for Marvell MVEBU SATA PHY. (2013-12-24 23:52:58 +0530)

----------------------------------------------------------------
Pull request for PHY subsystem contains few fixes in PHY-CORE mostly w.r.t PM and reference counting and also a new PHY driver used by SATA in Marvell SoC.

----------------------------------------------------------------
Andrew Lunn (1):
Phy: Add a PHY driver for Marvell MVEBU SATA PHY.

Felipe Balbi (1):
phy: core: properly handle failure of pm_runtime_get functions

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Kishon Vijay Abraham I (2):
phy: phy-core: increment refcounting variables only on 'success'
phy: phy-core.c: remove unnecessary initialization of local variables\

Will you be taking these patches?

Yes, sorry, catching up from my vacation backlog...

no problem, thanks.

-Kishon

Quoted 3 lines

greg k-h

#8 lore raw
In reply to Kishon Vijay Abraham I
Quoted 10 lines · Kishon Vijay Abraham I

Hi Greg,

here's the patches for 3.14. It contains few fixes on phy-core and added a new PHY driver used by SATA in Marvell SoCs.

Let me know if you need any changes.

Thanks
Kishon

Quoted 7 lines

The following changes since commit 413541dd66d51f791a0b169d9b9014e4f56be13c:

Linux 3.13-rc5 (2013-12-22 13:08:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/for_3.14

Pulled and pushed out, sorry for the delay.

greg k-h