drm/amdgpu: Fix MMIO HDP flush on SRIOV
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: Fix MMIO HDP flush on SRIOV
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
--- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4 -0
@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CONFIG_CNTL, data); + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }#define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000 // off by default, no gains over L1
drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4 -0
@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CI_CNTL, data); + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void nbio_v6_1_program_ltr (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3 -1
@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = {static void nbio_v7_0_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset = +SOC15_REG_OFFSET (NBIO ,0 , mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {
drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4 -0
@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE_PORT (SOC15_REG_OFFSET (NBIO ,0 , regPCIE_CONFIG_CNTL), data); } + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_2_funcs = {
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3 -1
@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = {static void nbio_v7_4_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void nbio_v7_4_handle_ras_controller_intr_no_bifring (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/nv.c +5 -3
@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &nv_pcie_rreg;
@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +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);
drivers/gpu/drm/amd/amdgpu/soc15.c +5 -3
@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &soc15_pcie_rreg;
@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers (adev);/* enable the doorbell aperture */
Signature · 1 line
2.32.0
Quoted 19 lines · Felix Kuehling
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct amdgpu_device *adev) · line 365
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CONFIG_CNTL, data); + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ;
Wouldn't it be better to do this assignment inside remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.
Thanks,
Lijo
Quoted 116 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0}#define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000 // off by default, no gains over L1drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CI_CNTL, data); + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void nbio_v6_1_program_ltr (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = {static void nbio_v7_0_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset = +SOC15_REG_OFFSET (NBIO ,0 , mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE_PORT (SOC15_REG_OFFSET (NBIO ,0 , regPCIE_CONFIG_CNTL), data); } + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_2_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = {static void nbio_v7_4_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void nbio_v7_4_handle_ras_controller_intr_no_bifring (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +5
-3@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &nv_pcie_rreg;@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +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);drivers/gpu/drm/amd/amdgpu/soc15.c +5
-3@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &soc15_pcie_rreg;@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers (adev);/* enable the doorbell aperture */
Am 2021-11-10 um 4:14 a.m. schrieb Lazar, Lijo:
Quoted 26 lines · Felix Kuehling
Quoted 23 lines
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>---
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CONFIG_CNTL, data);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct amdgpu_device *adev) · line 365
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0+ + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2;Wouldn't it be better to do this assignment inside
remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.
I was considering that. I felt it was clearer not to have that hidden side effect in remap_hdp_registers and to have the explicit condition (... && !amdgpu_sriov_vf(adev)) around the remap_hdp_registers call in soc15/nv_common_hw_init.
Regards,
Felix
Quoted 130 lines
Thanks,
LijoQuoted 126 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0} #define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000// off by default, no gains over L1 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CI_CNTL, data); + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; } static void nbio_v6_1_program_ltr(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { static void nbio_v7_0_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = + SOC15_REG_OFFSET(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regPCIE_CONFIG_CNTL), data); } + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }const struct
amdgpu_nbio_funcsnbio_v7_2_funcs= {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = { static void nbio_v7_4_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }static void
nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +4
-1@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&nv_pcie_rreg;drivers/gpu/drm/amd/amdgpu/nv.c +1
-1@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + 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);drivers/gpu/drm/amd/amdgpu/soc15.c +4
-1@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&soc15_pcie_rreg;drivers/gpu/drm/amd/amdgpu/soc15.c +1
-1@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers(adev); /* enable the doorbell aperture */
[Public]
Quoted 1 line
(... && !amdgpu_sriov_vf(adev))
This kind of closes the door for all versions. My thought was - having it in the same function provides a logical grouping for how it's handled for different cases - VF vs non-VF - for a particular IP version.
Thanks,
Lijo
________________________________
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, November 10, 2021 9:27:22 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Zhang, Bokun <[email protected]>
Subject: Re: [PATCH v2 1/1] drm/amdgpu: Fix MMIO HDP flush on SRIOV
Am 2021-11-10 um 4:14 a.m. schrieb Lazar, Lijo:
Quoted 26 lines · Felix Kuehling
Quoted 23 lines
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CONFIG_CNTL, data);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct amdgpu_device *adev) · line 365
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0+ +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ;Wouldn't it be better to do this assignment inside
remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.
I was considering that. I felt it was clearer not to have that hidden side effect in remap_hdp_registers and to have the explicit condition (... && !amdgpu_sriov_vf(adev)) around the remap_hdp_registers call in soc15/nv_common_hw_init.
Regards,
Felix
Quoted 130 lines
Thanks,
LijoQuoted 126 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0}#define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000// off by default, no gains over L1 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE (smnPCIE_CI_CNTL, data); + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void nbio_v6_1_program_ltr (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = {static void nbio_v7_0_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset = +SOC15_REG_OFFSET (NBIO ,0 , mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev)if (def != data)WREG32_PCIE_PORT (SOC15_REG_OFFSET (NBIO ,0 , regPCIE_CONFIG_CNTL), data); } + +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }const struct amdgpu_nbio_funcs nbio_v7_2_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = {static void nbio_v7_4_init_registers (struct amdgpu_device *adev) { - +if (amdgpu_sriov_vf (adev)) + adev->rmmio_remap.reg_offset =SOC15_REG_OFFSET (NBIO ,0 , + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } static void
nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +5
-2@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &nv_pcie_rreg;@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +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);drivers/gpu/drm/amd/amdgpu/soc15.c +5
-2@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle)#define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; +if (!amdgpu_sriov_vf (adev)) { + adev->rmmio_remap.reg_offset =MMIO_REG_HOLE_OFFSET ; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg =NULL ; adev->smc_wreg =NULL ; adev->pcie_rreg = &soc15_pcie_rreg;@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ -if (adev->nbio.funcs->remap_hdp_registers) +if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers (adev);/* enable the doorbell aperture */
Am 2021-11-10 um 11:11 a.m. schrieb Lazar, Lijo:
Quoted 9 lines
[Public]
Quoted 1 line
(... && !amdgpu_sriov_vf(adev))
This kind of closes the door for all versions. My thought was - having it in the same function provides a logical grouping for how it's handled for different cases - VF vs non-VF - for a particular IP version.
Except that's not really true. There is still common code (setting adev->rmmio_remap.bus_addr) for handling MMIO remapping on VFs in soc15.c and nv.c. I'm not comfortable with duplicating all of that across all the IP version-specific files.
I also think it's very unlikely that a small IP version bump is going to change this logic. So I'd rather prefer to keep the code more general and conservatively correct.
Regards,
Felix
Quoted 186 lines
Thanks,
Lijo
------------------------------------------------------------------------
*From:* Kuehling, Felix <[email protected]>
*Sent:* Wednesday, November 10, 2021 9:27:22 PM
*To:* Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
*Cc:* Zhang, Bokun <[email protected]>
*Subject:* Re: [PATCH v2 1/1] drm/amdgpu: Fix MMIO HDP flush on SRIOV
Am 2021-11-10 um 4:14 a.m. schrieb Lazar, Lijo:Quoted 26 lines · Felix Kuehling
Quoted 23 lines
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>---
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CONFIG_CNTL, data);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct amdgpu_device *adev) · line 365
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0+ + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2;Wouldn't it be better to do this assignment inside
remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.I was considering that. I felt it was clearer not to have that hidden side effect in
remap_hdp_registersand to have the explicit condition (... && !amdgpu_sriov_vf(adev)) around theremap_hdp_registerscall in soc15/nv_common_hw_init.Regards,
FelixQuoted 130 lines
Thanks,
LijoQuoted 126 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0} #define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000// off by default, no gains over L1 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CI_CNTL, data); + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; } static void nbio_v6_1_program_ltr(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { static void nbio_v7_0_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = + SOC15_REG_OFFSET(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regPCIE_CONFIG_CNTL), data); } + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }const struct
amdgpu_nbio_funcsnbio_v7_2_funcs= {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = { static void nbio_v7_4_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }static void
nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +4
-1@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&nv_pcie_rreg;drivers/gpu/drm/amd/amdgpu/nv.c +1
-1@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + 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);drivers/gpu/drm/amd/amdgpu/soc15.c +4
-1@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&soc15_pcie_rreg;drivers/gpu/drm/amd/amdgpu/soc15.c +1
-1@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers(adev); /* enable the doorbell aperture */
Quoted 8 lines · Felix Kuehling
Am 2021-11-10 um 11:11 a.m. schrieb Lazar, Lijo:
Quoted 7 lines
[Public]
Quoted 1 line
(... && !amdgpu_sriov_vf(adev))
This kind of closes the door for all versions. My thought was - having it in the same function provides a logical grouping for how it's handled for different cases - VF vs non-VF - for a particular IP version.
Quoted 8 lines
Except that's not really true. There is still common code (setting
adev->rmmio_remap.bus_addr) for handling MMIO remapping on VFs insoc15.candnv.c. I'm not comfortable with duplicating all of that across all the IP version-specific files.I also think it's very unlikely that a small IP version bump is going to change this logic. So I'd rather prefer to keep the code more general and conservatively correct.
Hi Lijo,
The virtualization team has finished testing this patch and wants me to submit it. Do you insist I rework the patch to move all the adev->rmmio_remap fixups for virtualization into the nbio version-specific remap_hdp_registers functions?
Regards,
Felix
Quoted 185 lines
Regards,
FelixQuoted 180 lines
Thanks,
Lijo
------------------------------------------------------------------------
*From:* Kuehling, Felix <[email protected]>
*Sent:* Wednesday, November 10, 2021 9:27:22 PM
*To:* Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
*Cc:* Zhang, Bokun <[email protected]>
*Subject:* Re: [PATCH v2 1/1] drm/amdgpu: Fix MMIO HDP flush on SRIOVAm 2021-11-10 um 4:14 a.m. schrieb Lazar, Lijo:
Quoted 15 lines · Felix Kuehling
Quoted 14 lines
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct · line 365
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CONFIG_CNTL, data); + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2;Wouldn't it be better to do this assignment inside
remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.I was considering that. I felt it was clearer not to have that hidden side effect in
remap_hdp_registersand to have the explicit condition (... && !amdgpu_sriov_vf(adev)) around theremap_hdp_registerscall in soc15/nv_common_hw_init.Regards,
FelixQuoted 129 lines
Thanks,
LijoQuoted 126 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0} #define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000// off by default, no gains over L1 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CI_CNTL, data); + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; } static void nbio_v6_1_program_ltr(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { static void nbio_v7_0_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = + SOC15_REG_OFFSET(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regPCIE_CONFIG_CNTL), data); } + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }const struct
amdgpu_nbio_funcsnbio_v7_2_funcs= {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = { static void nbio_v7_4_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; } static void
nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +5
-2@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL; adev->smc_wreg = NULL; adev->pcie_rreg = &nv_pcie_rreg;@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + 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);drivers/gpu/drm/amd/amdgpu/soc15.c +5
-2@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL; adev->smc_wreg = NULL; adev->pcie_rreg = &soc15_pcie_rreg;@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers(adev); /* enable the doorbell aperture */
Lazar, Lijo
Reviewed-byQuoted 14 lines · Felix Kuehling
Quoted 13 lines · Felix Kuehling
Am 2021-11-10 um 11:11 a.m. schrieb Lazar, Lijo:
Quoted 7 lines
[Public]
Quoted 1 line
(... && !amdgpu_sriov_vf(adev))
This kind of closes the door for all versions. My thought was - having it in the same function provides a logical grouping for how it's handled for different cases - VF vs non-VF - for a particular IP version.
Except that's not really true. There is still common code (setting
adev->rmmio_remap.bus_addr) for handling MMIO remapping on VFs insoc15.candnv.c. I'm not comfortable with duplicating all of that across all the IP version-specific files.
Quoted 8 lines
Quoted 3 lines
I also think it's very unlikely that a small IP version bump is going to change this logic. So I'd rather prefer to keep the code more general and conservatively correct.
Hi Lijo,
The virtualization team has finished testing this patch and wants me to submit it. Do you insist I rework the patch to move all the
adev->rmmio_remapfixups for virtualization into the nbio version-specificremap_hdp_registersfunctions?
Not required, it's fine -
Thanks,
Lijo
Quoted 191 lines
Regards,
FelixQuoted 187 lines
Regards,
FelixQuoted 182 lines
Thanks,
Lijo
------------------------------------------------------------------------
*From:* Kuehling, Felix <[email protected]>
*Sent:* Wednesday, November 10, 2021 9:27:22 PM
*To:* Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
*Cc:* Zhang, Bokun <[email protected]>
*Subject:* Re: [PATCH v2 1/1] drm/amdgpu: Fix MMIO HDP flush on SRIOV Am 2021-11-10 um 4:14 a.m. schrieb Lazar, Lijo:Quoted 24 lines · Felix Kuehling
Quoted 23 lines
Disable HDP register remapping on SRIOV and set rmmio_remap.reg_offset to the fixed address of the VF register for hdp_v*_flush_hdp.
Signed-off-by Felix Kuehling <[email protected]>---
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/nbio_v7_0.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/nv.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 8 +++++--- 7 files changed, 28 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0@@ -359,6 +359,10 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CONFIG_CNTL, data);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_init_registers(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +4
-0+ + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ;Wouldn't it be better to do this assignment inside
remap_hdp_registers()? Return with a comment saying no remap is done for VFs. That looks easier to manage per IP version.I was considering that. I felt it was clearer not to have that hidden side effect in
remap_hdp_registersand to have the explicit condition (... && !amdgpu_sriov_vf(adev)) around theremap_hdp_registerscall in soc15/nv_common_hw_init.Regards,
FelixQuoted 131 lines
Thanks,
LijoQuoted 128 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0
-0} #define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000// off by default, no gains over L1
drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +4
-0@@ -276,6 +276,10 @@ static void nbio_v6_1_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE(smnPCIE_CI_CNTL, data); + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } static void nbio_v6_1_program_ltr(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +3
-1@@ -273,7 +273,9 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { static void nbio_v7_0_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = + SOC15_REG_OFFSET(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; } const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c +4
-0@@ -371,6 +371,10 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev) if (def != data) WREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regPCIE_CONFIG_CNTL), data); } + + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2; }const struct
amdgpu_nbio_funcsnbio_v7_2_funcs= {drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +3
-1@@ -362,7 +362,9 @@ const struct nbio_hdp_flush_reg nbio_v7_4_hdp_flush_reg_ald = { static void nbio_v7_4_init_registers(struct amdgpu_device *adev) { - + if (amdgpu_sriov_vf(adev)) + adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0, + mmBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL) <<2 ; }static void
nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/nv.c +4
-1@@ -730,8 +730,10 @@ static int nv_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&nv_pcie_rreg;drivers/gpu/drm/amd/amdgpu/nv.c +1
-1@@ -1031,7 +1033,7 @@ static int nv_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + 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);drivers/gpu/drm/amd/amdgpu/soc15.c +4
-1@@ -971,8 +971,10 @@ static int soc15_common_early_init(void *handle) #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; - adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + if (!amdgpu_sriov_vf(adev)) { + adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; + adev->rmmio_remap.bus_addr = adev->rmmio_base +MMIO_REG_HOLE_OFFSET ; + } adev->smc_rreg = NULL;
adev->smc_wreg= NULL;
adev->pcie_rreg=&soc15_pcie_rreg;drivers/gpu/drm/amd/amdgpu/soc15.c +1
-1@@ -1285,7 +1287,7 @@ static int soc15_common_hw_init(void *handle)* for the purpose of expose those registers * to process space */ - if (adev->nbio.funcs->remap_hdp_registers) + if (adev->nbio.funcs->remap_hdp_registers && !amdgpu_sriov_vf (adev)) adev->nbio.funcs->remap_hdp_registers(adev); /* enable the doorbell aperture */