Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp285208imu; Thu, 8 Nov 2018 08:17:46 -0800 (PST) X-Google-Smtp-Source: AJdET5ehQEekHX6lBNy6ZZnfzCjh4btLj9Pt6rguYgmMMRMTUpwl+XG3s+FlqX42gzH28bPA33iK X-Received: by 2002:a17:902:d698:: with SMTP id v24-v6mr5056610ply.325.1541693866376; Thu, 08 Nov 2018 08:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541693866; cv=none; d=google.com; s=arc-20160816; b=X1CLTt/nNaA5JD4RZBjnAe1rZ6Jpbt6SG0ejoq18FkEp9SkfN/3jFE07vHPgS1sEYd Q7NtaqzoPbhimsa3jYsX7OnO6+4xyUH+TrcFu70LRFaMquFPtci0ygCj8dKeocXS1t78 BfoGQYiQXr5qjcjfiTE7qxeYSYCOoA+L0aR735IovIj67vn3BV3xjxat8vtJet+ZPxBb stnZBViYQK4e4YkU/X7Y9slBjzx8m+PfBzHhZ+Q/AP7fiolg6rPdiuhW2MqPNEbL+hox VpGOj+B6hfzOr7Ua3cj+CbVtj8gTi5Vzb/hvv64+LTFg0/GE8/PfsYl5YgXUGHoPrz5n 8HVg== 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=iTlcrDZ4qhACTX6+sMGlYi+EoWzNMsqb57rzpB+T0h8=; b=XQdCsxWj/bxzLKNVHlnDmEQtfZCt8MrVyP4RBso1AKBpvlZ5ph/BKzRQaQ3fKmNSm4 tRUNhb+t9oPmD5hOvWktN3tmKaXwNbnrelFh7V2/Jwe9FlwCf3kbsCcJRDt7IPIUlzKp BnKP54xXcuzeTbk2XaSsFSoov8iaGGiv6xh8e63pr76nTJfVhPqjzORXzKg41IphfojU vZQZMY0h2lpVe6kTqBLCZq4d7+5r8KEzqPRjsguKE+g9TEsdUfipVtEb97PgXiNSsvmG dRqYyIaUrDx6+ZtsRi5Cffhn/QObGE3nvfJGTTEmJ2XesPH0R/O4XrxxBFOVmmEeeKiR 078w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v64-v6si5188703pfj.167.2018.11.08.08.17.30; Thu, 08 Nov 2018 08:17:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbeKIBxQ (ORCPT + 99 others); Thu, 8 Nov 2018 20:53:16 -0500 Received: from anholt.net ([50.246.234.109]:33410 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727299AbeKIBxP (ORCPT ); Thu, 8 Nov 2018 20:53:15 -0500 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 0A5C410A1339; Thu, 8 Nov 2018 08:17:03 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mBACcP1FQJaz; Thu, 8 Nov 2018 08:17:00 -0800 (PST) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 7448210A1314; Thu, 8 Nov 2018 08:16:55 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 102F52FE1BF5; Thu, 8 Nov 2018 08:16:54 -0800 (PST) From: Eric Anholt To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, boris.brezillon@bootlin.com, Daniel Vetter , Eric Anholt Subject: [PATCH 3/4] drm/v3d: Clean up the reservation object setup. Date: Thu, 8 Nov 2018 08:16:53 -0800 Message-Id: <20181108161654.19888-4-eric@anholt.net> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108161654.19888-1-eric@anholt.net> References: <20181108161654.19888-1-eric@anholt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The extra to_v3d_bo() calls came from copying this from the vc4 driver, which stored the cma gem object in the structs. Signed-off-by: Eric Anholt --- drivers/gpu/drm/v3d/v3d_gem.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index b88c96911453..d0dfdcbbd42c 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -214,10 +214,8 @@ v3d_attach_object_fences(struct v3d_exec_info *exec) int i; for (i = 0; i < exec->bo_count; i++) { - bo = to_v3d_bo(&exec->bo[i]->base); - /* XXX: Use shared fences for read-only objects. */ - reservation_object_add_excl_fence(bo->resv, out_fence); + reservation_object_add_excl_fence(exec->bo[i]->resv, out_fence); } } @@ -228,11 +226,8 @@ v3d_unlock_bo_reservations(struct drm_device *dev, { int i; - for (i = 0; i < exec->bo_count; i++) { - struct v3d_bo *bo = to_v3d_bo(&exec->bo[i]->base); - - ww_mutex_unlock(&bo->resv->lock); - } + for (i = 0; i < exec->bo_count; i++) + ww_mutex_unlock(&exec->bo[i]->resv->lock); ww_acquire_fini(acquire_ctx); } @@ -251,13 +246,13 @@ v3d_lock_bo_reservations(struct drm_device *dev, { int contended_lock = -1; int i, ret; - struct v3d_bo *bo; ww_acquire_init(acquire_ctx, &reservation_ww_class); retry: if (contended_lock != -1) { - bo = to_v3d_bo(&exec->bo[contended_lock]->base); + struct v3d_bo *bo = exec->bo[contended_lock]; + ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, acquire_ctx); if (ret) { @@ -270,19 +265,16 @@ v3d_lock_bo_reservations(struct drm_device *dev, if (i == contended_lock) continue; - bo = to_v3d_bo(&exec->bo[i]->base); - - ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx); + ret = ww_mutex_lock_interruptible(&exec->bo[i]->resv->lock, + acquire_ctx); if (ret) { int j; - for (j = 0; j < i; j++) { - bo = to_v3d_bo(&exec->bo[j]->base); - ww_mutex_unlock(&bo->resv->lock); - } + for (j = 0; j < i; j++) + ww_mutex_unlock(&exec->bo[j]->resv->lock); if (contended_lock != -1 && contended_lock >= i) { - bo = to_v3d_bo(&exec->bo[contended_lock]->base); + struct v3d_bo *bo = exec->bo[contended_lock]; ww_mutex_unlock(&bo->resv->lock); } @@ -303,9 +295,7 @@ v3d_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_v3d_bo(&exec->bo[i]->base); - - ret = reservation_object_reserve_shared(bo->resv, 1); + ret = reservation_object_reserve_shared(exec->bo[i]->resv, 1); if (ret) { v3d_unlock_bo_reservations(dev, exec, acquire_ctx); return ret; -- 2.19.1