[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211129150920.4a400828@hermes.local>
Date: Mon, 29 Nov 2021 15:09:20 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Heiner Kallweit <hkallweit1@...il.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>,
Jesse Brandeburg <jesse.brandeburg@...el.com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
intel-wired-lan <intel-wired-lan@...ts.osuosl.org>
Subject: Re: [PATCH net] igb: fix deadlock caused by taking RTNL in RPM
resume path
On Mon, 29 Nov 2021 22:14:06 +0100
Heiner Kallweit <hkallweit1@...il.com> wrote:
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index dd208930f..8073cce73 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -9254,7 +9254,7 @@ static int __maybe_unused igb_suspend(struct device *dev)
> return __igb_shutdown(to_pci_dev(dev), NULL, 0);
> }
>
> -static int __maybe_unused igb_resume(struct device *dev)
> +static int __maybe_unused __igb_resume(struct device *dev, bool rpm)
> {
> struct pci_dev *pdev = to_pci_dev(dev);
> struct net_device *netdev = pci_get_drvdata(pdev);
> @@ -9297,17 +9297,24 @@ static int __maybe_unused igb_resume(struct device *dev)
>
> wr32(E1000_WUS, ~0);
>
> - rtnl_lock();
> + if (!rpm)
> + rtnl_lock();
> if (!err && netif_running(netdev))
> err = __igb_open(netdev, true);
>
> if (!err)
> netif_device_attach(netdev);
> - rtnl_unlock();
> + if (!rpm)
> + rtnl_unlock();
>
> return err;
> }
>
> +static int __maybe_unused igb_resume(struct device *dev)
> +{
> + return __igb_resume(dev, false);
> +}
> +
> static int __maybe_unused igb_runtime_idle(struct device *dev)
> {
> struct net_device *netdev = dev_get_drvdata(dev);
> @@ -9326,7 +9333,7 @@ static int __maybe_unused igb_runtime_suspend(struct device *dev)
>
> static int __maybe_unused igb_runtime_resume(struct device *dev)
> {
> - return igb_resume(dev);
> + return __igb_resume(dev, true);
> }
Rather than conditional locking which is one of the seven deadly sins of SMP,
why not just have __igb_resume() be the locked version where lock is held by caller?
Powered by blists - more mailing lists