public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jacob Pan <jacob.pan@linux.microsoft.com>
To: linux-kernel@vger.kernel.org,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Will Deacon <will@kernel.org>, Joerg Roedel <joro@8bytes.org>,
	Mostafa Saleh <smostafa@google.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>,
	Zhang Yu <zhangyu1@linux.microsoft.com>,
	Jean Philippe-Brucker <jean-philippe@linaro.org>,
	Alexander Grest <Alexander.Grest@microsoft.com>
Subject: [PATCH v5 1/3] iommu/arm-smmu-v3: Parameterize wfe for CMDQ polling
Date: Mon,  8 Dec 2025 13:28:55 -0800	[thread overview]
Message-ID: <20251208212857.13101-2-jacob.pan@linux.microsoft.com> (raw)
In-Reply-To: <20251208212857.13101-1-jacob.pan@linux.microsoft.com>

When SMMU_IDR0.SEV == 1, the SMMU triggers a WFE wake-up event when a
Command queue becomes non-full and an agent external to the SMMU could
have observed that the queue was previously full. However, WFE is not
always required or available during space polling. Introduce an optional
parameter to control WFE usage.

Signed-off-by: Jacob Pan <jacob.pan@linux.microsoft.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index bf67d9abc901..d637a5dcf48a 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -191,11 +191,11 @@ static u32 queue_inc_prod_n(struct arm_smmu_ll_queue *q, int n)
 }
 
 static void queue_poll_init(struct arm_smmu_device *smmu,
-			    struct arm_smmu_queue_poll *qp)
+			    struct arm_smmu_queue_poll *qp, bool want_wfe)
 {
 	qp->delay = 1;
 	qp->spin_cnt = 0;
-	qp->wfe = !!(smmu->features & ARM_SMMU_FEAT_SEV);
+	qp->wfe = want_wfe && (!!(smmu->features & ARM_SMMU_FEAT_SEV));
 	qp->timeout = ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US);
 }
 
@@ -656,13 +656,11 @@ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu,
 	struct arm_smmu_queue_poll qp;
 	u32 *cmd = (u32 *)(Q_ENT(&cmdq->q, llq->prod));
 
-	queue_poll_init(smmu, &qp);
-
 	/*
 	 * The MSI won't generate an event, since it's being written back
 	 * into the command queue.
 	 */
-	qp.wfe = false;
+	queue_poll_init(smmu, &qp, false);
 	smp_cond_load_relaxed(cmd, !VAL || (ret = queue_poll(&qp)));
 	llq->cons = ret ? llq->prod : queue_inc_prod_n(llq, 1);
 	return ret;
@@ -680,7 +678,7 @@ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu,
 	u32 prod = llq->prod;
 	int ret = 0;
 
-	queue_poll_init(smmu, &qp);
+	queue_poll_init(smmu, &qp, true);
 	llq->val = READ_ONCE(cmdq->q.llq.val);
 	do {
 		if (queue_consumed(llq, prod))
-- 
2.43.0


  reply	other threads:[~2025-12-08 21:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 21:28 [PATCH v5 0/3] SMMU v3 CMDQ fix and improvement Jacob Pan
2025-12-08 21:28 ` Jacob Pan [this message]
2025-12-08 21:28 ` [PATCH v5 2/3] iommu/arm-smmu-v3: Fix CMDQ timeout warning Jacob Pan
2025-12-10  3:16   ` Will Deacon
2025-12-12 20:05     ` Jacob Pan
2025-12-08 21:28 ` [PATCH v5 3/3] iommu/arm-smmu-v3: Improve CMDQ lock fairness and efficiency Jacob Pan
2026-01-05 22:58 ` [PATCH v5 0/3] SMMU v3 CMDQ fix and improvement Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251208212857.13101-2-jacob.pan@linux.microsoft.com \
    --to=jacob.pan@linux.microsoft.com \
    --cc=Alexander.Grest@microsoft.com \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=smostafa@google.com \
    --cc=will@kernel.org \
    --cc=zhangyu1@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox