drm/amd/sriov: add PF SR-IOV host driver
Subsystems (5)
cover drm/amd/sriov: add PF SR-IOV host driver
This RFC adds SR-IOV PF host mode to the amdgpu driver. It introduces a new drivers/gpu/drm/amd/sriov/ control plane under the existing amdgpu PF device lifecycle. The validation target is 1VF bring-up on real asic:
after a clean PF host load with one VF configured, a single VF is created, the guest amdgpu driver load and reload complete, and a guest workload runs.
Thirty-four patches are attached.
Ownership map
-------------
struct amdgpu_device remains the single source of truth for PF physical
state: PCI lifecycle, BAR, IP discovery, firmware, IRQ, reset, RAS, PSP, SMU, GMC, GART, TTM, VRAM, and other hardware-facing PF initialization stay in the existing amdgpu owner paths.
SR-IOV PF host mode adds:
- adev->num_vfs — resolved VF count from boot-time module parameters
- adev->sriov — SR-IOV host subsystem root object
- drivers/gpu/drm/amd/sriov/ — PF-side control plane for VF management and service orchestration
Integration uses one host-style IP block, sriov_host_v1_0_ip_block, mounted through the existing amdgpu IP block discovery path. GPUIOV, mailbox, FFBM, VFMGR, and scheduler are service objects under adev->sriov; they are not registered as separate physical IP blocks.
Request flow
------------
Guest VF lifecycle request (VF2PF mailbox message):
VF2PF mailbox ingress
-> decode message, manage valid/ACK state
scheduler event service
-> queue/worker, timeout, full-access state, PF2VF response
manual world switch (single-VF path)
-> idle/save/load/run/shutdown/reset through scheduler-owned actions
middle services
-> VFMGR (resource view, boot data)
-> GPUIOV (command/state, VF PCI exposure)
-> FFBM (VF backing map/unmap, GPA-to-SPA)
hardware / firmware providers
-> IOVM PSP command transport
-> NBIF mailbox registers
-> GC/GMC provider hooksPF physical bring-up (firmware, discovery, PM/user-path policy) stays in the existing amdgpu owner paths and gates entry into the flow above.
Boot-time contract
------------------
The user-visible module parameter remains amdgpu.sriov_numvfs.
Supported forms:
amdgpu.sriov_numvfs=all,N
amdgpu.sriov_numvfs=dddd:bb:dd.f,N
amdgpu_parse_sriov_host_params() runs immediately after IP discovery data is parsed and adev->ip_versions[] is available, before display, multimedia, and SR-IOV host IP block registration that depend on amdgpu_sriov_pf(adev).
Mode helpers:
amdgpu_sriov_pf_supported(adev) — hardware / IP version capability amdgpu_sriov_pf(adev) — adev->num_vfs > 0
Unsupported devices, malformed parameters, zero VF count, or a device without SR-IOV VFs fail closed and keep the bare-metal path unchanged. If the requested count exceeds the device TotalVFs, the driver warns and falls back to one VF.
Patch list
----------
0001 drm/amd/sriov: add PF host build wiring
0002 drm/amd/sriov: add PF host boot parameters
0003 drm/amd/sriov: disable PF host PM defaults
0004 drm/amd/sriov: block PF host user submissions
0005 drm/amd/sriov: block PF host KFD user queues
0006 drm/amd/sriov: skip MM IP blocks on PF host
0007 drm/amd/sriov: skip display blocks on PF host
0008 drm/amd/sriov: add PF host IP block init and fini 0009 drm/amd/sriov: load PF RLC firmware variant
0010 drm/amd/sriov: extend PSP GFX interface for IOVM 0011 drm/amd/sriov: add PSP 15.0.3 IOVM driver bootloader callback 0012 drm/amd/sriov: update PF PSP init for IOVM firmware 0013 drm/amd/sriov: add IOVM driver PSP command submission 0014 drm/amd/sriov: add IOVM PSP command helpers
0015 drm/amd/sriov: add GPUIOV service
0016 drm/amd/sriov: add GC 13.0.1 GPUIOV provider
0017 drm/amd/sriov: add GMC 13.0.1 GPUIOV provider
0018 drm/amd/sriov: add PF mailbox service
0019 drm/amd/sriov: add NBIF 7.10.0 PF mailbox backend 0020 drm/amd/sriov: add FFBM service
0021 drm/amd/sriov: add VF manager
0022 drm/amd/sriov: add VF resource setup
0023 drm/amd/sriov: add PSP 15.0.3 VF access gate provider 0024 drm/amd/sriov: add NBIF 7.10.0 VF access gate headers 0025 drm/amd/sriov: add NBIF 7.10.0 VF access gate backend 0026 drm/amd/sriov: add VF mailbox boot layout
0027 drm/amd/sriov: add VF IP discovery table builder 0028 drm/amd/sriov: add guest VBIOS image builder
0029 drm/amd/sriov: export VF boot data to guest FB 0030 drm/amd/sriov: add PF scheduler documentation
0031 drm/amd/sriov: add scheduler event handling
0032 drm/amd/sriov: add manual scheduler topology
0033 drm/amd/sriov: add manual world switch support 0034 drm/amd/sriov: add VF guard event limits
Thanks,
Emily Deng
Emily Deng (34):
drm/amd/sriov: add PF host build wiring drm/amd/sriov: add PF host boot parameters drm/amd/sriov: disable PF host PM defaults drm/amd/sriov: block PF host user submissions drm/amd/sriov: block PF host KFD user queues drm/amd/sriov: skip MM IP blocks on PF host drm/amd/sriov: skip display blocks on PF host drm/amd/sriov: add PF host IP block init and fini drm/amd/sriov: load PF RLC firmware variant drm/amd/sriov: extend PSP GFX interface for IOVM drm/amd/sriov: add PSP 15.0.3 IOVM driver bootloader callback drm/amd/sriov: update PF PSP init for IOVM firmware drm/amd/sriov: add IOVM driver PSP command submission drm/amd/sriov: add IOVM PSP command helpers drm/amd/sriov: add GPUIOV service
drm/amd/sriov: add GC 13.0.1 GPUIOV provider drm/amd/sriov: add GMC 13.0.1 GPUIOV provider drm/amd/sriov: add PF mailbox service drm/amd/sriov: add NBIF 7.10.0 PF mailbox backend drm/amd/sriov: add FFBM service
drm/amd/sriov: add VF manager
drm/amd/sriov: add VF resource setup
drm/amd/sriov: add PSP 15.0.3 VF access gate provider drm/amd/sriov: add NBIF 7.10.0 VF access gate headers drm/amd/sriov: add NBIF 7.10.0 VF access gate backend drm/amd/sriov: add VF mailbox boot layout drm/amd/sriov: add VF IP discovery table builder drm/amd/sriov: add guest VBIOS image builder drm/amd/sriov: export VF boot data to guest FB drm/amd/sriov: add PF scheduler documentation drm/amd/sriov: add scheduler event handling drm/amd/sriov: add manual scheduler topology drm/amd/sriov: add manual world switch support drm/amd/sriov: add VF guard event limits
Documentation/gpu/amdgpu/index.rst | 1 + Documentation/gpu/amdgpu/sriov-scheduler.rst | 737 ++++++++ MAINTAINERS | 1 + drivers/gpu/drm/amd/amdgpu/Makefile | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 138 +- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 54 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 60 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 22 +- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 132 +- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 21 + .../gpu/drm/amd/amdgpu/amdgpu_sriov_host.h | 37 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 103 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 13 +- drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c | 23 +- drivers/gpu/drm/amd/amdgpu/nbif_v7_10.c | 4 + drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 55 +- drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c | 13 + drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c | 5 + drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 38 + drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 55 +- drivers/gpu/drm/amd/include/amd_shared.h | 2 + .../asic_reg/nbif/nbif_7_10_0_offset.h | 6 + .../asic_reg/nbif/nbif_7_10_0_sh_mask.h | 11 + drivers/gpu/drm/amd/sriov/Makefile | 46 + drivers/gpu/drm/amd/sriov/sriov.c | 590 +++++++ drivers/gpu/drm/amd/sriov/sriov.h | 162 ++ drivers/gpu/drm/amd/sriov/sriov_ffbm.c | 332 ++++ drivers/gpu/drm/amd/sriov/sriov_ffbm.h | 71 + drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c | 295 ++++ drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.h | 32 + drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.c | 77 + drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.h | 32 + drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 695 ++++++++ drivers/gpu/drm/amd/sriov/sriov_gpuiov.h | 184 ++ drivers/gpu/drm/amd/sriov/sriov_guard.c | 255 +++ drivers/gpu/drm/amd/sriov/sriov_guard.h | 100 ++ drivers/gpu/drm/amd/sriov/sriov_hwsm.c | 235 +++ drivers/gpu/drm/amd/sriov/sriov_hwsm.h | 50 + drivers/gpu/drm/amd/sriov/sriov_iovm.c | 715 ++++++++ drivers/gpu/drm/amd/sriov/sriov_iovm.h | 111 ++ .../gpu/drm/amd/sriov/sriov_ip_discovery.c | 627 +++++++ .../gpu/drm/amd/sriov/sriov_ip_discovery.h | 47 + drivers/gpu/drm/amd/sriov/sriov_mailbox.c | 582 ++++++ drivers/gpu/drm/amd/sriov/sriov_mailbox.h | 89 + drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c | 401 +++++ drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.h | 32 + drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.c | 298 ++++ drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.h | 32 + drivers/gpu/drm/amd/sriov/sriov_sched.c | 192 ++ drivers/gpu/drm/amd/sriov/sriov_sched_event.c | 1428 +++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_sched_event.h | 190 ++ .../drm/amd/sriov/sriov_sched_event_data.h | 84 + .../amd/sriov/sriov_sched_event_dispatch.c | 88 + .../amd/sriov/sriov_sched_event_dispatch.h | 62 + .../amd/sriov/sriov_sched_event_handlers.c | 179 ++ .../amd/sriov/sriov_sched_event_handlers.h | 55 + .../drm/amd/sriov/sriov_sched_event_priv.h | 78 + .../gpu/drm/amd/sriov/sriov_sched_switch.c | 1564 +++++++++++++++++ .../gpu/drm/amd/sriov/sriov_sched_switch.h | 209 +++ .../gpu/drm/amd/sriov/sriov_sched_ws_manual.c | 512 ++++++ .../gpu/drm/amd/sriov/sriov_sched_ws_manual.h | 33 + drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 1295 ++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.h | 130 ++ 70 files changed, 13696 insertions(+), 57 deletions(-) create mode 100644 Documentation/gpu/amdgpu/sriov-scheduler.rst create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_sriov_host.h create mode 100644 drivers/gpu/drm/amd/sriov/Makefile create mode 100644 drivers/gpu/drm/amd/sriov/sriov.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ffbm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ffbm.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gpuiov.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gpuiov.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_guard.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_guard.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_hwsm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_hwsm.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_iovm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_iovm.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ip_discovery.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ip_discovery.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_mailbox.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_mailbox.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_data.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_priv.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_switch.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_switch.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_vfmgr.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_vfmgr.h
Signature · 1 line
2.34.1
RFC PATCH 1/34 drm/amd/sriov: add PF host build wiring
Add the SR-IOV PF host object list and MAINTAINERS coverage. PF host support builds with CONFIG_DRM_AMDGPU; no separate Kconfig toggle.
--- MAINTAINERS | 1 + drivers/gpu/drm/amd/sriov/Makefile | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/Makefile
MAINTAINERS +1 -0
@@ -22432,6 +22432,7 @@ C: irc://irc.oftc.net/radeon T: git https://gitlab.freedesktop.org/drm/amdgpu/kernel.git F: Documentation/gpu/amdgpu/ F: drivers/gpu/drm/amd/ +F: drivers/gpu/drm/amd/sriov/ F: drivers/gpu/drm/ci/xfails/amd* F: drivers/gpu/drm/radeon/ F: include/uapi/drm/amdgpu_drm.h
drivers/gpu/drm/amd/sriov/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: MIT +# +# Copyright 2026 Advanced Micro Devices, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# +# AMDGPU SR-IOV PF host support + +AMD_SRIOV_FILES :=
Signature · 1 line
2.34.1
RFC PATCH 2/34 drm/amd/sriov: add PF host boot parameters
In reply to Emily DengParse the enabled VF count from module parameters and store it on the device so SR-IOV PF host initialization can replace bare-metal setup.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 15 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 88 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 ++ 5 files changed, 118 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
@@ -117,6 +117,7 @@#include "amdgpu_sa.h" #include "amdgpu_acpi.h" #include "amdgpu_ualink.h" +struct amdgpu_sriov ;#if defined(CONFIG_DRM_AMD_ISP )#include "amdgpu_isp.h" #endif
@@ -267,6 +268,7 @@ extern int amdgpu_wbrf;extern int amdgpu_user_queue;extern int amdgpu_ptl;extern char *amdgpu_ptl_format; +extern char *amdgpu_sriov_numvfs;extern uint amdgpu_hdmi_hpd_debounce_delay_ms;
@@ -983,6 +985,10 @@ struct amdgpu_device {struct amdgpu_uma_carveout_info uma_info; +/* SR-IOV PF host */ +unsigned int num_vfs; +struct amdgpu_sriov *sriov; +/* KFD * Must be last --ends in a flexible-array member. */
@@ -1203,6 +1209,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);/* Common functions */ bool amdgpu_device_has_job_running (struct amdgpu_device *adev); +int amdgpu_device_wait_for_ring_idle (struct amdgpu_device *adev);bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev); int amdgpu_device_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job,
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +3 -0
@@ -3742,6 +3742,9 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) }amdgpu_discovery_init_soc_config (adev); + +amdgpu_parse_sriov_host_params (adev); +amdgpu_discovery_sysfs_init (adev);switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +15 -0
@@ -253,6 +253,7 @@ int amdgpu_user_queue = -1;uint amdgpu_hdmi_hpd_debounce_delay_ms;int amdgpu_ptl =-1 ;/* auto */ char *amdgpu_ptl_format; +char *amdgpu_sriov_numvfs; DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, "DRM_UT_CORE",
@@ -549,6 +550,16 @@ MODULE_PARM_DESC(virtual_display, "Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x,x;xxxx:xx:xx.x,x)");module_param_named (virtual_display, amdgpu_virtual_display, charp,0444 ); +/** +* DOC: sriov_numvfs (charp) +* Set the number of SR-IOV VFs to enable during PF driver initialization. +* The parameter accepts N, all,N, or xxxx:xx:xx.x,N;xxxx:xx:xx.x,N. Bare N is +* treated as all,N. The default is NULL, which keeps the existing non-PF-host path. +*/ +MODULE_PARM_DESC (sriov_numvfs, +"Number of SR-IOV VFs at PF boot time (format: N, all,N, or xxxx:xx:xx.x,N;xxxx:xx:xx.x,N)" ); +module_param_named (sriov_numvfs, amdgpu_sriov_numvfs, charp,0444 ); +/** * DOC: lbpw (int) * Override Load Balancing Per Watt (LBPW) support (1 = enable, 0 = disable). The default is -1 (auto, enabled).
@@ -2421,6 +2432,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,unsigned long flags = ent->driver_data;int ret, retry =0 , i; +if (pdev->is_virtfn && amdgpu_sriov_numvfs) { +return -ENODEV ; + } +if ((pdev->class >>8 ) ==PCI_CLASS_DISPLAY_VGA || (pdev->class >>8 ) ==PCI_CLASS_DISPLAY_OTHER ) {if (drm_firmware_drivers_only () && amdgpu_modeset ==-1 )
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +88 -0
94 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5 -0
@@ -378,6 +378,9 @@ struct amdgpu_video_codec_info;#define amdgpu_sriov_vf (adev) \ ((adev)->virt.caps & AMDGPU_SRIOV_CAPS_IS_VF) +#define amdgpu_sriov_pf (adev) \ +((adev)->num_vfs > 0) +#define amdgpu_sriov_bios (adev) \ ((adev)->virt.caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS)
@@ -476,6 +479,8 @@ static inline bool is_virtual_machine(void)bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev);void amdgpu_virt_init_setting (struct amdgpu_device *adev); +void amdgpu_parse_sriov_host_params (struct amdgpu_device *adev); +bool amdgpu_sriov_pf_supported (struct amdgpu_device *adev);int amdgpu_virt_request_full_gpu (struct amdgpu_device *adev,bool init);int amdgpu_virt_release_full_gpu (struct amdgpu_device *adev,bool init);void amdgpu_virt_deactivate (struct amdgpu_device *adev);
Signature · 1 line
2.34.1
RFC PATCH 3/34 drm/amd/sriov: disable PF host PM defaults
In reply to Emily DengDisable runtime PM, ASPM, rebar and DPM defaults on SR-IOV PF hosts and clear device power-management state after boot parameters are applied.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c | 7 ++++--- 4 files changed, 33 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
@@ -618,6 +618,12 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)int bamaco_support; adev->pm.rpm_mode =AMDGPU_RUNPM_NONE ; + +if (amdgpu_sriov_pf (adev)) { +dev_info (adev->dev,"runtime pm is disabled for SR-IOV PF host\n" ); +return ; + } +if (amdgpu_device_is_removable (adev)) {dev_info (adev->dev,"Runtime PM disabled for externally attached device\n" );
@@ -1115,6 +1121,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)if (amdgpu_sriov_vf (adev))return 0 ; +if (amdgpu_sriov_pf (adev)) +return 0 ; +if (!amdgpu_rebar)return 0 ;
@@ -1384,6 +1393,9 @@ bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev)struct pci_dev *aspm_pdev, *parent;bool enabled; +if (amdgpu_sriov_pf (adev)) +return false; +switch (amdgpu_aspm) {case -1 :break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -2
@@ -4134,9 +4134,9 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)if ((adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT && !amdgpu_sriov_vf (adev) && - amdgpu_dpm ==1 ) || + !amdgpu_sriov_pf (adev) && amdgpu_dpm ==1 ) || (adev->firmware.load_type ==AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && - amdgpu_dpm ==1 )) { + !amdgpu_sriov_pf (adev) && amdgpu_dpm ==1 )) { r =amdgpu_discovery_set_smu_ip_blocks (adev);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +15 -0
@@ -34,6 +34,7 @@#include "amdgpu_ras.h" #include "amdgpu_reset.h" #include "amdgpu_dpm.h" +#include "amdgpu_smu.h" #include "amdgpu_video_codecs.h" #include "vi.h" #include "soc15.h"
@@ -92,6 +93,17 @@ bool amdgpu_sriov_pf_supported(struct amdgpu_device *adev) } } +static void amdgpu_sriov_pf_apply_param_defaults (struct amdgpu_device *adev) +{ +struct smu_context *smu = adev->powerplay.pp_handle; + + adev->pm.pp_feature =0 ; + adev->cg_flags =0 ; + adev->pg_flags =0 ; +if (smu) + smu->pm_enabled = false; +} +void amdgpu_parse_sriov_host_params (struct amdgpu_device *adev) {const char *pci_address_name =pci_name (adev->pdev);
@@ -155,6 +167,9 @@ void amdgpu_parse_sriov_host_params(struct amdgpu_device *adev)break ; } +if (amdgpu_sriov_pf (adev)) +amdgpu_sriov_pf_apply_param_defaults (adev); +kfree (params); }
drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c +4 -3
@@ -1337,7 +1337,7 @@ static int gfx_v13_0_rlc_backdoor_autoload_enable(struct amdgpu_device *adev)WREG32_SOC15 (GC ,0 , regGFX_IMU_RLC_BOOTLOADER_SIZE, rlc_g_size); -if (adev->gfx.imu.funcs && (amdgpu_dpm >0 )) { +if (adev->gfx.imu.funcs && !amdgpu_sriov_pf (adev) && amdgpu_dpm >0 ) {/* RLC autoload sequence 3: load IMU fw */ if (adev->gfx.imu.funcs->load_microcode) adev->gfx.imu.funcs->load_microcode (adev);
@@ -3577,7 +3577,7 @@ static int gfx_v13_0_hw_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;if (adev->firmware.load_type ==AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO ) { -if (adev->gfx.imu.funcs && (amdgpu_dpm >0 )) { +if (adev->gfx.imu.funcs && !amdgpu_sriov_pf (adev) && amdgpu_dpm >0 ) {/* RLC autoload sequence 1: Program rlc ram */ if (adev->gfx.imu.funcs->program_rlc_ram) adev->gfx.imu.funcs->program_rlc_ram (adev);
@@ -3588,7 +3588,8 @@ static int gfx_v13_0_hw_init(struct amdgpu_ip_block *ip_block)return r; }else {if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) { -if (adev->gfx.imu.funcs && (amdgpu_dpm >0 )) { +if (adev->gfx.imu.funcs && !amdgpu_sriov_pf (adev) && + amdgpu_dpm >0 ) {if (adev->gfx.imu.funcs->load_microcode) adev->gfx.imu.funcs->load_microcode (adev);if (adev->gfx.imu.funcs->setup_imu)
Signature · 1 line
2.34.1
RFC PATCH 4/34 drm/amd/sriov: block PF host user submissions
In reply to Emily DengReject GEM mmap and non-query DRM ioctls on SR-IOV PF, skip user queue resume on release, and block user submissions on graphics rings and MES user queues while allowing device info queries.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 45 ++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 22 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 3 ++ drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c | 10 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c | 5 +++ 5 files changed, 82 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +44 -1
@@ -28,6 +28,7 @@#include <drm/drm_fbdev_ttm.h> #include <drm/drm_gem.h> #include <drm/drm_gem_ttm_helper.h> +#include <drm/drm_ioctl.h> #include <drm/drm_managed.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h>
@@ -3024,8 +3025,12 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp)struct drm_file *file_priv = filp->private_data;struct amdgpu_fpriv *fpriv = file_priv->driver_priv;struct drm_device *dev = file_priv->minor->dev; +struct amdgpu_device *adev =drm_to_adev (dev);int idx; +if (fpriv &&amdgpu_sriov_pf (adev)) +return drm_release (inode, filp); +if (fpriv &&drm_dev_enter (dev, &idx)) {amdgpu_evf_mgr_shutdown (&fpriv->evf_mgr);amdgpu_userq_mgr_cancel_resume (&fpriv->userq_mgr);
@@ -3038,14 +3043,47 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp)return drm_release (inode, filp); } +static int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma) +{ +struct drm_file *file_priv = filp->private_data; +struct drm_device *dev = file_priv->minor->dev; +struct amdgpu_device *adev =drm_to_adev (dev); + +if (amdgpu_sriov_pf (adev)) +return -EOPNOTSUPP ; + +return drm_gem_mmap (filp, vma); +} + +static bool amdgpu_drm_ioctl_allowed_on_sriov_pf (unsigned int nr) +{ +if (nr <DRM_COMMAND_BASE ) +return true; + +switch (nr -DRM_COMMAND_BASE ) { +case DRM_AMDGPU_INFO : +return true; +default : +return false; + } +} +long amdgpu_drm_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {struct drm_file *file_priv = filp->private_data;struct drm_device *dev; +struct amdgpu_device *adev; +unsigned int nr =DRM_IOCTL_NR (cmd);long ret; dev = file_priv->minor->dev; + adev =drm_to_adev (dev); + +if (amdgpu_sriov_pf (adev) && + !amdgpu_drm_ioctl_allowed_on_sriov_pf (nr)) +return -EOPNOTSUPP ; + ret =pm_runtime_get_sync (dev->dev);if (ret <0 ) goto out;
@@ -3076,8 +3114,13 @@ static int amdgpu_flush(struct file *f, fl_owner_t id) {struct drm_file *file_priv = f->private_data;struct amdgpu_fpriv *fpriv = file_priv->driver_priv; +struct drm_device *dev = file_priv->minor->dev; +struct amdgpu_device *adev =drm_to_adev (dev);long timeout =MAX_WAIT_SCHED_ENTITY_Q_EMPTY ; +if (!fpriv ||amdgpu_sriov_pf (adev)) +return 0 ; + timeout =amdgpu_ctx_mgr_entity_flush (&fpriv->ctx_mgr, timeout); timeout =amdgpu_vm_wait_idle (&fpriv->vm, timeout);
@@ -3090,7 +3133,7 @@ static const struct file_operations amdgpu_driver_kms_fops = { .flush = amdgpu_flush, .release = amdgpu_drm_release, .unlocked_ioctl = amdgpu_drm_ioctl, - .mmap = drm_gem_mmap, + .mmap = amdgpu_mmap, .poll = drm_poll, .read = drm_read,#ifdef CONFIG_COMPAT
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +20 -2
@@ -1409,6 +1409,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)struct drm_amdgpu_info_gpuvm_fault gpuvm_fault;unsigned long flags; +if (amdgpu_sriov_pf (adev)) +return -EOPNOTSUPP ; +if (!vm)return -EINVAL ;
@@ -1426,6 +1429,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)case AMDGPU_INFO_UQ_FW_AREAS : {struct drm_amdgpu_info_uq_metadata meta_info = {}; +if (amdgpu_sriov_pf (adev)) +return -EOPNOTSUPP ; +switch (info->query_hw_ip.type) {case AMDGPU_HW_IP_GFX : ret =amdgpu_userq_metadata_info_gfx (adev, info, &meta_info.gfx);
@@ -1505,8 +1511,9 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)struct drm_exec exec;int r, pasid =0 ; -/* Ensure IB tests are run on ring */ -flush_delayed_work (&adev->delayed_init_work); +/* Ensure IB tests are run on ring for files that can submit work. */ +if (!amdgpu_sriov_pf (adev)) +flush_delayed_work (&adev->delayed_init_work);if (amdgpu_ras_intr_triggered ()) {
@@ -1530,6 +1537,11 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)if (r) goto error_pasid; +if (amdgpu_sriov_pf (adev)) { + file_priv->driver_priv = fpriv; + goto out_suspend; + } +amdgpu_debugfs_vm_init (file_priv); r =amdgpu_vm_init (adev, &fpriv->vm, fpriv->xcp_id);
@@ -1627,6 +1639,12 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,if (!fpriv)return ; +if (amdgpu_sriov_pf (adev)) { +kfree (fpriv); + file_priv->driver_priv =NULL ; +return ; + } +pm_runtime_get_sync (dev->dev);if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_UVD ) !=NULL )
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +3 -0
@@ -42,6 +42,9 @@ u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev)int i;u32 userq_ip_mask =0 ; +if (amdgpu_sriov_pf (adev)) +return 0 ; +for (i =0 ; i <AMDGPU_HW_IP_NUM ; i++) {if (adev->userq_funcs[i]) userq_ip_mask |= (1 << i);
drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c +10 -0
@@ -1002,6 +1002,10 @@ static int gfx_v13_0_gfx_ring_init(struct amdgpu_device *adev, int ring_id, AMDGPU_RING_PRIO_DEFAULT, NULL);if (r)return r; + +if (amdgpu_sriov_pf (adev)) + ring->no_user_submission = true; +return 0 ; }
@@ -1039,6 +1043,9 @@ static int gfx_v13_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,if (r)return r; +if (amdgpu_sriov_pf (adev)) + ring->no_user_submission = true; +return 0 ; }
@@ -3854,6 +3861,9 @@ static int gfx_v13_0_early_init(struct amdgpu_ip_block *ip_block)break ; } +if (amdgpu_sriov_pf (adev)) + adev->gfx.disable_uq = true; + adev->gfx.funcs = &gfx_v13_0_gfx_funcs;if (adev->gfx.disable_kq) {
drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c +5 -0
@@ -1287,6 +1287,11 @@ static int sdma_v8_0_early_init(struct amdgpu_ip_block *ip_block)break ; } +if (amdgpu_sriov_pf (adev)) { + adev->sdma.no_user_submission = true; + adev->sdma.disable_uq = true; + } + r =amdgpu_sdma_init_microcode (adev,0 , true);if (r) {DRM_ERROR ("Failed to init sdma firmware!\n" );
Signature · 1 line
2.34.1
RFC PATCH 5/34 drm/amd/sriov: block PF host KFD user queues
In reply to Emily DengAllow only management and read-only KFD access on SR-IOV PF, reject queue, memory, VM, debug and mmap paths, and omit AIS initialization and PF queue capabilities from topology.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 38 ++++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 55 +++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +38 -0
@@ -3686,6 +3686,35 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) +static bool kfd_sriov_pf_blocks_user_queues (void ) +{ +struct kfd_node *dev; +u8 id =0 ; + +while (kfd_topology_enum_kfd_devices (id++, &dev) ==0 ) { +if (dev &&amdgpu_sriov_pf (dev->adev)) +return true; + } + +return false; +} + +static bool kfd_ioctl_allowed_on_sriov_pf (unsigned int cmd) +{ +switch (cmd) { +case AMDKFD_IOC_GET_VERSION : +case AMDKFD_IOC_GET_CLOCK_COUNTERS : +case AMDKFD_IOC_GET_PROCESS_APERTURES : +case AMDKFD_IOC_GET_PROCESS_APERTURES_NEW : +case AMDKFD_IOC_GET_TILE_CONFIG : +case AMDKFD_IOC_AVAILABLE_MEMORY : +case AMDKFD_IOC_SMI_EVENTS : +return true; +default : +return false; + } +} +static long kfd_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) {struct kfd_process *process;
@@ -3749,6 +3778,12 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) goto err_i1; } +if (kfd_sriov_pf_blocks_user_queues () && + !kfd_ioctl_allowed_on_sriov_pf (cmd)) { + retcode = -EOPNOTSUPP ; + goto err_i1; + } +/* * Versions of docker shipped in Ubuntu 18.xx and 20.xx do not support * CAP_CHECKPOINT_RESTORE, so we also allow access if CAP_SYS_ADMIN as CAP_SYS_ADMIN is a
@@ -3860,6 +3895,9 @@ static int kfd_mmap(struct file *filep, struct vm_area_struct *vma)if (process->lead_thread != current->group_leader)return -EBADF ; +if (kfd_sriov_pf_blocks_user_queues ()) +return -EOPNOTSUPP ; + mmap_offset = vma->vm_pgoff <<PAGE_SHIFT ; gpu_id =KFD_MMAP_GET_GPU_ID (mmap_offset);
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +46 -9
109 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 6/34 drm/amd/sriov: skip MM IP blocks on PF host
In reply to Emily DengSkip multimedia IP block registration on SR-IOV PF hosts.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +16 -12
@@ -4142,25 +4142,29 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)return r; } - r =amdgpu_discovery_set_mm_ip_blocks (adev); -if (r) -return r; +if (!amdgpu_sriov_pf (adev)) { + r =amdgpu_discovery_set_mm_ip_blocks (adev); +if (r) +return r; + } r =amdgpu_discovery_set_mes_ip_blocks (adev);if (r)return r; - r =amdgpu_discovery_set_vpe_ip_blocks (adev); -if (r) -return r; +if (!amdgpu_sriov_pf (adev)) { + r =amdgpu_discovery_set_vpe_ip_blocks (adev); +if (r) +return r; - r =amdgpu_discovery_set_umsch_mm_ip_blocks (adev); -if (r) -return r; + r =amdgpu_discovery_set_umsch_mm_ip_blocks (adev); +if (r) +return r; - r =amdgpu_discovery_set_isp_ip_blocks (adev); -if (r) -return r; + r =amdgpu_discovery_set_isp_ip_blocks (adev); +if (r) +return r; + } r =amdgpu_discovery_set_ualink_ip_blocks (adev);if (r)
Signature · 1 line
2.34.1
RFC PATCH 7/34 drm/amd/sriov: skip display blocks on PF host
In reply to Emily DengSkip display IP block registration on SR-IOV PF hosts.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +5 -3
@@ -4116,9 +4116,11 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)return r; } - r =amdgpu_discovery_set_display_ip_blocks (adev); -if (r) -return r; +if (!amdgpu_sriov_pf (adev)) { + r =amdgpu_discovery_set_display_ip_blocks (adev); +if (r) +return r; + } r =amdgpu_discovery_set_gc_ip_blocks (adev);if (r)
Signature · 1 line
2.34.1
RFC PATCH 8/34 drm/amd/sriov: add PF host IP block init and fini
In reply to Emily DengRegister the SR-IOV host IP block and late init/fini hooks activated when SR-IOV PF host mode is selected.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 126 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 14 + drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 1 + .../gpu/drm/amd/amdgpu/amdgpu_sriov_host.h | 36 ++ drivers/gpu/drm/amd/include/amd_shared.h | 2 + drivers/gpu/drm/amd/sriov/Makefile | 2 + drivers/gpu/drm/amd/sriov/sriov.c | 357 ++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov.h | 59 +++ 10 files changed, 594 insertions(+), 8 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_sriov_host.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov.h
drivers/gpu/drm/amd/amdgpu/Makefile +3 -0
@@ -299,6 +299,9 @@ amdgpu-y += amdgpu_userq.o # add UALink manager support amdgpu-y += amdgpu_ualink.o ualink_v1_0.o +include $(FULL_AMD_PATH)/sriov/Makefile +amdgpu-y += $(AMD_SRIOV_FILES) + ifneq ($(CONFIG_HSA_AMD),) AMDKFD_PATH := ../amdkfd include $(FULL_AMD_PATH)/amdkfd/Makefile
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -117,7 +117,7 @@#include "amdgpu_sa.h" #include "amdgpu_acpi.h" #include "amdgpu_ualink.h" -struct amdgpu_sriov ; +#include "amdgpu_sriov_host.h" #if defined(CONFIG_DRM_AMD_ISP )#include "amdgpu_isp.h" #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +119 -7
205 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +14 -0
@@ -3238,6 +3238,16 @@ static int amdgpu_discovery_set_ras_ip_blocks(struct amdgpu_device *adev)return 0 ; } +static int amdgpu_discovery_set_sriov_host_ip_blocks (struct amdgpu_device *adev) +{ +if (!amdgpu_sriov_pf (adev)) +return 0 ; + +amdgpu_device_ip_block_add (adev, &sriov_host_v1_0_ip_block); + +return 0 ; +} +static int amdgpu_discovery_set_mm_ip_blocks (struct amdgpu_device *adev) {if (amdgpu_ip_version (adev,VCE_HWIP ,0 )) {
@@ -4122,6 +4132,10 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)return r; } + r =amdgpu_discovery_set_sriov_host_ip_blocks (adev); +if (r) +return r; + r =amdgpu_discovery_set_gc_ip_blocks (adev);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c +1 -0
@@ -156,6 +156,7 @@ static const char *const ip_block_names[] = { [AMD_IP_BLOCK_TYPE_ISP] = "isp", [AMD_IP_BLOCK_TYPE_RAS] = "ras", [AMD_IP_BLOCK_TYPE_UALINK] = "ualink", + [AMD_IP_BLOCK_TYPE_SRIOV_HOST] = "sriov_host", }; static const char *ip_block_name(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_sriov_host.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_HOST_H__ +#define __SRIOV_HOST_H__ + +#include <linux/types.h> + +struct amdgpu_device ; +struct amdgpu_ip_block_version ; +struct amdgpu_sriov ; + +extern const struct amdgpu_ip_block_version sriov_host_v1_0_ip_block; + +#endif
drivers/gpu/drm/amd/include/amd_shared.h +2 -0
@@ -91,6 +91,7 @@ enum amd_apu_flags {* @AMD_IP_BLOCK_TYPE_ISP: Image Signal Processor * @AMD_IP_BLOCK_TYPE_RAS: Reliability, Availability, Serviceability * @AMD_IP_BLOCK_TYPE_UALINK: Ultra Accelerator Link +* @AMD_IP_BLOCK_TYPE_SRIOV_HOST: SR-IOV PF host control plane * @AMD_IP_BLOCK_TYPE_NUM: Total number of IP block types */ enum amd_ip_block_type {
@@ -113,6 +114,7 @@ enum amd_ip_block_type {AMD_IP_BLOCK_TYPE_ISP ,AMD_IP_BLOCK_TYPE_RAS ,AMD_IP_BLOCK_TYPE_UALINK , +AMD_IP_BLOCK_TYPE_SRIOV_HOST , AMD_IP_BLOCK_TYPE_NUM, };
drivers/gpu/drm/amd/sriov/Makefile +2 -0
@@ -24,3 +24,5 @@ # AMDGPU SR-IOV PF host support AMD_SRIOV_FILES := + +AMD_SRIOV_FILES += ../sriov/sriov.o
drivers/gpu/drm/amd/sriov/sriov.c new file +357 -0
357 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 9/34 drm/amd/sriov: load PF RLC firmware variant
In reply to Emily DengLoad the SR-IOV RLC firmware image on SR-IOV PF hosts and extend PSP firmware staging for the additional RLC slots in the PF host bundle.
--- drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v13_0.c +5 -1
@@ -72,6 +72,7 @@ MODULE_FIRMWARE("amdgpu/gc_13_0_1_pfp.bin");MODULE_FIRMWARE ("amdgpu/gc_13_0_1_me.bin" );MODULE_FIRMWARE ("amdgpu/gc_13_0_1_mec.bin" );MODULE_FIRMWARE ("amdgpu/gc_13_0_1_rlc.bin" ); +MODULE_FIRMWARE ("amdgpu/gc_13_0_1_rlc_sriov.bin" );MODULE_FIRMWARE ("amdgpu/gc_13_0_1_toc.bin" );static const struct amdgpu_hwip_reg_entry gc_reg_list_13_0[] = {
@@ -614,7 +615,10 @@ static int gfx_v13_0_init_microcode(struct amdgpu_device *adev)if (!amdgpu_sriov_vf (adev)) { err =amdgpu_ucode_request (adev, &adev->gfx.rlc_fw,AMDGPU_UCODE_REQUIRED , -"amdgpu/%s_rlc.bin" , ucode_prefix); +amdgpu_sriov_pf (adev) ? +"amdgpu/%s_rlc_sriov.bin" : +"amdgpu/%s_rlc.bin" , + ucode_prefix);if (err) goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c +6 -0
@@ -746,6 +746,12 @@ static int psp_v15_0_3_get_fw_type(struct amdgpu_firmware_info *ucode,case AMDGPU_UCODE_ID_RLC_DRAM : *type =GFX_FW_TYPE_RLC_DRAM_BOOT ;break ; +case AMDGPU_UCODE_ID_RLC_IRAM_1 : + *type =GFX_FW_TYPE_RLX6_UCODE_CORE1 ; +break ; +case AMDGPU_UCODE_ID_RLC_DRAM_1 : + *type =GFX_FW_TYPE_RLX6_DRAM_BOOT_CORE1 ; +break ;case AMDGPU_UCODE_ID_SMC : *type =GFX_FW_TYPE_SMU ;break ;
Signature · 1 line
2.34.1
RFC PATCH 10/34 drm/amd/sriov: extend PSP GFX interface for IOVM
In reply to Emily DengExtend PSP GFX command definitions, firmware types and debug helpers for SR-IOV IOVM driver support.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 6 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 1 + drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 55 ++++++++++++++++++++++- 4 files changed, 64 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
@@ -871,6 +871,8 @@ static const char *psp_gfx_cmd_name(enum psp_gfx_cmd_id cmd_id)return "DESTROY_VMR" ;case GFX_CMD_ID_PROG_REG :return "PROG_REG" ; +case GFX_CMD_ID_NUM_ENABLED_VFS : +return "NUM_ENABLED_VFS" ;case GFX_CMD_ID_GET_FW_ATTESTATION :return "GET_FW_ATTESTATION" ;case GFX_CMD_ID_LOAD_TOC :
@@ -889,6 +891,8 @@ static const char *psp_gfx_cmd_name(enum psp_gfx_cmd_id cmd_id)return "SPATIAL_PARTITION" ;case GFX_CMD_ID_FB_NPS_MODE :return "NPS_MODE_CHANGE" ; +case GFX_CMD_ID_IOVM_DRV : +return "IOVM_DRV" ;case GFX_CMD_ID_PERF_HW :return "PERF MONITORING HW" ;case GFX_CMD_ID_UAL_GET_INTERFACE_VER :
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +6 -0
@@ -506,6 +506,12 @@ void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header *hdr)DRM_DEBUG ("psp_ipkeymgr_drv_size_bytes: %u\n" ,le32_to_cpu (desc->size_bytes));break ; +case PSP_FW_TYPE_PSP_IOVM_DRV : +DRM_DEBUG ("psp_iovm_drv_version: %u\n" , +le32_to_cpu (desc->fw_version)); +DRM_DEBUG ("psp_iovm_drv_size_bytes: %u\n" , +le32_to_cpu (desc->size_bytes)); +break ;default :DRM_DEBUG ("Unsupported PSP fw type: %d\n" , desc->fw_type);break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +1 -0
@@ -129,6 +129,7 @@ enum psp_fw_type {PSP_FW_TYPE_PSP_RAS_DRV ,PSP_FW_TYPE_PSP_IPKEYMGR_DRV ,PSP_FW_TYPE_PSP_SPDM_DRV , +PSP_FW_TYPE_PSP_IOVM_DRV , PSP_FW_TYPE_MAX_INDEX, };
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h +53 -2
110 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 11/34 drm/amd/sriov: add PSP 15.0.3 IOVM driver bootloader callback
In reply to Emily DengRegister the IOVM driver bootloader load path for PSP 15.0.3 and stage IOVM driver firmware descriptors in the PSP context.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 2 ++ drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c | 7 +++++++ 3 files changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +9 -0
@@ -102,6 +102,7 @@ enum psp_bootloader_cmd {PSP_BL__LOAD_INTFDRV =0xD0000 ,PSP_BL__LOAD_RASDRV =0xE0000 ,PSP_BL__LOAD_IPKEYMGRDRV =0xF0000 , +PSP_BL__LOAD_IOVMDRV =0x130000 ,PSP_BL__DRAM_LONG_TRAIN =0x100000 ,PSP_BL__DRAM_SHORT_TRAIN =0x200000 , PSP_BL__LOAD_TOS_SPL_TABLE = 0x10000000,
@@ -153,6 +154,7 @@ struct psp_funcs {int (*bootloader_load_dbg_drv)(struct psp_context *psp);int (*bootloader_load_ras_drv)(struct psp_context *psp);int (*bootloader_load_ipkeymgr_drv)(struct psp_context *psp); +int (*bootloader_load_iovm_drv)(struct psp_context *psp);int (*bootloader_load_spdm_drv)(struct psp_context *psp);int (*bootloader_load_sos)(struct psp_context *psp); int (*ring_create)(struct psp_context *psp,
@@ -448,6 +450,8 @@ struct psp_context {struct psp_bin_desc ras_drv;struct psp_bin_desc ipkeymgr_drv;struct psp_bin_desc spdm_drv; +struct psp_bin_desc iovm_drv; +bool iovm_enabled;/* tmr buffer */ struct amdgpu_bo *tmr_bo;
@@ -458,6 +462,8 @@ struct psp_context {/* toc firmware */ const struct firmware *toc_fw; +/* iovm driver firmware (iOVM) */ +const struct firmware *iovm_drv_fw;/* cap firmware */ const struct firmware *cap_fw;
@@ -549,6 +555,9 @@ struct amdgpu_psp_funcs {#define psp_bootloader_load_ipkeymgr_drv (psp) \ ((psp)->funcs->bootloader_load_ipkeymgr_drv ? \ (psp)->funcs->bootloader_load_ipkeymgr_drv((psp)) : 0) +#define psp_bootloader_load_iovm_drv (psp) \ + ((psp)->funcs->bootloader_load_iovm_drv ? \ + (psp)->funcs->bootloader_load_iovm_drv((psp)) : 0)#define psp_bootloader_load_spdm_drv (psp) \ ((psp)->funcs->bootloader_load_spdm_drv ? \ (psp)->funcs->bootloader_load_spdm_drv((psp)) : 0)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +2 -0
@@ -813,6 +813,7 @@ FW_VERSION_ATTR(sos_fw_version, 0444, psp.sos.fw_version);FW_VERSION_ATTR (asd_fw_version,0444 , psp.asd_context.bin_desc.fw_version);FW_VERSION_ATTR (ta_ras_fw_version,0444 , psp.ras_context.context.bin_desc.fw_version);FW_VERSION_ATTR (ta_xgmi_fw_version,0444 , psp.xgmi_context.context.bin_desc.fw_version); +FW_VERSION_ATTR (iovm_drv_fw_version,0444 , psp.iovm_drv.fw_version);FW_VERSION_ATTR (smc_fw_version,0444 , pm.fw_version);FW_VERSION_ATTR (mp5_fw_version,0444 , pm.mp5_fw_version);FW_VERSION_ATTR (sdma_fw_version,0444 , sdma.instance[0 ].fw_version);
@@ -833,6 +834,7 @@ static struct attribute *fw_attrs[] = { &dev_attr_mec_fw_version.attr, &dev_attr_mec2_fw_version.attr, &dev_attr_sos_fw_version.attr, &dev_attr_asd_fw_version.attr, &dev_attr_ta_ras_fw_version.attr, &dev_attr_ta_xgmi_fw_version.attr, + &dev_attr_iovm_drv_fw_version.attr, &dev_attr_smc_fw_version.attr, &dev_attr_sdma_fw_version.attr, &dev_attr_sdma2_fw_version.attr, &dev_attr_vcn_fw_version.attr, &dev_attr_dmcu_fw_version.attr, &dev_attr_dmcub_fw_version.attr,
drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c +7 -0
@@ -177,6 +177,12 @@ static int psp_v15_0_3_bootloader_load_ipkeymgr_drv(struct psp_context *psp)return psp_v15_0_3_bootloader_load_component (psp,&psp->ipkeymgr_drv,PSP_BL__LOAD_IPKEYMGRDRV ); } +static int psp_v15_0_3_bootloader_load_iovm_drv (struct psp_context *psp) +{ +return psp_v15_0_3_bootloader_load_component (psp, &psp->iovm_drv, +PSP_BL__LOAD_IOVMDRV ); +} +static int psp_v15_0_3_bootloader_load_sos (struct psp_context *psp) {int ret;
@@ -852,6 +858,7 @@ static const struct psp_funcs psp_v15_0_3_funcs = { .bootloader_load_dbg_drv = psp_v15_0_3_bootloader_load_dbg_drv, .bootloader_load_ras_drv = psp_v15_0_3_bootloader_load_ras_drv, .bootloader_load_ipkeymgr_drv = psp_v15_0_3_bootloader_load_ipkeymgr_drv, + .bootloader_load_iovm_drv = psp_v15_0_3_bootloader_load_iovm_drv, .bootloader_load_sos = psp_v15_0_3_bootloader_load_sos, .ring_create = psp_v15_0_3_ring_create, .ring_stop = psp_v15_0_3_ring_stop,
Signature · 1 line
2.34.1
RFC PATCH 12/34 drm/amd/sriov: update PF PSP init for IOVM firmware
In reply to Emily DengStage SR-IOV PSP firmware in PF-visible VRAM, load the IOVM driver during PSP hardware start, and configure the enabled VF count.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 87 ++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +77 -10
@@ -711,8 +711,12 @@ static int psp_sw_init(struct amdgpu_ip_block *ip_block) } } +/* SR-IOV PSP firmware staging must be in PF-visible VRAM. */ ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG, - (amdgpu_sriov_vf(adev) || adev->debug_use_vram_fw_buf || adev->gmc.xgmi.connected_to_cpu) ? + (amdgpu_sriov_vf(adev) || + amdgpu_sriov_pf(adev) || + adev->gmc.xgmi.connected_to_cpu || + adev->debug_use_vram_fw_buf) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, &psp->fw_pri_bo, &psp->fw_pri_mc_addr,
@@ -766,6 +770,9 @@ static int psp_sw_fini(struct amdgpu_ip_block *ip_block)amdgpu_ucode_release (&psp->ta_fw);amdgpu_ucode_release (&psp->cap_fw);amdgpu_ucode_release (&psp->toc_fw); +amdgpu_ucode_release (&psp->iovm_drv_fw); +memset (&psp->iovm_drv,0 ,sizeof (psp->iovm_drv)); + psp->iovm_enabled = false;kfree (psp->cmd); psp->cmd =NULL ;
@@ -2181,6 +2188,28 @@ static int psp_asd_initialize(struct psp_context *psp)return ret; } +static int psp_set_num_vfs (struct psp_context *psp,uint32_t num_vfs) +{ +struct psp_gfx_cmd_resp *cmd; +int ret; + + cmd =acquire_psp_cmd_buf (psp); + cmd->cmd_id =GFX_CMD_ID_NUM_ENABLED_VFS ; + cmd->cmd.cmd_num_vfs.number_of_vfs = num_vfs; + + ret =psp_cmd_submit_buf (psp,NULL , cmd, psp->fence_buf_mc_addr); +if (!ret && cmd->resp.status) { +dev_err (psp->adev->dev, +"PSP failed to set SR-IOV num_vfs=%u, status=0x%x\n" , + num_vfs, cmd->resp.status); + ret = -EIO ; + } + +release_psp_cmd_buf (psp); + +return ret; +} +static void psp_prep_ta_unload_cmd_buf (struct psp_gfx_cmd_resp *cmd,uint32_t session_id) {
@@ -3538,15 +3567,6 @@ static int psp_hw_start(struct psp_context *psp) } } -if ((is_psp_fw_valid (psp->intf_drv)) && - (psp->funcs->bootloader_load_intf_drv !=NULL )) { - ret =psp_bootloader_load_intf_drv (psp); -if (ret) { -dev_err (adev->dev,"PSP load intf drv failed!\n" ); -return ret; - } - } -if ((is_psp_fw_valid (psp->dbg_drv)) && (psp->funcs->bootloader_load_dbg_drv !=NULL )) { ret =psp_bootloader_load_dbg_drv (psp);
@@ -3583,6 +3603,26 @@ static int psp_hw_start(struct psp_context *psp) } } +if (amdgpu_sriov_pf (adev) && +is_psp_fw_valid (psp->iovm_drv) && + (psp->funcs->bootloader_load_iovm_drv !=NULL )) { + ret =psp_bootloader_load_iovm_drv (psp); +if (ret) { +dev_err (adev->dev,"PSP load iovm_drv failed!\n" ); +return ret; + } + psp->iovm_enabled = true; + } + +if ((is_psp_fw_valid (psp->intf_drv)) && + (psp->funcs->bootloader_load_intf_drv !=NULL )) { + ret =psp_bootloader_load_intf_drv (psp); +if (ret) { +dev_err (adev->dev,"PSP load intf drv failed!\n" ); +return ret; + } + } +if ((is_psp_fw_valid (psp->sos)) && (psp->funcs->bootloader_load_sos !=NULL )) { ret =psp_bootloader_load_sos (psp);
@@ -3600,6 +3640,14 @@ static int psp_hw_start(struct psp_context *psp)return ret; } +if (amdgpu_sriov_pf (adev)) { + ret =psp_set_num_vfs (psp, adev->num_vfs); +if (ret) { +dev_err (adev->dev,"PSP set SR-IOV num_vfs failed!\n" ); +return ret; + } + } +if (!amdgpu_in_reset (adev) && !adev->in_suspend) { ret =psp_update_fw_reservation (psp);if (ret) {
@@ -3942,6 +3990,14 @@ static int psp_prep_load_ip_fw_cmd_buf(struct psp_context *psp,int ret;uint64_t fw_mem_mc_addr = ucode->mc_addr; +if (amdgpu_sriov_pf (psp->adev)) { + ret =psp_copy_fw (psp, ucode->kaddr, ucode->ucode_size); +if (ret) +return ret; + + fw_mem_mc_addr = psp->fw_pri_mc_addr; + } + cmd->cmd_id =GFX_CMD_ID_LOAD_IP_FW ; cmd->cmd.cmd_load_ip_fw.fw_phy_addr_lo =lower_32_bits (fw_mem_mc_addr); cmd->cmd.cmd_load_ip_fw.fw_phy_addr_hi =upper_32_bits (fw_mem_mc_addr);
@@ -4708,6 +4764,12 @@ static int parse_psp_v2_bin_descriptor(struct psp_context *psp, psp->spdm_drv.size_bytes =le32_to_cpu (desc->size_bytes); psp->spdm_drv.start_addr = ucode_start_addr;break ; +case PSP_FW_TYPE_PSP_IOVM_DRV : + psp->iovm_drv.fw_version =le32_to_cpu (desc->fw_version); + psp->iovm_drv.feature_version =le32_to_cpu (desc->fw_version); + psp->iovm_drv.size_bytes =le32_to_cpu (desc->size_bytes); + psp->iovm_drv.start_addr = ucode_start_addr; +break ;default :dev_warn (psp->adev->dev,"Unsupported PSP FW type: %d\n" , desc->fw_type);break ;
@@ -4778,6 +4840,9 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)if (amdgpu_is_kicker_fw (adev)) err =amdgpu_ucode_request (adev, &adev->psp.sos_fw,AMDGPU_UCODE_REQUIRED ,"amdgpu/%s_sos_kicker.bin" , chip_name); +else if (amdgpu_sriov_pf (adev)) + err =amdgpu_ucode_request (adev, &adev->psp.sos_fw,AMDGPU_UCODE_REQUIRED , +"amdgpu/%s_sos_sriov.bin" , chip_name);else err =amdgpu_ucode_request (adev, &adev->psp.sos_fw,AMDGPU_UCODE_REQUIRED ,"amdgpu/%s_sos.bin" , chip_name);
@@ -4867,6 +4932,8 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)return 0 ; out: +amdgpu_ucode_release (&adev->psp.iovm_drv_fw); +memset (&adev->psp.iovm_drv,0 ,sizeof (adev->psp.iovm_drv));amdgpu_ucode_release (&adev->psp.sos_fw);return err;
Signature · 1 line
2.34.1
RFC PATCH 13/34 drm/amd/sriov: add IOVM driver PSP command submission
In reply to Emily DengAdd the PSP-side IOVM driver command submission path used by SR-IOV IOVM transport.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 30 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 6 +++++ 2 files changed, 36 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +30 -0
@@ -4020,6 +4020,36 @@ int psp_execute_ip_fw_load(struct psp_context *psp, ret =psp_cmd_submit_buf (psp, ucode, cmd, psp->fence_buf_mc_addr); } +release_psp_cmd_buf (psp); + +return ret; +} + +int psp_iovm_drv_submit_cmd (struct psp_context *psp, +uint32_t iovm_drv_int_ver, +uint32_t command_id, +const void *command_buf, +size_t command_buf_size, +struct psp_gfx_resp *resp) +{ +struct psp_gfx_cmd_resp *cmd; +int ret; + +if (!psp || !command_buf || !command_buf_size || !resp) +return -EINVAL ; +if (command_buf_size >sizeof (cmd->cmd.cmd_iovm_drv.command_buf)) +return -EINVAL ; + + cmd =acquire_psp_cmd_buf (psp); + cmd->cmd_id =GFX_CMD_ID_IOVM_DRV ; + cmd->cmd.cmd_iovm_drv.iovm_drv_int_ver = iovm_drv_int_ver; + cmd->cmd.cmd_iovm_drv.command_id = command_id; +memcpy (&cmd->cmd.cmd_iovm_drv.command_buf, command_buf, + command_buf_size); + + ret =psp_cmd_submit_buf (psp,NULL , cmd, psp->fence_buf_mc_addr); +if (!ret) +memcpy (resp, &cmd->resp,sizeof (*resp));release_psp_cmd_buf (psp);
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -0
@@ -629,6 +629,12 @@ extern int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_indeint psp_execute_ip_fw_load (struct psp_context *psp,struct amdgpu_firmware_info *ucode); +int psp_iovm_drv_submit_cmd (struct psp_context *psp, +uint32_t iovm_drv_int_ver, +uint32_t command_id, +const void *command_buf, +size_t command_buf_size, +struct psp_gfx_resp *resp);int psp_gpu_reset (struct amdgpu_device *adev);
Signature · 1 line
2.34.1
RFC PATCH 14/34 drm/amd/sriov: add IOVM PSP command helpers
In reply to Emily DengAdd SR-IOV IOVM command helpers for GPUIOV, VF access, framebuffer assignment and FFBM map/query operations.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov_iovm.c | 715 +++++++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_iovm.h | 111 ++++ 3 files changed, 827 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_iovm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_iovm.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -26,3 +26,4 @@ AMD_SRIOV_FILES := AMD_SRIOV_FILES += ../sriov/sriov.o +AMD_SRIOV_FILES += ../sriov/sriov_iovm.o
drivers/gpu/drm/amd/sriov/sriov_iovm.c new file +715 -0
715 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_iovm.h new file +111 -0
111 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 15/34 drm/amd/sriov: add GPUIOV service
In reply to Emily DengAdd GPUIOV VSEC discovery, control-block management, VF PCI exposure helpers and command submission through register or IOVM-backed paths.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 82 ++++ drivers/gpu/drm/amd/sriov/sriov.h | 12 + drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 452 +++++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_gpuiov.h | 136 +++++++ 5 files changed, 683 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gpuiov.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gpuiov.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -27,3 +27,4 @@ AMD_SRIOV_FILES := AMD_SRIOV_FILES += ../sriov/sriov.o AMD_SRIOV_FILES += ../sriov/sriov_iovm.o +AMD_SRIOV_FILES += ../sriov/sriov_gpuiov.o
drivers/gpu/drm/amd/sriov/sriov.c +82 -0
106 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov.h +12 -0
@@ -25,8 +25,11 @@#ifndef __SRIOV_H__#define __SRIOV_H__ +#include <linux/sizes.h> #include <linux/types.h> +#include "sriov_gpuiov.h" +struct amdgpu_device ; struct sriov_init_func {
@@ -43,11 +46,18 @@ struct sriov_init_func {#define SRIOV_MAX_INIT_FUNCS 16 +#define SRIOV_VF_FB_ALIGNMENT SZ_16M + +#define SRIOV_FLAG_GC_REG_RLC_EN BIT_ULL(20) +struct amdgpu_sriov {struct amdgpu_device *adev; +u64 flags; +struct sriov_gpuiov gpuiov;const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs; +bool pci_vfs_enabled;bool sw_init;bool hw_init;bool late_init;
@@ -55,5 +65,7 @@ struct amdgpu_sriov {void sriov_init_func_add (struct amdgpu_device *adev,const struct sriov_init_func *func); +int sriov_host_enable_vfs (struct amdgpu_device *adev); +void sriov_host_disable_vfs (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/sriov/sriov_gpuiov.c new file +452 -0
452 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_gpuiov.h new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 16/34 drm/amd/sriov: add GC 13.0.1 GPUIOV provider
In reply to Emily DengAdd the GC GPUIOV backend for control-block discovery, command submission and active-VF queries.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 16 ++ drivers/gpu/drm/amd/sriov/sriov.h | 22 ++ drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c | 273 ++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.h | 32 +++ drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 112 +++++++- drivers/gpu/drm/amd/sriov/sriov_gpuiov.h | 15 ++ 7 files changed, 463 insertions(+), 8 deletions(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -28,3 +28,4 @@ AMD_SRIOV_FILES := AMD_SRIOV_FILES += ../sriov/sriov.o AMD_SRIOV_FILES += ../sriov/sriov_iovm.o AMD_SRIOV_FILES += ../sriov/sriov_gpuiov.o +AMD_SRIOV_FILES += ../sriov/sriov_gfx_v13_0.o
drivers/gpu/drm/amd/sriov/sriov.c +16 -0
@@ -27,6 +27,7 @@#include "amdgpu.h" #include "amdgpu_virt.h" #include "sriov.h" +#include "sriov_gfx_v13_0.h" #define SRIOV_PCI_SRIOV_CAP_VF_10BIT_TAG BIT(2)#define SRIOV_PCI_SRIOV_CTRL_VF_10BIT_TAG BIT(5)
@@ -48,6 +49,17 @@ void sriov_init_func_add(struct amdgpu_device *adev, sriov->init_funcs[sriov->num_init_funcs++] = func; } +static int sriov_set_gfx_funcs (struct amdgpu_device *adev) +{ +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (13 ,0 ,1 ): + adev->sriov->gfx_funcs = &sriov_gfx_v13_0_funcs; +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +static int sriov_set_init_funcs (struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func);
@@ -73,6 +85,10 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block) sriov->adev = adev; adev->sriov = sriov; + r =sriov_set_gfx_funcs (adev); +if (r) + goto err_fini; + r =sriov_set_init_funcs (adev);if (r) goto err_fini;
drivers/gpu/drm/amd/sriov/sriov.h +22 -0
@@ -44,6 +44,27 @@ struct sriov_init_func {void (*late_fini)(struct amdgpu_device *adev); }; +struct sriov_gfx_funcs { +const struct sriov_gpuiov_hw_sched_static_config * + (*get_gpuiov_ctrl_blocks)(unsigned int *num_blocks); +int (*toggle_rlcg_vf_interface)(struct amdgpu_device *adev, +unsigned int vf_idx,bool enable); +int (*gpuiov_set_cmd)(struct amdgpu_device *adev, +unsigned int hw_sched_id, +u32 vf_idx,u32 next_vf_idx,u32 cmd); +bool (*gpuiov_is_cmd_complete)(struct amdgpu_device *adev, +unsigned int hw_sched_id, +u32 *command,u32 *status); +int (*gpuiov_get_active_vf_idx)(struct amdgpu_device *adev, +unsigned int hw_sched_id, +unsigned int *vf_idx); +int (*gpuiov_get_active_vf_status)(struct amdgpu_device *adev, +unsigned int hw_sched_id, +u8 *status); +u32 (*gpuiov_cp_sched_state)(struct amdgpu_device *adev, +unsigned int vf_idx); +}; +#define SRIOV_MAX_INIT_FUNCS 16#define SRIOV_VF_FB_ALIGNMENT SZ_16M
@@ -52,6 +73,7 @@ struct sriov_init_func {struct amdgpu_sriov {struct amdgpu_device *adev; +const struct sriov_gfx_funcs *gfx_funcs;u64 flags;struct sriov_gpuiov gpuiov;const struct sriov_init_func
drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c new file +273 -0
273 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_GFX_V13_0_H__ +#define __SRIOV_GFX_V13_0_H__ + +#include "sriov.h" + +extern const struct sriov_gfx_funcs sriov_gfx_v13_0_funcs; + +#endif
drivers/gpu/drm/amd/sriov/sriov_gpuiov.c +104 -8
156 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_gpuiov.h +15 -0
@@ -118,6 +118,21 @@ struct sriov_gpuiov { ctrl_blocks[SRIOV_GPUIOV_MAX_CTRL_BLOCKS ]; }; +#define sriov_is_hw_sched_type_gfx (adev, hw_sched_id) \ + sriov_gpuiov_is_hw_sched_type_gfx(&(adev)->sriov->gpuiov, (hw_sched_id)) + +static inline bool +sriov_gpuiov_is_hw_sched_type_gfx (struct sriov_gpuiov *gpuiov, +unsigned int hw_sched_id) +{ +if (!gpuiov || hw_sched_id >= gpuiov->num_ctrl_blocks) +return false; + +return gpuiov->ctrl_blocks[hw_sched_id].enabled && + gpuiov->ctrl_blocks[hw_sched_id].hw_sched_type == +SRIOV_GPUIOV_SCHED_GFX ; +} +extern const struct sriov_init_func sriov_gpuiov_func;bool sriov_gpuiov_is_cmd_complete (struct amdgpu_device *adev,unsigned int hw_sched_id);
Signature · 1 line
2.34.1
RFC PATCH 17/34 drm/amd/sriov: add GMC 13.0.1 GPUIOV provider
In reply to Emily DengAdd the GMC GPUIOV backend for VF framebuffer assignment.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 16 +++++ drivers/gpu/drm/amd/sriov/sriov.h | 7 ++ drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.c | 77 +++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.h | 32 +++++++++ drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 15 +++- 6 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -29,3 +29,4 @@ AMD_SRIOV_FILES += ../sriov/sriov.o AMD_SRIOV_FILES += ../sriov/sriov_iovm.o AMD_SRIOV_FILES += ../sriov/sriov_gpuiov.o AMD_SRIOV_FILES += ../sriov/sriov_gfx_v13_0.o +AMD_SRIOV_FILES += ../sriov/sriov_gmc_v13_0.o
drivers/gpu/drm/amd/sriov/sriov.c +16 -0
@@ -28,6 +28,7 @@#include "amdgpu_virt.h" #include "sriov.h" #include "sriov_gfx_v13_0.h" +#include "sriov_gmc_v13_0.h" #define SRIOV_PCI_SRIOV_CAP_VF_10BIT_TAG BIT(2)#define SRIOV_PCI_SRIOV_CTRL_VF_10BIT_TAG BIT(5)
@@ -60,6 +61,17 @@ static int sriov_set_gfx_funcs(struct amdgpu_device *adev) } } +static int sriov_set_gmc_funcs (struct amdgpu_device *adev) +{ +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (13 ,0 ,1 ): + adev->sriov->gmc_funcs = &sriov_gmc_v13_0_funcs; +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +static int sriov_set_init_funcs (struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func);
@@ -89,6 +101,10 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block)if (r) goto err_fini; + r =sriov_set_gmc_funcs (adev); +if (r) + goto err_fini; + r =sriov_set_init_funcs (adev);if (r) goto err_fini;
drivers/gpu/drm/amd/sriov/sriov.h +7 -0
@@ -65,6 +65,12 @@ struct sriov_gfx_funcs { unsigned int vf_idx); }; +struct sriov_gmc_funcs { +int (*gpuiov_set_vf_fb)(struct amdgpu_device *adev, +unsigned int vf_idx,u64 fb_offset, +u64 fb_size); +}; +#define SRIOV_MAX_INIT_FUNCS 16#define SRIOV_VF_FB_ALIGNMENT SZ_16M
@@ -74,6 +80,7 @@ struct sriov_gfx_funcs {struct amdgpu_sriov {struct amdgpu_device *adev;const struct sriov_gfx_funcs *gfx_funcs; +const struct sriov_gmc_funcs *gmc_funcs;u64 flags;struct sriov_gpuiov gpuiov;const struct sriov_init_func
drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.c new file +77 -0
77 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_gmc_v13_0.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_GMC_V13_0_H__ +#define __SRIOV_GMC_V13_0_H__ + +#include "sriov.h" + +extern const struct sriov_gmc_funcs sriov_gmc_v13_0_funcs; + +#endif
drivers/gpu/drm/amd/sriov/sriov_gpuiov.c +14 -1
@@ -335,7 +335,20 @@ int sriov_gpuiov_set_vf_fb(struct amdgpu_device *adev,unsigned int vf_idx, u64 fb_offset, u64 fb_size) { - return -EOPNOTSUPP; + if (!adev->sriov->gpuiov.hw_init) + return -EINVAL; +if (vf_idx >= adev->num_vfs) +return -EINVAL ; +if (!IS_ALIGNED (fb_offset, (u64 )SRIOV_VF_FB_ALIGNMENT ) || + !IS_ALIGNED (fb_size, (u64 )SRIOV_VF_FB_ALIGNMENT )) +return -EINVAL ; + +if (!adev->sriov->gmc_funcs || + !adev->sriov->gmc_funcs->gpuiov_set_vf_fb) +return -EOPNOTSUPP ; + +return adev->sriov->gmc_funcs->gpuiov_set_vf_fb (adev, vf_idx, + fb_offset, fb_size); } bool sriov_gpuiov_is_cmd_complete(struct amdgpu_device *adev,
Signature · 1 line
2.34.1
RFC PATCH 18/34 drm/amd/sriov: add PF mailbox service
In reply to Emily DengAdd PF mailbox message decode helpers and mailbox state types.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.h | 2 + drivers/gpu/drm/amd/sriov/sriov_mailbox.c | 50 +++++++++++++ drivers/gpu/drm/amd/sriov/sriov_mailbox.h | 91 +++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_mailbox.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_mailbox.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -30,3 +30,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_iovm.o AMD_SRIOV_FILES += ../sriov/sriov_gpuiov.o AMD_SRIOV_FILES += ../sriov/sriov_gfx_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_gmc_v13_0.o +AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o
drivers/gpu/drm/amd/sriov/sriov.h +2 -0
@@ -29,6 +29,7 @@#include <linux/types.h> #include "sriov_gpuiov.h" +#include "sriov_mailbox.h" struct amdgpu_device ;
@@ -83,6 +84,7 @@ struct amdgpu_sriov {const struct sriov_gmc_funcs *gmc_funcs;u64 flags;struct sriov_gpuiov gpuiov; +struct sriov_mailbox mailbox;const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs;
drivers/gpu/drm/amd/sriov/sriov_mailbox.c new file +50 -0
50 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_mailbox.h new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 19/34 drm/amd/sriov: add NBIF 7.10.0 PF mailbox backend
In reply to Emily DengAdd the NBIF PF mailbox backend with interrupt handling, direct IRQ dispatch and SR-IOV host interrupt routing.
--- drivers/gpu/drm/amd/amdgpu/nbif_v7_10.c | 4 + drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 17 + drivers/gpu/drm/amd/sriov/sriov.h | 18 + drivers/gpu/drm/amd/sriov/sriov_mailbox.c | 501 +++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_mailbox.h | 2 - drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c | 221 ++++++++ drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.h | 32 ++ 8 files changed, 794 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.h
drivers/gpu/drm/amd/amdgpu/nbif_v7_10.c +4 -0
@@ -233,6 +233,10 @@ static void nbif_v7_10_ih_control(struct amdgpu_device *adev)/* BIF_BX0_INTERRUPT_CNTL__IH_REQ_NONSNOOP_EN_MASK=1 if ring is in non-cacheable memory, e.g., vram */ interrupt_cntl =REG_SET_FIELD (interrupt_cntl,BIF_BX0_INTERRUPT_CNTL ,IH_REQ_NONSNOOP_EN ,0 ); +if (amdgpu_sriov_pf (adev)) + interrupt_cntl =REG_SET_FIELD (interrupt_cntl, +BIF_BX0_INTERRUPT_CNTL , +GEN_IH_INT_EN ,1 );WREG32_SOC15 (NBIO ,0 , regBIF_BX0_INTERRUPT_CNTL, interrupt_cntl); }
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -31,3 +31,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_gpuiov.o AMD_SRIOV_FILES += ../sriov/sriov_gfx_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_gmc_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o +AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o
drivers/gpu/drm/amd/sriov/sriov.c +17 -0
@@ -29,6 +29,7 @@#include "sriov.h" #include "sriov_gfx_v13_0.h" #include "sriov_gmc_v13_0.h" +#include "sriov_nbif_v7_10.h" #define SRIOV_PCI_SRIOV_CAP_VF_10BIT_TAG BIT(2)#define SRIOV_PCI_SRIOV_CTRL_VF_10BIT_TAG BIT(5)
@@ -61,6 +62,17 @@ static int sriov_set_gfx_funcs(struct amdgpu_device *adev) } } +static int sriov_set_nbio_funcs (struct amdgpu_device *adev) +{ +switch (amdgpu_ip_version (adev,NBIO_HWIP ,0 )) { +case IP_VERSION (7 ,10 ,0 ): + adev->sriov->nbio_funcs = &sriov_nbif_v7_10_nbio_funcs; +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +static int sriov_set_gmc_funcs (struct amdgpu_device *adev) {switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) {
@@ -75,6 +87,7 @@ static int sriov_set_gmc_funcs(struct amdgpu_device *adev)static int sriov_set_init_funcs (struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func); +sriov_init_func_add (adev, &sriov_mailbox_func);return 0 ; }
@@ -101,6 +114,10 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block)if (r) goto err_fini; + r =sriov_set_nbio_funcs (adev); +if (r) + goto err_fini; + r =sriov_set_gmc_funcs (adev);if (r) goto err_fini;
drivers/gpu/drm/amd/sriov/sriov.h +18 -0
@@ -72,6 +72,23 @@ struct sriov_gmc_funcs { u64 fb_size); }; +struct sriov_nbio_funcs { +int (*mailbox_irq_enable)(struct amdgpu_device *adev, +bool valid_enable,bool ack_enable); +int (*mailbox_get_index)(struct amdgpu_device *adev, +unsigned int *vf_idx); +int (*mailbox_update_index)(struct amdgpu_device *adev, +unsigned int vf_idx); +int (*mailbox_rcv_msg)(struct amdgpu_device *adev,unsigned int vf_idx, +int offset,u32 *msg_data); +int (*mailbox_trn_msg)(struct amdgpu_device *adev,unsigned int vf_idx, +int offset,u32 msg_data); +int (*mailbox_trn_msg_valid)(struct amdgpu_device *adev, +unsigned int vf_idx,bool valid); +int (*mailbox_ack_msg)(struct amdgpu_device *adev,unsigned int vf_idx); +int (*mailbox_reset)(struct amdgpu_device *adev); +}; +#define SRIOV_MAX_INIT_FUNCS 16#define SRIOV_VF_FB_ALIGNMENT SZ_16M
@@ -81,6 +98,7 @@ struct sriov_gmc_funcs {struct amdgpu_sriov {struct amdgpu_device *adev;const struct sriov_gfx_funcs *gfx_funcs; +const struct sriov_nbio_funcs *nbio_funcs;const struct sriov_gmc_funcs *gmc_funcs;u64 flags;struct sriov_gpuiov gpuiov;
drivers/gpu/drm/amd/sriov/sriov_mailbox.c +501 -0
510 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_mailbox.h +0 -2
@@ -53,7 +53,6 @@ struct sriov_mailbox_vf_state {u32 msg_trn_dw[4 ];bool rcv_msg_acked;bool trn_msg_valid; -bool pending_pf2vf_ack; };struct sriov_mailbox {
@@ -71,7 +70,6 @@ struct sriov_mailbox {u64 dropped_invalid_vf_cnt;/* Serializes mailbox register access and the counters. */ spinlock_t lock; -struct work_struct work;struct sriov_mailbox_vf_state *state_vf;struct amdgpu_irq_src ack_irq;struct amdgpu_irq_src rcv_irq;
drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c new file +221 -0
221 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_NBIF_V7_10_H__ +#define __SRIOV_NBIF_V7_10_H__ + +#include "sriov.h" + +extern const struct sriov_nbio_funcs sriov_nbif_v7_10_nbio_funcs; + +#endif
Signature · 1 line
2.34.1
RFC PATCH 20/34 drm/amd/sriov: add FFBM service
In reply to Emily DengAdd FFBM fragment setup, initialization, PF reserved mapping and VF map/unmap helpers backed by IOVM commands. Provide GPA-to-SPA translation and mapping queries used by VFMGR resource setup.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 1 + drivers/gpu/drm/amd/sriov/sriov.h | 2 + drivers/gpu/drm/amd/sriov/sriov_ffbm.c | 332 +++++++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_ffbm.h | 71 ++++++ 5 files changed, 407 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ffbm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ffbm.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -32,3 +32,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_gfx_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_gmc_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o +AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o
drivers/gpu/drm/amd/sriov/sriov.c +1 -0
@@ -88,6 +88,7 @@ static int sriov_set_init_funcs(struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func);sriov_init_func_add (adev, &sriov_mailbox_func); +sriov_init_func_add (adev, &sriov_ffbm_func);return 0 ; }
drivers/gpu/drm/amd/sriov/sriov.h +2 -0
@@ -30,6 +30,7 @@#include "sriov_gpuiov.h" #include "sriov_mailbox.h" +#include "sriov_ffbm.h" struct amdgpu_device ;
@@ -103,6 +104,7 @@ struct amdgpu_sriov {u64 flags;struct sriov_gpuiov gpuiov;struct sriov_mailbox mailbox; +struct sriov_ffbm ffbm;const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs;
drivers/gpu/drm/amd/sriov/sriov_ffbm.c new file +332 -0
332 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_ffbm.h new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 21/34 drm/amd/sriov: add VF manager
In reply to Emily DengAdd VFMGR per-VF state, init/fini hooks and SR-IOV host service ordering.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 1 + drivers/gpu/drm/amd/sriov/sriov.h | 3 + drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 114 ++++++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.h | 96 ++++++++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_vfmgr.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_vfmgr.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -33,3 +33,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_gmc_v13_0.o AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o +AMD_SRIOV_FILES += ../sriov/sriov_vfmgr.o
drivers/gpu/drm/amd/sriov/sriov.c +1 -0
@@ -89,6 +89,7 @@ static int sriov_set_init_funcs(struct amdgpu_device *adev)sriov_init_func_add (adev, &sriov_gpuiov_func);sriov_init_func_add (adev, &sriov_mailbox_func);sriov_init_func_add (adev, &sriov_ffbm_func); +sriov_init_func_add (adev, &sriov_vfmgr_func);return 0 ; }
drivers/gpu/drm/amd/sriov/sriov.h +3 -0
@@ -31,6 +31,7 @@#include "sriov_gpuiov.h" #include "sriov_mailbox.h" #include "sriov_ffbm.h" +#include "sriov_vfmgr.h" struct amdgpu_device ;
@@ -105,6 +106,8 @@ struct amdgpu_sriov {struct sriov_gpuiov gpuiov;struct sriov_mailbox mailbox;struct sriov_ffbm ffbm; +struct sriov_vfmgr vfmgr; +struct sriov_vf_state vfs[SRIOV_MAX_VF_SLOT ];const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs;
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c new file +114 -0
114 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.h new file +96 -0
96 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 22/34 drm/amd/sriov: add VF resource setup
In reply to Emily DengCompute PF/VF framebuffer layout, map VF BARs through FFBM, assign VF framebuffer through GPUIOV and reserve VF-visible VRAM.
--- .../gpu/drm/amd/amdgpu/amdgpu_sriov_host.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 5 + drivers/gpu/drm/amd/sriov/sriov.c | 71 +++++ drivers/gpu/drm/amd/sriov/sriov.h | 2 + drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 281 ++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.h | 14 + 6 files changed, 374 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_sriov_host.h +1 -0
@@ -31,6 +31,7 @@ struct amdgpu_device;struct amdgpu_ip_block_version ;struct amdgpu_sriov ; +int sriov_host_reserve_vf_vram (struct amdgpu_device *adev);extern const struct amdgpu_ip_block_version sriov_host_v1_0_ip_block;#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -0
@@ -59,6 +59,7 @@#include "amdgpu_ras_mgr.h" #include "amdgpu_hmm.h" #include "amdgpu_atomfirmware.h" +#include "amdgpu_sriov_host.h" #include "amdgpu_res_cursor.h" #include "bif/bif_4_1_d.h" #include "kfd_svm.h"
@@ -2161,6 +2162,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)dev_err (adev->dev,"Failed initializing VRAM heap.\n" ); goto err_fini; } + + r =sriov_host_reserve_vf_vram (adev); +if (r) +return r; }/* Change the size here instead of the init above so only lpfn is affected */
drivers/gpu/drm/amd/sriov/sriov.c +71 -0
90 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov.h +2 -0
@@ -108,6 +108,8 @@ struct amdgpu_sriov {struct sriov_ffbm ffbm;struct sriov_vfmgr vfmgr;struct sriov_vf_state vfs[SRIOV_MAX_VF_SLOT ]; +u64 vf_reserve_offset; +u64 vf_reserve_size;const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs;
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +281 -0
318 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.h +14 -0
@@ -25,6 +25,7 @@#ifndef __SRIOV_VFMGR_H__#define __SRIOV_VFMGR_H__ +#include <linux/bits.h> #include <linux/types.h> #include "amdgv_sriovmsg.h"
@@ -91,6 +92,19 @@ struct sriov_vfmgr { struct sriov_vf_resource *resources; }; +enum sriov_vf_access_select { +SRIOV_VF_ACCESS_FB =BIT (0 ), +SRIOV_VF_ACCESS_DOORBELL =BIT (1 ), +SRIOV_VF_ACCESS_MMIO_REG_WRITE =BIT (2 ), +SRIOV_VF_ACCESS_ALL =SRIOV_VF_ACCESS_FB | +SRIOV_VF_ACCESS_DOORBELL | +SRIOV_VF_ACCESS_MMIO_REG_WRITE , +}; + +int sriov_vfmgr_set_vf_access (struct amdgpu_device *adev, +unsigned int vf_idx,u32 access_select, +bool enable); +extern const struct sriov_init_func sriov_vfmgr_func;#endif
Signature · 1 line
2.34.1
RFC PATCH 23/34 drm/amd/sriov: add PSP 15.0.3 VF access gate provider
In reply to Emily DengAdd the PSP VF access gate backend for mailbox interrupt routing, guest MC configuration and VF firmware clear commands.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 6 + drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 16 + drivers/gpu/drm/amd/sriov/sriov.h | 12 + drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.c | 298 +++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.h | 32 ++ 7 files changed, 370 insertions(+), 6 deletions(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.h
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -6
@@ -933,10 +933,9 @@ static bool psp_err_warn(struct psp_context *psp)return true; } -static int -psp_cmd_submit_buf (struct psp_context *psp, -struct amdgpu_firmware_info *ucode, -struct psp_gfx_cmd_resp *cmd,uint64_t fence_mc_addr) +int psp_cmd_submit_buf (struct psp_context *psp, +struct amdgpu_firmware_info *ucode, +struct psp_gfx_cmd_resp *cmd,uint64_t fence_mc_addr) {int ret;int index;
@@ -1023,7 +1022,7 @@ psp_cmd_submit_buf(struct psp_context *psp,return ret; } -static struct psp_gfx_cmd_resp *acquire_psp_cmd_buf (struct psp_context *psp) +struct psp_gfx_cmd_resp *acquire_psp_cmd_buf (struct psp_context *psp) {struct psp_gfx_cmd_resp *cmd = psp->cmd;
@@ -1034,7 +1033,7 @@ static struct psp_gfx_cmd_resp *acquire_psp_cmd_buf(struct psp_context *psp)return cmd; } -static void release_psp_cmd_buf (struct psp_context *psp) +void release_psp_cmd_buf (struct psp_context *psp) {mutex_unlock (&psp->mutex); }
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -0
@@ -629,6 +629,12 @@ extern int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_indeint psp_execute_ip_fw_load (struct psp_context *psp,struct amdgpu_firmware_info *ucode); +struct psp_gfx_cmd_resp *acquire_psp_cmd_buf (struct psp_context *psp); +/* The caller must hold the command buffer acquired above. */ +int psp_cmd_submit_buf (struct psp_context *psp, +struct amdgpu_firmware_info *ucode, +struct psp_gfx_cmd_resp *cmd,uint64_t fence_mc_addr); +void release_psp_cmd_buf (struct psp_context *psp); int psp_iovm_drv_submit_cmd(struct psp_context *psp, uint32_t iovm_drv_int_ver, uint32_t command_id,
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -34,3 +34,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o AMD_SRIOV_FILES += ../sriov/sriov_vfmgr.o +AMD_SRIOV_FILES += ../sriov/sriov_psp_15_0_3.o
drivers/gpu/drm/amd/sriov/sriov.c +16 -0
@@ -32,6 +32,7 @@#include "sriov_gfx_v13_0.h" #include "sriov_gmc_v13_0.h" #include "sriov_nbif_v7_10.h" +#include "sriov_psp_15_0_3.h" #define SRIOV_RUNTIME_RESERVE SZ_512M#define SRIOV_DEFAULT_PF_SIZE SZ_256M
@@ -90,6 +91,17 @@ static int sriov_set_gmc_funcs(struct amdgpu_device *adev) } } +static int sriov_set_psp_funcs (struct amdgpu_device *adev) +{ +switch (amdgpu_ip_version (adev,MP0_HWIP ,0 )) { +case IP_VERSION (15 ,0 ,3 ): + adev->sriov->psp_funcs = &sriov_psp_15_0_3_funcs; +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +static int sriov_set_init_funcs (struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func);
@@ -130,6 +142,10 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block)if (r) goto err_fini; + r =sriov_set_psp_funcs (adev); +if (r) + goto err_fini; + r =sriov_set_init_funcs (adev);if (r) goto err_fini;
drivers/gpu/drm/amd/sriov/sriov.h +12 -0
@@ -91,6 +91,17 @@ struct sriov_nbio_funcs {int (*mailbox_reset)(struct amdgpu_device *adev); }; +struct sriov_psp_funcs { +int (*set_mb_int)(struct amdgpu_device *adev,unsigned int vf_idx, +bool enable); +int (*get_mb_int_status)(struct amdgpu_device *adev, +unsigned int vf_idx,bool *enabled, +u32 *mb_status); +int (*program_guest_mc_settings)(struct amdgpu_device *adev, +unsigned int vf_idx,u64 vf_fb_size); +int (*clear_vf_fw)(struct amdgpu_device *adev,unsigned int vf_idx); +}; +#define SRIOV_MAX_INIT_FUNCS 16#define SRIOV_VF_FB_ALIGNMENT SZ_16M
@@ -102,6 +113,7 @@ struct amdgpu_sriov {const struct sriov_gfx_funcs *gfx_funcs;const struct sriov_nbio_funcs *nbio_funcs;const struct sriov_gmc_funcs *gmc_funcs; +const struct sriov_psp_funcs *psp_funcs;u64 flags;struct sriov_gpuiov gpuiov;struct sriov_mailbox mailbox;
drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.c new file +298 -0
298 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_psp_15_0_3.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_PSP_15_0_3_H__ +#define __SRIOV_PSP_15_0_3_H__ + +struct sriov_psp_funcs ; + +extern const struct sriov_psp_funcs sriov_psp_15_0_3_funcs; + +#endif
Signature · 1 line
2.34.1
RFC PATCH 24/34 drm/amd/sriov: add NBIF 7.10.0 VF access gate headers
In reply to Emily DengAdd NBIF 7.10.0 offset and sh_mask definitions used by the VF access gate backend.
--- .../amd/include/asic_reg/nbif/nbif_7_10_0_offset.h | 6 ++++++ .../amd/include/asic_reg/nbif/nbif_7_10_0_sh_mask.h | 11 +++++++++++ 2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/include/asic_reg/nbif/nbif_7_10_0_offset.h +6 -0
@@ -5557,6 +5557,8 @@#define regGDC_S2A0_S2A_DOORBELL_ENTRY_3_CTRL_BASE_IDX 2#define regGDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL 0x01d3#define regGDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL_BASE_IDX 2 +#define regGDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1 0x01d4 +#define regGDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1_BASE_IDX 2#define regGDC_S2A0_S2A_DOORBELL_ENTRY_5_CTRL 0x01d5#define regGDC_S2A0_S2A_DOORBELL_ENTRY_5_CTRL_BASE_IDX 2#define regGDC_S2A0_S2A_DOORBELL_ENTRY_6_CTRL 0x01d7
@@ -10373,6 +10375,10 @@#define regBIF_BX_DEV0_EPF0_VF7_0_BIF_VMHV_MAILBOX_BASE_IDX 2#define regBIF_BX0_VF_REGWR_EN 0x0124#define regBIF_BX0_VF_REGWR_EN_BASE_IDX 2 +#define regBIF_BX0_VF_DOORBELL_EN 0x0125 +#define regBIF_BX0_VF_DOORBELL_EN_BASE_IDX 2 +#define regBIF_BX0_VF_FB_EN 0x0126 +#define regBIF_BX0_VF_FB_EN_BASE_IDX 2#define regDOORBELL_ACCESS_EN_PF 0x4f3810#define regDOORBELL_ACCESS_EN_PF_BASE_IDX 3#define regDOORBELL_ACCESS_EN_VF0 0x4f3811
drivers/gpu/drm/amd/include/asic_reg/nbif/nbif_7_10_0_sh_mask.h +11 -0
@@ -20355,6 +20355,17 @@#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL__S2A_DOORBELL_PORT4_NEED_DEDUCT_RANGE_OFFSET_MASK 0x04000000L#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL__S2A_DOORBELL_PORT4_DROP_EN_MASK 0x08000000L#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL__S2A_DOORBELL_PORT4_AWADDR_31_28_VALUE_MASK 0xF0000000L +//GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_PORT_TYPE__SHIFT 0x0 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_DIEID__SHIFT 0x2 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_PORT_ID__SHIFT 0x4 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_OVERRIDE_POISON_DATA__SHIFT 0x6 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_4K_PAGE_DECODE_DISABLE__SHIFT 0x7 +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_PORT_TYPE_MASK 0x00000003L +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_DIEID_MASK 0x0000000CL +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_TARGET_PORT_ID_MASK 0x00000030L +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_OVERRIDE_POISON_DATA_MASK 0x00000040L +#define GDC_S2A0_S2A_DOORBELL_ENTRY_4_CTRL1__S2A_DOORBELL_PORT4_4K_PAGE_DECODE_DISABLE_MASK 0x00000080L//GDC_S2A0_S2A_DOORBELL_ENTRY_5_CTRL #define GDC_S2A0_S2A_DOORBELL_ENTRY_5_CTRL__S2A_DOORBELL_PORT5_ENABLE__SHIFT 0x0#define GDC_S2A0_S2A_DOORBELL_ENTRY_5_CTRL__S2A_DOORBELL_PORT5_AWID__SHIFT 0x1
Signature · 1 line
2.34.1
RFC PATCH 25/34 drm/amd/sriov: add NBIF 7.10.0 VF access gate backend
In reply to Emily DengAdd the NBIF VF access gate backend for VF framebuffer, doorbell, MMIO write and GPUIOV gates.
--- drivers/gpu/drm/amd/sriov/sriov.h | 12 ++ drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c | 180 +++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 66 +++++++ 3 files changed, 258 insertions(+)
drivers/gpu/drm/amd/sriov/sriov.h +12 -0
@@ -34,6 +34,7 @@#include "sriov_vfmgr.h" struct amdgpu_device ; +struct pci_dev ;struct sriov_init_func {const char *name;
@@ -75,6 +76,14 @@ struct sriov_gmc_funcs { };struct sriov_nbio_funcs { +void (*enable_func_doorbell_access)(struct amdgpu_device *adev, +bool enable); +void (*assign_multi_media_doorbell)(struct amdgpu_device *adev); +void (*enable_vf_access_mmio_over_512k)(struct amdgpu_device *adev); +void (*enable_vf_reg_write_access)(struct amdgpu_device *adev, +unsigned int vf_idx); +void (*enable_pci_atomic_request)(struct amdgpu_device *adev); +void (*disable_vf_flr)(struct amdgpu_device *adev);int (*mailbox_irq_enable)(struct amdgpu_device *adev,bool valid_enable,bool ack_enable); int (*mailbox_get_index)(struct amdgpu_device *adev,
@@ -89,6 +98,9 @@ struct sriov_nbio_funcs { unsigned int vf_idx, bool valid);int (*mailbox_ack_msg)(struct amdgpu_device *adev,unsigned int vf_idx);int (*mailbox_reset)(struct amdgpu_device *adev); +int (*gpuiov_set_vf_access)(struct amdgpu_device *adev, +struct pci_dev *pdev,unsigned int vf_idx, +u32 access_mask); };struct sriov_psp_funcs {
drivers/gpu/drm/amd/sriov/sriov_nbif_v7_10.c +180 -0
203 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +66 -0
98 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 26/34 drm/amd/sriov: add VF mailbox boot layout
In reply to Emily DengDefine PF/VF mailbox offsets, PF2VF/VF2PF message layout, critical region negotiation fields and mailbox message helpers.
--- drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 13 +- drivers/gpu/drm/amd/sriov/sriov.h | 6 + drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 244 ++++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.h | 13 ++ 4 files changed, 275 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +12 -1
@@ -281,7 +281,7 @@ struct amd_sriov_msg_pf2vf_info_header {uint32_t reserved[2 ]; }; -#define AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE (59) +#define AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE (69)struct amd_sriov_msg_pf2vf_info {/* header contains size and version */ struct amd_sriov_msg_pf2vf_info_header header;
@@ -345,6 +345,17 @@ struct amd_sriov_msg_pf2vf_info {/* unit ID assigned by host; vf_idx [0..254] maps to unitid [1..255] (0 = pf) */ uint8_t unitid;uint8_t padding[3 ];//use the 3 bytes to align +/* critical region/init-data negotiation */ +uint32_t guest_gpu_init_flags; +uint32_t host_crit_region_caps; +uint32_t guest_crit_region_caps; +uint32_t vf_crit_region; +uint32_t init_data_header_offset; +uint32_t init_data_header_size; +uint32_t dataexchange_offset; +uint32_t dataexchange_size; +uint32_t bad_page_block_offset; +uint32_t bad_page_block_size;/* reserved */ uint32_t reserved[256 -AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE ];
drivers/gpu/drm/amd/sriov/sriov.h +6 -0
@@ -25,6 +25,7 @@#ifndef __SRIOV_H__#define __SRIOV_H__ +#include <linux/bits.h> #include <linux/sizes.h> #include <linux/types.h>
@@ -118,7 +119,12 @@ struct sriov_psp_funcs {#define SRIOV_VF_FB_ALIGNMENT SZ_16M +#define SRIOV_FLAG_DISABLE_SELF_SWITCH BIT_ULL(5) +#define SRIOV_FLAG_SMU_NO_SUPPORT_PP_ONE_VF BIT_ULL(12) +#define SRIOV_FLAG_IH_REG_PSP_EN BIT_ULL(19)#define SRIOV_FLAG_GC_REG_RLC_EN BIT_ULL(20) +#define SRIOV_FLAG_MMHUB_REG_RLC_EN BIT_ULL(21) +#define SRIOV_FLAG_L1_TLB_CNTL_REG_PSP_EN BIT_ULL(47)struct amdgpu_sriov {struct amdgpu_device *adev;
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +244 -0
286 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.h +13 -0
@@ -30,6 +30,10 @@#include "amdgv_sriovmsg.h" +#ifndef SRIOV_CRIT_CAP_BIT +#define SRIOV_CRIT_CAP_BIT (_version) BIT((_version) - 1) +#endif +struct sriov_init_func ;struct amdgpu_device ;struct pci_dev ;
@@ -106,5 +110,14 @@ int sriov_vfmgr_set_vf_access(struct amdgpu_device *adev, bool enable);extern const struct sriov_init_func sriov_vfmgr_func; +int sriov_vfmgr_update_pf2vf_message (struct amdgpu_device *adev, +unsigned int vf_idx); +int sriov_vfmgr_retrieve_vf2pf_message (struct amdgpu_device *adev, +unsigned int vf_idx, +struct amd_sriov_msg_vf2pf_info *output); +int sriov_vfmgr_init_crit_region_caps (struct amdgpu_device *adev, +unsigned int vf_idx); +int sriov_vfmgr_init_crit_region (struct amdgpu_device *adev, +unsigned int vf_idx);#endif
Signature · 1 line
2.34.1
RFC PATCH 27/34 drm/amd/sriov: add VF IP discovery table builder
In reply to Emily DengAdd the SR-IOV IP discovery provider that builds per-VF discovery table images from the PF discovery blob.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 11 + drivers/gpu/drm/amd/sriov/sriov.h | 2 + .../gpu/drm/amd/sriov/sriov_ip_discovery.c | 627 ++++++++++++++++++ .../gpu/drm/amd/sriov/sriov_ip_discovery.h | 47 ++ 5 files changed, 688 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ip_discovery.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_ip_discovery.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -35,3 +35,4 @@ AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o AMD_SRIOV_FILES += ../sriov/sriov_vfmgr.o AMD_SRIOV_FILES += ../sriov/sriov_psp_15_0_3.o +AMD_SRIOV_FILES += ../sriov/sriov_ip_discovery.o
drivers/gpu/drm/amd/sriov/sriov.c +11 -0
@@ -102,6 +102,13 @@ static int sriov_set_psp_funcs(struct amdgpu_device *adev) } } +static int sriov_set_ip_discovery_funcs (struct amdgpu_device *adev) +{ + adev->sriov->ip_discovery_funcs = &sriov_ip_discovery_funcs; + +return 0 ; +} +static int sriov_set_init_funcs (struct amdgpu_device *adev) {sriov_init_func_add (adev, &sriov_gpuiov_func);
@@ -146,6 +153,10 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block)if (r) goto err_fini; + r =sriov_set_ip_discovery_funcs (adev); +if (r) + goto err_fini; + r =sriov_set_init_funcs (adev);if (r) goto err_fini;
drivers/gpu/drm/amd/sriov/sriov.h +2 -0
@@ -33,6 +33,7 @@#include "sriov_mailbox.h" #include "sriov_ffbm.h" #include "sriov_vfmgr.h" +#include "sriov_ip_discovery.h" struct amdgpu_device ;struct pci_dev ;
@@ -132,6 +133,7 @@ struct amdgpu_sriov {const struct sriov_nbio_funcs *nbio_funcs;const struct sriov_gmc_funcs *gmc_funcs;const struct sriov_psp_funcs *psp_funcs; +const struct sriov_ip_discovery_funcs *ip_discovery_funcs;u64 flags;struct sriov_gpuiov gpuiov;struct sriov_mailbox mailbox;
drivers/gpu/drm/amd/sriov/sriov_ip_discovery.c new file +627 -0
627 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_ip_discovery.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 28/34 drm/amd/sriov: add guest VBIOS image builder
In reply to Emily DengBuild per-VF guest VBIOS images from the PF ROM with SR-IOV specific checksum and table updates used during VF boot data export.
--- drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 95 ++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +93 -2
@@ -28,6 +28,7 @@#include <linux/pci.h> #include <linux/slab.h> +#include "atomfirmware.h" #include "amdgpu.h" #include "sriov_iovm.h" #include "sriov.h"
@@ -254,6 +255,17 @@ static void sriov_vfmgr_disable_vf_flr(struct amdgpu_device *adev) sriov->nbio_funcs->disable_vf_flr (adev); } +static u32 sriov_vfmgr_vbios_slot_kb (struct amdgpu_device *adev) +{ +u32 need_kb; + +if (!adev->bios_size) +return AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1 ; + + need_kb =DIV_ROUND_UP (adev->bios_size,1024 ); +return max (AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1 , need_kb); +} +static int sriov_vfmgr_init_message_layout (struct amdgpu_device *adev,unsigned int vf_idx) {
@@ -264,7 +276,7 @@ static int sriov_vfmgr_init_message_layout(struct amdgpu_device *adev, vf = &adev->sriov->vfs[vf_idx]; vf->vbios_offset = (u64 )AMD_SRIOV_MSG_VBIOS_OFFSET_V1 <<10 ; vf->vbios_size = adev->bios_size ? - ((u64 )AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1 <<10 ) :0 ; + ((u64 )sriov_vfmgr_vbios_slot_kb (adev) <<10 ) :0 ; vf->dataexchange_offset = (u64 )AMD_SRIOV_MSG_DATAEXCHANGE_OFFSET_KB_V1 <<10 ; vf->dataexchange_size =SRIOV_VFMGR_DATAEXCHANGE_SIZE ;
@@ -284,7 +296,7 @@ static int sriov_vfmgr_init_message_layout(struct amdgpu_device *adev, vf->vf_table_offsets[AMD_SRIOV_MSG_VBIOS_IMG_TABLE_ID ] = vf->vbios_offset; vf->vf_table_sizes_kb[AMD_SRIOV_MSG_VBIOS_IMG_TABLE_ID ] = - vf->vbios_size >>10 ; +AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1 ; vf->vf_table_offsets[AMD_SRIOV_MSG_DATAEXCHANGE_TABLE_ID ] = vf->dataexchange_offset; vf->vf_table_sizes_kb[AMD_SRIOV_MSG_DATAEXCHANGE_TABLE_ID] =
@@ -391,6 +403,85 @@ static int sriov_vfmgr_build_fb_layout(struct amdgpu_device *adev)return 0 ; } +static void sriov_vfmgr_update_vbios_checksum (u8 *image,size_t image_size) +{ +u8 checksum =0 ; +size_t i; + +if (image_size <=SRIOV_VFMGR_VBIOS_CHECKSUM_OFFSET ) +return ; + + image[SRIOV_VFMGR_VBIOS_CHECKSUM_OFFSET ] =0 ; +for (i =0 ; i < image_size; i++) + checksum += image[i]; + + image[SRIOV_VFMGR_VBIOS_CHECKSUM_OFFSET ] = (u8)(0 - checksum); +} + +static int sriov_vfmgr_prepare_guest_vbios (struct amdgpu_device *adev, +u8 *image, +size_t image_size) +{ +struct atom_context *ctx = adev->mode_info.atom_context; +struct vram_usagebyfirmware_v2_2 *fw_usage_v2_2; +u16 data_offset =0 ; +u16 size =0 ; +u8 frev =0 ; +u8 crev =0 ; +int index; + +if (!ctx || !adev->bios || !adev->bios_size) +return -EINVAL ; +if (image_size < adev->bios_size) +return -EINVAL ; + +memcpy (image, adev->bios, adev->bios_size); + + index =SRIOV_VFMGR_VRAM_USAGE_TABLE_INDEX ; +if (!amdgpu_atom_parse_data_header (ctx, index, &size, &frev, &crev, + &data_offset)) +return -EINVAL ; + +if (frev ==2 && crev ==1 ) { +struct vram_usagebyfirmware_v2_1 *fw_usage_v2_1; + + fw_usage_v2_1 = (void *)(image + data_offset); + fw_usage_v2_1->start_address_in_kb = +cpu_to_le32 (AMD_SRIOV_MSG_VBIOS_OFFSET_V1 | + (ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION << +ATOM_VRAM_OPERATION_FLAGS_SHIFT )); + fw_usage_v2_1->used_by_firmware_in_kb = +cpu_to_le16 (AMD_SRIOV_MSG_INIT_DATA_TOT_SIZE_KB_V1 ); +sriov_vfmgr_update_vbios_checksum (image, adev->bios_size); +return 0 ; + } +if (frev <2 || crev <2 ) { +dev_err (adev->dev, +"SR-IOV vfmgr: guest vbios VRAM_USAGE rev %u.%u unsupported\n" , + frev, crev); +return -EINVAL ; + } +if (data_offset +sizeof (*fw_usage_v2_2) > adev->bios_size || + size <sizeof (*fw_usage_v2_2)) { +dev_err (adev->dev, +"SR-IOV vfmgr: guest vbios VRAM_USAGE v2.2 out of range (off=%u size=%u bios=%u)\n" , + data_offset, size, adev->bios_size); +return -ERANGE ; + } + + fw_usage_v2_2 = (void *)(image + data_offset); + fw_usage_v2_2->fw_region_start_address_in_kb = +cpu_to_le32 (ATOM_VRAM_BLOCK_NEEDS_NO_RESERVATION << +ATOM_VRAM_OPERATION_FLAGS_SHIFT ); + fw_usage_v2_2->used_by_firmware_in_kb =cpu_to_le16 (0 ); + fw_usage_v2_2->driver_region0_start_address_in_kb =cpu_to_le32 (0 ); + fw_usage_v2_2->used_by_driver_region0_in_kb = +cpu_to_le32 (AMD_SRIOV_MSG_INIT_DATA_TOT_SIZE_KB_V1 ); +sriov_vfmgr_update_vbios_checksum (image, adev->bios_size); + +return 0 ; +} +static int sriov_vfmgr_program_fb_layout (struct amdgpu_device *adev) {struct sriov_vfmgr *vfmgr = &adev->sriov->vfmgr;
Signature · 1 line
2.34.1
RFC PATCH 29/34 drm/amd/sriov: export VF boot data to guest FB
In reply to Emily DengCopy PF2VF mailboxes, IP discovery tables and guest VBIOS images into VF framebuffer backing during init.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 1 + drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 500 +++++++++++++++++- drivers/gpu/drm/amd/sriov/sriov_vfmgr.h | 7 + 3 files changed, 506 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +1 -0
@@ -4086,6 +4086,7 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->lsdma.funcs = &lsdma_v7_1_funcs;break ;case IP_VERSION (8 ,0 ,0 ): +case IP_VERSION (8 ,0 ,1 ): adev->lsdma.funcs = &lsdma_v8_0_funcs;break ;default :
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +498 -2
545 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.h +7 -0
@@ -65,6 +65,7 @@ struct sriov_vf_state {u32 access_mask;bool valid;bool vf2pf_valid; +bool vram_lost; };struct sriov_vf_resource {
@@ -117,6 +118,12 @@ int sriov_vfmgr_retrieve_vf2pf_message(struct amdgpu_device *adev, struct amd_sriov_msg_vf2pf_info *output);int sriov_vfmgr_init_crit_region_caps (struct amdgpu_device *adev,unsigned int vf_idx); +int sriov_vfmgr_update_init_data (struct amdgpu_device *adev, +unsigned int vf_idx); +int sriov_vfmgr_program_guest_mc (struct amdgpu_device *adev, +unsigned int vf_idx); +int sriov_vfmgr_prepare_guest_fb (struct amdgpu_device *adev, +unsigned int vf_idx);int sriov_vfmgr_init_crit_region (struct amdgpu_device *adev,unsigned int vf_idx);
Signature · 1 line
2.34.1
RFC PATCH 30/34 drm/amd/sriov: add PF scheduler documentation
In reply to Emily DengAdd kernel-doc overview of the PF-side scheduler stack: event queue, full-access arbitration, manual topology/world switch and VF guard limits.
--- Documentation/gpu/amdgpu/index.rst | 1 + Documentation/gpu/amdgpu/sriov-scheduler.rst | 737 +++++++++++++++++++ 2 files changed, 738 insertions(+) create mode 100644 Documentation/gpu/amdgpu/sriov-scheduler.rst
Documentation/gpu/amdgpu/index.rst +1 -0
@@ -22,6 +22,7 @@ Next (GCN), Radeon DNA (RDNA), and Compute DNA (CDNA) architectures. debugging debugfs process-isolation + sriov-scheduler amdgpu-glossary ualink ptl
Documentation/gpu/amdgpu/sriov-scheduler.rst new file +737 -0
737 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 31/34 drm/amd/sriov: add scheduler event handling
In reply to Emily DengAdd the PF-side scheduler service, software event queue and worker used to serialize VF lifecycle requests from the mailbox layer. Implement event queue init/process start/stop, full-access arbitration for GPU init/fini/reset request and release handling, mailbox response routing and baseline VF event handlers.
--- drivers/gpu/drm/amd/sriov/Makefile | 4 + drivers/gpu/drm/amd/sriov/sriov.c | 1 + drivers/gpu/drm/amd/sriov/sriov.h | 2 + drivers/gpu/drm/amd/sriov/sriov_mailbox.c | 10 + drivers/gpu/drm/amd/sriov/sriov_sched.c | 128 ++ drivers/gpu/drm/amd/sriov/sriov_sched_event.c | 1125 +++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_sched_event.h | 177 +++ .../drm/amd/sriov/sriov_sched_event_data.h | 84 ++ .../amd/sriov/sriov_sched_event_dispatch.c | 88 ++ .../amd/sriov/sriov_sched_event_dispatch.h | 62 + .../amd/sriov/sriov_sched_event_handlers.c | 179 +++ .../amd/sriov/sriov_sched_event_handlers.h | 55 + .../drm/amd/sriov/sriov_sched_event_priv.h | 78 ++ drivers/gpu/drm/amd/sriov/sriov_vfmgr.c | 3 + 14 files changed, 1996 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_data.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_event_priv.h
drivers/gpu/drm/amd/sriov/Makefile +4 -0
@@ -34,5 +34,9 @@ AMD_SRIOV_FILES += ../sriov/sriov_mailbox.o AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o AMD_SRIOV_FILES += ../sriov/sriov_vfmgr.o +AMD_SRIOV_FILES += ../sriov/sriov_sched.o +AMD_SRIOV_FILES += ../sriov/sriov_sched_event.o +AMD_SRIOV_FILES += ../sriov/sriov_sched_event_dispatch.o +AMD_SRIOV_FILES += ../sriov/sriov_sched_event_handlers.o AMD_SRIOV_FILES += ../sriov/sriov_psp_15_0_3.o AMD_SRIOV_FILES += ../sriov/sriov_ip_discovery.o
drivers/gpu/drm/amd/sriov/sriov.c +1 -0
@@ -115,6 +115,7 @@ static int sriov_set_init_funcs(struct amdgpu_device *adev)sriov_init_func_add (adev, &sriov_mailbox_func);sriov_init_func_add (adev, &sriov_ffbm_func);sriov_init_func_add (adev, &sriov_vfmgr_func); +sriov_init_func_add (adev, &sriov_sched_func);return 0 ; }
drivers/gpu/drm/amd/sriov/sriov.h +2 -0
@@ -33,6 +33,7 @@#include "sriov_mailbox.h" #include "sriov_ffbm.h" #include "sriov_vfmgr.h" +#include "sriov_sched_event.h" #include "sriov_ip_discovery.h" struct amdgpu_device ;
@@ -142,6 +143,7 @@ struct amdgpu_sriov {struct sriov_vf_state vfs[SRIOV_MAX_VF_SLOT ];u64 vf_reserve_offset;u64 vf_reserve_size; +struct sriov_sched sched;const struct sriov_init_func *init_funcs[SRIOV_MAX_INIT_FUNCS ];unsigned int num_init_funcs;
drivers/gpu/drm/amd/sriov/sriov_mailbox.c +10 -0
@@ -161,6 +161,16 @@ static void sriov_mailbox_handle_vf2pf_valid(struct amdgpu_device *adev, vf_idx, msg_data[1], msg_data[2], msg_data[3]);return ; } + r =sriov_sched_queue_event_ex ( + adev, vf_idx, sched_event,SRIOV_GPUIOV_BLOCK_ALL , + msg_data); +if (r) { + adev->sriov->sched.dropped_event_cnt++; +dev_warn (adev->dev, +"SR-IOV mailbox: VF%u queue sched_event=%d failed r=%d dropped=%llu\n" , + vf_idx, sched_event, r, + adev->sriov->sched.dropped_event_cnt); + } } static void sriov_mailbox_handle_pf2vf_ack(struct amdgpu_device *adev,
drivers/gpu/drm/amd/sriov/sriov_sched.c new file +128 -0
128 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event.c new file +1125 -0
1,125 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event.h new file +177 -0
177 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_data.h new file +84 -0
84 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.c new file +88 -0
88 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_dispatch.h new file +62 -0
62 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.c new file +179 -0
179 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_handlers.h new file +55 -0
55 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event_priv.h new file +78 -0
78 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_vfmgr.c +3 -0
@@ -879,6 +879,8 @@ int sriov_vfmgr_prepare_guest_fb(struct amdgpu_device *adev,if (r)return r; +sriov_sched_clear_init_data_ready (adev, vf_idx); +return 0 ; }
@@ -903,6 +905,7 @@ static int sriov_vfmgr_init_vf_fb(struct amdgpu_device *adev,if (r)return r; +sriov_sched_clear_init_data_ready (adev, vf_idx);return 0 ; }
Signature · 1 line
2.34.1
RFC PATCH 32/34 drm/amd/sriov: add manual scheduler topology
In reply to Emily DengAdd GPUIOV spatial-partition tables, VF-to-partition membership, world-switch object wiring and spatial-partition topology for the single-VF baseline.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov.c | 1 + drivers/gpu/drm/amd/sriov/sriov.h | 1 + drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c | 22 + drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 98 ++- drivers/gpu/drm/amd/sriov/sriov_gpuiov.h | 31 + drivers/gpu/drm/amd/sriov/sriov_sched.c | 21 + drivers/gpu/drm/amd/sriov/sriov_sched_event.c | 16 +- drivers/gpu/drm/amd/sriov/sriov_sched_event.h | 11 + .../gpu/drm/amd/sriov/sriov_sched_switch.c | 611 ++++++++++++++++++ .../gpu/drm/amd/sriov/sriov_sched_switch.h | 196 ++++++ 11 files changed, 1000 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_switch.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_switch.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -38,5 +38,6 @@ AMD_SRIOV_FILES += ../sriov/sriov_sched.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_dispatch.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_handlers.o +AMD_SRIOV_FILES += ../sriov/sriov_sched_switch.o AMD_SRIOV_FILES += ../sriov/sriov_psp_15_0_3.o AMD_SRIOV_FILES += ../sriov/sriov_ip_discovery.o
drivers/gpu/drm/amd/sriov/sriov.c +1 -0
@@ -136,6 +136,7 @@ static int sriov_early_init(struct amdgpu_ip_block *ip_block)return -ENOMEM ; sriov->adev = adev; + sriov->flags =SRIOV_FLAG_DISABLE_SELF_SWITCH ; adev->sriov = sriov; r =sriov_set_gfx_funcs (adev);
drivers/gpu/drm/amd/sriov/sriov.h +1 -0
@@ -54,6 +54,7 @@ struct sriov_init_func {struct sriov_gfx_funcs {const struct sriov_gpuiov_hw_sched_static_config * (*get_gpuiov_ctrl_blocks)(unsigned int *num_blocks); +int (*sched_copy_static_spatial_part_table)(struct amdgpu_device *adev);int (*toggle_rlcg_vf_interface)(struct amdgpu_device *adev,unsigned int vf_idx,bool enable); int (*gpuiov_set_cmd)(struct amdgpu_device *adev,
drivers/gpu/drm/amd/sriov/sriov_gfx_v13_0.c +22 -0
@@ -24,9 +24,12 @@#include <linux/delay.h> #include <linux/jiffies.h> +#include <linux/string.h> #include "amdgpu.h" #include "sriov.h" +#include "sriov_gpuiov.h" +#include "sriov_sched_switch.h" #include "sriov_gfx_v13_0.h" #include "gc/gc_13_0_1_offset.h" #include "gc/gc_13_0_1_sh_mask.h"
@@ -56,6 +59,14 @@ sriov_gfx_v13_0_gpuiov_blocks[] = { GFX_V13_0_GPUIOV_GFX_BLOCK("GFX_SCH0_RLCV", 0), }; +static const struct sriov_sched_spatial_part +sriov_gfx_v13_0_block_configs_1x1[] = { + { + .idx_vf_mask =BIT (0 ) |BIT (SRIOV_GPUIOV_PF_FUNC_ID ), + .hw_sched_mask =BIT (SRIOV_GFX_V13_0_HW_SCHED_GFX_SCH0_RLCV ), + }, +}; +static const struct sriov_gpuiov_hw_sched_static_config *sriov_gfx_v13_0_get_gpuiov_ctrl_blocks (unsigned int *num_blocks) {
@@ -67,6 +78,15 @@ sriov_gfx_v13_0_get_gpuiov_ctrl_blocks(unsigned int *num_blocks)return sriov_gfx_v13_0_gpuiov_blocks; } +static int +sriov_gfx_v13_0_sched_copy_static_spatial_part_table (struct amdgpu_device *adev) +{ +return sriov_sched_apply_static_spatial_part_table ( + adev, sriov_gfx_v13_0_block_configs_1x1, +ARRAY_SIZE (sriov_gfx_v13_0_block_configs_1x1),1 , +SRIOV_GFX_V13_0_HW_SCHED_GFX_SCH0_RLCV ); +} +static int sriov_gfx_v13_0_toggle_rlcg_vf_interface (struct amdgpu_device *adev,unsigned int vf_idx,bool enable)
@@ -261,6 +281,8 @@ static u32 sriov_gfx_v13_0_gpuiov_cp_sched_state(struct amdgpu_device *adev,const struct sriov_gfx_funcs sriov_gfx_v13_0_funcs = { .get_gpuiov_ctrl_blocks = sriov_gfx_v13_0_get_gpuiov_ctrl_blocks, + .sched_copy_static_spatial_part_table = + sriov_gfx_v13_0_sched_copy_static_spatial_part_table, .toggle_rlcg_vf_interface = sriov_gfx_v13_0_toggle_rlcg_vf_interface, .gpuiov_set_cmd = sriov_gfx_v13_0_gpuiov_set_cmd,
drivers/gpu/drm/amd/sriov/sriov_gpuiov.c +96 -2
133 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_gpuiov.h +31 -0
@@ -25,6 +25,7 @@#ifndef __SRIOV_GPUIOV_H__#define __SRIOV_GPUIOV_H__ +#include <linux/bitops.h> #include <linux/bits.h> #include <linux/mutex.h> #include <linux/types.h>
@@ -97,6 +98,7 @@ struct sriov_gpuiov_ctrl_block {u32 cur_vf_id;u8 hw_inst;bool enabled; +bool saved_rlcv_state; };#define SRIOV_GPUIOV_MAX_CTRL_BLOCKS (20)
@@ -133,6 +135,28 @@ sriov_gpuiov_is_hw_sched_type_gfx(struct sriov_gpuiov *gpuiov,SRIOV_GPUIOV_SCHED_GFX ; } +static inline bool +sriov_gpuiov_hw_sched_active (struct sriov_gpuiov *gpuiov, +unsigned int hw_sched_id) +{ +if (!gpuiov || hw_sched_id >= gpuiov->num_ctrl_blocks) +return false; + +return gpuiov->ctrl_blocks[hw_sched_id].enabled; +} + +#define sriov_gpuiov_vf_gpu_state (_gpuiov, _vf_idx, _hw_sched_id) ( \ + (&(_gpuiov)->vf_gpu_states \ + [((_vf_idx) == SRIOV_GPUIOV_PF_FUNC_ID ? \ + (_gpuiov)->num_vfs : (_vf_idx)) * (_gpuiov)->num_ctrl_blocks + \ + (_hw_sched_id)])) + +#define BIT_MASK_UPPER (i) ((i) >= BITS_PER_LONG ? 0 : ~0UL << (i)) + +#define sriov_gpuiov_for_each_hw_sched_id (_id, _mask) \ + for ((_id) = ffs(_mask); (_id)-- != 0; \ + (_id) = ffs((_mask) & BIT_MASK_UPPER(_id + 1))) +extern const struct sriov_init_func sriov_gpuiov_func;bool sriov_gpuiov_is_cmd_complete (struct amdgpu_device *adev,unsigned int hw_sched_id);
@@ -147,5 +171,12 @@ int sriov_gpuiov_cmd_vf(struct amdgpu_device *adev,int sriov_gpuiov_save_rlcv_state (struct amdgpu_device *adev,unsigned int hw_sched_id,unsigned int vf_idx); +int sriov_gpuiov_load_rlcv_state (struct amdgpu_device *adev, +unsigned int hw_sched_id, +unsigned int vf_idx); +void sriov_gpuiov_reset_saved_rlcv_state (struct amdgpu_device *adev); +int sriov_gpuiov_get_active_vf_idx (struct amdgpu_device *adev, +unsigned int hw_sched_id, +unsigned int *vf_idx);#endif
drivers/gpu/drm/amd/sriov/sriov_sched.c +21 -0
@@ -24,6 +24,7 @@#include "amdgpu.h" #include "sriov.h" +#include "sriov_sched_switch.h" static void sriov_sched_reset_vf_runtime_state (struct sriov_sched_vf *vf);
@@ -38,6 +39,8 @@ sriov_sched_reset_vf_runtime_state(struct sriov_sched_vf *vf) { vf->state =SRIOV_SCHED_VF_UNAVAILABLE ; vf->full_access_event =SRIOV_EVENT_INVALID ; + vf->ws_mask =0 ; + vf->hw_sched_mask =0 ; vf->full_access_start =0 ; vf->init_data_ready = false; vf->in_full_access = false;
@@ -89,19 +92,37 @@ static int sriov_sched_sw_fini(struct amdgpu_device *adev)static int sriov_sched_hw_init (struct amdgpu_device *adev) {struct sriov_sched *sched = &adev->sriov->sched; +int r;if (!sched->sw_init)return -EINVAL ; + r =sriov_sched_copy_static_spatial_part_table (adev); +if (r) +return r; + + r =sriov_sched_ws_init (adev); +if (r) + goto err_switch_fini; + sched->hw_init = true;return 0 ; + +err_switch_fini: +sriov_sched_ws_fini (adev); +return r; }static int sriov_sched_hw_fini (struct amdgpu_device *adev) {struct sriov_sched *sched = &adev->sriov->sched; +if (!sched->hw_init) +return 0 ; + +sriov_sched_stop_all (adev); +sriov_sched_ws_fini (adev); sched->hw_init = false;return 0 ;
drivers/gpu/drm/amd/sriov/sriov_sched_event.c +9 -7
@@ -28,15 +28,21 @@#include "amdgpu.h" #include "sriov.h" +#include "sriov_sched_switch.h" #include "sriov_sched_event_dispatch.h" #include "sriov_sched_event_priv.h" +#define SRIOV_SCHED_EXCLUSIVE_TIMEOUT_MS_1VF 3000#define SRIOV_SCHED_EXCLUSIVE_TIMEOUT_MS_COMMON 1500#define SRIOV_SCHED_EVENT_QUEUE_SIZE 256static unsigned int sriov_sched_full_access_timeout_ms (struct amdgpu_device *adev) { +struct sriov_sched *sched = &adev->sriov->sched; + +if (sched->num_vf_per_gfx_sched ==1 ) +return SRIOV_SCHED_EXCLUSIVE_TIMEOUT_MS_1VF ;return SRIOV_SCHED_EXCLUSIVE_TIMEOUT_MS_COMMON ; }
@@ -249,7 +255,7 @@ static bool sriov_sched_single_vf_path(struct amdgpu_device *adev) {struct sriov_sched *sched = &adev->sriov->sched; -return sched->num_vfs ==1 || +return sched->num_vf_per_gfx_sched ==1 ||sriov_sched_active_vf_count (sched) ==0 ; }
@@ -533,9 +539,7 @@ sriov_sched_handle_req_gpu_reset(struct amdgpu_device *adev,static void sriov_sched_rlc_enter_safe_mode_vf (struct amdgpu_device *adev,unsigned int vf_idx) { -struct sriov_sched_vf *vf = -sriov_sched_vf_slot (&adev->sriov->sched, vf_idx); -u32 xcc_mask = vf ? vf->xcc_mask :0 ; +u32 xcc_mask =sriov_sched_get_xcc_mask_by_vf (adev, vf_idx);int xcc_id;if (!xcc_mask)
@@ -548,9 +552,7 @@ static void sriov_sched_rlc_enter_safe_mode_vf(struct amdgpu_device *adev,static void sriov_sched_rlc_exit_safe_mode_vf (struct amdgpu_device *adev,unsigned int vf_idx) { -struct sriov_sched_vf *vf = -sriov_sched_vf_slot (&adev->sriov->sched, vf_idx); -u32 xcc_mask = vf ? vf->xcc_mask :0 ; +u32 xcc_mask =sriov_sched_get_xcc_mask_by_vf (adev, vf_idx);int xcc_id;if (!xcc_mask)
drivers/gpu/drm/amd/sriov/sriov_sched_event.h +11 -0
@@ -36,6 +36,7 @@#include "sriov_gpuiov.h" #include "sriov_mailbox.h" #include "sriov_sched_event_data.h" +#include "sriov_sched_switch.h" struct amdgpu_device ;struct sriov_init_func ;
@@ -100,10 +101,20 @@ struct sriov_sched_vf {struct sriov_sched {unsigned int num_vfs; +unsigned int num_ws; +unsigned int num_spatial_partitions; +unsigned int num_vf_per_gfx_sched; +u32 time_quanta_option[SRIOV_GPUIOV_BLOCK_MAX ];bool setup_vf_timeslice;bool sw_init;bool hw_init;bool event_enabled; +struct sriov_hw_state_machine + hw_state_machine[SRIOV_GPUIOV_MAX_CTRL_BLOCKS ]; +struct sriov_sched_ws + ws[SRIOV_SCHED_MAX_WS ]; +struct sriov_sched_spatial_part + spatial_parts[SRIOV_SCHED_MAX_SPATIAL_PARTITIONS ];struct workqueue_struct *wq;struct work_struct work;struct delayed_work timeout_work;
drivers/gpu/drm/amd/sriov/sriov_sched_switch.c new file +611 -0
611 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_switch.h new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 33/34 drm/amd/sriov: add manual world switch support
In reply to Emily DengImplement manual save/load/run/shutdown/reset world-switch actions and connect them to scheduler lifecycle events for the single-VF baseline.
--- drivers/gpu/drm/amd/sriov/Makefile | 2 + drivers/gpu/drm/amd/sriov/sriov_gpuiov.c | 40 + drivers/gpu/drm/amd/sriov/sriov_gpuiov.h | 2 + drivers/gpu/drm/amd/sriov/sriov_hwsm.c | 235 +++++ drivers/gpu/drm/amd/sriov/sriov_hwsm.h | 50 + drivers/gpu/drm/amd/sriov/sriov_sched.c | 35 + drivers/gpu/drm/amd/sriov/sriov_sched_event.c | 262 ++++- .../gpu/drm/amd/sriov/sriov_sched_switch.c | 953 ++++++++++++++++++ .../gpu/drm/amd/sriov/sriov_sched_switch.h | 19 +- .../gpu/drm/amd/sriov/sriov_sched_ws_manual.c | 512 ++++++++++ .../gpu/drm/amd/sriov/sriov_sched_ws_manual.h | 33 + 11 files changed, 2138 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_hwsm.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_hwsm.h create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.h
drivers/gpu/drm/amd/sriov/Makefile +2 -0
@@ -38,6 +38,8 @@ AMD_SRIOV_FILES += ../sriov/sriov_sched.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_dispatch.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_handlers.o +AMD_SRIOV_FILES += ../sriov/sriov_hwsm.o +AMD_SRIOV_FILES += ../sriov/sriov_sched_ws_manual.o AMD_SRIOV_FILES += ../sriov/sriov_sched_switch.o AMD_SRIOV_FILES += ../sriov/sriov_psp_15_0_3.o AMD_SRIOV_FILES += ../sriov/sriov_ip_discovery.o
drivers/gpu/drm/amd/sriov/sriov_gpuiov.c +40 -0
@@ -322,6 +322,45 @@ static int sriov_gpuiov_hw_fini(struct amdgpu_device *adev)return 0 ; } +const char *sriov_gpuiov_cmd_name (u32 cmd) +{ +switch (cmd) { +case SRIOV_GPUIOV_CMD_IDLE_GPU : +return "IDLE" ; +case SRIOV_GPUIOV_CMD_SAVE_GPU_STATE : +return "SAVE" ; +case SRIOV_GPUIOV_CMD_LOAD_GPU_STATE : +return "LOAD" ; +case SRIOV_GPUIOV_CMD_RUN_GPU : +return "RUN" ; +case SRIOV_GPUIOV_CMD_INIT_GPU : +return "INIT" ; +case SRIOV_GPUIOV_CMD_SAVE_RLCV_STATE : +return "SAVE_RLCV" ; +case SRIOV_GPUIOV_CMD_LOAD_RLCV_STATE : +return "LOAD_RLCV" ; +case SRIOV_GPUIOV_CMD_CLEAR_VF_STATE : +return "CLEAR_VF" ; +case SRIOV_GPUIOV_CMD_SHUTDOWN_GPU : +return "SHUTDOWN" ; +default : +return "UNKNOWN" ; + } +} + +void sriov_gpuiov_format_vf (unsigned int vf_idx,char *buf,size_t buflen) +{ +if (!buf || !buflen) +return ; + +if (vf_idx ==SRIOV_GPUIOV_INVALID_FUNC_ID ) +scnprintf (buf, buflen,"none" ); +else if (vf_idx ==SRIOV_GPUIOV_PF_FUNC_ID ) +scnprintf (buf, buflen,"PF" ); +else +scnprintf (buf, buflen,"VF%u" , vf_idx); +} +int sriov_gpuiov_set_vf_access (struct amdgpu_device *adev,unsigned int vf_idx,u32 access_mode) {
@@ -400,6 +439,7 @@ static int sriov_gpuiov_wait_cmd_complete(struct amdgpu_device *adev,dev_warn (adev->dev,"SR-IOV GPUIOV: command timeout hw_sched=%u\n" , hw_sched_id); +sriov_sched_dump_gpu_state (adev);return -ETIMEDOUT ; }
drivers/gpu/drm/amd/sriov/sriov_gpuiov.h +2 -0
@@ -158,6 +158,8 @@ sriov_gpuiov_hw_sched_active(struct sriov_gpuiov *gpuiov, (_id) = ffs((_mask) & BIT_MASK_UPPER(_id + 1)))extern const struct sriov_init_func sriov_gpuiov_func; +const char *sriov_gpuiov_cmd_name (u32 cmd); +void sriov_gpuiov_format_vf (unsigned int vf_idx,char *buf,size_t buflen);bool sriov_gpuiov_is_cmd_complete (struct amdgpu_device *adev,unsigned int hw_sched_id); int sriov_gpuiov_set_vf_access(struct amdgpu_device *adev,
drivers/gpu/drm/amd/sriov/sriov_hwsm.c new file +235 -0
235 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_hwsm.h new file +50 -0
50 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched.c +35 -0
@@ -41,9 +41,15 @@ sriov_sched_reset_vf_runtime_state(struct sriov_sched_vf *vf) vf->full_access_event =SRIOV_EVENT_INVALID ; vf->ws_mask =0 ; vf->hw_sched_mask =0 ; +memset (vf->block_map,0 ,sizeof (vf->block_map)); +memset (vf->time_slice,0 ,sizeof (vf->time_slice)); vf->full_access_start =0 ; + vf->used_time_full_access =0 ; vf->init_data_ready = false; vf->in_full_access = false; + vf->unshutdown = false; + vf->skip_run = false; + vf->auto_run = false; vf->guest_gpu_init_flags =0 ; vf->guest_crit_region_caps =0 ; vf->guest_crit_region_version =0 ;
@@ -62,6 +68,8 @@ static int sriov_sched_sw_init(struct amdgpu_device *adev)for (i =0 ; i <SRIOV_MAX_VF_SLOT ; i++)sriov_sched_reset_vf_runtime_state (&sched->vfs[i]); + sched->setup_vf_timeslice = true; +sriov_sched_event_queue_init (adev); r =sriov_sched_event_queue_process_init (adev);
@@ -92,19 +100,40 @@ static int sriov_sched_sw_fini(struct amdgpu_device *adev)static int sriov_sched_hw_init (struct amdgpu_device *adev) {struct sriov_sched *sched = &adev->sriov->sched; +struct sriov_vfmgr *vfmgr = &adev->sriov->vfmgr; +u32 gfx_time_slice_us; +unsigned int i;int r;if (!sched->sw_init)return -EINVAL ; +if (vfmgr->hw_init) { +for (i =0 ; i < vfmgr->num_vfs; i++) + sched->vfs[i].state =SRIOV_SCHED_VF_AVAILABLE ; + } + r =sriov_sched_copy_static_spatial_part_table (adev);if (r)return r; + gfx_time_slice_us =sriov_sched_get_gfx_time_slice (adev); +for (i =0 ; i < sched->num_vfs; i++) + sched->vfs[i].time_slice[SRIOV_GPUIOV_BLOCK_GFX ] = + gfx_time_slice_us; + sched->vfs[SRIOV_GPUIOV_PF_FUNC_ID ].time_slice[ +SRIOV_GPUIOV_BLOCK_GFX ] = gfx_time_slice_us; + r =sriov_sched_ws_init (adev);if (r) goto err_switch_fini; + r =sriov_sched_context_init ( + adev,SRIOV_GPUIOV_PF_FUNC_ID , +SRIOV_GPUIOV_BLOCK_ALL ); +if (r) + goto err_switch_fini; + sched->hw_init = true;return 0 ;
@@ -130,6 +159,12 @@ static int sriov_sched_hw_fini(struct amdgpu_device *adev)static int sriov_sched_late_init (struct amdgpu_device *adev) { +int r; + + r =sriov_sched_context_save_all (adev,SRIOV_GPUIOV_BLOCK_ALL ); +if (r) +return r; +return sriov_sched_event_queue_process_start (adev); }
drivers/gpu/drm/amd/sriov/sriov_sched_event.c +260 -2
393 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_switch.c +953 -0
971 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_switch.h +16 -3
@@ -64,10 +64,21 @@ struct sriov_sched_ws_funcs { unsigned int vf_idx); }; +#define SRIOV_SCHED_INVALID_VF_IDX SRIOV_MAX_VF_SLOT + +struct sriov_sched_active_vf_entry { +struct list_head list; +unsigned int idx_vf; +bool dummy_vf; +}; +struct sriov_sched_ws_manual {/* Serializes manual WorldSwitch processing. */ struct mutex lock;struct delayed_work work; +struct list_head active_vf_list; +struct sriov_sched_active_vf_entry array_vf[SRIOV_MAX_VF_SLOT ]; +bool fairness_mode;bool initialized; };
@@ -184,11 +195,13 @@ int sriov_sched_context_clear_state(struct amdgpu_device *adev, enum sriov_gpuiov_sched_block sched_block);bool sriov_sched_is_state_ok (struct amdgpu_device *adev,unsigned int ws_id);bool sriov_sched_all_states_ok (struct amdgpu_device *adev); +bool sriov_sched_ws_mask_states_ok (struct amdgpu_device *adev,u32 ws_mask);int sriov_sched_get_abnormal_ws (struct amdgpu_device *adev); +int sriov_sched_get_abnormal_ws_in_mask (struct amdgpu_device *adev, +u32 ws_mask);int sriov_sched_context_one_time_loop (struct amdgpu_device *adev, -enum sriov_gpuiov_sched_block sched_block); -int sriov_sched_shutdown_vf (struct amdgpu_device *adev, -unsigned int vf_idx); +unsigned int vf_idx); +int sriov_sched_shutdown_vf (struct amdgpu_device *adev,unsigned int vf_idx);int sriov_sched_reset (struct amdgpu_device *adev,unsigned int vf_idx,enum sriov_gpuiov_sched_block sched_block);
drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.c new file +512 -0
512 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_ws_manual.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2026 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef __SRIOV_SCHED_WS_MANUAL_H__ +#define __SRIOV_SCHED_WS_MANUAL_H__ + +#include "sriov_sched_event.h" + +extern const struct sriov_sched_ws_funcs + sriov_sched_ws_manual_funcs; + +#endif
Signature · 1 line
2.34.1
RFC PATCH 34/34 drm/amd/sriov: add VF guard event limits
In reply to Emily DengTrack repeated VF guard events per VF and reject new scheduler requests that exceed configured thresholds before they enter the event queue. Reset guard state on VF teardown.
--- drivers/gpu/drm/amd/sriov/Makefile | 1 + drivers/gpu/drm/amd/sriov/sriov_guard.c | 255 ++++++++++++++++++ drivers/gpu/drm/amd/sriov/sriov_guard.h | 100 +++++++ drivers/gpu/drm/amd/sriov/sriov_mailbox.c | 21 ++ drivers/gpu/drm/amd/sriov/sriov_sched.c | 8 + drivers/gpu/drm/amd/sriov/sriov_sched_event.c | 43 +++ drivers/gpu/drm/amd/sriov/sriov_sched_event.h | 2 + 7 files changed, 430 insertions(+) create mode 100644 drivers/gpu/drm/amd/sriov/sriov_guard.c create mode 100644 drivers/gpu/drm/amd/sriov/sriov_guard.h
drivers/gpu/drm/amd/sriov/Makefile +1 -0
@@ -35,6 +35,7 @@ AMD_SRIOV_FILES += ../sriov/sriov_nbif_v7_10.o AMD_SRIOV_FILES += ../sriov/sriov_ffbm.o AMD_SRIOV_FILES += ../sriov/sriov_vfmgr.o AMD_SRIOV_FILES += ../sriov/sriov_sched.o +AMD_SRIOV_FILES += ../sriov/sriov_guard.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_dispatch.o AMD_SRIOV_FILES += ../sriov/sriov_sched_event_handlers.o
drivers/gpu/drm/amd/sriov/sriov_guard.c new file +255 -0
255 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_guard.h new file +100 -0
100 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_mailbox.c +21 -0
@@ -25,6 +25,7 @@#include "amdgpu.h" #include "sriov.h" #include "amdgv_sriovmsg.h" +#include "sriov_guard.h" #define SRIOV_MAILBOX_DATA_LEN 4
@@ -136,6 +137,16 @@ static void sriov_mailbox_handle_vf2pf_valid(struct amdgpu_device *adev,u32 event;int r; + r =sriov_guard_add_active_event ( + adev, vf_idx,SRIOV_GUARD_EVENT_ALL_INT ); +if (r ==SRIOV_GUARD_EVENT_OVERFLOW_ERR ) { + adev->sriov->sched.dropped_event_cnt++; +dev_warn (adev->dev, +"SR-IOV mailbox: VF%u interrupt guard overflow dropped=%llu\n" , + vf_idx, adev->sriov->sched.dropped_event_cnt); +return ; + } + r =sriov_mailbox_receive_msg (adev, vf_idx, &msg_data[0 ], &msg_data[1 ], &msg_data[2 ], &msg_data[3 ]);
@@ -178,6 +189,16 @@ static void sriov_mailbox_handle_pf2vf_ack(struct amdgpu_device *adev, {int r; + r =sriov_guard_add_active_event ( + adev, vf_idx,SRIOV_GUARD_EVENT_ALL_INT ); +if (r ==SRIOV_GUARD_EVENT_OVERFLOW_ERR ) { + adev->sriov->sched.dropped_event_cnt++; +dev_warn (adev->dev, +"SR-IOV mailbox: VF%u PF->VF ack guard overflow dropped=%llu\n" , + vf_idx, adev->sriov->sched.dropped_event_cnt); +return ; + } + r =sriov_mailbox_clear_valid_msg (adev, vf_idx);if (r) dev_warn(adev->dev,
drivers/gpu/drm/amd/sriov/sriov_sched.c +8 -0
@@ -24,6 +24,7 @@#include "amdgpu.h" #include "sriov.h" +#include "sriov_guard.h" #include "sriov_sched_switch.h" static void sriov_sched_reset_vf_runtime_state (struct sriov_sched_vf *vf);
@@ -32,6 +33,7 @@ void sriov_sched_init_vf_state(struct amdgpu_device *adev, struct sriov_sched_vf *vf) {sriov_sched_reset_vf_runtime_state (vf); +sriov_guard_vf_reset (vf); } static void
@@ -68,6 +70,9 @@ static int sriov_sched_sw_init(struct amdgpu_device *adev)for (i =0 ; i <SRIOV_MAX_VF_SLOT ; i++)sriov_sched_reset_vf_runtime_state (&sched->vfs[i]); +for (i =0 ; i < sched->num_vfs; i++) +sriov_guard_vf_init (&sched->vfs[i]); + sched->setup_vf_timeslice = true;sriov_sched_event_queue_init (adev);
@@ -88,9 +93,12 @@ static int sriov_sched_sw_init(struct amdgpu_device *adev)static int sriov_sched_sw_fini (struct amdgpu_device *adev) {struct sriov_sched *sched = &adev->sriov->sched; +unsigned int i;sriov_sched_event_queue_process_fini (adev);sriov_sched_event_queue_fini (adev); +for (i =0 ; i < sched->num_vfs; i++) +sriov_guard_vf_remove (&sched->vfs[i]); sched->num_vfs =0 ; sched->sw_init = false;
drivers/gpu/drm/amd/sriov/sriov_sched_event.c +43 -0
67 lines not on this page · raw message
drivers/gpu/drm/amd/sriov/sriov_sched_event.h +2 -0
@@ -34,6 +34,7 @@#include <linux/workqueue.h> #include "sriov_gpuiov.h" +#include "sriov_guard.h" #include "sriov_mailbox.h" #include "sriov_sched_event_data.h" #include "sriov_sched_switch.h"
@@ -97,6 +98,7 @@ struct sriov_sched_vf {u32 guest_gpu_init_flags;u32 guest_crit_region_caps;u32 guest_crit_region_version; +struct sriov_guard guard; };struct sriov_sched {
Signature · 1 line
2.34.1