All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Mike Galbraith <efault@gmx.de>, Li Jun <jun.li@nxp.com>
Subject: [PATCH 3/3] xhci: Don't create stream debugfs files with spinlock held.
Date: Wed, 28 Oct 2020 22:31:24 +0200	[thread overview]
Message-ID: <20201028203124.375344-4-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20201028203124.375344-1-mathias.nyman@linux.intel.com>

Creating debugfs files while loding the spin_lock_irqsave(xhci->lock)
creates a lock dependecy that could possibly deadlock.

Lockdep warns:

=====================================================
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
5.10.0-rc1pdx86+ #8 Not tainted
-----------------------------------------------------
systemd-udevd/386 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
ffffffffb1a94038 (pin_fs_lock){+.+.}-{2:2}, at: simple_pin_fs+0x22/0xa0

and this task is already holding:
ffff9e7b87fbc430 (&xhci->lock){-.-.}-{2:2}, at: xhci_alloc_streams+0x5f9/0x810
which would create a new lock dependency:
(&xhci->lock){-.-.}-{2:2} -> (pin_fs_lock){+.+.}-{2:2}

Create the files a bit later after lock is released.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Reported-by: Mike Galbraith <efault@gmx.de>
Tested-by: Hans de Goede <hdegoede@redhat.com>
CC: Li Jun <jun.li@nxp.com>
Fixes: 673d74683627 ("usb: xhci: add debugfs support for ep with stream")
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 482fe8c5e3b4..d4a8d0efbbc4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3533,11 +3533,14 @@ static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
 		xhci_dbg(xhci, "Slot %u ep ctx %u now has streams.\n",
 			 udev->slot_id, ep_index);
 		vdev->eps[ep_index].ep_state |= EP_HAS_STREAMS;
-		xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
 	}
 	xhci_free_command(xhci, config_cmd);
 	spin_unlock_irqrestore(&xhci->lock, flags);
 
+	for (i = 0; i < num_eps; i++) {
+		ep_index = xhci_get_endpoint_index(&eps[i]->desc);
+		xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
+	}
 	/* Subtract 1 for stream 0, which drivers can't use */
 	return num_streams - 1;
 
-- 
2.25.1


  parent reply	other threads:[~2020-10-29  2:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 20:31 [PATCH 0/3] xhci fixes for usb-linus Mathias Nyman
2020-10-28 20:31 ` [PATCH 1/3] xhci: Fix sizeof() mismatch Mathias Nyman
2020-10-28 20:31 ` [PATCH 2/3] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC Mathias Nyman
2020-10-28 20:31 ` Mathias Nyman [this message]
2020-10-29  6:03   ` [PATCH 3/3] xhci: Don't create stream debugfs files with spinlock held Mike Galbraith
2020-10-29  9:41     ` Mathias Nyman
2020-10-29  9:42       ` Sebastian Andrzej Siewior
2020-10-29 10:23         ` Mike Galbraith
2020-10-29 10:37           ` Sebastian Andrzej Siewior
2020-10-29 11:11       ` Mike Galbraith
2020-10-29 11:22         ` Mathias Nyman
2020-10-29 11:38           ` Sebastian Andrzej Siewior
2020-10-29 12:44             ` Jun Li
2020-10-29 13:08             ` Mathias Nyman
2020-10-29 15:10               ` Sebastian Andrzej Siewior
2020-10-29 16:26               ` David Laight
2020-10-29 17:43               ` Sebastian Andrzej Siewior
2020-10-30  8:01   ` Jun Li

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=20201028203124.375344-4-mathias.nyman@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=efault@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jun.li@nxp.com \
    --cc=linux-usb@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.