Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp41941lfv; Tue, 12 Apr 2022 16:28:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXwAGxW+cd/80gGtP3g4n2vvl1u6ZHddetvF38OX5JEsukk5JRHSN7cpVU304xs8PfE8bi X-Received: by 2002:a17:902:cf05:b0:156:9d:ca01 with SMTP id i5-20020a170902cf0500b00156009dca01mr39538886plg.111.1649806132568; Tue, 12 Apr 2022 16:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649806132; cv=none; d=google.com; s=arc-20160816; b=XHEiUlIMrIR38y5nG7kBWhhUyabE+Lb1H7SS2iExjJ6EX7+zSfC65ZzjUNJZfKgYNF VV58TFZs1PUuLaEVZ5cF+DMm6VIMRlzlQWW2Pm09Ba37BSHyTpsEo2VZBw25/QAxFJf0 HcJ/MKVVIMvRsre0VhZWIgxdAzzxxNdAGHU8yirzbACGsRy0cQMkEwac0rbVIFg4nU1Z VSbw4eLgrFsnlu/q4sq0PZiGWNHCgzaPaHktdvKWl5W6Ji9yLLYOAx3wZnDC/xNKHPYU pbxlP14YpRlu1zj/9RBEWrkLFNuu5RGjv48YL0sO0DNDGXPC/LOfYe9SGs+JIsQEZGs4 iuJw== 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=XIV0w1FJLoEi+fM7UGGcLAvztcNNw8u8S30jOIW5Lx9PbkqZJFmQwAoR0E7AccrqCe PhvMp+DFgPdEz5esIZYtzA+xQOjJUumyEb9CDsYz9MwoADSoQLVt8giuSw5V764a+6dT vb6NfwjZxuNykIw1BOKEr3ZcHr3iV8eD3NOm9Uey9Ypiv8Ta9KW9WCEL/G5DV7qVzdMr PLYMvh1L5STiOM1JQe+zn6IIHtT69S5ufTDHcFIbDILeBr+2/6jAMJkXGnZ2lNTH0ujq SKNTgHQU4VtikxGVv3YWeIDApTQ+MR1Clrk7Nbq5TQaCiuzB3B0XFgkl2464gaBYq83E 8JNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JN5Ron1n; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id i12-20020a17090332cc00b001569a746663si14895761plr.511.2022.04.12.16.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:28:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JN5Ron1n; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3257DE9C; Tue, 12 Apr 2022 14:21:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356962AbiDLPV3 (ORCPT + 99 others); Tue, 12 Apr 2022 11:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356914AbiDLPVU (ORCPT ); Tue, 12 Apr 2022 11:21:20 -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 13BAA1A2 for ; Tue, 12 Apr 2022 08:19:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id AA09F1F4496E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649776740; bh=yZDfYMtfaZRY0QUffB9LSGM0LIHt1Kf7UYxXwd7bE5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JN5Ron1nZTWRkENle/xnzDNFAkQumqDrhbZzC+JStRCdk1Dns6W2A/A+yMyNsG7qa g3mQvydkfD0VB40uMulAq17Po6IYbD+HKlwoxvM5z2IZACg8gjjp4fNWRcJw/CxUln hM3HPcm8/NCmAQouX2hSLVNdxXLboIKCvRqnGnm4UNNVo0vuzQ+DPZ7w7lSatir8PP WzSt7yDtVvUx49vvJZsuWDnzBNlbS6D5Yw+ONrxfbi+RyST0pMze58md0gcE19X26f WUooBM0CFGj8os9MZq59dY2GxWx9tPvgZ7KVGUZq0qNBamTteuKQKKraTVApC08onJ NSOwlXETuoxhA== 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 v2 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers Date: Tue, 12 Apr 2022 15:18:37 +0000 Message-Id: <20220412151838.1298956-5-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412151838.1298956-1-bob.beckett@collabora.com> References: <20220412151838.1298956-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