From patchwork Thu Jan 6 11:20:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12705331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 333BDC433F5 for ; Thu, 6 Jan 2022 11:20:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 233F810E80A; Thu, 6 Jan 2022 11:20:47 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 06F4A10E75F; Thu, 6 Jan 2022 11:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641468045; x=1673004045; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tYmFGUZUQmsuiiMhTM3+0FrldAQob4FPAHSWtOh9p14=; b=ROR7yKWUjQsCGDqvg0UUQRY110xxS3whtXxXI41w0eafynr56Jqii9RZ WyAaUEZKFqYPSRhRbtZUr3tgUxZcx3WTarQoq+ehuKIhkULM1jhoKifkn RbqMKq3YDp5NBjKtkCr9yC0kat0N3Ni88GQZQvxQsxjrCbcPA6xiZfxg3 FZQ2Rz0vXZd0WkXxolK1df2v+5ni00GymqjxowVTTTbTc2L35Fdlxq9NY 0GALsjPKh89oYPUZSreoibAwt/i5poZpYWn4NP80BrEBb2M4AeqH6D0px dTnWD5dvquEb+al8kgIYSfKqs3jMM+XUnF74PSA519i9mK8pDIrsuD2YY Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10217"; a="305992104" X-IronPort-AV: E=Sophos;i="5.88,266,1635231600"; d="scan'208";a="305992104" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2022 03:20:44 -0800 X-IronPort-AV: E=Sophos;i="5.88,266,1635231600"; d="scan'208";a="556892141" Received: from lsgoh-mobl1.gar.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.249.65.184]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2022 03:20:42 -0800 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Thu, 6 Jan 2022 11:20:24 +0000 Message-Id: <20220106112026.247459-2-matthew.auld@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220106112026.247459-1-matthew.auld@intel.com> References: <20220106112026.247459-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 2/4] drm/i915/ttm: only fault WILLNEED objects X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Don't attempt to fault and re-populate purged objects. By some fluke this passes the dontneed-after-mmap IGT, but for the wrong reasons. Fixes: cf3e3e86d779 ("drm/i915: Use ttm mmap handling for ttm bo's.") Signed-off-by: Matthew Auld Cc: Thomas Hellström Reviewed-by: Thomas Hellström --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 923cc7ad8d70..8d61d4538a64 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -883,6 +883,11 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf) if (ret) return ret; + if (obj->mm.madv != I915_MADV_WILLNEED) { + dma_resv_unlock(bo->base.resv); + return VM_FAULT_SIGBUS; + } + if (drm_dev_enter(dev, &idx)) { ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot, TTM_BO_VM_NUM_PREFAULT);