Skip to content

Commit 8639cc8

Browse files
Zhen Leiwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Add and use static helper function arm_smmu_get_cmdq()
One SMMU has only one normal CMDQ. Therefore, this CMDQ is used regardless of the core on which the command is inserted. It can be referenced directly through "smmu->cmdq". However, one SMMU has multiple ECMDQs, and the ECMDQ used by the core on which the command insertion is executed may be different. So the helper function arm_smmu_get_cmdq() is added, which returns the CMDQ/ECMDQ that the current core should use. Currently, the code that supports ECMDQ is not added. just simply returns "&smmu->cmdq". Many subfunctions of arm_smmu_cmdq_issue_cmdlist() use "&smmu->cmdq" or "&smmu->cmdq.q" directly. To support ECMDQ, they need to call the newly added function arm_smmu_get_cmdq() instead. Note that normal CMDQ is still required until ECMDQ is available. Signed-off-by: Zhen Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 4537f6f commit 8639cc8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,14 @@ static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent)
335335
return 0;
336336
}
337337

338+
static struct arm_smmu_cmdq *arm_smmu_get_cmdq(struct arm_smmu_device *smmu)
339+
{
340+
return &smmu->cmdq;
341+
}
342+
338343
static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
339-
u32 prod)
344+
struct arm_smmu_queue *q, u32 prod)
340345
{
341-
struct arm_smmu_queue *q = &smmu->cmdq.q;
342346
struct arm_smmu_cmdq_ent ent = {
343347
.opcode = CMDQ_OP_CMD_SYNC,
344348
};
@@ -579,7 +583,7 @@ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu,
579583
{
580584
unsigned long flags;
581585
struct arm_smmu_queue_poll qp;
582-
struct arm_smmu_cmdq *cmdq = &smmu->cmdq;
586+
struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu);
583587
int ret = 0;
584588

585589
/*
@@ -595,7 +599,7 @@ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu,
595599

596600
queue_poll_init(smmu, &qp);
597601
do {
598-
llq->val = READ_ONCE(smmu->cmdq.q.llq.val);
602+
llq->val = READ_ONCE(cmdq->q.llq.val);
599603
if (!queue_full(llq))
600604
break;
601605

@@ -614,7 +618,7 @@ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu,
614618
{
615619
int ret = 0;
616620
struct arm_smmu_queue_poll qp;
617-
struct arm_smmu_cmdq *cmdq = &smmu->cmdq;
621+
struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu);
618622
u32 *cmd = (u32 *)(Q_ENT(&cmdq->q, llq->prod));
619623

620624
queue_poll_init(smmu, &qp);
@@ -637,12 +641,12 @@ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu,
637641
struct arm_smmu_ll_queue *llq)
638642
{
639643
struct arm_smmu_queue_poll qp;
640-
struct arm_smmu_cmdq *cmdq = &smmu->cmdq;
644+
struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu);
641645
u32 prod = llq->prod;
642646
int ret = 0;
643647

644648
queue_poll_init(smmu, &qp);
645-
llq->val = READ_ONCE(smmu->cmdq.q.llq.val);
649+
llq->val = READ_ONCE(cmdq->q.llq.val);
646650
do {
647651
if (queue_consumed(llq, prod))
648652
break;
@@ -732,7 +736,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu,
732736
u32 prod;
733737
unsigned long flags;
734738
bool owner;
735-
struct arm_smmu_cmdq *cmdq = &smmu->cmdq;
739+
struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu);
736740
struct arm_smmu_ll_queue llq, head;
737741
int ret = 0;
738742

@@ -772,7 +776,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu,
772776
arm_smmu_cmdq_write_entries(cmdq, cmds, llq.prod, n);
773777
if (sync) {
774778
prod = queue_inc_prod_n(&llq, n);
775-
arm_smmu_cmdq_build_sync_cmd(cmd_sync, smmu, prod);
779+
arm_smmu_cmdq_build_sync_cmd(cmd_sync, smmu, &cmdq->q, prod);
776780
queue_write(Q_ENT(&cmdq->q, prod), cmd_sync, CMDQ_ENT_DWORDS);
777781

778782
/*

0 commit comments

Comments
 (0)