drm/amdgpu/discovery: reserve discovery data at the top of VRAM
Subsystems (2)
PATCH v2 1/1 drm/amdgpu/discovery: reserve discovery data at the top of VRAM
IP Discovery data is TMR fenced by the latest PSP BL, so we need to reserve this region.
Tested on navi10/12/14 with VBIOS integrated with latest PSP BL.
v2: use DISCOVERY_TMR_SIZE macro as bo size
use amdgpu_bo_create_kernel_at() to allocate bo
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/include/discovery.h | 1 - 5 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -812,6 +812,7 @@ struct amdgpu_device {uint8_t *bios;uint32_t bios_size;struct amdgpu_bo *stolen_vga_memory; +struct amdgpu_bo *discovery_memory;uint32_t bios_scratch_reg_offset;uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH ];
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -2
@@ -136,7 +136,7 @@ static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t *bin {uint32_t *p = (uint32_t *)binary;uint64_t vram_size = (uint64_t )RREG32 (mmRCC_CONFIG_MEMSIZE) <<20 ; -uint64_t pos = vram_size -BINARY_MAX_SIZE ; +uint64_t pos = vram_size -DISCOVERY_TMR_SIZE ;unsigned long flags;while (pos < vram_size) {
@@ -179,7 +179,7 @@ int amdgpu_discovery_init(struct amdgpu_device *adev)uint16_t checksum;int r; - adev->discovery =kzalloc (BINARY_MAX_SIZE ,GFP_KERNEL ); + adev->discovery =kzalloc (DISCOVERY_TMR_SIZE ,GFP_KERNEL );if (!adev->discovery)return -ENOMEM ;
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +2 -0
@@ -24,6 +24,8 @@#ifndef __AMDGPU_DISCOVERY__#define __AMDGPU_DISCOVERY__ +#define DISCOVERY_TMR_SIZE (64 << 10) +int amdgpu_discovery_init (struct amdgpu_device *adev);void amdgpu_discovery_fini (struct amdgpu_device *adev);int amdgpu_discovery_reg_base_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +17 -0
@@ -1955,6 +1955,20 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) NULL, &stolen_vga_buf);if (r)return r; + +/* +* reserve one TMR (64K) memory at the top of VRAM which holds +* IP Discovery data and is protected by PSP. +*/ + r =amdgpu_bo_create_kernel_at (adev, + adev->gmc.real_vram_size -DISCOVERY_TMR_SIZE , +DISCOVERY_TMR_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &adev->discovery_memory, +NULL ); +if (r) +return r; +DRM_INFO ("amdgpu: %uM of VRAM memory ready\n" , (unsigned ) (adev->gmc.real_vram_size / (1024 *1024 )));
@@ -2024,6 +2038,9 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)void *stolen_vga_buf;/* return the VGA stolen memory (if any) back to VRAM */ amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); + +/* return the IP Discovery TMR memory back to VRAM */ +amdgpu_bo_free_kernel (&adev->discovery_memory,NULL ,NULL ); }/**
drivers/gpu/drm/amd/include/discovery.h +0 -1
@@ -25,7 +25,6 @@#define _DISCOVERY_H_#define PSP_HEADER_SIZE 256 -#define BINARY_MAX_SIZE (64 << 10)#define BINARY_SIGNATURE 0x28211407#define DISCOVERY_TABLE_SIGNATURE 0x53445049
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Yuan, Xiaojie <[email protected]>
Sent: Friday, October 11, 2019 12:09 AM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Xiao, Jack <[email protected]>; Yuan, Xiaojie <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH v2] drm/amdgpu/discovery: reserve discovery data at the top of VRAM
IP Discovery data is TMR fenced by the latest PSP BL, so we need to reserve this region.
Tested on navi10/12/14 with VBIOS integrated with latest PSP BL.
v2: use DISCOVERY_TMR_SIZE macro as bo size
use amdgpu_bo_create_kernel_at() to allocate bo
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/include/discovery.h | 1 - 5 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -812,6 +812,7 @@ struct amdgpu_device {uint8_t *bios;uint32_t bios_size;struct amdgpu_bo *stolen_vga_memory; +struct amdgpu_bo *discovery_memory;uint32_t bios_scratch_reg_offset;uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH ];
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -2
@@ -136,7 +136,7 @@ static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t *bin {uint32_t *p = (uint32_t *)binary;uint64_t vram_size = (uint64_t )RREG32 (mmRCC_CONFIG_MEMSIZE) <<20 ; -uint64_t pos = vram_size -BINARY_MAX_SIZE ; +uint64_t pos = vram_size -DISCOVERY_TMR_SIZE ;unsigned long flags;while (pos < vram_size) {
@@ -179,7 +179,7 @@ int amdgpu_discovery_init(struct amdgpu_device *adev)uint16_t checksum;int r; - adev->discovery =kzalloc (BINARY_MAX_SIZE ,GFP_KERNEL ); + adev->discovery =kzalloc (DISCOVERY_TMR_SIZE ,GFP_KERNEL );if (!adev->discovery)return -ENOMEM ;
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +2 -0
@@ -24,6 +24,8 @@#ifndef __AMDGPU_DISCOVERY__#define __AMDGPU_DISCOVERY__ +#define DISCOVERY_TMR_SIZE (64 << 10) +int amdgpu_discovery_init (struct amdgpu_device *adev);void amdgpu_discovery_fini (struct amdgpu_device *adev);int amdgpu_discovery_reg_base_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +17 -0
@@ -1955,6 +1955,20 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) NULL, &stolen_vga_buf);if (r)return r; + +/* +* reserve one TMR (64K) memory at the top of VRAM which holds +* IP Discovery data and is protected by PSP. +*/ + r =amdgpu_bo_create_kernel_at (adev, + adev->gmc.real_vram_size -DISCOVERY_TMR_SIZE , +DISCOVERY_TMR_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &adev->discovery_memory, +NULL ); +if (r) +return r; +DRM_INFO ("amdgpu: %uM of VRAM memory ready\n" , (unsigned ) (adev->gmc.real_vram_size / (1024 *1024 )));
@@ -2024,6 +2038,9 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)void *stolen_vga_buf;/* return the VGA stolen memory (if any) back to VRAM */ amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); + +/* return the IP Discovery TMR memory back to VRAM */ +amdgpu_bo_free_kernel (&adev->discovery_memory,NULL ,NULL ); }/**
drivers/gpu/drm/amd/include/discovery.h +0 -1
@@ -25,7 +25,6 @@#define _DISCOVERY_H_#define PSP_HEADER_SIZE 256 -#define BINARY_MAX_SIZE (64 << 10)#define BINARY_SIGNATURE 0x28211407#define DISCOVERY_TABLE_SIGNATURE 0x53445049
--
2.20.1
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx