Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp9081iof; Wed, 8 Jun 2022 13:58:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzGI8oob+4bqEolWxim+6fNjwz92XuzWA5pdK11rmnihoJRCulXeijTH3rsZEQMkH6TvMH X-Received: by 2002:a05:6402:27cc:b0:42d:de37:7e42 with SMTP id c12-20020a05640227cc00b0042dde377e42mr41469213ede.200.1654721893083; Wed, 08 Jun 2022 13:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654721893; cv=none; d=google.com; s=arc-20160816; b=jq8cQf8pPDSc9b2cVeohoY3off2BbgWOHhNWY+U0Q0ofLVSbgLlwNIrqfKnfa30Mua i/lCGOTMbeaZRrF9dWhtY2iSq+GTGkYnOkNdcbHmhUl+QuVDm1UPTM5ovrItZk9EcW50 wFnAaKDFnwksf5weoqVQxcaKUCAl4jbJOtHq4Xj7Eb5OqSDSr27dewWa4ypeymAZuIk+ J7zNqBN81cSteGAr3N30Wj7iEi0YpRrrx6VykYGRmjhe7DYdq8qL20xKc1GcyGULY909 kjE5zNq72+ZDD323LrM1Io9GX4ST0oDjGQou0gxJrHaAHTdL2zh3RKZ8q95hLZ3Rcjcr 46yw== 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=7YID1z0WS347nwkr3Kf0yCuok3u7JR7iLGvLtph48Io=; b=jqlYm80FtnU6snY1BR1g7h4J4w7JuP1nFGm8kCVGVMLZBfQFxZ+y/JXDA1erMPvpL8 UH8RiZ2dvARmrNdBvMsR/s6LsZV8ybBtH38du0WEWupQxNaa8Bh412WLPyY2bAihxYhr 3vB7Q/APUAP1VRBp5lc0yHyO60DVroiIeGQiTt4yN/eW55XC1FwfXF8B2F+tzaCmx5lm 5j8deT4fwAScuwPXdbfnnbp4EOOAKfmmbZEHXXMYx8OqcUPvzlLRE/cACF5yVnFYwF1F 6Hoj8frI73MSFcc6Bpy8FS5ZFIEKLr2JRbzf99D436mNohdYR+1K/ElVaBhRdEbHHfki AAQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RgiklC2r; 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 qk11-20020a1709077f8b00b006fef8601452si7423992ejc.818.2022.06.08.13.57.46; Wed, 08 Jun 2022 13:58:13 -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=RgiklC2r; 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 S233891AbiFHUw7 (ORCPT + 99 others); Wed, 8 Jun 2022 16:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231326AbiFHUwz (ORCPT ); Wed, 8 Jun 2022 16:52:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 354C51C9278 for ; Wed, 8 Jun 2022 13:52:54 -0700 (PDT) Received: from hermes-devbox.fritz.box (82-71-8-225.dsl.in-addr.zen.co.uk [82.71.8.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id A6A9D6601753; Wed, 8 Jun 2022 21:52:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654721572; bh=5MPDE6PLauo4xeTXuzQqjxRuaatIiJJgaRF7Azzw0o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgiklC2rhICBDdiymtf1iLzRIQVPyTdJkgxZYmqfMU7E6hz1sPyzO5TQT8YntXzNG +2PB79U3lWL1ynzxW+Y7HvFkuEPJTZ07Jrr6pkfJCrFnPNsFF+m8CLHfr4mAkoZ2Ax xxWHVkOuRgp70oVU1qfhOFRZueOgUC+gofnLYE5dMvhkBh5bbdV4xWvBPvpltmWu6B eem+hjMpegwMAL6+cmdtWAJZUPzBQKYgDr02zqbRSsW7wbzD59dhUkj8UC1saaa1tE Pv5QLPxJuuk6ofmI4yOx+EsFb4auYG7M6Iy21gkGO9YZs9aZMRAeLc7AT8RhKt8IC9 0j5Vyq8eBTpFA== 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: kernel@collabora.com, Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] drm/i915: add gen6 ppgtt dummy creation function Date: Wed, 8 Jun 2022 20:51:25 +0000 Message-Id: <20220608205132.438596-3-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220608205132.438596-1-bob.beckett@collabora.com> References: <20220608205132.438596-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_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Internal gem objects will soon just be volatile system memory region objects. To enable this, create a separate dummy object creation function for gen6 ppgtt. The object only exists as a fake object pointing to ggtt and gains no benefit in going via the internal backend. Instead, create a dummy gem object and avoid having to maintain a custom ops api in the internal backend, which makes later refactoring easier. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 43 ++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/gen6_ppgtt.c b/drivers/gpu/drm/i915/gt/gen6_ppgtt.c index 1bb766c79dcb..f3b660cfeb7f 100644 --- a/drivers/gpu/drm/i915/gt/gen6_ppgtt.c +++ b/drivers/gpu/drm/i915/gt/gen6_ppgtt.c @@ -372,6 +372,45 @@ static const struct drm_i915_gem_object_ops pd_dummy_obj_ops = { .put_pages = pd_dummy_obj_put_pages, }; +static struct drm_i915_gem_object * +i915_gem_object_create_dummy(struct drm_i915_private *i915, phys_addr_t size) +{ + static struct lock_class_key lock_class; + struct drm_i915_gem_object *obj; + unsigned int cache_level; + + GEM_BUG_ON(!size); + GEM_BUG_ON(!IS_ALIGNED(size, PAGE_SIZE)); + + if (overflows_type(size, obj->base.size)) + return ERR_PTR(-E2BIG); + + obj = i915_gem_object_alloc(); + if (!obj) + return ERR_PTR(-ENOMEM); + + drm_gem_private_object_init(&i915->drm, &obj->base, size); + i915_gem_object_init(obj, &pd_dummy_obj_ops, &lock_class, 0); + obj->mem_flags |= I915_BO_FLAG_STRUCT_PAGE; + + /* + * Mark the object as volatile, such that the pages are marked as + * dontneed whilst they are still pinned. As soon as they are unpinned + * they are allowed to be reaped by the shrinker, and the caller is + * expected to repopulate - the contents of this object are only valid + * whilst active and pinned. + */ + i915_gem_object_set_volatile(obj); + + obj->read_domains = I915_GEM_DOMAIN_CPU; + obj->write_domain = I915_GEM_DOMAIN_CPU; + + cache_level = HAS_LLC(i915) ? I915_CACHE_LLC : I915_CACHE_NONE; + i915_gem_object_set_cache_coherency(obj, cache_level); + + return obj; +} + static struct i915_page_directory * gen6_alloc_top_pd(struct gen6_ppgtt *ppgtt) { @@ -383,9 +422,7 @@ gen6_alloc_top_pd(struct gen6_ppgtt *ppgtt) if (unlikely(!pd)) return ERR_PTR(-ENOMEM); - pd->pt.base = __i915_gem_object_create_internal(ppgtt->base.vm.gt->i915, - &pd_dummy_obj_ops, - I915_PDES * SZ_4K); + pd->pt.base = i915_gem_object_create_dummy(ppgtt->base.vm.gt->i915, I915_PDES * SZ_4K); if (IS_ERR(pd->pt.base)) { err = PTR_ERR(pd->pt.base); pd->pt.base = NULL; -- 2.25.1