Skip to contentSkip to conversation

drm/tilcdc: do the complete reset sequence if the LCDC is enabled

PATCH In review Emiliano Ingrassia 2 participants 2 messages Mar 28, 2017 – Apr 10, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tilcdc: do the complete reset sequence if the LCDC is enabled

If the LCD controller was already enabled (e.g. by the bootloader), do the complete software reset sequence to avoid time out while loading the palette and a consequent time out waiting for vblank.

---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +23 -0
index 3621ff42979f..589156b2f76c 100644
@@ -208,10 +208,33 @@ static void reset(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
 	struct tilcdc_drm_private *priv = dev->dev_private;
+	struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
+	int ret;
 
 	if (priv->rev != 2)
 		return;
 
+	/*
+	 * If the LCDC was already enabled (e.g. by the bootloader)
+	 * do the complete software reset sequence.
+	 */
+	if (tilcdc_read(dev, LCDC_RASTER_CTRL_REG) & LCDC_RASTER_ENABLE) {
+
+		/* Enable DMA Frame Done Interrupt */
+		tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG, LCDC_FRAME_DONE);
+		tilcdc_clear_irqstatus(dev, 0xffffffff);
+
+		tilcdc_crtc->frame_done = false;
+		tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
+
+		ret = wait_event_timeout(tilcdc_crtc->frame_done_wq,
+					 tilcdc_crtc->frame_done,
+					 msecs_to_jiffies(500));
+		if (ret == 0)
+			dev_err(dev->dev, "%s: timeout waiting for framedone while resetting LCDC\n",
+				__func__);
+	}
+
 	tilcdc_set(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
 	usleep_range(250, 1000);
 	tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 5 lines · Emiliano Ingrassia

If the LCD controller was already enabled (e.g. by the bootloader), do the complete software reset sequence to avoid time out while loading the palette and a consequent time out waiting for vblank.

Thanks for the patch, and sorry that I did not respond to you earlier.

The issue is obviously real, but I do not like duplicating the already existing code for CRTC disable irq enable. Another issue is making the check every time the CRTC is turned on.

I'll send a patch of my own to try to fix the issue shortly. Could you spare time to test it if it fixes the issue on your platform?

Best regards,
Jyri

Quoted 33 lines
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +16 -0
index 3621ff42979f..589156b2f76c 100644
@@ -208,10 +208,33 @@ static void reset(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
 	struct tilcdc_drm_private *priv = dev->dev_private;
+	struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
+	int ret;
 
 	if (priv->rev != 2)
 		return;
 
+	/*
+	 * If the LCDC was already enabled (e.g. by the bootloader)
+	 * do the complete software reset sequence.
+	 */
+	if (tilcdc_read(dev, LCDC_RASTER_CTRL_REG) & LCDC_RASTER_ENABLE) {
+
+		/* Enable DMA Frame Done Interrupt */
+		tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG, LCDC_FRAME_DONE);
+		tilcdc_clear_irqstatus(dev, 0xffffffff);
+
+		tilcdc_crtc->frame_done = false;
+		tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
+
+		ret = wait_event_timeout(tilcdc_crtc->frame_done_wq,

drivers/gpu/drm/tilcdc/tilcdc_crtc.c static void reset(struct drm_crtc *crtc) · line 240

Quoted 10 lines
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +7 -0
+					 tilcdc_crtc->frame_done,
+					 msecs_to_jiffies(500));
+		if (ret == 0)
+			dev_err(dev->dev, "%s: timeout waiting for framedone while resetting LCDC\n",
+				__func__);
+	}
+
 	tilcdc_set(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
 	usleep_range(250, 1000);
 	tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel