Page MenuHomeFreeBSD

amdgpio, gpiobus: Add interrupt support for !INTRNG platforms
Needs ReviewPublic

Authored by rz_fabmicro.ru on Jun 30 2026, 5:53 PM.
Referenced Files
Unknown Object (File)
Fri, Sep 4, 10:24 PM
Unknown Object (File)
Fri, Sep 4, 12:40 PM
Unknown Object (File)
Wed, Sep 2, 4:38 PM
Unknown Object (File)
Tue, Sep 1, 6:38 PM
Unknown Object (File)
Tue, Sep 1, 4:08 PM
Unknown Object (File)
Sat, Aug 29, 1:42 PM
Unknown Object (File)
Sat, Aug 29, 8:25 AM
Unknown Object (File)
Fri, Aug 28, 8:41 PM

Details

Summary

This commit is based on work done by Andriy Gapon initially
submmitted in D26407 back in 2020. The idea was to add internal PIC
controller to serve GPIO interrupts to attached bus client (child),
new flag IE_BUS_PRIV is introduced to mark interrupts internal to the
bus. The code has been adopted to build with recent kernel source.

It was observed that after client event handler is removed (module
unloaded), a stray interrupt may appear because handler is scheduled
for execution one last time to let it remove itself. The sometimes
delayed handler then consequently calls to pre_ and post_ithread which
unmasks interrupts on no longer used GPIO pin.
A workaround added to prevent such stray interrupts, see extended
comment in gpiopic_remove_handler().

Test Plan

Tested on AMD Ryzen 5 based laptops: HP-15s and Lenovo Ideapad Gaming
with gpioaei.ko (Power Button connected to GPIO pin 0).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 74420
Build 71303: arc lint + arc unit

Event Timeline

adrian added a subscriber: adrian.

most of this is fine but the code that handles the non-intrng path seems .. a lot. I think I want this eyeballed by some other folks and see if there's scope to just push to get everything migrated to intrng already.

Last time I checked, porting x86 to intrng did not look trivial, at least for me.
Maybe it would not be too hard for someone with more experience in both.

Another idea that I had was to have gpiobus-with-interrupts as a sub-class of gpiobus.
Just to minimize changes to the core gpiobus and to split the code a little bit.

For reference, here's bug report I posted some time ago which made me deep-dive into this problem. It seems, as reduced ACPI hardware laptops (with Power buttons served by GPIO pin) become more frequent, we will have to solve this GPIO interrupts issue either way.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295251