Skip to contentSkip to conversation

New: Kernel crash when unloading radeon module for switcheroo card

Bug 84431 [email protected] 1 participant 12 messages Sep 12, 2014 – Aug 5, 2016

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=84431

Bug ID: 84431
Summary: Kernel crash when unloading radeon module for
switcheroo card
Product: Drivers
Version: 2.5
Kernel Version: all
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: high
Priority: P1
Component: Video(DRI - non Intel)
Assignee: [email protected]
Reporter: [email protected]
Regression: No

Created attachment 149991
--> https://bugzilla.kernel.org/attachment.cgi?id=149991&action=edit
Fix crash after rmmod radeon on PX systems.

Calling rmmod radeon on PX system cause kernel crash. Reason is function vga_switcheroo_init_domain_pm_ops() which setting dev->pm_domain function of PCI device. When radeon module is unloaded pointer dev->pm_domain is set to vga_switcheroo function which try to call radeon function (which does not exists in memory after rmmod radeon). I bet that nouveau has same problem.

I'm attaching simple patch which set dev->pm_domain of PCI device back to NULL when removing radeon device so vga_switcheroo will not be called.

But I think that proper way for fixing this bug - which is in vga_switcheroo - should be to add function like "vga_switcheroo_exit_domain_pm_ops()" which will set pm_domain back to origin value (which is in my case NULL).

With my patch on PX system I can call rmmod radeon, modprobe radeon, rmmod radeon, ... many times without no crash.

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

https://bugzilla.kernel.org/show_bug.cgi?id=84431

Pali Rohár <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

 Attachment #149991|0                           |1
           is patch|                            |
 Attachment #149991|application/octet-stream    |text/plain
          mime type|                            |
Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

Alex Deucher <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #1 from Alex Deucher <[email protected]> --- Care to generate a git patch and sign-off on it?

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#3 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

--- Comment #2 from Pali Rohár <[email protected]> ---
I can, but I do not know if this is proper way how to fix it. I still think that root of bug is in function vga_switcheroo_init_domain_pm_ops() which overwrite dev->pm_domain, but does not restore it when driver/device unregister.

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

--- Comment #6 from Pali Rohár <[email protected]> ---
I tested 1/3 and 2/3 on 3.13 kernel. And as expected (because patches doing same thing) same result as with my patch - no kernel crash anymore. You can add my Signed-off.

I do not have nvidia optimus card, so I cannot test last patch.

Anyway in vga_switcheroo.c is exported function vga_switcheroo_init_domain_pm_optimus_hdmi_audio() which changing dev->pm_domain too. But I do not see any driver which using it.

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

--- Comment #7 from Pali Rohár <[email protected]> --- Function vga_switcheroo_init_domain_pm_optimus_hdmi_audio() is used in sound/pci/hda/hda_intel.c. So that driver has same problem and cause kernel panic on driver unload.

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

Joaquín Aramendía <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #8 from Joaquín Aramendía <[email protected]> --- Alex, That patchset indeed got rid of that bug, but for some reason it introduced another one:
https://bugzilla.kernel.org/show_bug.cgi?id=86011

97d30fa3524ff60b43d450012abe8f961d280478 from stable kernel tree breaks nouveau power management through vga-switcheroo.

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

Peter Wu <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #9 from Peter Wu <[email protected]> --- (In reply to Pali Rohár from comment #7)

Quoted 3 lines

Function vga_switcheroo_init_domain_pm_optimus_hdmi_audio() is used in sound/pci/hda/hda_intel.c. So that driver has same problem and cause kernel panic on driver unload.

A patch for this issue is queued at
http://mailman.alsa-project.org/pipermail/alsa-devel/2016-July/110125.html

Joaquín, how does 97d30fa35 break nouveau vga-switcheroo? If you load nouveau with runpm=0, then you can write OFF to debugfs' vga_switcheroo. However runpm=1 (or -1 for Optimus systems) is recommended.

I think that the original bug is fixed, so this can be marked as resolved?

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

[Bug 84431] Kernel crash when unloading radeon module for switcheroo card

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=84431

--- Comment #10 from Joaquín Aramendía <[email protected]> ---

Quoted 3 lines

Joaquín, how does 97d30fa35 break nouveau vga-switcheroo? If you load nouveau with runpm=0, then you can write OFF to debugfs' vga_switcheroo. However runpm=1 (or -1 for Optimus systems) is recommended.

Just tested removing nouveau module with Ubuntu 16.04 on mainline kernel v4.6.5 and it worked correctly. Also modprobed it after that and worked correctly. This bug should be marked as resolved.

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel