Page MenuHomeFreeBSD

gpio: rework gpioaei
Needs ReviewPublic

Authored by vexeduxr on Sun, Jul 27, 8:45 PM.
Tags
None
Referenced Files
F126058539: D51584.diff
Thu, Aug 14, 2:33 PM
Unknown Object (File)
Wed, Aug 13, 3:47 AM
Unknown Object (File)
Sat, Aug 9, 11:33 PM
Unknown Object (File)
Thu, Aug 7, 9:33 AM
Unknown Object (File)
Sun, Aug 3, 3:00 AM
Unknown Object (File)
Wed, Jul 30, 10:02 AM
Unknown Object (File)
Mon, Jul 28, 7:09 PM
Unknown Object (File)
Mon, Jul 28, 6:32 PM
Subscribers

Details

Summary

Rework gpioaei to make it support more than one pin per GPIO resource.
Also allow one instance of gpioaei to handle multiple resources.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65960
Build 62843: arc lint + arc unit

Event Timeline

I don't really like that we have to loop through the AEI resources twice, but I haven't been able to find a better way to do this.

sys/dev/gpio/acpi_gpiobus.c
310

What's this brace doing here?

334

why BUS_ADD_CHILD and not bus_add_child? The usual pattern is to add the child with the ivars... So I'm a bit confused below that you get the ivards... Am I missing something here?

sys/dev/gpio/gpioaei.c
137

Doesn't this rely on the fact that type is initialized to 0 in the malloc? Maybe making that more explicit would help?

sys/dev/gpio/acpi_gpiobus.c
310

It's so I don't pollute the rest of the function with the 4 aei variables.

334

gpiobus_add_child_common (which is called from acpi_gpiobus' bus_add_child) deals with allocating the ivars and calling device_set_ivars. So all we have to do after that is set the acpi specific bits and set the pins needed by _AEI.

why BUS_ADD_CHILD and not bus_add_child?

s/bus_add_child/device_add_child ?
Before we were doing device_add_child_ordered then initializing the resource list and calling device_set_ivars. But all of that is already done in gpiobus_add_child_common, which we can either call directly or call through BUS_ADD_CHILD, so I thought this would be better.

sys/dev/gpio/gpioaei.c
137

Yes and Yes :)

Looking through the code again, we could just remove the M_ZERO and initialize type and intr_rid explicitly.

Allocate ctx without M_ZERO and explicitly initialize type and intr_rid.

imp added a subscriber: jhb.

This is good to go in, but I'd feel happier if @jhb also reviewed it.

This revision is now accepted and ready to land.Mon, Aug 11, 10:54 PM

Fix max pin check when enumerating _AEI.
GPIO_PIN_MAX returns the highest usable pin, so '>' should be used, not '>='.

This revision now requires review to proceed.Thu, Aug 14, 8:50 AM
sys/dev/gpio/acpi_gpiobus.c
310

If you don't want to move the variables to the top of the function moving this into a new function might be cleaner. It's uncommon to put these into the middle of a function.

sys/dev/gpio/gpioaei.c
124

Why M_NOWAIT when you don't handle it returning NULL?

239–249

It looks like you're implementing SLIST_FOREACH_SAFE

sys/dev/gpio/gpioaei.c
124

This function gets called by ACPICA. While I tested M_WAITOK and it seemed to work fine, I'd rather not assume it's not doing anything else (e.g holding a mutex).

when you don't handle it returning NULL?

Not sure what else to do other than an assertion.

239–249

Ah, looks like I am.

Move addition of gpioaei child to it's own function.
Use SLIST_FOREACH_SAFE.