]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/tegra241-cmdqv: Add IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV support
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:59:21 +0000 (22:59 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jul 2025 17:34:36 +0000 (14:34 -0300)
Add a new vEVENTQ type for VINTFs that are assigned to the user space.
Simply report the two 64-bit LVCMDQ_ERR_MAPs register values.

Link: https://patch.msgid.link/r/68161a980da41fa5022841209638aeff258557b5.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
include/uapi/linux/iommufd.h

index 3eeb8444fadf13c628e687f383015c12fd38adfc..d5d43a1c7708290d793a9eb1871e10f9107c7e9f 100644 (file)
@@ -295,6 +295,20 @@ static inline int vcmdq_write_config(struct tegra241_vcmdq *vcmdq, u32 regval)
 
 /* ISR Functions */
 
+static void tegra241_vintf_user_handle_error(struct tegra241_vintf *vintf)
+{
+       struct iommufd_viommu *viommu = &vintf->vsmmu.core;
+       struct iommu_vevent_tegra241_cmdqv vevent_data;
+       int i;
+
+       for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++)
+               vevent_data.lvcmdq_err_map[i] =
+                       readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i)));
+
+       iommufd_viommu_report_event(viommu, IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV,
+                                   &vevent_data, sizeof(vevent_data));
+}
+
 static void tegra241_vintf0_handle_error(struct tegra241_vintf *vintf)
 {
        int i;
@@ -340,6 +354,14 @@ static irqreturn_t tegra241_cmdqv_isr(int irq, void *devid)
                vintf_map &= ~BIT_ULL(0);
        }
 
+       /* Handle other user VINTFs and their LVCMDQs */
+       while (vintf_map) {
+               unsigned long idx = __ffs64(vintf_map);
+
+               tegra241_vintf_user_handle_error(cmdqv->vintfs[idx]);
+               vintf_map &= ~BIT_ULL(idx);
+       }
+
        return IRQ_HANDLED;
 }
 
index 2fecea1973bcc7cecb6f74e79db3efe723aed6dd..554aacf89ea7b45bdb79bb7e0f02bbca81e232ab 100644 (file)
@@ -1146,10 +1146,12 @@ struct iommufd_vevent_header {
  * enum iommu_veventq_type - Virtual Event Queue Type
  * @IOMMU_VEVENTQ_TYPE_DEFAULT: Reserved for future use
  * @IOMMU_VEVENTQ_TYPE_ARM_SMMUV3: ARM SMMUv3 Virtual Event Queue
+ * @IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV Extension IRQ
  */
 enum iommu_veventq_type {
        IOMMU_VEVENTQ_TYPE_DEFAULT = 0,
        IOMMU_VEVENTQ_TYPE_ARM_SMMUV3 = 1,
+       IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV = 2,
 };
 
 /**
@@ -1173,6 +1175,19 @@ struct iommu_vevent_arm_smmuv3 {
        __aligned_le64 evt[4];
 };
 
+/**
+ * struct iommu_vevent_tegra241_cmdqv - Tegra241 CMDQV IRQ
+ *                                      (IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV)
+ * @lvcmdq_err_map: 128-bit logical vcmdq error map, little-endian.
+ *                  (Refer to register LVCMDQ_ERR_MAPs per VINTF )
+ *
+ * The 128-bit register value from HW exclusively reflect the error bits for a
+ * Virtual Interface represented by a vIOMMU object. Read and report directly.
+ */
+struct iommu_vevent_tegra241_cmdqv {
+       __aligned_le64 lvcmdq_err_map[2];
+};
+
 /**
  * struct iommu_veventq_alloc - ioctl(IOMMU_VEVENTQ_ALLOC)
  * @size: sizeof(struct iommu_veventq_alloc)