Re: [PATCH 07/13] drm/amdgpu: store doorbell info in gmc structure

2023-02-06 Thread Christian König

Am 03.02.23 um 20:08 schrieb Shashank Sharma:

From: Alex Deucher 

This patch moves doorbell info into adev->gmc structure, to align
with vram info. This will prepare structures for proper ttm management
of the doorbell BAR.


Mhm, this is most likely not a good idea either.

The doorbell isn't managed by the GMC in any way. That are two 
completely different things in hw if I'm not completely mistaken.


Christian.



Signed-off-by: Alex Deucher 
Signed-off-by: Shashank Sharma 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  8 
  drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c  |  4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   | 14 +++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h |  3 ---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h  |  7 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  |  2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c|  2 +-
  drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c   |  4 ++--
  drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c   |  4 ++--
  drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c   |  4 ++--
  drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c   |  4 ++--
  drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   |  4 ++--
  drivers/gpu/drm/amd/amdgpu/nbio_v7_7.c   |  4 ++--
  13 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 58689b2a2d1c..28076da2258f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -106,13 +106,13 @@ static void amdgpu_doorbell_get_kfd_info(struct 
amdgpu_device *adev,
 * not initialized as AMDGPU manages the whole
 * doorbell space.
 */
-   *aperture_base = adev->doorbell.base;
+   *aperture_base = adev->gmc.doorbell_aper_base;
*aperture_size = 0;
*start_offset = 0;
-   } else if (adev->doorbell.size > adev->doorbell.num_doorbells *
+   } else if (adev->gmc.doorbell_aper_size > adev->doorbell.num_doorbells *
sizeof(u32)) {
-   *aperture_base = adev->doorbell.base;
-   *aperture_size = adev->doorbell.size;
+   *aperture_base = adev->gmc.doorbell_aper_base;
+   *aperture_size = adev->gmc.doorbell_aper_size;
*start_offset = adev->doorbell.num_doorbells * sizeof(u32);
} else {
*aperture_base = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
index 3257da5c3a66..0656e5bb4f05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
@@ -209,7 +209,7 @@ static ssize_t amdgpu_mem_info_doorbell_total_show(struct 
device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
  
-	return sysfs_emit(buf, "%llu\n", adev->doorbell.size);

+   return sysfs_emit(buf, "%llu\n", adev->gmc.doorbell_aper_size);
  }
  
  /**

@@ -897,7 +897,7 @@ int amdgpu_bar_mgr_init(struct amdgpu_device *adev, u32 
domain)
size = adev->gmc.real_vram_size;
} else if (domain == AMDGPU_PL_DOORBELL) {
mgr = &adev->mman.doorbell_mgr;
-   size = adev->doorbell.size;
+   size = adev->gmc.doorbell_aper_size;
} else {
return -EINVAL;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 45588b7919fe..16580d9580d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1035,8 +1035,8 @@ static int amdgpu_device_doorbell_init(struct 
amdgpu_device *adev)
  
  	/* No doorbell on SI hardware generation */

if (adev->asic_type < CHIP_BONAIRE) {
-   adev->doorbell.base = 0;
-   adev->doorbell.size = 0;
+   adev->gmc.doorbell_aper_base = 0;
+   adev->gmc.doorbell_aper_size = 0;
adev->doorbell.num_doorbells = 0;
adev->doorbell.ptr = NULL;
return 0;
@@ -1048,15 +1048,15 @@ static int amdgpu_device_doorbell_init(struct 
amdgpu_device *adev)
amdgpu_asic_init_doorbell_index(adev);
  
  	/* doorbell bar mapping */

-   adev->doorbell.base = pci_resource_start(adev->pdev, 2);
-   adev->doorbell.size = pci_resource_len(adev->pdev, 2);
+   adev->gmc.doorbell_aper_base = pci_resource_start(adev->pdev, 2);
+   adev->gmc.doorbell_aper_size = pci_resource_len(adev->pdev, 2);
  
  	if (adev->enable_mes) {

adev->doorbell.num_doorbells =
-   adev->doorbell.size / sizeof(u32);
+   adev->gmc.doorbell_aper_size / sizeof(u32);
} else {
adev->doorbell.num_doorbells =
-   min_t(u32, adev->doorbell.size /

[PATCH 07/13] drm/amdgpu: store doorbell info in gmc structure

2023-02-03 Thread Shashank Sharma
From: Alex Deucher 

This patch moves doorbell info into adev->gmc structure, to align
with vram info. This will prepare structures for proper ttm management
of the doorbell BAR.

Signed-off-by: Alex Deucher 
Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  8 
 drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c  |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   | 14 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h |  3 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h  |  7 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/nbio_v7_7.c   |  4 ++--
 13 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 58689b2a2d1c..28076da2258f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -106,13 +106,13 @@ static void amdgpu_doorbell_get_kfd_info(struct 
amdgpu_device *adev,
 * not initialized as AMDGPU manages the whole
 * doorbell space.
 */
-   *aperture_base = adev->doorbell.base;
+   *aperture_base = adev->gmc.doorbell_aper_base;
*aperture_size = 0;
*start_offset = 0;
-   } else if (adev->doorbell.size > adev->doorbell.num_doorbells *
+   } else if (adev->gmc.doorbell_aper_size > adev->doorbell.num_doorbells *
sizeof(u32)) {
-   *aperture_base = adev->doorbell.base;
-   *aperture_size = adev->doorbell.size;
+   *aperture_base = adev->gmc.doorbell_aper_base;
+   *aperture_size = adev->gmc.doorbell_aper_size;
*start_offset = adev->doorbell.num_doorbells * sizeof(u32);
} else {
*aperture_base = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
index 3257da5c3a66..0656e5bb4f05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bar_mgr.c
@@ -209,7 +209,7 @@ static ssize_t amdgpu_mem_info_doorbell_total_show(struct 
device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
 
-   return sysfs_emit(buf, "%llu\n", adev->doorbell.size);
+   return sysfs_emit(buf, "%llu\n", adev->gmc.doorbell_aper_size);
 }
 
 /**
@@ -897,7 +897,7 @@ int amdgpu_bar_mgr_init(struct amdgpu_device *adev, u32 
domain)
size = adev->gmc.real_vram_size;
} else if (domain == AMDGPU_PL_DOORBELL) {
mgr = &adev->mman.doorbell_mgr;
-   size = adev->doorbell.size;
+   size = adev->gmc.doorbell_aper_size;
} else {
return -EINVAL;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 45588b7919fe..16580d9580d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1035,8 +1035,8 @@ static int amdgpu_device_doorbell_init(struct 
amdgpu_device *adev)
 
/* No doorbell on SI hardware generation */
if (adev->asic_type < CHIP_BONAIRE) {
-   adev->doorbell.base = 0;
-   adev->doorbell.size = 0;
+   adev->gmc.doorbell_aper_base = 0;
+   adev->gmc.doorbell_aper_size = 0;
adev->doorbell.num_doorbells = 0;
adev->doorbell.ptr = NULL;
return 0;
@@ -1048,15 +1048,15 @@ static int amdgpu_device_doorbell_init(struct 
amdgpu_device *adev)
amdgpu_asic_init_doorbell_index(adev);
 
/* doorbell bar mapping */
-   adev->doorbell.base = pci_resource_start(adev->pdev, 2);
-   adev->doorbell.size = pci_resource_len(adev->pdev, 2);
+   adev->gmc.doorbell_aper_base = pci_resource_start(adev->pdev, 2);
+   adev->gmc.doorbell_aper_size = pci_resource_len(adev->pdev, 2);
 
if (adev->enable_mes) {
adev->doorbell.num_doorbells =
-   adev->doorbell.size / sizeof(u32);
+   adev->gmc.doorbell_aper_size / sizeof(u32);
} else {
adev->doorbell.num_doorbells =
-   min_t(u32, adev->doorbell.size / sizeof(u32),
+   min_t(u32, adev->gmc.doorbell_aper_size / sizeof(u32),
  adev->doorbell_index.max_assignment+1);
if (adev->doorbell.num_doorbells == 0)
return -