Skip to contentSkip to conversation

vgaswitcheroo: add vga_switcheroo_fini_domain_pm_ops

PATCH In review Alex Deucher 1 participant 4 messages Sep 14, 2014 – Sep 18, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 vgaswitcheroo: add vga_switcheroo_fini_domain_pm_ops

Drivers should call this on unload to unregister pmops.

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

---
 drivers/gpu/vga/vga_switcheroo.c | 6 ++++++
 include/linux/vga_switcheroo.h   | 2 ++
 2 files changed, 8 insertions(+)
drivers/gpu/vga/vga_switcheroo.c +6 -0
index 6866448..37ac7b5 100644
@@ -660,6 +660,12 @@ int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *
 }
 EXPORT_SYMBOL(vga_switcheroo_init_domain_pm_ops);
 
+void vga_switcheroo_fini_domain_pm_ops(struct device *dev)
+{
+	dev->pm_domain = NULL;
+}
+EXPORT_SYMBOL(vga_switcheroo_fini_domain_pm_ops);
+
 static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
include/linux/vga_switcheroo.h +2 -0
index 502073a..b483abd 100644
@@ -64,6 +64,7 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
 
 int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
+void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
 int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
 #else
 
@@ -82,6 +83,7 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
 
 static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
+static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
 static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
 
 #endif
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/3 drm/radeon/px: fix module unload

Use the new vga_switcheroo_fini_domain_pm_ops function to unregister the pm ops.

Based on a patch from:
Pali Rohár <[email protected]>

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

---
 drivers/gpu/drm/radeon/radeon_device.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +9 -2
index 6a219bc..75223dd 100644
@@ -1393,7 +1393,7 @@ int radeon_device_init(struct radeon_device *rdev,
 
 	r = radeon_init(rdev);
 	if (r)
-		return r;
+		goto failed;
 
 	r = radeon_ib_ring_tests(rdev);
 	if (r)
@@ -1413,7 +1413,7 @@ int radeon_device_init(struct radeon_device *rdev,
 		radeon_agp_disable(rdev);
 		r = radeon_init(rdev);
 		if (r)
-			return r;
+			goto failed;
 	}
 
 	if ((radeon_testing & 1)) {
@@ -1435,6 +1435,11 @@ int radeon_device_init(struct radeon_device *rdev,
 			DRM_INFO("radeon: acceleration disabled, skipping benchmarks\n");
 	}
 	return 0;
+
+failed:
+	if (runtime)
+		vga_switcheroo_fini_domain_pm_ops(rdev->dev);
+	return r;
 }
 
 static void radeon_debugfs_remove_files(struct radeon_device *rdev);
@@ -1455,6 +1460,8 @@ void radeon_device_fini(struct radeon_device *rdev)
 	radeon_bo_evict_vram(rdev);
 	radeon_fini(rdev);
 	vga_switcheroo_unregister_client(rdev->pdev);
+	if (rdev->flags & RADEON_IS_PX)
+		vga_switcheroo_fini_domain_pm_ops(rdev->dev);
 	vga_client_register(rdev->pdev, NULL, NULL, NULL);
 	if (rdev->rio_mem)
 		pci_iounmap(rdev->pdev, rdev->rio_mem);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 3/3 drm/nouveau/runpm: fix module unload

In reply to Alex Deucher

Use the new vga_switcheroo_fini_domain_pm_ops function to unregister the pm ops.

Based on a patch from:
Pali Rohár <[email protected]>

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

---
 drivers/gpu/drm/nouveau/nouveau_vga.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/nouveau/nouveau_vga.c +9 -0
index 18d55d4..c7592ec 100644
@@ -108,7 +108,16 @@ void
 nouveau_vga_fini(struct nouveau_drm *drm)
 {
 	struct drm_device *dev = drm->dev;
+	bool runtime = false;
+
+	if (nouveau_runtime_pm == 1)
+		runtime = true;
+	if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
+		runtime = true;
+
 	vga_switcheroo_unregister_client(dev->pdev);
+	if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
+		vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);
 	vga_client_register(dev->pdev, NULL, NULL, NULL);
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH 3/3] drm/nouveau/runpm: fix module unload

Quoted 6 lines · Alex Deucher

Use the new vga_switcheroo_fini_domain_pm_ops function to unregister the pm ops.

Based on a patch from:
Pali Rohár <[email protected]>

Quoted 6 lines

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

Dave or Ben any comment on this patch? I'd like the merge the radeon parts for -fixes and this one seems logic too.

Alex

Quoted 26 lines
---
 drivers/gpu/drm/nouveau/nouveau_vga.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/nouveau/nouveau_vga.c +9 -1
index 18d55d4..c7592ec 100644
@@ -108,7 +108,16 @@ void
 nouveau_vga_fini(struct nouveau_drm *drm)
 {
        struct drm_device *dev = drm->dev;
+       bool runtime = false;
+
+       if (nouveau_runtime_pm == 1)
+               runtime = true;
+       if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
+               runtime = true;
+
        vga_switcheroo_unregister_client(dev->pdev);
+       if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
+               vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);
        vga_client_register(dev->pdev, NULL, NULL, NULL);
 }
 
--
Quoted 2 lines

1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel