Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp43904pxb; Tue, 12 Apr 2022 16:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywNvfSuLfISBtZLOVeY+KdXVxqcSiE9RpMtOPtn2zNE+CVFmJ+U5TCxjx9SsEf520Lv47S X-Received: by 2002:a17:902:e804:b0:158:8117:7e3e with SMTP id u4-20020a170902e80400b0015881177e3emr7393981plg.102.1649805458998; Tue, 12 Apr 2022 16:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649805458; cv=none; d=google.com; s=arc-20160816; b=LZcPrAE1rT8uc7+NrKLZsIH3Et4yC9W6q/GNAv5DShBLCxuMhQO4apJzQb95WNz83C dFVo4Q8IGFTuIX1pdonLaZS05M9exIaJ+2eKLtB1lMgaBQKYOgt/KpbpXiexPmyBougJ j60f0RIAkgm9J2QDtr8MZLuATGbdrPIXkZXizHCp1r1GZqPO8yANDUZmE7sOOxZL9RLx 7FG7N1g+jpQdLEl5QEb3hGECQt26qm4+Jpk6jw/BUr13qj6QNckA6VjcNWxHmRNXqVl0 6LQr7MFn1qwqcLDum/UDB32nFH6IGuUOf02CpqlkMdTl3vl9muc/zeaOG64W0/dhhagn yhSQ== 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=9IWw6caPmh/cj4EUJKCnBGFKB+XL3WhMIaj/HxoDjsw=; b=Wfecd9Jz0sK8hAg8c/n1kx+0hnh6DzJE+cS+zYQ24dHXasBAVO0SoTRu7GeoLYLHld HJVSZfWuZvlT1lNr1d1Zx9rR84355lHjwdUFL/fOHYHq+roICf84QylUCjmi3kM1XZaw xREJJEwnp6ERR8YXvEScVs8eO6T+7f27w0TAolf0S+Cn0XJdnEzr8W8m3shkl/zeE+ij e7ZBkkS60Z3ZH5cerrbJsQtrfGcKfhkkOd60scW5L4fVqdZiO1Rlx80apDWjMbC2++Rd vEgmb2PCHiMuEszmzfKlTmiVm2R8QWp/jW+BZezt+y8RdlnmRuX+B/gUba7UrqLmUm8g WD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Yr+pCLy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a1-20020a170902ecc100b00153b2d1640fsi3335374plh.23.2022.04.12.16.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:17:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Yr+pCLy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 20B4A21D7CF; Tue, 12 Apr 2022 15:02:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347435AbiDLTli (ORCPT + 99 others); Tue, 12 Apr 2022 15:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236301AbiDLTk4 (ORCPT ); Tue, 12 Apr 2022 15:40:56 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B6B326E8 for ; Tue, 12 Apr 2022 12:38:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id B92191F41ACF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649792316; bh=yZDfYMtfaZRY0QUffB9LSGM0LIHt1Kf7UYxXwd7bE5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yr+pCLy+5JXAKT4xb1FbezpkiIbHo8z+VIVmtkIgRy83R9s3Susb+FJX76BVllYd7 /IpfTeaBPuFf8ar/ay6aIaWYmk5jd+ZUKcIvjpk9UILtw6Jml68wnwi5Uok7bE4cU5 AnyGQ3uL4jkd/dF37lNM/bmD7aWLth9nf75JIPvwbynZUdxkmZXn8TUKpcbdmT778x 01HggYIAdHAb4rBzyf/QK6Po4racbalBrpAL8mGP/tdGk31173Qpls7UKQe0cxNfQ9 CoKvZJb4NBte77EoqWlu+ihZtB1gnD/s83RGm1G9t/KBcR3XLbHLK8zb23Hirr8b/4 BjWxcVRBV0IQQ== 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 v3 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers Date: Tue, 12 Apr 2022 19:38:15 +0000 Message-Id: <20220412193817.2098308-5-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412193817.2098308-1-bob.beckett@collabora.com> References: <20220412193817.2098308-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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/kernel buffers should not be mmapable by userland. do not provide callbacks to facilitate this for these buffers. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index a878910a563c..b20f81836c54 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1092,8 +1092,8 @@ static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj) ttm_bo_unmap_virtual(i915_gem_to_ttm(obj)); } -static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { - .name = "i915_gem_object_ttm", +static const struct drm_i915_gem_object_ops i915_gem_ttm_user_obj_ops = { + .name = "i915_gem_object_ttm_user", .flags = I915_GEM_OBJECT_IS_SHRINKABLE | I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST, @@ -1111,6 +1111,21 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { .mmap_ops = &vm_ops_ttm, }; +static const struct drm_i915_gem_object_ops i915_gem_ttm_kern_obj_ops = { + .name = "i915_gem_object_ttm_kern", + .flags = I915_GEM_OBJECT_IS_SHRINKABLE | + I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST, + + .get_pages = i915_ttm_get_pages, + .put_pages = i915_ttm_put_pages, + .truncate = i915_ttm_truncate, + .shrink = i915_ttm_shrink, + + .adjust_lru = i915_ttm_adjust_lru, + .delayed_free = i915_ttm_delayed_free, + .migrate = i915_ttm_migrate, +}; + void i915_ttm_bo_destroy(struct ttm_buffer_object *bo) { struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo); @@ -1165,10 +1180,19 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, .no_wait_gpu = false, }; enum ttm_bo_type bo_type; + const struct drm_i915_gem_object_ops *ops; int ret; drm_gem_private_object_init(&i915->drm, &obj->base, size); - i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class, flags); + + if (flags & I915_BO_ALLOC_USER && intel_region_to_ttm_type(mem) != I915_PL_STOLEN) { + bo_type = ttm_bo_type_device; + ops = &i915_gem_ttm_user_obj_ops; + } else { + bo_type = ttm_bo_type_kernel; + ops = &i915_gem_ttm_kern_obj_ops; + } + i915_gem_object_init(obj, ops, &lock_class, flags); obj->bo_offset = offset; @@ -1178,8 +1202,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL | __GFP_NOWARN); mutex_init(&obj->ttm.get_io_page.lock); - bo_type = (obj->flags & I915_BO_ALLOC_USER) ? ttm_bo_type_device : - ttm_bo_type_kernel; obj->base.vma_node.driver_private = i915_gem_to_ttm(obj); -- 2.25.1