Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3547179pxj; Mon, 24 May 2021 09:06:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIz8nH4fF6O0LV9ADcxFI27v10Y0ldjoy2QzCEJoIBKjrAxURO+vvm+q5VnKEFDfYx9wMQ X-Received: by 2002:a05:6e02:104e:: with SMTP id p14mr18779270ilj.109.1621872399391; Mon, 24 May 2021 09:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872399; cv=none; d=google.com; s=arc-20160816; b=R1C/Fy2Hdl0R6JoAmVMbX5qyF2hLEHrb0a8y5VltykKiHDuZWY5CEHWl1i7eckQboM ez0usj0T/fQS2mxLXbyIAJiwQ+j+hKdLgLetQYilfNV9VdPZjmu/7IuSS4K6yLDDck8i xFLA9dNh+ak/lnkGknYoVpLh8EuQbXoDps0qKlrRDEMiBfeK1ZM6TuQCUMr1P3EFxwNh uhEUMvrUKpjmlUNaxOrdIod3CfkNjHBIz8olZR9tR3DtrGzEx9nWjQjuyYVqK/rLQg3V PJc/H8qqm2IXyAcZ3PaPUZPVphUCTXeJ1u0a7f8e21L778qWFICvXrn1oZGfYkzO1slG R4wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ma5gvM5gFEoK9TK/HUGGIehmmYB4dacQVKHlrNOoGd8=; b=cEQ099DqlqfbLoTXzm6bRtS7zYENg4fyhor4ZgarUf5PI0JmZJ+rLK+feaKQDpdV80 q+TS1GTrxu+QPagwBppN3geJ+AEJioN6+lmcmwk6SaqLWjVk0GgHbUVRLR4GSHGxygDy gcXPJLEkWhIyx/cGiC6br6fv18Uy7Z/MAQ6BCLd5u/GOFiu+qs62S1tSWVe48VvPlfri k6zPnF7xQ2QoxPmRR5ip5Ft35ot5RzcjOMsaViMIIB8QwXaSOqFZL1/em+wT/8HF4Y14 zrZ6MUvpQKaDxSByyTb0aM2H+QXpqoLq/DFmARu3Yls0iIjvTbepFB/7prdJJLT1RfoX rAFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iPYCi3jN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si15085680ill.144.2021.05.24.09.06.17; Mon, 24 May 2021 09:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iPYCi3jN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237811AbhEXQFl (ORCPT + 99 others); Mon, 24 May 2021 12:05:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235772AbhEXP7K (ORCPT ); Mon, 24 May 2021 11:59:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43A1561458; Mon, 24 May 2021 15:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871100; bh=eadT2zUv5c4+LfVwgG4BewoW5XfhCB48vrFx2JGtniw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iPYCi3jNlFz5QFivpIspq0pjPAZoNQCBNWDoodNWOsKQLe0oNwwgN2cfHnpB0Vo78 VZ9rOt8veEG/6fk034R3aGYEhzfjKeoJSxNm+Hvu6m609ZvqO2iOiRmC05pxLmZT2W zRBf2uLqyekGAvZk+fcTTkhPOzKUoSmXcLhED2z0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Chris Wilson , Matthew Auld , Jani Nikula Subject: [PATCH 5.12 074/127] drm/i915/gem: Pin the L-shape quirked object as unshrinkable Date: Mon, 24 May 2021 17:26:31 +0200 Message-Id: <20210524152337.361689558@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit 036867e93ebf4d7e70eba6a8c72db74ee3760bc3 upstream. When instantiating a tiled object on an L-shaped memory machine, we mark the object as unshrinkable to prevent the shrinker from trying to swap out the pages. We have to do this as we do not know the swizzling on the individual pages, and so the data will be scrambled across swap out/in. Not only do we need to move the object off the shrinker list, we need to mark the object with shrink_pin so that the counter is consistent across calls to madvise. v2: in the madvise ioctl we need to check if the object is currently shrinkable/purgeable, not if the object type supports shrinking Fixes: 0175969e489a ("drm/i915/gem: Use shrinkable status for unknown swizzle quirks") Reported-by: Ville Syrjälä Tested-by: Ville Syrjälä Signed-off-by: Chris Wilson Reviewed-by: Matthew Auld Signed-off-by: Matthew Auld Cc: # v5.12+ Link: https://patchwork.freedesktop.org/patch/msgid/20210517084640.18862-1-matthew.auld@intel.com (cherry picked from commit 8777d17b68dcfbfbd4d524f444adefae56f41225) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 ++ drivers/gpu/drm/i915/i915_gem.c | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c @@ -63,6 +63,8 @@ void __i915_gem_object_set_pages(struct i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) { GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj)); i915_gem_object_set_tiling_quirk(obj); + GEM_BUG_ON(!list_empty(&obj->mm.link)); + atomic_inc(&obj->mm.shrink_pin); shrinkable = false; } --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -972,12 +972,11 @@ i915_gem_madvise_ioctl(struct drm_device obj->mm.madv = args->madv; if (i915_gem_object_has_pages(obj)) { - struct list_head *list; + unsigned long flags; - if (i915_gem_object_is_shrinkable(obj)) { - unsigned long flags; - - spin_lock_irqsave(&i915->mm.obj_lock, flags); + spin_lock_irqsave(&i915->mm.obj_lock, flags); + if (!list_empty(&obj->mm.link)) { + struct list_head *list; if (obj->mm.madv != I915_MADV_WILLNEED) list = &i915->mm.purge_list; @@ -985,8 +984,8 @@ i915_gem_madvise_ioctl(struct drm_device list = &i915->mm.shrink_list; list_move_tail(&obj->mm.link, list); - spin_unlock_irqrestore(&i915->mm.obj_lock, flags); } + spin_unlock_irqrestore(&i915->mm.obj_lock, flags); } /* if the object is no longer attached, discard its backing storage */