From patchwork Thu Dec 15 17:10:14 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: 9476563 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 CC22A60571 for ; Thu, 15 Dec 2016 17:11:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9272287B8 for ; Thu, 15 Dec 2016 17:11:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADF75287DA; Thu, 15 Dec 2016 17:11:06 +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 6D4F1287B8 for ; Thu, 15 Dec 2016 17:11:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F36E6EA43; Thu, 15 Dec 2016 17:10:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED9076EA38; Thu, 15 Dec 2016 17:10:29 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id g23so7776353wme.1; Thu, 15 Dec 2016 09:10:29 -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=343+j5KR8eB64iNlSDM+plUtstJzpt/BX6BcRiUWE/k=; b=SqwAgWKrX3tsQYk2Ihr2qs8FxfT5AMuXHJLSV6xMFKGFNRFalkfp8WFd+UbuaLWk/d TfhBrgLQofR+u/5To5goUsikvMrr9VqCKUImgTYGbktqkyGalRANUntNGAXeERRXjj/f wsMwD+wEIfpdXyz1gr8lRlmxJZCVouU3l9c/gdzjlwyUe7jBSn04/v+scGww521/Wox+ HRTPQLtMbBYrkuYpMZ5adB4uu7OXJ/iWbp9+wpgmX7yd+maHj0ZmZvAihK3IDbUFZxvJ MZc6F76t4yXS6xG4D9H6syL46TkWXdKzLeMft66ud5WEhjmFLVdVzDcz1xd7N05lmdB7 oq8g== 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=343+j5KR8eB64iNlSDM+plUtstJzpt/BX6BcRiUWE/k=; b=SX25jOznsCgKUgg5FLjMWix3A1cmwiRvx80HTgEUMWfX0AFgcS/2BAHHyHMz+RHEXA niQ+TAXhS4ncLiBghr+Iu+XOwA3gzk3qj7evBXIGmfLxgRc+Ywe2OItakAUO0cgCGS0J OXBCpEnZrKC67wsjjrOkzENebJy9canclxeC63iO9nszVC8EVfHJ2oMx0/v5XG//ffe6 hB+GVv+XItVB5p/oJzeM0ZoV51OIKSJNllBEf7zI2wXerR8nJx+AEHAowbiVWSmt92DM iX0oYqoZsueHpC/ZjnG8wFcA+tCgaW9Y+aUloXo9FK0PlebAWGh+qJDfAQDCNrR4bD8r oSrA== X-Gm-Message-State: AIkVDXKcJBMSQkZLbw0IpoGot2rC1xtrTqJdUggYP42ZCS6szT3GzcZ2mIlmhGFs3xtX0Q== X-Received: by 10.28.30.146 with SMTP id e140mr2479803wme.112.1481821828085; Thu, 15 Dec 2016 09:10:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Dec 2016 09:10:27 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: amd-gfx@lists.freedesktop.org Subject: [PATCH 4/5] drm/amd/amdgpu: add check that shadow page directory is GPU-accessible Date: Thu, 15 Dec 2016 18:10:14 +0100 Message-Id: <1481821815-9971-5-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 Skip amdgpu_gem_va_update_vm when shadow the page directory is swapped out. Clean up the check for non-shadow BOs as well using the new helper function. This fixes a crash with the stack trace: amdgpu_gem_va_update_vm -> amdgpu_vm_update_page_directory -> amdgpu_ttm_bind -> amdgpu_gtt_mgr_alloc Signed-off-by: Nicolai Hähnle Reviewed-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index cd62f6f..4e1eb05 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -489,44 +489,49 @@ static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo) * vital here, so they are not reported back to userspace. */ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va, uint32_t operation) { struct ttm_validate_buffer tv, *entry; struct amdgpu_bo_list_entry vm_pd; struct ww_acquire_ctx ticket; struct list_head list, duplicates; - unsigned domain; int r; INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&duplicates); tv.bo = &bo_va->bo->tbo; tv.shared = true; list_add(&tv.head, &list); amdgpu_vm_get_pd_bo(bo_va->vm, &list, &vm_pd); /* Provide duplicates to avoid -EALREADY */ r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); if (r) goto error_print; list_for_each_entry(entry, &list, head) { - domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); + struct amdgpu_bo *bo = + container_of(entry->bo, struct amdgpu_bo, tbo); + /* if anything is swapped out don't swap it in here, just abort and wait for the next CS */ - if (domain == AMDGPU_GEM_DOMAIN_CPU) + if (!amdgpu_bo_gpu_accessible(bo)) + goto error_unreserve; + + if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) goto error_unreserve; } + r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check, NULL); if (r) goto error_unreserve; r = amdgpu_vm_update_page_directory(adev, bo_va->vm); if (r) goto error_unreserve; r = amdgpu_vm_clear_freed(adev, bo_va->vm);