Skip to content

Commit b03f38b

Browse files
AMD-ShaneXiaoalexdeucher
authored andcommitted
drm/amdgpu: Enable doorbell selfring after resize FB BAR
[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> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 4eea7fb commit b03f38b

3 files changed

Lines changed: 41 additions & 30 deletions

File tree

drivers/gpu/drm/amd/amdgpu/nv.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,6 @@ static void nv_program_aspm(struct amdgpu_device *adev)
531531

532532
}
533533

534-
static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
535-
bool enable)
536-
{
537-
adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
538-
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
539-
}
540-
541534
const struct amdgpu_ip_block_version nv_common_ip_block =
542535
{
543536
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -999,6 +992,11 @@ static int nv_common_late_init(void *handle)
999992
}
1000993
}
1001994

995+
/* Enable selfring doorbell aperture late because doorbell BAR
996+
* aperture will change if resize BAR successfully in gmc sw_init.
997+
*/
998+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
999+
10021000
return 0;
10031001
}
10041002

@@ -1038,7 +1036,7 @@ static int nv_common_hw_init(void *handle)
10381036
if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf(adev))
10391037
adev->nbio.funcs->remap_hdp_registers(adev);
10401038
/* enable the doorbell aperture */
1041-
nv_enable_doorbell_aperture(adev, true);
1039+
adev->nbio.funcs->enable_doorbell_aperture(adev, true);
10421040

10431041
return 0;
10441042
}
@@ -1047,8 +1045,13 @@ static int nv_common_hw_fini(void *handle)
10471045
{
10481046
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
10491047

1050-
/* disable the doorbell aperture */
1051-
nv_enable_doorbell_aperture(adev, false);
1048+
/* Disable the doorbell aperture and selfring doorbell aperture
1049+
* separately in hw_fini because nv_enable_doorbell_aperture
1050+
* has been removed and there is no need to delay disabling
1051+
* selfring doorbell.
1052+
*/
1053+
adev->nbio.funcs->enable_doorbell_aperture(adev, false);
1054+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
10521055

10531056
return 0;
10541057
}

drivers/gpu/drm/amd/amdgpu/soc15.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
619619
adev->nbio.funcs->program_aspm(adev);
620620
}
621621

622-
static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
623-
bool enable)
624-
{
625-
adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
626-
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
627-
}
628-
629622
const struct amdgpu_ip_block_version vega10_common_ip_block =
630623
{
631624
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -1125,6 +1118,11 @@ static int soc15_common_late_init(void *handle)
11251118
if (amdgpu_sriov_vf(adev))
11261119
xgpu_ai_mailbox_get_irq(adev);
11271120

1121+
/* Enable selfring doorbell aperture late because doorbell BAR
1122+
* aperture will change if resize BAR successfully in gmc sw_init.
1123+
*/
1124+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
1125+
11281126
return 0;
11291127
}
11301128

@@ -1182,7 +1180,8 @@ static int soc15_common_hw_init(void *handle)
11821180
adev->nbio.funcs->remap_hdp_registers(adev);
11831181

11841182
/* enable the doorbell aperture */
1185-
soc15_enable_doorbell_aperture(adev, true);
1183+
adev->nbio.funcs->enable_doorbell_aperture(adev, true);
1184+
11861185
/* HW doorbell routing policy: doorbell writing not
11871186
* in SDMA/IH/MM/ACV range will be routed to CP. So
11881187
* we need to init SDMA doorbell range prior
@@ -1198,8 +1197,14 @@ static int soc15_common_hw_fini(void *handle)
11981197
{
11991198
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
12001199

1201-
/* disable the doorbell aperture */
1202-
soc15_enable_doorbell_aperture(adev, false);
1200+
/* Disable the doorbell aperture and selfring doorbell aperture
1201+
* separately in hw_fini because soc15_enable_doorbell_aperture
1202+
* has been removed and there is no need to delay disabling
1203+
* selfring doorbell.
1204+
*/
1205+
adev->nbio.funcs->enable_doorbell_aperture(adev, false);
1206+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
1207+
12031208
if (amdgpu_sriov_vf(adev))
12041209
xgpu_ai_mailbox_put_irq(adev);
12051210

drivers/gpu/drm/amd/amdgpu/soc21.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,6 @@ static void soc21_program_aspm(struct amdgpu_device *adev)
450450
adev->nbio.funcs->program_aspm(adev);
451451
}
452452

453-
static void soc21_enable_doorbell_aperture(struct amdgpu_device *adev,
454-
bool enable)
455-
{
456-
adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
457-
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
458-
}
459-
460453
const struct amdgpu_ip_block_version soc21_common_ip_block =
461454
{
462455
.type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -764,6 +757,11 @@ static int soc21_common_late_init(void *handle)
764757
amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0);
765758
}
766759

760+
/* Enable selfring doorbell aperture late because doorbell BAR
761+
* aperture will change if resize BAR successfully in gmc sw_init.
762+
*/
763+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
764+
767765
return 0;
768766
}
769767

@@ -797,7 +795,7 @@ static int soc21_common_hw_init(void *handle)
797795
if (adev->nbio.funcs->remap_hdp_registers)
798796
adev->nbio.funcs->remap_hdp_registers(adev);
799797
/* enable the doorbell aperture */
800-
soc21_enable_doorbell_aperture(adev, true);
798+
adev->nbio.funcs->enable_doorbell_aperture(adev, true);
801799

802800
return 0;
803801
}
@@ -806,8 +804,13 @@ static int soc21_common_hw_fini(void *handle)
806804
{
807805
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
808806

809-
/* disable the doorbell aperture */
810-
soc21_enable_doorbell_aperture(adev, false);
807+
/* Disable the doorbell aperture and selfring doorbell aperture
808+
* separately in hw_fini because soc21_enable_doorbell_aperture
809+
* has been removed and there is no need to delay disabling
810+
* selfring doorbell.
811+
*/
812+
adev->nbio.funcs->enable_doorbell_aperture(adev, false);
813+
adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
811814

812815
if (amdgpu_sriov_vf(adev)) {
813816
xgpu_nv_mailbox_put_irq(adev);

0 commit comments

Comments
 (0)