* [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
@ 2023-04-25 14:54 Shane Xiao
2023-04-25 15:49 ` Christian König
0 siblings, 1 reply; 5+ messages in thread
From: Shane Xiao @ 2023-04-25 14:54 UTC (permalink / raw)
To: amd-gfx, alexander.deucher, christian.koenig, felix.kuehling,
hawking.zhang
Cc: Xiaomeng Hou, Shane Xiao, Aaron Liu
[Why]
The selfring doorbell aperture will change when resize FB
BAR successfully during gmc sw init, we should reorder
the sequence of enabling doorbell selfring aperture.
[How]
Move enable_doorbell_selfring_aperture from *_common_hw_init
to *_common_late_init.
This fixes the potential issue that GPU ring its own
doorbell when this device is in translated mode when
iommu is on.
v2: Remove *_enable_doorbell_aperture functions (Christian)
v3: Add comments to note that why we need enable doorbell
selfring late (Christian)
Signed-off-by: Shane Xiao <shane.xiao@amd.com>
Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Tested-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
---
drivers/gpu/drm/amd/amdgpu/nv.c | 23 +++++++++++++----------
drivers/gpu/drm/amd/amdgpu/soc15.c | 25 +++++++++++++++----------
drivers/gpu/drm/amd/amdgpu/soc21.c | 23 +++++++++++++----------
3 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index dabeeab2f2ad..3cc068974bcd 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device *adev)
}
-static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version nv_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -999,6 +992,11 @@ static int nv_common_late_init(void *handle)
}
}
+ /* Enable selfring doorbell aperture late because doorbell BAR
+ * aperture will change if resize BAR successfully in gmc sw_init.
+ */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -1038,7 +1036,7 @@ static int nv_common_hw_init(void *handle)
if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf(adev))
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- nv_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
return 0;
}
@@ -1047,8 +1045,13 @@ static int nv_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- nv_enable_doorbell_aperture(adev, false);
+ /* Disable the doorbell aperture and selfring doorbell aperture
+ * separately in hw_fini because nv_enable_doorbell_aperture
+ * has been removed and there is no need to delay disabling
+ * selfring doorbell.
+ */
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 4d1487a9836c..3221522e71e8 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
adev->nbio.funcs->program_aspm(adev);
}
-static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version vega10_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -1125,6 +1118,11 @@ static int soc15_common_late_init(void *handle)
if (amdgpu_sriov_vf(adev))
xgpu_ai_mailbox_get_irq(adev);
+ /* Enable selfring doorbell aperture late because doorbell BAR
+ * aperture will change if resize BAR successfully in gmc sw_init.
+ */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -1182,7 +1180,8 @@ static int soc15_common_hw_init(void *handle)
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- soc15_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
+
/* HW doorbell routing policy: doorbell writing not
* in SDMA/IH/MM/ACV range will be routed to CP. So
* we need to init SDMA doorbell range prior
@@ -1198,8 +1197,14 @@ static int soc15_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- soc15_enable_doorbell_aperture(adev, false);
+ /* Disable the doorbell aperture and selfring doorbell aperture
+ * separately in hw_fini because soc15_enable_doorbell_aperture
+ * has been removed and there is no need to delay disabling
+ * selfring doorbell.
+ */
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
+
if (amdgpu_sriov_vf(adev))
xgpu_ai_mailbox_put_irq(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c b/drivers/gpu/drm/amd/amdgpu/soc21.c
index 7d59303ca2f9..0f82b8e83acb 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc21.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
@@ -450,13 +450,6 @@ static void soc21_program_aspm(struct amdgpu_device *adev)
adev->nbio.funcs->program_aspm(adev);
}
-static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version soc21_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -764,6 +757,11 @@ static int soc21_common_late_init(void *handle)
amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0);
}
+ /* Enable selfring doorbell aperture late because doorbell BAR
+ * aperture will change if resize BAR successfully in gmc sw_init.
+ */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -797,7 +795,7 @@ static int soc21_common_hw_init(void *handle)
if (adev->nbio.funcs->remap_hdp_registers)
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- soc21_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
return 0;
}
@@ -806,8 +804,13 @@ static int soc21_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- soc21_enable_doorbell_aperture(adev, false);
+ /* Disable the doorbell aperture and selfring doorbell aperture
+ * separately in hw_fini because soc21_enable_doorbell_aperture
+ * has been removed and there is no need to delay disabling
+ * selfring doorbell.
+ */
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
if (amdgpu_sriov_vf(adev)) {
xgpu_nv_mailbox_put_irq(adev);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
2023-04-25 14:54 [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR Shane Xiao
@ 2023-04-25 15:49 ` Christian König
0 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2023-04-25 15:49 UTC (permalink / raw)
To: Shane Xiao, amd-gfx, alexander.deucher, felix.kuehling,
hawking.zhang
Cc: Xiaomeng Hou, Aaron Liu
Am 25.04.23 um 16:54 schrieb Shane Xiao:
> [Why]
> The selfring doorbell aperture will change when resize FB
> BAR successfully during gmc sw init, we should reorder
> the sequence of enabling doorbell selfring aperture.
>
> [How]
> Move enable_doorbell_selfring_aperture from *_common_hw_init
> to *_common_late_init.
>
> This fixes the potential issue that GPU ring its own
> doorbell when this device is in translated mode when
> iommu is on.
>
> v2: Remove *_enable_doorbell_aperture functions (Christian)
> v3: Add comments to note that why we need enable doorbell
> selfring late (Christian)
>
> Signed-off-by: Shane Xiao <shane.xiao@amd.com>
> Signed-off-by: Aaron Liu <aaron.liu@amd.com>
> Tested-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/nv.c | 23 +++++++++++++----------
> drivers/gpu/drm/amd/amdgpu/soc15.c | 25 +++++++++++++++----------
> drivers/gpu/drm/amd/amdgpu/soc21.c | 23 +++++++++++++----------
> 3 files changed, 41 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
> index dabeeab2f2ad..3cc068974bcd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.c
> @@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device *adev)
>
> }
>
> -static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version nv_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -999,6 +992,11 @@ static int nv_common_late_init(void *handle)
> }
> }
>
> + /* Enable selfring doorbell aperture late because doorbell BAR
> + * aperture will change if resize BAR successfully in gmc sw_init.
> + */
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -1038,7 +1036,7 @@ static int nv_common_hw_init(void *handle)
> if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf(adev))
> adev->nbio.funcs->remap_hdp_registers(adev);
> /* enable the doorbell aperture */
> - nv_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
>
> return 0;
> }
> @@ -1047,8 +1045,13 @@ static int nv_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - nv_enable_doorbell_aperture(adev, false);
> + /* Disable the doorbell aperture and selfring doorbell aperture
> + * separately in hw_fini because nv_enable_doorbell_aperture
> + * has been removed and there is no need to delay disabling
> + * selfring doorbell.
> + */
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
>
> return 0;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
> index 4d1487a9836c..3221522e71e8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
> @@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
> adev->nbio.funcs->program_aspm(adev);
> }
>
> -static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version vega10_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -1125,6 +1118,11 @@ static int soc15_common_late_init(void *handle)
> if (amdgpu_sriov_vf(adev))
> xgpu_ai_mailbox_get_irq(adev);
>
> + /* Enable selfring doorbell aperture late because doorbell BAR
> + * aperture will change if resize BAR successfully in gmc sw_init.
> + */
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -1182,7 +1180,8 @@ static int soc15_common_hw_init(void *handle)
> adev->nbio.funcs->remap_hdp_registers(adev);
>
> /* enable the doorbell aperture */
> - soc15_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
> +
> /* HW doorbell routing policy: doorbell writing not
> * in SDMA/IH/MM/ACV range will be routed to CP. So
> * we need to init SDMA doorbell range prior
> @@ -1198,8 +1197,14 @@ static int soc15_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - soc15_enable_doorbell_aperture(adev, false);
> + /* Disable the doorbell aperture and selfring doorbell aperture
> + * separately in hw_fini because soc15_enable_doorbell_aperture
> + * has been removed and there is no need to delay disabling
> + * selfring doorbell.
> + */
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
> +
> if (amdgpu_sriov_vf(adev))
> xgpu_ai_mailbox_put_irq(adev);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c b/drivers/gpu/drm/amd/amdgpu/soc21.c
> index 7d59303ca2f9..0f82b8e83acb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc21.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
> @@ -450,13 +450,6 @@ static void soc21_program_aspm(struct amdgpu_device *adev)
> adev->nbio.funcs->program_aspm(adev);
> }
>
> -static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version soc21_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -764,6 +757,11 @@ static int soc21_common_late_init(void *handle)
> amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0);
> }
>
> + /* Enable selfring doorbell aperture late because doorbell BAR
> + * aperture will change if resize BAR successfully in gmc sw_init.
> + */
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -797,7 +795,7 @@ static int soc21_common_hw_init(void *handle)
> if (adev->nbio.funcs->remap_hdp_registers)
> adev->nbio.funcs->remap_hdp_registers(adev);
> /* enable the doorbell aperture */
> - soc21_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
>
> return 0;
> }
> @@ -806,8 +804,13 @@ static int soc21_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - soc21_enable_doorbell_aperture(adev, false);
> + /* Disable the doorbell aperture and selfring doorbell aperture
> + * separately in hw_fini because soc21_enable_doorbell_aperture
> + * has been removed and there is no need to delay disabling
> + * selfring doorbell.
> + */
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
>
> if (amdgpu_sriov_vf(adev)) {
> xgpu_nv_mailbox_put_irq(adev);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
@ 2023-04-25 10:16 Shane Xiao
2023-04-25 11:24 ` Christian König
0 siblings, 1 reply; 5+ messages in thread
From: Shane Xiao @ 2023-04-25 10:16 UTC (permalink / raw)
To: amd-gfx, alexander.deucher, christian.koenig, felix.kuehling,
hawking.zhang
Cc: Xiaomeng Hou, Shane Xiao, Aaron Liu
[Why]
The selfring doorbell aperture will change when resize FB
BAR successfully during gmc sw init, we should reorder
the sequence of enabling doorbell selfring aperture.
[How]
Move enable_doorbell_selfring_aperture from *_common_hw_init
to *_common_late_init.
This fixes the potential issue that GPU ring its own
doorbell when this device is in translated mode when
iommu is on.
v2:
1. Remove *_enable_doorbell_aperture functions
Signed-off-by: Shane Xiao <shane.xiao@amd.com>
Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Tested-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
---
drivers/gpu/drm/amd/amdgpu/nv.c | 17 +++++++----------
drivers/gpu/drm/amd/amdgpu/soc15.c | 19 +++++++++----------
drivers/gpu/drm/amd/amdgpu/soc21.c | 17 +++++++----------
3 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index dabeeab2f2ad..cb39d556c23d 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device *adev)
}
-static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version nv_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -999,6 +992,9 @@ static int nv_common_late_init(void *handle)
}
}
+ /* enable selfring doorbell aperture */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -1038,7 +1034,7 @@ static int nv_common_hw_init(void *handle)
if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf(adev))
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- nv_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
return 0;
}
@@ -1047,8 +1043,9 @@ static int nv_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- nv_enable_doorbell_aperture(adev, false);
+ /* disable the doorbell aperture and selfring doorbell aperture*/
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 4d1487a9836c..2db021f6e8ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
adev->nbio.funcs->program_aspm(adev);
}
-static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version vega10_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -1125,6 +1118,9 @@ static int soc15_common_late_init(void *handle)
if (amdgpu_sriov_vf(adev))
xgpu_ai_mailbox_get_irq(adev);
+ /* enable selfring doorbell aperture */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -1182,7 +1178,8 @@ static int soc15_common_hw_init(void *handle)
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- soc15_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
+
/* HW doorbell routing policy: doorbell writing not
* in SDMA/IH/MM/ACV range will be routed to CP. So
* we need to init SDMA doorbell range prior
@@ -1198,8 +1195,10 @@ static int soc15_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- soc15_enable_doorbell_aperture(adev, false);
+ /* disable the doorbell aperture and selfring doorbell aperture */
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
+
if (amdgpu_sriov_vf(adev))
xgpu_ai_mailbox_put_irq(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c b/drivers/gpu/drm/amd/amdgpu/soc21.c
index 7d59303ca2f9..21d11b7c510e 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc21.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
@@ -450,13 +450,6 @@ static void soc21_program_aspm(struct amdgpu_device *adev)
adev->nbio.funcs->program_aspm(adev);
}
-static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
- bool enable)
-{
- adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
- adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
const struct amdgpu_ip_block_version soc21_common_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -764,6 +757,9 @@ static int soc21_common_late_init(void *handle)
amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0);
}
+ /* enable selfring doorbell aperture */
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
return 0;
}
@@ -797,7 +793,7 @@ static int soc21_common_hw_init(void *handle)
if (adev->nbio.funcs->remap_hdp_registers)
adev->nbio.funcs->remap_hdp_registers(adev);
/* enable the doorbell aperture */
- soc21_enable_doorbell_aperture(adev, true);
+ adev->nbio.funcs->enable_doorbell_aperture(adev, true);
return 0;
}
@@ -806,8 +802,9 @@ static int soc21_common_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
- /* disable the doorbell aperture */
- soc21_enable_doorbell_aperture(adev, false);
+ /* disable the doorbell aperture and selfring doorbell aperture */
+ adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+ adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
if (amdgpu_sriov_vf(adev)) {
xgpu_nv_mailbox_put_irq(adev);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
2023-04-25 10:16 Shane Xiao
@ 2023-04-25 11:24 ` Christian König
2023-04-25 13:19 ` Xiao, Shane
0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2023-04-25 11:24 UTC (permalink / raw)
To: Shane Xiao, amd-gfx, alexander.deucher, felix.kuehling,
hawking.zhang
Cc: Xiaomeng Hou, Aaron Liu
Am 25.04.23 um 12:16 schrieb Shane Xiao:
> [Why]
> The selfring doorbell aperture will change when resize FB
> BAR successfully during gmc sw init, we should reorder
> the sequence of enabling doorbell selfring aperture.
>
> [How]
> Move enable_doorbell_selfring_aperture from *_common_hw_init
> to *_common_late_init.
>
> This fixes the potential issue that GPU ring its own
> doorbell when this device is in translated mode when
> iommu is on.
>
> v2:
> 1. Remove *_enable_doorbell_aperture functions
>
> Signed-off-by: Shane Xiao <shane.xiao@amd.com>
> Signed-off-by: Aaron Liu <aaron.liu@amd.com>
> Tested-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/nv.c | 17 +++++++----------
> drivers/gpu/drm/amd/amdgpu/soc15.c | 19 +++++++++----------
> drivers/gpu/drm/amd/amdgpu/soc21.c | 17 +++++++----------
> 3 files changed, 23 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
> index dabeeab2f2ad..cb39d556c23d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.c
> @@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device *adev)
>
> }
>
> -static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version nv_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -999,6 +992,9 @@ static int nv_common_late_init(void *handle)
> }
> }
>
> + /* enable selfring doorbell aperture */
Documenting *what* you do is usually a bad idea since that should be
obvious. You need to document *why* you do it.
In other words maybe change the comment to /* Enable this late because
doorbell BAR location can change during hw_init */.
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -1038,7 +1034,7 @@ static int nv_common_hw_init(void *handle)
> if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf(adev))
> adev->nbio.funcs->remap_hdp_registers(adev);
> /* enable the doorbell aperture */
> - nv_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
>
> return 0;
> }
> @@ -1047,8 +1043,9 @@ static int nv_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - nv_enable_doorbell_aperture(adev, false);
> + /* disable the doorbell aperture and selfring doorbell aperture*/
Same here and all other places as well.
Apart from that looks good to me,
Christian.
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
>
> return 0;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
> index 4d1487a9836c..2db021f6e8ac 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
> @@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
> adev->nbio.funcs->program_aspm(adev);
> }
>
> -static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version vega10_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -1125,6 +1118,9 @@ static int soc15_common_late_init(void *handle)
> if (amdgpu_sriov_vf(adev))
> xgpu_ai_mailbox_get_irq(adev);
>
> + /* enable selfring doorbell aperture */
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -1182,7 +1178,8 @@ static int soc15_common_hw_init(void *handle)
> adev->nbio.funcs->remap_hdp_registers(adev);
>
> /* enable the doorbell aperture */
> - soc15_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
> +
> /* HW doorbell routing policy: doorbell writing not
> * in SDMA/IH/MM/ACV range will be routed to CP. So
> * we need to init SDMA doorbell range prior
> @@ -1198,8 +1195,10 @@ static int soc15_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - soc15_enable_doorbell_aperture(adev, false);
> + /* disable the doorbell aperture and selfring doorbell aperture */
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
> +
> if (amdgpu_sriov_vf(adev))
> xgpu_ai_mailbox_put_irq(adev);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c b/drivers/gpu/drm/amd/amdgpu/soc21.c
> index 7d59303ca2f9..21d11b7c510e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc21.c
> +++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
> @@ -450,13 +450,6 @@ static void soc21_program_aspm(struct amdgpu_device *adev)
> adev->nbio.funcs->program_aspm(adev);
> }
>
> -static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
> - bool enable)
> -{
> - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> -}
> -
> const struct amdgpu_ip_block_version soc21_common_ip_block =
> {
> .type = AMD_IP_BLOCK_TYPE_COMMON,
> @@ -764,6 +757,9 @@ static int soc21_common_late_init(void *handle)
> amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0);
> }
>
> + /* enable selfring doorbell aperture */
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> +
> return 0;
> }
>
> @@ -797,7 +793,7 @@ static int soc21_common_hw_init(void *handle)
> if (adev->nbio.funcs->remap_hdp_registers)
> adev->nbio.funcs->remap_hdp_registers(adev);
> /* enable the doorbell aperture */
> - soc21_enable_doorbell_aperture(adev, true);
> + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
>
> return 0;
> }
> @@ -806,8 +802,9 @@ static int soc21_common_hw_fini(void *handle)
> {
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> - /* disable the doorbell aperture */
> - soc21_enable_doorbell_aperture(adev, false);
> + /* disable the doorbell aperture and selfring doorbell aperture */
> + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
>
> if (amdgpu_sriov_vf(adev)) {
> xgpu_nv_mailbox_put_irq(adev);
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
2023-04-25 11:24 ` Christian König
@ 2023-04-25 13:19 ` Xiao, Shane
0 siblings, 0 replies; 5+ messages in thread
From: Xiao, Shane @ 2023-04-25 13:19 UTC (permalink / raw)
To: Koenig, Christian, amd-gfx@lists.freedesktop.org,
Deucher, Alexander, Kuehling, Felix, Zhang, Hawking
Cc: Hou, Xiaomeng (Matthew), Liu, Aaron
[AMD Official Use Only - General]
> -----Original Message-----
> From: Koenig, Christian <Christian.Koenig@amd.com>
> Sent: Tuesday, April 25, 2023 7:24 PM
> To: Xiao, Shane <shane.xiao@amd.com>; amd-gfx@lists.freedesktop.org;
> Deucher, Alexander <Alexander.Deucher@amd.com>; Kuehling, Felix
> <Felix.Kuehling@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>
> Cc: Liu, Aaron <Aaron.Liu@amd.com>; Hou, Xiaomeng (Matthew)
> <Xiaomeng.Hou@amd.com>
> Subject: Re: [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR
>
> Am 25.04.23 um 12:16 schrieb Shane Xiao:
> > [Why]
> > The selfring doorbell aperture will change when resize FB BAR
> > successfully during gmc sw init, we should reorder the sequence of
> > enabling doorbell selfring aperture.
> >
> > [How]
> > Move enable_doorbell_selfring_aperture from *_common_hw_init to
> > *_common_late_init.
> >
> > This fixes the potential issue that GPU ring its own doorbell when
> > this device is in translated mode when iommu is on.
> >
> > v2:
> > 1. Remove *_enable_doorbell_aperture functions
> >
> > Signed-off-by: Shane Xiao <shane.xiao@amd.com>
> > Signed-off-by: Aaron Liu <aaron.liu@amd.com>
> > Tested-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/nv.c | 17 +++++++----------
> > drivers/gpu/drm/amd/amdgpu/soc15.c | 19 +++++++++----------
> > drivers/gpu/drm/amd/amdgpu/soc21.c | 17 +++++++----------
> > 3 files changed, 23 insertions(+), 30 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c
> > b/drivers/gpu/drm/amd/amdgpu/nv.c index dabeeab2f2ad..cb39d556c23d
> > 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/nv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/nv.c
> > @@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device
> > *adev)
> >
> > }
> >
> > -static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
> > - bool enable)
> > -{
> > - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> > - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> > -}
> > -
> > const struct amdgpu_ip_block_version nv_common_ip_block =
> > {
> > .type = AMD_IP_BLOCK_TYPE_COMMON,
> > @@ -999,6 +992,9 @@ static int nv_common_late_init(void *handle)
> > }
> > }
> >
> > + /* enable selfring doorbell aperture */
>
> Documenting *what* you do is usually a bad idea since that should be obvious.
> You need to document *why* you do it.
>
> In other words maybe change the comment to /* Enable this late because
> doorbell BAR location can change during hw_init */.
>
Yes, I will update this comment.
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> > +
> > return 0;
> > }
> >
> > @@ -1038,7 +1034,7 @@ static int nv_common_hw_init(void *handle)
> > if (adev->nbio.funcs->remap_hdp_registers
> && !amdgpu_sriov_vf(adev))
> > adev->nbio.funcs->remap_hdp_registers(adev);
> > /* enable the doorbell aperture */
> > - nv_enable_doorbell_aperture(adev, true);
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
> >
> > return 0;
> > }
> > @@ -1047,8 +1043,9 @@ static int nv_common_hw_fini(void *handle)
> > {
> > struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >
> > - /* disable the doorbell aperture */
> > - nv_enable_doorbell_aperture(adev, false);
> > + /* disable the doorbell aperture and selfring doorbell aperture*/
>
> Same here and all other places as well.
>
Get it. I will update all the comment in the next version.
Best Regards,
Shane
> Apart from that looks good to me,
> Christian.
>
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
> >
> > return 0;
> > }
> > diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c
> > b/drivers/gpu/drm/amd/amdgpu/soc15.c
> > index 4d1487a9836c..2db021f6e8ac 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/soc15.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
> > @@ -619,13 +619,6 @@ static void soc15_program_aspm(struct
> amdgpu_device *adev)
> > adev->nbio.funcs->program_aspm(adev);
> > }
> >
> > -static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
> > - bool enable)
> > -{
> > - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> > - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> > -}
> > -
> > const struct amdgpu_ip_block_version vega10_common_ip_block =
> > {
> > .type = AMD_IP_BLOCK_TYPE_COMMON,
> > @@ -1125,6 +1118,9 @@ static int soc15_common_late_init(void *handle)
> > if (amdgpu_sriov_vf(adev))
> > xgpu_ai_mailbox_get_irq(adev);
> >
> > + /* enable selfring doorbell aperture */
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> > +
> > return 0;
> > }
> >
> > @@ -1182,7 +1178,8 @@ static int soc15_common_hw_init(void *handle)
> > adev->nbio.funcs->remap_hdp_registers(adev);
> >
> > /* enable the doorbell aperture */
> > - soc15_enable_doorbell_aperture(adev, true);
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
> > +
> > /* HW doorbell routing policy: doorbell writing not
> > * in SDMA/IH/MM/ACV range will be routed to CP. So
> > * we need to init SDMA doorbell range prior @@ -1198,8 +1195,10
> @@
> > static int soc15_common_hw_fini(void *handle)
> > {
> > struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >
> > - /* disable the doorbell aperture */
> > - soc15_enable_doorbell_aperture(adev, false);
> > + /* disable the doorbell aperture and selfring doorbell aperture */
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
> > +
> > if (amdgpu_sriov_vf(adev))
> > xgpu_ai_mailbox_put_irq(adev);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c
> > b/drivers/gpu/drm/amd/amdgpu/soc21.c
> > index 7d59303ca2f9..21d11b7c510e 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/soc21.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
> > @@ -450,13 +450,6 @@ static void soc21_program_aspm(struct
> amdgpu_device *adev)
> > adev->nbio.funcs->program_aspm(adev);
> > }
> >
> > -static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
> > - bool enable)
> > -{
> > - adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
> > - adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
> > -}
> > -
> > const struct amdgpu_ip_block_version soc21_common_ip_block =
> > {
> > .type = AMD_IP_BLOCK_TYPE_COMMON,
> > @@ -764,6 +757,9 @@ static int soc21_common_late_init(void *handle)
> > amdgpu_irq_get(adev, &adev-
> >nbio.ras_err_event_athub_irq, 0);
> > }
> >
> > + /* enable selfring doorbell aperture */
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
> > +
> > return 0;
> > }
> >
> > @@ -797,7 +793,7 @@ static int soc21_common_hw_init(void *handle)
> > if (adev->nbio.funcs->remap_hdp_registers)
> > adev->nbio.funcs->remap_hdp_registers(adev);
> > /* enable the doorbell aperture */
> > - soc21_enable_doorbell_aperture(adev, true);
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, true);
> >
> > return 0;
> > }
> > @@ -806,8 +802,9 @@ static int soc21_common_hw_fini(void *handle)
> > {
> > struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >
> > - /* disable the doorbell aperture */
> > - soc21_enable_doorbell_aperture(adev, false);
> > + /* disable the doorbell aperture and selfring doorbell aperture */
> > + adev->nbio.funcs->enable_doorbell_aperture(adev, false);
> > + adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
> >
> > if (amdgpu_sriov_vf(adev)) {
> > xgpu_nv_mailbox_put_irq(adev);
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-25 15:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-25 14:54 [PATCH] drm/amdgpu: Enable doorbell selfring after resize FB BAR Shane Xiao
2023-04-25 15:49 ` Christian König
-- strict thread matches above, loose matches on Subject: below --
2023-04-25 10:16 Shane Xiao
2023-04-25 11:24 ` Christian König
2023-04-25 13:19 ` Xiao, Shane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox