Skip to contentSkip to conversation

drm/amdgpu/discovery: reserve discovery data at the top of VRAM

PATCH Superseded Yuan, Xiaojie 3 participants 4 messages Oct 10, 2019 2 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index be0b2c69c223..6775647f0ba5 100644
@@ -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_ttm.c +15 -0
index edffc883549a..c3d7eb685a23 100644
@@ -1955,6 +1955,18 @@ 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(adev, 64 << 10, PAGE_SIZE,
+				    AMDGPU_GEM_DOMAIN_VRAM,
+				    &adev->discovery_memory,
+				    NULL, NULL);
+	if (r)
+		return r;
+
 	DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
 		 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
@@ -2024,6 +2036,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);
 }
 
 /**
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]

Reviewed-by Hawking Zhang
#2 lore raw

Please add define on tmr memory size instead of hard-code. Other than that the patch is

Regards,
Hawking
-----Original Message-----
From: Yuan, Xiaojie <[email protected]>
Sent: 2019年10月10日 20:48
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Xiao, Jack <[email protected]>; Yuan, Xiaojie <[email protected]>
Subject: [PATCH] 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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index be0b2c69c223..6775647f0ba5 100644
@@ -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_ttm.c +15 -0
index edffc883549a..c3d7eb685a23 100644
@@ -1955,6 +1955,18 @@ 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(adev, 64 << 10, PAGE_SIZE,
+				    AMDGPU_GEM_DOMAIN_VRAM,
+				    &adev->discovery_memory,
+				    NULL, NULL);
+	if (r)
+		return r;
+
 	DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
 		 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
@@ -2024,6 +2036,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);
 }
 
 /**

--
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive
Quoted 32 lines · Xiaojie

IP Discovery data is TMR fenced by the latest PSP BL, so we need to reserve this region.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index be0b2c69c223..6775647f0ba5 100644
@@ -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_ttm.c +2 -0
index edffc883549a..c3d7eb685a23 100644
@@ -1955,6 +1955,18 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                                    NULL, &stolen_vga_buf);
        if (r)
                return r;
+
+       /*

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1969

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+        * 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(adev, 64 << 10, PAGE_SIZE,
+                                   AMDGPU_GEM_DOMAIN_VRAM,
+                                   &adev->discovery_memory,
+                                   NULL, NULL);
+       if (r)
+               return r;
+

I think we should use amdgpu_bo_create_kernel_at() for both this and stolen_vga_memory so that we make sure we end up reserving the right location since both of these buffers are created by firmware at fixed locations.

Alex

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -1
        DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
                 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
@@ -2024,6 +2036,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);
 }
 
 /**
--

2.20.1

Quoted 4 lines

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): CADnq5_Mz7SDUs4MWKzhZp3toc0x0guRJjA+JyFb7CcChtBAixw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw

Thanks Alex. I'll try to use the new api and send v2 patch.

BR,
Xiaojie
________________________________
From: Alex Deucher <[email protected]>
Sent: Thursday, October 10, 2019 8:57 PM
To: Yuan, Xiaojie <[email protected]>
Cc: [email protected] <[email protected]>; Xiao, Jack <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu/discovery: reserve discovery data at the top of VRAM

Quoted 32 lines · Xiaojie

IP Discovery data is TMR fenced by the latest PSP BL, so we need to reserve this region.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index be0b2c69c223..6775647f0ba5 100644
@@ -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_ttm.c +2 -0
index edffc883549a..c3d7eb685a23 100644
@@ -1955,6 +1955,18 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                                    NULL, &stolen_vga_buf);
        if (r)
                return r;
+
+       /*

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1969

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+        * 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(adev, 64 << 10, PAGE_SIZE,
+                                   AMDGPU_GEM_DOMAIN_VRAM,
+                                   &adev->discovery_memory,
+                                   NULL, NULL);
+       if (r)
+               return r;
+

I think we should use amdgpu_bo_create_kernel_at() for both this and stolen_vga_memory so that we make sure we end up reserving the right location since both of these buffers are created by firmware at fixed locations.

Alex

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -1
        DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
                 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
@@ -2024,6 +2036,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);
 }
 
 /**
--

2.20.1

Quoted 4 lines

_______________________________________________
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