From: Wei Chen <Wei.Chen@arm.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.chen@arm.com, steve.capper@arm.com,
Kaly.Xin@arm.com, julien.grall@arm.com, nd@arm.com
Subject: [PATCH 4/7] xen/arm: SMMU: Detect types of device tree binding
Date: Fri, 30 Jun 2017 11:15:08 +0800 [thread overview]
Message-ID: <1498792511-25149-5-git-send-email-Wei.Chen@arm.com> (raw)
In-Reply-To: <1498792511-25149-1-git-send-email-Wei.Chen@arm.com>
The device tree provides two types of IOMMU bindings, one is legacy
another is generic. The legacy bindings will be depercated in favour
of the generic bindings. But in the transitional period, we have to
support both of them.
The codes to handle these two types of bindings are very differnet,
so we have to detect the binding types while doing SMMU probing.
This detect code is based on Linux ARM SMMUv2 driver:
https://github.com/torvalds/linux/blob/master/drivers/iommu/arm-smmu.c
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
---
xen/drivers/passthrough/arm/smmu.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 2efa52d..441c296 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -143,6 +143,8 @@ typedef enum irqreturn irqreturn_t;
#define dev_name(dev) dt_node_full_name(dev_to_dt(dev))
+#define pr_notice(fmt, ...) printk(XENLOG_INFO fmt, ## __VA_ARGS__)
+
/* Alias to Xen allocation helpers */
#define kfree xfree
#define kmalloc(size, flags) _xmalloc(size, sizeof(void *))
@@ -681,6 +683,8 @@ struct arm_smmu_option_prop {
const char *prop;
};
+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" },
{ 0, NULL},
@@ -2289,6 +2293,25 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
struct rb_node *node;
struct of_phandle_args masterspec;
int num_irqs, i, err;
+ bool legacy_binding;
+
+ /*
+ * Xen: Do the same check as Linux. Checking the SMMU device tree bindings
+ * are either using generic or legacy one.
+ *
+ * The "mmu-masters" property is only existed in legacy bindings.
+ */
+ legacy_binding = dt_find_property(dev->of_node, "mmu-masters", NULL);
+ if (legacy_binding && !using_generic_binding) {
+ if (!using_legacy_binding)
+ pr_notice("deprecated \"mmu-masters\" DT property in use\n");
+ using_legacy_binding = true;
+ } else if (!legacy_binding && !using_legacy_binding) {
+ using_generic_binding = true;
+ } else {
+ dev_err(dev, "not probing due to mismatched DT properties\n");
+ return -ENODEV;
+ }
smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
if (!smmu) {
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-30 3:15 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 3:15 [PATCH 0/7] Generic IOMMU bindings support for Xen platform devices Wei Chen
2017-06-30 3:15 ` [PATCH 1/7] xen/arm: SMMU: Implement the add_device callback in SMMU Wei Chen
2017-07-03 21:58 ` Stefano Stabellini
2017-07-04 5:37 ` Wei Chen
2017-07-05 17:57 ` Stefano Stabellini
2017-07-06 2:16 ` Wei Chen
2017-07-04 15:40 ` Julien Grall
2017-07-05 7:06 ` Wei Chen
2017-06-30 3:15 ` [PATCH 2/7] xen/arm: SMMU: Introduce a helper to add DT device to SMMU Wei Chen
2017-07-03 22:02 ` Stefano Stabellini
2017-07-04 5:45 ` Wei Chen
2017-07-05 18:02 ` Stefano Stabellini
2017-07-06 2:20 ` Wei Chen
2017-06-30 3:15 ` [PATCH 3/7] xen/arm: Prepare SMMU resources for protected devices Wei Chen
2017-07-03 22:05 ` Stefano Stabellini
2017-06-30 3:15 ` Wei Chen [this message]
2017-07-03 22:30 ` [PATCH 4/7] xen/arm: SMMU: Detect types of device tree binding Stefano Stabellini
2017-07-04 6:20 ` Wei Chen
2017-07-05 18:08 ` Stefano Stabellini
2017-07-06 2:25 ` Wei Chen
2017-06-30 3:15 ` [PATCH 5/7] xen/arm: SMMU: Keep registering legacy master in SMMU probe Wei Chen
2017-07-03 22:32 ` Stefano Stabellini
2017-06-30 3:15 ` [PATCH 6/7] xen/arm: SMMU: Support generic IOMMU bindings Wei Chen
2017-07-03 22:59 ` Stefano Stabellini
2017-07-04 6:27 ` Wei Chen
2017-07-04 7:26 ` Julien Grall
2017-07-05 7:04 ` Wei Chen
2017-07-05 13:07 ` Julien Grall
2017-07-06 2:11 ` Wei Chen
2017-07-05 18:15 ` Stefano Stabellini
2017-07-06 2:45 ` Wei Chen
2017-06-30 3:15 ` [PATCH 7/7] xen: Fix a typo in error message of iommu_do_dt_domctl Wei Chen
2017-07-03 21:53 ` Stefano Stabellini
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=1498792511-25149-5-git-send-email-Wei.Chen@arm.com \
--to=wei.chen@arm.com \
--cc=Kaly.Xin@arm.com \
--cc=julien.grall@arm.com \
--cc=nd@arm.com \
--cc=sstabellini@kernel.org \
--cc=steve.capper@arm.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).