From: Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Jordan Crouse <jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Subject: [RFC 1/3] iommu/arm-smmu: Add support to opt-in to stalling
Date: Tue, 3 Jan 2017 16:30:54 -0500 [thread overview]
Message-ID: <1483479056-15202-2-git-send-email-robdclark@gmail.com> (raw)
In-Reply-To: <1483479056-15202-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
TODO maybe we want two options, one to enable stalling, and 2nd to punt
handling to wq? I haven't needed to use mm APIs from fault handler yet
(although it is something that I think we'll want some day). Perhaps
stalling support is limited to just letting driver dump some extra
debugging information otherwise. Threaded handling probably only useful
with stalling, but inverse may not always be true.
Signed-off-by: Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
.../devicetree/bindings/iommu/arm,smmu.txt | 3 ++
drivers/iommu/arm-smmu.c | 42 ++++++++++++++++++----
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index ef465b0..5f405a6 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -68,6 +68,9 @@ conditions.
aliases of secure registers have to be used during
SMMU configuration.
+- arm,smmu-enable-stall : Enable stall mode to stall memory transactions
+ and resume after fault is handled
+
** Deprecated properties:
- mmu-masters (deprecated in favour of the generic "iommus" binding) :
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index d505432..a71cb8f 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -350,6 +350,7 @@ struct arm_smmu_device {
u32 features;
#define ARM_SMMU_OPT_SECURE_CFG_ACCESS (1 << 0)
+#define ARM_SMMU_OPT_ENABLE_STALL (1 << 1)
u32 options;
enum arm_smmu_arch_version version;
enum arm_smmu_implementation model;
@@ -425,6 +426,7 @@ static bool using_legacy_binding, using_generic_binding;
static struct arm_smmu_option_prop arm_smmu_options[] = {
{ ARM_SMMU_OPT_SECURE_CFG_ACCESS, "calxeda,smmu-secure-config-access" },
+ { ARM_SMMU_OPT_ENABLE_STALL, "arm,smmu-enable-stall" },
{ 0, NULL},
};
@@ -676,7 +678,8 @@ static struct iommu_gather_ops arm_smmu_gather_ops = {
static irqreturn_t arm_smmu_context_fault(int irq, void *dev)
{
- u32 fsr, fsynr;
+ int flags, ret;
+ u32 fsr, fsynr, resume;
unsigned long iova;
struct iommu_domain *domain = dev;
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
@@ -690,15 +693,40 @@ static irqreturn_t arm_smmu_context_fault(int irq, void *dev)
if (!(fsr & FSR_FAULT))
return IRQ_NONE;
+ if (fsr & FSR_IGN)
+ dev_err_ratelimited(smmu->dev,
+ "Unexpected context fault (fsr 0x%x)\n",
+ fsr);
+
fsynr = readl_relaxed(cb_base + ARM_SMMU_CB_FSYNR0);
- iova = readq_relaxed(cb_base + ARM_SMMU_CB_FAR);
+ flags = fsynr & FSYNR0_WNR ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ;
- dev_err_ratelimited(smmu->dev,
- "Unhandled context fault: fsr=0x%x, iova=0x%08lx, fsynr=0x%x, cb=%d\n",
- fsr, iova, fsynr, cfg->cbndx);
+ iova = readq_relaxed(cb_base + ARM_SMMU_CB_FAR);
+ if (!report_iommu_fault(domain, smmu->dev, iova, flags)) {
+ ret = IRQ_HANDLED;
+ resume = RESUME_RETRY;
+ } else {
+ dev_err_ratelimited(smmu->dev,
+ "Unhandled context fault: iova=0x%08lx, fsynr=0x%x, cb=%d\n",
+ iova, fsynr, cfg->cbndx);
+ ret = IRQ_NONE;
+ resume = RESUME_TERMINATE;
+ }
+ /* Clear the faulting FSR */
writel(fsr, cb_base + ARM_SMMU_CB_FSR);
- return IRQ_HANDLED;
+
+ /* Retry or terminate any stalled transactions */
+ if (fsr & FSR_SS) {
+ /* Should we care about ending up w/ a stalled transaction
+ * when we didn't ask for it? I guess for now best to call
+ * attention to it and resume anyways.
+ */
+ WARN_ON(!(smmu->options & ARM_SMMU_OPT_ENABLE_STALL));
+ writel_relaxed(resume, cb_base + ARM_SMMU_CB_RESUME);
+ }
+
+ return ret;
}
static irqreturn_t arm_smmu_global_fault(int irq, void *dev)
@@ -824,6 +852,8 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain,
/* SCTLR */
reg = SCTLR_CFIE | SCTLR_CFRE | SCTLR_AFE | SCTLR_TRE | SCTLR_M;
+ if (smmu->options & ARM_SMMU_OPT_ENABLE_STALL)
+ reg |= SCTLR_CFCFG;
if (stage1)
reg |= SCTLR_S1_ASIDPNE;
#ifdef __BIG_ENDIAN
--
2.7.4
next prev parent reply other threads:[~2017-01-03 21:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-03 21:30 [RFC 0/3] iommu/arm-smmu: patches for adreno Rob Clark
[not found] ` <1483479056-15202-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-03 21:30 ` Rob Clark [this message]
[not found] ` <1483479056-15202-2-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-05 11:55 ` [RFC 1/3] iommu/arm-smmu: Add support to opt-in to stalling Will Deacon
2017-01-05 12:08 ` Mark Rutland
2017-01-05 14:00 ` Will Deacon
[not found] ` <20170105140005.GJ679-5wv7dgnIgG8@public.gmane.org>
2017-01-05 14:07 ` Mark Rutland
2017-01-05 14:47 ` Will Deacon
[not found] ` <20170105144742.GK679-5wv7dgnIgG8@public.gmane.org>
2017-01-05 15:32 ` Robin Murphy
2017-01-05 16:07 ` Will Deacon
[not found] ` <20170105160755.GN679-5wv7dgnIgG8@public.gmane.org>
2017-01-05 17:03 ` Robin Murphy
[not found] ` <611575f4-3e37-1f4d-ef29-94e6f65baf66-5wv7dgnIgG8@public.gmane.org>
2017-01-05 17:25 ` Will Deacon
2017-01-06 16:36 ` Rob Clark
[not found] ` <20170105115528.GG679-5wv7dgnIgG8@public.gmane.org>
2017-01-05 15:27 ` Rob Clark
[not found] ` <CAF6AEGsUdZALAQTozmxPV8Os=3pG7ay=1Oqtctx99FV9_4SX7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-05 15:49 ` Will Deacon
[not found] ` <20170105154950.GM679-5wv7dgnIgG8@public.gmane.org>
2017-01-06 16:26 ` Rob Clark
2017-01-10 17:52 ` Will Deacon
[not found] ` <20170110175219.GK527-5wv7dgnIgG8@public.gmane.org>
2017-01-10 19:20 ` Rob Clark
[not found] ` <CAF6AEGsCJ6L-wmBHFYy2jfQ1bfq_d2wmiWVUXno344US9ikLVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-11 9:36 ` Will Deacon
[not found] ` <20170111093606.GA12388-5wv7dgnIgG8@public.gmane.org>
2017-01-11 20:59 ` Rob Clark
2017-01-12 15:17 ` Will Deacon
[not found] ` <20170112151717.GB13843-5wv7dgnIgG8@public.gmane.org>
2017-01-30 20:51 ` Rob Clark
2017-01-03 21:30 ` [RFC 2/3] iommu/arm-smmu: Add qcom implementation Rob Clark
[not found] ` <1483479056-15202-3-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-03 22:28 ` Jordan Crouse
[not found] ` <20170103222832.GA19199-9PYrDHPZ2Orvke4nUoYGnHL1okKdlPRT@public.gmane.org>
2017-01-04 13:33 ` Sricharan
2017-01-04 14:31 ` Rob Clark
[not found] ` <CAF6AEGuT_qq-UJK3sdvtVqxfsLBH-_jZVKz1vF383tOYVQpraw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-04 17:16 ` Rob Clark
2017-01-03 21:30 ` [RFC 3/3] iommu/arm-smmu: Let fault handler return -EFAULT Rob Clark
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=1483479056-15202-2-git-send-email-robdclark@gmail.com \
--to=robdclark-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.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