Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Horace Chen <horace.chen@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Horace Chen and committed by
Alex Deucher
119dc6c5 09872b1c

+49 -1
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 2242 2242 break; 2243 2243 case IP_VERSION(4, 3, 0): 2244 2244 case IP_VERSION(4, 3, 1): 2245 - adev->nbio.funcs = &nbio_v4_3_funcs; 2245 + if (amdgpu_sriov_vf(adev)) 2246 + adev->nbio.funcs = &nbio_v4_3_sriov_funcs; 2247 + else 2248 + adev->nbio.funcs = &nbio_v4_3_funcs; 2246 2249 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg; 2247 2250 break; 2248 2251 case IP_VERSION(7, 7, 0):
+44
drivers/gpu/drm/amd/amdgpu/nbio_v4_3.c
··· 488 488 .get_rom_offset = nbio_v4_3_get_rom_offset, 489 489 .program_aspm = nbio_v4_3_program_aspm, 490 490 }; 491 + 492 + 493 + static void nbio_v4_3_sriov_ih_doorbell_range(struct amdgpu_device *adev, 494 + bool use_doorbell, int doorbell_index) 495 + { 496 + } 497 + 498 + static void nbio_v4_3_sriov_sdma_doorbell_range(struct amdgpu_device *adev, int instance, 499 + bool use_doorbell, int doorbell_index, 500 + int doorbell_size) 501 + { 502 + } 503 + 504 + static void nbio_v4_3_sriov_vcn_doorbell_range(struct amdgpu_device *adev, bool use_doorbell, 505 + int doorbell_index, int instance) 506 + { 507 + } 508 + 509 + static void nbio_v4_3_sriov_gc_doorbell_init(struct amdgpu_device *adev) 510 + { 511 + } 512 + 513 + const struct amdgpu_nbio_funcs nbio_v4_3_sriov_funcs = { 514 + .get_hdp_flush_req_offset = nbio_v4_3_get_hdp_flush_req_offset, 515 + .get_hdp_flush_done_offset = nbio_v4_3_get_hdp_flush_done_offset, 516 + .get_pcie_index_offset = nbio_v4_3_get_pcie_index_offset, 517 + .get_pcie_data_offset = nbio_v4_3_get_pcie_data_offset, 518 + .get_rev_id = nbio_v4_3_get_rev_id, 519 + .mc_access_enable = nbio_v4_3_mc_access_enable, 520 + .get_memsize = nbio_v4_3_get_memsize, 521 + .sdma_doorbell_range = nbio_v4_3_sriov_sdma_doorbell_range, 522 + .vcn_doorbell_range = nbio_v4_3_sriov_vcn_doorbell_range, 523 + .gc_doorbell_init = nbio_v4_3_sriov_gc_doorbell_init, 524 + .enable_doorbell_aperture = nbio_v4_3_enable_doorbell_aperture, 525 + .enable_doorbell_selfring_aperture = nbio_v4_3_enable_doorbell_selfring_aperture, 526 + .ih_doorbell_range = nbio_v4_3_sriov_ih_doorbell_range, 527 + .update_medium_grain_clock_gating = nbio_v4_3_update_medium_grain_clock_gating, 528 + .update_medium_grain_light_sleep = nbio_v4_3_update_medium_grain_light_sleep, 529 + .get_clockgating_state = nbio_v4_3_get_clockgating_state, 530 + .ih_control = nbio_v4_3_ih_control, 531 + .init_registers = nbio_v4_3_init_registers, 532 + .remap_hdp_registers = nbio_v4_3_remap_hdp_registers, 533 + .get_rom_offset = nbio_v4_3_get_rom_offset, 534 + };
+1
drivers/gpu/drm/amd/amdgpu/nbio_v4_3.h
··· 28 28 29 29 extern const struct nbio_hdp_flush_reg nbio_v4_3_hdp_flush_reg; 30 30 extern const struct amdgpu_nbio_funcs nbio_v4_3_funcs; 31 + extern const struct amdgpu_nbio_funcs nbio_v4_3_sriov_funcs; 31 32 32 33 #endif