From patchwork Thu Aug 14 16:12:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 4724731 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EE5EAC0338 for ; Thu, 14 Aug 2014 16:15:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7399201ED for ; Thu, 14 Aug 2014 16:14:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BC1992017E for ; Thu, 14 Aug 2014 16:14:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 351F16E6E7; Thu, 14 Aug 2014 09:14:24 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id 38A746E6E6 for ; Thu, 14 Aug 2014 09:14:22 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id A62D172A159 for ; Thu, 14 Aug 2014 18:14:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: 0.165 X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=softfail (invalid, public key: DNS query timeout for mail._domainkey.vodafone.de) header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QWd8yLwuUZYu for ; Thu, 14 Aug 2014 18:13:59 +0200 (CEST) Received: from smtp-02.vodafone.de (smtp-02.vodafone.de [10.215.254.37]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id BE04672A135 for ; Thu, 14 Aug 2014 18:12:19 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de BE04672A135 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1408032739; bh=QzdllhGB7mSUi4cQ7f46+yUjGoNyIhDTqMsam1t2/SA=; h=From:To:Subject:Date:In-Reply-To:References; b=11qCJ8AS4v/4SljX4GqnTQx25iQW4wMSiwmOrGyYs5Z6oCI/hxblzjIiKtBBxz/Rk iq9lEhtDUSUBo6nYmznrsm+/JnqTzel2VQj3j7MxYRxqRqs37nkQu8KOE9iCddjBHG S2HmOy7EL0NSTInEAOHP4DHNJtsV85BqEP+nKAZY= X-DKIM: OpenDKIM Filter v2.0.2 smtp-02.vodafone.de 0E2E2E6318 X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-02.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz6.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qJvgIMbJXoMV for ; Thu, 14 Aug 2014 18:12:08 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/radeon: add DONT_SYNC flag to CS relocs Date: Thu, 14 Aug 2014 18:12:04 +0200 Message-Id: <1408032725-6236-4-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408032725-6236-1-git-send-email-deathsimple@vodafone.de> References: <1408032725-6236-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König This allows userspace to explicitly don't sync submission to different rings as long as all uses stay in the same client. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon.h | 3 +++ drivers/gpu/drm/radeon/radeon_cs.c | 23 ++++++++++++++++++++++- drivers/gpu/drm/radeon/radeon_gem.c | 1 + drivers/gpu/drm/radeon/radeon_ttm.c | 3 +++ include/uapi/drm/radeon_drm.h | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index c0f7773..740a0b2 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -478,6 +478,8 @@ struct radeon_bo { u32 tiling_flags; u32 pitch; int surface_reg; + struct drm_file *last_user; + struct radeon_fence *last_sync; struct radeon_fence *written; /* list of all virtual address to which this bo * is associated to @@ -1018,6 +1020,7 @@ struct radeon_cs_reloc { unsigned allowed_domains; uint32_t tiling_flags; uint32_t handle; + uint32_t flags; bool written; }; diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 3aa7e48..11e4789 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c @@ -166,6 +166,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; p->relocs[i].handle = r->handle; + p->relocs[i].flags = r->flags; p->relocs[i].written = !!r->write_domain; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, @@ -236,6 +237,14 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p) if (!bo) continue; + /* always sync to the last operation + the clients doesn't know about */ + radeon_semaphore_sync_to(p->ib.presync, bo->last_sync); + + if (bo->last_user == p->filp && + reloc->flags & RADEON_RELOC_DONT_SYNC) + continue; + fence = bo->tbo.sync_obj; if (bo->written && radeon_fence_signaled(bo->written)) @@ -421,7 +430,19 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo struct radeon_cs_reloc *reloc = &parser->relocs[i]; struct radeon_bo *bo = reloc->robj; - if (!bo || !reloc->written) + if (!bo) + continue; + + /* if the client changes remember that and always serialize + all operations from different clients */ + if (bo->last_user != parser->filp && bo->tbo.sync_obj) { + struct radeon_fence *fence = bo->tbo.sync_obj; + radeon_fence_unref(&bo->last_sync); + bo->last_sync = radeon_fence_ref(fence); + } + bo->last_user = parser->filp; + + if (!reloc->written) continue; radeon_fence_unref(&bo->written); diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index bfd7e1b..c73dbc1 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -259,6 +259,7 @@ int radeon_gem_create_ioctl(struct drm_device *dev, void *data, r = radeon_gem_handle_lockup(rdev, r); return r; } + gem_to_radeon_bo(gobj)->last_user = filp; r = drm_gem_handle_create(filp, gobj, &handle); /* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked(gobj); diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 76be612..a4f964f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -273,6 +273,9 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, &fence); if (!r) { + rbo->last_user = NULL; + radeon_fence_unref(&rbo->last_sync); + rbo->last_sync = radeon_fence_ref(fence); radeon_fence_unref(&rbo->written); rbo->written = radeon_fence_ref(fence); } diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h index 509b2d7..5bd3f68 100644 --- a/include/uapi/drm/radeon_drm.h +++ b/include/uapi/drm/radeon_drm.h @@ -944,6 +944,8 @@ struct drm_radeon_cs_chunk { }; /* drm_radeon_cs_reloc.flags */ +#define RADEON_RELOC_PRIO_MASK (0xf << 0) +#define RADEON_RELOC_DONT_SYNC (1 << 4) struct drm_radeon_cs_reloc { uint32_t handle;