Reviewed and applied. Thanks,
On Tue, Nov 10, 2026 at 10:56 AM Jiaming Fan <[email protected]> wrote: > > radeon_register_atpx_handler() registers the ATPX handler with > vga_switcheroo only when ATPX is detected, and ignores the result: > vga_switcheroo has a single handler slot and refuses a second handler > with -EINVAL. radeon_unregister_atpx_handler() calls > vga_switcheroo_unregister_handler() in either case, and that clears the > slot no matter who set it. > > So unloading radeon removes a handler registered by another driver, such > as apple-gmux. No Radeon GPU is needed for this; loading and unloading > radeon is enough. amdgpu is another such driver: when radeon and amdgpu > are both loaded and both detect ATPX, only the first one gets the slot, > and unloading the other one clears it. Afterwards vga_switcheroo can no > longer switch outputs, and a client that uses the vga_switcheroo runtime > PM domain, such as nouveau on a non-Optimus machine with a v1 DSM, can > dereference the now NULL handler during runtime suspend. > > Record whether the registration succeeded and unregister only in that > case. amdgpu has the same problem and gets the same fix. > > Fixes: 6a9ee8af344e ("vga_switcheroo: initial implementation (v15)") > Cc: [email protected] > Signed-off-by: Jiaming Fan <[email protected]> > --- > The amdgpu counterpart is patch 1 of this series: > https://lists.freedesktop.org/archives/amd-gfx/2026-November/157097.html > > drivers/gpu/drm/radeon/radeon_atpx_handler.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c > b/drivers/gpu/drm/radeon/radeon_atpx_handler.c > index f557535..9ed75c6 100644 > --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c > +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c > @@ -34,6 +34,7 @@ struct radeon_atpx { > static struct radeon_atpx_priv { > bool atpx_detected; > bool bridge_pm_usable; > + bool handler_registered; > /* handle for device - and atpx */ > acpi_handle dhandle; > struct radeon_atpx atpx; > @@ -605,7 +606,8 @@ void radeon_register_atpx_handler(void) > if (!r) > return; > > - vga_switcheroo_register_handler(&radeon_atpx_handler, handler_flags); > + if (!vga_switcheroo_register_handler(&radeon_atpx_handler, > handler_flags)) > + radeon_atpx_priv.handler_registered = true; > } > > /** > @@ -615,5 +617,14 @@ void radeon_register_atpx_handler(void) > */ > void radeon_unregister_atpx_handler(void) > { > + /* > + * vga_switcheroo has a single handler slot and unregistering clears > it > + * no matter who set it, so leave a handler registered by another > + * driver, such as amdgpu or apple-gmux, in place. > + */ > + if (!radeon_atpx_priv.handler_registered) > + return; > + > vga_switcheroo_unregister_handler(); > + radeon_atpx_priv.handler_registered = false; > } > -- > 2.56.0 > >
