From patchwork Thu Aug 29 14:29:15 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: 11121853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9934814D5 for ; Thu, 29 Aug 2019 16:16:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 814E021874 for ; Thu, 29 Aug 2019 16:16:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 814E021874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04FE46E11F; Thu, 29 Aug 2019 16:16:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id E90266E10B; Thu, 29 Aug 2019 14:29:22 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id k2so2527036wmj.4; Thu, 29 Aug 2019 07:29:22 -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=N4tzF5ZJXTgKfqcRosNis+efs/wFEuz1xTl1VpiMyO0=; b=CyIE6H7FSKvV0mok3YlqruyHvGJI9yPx62ke1++GWNID4Lz+7sqzqDmv1Dsynf8cz/ Rh/dUZdeuVX8htEkQZejUeNAwn+bLdTRTx9PiL2natPwu3R385im2jF0JrLEgbx/eoQm qpjvOaO/Dfnd4+WseuKEXT6sbYMJYpwpGqpiKD3WavnLuWoCIaUe63MPUtbx9vaKwIKo w7w5RARtkCs33f94sZLNSnzSm160Am26B9FjSa85gE9feG9BIzhMFwsOd7vMtkcmzUZj qCZdvQu6h0xn4pkhqY0KVD8tPAxidS/7jQZUBInmd/ykz+ppqAszwFpe2/zcm4/iiOZC 30xQ== X-Gm-Message-State: APjAAAU0zM5pWZOcpYVefTOOJxSYYVdfQBZCwz1Z+xOhokNG20XclUAz 7PR/iYQoHIIh5GLMMtHSHZc= X-Google-Smtp-Source: APXvYqx6tcKU1r7qaaYSr8sMssGM//Lu4xfotFoq5cn8rHzDfn/+zTlOF7MIv+pK5f1a63O1TAUJWA== X-Received: by 2002:a1c:c542:: with SMTP id v63mr11679165wmf.97.1567088961582; Thu, 29 Aug 2019 07:29:21 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:d57:5a0b:4833:fc9f]) by smtp.gmail.com with ESMTPSA id w13sm6188214wre.44.2019.08.29.07.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 07:29:21 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, sumit.semwal@linaro.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Date: Thu, 29 Aug 2019 16:29:15 +0200 Message-Id: <20190829142917.13058-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190829142917.13058-1-christian.koenig@amd.com> References: <20190829142917.13058-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 29 Aug 2019 16:16:26 +0000 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=N4tzF5ZJXTgKfqcRosNis+efs/wFEuz1xTl1VpiMyO0=; b=o4USWOkNUcJcJk2i5BUVKmMP46dwQ6nHcENwePmgNaZCtn1TyhafxSHQX5pA0d3MrI R9drdt67SNuxkXWmvJwoRESzyzvTM+Tdvd2M9T6KKwdXHKTqKXGqE1aB7zQz1nRCVHW5 vet+jugOfy56V4JD0xw2JbjpGkP6FXNTvW3c1VmGArHcrkgAFOlP8Sa1+RCbu2N+Z2aA tjdSKbBUNoAKNENY6tTVVuvY86W5kuHc9XXEqBmsTlTe+0HxRhfWHIbK3e5wAg+T8W/F qbad5PNl1Yy/7X6qZFFW6Oo7y60haPANoo+4gwD6zh2shzbOqzBybdAOw9D3taqF5pmk Xs9A== Subject: [Intel-gfx] [PATCH 2/4] 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" 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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index fe81c565e7ef..2ebe9fe7f6c8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -517,7 +517,9 @@ 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.base.resv = &fbo->base.base._resv; + if (bo->base.resv == &bo->base._resv) + fbo->base.base.resv = &fbo->base.base._resv; + dma_resv_init(fbo->base.base.resv); ret = dma_resv_trylock(fbo->base.base.resv); WARN_ON(!ret); @@ -716,7 +718,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, if (ret) return ret; - dma_resv_add_excl_fence(ghost_obj->base.resv, fence); + dma_resv_add_excl_fence(&ghost_obj->base._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); + dma_resv_unlock(&ghost_obj->base._resv); ttm_bo_put(ghost_obj); } @@ -772,7 +774,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, if (ret) return ret; - dma_resv_add_excl_fence(ghost_obj->base.resv, fence); + dma_resv_add_excl_fence(&ghost_obj->base._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); + dma_resv_unlock(&ghost_obj->base._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 = dma_resv_copy_fences(ghost->base.resv, bo->base.resv); + ret = dma_resv_copy_fences(&ghost->base._resv, bo->base.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); + dma_resv_unlock(&ghost->base._resv); ttm_bo_put(ghost); return 0;