Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1442967iob; Fri, 29 Apr 2022 05:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzifzZPsoCTmRhi/l1UOLb14WSaQbv0UjEFusJqj8vqbDOtV18ZBI/b1nhRFa1Rb3pa07+a X-Received: by 2002:a05:6a00:2186:b0:4f7:5544:1cc9 with SMTP id h6-20020a056a00218600b004f755441cc9mr39370088pfi.62.1651235588520; Fri, 29 Apr 2022 05:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651235588; cv=none; d=google.com; s=arc-20160816; b=LoQTMEVvNW5aVd1URQMwyGOmCRk0mP07NfynZ4SCPVOMW6VRGy2Yh1225GquKDzDsN FnC2H4vchNUa5YCmpJA0qIm1Cg1v9u1+hJnPjzuTHTgIEFHXp1A/uZfnY3xOrghYANuv atI61RY8TlClrFLyfMrlqXkZUBS+A5LHu4GKIOVh+snl6bMaU54m2cYanpXpoWGKpTHX krRQgMfMft02nOkKq8MLJ2ION7VdS6p1GRclL/vN7o9+EflsdkblakA2FapbEpxT0VQA AxCqsObWX6N2YqFg8CabOhz9DKbcc7T2UJtgHBHWceYAji0KP+JuaGtYEjBUVwvoLg27 KkZA== 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=id9wfTx1ompAak/eWF4EMprOk9VPeqAFVMi9lbwThDU=; b=yV13DW9rnCSC6vsWiLHhghRW24E75CS/rZuU5Fd2XJnsRi/4wz/Rucbzep1yyhBE+8 LwYECbrfDliuJaM2M+rqs/+Oq5hx6c3kPVH16BBG5iZbNewAhUP/Yc/Ri/921C9uV3+M jQJKzMrATHifQlmgw2x0nr13kz0hZCB8rFT7jBrthl5KwLN52pSSNzVox8HqfWeNXI8K IB7l/oiQfCgOn+/PCpUTlPpXMv1Pb4Z4+0hsdyi6oZDM/CFKPmE7FrRfceU+UVRaTbzF 0mB00d04YCZpLTv0DFK6zMFg7kfOP05zQYmx6t7UjYZGQxoqdoH31YRCoGhMjq8VUpvc 2efQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZC6Kdv02; 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 be3-20020a170902aa0300b00153b2d1663bsi7586758plb.579.2022.04.29.05.32.48; Fri, 29 Apr 2022 05:33:08 -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=ZC6Kdv02; 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 S1351660AbiD1UPg (ORCPT + 99 others); Thu, 28 Apr 2022 16:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350178AbiD1UPa (ORCPT ); Thu, 28 Apr 2022 16:15:30 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A77BAB83 for ; Thu, 28 Apr 2022 13:12:14 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 6CEF41F45C28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1651176733; bh=OFZJNy5wYWNqNEPg/dD6oQZwof/EPOJOolCUKpef6b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZC6Kdv02ijN89ohNJR9iZST0Aw3erEe2ug6OlSm26b1Jka+GF/mAhhmNuid7Wrrc8 K3/fS36inyr3nhAhLdUk71fCR7Uk3JFqR90mtVJy6+s+gC6g0zlHHEeOwIu8HNHlb6 vsB50VZaKT0vcyUmbMhJ7T753h1VcYWxmjpNtluFzgYNBI5n1YSP/q1o+vSFCJvbrt /7MdY550zJ8AldOKxT1SzeFJ/6rgjyOrFR6wLUQLKwQXooyvnDX7MdrKnrBWt87mj5 PqMevoxI0Jca5EmZImzlqRckTb+24DEKSr0/Xftw8a83f0xkMuZlHtZ6FEhKg8gMiD czd0fwVVhxqUg== 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: Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/6] drm/i915: sanitize mem_flags for stolen buffers Date: Thu, 28 Apr 2022 20:11:21 +0000 Message-Id: <20220428201125.412896-3-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220428201125.412896-1-bob.beckett@collabora.com> References: <20220428201125.412896-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_PASS,SPF_PASS, UNPARSEABLE_RELAY 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 358f8a1a30ce..48046cfd8c4b 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" @@ -122,8 +123,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; cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), bo->resource, bo->ttm); -- 2.25.1