Andreas Heider
2012-Mar-23 21:57 UTC
[Nouveau] [PATCH 0/3] Prepare nouveau for other switcheroo handlers
While working on a vga_switcheroo handler for Apple's Macbook Pros I stumbled upon a few bugs regarding the usage of nouveau with other switcheroo handlers and module unloading, here are my fixes for them. Andreas Heider (3): drm/nouveau: Initialize has_optimus drm/nouveau: Check dsm on switcheroo unregister drm/nouveau: Unregister switcheroo client on exit drivers/gpu/drm/nouveau/nouveau_acpi.c | 5 +++-- drivers/gpu/drm/nouveau/nouveau_state.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) -- 1.7.9.1
Andreas Heider
2012-Mar-23 21:57 UTC
[Nouveau] [PATCH 1/3] drm/nouveau: Initialize has_optimus
During dsm detection it is possible that has_optimus is read uninitialized,
which can lead to optimus being detected erroneously. This patch
initialized has_optimus with 0.
Signed-off-by: Andreas Heider <andreas at meetr.de>
---
drivers/gpu/drm/nouveau/nouveau_acpi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c
b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 7814a76..284bd25 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -270,7 +270,7 @@ static bool nouveau_dsm_detect(void)
struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
struct pci_dev *pdev = NULL;
int has_dsm = 0;
- int has_optimus;
+ int has_optimus = 0;
int vga_count = 0;
bool guid_valid;
int retval;
--
1.7.9.1
Andreas Heider
2012-Mar-23 21:57 UTC
[Nouveau] [PATCH 2/3] drm/nouveau: Check dsm on switcheroo unregister
Currently vga_switcheroo_unregister_handler is called unconditionally when
nouveau is unloaded, even when nouveau never registered a handler. This
interferes with other switcheroo handlers, as vga_switcheroo doesn't check
who
called unregister_handler, but simply unregisters the current handler. This
patch adds a check so unregister is only called if a handler was registered by
nouveau before.
Signed-off-by: Andreas Heider <andreas at meetr.de>
---
drivers/gpu/drm/nouveau/nouveau_acpi.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c
b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 284bd25..fc841e8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -338,7 +338,8 @@ void nouveau_switcheroo_optimus_dsm(void)
void nouveau_unregister_dsm_handler(void)
{
- vga_switcheroo_unregister_handler();
+ if (nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.dsm_detected)
+ vga_switcheroo_unregister_handler();
}
/* retrieve the ROM in 4k blocks */
--
1.7.9.1
Andreas Heider
2012-Mar-23 21:57 UTC
[Nouveau] [PATCH 3/3] drm/nouveau: Unregister switcheroo client on exit
Currently nouveau only registers as a vga_switcheroo client, but never unregisters. This patch adds the necessary unregister calls. --- drivers/gpu/drm/nouveau/nouveau_state.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index 9da6a74..2e11361 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c @@ -912,6 +912,7 @@ out_bios: out_display_early: engine->display.late_takedown(dev); out: + vga_switcheroo_unregister_client(dev->pdev); vga_client_register(dev->pdev, NULL, NULL, NULL); return ret; } @@ -969,6 +970,7 @@ static void nouveau_card_takedown(struct drm_device *dev) nouveau_irq_fini(dev); + vga_switcheroo_unregister_client(dev->pdev); vga_client_register(dev->pdev, NULL, NULL, NULL); } -- 1.7.9.1