Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
@ 2021-02-19 10:10 Dan Carpenter
  2021-02-19 10:46 ` Michael Walle
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-02-19 10:10 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, Russell King, David S. Miller, Jakub Kicinski,
	Michael Walle, netdev, kernel-janitors

The comments to phy_select_page() say that "phy_restore_page() must
always be called after this, irrespective of success or failure of this
call."  If we don't call phy_restore_page() then we are still holding
the phy_lock_mdio_bus() so it eventually leads to a dead lock.

Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for IP101A/G")
Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: fix a couple other instances I missed in v1

 drivers/net/phy/icplus.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index 3e431737c1ba..a00a667454a9 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -239,7 +239,7 @@ static int ip101a_g_config_intr_pin(struct phy_device *phydev)
 
 	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
 	if (oldpage < 0)
-		return oldpage;
+		goto out;
 
 	/* configure the RXER/INTR_32 pin of the 32-pin IP101GR if needed: */
 	switch (priv->sel_intr32) {
@@ -314,7 +314,7 @@ static int ip101a_g_read_status(struct phy_device *phydev)
 
 	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
 	if (oldpage < 0)
-		return oldpage;
+		goto out;
 
 	ret = __phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
 	if (ret < 0)
@@ -349,7 +349,8 @@ static int ip101a_g_read_status(struct phy_device *phydev)
 static int ip101a_g_config_mdix(struct phy_device *phydev)
 {
 	u16 ctrl = 0, ctrl2 = 0;
-	int oldpage, ret;
+	int oldpage;
+	int ret = 0;
 
 	switch (phydev->mdix_ctrl) {
 	case ETH_TP_MDI:
@@ -367,7 +368,7 @@ static int ip101a_g_config_mdix(struct phy_device *phydev)
 
 	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
 	if (oldpage < 0)
-		return oldpage;
+		goto out;
 
 	ret = __phy_modify(phydev, IP10XX_SPEC_CTRL_STATUS,
 			   IP101A_G_AUTO_MDIX_DIS, ctrl);
-- 
2.30.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
  2021-02-19 10:10 [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails Dan Carpenter
@ 2021-02-19 10:46 ` Michael Walle
  2021-02-19 11:09   ` Dan Carpenter
  2021-02-19 11:36 ` Russell King - ARM Linux admin
  2021-02-23  3:00 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Walle @ 2021-02-19 10:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Jakub Kicinski, netdev, kernel-janitors

Am 2021-02-19 11:10, schrieb Dan Carpenter:
> The comments to phy_select_page() say that "phy_restore_page() must
> always be called after this, irrespective of success or failure of this
> call."  If we don't call phy_restore_page() then we are still holding
> the phy_lock_mdio_bus() so it eventually leads to a dead lock.
> 
> Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for 
> IP101A/G")
> Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Michael Walle <michael@walle.cc>

I assume, this has to go through "net" if the merge window is closed, 
no?

-michael

> ---
> v2: fix a couple other instances I missed in v1
> 
>  drivers/net/phy/icplus.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
> index 3e431737c1ba..a00a667454a9 100644
> --- a/drivers/net/phy/icplus.c
> +++ b/drivers/net/phy/icplus.c
> @@ -239,7 +239,7 @@ static int ip101a_g_config_intr_pin(struct
> phy_device *phydev)
> 
>  	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
>  	if (oldpage < 0)
> -		return oldpage;
> +		goto out;
> 
>  	/* configure the RXER/INTR_32 pin of the 32-pin IP101GR if needed: */
>  	switch (priv->sel_intr32) {
> @@ -314,7 +314,7 @@ static int ip101a_g_read_status(struct phy_device 
> *phydev)
> 
>  	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
>  	if (oldpage < 0)
> -		return oldpage;
> +		goto out;
> 
>  	ret = __phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
>  	if (ret < 0)
> @@ -349,7 +349,8 @@ static int ip101a_g_read_status(struct phy_device 
> *phydev)
>  static int ip101a_g_config_mdix(struct phy_device *phydev)
>  {
>  	u16 ctrl = 0, ctrl2 = 0;
> -	int oldpage, ret;
> +	int oldpage;
> +	int ret = 0;
> 
>  	switch (phydev->mdix_ctrl) {
>  	case ETH_TP_MDI:
> @@ -367,7 +368,7 @@ static int ip101a_g_config_mdix(struct phy_device 
> *phydev)
> 
>  	oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
>  	if (oldpage < 0)
> -		return oldpage;
> +		goto out;
> 
>  	ret = __phy_modify(phydev, IP10XX_SPEC_CTRL_STATUS,
>  			   IP101A_G_AUTO_MDIX_DIS, ctrl);

-- 
-michael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
  2021-02-19 10:46 ` Michael Walle
@ 2021-02-19 11:09   ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-02-19 11:09 UTC (permalink / raw)
  To: Michael Walle
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Jakub Kicinski, netdev, kernel-janitors

On Fri, Feb 19, 2021 at 11:46:23AM +0100, Michael Walle wrote:
> Am 2021-02-19 11:10, schrieb Dan Carpenter:
> > The comments to phy_select_page() say that "phy_restore_page() must
> > always be called after this, irrespective of success or failure of this
> > call."  If we don't call phy_restore_page() then we are still holding
> > the phy_lock_mdio_bus() so it eventually leads to a dead lock.
> > 
> > Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for
> > IP101A/G")
> > Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Reviewed-by: Michael Walle <michael@walle.cc>
> 
> I assume, this has to go through "net" if the merge window is closed, no?

It applies to net-next and not to net.  I expect that all of net-next
will be merged into net soon enough, but as of a couple hours ago it
only applied to net-next.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
  2021-02-19 10:10 [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails Dan Carpenter
  2021-02-19 10:46 ` Michael Walle
@ 2021-02-19 11:36 ` Russell King - ARM Linux admin
  2021-02-23  3:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2021-02-19 11:36 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Jakub Kicinski,
	Michael Walle, netdev, kernel-janitors

On Fri, Feb 19, 2021 at 01:10:44PM +0300, Dan Carpenter wrote:
> The comments to phy_select_page() say that "phy_restore_page() must
> always be called after this, irrespective of success or failure of this
> call."  If we don't call phy_restore_page() then we are still holding
> the phy_lock_mdio_bus() so it eventually leads to a dead lock.
> 
> Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for IP101A/G")
> Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.
-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
  2021-02-19 10:10 [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails Dan Carpenter
  2021-02-19 10:46 ` Michael Walle
  2021-02-19 11:36 ` Russell King - ARM Linux admin
@ 2021-02-23  3:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-23  3:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: andrew, hkallweit1, linux, davem, kuba, michael, netdev, kernel-janitors

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri, 19 Feb 2021 13:10:44 +0300 you wrote:
> The comments to phy_select_page() say that "phy_restore_page() must
> always be called after this, irrespective of success or failure of this
> call."  If we don't call phy_restore_page() then we are still holding
> the phy_lock_mdio_bus() so it eventually leads to a dead lock.
> 
> Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for IP101A/G")
> Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> [...]

Here is the summary with links:
  - [v2,net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails
    https://git.kernel.org/netdev/net/c/4e9d9d1f4880

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 10:10 [PATCH v2 net-next] net: phy: icplus: call phy_restore_page() when phy_select_page() fails Dan Carpenter
2021-02-19 10:46 ` Michael Walle
2021-02-19 11:09   ` Dan Carpenter
2021-02-19 11:36 ` Russell King - ARM Linux admin
2021-02-23  3:00 ` patchwork-bot+netdevbpf

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git