Only attach gpiobus when the controller is fully initialized. Children
of gpiobus expect this to be the case.
Details
Tested the pl061 change, the rest are only compile tested.
Note that most drivers in the tree already do this. These are just the few that don't.
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 65126 Build 62009: arc lint + arc unit
Event Timeline
One commit for moving gpiobus_attach_bus() after init (seems fine to me)
and another for changes to pl061 (the ACPI/WDT interrupt changes seems unrelated).
Removing bus_attach_children() is questionable ( and probably wrong)
and moving bus_setup_intr() before HW init is clearly wrong.
sys/arm/nvidia/as3722.c | ||
---|---|---|
314 | This is clearly wrong, you can't set an interrupt without having fully initialized HW and driver data. | |
331 | Why did you remove the bus_attach_children() function? Ditto for other drivers. | |
sys/arm64/apple/apple_pinctrl.c | ||
164 | Why? | |
sys/arm64/nvidia/tegra210/max77620.c | ||
418 | Again, wrong change. |
They're required to move the intr_pic_register call to pl061_attach.
sys/arm/nvidia/as3722.c | ||
---|---|---|
314 | Hm, I should just move the gpiobus_attach_bus call out instead of moving the whole function. | |
331 | Because gpiobus_attach_bus already calls it. | |
sys/arm64/apple/apple_pinctrl.c | ||
164 | The PIC needs to be registered before we attach gpiobus. If a gpiobus child gets attached in the same bus pass, and said child tried to setup an interrupt, it would fail. |
sys/arm/nvidia/as3722.c | ||
---|---|---|
331 | Yeah, I'll move it to a separate review. |
Move as3722_gpio_attach and max77620_gpio_attach back up, and instead swap them with the rtc functions.
It's hard to tell if the interrupt is needed by the controller's children (presumably it is), but
they're both currently unimplemented.
Simplify the pl061 attach functions by tail calling pl061_attach.
Move the removal of bus_attach_children calls to a parent commit.
max77620 and as3722 are much more problematic. I think each function expects the other functions to have HW initialized before they can be consumed.
In other words, and I hope more clearly:
Having bus_attach_children() in gpiobus_attach_bus() is a nice shortcut for trivial cases, but a nightmare for complex ones. Personally, I vote for creating a 'clone' of gpiobus_attach_bus() without scanning children and using it in those cases along with explicit bus_attach_children() in the driver.
What do you think about that?
sys/arm64/apple/apple_pinctrl.c | ||
---|---|---|
164 | However, you moved it before pinctrl configured the pins, so the result is again misordered. Imho, pinctrl init should be moved along with intr_pic_register(). |
I see, I'll revert the move.
Hmm, is there a reason we need to add a child in max77620_gpio_attach/as3722_gpio_attach specifically? I think we should just move the gpiobus_attach_bus call after hw init is done.
sys/arm64/apple/apple_pinctrl.c | ||
---|---|---|
164 | Agreed. I think I just got confused since I saw other drivers doing it this way. |
Actually, I've changed my mind. You're right, even if the max77620 and as3722 drivers don't *need* this functionality, adding a separate function is definitely a cleaner way to implement it.
Move max77620 and as3722's gpio_attach functions to their original place,
and use gpiobus_add_bus instead.
Move the pinctrl functions before gpiobus attachment too.
Also fix a few more drivers that do this.
Thank you very much for your patience. Please don't forget the MFC for this whole series.
sys/arm/allwinner/aw_gpio.c | ||
---|---|---|
1160–1163 ↗ | (On Diff #157852) | Do we need to undo this in the failure case? |
sys/arm/allwinner/aw_gpio.c | ||
---|---|---|
1160–1163 ↗ | (On Diff #157852) | All fdt_pinctrl_register does is call OF_device_register_xref on a few nodes, so I think that's fine. |