From nobody Fri Dec 19 15:48:06 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 316F12DF719 for ; Mon, 8 Dec 2025 21:29:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765229341; cv=none; b=t1mThABxSxmqIIDw9yEEdUQK8RoSUCju0Kgon+abUQvL9B4ILaVOxGR7duqwbs9/G5KonzAQGqR/7yt6B3fd0cQBoCJnFwNg9kFAwTBAVxQPq5en/m9YgysCYzni3UT/WqVZCpJf/225MMUA18gFsLHGGlTt0EmbMYZNza+HvJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765229341; c=relaxed/simple; bh=ZWO1QudnFRSa/UfJWADrKqPlpf4gjcW/LBipSYFpdRA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g80LTscINChPMgGZd0yR61HDBxPakxj5dcdjSMqNnBhoxA5xUXTyyKruqyNYkABEU1p8uHPyrou84845shfH0CwwToCajaEpjdybQw2ruoLgGtcAJPhL9WIzPYWhPf1F5YJoGKv2teY/iVyxtON2vspqLNWe0TAFpy0ql3GU4iI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=B/n8wCWT; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="B/n8wCWT" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [52.148.138.235]) by linux.microsoft.com (Postfix) with ESMTPSA id 4F3772116048; Mon, 8 Dec 2025 13:28:59 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4F3772116048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1765229339; bh=tsK3GpldGAW1/rhp32GUlYbF7U4FuS5oiQ9b0RSvaIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/n8wCWThXglPw4hACGK2/bbAbgaXQngxfoYLcj9s6kh/wkRdHLCE+NtZSa8zdOWV Ut5j81lhHTPlorWHzs4BW5SSO/lq0xah7vpP7vYd9nE39UJgTaK1q8BpXn53DLt7+a SAUsM4P/Nf7BUUyj3EAzJh2TnCzAf1iyCzml5aVc= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Will Deacon , Joerg Roedel , Mostafa Saleh , Jason Gunthorpe , Robin Murphy , Nicolin Chen Cc: Jacob Pan , Zhang Yu , Jean Philippe-Brucker , Alexander Grest Subject: [PATCH v5 1/3] iommu/arm-smmu-v3: Parameterize wfe for CMDQ polling Date: Mon, 8 Dec 2025 13:28:55 -0800 Message-Id: <20251208212857.13101-2-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251208212857.13101-1-jacob.pan@linux.microsoft.com> References: <20251208212857.13101-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When SMMU_IDR0.SEV =3D=3D 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 --- 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/ar= m/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) } =20 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 =3D 1; qp->spin_cnt =3D 0; - qp->wfe =3D !!(smmu->features & ARM_SMMU_FEAT_SEV); + qp->wfe =3D want_wfe && (!!(smmu->features & ARM_SMMU_FEAT_SEV)); qp->timeout =3D ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US); } =20 @@ -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 =3D (u32 *)(Q_ENT(&cmdq->q, llq->prod)); =20 - queue_poll_init(smmu, &qp); - /* * The MSI won't generate an event, since it's being written back * into the command queue. */ - qp.wfe =3D false; + queue_poll_init(smmu, &qp, false); smp_cond_load_relaxed(cmd, !VAL || (ret =3D queue_poll(&qp))); llq->cons =3D ret ? llq->prod : queue_inc_prod_n(llq, 1); return ret; @@ -680,7 +678,7 @@ static int __arm_smmu_cmdq_poll_until_consumed(struct a= rm_smmu_device *smmu, u32 prod =3D llq->prod; int ret =3D 0; =20 - queue_poll_init(smmu, &qp); + queue_poll_init(smmu, &qp, true); llq->val =3D READ_ONCE(cmdq->q.llq.val); do { if (queue_consumed(llq, prod)) --=20 2.43.0