Received: by 2002:a05:6a10:3150:0:0:0:0 with SMTP id m16csp2775427pxc; Tue, 12 Apr 2022 06:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6zGekSjMjrGGGA9nrTg36UDJ6RPrcE6eZ2XdIZ3jC2/0GybqsFJQPqXNP7U8rbBeiktUI X-Received: by 2002:a05:6638:1301:b0:323:3b47:8b3f with SMTP id r1-20020a056638130100b003233b478b3fmr17975157jad.291.1649768686911; Tue, 12 Apr 2022 06:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649768686; cv=none; d=google.com; s=arc-20160816; b=zXFzhujeqKOKTP3CDoJBBmp7TpxVa+8ZL5oYrBRI3C7ik/vxCFHfztoybi3dcKSmBn fjTkLKgyKsbn8fFX1opYtCmXsypcKRPLH6mbtwTQnu73UbvRi1Iw8R0lTcJ8qX2Y2e4b HNGppjpBMNtsj7og3g46fjjf0bJ9btlwHrT8OQui+doekkBRz+RvX1BmYo4yny/DNIgq ZtEMgmFstALCCKhfnzJR5bPGenlNxCQznQ3kMTeEbwfdAGn+8sBseK12ROCNuDce9k+u b4acGfE4/4GZkWnBF3DxuOEQw2+CAltWMZoDiOkSC93NssYa49dEEv3PEpAa53QtL70U raCg== 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=mPhZxwEBNfQGjAwYkdwOx2pGUSI46hfGHViy9Umb11zClq+juuuhaQS/F/+mnUcUJJ lzY8dR0eJFavKotTp3NQ6kSsICFclmaNe6R6L1OKkW0C4LEL195IHo9yeDulZc/0MdCn /IlCxz9bjEqfbAAQqd0SBYLyoj1nHAXKhOjj5PQUpJeHMBVcUVAk033quZLvcUAJwyja /1STds21Ha6YycGkEDj57VpS32KLOlmVFJyBGswFu2ixUfqDQk9IH+id4lXyJ6S9FnkY Av/wsby3Q1yTPItK6ovPvBBoIR+J6T+YqUVpifNIAWMZqj1Jt/HFlXgcBZOBSwTV4Z4K nROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bsgfAQMu; 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 y1-20020a056e021be100b002c8063b4eb4si3322363ilv.112.2022.04.12.06.04.34; Tue, 12 Apr 2022 06:04:46 -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=bsgfAQMu; 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 S1349641AbiDKT2X (ORCPT + 99 others); Mon, 11 Apr 2022 15:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349616AbiDKT10 (ORCPT ); Mon, 11 Apr 2022 15:27:26 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980DF1400F for ; Mon, 11 Apr 2022 12:25:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 338461F43CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649705110; bh=yZDfYMtfaZRY0QUffB9LSGM0LIHt1Kf7UYxXwd7bE5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsgfAQMuBcUec5kIPrh3W8eFfG7NSq8Fjs+q+NnVAFvt8MOz1VzIMCLkqUXY8mNrg SbUOHsAvASeX8Q/sGdT7i9iveZm7Wmo+tB1dBIbACZyLFYsBZo5pKFGAVRNm5AaB7/ +Q2LNbGb9X2GOBtd3tD/zvEz0aZFwVHXCsGro8L6TYwqDT/p6y6bAd0mu97Iejzlbx QynHcTj+Uy85sDvDz9/at8SDsvNTl46DoqhpFx1M/BQ2ODbux5/ey3xOqudph8NJO1 ILllXNz2bEjfFMIFDQk4mO9kPZFqjK28ml38pcnkSPHBCnuzsqifo/t1LyfiCUz6tT 05FjkOnda2klQ== 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 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers Date: Mon, 11 Apr 2022 19:24:52 +0000 Message-Id: <20220411192453.1000147-5-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411192453.1000147-1-bob.beckett@collabora.com> References: <20220411192453.1000147-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, T_SCC_BODY_TEXT_LINE,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 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