All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Robert Hancock <hancock@sedsystems.ca>
Cc: netdev@vger.kernel.org, andrew@lunn.ch, f.fainelli@gmail.com,
	hkallweit1@gmail.com
Subject: Re: [PATCH net-next] net: sfp: Stop SFP polling and interrupt handling during shutdown
Date: Thu, 6 Jun 2019 19:09:08 +0100	[thread overview]
Message-ID: <20190606180908.ctoxi7c4i2uothzn@shell.armlinux.org.uk> (raw)
In-Reply-To: <1559844377-17188-1-git-send-email-hancock@sedsystems.ca>

On Thu, Jun 06, 2019 at 12:06:17PM -0600, Robert Hancock wrote:
> SFP device polling can cause problems during the shutdown process if the
> parent devices of the network controller have been shut down already.
> This problem was seen on the iMX6 platform with PCIe devices, where
> accessing the device after the bus is shut down causes a hang.
> 
> Stop all delayed work in the SFP driver during the shutdown process, and
> set a flag which causes any further state checks or state machine events
> (possibly triggered by previous GPIO IRQs) to be skipped.
> 
> Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
> ---
> 
> This is an updated version of a previous patch "net: sfp: Stop SFP polling
> during shutdown" with the addition of stopping handling of GPIO-triggered
> interrupts as well, as pointed out by Russell King.
> 
>  drivers/net/phy/sfp.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 554acc8..5fdf573 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -191,6 +191,7 @@ struct sfp {
>  	struct delayed_work poll;
>  	struct delayed_work timeout;
>  	struct mutex sm_mutex;
> +	bool shutdown;
>  	unsigned char sm_mod_state;
>  	unsigned char sm_dev_state;
>  	unsigned short sm_state;
> @@ -1466,6 +1467,11 @@ static void sfp_sm_mod_remove(struct sfp *sfp)
>  static void sfp_sm_event(struct sfp *sfp, unsigned int event)
>  {
>  	mutex_lock(&sfp->sm_mutex);
> +	if (unlikely(sfp->shutdown)) {
> +		/* Do not handle any more state machine events. */
> +		mutex_unlock(&sfp->sm_mutex);
> +		return;
> +	}
>  
>  	dev_dbg(sfp->dev, "SM: enter %s:%s:%s event %s\n",
>  		mod_state_to_str(sfp->sm_mod_state),
> @@ -1704,6 +1710,13 @@ static void sfp_check_state(struct sfp *sfp)
>  {
>  	unsigned int state, i, changed;
>  
> +	mutex_lock(&sfp->sm_mutex);
> +	if (unlikely(sfp->shutdown)) {
> +		/* No more state checks */
> +		mutex_unlock(&sfp->sm_mutex);
> +		return;
> +	}
> +

I don't think you need to add the mutex locking - just check for
sfp->shutdown and be done with it...

> +static void sfp_shutdown(struct platform_device *pdev)
> +{
> +	struct sfp *sfp = platform_get_drvdata(pdev);
> +
> +	mutex_lock(&sfp->sm_mutex);
> +	sfp->shutdown = true;
> +	mutex_unlock(&sfp->sm_mutex);
> +
> +	cancel_delayed_work_sync(&sfp->poll);
> +	cancel_delayed_work_sync(&sfp->timeout);

Since the work cancellation will ensure that the works are not running
at the point they return, and should they then run again, they'll hit
the sfp->shutdown condition.

> +}
> +
>  static struct platform_driver sfp_driver = {
>  	.probe = sfp_probe,
>  	.remove = sfp_remove,
> +	.shutdown = sfp_shutdown,
>  	.driver = {
>  		.name = "sfp",
>  		.of_match_table = sfp_of_match,
> -- 
> 1.8.3.1
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  reply	other threads:[~2019-06-06 18:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 18:06 [PATCH net-next] net: sfp: Stop SFP polling and interrupt handling during shutdown Robert Hancock
2019-06-06 18:09 ` Russell King - ARM Linux admin [this message]
2019-06-06 20:57   ` Robert Hancock
2019-06-07  3:21     ` Florian Fainelli
2019-06-07 10:26     ` Russell King - ARM Linux admin
2019-06-07 10:42     ` Russell King - ARM Linux admin
2019-06-07 16:08       ` Robert Hancock

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=20190606180908.ctoxi7c4i2uothzn@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hancock@sedsystems.ca \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.