All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Always allocate initial connector state state
@ 2019-06-04 19:21 Nicholas Kazlauskas
       [not found] ` <20190604192114.20995-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Kazlauskas @ 2019-06-04 19:21 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Leo Li, Harry Wentland, Nicholas Kazlauskas, Roman Li

[Why]
Unlike our regular connectors, MST connectors don't start off with
an initial connector state. This causes a NULL pointer dereference to
occur when attaching the bpc property since it tries to modify the
connector state.

We need an initial connector state on the connector to avoid the crash.

[How]
Use our reset helper to allocate an initial state and reset the values
to their defaults. We were already doing this before, just not for
MST connectors.

Cc: Leo Li <sunpeng.li@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a698c8f272ed..4523ab100bc3 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4743,6 +4743,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 {
 	struct amdgpu_device *adev = dm->ddev->dev_private;
 
+	/*
+	 * Some of the properties below require access to state, like bpc.
+	 * Allocate some default initial connector state with our reset helper.
+	 */
+	if (aconnector->base.funcs->reset)
+		aconnector->base.funcs->reset(&aconnector->base);
+
 	aconnector->connector_id = link_index;
 	aconnector->dc_link = link;
 	aconnector->base.interlace_allowed = false;
@@ -4932,9 +4939,6 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
 			&aconnector->base,
 			&amdgpu_dm_connector_helper_funcs);
 
-	if (aconnector->base.funcs->reset)
-		aconnector->base.funcs->reset(&aconnector->base);
-
 	amdgpu_dm_connector_init_helper(
 		dm,
 		aconnector,
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amd/display: Always allocate initial connector state state
       [not found] ` <20190604192114.20995-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2019-06-04 19:26   ` Li, Sun peng (Leo)
  0 siblings, 0 replies; 2+ messages in thread
From: Li, Sun peng (Leo) @ 2019-06-04 19:26 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Wentland, Harry, Li, Roman



On 2019-06-04 3:21 p.m., Nicholas Kazlauskas wrote:
> [Why]
> Unlike our regular connectors, MST connectors don't start off with
> an initial connector state. This causes a NULL pointer dereference to
> occur when attaching the bpc property since it tries to modify the
> connector state.
> 
> We need an initial connector state on the connector to avoid the crash.
> 
> [How]
> Use our reset helper to allocate an initial state and reset the values
> to their defaults. We were already doing this before, just not for
> MST connectors.
> 
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Roman Li <roman.li@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>

LGTM,

Reviewed-by: Leo Li <sunpeng.li@amd.com>

> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index a698c8f272ed..4523ab100bc3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4743,6 +4743,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
>   {
>   	struct amdgpu_device *adev = dm->ddev->dev_private;
>   
> +	/*
> +	 * Some of the properties below require access to state, like bpc.
> +	 * Allocate some default initial connector state with our reset helper.
> +	 */
> +	if (aconnector->base.funcs->reset)
> +		aconnector->base.funcs->reset(&aconnector->base);
> +
>   	aconnector->connector_id = link_index;
>   	aconnector->dc_link = link;
>   	aconnector->base.interlace_allowed = false;
> @@ -4932,9 +4939,6 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
>   			&aconnector->base,
>   			&amdgpu_dm_connector_helper_funcs);
>   
> -	if (aconnector->base.funcs->reset)
> -		aconnector->base.funcs->reset(&aconnector->base);
> -
>   	amdgpu_dm_connector_init_helper(
>   		dm,
>   		aconnector,
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-04 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 19:21 [PATCH] drm/amd/display: Always allocate initial connector state state Nicholas Kazlauskas
     [not found] ` <20190604192114.20995-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-06-04 19:26   ` Li, Sun peng (Leo)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.