From patchwork Fri Feb 1 00:50:56 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: 157166 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7870425jaa; Thu, 31 Jan 2019 16:51:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN7t7h+EHr+LdFhEQxM89Lwzb2s5gWurVetHIJ7D4GySI3lidDMa/KTmiZFhg8ETKbDYGBW3 X-Received: by 2002:a17:902:b406:: with SMTP id x6mr35464590plr.329.1548982271407; Thu, 31 Jan 2019 16:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548982271; cv=none; d=google.com; s=arc-20160816; b=UZrU1p47HHad8fhPNb8pbzzSs0RR0IYfeQCiHfcaPsSOG515iZndX3SD9E+K6Yb8iA XZ4qBSkmn8+1ycoLdJL2of5R3sMqyXR0dBVsR8j9BZNS/988AQUFW5U0KHRI6RGQtGyh 6DRiQpGdmZOjC1c6mAtrTP7smuQyG0Uf70jdacVspbrkWK9jHfwYvaWGgGXdSeclLO3m G2lDbv0fQmd/WCHmC7lL+M/ttiB3D3ubY4ZVlshEEluu2k599C4lBliq8tvdTJ3JAZ3z z7BRIyynW6sjysPOiFHqevLhj+fJGhmMGrS3Ebo6wD/08MQRdQBby05MoM1KS49CdSOP zqEQ== 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=VWv8zjyYh3gg6arKqBLtueKXrA7ob3JR2fEQbe7uuS4=; b=uzeOx2HPBMN/asEFydiPbv0a6x9L5ZoI42ITxIVlpZiqzJu9ENBtOMUIcjbeHhU3lF 601QgBBOpXSgC3qbotrburtp8HMBlicfPpYzZ0/3TuacrEqIljVDFH6K0+ISVArIPHWl aEYTcm9TFY0yCTjFd93VuHAhEs7ceRp2yBhzUCfUGAmJMc6/EE2gXRy6Cr98L7FEgbpo M1YMfnbaq5LiDaVW6JgMw8lFHFo3K3tREkgJzHYWmbmHdOqn68pnW/Sc5u5EZruMO3Ub 8VL2izqvvFkx17vna8QgtqFDYeKSQCFYoVTggEZDrValFKpoNmRULh8jCphZYP9WC+MD pWtg== 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 s5si76944pgl.481.2019.01.31.16.51.09; Thu, 31 Jan 2019 16:51:11 -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 S1728907AbfBAAvG (ORCPT + 15 others); Thu, 31 Jan 2019 19:51:06 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:35867 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfBAAvF (ORCPT ); Thu, 31 Jan 2019 19:51:05 -0500 Received: by mail-oi1-f194.google.com with SMTP id x23so4469763oix.3 for ; Thu, 31 Jan 2019 16:51:05 -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=VWv8zjyYh3gg6arKqBLtueKXrA7ob3JR2fEQbe7uuS4=; b=c8fxOJNauXd5q6O3cRKw3XAK1aNfLYzljsPKdKAq9zSZsEuQSRVH1uLt7sN83wA5+g 0krpbnmZXHX4P2BnW5WAEGt2bmcFqRrMZXyK6JQwZvi0Y6MsEiCRCXFQHs+ygIo68QhY giJqModQIZOxYXvQ0Z8VX3S4FAo00SB8mcHefkiXvbNUurXVoPqtCZFrjFsP2GK8yjx9 V4RQ31/+fs1Yt1K6EOIDVfh86e6KYsObZ4NrpmtbGR/9SR2cU2Q9xi/vzedxsXpTPphO QIr7JMvlVYCrEEZdlt123IXYIm1/5t2ttP9G/n1YMlYc4ZRZhDyT7NQgR29iMCGRNNr7 au5w== X-Gm-Message-State: AHQUAuZpXvVx9es2jCiFbEwBTALwxDpTRUMzEd5Q9ndMzKhsEh3Mky4Y iEpkUFNsIsuX0WXmr4Uk/Q== X-Received: by 2002:aca:4e92:: with SMTP id c140mr16486007oib.97.1548982264658; Thu, 31 Jan 2019 16:51: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 31sm3137699otw.55.2019.01.31.16.51.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:51:04 -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 4/5] drm: v3d: Switch to use drm_gem_object reservation_object Date: Thu, 31 Jan 2019 18:50:56 -0600 Message-Id: <20190201005057.13648-5-robh@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190201005057.13648-1-robh@kernel.org> References: <20190201005057.13648-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 --- drivers/gpu/drm/v3d/v3d_bo.c | 14 +------------- drivers/gpu/drm/v3d/v3d_drv.c | 1 - drivers/gpu/drm/v3d/v3d_drv.h | 5 ----- drivers/gpu/drm/v3d/v3d_gem.c | 35 +++++++++-------------------------- 4 files changed, 10 insertions(+), 45 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..5641d056b85d 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.h +++ b/drivers/gpu/drm/v3d/v3d_drv.h @@ -133,10 +133,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 +277,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; }