qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
	kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org, drjones@redhat.com,
	marc.zyngier@arm.com, christoffer.dall@linaro.org
Cc: andre.przywara@arm.com, peter.maydell@linaro.org,
	alex.bennee@linaro.org, pbonzini@redhat.com
Subject: [Qemu-devel] [kvm-unit-tests RFC 03/15] arm/arm64: ITS skeleton
Date: Mon,  5 Dec 2016 22:46:34 +0100	[thread overview]
Message-ID: <1480974406-29345-4-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1480974406-29345-1-git-send-email-eric.auger@redhat.com>

At the moment we just detect the presence of ITS as part of the
GICv3 init routine and initialize its base address.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 arm/Makefile.common        |  1 +
 lib/arm/asm/gic-v3-its.h   | 22 ++++++++++++++++++++++
 lib/arm/asm/gic.h          |  1 +
 lib/arm/gic-v3-its.c       |  9 +++++++++
 lib/arm/gic.c              | 30 +++++++++++++++++++++++++-----
 lib/arm64/asm/gic-v3-its.h |  1 +
 6 files changed, 59 insertions(+), 5 deletions(-)
 create mode 100644 lib/arm/asm/gic-v3-its.h
 create mode 100644 lib/arm/gic-v3-its.c
 create mode 100644 lib/arm64/asm/gic-v3-its.h

diff --git a/arm/Makefile.common b/arm/Makefile.common
index 6c0898f..070f349 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -47,6 +47,7 @@ cflatobjs += lib/arm/bitops.o
 cflatobjs += lib/arm/psci.o
 cflatobjs += lib/arm/smp.o
 cflatobjs += lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
+cflatobjs += lib/arm/gic-v3-its.o
 
 libeabi = lib/arm/libeabi.a
 eabiobjs = lib/arm/eabi_compat.o
diff --git a/lib/arm/asm/gic-v3-its.h b/lib/arm/asm/gic-v3-its.h
new file mode 100644
index 0000000..2044565
--- /dev/null
+++ b/lib/arm/asm/gic-v3-its.h
@@ -0,0 +1,22 @@
+/*
+ * All ITS* defines are lifted from include/linux/irqchip/arm-gic-v3.h
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#ifndef _ASMARM_GIC_V3_ITS_H_
+#define _ASMARM_GIC_V3_ITS_H_
+
+#ifndef __ASSEMBLY__
+
+struct its_data {
+	void *base;
+};
+
+extern struct its_data its_data;
+
+#define gicv3_its_base()		(its_data.base)
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASMARM_GIC_V3_ITS_H_ */
diff --git a/lib/arm/asm/gic.h b/lib/arm/asm/gic.h
index ea5fde9..73d4502 100644
--- a/lib/arm/asm/gic.h
+++ b/lib/arm/asm/gic.h
@@ -30,6 +30,7 @@
 
 #include <asm/gic-v2.h>
 #include <asm/gic-v3.h>
+#include <asm/gic-v3-its.h>
 
 #ifndef __ASSEMBLY__
 #include <asm/cpumask.h>
diff --git a/lib/arm/gic-v3-its.c b/lib/arm/gic-v3-its.c
new file mode 100644
index 0000000..e382b80
--- /dev/null
+++ b/lib/arm/gic-v3-its.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Eric Auger <eric.auger@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <asm/gic.h>
+
+struct its_data its_data;
+
diff --git a/lib/arm/gic.c b/lib/arm/gic.c
index 957a146..e551abd 100644
--- a/lib/arm/gic.c
+++ b/lib/arm/gic.c
@@ -6,6 +6,7 @@
 #include <devicetree.h>
 #include <asm/gic.h>
 #include <asm/io.h>
+#include <asm/gic-v3-its.h>
 
 struct gic_common_ops *gic_common_ops;
 
@@ -17,12 +18,14 @@ struct gicv3_data gicv3_data;
  * Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
  */
 static bool
-gic_get_dt_bases(const char *compatible, void **base1, void **base2)
+gic_get_dt_bases(const char *compatible, void **base1, void **base2,
+		 void **base3)
 {
 	struct dt_pbus_reg reg;
-	struct dt_device gic;
+	struct dt_device gic, its;
 	struct dt_bus bus;
-	int node, ret;
+	int node, subnode, ret, len;
+	const void *fdt = dt_fdt();
 
 	dt_bus_init_defaults(&bus);
 	dt_device_init(&gic, &bus, NULL);
@@ -43,19 +46,36 @@ gic_get_dt_bases(const char *compatible, void **base1, void **base2)
 	assert(ret == 0);
 	*base2 = ioremap(reg.addr, reg.size);
 
+	if (base3 && !strcmp(compatible, "arm,gic-v3")) {
+		dt_for_each_subnode(node, subnode) {
+			const struct fdt_property *prop;
+
+			prop = fdt_get_property(fdt, subnode,
+						"compatible", &len);
+			if (!strcmp((char *)prop->data, "arm,gic-v3-its")) {
+				dt_device_bind_node(&its, subnode);
+				ret = dt_pbus_translate(&its, 0, &reg);
+				assert(ret == 0);
+				*base3 = ioremap(reg.addr, reg.size);
+				break;
+			}
+		}
+
+	}
+
 	return true;
 }
 
 int gicv2_init(void)
 {
 	return gic_get_dt_bases("arm,cortex-a15-gic",
-			&gicv2_data.dist_base, &gicv2_data.cpu_base);
+			&gicv2_data.dist_base, &gicv2_data.cpu_base, NULL);
 }
 
 int gicv3_init(void)
 {
 	return gic_get_dt_bases("arm,gic-v3", &gicv3_data.dist_base,
-			&gicv3_data.redist_base[0]);
+			&gicv3_data.redist_base[0], &its_data.base);
 }
 
 int gic_init(void)
diff --git a/lib/arm64/asm/gic-v3-its.h b/lib/arm64/asm/gic-v3-its.h
new file mode 100644
index 0000000..083cba4
--- /dev/null
+++ b/lib/arm64/asm/gic-v3-its.h
@@ -0,0 +1 @@
+#include "../../arm/asm/gic-v3-its.h"
-- 
2.5.5

  parent reply	other threads:[~2016-12-05 21:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 21:46 [Qemu-devel] [kvm-unit-tests RFC 00/15] arm/arm64: add ITS framework Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 01/15] libcflat: Add other size defines Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 02/15] arm/arm64: gicv3: Add some re-distributor defines Eric Auger
2016-12-05 21:46 ` Eric Auger [this message]
2016-12-06  9:23   ` [Qemu-devel] [kvm-unit-tests RFC 03/15] arm/arm64: ITS skeleton Andrew Jones
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 04/15] arm/arm64: ITS: BASER parsing and setup Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 05/15] arm/arm64: GICv3: add cpu count Eric Auger
2016-12-06  9:29   ` Andrew Jones
2016-12-06  9:32     ` Andre Przywara
2016-12-06 10:04       ` Auger Eric
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 06/15] arm/arm64: ITS: Set the LPI config and pending tables Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 07/15] arm/arm64: ITS: Init the command queue Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 08/15] arm/arm64: ITS: enable LPIs at re-distributor level Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 09/15] arm/arm64: ITS: Parse the typer register Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 10/15] arm/arm64: ITS: its_enable_defaults Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 11/15] arm/arm64: ITS: create device Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 12/15] arm/arm64: ITS: create collection Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 13/15] arm/arm64: ITS: commands Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 14/15] arm/arm64: gic: Generalize ipi_enable() Eric Auger
2016-12-05 21:46 ` [Qemu-devel] [kvm-unit-tests RFC 15/15] arm/arm64: ITS test Eric Auger
2016-12-06  9:48 ` [Qemu-devel] [kvm-unit-tests RFC 00/15] arm/arm64: add ITS framework Andrew Jones
2016-12-06 11:14   ` Andre Przywara
2016-12-06 11:21     ` Andrew Jones

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=1480974406-29345-4-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=andre.przywara@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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).