From patchwork Fri Sep 25 11:57:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 7263731 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9EA29F6DA for ; Fri, 25 Sep 2015 11:58:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4B9120AE7 for ; Fri, 25 Sep 2015 11:58:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DDA1E20AC0 for ; Fri, 25 Sep 2015 11:58:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7EFA6F08F; Fri, 25 Sep 2015 04:58:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.4.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFDE36F091 for ; Fri, 25 Sep 2015 04:58:04 -0700 (PDT) Received: from weser.hi.4.pengutronix.de ([10.1.0.109] helo=weser.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1ZfRda-0004Em-G9; Fri, 25 Sep 2015 13:58:02 +0200 From: Lucas Stach To: Russell King , Christian Gmeiner Subject: [PATCH 20/48] staging: etnaviv: provide etnaviv_queue_work() Date: Fri, 25 Sep 2015 13:57:32 +0200 Message-Id: <1443182280-15868-21-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443182280-15868-1-git-send-email-l.stach@pengutronix.de> References: <20150916080435.GA21084@n2100.arm.linux.org.uk> <1443182280-15868-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.109 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King Provide a helper to queue a work_struct onto our private workqueue. This avoids repetitions of: struct drm_device *dev = ... struct etnaviv_private *priv = dev->dev_private; queue_work(priv->wq, w); Signed-off-by: Russell King --- drivers/staging/etnaviv/etnaviv_drv.h | 7 +++++++ drivers/staging/etnaviv/etnaviv_gem.c | 4 +--- drivers/staging/etnaviv/etnaviv_gpu.c | 18 +++++------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/etnaviv/etnaviv_drv.h b/drivers/staging/etnaviv/etnaviv_drv.h index 98536090e947..8f9c1f747b4e 100644 --- a/drivers/staging/etnaviv/etnaviv_drv.h +++ b/drivers/staging/etnaviv/etnaviv_drv.h @@ -61,6 +61,13 @@ struct etnaviv_drm_private { struct workqueue_struct *wq; }; +static void etnaviv_queue_work(struct drm_device *dev, struct work_struct *w) +{ + struct etnaviv_drm_private *priv = drm->dev_private; + + queue_work(priv->wq, w); +} + int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_file *file); diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c index aaa0f5eaeabd..6e114a390101 100644 --- a/drivers/staging/etnaviv/etnaviv_gem.c +++ b/drivers/staging/etnaviv/etnaviv_gem.c @@ -800,7 +800,6 @@ static void __etnaviv_gem_userptr_get_pages(struct work_struct *_work) static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) { - struct etnaviv_drm_private *priv; struct page **pvec = NULL; struct get_pages_work *work; struct mm_struct *mm; @@ -859,8 +858,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) etnaviv_obj->userptr.work = &work->work; INIT_WORK(&work->work, __etnaviv_gem_userptr_get_pages); - priv = etnaviv_obj->base.dev->dev_private; - queue_work(priv->wq, &work->work); + etnaviv_queue_work(etnaviv_obj->base.dev, &work->work); return -EAGAIN; } diff --git a/drivers/staging/etnaviv/etnaviv_gpu.c b/drivers/staging/etnaviv/etnaviv_gpu.c index 39fe69414679..4f2174431c2b 100644 --- a/drivers/staging/etnaviv/etnaviv_gpu.c +++ b/drivers/staging/etnaviv/etnaviv_gpu.c @@ -727,7 +727,8 @@ static void recover_worker(struct work_struct *work) /* TODO gpu->funcs->recover(gpu); */ mutex_unlock(&dev->struct_mutex); - etnaviv_gpu_retire(gpu); + /* Retire the buffer objects in a work */ + etnaviv_queue_work(gpu->dev, &gpu->retire_work); } static void hangcheck_timer_reset(struct etnaviv_gpu *gpu) @@ -740,8 +741,6 @@ static void hangcheck_timer_reset(struct etnaviv_gpu *gpu) static void hangcheck_handler(unsigned long data) { struct etnaviv_gpu *gpu = (struct etnaviv_gpu *)data; - struct drm_device *dev = gpu->drm; - struct etnaviv_drm_private *priv = dev->dev_private; uint32_t fence = gpu->retired_fence; bool progress = false; @@ -765,7 +764,7 @@ static void hangcheck_handler(unsigned long data) dev_err(gpu->dev, " completed fence: %u\n", fence); dev_err(gpu->dev, " submitted fence: %u\n", gpu->submitted_fence); - queue_work(priv->wq, &gpu->recover_work); + etnaviv_queue_work(gpu->dev, &gpu->recover_work); } /* if still more pending work, reset the hangcheck timer: */ @@ -864,14 +863,6 @@ static void retire_worker(struct work_struct *work) wake_up_all(&gpu->fence_event); } -/* call from irq handler to schedule work to retire bo's */ -void etnaviv_gpu_retire(struct etnaviv_gpu *gpu) -{ - struct etnaviv_drm_private *priv = gpu->drm->dev_private; - - queue_work(priv->wq, &gpu->retire_work); -} - int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, uint32_t fence, struct timespec *timeout) { @@ -1044,7 +1035,8 @@ static irqreturn_t irq_handler(int irq, void *data) pm_runtime_put_autosuspend(gpu->dev); } - etnaviv_gpu_retire(gpu); + /* Retire the buffer objects in a work */ + etnaviv_queue_work(gpu->dev, &gpu->retire_work); ret = IRQ_HANDLED; }