Skip to contentSkip to conversation

drm/amdgpu: Add comments to gmc structure

PATCH In review Zeng, Oak 4 participants 5 messages Nov 6, 2019 – Nov 7, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Zeng, Oak

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Add comments to gmc structure

Explain fields like aper_base, agp_start etc. The definition of those fields are confusing as they are from different view (CPU or GPU). Add comments for easier understand.

Change-Id I02c2a27cd0dbc205498eb86aafa722f2e0c25fe6
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +26 -0
index 555d8e5..1356ff9 100644
@@ -127,18 +127,44 @@ struct amdgpu_xgmi {
 };
 
 struct amdgpu_gmc {
+	/* FB's physical address in MMIO space (for CPU to
+	 * map FB). This is different compared to the apg/
+	 * gart/vram_start/end field as the later is from
+	 * GPU's view and aper_base is from CPU's view.
+	 */
 	resource_size_t		aper_size;
 	resource_size_t		aper_base;
 	/* for some chips with <= 32MB we need to lie
 	 * about vram size near mc fb location */
 	u64			mc_vram_size;
 	u64			visible_vram_size;
+	/* APG aperture start and end in MC address space
+	 * Driver find a hole in the MC address space
+	 * to place AGP by setting MC_VM_AGP_BOT/TOP registers
+	 * Under VMID0, logical address == MC address
+	 * AGP aperture is used to simulate FB in ZFB case
+	 */
 	u64			agp_size;
 	u64			agp_start;
 	u64			agp_end;
+	/* GART aperture start and end in MC address space
+	 * Driver find a hole in the MC address space
+	 * to place GART by setting VM_CONTEXT0_PAGE_TABLE_START/END_ADDR
+	 * registers
+	 * Under VMID0, logical address inside GART aperture will
+	 * be translated through gpuvm gart page table to access
+	 * paged system memory
+	 */
 	u64			gart_size;
 	u64			gart_start;
 	u64			gart_end;
+	/* Frame buffer aperture of this GPU device. Different from
+	 * fb_start (see below), this only covers the local GPU device.
+	 * Driver get fb_start from MC_VM_FB_LOCATION_BASE (set by vbios)
+	 * and calculate vram_start of this local device by adding an
+	 * offset inside the XGMI hive.
+	 * Under VMID0, logical address == MC address
+	 */
 	u64			vram_start;
 	u64			vram_end;
 	/* FB region , it's same as local vram region in single GPU, in XGMI
Signature · 6 lines
2.7.4

_______________________________________________
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): 1573061209-13148-1-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 06.11.19 um 18:26 schrieb Zeng, Oak:

Quoted 25 lines

Explain fields like aper_base, agp_start etc. The definition of those fields are confusing as they are from different view (CPU or GPU). Add comments for easier understand.

Change-Id I02c2a27cd0dbc205498eb86aafa722f2e0c25fe6
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 26 ++++++++++++++++++++++++++
  1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +5 -0
index 555d8e5..1356ff9 100644
@@ -127,18 +127,44 @@ struct amdgpu_xgmi {
  };
 
  struct amdgpu_gmc {
+	/* FB's physical address in MMIO space (for CPU to
+	 * map FB). This is different compared to the apg/
+	 * gart/vram_start/end field as the later is from
+	 * GPU's view and aper_base is from CPU's view.
+	 */
  	resource_size_t		aper_size;
  	resource_size_t		aper_base;

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h struct amdgpu_xgmi { · line 146

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +6 -0
  	/* for some chips with <= 32MB we need to lie
  	 * about vram size near mc fb location */
  	u64			mc_vram_size;
  	u64			visible_vram_size;
+	/* APG aperture start and end in MC address space
+	 * Driver find a hole in the MC address space
+	 * to place AGP by setting MC_VM_AGP_BOT/TOP registers
+	 * Under VMID0, logical address == MC address
+	 * AGP aperture is used to simulate FB in ZFB case
+	 */

Really nice improvement. Alex noted as well please mention the page table use case here as well.

Additional to that we also have a use case for display scanout, but that one is currently not implemented yet. Might be a good idea to mention that as well.

With that fixed the patch is Reviewed-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +8 -0
  	u64			agp_size;
  	u64			agp_start;
  	u64			agp_end;
+	/* GART aperture start and end in MC address space
+	 * Driver find a hole in the MC address space
+	 * to place GART by setting VM_CONTEXT0_PAGE_TABLE_START/END_ADDR
+	 * registers
+	 * Under VMID0, logical address inside GART aperture will
+	 * be translated through gpuvm gart page table to access
+	 * paged system memory
+	 */
  	u64			gart_size;
  	u64			gart_start;
  	u64			gart_end;

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h struct amdgpu_xgmi { · line 170

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +7 -0
+	/* Frame buffer aperture of this GPU device. Different from
+	 * fb_start (see below), this only covers the local GPU device.
+	 * Driver get fb_start from MC_VM_FB_LOCATION_BASE (set by vbios)
+	 * and calculate vram_start of this local device by adding an
+	 * offset inside the XGMI hive.
+	 * Under VMID0, logical address == MC address
+	 */
  	u64			vram_start;
  	u64			vram_end;
  	/* FB region , it's same as local vram region in single GPU, in XGMI

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

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 7 lines · Oak

Explain fields like aper_base, agp_start etc. The definition of those fields are confusing as they are from different view (CPU or GPU). Add comments for easier understand.

Change-Id I02c2a27cd0dbc205498eb86aafa722f2e0c25fe6

Same comments as the previous version. With those addressed,

Quoted 56 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +26 -1
index 555d8e5..1356ff9 100644
@@ -127,18 +127,44 @@ struct amdgpu_xgmi {
 };
 
 struct amdgpu_gmc {
+       /* FB's physical address in MMIO space (for CPU to
+        * map FB). This is different compared to the apg/
+        * gart/vram_start/end field as the later is from
+        * GPU's view and aper_base is from CPU's view.
+        */
        resource_size_t         aper_size;
        resource_size_t         aper_base;
        /* for some chips with <= 32MB we need to lie
         * about vram size near mc fb location */
        u64                     mc_vram_size;
        u64                     visible_vram_size;
+       /* APG aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place AGP by setting MC_VM_AGP_BOT/TOP registers
+        * Under VMID0, logical address == MC address
+        * AGP aperture is used to simulate FB in ZFB case
+        */
        u64                     agp_size;
        u64                     agp_start;
        u64                     agp_end;
+       /* GART aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place GART by setting VM_CONTEXT0_PAGE_TABLE_START/END_ADDR
+        * registers
+        * Under VMID0, logical address inside GART aperture will
+        * be translated through gpuvm gart page table to access
+        * paged system memory
+        */
        u64                     gart_size;
        u64                     gart_start;
        u64                     gart_end;
+       /* Frame buffer aperture of this GPU device. Different from
+        * fb_start (see below), this only covers the local GPU device.
+        * Driver get fb_start from MC_VM_FB_LOCATION_BASE (set by vbios)
+        * and calculate vram_start of this local device by adding an
+        * offset inside the XGMI hive.
+        * Under VMID0, logical address == MC address
+        */
        u64                     vram_start;
        u64                     vram_end;
        /* FB region , it's same as local vram region in single GPU, in XGMI
--

2.7.4

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_OinRnn+39TiX2SQkoBwwMPRO2vt0nTSLkwSBq-Mw2vBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Reviewed-by Alex Deucher
#5 lore raw

If this is not submitted, I would like to see some comments regarding the explanation of MC address and logical address, which I prefer to mention as GPU physical/virtual address.

Regards,
Yong

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Alex Deucher <[email protected]>
Sent: Thursday, November 7, 2019 9:02 AM
To: Zeng, Oak <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Add comments to gmc structure

Quoted 7 lines · Oak

Explain fields like aper_base, agp_start etc. The definition of those fields are confusing as they are from different view (CPU or GPU). Add comments for easier understand.

Change-Id I02c2a27cd0dbc205498eb86aafa722f2e0c25fe6

Same comments as the previous version. With those addressed,

Quoted 56 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +26 -1
index 555d8e5..1356ff9 100644
@@ -127,18 +127,44 @@ struct amdgpu_xgmi {
 };
 
 struct amdgpu_gmc {
+       /* FB's physical address in MMIO space (for CPU to
+        * map FB). This is different compared to the apg/
+        * gart/vram_start/end field as the later is from
+        * GPU's view and aper_base is from CPU's view.
+        */
        resource_size_t         aper_size;
        resource_size_t         aper_base;
        /* for some chips with <= 32MB we need to lie
         * about vram size near mc fb location */
        u64                     mc_vram_size;
        u64                     visible_vram_size;
+       /* APG aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place AGP by setting MC_VM_AGP_BOT/TOP registers
+        * Under VMID0, logical address == MC address
+        * AGP aperture is used to simulate FB in ZFB case
+        */
        u64                     agp_size;
        u64                     agp_start;
        u64                     agp_end;
+       /* GART aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place GART by setting VM_CONTEXT0_PAGE_TABLE_START/END_ADDR
+        * registers
+        * Under VMID0, logical address inside GART aperture will
+        * be translated through gpuvm gart page table to access
+        * paged system memory
+        */
        u64                     gart_size;
        u64                     gart_start;
        u64                     gart_end;
+       /* Frame buffer aperture of this GPU device. Different from
+        * fb_start (see below), this only covers the local GPU device.
+        * Driver get fb_start from MC_VM_FB_LOCATION_BASE (set by vbios)
+        * and calculate vram_start of this local device by adding an
+        * offset inside the XGMI hive.
+        * Under VMID0, logical address == MC address
+        */
        u64                     vram_start;
        u64                     vram_end;
        /* FB region , it's same as local vram region in single GPU, in XGMI
--

2.7.4

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

_______________________________________________
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): DM6PR12MB2778E5EB97BBDE1FBFB3DA12F0780-lmeGfMZKVrFSet88YzIdmgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author Reviewed-by Alex Deucher
#7 lore raw

Hi Yong,

That has been submitted.

MC address is the address sent to memory controller bus to address the physical memory. In many places it is also called physical address.

Logical address is the address before it is translated to physical address. The translation can be either linear or through page table. Under VMID0, logical address of some apertures (AGP, FB) are linearly mapped to MC address. (I think in our driver implementation, logical address == MC address). But Gart aperture is mapped through gpuvm (gart) page table - the mapped address can also be called virtual address.

Under VMID1~15, it is user space virtual address (can also be called logical address), mapped through gpuvm page tables.

So virtual address is one type of logical address. Virtual address is usually mapped through page table/vm.

Just my understanding.

Regards,
Oak

From: Zhao, Yong <[email protected]>
Sent: Thursday, November 7, 2019 12:16 PM
To: Alex Deucher <[email protected]>; Zeng, Oak <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add comments to gmc structure

If this is not submitted, I would like to see some comments regarding the explanation of MC address and logical address, which I prefer to mention as GPU physical/virtual address.

Regards,
Yong

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Thursday, November 7, 2019 9:02 AM
To: Zeng, Oak <[email protected]<mailto:[email protected]>>
Cc: Kuehling, Felix <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH] drm/amdgpu: Add comments to gmc structure

Quoted 7 lines · On Wed, Nov 6, 2019 at 12:27 PM Zeng, Oak…

Explain fields like aper_base, agp_start etc. The definition of those fields are confusing as they are from different view (CPU or GPU). Add comments for easier understand.

Change-Id I02c2a27cd0dbc205498eb86aafa722f2e0c25fe6

Same comments as the previous version. With those addressed,

Quoted 56 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +26 -1
index 555d8e5..1356ff9 100644
@@ -127,18 +127,44 @@ struct amdgpu_xgmi {
 };
 
 struct amdgpu_gmc {
+       /* FB's physical address in MMIO space (for CPU to
+        * map FB). This is different compared to the apg/
+        * gart/vram_start/end field as the later is from
+        * GPU's view and aper_base is from CPU's view.
+        */
        resource_size_t         aper_size;
        resource_size_t         aper_base;
        /* for some chips with <= 32MB we need to lie
         * about vram size near mc fb location */
        u64                     mc_vram_size;
        u64                     visible_vram_size;
+       /* APG aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place AGP by setting MC_VM_AGP_BOT/TOP registers
+        * Under VMID0, logical address == MC address
+        * AGP aperture is used to simulate FB in ZFB case
+        */
        u64                     agp_size;
        u64                     agp_start;
        u64                     agp_end;
+       /* GART aperture start and end in MC address space
+        * Driver find a hole in the MC address space
+        * to place GART by setting VM_CONTEXT0_PAGE_TABLE_START/END_ADDR
+        * registers
+        * Under VMID0, logical address inside GART aperture will
+        * be translated through gpuvm gart page table to access
+        * paged system memory
+        */
        u64                     gart_size;
        u64                     gart_start;
        u64                     gart_end;
+       /* Frame buffer aperture of this GPU device. Different from
+        * fb_start (see below), this only covers the local GPU device.
+        * Driver get fb_start from MC_VM_FB_LOCATION_BASE (set by vbios)
+        * and calculate vram_start of this local device by adding an
+        * offset inside the XGMI hive.
+        * Under VMID0, logical address == MC address
+        */
        u64                     vram_start;
        u64                     vram_end;
        /* FB region , it's same as local vram region in single GPU, in XGMI
--

2.7.4

Quoted 4 lines

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

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

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