From patchwork Sat Feb 2 15:41:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 157346 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1833008jaa; Sat, 2 Feb 2019 07:42:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IaOU6SI1Q4XujJjLNf75ymV3wQPX1BiLHdlDxNKAoAqO8CtclchP+iHuVzzTJv+EMOvec0s X-Received: by 2002:a62:68c5:: with SMTP id d188mr5855257pfc.194.1549122127942; Sat, 02 Feb 2019 07:42:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549122127; cv=none; d=google.com; s=arc-20160816; b=f5/3z/z6QyfpfhlxR/7kXzufaqpVPoGkN/dbqWQ21W3UfxRGPLWPXffLyg3AiIHwEm RfZDtzyaYYsE88rBMCbmM5LpcIW/+8sFNK1mf862EbHgE4Iv3hHMybuGN2sxHtLywT1z gWDpieCKuXkUTPJur2ABoepsTmJWDaLTTnNLTkkbgCfwi3nGqrWsSu5XY4uvPL+Wu7Up gtF2NjpdxvB9MN+6x9iXTSno2zjH21LphQ4roUhGU+JGBKwpG3zdNdVaJFmoy99NFNVB M3441rUGEga64I0PCmG37HIpzsFo6IG42nPqunPAy7jeNzYTBMY+v66r+iGqnRqXo1CY jW6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=C1v72TBNK/KEWh0PzHVLvRtsJ9IEMbuo39uJ7/6p4rE=; b=GUTAiOPer7vQwkQq8ebsnTG0d0wvM5hYrYm1Wuq5pqABPxN6/869UyjOoFGka9x+Bv QcAtCVvUyWTtHLi8QTUzdoHLUQw/Q2PJtNg1fPyoh+eRyN8mb1pUf3jmyM+227DHUDXO +vZJNFY9ffqZYETNZ/B2o+Rl66dXuiY+xHPzrFljuJ0dzeeArK8DZ1yavWJamgup5zYk dB2peh+ZYWEI5CsWvEwboPxAhUCnLaLQpPJACTWqCqExaYUNFYL6O+PDR7WqMtkMDSO3 +AsbKgsuCnLanss6zSSsQG8dZ4858up8Q58AB3D+sO04OZNr5EP5c2NOg+nAtL5XLuO6 C6XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si8238222pli.50.2019.02.02.07.42.07; Sat, 02 Feb 2019 07:42:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbfBBPmH (ORCPT + 15 others); Sat, 2 Feb 2019 10:42:07 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:38978 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbfBBPmH (ORCPT ); Sat, 2 Feb 2019 10:42:07 -0500 Received: by mail-oi1-f193.google.com with SMTP id i6so8313498oia.6 for ; Sat, 02 Feb 2019 07:42:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C1v72TBNK/KEWh0PzHVLvRtsJ9IEMbuo39uJ7/6p4rE=; b=JjxBl4TYddlCZmUzzixWyw3yVXn09/SEkCuGQCx2ky8zr8J07ivuz/0agdYOltTtFG eHJQ02W9BU5myp2lk6xOq+xJGgBNqFahkkdWYisUYVgqCDgwSOuLkA++VJV2vzduIHjT a1s+gmgukxpC52M/71BLZBxzYzxu9ZP10lmZPegiL6/UNiHxBiv3hIk2p1y11MiqmyNF cbK9cJ3UtmQrJB2ickM3iurwAwZg9dh2nOrNPPOW5g05cJqUvH8Ut0HO9VXWdGbrD+X7 sNHtmVe4TxcOim3DM0ihHEuVZc6lYKwAzEo4uCvnJFoqKbkWRBlJOHxXpzBr9dKh5Ncm rgzw== X-Gm-Message-State: AHQUAuaUy4ZMGdXqHD7KoMiOI16QdglsRPGplW4p2JOs6vojF5IKMHAs bd7W7/jLPbs7SW8XQFv/lg== X-Received: by 2002:aca:2ecf:: with SMTP id u198mr4349687oiu.338.1549122124283; Sat, 02 Feb 2019 07:42:04 -0800 (PST) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id 187sm5215559oic.12.2019.02.02.07.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 07:42:03 -0800 (PST) From: Rob Herring To: dri-devel@lists.freedesktop.org Cc: Christian Gmeiner , Daniel Vetter , David Airlie , Eric Anholt , etnaviv@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Lucas Stach , Maarten Lankhorst , Maxime Ripard , Rob Clark , Russell King , Sean Paul Subject: [PATCH v2 4/5] drm: v3d: Switch to use drm_gem_object reservation_object Date: Sat, 2 Feb 2019 09:41:57 -0600 Message-Id: <20190202154158.10443-5-robh@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190202154158.10443-1-robh@kernel.org> References: <20190202154158.10443-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Now that the base struct drm_gem_object has a reservation_object, use it and remove the private BO one. Cc: Eric Anholt Cc: Daniel Vetter Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Signed-off-by: Rob Herring --- v2: - No change. Added the timeout handling to drm_gem_reservation_object_wait drivers/gpu/drm/v3d/v3d_bo.c | 14 +------------- drivers/gpu/drm/v3d/v3d_drv.c | 1 - drivers/gpu/drm/v3d/v3d_drv.h | 6 ------ drivers/gpu/drm/v3d/v3d_gem.c | 35 +++++++++-------------------------- 4 files changed, 10 insertions(+), 46 deletions(-) -- 2.19.1 diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c index a08766d39eab..814213d18a15 100644 --- a/drivers/gpu/drm/v3d/v3d_bo.c +++ b/drivers/gpu/drm/v3d/v3d_bo.c @@ -155,9 +155,6 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv, return bo; obj = &bo->base; - bo->resv = &bo->_resv; - reservation_object_init(bo->resv); - ret = v3d_bo_get_pages(bo); if (ret) goto free_mm; @@ -194,8 +191,6 @@ void v3d_free_object(struct drm_gem_object *obj) v3d->bo_stats.pages_allocated -= obj->size >> PAGE_SHIFT; mutex_unlock(&v3d->bo_lock); - reservation_object_fini(&bo->_resv); - v3d_bo_put_pages(bo); if (obj->import_attach) @@ -212,13 +207,6 @@ void v3d_free_object(struct drm_gem_object *obj) kfree(bo); } -struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj) -{ - struct v3d_bo *bo = to_v3d_bo(obj); - - return bo->resv; -} - static void v3d_set_mmap_vma_flags(struct vm_area_struct *vma) { @@ -290,7 +278,7 @@ v3d_prime_import_sg_table(struct drm_device *dev, return ERR_CAST(bo); obj = &bo->base; - bo->resv = attach->dmabuf->resv; + obj->resv = attach->dmabuf->resv; bo->sgt = sgt; obj->import_attach = attach; diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index f0afcec72c34..bafe8e54e75b 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -214,7 +214,6 @@ static struct drm_driver v3d_drm_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = drm_gem_prime_import, .gem_prime_export = drm_gem_prime_export, - .gem_prime_res_obj = v3d_prime_res_obj, .gem_prime_get_sg_table = v3d_prime_get_sg_table, .gem_prime_import_sg_table = v3d_prime_import_sg_table, .gem_prime_mmap = v3d_prime_mmap, diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h index dcb772a19191..fc35412eba33 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.h +++ b/drivers/gpu/drm/v3d/v3d_drv.h @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* Copyright (C) 2015-2018 Broadcom */ -#include #include #include #include @@ -133,10 +132,6 @@ struct v3d_bo { * v3d_exec_info->unref_list */ struct list_head unref_head; - - /* normally (resv == &_resv) except for imported bo's */ - struct reservation_object *resv; - struct reservation_object _resv; }; static inline struct v3d_bo * @@ -281,7 +276,6 @@ int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); vm_fault_t v3d_gem_fault(struct vm_fault *vmf); int v3d_mmap(struct file *filp, struct vm_area_struct *vma); -struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj); int v3d_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); struct sg_table *v3d_prime_get_sg_table(struct drm_gem_object *obj); struct drm_gem_object *v3d_prime_import_sg_table(struct drm_device *dev, diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index 05ca6319065e..bee4fc3f47a8 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -214,7 +214,7 @@ v3d_attach_object_fences(struct v3d_bo **bos, int bo_count, for (i = 0; i < bo_count; i++) { /* XXX: Use shared fences for read-only objects. */ - reservation_object_add_excl_fence(bos[i]->resv, fence); + reservation_object_add_excl_fence(bos[i]->base.resv, fence); } } @@ -226,7 +226,7 @@ v3d_unlock_bo_reservations(struct v3d_bo **bos, int i; for (i = 0; i < bo_count; i++) - ww_mutex_unlock(&bos[i]->resv->lock); + ww_mutex_unlock(&bos[i]->base.resv->lock); ww_acquire_fini(acquire_ctx); } @@ -252,7 +252,7 @@ v3d_lock_bo_reservations(struct v3d_bo **bos, if (contended_lock != -1) { struct v3d_bo *bo = bos[contended_lock]; - ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, + ret = ww_mutex_lock_slow_interruptible(&bo->base.resv->lock, acquire_ctx); if (ret) { ww_acquire_done(acquire_ctx); @@ -264,18 +264,18 @@ v3d_lock_bo_reservations(struct v3d_bo **bos, if (i == contended_lock) continue; - ret = ww_mutex_lock_interruptible(&bos[i]->resv->lock, + ret = ww_mutex_lock_interruptible(&bos[i]->base.resv->lock, acquire_ctx); if (ret) { int j; for (j = 0; j < i; j++) - ww_mutex_unlock(&bos[j]->resv->lock); + ww_mutex_unlock(&bos[j]->base.resv->lock); if (contended_lock != -1 && contended_lock >= i) { struct v3d_bo *bo = bos[contended_lock]; - ww_mutex_unlock(&bo->resv->lock); + ww_mutex_unlock(&bo->base.resv->lock); } if (ret == -EDEADLK) { @@ -294,7 +294,7 @@ v3d_lock_bo_reservations(struct v3d_bo **bos, * before we commit the CL to the hardware. */ for (i = 0; i < bo_count; i++) { - ret = reservation_object_reserve_shared(bos[i]->resv, 1); + ret = reservation_object_reserve_shared(bos[i]->base.resv, 1); if (ret) { v3d_unlock_bo_reservations(bos, bo_count, acquire_ctx); @@ -453,8 +453,6 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data, { int ret; struct drm_v3d_wait_bo *args = data; - struct drm_gem_object *gem_obj; - struct v3d_bo *bo; ktime_t start = ktime_get(); u64 delta_ns; unsigned long timeout_jiffies = @@ -463,21 +461,8 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data, if (args->pad != 0) return -EINVAL; - gem_obj = drm_gem_object_lookup(file_priv, args->handle); - if (!gem_obj) { - DRM_DEBUG("Failed to look up GEM BO %d\n", args->handle); - return -EINVAL; - } - bo = to_v3d_bo(gem_obj); - - ret = reservation_object_wait_timeout_rcu(bo->resv, - true, true, - timeout_jiffies); - - if (ret == 0) - ret = -ETIME; - else if (ret > 0) - ret = 0; + ret = drm_gem_reservation_object_wait(file_priv, args->handle, + true, timeout_jiffies); /* Decrement the user's timeout, in case we got interrupted * such that the ioctl will be restarted. @@ -492,8 +477,6 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data, if (ret == -ETIME && args->timeout_ns) ret = -EAGAIN; - drm_gem_object_put_unlocked(gem_obj); - return ret; }