[PATCH v1 33/44] dmaengine: sdxi: amd: register QoS vendor handler
From: Wei Huang
Date: Thu Nov 19 2026 - 15:30:44 EST
Register the AMD QoS GUID with the SDXI vendor framework and add the
Kconfig and module build glue for the handler.
Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
---
drivers/dma/sdxi/Kconfig | 11 +++++++
drivers/dma/sdxi/Makefile | 2 ++
drivers/dma/sdxi/amd/Makefile | 4 +++
drivers/dma/sdxi/amd/qos.c | 58 ++++++++++++++++++++++++++++++++---
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 drivers/dma/sdxi/amd/Makefile
diff --git a/drivers/dma/sdxi/Kconfig b/drivers/dma/sdxi/Kconfig
index 9b8416304ee2..ec89d976c3d3 100644
--- a/drivers/dma/sdxi/Kconfig
+++ b/drivers/dma/sdxi/Kconfig
@@ -41,3 +41,14 @@ config SDXI_KUNIT_TEST
SDXI hardware.
If unsure, say N.
+
+config SDXI_AMD_QOS
+ tristate "AMD SDXI QoS vendor control"
+ depends on SDXI_CORE
+ help
+ Enable AMD SDXI Quality-of-Service vendor-command handling
+ through SDXI_ADMIN_VENDOR. This registers the AMD QoS GUID
+ with the SDXI core and lets the kernel compose the QoS
+ descriptors on the admin context on behalf of userspace.
+
+ If built as a module, this will be called sdxi-amd-qos.
diff --git a/drivers/dma/sdxi/Makefile b/drivers/dma/sdxi/Makefile
index 34f62b7366eb..d808492c60f1 100644
--- a/drivers/dma/sdxi/Makefile
+++ b/drivers/dma/sdxi/Makefile
@@ -20,6 +20,8 @@ sdxi-core-y := \
obj-$(CONFIG_SDXI_PCI) += sdxi-pci.o
sdxi-pci-y := pci.o
+obj-y += amd/
+
obj-$(CONFIG_SDXI_KUNIT_TEST) += \
completion_kunit.o \
descriptor_kunit.o \
diff --git a/drivers/dma/sdxi/amd/Makefile b/drivers/dma/sdxi/amd/Makefile
new file mode 100644
index 000000000000..5aee7e8a2414
--- /dev/null
+++ b/drivers/dma/sdxi/amd/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SDXI_AMD_QOS) += sdxi-amd-qos.o
+sdxi-amd-qos-objs := qos.o
diff --git a/drivers/dma/sdxi/amd/qos.c b/drivers/dma/sdxi/amd/qos.c
index 7d5dc9b6b32c..be5a03c00327 100644
--- a/drivers/dma/sdxi/amd/qos.c
+++ b/drivers/dma/sdxi/amd/qos.c
@@ -6,6 +6,7 @@
*/
#include <linux/capability.h>
+#include <linux/bitfield.h>
#include <linux/dma-mapping.h>
#include <linux/export.h>
#include <kunit/visibility.h>
@@ -133,9 +134,10 @@ sdxi_amd_qos_prepare_output(struct sdxi_admin_vendor_args *args,
static int sdxi_amd_qos_admin_ready(const struct sdxi_cxt *adm)
{
- if (!adm || !adm->sq || !adm->ring_state || !adm->sq->cxt_sts)
+ if (!adm || !adm->sq || !adm->ring_state)
return -ENODEV;
- if (sdxi_cxt_sts_state(adm->sq->cxt_sts) != CXTV_RUN)
+ if (FIELD_GET(SDXI_CXT_STS_STATE,
+ READ_ONCE(adm->sq->cxt_sts.state)) != CXTV_RUN)
return -EIO;
return 0;
@@ -310,6 +312,8 @@ static u16 sdxi_amd_qos_max_vfs(struct sdxi_dev *sdxi)
if (!sdxi || sdxi_fn_reports_vf(sdxi))
return 0;
+ if (!dev_is_pci(sdxi_to_dev(sdxi)))
+ return 0;
pdev = to_pci_dev(sdxi_to_dev(sdxi));
totalvfs = pci_sriov_get_totalvfs(pdev);
@@ -705,7 +709,7 @@ static int sdxi_amd_qos_prevalidate_fnupd(struct sdxi_dev *sdxi,
err = sdxi_amd_qos_validate_fnupd_req(req, cap->max_pools,
sdxi_amd_qos_max_vfs(sdxi),
- sdxi->max_cxts,
+ (u32)sdxi->max_cxtid + 1,
cap->feature_flags);
if (err)
return err;
@@ -742,7 +746,7 @@ static int sdxi_amd_qos_prevalidate_tel(struct sdxi_dev *sdxi,
err = sdxi_amd_qos_validate_tel_req(req, cap->max_pools,
sdxi_amd_qos_max_vfs(sdxi),
- sdxi->max_cxts,
+ (u32)sdxi->max_cxtid + 1,
cap->feature_flags);
if (err)
return err;
@@ -1083,3 +1087,49 @@ static int sdxi_amd_qos_exec(struct sdxi_dev *sdxi, u16 opcode_type,
dma_free_coherent(sdxi_to_dev(sdxi), dma_size, buf, buf_dma);
return err;
}
+
+static int sdxi_amd_qos_authorize(struct sdxi_dev *sdxi,
+ const struct sdxi_admin_vendor_args *args)
+{
+ (void)args;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ /* ASQOSE is PF admin-context only, including vendor PROBE. */
+ if (sdxi_fn_reports_vf(sdxi))
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
+static const struct sdxi_vendor_handler_ops sdxi_amd_qos_ops = {
+ .authorize = sdxi_amd_qos_authorize,
+ .exec = sdxi_amd_qos_exec,
+};
+
+static struct sdxi_vendor_handler sdxi_amd_qos_handler = {
+ .name = "sdxi-amd-qos",
+ .guid = sdxi_amd_guid_qos,
+ .owner = THIS_MODULE,
+ .ops = &sdxi_amd_qos_ops,
+};
+
+static int __init sdxi_amd_qos_init(void)
+{
+ return sdxi_vendor_register(&sdxi_amd_qos_handler);
+}
+
+static void __exit sdxi_amd_qos_exit(void)
+{
+ sdxi_vendor_unregister(&sdxi_amd_qos_handler);
+}
+
+module_init(sdxi_amd_qos_init);
+module_exit(sdxi_amd_qos_exit);
+
+MODULE_AUTHOR("Wei Huang <wei.huang2@xxxxxxx>");
+MODULE_DESCRIPTION("AMD SDXI QoS extension support");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("SDXI");
+MODULE_SOFTDEP("pre: sdxi-core");
--
2.56.1