diff mbox series

[meta-arago,master/dunfell,1/2] systemd: fix the local rule to load modules when new hardware is added

Message ID 20230104141150.186773-2-j-choudhary@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series Fix module loading udev rules | expand

Commit Message

Jayesh Choudhary Jan. 4, 2023, 2:11 p.m. UTC
Using modprobe causes the rule to fail when the module is builtin in kernel
and it is logged in journalctl. So use the builtin command 'kmod' instead.
This makes the journalctl logs clean and significantly easier to read.

Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
---
 meta-arago-distro/recipes-core/systemd/systemd/local.rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Davis Jan. 4, 2023, 4:12 p.m. UTC | #1
On 1/4/23 8:11 AM, Jayesh Choudhary via lists.yoctoproject.org wrote:
> Using modprobe causes the rule to fail when the module is builtin in kernel
> and it is logged in journalctl. So use the builtin command 'kmod' instead.
> This makes the journalctl logs clean and significantly easier to read.
> 
> Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
> ---
>   meta-arago-distro/recipes-core/systemd/systemd/local.rules | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta-arago-distro/recipes-core/systemd/systemd/local.rules b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> index b0e9f84f..4829ca14 100644
> --- a/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> +++ b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> @@ -14,7 +14,7 @@
>   #
>   
>   # Try and modprobe for drivers for new hardware
> -ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
> +ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"
>   

Is the builtin version as full featured? Does this work in non-systemd systems? Is this just
masking all errors or do real errors still get logged somewhere? If this is just a way
to mask errors then --quiet might be more portable.

(BTW I ran into this same issue of having no good way to know if a module was builtin or just
missing when adding dynamic kernel module support for Android [0])

Andrew

[0] https://android.googlesource.com/platform/system/core/+/9963847419f41c76ca008cf0c09e986c79f04e4c

>   # Create a symlink to any touchscreen input device
>   SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", SYMLINK+="input/touchscreen0"
Denys Dmytriyenko Jan. 12, 2023, 4:20 p.m. UTC | #2
On Wed, Jan 04, 2023 at 10:12:42AM -0600, Andrew Davis via lists.yoctoproject.org wrote:
> On 1/4/23 8:11 AM, Jayesh Choudhary via lists.yoctoproject.org wrote:
> >Using modprobe causes the rule to fail when the module is builtin in kernel
> >and it is logged in journalctl. So use the builtin command 'kmod' instead.
> >This makes the journalctl logs clean and significantly easier to read.
> >
> >Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
> >---
> >  meta-arago-distro/recipes-core/systemd/systemd/local.rules | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/meta-arago-distro/recipes-core/systemd/systemd/local.rules b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> >index b0e9f84f..4829ca14 100644
> >--- a/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> >+++ b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
> >@@ -14,7 +14,7 @@
> >  #
> >  # Try and modprobe for drivers for new hardware
> >-ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
> >+ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"
> 
> Is the builtin version as full featured? Does this work in non-systemd systems? Is this just
> masking all errors or do real errors still get logged somewhere? If this is just a way
> to mask errors then --quiet might be more portable.
> 
> (BTW I ran into this same issue of having no good way to know if a module was builtin or just
> missing when adding dynamic kernel module support for Android [0])
> 
> Andrew
> 
> [0] https://android.googlesource.com/platform/system/core/+/9963847419f41c76ca008cf0c09e986c79f04e4c

Ping! I haven't seen any answers to the above questions, but the patch 
unfortunately already got merged...
Jayesh Choudhary Jan. 16, 2023, 7:16 a.m. UTC | #3
On 12/01/23 21:50, Denys Dmytriyenko wrote:
> On Wed, Jan 04, 2023 at 10:12:42AM -0600, Andrew Davis via lists.yoctoproject.org wrote:
>> On 1/4/23 8:11 AM, Jayesh Choudhary via lists.yoctoproject.org wrote:
>>> Using modprobe causes the rule to fail when the module is builtin in kernel
>>> and it is logged in journalctl. So use the builtin command 'kmod' instead.
>>> This makes the journalctl logs clean and significantly easier to read.
>>>
>>> Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
>>> ---
>>>   meta-arago-distro/recipes-core/systemd/systemd/local.rules | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/meta-arago-distro/recipes-core/systemd/systemd/local.rules b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
>>> index b0e9f84f..4829ca14 100644
>>> --- a/meta-arago-distro/recipes-core/systemd/systemd/local.rules
>>> +++ b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
>>> @@ -14,7 +14,7 @@
>>>   #
>>>   # Try and modprobe for drivers for new hardware
>>> -ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
>>> +ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"
>>
>> Is the builtin version as full featured? Does this work in non-systemd systems? Is this just
>> masking all errors or do real errors still get logged somewhere? If this is just a way
>> to mask errors then --quiet might be more portable.


Andrew,

Even with --quiet, the error logs were there in journalctl as modprobe
has a non-zero exit status. I looked at other udev rules for loading
modules and since they were also using `kmod`, I used this command.

For instance, in /lib/udev/rules.d/80-drivers.rules:
ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"


>>
>> (BTW I ran into this same issue of having no good way to know if a module was builtin or just
>> missing when adding dynamic kernel module support for Android [0])
>>
>> Andrew
>>
>> [0] https://android.googlesource.com/platform/system/core/+/9963847419f41c76ca008cf0c09e986c79f04e4c
> 
> Ping! I haven't seen any answers to the above questions, but the patch
> unfortunately already got merged...
> 

Denys,

I missed this email thread.
I am extremely sorry about that.

-Jayesh
diff mbox series

Patch

diff --git a/meta-arago-distro/recipes-core/systemd/systemd/local.rules b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
index b0e9f84f..4829ca14 100644
--- a/meta-arago-distro/recipes-core/systemd/systemd/local.rules
+++ b/meta-arago-distro/recipes-core/systemd/systemd/local.rules
@@ -14,7 +14,7 @@ 
 #
 
 # Try and modprobe for drivers for new hardware
-ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
+ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"
 
 # Create a symlink to any touchscreen input device
 SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", SYMLINK+="input/touchscreen0"