From 02969dd0630ea32ca87156c8b0906f16654e9b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Sat, 14 Sep 2013 17:24:41 +0000 Subject: [PATCH] drm/radeon: Fix usage of pci_save_state() and pci_restore_state() Calling those functions with the drmn device as argument causes a panic, because it's not a direct child of pci$N. They must be called with the vgapci device instead. This fix is not enough to make suspend/resume work reliably. Approved by: re (blanket) --- sys/dev/drm2/radeon/r100.c | 4 ++-- sys/dev/drm2/radeon/r300.c | 4 ++-- sys/dev/drm2/radeon/radeon_device.c | 4 ++-- sys/dev/drm2/radeon/rs600.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/dev/drm2/radeon/r100.c b/sys/dev/drm2/radeon/r100.c index 595f9221ba0..a66c7c2418b 100644 --- a/sys/dev/drm2/radeon/r100.c +++ b/sys/dev/drm2/radeon/r100.c @@ -2647,7 +2647,7 @@ int r100_asic_reset(struct radeon_device *rdev) WREG32(RADEON_CP_RB_WPTR, 0); WREG32(RADEON_CP_RB_CNTL, tmp); /* save PCI state */ - pci_save_state(rdev->dev); + pci_save_state(device_get_parent(rdev->dev)); /* disable bus mastering */ r100_bm_disable(rdev); WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_SE(1) | @@ -2669,7 +2669,7 @@ int r100_asic_reset(struct radeon_device *rdev) status = RREG32(R_000E40_RBBM_STATUS); dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); /* restore PCI & busmastering */ - pci_restore_state(rdev->dev); + pci_restore_state(device_get_parent(rdev->dev)); r100_enable_bm(rdev); /* Check if GPU is idle */ if (G_000E40_SE_BUSY(status) || G_000E40_RE_BUSY(status) || diff --git a/sys/dev/drm2/radeon/r300.c b/sys/dev/drm2/radeon/r300.c index b8fdefc3365..aa9073cf270 100644 --- a/sys/dev/drm2/radeon/r300.c +++ b/sys/dev/drm2/radeon/r300.c @@ -401,7 +401,7 @@ int r300_asic_reset(struct radeon_device *rdev) WREG32(RADEON_CP_RB_WPTR, 0); WREG32(RADEON_CP_RB_CNTL, tmp); /* save PCI state */ - pci_save_state(rdev->dev); + pci_save_state(device_get_parent(rdev->dev)); /* disable bus mastering */ r100_bm_disable(rdev); WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) | @@ -425,7 +425,7 @@ int r300_asic_reset(struct radeon_device *rdev) status = RREG32(R_000E40_RBBM_STATUS); dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); /* restore PCI & busmastering */ - pci_restore_state(rdev->dev); + pci_restore_state(device_get_parent(rdev->dev)); r100_enable_bm(rdev); /* Check if GPU is idle */ if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) { diff --git a/sys/dev/drm2/radeon/radeon_device.c b/sys/dev/drm2/radeon/radeon_device.c index 5ed74fdbe23..676b38aad94 100644 --- a/sys/dev/drm2/radeon/radeon_device.c +++ b/sys/dev/drm2/radeon/radeon_device.c @@ -1316,7 +1316,7 @@ int radeon_suspend_kms(struct drm_device *dev) radeon_agp_suspend(rdev); - pci_save_state(dev->device); + pci_save_state(device_get_parent(rdev->dev)); #ifdef DUMBBELL_WIP if (state.event == PM_EVENT_SUSPEND) { /* Shut down the device */ @@ -1356,7 +1356,7 @@ int radeon_resume_kms(struct drm_device *dev) console_lock(); #endif /* DUMBBELL_WIP */ pci_set_powerstate(dev->device, PCI_POWERSTATE_D0); - pci_restore_state(dev->device); + pci_restore_state(device_get_parent(rdev->dev)); #ifdef DUMBBELL_WIP if (pci_enable_device(dev->pdev)) { console_unlock(); diff --git a/sys/dev/drm2/radeon/rs600.c b/sys/dev/drm2/radeon/rs600.c index 6d3b17a495b..11edbdfc5df 100644 --- a/sys/dev/drm2/radeon/rs600.c +++ b/sys/dev/drm2/radeon/rs600.c @@ -373,7 +373,7 @@ int rs600_asic_reset(struct radeon_device *rdev) WREG32(RADEON_CP_RB_RPTR_WR, 0); WREG32(RADEON_CP_RB_WPTR, 0); WREG32(RADEON_CP_RB_CNTL, tmp); - pci_save_state(rdev->dev); + pci_save_state(device_get_parent(rdev->dev)); /* disable bus mastering */ pci_disable_busmaster(rdev->dev); DRM_MDELAY(1); @@ -403,7 +403,7 @@ int rs600_asic_reset(struct radeon_device *rdev) status = RREG32(R_000E40_RBBM_STATUS); dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); /* restore PCI & busmastering */ - pci_restore_state(rdev->dev); + pci_restore_state(device_get_parent(rdev->dev)); /* Check if GPU is idle */ if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) { dev_err(rdev->dev, "failed to reset GPU\n");