Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adbbdbac authored by Dave Airlie's avatar Dave Airlie
Browse files

drm/nouveau: fail runtime pm properly.



If we were on a non-optimus device, we'd return -EINVAL, this would
lead to the over engineered runtime pm system to go into an error
state, subsequent get_sync's would fail, so we'd never be able
to open the device again.

(like really get_sync shouldn't fail if the device isn't powered
down).

Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 347cf10a
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -866,13 +866,16 @@ static int nouveau_pmops_runtime_suspend(struct device *dev)
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
	int ret;
	int ret;


	if (nouveau_runtime_pm == 0)
	if (nouveau_runtime_pm == 0) {
		return -EINVAL;
		pm_runtime_forbid(dev);
		return -EBUSY;
	}


	/* are we optimus enabled? */
	/* are we optimus enabled? */
	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
		return -EINVAL;
		pm_runtime_forbid(dev);
		return -EBUSY;
	}
	}


	nv_debug_level(SILENT);
	nv_debug_level(SILENT);
@@ -923,12 +926,15 @@ static int nouveau_pmops_runtime_idle(struct device *dev)
	struct nouveau_drm *drm = nouveau_drm(drm_dev);
	struct nouveau_drm *drm = nouveau_drm(drm_dev);
	struct drm_crtc *crtc;
	struct drm_crtc *crtc;


	if (nouveau_runtime_pm == 0)
	if (nouveau_runtime_pm == 0) {
		pm_runtime_forbid(dev);
		return -EBUSY;
		return -EBUSY;
	}


	/* are we optimus enabled? */
	/* are we optimus enabled? */
	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
		pm_runtime_forbid(dev);
		return -EBUSY;
		return -EBUSY;
	}
	}