All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 18/24] drm/msm/hdmi: cache is_hdmi instead of storing the connector
Date: Wed, 22 Jul 2026 07:06:23 +0000	[thread overview]
Message-ID: <20260722070624.610F61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722-drm-msm-display-interface-v1-18-368c10fe62fd@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] Missing State Synchronization when connector state is forced via sysfs.
- [Medium] Data Race on `hdmi->is_hdmi` boolean.

Pre-existing issues:
- [High] NULL Pointer Dereference on drmm-managed connector destroy hook.
--

--- Patch [18]: [PATCH 18/24] drm/msm/hdmi: cache is_hdmi instead of storing the connector ---
commit c8e64d4ebbe7d3c6a0a2cb94dd5d7a4af528ed77
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

drm/msm/hdmi: cache is_hdmi instead of storing the connector

This commit updates the HDMI driver to cache the is_hdmi boolean from the
EDID rather than retaining a driver-side pointer to the drm_connector. The
cached value is refreshed via a new hpd_notify bridge callback.

> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
> index 1d5a4b63f3c8f..62961dddd8f5e 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c

[ ... ]

> @@ -204,10 +205,8 @@ static int msm_hdmi_modeset_init(struct msm_display *display,
>  	return 0;
>  
>  fail:
> -	if (hdmi->connector) {
> -		hdmi->connector->funcs->destroy(hdmi->connector);
> -		hdmi->connector = NULL;
> -	}
> +	if (connector)
> +		connector->funcs->destroy(connector);

[Severity: High]
This is a pre-existing issue, but does calling the destroy hook here cause a
NULL pointer dereference? 
    
The connector is created earlier in msm_hdmi_modeset_init() via
drm_bridge_connector_init(), which uses the drmm-managed API
drmm_connector_init(). The DRM-managed API explicitly requires funcs->destroy
to be NULL, otherwise it returns -EINVAL. 
    
This means connector->funcs->destroy is guaranteed to be NULL when this error
path is taken, which would cause a panic when dereferenced.

>  
>  	return ret;
>  }

[ ... ]

> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> index 7abb9243dba57..84a423af73e93 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c

[ ... ]

> @@ -452,6 +452,17 @@ static enum drm_mode_status msm_hdmi_bridge_tmds_char_rate_valid(const struct dr
>  	return 0;
>  }
>  
> +static void msm_hdmi_bridge_hpd_notify(struct drm_bridge *bridge,
> +				       struct drm_connector *connector,
> +				       enum drm_connector_status status)
> +{
> +	struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge);
> +	struct hdmi *hdmi = hdmi_bridge->hdmi;
> +
> +	/* called after the EDID update, so display_info is up to date */
> +	hdmi->is_hdmi = connector->display_info.is_hdmi;

[Severity: High]
Can the cached hdmi->is_hdmi state become stale if the connector is forced
via sysfs? 

When userspace forces the connector state (for example, by echoing on to the
status file), the DRM core sets the status and invokes 
connector->funcs->force(), which maps to drm_bridge_connector_force(). 

This force operation successfully updates the EDID and display_info.is_hdmi,
but it bypasses the standard detect hook and does not invoke the hpd_notify
callback. Will this missing state synchronization cause HDMI-specific hardware
programming to incorrectly fall back to DVI mode and drop audio?

[Severity: Medium]
Could there be a data race when accessing hdmi->is_hdmi? 

This variable is updated here in msm_hdmi_bridge_hpd_notify() from the
asynchronous hotplug workqueue thread. Concurrently, it is read in
msm_hdmi_set_mode() under the reg_lock spinlock, and in msm_hdmi_audio_update()
from audio subsystem paths. 

Since there is no common lock protecting this cross-thread state access, and
neither READ_ONCE() nor WRITE_ONCE() is used, will this trigger KCSAN
warnings?

> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-drm-msm-display-interface-v1-0-368c10fe62fd@oss.qualcomm.com?part=18

  reply	other threads:[~2026-07-22  7:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  6:36 [PATCH 00/24] drm/msm: introduce the struct msm_display interface Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 01/24] drm/msm/dp: reject YUV420-only modes without VSC SDP support Dmitry Baryshkov
2026-07-22  7:03   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 02/24] drm/msm/dp: drop the always-true yuv_supported argument Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 03/24] drm/msm: create the display connectors from common code Dmitry Baryshkov
2026-07-22  7:04   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 04/24] drm/msm: introduce the struct msm_display interface Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 05/24] drm/msm: route the display snapshot through the " Dmitry Baryshkov
2026-07-22  6:56   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 06/24] drm/msm/hdmi: capture the HDMI registers in the display snapshot Dmitry Baryshkov
2026-07-22  6:59   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 07/24] drm/msm: add the wide_bus_enabled callback to msm_display Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 08/24] drm/msm: add the needs_periph_flush " Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 09/24] drm/msm: add the is_cmd_mode " Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 10/24] drm/msm: add the get_dsc_config " Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 11/24] drm/msm: add the get_te_source " Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 12/24] drm/msm: add is_bonded and needs_encoder callbacks " Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 13/24] drm/msm/hdmi: use dev_get_drvdata() in msm_hdmi_unbind() Dmitry Baryshkov
2026-07-22  7:03   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 14/24] drm/msm: store the display sub-blocks as struct msm_display Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 15/24] drm/msm/dp: do not reject wide-bus modes while a YUV420 mode is active Dmitry Baryshkov
2026-07-22  7:03   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 16/24] drm/msm/dp: remove cached drm_edid from panel Dmitry Baryshkov
2026-07-22  7:08   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 17/24] drm/msm/dp: drop deprecated .mode_set() and use .atomic_pre_enable Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 18/24] drm/msm/hdmi: cache is_hdmi instead of storing the connector Dmitry Baryshkov
2026-07-22  7:06   ` sashiko-bot [this message]
2026-07-22  6:36 ` [PATCH 19/24] drm/msm/dp: drop redundant panel->connector Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 20/24] drm/msm/dp: use drm_display_info in mode_valid callbacks Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 21/24] drm/msm/dp: guard subconnector setup on the connector type Dmitry Baryshkov
2026-07-22  6:36 ` [PATCH 22/24] drm/msm/dp: stop storing the connector in struct msm_dp Dmitry Baryshkov
2026-07-22  7:12   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 23/24] drm/msm: create the bridge connectors from common code Dmitry Baryshkov
2026-07-22  7:04   ` sashiko-bot
2026-07-22  6:36 ` [PATCH 24/24] drm/bridge-connector: attach the DP subconnector property Dmitry Baryshkov
2026-07-22  7:05   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260722070624.610F61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.