Skip to content

Commit f59e854

Browse files
nicolincwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Start a new batch if new command is not supported
The VCMDQ in the tegra241-cmdqv driver has a guest mode that supports only a few invalidation commands. A batch is initialized with a cmdq, so it has to confirm whether a new command is supported or not. Add a supports_cmd function pointer to the cmdq structure, where the vcmdq driver should hook a command scan function. Add an inline helper too so it can be used by both sides. If a new command is not supported, simply issue the existing batch and re- init it as a new batch. Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Link: https://lore.kernel.org/r/aafb24b881504f18c5d0c7c15f2134e40ad2c486.1724970714.git.nicolinc@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 918eb5c commit f59e854

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,12 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
923923
struct arm_smmu_cmdq_batch *cmds,
924924
struct arm_smmu_cmdq_ent *cmd)
925925
{
926+
bool unsupported_cmd = !arm_smmu_cmdq_supports_cmd(cmds->cmdq, cmd);
927+
bool force_sync = (cmds->num == CMDQ_BATCH_ENTRIES - 1) &&
928+
(smmu->options & ARM_SMMU_OPT_CMDQ_FORCE_SYNC);
926929
int index;
927930

928-
if (cmds->num == CMDQ_BATCH_ENTRIES - 1 &&
929-
(smmu->options & ARM_SMMU_OPT_CMDQ_FORCE_SYNC)) {
931+
if (force_sync || unsupported_cmd) {
930932
arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
931933
cmds->num, true);
932934
arm_smmu_cmdq_batch_init(smmu, cmds);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,15 @@ struct arm_smmu_cmdq {
568568
atomic_long_t *valid_map;
569569
atomic_t owner_prod;
570570
atomic_t lock;
571+
bool (*supports_cmd)(struct arm_smmu_cmdq_ent *ent);
571572
};
572573

574+
static inline bool arm_smmu_cmdq_supports_cmd(struct arm_smmu_cmdq *cmdq,
575+
struct arm_smmu_cmdq_ent *ent)
576+
{
577+
return cmdq->supports_cmd ? cmdq->supports_cmd(ent) : true;
578+
}
579+
573580
struct arm_smmu_cmdq_batch {
574581
u64 cmds[CMDQ_BATCH_ENTRIES * CMDQ_ENT_DWORDS];
575582
struct arm_smmu_cmdq *cmdq;

0 commit comments

Comments
 (0)