From patchwork Thu Dec 15 17:10:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Nicolai_H=C3=A4hnle?= X-Patchwork-Id: 9476557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E8AF60571 for ; Thu, 15 Dec 2016 17:10:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BAFE287B8 for ; Thu, 15 Dec 2016 17:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 602CE287DA; Thu, 15 Dec 2016 17:10:56 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 00110287B8 for ; Thu, 15 Dec 2016 17:10:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 394CF89C46; Thu, 15 Dec 2016 17:10:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 582016EA34; Thu, 15 Dec 2016 17:10:28 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id a20so7794700wme.2; Thu, 15 Dec 2016 09:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NK9wn24SIeKtzdeS9RHxhoJ98Ot+WuqQaZOzHHP6GkI=; b=jc/Xi9J3PQyW+tnb6m7YCKBU4S+Ep7DtUymGHggLQ6C1cFAw4oroNICIz0nB2WDvks ubMcj4x80pJdGigVrXIWaYdm+53EzQGTMR1sO5nGsNNNhjVh2WZpmBR2vAAzty8ChFtW d/ErJloAbW27P1dj9VIpdYMRmkpz2A/qzP/sarSK3u8t3qUo1bqZRA0IAPRHFAQwgNNM unQ7wG6D/8BdN1K3mtkxHtwpZOlKDfhS4HftaXMQqcayTs54kFo37Msa4toukbyKkDKF 0GPtovr1EWyYpc5IV+mbMZRqbHkJVe8m5tvaFaobWtPjTIMfeHRB/d7aPl38PmGuySLE 7BBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NK9wn24SIeKtzdeS9RHxhoJ98Ot+WuqQaZOzHHP6GkI=; b=qfsLaBdR+/rWarJ5d68KDd88KXBvsNkcmeP6FStAiPcdEBzQvl1rNlnvagxqdO4xsb HLYNscRNU0+dmpmRWXl9AwbQRbuvsnemv9VVEFLMHG5Lu6hnSKG2b04Rw3h6VQuWbNRL gU6vY3mPYFO2pstwFaAN8Xx5j66MvFIrmodD87yCZTB0YQ3agfWo6RLu5/ceFXUKwalW CPsgmqItyYDQuWaezT8Kd2pbiZ9ql5RZhTAbsSIC+DkW1WihxAHP1QMdT+CjYMrXfJw1 7ODSorPi9oPdhCyRhCA4qroi4TfW9Vi5XsqUAWT3uYKbaiYt+zL40Gn0eoYXdMxUy8QZ OJNA== X-Gm-Message-State: AIkVDXKDOR8NfnrA2eG9ba6KtPqzUqO0hgQjCm0Wj8U6zu48C4leUKbMteKmBsbnHRujLQ== X-Received: by 10.28.154.140 with SMTP id c134mr2489522wme.25.1481821826422; Thu, 15 Dec 2016 09:10:26 -0800 (PST) Received: from auriga.fritz.box ([2001:a61:1106:8e01:10c0:f59e:de43:5485]) by smtp.gmail.com with ESMTPSA id d85sm13323015wmd.17.2016.12.15.09.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Dec 2016 09:10:26 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: amd-gfx@lists.freedesktop.org Subject: [PATCH 2/5] drm/amd/amdgpu: move eviction counting to amdgpu_bo_move_notify Date: Thu, 15 Dec 2016 18:10:12 +0100 Message-Id: <1481821815-9971-3-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481821815-9971-1-git-send-email-nhaehnle@gmail.com> References: <1481821815-9971-1-git-send-email-nhaehnle@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Virus-Scanned: ClamAV using ClamSMTP From: Nicolai Hähnle This catches evictions of shadow page tables from the GART. Since shadow page tables are always stored in system memory, amdgpu_bo_move is never called for them. This fixes a crash during command submission that occurs when only a shadow page table and no other BOs were evicted since the last submission. Fixes: 1baa439fb2f4e586 ("drm/amdgpu: allocate shadow for pd/pt bo V2") Signed-off-by: Nicolai Hähnle Acked-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index c29db99..d94cdef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -855,20 +855,24 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); struct amdgpu_bo *abo; struct ttm_mem_reg *old_mem = &bo->mem; if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) return; abo = container_of(bo, struct amdgpu_bo, tbo); amdgpu_vm_bo_invalidate(adev, abo); + /* remember the eviction */ + if (evict) + atomic64_inc(&adev->num_evictions); + /* update statistics */ if (!new_mem) return; /* move_notify is called before move happens */ amdgpu_update_memory_usage(adev, &bo->mem, new_mem); trace_amdgpu_ttm_bo_move(abo, new_mem->mem_type, old_mem->mem_type); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8f18b8e..80924c2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -460,24 +460,20 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, struct ttm_mem_reg *old_mem = &bo->mem; int r; /* Can't move a pinned BO */ abo = container_of(bo, struct amdgpu_bo, tbo); if (WARN_ON_ONCE(abo->pin_count > 0)) return -EINVAL; adev = amdgpu_ttm_adev(bo->bdev); - /* remember the eviction */ - if (evict) - atomic64_inc(&adev->num_evictions); - if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) { amdgpu_move_null(bo, new_mem); return 0; } if ((old_mem->mem_type == TTM_PL_TT && new_mem->mem_type == TTM_PL_SYSTEM) || (old_mem->mem_type == TTM_PL_SYSTEM && new_mem->mem_type == TTM_PL_TT)) { /* bind is enough */ amdgpu_move_null(bo, new_mem);