From 4e5ca2d930aa8714400aedf4bf1dc959cb04280f Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Tue, 5 Dec 2017 16:30:51 -0700 Subject: drm/tilcdc: ensure nonatomic iowrite64 is not used Add a check to ensure iowrite64 is only used if it is atomic. It was decided in [1] that the tilcdc driver should not be using an atomic operation (so it was left out of this patchset). However, it turns out that through the drm code, a nonatomic header is actually included: include/linux/io-64-nonatomic-lo-hi.h is included from include/drm/drm_os_linux.h:9:0, from include/drm/drmP.h:74, from include/drm/drm_modeset_helper.h:26, from include/drm/drm_atomic_helper.h:33, from drivers/gpu/drm/tilcdc/tilcdc_crtc.c:19: And thus, without this change, this patchset would inadvertantly change the behaviour of the tilcdc driver. [1] lkml.kernel.org/r/CAK8P3a2HhO_zCnsTzq7hmWSz5La5Thu19FWZpun16iMnyyNreQ@mail.gmail.com Signed-off-by: Logan Gunthorpe Reviewed-by: Andy Shevchenko Cc: Jyri Sarha Cc: Arnd Bergmann Cc: Tomi Valkeinen Cc: David Airlie Signed-off-by: Jyri Sarha --- drivers/gpu/drm/tilcdc/tilcdc_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/tilcdc') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_regs.h b/drivers/gpu/drm/tilcdc/tilcdc_regs.h index 9d528c0a67a4..5048ebb86835 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_regs.h +++ b/drivers/gpu/drm/tilcdc/tilcdc_regs.h @@ -133,7 +133,7 @@ static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data) struct tilcdc_drm_private *priv = dev->dev_private; volatile void __iomem *addr = priv->mmio + reg; -#ifdef iowrite64 +#if defined(iowrite64) && !defined(iowrite64_is_nonatomic) iowrite64(data, addr); #else __iowmb(); -- cgit v1.2.3 From 1775ede035a425ff35b73d6daceb619061278ade Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 3 Nov 2017 23:30:54 +0200 Subject: drm/tilcdc: Remove drm_framebuffer_get() and *_put() calls The drm_framebuffer_get() and drm_framebuffer_put() calls in the tilcdc driver are obsolete. The drm atomic modesetting core should take care of holding the references while the atomic state object is in use. The old state is deleted when a commit of a new one is completed after drm_atomic_helper_wait_for_vblanks(). This also fixes an occasional framebuffer leak the old drm_framebuffer_get() and drm_framebuffer_put() code had. Signed-off-by: Jyri Sarha --- drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 49 ------------------------------------ 1 file changed, 49 deletions(-) (limited to 'drivers/gpu/drm/tilcdc') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 6ef4d1a1e3a9..b81a593aefb2 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -51,12 +51,8 @@ struct tilcdc_crtc { ktime_t last_vblank; unsigned int hvtotal_us; - struct drm_framebuffer *curr_fb; struct drm_framebuffer *next_fb; - /* for deferred fb unref's: */ - struct drm_flip_work unref_work; - /* Only set if an external encoder is connected */ bool simulate_vesa_sync; @@ -70,20 +66,8 @@ struct tilcdc_crtc { }; #define to_tilcdc_crtc(x) container_of(x, struct tilcdc_crtc, base) -static void unref_worker(struct drm_flip_work *work, void *val) -{ - struct tilcdc_crtc *tilcdc_crtc = - container_of(work, struct tilcdc_crtc, unref_work); - struct drm_device *dev = tilcdc_crtc->base.dev; - - mutex_lock(&dev->mode_config.mutex); - drm_framebuffer_put(val); - mutex_unlock(&dev->mode_config.mutex); -} - static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb) { - struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); struct drm_device *dev = crtc->dev; struct tilcdc_drm_private *priv = dev->dev_private; struct drm_gem_cma_object *gem; @@ -108,12 +92,6 @@ static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb) dma_base_and_ceiling = (u64)end << 32 | start; tilcdc_write64(dev, LCDC_DMA_FB_BASE_ADDR_0_REG, dma_base_and_ceiling); - - if (tilcdc_crtc->curr_fb) - drm_flip_work_queue(&tilcdc_crtc->unref_work, - tilcdc_crtc->curr_fb); - - tilcdc_crtc->curr_fb = fb; } /* @@ -464,8 +442,6 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) set_scanout(crtc, fb); - drm_framebuffer_get(fb); - crtc->hwmode = crtc->state->adjusted_mode; tilcdc_crtc->hvtotal_us = @@ -524,7 +500,6 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown) { struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); struct drm_device *dev = crtc->dev; - struct tilcdc_drm_private *priv = dev->dev_private; int ret; mutex_lock(&tilcdc_crtc->enable_lock); @@ -554,20 +529,6 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown) pm_runtime_put_sync(dev->dev); - if (tilcdc_crtc->next_fb) { - drm_flip_work_queue(&tilcdc_crtc->unref_work, - tilcdc_crtc->next_fb); - tilcdc_crtc->next_fb = NULL; - } - - if (tilcdc_crtc->curr_fb) { - drm_flip_work_queue(&tilcdc_crtc->unref_work, - tilcdc_crtc->curr_fb); - tilcdc_crtc->curr_fb = NULL; - } - - drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); - tilcdc_crtc->enabled = false; mutex_unlock(&tilcdc_crtc->enable_lock); } @@ -614,7 +575,6 @@ out: static void tilcdc_crtc_destroy(struct drm_crtc *crtc) { - struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); struct tilcdc_drm_private *priv = crtc->dev->dev_private; tilcdc_crtc_shutdown(crtc); @@ -623,7 +583,6 @@ static void tilcdc_crtc_destroy(struct drm_crtc *crtc) of_node_put(crtc->port); drm_crtc_cleanup(crtc); - drm_flip_work_cleanup(&tilcdc_crtc->unref_work); } int tilcdc_crtc_update_fb(struct drm_crtc *crtc, @@ -638,9 +597,6 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc, return -EBUSY; } - drm_framebuffer_get(fb); - - crtc->primary->fb = fb; tilcdc_crtc->event = event; mutex_lock(&tilcdc_crtc->enable_lock); @@ -936,8 +892,6 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc) now = ktime_get(); - drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); - spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags); tilcdc_crtc->last_vblank = now; @@ -1064,9 +1018,6 @@ int tilcdc_crtc_create(struct drm_device *dev) init_waitqueue_head(&tilcdc_crtc->frame_done_wq); - drm_flip_work_init(&tilcdc_crtc->unref_work, - "unref", unref_worker); - spin_lock_init(&tilcdc_crtc->irq_lock); INIT_WORK(&tilcdc_crtc->recover_work, tilcdc_crtc_recover_work); -- cgit v1.2.3 From 584d4ed80e93889c54daeee75243c765f9d1e879 Mon Sep 17 00:00:00 2001 From: Xiongwei Song Date: Sat, 2 Dec 2017 19:24:22 +0800 Subject: drm/tilcdc: make tilcdc_mode_hvtotal() static The function tilcdc_mode_hvtotal is local to the source and does not need to be in global scope, so make it static. drivers/gpu/drm/tilcdc/tilcdc_crtc.c:297:6: warning: no previous prototype for 'tilcdc_mode_hvtotal' [-Wmissing-prototypes] uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode) Signed-off-by: Xiongwei Song Signed-off-by: Jyri Sarha --- drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/tilcdc') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index b81a593aefb2..8bf6bb93dc79 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -272,7 +272,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc) LCDC_V2_CORE_CLK_EN); } -uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode) +static uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode) { return (uint) div_u64(1000llu * mode->htotal * mode->vtotal, mode->clock); -- cgit v1.2.3