mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Cc: Jon Hunter <jonathanh@nvidia.com>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v1 1/1] net: usb: asix: ax88772: manage PHY PM from MAC
Date: Fri, 11 Jun 2021 00:22:53 +0200	[thread overview]
Message-ID: <48ad8efd-e1c7-a352-8295-31bb14f85575@samsung.com> (raw)
In-Reply-To: <20210610142009.16162-1-o.rempel@pengutronix.de>

Hi Oleksij,

On 10.06.2021 16:20, Oleksij Rempel wrote:
> Take over PHY power management, otherwise PHY framework will try to
> access ASIX MDIO bus before MAC resume was completed.
>
> Fixes: e532a096be0e ("net: usb: asix: ax88772: add phylib support")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>

This fixes the issues observed on my test systems. Thanks!

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/net/usb/asix_devices.c | 43 ++++++++++------------------------
>   1 file changed, 12 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
> index 8a477171e8f5..aec97b021a73 100644
> --- a/drivers/net/usb/asix_devices.c
> +++ b/drivers/net/usb/asix_devices.c
> @@ -598,6 +598,9 @@ static void ax88772_suspend(struct usbnet *dev)
>   	struct asix_common_private *priv = dev->driver_priv;
>   	u16 medium;
>   
> +	if (netif_running(dev->net))
> +		phy_stop(priv->phydev);
> +
>   	/* Stop MAC operation */
>   	medium = asix_read_medium_status(dev, 1);
>   	medium &= ~AX_MEDIUM_RE;
> @@ -605,14 +608,6 @@ static void ax88772_suspend(struct usbnet *dev)
>   
>   	netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n",
>   		   asix_read_medium_status(dev, 1));
> -
> -	/* Preserve BMCR for restoring */
> -	priv->presvd_phy_bmcr =
> -		asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_BMCR);
> -
> -	/* Preserve ANAR for restoring */
> -	priv->presvd_phy_advertise =
> -		asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE);
>   }
>   
>   static int asix_suspend(struct usb_interface *intf, pm_message_t message)
> @@ -626,39 +621,22 @@ static int asix_suspend(struct usb_interface *intf, pm_message_t message)
>   	return usbnet_suspend(intf, message);
>   }
>   
> -static void ax88772_restore_phy(struct usbnet *dev)
> -{
> -	struct asix_common_private *priv = dev->driver_priv;
> -
> -	if (priv->presvd_phy_advertise) {
> -		/* Restore Advertisement control reg */
> -		asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE,
> -				     priv->presvd_phy_advertise);
> -
> -		/* Restore BMCR */
> -		if (priv->presvd_phy_bmcr & BMCR_ANENABLE)
> -			priv->presvd_phy_bmcr |= BMCR_ANRESTART;
> -
> -		asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR,
> -				     priv->presvd_phy_bmcr);
> -
> -		priv->presvd_phy_advertise = 0;
> -		priv->presvd_phy_bmcr = 0;
> -	}
> -}
> -
>   static void ax88772_resume(struct usbnet *dev)
>   {
> +	struct asix_common_private *priv = dev->driver_priv;
>   	int i;
>   
>   	for (i = 0; i < 3; i++)
>   		if (!ax88772_hw_reset(dev, 1))
>   			break;
> -	ax88772_restore_phy(dev);
> +
> +	if (netif_running(dev->net))
> +		phy_start(priv->phydev);
>   }
>   
>   static void ax88772a_resume(struct usbnet *dev)
>   {
> +	struct asix_common_private *priv = dev->driver_priv;
>   	int i;
>   
>   	for (i = 0; i < 3; i++) {
> @@ -666,7 +644,8 @@ static void ax88772a_resume(struct usbnet *dev)
>   			break;
>   	}
>   
> -	ax88772_restore_phy(dev);
> +	if (netif_running(dev->net))
> +		phy_start(priv->phydev);
>   }
>   
>   static int asix_resume(struct usb_interface *intf)
> @@ -722,6 +701,8 @@ static int ax88772_init_phy(struct usbnet *dev)
>   		return ret;
>   	}
>   
> +	priv->phydev->mac_managed_pm = 1;
> +
>   	phy_attached_info(priv->phydev);
>   
>   	return 0;

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      parent reply	other threads:[~2021-06-10 22:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210610142025eucas1p2f3377bf0dbf1b02e37513ab338adc384@eucas1p2.samsung.com>
2021-06-10 14:20 ` Oleksij Rempel
2021-06-10 16:08   ` Jon Hunter
2021-06-10 22:22   ` Marek Szyprowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48ad8efd-e1c7-a352-8295-31bb14f85575@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®