Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1851777iob; Fri, 29 Apr 2022 14:32:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDPCbuC+iamNOKBzmcV/zMmLVxR3sO2uqxNPya1Sv/QSaXZHtI+uJ3BN3tcXMmF2gG5dai X-Received: by 2002:a63:6a82:0:b0:3bc:321e:6d54 with SMTP id f124-20020a636a82000000b003bc321e6d54mr1001237pgc.232.1651267945628; Fri, 29 Apr 2022 14:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651267945; cv=none; d=google.com; s=arc-20160816; b=zxzapf1MEbcMKW99JyEXXTQVOmrnv1ZteFUESAzZinIJwty8N+uZTwqltDsXJhHKmC 5dN0mMTGOPVnK4/3LPHCC0fZEq1Qze+UTz+UqYiS7W2fnpBK2SLPPzCH3+qmW90AwkXc Ou/YiBwPyFJFGrfHl6LyvApEdGVL+G4KJimBHXFlHfPNnis4Wi7uzcHitTiluXkv59lj BMQhri2vXIhIir1+138kD4GH7qXO16sjS3UTL5aGfQZJ6UEFSqMcLj9dXF31AVIYYF00 mrh3J3ok3UYoeql5cwLgXtnX9UMTyeAs1qsRSUfm57eRTOE45UXCSKKLiurt85YMrsWL feVg== 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=ZUwquiYoLfA7cHiCdfGIwkKpfTXBtlGcSgr5wlwKc90=; b=uAA80JVykhdUdzZqhT+Ne2Hbmd66VimNFcZMN3hxs0fhH3LBkJcOXnvOns8frSwITm WjO7XfbrBSXS729BN3Kdtr4OFoSs8RcFe+zax8Vtra56iIggGmt45Yrd/vEdhOE+CpDL wma6zVQry9VRRXybxtdVfPLXOU462wXYe+gmvpTtOUKz7bXyDoWbo9COUXhf98q7i/IQ Dt3Rp1q524FeUFTAxZ+rYnE7tNidgIYQG1JF5wEWzAqnoyr+5c89Un87vqwjXz5KxZBv co7mXFp8ZgK70Mq5C6virvT3ZzRrQzq9ZECUx7ZAyqWm/hoKzlelsNgRTSPKgULAyTUV VeGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="W8Ls/Zfp"; 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 l8-20020a17090aaa8800b001d9928adeb5si7062364pjq.123.2022.04.29.14.32.09; Fri, 29 Apr 2022 14:32:25 -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="W8Ls/Zfp"; 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 S1351697AbiD1UPx (ORCPT + 99 others); Thu, 28 Apr 2022 16:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351706AbiD1UPq (ORCPT ); Thu, 28 Apr 2022 16:15:46 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4FBC0D03 for ; Thu, 28 Apr 2022 13:12:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 8B7361F45C28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1651176746; bh=88vk3HBnk+zJGQiRrc2VM0uGkuQfuKnKQwLqW2y7Svo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8Ls/ZfpAIskhyH03AfdpvdQlHpLXrw7pwlsvFOaMQ1jwLPdX6QxNmO3iUk1HxqxZ cUsLsFz5sx0zC9BfKUT/nxyhknFJsS0jhB+ohqDS5zSbmIPKOhNGyhg6klkqbxoyBh AHwfo4cTBz5DikEbZn/KtN/QpqjkESkJy2tyPQ10qTEIViAbTBtPr4GGV3yhUjUASU VG58D3eV0zQKgusWjC4XngA9IE3DMyvLu2naJPJZEL/BGhQ0AaYzlJDlj9cjsE+v25 zBqTqqW59Vwob/voAU9XGcrCLlqop6sa9+wO4JQILYKYGut2RBcpTyvWEdwath9qA6 +nND7ZtWxFyJw== 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 4/6] drm/i915: ttm backend dont provide mmap_offset for kernel buffers Date: Thu, 28 Apr 2022 20:11:23 +0000 Message-Id: <20220428201125.412896-5-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-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/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 4c25d9b2f138..d22a1af214ce 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1120,8 +1120,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, @@ -1139,6 +1139,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); @@ -1193,10 +1208,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; @@ -1206,8 +1230,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