Glam Prestige Journal

Bright entertainment trends with youth appeal.

I would like to expose some IRQ to user-space using uio_pdrv_genirq driver on Raspberry Pi 4 Model B. However, I've faced some problems that the device /dev/uio0 is not created (on first module load).

I use raspbian with kernel 5.2.2-v7l+, but I've started with kernel 4.19.57-v7l+ with the same results.

I've prepared device-tree overlay:

/dts-v1/;
/plugin/;
/ { fragment@0 { target = <&gpio>; __overlay__ { mfrc522_uio_pins: mfrc522_uio_pins { brcm,pins = <4>; brcm,function = <0>; //<BCM2835_FSEL_GPIO_IN>; brcm,pull = <0>; //<BCM2835_PUD_OFF>; }; }; }; fragment@1 { target-path = "/"; __overlay__ { mfrc522_uio: mfrc522_uio { compatible = "mfrc522-uio,generic-uio"; interrupt-parent = <&gpio>; interrupts = <4 1>; // IRQ_TYPE_EDGE_RISING pinctrl-names = "default"; pinctrl-0 = <&mfrc522_uio_pins>; status = "okay"; }; }; }; __overrides__ { gpiopin = <&mfrc522_uio_pins>,"brcm,pins:0", <&mfrc522_uio>,"interrupts:0"; };
};

Compiled it by:

dtc -@ -I dts -O dtb -o mfrc522-uio-overlay.dt{bo,s}

and loaded:

sudo dtoverlay mfrc522-uio-overlay.dtbo

After module load:

sudo modprobe uio_pdrv_genirq of_id="mfrc522-uio,generic-uio"

the /dev/uio0 should appear, but it does not. Kernel log shows nothing about this situation.

The workaround is to remove module:

sudo modprobe -r uio_pdrv_genirq

and load it once again. Then the device appears in /dev.

There is no problem if I use kernel with built-in uio_pdrv_genirq driver and add to bootargs uio_pdrv_genirq.of_id="mfrc522-uio,generic-uio". However, for some reasons I prefer to use distro's precompiled kernel.

The question is: why do I have to reload uio_pdrv_genirq module to get /dev/uio0 device, and how to fix this behavior?

1 Answer

The blank of_id in the uio_pdrv_genirq driver has the unintentional side-effect of causing userspace to view the module as a potential match for every platform device, thus the uio_pdrv_genirq module (if present) will always get automatically loaded at boot. And since the module is already loaded, attempting to modprobe it with different settings has no effect (unless you unload the module first).

The solution is to create a /etc/modprobe.d/uio_pdrv_genirq.conf file containing

options uio_pdrv_genirq of_id=mfrc522-uio,generic-uio

This will make modprobe apply your setting automatically when the module gets loaded.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy