dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Tony Lindgren <tony@atomide.com>,
	hns@goldelico.com, Sekhar Nori <nsekhar@ti.com>,
	Sebastian Reichel <sre@kernel.org>,
	dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org,
	Sam Ravnborg <sam@ravnborg.org>,
	Nikhil Devshatwar <nikhil.nd@ti.com>
Subject: Re: [PATCH v5 29/29] drm/omap: dsi: allow DSI commands to be sent early
Date: Tue, 8 Dec 2020 17:48:45 +0200	[thread overview]
Message-ID: <X8+gXWBwLItZA7gA@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20201208122855.254819-30-tomi.valkeinen@ti.com>

Hi Tomi,

Thank you for the patch.

On Tue, Dec 08, 2020 at 02:28:55PM +0200, Tomi Valkeinen wrote:
> Panel drivers can send DSI commands in panel's prepare(), which happens
> before the bridge's enable() is called. The OMAP DSI driver currently
> only sets up the DSI interface at bridge's enable(), so prepare() cannot
> be used to send DSI commands.
> 
> This patch fixes the issue by making it possible to enable the DSI
> interface any time a command is about to be sent. Disabling the
> interface is be done via delayed work.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 49 +++++++++++++++++++++++++++----
>  drivers/gpu/drm/omapdrm/dss/dsi.h |  3 ++
>  2 files changed, 47 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 53a64bc91867..34f665aa9a59 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3503,6 +3503,9 @@ static void dsi_enable(struct dsi_data *dsi)
>  
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> +	if (WARN_ON(dsi->iface_enabled))
> +		return;
> +
>  	mutex_lock(&dsi->lock);
>  
>  	r = dsi_runtime_get(dsi);
> @@ -3515,6 +3518,8 @@ static void dsi_enable(struct dsi_data *dsi)
>  	if (r)
>  		goto err_init_dsi;
>  
> +	dsi->iface_enabled = true;
> +
>  	mutex_unlock(&dsi->lock);
>  
>  	return;
> @@ -3530,6 +3535,9 @@ static void dsi_disable(struct dsi_data *dsi)
>  {
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> +	if (WARN_ON(!dsi->iface_enabled))
> +		return;
> +
>  	mutex_lock(&dsi->lock);
>  
>  	dsi_sync_vc(dsi, 0);
> @@ -3541,6 +3549,8 @@ static void dsi_disable(struct dsi_data *dsi)
>  
>  	dsi_runtime_put(dsi);
>  
> +	dsi->iface_enabled = false;
> +
>  	mutex_unlock(&dsi->lock);
>  }
>  
> @@ -4229,10 +4239,12 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
>  
>  	dsi_bus_lock(dsi);
>  
> -	if (dsi->video_enabled)
> -		r = _omap_dsi_host_transfer(dsi, vc, msg);
> -	else
> -		r = -EIO;
> +	if (!dsi->iface_enabled) {
> +		dsi_enable(dsi);
> +		schedule_delayed_work(&dsi->dsi_disable_work, msecs_to_jiffies(2000));
> +	}
> +
> +	r = _omap_dsi_host_transfer(dsi, vc, msg);
>  
>  	dsi_bus_unlock(dsi);
>  
> @@ -4397,6 +4409,14 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
>  	if (WARN_ON(dsi->dsidev != client))
>  		return -EINVAL;
>  
> +	cancel_delayed_work_sync(&dsi->dsi_disable_work);
> +
> +	if (dsi->iface_enabled) {
> +		dsi_bus_lock(dsi);
> +		dsi_disable(dsi);
> +		dsi_bus_unlock(dsi);
> +	}
> +
>  	omap_dsi_unregister_te_irq(dsi);
>  	dsi->dsidev = NULL;
>  	return 0;
> @@ -4632,9 +4652,12 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
>  	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
>  	struct omap_dss_device *dssdev = &dsi->output;
>  
> +	cancel_delayed_work_sync(&dsi->dsi_disable_work);
> +

Is there a risk of a race condition if omap_dsi_host_transfer() is
called right here, before locking the bus ? Or is there a guarantee that
the two functions can't be executed concurrently ? Same for
dsi_bridge_disable() below.

>  	dsi_bus_lock(dsi);
>  
> -	dsi_enable(dsi);
> +	if (!dsi->iface_enabled)
> +		dsi_enable(dsi);
>  
>  	dsi_enable_video_output(dssdev, VC_VIDEO);
>  
> @@ -4648,6 +4671,8 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
>  	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
>  	struct omap_dss_device *dssdev = &dsi->output;
>  
> +	cancel_delayed_work_sync(&dsi->dsi_disable_work);
> +
>  	dsi_bus_lock(dsi);
>  
>  	dsi->video_enabled = false;
> @@ -4840,6 +4865,18 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
>  	{ /* sentinel */ }
>  };
>  
> +static void omap_dsi_disable_work_callback(struct work_struct *work)
> +{
> +	struct dsi_data *dsi = container_of(work, struct dsi_data, dsi_disable_work.work);
> +
> +	dsi_bus_lock(dsi);
> +
> +	if (dsi->iface_enabled && !dsi->video_enabled)
> +		dsi_disable(dsi);
> +
> +	dsi_bus_unlock(dsi);
> +}
> +
>  static int dsi_probe(struct platform_device *pdev)
>  {
>  	const struct soc_device_attribute *soc;
> @@ -4873,6 +4910,8 @@ static int dsi_probe(struct platform_device *pdev)
>  	INIT_DEFERRABLE_WORK(&dsi->framedone_timeout_work,
>  			     dsi_framedone_timeout_work_callback);
>  
> +	INIT_DEFERRABLE_WORK(&dsi->dsi_disable_work, omap_dsi_disable_work_callback);
> +
>  #ifdef DSI_CATCH_MISSING_TE
>  	timer_setup(&dsi->te_timer, dsi_te_timeout, 0);
>  #endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
> index de9411067ba2..601707c0ecc4 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
> @@ -394,6 +394,7 @@ struct dsi_data {
>  	atomic_t do_ext_te_update;
>  
>  	bool te_enabled;
> +	bool iface_enabled;
>  	bool video_enabled;
>  
>  	struct delayed_work framedone_timeout_work;
> @@ -443,6 +444,8 @@ struct dsi_data {
>  
>  	struct omap_dss_device output;
>  	struct drm_bridge bridge;
> +
> +	struct delayed_work dsi_disable_work;
>  };
>  
>  struct dsi_packet_sent_handler_data {

-- 
Regards,

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

  reply	other threads:[~2020-12-08 15:48 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 12:28 [PATCH v5 00/29] Convert DSI code to use drm_mipi_dsi and drm_panel (second half) Tomi Valkeinen
2020-12-08 12:28 ` [PATCH v5 01/29] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
2020-12-14 13:09   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 02/29] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
2020-12-14 13:09   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 03/29] drm/omap: pll: fix iteration loop check Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 04/29] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 05/29] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 06/29] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
2020-12-14 14:22   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 07/29] drm/omap: dsi: simplify VC handling Tomi Valkeinen
2020-12-14 14:31   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 08/29] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
2020-12-14 14:32   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 09/29] drm/omap: dsi: cleanup dispc channel usage Tomi Valkeinen
2020-12-08 15:17   ` Laurent Pinchart
2020-12-14 14:35   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 10/29] drm/omap: dsi: rename 'channel' to 'vc' Tomi Valkeinen
2020-12-08 15:22   ` Laurent Pinchart
2020-12-14 15:18   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 11/29] drm/omap: dsi: pass vc to various functions Tomi Valkeinen
2020-12-08 15:38   ` Laurent Pinchart
2020-12-08 15:45     ` Tomi Valkeinen
2020-12-14 15:37   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 12/29] drm/omap: dsi: untangle vc & channel Tomi Valkeinen
2020-12-08 15:41   ` Laurent Pinchart
2020-12-14 15:47     ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 13/29] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
2020-12-14 15:50   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 14/29] drm/omap: dsi: enable HS before sending the frame Tomi Valkeinen
2020-12-08 15:42   ` Laurent Pinchart
2020-12-14 15:51   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 15/29] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
2020-12-14 15:54   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 16/29] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
2020-12-08 15:42   ` Laurent Pinchart
2020-12-14 15:55   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 17/29] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
2020-12-14 16:04   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 18/29] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
2020-12-14 16:06   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 19/29] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
2020-12-14 16:14   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 20/29] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
2020-12-14 16:16   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 21/29] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
2020-12-14 16:17   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 22/29] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
2020-12-14 16:20   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 23/29] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
2020-12-14 16:22   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 24/29] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
2020-12-14 16:34   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 25/29] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
2020-12-14 16:38   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 26/29] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
2020-12-14 16:39   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 27/29] drm/omap: dsi: remove ulps support Tomi Valkeinen
2020-12-14 17:39   ` Sebastian Reichel
2020-12-14 18:55     ` Tomi Valkeinen
2020-12-14 22:08       ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 28/29] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
2020-12-14 16:48   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 29/29] drm/omap: dsi: allow DSI commands to be sent early Tomi Valkeinen
2020-12-08 15:48   ` Laurent Pinchart [this message]
2020-12-10  7:34     ` Tomi Valkeinen
2020-12-10  8:17       ` Tomi Valkeinen
2020-12-14 17:17   ` Sebastian Reichel
2020-12-15 10:05     ` Tomi Valkeinen

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=X8+gXWBwLItZA7gA@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hns@goldelico.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=nikhil.nd@ti.com \
    --cc=nsekhar@ti.com \
    --cc=sam@ravnborg.org \
    --cc=sre@kernel.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox