Skip to contentSkip to conversation

drm/amd/display: check plane state before validating fbc

PATCH In review S, Shirish 3 participants 8 messages Nov 22, 2017 – Nov 27, 2017 8 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 1511334698-5752-1-git-send-email-shirish.s12-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

S, Shirish

author
#2 lore raw

PATCH 1/1 drm/amd/display: check plane state before validating fbc

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +4 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
 	if (pipe_ctx->stream->sink->link->psr_enabled)
 		return DC_ERROR_UNEXPECTED;
 
+	/* Nothing to compress */
+	if (!pipe_ctx->plane_state)
+		return DC_ERROR_UNEXPECTED;
+
 	/* Only for non-linear tiling */
 	if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
 		return DC_ERROR_UNEXPECTED;

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB182648D32C4125E3124C7C8AF2200-/b2+HYfkarSCndJ3FSsNdQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

Reviewed-by
#4 lore raw
Quoted 10 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

Harry

Quoted 22 lines
---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +4 -1
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
 	if (pipe_ctx->stream->sink->link->psr_enabled)
 		return DC_ERROR_UNEXPECTED;
 
+	/* Nothing to compress */
+	if (!pipe_ctx->plane_state)
+		return DC_ERROR_UNEXPECTED;
+
 	/* Only for non-linear tiling */
 	if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
 		return DC_ERROR_UNEXPECTED;
--

2.7.4

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
In reply to a message not in the archive

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Thanks,
Andrey

Quoted 32 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +4 -1
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
  	if (pipe_ctx->stream->sink->link->psr_enabled)
  		return DC_ERROR_UNEXPECTED;
 
+	/* Nothing to compress */
+	if (!pipe_ctx->plane_state)
+		return DC_ERROR_UNEXPECTED;
+
  	/* Only for non-linear tiling */
  	if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
  		return DC_ERROR_UNEXPECTED;
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): c8ca42f2-1237-d13c-ad30-dd42a5d850f2-5C7GfCeVMHo@public.gmane.org

#7 lore raw
Quoted 2 lines · Andrey Grodzovsky

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Ideally yes, but I don't think this has any impact on bandwidth and mode validation, i.e. we should never fail to apply an atomic state, no matter whether we do FBC. If we let user-mode decide whether to do FBC or not it would need to be a property and check in atomic_check but I don't think it makes any sense to expose this outside DC.

Harry

Quoted 35 lines

Thanks,
Andrey

Quoted 31 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
  drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++

  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
       if (pipe_ctx->stream->sink->link->psr_enabled)
           return DC_ERROR_UNEXPECTED;

  +    /* Nothing to compress */
+    if (!pipe_ctx->plane_state)
+        return DC_ERROR_UNEXPECTED;
+
      /* Only for non-linear tiling */
      if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL) return DC_ERROR_UNEXPECTED;

Signature · 1 line
2.7.4
Quoted 5 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 6e85fe6c-ff85-cf10-be5b-a6f411f8b83d-5C7GfCeVMHo@public.gmane.org

#9 lore raw
Quoted 6 lines · Harry Wentland
Quoted 2 lines · Andrey Grodzovsky

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Ideally yes, but I don't think this has any impact on bandwidth and mode validation, i.e. we should never fail to apply an atomic state, no matter whether we do FBC. If we let user-mode decide whether to do FBC or not it would need to be a property and check in atomic_check but I don't think it makes any sense to expose this outside DC.

Harry

I see, as long as enable_fbc return code is ignored as it is today that ok.

Thanks,
Andrey

Quoted 36 lines
Quoted 36 lines

Thanks,
Andrey

Quoted 31 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
   drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++
   1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +3 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
       if (pipe_ctx->stream->sink->link->psr_enabled)
           return DC_ERROR_UNEXPECTED;
   +    /* Nothing to compress */
+    if (!pipe_ctx->plane_state)
+        return DC_ERROR_UNEXPECTED;
+
       /* Only for non-linear tiling */
       if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
           return DC_ERROR_UNEXPECTED;
Signature · 1 line
2.7.4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 6ac8f56c-8782-901a-35f9-d54fac563000-5C7GfCeVMHo@public.gmane.org

#11 lore raw
Quoted 12 lines · Andrey Grodzovsky
Quoted 6 lines · Harry Wentland
Quoted 2 lines · Andrey Grodzovsky

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Ideally yes, but I don't think this has any impact on bandwidth and mode validation, i.e. we should never fail to apply an atomic state, no matter whether we do FBC. If we let user-mode decide whether to do FBC or not it would need to be a property and check in atomic_check but I don't think it makes any sense to expose this outside DC.

Harry

I see, as long as enable_fbc return code is ignored as it is today that ok.

Maybe we just shouldn't return an error code here. dce110_apply_ctx_to_hw probably shouldn't return one either then, and apply_single_controller_ctx_to_hw_plane (just a couple lines before enable_fbc) shouldn't fail. I might have to look at those sometime.

Harry

Quoted 39 lines

Thanks,
Andrey

Quoted 36 lines
Quoted 36 lines

Thanks,
Andrey

Quoted 31 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
   drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++

   1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
        if (pipe_ctx->stream->sink->link->psr_enabled)
            return DC_ERROR_UNEXPECTED;

   +    /* Nothing to compress */
+    if (!pipe_ctx->plane_state)
+        return DC_ERROR_UNEXPECTED;
+
       /* Only for non-linear tiling */
       if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL) return DC_ERROR_UNEXPECTED;
--
2.7.4

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a33f198c-10fc-4976-67f3-5243029da52c-5C7GfCeVMHo@public.gmane.org

#13 lore raw
Quoted 7 lines · Harry Wentland
Quoted 5 lines · Andrey Grodzovsky
Quoted 3 lines · Harry Wentland
Quoted 2 lines · Andrey Grodzovsky

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Ideally yes, but I don't think this has any impact on bandwidth and mode validation, i.e. we should never fail to apply an atomic state, no matter whether we do FBC. If we let user-mode decide whether to do FBC or not it would need to be a property and check in atomic_check but I don't think it makes any sense to expose this outside DC.

Harry

I see, as long as enable_fbc return code is ignored as it is today that ok.

Maybe we just shouldn't return an error code here. dce110_apply_ctx_to_hw probably shouldn't return one either then, and apply_single_controller_ctx_to_hw_plane (just a couple lines before enable_fbc) shouldn't fail. I might have to look at those sometime.

Harry

Well, it seems wrong to have a validation function which never fails or it's return value ignored, maybe just merge validate_fbc into enable_fbc , drop all the error codes and rename enable_fbc into try_enable_fbc

Thanks,
Andrey

Quoted 39 lines
Quoted 39 lines

Thanks,
Andrey

Quoted 35 lines
Quoted 35 lines

Thanks,
Andrey

Quoted 31 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
    drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++
    1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +3 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
        if (pipe_ctx->stream->sink->link->psr_enabled)
            return DC_ERROR_UNEXPECTED;
    +    /* Nothing to compress */
+    if (!pipe_ctx->plane_state)
+        return DC_ERROR_UNEXPECTED;
+
        /* Only for non-linear tiling */
        if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
            return DC_ERROR_UNEXPECTED;
Signature · 1 line
2.7.4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 80a8e63b-6b84-c880-ba96-58534d3fff44-5C7GfCeVMHo@public.gmane.org

#15 lore raw
Quoted 12 lines · Andrey Grodzovsky
Quoted 9 lines · Harry Wentland
Quoted 7 lines · Andrey Grodzovsky
Quoted 5 lines · Harry Wentland
Quoted 2 lines · Andrey Grodzovsky

The patch is good, but why validate_fbc is being called from dce110_apply_ctx_to_hw (atomic_commit) ? It should be called from atomic_check.

Ideally yes, but I don't think this has any impact on bandwidth and mode validation, i.e. we should never fail to apply an atomic state, no matter whether we do FBC. If we let user-mode decide whether to do FBC or not it would need to be a property and check in atomic_check but I don't think it makes any sense to expose this outside DC.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Harry

I see, as long as enable_fbc return code is ignored as it is today that ok.

Maybe we just shouldn't return an error code here. dce110_apply_ctx_to_hw probably shouldn't return one either then, and apply_single_controller_ctx_to_hw_plane (just a couple lines before enable_fbc) shouldn't fail. I might have to look at those sometime.

Harry

Well, it seems wrong to have a validation function which never fails or it's return value ignored, maybe just merge validate_fbc into enable_fbc , drop all the error codes and rename enable_fbc into try_enable_fbc

This function just seems to mislabeled. decide_fbc might be better. It's only called from enable_fbc to decide whether or not to do FBC.

Roma, would it make sense to rename this function to avoid confusion?

Harry

Quoted 43 lines

Thanks,
Andrey

Quoted 39 lines
Quoted 39 lines

Thanks,
Andrey

Quoted 35 lines
Quoted 35 lines

Thanks,
Andrey

Quoted 31 lines · Shirish

From: Shirish S <[email protected]>

While validation fbc, array_mode of the pipe is accessed without checking plane_state exists for it. Causing to null pointer dereferencing followed by reboot when a crtc associated with external display(not connected) is page flipped.

This patch adds a check for plane_state before using it to validate fbc.

---
    drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 ++++

    1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +0 -0
index ee3b944..a6cd63a 100644
@@ -1724,6 +1724,10 @@ static enum dc_status validate_fbc(struct dc *dc,
         if (pipe_ctx->stream->sink->link->psr_enabled)
             return DC_ERROR_UNEXPECTED;

    +    /* Nothing to compress */
+    if (!pipe_ctx->plane_state)
+        return DC_ERROR_UNEXPECTED;
+
        /* Only for non-linear tiling */
        if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL) return DC_ERROR_UNEXPECTED;
--
2.7.4

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx