Re: USB: add check to detect host controller hardware removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 13 Oct 2023 13:17:52 -0400
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> 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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux