From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/7] iommu/arm-smmu: put iommu_domain pointer in dev->archdata.iommu
Date: Thu, 4 Sep 2014 17:50:01 +0100 [thread overview]
Message-ID: <1409849405-17347-4-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1409849405-17347-1-git-send-email-will.deacon@arm.com>
In preparation for nested translation support, stick a pointer to the
iommu_domain in dev->archdata.iommu. This makes it much easier to grab
hold of the physical group configuration (e.g. cbndx) when dealing with
vSMMU accesses from a guest.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
drivers/iommu/arm-smmu.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index ef6623dbba9a..7ab3cc4ffbb3 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1206,6 +1206,11 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
return -ENXIO;
}
+ if (dev->archdata.iommu) {
+ dev_err(dev, "already attached to IOMMU domain\n");
+ return -EEXIST;
+ }
+
/*
* Sanity check the domain. We don't support domains across
* different SMMUs.
@@ -1232,7 +1237,10 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
if (!cfg)
return -ENODEV;
- return arm_smmu_domain_add_master(smmu_domain, cfg);
+ ret = arm_smmu_domain_add_master(smmu_domain, cfg);
+ if (!ret)
+ dev->archdata.iommu = domain;
+ return ret;
}
static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev)
@@ -1241,8 +1249,11 @@ static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev)
struct arm_smmu_master_cfg *cfg;
cfg = find_smmu_master_cfg(dev);
- if (cfg)
- arm_smmu_domain_remove_master(smmu_domain, cfg);
+ if (!cfg)
+ return;
+
+ dev->archdata.iommu = NULL;
+ arm_smmu_domain_remove_master(smmu_domain, cfg);
}
static bool arm_smmu_pte_is_contiguous_range(unsigned long addr,
--
2.1.0
next prev parent reply other threads:[~2014-09-04 16:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 16:49 [PATCH 0/7] iommu/arm-smmu: misc. driver updates targetting 3.18 Will Deacon
2014-09-04 16:49 ` [PATCH 1/7] iommu/arm-smmu: allow translation stage to be forced on the cmdline Will Deacon
2014-09-04 16:50 ` [PATCH 2/7] iommu/arm-smmu: add support for multi-master iommu groups Will Deacon
[not found] ` <1409849405-17347-3-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2014-09-15 15:22 ` Joerg Roedel
2014-09-15 15:22 ` Joerg Roedel
[not found] ` <20140915152257.GX28786-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-15 18:36 ` Will Deacon
2014-09-15 18:36 ` Will Deacon
2014-09-04 16:50 ` Will Deacon [this message]
2014-09-04 16:50 ` [PATCH 4/7] iommu/arm-smmu: use page shift instead of page size to avoid division Will Deacon
2014-09-04 16:50 ` [PATCH 5/7] iommu/arm-smmu: don't bother truncating the s1 output size to VA_BITS Will Deacon
2014-12-01 20:39 ` Andreas Schwab
[not found] ` <87mw77cdft.fsf-hBGjKatGTSWzQB+pC5nmwQ@public.gmane.org>
2014-12-02 9:26 ` Will Deacon
2014-12-02 9:26 ` Will Deacon
[not found] ` <1409849405-17347-6-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2014-12-01 20:39 ` Andreas Schwab
2014-09-04 16:50 ` [PATCH 6/7] iommu/arm-smmu: fix architecture version detection Will Deacon
2014-09-04 16:50 ` [PATCH 7/7] iommu/arm-smmu: support MMU-401 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=1409849405-17347-4-git-send-email-will.deacon@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.