From patchwork Sat Feb 2 15:41: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: 157343 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1832961jaa; Sat, 2 Feb 2019 07:42:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IYiRU6IylFRlY+rd8D+TynG2wdHRDYJuNMi7u5ZC8VEPeBNmQDH5pVVPK8tusoV5q78fvx4 X-Received: by 2002:a65:590b:: with SMTP id f11mr6579710pgu.60.1549122124251; Sat, 02 Feb 2019 07:42:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549122124; cv=none; d=google.com; s=arc-20160816; b=imHw7XZsYkCVk03p8BLAZHG4WuctZhHEtLVPN2Pr1W8aF2N6uX+NnHKAkhAi+egCUz oO5HcdNM53gipfOuUQKeW2gJwRB6FliTvmw+8gTXjVSR7pDnjTUDfAXqkLqIaBjiX72a mw4OUcqN/XSBpQLk8g0p/l99fJwCy90REsC/+uVJhYG7r1fvyOxJM9jM6xUlBP+2ulOP kIO8XuD/IGNjdP1zhV24RLcurcueysgKdZF6CWpHNz+lZr/BLLu9iHAsX0di3id1p+tz OYKjS65/eyLDprVUyQnv4+zgbH+2YUwV7slfcdvB7IEEzRv4nV9dn/KQZnKX67YvNniz LUuA== 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=kXO9EnLK/WG9l04J2zoTVZIyTiSdpAPmcoczIKV7sqM=; b=rknFXpHx6QwIyz8kU1ENsGrMHvlU0EsNozccslUJq89t3Q+Zas1+4WcWWcgifHW6zJ vIdXtKZlQApvOmNHjrcSgtO0Zoil1/cbr4nh2vixpxR0JPHRLAZLuTy+byWZVJGA8QZu y8P4OdfDoNji/y5ydSAnBqXVK0F+k8U2AmsXEwCnAgsCFLT3ud5gjH4WOK9qeVX0aI5C QSYK/ssdZxOtXWibk2DExajMhiJhKbTVe9te6HjF/a87Mrl+vNI1LSvVFZ1fZmgwqHMI ayZyHFKIftRzS2tEH2wkOvkxIV9P39XQxqVHJK34ueSGjjvZrhnQAogP3Em6v44RRNSj NxQA== 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.04; Sat, 02 Feb 2019 07:42:04 -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 S1727770AbfBBPmD (ORCPT + 15 others); Sat, 2 Feb 2019 10:42:03 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:46424 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727474AbfBBPmD (ORCPT ); Sat, 2 Feb 2019 10:42:03 -0500 Received: by mail-oi1-f193.google.com with SMTP id x202so8259720oif.13 for ; Sat, 02 Feb 2019 07:42: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=kXO9EnLK/WG9l04J2zoTVZIyTiSdpAPmcoczIKV7sqM=; b=Spz5cINv7S0JaL/vfF4Hm2w7Z+lhIxvjszRP/aTHNx8CrxlQvO4uAW3chhOAgKrF6T Kw99lGDccwkYJ+4DkRaDHPSkADbXCwjm8ayU1NWOT0s90PsckDBEVaskD01LGwEwJaDu sFHC3j3JvzqEGzD7BQ5Y61nwA4Qpc3u97/AGu93WRspzCfjGP6Zm42ogbmQO0dZWEboV 4r+BmmFrCTHsZAvKXGPTBMWHNTH6xX2jasHVOvSgTyhxi7uehUOMtLOVHn0GTVnXODnU DwO/tnhbowoB+TcTk9TO1LsIlIxHdrlwJVscVV84IzXZfMcMqURBd4bQiXJZ1xGooidd QsCg== X-Gm-Message-State: AJcUukeF5nCGPTQzpP56WG72p7CpY3sI4/9NIXV56/yzYlJDjyTF9GeP XA00MpZY/UwWUTw6ElkECA== X-Received: by 2002:aca:f1d7:: with SMTP id p206mr22581205oih.239.1549122120725; Sat, 02 Feb 2019 07:42: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 187sm5215559oic.12.2019.02.02.07.41.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 07:42: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 v2 1/5] drm: Add reservation_object to drm_gem_object Date: Sat, 2 Feb 2019 09:41:54 -0600 Message-Id: <20190202154158.10443-2-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 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 --- v2: - Fix missing kerneldoc - Reword todo with what is left todo. - Fix timeout error handling (added to drm_gem_reservation_object_wait) Documentation/gpu/todo.rst | 8 +++---- drivers/gpu/drm/drm_gem.c | 43 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_prime.c | 1 + include/drm/drm_gem.h | 21 ++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) -- 2.19.1 Reviewed-by: Eric Anholt Reviewed-by: Christian Gmeiner diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 14191b64446d..c9ed55605641 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -209,12 +209,12 @@ 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 +Remove the ->gem_prime_res_obj callback -------------------------------------------- -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. +The ->gem_prime_res_obj callback can be removed from drivers by using the +reservation_object in the drm_gem_object. It may also be possible to use the +generic drm_gem_reservation_object_wait helper for waiting for a bo. Contact: Daniel Vetter diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 8b55ece97967..b09acbc5a655 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; + reservation_object_init(&obj->_resv); + if (!obj->resv) + obj->resv = &obj->_resv; + drm_vma_node_reset(&obj->vma_node); } EXPORT_SYMBOL(drm_gem_private_object_init); @@ -657,6 +661,44 @@ drm_gem_object_lookup(struct drm_file *filp, u32 handle) } EXPORT_SYMBOL(drm_gem_object_lookup); +/** + * drm_gem_reservation_object_wait - Wait on GEM object's reservation's objects + * shared and/or exclusive fences. + * @filep: 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); + if (ret == 0) + ret = -ETIME; + else if (ret > 0) + ret = 0; + + 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 +863,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..25f1ff2df464 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -35,6 +35,7 @@ */ #include +#include #include @@ -262,6 +263,24 @@ struct drm_gem_object { */ struct dma_buf_attachment *import_attach; + /** + * @resv: + * + * Pointer to reservation object associated with the this GEM object. + * + * Normally (@resv == &@_resv) except for imported GEM objects. + */ + struct reservation_object *resv; + + /** + * @_resv: + * + * A reservation object for this GEM object. + * + * This is unused for imported GEM objects. + */ + struct reservation_object _resv; + /** * @funcs: * @@ -363,6 +382,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 Sat Feb 2 15:41: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: 157344 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1832972jaa; Sat, 2 Feb 2019 07:42:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN4WUGdwBPpnYTuT0o8+5KBM89XQdfHvqozeOU+SkIdAS44/CS7yqLpqR7qJdUv9vzzVzYpV X-Received: by 2002:a17:902:654a:: with SMTP id d10mr43312427pln.324.1549122125198; Sat, 02 Feb 2019 07:42:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549122125; cv=none; d=google.com; s=arc-20160816; b=OwvH3YtagQi1nStxDEO+4jszGVz4ZBbcUafNCdlcWogWMWr2Z4e0mp98FiSAz4VnwN KecPZK+MmkwrW5QB4/FisPLMdYQTWbXihPJyo1Mp3tOA8x+kr7tJh59hGQMdHEc+bYLa tdCWe3ByneBl7cNAYu+mycTcbOXq9NlxcF8vqG0yHWPZhPdP7V+wBlxywXkt0dHfDKQl 5d4p5JrSGC3nnPH8cOwgDBuoVNJhLIAVBFXpMavIab7WibV8q7JS2qv+R4gQ/7amLIat 3UI9eNCHH+rS+kO0Lv+Wje3p9muEL8risX5fG2PUpTvvHU8bnPyzhwmINcsMO+6YpH8Z Obvw== 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=V45qQ7Pb5GOed+A1492ERLodj2/C7mfLbFBZLyFvebZy7eaGyLoI3/y0pJfIvXox2r Wc/9F7xLqYsa8yueD+I96TplMe685ALZTq8bZ7eyWra9X6Ezmf6DK/VUb1AqQ+R/m2oM v1m7tB0rqHmeN/bpGWmdIVwszt+4M7oAmkBA5LqOVlIeGeJdmG3Qhoj3SWJU+aefl7OO o0rk73n0eDrB6Ru4JJplBuZHSYqSBvdlcY7TbblRLANHOcm9jAA0U/JIdIwxOK6141o5 I2yBjLKni73nYUY2lffRlf3T9QbcME9u84DiM8ozGmkVffhzpCqWkDn3t1KhRWS4eyQg lvyw== 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.04; Sat, 02 Feb 2019 07:42: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 S1727778AbfBBPmE (ORCPT + 15 others); Sat, 2 Feb 2019 10:42:04 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:38831 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbfBBPmE (ORCPT ); Sat, 2 Feb 2019 10:42:04 -0500 Received: by mail-oi1-f194.google.com with SMTP id a77so8304142oii.5 for ; Sat, 02 Feb 2019 07:42: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=hL/fqpCcY3MoDqzEN0lercQ/14BLqfDeFunCCnYrFTo=; b=lA2n/Xad5aqOaYKQneUPhPb46fMwh4a7QNBY0MddjnbrAnIV2ml2obDHUVYtQwNBNd MN/Cg/L2g0LdQF37E+epmLM5TqZt4hsYYzJStDd3Z8Nw4Ic4+qYlW/DTdaavJBmAMDlv MulJrs8/TRgadyztxyfbr/Z2R8XV2SDIWwDy4AV9lFaKqQLSOXpBfhzrnElZDuGtGtoJ r0tUoQDoDzV6ZMrnqJWrVHyDnVOLC/3/ZlQz2fsR4lRMEwNkTY7W9xEHaUg2EvjGBRMR lp1zNf/BgeEqSf+INFG6v6WLNUV586YRiNLNTk5G8CGCf3xC61SWu8RtNl9MRzHKywmY EuMQ== X-Gm-Message-State: AJcUukc+AKHWfgnL/9Lvxme9aI0I8zVyW878oan5MQPLVg03Swygr0Dm B5IyxMnRTabSnAUCdIG5Zw== X-Received: by 2002:aca:2803:: with SMTP id 3mr22504886oix.85.1549122121726; Sat, 02 Feb 2019 07:42:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 07:42: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 v2 2/5] drm: etnaviv: Switch to use drm_gem_object reservation_object Date: Sat, 2 Feb 2019 09:41:55 -0600 Message-Id: <20190202154158.10443-3-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: 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 Reviewed-by: Christian Gmeiner 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 Sat Feb 2 15:41: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: 157345 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1832991jaa; Sat, 2 Feb 2019 07:42:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ftVGwcoaTK2mc8uprjJqLr0g083UvzZbVwuFg0m53jNL7xXtm22Vo1uQpZUALpARJ6rY5 X-Received: by 2002:a62:fc8a:: with SMTP id e132mr43380587pfh.176.1549122126822; Sat, 02 Feb 2019 07:42:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549122126; cv=none; d=google.com; s=arc-20160816; b=ozAEbaEf9DaOi5xGmsmVRau0NOKqkk9m2Qc+xXu74FKFnaV9UsVhCQkI/AsFXEojdK CHJ4tT45VqgTLNLgcKQJEWjgo6sJnahd4Lui5IOobGx840477schgonu5g+gIrRNSxYE yw9DLvkk6fJHPm9aD6yzaWgH33wMVZE4+cnHGnzWGN3bCKXjbYD7IfPMGtP4Hy6ZWvdA 2domkUYJDE0/L0We5URYiW9KLHsEdH6gSxm+gOMcJCkNu7G6vwzgEzSC7wdD70u4X+x+ jekGEXf8Xv2nhz8tzaEpJtEkuIDp4v6tc9qLSlQ6Xh7aLSkgcPXZuSkUFM5QdFmBtOjh nmxA== 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=KH7YCaEcJco0dB7dFIb3+1rJ0vk4GJGDl92UDJXvKADokqCXIg54TcMuYPn9M4zr99 wQUTjEfmVL1NratJyURdkkweS270lcQRYSduC/wLwDTxssOizleOYxlGpC1tAQ+AF/z4 Kq2x6BPoaDfhGsG58UBW+zpGROFFxz5yFI5uG+/UILwr49Okk3A7HxtlbWci+wiFosjA AlquvF3jahluvR+e10SuNMKXyuub1G+ijbxwVPJNRgV1PnUDhwXVTZrXxLre36jCEzxy de0kXI/+pjnPStnZiNAqHP56L8RVQG5KMuOkATlyixVLvZsrqcgVYPXuWTwkTgQqeQWf VxVQ== 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.06; Sat, 02 Feb 2019 07:42:06 -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 S1727784AbfBBPmG (ORCPT + 15 others); Sat, 2 Feb 2019 10:42:06 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:38832 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727474AbfBBPmF (ORCPT ); Sat, 2 Feb 2019 10:42:05 -0500 Received: by mail-oi1-f194.google.com with SMTP id a77so8304171oii.5 for ; Sat, 02 Feb 2019 07:42: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=cC26GpCVNPJKphooEF8oiPVF5cKJoGyJ5oaEHSMW3Xc=; b=KZsJkOTiJRl2RMuuQ69NwGr0YL/ANPi1W3ng4yvOngxp46aeeKLIcAxelb1FD/CW5L K9rn6aRb3NNXIww/LVhxEwGJD0Ai2frlMcrcJ/is7Fw+tkty9L3UwbYkTfhvC2VpnyV4 l3NuTVeYwhd1LRrw9UR1wUYUkV620wXxnRW8av4FjnZAxByG84RpD6bj8p6UvUyA0hXz paHliBhfCBbP4tz/L1WXpuFuDF/YY2RSjvxmtAWmk4FymB1Yd2mr5vGe2OIdLbNc0z2t d4HaHdsCD4jQZ9ZnRJ6vt/DlWBZDuFNXr9V+TCw/VYqC4POaLjuVL8vrkqCP4cFO4Dzi 7lvg== X-Gm-Message-State: AHQUAuYOUEgXPG9CiyFmaUl5gUHpFdOViytIHIu2noda9KYr73NxTkCa Kmcp8CaMjkX3uAQtNkDoHw== X-Received: by 2002:a54:4e1b:: with SMTP id a27mr22241542oiy.143.1549122123192; Sat, 02 Feb 2019 07:42: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 187sm5215559oic.12.2019.02.02.07.42.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 07:42: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 v2 3/5] drm: msm: Switch to use drm_gem_object reservation_object Date: Sat, 2 Feb 2019 09:41:56 -0600 Message-Id: <20190202154158.10443-4-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. 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 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 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; } From patchwork Sat Feb 2 15:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157347 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1833026jaa; Sat, 2 Feb 2019 07:42:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Ymj936Pr2I3Tee8tlDdDnnR5htAANnHAHzqo2LxdHJj38OjM5IiaTmvDSePXUygrUPUR6 X-Received: by 2002:a62:868b:: with SMTP id x133mr46321940pfd.252.1549122128932; Sat, 02 Feb 2019 07:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549122128; cv=none; d=google.com; s=arc-20160816; b=uGfICCwuFvGrH9H6GMR45NPKnJibGRHcJCZA4OaDikVnS++CR7nx4T0ES5kb7eiM/E FCXrsufwvmuKI6gIvRb+piGhJ8Qc0UdYhg14zCw2Hu38Gc8ub/zqQVKs8RKgMko3RWAo WGUIkIyzzSnqPVABBfYiBNMCdgj1WCkW/6/LgYg/SLarl0a7/BHUbDdjLXuf7ei5YbK4 ANiC2nItLE32+3siTA7le7hLF5ZAJowFPT3A2dJ6uHwDuaIliuXWUYngU5Lp9lOynziM UsSYIp5p4+AnzPBZuTdqVmiO4wyKdUrcX438DasULBuPXF+jVwS/VAwxKk3J4ltJsK1K lKmA== 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=EcY7KbO6hKDIjnSJCdxYMZiUUicK8qjO+OaoCAH/Xwc=; b=j8QA1yLzWV4ahRRguJiOWtDgUkZsICB1MhU76gAXiXDSEi4Y2wXdERf3LJwJ9wusNf OFQBQSayoF4cSDfeneGZD78qN+N0ZgMpt4EllNni5PevxTCHst9413Uff764kMg4IjBE F6O7kdn3UK5rYjL6+l8UTpzKZ00E0Lwn5TX7xqcjnVrYeqKTsuDfmBSVCRydn82x6HG+ MtSPaA0Yi2UIQF70qBabIeEBL4klZzDRQVXyaWbQ9bnFe9oZURmI478mlC2xTzVIKApF 4ZfICCCX56KPBckzQjOLSVyB/nHAP2Sy5pVG+e7YcZgjtL7Dr3G3lMgwZyRTw4q6e79J GvzA== 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.08; Sat, 02 Feb 2019 07:42:08 -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 S1727790AbfBBPmI (ORCPT + 15 others); Sat, 2 Feb 2019 10:42:08 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:36225 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbfBBPmI (ORCPT ); Sat, 2 Feb 2019 10:42:08 -0500 Received: by mail-oi1-f193.google.com with SMTP id x23so8329535oix.3 for ; Sat, 02 Feb 2019 07:42:07 -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=EcY7KbO6hKDIjnSJCdxYMZiUUicK8qjO+OaoCAH/Xwc=; b=htV6mz/ZhiPCGOMtkNX+NvULlceS1fP7gMy+2nW1sLY2bL0TV2WpXvq+RisKemA9wC /hgpKzr+JYKgZz+mrdCnVEvcfkEHzc0fEeSSaDJPPEvZ3hzavGEmKBN/knomCvhZbjqP BHCSdYAzh8dBcmu+mN3Pu6bu+Zm3smmDBeqnBwoFQb+f3FlE+BUHxcH9M5ixRIeDeD7I EEpDdbBquByNiZmtWnzSXJFSDbcNERJ6hx9x2vsynryVtRBOvllhw72eZ/XF4Eht+5TF 39D6HPG6WHr2/e47y81JMu0GIeWSlW4CDAGj6kXF4VfV3hMnPArcTHV1H8GTHjx+IVIn K9Vg== X-Gm-Message-State: AJcUukfzqCQHEHbsGbGxSEPe2PyEn6n2ZYB0UtMrMCQgmavWPtyrK6Tw lcvwtnkuLqeBqCErZkpscA== X-Received: by 2002:aca:e7c9:: with SMTP id e192mr22347780oih.155.1549122125724; Sat, 02 Feb 2019 07:42:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 07:42: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 v2 5/5] drm: vc4: Switch to use drm_gem_object reservation_object Date: Sat, 2 Feb 2019 09:41:58 -0600 Message-Id: <20190202154158.10443-6-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: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Reviewed-by: Eric Anholt 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 | 6 ------ drivers/gpu/drm/vc4/vc4_gem.c | 18 +++++++++--------- drivers/gpu/drm/vc4/vc4_plane.c | 2 +- 5 files changed, 11 insertions(+), 31 deletions(-) -- 2.19.1 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..03e9615b7229 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -7,7 +7,6 @@ */ #include -#include #include #include #include @@ -239,10 +238,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 +679,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)