Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Roman Lozko <lozko.roma@gmail.com>,
	linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Sean Christopherson <seanjc@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Christian Marangi <ansuelsmth@gmail.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	intel-wired-lan@lists.osuosl.org
Subject: Re: Deadlock in pciehp on dock disconnect
Date: Fri, 5 Apr 2024 21:01:59 +0200	[thread overview]
Message-ID: <b2845d6b-ee0b-4f21-9cac-bdc41393a739@gmail.com> (raw)
In-Reply-To: <ZhA5WAYyMQJsAey8@wunner.de>

On 05.04.2024 19:48, Lukas Wunner wrote:
> On Fri, Apr 05, 2024 at 03:31:34PM +0200, Heiner Kallweit wrote:
>> On 05.04.2024 12:02, Lukas Wunner wrote:
>>> On Fri, Apr 05, 2024 at 11:14:01AM +0200, Roman Lozko wrote:
>>>> Hi, I'm using HP G4 Thunderbolt docking station, and recently (?)
>>>> kernel started to "partially" deadlock after disconnecting the dock
>>>> station. This results in inability to turn network interfaces on or
>>>> off, system can't reboot, `sudo` does not work (guess because it uses
>>>> DNS).
>>>
>>> unregister_netdev() acquires rtnl_lock(), indirectly invokes
>>> netdev_trig_deactivate() upon unregistering some LED, thereby
>>> calling unregister_netdevice_notifier(), which tries to
>>> acquire rtnl_lock() again.
>>>
>>> From a quick look at the source files involved, this doesn't look
>>> like something new, though I note LED support for igc was added
>>> only recently with ea578703b03d ("igc: Add support for LEDs on
>>> i225/i226"), which went into v6.9-rc1.
>>
>> It's unfortunate that the device-managed LED is bound to the netdev device.
>> Wouldn't binding it to the parent (&pdev->dev) solve the issue?
> 
> I'm guessing igc commit ea578703b03d copy-pasted from r8169 commit
> be51ed104ba9 ("r8169: add LED support for RTL8125/RTL8126") because
> that driver has exactly the same problem. :)
> 
Right, just tested it for r8169 and got a similar lockdep error.

> Roman, does the below patch fix the issue?
> 
> Note that just changing the devm_led_classdev_register() call isn't
> sufficient:  I'm changing the devm_kcalloc() in igc_led_setup() as well
> to avoid a use-after-free (memory would already get freed on netdev
> unregister but led a little later on pdev unbind).
> 
> -- >8 --
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc_leds.c b/drivers/net/ethernet/intel/igc/igc_leds.c
> index bf240c5..0b78c30 100644
> --- a/drivers/net/ethernet/intel/igc/igc_leds.c
> +++ b/drivers/net/ethernet/intel/igc/igc_leds.c
> @@ -257,13 +257,13 @@ static void igc_setup_ldev(struct igc_led_classdev *ldev,
>  	led_cdev->hw_control_get = igc_led_hw_control_get;
>  	led_cdev->hw_control_get_device = igc_led_hw_control_get_device;
>  
> -	devm_led_classdev_register(&netdev->dev, led_cdev);
> +	devm_led_classdev_register(&adapter->pdev->dev, led_cdev);
>  }
>  
>  int igc_led_setup(struct igc_adapter *adapter)
>  {
>  	struct net_device *netdev = adapter->netdev;
> -	struct device *dev = &netdev->dev;
> +	struct device *dev = &adapter->pdev->dev;
>  	struct igc_led_classdev *leds;
>  	int i;
>  
> 


  reply	other threads:[~2024-04-05 19:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  9:14 Deadlock in pciehp on dock disconnect Roman Lozko
2024-04-05 10:02 ` Lukas Wunner
2024-04-05 13:31   ` Heiner Kallweit
2024-04-05 17:48     ` Lukas Wunner
2024-04-05 19:01       ` Heiner Kallweit [this message]
2024-04-05 19:16       ` Lukas Wunner
2024-04-05 20:16         ` Heiner Kallweit

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=b2845d6b-ee0b-4f21-9cac-bdc41393a739@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=ansuelsmth@gmail.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=bhelgaas@google.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=lozko.roma@gmail.com \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=seanjc@google.com \
    /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