From patchwork Tue Jun 25 12:46:51 2019 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: 11015447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77A9A14E5 for ; Tue, 25 Jun 2019 12:47:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FB028BDB for ; Tue, 25 Jun 2019 12:47:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E770286BC; Tue, 25 Jun 2019 12:47:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E85928806 for ; Tue, 25 Jun 2019 12:47:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8D636E0FF; Tue, 25 Jun 2019 12:47:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB51C6E0F3; Tue, 25 Jun 2019 12:47:00 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id r16so17691528wrl.11; Tue, 25 Jun 2019 05:47:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v5L9Xdn0y6izCymoL49EFO43kHxHRkZQHp0S0q+DdXM=; b=GiWRLFYF+YUxbmNwbnYgQWjide+5O18szpH81W6fPSOe1DG6n0aZYYjheSNWvjjSL3 mZ82uyoPozb15Q2JmYVqpPDzivVEH+9xxvinsThVx0vRcoIo6dFGPFk0+x1/uFDHc5GR mZL9mhCdpu+wmZvnGg3piIQqPwDwB+yBrsLMHwEChyXtuIHhe0LSK1RPqrsvLVvFfJk+ w9zdOYr6XOL2URuIFKJG7eJFMif9wIXWnJDIfF6J5y4MHuqeyIDJf8sqytRiUw241U2k BrhZXElg4jBGgc152SB+T/X5VaZROCqn86OXGkPYOy/0424LugOC4NGXcoURrFGa7t0m jeTA== X-Gm-Message-State: APjAAAUmiGh5M69ZF+/PEvM6PWnUcUVgHCMn8BWd5In8swCApc1lPO4C OVkLAlqElB4PR+byamcbKRrr7afn X-Google-Smtp-Source: APXvYqzLm537RelRgc9zEkSa2HCmaWytr92QdtVEc3me037JupZZ8c2kKNng1w1q+vNq0awSg+jb9Q== X-Received: by 2002:a5d:694a:: with SMTP id r10mr19534543wrw.345.1561466819313; Tue, 25 Jun 2019 05:46:59 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:2df2:5da:22f9:1506]) by smtp.gmail.com with ESMTPSA id y184sm2334231wmg.14.2019.06.25.05.46.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 05:46:58 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Date: Tue, 25 Jun 2019 14:46:51 +0200 Message-Id: <20190625124654.122364-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625124654.122364-1-christian.koenig@amd.com> References: <20190625124654.122364-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=v5L9Xdn0y6izCymoL49EFO43kHxHRkZQHp0S0q+DdXM=; b=i7ueI8utfteh7RZxDdSyXEb0upNg+zQZE7uBwKx1sswpnBaw80Re0357IJ55wMoRTS AG9f2bvc0xWKXkMnprFI4Pi8PCSnNlfiVPKX6THnUlddarC2lYDHK8RGF4/E2QrCD5jJ HSip7Oe4ClFV9akxuoqYwqONchWcEybrSq8HnItEgrC9wtk58dyKykXGGigEmxm64Bqi zURzSp4CmzHIKAr42cMcEOC0Bikcd3/h4IhZxH0jpg3tGEpQQyq20TT3v7y8cdGhHc6g 56eQcot8YoSj3eWLAg2g3JNYn3weas1hFmfYG3hOfsDbEX6L3Yb0e+JjsGxAF3O0Gh24 g84Q== Subject: [Intel-gfx] [PATCH 3/6] drm/ttm: use the parent resv for ghost objects v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This way we can even pipeline imported BO evictions. v2: Limit this to only cases when the parent object uses a separate reservation object as well. This fixes another OOM problem. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 9f918b992f7e..5992ca821c69 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -517,9 +517,11 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, kref_init(&fbo->base.kref); fbo->base.destroy = &ttm_transfered_destroy; fbo->base.acc_size = 0; - fbo->base.resv = &fbo->base.ttm_resv; - reservation_object_init(fbo->base.resv); - ret = reservation_object_trylock(fbo->base.resv); + if (bo->resv == &bo->ttm_resv) + fbo->base.resv = &fbo->base.ttm_resv; + + reservation_object_init(&fbo->base.ttm_resv); + ret = reservation_object_trylock(&fbo->base.ttm_resv); WARN_ON(!ret); *new_obj = &fbo->base; @@ -716,7 +718,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, if (ret) return ret; - reservation_object_add_excl_fence(ghost_obj->resv, fence); + reservation_object_add_excl_fence(&ghost_obj->ttm_resv, fence); /** * If we're not moving to fixed memory, the TTM object @@ -729,7 +731,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, else bo->ttm = NULL; - ttm_bo_unreserve(ghost_obj); + reservation_object_unlock(&ghost_obj->ttm_resv); ttm_bo_put(ghost_obj); } @@ -772,7 +774,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, if (ret) return ret; - reservation_object_add_excl_fence(ghost_obj->resv, fence); + reservation_object_add_excl_fence(&ghost_obj->ttm_resv, fence); /** * If we're not moving to fixed memory, the TTM object @@ -785,7 +787,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, else bo->ttm = NULL; - ttm_bo_unreserve(ghost_obj); + reservation_object_unlock(&ghost_obj->ttm_resv); ttm_bo_put(ghost_obj); } else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) { @@ -841,7 +843,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) if (ret) return ret; - ret = reservation_object_copy_fences(ghost->resv, bo->resv); + ret = reservation_object_copy_fences(&ghost->ttm_resv, bo->resv); /* Last resort, wait for the BO to be idle when we are OOM */ if (ret) ttm_bo_wait(bo, false, false); @@ -850,7 +852,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) bo->mem.mem_type = TTM_PL_SYSTEM; bo->ttm = NULL; - ttm_bo_unreserve(ghost); + reservation_object_unlock(&ghost->ttm_resv); ttm_bo_put(ghost); return 0;