Linux-rt-users archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Li, Meng" <Meng.Li@windriver.com>,
	Ingo Molnar <mingo@redhat.com>,
	USB mailing list <linux-usb@vger.kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Subject: Re: USB: add check to detect host controller hardware removal
Date: Mon, 16 Oct 2023 12:56:24 -0400	[thread overview]
Message-ID: <20231016125624.1096766a@gandalf.local.home> (raw)
In-Reply-To: <9a1074e2-c1ae-485b-b5e7-a34442c98c0b@rowland.harvard.edu>

On Fri, 13 Oct 2023 13:17:52 -0400
Alan Stern <stern@rowland.harvard.edu> wrote:

> --- a/drivers/usb/core/hcd-pci.c
> +++ b/drivers/usb/core/hcd-pci.c
> @@ -292,6 +292,14 @@ void usb_hcd_pci_remove(struct pci_dev *dev)
>         if (!hcd)
>                 return;
>  
> +       /* Fake an interrupt request in order to give the driver a chance
> +        * to test whether the controller hardware has been removed (e.g.,
> +        * cardbus physical eject).
> +        */
> +       local_irq_disable();
> +       usb_hcd_irq(0, hcd);
> +       local_irq_enable();
> +
>         usb_remove_hcd(hcd);
>         if (hcd->driver->flags & HCD_MEMORY) {
>                 iounmap(hcd->regs);
> 
> The local_irq_disable() is there so that the irq handler will be invoked 
> in the state that it expects (i.e., with interrupts disabled).  
> Apparently Meng's RT kernel doesn't like it when the handler then 
> calls spin_lock(); I don't know why.

Because in RT, spin_lock()s are actually mutexes.

In RT, interrupt handlers do not even run with interrupts disabled (they
run as threads), so the assumption that they run with interrupts disabled
on RT is incorrect. One hack would simply be:

	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
		local_irq_disable();
	usb_hcd_irq(0, hcd);
	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
		local_irq_enable();

But that's rather ugly. We use to have that as a wrapper of just:

	local_irq_disable_nort();

but I don't know if we removed that or not.

Sebastian?

-- Steve

       reply	other threads:[~2023-10-16 16:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <PH0PR11MB5191464B2F01511D2ADECB3BF1D2A@PH0PR11MB5191.namprd11.prod.outlook.com>
     [not found] ` <9a1074e2-c1ae-485b-b5e7-a34442c98c0b@rowland.harvard.edu>
2023-10-16 16:56   ` Steven Rostedt [this message]
2023-10-16 19:23     ` USB: add check to detect host controller hardware removal Alan Stern
2023-10-17  2:23       ` Li, Meng
2023-10-17 14:06         ` Alan Stern
2023-10-18  5:00           ` Li, Meng
2023-10-18 15:20             ` Alan Stern
2023-10-18 15:34               ` Alan Stern
2023-10-19 12:38               ` Sebastian Andrzej Siewior
2023-10-19 15:09                 ` Alan Stern
2023-10-19 15:27                   ` Alan Stern
2023-10-20  9:52                     ` Sebastian Andrzej Siewior
2023-10-20 15:19                       ` Alan Stern
2023-11-03 15:46                         ` Sebastian Andrzej Siewior
2023-11-03 20:42                           ` Alan Stern
2023-11-06  3:02                             ` Li, Meng
2023-11-06  8:28                               ` Sebastian Andrzej Siewior
2023-11-06  8:54                                 ` Li, Meng
2023-11-06  9:09                                   ` Sebastian Andrzej Siewior
2023-11-07  3:08                                     ` Li, Meng
2023-11-07  6:17                                       ` Greg KH
2023-11-06 15:25                                 ` Alan Stern
2023-11-06  8:27                             ` Sebastian Andrzej Siewior
2023-10-19 12:49     ` Sebastian Andrzej Siewior

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=20231016125624.1096766a@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=Meng.Li@windriver.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stern@rowland.harvard.edu \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).