Skip to content

Commit b935a5b

Browse files
nicolincwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Add ARM_SMMU_OPT_TEGRA241_CMDQV
The CMDQV extension in NVIDIA Tegra241 SoC only supports CS_NONE in the CS field of CMD_SYNC. Add a new SMMU option to accommodate that. Suggested-by: Will Deacon <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Link: https://lore.kernel.org/r/a3cb9bb2429fbae4a59f7ef517614d226763d717.1724970714.git.nicolinc@nvidia.com Signed-off-by: Will Deacon <[email protected]>
1 parent a7a08b8 commit b935a5b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ static struct arm_smmu_cmdq *arm_smmu_get_cmdq(struct arm_smmu_device *smmu)
351351
return &smmu->cmdq;
352352
}
353353

354+
static bool arm_smmu_cmdq_needs_busy_polling(struct arm_smmu_device *smmu,
355+
struct arm_smmu_cmdq *cmdq)
356+
{
357+
if (cmdq == &smmu->cmdq)
358+
return false;
359+
360+
return smmu->options & ARM_SMMU_OPT_TEGRA241_CMDQV;
361+
}
362+
354363
static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
355364
struct arm_smmu_cmdq *cmdq, u32 prod)
356365
{
@@ -369,6 +378,8 @@ static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
369378
}
370379

371380
arm_smmu_cmdq_build_cmd(cmd, &ent);
381+
if (arm_smmu_cmdq_needs_busy_polling(smmu, cmdq))
382+
u64p_replace_bits(cmd, CMDQ_SYNC_0_CS_NONE, CMDQ_SYNC_0_CS);
372383
}
373384

374385
void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
@@ -423,6 +434,8 @@ void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
423434

424435
/* Convert the erroneous command into a CMD_SYNC */
425436
arm_smmu_cmdq_build_cmd(cmd, &cmd_sync);
437+
if (arm_smmu_cmdq_needs_busy_polling(smmu, cmdq))
438+
u64p_replace_bits(cmd, CMDQ_SYNC_0_CS_NONE, CMDQ_SYNC_0_CS);
426439

427440
queue_write(Q_ENT(q, cons), cmd, q->ent_dwords);
428441
}
@@ -706,7 +719,8 @@ static int arm_smmu_cmdq_poll_until_sync(struct arm_smmu_device *smmu,
706719
struct arm_smmu_cmdq *cmdq,
707720
struct arm_smmu_ll_queue *llq)
708721
{
709-
if (smmu->options & ARM_SMMU_OPT_MSIPOLL)
722+
if (smmu->options & ARM_SMMU_OPT_MSIPOLL &&
723+
!arm_smmu_cmdq_needs_busy_polling(smmu, cmdq))
710724
return __arm_smmu_cmdq_poll_until_msi(smmu, cmdq, llq);
711725

712726
return __arm_smmu_cmdq_poll_until_consumed(smmu, cmdq, llq);

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ struct arm_smmu_device {
665665
#define ARM_SMMU_OPT_PAGE0_REGS_ONLY (1 << 1)
666666
#define ARM_SMMU_OPT_MSIPOLL (1 << 2)
667667
#define ARM_SMMU_OPT_CMDQ_FORCE_SYNC (1 << 3)
668+
#define ARM_SMMU_OPT_TEGRA241_CMDQV (1 << 4)
668669
u32 options;
669670

670671
struct arm_smmu_cmdq cmdq;

0 commit comments

Comments
 (0)