From patchwork Tue Nov 7 09:56:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 10046127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7AE546031B for ; Tue, 7 Nov 2017 09:56:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 629E528F8B for ; Tue, 7 Nov 2017 09:56:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5752829CF3; Tue, 7 Nov 2017 09:56:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8037128F8B for ; Tue, 7 Nov 2017 09:56:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE08D6E3F5; Tue, 7 Nov 2017 09:56:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EF816E3F5 for ; Tue, 7 Nov 2017 09:56:55 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id vA79upKh024098; Tue, 7 Nov 2017 03:56:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1510048611; bh=RTwOnMqfwTOTlUBiTdyllvn4Mvhwl2zvgyfxFgWim1o=; h=From:To:CC:Subject:Date; b=AicfUIQLgqTr2nqDPryYZJqw2Nv44HmAwn6AGrZN8MKarm/WrIi0cKuAqWyPCJccR s7mSCyIHvSIvjlOTEYMbkDS/45qpM1bN6wjGYZ1M8NUpUVw14HooQms0bG3dv9nU+W AM5wPErsASPUMYtFD9tLDiKYO650nmvIklrVmzcM= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vA79uplf022760; Tue, 7 Nov 2017 03:56:51 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 7 Nov 2017 03:56:51 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 7 Nov 2017 03:56:51 -0600 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vA79unXS017691; Tue, 7 Nov 2017 03:56:50 -0600 From: Jyri Sarha To: Subject: [PATCH] drm/tilcdc: Remove drm_framebuffer_get() and *_put() calls Date: Tue, 7 Nov 2017 11:56:45 +0200 Message-ID: <1510048605-4407-1-git-send-email-jsarha@ti.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: airlied@linux.ie, tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com, Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 6ef4d1a..b81a593 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 @@ static void tilcdc_crtc_recover_work(struct work_struct *work) 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);