From patchwork Fri Feb 1 00:50:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157163 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7870323jaa; Thu, 31 Jan 2019 16:51:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6cOswfrse+HB77PN/wWO985viDf8NUYlsV2dx4NDANZu9Qu8k37BMHodL0wIvTWIhoTOU7 X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr36417067pll.273.1548982265541; Thu, 31 Jan 2019 16:51:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548982265; cv=none; d=google.com; s=arc-20160816; b=eivAYd7a3gueVwuPDJ6bQLbxmKjDR7xS8coV3ZgxSu+MOfq0iNamlM/c3yTaOeErAU JmQX5vDFUPMoL+YmZ5IWoqfhBeDXtlAhcKzGjS1nfIVKV/uDraaIDCqeYQakZKv43s5w 4G+Tu6aRyUusL9Dgxu7vvPYBStfmr3GrOrlqoZ7hT6TXh+LFCFTJjRdVSsR/eKvgHRYo GGuA8qwDx3J724Okj+1hLKLEUWCLhbarbc9vsuTRImMGrvgsXj9PUJedBPEs5oatfzdT qRmBLLpfvQ0aje+mRMFQdZza8I6Jzefjjru+B6tuX/ygSEzh2/wwLokYtBezcBzzBry4 wDYA== 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=ZuYglknL1Ha67Z8bKmDkd+9e4Ru71S9MI3ZsQ1DGxZ8=; b=HfZqbVzksw7KqKTfID1naZGfYrJiO6STWtb/O2nQS8wZsUfGn930V41UZiD95X55bG KJaF9S/dJ+CGBjHKpa/QkzmaC2/+al+wp9ozC4z1ZQhfO3/05Q40zch47XLMxWqYYbzC 8Ku1DEghJla0Ijk8V0c90CfQJ5M26grhWj1iATRk9VSA4Pu5Q58TqAcstxsr8Zk2PQq/ m+7SUzNLQ26qV3KLpSBuG1BwO0buUxqsdaPH2oqoQhyzwaMqk/dB6foEQL0JCzU/hmQj bWbZrmdH5Jc80eeOVqn79XOiZJ0vKgbFd+hbyexF3baiqu2Nvntxs8faqXlESWXcdxQD Jk6A== 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.03; Thu, 31 Jan 2019 16:51:05 -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 S1727784AbfBAAvB (ORCPT + 15 others); Thu, 31 Jan 2019 19:51:01 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:41283 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfBAAvB (ORCPT ); Thu, 31 Jan 2019 19:51:01 -0500 Received: by mail-ot1-f65.google.com with SMTP id u16so4592344otk.8 for ; Thu, 31 Jan 2019 16:51:01 -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=ZuYglknL1Ha67Z8bKmDkd+9e4Ru71S9MI3ZsQ1DGxZ8=; b=sKo6ZHL7ZqK8XHF0sA9w5E/n6i/C4m9f99DzOa/F8Uxcq2+2ZqueX2NOgKlgedirAP MZqdJmynjAWVLOOT6cEcXMGlsanajhW4EERerBSYPS1zMEjXG4QVNveh4TR+F6EYnJek tBny6CLZ1y+c2nLhShdqH09EzW7Tj07TJ6XxbmUCuAGRF0ZvCyA3APxmo8Q938j+3ypa ziegg7W/KRZkyYorjd72dNJfsgC8vOwkb28sSTos6ngAHhm0IsKbhvZw2YTEdVTIuzj1 43VmJ0C6EodyqSt3EcbPqAGbjR/aDQ1a09NMuyWKcsoRc2SRndpI6/gJ7OFmbs+BFH1s z9XA== X-Gm-Message-State: AJcUukeGMYa8Y1BXtc0l8YjQEKzDCaavczWjNY3vKzYvuS8ptHQJKFlM aoyWTGA3FbAtJHWNjYmC3A== X-Received: by 2002:a9d:2184:: with SMTP id s4mr28893399otb.46.1548982260844; Thu, 31 Jan 2019 16:51:00 -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.50.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:51:00 -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 1/5] drm: Add reservation_object to drm_gem_object Date: Thu, 31 Jan 2019 18:50:53 -0600 Message-Id: <20190201005057.13648-2-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 Many users of drm_gem_object embed a struct reservation_object into their subclassed struct, so let's add one to struct drm_gem_object. This will allow removing the reservation object from the subclasses and removing the ->gem_prime_res_obj callback. With the addition, add a drm_gem_reservation_object_wait() helper function for drivers to use in wait ioctls. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring --- Documentation/gpu/todo.rst | 9 --------- drivers/gpu/drm/drm_gem.c | 39 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_prime.c | 1 + include/drm/drm_gem.h | 7 +++++++ 4 files changed, 47 insertions(+), 9 deletions(-) -- 2.19.1 diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 14191b64446d..6e0a37d0bf6d 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -209,15 +209,6 @@ Would be great to refactor this all into a set of small common helpers. Contact: Daniel Vetter -Put a reservation_object into drm_gem_object --------------------------------------------- - -This would remove the need for the ->gem_prime_res_obj callback. It would also -allow us to implement generic helpers for waiting for a bo, allowing for quite a -bit of refactoring in the various wait ioctl implementations. - -Contact: Daniel Vetter - idr_init_base() --------------- diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 8b55ece97967..91dd06c1b3a8 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -170,6 +170,10 @@ void drm_gem_private_object_init(struct drm_device *dev, kref_init(&obj->refcount); obj->handle_count = 0; obj->size = size; + if (!obj->resv) { + obj->resv = &obj->_resv; + reservation_object_init(obj->resv); + } drm_vma_node_reset(&obj->vma_node); } EXPORT_SYMBOL(drm_gem_private_object_init); @@ -657,6 +661,40 @@ drm_gem_object_lookup(struct drm_file *filp, u32 handle) } EXPORT_SYMBOL(drm_gem_object_lookup); +/** + * drm_gem_object_lookup - Wait on GEM object's reservation's objects + * shared and/or exclusive fences. + * @filp: DRM file private date + * @handle: userspace handle + * @wait_all: if true, wait on all fences, else wait on just exclusive fence + * @timeout: timeout value in jiffies or zero to return immediately + * + * Returns: + * + * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or + * greater than 0 on success. + */ +long drm_gem_reservation_object_wait(struct drm_file *filep, u32 handle, + bool wait_all, unsigned long timeout) +{ + long ret; + struct drm_gem_object *obj; + + obj = drm_gem_object_lookup(filep, handle); + if (!obj) { + DRM_DEBUG("Failed to look up GEM BO %d\n", handle); + return -EINVAL; + } + + ret = reservation_object_wait_timeout_rcu(obj->resv, wait_all, + true, timeout); + + drm_gem_object_put_unlocked(obj); + + return ret; +} +EXPORT_SYMBOL(drm_gem_reservation_object_wait); + /** * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl * @dev: drm_device @@ -821,6 +859,7 @@ drm_gem_object_release(struct drm_gem_object *obj) if (obj->filp) fput(obj->filp); + reservation_object_fini(&obj->_resv); drm_gem_free_mmap_offset(obj); } EXPORT_SYMBOL(drm_gem_object_release); diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 231e3f6d5f41..dc079efb3b0f 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -504,6 +504,7 @@ struct dma_buf *drm_gem_prime_export(struct drm_device *dev, .size = obj->size, .flags = flags, .priv = obj, + .resv = obj->resv, }; if (dev->driver->gem_prime_res_obj) diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index c95727425284..f450a5b6038e 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -35,6 +35,7 @@ */ #include +#include #include @@ -262,6 +263,10 @@ struct drm_gem_object { */ struct dma_buf_attachment *import_attach; + /* normally (resv == &_resv) except for imported bo's */ + struct reservation_object *resv; + struct reservation_object _resv; + /** * @funcs: * @@ -363,6 +368,8 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, bool dirty, bool accessed); struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle); +long drm_gem_reservation_object_wait(struct drm_file *filep, u32 handle, + bool wait_all, unsigned long timeout); int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, u32 handle, u64 *offset); int drm_gem_dumb_destroy(struct drm_file *file, From patchwork Fri Feb 1 00:50:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157164 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7870354jaa; Thu, 31 Jan 2019 16:51:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4yt8KqxHIT5rKMeFI/p+dh9SKtAo/ncx/hH6meGXFrZigVSCRATfa8R7bL4sraq4v3Pd19 X-Received: by 2002:a63:e84c:: with SMTP id a12mr33076839pgk.241.1548982267487; Thu, 31 Jan 2019 16:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548982267; cv=none; d=google.com; s=arc-20160816; b=IouYR5pdJXdY5DTV1t8+rhgpBTfG2MXK3cUSDlnhjnOKtgTY/YAlcKe+M4DMUHc9qz yH2IL/R4ELbRDbc2xw0ZQKRpR7NWTgIN8qJwYKfJ0/pMO55Z1sNvaGUpI6r19hrUyw/W W5RIoEVJ+sIIe6J9knxzo6NovG3Ui9f/YLooI2F1T6H7nJk7Uso66NHAwZ07r5zpfgi9 HjE8N3LDh+DisgURzexn5OyS0EBIC1eORgxfkWMZ0mScGCj5R/TaV5AM6CpzousRdpyy wP5A3cIvTMSC1M+3g2W9u/P+2DwvU0+5SR78Xc+p86Tv3f9ISqbSdjjdag8HevDUkOaj TzZQ== 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=hL/fqpCcY3MoDqzEN0lercQ/14BLqfDeFunCCnYrFTo=; b=TCu3waQlISZoJwHhUugadWy5zjLr0vsDvfeNezO7NcJf2ASMD2tGHwrxpVcRKquDSE UmbgK4nbyJ0xeImVi310eG6PqlK/63c7stUadc3rKMHXqktOl4hqch3yWGTMNOwb/QSp 3cQoDiSsIYuqRLe2OcuwZSpeuMXkPz0GVO5HJYVuY0q0uHOL4L/t3zpqO4FyAqvK+T3M nwFFY5XEtumGcR4aPb3v0jf/+0bfVGmTQVS3ZYvxjN/k8As2IZ7cYCcvvuLz/X6JtuRI spkq2qHCbXWqEq+j7OTNqWk0c1s4dnZfuBpeClFxSWF3Qtx2jsxN6bvjOdHHyDMQqkqy cYBg== 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.05; Thu, 31 Jan 2019 16:51: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 S1728305AbfBAAvD (ORCPT + 15 others); Thu, 31 Jan 2019 19:51:03 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:33035 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfBAAvD (ORCPT ); Thu, 31 Jan 2019 19:51:03 -0500 Received: by mail-oi1-f194.google.com with SMTP id c206so4492619oib.0 for ; Thu, 31 Jan 2019 16:51:02 -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=hL/fqpCcY3MoDqzEN0lercQ/14BLqfDeFunCCnYrFTo=; b=i0djz4QLp2XIQuxgk8DfGSXwbSu55BDoc5yMsd2NO6yL27FZX8CzBHhnUmwpxgMpcH 9sEeycD7cWUixl//nOq4ZgXdZrnnYqVSrwoT5vNr1HvUG/SiyfdZnaHEhphY4xBtCyJf ae2eVmuzt2X3kYLgz0pGC+cQBm/QOOK9JoSHbhBMFrfg8CJf2t6N9S1URvDXWfQKSAuO 7vrB8I/Ym2RrTy6r4ybMOh6d79BZd2QdcVBbHK8rxur9dxo35JmatoUrZ/CLxiwDORRH +VLzf80qIrM+HgoP/3+qUAhPuYnNcA967ntkjo+xmWWPSKLhOP+H6TNNcAvtsl+AuGjC 2ANQ== X-Gm-Message-State: AJcUuke//pu0B4SCB71OTVXsbB184ODp0lg5cB+wG2PwHqoj5Qk9sG6C pWaKPLU7LJEut0MpTDnRQw== X-Received: by 2002:aca:4489:: with SMTP id r131mr17371691oia.296.1548982262104; Thu, 31 Jan 2019 16:51:02 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:51:01 -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 2/5] drm: etnaviv: Switch to use drm_gem_object reservation_object Date: Thu, 31 Jan 2019 18:50:54 -0600 Message-Id: <20190201005057.13648-3-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: Lucas Stach Cc: Russell King Cc: Christian Gmeiner Cc: David Airlie Cc: Daniel Vetter Cc: etnaviv@lists.freedesktop.org Signed-off-by: Rob Herring --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 1 - drivers/gpu/drm/etnaviv/etnaviv_drv.h | 1 - drivers/gpu/drm/etnaviv/etnaviv_gem.c | 16 +++++--------- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 4 ---- drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 7 ------- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 22 ++++++++++---------- 6 files changed, 16 insertions(+), 35 deletions(-) -- 2.19.1 diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 18c27f795cf6..9f42f7538236 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -473,7 +473,6 @@ static struct drm_driver etnaviv_drm_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = drm_gem_prime_export, .gem_prime_import = drm_gem_prime_import, - .gem_prime_res_obj = etnaviv_gem_prime_res_obj, .gem_prime_pin = etnaviv_gem_prime_pin, .gem_prime_unpin = etnaviv_gem_prime_unpin, .gem_prime_get_sg_table = etnaviv_gem_prime_get_sg_table, diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 4bf698de5996..351db0c5822d 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -61,7 +61,6 @@ void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj); void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); int etnaviv_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); -struct reservation_object *etnaviv_gem_prime_res_obj(struct drm_gem_object *obj); struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, struct sg_table *sg); int etnaviv_gem_prime_pin(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 1fa74226db91..3e954adcb2cc 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -397,13 +397,13 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, } if (op & ETNA_PREP_NOSYNC) { - if (!reservation_object_test_signaled_rcu(etnaviv_obj->resv, + if (!reservation_object_test_signaled_rcu(obj->resv, write)) return -EBUSY; } else { unsigned long remain = etnaviv_timeout_to_jiffies(timeout); - ret = reservation_object_wait_timeout_rcu(etnaviv_obj->resv, + ret = reservation_object_wait_timeout_rcu(obj->resv, write, true, remain); if (ret <= 0) return ret == 0 ? -ETIMEDOUT : ret; @@ -459,7 +459,7 @@ static void etnaviv_gem_describe_fence(struct dma_fence *fence, static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); - struct reservation_object *robj = etnaviv_obj->resv; + struct reservation_object *robj = obj->resv; struct reservation_object_list *fobj; struct dma_fence *fence; unsigned long off = drm_vma_node_start(&obj->vma_node); @@ -549,8 +549,6 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj) drm_gem_free_mmap_offset(obj); etnaviv_obj->ops->release(etnaviv_obj); - if (etnaviv_obj->resv == &etnaviv_obj->_resv) - reservation_object_fini(&etnaviv_obj->_resv); drm_gem_object_release(obj); kfree(etnaviv_obj); @@ -596,12 +594,8 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags, etnaviv_obj->flags = flags; etnaviv_obj->ops = ops; - if (robj) { - etnaviv_obj->resv = robj; - } else { - etnaviv_obj->resv = &etnaviv_obj->_resv; - reservation_object_init(&etnaviv_obj->_resv); - } + if (robj) + etnaviv_obj->base.resv = robj; mutex_init(&etnaviv_obj->lock); INIT_LIST_HEAD(&etnaviv_obj->vram_list); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h index 76079c2291f8..7015837ccc1c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h @@ -47,10 +47,6 @@ struct etnaviv_gem_object { struct sg_table *sgt; void *vaddr; - /* normally (resv == &_resv) except for imported bo's */ - struct reservation_object *resv; - struct reservation_object _resv; - struct list_head vram_list; /* cache maintenance */ diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c index 0566171f8df2..01e7ad96339c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c @@ -139,10 +139,3 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, return ERR_PTR(ret); } - -struct reservation_object *etnaviv_gem_prime_res_obj(struct drm_gem_object *obj) -{ - struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); - - return etnaviv_obj->resv; -} diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 30875f8f2933..a10281e915e5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -108,9 +108,9 @@ static int submit_lookup_objects(struct etnaviv_gem_submit *submit, static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i) { if (submit->bos[i].flags & BO_LOCKED) { - struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; + struct drm_gem_object *obj = &submit->bos[i].obj->base; - ww_mutex_unlock(&etnaviv_obj->resv->lock); + ww_mutex_unlock(&obj->resv->lock); submit->bos[i].flags &= ~BO_LOCKED; } } @@ -122,7 +122,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, retry: for (i = 0; i < submit->nr_bos; i++) { - struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; + struct drm_gem_object *obj = &submit->bos[i].obj->base; if (slow_locked == i) slow_locked = -1; @@ -130,7 +130,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, contended = i; if (!(submit->bos[i].flags & BO_LOCKED)) { - ret = ww_mutex_lock_interruptible(&etnaviv_obj->resv->lock, + ret = ww_mutex_lock_interruptible(&obj->resv->lock, ticket); if (ret == -EALREADY) DRM_ERROR("BO at index %u already on submit list\n", @@ -153,12 +153,12 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, submit_unlock_object(submit, slow_locked); if (ret == -EDEADLK) { - struct etnaviv_gem_object *etnaviv_obj; + struct drm_gem_object *obj; - etnaviv_obj = submit->bos[contended].obj; + obj = &submit->bos[contended].obj->base; /* we lost out in a seqno race, lock and retry.. */ - ret = ww_mutex_lock_slow_interruptible(&etnaviv_obj->resv->lock, + ret = ww_mutex_lock_slow_interruptible(&obj->resv->lock, ticket); if (!ret) { submit->bos[contended].flags |= BO_LOCKED; @@ -176,7 +176,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit) for (i = 0; i < submit->nr_bos; i++) { struct etnaviv_gem_submit_bo *bo = &submit->bos[i]; - struct reservation_object *robj = bo->obj->resv; + struct reservation_object *robj = bo->obj->base.resv; if (!(bo->flags & ETNA_SUBMIT_BO_WRITE)) { ret = reservation_object_reserve_shared(robj, 1); @@ -207,13 +207,13 @@ static void submit_attach_object_fences(struct etnaviv_gem_submit *submit) int i; for (i = 0; i < submit->nr_bos; i++) { - struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; + struct drm_gem_object *obj = &submit->bos[i].obj->base; if (submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE) - reservation_object_add_excl_fence(etnaviv_obj->resv, + reservation_object_add_excl_fence(obj->resv, submit->out_fence); else - reservation_object_add_shared_fence(etnaviv_obj->resv, + reservation_object_add_shared_fence(obj->resv, submit->out_fence); submit_unlock_object(submit, i); From patchwork Fri Feb 1 00:50:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157165 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7870394jaa; Thu, 31 Jan 2019 16:51:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IazPx9a8cfiIQWjInULTauspiYEJlnVlqVtsRM1Q71Z4Fy0WVGdYREmeTIKwLeYft4yrI8S X-Received: by 2002:a63:b4c:: with SMTP id a12mr184823pgl.131.1548982269460; Thu, 31 Jan 2019 16:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548982269; cv=none; d=google.com; s=arc-20160816; b=sD2we+kiqfiB0o5Y0vtKN1XHF1QxD1UaoZ0f5ACSLEOLMCxAYxrRnobJaA7fy8bd5/ sfMzFbY2XS8orfjjUHGI7zsTtbHvkc+cm1wuPSOQyfyA4zLrM3CaMCqRUDD9m6NMWoP2 tKH72DZLuy7/yKedjuvfwZtZSNtpxM/SdrB+BwcxAdpt9KnMU/G3kFgcYy2vnqBj2rF6 JabVaIsFWvYZcf7csXLztYsAp0y2F+AV/TRriGg5m+PHin/MAJogGNuH5aQ8/4LhPqvU Pmx8zztbzj3iqfG2w7k+4vprFCnnEUB+pIPL9w6H9X1I1J36psHAJNDC1/0Bk1IHFM26 VqYA== 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=cC26GpCVNPJKphooEF8oiPVF5cKJoGyJ5oaEHSMW3Xc=; b=jL7pchIAetPJtPSGN5tAD5r71YaSlDwVVlODXW9CZN9Ll2loK457yd9Vo1EJlXvUfE DuIaygm/+wPDwqYa1L4+He4hq3MRIshItmNMEfLKTRuwUcGgu/tmRmpveZhlCcIhsIsQ /zWQWqV2YwvBopKVL4nR1HIdXpqEPK9twyzfEuHgiECCWZthRZ5C5RMz/m/qovWQ14+s K6eOYEE+v2NT2ygRxFfxamGcVTFe0IivRRibPj15QXDFuajDaofv4FgW+6FYfi//AZ0S mq1DyhQXJpYQ+wzLXzhytyCHkIJeW14oBysr7YMkamBXZ4QX1o+fPHqjhTHxtKgBwXIo Kckg== 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.07; Thu, 31 Jan 2019 16:51:09 -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 S1728636AbfBAAvF (ORCPT + 15 others); Thu, 31 Jan 2019 19:51:05 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:44534 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfBAAvE (ORCPT ); Thu, 31 Jan 2019 19:51:04 -0500 Received: by mail-ot1-f65.google.com with SMTP id g16so4559948otg.11 for ; Thu, 31 Jan 2019 16:51:03 -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=cC26GpCVNPJKphooEF8oiPVF5cKJoGyJ5oaEHSMW3Xc=; b=RqNkl4Q0QfjYyFMhRyUe2PKiFHBaByJXv1+NG1WKNeTdmV2FWOSGl+hwX0tEr4/ra4 e25hVY7158s8yzfXNT2AXGAVPfqyD5KiRVbCNSIQXxDdRocr/I0IjnBOn5zmLMPWUonX +4M1G1scdrGCN/ZP4ikdZneaSlXiCI/LmGbGnN5Aeydlj0BZV/uKgxdxMn6EcWfxsHqU pk0Z+CtSF4NiSRmedOEERyRe0Sc18W8poxU6HGKbKnJb93tOsKRUWUmBbC2qnM7pbXGL taQGQJKqu9qRTPnke489MRgXeOP1VKuUM/9iiRaqp7X2cIrlyd4q9vcpv+SqKtXXbJ4J +ihA== X-Gm-Message-State: AJcUukeH19cunDGooU4xicTo6ckFi1Qg30WWVzGbK3vLtAOt4kVZC5zD x0JfgMPiryR+gcFl8Umobg== X-Received: by 2002:a9d:3e16:: with SMTP id a22mr28893542otd.43.1548982263351; Thu, 31 Jan 2019 16:51:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:51:02 -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 3/5] drm: msm: Switch to use drm_gem_object reservation_object Date: Thu, 31 Jan 2019 18:50:55 -0600 Message-Id: <20190201005057.13648-4-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. We can't use the drm_gem_reservation_object_wait() helper for MSM because (in theory) msm_gem_cpu_prep() will also do some cache maintenance on the GEM object. Cc: Rob Clark Cc: David Airlie Cc: Daniel Vetter Cc: linux-arm-msm@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org Signed-off-by: Rob Herring --- drivers/gpu/drm/msm/msm_drv.c | 1 - drivers/gpu/drm/msm/msm_drv.h | 1 - drivers/gpu/drm/msm/msm_gem.c | 27 +++++++++------------------ drivers/gpu/drm/msm/msm_gem_prime.c | 7 ------- drivers/gpu/drm/msm/msm_gem_submit.c | 8 ++++---- 5 files changed, 13 insertions(+), 31 deletions(-) -- 2.19.1 diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index d2cdc7b553fe..522ddbd72250 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1086,7 +1086,6 @@ static struct drm_driver msm_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = drm_gem_prime_export, .gem_prime_import = drm_gem_prime_import, - .gem_prime_res_obj = msm_gem_prime_res_obj, .gem_prime_pin = msm_gem_prime_pin, .gem_prime_unpin = msm_gem_prime_unpin, .gem_prime_get_sg_table = msm_gem_prime_get_sg_table, diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 927e5d86f7c1..068f9172ad70 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -300,7 +300,6 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj); void *msm_gem_prime_vmap(struct drm_gem_object *obj); void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); -struct reservation_object *msm_gem_prime_res_obj(struct drm_gem_object *obj); struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, struct sg_table *sg); int msm_gem_prime_pin(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index c8886d3071fa..d3973cc26522 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -672,14 +672,13 @@ void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass) int msm_gem_sync_object(struct drm_gem_object *obj, struct msm_fence_context *fctx, bool exclusive) { - struct msm_gem_object *msm_obj = to_msm_bo(obj); struct reservation_object_list *fobj; struct dma_fence *fence; int i, ret; - fobj = reservation_object_get_list(msm_obj->resv); + fobj = reservation_object_get_list(obj->resv); if (!fobj || (fobj->shared_count == 0)) { - fence = reservation_object_get_excl(msm_obj->resv); + fence = reservation_object_get_excl(obj->resv); /* don't need to wait on our own fences, since ring is fifo */ if (fence && (fence->context != fctx->context)) { ret = dma_fence_wait(fence, true); @@ -693,7 +692,7 @@ int msm_gem_sync_object(struct drm_gem_object *obj, for (i = 0; i < fobj->shared_count; i++) { fence = rcu_dereference_protected(fobj->shared[i], - reservation_object_held(msm_obj->resv)); + reservation_object_held(obj->resv)); if (fence->context != fctx->context) { ret = dma_fence_wait(fence, true); if (ret) @@ -711,9 +710,9 @@ void msm_gem_move_to_active(struct drm_gem_object *obj, WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED); msm_obj->gpu = gpu; if (exclusive) - reservation_object_add_excl_fence(msm_obj->resv, fence); + reservation_object_add_excl_fence(obj->resv, fence); else - reservation_object_add_shared_fence(msm_obj->resv, fence); + reservation_object_add_shared_fence(obj->resv, fence); list_del_init(&msm_obj->mm_list); list_add_tail(&msm_obj->mm_list, &gpu->active_list); } @@ -733,13 +732,12 @@ void msm_gem_move_to_inactive(struct drm_gem_object *obj) int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout) { - struct msm_gem_object *msm_obj = to_msm_bo(obj); bool write = !!(op & MSM_PREP_WRITE); unsigned long remain = op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout); long ret; - ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write, + ret = reservation_object_wait_timeout_rcu(obj->resv, write, true, remain); if (ret == 0) return remain == 0 ? -EBUSY : -ETIMEDOUT; @@ -771,7 +769,7 @@ static void describe_fence(struct dma_fence *fence, const char *type, void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) { struct msm_gem_object *msm_obj = to_msm_bo(obj); - struct reservation_object *robj = msm_obj->resv; + struct reservation_object *robj = obj->resv; struct reservation_object_list *fobj; struct dma_fence *fence; struct msm_gem_vma *vma; @@ -883,9 +881,6 @@ void msm_gem_free_object(struct drm_gem_object *obj) put_pages(obj); } - if (msm_obj->resv == &msm_obj->_resv) - reservation_object_fini(msm_obj->resv); - drm_gem_object_release(obj); mutex_unlock(&msm_obj->lock); @@ -945,12 +940,8 @@ static int msm_gem_new_impl(struct drm_device *dev, msm_obj->flags = flags; msm_obj->madv = MSM_MADV_WILLNEED; - if (resv) { - msm_obj->resv = resv; - } else { - msm_obj->resv = &msm_obj->_resv; - reservation_object_init(msm_obj->resv); - } + if (resv) + msm_obj->base.resv = resv; INIT_LIST_HEAD(&msm_obj->submit_entry); INIT_LIST_HEAD(&msm_obj->vmas); diff --git a/drivers/gpu/drm/msm/msm_gem_prime.c b/drivers/gpu/drm/msm/msm_gem_prime.c index 13403c6da6c7..60bb290700ce 100644 --- a/drivers/gpu/drm/msm/msm_gem_prime.c +++ b/drivers/gpu/drm/msm/msm_gem_prime.c @@ -70,10 +70,3 @@ void msm_gem_prime_unpin(struct drm_gem_object *obj) if (!obj->import_attach) msm_gem_put_pages(obj); } - -struct reservation_object *msm_gem_prime_res_obj(struct drm_gem_object *obj) -{ - struct msm_gem_object *msm_obj = to_msm_bo(obj); - - return msm_obj->resv; -} diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 12b983fc0b56..df302521ec74 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -173,7 +173,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, msm_gem_unpin_iova(&msm_obj->base, submit->gpu->aspace); if (submit->bos[i].flags & BO_LOCKED) - ww_mutex_unlock(&msm_obj->resv->lock); + ww_mutex_unlock(&msm_obj->base.resv->lock); if (backoff && !(submit->bos[i].flags & BO_VALID)) submit->bos[i].iova = 0; @@ -196,7 +196,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit) contended = i; if (!(submit->bos[i].flags & BO_LOCKED)) { - ret = ww_mutex_lock_interruptible(&msm_obj->resv->lock, + ret = ww_mutex_lock_interruptible(&msm_obj->base.resv->lock, &submit->ticket); if (ret) goto fail; @@ -218,7 +218,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit) if (ret == -EDEADLK) { struct msm_gem_object *msm_obj = submit->bos[contended].obj; /* we lost out in a seqno race, lock and retry.. */ - ret = ww_mutex_lock_slow_interruptible(&msm_obj->resv->lock, + ret = ww_mutex_lock_slow_interruptible(&msm_obj->base.resv->lock, &submit->ticket); if (!ret) { submit->bos[contended].flags |= BO_LOCKED; @@ -244,7 +244,7 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) * strange place to call it. OTOH this is a * convenient can-fail point to hook it in. */ - ret = reservation_object_reserve_shared(msm_obj->resv, + ret = reservation_object_reserve_shared(msm_obj->base.resv, 1); if (ret) return ret; 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 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; } From patchwork Fri Feb 1 00:50:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157167 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7870453jaa; Thu, 31 Jan 2019 16:51:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5gDSHTG5YeYdPFwPgZY6jgWfdLW00jeb4shrfx8futrw7ByP+cPhXPASP/3A2zVN3YgNFr X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr31429786plt.30.1548982273417; Thu, 31 Jan 2019 16:51:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548982273; cv=none; d=google.com; s=arc-20160816; b=i9Sit1GF7LcxRbWzkPam3uGTxC6vUh3GDFSmx4OKMJ9neawimYE+EF7k9edgifthjp THrEMiBO6NWn7R315zsDDcAFDJ68BPmFNA1ziasUqomue2JxVhVPcp+jY01IDn+2drce 2/a1AhorkmsVEFIeC3o5xk8W55CAEXyOclEbKWABIYtp6pv2uWwsxHOlF2iCyK0jkm4g oAvhtrLEMEuH3kduSUoNKjV17EOU81DA5IJYpXfpnVkCzf9n1oDho2e3zhqvPMQVpV+F sybh6dCZCxTjGFhG8IDBvzAzVXrhDZp7G4Kei+M3rTtXThQjN6fCgU5ftUQARnV8wlHi jpeA== 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=SVOXbwcipxjlRkeNW4ZAeV+v+0OgKLHM+wSD5v4sZ98=; b=K1uT0Jk/HFW8iCJoWQ8q9jP/feT4buA4UmA3YYL7vgBl/CCnFSmE4ho6ntracoWDOf GJyJ36j1Mt8Fcf5CPDkeQpDW+ODBjpVT2nyezp+N4CgV6SQkIfFUR5qp0CJTzG4r6QaK oQSyysN1pyJuHP3f4GlMjr7pXh5m87J2/G4RkwDt4O0Gd7mv/37dcdYDcHqHITrfaGLK qL7ESXd+TEWOJKezz0W/zmpWsk02+muXR9qztIgzGktjxi7cIHTf7EdhsxFNFk2bm38l eWXSUyDkM+uOuvFJDNLzcODa4qLLcO3ZQUgMRXPHb8HdjFYobNO5nPfpr4SHvRvxrpdb WhZQ== 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.11; Thu, 31 Jan 2019 16:51:13 -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 S1728931AbfBAAvH (ORCPT + 15 others); Thu, 31 Jan 2019 19:51:07 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:39634 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfBAAvH (ORCPT ); Thu, 31 Jan 2019 19:51:07 -0500 Received: by mail-ot1-f65.google.com with SMTP id n8so4599482otl.6 for ; Thu, 31 Jan 2019 16:51: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=SVOXbwcipxjlRkeNW4ZAeV+v+0OgKLHM+wSD5v4sZ98=; b=MOJLfM/oqFZXu0Rl/zL0GT80DgU4nhpmQ10C27DymKJXMtYhhVDTo1nYQX3ZMrGFys IC5TyjWhLHlnVpPbRBCHO6t45UcPKnYkwVh5vsHECnN3PX9IKIIbx4Lj10hViqiVzpt0 6n5o91dEmY/oXGdH8SmBF4DJV2nLbsOjjGQ9wRTjP8gQKTLLgOcje/NQgnRcTpteQ5Lo fO1WAaZv0BeA4Pn3/c2U8uB3U5jh4nkSY/r5fFPxQpyu9w78F2z5JEtKxSNc/8HTdfwW 6l7Y/Lr7sY3v5IjhPblqi+0GHrrQ4yw2LMuHrbEKQUSpElZJeCVH/dBJxFgOz/J24wvf KjqA== X-Gm-Message-State: AJcUukfAhqpwUAh2i4OsH+mO+lcqvymdyGHtX9IKsCLq3THvp2DcC4U1 bph5XqqnE+lsMkaR8jXIcg== X-Received: by 2002:a9d:2227:: with SMTP id o36mr27771171ota.29.1548982266453; Thu, 31 Jan 2019 16:51:06 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 16:51:05 -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 5/5] drm: vc4: Switch to use drm_gem_object reservation_object Date: Thu, 31 Jan 2019 18:50:57 -0600 Message-Id: <20190201005057.13648-6-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: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Signed-off-by: Rob Herring --- drivers/gpu/drm/vc4/vc4_bo.c | 15 +-------------- drivers/gpu/drm/vc4/vc4_drv.c | 1 - drivers/gpu/drm/vc4/vc4_drv.h | 7 +------ drivers/gpu/drm/vc4/vc4_gem.c | 18 +++++++++--------- drivers/gpu/drm/vc4/vc4_plane.c | 2 +- 5 files changed, 12 insertions(+), 31 deletions(-) -- 2.19.1 Reviewed-by: Eric Anholt diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 8dcce7182bb7..92e3f98d8478 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -201,8 +201,6 @@ static void vc4_bo_destroy(struct vc4_bo *bo) bo->validated_shader = NULL; } - reservation_object_fini(&bo->_resv); - drm_gem_cma_free_object(obj); } @@ -427,8 +425,6 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) vc4->bo_labels[VC4_BO_TYPE_KERNEL].num_allocated++; vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size; mutex_unlock(&vc4->bo_lock); - bo->resv = &bo->_resv; - reservation_object_init(bo->resv); return &bo->base.base; } @@ -684,13 +680,6 @@ static void vc4_bo_cache_time_timer(struct timer_list *t) schedule_work(&vc4->bo_cache.time_work); } -struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj) -{ - struct vc4_bo *bo = to_vc4_bo(obj); - - return bo->resv; -} - struct dma_buf * vc4_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { @@ -822,14 +811,12 @@ vc4_prime_import_sg_table(struct drm_device *dev, struct sg_table *sgt) { struct drm_gem_object *obj; - struct vc4_bo *bo; obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt); if (IS_ERR(obj)) return obj; - bo = to_vc4_bo(obj); - bo->resv = attach->dmabuf->resv; + obj->resv = attach->dmabuf->resv; return obj; } diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index f6f5cd80c04d..d17df8c0291b 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -201,7 +201,6 @@ static struct drm_driver vc4_drm_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = drm_gem_prime_import, .gem_prime_export = vc4_prime_export, - .gem_prime_res_obj = vc4_prime_res_obj, .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, .gem_prime_import_sg_table = vc4_prime_import_sg_table, .gem_prime_vmap = vc4_prime_vmap, diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 4f87b03f837d..76e6be9f7f7b 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -7,7 +7,7 @@ */ #include -#include +//#include #include #include #include @@ -239,10 +239,6 @@ struct vc4_bo { */ struct vc4_validated_shader_info *validated_shader; - /* normally (resv == &_resv) except for imported bo's */ - struct reservation_object *resv; - struct reservation_object _resv; - /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i * for user-allocated labels. */ @@ -684,7 +680,6 @@ int vc4_label_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); vm_fault_t vc4_fault(struct vm_fault *vmf); int vc4_mmap(struct file *filp, struct vm_area_struct *vma); -struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj); int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index aea2b8dfec17..5ee5bf7fedf7 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -536,7 +536,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno) bo = to_vc4_bo(&exec->bo[i]->base); bo->seqno = seqno; - reservation_object_add_shared_fence(bo->resv, exec->fence); + reservation_object_add_shared_fence(bo->base.base.resv, exec->fence); } list_for_each_entry(bo, &exec->unref_list, unref_head) { @@ -547,7 +547,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno) bo = to_vc4_bo(&exec->rcl_write_bo[i]->base); bo->write_seqno = seqno; - reservation_object_add_excl_fence(bo->resv, exec->fence); + reservation_object_add_excl_fence(bo->base.base.resv, exec->fence); } } @@ -559,7 +559,7 @@ vc4_unlock_bo_reservations(struct drm_device *dev, int i; for (i = 0; i < exec->bo_count; i++) { - struct vc4_bo *bo = to_vc4_bo(&exec->bo[i]->base); + struct drm_gem_object *bo = &exec->bo[i]->base; ww_mutex_unlock(&bo->resv->lock); } @@ -581,13 +581,13 @@ vc4_lock_bo_reservations(struct drm_device *dev, { int contended_lock = -1; int i, ret; - struct vc4_bo *bo; + struct drm_gem_object *bo; ww_acquire_init(acquire_ctx, &reservation_ww_class); retry: if (contended_lock != -1) { - bo = to_vc4_bo(&exec->bo[contended_lock]->base); + bo = &exec->bo[contended_lock]->base; ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, acquire_ctx); if (ret) { @@ -600,19 +600,19 @@ vc4_lock_bo_reservations(struct drm_device *dev, if (i == contended_lock) continue; - bo = to_vc4_bo(&exec->bo[i]->base); + bo = &exec->bo[i]->base; ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx); if (ret) { int j; for (j = 0; j < i; j++) { - bo = to_vc4_bo(&exec->bo[j]->base); + bo = &exec->bo[j]->base; ww_mutex_unlock(&bo->resv->lock); } if (contended_lock != -1 && contended_lock >= i) { - bo = to_vc4_bo(&exec->bo[contended_lock]->base); + bo = &exec->bo[contended_lock]->base; ww_mutex_unlock(&bo->resv->lock); } @@ -633,7 +633,7 @@ vc4_lock_bo_reservations(struct drm_device *dev, * before we commit the CL to the hardware. */ for (i = 0; i < exec->bo_count; i++) { - bo = to_vc4_bo(&exec->bo[i]->base); + bo = &exec->bo[i]->base; ret = reservation_object_reserve_shared(bo->resv, 1); if (ret) { diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 75db62cbe468..b8baceebb73b 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -994,7 +994,7 @@ static int vc4_prepare_fb(struct drm_plane *plane, bo = to_vc4_bo(&drm_fb_cma_get_gem_obj(state->fb, 0)->base); - fence = reservation_object_get_excl_rcu(bo->resv); + fence = reservation_object_get_excl_rcu(bo->base.base.resv); drm_atomic_set_fence_for_plane(state, fence); if (plane->state->fb == state->fb)