Skip to contentSkip to conversation

Revert "drm/msm: dpu: Add modeset lock checks where applicable"

PATCH In review Sean Paul 2 participants 4 messages Oct 10, 2019 – Oct 11, 2019 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Sean Paul

author
#0 lore raw

PATCH 1/1 Revert "drm/msm: dpu: Add modeset lock checks where applicable"

From: Sean Paul <[email protected]>

This reverts commit 1dfdb0e107dbe6ebff3f6bbbe4aad0b5aa87bba4.

As Daniel mentions in his email [1], non-blocking commits don't hold the modeset locks, so we can safely access state as long as these functions are in the commit path. I'm not entirely sure if these have always been isolated to the commit path, but they seem to be now.

[1]- https://lists.freedesktop.org/archives/dri-devel/2019-October/239441.html

Fixes 1dfdb0e107db ("drm/msm: dpu: Add modeset lock checks where applicable")
Cc Jeykumar Sankaran <[email protected]>
Cc Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 --
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 -
 2 files changed, 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +0 -2
index db6c9ccf3be26..c645dd201368b 100644
@@ -282,8 +282,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
 		return INTF_MODE_NONE;
 	}
 
-	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
-
 	/* TODO: Returns the first INTF_MODE, could there be multiple values? */
 	drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
 		return dpu_encoder_get_intf_mode(encoder);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
index e393a423d7d7a..0e68e20d19c87 100644
@@ -305,7 +305,6 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
 	if (funcs && funcs->commit)
 		funcs->commit(encoder);
 
-	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
 	drm_for_each_crtc(crtc, dev) {
 		if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
 			continue;
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20191010151351.126735-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 27 lines · Sean Paul

From: Sean Paul <[email protected]>

This reverts commit 1dfdb0e107dbe6ebff3f6bbbe4aad0b5aa87bba4.

As Daniel mentions in his email [1], non-blocking commits don't hold the modeset locks, so we can safely access state as long as these functions are in the commit path. I'm not entirely sure if these have always been isolated to the commit path, but they seem to be now.

[1]- https://lists.freedesktop.org/archives/dri-devel/2019-October/239441.html

Fixes 1dfdb0e107db ("drm/msm: dpu: Add modeset lock checks where applicable")
Cc Jeykumar Sankaran <[email protected]>
Cc Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 --
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 -
 2 files changed, 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +0 -0
index db6c9ccf3be26..c645dd201368b 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc) · line 285

Quoted 4 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +0 -1
@@ -282,8 +282,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
                return INTF_MODE_NONE;
        }
 
-       WARN_ON(!drm_modeset_is_locked(&crtc->mutex));

This one is worse ... it's used in two places:
- debugfs, where you actually want to make sure you're holding this lock
- atomic_check, where this is broken since you're supposed to look at the free-standing states only, except if you really know what you're doing. Given that there's no comment here, I suspect that's not the case. Note that for atomic_check you're guaranteed to hold the modeset lock.

I'd put a FIXME here, but leave the WARN_ON until this is fixed properly.

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c void dpu_kms_encoder_enable(struct drm_encoder *encoder) · line 308

Quoted 13 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +0 -1
-
        /* TODO: Returns the first INTF_MODE, could there be multiple values? */
        drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
                return dpu_encoder_get_intf_mode(encoder);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
index e393a423d7d7a..0e68e20d19c87 100644
@@ -305,7 +305,6 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
        if (funcs && funcs->commit)
                funcs->commit(encoder);
 
-       WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));

but only for this hunk here.
-Daniel

Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
        drm_for_each_crtc(crtc, dev) {
                if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
                        continue;
--

Sean Paul, Software Engineer, Google / Chromium OS

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): CAKMK7uF2HsM5WrC5j_WNXWDjkXTyK5tP2DuoRt78FeaL5791QA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#4 lore raw

PATCH v2 1/1 drm/msm: Sanitize the modeset_is_locked checks in dpu

From: Sean Paul <[email protected]>

As Daniel mentions in his email [1], non-blocking commits don't hold the modeset locks, so we can safely access state as long as these functions are in the commit path. So remove the WARN_ON in dpu_kms_encoder_enable.

In dpu_crtc_get_intf_mode, things are a bit more complicated. So keep the WARN_ON, but add a comment explaining the situation and hope someone comes along and fixes the issue.

[1]- https://lists.freedesktop.org/archives/dri-devel/2019-October/239441.html

Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]

Changes in v2:
- Restored the WARN_ON in get_intf_mode and added a clarifying comment (Daniel)

Fixes 1dfdb0e107db ("drm/msm: dpu: Add modeset lock checks where applicable")
Cc Jeykumar Sankaran <[email protected]>
Cc Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 9 +++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 -
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +9 -0
index 0b9dc042d2e22..f197dce545761 100644
@@ -271,6 +271,15 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
 		return INTF_MODE_NONE;
 	}
 
+	/*
+	 * TODO: This function is called from dpu debugfs and as part of atomic
+	 * check. When called from debugfs, the crtc->mutex must be held to
+	 * read crtc->state. However reading crtc->state from atomic check isn't
+	 * allowed (unless you have a good reason, a big comment, and a deep
+	 * understanding of how the atomic/modeset locks work (<- and this is
+	 * probably not possible)). So we'll keep the WARN_ON here for now, but
+	 * really we need to figure out a better way to track our operating mode
+	 */
 	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
 
 	/* TODO: Returns the first INTF_MODE, could there be multiple values? */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
index b1645ad83a1e1..6c92f0fbeac98 100644
@@ -316,7 +316,6 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
 	if (funcs && funcs->commit)
 		funcs->commit(encoder);
 
-	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
 	drm_for_each_crtc(crtc, dev) {
 		if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
 			continue;
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20191010181801.186069-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org

author Applied
#6 lore raw

Re: [PATCH v2] drm/msm: Sanitize the modeset_is_locked checks in dpu

Quoted 14 lines · Sean Paul

From: Sean Paul <[email protected]>

As Daniel mentions in his email [1], non-blocking commits don't hold the modeset locks, so we can safely access state as long as these functions are in the commit path. So remove the WARN_ON in dpu_kms_encoder_enable.

In dpu_crtc_get_intf_mode, things are a bit more complicated. So keep the WARN_ON, but add a comment explaining the situation and hope someone comes along and fixes the issue.

[1]- https://lists.freedesktop.org/archives/dri-devel/2019-October/239441.html

Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]

Quoted 8 lines

Changes in v2:
- Restored the WARN_ON in get_intf_mode and added a clarifying comment (Daniel)

Fixes 1dfdb0e107db ("drm/msm: dpu: Add modeset lock checks where applicable")
Cc Jeykumar Sankaran <[email protected]>
Cc Rob Clark <[email protected]>

Applied to msm-next with danvet's full irc r-b, thanks for the report and review!

Sean

Quoted 41 lines
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 9 +++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 -
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +9 -0
index 0b9dc042d2e22..f197dce545761 100644
@@ -271,6 +271,15 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
 		return INTF_MODE_NONE;
 	}
 
+	/*
+	 * TODO: This function is called from dpu debugfs and as part of atomic
+	 * check. When called from debugfs, the crtc->mutex must be held to
+	 * read crtc->state. However reading crtc->state from atomic check isn't
+	 * allowed (unless you have a good reason, a big comment, and a deep
+	 * understanding of how the atomic/modeset locks work (<- and this is
+	 * probably not possible)). So we'll keep the WARN_ON here for now, but
+	 * really we need to figure out a better way to track our operating mode
+	 */
 	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
 
 	/* TODO: Returns the first INTF_MODE, could there be multiple values? */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -1
index b1645ad83a1e1..6c92f0fbeac98 100644
@@ -316,7 +316,6 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
 	if (funcs && funcs->commit)
 		funcs->commit(encoder);
 
-	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
 	drm_for_each_crtc(crtc, dev) {
 		if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
 			continue;
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno