dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: <dri-devel@lists.freedesktop.org>
Cc: tomi.valkeinen@ti.com
Subject: [PATCH v6 84/84] drm/omap: dsi: allow DSI commands to be sent early
Date: Tue, 15 Dec 2020 12:46:57 +0200	[thread overview]
Message-ID: <20201215104657.802264-85-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <20201215104657.802264-1-tomi.valkeinen@ti.com>

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.

Clarifications for the delayed disable work and the panel doing DSI
transactions:

bridge_enable: If the disable callback is called just before
bridge_enable takes the dsi_bus_lock, no problem, bridge_enable just
enables the interface again. If the callback is ran just after
bridge_enable's dsi_bus_unlock, no problem, dsi->video_enabled == true
so the callback does nothing.

bridge_disable: similar to bridge-enable, the callback won't do anything
if video_enabled == true, and after bridge-disable has turned the video
and the interface off, there's nothing to do for the callback.

omap_dsi_host_detach: this is called when the panel does
mipi_dsi_detach(), and we expect the panel to _not_ do any DSI
transactions after (or during) mipi_dsi_detatch(), so there are no
race conditions.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 50 +++++++++++++++++++++++++++----
 drivers/gpu/drm/omapdrm/dss/dsi.h |  3 ++
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 0dd5c0381080..8e11612f5fe1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3500,6 +3500,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);
@@ -3512,6 +3515,8 @@ static void dsi_enable(struct dsi_data *dsi)
 	if (r)
 		goto err_init_dsi;
 
+	dsi->iface_enabled = true;
+
 	mutex_unlock(&dsi->lock);
 
 	return;
@@ -3527,6 +3532,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);
@@ -3538,6 +3546,8 @@ static void dsi_disable(struct dsi_data *dsi)
 
 	dsi_runtime_put(dsi);
 
+	dsi->iface_enabled = false;
+
 	mutex_unlock(&dsi->lock);
 }
 
@@ -4226,10 +4236,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);
 
@@ -4394,6 +4406,15 @@ 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);
+
+	dsi_bus_lock(dsi);
+
+	if (dsi->iface_enabled)
+		dsi_disable(dsi);
+
+	dsi_bus_unlock(dsi);
+
 	omap_dsi_unregister_te_irq(dsi);
 	dsi->dsidev = NULL;
 	return 0;
@@ -4629,9 +4650,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);
+
 	dsi_bus_lock(dsi);
 
-	dsi_enable(dsi);
+	if (!dsi->iface_enabled)
+		dsi_enable(dsi);
 
 	dsi_enable_video_output(dssdev, VC_VIDEO);
 
@@ -4645,6 +4669,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;
@@ -4837,6 +4863,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;
@@ -4870,6 +4908,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 {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

      parent reply	other threads:[~2020-12-15 10:49 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 10:45 [PATCH v6 00/84] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 01/84] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 02/84] drm/omap: drop unused dsi.configure_pins Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 03/84] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 04/84] drm/omap: constify write buffers Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 05/84] drm/omap: dsi: add generic transfer function Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 06/84] drm/omap: panel-dsi-cm: convert to transfer API Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 07/84] drm/omap: dsi: unexport specific data transfer functions Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 08/84] drm/omap: dsi: drop virtual channel logic Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 09/84] drm/omap: dsi: simplify write function Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 10/84] drm/omap: dsi: simplify read functions Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 11/84] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 12/84] drm/omap: dsi: introduce mipi_dsi_host Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 13/84] drm/omap: panel-dsi-cm: use DSI helpers Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 14/84] drm/omap: dsi: request VC via mipi_dsi_attach Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 15/84] drm/omap: panel-dsi-cm: drop hardcoded VC Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 16/84] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 17/84] drm/omap: dsi: drop unused memory_read() Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 18/84] drm/omap: dsi: drop unused get_te() Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 19/84] drm/omap: dsi: drop unused enable_te() Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 20/84] drm/omap: dsi: drop useless sync() Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 21/84] drm/omap: dsi: use pixel-format and mode from attach Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 22/84] drm/omap: panel-dsi-cm: use bulk regulator API Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 23/84] drm/omap: dsi: lp/hs switching support for transfer() Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 24/84] drm/omap: dsi: move TE GPIO handling into core Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 25/84] drm/omap: dsi: drop custom enable_te() API Tomi Valkeinen
2020-12-15 10:45 ` [PATCH v6 26/84] drm/omap: dsi: do bus locking in host driver Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 27/84] drm/omap: dsi: untangle ulps ops from enable/disable Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 28/84] drm/omap: dsi: do ULPS in host driver Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 29/84] drm/omap: dsi: move panel refresh function to host Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 30/84] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 31/84] drm/omap: dsi: drop custom panel capability support Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 32/84] drm/omap: dsi: convert to drm_panel Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 33/84] drm/omap: drop omapdss-boot-init Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 34/84] drm/omap: dsi: implement check timings Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 35/84] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 36/84] drm/omap: panel-dsi-cm: support unbinding Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 37/84] drm/omap: panel-dsi-cm: fix remove() Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 38/84] drm/omap: remove global dss_device variable Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 39/84] drm/panel: Move OMAP's DSI command mode panel driver Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 40/84] drm/omap: dsi: Register a drm_bridge Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 41/84] drm/omap: remove legacy DSS device operations Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 42/84] drm/omap: remove unused omap_connector Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 43/84] drm/omap: simplify omap_display_id Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 44/84] drm/omap: drop unused DSS next pointer Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 45/84] drm/omap: drop DSS ops_flags Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 46/84] drm/omap: drop dssdev display field Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 47/84] drm/omap: simplify DSI manual update code Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 48/84] drm/omap: dsi: simplify pin config Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 49/84] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 50/84] drm/omap: squash omapdrm sub-modules into one Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 51/84] drm/omap: remove unused display.c Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 52/84] drm/omap: drop unused owner field Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 53/84] drm/omap: remove dispc_ops Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 54/84] drm/omap: remove dss_mgr_ops Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 55/84] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 56/84] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 57/84] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 58/84] drm/omap: pll: fix iteration loop check Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 59/84] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 60/84] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 61/84] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 62/84] drm/omap: dsi: simplify VC handling Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 63/84] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 64/84] drm/omap: dsi: cleanup dispc channel usage Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 65/84] drm/omap: dsi: rename 'channel' to 'vc' Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 66/84] drm/omap: dsi: pass vc and channel to various functions Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 67/84] drm/omap: dsi: untangle vc & channel Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 68/84] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 69/84] drm/omap: dsi: enable HS before sending the frame Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 70/84] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 71/84] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 72/84] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 73/84] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 74/84] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 75/84] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 76/84] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 77/84] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 78/84] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 79/84] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 80/84] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 81/84] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 82/84] drm/omap: dsi: remove ulps support Tomi Valkeinen
2020-12-15 10:46 ` [PATCH v6 83/84] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
2020-12-15 10:46 ` Tomi Valkeinen [this message]

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=20201215104657.802264-85-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=dri-devel@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).