]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dmaengine: idxd: Narrow the restriction on BATCH to ver. 1 only
authorVinicius Costa Gomes <vinicius.gomes@intel.com>
Wed, 12 Mar 2025 22:15:10 +0000 (15:15 -0700)
committerVinod Koul <vkoul@kernel.org>
Wed, 14 May 2025 14:29:04 +0000 (15:29 +0100)
Allow BATCH operations to be submitted and the capability to be
exposed for DSA version 2 (or later) devices.

DSA version 2 devices allow safe submission of BATCH operations.

Signed-off-by: Anil Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reported-by: Yi Sun <yi.sun@intel.com>
Tested-by: Yi Sun <yi.sun@intel.com>
Link: https://lore.kernel.org/r/20250312221511.277954-1-vinicius.gomes@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/cdev.c
drivers/dma/idxd/sysfs.c

index a202fe4937a793af2cef754795e1e039fae572fa..ce21e1692c63f39ea3371102fb2ae8ecc6627349 100644 (file)
@@ -441,10 +441,12 @@ static int idxd_submit_user_descriptor(struct idxd_user_context *ctx,
         * DSA devices are capable of indirect ("batch") command submission.
         * On devices where direct user submissions are not safe, we cannot
         * allow this since there is no good way for us to verify these
-        * indirect commands.
+        * indirect commands. Narrow the restriction of operations with the
+        * BATCH opcode to only DSA version 1 devices.
         */
        if (is_dsa_dev(idxd_dev) && descriptor.opcode == DSA_OPCODE_BATCH &&
-               !wq->idxd->user_submission_safe)
+           wq->idxd->hw.version == DEVICE_VERSION_1 &&
+           !wq->idxd->user_submission_safe)
                return -EINVAL;
        /*
         * As per the programming specification, the completion address must be
index 6af493f6ba77c2f3fe739d50f5afc2e673266424..9f0701021af0e6fbe3c3c04a0e336ee9cd094641 100644 (file)
@@ -1208,9 +1208,11 @@ static ssize_t op_cap_show_common(struct device *dev, char *buf, unsigned long *
 
                /* On systems where direct user submissions are not safe, we need to clear out
                 * the BATCH capability from the capability mask in sysfs since we cannot support
-                * that command on such systems.
+                * that command on such systems. Narrow the restriction of operations with the
+                * BATCH opcode to only DSA version 1 devices.
                 */
-               if (i == DSA_OPCODE_BATCH/64 && !confdev_to_idxd(dev)->user_submission_safe)
+               if (i == DSA_OPCODE_BATCH/64 && !confdev_to_idxd(dev)->user_submission_safe &&
+                   confdev_to_idxd(dev)->hw.version == DEVICE_VERSION_1)
                        clear_bit(DSA_OPCODE_BATCH % 64, &val);
 
                pos += sysfs_emit_at(buf, pos, "%*pb", 64, &val);