Commit 6ae6c7d4 authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu: start to disentangle boco from runtime pm

BACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off

We originally only supported runtime pm on PX/HG
laptops so most of the runtime pm code looks for this.
Add a new flag to check for runtime pm enablement and
use this rather than checking for PX/HG.
Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 19134317
...@@ -987,6 +987,8 @@ struct amdgpu_device { ...@@ -987,6 +987,8 @@ struct amdgpu_device {
/* device pstate */ /* device pstate */
int pstate; int pstate;
/* enable runtime pm on the device */
bool runpm;
}; };
static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
......
...@@ -1202,9 +1202,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ...@@ -1202,9 +1202,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
struct amdgpu_device *adev = drm_dev->dev_private;
int ret; int ret;
if (!amdgpu_device_supports_boco(drm_dev)) { if (!adev->runpm) {
pm_runtime_forbid(dev); pm_runtime_forbid(dev);
return -EBUSY; return -EBUSY;
} }
...@@ -1234,9 +1235,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) ...@@ -1234,9 +1235,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
struct amdgpu_device *adev = drm_dev->dev_private;
int ret; int ret;
if (!amdgpu_device_supports_boco(drm_dev)) if (!adev->runpm)
return -EINVAL; return -EINVAL;
if (amdgpu_device_supports_boco(drm_dev)) { if (amdgpu_device_supports_boco(drm_dev)) {
...@@ -1263,9 +1265,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) ...@@ -1263,9 +1265,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
static int amdgpu_pmops_runtime_idle(struct device *dev) static int amdgpu_pmops_runtime_idle(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_dev->dev_private;
struct drm_crtc *crtc; struct drm_crtc *crtc;
if (!amdgpu_device_supports_boco(drm_dev)) { if (!adev->runpm) {
pm_runtime_forbid(dev); pm_runtime_forbid(dev);
return -EBUSY; return -EBUSY;
} }
......
...@@ -91,7 +91,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) ...@@ -91,7 +91,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
if (amdgpu_sriov_vf(adev)) if (amdgpu_sriov_vf(adev))
amdgpu_virt_request_full_gpu(adev, false); amdgpu_virt_request_full_gpu(adev, false);
if (amdgpu_device_supports_boco(dev)) { if (adev->runpm) {
pm_runtime_get_sync(dev->dev); pm_runtime_get_sync(dev->dev);
pm_runtime_forbid(dev->dev); pm_runtime_forbid(dev->dev);
} }
...@@ -150,14 +150,17 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) ...@@ -150,14 +150,17 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
} }
dev->dev_private = (void *)adev; dev->dev_private = (void *)adev;
if ((amdgpu_runtime_pm != 0) && if (amdgpu_has_atpx() &&
amdgpu_has_atpx() &&
(amdgpu_is_atpx_hybrid() || (amdgpu_is_atpx_hybrid() ||
amdgpu_has_atpx_dgpu_power_cntl()) && amdgpu_has_atpx_dgpu_power_cntl()) &&
((flags & AMD_IS_APU) == 0) && ((flags & AMD_IS_APU) == 0) &&
!pci_is_thunderbolt_attached(dev->pdev)) !pci_is_thunderbolt_attached(dev->pdev))
flags |= AMD_IS_PX; flags |= AMD_IS_PX;
if ((amdgpu_runtime_pm != 0) &&
(flags & AMD_IS_PX))
adev->runpm = true;
/* amdgpu_device_init should report only fatal error /* amdgpu_device_init should report only fatal error
* like memory allocation failure or iomapping failure, * like memory allocation failure or iomapping failure,
* or memory manager initialization failure, it must * or memory manager initialization failure, it must
...@@ -180,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) ...@@ -180,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
"Error during ACPI methods call\n"); "Error during ACPI methods call\n");
} }
if (amdgpu_device_supports_boco(dev)) { if (adev->runpm) {
dev_pm_set_driver_flags(dev->dev, DPM_FLAG_NEVER_SKIP); dev_pm_set_driver_flags(dev->dev, DPM_FLAG_NEVER_SKIP);
pm_runtime_use_autosuspend(dev->dev); pm_runtime_use_autosuspend(dev->dev);
pm_runtime_set_autosuspend_delay(dev->dev, 5000); pm_runtime_set_autosuspend_delay(dev->dev, 5000);
...@@ -193,7 +196,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) ...@@ -193,7 +196,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
out: out:
if (r) { if (r) {
/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
if (adev->rmmio && amdgpu_device_supports_boco(dev)) if (adev->rmmio && adev->runpm)
pm_runtime_put_noidle(dev->dev); pm_runtime_put_noidle(dev->dev);
amdgpu_driver_unload_kms(dev); amdgpu_driver_unload_kms(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment