From patchwork Thu Dec 15 17:59:02 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: 9476667 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 2425D60571 for ; Thu, 15 Dec 2016 17:59:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B32287FB for ; Thu, 15 Dec 2016 17:59:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA7F28807; Thu, 15 Dec 2016 17:59:19 +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 BBB30287FB for ; Thu, 15 Dec 2016 17:59:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96BB36EA5D; Thu, 15 Dec 2016 17:59:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id ACF616EA58; Thu, 15 Dec 2016 17:59:11 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u144so8027441wmu.0; Thu, 15 Dec 2016 09:59:11 -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=tjGKdJnxHFZr6aUmUpuE1qh/XeCcQ2yLM+pwDEQleAs=; b=HW+BRIedGO8VwBdpnZMbkR/igUd+bR4NuWXlVop68/z8z3jRQAtiAcUq5DmyvDvNG/ T44mKuzQMa/GTpgI4MC2vrVWagthGsmJ7ZTWjM318CsmLNRsO7dVPdHUHmJkN7ND+83A tl5A+o6ENMhVgMW400w0bmBZHlC8aYr7QthzA8ONNI2ONXT0shhGQDzwEjRJL+iDvoZU 8452fnhToucSGFST3xAnzMY8+Nrq+djRntEQ7v8UTmjfd5ukKLFdEotk4CEB3eCPd6l8 iP71QFznSPLFVJaIEf+6OOgDhFPFyND06e9WK+u4sDPoMpYosONagSX20cpL5nOrHxbD PLuQ== 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=tjGKdJnxHFZr6aUmUpuE1qh/XeCcQ2yLM+pwDEQleAs=; b=lTw03wFa0G2e8HP73X5kJx65M3g8r0z7HI77U4DiOWxrJGfJQ0rT+UF++7Ean6svhq sn8IG30r2KeCGEgJYUPOaLaCkXxVGABmxjFD0/5paFDx/v1uINeonMMfb+Gbixetd6Gk 1GO/BcnYiUqtLFLNwpL6WkrBpkflANBtnyxfyGelBL1YoTsdqsjdTQI+YmrwwjZW1Oi0 60WCM+3UoiVfqG7x+4DOjFEZXgQBcPHCoUiGLC32jToreWPt8BykobrMj8e/yICaZahW eIKFPI+lKxK3w/+PX7NB0CFvawb25VF6Teg8twHwwdTaZEkPUc/R0ekgs1ybybyzaHoF apfw== X-Gm-Message-State: AIkVDXIsibz9zl3MWZXYS6HhwWfv6USFS8qbOhyOnaCKCgjudy6IUxTV9U7SGSDzI23xLw== X-Received: by 10.28.25.134 with SMTP id 128mr2556494wmz.37.1481824750056; Thu, 15 Dec 2016 09:59:10 -0800 (PST) Received: from auriga.fritz.box ([2001:a61:1106:8e01:10c0:f59e:de43:5485]) by smtp.gmail.com with ESMTPSA id kq7sm3066047wjb.30.2016.12.15.09.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Dec 2016 09:59:09 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: amd-gfx@lists.freedesktop.org Subject: [PATCH v2] drm/amd/amdgpu: add check that shadow page tables are GPU-accessible Date: Thu, 15 Dec 2016 18:59:02 +0100 Message-Id: <1481824743-11139-1-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481821815-9971-6-git-send-email-nhaehnle@gmail.com> References: <1481821815-9971-6-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 otherwise. Also clean up the check for the non-shadow page tables 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 v2: actually check bo->shadow instead of just checking bo twice Signed-off-by: Nicolai Hähnle Reviewed-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 4e1eb05..9bd1b4e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -464,26 +464,29 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data, unreserve: amdgpu_bo_unreserve(robj); out: drm_gem_object_unreference_unlocked(gobj); return r; } static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo) { - unsigned domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); - /* if anything is swapped out don't swap it in here, just abort and wait for the next CS */ + if (!amdgpu_bo_gpu_accessible(bo)) + return -ERESTARTSYS; + + if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) + return -ERESTARTSYS; - return domain == AMDGPU_GEM_DOMAIN_CPU ? -ERESTARTSYS : 0; + return 0; } /** * amdgpu_gem_va_update_vm -update the bo_va in its VM * * @adev: amdgpu_device pointer * @bo_va: bo_va to update * * Update the bo_va directly after setting it's address. Errors are not * vital here, so they are not reported back to userspace.