From: Fenghua Yu <fenghua.yu@intel.com>
To: Ingo Molnar <mingo@elte.hu>,
Linus Torvalds <torvalds@linux-foundation.org>,
David Woodhouse <dwmw2@infradead.org>
Cc: Andrew Lutomirski <amluto@gmail.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Kyle McMartin <kyle@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org
Subject: [PATCH 2/2] Intel IOMMU Suspend/Resume Support for Queued Invalidation
Date: Tue, 24 Mar 2009 15:37:23 -0700 [thread overview]
Message-ID: <20090324223723.GA24125@linux-os.sc.intel.com> (raw)
In-Reply-To: <20090324203259.GC26930@elte.hu>
This patch supports suspend/resume for queued invalidation. During suspend/
resume, queued invalidation is disabled and then reenabled. This patch also
consolidate queued invalidation hardware operation into one function.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
dmar.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index d313039..b318bd1 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -790,14 +790,39 @@ end:
}
/*
+ * Enable queued invalidation.
+ */
+static void __dmar_enable_qi(struct intel_iommu *iommu)
+{
+ u32 cmd, sts;
+ unsigned long flags;
+ struct q_inval *qi = iommu->qi;
+
+ qi->free_head = qi->free_tail = 0;
+ qi->free_cnt = QI_LENGTH;
+
+ spin_lock_irqsave(&iommu->register_lock, flags);
+ /* write zero to the tail reg */
+ writel(0, iommu->reg + DMAR_IQT_REG);
+
+ dmar_writeq(iommu->reg + DMAR_IQA_REG, virt_to_phys(qi->desc));
+
+ cmd = iommu->gcmd | DMA_GCMD_QIE;
+ iommu->gcmd |= DMA_GCMD_QIE;
+ writel(cmd, iommu->reg + DMAR_GCMD_REG);
+
+ /* Make sure hardware complete it */
+ IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_QIES), sts);
+ spin_unlock_irqrestore(&iommu->register_lock, flags);
+}
+
+/*
* Enable Queued Invalidation interface. This is a must to support
* interrupt-remapping. Also used by DMA-remapping, which replaces
* register based IOTLB invalidation.
*/
int dmar_enable_qi(struct intel_iommu *iommu)
{
- u32 cmd, sts;
- unsigned long flags;
struct q_inval *qi;
if (!ecap_qis(iommu->ecap))
@@ -835,19 +860,7 @@ int dmar_enable_qi(struct intel_iommu *iommu)
spin_lock_init(&qi->q_lock);
- spin_lock_irqsave(&iommu->register_lock, flags);
- /* write zero to the tail reg */
- writel(0, iommu->reg + DMAR_IQT_REG);
-
- dmar_writeq(iommu->reg + DMAR_IQA_REG, virt_to_phys(qi->desc));
-
- cmd = iommu->gcmd | DMA_GCMD_QIE;
- iommu->gcmd |= DMA_GCMD_QIE;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
-
- /* Make sure hardware complete it */
- IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_QIES), sts);
- spin_unlock_irqrestore(&iommu->register_lock, flags);
+ __dmar_enable_qi(iommu);
return 0;
}
@@ -1102,3 +1115,27 @@ int __init enable_drhd_fault_handling(void)
return 0;
}
+
+/*
+ * Re-enable Queued Invalidation interface.
+ */
+int dmar_reenable_qi(struct intel_iommu *iommu)
+{
+ if (!ecap_qis(iommu->ecap))
+ return -ENOENT;
+
+ if (!iommu->qi)
+ return -ENOENT;
+
+ /*
+ * First disable queued invalidation.
+ */
+ dmar_disable_qi(iommu);
+ /* Then enable queued invalidation again. Since there is no pending
+ * invalidation requests now, it's safe to re-enable queued
+ * invalidation.
+ */
+ __dmar_enable_qi(iommu);
+
+ return 0;
+}
next prev parent reply other threads:[~2009-03-25 18:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-24 19:58 2.6.29: can't resume from suspend with DMAR (intel iommu) enabled Andrew Lutomirski
2009-03-24 20:03 ` Rafael J. Wysocki
2009-03-24 20:32 ` Ingo Molnar
2009-03-24 20:36 ` Yu, Fenghua
2009-03-24 20:40 ` Kyle McMartin
2009-04-10 22:46 ` David Woodhouse
2009-04-10 23:21 ` Yu, Fenghua
2009-04-11 0:48 ` Suresh Siddha
2009-04-11 2:12 ` David Woodhouse
2009-03-24 22:36 ` [PATCH 1/2] Intel IOMMU Suspend/Resume Support for DMAR Fenghua Yu
2009-03-24 22:37 ` Fenghua Yu [this message]
2009-03-25 17:32 ` 2.6.29: can't resume from suspend with DMAR (intel iommu) enabled mark gross
2009-03-25 17:38 ` Ingo Molnar
2009-03-25 17:53 ` David Woodhouse
2009-03-25 17:59 ` Ingo Molnar
2009-03-25 18:03 ` David Woodhouse
2009-03-25 18:07 ` Ingo Molnar
2009-03-25 18:10 ` David Woodhouse
2009-03-25 18:20 ` Ingo Molnar
2009-03-25 18:42 ` Ingo Molnar
2009-04-06 20:56 ` David Woodhouse
2009-04-07 7:56 ` Matthew Garrett
2009-04-07 11:10 ` David Woodhouse
2009-04-10 21:27 ` David Woodhouse
2009-04-11 6:04 ` David Woodhouse
2009-04-11 14:38 ` Kyle McMartin
2009-04-11 16:52 ` David Woodhouse
2009-04-11 17:14 ` Kyle McMartin
-- strict thread matches above, loose matches on Subject: below --
2009-03-25 18:45 [patch 0/2] Intel IOMMU Suspend/Resume Support fenghua.yu
2009-03-25 18:45 ` [patch 2/2] Intel IOMMU Suspend/Resume Support for Queued Invalidation fenghua.yu
2009-03-25 20:28 ` Ingo Molnar
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=20090324223723.GA24125@linux-os.sc.intel.com \
--to=fenghua.yu@intel.com \
--cc=amluto@gmail.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=kyle@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.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