Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp750742imw; Wed, 13 Jul 2022 07:21:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1NwyleX5ghcrr5Y3IZwBVop6JZuqKLcCwY/ewmkqcfkbPkZHteNkVK1+Gd2nw2Jb1wJWB X-Received: by 2002:a17:907:7f05:b0:72b:5a11:b357 with SMTP id qf5-20020a1709077f0500b0072b5a11b357mr3809618ejc.67.1657722102122; Wed, 13 Jul 2022 07:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657722102; cv=none; d=google.com; s=arc-20160816; b=yr9ctIVU2Fltiu17uQMdybNJr2mEhDkWfdpH+Mm78uzff9s7+qrbiOO6AbUJL63HmK YrznOa3ZqFQSrgR5beG6KeU+NG6yn+h9CMxu0YhgbZ4YqlvPwIZP9khkFflFQBtttwqu gSvlK2Ykv97F0iJl1xaUSNJnRhjoDdInbIun8aDCb7dkBjKU68g0J9vV0SnJlBESEMFw QJC52HjxPTQHka5nXLlbCz+wsrAo0ag5pKjXJY0RJOhxFcGSmOEBe8K2v4pmYxuSDEVF 4b3dkG+D/52gF3KodtGitH1tmi0PJEHIij5FNtNq7t2zlAzIky8UqdjAYvvXMuftv9p+ 2T9w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ldBebtrzwJuNGLq0j0aTDRvf2pWYqCBp/pukeXW3Nfg=; b=tqM5BZTvvf7cmM81ZlorkkUY0niqMxI0s2LMlpRYRKAfVlfaj1xy+U/YabPd0AyTsC Rv6ehNeFRxXMwu/bFspGhdXMZyC+O1OnFoCPBigFr9uaKEN2Niqh0de/TZK71sq+qUcS 08+rg+8gzA9QTdsX3zO6lPkXy8uf9Zbc1zfoiH9R4tatnDeJxoPjaTiULaHcaT2LVtVM KvxIrw8/8cnjOFSqsgUasLa7xif+4hucedOH84dBPqL4gBN1h5FAst0rQSnG83PSrfKW ArrKs1hUmTLB6ovxcYvuC80JiJU+vqhgxBKvMZvmDKqJDQM3QEXoJhlXT49BqscDtUn8 /ehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="gcVqzi/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs14-20020a1709072d0e00b0072b4d8bc1c6si2361151ejc.367.2022.07.13.07.21.16; Wed, 13 Jul 2022 07:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="gcVqzi/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236287AbiGMNvG (ORCPT + 99 others); Wed, 13 Jul 2022 09:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236243AbiGMNup (ORCPT ); Wed, 13 Jul 2022 09:50:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 454AB20194 for ; Wed, 13 Jul 2022 06:50:44 -0700 (PDT) Received: from hermes-devbox.fritz.box (82-71-8-225.dsl.in-addr.zen.co.uk [82.71.8.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id C21006601A3C; Wed, 13 Jul 2022 14:50:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657720243; bh=lN7/72IELAABa/q8YAxfVX3RpiJXEatJtrVtob+QH7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gcVqzi/HJAAI7hVp3JnLWU8GWvaQsk58Vwongwd5KUqf4pSAAhFM2aHPxw29a+1EO /hVp29d7FCLgTlytfunfYIwBEKMYeVz3NZVz/5sECf86iY7wRgDBAlH4A3asmTQr/z BOehwDs7oUmpRnXDsfCDQRSFGhcWA7/iMWlOYx73+VFdzu+IGlDe0J2YIZV5LCynXY vcEx7XuudwIQnFJ75EVeQZib4PCfY4bCc1Rc4Dhd64DKocgYX0uZ1BGbkTiPJcRyd9 7a+fysPR2l4eFV4xgJ0+p8tMfUU0NGx83DTguZHLiHee/2pwxywQkuxhEWa3EX0bBG 5aSwhhxwYMfZA== From: Robert Beckett To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: kernel@collabora.com, Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v11 05/10] drm/i915: sanitize mem_flags for stolen buffers Date: Wed, 13 Jul 2022 14:50:17 +0100 Message-Id: <20220713135022.3710682-6-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713135022.3710682-1-bob.beckett@collabora.com> References: <20220713135022.3710682-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stolen regions are not page backed or considered iomem. Prevent flags indicating such. This correctly prevents stolen buffers from attempting to directly map them. See i915_gem_object_has_struct_page() and i915_gem_object_has_iomem() usage for where it would break otherwise. Signed-off-by: Robert Beckett Reviewed-by: Thomas Hellström --- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c index 2cc2c08bd50f..18d574ac167f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -14,6 +14,7 @@ #include "gem/i915_gem_region.h" #include "gem/i915_gem_ttm.h" #include "gem/i915_gem_ttm_move.h" +#include "gem/i915_gem_stolen.h" #include "gt/intel_engine_pm.h" #include "gt/intel_gt.h" @@ -130,8 +131,9 @@ void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj) obj->mem_flags &= ~(I915_BO_FLAG_STRUCT_PAGE | I915_BO_FLAG_IOMEM); - obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM : - I915_BO_FLAG_STRUCT_PAGE; + if (!i915_gem_object_is_stolen(obj)) + obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM : + I915_BO_FLAG_STRUCT_PAGE; if (!obj->ttm.cache_level_override) { cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), -- 2.25.1