Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp987643pxb; Fri, 15 Apr 2022 17:31:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9M5gAOmM+dDmPYLSQ3UEUCmGzqpG++HlXvxtWqKyNKWwqE4m2Y4PaDHTC0w+kMPWHthAN X-Received: by 2002:a17:902:8c96:b0:158:9135:98d3 with SMTP id t22-20020a1709028c9600b00158913598d3mr1380883plo.171.1650069066974; Fri, 15 Apr 2022 17:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069066; cv=none; d=google.com; s=arc-20160816; b=nOhovZv1FME/F7O9Py4XhJ3oCDg3E/7uLG5WaQ8ZIxrLwNx0hTRWhhiA/zfStgaEeW MiGrUL1ERk6Uq2dTRr95Kvsl0w7oqqFBEnW82P/Up6cNoxkqyFnUH4ReFyuHp9gmvlMN P1RQCBvkvkf/HxArYvqpMwynCZsRineN61RFuwiChmSOTYqbUq4PEL2D271AU08dedeR /OQJd6Me10GR0s4Kh62omfYbZV8AY635+per4oOyOdqdYFpeTVXqyxgCJbkM1jaKFhBv PKYMwyso/9weRE0zXcd7GNHCnYkp74QOsHboGuCDCwTntrtFhpH97fSOFmo+UxOR7iVB xIzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=36BtasGft/8KDnCT1zbCCaF1dPq3oohAdMjFZrpfTLI=; b=rYzkCxJvPHS4PQB2KN6YYZW8gIl4wTo50cT6E3jJFtWKD/empZzs9jJ5blv4H/I5rx bmlMoVfmZ3elyVMuNFBM5cABaAmTfXSOmhniXVrCgCC157HgGgl4uxiIh1sVcU03IZ2p KZxPYPg8LHW/zAX6DeQVJQMyUds81O/38ZjaJKAWV1cvTR2tqwD+IC3hzNQE9ZuRLXpH yuyZnaFY4K/GcAbQDY2/6mnqPSf8e/5kTTKTgWBfyc6IFX811XnTpWeHbV1Subwpwhls 0cH0/wwTUwXpQJFTVxw6koMKKHC+3wse8fAaNj/Oiih/NnhXmVIrjV0LnF9PvsVjx0fk UtBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KFGglyIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g4-20020a170902934400b00153b2d165ecsi2247991plp.500.2022.04.15.17.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KFGglyIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6006EA66D1; Fri, 15 Apr 2022 17:28:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344805AbiDNNom (ORCPT + 99 others); Thu, 14 Apr 2022 09:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245676AbiDNN3O (ORCPT ); Thu, 14 Apr 2022 09:29:14 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BC4AFAC8 for ; Thu, 14 Apr 2022 06:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649942614; x=1681478614; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=NO3sfIaXbtW/daMNfOs46Z/HBgbjixeiUp7yO1HtmUY=; b=KFGglyIPytLZGwL1JCmMBRRLXXlryP27prpz/Nl9rq8Boa30+jCz6/dk ceQvASQI7hhgZw9NUBRCtPMK6cnwHKFHdGknraQN02d/Y6ve4xNTD0O07 O5l6lRmMueggYq3JWrPZYUOZ5BhTBcp2nN43RC2jbIm7g1pfqRu4+Bcjd igRS1GmeagiVHkzEnB+qsXc8RpR0F8+p+ofFS/t4C13pwRQUDCc2fNp3z ubuwZMI0sXnKt+R2V9MXlkWNbG/HFgZU8iWrOBi+YTDLp2jSA/ZszGEyX FCjur/iRBUCRgkm3z8Rev168ByERh8WUnQlQ+o313/+LH10vqbhlHsoGO w==; X-IronPort-AV: E=McAfee;i="6400,9594,10316"; a="287982868" X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="287982868" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 06:23:33 -0700 X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="508404605" Received: from aviljane-mobl.ger.corp.intel.com (HELO [10.249.254.86]) ([10.249.254.86]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 06:23:30 -0700 Message-ID: <28042cc2-be62-eeb7-35a7-f2e33c43bad5@linux.intel.com> Date: Thu, 14 Apr 2022 15:23:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 1/5] drm/i915: instantiate ttm ranger manager for stolen memory Content-Language: en-US To: Robert Beckett , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: Matthew Auld , linux-kernel@vger.kernel.org References: <20220412193817.2098308-1-bob.beckett@collabora.com> <20220412193817.2098308-2-bob.beckett@collabora.com> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m?= In-Reply-To: <20220412193817.2098308-2-bob.beckett@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 4/12/22 21:38, Robert Beckett wrote: > prepare for ttm based stolen region by using ttm range manager > as the resource manager for stolen region. > > Signed-off-by: Robert Beckett LGTM. 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 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; >