All of lore.kernel.org
 help / color / mirror / Atom feed
From: Moritz Fischer <mdf@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Moritz Fischer <mdf@kernel.org>,
	netdev@vger.kernel.org, davem@davemloft.net,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	lucyyan@google.com, moritzf@google.com,
	James.Bottomley@hansenpartnership.com
Subject: Re: [PATCH/RFC net-next v3] net: dec: tulip: de2104x: Add shutdown handler to stop NIC
Date: Tue, 27 Oct 2020 18:59:09 -0700	[thread overview]
Message-ID: <20201028015909.GA52884@epycbox.lan> (raw)
In-Reply-To: <20201027161606.477a445e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

Hi Jakub,

On Tue, Oct 27, 2020 at 04:16:06PM -0700, Jakub Kicinski wrote:
> On Fri, 23 Oct 2020 13:28:34 -0700 Moritz Fischer wrote:
> > diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
> > index d9f6c19940ef..ea7442cc8e75 100644
> > --- a/drivers/net/ethernet/dec/tulip/de2104x.c
> > +++ b/drivers/net/ethernet/dec/tulip/de2104x.c
> > @@ -2175,11 +2175,19 @@ static int __maybe_unused de_resume(struct device *dev_d)
> >  
> >  static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume);
> >  
> > +static void de_shutdown(struct pci_dev *pdev)
> > +{
> > +	struct net_device *dev = pci_get_drvdata(pdev);
> > +
> > +	de_close(dev);
> 
> Apparently I get all the best ideas when I'm about to apply something..

Better now than after =)

> I don't think you can just call de_close() like that, because 
> (a) it may expect rtnl_lock() to be held, and (b) it may not be open.

how about:

rtnl_lock();
if (netif_running(dev))
	dev_close(dev);
rtnl_unlock();

> 
> Perhaps call unregister_netdev(dev) - that'll close the device.
> Or rtnl_lock(); dev_close(dev); rtnl_unlock();
> 
> > +}
> > +
> >  static struct pci_driver de_driver = {
> >  	.name		= DRV_NAME,
> >  	.id_table	= de_pci_tbl,
> >  	.probe		= de_init_one,
> >  	.remove		= de_remove_one,
> > +	.shutdown	= de_shutdown,
> >  	.driver.pm	= &de_pm_ops,
> >  };
> >  
> 

Cheers,
Moritz

  reply	other threads:[~2020-10-28 23:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 20:28 [PATCH/RFC net-next v3] net: dec: tulip: de2104x: Add shutdown handler to stop NIC Moritz Fischer
2020-10-27 23:16 ` Jakub Kicinski
2020-10-28  1:59   ` Moritz Fischer [this message]
2020-10-28 16:40     ` Jakub Kicinski

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=20201028015909.GA52884@epycbox.lan \
    --to=mdf@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=lucyyan@google.com \
    --cc=moritzf@google.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.