Discussion:
[PATCH] usb: ohci/uhci - add soft dependencies on ehci_hcd
Tom Gundersen
2013-09-10 16:37:30 UTC
Permalink
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.

Signed-off-by: Tom Gundersen <teg-***@public.gmane.org>
Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/***@public.gmane.org>
Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+***@public.gmane.org>
---
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");
--
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Alan Stern
2013-09-10 17:02:16 UTC
Permalink
Post by Tom Gundersen
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.
Post by Tom Gundersen
---
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.

Alan Stern
Kay Sievers
2013-09-10 17:07:29 UTC
Permalink
Post by Alan Stern
Where is MODULE_SOFTDEP defined? It isn't mentioned in any .h files in
my kernel tree.
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7cb14ba75d57910cc4b62115dd5db7bd83c93684

Kay
Tom Gundersen
2013-09-10 17:12:12 UTC
Permalink
Hi Alan,
Post by Alan Stern
Post by Tom Gundersen
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.
//
Post by Alan Stern
Post by Tom Gundersen
---
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

Cheers,

Tom
Alan Stern
2013-09-10 17:31:50 UTC
Permalink
Post by Tom Gundersen
Hi Alan,
Post by Alan Stern
Post by Tom Gundersen
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.
//
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?
Post by Tom Gundersen
Post by Alan Stern
Post by Tom Gundersen
---
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
Tom Gundersen
2013-09-10 21:27:09 UTC
Permalink
Post by Alan Stern
Post by Tom Gundersen
Hi Alan,
Post by Alan Stern
Post by Tom Gundersen
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.
//
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?
Exactly.
Post by Alan Stern
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?
No, unloading does not care about dependencies.
Post by Alan Stern
Post by Tom Gundersen
Post by Alan Stern
Post by Tom Gundersen
---
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.
Thanks, I'll send a new patch.

-t
Lucas De Marchi
2013-09-10 22:48:52 UTC
Permalink
Post by Tom Gundersen
Post by Alan Stern
Post by Tom Gundersen
Hi Alan,
Post by Alan Stern
Post by Tom Gundersen
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.
Then IMO it should not only be advised to have this dependency, but
also require it.
Post by Tom Gundersen
Post by Alan Stern
Post by Tom Gundersen
//
The softdep command allows you to specify soft, or optional, module
dependencies. modulename can be used without these optional modules
Note that with this patch and another to kmod we are planning to
change the behavior. It won't be optional anymore but required since
depmod would then parse the modules.softdeps file and add them as
dependencies automatically.
Post by Tom Gundersen
Post by Alan Stern
Post by Tom Gundersen
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?
Exactly.
Not really. If we try to load the module, but then fail we fail the
operation altogether. Whereas if the module simply doesn't exist, then
we carry on. In reality what we do is to assume the indexes and
softdeps in configuration are correct)
Post by Tom Gundersen
Post by Alan Stern
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?
No, unloading does not care about dependencies.
modprobe -r will remove then as well, in the opposite order, i.e. post
softdep, module, pre softdep. However this applies only to modprobe,
not to the related function in libkmod since it would be weird to
other programs using this library function.


Try playing with this in /etc/modprobe.d/bla.conf (and replace echo
with whatever unknown command to test a failure scenario):
install bla echo install bla
remove bla echo remove bla
softdep sr_mod pre: bla


Lucas De Marchi
Alan Stern
2013-09-11 14:29:09 UTC
Permalink
Post by Lucas De Marchi
Post by Tom Gundersen
Post by Alan Stern
Post by Alan Stern
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.
Then IMO it should not only be advised to have this dependency, but
also require it.
Requiring the ordering won't fix all the possible problems. For
example, ehci-pci might be compiled into the kernel while ohci-pci is
built as a module (although this probably could be prevented by
tweaking the Kconfig file).
Post by Lucas De Marchi
Post by Tom Gundersen
Post by Alan Stern
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?
Exactly.
Not really. If we try to load the module, but then fail we fail the
operation altogether. Whereas if the module simply doesn't exist, then
we carry on. In reality what we do is to assume the indexes and
softdeps in configuration are correct)
What if somebody really does want to load ohci-pci without loading
ehci-pci? That is a perfectly valid thing to do (and I often want to
do it for testing).

It sounds like the only way to accomplish this would be to load both
and then unload ehci-pci. Yes? Or would that unload ohci-pci as well?
Post by Lucas De Marchi
Post by Tom Gundersen
Post by Alan Stern
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?
No, unloading does not care about dependencies.
modprobe -r will remove then as well, in the opposite order, i.e. post
softdep, module, pre softdep. However this applies only to modprobe,
not to the related function in libkmod since it would be weird to
other programs using this library function.
Aside from testing, people hardly ever unload drivers. So this is a
relatively minor concern.
Post by Lucas De Marchi
Try playing with this in /etc/modprobe.d/bla.conf (and replace echo
install bla echo install bla
remove bla echo remove bla
softdep sr_mod pre: bla
Good recommendation.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Gundersen
2013-09-10 21:30:14 UTC
Permalink
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.

Signed-off-by: Tom Gundersen <teg-***@public.gmane.org>
Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/***@public.gmane.org>
Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+***@public.gmane.org>

---
v2: change the dependencies to *_pci, as suggested by Alan
drivers/usb/host/ohci-pci.c | 1 +
drivers/usb/host/uhci-pci.c | 2 ++
2 files changed, 3 insertions(+)

diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index ec337c2..eedf97c 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -323,3 +323,4 @@ module_exit(ohci_pci_cleanup);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
+MODULE_SOFTDEP("pre: ehci_pci");
diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
index c300bd2f7..f7bbf43 100644
--- a/drivers/usb/host/uhci-pci.c
+++ b/drivers/usb/host/uhci-pci.c
@@ -299,3 +299,5 @@ static struct pci_driver uhci_pci_driver = {
},
#endif
};
+
+MODULE_SOFTDEP("pre: ehci_pci");
--
1.8.4
Sergei Shtylyov
2013-09-10 22:06:04 UTC
Permalink
Hello.
Post by Tom Gundersen
Support for specifying soft dependencies in the modules themselves was
introduced in commit 7cb14ba.
Please also specify that commit's summary line in parens.
Post by Tom Gundersen
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.
WBR, Sergei
Loading...