All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org,
	Douglas Anderson <dianders@chromium.org>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/bridge: ti-sn65dsi86: Check bridge connection failure
Date: Tue, 18 Mar 2025 22:41:33 +0200	[thread overview]
Message-ID: <20250318204133.GC22890@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250318155549.19625-2-wsa+renesas@sang-engineering.com>

Hi Wolfram,

Thank you for the patch.

On Tue, Mar 18, 2025 at 04:52:56PM +0100, Wolfram Sang wrote:
> Read out and check the ID registers, so we can bail out if I2C
> communication does not work or if the device is unknown.

What's the advantage of that, what are you trying to guard against ?

> Tested on a
> Renesas GrayHawk board (R-Car V4M) by using a wrong I2C address and by
> not enabling RuntimePM for the device.

What do you mean by not enabling runtime PM for the device ?

> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Changes since v2:
> * switched to a new approach suggested by Doug (Thanks!). We add a
>   dedicated read instead of using the first read. This prevents creating
>   the aux devices. As a side-gain, we check now if the chip at the address
>   is really the one we want to support.
> 
>  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> index 87fffaa52bb0..8caa7918933d 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> @@ -36,6 +36,7 @@
>  #include <drm/drm_print.h>
>  #include <drm/drm_probe_helper.h>
>  
> +#define SN_DEVICE_ID_REGS			0x00	/* up to 0x07 */
>  #define SN_DEVICE_REV_REG			0x08
>  #define SN_DPPLL_SRC_REG			0x0A
>  #define  DPPLL_CLK_SRC_DSICLK			BIT(0)
> @@ -1875,6 +1876,7 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
>  	struct ti_sn65dsi86 *pdata;
> +	u8 id_buf[8];
>  	int ret;
>  
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> @@ -1918,6 +1920,16 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
>  	if (ret)
>  		return ret;
>  
> +	pm_runtime_get_sync(dev);

Missing error checking. You should probably use
pm_runtime_resume_and_get().

> +	ret = regmap_bulk_read(pdata->regmap, SN_DEVICE_ID_REGS, id_buf, ARRAY_SIZE(id_buf));
> +	pm_runtime_put_autosuspend(dev);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to read device id\n");
> +
> +	/* The ID string is stored backwards */
> +	if (strncmp(id_buf, "68ISD   ", ARRAY_SIZE(id_buf)))
> +		return dev_err_probe(dev, -EOPNOTSUPP, "unsupported device id\n");
> +
>  	/*
>  	 * Break ourselves up into a collection of aux devices. The only real
>  	 * motiviation here is to solve the chicken-and-egg problem of probe

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2025-03-18 20:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 15:52 [PATCH v3] drm/bridge: ti-sn65dsi86: Check bridge connection failure Wolfram Sang
2025-03-18 15:59 ` Wolfram Sang
2025-03-18 17:56 ` Doug Anderson
2025-03-24 16:37   ` Doug Anderson
2025-03-18 20:41 ` Laurent Pinchart [this message]
2025-03-18 21:00   ` Wolfram Sang
2025-03-24 16:40     ` Laurent Pinchart
2025-03-24 17:17       ` Doug Anderson
2025-03-24 17:30         ` Laurent Pinchart
2025-03-24 17:35           ` Doug Anderson

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=20250318204133.GC22890@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=wsa+renesas@sang-engineering.com \
    /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.