From patchwork Mon Sep 21 03:50:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Zbigniew_Kempczy=C5=84ski?= X-Patchwork-Id: 11788275 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 9C850112C for ; Mon, 21 Sep 2020 03:50:41 +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 5AC00206E5 for ; Mon, 21 Sep 2020 03:50:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AC00206E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE5AD89EBD; Mon, 21 Sep 2020 03:50:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9630E89EBD for ; Mon, 21 Sep 2020 03:50:36 +0000 (UTC) IronPort-SDR: sSoWvUiInt3cYAdLqBSP4jxBrT3W7ZzrwcD4Gxi/nDCcFB9Ck9C/iERYao/2t/oFZPtWYiJdFD iTBRfC1fXLjA== X-IronPort-AV: E=McAfee;i="6000,8403,9750"; a="178380496" X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="178380496" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 20:50:35 -0700 IronPort-SDR: c0pXzbsm1hszCf+aUkgZG7xv0amxCafNyOnhRrJ8dqX+TWpHQQ4AFz8P3LUg8tmE8QeQcRv9/b B0TUJ6u9yNMQ== X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="485240365" Received: from mateuszp-mobl1.ger.corp.intel.com (HELO zkempczy-mobl2.ger.corp.intel.com) ([10.213.5.247]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 20:50:34 -0700 From: =?utf-8?q?Zbigniew_Kempczy=C5=84ski?= To: intel-gfx@lists.freedesktop.org Date: Mon, 21 Sep 2020 05:50:17 +0200 Message-Id: <20200921035017.6868-1-zbigniew.kempczynski@intel.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Ensure bo is dirty when WB-mapped on !llc in pagefault handler 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: Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On !llc platforms when buffer is mapped with WB using GEM_MMAP_OFFSET pagefault handler clears its dirty flag. This has consequences buffer is not flushed on exec before moving to render domain. So make sure we keep dirty flag for buffers mapped to write until it leaves cpu domain. Signed-off-by: Zbigniew KempczyƄski Cc: Chris Wilson --- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index 3d69e51f3e4d..3f61a5ccbdd5 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -239,6 +239,7 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) struct i915_mmap_offset *mmo = area->vm_private_data; struct drm_i915_gem_object *obj = mmo->obj; resource_size_t iomap; + u16 prev_write_domain; int err; /* Sanity check that we allow writing into this object */ @@ -246,6 +247,8 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) area->vm_flags & VM_WRITE)) return VM_FAULT_SIGBUS; + prev_write_domain = obj->write_domain; + err = i915_gem_object_pin_pages(obj); if (err) goto out; @@ -268,6 +271,10 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) i915_gem_object_unpin_pages(obj); + /* On !llc we need to flush before moving to render domain */ + if (!obj->cache_coherent && prev_write_domain == I915_GEM_DOMAIN_CPU) + obj->cache_dirty = true; + out: return i915_error_to_vmf_fault(err); }