2023-08-04 12:14:36

by Tomi Valkeinen

[permalink] [raw]
Subject: [PATCH 0/4] drm/bridge: lt8912b: Init & remove related fixes

Fix various issues in lt8912b driver.

Tomi

Signed-off-by: Tomi Valkeinen <[email protected]>
---
Tomi Valkeinen (4):
drm/bridge: lt8912b: Fix bridge_detach
drm/bridge: lt8912b: Fix crash on bridge detach
drm/bridge: lt8912b: Manually disable HPD only if it was enabled
drm/bridge: lt8912b: Add missing drm_bridge_attach call

drivers/gpu/drm/bridge/lontium-lt8912b.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
---
base-commit: b0e9267d4ccce9be9217337f4bc364ca24cf7f73
change-id: 20230804-lt8912b-9cbb79018632

Best regards,
--
Tomi Valkeinen <[email protected]>



2023-08-04 13:27:10

by Tomi Valkeinen

[permalink] [raw]
Subject: [PATCH 1/4] drm/bridge: lt8912b: Fix bridge_detach

The driver calls lt8912_bridge_detach() from its lt8912_remove()
function. As the DRM core detaches bridges automatically, this leads to
calling lt8912_bridge_detach() twice. The code probably has tried to
manage the double-call with the 'is_attached' variable, but the driver
never sets the variable to false, so its of no help.

Fix the issue by dropping the call to lt8912_bridge_detach() from
lt8912_remove(), as the DRM core will handle the detach call for us,
and also drop the useless is_attached field.

Fixes: 88abfc2b9e61 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
Signed-off-by: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/bridge/lontium-lt8912b.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 4eaea67fb71c..0e581f6e3c88 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -45,7 +45,6 @@ struct lt8912 {

u8 data_lanes;
bool is_power_on;
- bool is_attached;
};

static int lt8912_write_init_config(struct lt8912 *lt)
@@ -575,8 +574,6 @@ static int lt8912_bridge_attach(struct drm_bridge *bridge,
if (ret)
goto error;

- lt->is_attached = true;
-
return 0;

error:
@@ -588,15 +585,13 @@ static void lt8912_bridge_detach(struct drm_bridge *bridge)
{
struct lt8912 *lt = bridge_to_lt8912(bridge);

- if (lt->is_attached) {
- lt8912_hard_power_off(lt);
+ lt8912_hard_power_off(lt);

- if (lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD)
- drm_bridge_hpd_disable(lt->hdmi_port);
+ if (lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD)
+ drm_bridge_hpd_disable(lt->hdmi_port);

- drm_connector_unregister(&lt->connector);
- drm_connector_cleanup(&lt->connector);
- }
+ drm_connector_unregister(&lt->connector);
+ drm_connector_cleanup(&lt->connector);
}

static enum drm_connector_status
@@ -750,7 +745,6 @@ static void lt8912_remove(struct i2c_client *client)
{
struct lt8912 *lt = i2c_get_clientdata(client);

- lt8912_bridge_detach(&lt->bridge);
drm_bridge_remove(&lt->bridge);
lt8912_free_i2c(lt);
lt8912_put_dt(lt);

--
2.34.1


2023-08-04 15:29:16

by Robert Foss

[permalink] [raw]
Subject: Re: [PATCH 1/4] drm/bridge: lt8912b: Fix bridge_detach

On Fri, Aug 4, 2023 at 12:48 PM Tomi Valkeinen
<[email protected]> wrote:
>
> The driver calls lt8912_bridge_detach() from its lt8912_remove()
> function. As the DRM core detaches bridges automatically, this leads to
> calling lt8912_bridge_detach() twice. The code probably has tried to
> manage the double-call with the 'is_attached' variable, but the driver
> never sets the variable to false, so its of no help.
>
> Fix the issue by dropping the call to lt8912_bridge_detach() from
> lt8912_remove(), as the DRM core will handle the detach call for us,
> and also drop the useless is_attached field.
>
> Fixes: 88abfc2b9e61 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
> Signed-off-by: Tomi Valkeinen <[email protected]>
> ---
> drivers/gpu/drm/bridge/lontium-lt8912b.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> index 4eaea67fb71c..0e581f6e3c88 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> @@ -45,7 +45,6 @@ struct lt8912 {
>
> u8 data_lanes;
> bool is_power_on;
> - bool is_attached;
> };
>
> static int lt8912_write_init_config(struct lt8912 *lt)
> @@ -575,8 +574,6 @@ static int lt8912_bridge_attach(struct drm_bridge *bridge,
> if (ret)
> goto error;
>
> - lt->is_attached = true;
> -
> return 0;
>
> error:
> @@ -588,15 +585,13 @@ static void lt8912_bridge_detach(struct drm_bridge *bridge)
> {
> struct lt8912 *lt = bridge_to_lt8912(bridge);
>
> - if (lt->is_attached) {
> - lt8912_hard_power_off(lt);
> + lt8912_hard_power_off(lt);
>
> - if (lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD)
> - drm_bridge_hpd_disable(lt->hdmi_port);
> + if (lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD)
> + drm_bridge_hpd_disable(lt->hdmi_port);
>
> - drm_connector_unregister(&lt->connector);
> - drm_connector_cleanup(&lt->connector);
> - }
> + drm_connector_unregister(&lt->connector);
> + drm_connector_cleanup(&lt->connector);
> }
>
> static enum drm_connector_status
> @@ -750,7 +745,6 @@ static void lt8912_remove(struct i2c_client *client)
> {
> struct lt8912 *lt = i2c_get_clientdata(client);
>
> - lt8912_bridge_detach(&lt->bridge);
> drm_bridge_remove(&lt->bridge);
> lt8912_free_i2c(lt);
> lt8912_put_dt(lt);
>
> --
> 2.34.1
>


Reviewed-by: Robert Foss <[email protected]>