From 01581ff3bff3838bf9240003704d5240911cf2ff Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 7 Dec 2016 15:17:34 -0500 Subject: [PATCH] drm/amdgpu: use drm_unplug_dev for pci shutdown drm_unplug_dev will not call drm_dev_unref via drm_dev_put unless the open_count is 0. Based on a patch from: Hongbo He Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98638 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97980 Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 7914f99..284f406 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -486,12 +486,14 @@ amdgpu_pci_remove(struct pci_dev *pdev) static void amdgpu_pci_shutdown(struct pci_dev *pdev) { + struct drm_device *dev = pci_get_drvdata(pdev); /* if we are running in a VM, make sure the device * torn down properly on reboot/shutdown. * unfortunately we can't detect certain * hypervisors so just do this all the time. */ - amdgpu_pci_remove(pdev); + if (!drm_device_is_unplugged(dev)) + drm_unplug_dev(dev); } static int amdgpu_pmops_suspend(struct device *dev) -- 2.5.5