From patchwork Thu Oct 24 11:16:32 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: 11209013 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 B252B112C for ; Thu, 24 Oct 2019 11:16:38 +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 8F14A2084C for ; Thu, 24 Oct 2019 11:16:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F14A2084C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C9796E2A5; Thu, 24 Oct 2019 11:16:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id F09896E2A5; Thu, 24 Oct 2019 11:16:35 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id v3so1762090wmh.1; Thu, 24 Oct 2019 04:16:35 -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:mime-version :content-transfer-encoding; bh=aCQaA/HwCTAIu7RWh6OLFtX0XDvs1xwjUEkUewqaQ5o=; b=RJri05qyFmWkZej7QvD+uR6mF3jw2uz643jry/A8QALKzz4fSAChPgRH1VSctmjBqt k6Nmj+xIFK8R5VyjZupwNdUc3wC7tYn74yIzDot4YQSEgVebtfMQEJKFS2xllsftPR/R rr5Cxs2aJ1GE2KapuK+kCAeyOmi044V+7qWb+4wGrGs5ETk518g2hiZvEtaU5jbphluE vVm2MDY/ityKGW6cOXgjrSp0qsu2fdQokHpdI58t/tQlksT0C++T+8DCVSrYZgigQ4xH pDPKJWl9juVXlNDC08f0PvaC+wfzpIauhruhW2kqsnNvl9hWV4sqDyB/TGifGAHWNcV0 EoVQ== X-Gm-Message-State: APjAAAXRRLnap8/lRrywvTeIZaU7I9uTyCCP2tr1byehpzZ28rINUAkg yJu9LHpxgqsVfHT89Qp7JCbNakWA X-Google-Smtp-Source: APXvYqwNJj/s5ncCyavF1dfw67l8mX9plop2wlS1buseBzJTnll7F8CtJfbit6tS7N70Ae8KZtaxWQ== X-Received: by 2002:a7b:c4cf:: with SMTP id g15mr4135636wmk.122.1571915794444; Thu, 24 Oct 2019 04:16:34 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:c1c6:7e3f:6219:69f7]) by smtp.gmail.com with ESMTPSA id r65sm2310210wmr.9.2019.10.24.04.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 04:16:33 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, David1.Zhou@amd.com Subject: [PATCH] drm/ttm: use the parent resv for ghost objects v3 Date: Thu, 24 Oct 2019 13:16:32 +0200 Message-Id: <20191024111632.1836-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 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:mime-version :content-transfer-encoding; bh=aCQaA/HwCTAIu7RWh6OLFtX0XDvs1xwjUEkUewqaQ5o=; b=a2HwealmptzOa/gD8XCQ2u68IbXTrafOWXJhkDzpBA01lXlUgTr8vtQplQtz8wE6cR Hbpboxjglzh4H3Me7QUUaE+hcBo/FSa19Yi3Re+rcs1++q7Cz6bP4HtXdrA3kMgt3UzZ Y5rjlwhv2y2hdTicO3g0Or6xe3ciMcBFHJTEZDrFbQaFcM8CC9oYZZRu7TUEmodmJGbC QOoEtpLl/67V7cbFskqxUUK99Z2d2JPBD2jI3D47yR/xzc4JssvQvz7Xw/86bDGZBRf8 l11VJN3pAguBlwY++fZqMjHjwUjQWGO3k4Gx3DQqeZJ26ZBpWNSDoozMAU0jYeI5WY2K TjyQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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" This way the TTM is destroyed with the correct dma_resv object locked and 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. v3: fix init and try_lock on the wrong object Signed-off-by: Christian König Reviewed-by: Daniel Vetter Reviewed-by: Huang Rui 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 73a1b0186029..f7b57ca1a95b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -516,9 +516,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.base.resv = &fbo->base.base._resv; - dma_resv_init(fbo->base.base.resv); - ret = dma_resv_trylock(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); *new_obj = &fbo->base; @@ -715,7 +717,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 @@ -728,7 +730,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); } @@ -771,7 +773,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 @@ -784,7 +786,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) { @@ -840,7 +842,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); @@ -849,7 +851,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;