Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp328368iob; Tue, 3 May 2022 18:56:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyozK25FFJI43UdSEpMleYW7Y5VZARiW5zx5ThaDcT+ZQize5hJNYGLJdS4kkQZa9/po/7S X-Received: by 2002:a63:1b5e:0:b0:3aa:593c:9392 with SMTP id b30-20020a631b5e000000b003aa593c9392mr16030118pgm.470.1651629419138; Tue, 03 May 2022 18:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651629419; cv=none; d=google.com; s=arc-20160816; b=kUUtRSdy9RP3776zvN0Ww7cG8ESbgbb0QTFUhMsxWnTX2GRs8SuzgC2JGca6i2Dsx9 /nwM8z91+zh/9C2j/IWRC8zNDbgfnDAPZB/tQR7dLtWzkMSeFqEtkCSSWEmplrLFXgB0 50wLtfXvIjtgXVOKXrSBa1j5plH8hZNJK3nS8CeZDdhDS8e2UCvysBgzBsffqbb/RZVV UsKmRmXaDhUq9DkRRveIrdgMxKMNhdPQn2GWVYxcaNFLlS50TfqXXyEHQWdEljh/hXDJ fPDR3m64N1aaV0jA2CQEL3C/7eEm9B9g5aUR5XAW8blAsIAystXwyUtSFnIGIwnElk2u PL1A== 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=Oq3l0GA8gdgEHYqTEvbA6jYeMenY2FBqWlLjBh2bdB8=; b=wm6xEYMjL5aMq+441nOgwCwENDeeAIKVfOAO72+l0WTdTDyYSpkh6rSugsQ94GluVF mVjdJjaZ9dNy0iZg0arnRIK1rkj7iVOaEj1nWHvSs1aMyaihEsa5bSHmrYCO42dBeW0e LJIncMea0+sSRaLBSFg/xfTZKv/Taik2IFTxgsr7zvZWncIva/DxooxOeXbkS150+YOy Vz5OIOQMvK9GA07+HhItSUbRXvcB9/OOJFmW1whvybsupXYSI2kcHcNph3WtZFXvKSD7 /j9XHGF9wlPs/Kmoq3tZVJsyjUFAkTJhN6223yEXo1Wgj7rxedV2ZrYzkk56Rz8HHwuw K2Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Oz/lvbPy"; 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 q4-20020a63ae04000000b0039e44e45e87si19292755pgf.485.2022.05.03.18.56.43; Tue, 03 May 2022 18:56:59 -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="Oz/lvbPy"; 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 S241810AbiECTRR (ORCPT + 99 others); Tue, 3 May 2022 15:17:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241804AbiECTRQ (ORCPT ); Tue, 3 May 2022 15:17:16 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DBD93F8BD for ; Tue, 3 May 2022 12:13:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 017E91F44695 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1651605221; bh=lkfS0h4hQ00/zwX5uLOHlh8Z1oRKz8TLsq9x9k0d9gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oz/lvbPyoYAHzU1dTR3NmI7mFVTOrjt7ialeDRbeSVstFthOqm3cnO+f58FPFg87Z 5TWkaBJmc0ME/UovuMjhwDTcKGcQYdY/kIDtW+aKyitNMXWYCW42KnKJknvwvhdUeq 2D4PKVNy7O2M9tY+Xp+7aI1OK3jv/iNAb+KH1UoQgcxlW479Qxm5Z50lRh/gbqoApx DAugKoatCQ9QGgDGCcQOJ5p86c54DDDLQhZVLMPbeujU2994eMcx5nj11RKblVF9mE D0NnPuEcQLcTjP5YvA6ZH3ccm/MP8hYq/DeSNNk7fHQ86FHJrUnZ09GBoEEplT2bMl WslBhgU9Q3rXg== 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 1/4] drm/i915: add gen6 ppgtt dummy creation function Date: Tue, 3 May 2022 19:13:13 +0000 Message-Id: <20220503191316.1145124-2-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220503191316.1145124-1-bob.beckett@collabora.com> References: <20220503191316.1145124-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 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 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