Re: [PATCH] usb: ohci/uhci - add soft dependencies on ehci_hcd

From: Alan Stern
Date: Tue Sep 10 2013 - 13:31:57 EST


On Tue, 10 Sep 2013, Tom Gundersen wrote:

> Hi Alan,
>
> On Tue, Sep 10, 2013 at 7:02 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> > On Tue, 10 Sep 2013, Tom Gundersen wrote:
> >
> >> Support for specifying soft dependencies in the modules themselves was
> >> introduced in commit 7cb14ba.
> >>
> >> In Arch we have always been shipping a module.d(5) fragment ordering ohci/uhci
> >> after ehci. If this ordering is really necessary, it would be great to move it
> >> to the kernel and getting the correct fragment generated by depmod.
> >
> > The ordering is more of a recommendation than a necessity. Systems
> > should work oksy if the modules are loaded in the wrong order.
> >
> > The only issue if the drivers are loaded in the wrong order is that
> > full- and low-speed devices will end up being detected and enumerated
> > twice, with a disconnection in between. This can result in
> > disconcerting messages appearing in the system log.
> >
> > In theory, it is possible for a problem to arise. For example, suppose
> > a full-speed flash drive is plugged in when the system starts up.
> > When uhci-hcd or ohci-hcd gets loaded, the drive will be detected and
> > it may even be mounted. Then when ehci-hcd loads, the drive will get
> > disconnected and reconnected. Any open file references to the original
> > mount will be orphaned.
>
> Thanks for the explanation. Sounds to me that a softdep is indeed appropriate:
>
> //
> The softdep command allows you to specify soft, or optional, module
> dependencies. modulename can be used without these optional modules
> installed, but usually with some features missing. For example, a
> driver for a storage HBA might require another module be loaded in
> order to use management features.
>
> pre-deps and post-deps modules are lists of names and/or aliases of
> other modules that modprobe will attempt to install (or remove) in
> order before and after the main module given in the modulename
> argument.
> //

So this means that before installing ohci-hcd, modprobe would attempt
to install ehci-hcd? And if the attempt failed, it would go ahead and
load ohci-hcd anyway?

What about during unloading? Would this mean that rmmod ohci-hcd would
automatically cause ehci-hcd to be unloaded also? Or would unloading
ehci-hcd cause ohci-hcd to be unloaded?

> >> Signed-off-by: Tom Gundersen <teg@xxxxxxx>
> >> Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> >> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> >> ---
> >> drivers/usb/host/ohci-hcd.c | 1 +
> >> drivers/usb/host/uhci-hcd.c | 1 +
> >> 2 files changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> >> index 8f6b695..783b50a 100644
> >> --- a/drivers/usb/host/ohci-hcd.c
> >> +++ b/drivers/usb/host/ohci-hcd.c
> >> @@ -1171,6 +1171,7 @@ EXPORT_SYMBOL_GPL(ohci_init_driver);
> >> MODULE_AUTHOR (DRIVER_AUTHOR);
> >> MODULE_DESCRIPTION(DRIVER_DESC);
> >> MODULE_LICENSE ("GPL");
> >> +MODULE_SOFTDEP("pre: ehci_hcd");
> >>
> >> #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111)
> >> #include "ohci-sa1111.c"
> >> diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
> >> index 4a86b63..c2babf3 100644
> >> --- a/drivers/usb/host/uhci-hcd.c
> >> +++ b/drivers/usb/host/uhci-hcd.c
> >> @@ -937,3 +937,4 @@ module_exit(uhci_hcd_cleanup);
> >> MODULE_AUTHOR(DRIVER_AUTHOR);
> >> MODULE_DESCRIPTION(DRIVER_DESC);
> >> MODULE_LICENSE("GPL");
> >> +MODULE_SOFTDEP("pre: ehci_hcd");
> >
> > Where is MODULE_SOFTDEP defined? It isn't mentioned in any .h files in
> > my kernel tree.
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/module.h#n104

I think I get the picture.

The MODULE_SOFTDEP lines should be moved to uhci-pci.c and ohci-pci.c,
because the ordering restrictions apply only to the PCI versions of
these drivers. And they should specify "pre: ehci-pci", not ehci-hcd.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/