Skip to content

Commit 32b2d3a

Browse files
nicolincjgunthorpe
authored andcommitted
iommu/tegra241-cmdqv: Add IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV support
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 <[email protected]> Reviewed-by: Pranjal Shrivastava <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 4dc0d12 commit 32b2d3a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,20 @@ static inline int vcmdq_write_config(struct tegra241_vcmdq *vcmdq, u32 regval)
295295

296296
/* ISR Functions */
297297

298+
static void tegra241_vintf_user_handle_error(struct tegra241_vintf *vintf)
299+
{
300+
struct iommufd_viommu *viommu = &vintf->vsmmu.core;
301+
struct iommu_vevent_tegra241_cmdqv vevent_data;
302+
int i;
303+
304+
for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++)
305+
vevent_data.lvcmdq_err_map[i] =
306+
readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i)));
307+
308+
iommufd_viommu_report_event(viommu, IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV,
309+
&vevent_data, sizeof(vevent_data));
310+
}
311+
298312
static void tegra241_vintf0_handle_error(struct tegra241_vintf *vintf)
299313
{
300314
int i;
@@ -340,6 +354,14 @@ static irqreturn_t tegra241_cmdqv_isr(int irq, void *devid)
340354
vintf_map &= ~BIT_ULL(0);
341355
}
342356

357+
/* Handle other user VINTFs and their LVCMDQs */
358+
while (vintf_map) {
359+
unsigned long idx = __ffs64(vintf_map);
360+
361+
tegra241_vintf_user_handle_error(cmdqv->vintfs[idx]);
362+
vintf_map &= ~BIT_ULL(idx);
363+
}
364+
343365
return IRQ_HANDLED;
344366
}
345367

include/uapi/linux/iommufd.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,10 +1146,12 @@ struct iommufd_vevent_header {
11461146
* enum iommu_veventq_type - Virtual Event Queue Type
11471147
* @IOMMU_VEVENTQ_TYPE_DEFAULT: Reserved for future use
11481148
* @IOMMU_VEVENTQ_TYPE_ARM_SMMUV3: ARM SMMUv3 Virtual Event Queue
1149+
* @IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV Extension IRQ
11491150
*/
11501151
enum iommu_veventq_type {
11511152
IOMMU_VEVENTQ_TYPE_DEFAULT = 0,
11521153
IOMMU_VEVENTQ_TYPE_ARM_SMMUV3 = 1,
1154+
IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV = 2,
11531155
};
11541156

11551157
/**
@@ -1173,6 +1175,19 @@ struct iommu_vevent_arm_smmuv3 {
11731175
__aligned_le64 evt[4];
11741176
};
11751177

1178+
/**
1179+
* struct iommu_vevent_tegra241_cmdqv - Tegra241 CMDQV IRQ
1180+
* (IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV)
1181+
* @lvcmdq_err_map: 128-bit logical vcmdq error map, little-endian.
1182+
* (Refer to register LVCMDQ_ERR_MAPs per VINTF )
1183+
*
1184+
* The 128-bit register value from HW exclusively reflect the error bits for a
1185+
* Virtual Interface represented by a vIOMMU object. Read and report directly.
1186+
*/
1187+
struct iommu_vevent_tegra241_cmdqv {
1188+
__aligned_le64 lvcmdq_err_map[2];
1189+
};
1190+
11761191
/**
11771192
* struct iommu_veventq_alloc - ioctl(IOMMU_VEVENTQ_ALLOC)
11781193
* @size: sizeof(struct iommu_veventq_alloc)

0 commit comments

Comments
 (0)