All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
@ 2018-03-09 23:32 ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-03-09 23:32 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel, Eric Anholt, Boris Brezillon

In the cleanup, I didn't notice that we needed to dereference the
connector for the bus_format.  Fix the regression by looking up the
first (and only) connector attached to us, and assume that its
bus_format is what we want.  Some day it would be good to have that
part of display_info attached to the bridge, instead.

Signed-off-by: Eric Anholt <eric@anholt.net>
Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 72c9dbd81d7f..88783e143cc2 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -96,7 +96,6 @@ struct vc4_dpi {
 	struct platform_device *pdev;
 
 	struct drm_encoder *encoder;
-	struct drm_connector *connector;
 
 	void __iomem *regs;
 
@@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
 
 static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
 {
+	struct drm_device *dev = encoder->dev;
 	struct drm_display_mode *mode = &encoder->crtc->mode;
 	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
 	struct vc4_dpi *dpi = vc4_encoder->dpi;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *connector = NULL, *connector_scan;
 	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
 	int ret;
 
-	if (dpi->connector->display_info.num_bus_formats) {
-		u32 bus_format = dpi->connector->display_info.bus_formats[0];
+	/* Look up the connector attached to DPI so we can get the
+	 * bus_format.  Ideally the bridge would tell us the
+	 * bus_format we want, but it doesn't yet, so assume that it's
+	 * uniform throughout the bridge chain.
+	 */
+	drm_connector_list_iter_begin(dev, &conn_iter);
+	drm_for_each_connector_iter(connector_scan, &conn_iter) {
+		if (connector_scan->encoder == encoder) {
+			connector = connector_scan;
+			break;
+		}
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	if (connector && connector->display_info.num_bus_formats) {
+		u32 bus_format = connector->display_info.bus_formats[0];
 
 		switch (bus_format) {
 		case MEDIA_BUS_FMT_RGB888_1X24:
@@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
 			DRM_ERROR("Unknown media bus format %d\n", bus_format);
 			break;
 		}
+	} else {
+		/* Default to 24bit if no connector found. */
+		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
 	}
 
 	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
@@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
 			return ret;
 	}
 
-	if (panel)
+	if (panel) 
 		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
 
 	return drm_bridge_attach(dpi->encoder, bridge, NULL);
-- 
2.16.2

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

* [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
@ 2018-03-09 23:32 ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-03-09 23:32 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel, Boris Brezillon

In the cleanup, I didn't notice that we needed to dereference the
connector for the bus_format.  Fix the regression by looking up the
first (and only) connector attached to us, and assume that its
bus_format is what we want.  Some day it would be good to have that
part of display_info attached to the bridge, instead.

Signed-off-by: Eric Anholt <eric@anholt.net>
Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 72c9dbd81d7f..88783e143cc2 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -96,7 +96,6 @@ struct vc4_dpi {
 	struct platform_device *pdev;
 
 	struct drm_encoder *encoder;
-	struct drm_connector *connector;
 
 	void __iomem *regs;
 
@@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
 
 static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
 {
+	struct drm_device *dev = encoder->dev;
 	struct drm_display_mode *mode = &encoder->crtc->mode;
 	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
 	struct vc4_dpi *dpi = vc4_encoder->dpi;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *connector = NULL, *connector_scan;
 	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
 	int ret;
 
-	if (dpi->connector->display_info.num_bus_formats) {
-		u32 bus_format = dpi->connector->display_info.bus_formats[0];
+	/* Look up the connector attached to DPI so we can get the
+	 * bus_format.  Ideally the bridge would tell us the
+	 * bus_format we want, but it doesn't yet, so assume that it's
+	 * uniform throughout the bridge chain.
+	 */
+	drm_connector_list_iter_begin(dev, &conn_iter);
+	drm_for_each_connector_iter(connector_scan, &conn_iter) {
+		if (connector_scan->encoder == encoder) {
+			connector = connector_scan;
+			break;
+		}
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	if (connector && connector->display_info.num_bus_formats) {
+		u32 bus_format = connector->display_info.bus_formats[0];
 
 		switch (bus_format) {
 		case MEDIA_BUS_FMT_RGB888_1X24:
@@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
 			DRM_ERROR("Unknown media bus format %d\n", bus_format);
 			break;
 		}
+	} else {
+		/* Default to 24bit if no connector found. */
+		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
 	}
 
 	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
@@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
 			return ret;
 	}
 
-	if (panel)
+	if (panel) 
 		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
 
 	return drm_bridge_attach(dpi->encoder, bridge, NULL);
-- 
2.16.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
  2018-03-09 23:32 ` Eric Anholt
@ 2018-05-02 17:01   ` Eric Anholt
  -1 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-05-02 17:01 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel, Boris Brezillon

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

Eric Anholt <eric@anholt.net> writes:

> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.

Could anyone comment on this patch?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
@ 2018-05-02 17:01   ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-05-02 17:01 UTC (permalink / raw)
  To: dri-devel; +Cc: Boris Brezillon, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 405 bytes --]

Eric Anholt <eric@anholt.net> writes:

> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.

Could anyone comment on this patch?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
  2018-03-09 23:32 ` Eric Anholt
@ 2018-05-02 20:03   ` Sean Paul
  -1 siblings, 0 replies; 8+ messages in thread
From: Sean Paul @ 2018-05-02 20:03 UTC (permalink / raw)
  To: Eric Anholt; +Cc: dri-devel, linux-kernel, Boris Brezillon

On Fri, Mar 09, 2018 at 03:32:56PM -0800, Eric Anholt wrote:
> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index 72c9dbd81d7f..88783e143cc2 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -96,7 +96,6 @@ struct vc4_dpi {
>  	struct platform_device *pdev;
>  
>  	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
>  
>  	void __iomem *regs;
>  
> @@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
>  
>  static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  {
> +	struct drm_device *dev = encoder->dev;
>  	struct drm_display_mode *mode = &encoder->crtc->mode;
>  	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
>  	struct vc4_dpi *dpi = vc4_encoder->dpi;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_connector *connector = NULL, *connector_scan;
>  	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
>  	int ret;
>  
> -	if (dpi->connector->display_info.num_bus_formats) {
> -		u32 bus_format = dpi->connector->display_info.bus_formats[0];
> +	/* Look up the connector attached to DPI so we can get the
> +	 * bus_format.  Ideally the bridge would tell us the
> +	 * bus_format we want, but it doesn't yet, so assume that it's
> +	 * uniform throughout the bridge chain.
> +	 */
> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector_scan, &conn_iter) {
> +		if (connector_scan->encoder == encoder) {
> +			connector = connector_scan;
> +			break;
> +		}
> +	}
> +	drm_connector_list_iter_end(&conn_iter);
> +
> +	if (connector && connector->display_info.num_bus_formats) {
> +		u32 bus_format = connector->display_info.bus_formats[0];
>  
>  		switch (bus_format) {
>  		case MEDIA_BUS_FMT_RGB888_1X24:
> @@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  			DRM_ERROR("Unknown media bus format %d\n", bus_format);
>  			break;
>  		}
> +	} else {
> +		/* Default to 24bit if no connector found. */
> +		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
>  	}
>  
>  	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
>  			return ret;
>  	}
>  
> -	if (panel)
> +	if (panel) 

whitespace creep, with that fixed:

Reviewed-by: Sean Paul <seanpaul@chromium.org>

>  		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
>  
>  	return drm_bridge_attach(dpi->encoder, bridge, NULL);
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
@ 2018-05-02 20:03   ` Sean Paul
  0 siblings, 0 replies; 8+ messages in thread
From: Sean Paul @ 2018-05-02 20:03 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Boris Brezillon, linux-kernel, dri-devel

On Fri, Mar 09, 2018 at 03:32:56PM -0800, Eric Anholt wrote:
> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index 72c9dbd81d7f..88783e143cc2 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -96,7 +96,6 @@ struct vc4_dpi {
>  	struct platform_device *pdev;
>  
>  	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
>  
>  	void __iomem *regs;
>  
> @@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
>  
>  static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  {
> +	struct drm_device *dev = encoder->dev;
>  	struct drm_display_mode *mode = &encoder->crtc->mode;
>  	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
>  	struct vc4_dpi *dpi = vc4_encoder->dpi;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_connector *connector = NULL, *connector_scan;
>  	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
>  	int ret;
>  
> -	if (dpi->connector->display_info.num_bus_formats) {
> -		u32 bus_format = dpi->connector->display_info.bus_formats[0];
> +	/* Look up the connector attached to DPI so we can get the
> +	 * bus_format.  Ideally the bridge would tell us the
> +	 * bus_format we want, but it doesn't yet, so assume that it's
> +	 * uniform throughout the bridge chain.
> +	 */
> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector_scan, &conn_iter) {
> +		if (connector_scan->encoder == encoder) {
> +			connector = connector_scan;
> +			break;
> +		}
> +	}
> +	drm_connector_list_iter_end(&conn_iter);
> +
> +	if (connector && connector->display_info.num_bus_formats) {
> +		u32 bus_format = connector->display_info.bus_formats[0];
>  
>  		switch (bus_format) {
>  		case MEDIA_BUS_FMT_RGB888_1X24:
> @@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  			DRM_ERROR("Unknown media bus format %d\n", bus_format);
>  			break;
>  		}
> +	} else {
> +		/* Default to 24bit if no connector found. */
> +		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
>  	}
>  
>  	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
>  			return ret;
>  	}
>  
> -	if (panel)
> +	if (panel) 

whitespace creep, with that fixed:

Reviewed-by: Sean Paul <seanpaul@chromium.org>

>  		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
>  
>  	return drm_bridge_attach(dpi->encoder, bridge, NULL);
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
  2018-03-09 23:32 ` Eric Anholt
@ 2018-05-02 20:29   ` Boris Brezillon
  -1 siblings, 0 replies; 8+ messages in thread
From: Boris Brezillon @ 2018-05-02 20:29 UTC (permalink / raw)
  To: Eric Anholt; +Cc: dri-devel, linux-kernel

On Fri,  9 Mar 2018 15:32:56 -0800
Eric Anholt <eric@anholt.net> wrote:

> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>

Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>

> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index 72c9dbd81d7f..88783e143cc2 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -96,7 +96,6 @@ struct vc4_dpi {
>  	struct platform_device *pdev;
>  
>  	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
>  
>  	void __iomem *regs;
>  
> @@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
>  
>  static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  {
> +	struct drm_device *dev = encoder->dev;
>  	struct drm_display_mode *mode = &encoder->crtc->mode;
>  	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
>  	struct vc4_dpi *dpi = vc4_encoder->dpi;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_connector *connector = NULL, *connector_scan;
>  	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
>  	int ret;
>  
> -	if (dpi->connector->display_info.num_bus_formats) {
> -		u32 bus_format = dpi->connector->display_info.bus_formats[0];
> +	/* Look up the connector attached to DPI so we can get the
> +	 * bus_format.  Ideally the bridge would tell us the
> +	 * bus_format we want, but it doesn't yet, so assume that it's
> +	 * uniform throughout the bridge chain.
> +	 */
> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector_scan, &conn_iter) {
> +		if (connector_scan->encoder == encoder) {
> +			connector = connector_scan;
> +			break;
> +		}
> +	}
> +	drm_connector_list_iter_end(&conn_iter);
> +
> +	if (connector && connector->display_info.num_bus_formats) {
> +		u32 bus_format = connector->display_info.bus_formats[0];
>  
>  		switch (bus_format) {
>  		case MEDIA_BUS_FMT_RGB888_1X24:
> @@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  			DRM_ERROR("Unknown media bus format %d\n", bus_format);
>  			break;
>  		}
> +	} else {
> +		/* Default to 24bit if no connector found. */
> +		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
>  	}
>  
>  	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
>  			return ret;
>  	}
>  
> -	if (panel)
> +	if (panel) 
>  		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
>  
>  	return drm_bridge_attach(dpi->encoder, bridge, NULL);

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

* Re: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge.
@ 2018-05-02 20:29   ` Boris Brezillon
  0 siblings, 0 replies; 8+ messages in thread
From: Boris Brezillon @ 2018-05-02 20:29 UTC (permalink / raw)
  To: Eric Anholt; +Cc: linux-kernel, dri-devel

On Fri,  9 Mar 2018 15:32:56 -0800
Eric Anholt <eric@anholt.net> wrote:

> In the cleanup, I didn't notice that we needed to dereference the
> connector for the bus_format.  Fix the regression by looking up the
> first (and only) connector attached to us, and assume that its
> bus_format is what we want.  Some day it would be good to have that
> part of display_info attached to the bridge, instead.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.")
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>

Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>

> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index 72c9dbd81d7f..88783e143cc2 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -96,7 +96,6 @@ struct vc4_dpi {
>  	struct platform_device *pdev;
>  
>  	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
>  
>  	void __iomem *regs;
>  
> @@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
>  
>  static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  {
> +	struct drm_device *dev = encoder->dev;
>  	struct drm_display_mode *mode = &encoder->crtc->mode;
>  	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
>  	struct vc4_dpi *dpi = vc4_encoder->dpi;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_connector *connector = NULL, *connector_scan;
>  	u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
>  	int ret;
>  
> -	if (dpi->connector->display_info.num_bus_formats) {
> -		u32 bus_format = dpi->connector->display_info.bus_formats[0];
> +	/* Look up the connector attached to DPI so we can get the
> +	 * bus_format.  Ideally the bridge would tell us the
> +	 * bus_format we want, but it doesn't yet, so assume that it's
> +	 * uniform throughout the bridge chain.
> +	 */
> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector_scan, &conn_iter) {
> +		if (connector_scan->encoder == encoder) {
> +			connector = connector_scan;
> +			break;
> +		}
> +	}
> +	drm_connector_list_iter_end(&conn_iter);
> +
> +	if (connector && connector->display_info.num_bus_formats) {
> +		u32 bus_format = connector->display_info.bus_formats[0];
>  
>  		switch (bus_format) {
>  		case MEDIA_BUS_FMT_RGB888_1X24:
> @@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  			DRM_ERROR("Unknown media bus format %d\n", bus_format);
>  			break;
>  		}
> +	} else {
> +		/* Default to 24bit if no connector found. */
> +		dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
>  	}
>  
>  	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
>  			return ret;
>  	}
>  
> -	if (panel)
> +	if (panel) 
>  		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
>  
>  	return drm_bridge_attach(dpi->encoder, bridge, NULL);

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-05-02 20:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 23:32 [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge Eric Anholt
2018-03-09 23:32 ` Eric Anholt
2018-05-02 17:01 ` Eric Anholt
2018-05-02 17:01   ` Eric Anholt
2018-05-02 20:03 ` Sean Paul
2018-05-02 20:03   ` Sean Paul
2018-05-02 20:29 ` Boris Brezillon
2018-05-02 20:29   ` Boris Brezillon

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.