Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1347124ybp; Thu, 17 Oct 2019 11:23:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvJri1cZVdC/Fe5Pydq8f1Yjh1xN06preuJNgcGimvodu/lbSJYaAxv2KrRrh9DNlpEQ0E X-Received: by 2002:a50:f414:: with SMTP id r20mr5332429edm.94.1571336638155; Thu, 17 Oct 2019 11:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336638; cv=none; d=google.com; s=arc-20160816; b=m7GpEb7TT+M0SA8WNNPqvvgpvP5l/VqYY63l/D40xENLDWaP7Ez2ErmgrovaNAYGNQ 3fblyN6qREjoVBmPnrIMNW/NwViKbVXe0bTdGyhkodmaDPAXUWc6yczgqOuTdWKx5tMl wbGFw8I21urAi4xIwAFd8q3hwLgkHZF0iBZBV4RlLr6XARVPNFxbrMFGIG1NuZABGXQy 6ShVp0uYooxb6rOSO2eZQ9Ve8Vk7fAKEL0oF1PTthP3WCef2QEfJmT0aHJtp9mpcRsBD AH72YojcleIS14Q7XOEO29X7bufcKrgkS8SbxhH/xd6zhGqs/4yG6pkYxyFxXV//06wp gijQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/ZGsBLtYzXgU3X4hmTrSaSjfX6kWmLU7UEf5ozLtTFg=; b=zvYIC4Fgy3zUxOwVgw+HiRZYmx2pdHqovpRmEmqmYyojcA20MNpj/t2PNQpnd1GG1l J2CWfearIJq5MzgnAforDWXSswINcwGrhMPxX1x38A9DzPJT0smJUzqrlM/Aek98wMVm tED6z01r2OXxbcjEBs3ET7nr51h2PSdA0OtE6CLcstDSf4KwjApPWri2yBS2QcL67oq7 BBP7IzZq6ENR8cdEar2SLsmx3tqTuLUZVEdHPsIE+jpu7AQmAQZVvJKDlW9xiHdrBj68 ko5OBhVMntgNsvm24yzp2AevY6DrcOJlkjp8XgW70IOYY+pnNnEmS9CWPcPNh0Wn1AsH /BKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f8LWlH25; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si1861502ejr.246.2019.10.17.11.23.35; Thu, 17 Oct 2019 11:23:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f8LWlH25; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406776AbfJPWDA (ORCPT + 99 others); Wed, 16 Oct 2019 18:03:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438540AbfJPV7d (ORCPT ); Wed, 16 Oct 2019 17:59:33 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05B2121D7D; Wed, 16 Oct 2019 21:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263172; bh=r+8aUgc/mfaf5/2iPvz/+sfyyYAYN95Yw/xN8JOWDWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8LWlH25HwUGhEa2B0i9sdqlOqi3xzDntY/YCZcOz90aWiaJTuKVpQ9SHdmhf9QWw PlB4VNrpAM4lNOTWcFPABICN5TTXLSv7n1d9xi1O/+weHaJd5C/dfFkSRZxdeW94R9 MirpzmB8ODkWXFmiS+Qnx+ZCTtfDJQRdWI7qp4HQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Matthew Auld , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Rodrigo Vivi Subject: [PATCH 5.3 099/112] drm/i915: Mark contents as dirty on a write fault Date: Wed, 16 Oct 2019 14:51:31 -0700 Message-Id: <20191016214906.326608454@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit b925708f28c2b7a3a362d709bd7f77bc75c1daac upstream. Since dropping the set-to-gtt-domain in commit a679f58d0510 ("drm/i915: Flush pages on acquisition"), we no longer mark the contents as dirty on a write fault. This has the issue of us then not marking the pages as dirty on releasing the buffer, which means the contents are not written out to the swap device (should we ever pick that buffer as a victim). Notably, this is visible in the dumb buffer interface used for cursors. Having updated the cursor contents via mmap, and swapped away, if the shrinker should evict the old cursor, upon next reuse, the cursor would be invisible. E.g. echo 80 > /proc/sys/kernel/sysrq ; echo f > /proc/sysrq-trigger Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111541 Fixes: a679f58d0510 ("drm/i915: Flush pages on acquisition") Signed-off-by: Chris Wilson Cc: Matthew Auld Cc: Ville Syrjälä Cc: # v5.2+ Reviewed-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20190920121821.7223-1-chris@chris-wilson.co.uk (cherry picked from commit 5028851cdfdf78dc22eacbc44a0ab0b3f599ee4a) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -317,7 +317,11 @@ vm_fault_t i915_gem_fault(struct vm_faul msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)); GEM_BUG_ON(!obj->userfault_count); - i915_vma_set_ggtt_write(vma); + if (write) { + GEM_BUG_ON(!i915_gem_object_has_pinned_pages(obj)); + i915_vma_set_ggtt_write(vma); + obj->mm.dirty = true; + } err_fence: i915_vma_unpin_fence(vma);