From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 1/7] iommu/vt-d: Handle volatile descriptor status read
Date: Tue, 2 Jul 2024 21:08:33 +0800 [thread overview]
Message-ID: <20240702130839.108139-2-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20240702130839.108139-1-baolu.lu@linux.intel.com>
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
Queued invalidation wait descriptor status is volatile in that IOMMU
hardware writes the data upon completion.
Use READ_ONCE() to prevent compiler optimizations which ensures memory
reads every time. As a side effect, READ_ONCE() also enforces strict
types and may add an extra instruction. But it should not have negative
performance impact since we use cpu_relax anyway and the extra time(by
adding an instruction) may allow IOMMU HW request cacheline ownership
easier.
e.g. gcc 12.3
BEFORE:
81 38 ad de 00 00 cmpl $0x2,(%rax)
AFTER (with READ_ONCE())
772f: 8b 00 mov (%rax),%eax
7731: 3d ad de 00 00 cmp $0x2,%eax
//status data is 32 bit
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20240607173817.3914600-1-jacob.jun.pan@linux.intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/intel/dmar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 304e84949ca7..1c8d3141cb55 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -1446,7 +1446,7 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc,
*/
writel(qi->free_head << shift, iommu->reg + DMAR_IQT_REG);
- while (qi->desc_status[wait_index] != QI_DONE) {
+ while (READ_ONCE(qi->desc_status[wait_index]) != QI_DONE) {
/*
* We will leave the interrupts disabled, to prevent interrupt
* context to queue another cmd while a cmd is already submitted
--
2.34.1
next prev parent reply other threads:[~2024-07-02 13:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 13:08 [PATCH 0/7] [PULL REQUEST] Intel IOMMU updates for v6.11 Lu Baolu
2024-07-02 13:08 ` Lu Baolu [this message]
2024-07-02 13:08 ` [PATCH 2/7] iommu/vt-d: Remove comment for def_domain_type Lu Baolu
2024-07-02 13:08 ` [PATCH 3/7] iommu/vt-d: Remove control over Execute-Requested requests Lu Baolu
2024-07-02 13:08 ` [PATCH 4/7] iommu/vt-d: Downgrade warning for pre-enabled IR Lu Baolu
2024-07-02 13:08 ` [PATCH 5/7] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
2024-07-02 13:25 ` Yi Liu
2024-07-02 13:08 ` [PATCH 6/7] iommu/vt-d: Add helper to flush caches for context change Lu Baolu
2024-08-14 22:27 ` Alex Williamson
2024-08-15 4:47 ` Baolu Lu
2024-08-15 12:34 ` Alex Williamson
2024-08-15 12:41 ` Baolu Lu
2024-07-02 13:08 ` [PATCH 7/7] iommu/vt-d: Refactor PCI PRI enabling/disabling callbacks Lu Baolu
2024-07-03 16:13 ` [PATCH 0/7] [PULL REQUEST] Intel IOMMU updates for v6.11 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=20240702130839.108139-2-baolu.lu@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.jun.pan@linux.intel.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
/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