Skip to contentSkip to conversation

drm/amdgpu: add CHIP_IP_DISCOVERY support for virtualization

PATCH In review Horace Chen 2 participants 14 messages Jul 21, 2022 – Jul 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/amdgpu: add CHIP_IP_DISCOVERY support for virtualization

For further chips we will use CHIP_IP_DISCOVERY, so add this support for virtualization

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -0
index 7d7044e9de2f..ab55602ff534 100644
@@ -705,6 +705,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
 	case CHIP_SIENNA_CICHLID:
 	case CHIP_ARCTURUS:
 	case CHIP_ALDEBARAN:
+	case CHIP_IP_DISCOVERY:
 		reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
 		break;
 	default: /* other chip doesn't support SRIOV */
@@ -748,6 +749,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
 		case CHIP_NAVI10:
 		case CHIP_NAVI12:
 		case CHIP_SIENNA_CICHLID:
+		case CHIP_IP_DISCOVERY:
 			nv_set_virt_ops(adev);
 			/* try send GPU_INIT_DATA request to host */
 			amdgpu_virt_request_init_data(adev);
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/6 drm/amdgpu: add sriov nbio callback structure

[Why]
under SR-IOV, the nbio doorbell range will be defined by PF. So VF nbio doorbell range registers will be blocked. It will cause violation if VF access those registers directly.

[How]
create an nbio_v4_3_sriov_funcs for sriov nbio_v4_3 initialization to skip the setting for the doorbell range registers.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |  5 ++-
 drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c        | 44 +++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/nbio_v4_3.h        |  1 +
 3 files changed, 49 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -1
index 242d1847c4aa..f559fda2811f 100644
@@ -2232,7 +2232,10 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
 		break;
 	case IP_VERSION(4, 3, 0):
 	case IP_VERSION(4, 3, 1):
-		adev->nbio.funcs = &nbio_v4_3_funcs;
+		if (amdgpu_sriov_vf(adev))
+			adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
+		else
+			adev->nbio.funcs = &nbio_v4_3_funcs;
 		adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
 		break;
 	case IP_VERSION(7, 7, 0):
drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c +44 -0

47 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/nbio_v4_3.h +1 -0
index ade43661d7a9..711999ceedf4 100644
@@ -28,5 +28,6 @@
 
 extern const struct nbio_hdp_flush_reg nbio_v4_3_hdp_flush_reg;
 extern const struct amdgpu_nbio_funcs nbio_v4_3_funcs;
+extern const struct amdgpu_nbio_funcs nbio_v4_3_sriov_funcs;
 
 #endif
Signature · 1 line
2.25.1
Reviewed-by on v1 2/6
#2 lore raw

Re: [PATCH 2/6] drm/amdgpu: add sriov nbio callback structure

Quoted 11 lines · Horace Chen

[Why]
under SR-IOV, the nbio doorbell range will be defined by PF. So VF nbio doorbell range registers will be blocked. It will cause violation if VF access those registers directly.

[How]
create an nbio_v4_3_sriov_funcs for sriov nbio_v4_3 initialization to skip the setting for the doorbell range registers.

Quoted 88 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |  5 ++-
 drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c        | 44 +++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/nbio_v4_3.h        |  1 +
 3 files changed, 49 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -1
index 242d1847c4aa..f559fda2811f 100644
@@ -2232,7 +2232,10 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
                break;
        case IP_VERSION(4, 3, 0):
        case IP_VERSION(4, 3, 1):
-               adev->nbio.funcs = &nbio_v4_3_funcs;
+               if (amdgpu_sriov_vf(adev))
+                       adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
+               else
+                       adev->nbio.funcs = &nbio_v4_3_funcs;
                adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
                break;
        case IP_VERSION(7, 7, 0):
drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c +44 -0
index 982a89f841d5..15eb3658d70e 100644
@@ -488,3 +488,47 @@ const struct amdgpu_nbio_funcs nbio_v4_3_funcs = {
        .get_rom_offset = nbio_v4_3_get_rom_offset,
        .program_aspm = nbio_v4_3_program_aspm,
 };
+
+
+static void nbio_v4_3_sriov_ih_doorbell_range(struct amdgpu_device *adev,
+                                       bool use_doorbell, int doorbell_index)
+{
+}
+
+static void nbio_v4_3_sriov_sdma_doorbell_range(struct amdgpu_device *adev, int instance,
+                                         bool use_doorbell, int doorbell_index,
+                                         int doorbell_size)
+{
+}
+
+static void nbio_v4_3_sriov_vcn_doorbell_range(struct amdgpu_device *adev, bool use_doorbell,
+                                        int doorbell_index, int instance)
+{
+}
+
+static void nbio_v4_3_sriov_gc_doorbell_init(struct amdgpu_device *adev)
+{
+}
+
+const struct amdgpu_nbio_funcs nbio_v4_3_sriov_funcs = {
+       .get_hdp_flush_req_offset = nbio_v4_3_get_hdp_flush_req_offset,
+       .get_hdp_flush_done_offset = nbio_v4_3_get_hdp_flush_done_offset,
+       .get_pcie_index_offset = nbio_v4_3_get_pcie_index_offset,
+       .get_pcie_data_offset = nbio_v4_3_get_pcie_data_offset,
+       .get_rev_id = nbio_v4_3_get_rev_id,
+       .mc_access_enable = nbio_v4_3_mc_access_enable,
+       .get_memsize = nbio_v4_3_get_memsize,
+       .sdma_doorbell_range = nbio_v4_3_sriov_sdma_doorbell_range,
+       .vcn_doorbell_range = nbio_v4_3_sriov_vcn_doorbell_range,
+       .gc_doorbell_init = nbio_v4_3_sriov_gc_doorbell_init,
+       .enable_doorbell_aperture = nbio_v4_3_enable_doorbell_aperture,
+       .enable_doorbell_selfring_aperture = nbio_v4_3_enable_doorbell_selfring_aperture,
+       .ih_doorbell_range = nbio_v4_3_sriov_ih_doorbell_range,
+       .update_medium_grain_clock_gating = nbio_v4_3_update_medium_grain_clock_gating,
+       .update_medium_grain_light_sleep = nbio_v4_3_update_medium_grain_light_sleep,
+       .get_clockgating_state = nbio_v4_3_get_clockgating_state,
+       .ih_control = nbio_v4_3_ih_control,
+       .init_registers = nbio_v4_3_init_registers,
+       .remap_hdp_registers = nbio_v4_3_remap_hdp_registers,
+       .get_rom_offset = nbio_v4_3_get_rom_offset,
+};
drivers/gpu/drm/amd/amdgpu/nbio_v4_3.h +1 -1
index ade43661d7a9..711999ceedf4 100644
@@ -28,5 +28,6 @@
 
 extern const struct nbio_hdp_flush_reg nbio_v4_3_hdp_flush_reg;
 extern const struct amdgpu_nbio_funcs nbio_v4_3_funcs;
+extern const struct amdgpu_nbio_funcs nbio_v4_3_sriov_funcs;
 
 #endif
--

2.25.1

#3 lore raw

PATCH 3/6 drm/amdgpu: add a compute pipe reset for SR-IOV

In reply to Horace Chen

[Why]
Under SR-IOV, we are not sure whether pipe status is good or not when doing initialization. The compute engine maybe fail to bringup if pipe status is bad.

[How]
For SR-IOV, disable the compute engine to do a pipe reset before we do initialization.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -1
index 0d8193b30fc5..b8f197a5ee84 100644
@@ -4586,8 +4586,12 @@ static int gfx_v11_0_hw_init(void *handle)
 		DRM_WARN("Invalid gb_addr_config !\n");
 
 	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP &&
-	    adev->gfx.rs64_enable)
+	    adev->gfx.rs64_enable) {
+		if (amdgpu_sriov_vf(adev))
+			gfx_v11_0_cp_compute_enable(adev, false);
+
 		gfx_v11_0_config_gfx_rs64(adev);
+	}
 
 	r = gfx_v11_0_gfxhub_enable(adev);
 	if (r)
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH 3/6] drm/amdgpu: add a compute pipe reset for SR-IOV

Quoted 5 lines · Horace Chen

[Why]
Under SR-IOV, we are not sure whether pipe status is good or not when doing initialization. The compute engine maybe fail to bringup if pipe status is bad.

Seems like this should be safe for bare metal too. Can we just do this for both to simplify the code?

Alex

Quoted 31 lines

[How]
For SR-IOV, disable the compute engine to do a pipe reset before we do initialization.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -2
index 0d8193b30fc5..b8f197a5ee84 100644
@@ -4586,8 +4586,12 @@ static int gfx_v11_0_hw_init(void *handle)
                DRM_WARN("Invalid gb_addr_config !\n");
 
        if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP &&
-           adev->gfx.rs64_enable)
+           adev->gfx.rs64_enable) {
+               if (amdgpu_sriov_vf(adev))
+                       gfx_v11_0_cp_compute_enable(adev, false);
+
                gfx_v11_0_config_gfx_rs64(adev);
+       }
 
        r = gfx_v11_0_gfxhub_enable(adev);
        if (r)
--

2.25.1

#5 lore raw

PATCH 4/6 drm/amdgpu: enable WPTR_POLL_ENABLE for sriov on sdma_v6_0

In reply to Horace Chen

[Why]
Under SR-IOV, if VF is switched out then its doorbell will be disabled, SDMA rely on WPTR_POLL to get doorbells which was sent during VF switched-out time.

[How]
For SR-IOV, set SDMA WPTR_POLL_ENABLE to 1.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +4 -1
index 0200cb3a31a4..23b01b121492 100644
@@ -593,7 +593,10 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
 		       lower_32_bits(ring->rptr_gpu_addr) & 0xFFFFFFFC);
 
 		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, RPTR_WRITEBACK_ENABLE, 1);
-		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 0);
+		if (amdgpu_sriov_vf(adev))
+			rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 1);
+		else
+			rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 0);
 		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, F32_WPTR_POLL_ENABLE, 1);
 
 		WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_RB_BASE), ring->gpu_addr >> 8);
Signature · 1 line
2.25.1
Reviewed-by on v1 4/6
#6 lore raw

Re: [PATCH 4/6] drm/amdgpu: enable WPTR_POLL_ENABLE for sriov on sdma_v6_0

Quoted 10 lines · Horace Chen

[Why]
Under SR-IOV, if VF is switched out then its doorbell will be disabled, SDMA rely on WPTR_POLL to get doorbells which was sent during VF switched-out time.

[How]
For SR-IOV, set SDMA WPTR_POLL_ENABLE to 1.

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +4 -2
index 0200cb3a31a4..23b01b121492 100644
@@ -593,7 +593,10 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
                       lower_32_bits(ring->rptr_gpu_addr) & 0xFFFFFFFC);
 
                rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, RPTR_WRITEBACK_ENABLE, 1);
-               rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 0);
+               if (amdgpu_sriov_vf(adev))
+                       rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 1);
+               else
+                       rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, WPTR_POLL_ENABLE, 0);
                rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, F32_WPTR_POLL_ENABLE, 1);
 
                WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_RB_BASE), ring->gpu_addr >> 8);
--

2.25.1

#7 lore raw

PATCH 5/6 drm/amdgpu: refine virtualization psp fw skip check

In reply to Horace Chen

SR-IOV may need to load different firmwares for different ASIC inside VF.
So create a new function in amdgpu_virt to check whether FW load needs to be skipped.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c  | 17 +++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 29 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 ++
 3 files changed, 34 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -14
index 6540582ecbf8..a601d0f67b1f 100644
@@ -334,11 +334,12 @@ static int psp_init_sriov_microcode(struct psp_context *psp)
 		ret = psp_init_cap_microcode(psp, "aldebaran");
 		ret &= psp_init_ta_microcode(psp, "aldebaran");
 		break;
+	case IP_VERSION(13, 0, 0):
+		break;
 	default:
 		BUG();
 		break;
 	}
-
 	return ret;
 }
 
@@ -2389,19 +2390,7 @@ static bool fw_load_skip_check(struct psp_context *psp,
 		return true;
 
 	if (amdgpu_sriov_vf(psp->adev) &&
-	   (ucode->ucode_id == AMDGPU_UCODE_ID_SDMA0
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA1
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA2
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA3
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA4
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA5
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA6
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA7
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
-	    || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
+	    amdgpu_virt_fw_load_skip_check(psp->adev, ucode->ucode_id))
 		/*skip ucode loading in SRIOV VF */
 		return true;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +29 -0
index ab55602ff534..ba367799d087 100644
@@ -807,6 +807,35 @@ enum amdgpu_sriov_vf_mode amdgpu_virt_get_sriov_vf_mode(struct amdgpu_device *ad
 	return mode;
 }
 
+bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev, uint32_t ucode_id)
+{
+	/* this version doesn't support sriov autoload */
+	if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(13, 0, 0)) {
+		if (ucode_id == AMDGPU_UCODE_ID_VCN1 ||
+		    ucode_id == AMDGPU_UCODE_ID_VCN)
+			return false;
+		else
+			return true;
+	}
+
+	if (ucode_id == AMDGPU_UCODE_ID_SDMA0
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA1
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA2
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA3
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA4
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA5
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA6
+	    || ucode_id == AMDGPU_UCODE_ID_SDMA7
+	    || ucode_id == AMDGPU_UCODE_ID_RLC_G
+	    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
+	    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
+	    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+	    || ucode_id == AMDGPU_UCODE_ID_SMC)
+		return true;
+
+	return false;
+}
+
 void amdgpu_virt_update_sriov_video_codec(struct amdgpu_device *adev,
 			struct amdgpu_video_codec_info *encode, uint32_t encode_array_size,
 			struct amdgpu_video_codec_info *decode, uint32_t decode_array_size)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
index 239f232f9c02..cd6fce05978f 100644
@@ -343,4 +343,6 @@ void amdgpu_sriov_wreg(struct amdgpu_device *adev,
 		       u32 acc_flags, u32 hwip);
 u32 amdgpu_sriov_rreg(struct amdgpu_device *adev,
 		      u32 offset, u32 acc_flags, u32 hwip);
+bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev,
+			uint32_t ucode_id);
 #endif
Signature · 1 line
2.25.1
Acked-by on v1 5/6
#8 lore raw

Re: [PATCH 5/6] drm/amdgpu: refine virtualization psp fw skip check

Quoted 7 lines · Horace Chen

SR-IOV may need to load different firmwares for different ASIC inside VF.
So create a new function in amdgpu_virt to check whether FW load needs to be skipped.

Quoted 99 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c  | 17 +++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 29 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 ++
 3 files changed, 34 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -14
index 6540582ecbf8..a601d0f67b1f 100644
@@ -334,11 +334,12 @@ static int psp_init_sriov_microcode(struct psp_context *psp)
                ret = psp_init_cap_microcode(psp, "aldebaran");
                ret &= psp_init_ta_microcode(psp, "aldebaran");
                break;
+       case IP_VERSION(13, 0, 0):
+               break;
        default:
                BUG();
                break;
        }
-
        return ret;
 }
 
@@ -2389,19 +2390,7 @@ static bool fw_load_skip_check(struct psp_context *psp,
                return true;
 
        if (amdgpu_sriov_vf(psp->adev) &&
-          (ucode->ucode_id == AMDGPU_UCODE_ID_SDMA0
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA1
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA2
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA3
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA4
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA5
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA6
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA7
-           || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G
-           || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
-           || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
-           || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
-           || ucode->ucode_id == AMDGPU_UCODE_ID_SMC))
+           amdgpu_virt_fw_load_skip_check(psp->adev, ucode->ucode_id))
                /*skip ucode loading in SRIOV VF */
                return true;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +29 -0
index ab55602ff534..ba367799d087 100644
@@ -807,6 +807,35 @@ enum amdgpu_sriov_vf_mode amdgpu_virt_get_sriov_vf_mode(struct amdgpu_device *ad
        return mode;
 }
 
+bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev, uint32_t ucode_id)
+{
+       /* this version doesn't support sriov autoload */
+       if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(13, 0, 0)) {
+               if (ucode_id == AMDGPU_UCODE_ID_VCN1 ||
+                   ucode_id == AMDGPU_UCODE_ID_VCN)
+                       return false;
+               else
+                       return true;
+       }
+
+       if (ucode_id == AMDGPU_UCODE_ID_SDMA0
+           || ucode_id == AMDGPU_UCODE_ID_SDMA1
+           || ucode_id == AMDGPU_UCODE_ID_SDMA2
+           || ucode_id == AMDGPU_UCODE_ID_SDMA3
+           || ucode_id == AMDGPU_UCODE_ID_SDMA4
+           || ucode_id == AMDGPU_UCODE_ID_SDMA5
+           || ucode_id == AMDGPU_UCODE_ID_SDMA6
+           || ucode_id == AMDGPU_UCODE_ID_SDMA7
+           || ucode_id == AMDGPU_UCODE_ID_RLC_G
+           || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
+           || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
+           || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+           || ucode_id == AMDGPU_UCODE_ID_SMC)
+               return true;
+
+       return false;
+}
+
 void amdgpu_virt_update_sriov_video_codec(struct amdgpu_device *adev,
                        struct amdgpu_video_codec_info *encode, uint32_t encode_array_size,
                        struct amdgpu_video_codec_info *decode, uint32_t decode_array_size)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -1
index 239f232f9c02..cd6fce05978f 100644
@@ -343,4 +343,6 @@ void amdgpu_sriov_wreg(struct amdgpu_device *adev,
                       u32 acc_flags, u32 hwip);
 u32 amdgpu_sriov_rreg(struct amdgpu_device *adev,
                      u32 offset, u32 acc_flags, u32 hwip);
+bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev,
+                       uint32_t ucode_id);
 #endif
--

2.25.1

#9 lore raw

PATCH 6/6 drm/amdgpu: sriov remove vcn_4_0 and jpeg_4_0

In reply to Horace Chen

SRIOV needs to initialize mmsch instead of multimedia engines directly. So currently remove them for SR-IOV until the code and firmwares are ready.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -2
index f559fda2811f..3f7e1d683df3 100644
@@ -1900,8 +1900,10 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
 		case IP_VERSION(4, 0, 0):
 		case IP_VERSION(4, 0, 2):
 		case IP_VERSION(4, 0, 4):
-			amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
-			amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
+			if (!amdgpu_sriov_vf(adev)) {
+				amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
+				amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
+			}
 			break;
 		default:
 			dev_err(adev->dev,
Signature · 1 line
2.25.1
Reviewed-by on v1 6/6
#10 lore raw

Re: [PATCH 6/6] drm/amdgpu: sriov remove vcn_4_0 and jpeg_4_0

Quoted 6 lines · Horace Chen

SRIOV needs to initialize mmsch instead of multimedia engines directly. So currently remove them for SR-IOV until the code and firmwares are ready.

Quoted 24 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -3
index f559fda2811f..3f7e1d683df3 100644
@@ -1900,8 +1900,10 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
                case IP_VERSION(4, 0, 0):
                case IP_VERSION(4, 0, 2):
                case IP_VERSION(4, 0, 4):
-                       amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
-                       amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
+                       if (!amdgpu_sriov_vf(adev)) {
+                               amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
+                               amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
+                       }
                        break;
                default:
                        dev_err(adev->dev,
--

2.25.1

#11 lore raw
In reply to Horace Chen
Quoted 3 lines · Horace Chen

For further chips we will use CHIP_IP_DISCOVERY, so add this support for virtualization

All current and future chips will use CHIP_IP_DISCOVERY. If we plan to keep the register the same for all new aics, this should be fine. If we might need to have it per asic I think you might want something more like this:

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 9be57389301b..0bdd71f9a8fb 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -0
@@ -709,6 +709,16 @@ void amdgpu_detect_virtualization(struct

amdgpu_device *adev)

        case CHIP_ALDEBARAN:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;

+ case CHIP_IP_DISCOVERY:
+ switch (adev->ip_versions[GC_HWIP][0]) {
+ case IP_VERSION(11, 0, 0):
+ reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
+ break;
+ default:
+ reg = 0;
+ break;
+ }

+               break;
        default: /* other chip doesn't support SRIOV */
                reg = 0;
                break;

Alex

Quoted 29 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -1
index 7d7044e9de2f..ab55602ff534 100644
@@ -705,6 +705,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
        case CHIP_SIENNA_CICHLID:
        case CHIP_ARCTURUS:
        case CHIP_ALDEBARAN:
+       case CHIP_IP_DISCOVERY:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;
        default: /* other chip doesn't support SRIOV */
@@ -748,6 +749,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
                case CHIP_NAVI10:
                case CHIP_NAVI12:
                case CHIP_SIENNA_CICHLID:
+               case CHIP_IP_DISCOVERY:
                        nv_set_virt_ops(adev);
                        /* try send GPU_INIT_DATA request to host */
                        amdgpu_virt_request_init_data(adev);
--

2.25.1

#12 lore raw

[AMD Official Use Only - General]

Hi Alex,

By current design, we will keep this register same for all new asics.
Also, the amdgpu_detect_virtualization will be called before we read the IP discovery table (virtualization needs to send a message to host machine to request for the IP discovery table preparation). So we can't use any IP version to decide the register.

Regards,
Horace.

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, July 21, 2022 10:37 PM
To: Chen, Horace <[email protected]>
Cc: [email protected]; Grodzovsky, Andrey <[email protected]>; Xiao, Jack <[email protected]>; Xu, Feifei <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Xiaojie Yuan <[email protected]>; Tuikov, Luben <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH 1/6] drm/amdgpu: add CHIP_IP_DISCOVERY support for virtualization

Quoted 3 lines · Horace Chen

For further chips we will use CHIP_IP_DISCOVERY, so add this support for virtualization

All current and future chips will use CHIP_IP_DISCOVERY. If we plan to keep the register the same for all new aics, this should be fine. If we might need to have it per asic I think you might want something more like this:

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 9be57389301b..0bdd71f9a8fb 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -0
@@ -709,6 +709,16 @@ void amdgpu_detect_virtualization(struct

amdgpu_device *adev)

        case CHIP_ALDEBARAN:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;

+ case CHIP_IP_DISCOVERY:
+ switch (adev->ip_versions[GC_HWIP][0]) {
+ case IP_VERSION(11, 0, 0):
+ reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
+ break;
+ default:
+ reg = 0;
+ break;
+ }

+               break;
        default: /* other chip doesn't support SRIOV */
                reg = 0;
                break;

Alex

Quoted 30 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +3 -1
index 7d7044e9de2f..ab55602ff534 100644
@@ -705,6 +705,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
        case CHIP_SIENNA_CICHLID:
        case CHIP_ARCTURUS:
        case CHIP_ALDEBARAN:
+       case CHIP_IP_DISCOVERY:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;
        default: /* other chip doesn't support SRIOV */ @@ -748,6
+749,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
                case CHIP_NAVI10:
                case CHIP_NAVI12:
                case CHIP_SIENNA_CICHLID:
+               case CHIP_IP_DISCOVERY:
                        nv_set_virt_ops(adev);
                        /* try send GPU_INIT_DATA request to host */
                        amdgpu_virt_request_init_data(adev);
--

2.25.1

Reviewed-by
#13 lore raw
Quoted 7 lines · Horace

[AMD Official Use Only - General]

Hi Alex,

By current design, we will keep this register same for all new asics.
Also, the amdgpu_detect_virtualization will be called before we read the IP discovery table (virtualization needs to send a message to host machine to request for the IP discovery table preparation). So we can't use any IP version to decide the register.

Quoted 75 lines

Regards,
Horace.

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, July 21, 2022 10:37 PM
To: Chen, Horace <[email protected]>
Cc: [email protected]; Grodzovsky, Andrey <[email protected]>; Xiao, Jack <[email protected]>; Xu, Feifei <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Xiaojie Yuan <[email protected]>; Tuikov, Luben <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH 1/6] drm/amdgpu: add CHIP_IP_DISCOVERY support for virtualization

Quoted 3 lines · Horace Chen

For further chips we will use CHIP_IP_DISCOVERY, so add this support for virtualization

All current and future chips will use CHIP_IP_DISCOVERY. If we plan to keep the register the same for all new aics, this should be fine. If we might need to have it per asic I think you might want something more like this:

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +10 -0
index 9be57389301b..0bdd71f9a8fb 100644
@@ -709,6 +709,16 @@ void amdgpu_detect_virtualization(struct
 amdgpu_device *adev)
        case CHIP_ALDEBARAN:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;
+       case CHIP_IP_DISCOVERY:
+               switch (adev->ip_versions[GC_HWIP][0]) {
+               case IP_VERSION(11, 0, 0):
+                       reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
+                       break;
+               default:
+                       reg = 0;
+                       break;
+               }
+               break;
        default: /* other chip doesn't support SRIOV */
                reg = 0;
                break;

Alex

Quoted 30 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +3 -1
index 7d7044e9de2f..ab55602ff534 100644
@@ -705,6 +705,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
        case CHIP_SIENNA_CICHLID:
        case CHIP_ARCTURUS:
        case CHIP_ALDEBARAN:
+       case CHIP_IP_DISCOVERY:
                reg = RREG32(mmRCC_IOV_FUNC_IDENTIFIER);
                break;
        default: /* other chip doesn't support SRIOV */ @@ -748,6
+749,7 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
                case CHIP_NAVI10:
                case CHIP_NAVI12:
                case CHIP_SIENNA_CICHLID:
+               case CHIP_IP_DISCOVERY:
                        nv_set_virt_ops(adev);
                        /* try send GPU_INIT_DATA request to host */
                        amdgpu_virt_request_init_data(adev);
--

2.25.1