[Intel-xe] [PATCH] drm/xe/xe2: Extend reserved stolen sizes

Lucas De Marchi lucas.demarchi at intel.com
Mon Oct 2 18:45:49 UTC 2023


On Fri, Sep 29, 2023 at 03:43:54PM -0700, Matt Roper wrote:
>On Thu, Sep 28, 2023 at 09:49:59PM -0700, Lucas De Marchi wrote:
>> For xe2, besides the previous sizes, the reserved portion of stolen can
>> also have 16MB and 32MB.
>>
>> Bspec: 53148
>> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>
>Reviewed-by: Matt Roper <matthew.d.roper at intel.com>
>
>While looking at this I'm trying to remember why we don't need to also
>use the media WOPCM field (13:11) from this register?  Is the media
>allocation already included in the value we're reading here?

it should be included already as the media wopcm field isn't accounted
for when calculating the stolen size - bspec 67090.

Maybe more clear is bspec 71410 showing the base and
Gfx Device WOPCM Size including everything.

Applied, thanks.

Lucas De Marchi


>
>
>Matt
>
>> ---
>>  drivers/gpu/drm/xe/regs/xe_regs.h      |  2 +-
>>  drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 32 ++++++++++++++++++++++----
>>  2 files changed, 29 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe_regs.h
>> index 8a93ab169e04..dbb0ea1a585e 100644
>> --- a/drivers/gpu/drm/xe/regs/xe_regs.h
>> +++ b/drivers/gpu/drm/xe/regs/xe_regs.h
>> @@ -69,7 +69,7 @@
>>  #define GSMBASE					XE_REG(0x108100)
>>
>>  #define STOLEN_RESERVED				XE_REG(0x1082c0)
>> -#define   WOPCM_SIZE_MASK			REG_GENMASK64(8, 7)
>> +#define   WOPCM_SIZE_MASK			REG_GENMASK64(9, 7)
>>
>>  #define MTL_RP_STATE_CAP			XE_REG(0x138000)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
>> index 6ba6b1b7f34b..79fbd74a3944 100644
>> --- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
>> +++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
>> @@ -86,6 +86,29 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
>>  	return ALIGN_DOWN(stolen_size, SZ_1M);
>>  }
>>
>> +static u32 get_wopcm_size(struct xe_device *xe)
>> +{
>> +	u32 wopcm_size;
>> +	u64 val;
>> +
>> +	val = xe_mmio_read64_2x32(xe_root_mmio_gt(xe), STOLEN_RESERVED);
>> +	val = REG_FIELD_GET64(WOPCM_SIZE_MASK, val);
>> +
>> +	switch (val) {
>> +	case 0x5 ... 0x6:
>> +		val--;
>> +		fallthrough;
>> +	case 0x0 ... 0x3:
>> +		wopcm_size = (1U << val) * SZ_1M;
>> +		break;
>> +	default:
>> +		WARN(1, "Missing case wopcm_size=%llx\n", val);
>> +		wopcm_size = 0;
>> +	}
>> +
>> +	return wopcm_size;
>> +}
>> +
>>  static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
>>  {
>>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>> @@ -125,10 +148,11 @@ static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr
>>  	}
>>
>>  	/* Carve out the top of DSM as it contains the reserved WOPCM region */
>> -	wopcm_size = REG_FIELD_GET64(WOPCM_SIZE_MASK,
>> -				     xe_mmio_read64_2x32(xe_root_mmio_gt(xe),
>> -							 STOLEN_RESERVED));
>> -	stolen_size -= (1U << wopcm_size) * SZ_1M;
>> +	wopcm_size = get_wopcm_size(xe);
>> +	if (drm_WARN_ON(&xe->drm, !wopcm_size))
>> +		return 0;
>> +
>> +	stolen_size -= wopcm_size;
>>
>>  	if (drm_WARN_ON(&xe->drm, stolen_size + SZ_8M > pci_resource_len(pdev, 2)))
>>  		return 0;
>> --
>> 2.40.1
>>
>
>-- 
>Matt Roper
>Graphics Software Engineer
>Linux GPU Platform Enablement
>Intel Corporation


More information about the Intel-xe mailing list