Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp17307lfv; Tue, 12 Apr 2022 15:25:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOHViBtqnddDznfsOOh5iyfrYBKT/zgQEHFWvMMFLojMnMBCOuLNHkmyZT9RoiyZF8W5VK X-Received: by 2002:a17:902:f792:b0:153:1566:18 with SMTP id q18-20020a170902f79200b0015315660018mr39440804pln.115.1649802327314; Tue, 12 Apr 2022 15:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649802327; cv=none; d=google.com; s=arc-20160816; b=SJd8U6AmXwP1VkwKLqWsn4qIYeQsN/Cyk5D5hghEyOj+PcrC3O2EYsRv5T19jIwrLy qeZCu2tB2DtwJmYdW6K/b/fXWE1v8fn3kMqrsxs170LhPtkTUXyC+9SaaA8JuAcNOAEx UGW11rK0aFzu7B1kggjpBluG2IUUQ4+GIw3dtC1OxKfZqdUvBNSGeL2qUWQMvoNp0VhJ 6p86skxSaFWh8HyHH1E1gsIxTzfDyVap/SYsbRQsMWxiQcMMzwFHxOIZPVHP4kqcoZIl 4VB0SRGjcxGK3SqL1hk6bxI83FrFXG1ZvY1M9DZREJRsOIVzJb6G46XlnegZHLPAcOll hxjQ== 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=4VEd/nVJEksNZekSF5wXozllLq+eo1fL/wBn0ZKKt8c=; b=T6AKliaq9TflieorMoUCX1rVZHOBfHCOq7HchluIQ532qtOmkaaGpnmkaINTQ3XMCa qAKKaV18vC3V99x/CKV525b0Jb/GVO4IR4jjJ4WAhezYK0ZOjUiDY07mZ9W3zQBkOFDI qUielL+tDz3mdT+SDraLafbRYmh2SV8ZKpmpB4JCWMOzRLkQUPQdnH1+O25r1tqi1Eqx hPZfbfRRr3wLiFvbo7jF3knss2Uq+H7nDUXGGAGcrkIeLZ9bobN2FIPUyPQhjeKP048z f5MEpiXc9WQK8GfJlNLus7iKoNz/iJCgh8sF8Z15GfDBVxZxjlYeqlsxL8Mk1yg6mhyf xXhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=m+Am9dZG; 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 o4-20020a639204000000b0039d82c5e0b8si3765742pgd.340.2022.04.12.15.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:25:27 -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=m+Am9dZG; 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 93ED4157594; Tue, 12 Apr 2022 14:04:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352607AbiDLTlG (ORCPT + 99 others); Tue, 12 Apr 2022 15:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbiDLTkz (ORCPT ); Tue, 12 Apr 2022 15:40:55 -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 C7D642DD69 for ; Tue, 12 Apr 2022 12:38:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id EC6E41F41973 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649792314; bh=4lkEaK+tGV/Iygaw6i15VKgZAMgQnTCuG7b9sgm7nuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+Am9dZG4XgNP3N+yjGUDpy1sPUlq4hmba3raPmrunOiSOfISqD9MeOKpnLo9bIYB vmJWdKg+Up1X5WnJcCkmQmQW59gTDRLnIP45UsKFd6Pf9UkXpB8s8Kqz1RILtOIurf xfQHASiLHZA9sO2mtWh7TnxgUqJpUsnVUTHY2b+hosSoABvhj7+Z1/fkg6MuCzBEQH c8E58zta+qSZ8k204p+wtvgv/ekTYYwreCvbK8eeKUBCyTZTDzqKfMR4QZ43msavLb i0o0B0u47z1MXvD0pn5v4wUOyUgN9YFmmn5UMJqStFGS3CG3nDOlckB2W6u+qldtoD fkWwZFjkA8Nyw== 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 v3 1/5] drm/i915: instantiate ttm ranger manager for stolen memory Date: Tue, 12 Apr 2022 19:38:12 +0000 Message-Id: <20220412193817.2098308-2-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412193817.2098308-1-bob.beckett@collabora.com> References: <20220412193817.2098308-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 prepare for ttm based stolen region by using ttm range manager as the resource manager for stolen region. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 6 ++-- drivers/gpu/drm/i915/intel_region_ttm.c | 31 +++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c index a10716f4e717..358f8a1a30ce 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -58,11 +58,13 @@ i915_ttm_region(struct ttm_device *bdev, int ttm_mem_type) struct drm_i915_private *i915 = container_of(bdev, typeof(*i915), bdev); /* There's some room for optimization here... */ - GEM_BUG_ON(ttm_mem_type != I915_PL_SYSTEM && - ttm_mem_type < I915_PL_LMEM0); + GEM_BUG_ON(ttm_mem_type == I915_PL_GGTT); + if (ttm_mem_type == I915_PL_SYSTEM) return intel_memory_region_lookup(i915, INTEL_MEMORY_SYSTEM, 0); + if (ttm_mem_type == I915_PL_STOLEN) + return i915->mm.stolen_region; return intel_memory_region_lookup(i915, INTEL_MEMORY_LOCAL, ttm_mem_type - I915_PL_LMEM0); diff --git a/drivers/gpu/drm/i915/intel_region_ttm.c b/drivers/gpu/drm/i915/intel_region_ttm.c index 62ff77445b01..7d49ea72e33f 100644 --- a/drivers/gpu/drm/i915/intel_region_ttm.c +++ b/drivers/gpu/drm/i915/intel_region_ttm.c @@ -49,7 +49,7 @@ void intel_region_ttm_device_fini(struct drm_i915_private *dev_priv) /* * Map the i915 memory regions to TTM memory types. We use the - * driver-private types for now, reserving TTM_PL_VRAM for stolen + * driver-private types for now, reserving I915_PL_STOLEN for stolen * memory and TTM_PL_TT for GGTT use if decided to implement this. */ int intel_region_to_ttm_type(const struct intel_memory_region *mem) @@ -58,11 +58,17 @@ int intel_region_to_ttm_type(const struct intel_memory_region *mem) GEM_BUG_ON(mem->type != INTEL_MEMORY_LOCAL && mem->type != INTEL_MEMORY_MOCK && - mem->type != INTEL_MEMORY_SYSTEM); + mem->type != INTEL_MEMORY_SYSTEM && + mem->type != INTEL_MEMORY_STOLEN_SYSTEM && + mem->type != INTEL_MEMORY_STOLEN_LOCAL); if (mem->type == INTEL_MEMORY_SYSTEM) return TTM_PL_SYSTEM; + if (mem->type == INTEL_MEMORY_STOLEN_SYSTEM || + mem->type == INTEL_MEMORY_STOLEN_LOCAL) + return I915_PL_STOLEN; + type = mem->instance + TTM_PL_PRIV; GEM_BUG_ON(type >= TTM_NUM_MEM_TYPES); @@ -86,10 +92,16 @@ int intel_region_ttm_init(struct intel_memory_region *mem) int mem_type = intel_region_to_ttm_type(mem); int ret; - ret = i915_ttm_buddy_man_init(bdev, mem_type, false, - resource_size(&mem->region), - mem->io_size, - mem->min_page_size, PAGE_SIZE); + if (mem_type == I915_PL_STOLEN) { + ret = ttm_range_man_init(bdev, mem_type, false, + resource_size(&mem->region) >> PAGE_SHIFT); + mem->is_range_manager = true; + } else { + ret = i915_ttm_buddy_man_init(bdev, mem_type, false, + resource_size(&mem->region), + mem->io_size, + mem->min_page_size, PAGE_SIZE); + } if (ret) return ret; @@ -109,6 +121,7 @@ int intel_region_ttm_init(struct intel_memory_region *mem) int intel_region_ttm_fini(struct intel_memory_region *mem) { struct ttm_resource_manager *man = mem->region_private; + int mem_type = intel_region_to_ttm_type(mem); int ret = -EBUSY; int count; @@ -139,8 +152,10 @@ int intel_region_ttm_fini(struct intel_memory_region *mem) if (ret || !man) return ret; - ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, - intel_region_to_ttm_type(mem)); + if (mem_type == I915_PL_STOLEN) + ret = ttm_range_man_fini(&mem->i915->bdev, mem_type); + else + ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, mem_type); GEM_WARN_ON(ret); mem->region_private = NULL; -- 2.25.1