From patchwork Thu Aug 14 16:12:03 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: 4724711 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 23191C0338 for ; Thu, 14 Aug 2014 16:14:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CBB62017A for ; Thu, 14 Aug 2014 16:14:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 19F922013A for ; Thu, 14 Aug 2014 16:14:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67A216E6E0; Thu, 14 Aug 2014 09:14:02 -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 98DC16E6E0 for ; Thu, 14 Aug 2014 09:14:00 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id BCBFB72A151 for ; Thu, 14 Aug 2014 18:13:59 +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 J8bxVLKF03MA for ; Thu, 14 Aug 2014 18:13:37 +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 9FFCB72A115 for ; Thu, 14 Aug 2014 18:12:19 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 9FFCB72A115 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1408032739; bh=UaBh4OAxp+RuO+SolaKtrznx+k5RGt1v76MAMu0pfY4=; h=From:To:Subject:Date:In-Reply-To:References; b=hbJnIPa+lObIAvC5kzX/OwtWCMWEQQKmC4tOjC/1smwLNFq5qAldZrepkZdMSiin3 W8ixeB2rCIf3YRmlibrz9yjJKpdZmXV3dasLHNr07t+vsj27mlmd+YSMfnRc2u5RhA /L7NEftfJ83ZViRq+kXYj5YPS1QYnZ06e45YEXxg= X-DKIM: OpenDKIM Filter v2.0.2 smtp-02.vodafone.de D629AE6307 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 X7G+msT5r8uV 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 2/4] drm/radeon: allow concurrent BO access by different engines Date: Thu, 14 Aug 2014 18:12:03 +0200 Message-Id: <1408032725-6236-3-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 patch allows concurrent access of different engines to the same BO as long as everybody only reads from it. Since TTM can't (yet) handle multiple fences for one BO we still sync the fence after executing the IB. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon.h | 2 ++ drivers/gpu/drm/radeon/radeon_cs.c | 24 +++++++++++++++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 8 ++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 4579361..c0f7773 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -478,6 +478,7 @@ struct radeon_bo { u32 tiling_flags; u32 pitch; int surface_reg; + struct radeon_fence *written; /* list of all virtual address to which this bo * is associated to */ @@ -1017,6 +1018,7 @@ struct radeon_cs_reloc { unsigned allowed_domains; uint32_t tiling_flags; uint32_t handle; + bool written; }; struct radeon_cs_chunk { diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 2be4fc5..3aa7e48 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].written = !!r->write_domain; radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, priority); @@ -236,7 +237,16 @@ static void radeon_cs_sync_rings(struct radeon_cs_parser *p) continue; fence = bo->tbo.sync_obj; - radeon_semaphore_sync_to(p->ib.presync, fence); + + if (bo->written && radeon_fence_signaled(bo->written)) + radeon_fence_unref(&bo->written); + + /* if either this CS or the last one write to + the BO we sync before executing the IB */ + if (reloc->written || bo->written) + radeon_semaphore_sync_to(p->ib.presync, fence); + else + radeon_semaphore_sync_to(p->ib.postsync, fence); } } @@ -406,6 +416,18 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo */ list_sort(NULL, &parser->validated, cmp_size_smaller_first); + /* remember which BOs we write to */ + for (i = 0; i < parser->nrelocs; i++) { + struct radeon_cs_reloc *reloc = &parser->relocs[i]; + struct radeon_bo *bo = reloc->robj; + + if (!bo || !reloc->written) + continue; + + radeon_fence_unref(&bo->written); + bo->written = radeon_fence_ref(parser->ib.fence); + } + ttm_eu_fence_buffer_objects(&parser->ticket, &parser->validated, parser->ib.fence); diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 72afe82..76be612 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -228,10 +228,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, struct radeon_device *rdev; uint64_t old_start, new_start; struct radeon_fence *fence; + struct radeon_bo *rbo; int r, ridx; rdev = radeon_get_rdev(bo->bdev); ridx = radeon_copy_ring_index(rdev); + rbo = container_of(bo, struct radeon_bo, tbo); old_start = old_mem->start << PAGE_SHIFT; new_start = new_mem->start << PAGE_SHIFT; @@ -269,6 +271,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, r = radeon_copy(rdev, old_start, new_start, new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */ &fence); + + if (!r) { + radeon_fence_unref(&rbo->written); + rbo->written = radeon_fence_ref(fence); + } + /* FIXME: handle copy error */ r = ttm_bo_move_accel_cleanup(bo, (void *)fence, evict, no_wait_gpu, new_mem);