* [PATCH] rfkill: allocate static minor
@ 2019-10-24 17:40 Marcel Holtmann
2019-10-24 18:44 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2019-10-24 17:40 UTC (permalink / raw)
To: arnd, gregkh, johannes, davem; +Cc: linux-kernel, linux-wireless, netdev
udev has a feature of creating /dev/<node> device-nodes if it finds
a devnode:<node> modalias. This allows for auto-loading of modules that
provide the node. This requires to use a statically allocated minor
number for misc character devices.
However, rfkill uses dynamic minor numbers and prevents auto-loading
of the module. So allocate the next static misc minor number and use
it for rfkill.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/linux/miscdevice.h | 1 +
net/rfkill/core.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 3247a3dc7934..b06b75776a32 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -57,6 +57,7 @@
#define UHID_MINOR 239
#define USERIO_MINOR 240
#define VHOST_VSOCK_MINOR 241
+#define RFKILL_MINOR 242
#define MISC_DYNAMIC_MINOR 255
struct device;
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index f9b08a6d8dbe..0bf9bf1ceb8f 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1316,10 +1316,12 @@ static const struct file_operations rfkill_fops = {
.llseek = no_llseek,
};
+#define RFKILL_NAME "rfkill"
+
static struct miscdevice rfkill_miscdev = {
- .name = "rfkill",
.fops = &rfkill_fops,
- .minor = MISC_DYNAMIC_MINOR,
+ .name = RFKILL_NAME,
+ .minor = RFKILL_MINOR,
};
static int __init rfkill_init(void)
@@ -1371,3 +1373,6 @@ static void __exit rfkill_exit(void)
class_unregister(&rfkill_class);
}
module_exit(rfkill_exit);
+
+MODULE_ALIAS_MISCDEV(RFKILL_MINOR);
+MODULE_ALIAS("devname:" RFKILL_NAME);
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: allocate static minor
2019-10-24 17:40 [PATCH] rfkill: allocate static minor Marcel Holtmann
@ 2019-10-24 18:44 ` Greg KH
2019-10-24 20:23 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2019-10-24 18:44 UTC (permalink / raw)
To: Marcel Holtmann
Cc: arnd, johannes, davem, linux-kernel, linux-wireless, netdev
On Thu, Oct 24, 2019 at 07:40:42PM +0200, Marcel Holtmann wrote:
> udev has a feature of creating /dev/<node> device-nodes if it finds
> a devnode:<node> modalias. This allows for auto-loading of modules that
> provide the node. This requires to use a statically allocated minor
> number for misc character devices.
>
> However, rfkill uses dynamic minor numbers and prevents auto-loading
> of the module. So allocate the next static misc minor number and use
> it for rfkill.
As rfkill has been around for a long time, what new use case is needing
to auto-load this based on a major number?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: allocate static minor
2019-10-24 18:44 ` Greg KH
@ 2019-10-24 20:23 ` Marcel Holtmann
2019-11-05 17:25 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2019-10-24 20:23 UTC (permalink / raw)
To: Greg KH
Cc: Arnd Bergmann, Johannes Berg, David S. Miller, linux-kernel,
linux-wireless, netdev
Hi Greg,
>> udev has a feature of creating /dev/<node> device-nodes if it finds
>> a devnode:<node> modalias. This allows for auto-loading of modules that
>> provide the node. This requires to use a statically allocated minor
>> number for misc character devices.
>>
>> However, rfkill uses dynamic minor numbers and prevents auto-loading
>> of the module. So allocate the next static misc minor number and use
>> it for rfkill.
>
> As rfkill has been around for a long time, what new use case is needing
> to auto-load this based on a major number?
we have bug reports from iwd users where it fails opening /dev/rfkill. Since iwd can be actually started before the WiFi hardware is fully probed and all its drivers are loaded, we have a race-condition here if rfkill is not capable of auto-loading.
The difference is really that iwd is a fully self-contained WiFi daemon compared to wpa_supplicant which is just some sort of helper. iwd is fully hot plug capable as well compared to wpa_supplicant. It looks like this is exposing the race condition for our users. Frankly, we should have fixed rfkill a long time ago when we fixed uinput, uhid etc, but seems we forgot it. I assume mainly because it magically got loaded in time by some module dependencies.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: allocate static minor
2019-10-24 20:23 ` Marcel Holtmann
@ 2019-11-05 17:25 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-11-05 17:25 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Arnd Bergmann, Johannes Berg, David S. Miller, linux-kernel,
linux-wireless, netdev
On Thu, Oct 24, 2019 at 10:23:57PM +0200, Marcel Holtmann wrote:
> Hi Greg,
>
> >> udev has a feature of creating /dev/<node> device-nodes if it finds
> >> a devnode:<node> modalias. This allows for auto-loading of modules that
> >> provide the node. This requires to use a statically allocated minor
> >> number for misc character devices.
> >>
> >> However, rfkill uses dynamic minor numbers and prevents auto-loading
> >> of the module. So allocate the next static misc minor number and use
> >> it for rfkill.
> >
> > As rfkill has been around for a long time, what new use case is needing
> > to auto-load this based on a major number?
>
> we have bug reports from iwd users where it fails opening /dev/rfkill. Since iwd can be actually started before the WiFi hardware is fully probed and all its drivers are loaded, we have a race-condition here if rfkill is not capable of auto-loading.
>
> The difference is really that iwd is a fully self-contained WiFi daemon compared to wpa_supplicant which is just some sort of helper. iwd is fully hot plug capable as well compared to wpa_supplicant. It looks like this is exposing the race condition for our users. Frankly, we should have fixed rfkill a long time ago when we fixed uinput, uhid etc, but seems we forgot it. I assume mainly because it magically got loaded in time by some module dependencies.
You need a better email client, one with \n characters...
Anyway, this sounds reasonable, I'll go queue this up for 5.5.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-05 17:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 17:40 [PATCH] rfkill: allocate static minor Marcel Holtmann
2019-10-24 18:44 ` Greg KH
2019-10-24 20:23 ` Marcel Holtmann
2019-11-05 17:25 ` Greg KH
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 NNTP newsgroup(s).