drm/radeon: Only call drm_vblank_on/off between drm_vblank_init/cleanup
diff mbox

Message ID 1459499324-26271-1-git-send-email-michel@daenzer.net
State New
Headers show

Commit Message

Michel Dänzer April 1, 2016, 8:28 a.m. UTC
From: Michel Dänzer <michel.daenzer@amd.com>

Prevents the

	if (WARN_ON(pipe >= dev->num_crtcs))

in drm_vblank_on/off from triggering if acceleration fails to
initialize, in which case we call drm_vblank_cleanup.

Reported-and-Tested-by: Julian Margetson <runaway@candw.ms>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/radeon/atombios_crtc.c      | 6 ++++--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

Comments

Alex Deucher April 1, 2016, 2:10 p.m. UTC | #1
On Fri, Apr 1, 2016 at 4:28 AM, Michel Dänzer <michel@daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> Prevents the
>
>         if (WARN_ON(pipe >= dev->num_crtcs))
>
> in drm_vblank_on/off from triggering if acceleration fails to
> initialize, in which case we call drm_vblank_cleanup.
>
> Reported-and-Tested-by: Julian Margetson <runaway@candw.ms>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Applied.  Thanks!

Alex


> ---
>  drivers/gpu/drm/radeon/atombios_crtc.c      | 6 ++++--
>  drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 6 ++++--
>  2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
> index cf61e08..b80b08f 100644
> --- a/drivers/gpu/drm/radeon/atombios_crtc.c
> +++ b/drivers/gpu/drm/radeon/atombios_crtc.c
> @@ -275,13 +275,15 @@ void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
>                 if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
>                         atombios_enable_crtc_memreq(crtc, ATOM_ENABLE);
>                 atombios_blank_crtc(crtc, ATOM_DISABLE);
> -               drm_vblank_on(dev, radeon_crtc->crtc_id);
> +               if (dev->num_crtcs > radeon_crtc->crtc_id)
> +                       drm_vblank_on(dev, radeon_crtc->crtc_id);
>                 radeon_crtc_load_lut(crtc);
>                 break;
>         case DRM_MODE_DPMS_STANDBY:
>         case DRM_MODE_DPMS_SUSPEND:
>         case DRM_MODE_DPMS_OFF:
> -               drm_vblank_off(dev, radeon_crtc->crtc_id);
> +               if (dev->num_crtcs > radeon_crtc->crtc_id)
> +                       drm_vblank_off(dev, radeon_crtc->crtc_id);
>                 if (radeon_crtc->enabled)
>                         atombios_blank_crtc(crtc, ATOM_ENABLE);
>                 if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
> diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
> index 24152df..478d409 100644
> --- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
> +++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
> @@ -331,13 +331,15 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
>                                                                          RADEON_CRTC_DISP_REQ_EN_B));
>                         WREG32_P(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl, ~(mask | crtc_ext_cntl));
>                 }
> -               drm_vblank_on(dev, radeon_crtc->crtc_id);
> +               if (dev->num_crtcs > radeon_crtc->crtc_id)
> +                       drm_vblank_on(dev, radeon_crtc->crtc_id);
>                 radeon_crtc_load_lut(crtc);
>                 break;
>         case DRM_MODE_DPMS_STANDBY:
>         case DRM_MODE_DPMS_SUSPEND:
>         case DRM_MODE_DPMS_OFF:
> -               drm_vblank_off(dev, radeon_crtc->crtc_id);
> +               if (dev->num_crtcs > radeon_crtc->crtc_id)
> +                       drm_vblank_off(dev, radeon_crtc->crtc_id);
>                 if (radeon_crtc->crtc_id)
>                         WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~(RADEON_CRTC2_EN | mask));
>                 else {
> --
> 2.8.0.rc3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index cf61e08..b80b08f 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -275,13 +275,15 @@  void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
 		if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
 			atombios_enable_crtc_memreq(crtc, ATOM_ENABLE);
 		atombios_blank_crtc(crtc, ATOM_DISABLE);
-		drm_vblank_on(dev, radeon_crtc->crtc_id);
+		if (dev->num_crtcs > radeon_crtc->crtc_id)
+			drm_vblank_on(dev, radeon_crtc->crtc_id);
 		radeon_crtc_load_lut(crtc);
 		break;
 	case DRM_MODE_DPMS_STANDBY:
 	case DRM_MODE_DPMS_SUSPEND:
 	case DRM_MODE_DPMS_OFF:
-		drm_vblank_off(dev, radeon_crtc->crtc_id);
+		if (dev->num_crtcs > radeon_crtc->crtc_id)
+			drm_vblank_off(dev, radeon_crtc->crtc_id);
 		if (radeon_crtc->enabled)
 			atombios_blank_crtc(crtc, ATOM_ENABLE);
 		if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 24152df..478d409 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -331,13 +331,15 @@  static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
 									 RADEON_CRTC_DISP_REQ_EN_B));
 			WREG32_P(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl, ~(mask | crtc_ext_cntl));
 		}
-		drm_vblank_on(dev, radeon_crtc->crtc_id);
+		if (dev->num_crtcs > radeon_crtc->crtc_id)
+			drm_vblank_on(dev, radeon_crtc->crtc_id);
 		radeon_crtc_load_lut(crtc);
 		break;
 	case DRM_MODE_DPMS_STANDBY:
 	case DRM_MODE_DPMS_SUSPEND:
 	case DRM_MODE_DPMS_OFF:
-		drm_vblank_off(dev, radeon_crtc->crtc_id);
+		if (dev->num_crtcs > radeon_crtc->crtc_id)
+			drm_vblank_off(dev, radeon_crtc->crtc_id);
 		if (radeon_crtc->crtc_id)
 			WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~(RADEON_CRTC2_EN | mask));
 		else {