From patchwork Mon Jun 17 11:34:10 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: 10998821 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 6ADAE14BB for ; Mon, 17 Jun 2019 11:34:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CB28288D8 for ; Mon, 17 Jun 2019 11:34:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51400285E8; Mon, 17 Jun 2019 11:34:29 +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 0307328606 for ; Mon, 17 Jun 2019 11:34:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 221D7891BA; Mon, 17 Jun 2019 11:34:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4971489187; Mon, 17 Jun 2019 11:34:18 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id f17so6202247wme.2; Mon, 17 Jun 2019 04:34:18 -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=SCmQnmcY4NzqY/5Bf7A5cP+mrIFdJrWjkKa1PaxVDnc=; b=UegRjsvNMh09Z5krAoBnu3HoWYRBRjBz5aVSIcernHvVGbq2u3AAgu4cdHPJeJOvum MbWaDVMHFeTcgAxStYmohSnd0QCNvdUkHkQoc1Ywp2aLOBb1Vvw8gPXe0pfRd8BJYSsa Ti4TAKm7ALe5MRsfhL2xwYQEkBOocKy+ai6GfwJbhSwEEH0cCXKgPkOn2E8uNLx2KZ+5 /7LahgO7Rx4820VAUKbi8ep9wz9ifoF/WwCqeSpU6Ds2eF0Orim1tActXhiTVlIE+UVO UUmYwNce6IMYF0AQT4hMvpA1Devp9RIxnJUendjXPs5ZvH+RO//BOnoNlmB2omzt8Qpd 64fA== X-Gm-Message-State: APjAAAUbl6bM9h4N9PkiGe5CH33YtfDQuRP6NBCg1xSVtyAMitOpzYB2 IPjnM1wWXm25bLGLd3jAFcKypuf2 X-Google-Smtp-Source: APXvYqwigm3l4QeXwdb63ujgrbOdGcv3hF1IefyC4mIRLt48y6Uon7WuwMRJAZRcpCyF6Rb9kAl4zw== X-Received: by 2002:a1c:3b45:: with SMTP id i66mr19176203wma.48.1560771256801; Mon, 17 Jun 2019 04:34:16 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:ad86:6268:1a78:d4c]) by smtp.gmail.com with ESMTPSA id s188sm12062110wmf.40.2019.06.17.04.34.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 04:34:16 -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: Mon, 17 Jun 2019 13:34:10 +0200 Message-Id: <20190617113413.1869-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617113413.1869-1-christian.koenig@amd.com> References: <20190617113413.1869-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=SCmQnmcY4NzqY/5Bf7A5cP+mrIFdJrWjkKa1PaxVDnc=; b=Y7u3q5P+feKNB2/zIa3cV8+YxXmxbiWPNQ+2lkR4JjrOKkSHHtrSUIas4a6qhIY9/M S2g+7MrrQ0QjoiHEKODfjR6KpvM9vQ+y6nYiMxTFtDslZUmojfRYjLRIhLcxF48rwjkp GE6QBv3xg5BMFF1aOrUe/mwRSUbV9Yu5hIqgMmnQPl8keorn1hAbM8pxvFZOrUOvTUcl 3mrK0JsLPI0LjHn4139Pvv182pvbvC1paDfHUPaQWcayDPH8rZHqhZjhQVyZ7vBAkhVk d1WlayxYVDv1yjj8Mg6gF+Fjn6mlfyKhc8peMKtBtW07eFPBzd0u9vNlFfxG9CWYAK2p xXNA== 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 895d77d799e4..95f47d685921 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;