Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4120568imw; Thu, 7 Jul 2022 13:07:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vnwkanrSsEVoIYBjh2Z4gENJTbgb4u0pj51x8FgQpYh4+07I9sZu8VweN91pHZP0LNLwS2 X-Received: by 2002:a62:442:0:b0:528:641c:cfde with SMTP id 63-20020a620442000000b00528641ccfdemr25482968pfe.14.1657224478609; Thu, 07 Jul 2022 13:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657224478; cv=none; d=google.com; s=arc-20160816; b=ii9bTr2w81/YCaV+zVjC2dYqVNTFRzBRxmScmxwN3qf5lZSBfwjtLEUWiQ0sgsomDz kY0mIT7nho12Eezox+Zmb4WhULbqOtwfq1gf+glo1n5UhgDJIXS+uUcWFGzyHUT5tRkd Tvxffykh3bPDiB4C1aPYpixclMXO4wvwTEKEz9INjjKxsmOdVMcglxwMMhUFBbNFNsME 9fU7k3cujatM9iSC/biiXeY2W30sXOWPBNULABai94aA7Uwcjk+KgjoI6hj/vDnGsaKw YjGdd1YEQ+3vd8pFfatIF2XEX6ZFM4wQqqxAiXuobxVIWlBX+SzuCC2ooxlwG/x05tvm K0gA== 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=1agfv+7BIthV6V2cWKYUMscfnTdofAn0dP21h/Hr9YY=; b=b1+uM50WNHSqfa5Ks06hHAY9R4f0ll4hiIZCByZXiG+D6Gz0pdFteLCyMn90L6wMz3 2+c+DAt0kDktiJqzQx5AmiYGKLAirvL3NiXxoWHmIa99Y2CGkWMt4g2KGww/aJU0Xwo3 JizP0pCr24QZ8VC8rR9yfJV0Jc/Jk8OLzwSBOyY0FLT/YZW8zytEiArnkHLsSne76lhD jxzK45uJ/uWgBF3Vv+XJnUqDmvq0y1BLmFKrR9H61ooo/XKzYZhIFk4WETeG7vo2pJ2z CH5cvOj0S4L4T7SH+1heMXjafdBP0/9I2K/EZri/OgKs0Sywh/lg34RR8BEMCyEUldP4 L1FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=evQyPjJl; 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 k17-20020a170902ba9100b0016bdf2220ddsi17544907pls.272.2022.07.07.13.07.45; Thu, 07 Jul 2022 13:07:58 -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=evQyPjJl; 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 S236846AbiGGUC7 (ORCPT + 99 others); Thu, 7 Jul 2022 16:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236818AbiGGUCs (ORCPT ); Thu, 7 Jul 2022 16:02:48 -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 C7E611E3F2 for ; Thu, 7 Jul 2022 13:02:47 -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 6FE0766019D9; Thu, 7 Jul 2022 21:02:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657224166; bh=4aLhOjNbnMWEd5TE2kdvFPY0DN2hydFT2IvNHlkBa+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evQyPjJlvvmk4j5PwsrJFD1QCYTbCuIf/tTRGtPN/q2Q48euAkUZ/mF5pIgVBhdcG hz/Os5AMdrMpuO+y51kCVCwaWfJL/qa/bJev4ksPXcwiv2mSQInsNIibPjlThh2JyL +4IJWlc2lZQEa0sIHedfY86y6aqETQNB6QaPx9zkkke9xGjmejoqO9vk6ADPeCiQyq JPasR3b5z6CHDbleZxYPLl9/+Ki83u+b/nE/jKUkPr7hG6mvl7iovNgYqTQkJkOOjC RJPkCY+EcrvvXbCQIOSZOWM79OYoQL9IQcNXK/jP/Y/G4LYBEVu/BVgNYQFfZsHYQL qaDp9z+Qzcqzw== 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 v10 05/11] drm/i915: instantiate ttm ranger manager for stolen memory Date: Thu, 7 Jul 2022 20:02:23 +0000 Message-Id: <20220707200230.1657555-6-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707200230.1657555-1-bob.beckett@collabora.com> References: <20220707200230.1657555-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 prepare for ttm based stolen region by using ttm range manager as the resource manager for stolen region. Signed-off-by: Robert Beckett Reviewed-by: Thomas Hellström --- 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 40249fa28a7a..675e9ab30396 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -60,11 +60,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 fd2ecfdd8fa1..694e9acb69e2 100644 --- a/drivers/gpu/drm/i915/intel_region_ttm.c +++ b/drivers/gpu/drm/i915/intel_region_ttm.c @@ -54,7 +54,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) @@ -63,11 +63,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); @@ -91,10 +97,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; @@ -114,6 +126,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; @@ -144,8 +157,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