Message ID | 20180920191759.17781-1-tpiepho@impinj.com (mailing list archive) |
---|---|
Headers | show |
Series | device tree spidev solution - driver_override for SPI | expand |
Hi Trent, On Thu, Sep 20, 2018 at 07:18:27PM +0000, Trent Piepho wrote: > This is an attempt to solve the problem of binding spidev to a device on > a device-tree system. > ... Tested-by: Kyle Roeschley <kyle.roeschley@ni.com> I tried this patch series on a Xilinx Zynq Z-7020 based system running kernel 4.14 with your patches (which applied cleanly). Our device tree previously listed spidev in its compatible strings. With just this change, I see the warnings prints as expected. When I update my compatible strings to something new and create a udev rule to write to driver_override, the warnings no longer show up. Thanks very much for addressing this issue!
On čtvrtek 20. září 2018 21:18:27 CEST, Trent Piepho wrote: > Trent Piepho (3): > spi: Add driver_override SPI device attribute > spi: Automatically attempt attach after driver_override alteration > spi: spidev: Fix OF tree warning logic Hello, I'm rebasing our internal kernels against 5.0, and I noticed that this patch series does not appear to be merged yet, and they are also not in any SPI subtree as far as I can see. I checked the mailing list, and I saw that the patches were reviewed by Geert and me. Are they blocked on something I missed? With kind regards, Jan
On Tue, 2019-03-05 at 12:15 +0100, Jan Kundrát wrote: > On čtvrtek 20. září 2018 21:18:27 CEST, Trent Piepho wrote: > > Trent Piepho (3): > > spi: Add driver_override SPI device attribute > > spi: Automatically attempt attach after driver_override alteration > > spi: spidev: Fix OF tree warning logic > > Hello, I'm rebasing our internal kernels against 5.0, and I noticed that > this patch series does not appear to be merged yet, and they are also not > in any SPI subtree as far as I can see. I checked the mailing list, and I > saw that the patches were reviewed by Geert and me. Are they blocked on > something I missed? The first and last are in, 5039563e7c25 and 605b3bec73cb. The second isn't. It's not strictly necessary to use it. But it does make the udev rules a lot smaller and I think makes the system easier to use. Mark quite rightly pointed out that the other driver_overrides didn't automatically attach and they should all work the same way. I made patches to convert them all to automatic, but then it fell off the radar and I never finished with it.
On úterý 5. března 2019 19:39:03 CET, Trent Piepho wrote: > On Tue, 2019-03-05 at 12:15 +0100, Jan Kundrát wrote: >> On čtvrtek 20. září 2018 21:18:27 CEST, Trent Piepho wrote: ... > > The first and last are in, 5039563e7c25 and 605b3bec73cb. The second > isn't. It's not strictly necessary to use it. But it does make the > udev rules a lot smaller and I think makes the system easier to use. Indeed :). Do you have an example on how this explicit attach from userspace looks like? I'm already setting ATTR{driver_override} from udev, but that's not enough without your second patch. Should I perhaps poke in sysfs, somehow? > Mark quite rightly pointed out that the other driver_overrides didn't > automatically attach and they should all work the same way. I made > patches to convert them all to automatic, but then it fell off the > radar and I never finished with it. If you ask me, that patch is rather simple and it enables a straightforward way of exporting devices to userspace. From my point of view, this is a desirable property. With kind regards, Jan
On Wed, 2019-03-06 at 14:01 +0100, Jan Kundrát wrote: > On úterý 5. března 2019 19:39:03 CET, Trent Piepho wrote: > > On Tue, 2019-03-05 at 12:15 +0100, Jan Kundrát wrote: > > > On čtvrtek 20. září 2018 21:18:27 CEST, Trent Piepho wrote: ... > > > > The first and last are in, 5039563e7c25 and 605b3bec73cb. The second > > isn't. It's not strictly necessary to use it. But it does make the > > udev rules a lot smaller and I think makes the system easier to use. > > Indeed :). Do you have an example on how this explicit attach from > userspace looks like? I'm already setting ATTR{driver_override} from udev, > but that's not enough without your second patch. Should I perhaps poke in > sysfs, somehow? What needs to happen is to write the device name to the spidev driver's bind attribute to manually attach. Because of driver_override, this will work, rather than fail as it does without. Unfortunately, "bind" is an attribute of the driver while udev is responding to a uevent for the device. So there's no handy ATTR{bind} to use. I don't recall the exact udev magic, but I did verify it can be done. I think it needed udev to run a command, something like: RUN+="echo %k > %S/%p/subsystem/drivers/spidev/bind" > > > Mark quite rightly pointed out that the other driver_overrides didn't > > automatically attach and they should all work the same way. I made > > patches to convert them all to automatic, but then it fell off the > > radar and I never finished with it. > > If you ask me, that patch is rather simple and it enables a straightforward > way of exporting devices to userspace. From my point of view, this is a > desirable property. Yes, I liked it too, that's why I did it that way. But it seems like all the driver_overrides should work the same way and it's not clear to my trying to change them would be accepted.
Hi Jan, On Wed, Mar 6, 2019 at 2:01 PM Jan Kundrát <jan.kundrat@cesnet.cz> wrote: > On úterý 5. března 2019 19:39:03 CET, Trent Piepho wrote: > > On Tue, 2019-03-05 at 12:15 +0100, Jan Kundrát wrote: > >> On čtvrtek 20. září 2018 21:18:27 CEST, Trent Piepho wrote: ... > > > > The first and last are in, 5039563e7c25 and 605b3bec73cb. The second > > isn't. It's not strictly necessary to use it. But it does make the > > udev rules a lot smaller and I think makes the system easier to use. > > Indeed :). Do you have an example on how this explicit attach from > userspace looks like? I'm already setting ATTR{driver_override} from udev, > but that's not enough without your second patch. Should I perhaps poke in > sysfs, somehow? > > > Mark quite rightly pointed out that the other driver_overrides didn't > > automatically attach and they should all work the same way. I made > > patches to convert them all to automatic, but then it fell off the > > radar and I never finished with it. > > If you ask me, that patch is rather simple and it enables a straightforward > way of exporting devices to userspace. From my point of view, this is a > desirable property. I don't have access to an appropriate system right now, but it should be something like: Override $dev to spidev: echo spidev > /sys/bus/spi/devices/$dev/driver_override Bind $dev to spidev: echo $dev > /sys/bus/spi/drivers/spidev/bind Good luck! Gr{oetje,eeting}s, Geert
> What needs to happen is to write the device name to the spidev driver's > bind attribute to manually attach. Because of driver_override, this > will work, rather than fail as it does without. > > Unfortunately, "bind" is an attribute of the driver while udev is > responding to a uevent for the device. So there's no handy ATTR{bind} > to use. > > I don't recall the exact udev magic, but I did verify it can be done. > I think it needed udev to run a command, something like: > RUN+="echo %k > %S/%p/subsystem/drivers/spidev/bind" Thanks. It turned out to be a bit more complicated because attributes set by ATTR{driver_override}+="spidev" only take effect after the rule has been processed, apparently. It's quite easy to hack around this. Here's a complete rule which works for me: # cannot use ATTR{driver_override}+="spidev" because it apparently only runs after the PROGRAM ACTION=="add|change", SUBSYSTEM=="spi", ENV{MODALIAS}=="spi:my-device-from-device-tree", PROGRAM+="/bin/sh -c 'echo spidev > %S%p/driver_override && echo %k > %S%p/subsystem/drivers/spidev/bind'" Thanks for pointing me in the right direction, Trent and Geert. With kind regards, Jan