Skip to content

Commit 7fb363c

Browse files
leo-sunli1alexdeucher
authored andcommitted
drm/amd/display: Let drm_crtc_vblank_on/off manage interrupts
[Why] We manage interrupts for CRTCs in two places: 1. In manage_dm_interrupts(), when CRTC get enabled or disabled 2. When drm_vblank_get/put() starts or kills the vblank counter, calling into amdgpu_dm_crtc_set_vblank() The interrupts managed by these twp places should be identical. [How] Since manage_dm_interrupts() already use drm_crtc_vblank_on/off(), just move all CRTC interrupt management into amdgpu_dm_crtc_set_vblank(). This has the added benefit of disabling all CRTC and HUBP interrupts when there are no vblank requestors. Note that there is a TODO item - unchanged from when it was first introduced - to properly identify the HUBP instance from the OTG instance, rather than just assume direct mapping. Signed-off-by: Leo Li <[email protected]> Reviewed-by: Aurabindo Pillai <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f9e6759 commit 7fb363c

File tree

2 files changed

+47
-37
lines changed

2 files changed

+47
-37
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8246,42 +8246,10 @@ static void manage_dm_interrupts(struct amdgpu_device *adev,
82468246
struct amdgpu_crtc *acrtc,
82478247
bool enable)
82488248
{
8249-
/*
8250-
* We have no guarantee that the frontend index maps to the same
8251-
* backend index - some even map to more than one.
8252-
*
8253-
* TODO: Use a different interrupt or check DC itself for the mapping.
8254-
*/
8255-
int irq_type =
8256-
amdgpu_display_crtc_idx_to_irq_type(
8257-
adev,
8258-
acrtc->crtc_id);
8259-
8260-
if (enable) {
8249+
if (enable)
82618250
drm_crtc_vblank_on(&acrtc->base);
8262-
amdgpu_irq_get(
8263-
adev,
8264-
&adev->pageflip_irq,
8265-
irq_type);
8266-
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
8267-
amdgpu_irq_get(
8268-
adev,
8269-
&adev->vline0_irq,
8270-
irq_type);
8271-
#endif
8272-
} else {
8273-
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
8274-
amdgpu_irq_put(
8275-
adev,
8276-
&adev->vline0_irq,
8277-
irq_type);
8278-
#endif
8279-
amdgpu_irq_put(
8280-
adev,
8281-
&adev->pageflip_irq,
8282-
irq_type);
8251+
else
82838252
drm_crtc_vblank_off(&acrtc->base);
8284-
}
82858253
}
82868254

82878255
static void dm_update_pflip_irq_state(struct amdgpu_device *adev,

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,14 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)
286286
struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
287287
struct amdgpu_display_manager *dm = &adev->dm;
288288
struct vblank_control_work *work;
289+
int irq_type;
289290
int rc = 0;
290291

291292
if (acrtc->otg_inst == -1)
292293
goto skip;
293294

295+
irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, acrtc->crtc_id);
296+
294297
if (enable) {
295298
/* vblank irq on -> Only need vupdate irq in vrr mode */
296299
if (amdgpu_dm_crtc_vrr_active(acrtc_state))
@@ -303,13 +306,52 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)
303306
if (rc)
304307
return rc;
305308

306-
rc = (enable)
307-
? amdgpu_irq_get(adev, &adev->crtc_irq, acrtc->crtc_id)
308-
: amdgpu_irq_put(adev, &adev->crtc_irq, acrtc->crtc_id);
309+
/* crtc vblank or vstartup interrupt */
310+
if (enable) {
311+
rc = amdgpu_irq_get(adev, &adev->crtc_irq, irq_type);
312+
drm_dbg_vbl(crtc->dev, "Get crtc_irq ret=%d\n", rc);
313+
} else {
314+
rc = amdgpu_irq_put(adev, &adev->crtc_irq, irq_type);
315+
drm_dbg_vbl(crtc->dev, "Put crtc_irq ret=%d\n", rc);
316+
}
309317

310318
if (rc)
311319
return rc;
312320

321+
/*
322+
* hubp surface flip interrupt
323+
*
324+
* We have no guarantee that the frontend index maps to the same
325+
* backend index - some even map to more than one.
326+
*
327+
* TODO: Use a different interrupt or check DC itself for the mapping.
328+
*/
329+
if (enable) {
330+
rc = amdgpu_irq_get(adev, &adev->pageflip_irq, irq_type);
331+
drm_dbg_vbl(crtc->dev, "Get pageflip_irq ret=%d\n", rc);
332+
} else {
333+
rc = amdgpu_irq_put(adev, &adev->pageflip_irq, irq_type);
334+
drm_dbg_vbl(crtc->dev, "Put pageflip_irq ret=%d\n", rc);
335+
}
336+
337+
if (rc)
338+
return rc;
339+
340+
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
341+
/* crtc vline0 interrupt, only available on DCN+ */
342+
if (amdgpu_ip_version(adev, DCE_HWIP, 0) != 0) {
343+
if (enable) {
344+
rc = amdgpu_irq_get(adev, &adev->vline0_irq, irq_type);
345+
drm_dbg_vbl(crtc->dev, "Get vline0_irq ret=%d\n", rc);
346+
} else {
347+
rc = amdgpu_irq_put(adev, &adev->vline0_irq, irq_type);
348+
drm_dbg_vbl(crtc->dev, "Put vline0_irq ret=%d\n", rc);
349+
}
350+
351+
if (rc)
352+
return rc;
353+
}
354+
#endif
313355
skip:
314356
if (amdgpu_in_reset(adev))
315357
return 0;

0 commit comments

Comments
 (0)