mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Johan Hovold <johan+linaro@kernel.org>,
	Douglas Anderson <dianders@chromium.org>,
	Rob Clark <robdclark@gmail.com>,
	Douglas Anderson <dianders@chromium.org>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <robert.foss@linaro.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Sean Paul <sean@poorly.run>, Stephen Boyd <swboyd@chromium.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 4/7] drm/msm/dp: fix aux-bus EP lifetime
Date: Mon, 12 Sep 2022 21:10:00 +0300	[thread overview]
Message-ID: <e60f0053-3801-bf33-5841-69f16215fa00@linaro.org> (raw)
In-Reply-To: <20220912154046.12900-5-johan+linaro@kernel.org>

On 12/09/2022 18:40, Johan Hovold wrote:
> Device-managed resources allocated post component bind must be tied to
> the lifetime of the aggregate DRM device or they will not necessarily be
> released when binding of the aggregate device is deferred.
> 
> This can lead resource leaks or failure to bind the aggregate device
> when binding is later retried and a second attempt to allocate the
> resources is made.
> 
> For the DP aux-bus, an attempt to populate the bus a second time will
> simply fail ("DP AUX EP device already populated").
> 
> Fix this by amending the DP aux interface and tying the lifetime of the
> EP device to the DRM device rather than DP controller platform device.

Doug, could you please take a look?

For me this is another reminder/pressure point that we should populate 
the AUX BUS from the probe(), before binding the components together.

> 
> Fixes: c3bf8e21b38a ("drm/msm/dp: Add eDP support via aux_bus")
> Cc: stable@vger.kernel.org      # 5.19
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>   drivers/gpu/drm/bridge/parade-ps8640.c   | 2 +-
>   drivers/gpu/drm/display/drm_dp_aux_bus.c | 5 +++--
>   drivers/gpu/drm/msm/dp/dp_display.c      | 3 ++-
>   include/drm/display/drm_dp_aux_bus.h     | 6 +++---
>   4 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c
> index d7483c13c569..6127979370cb 100644
> --- a/drivers/gpu/drm/bridge/parade-ps8640.c
> +++ b/drivers/gpu/drm/bridge/parade-ps8640.c
> @@ -719,7 +719,7 @@ static int ps8640_probe(struct i2c_client *client)
>   	if (ret)
>   		return ret;
>   
> -	ret = devm_of_dp_aux_populate_bus(&ps_bridge->aux, ps8640_bridge_link_panel);
> +	ret = devm_of_dp_aux_populate_bus(dev, &ps_bridge->aux, ps8640_bridge_link_panel);
>   
>   	/*
>   	 * If devm_of_dp_aux_populate_bus() returns -ENODEV then it's up to
> diff --git a/drivers/gpu/drm/display/drm_dp_aux_bus.c b/drivers/gpu/drm/display/drm_dp_aux_bus.c
> index f5741b45ca07..2706f2cf82f7 100644
> --- a/drivers/gpu/drm/display/drm_dp_aux_bus.c
> +++ b/drivers/gpu/drm/display/drm_dp_aux_bus.c
> @@ -322,6 +322,7 @@ static void of_dp_aux_depopulate_bus_void(void *data)
>   
>   /**
>    * devm_of_dp_aux_populate_bus() - devm wrapper for of_dp_aux_populate_bus()
> + * @dev: Device to tie the lifetime of the EP devices to
>    * @aux: The AUX channel whose device we want to populate
>    * @done_probing: Callback functions to call after EP device finishes probing.
>    *                Will not be called if there are no EP devices and this
> @@ -333,7 +334,7 @@ static void of_dp_aux_depopulate_bus_void(void *data)
>    *         no children. The done_probing() function won't be called in that
>    *         case.
>    */
> -int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
> +int devm_of_dp_aux_populate_bus(struct device *dev, struct drm_dp_aux *aux,
>   				int (*done_probing)(struct drm_dp_aux *aux))
>   {
>   	int ret;
> @@ -342,7 +343,7 @@ int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
>   	if (ret)
>   		return ret;
>   
> -	return devm_add_action_or_reset(aux->dev,
> +	return devm_add_action_or_reset(dev,
>   					of_dp_aux_depopulate_bus_void, aux);
>   }
>   EXPORT_SYMBOL_GPL(devm_of_dp_aux_populate_bus);
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index ba557328710a..e1aa6355bbf6 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1559,7 +1559,8 @@ static int dp_display_get_next_bridge(struct msm_dp *dp)
>   		 * panel driver is probed asynchronously but is the best we
>   		 * can do without a bigger driver reorganization.
>   		 */
> -		rc = devm_of_dp_aux_populate_ep_devices(dp_priv->aux);
> +		rc = devm_of_dp_aux_populate_ep_devices(dp->drm_dev->dev,
> +							dp_priv->aux);
>   		of_node_put(aux_bus);
>   		if (rc)
>   			goto error;
> diff --git a/include/drm/display/drm_dp_aux_bus.h b/include/drm/display/drm_dp_aux_bus.h
> index 8a0a486383c5..a4063aa7fc40 100644
> --- a/include/drm/display/drm_dp_aux_bus.h
> +++ b/include/drm/display/drm_dp_aux_bus.h
> @@ -47,7 +47,7 @@ static inline struct dp_aux_ep_driver *to_dp_aux_ep_drv(struct device_driver *dr
>   int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
>   			   int (*done_probing)(struct drm_dp_aux *aux));
>   void of_dp_aux_depopulate_bus(struct drm_dp_aux *aux);
> -int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
> +int devm_of_dp_aux_populate_bus(struct device *dev, struct drm_dp_aux *aux,
>   				int (*done_probing)(struct drm_dp_aux *aux));
>   
>   /* Deprecated versions of the above functions. To be removed when no callers. */
> @@ -61,11 +61,11 @@ static inline int of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
>   	return (ret != -ENODEV) ? ret : 0;
>   }
>   
> -static inline int devm_of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
> +static inline int devm_of_dp_aux_populate_ep_devices(struct device *dev, struct drm_dp_aux *aux)
>   {
>   	int ret;
>   
> -	ret = devm_of_dp_aux_populate_bus(aux, NULL);
> +	ret = devm_of_dp_aux_populate_bus(dev, aux, NULL);
>   
>   	/* New API returns -ENODEV for no child case; adapt to old assumption */
>   	return (ret != -ENODEV) ? ret : 0;

-- 
With best wishes
Dmitry


  reply	other threads:[~2022-09-12 18:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 15:40 [PATCH 0/7] drm/msm: probe deferral fixes Johan Hovold
2022-09-12 15:40 ` [PATCH 1/7] drm/msm: fix use-after-free on probe deferral Johan Hovold
2022-09-12 17:52   ` Dmitry Baryshkov
2022-09-13  7:31     ` Johan Hovold
2022-09-12 15:40 ` [PATCH 2/7] drm/msm: fix memory corruption with too many bridges Johan Hovold
2022-09-12 17:55   ` Dmitry Baryshkov
2022-09-13  7:49     ` Johan Hovold
2022-09-12 15:40 ` [PATCH 3/7] drm/msm/dp: fix IRQ lifetime Johan Hovold
2022-09-12 18:06   ` Dmitry Baryshkov
2022-09-12 15:40 ` [PATCH 4/7] drm/msm/dp: fix aux-bus EP lifetime Johan Hovold
2022-09-12 18:10   ` Dmitry Baryshkov [this message]
2022-09-12 21:55     ` Steev Klimaszewski
2022-09-13  7:20       ` Johan Hovold
2022-09-13  6:35     ` Doug Anderson
2022-09-13  7:18       ` Johan Hovold
2022-09-13  1:51   ` kernel test robot
2022-09-12 15:40 ` [PATCH 5/7] drm/msm/dp: fix bridge lifetime Johan Hovold
2022-09-12 18:11   ` Dmitry Baryshkov
2022-09-12 15:40 ` [PATCH 6/7] drm/msm/hdmi: fix IRQ lifetime Johan Hovold
2022-09-12 17:59   ` Dmitry Baryshkov
2022-09-12 15:40 ` [PATCH 7/7] drm/msm: drop modeset sanity checks Johan Hovold
2022-09-12 18:06   ` Dmitry Baryshkov
2022-09-13  7:53     ` Johan Hovold
2022-09-12 17:11 ` [PATCH 0/7] drm/msm: probe deferral fixes Abhinav Kumar

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=e60f0053-3801-bf33-5841-69f16215fa00@linaro.org \
    --to=dmitry.baryshkov@linaro.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=andersson@kernel.org \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=johan+linaro@kernel.org \
    --cc=jonas@kwiboo.se \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=neil.armstrong@linaro.org \
    --cc=robdclark@gmail.com \
    --cc=robert.foss@linaro.org \
    --cc=sean@poorly.run \
    --cc=stable@vger.kernel.org \
    --cc=swboyd@chromium.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®