Add ACPI support for arm64 on Xen
v2 cover Add ACPI support for arm64 on Xen
This patch series adds ACPI support for arm64.
Xen reads static tables described by ACPI standard (5.1) from uefi and configures timer, gic and uart. ACPI tables are modified to enable PSCI, HVC and xen specific information (grant table and event channel interrupts) and mapped into dom0 address space.
A skeleton device tree is created to pass efi table which contains memory layout (which cannot be passed using ACPI) and rsdp pointer to DOM0. DOM0 parses dynamic ACPI tables and configure other peripherals.
Patches 1-21 add ACPI support for xen/uefi interface Patches 22-41 add ACPI support for xen/Dom0 interface
Last patch "xen: arm64: Add ACPI support" enables the support for ACPI so that individual patches do not affect working xen code base.
Patches are tested on FVP base model and same binary is working for ACPI as well as device tree.(32 bit is not tested).
ACPI is now configurable via commandline option "acpi". To boot from ACPI this parameter should be set to "force".
Instructions for reproducing the setup and working code base can be found in the following repositories
wiki : https://wiki.linaro.org/LEG/Engineering/Xen_boot_on_FVP_ACPI_UEFI
linux : https://git.linaro.org/people/parth.dixit/xen-upstreaming/leg-kernel.git
xen : https://git.linaro.org/people/parth.dixit/xen-upstreaming/xen.git
uefi : https://git.linaro.org/people/parth.dixit/xen-acpi-support/linaro-edk2.git
Few workarounds have been made to get it working, these are as follows
1. In Xen interrupts are routed at the boot time with edge/trigger level set to 0 because this information is not available at the time of booting.
2. EFI runtime services are disaled in linux but proper solution has to come from linux side.
-------------------------------------------------------
Chanhelog v2
- ACPI configuration is now divided into two patches
- disabling numa is a seperate patch
- build pmstat is a seperate patch
- new patch for emulation io ports for arm in acpi
- refactoring of memory mapping code to arch specific mapping
- added new file boot.c and lib.c for acpi
- merged FADT parsing and modifcation into single patch
- divided smp functions into common and dt specific parts
- added smp support to ACPI
- divided gtdt functions to common and dt specific parts
- cleared el2 fields before passing to dom0
- refactored acpi parse entries
- refactored gic into common and dt specific parts
- added new framework for initializing acpi devices
- modified GICH and ICV values which are not relevant to Dom0
- renamed dt-uart.c to arm-uart.c
- refctored pl011 init
- added initrd support to dt stub
- new function to add efi node
- added new efi structures to common efi file
- marked ACPI memory in dom0 as reserved
- added new functions for estimating efi size
- added new function to dynamically map mmio's
- changed function names from map_acpi to prepare_acpi
- added new function for calculating crc32 by Igor Pavlov
- memory and rsdp is passed via efi table
- added new acpi parameter which needs to be set to enable acpi
- enabled efi
-------------------------------------------
Naresh Bhat (3):
arm/acpi: Build numa for x86 only
arm/acpi : Print GIC information when MADT is parsed
xen: arm64: Add ACPI support
Parth Dixit (38):
arm/acpi: Build pmstat for x86 only
arm/acpi : emulate io ports for arm
arm/acpi : add arm specific acpi header file acpi : add helper function for mapping memory arm/acpi : Add basic ACPI initialization
arm/acpi : Introduce ARM Boot Architecture Flags in FADT
arm/acpi : Parse FADT table and get PSCI flags arm/acpi : Add Generic Interrupt and Distributor struct arm/acpi : add GTDT support updated by ACPI 5.1
arm : move dt specific code in smp to seperate functions
arm/acpi : parse MADT to map logical cpu to MPIDR and get
cpu_possible_map
arm : acpi add helper function for setting interrupt type
arm : acpi parse GTDT to initialize timer
acpi : Introduce acpi_parse_entries
arm : refactor gic into generic and dt specific parts
arm: Introduce a generic way to use a device from acpi arm : acpi Add GIC specific ACPI boot support arm : create generic uart initialization function arm : acpi Initialize serial port from ACPI SPCR table arm : acpi create min DT stub for DOM0
arm : acpi create chosen node for DOM0
arm : acpi create efi node for DOM0
arm : acpi add status override table
arm : acpi add xen environment table
arm : add helper functions to map memory regions arm : acpi add efi structures to common efi header arm : acpi read acpi memory info from uefi
arm : acpi add placeholder for acpi load address arm : acpi estimate memory required for acpi/efi tables arm : acpi dynamically map mmio regions
arm : acpi prepare acpi tables for dom0
arm : acpi create and map acpi tables
arm : acpi add helper function to calculate crc32 arm : acpi pass rsdp and memory via efi table arm : acpi add acpi parameter to enable/disable acpi arm : acpi enable efi for acpi
arm : acpi configure interrupts dynamically arm : acpi route irq's at time of boot
config/arm64.mk | 1 + xen/arch/arm/Makefile | 1 + xen/arch/arm/acpi/Makefile | 2 + xen/arch/arm/acpi/boot.c | 279 +++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 31 +++ xen/arch/arm/arm64/smpboot.c | 12 +- xen/arch/arm/device.c | 19 ++ xen/arch/arm/domain_build.c | 551 ++++++++++++++++++++++++++++++++++++++++- xen/arch/arm/efi/efi-boot.h | 20 +- xen/arch/arm/gic-v2.c | 143 ++++++++++- xen/arch/arm/gic.c | 23 +- xen/arch/arm/irq.c | 17 ++ xen/arch/arm/kernel.c | 5 +- xen/arch/arm/kernel.h | 1 + xen/arch/arm/p2m.c | 26 ++ xen/arch/arm/psci.c | 16 ++ xen/arch/arm/setup.c | 43 +++- xen/arch/arm/smpboot.c | 33 ++- xen/arch/arm/time.c | 38 ++- xen/arch/arm/traps.c | 51 +++- xen/arch/arm/vgic.c | 18 ++ xen/arch/arm/xen.lds.S | 7 + xen/arch/x86/acpi/lib.c | 15 ++ xen/common/efi/boot.c | 2 + xen/common/efi/runtime.c | 2 +- xen/common/sysctl.c | 2 + xen/drivers/acpi/Makefile | 4 +- xen/drivers/acpi/osl.c | 11 +- xen/drivers/acpi/tables.c | 99 ++++++-- xen/drivers/char/Makefile | 2 +- xen/drivers/char/arm-uart.c | 136 ++++++++++ xen/drivers/char/dt-uart.c | 107 -------- xen/drivers/char/pl011.c | 96 +++++-- xen/include/acpi/actbl.h | 10 +- xen/include/acpi/actbl1.h | 62 ++++- xen/include/acpi/actbl2.h | 39 +++ xen/include/acpi/actbl3.h | 92 +++++-- xen/include/asm-arm/acpi.h | 95 +++++++ xen/include/asm-arm/arm64/io.h | 14 ++ xen/include/asm-arm/config.h | 5 + xen/include/asm-arm/device.h | 30 +++ xen/include/asm-arm/irq.h | 2 + xen/include/asm-arm/p2m.h | 10 + xen/include/asm-arm/setup.h | 1 + xen/include/xen/acpi.h | 10 + xen/include/xen/efi.h | 67 ++++- xen/include/xen/serial.h | 3 +- 47 files changed, 2038 insertions(+), 215 deletions(-) create mode 100644 xen/arch/arm/acpi/Makefile create mode 100644 xen/arch/arm/acpi/boot.c create mode 100644 xen/arch/arm/acpi/lib.c create mode 100644 xen/drivers/char/arm-uart.c delete mode 100644 xen/drivers/char/dt-uart.c create mode 100644 xen/include/asm-arm/acpi.h
Signature · 1 line
1.9.1
PATCH v2 1/41 arm/acpi: Build numa for x86 only
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen. Configure and build numa for x86 architecture only.
--- xen/drivers/acpi/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/acpi/Makefile +1 -1
@@ -3,7 +3,7 @@ subdir-y += utilities subdir-$(x86) += apei obj-bin-y += tables.init.o -obj-y += numa.o +obj-$(x86) += numa.o obj-y += osl.o obj-y += pmstat.o
Signature · 1 line
1.9.1
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Hi Parth,
Quoted 7 lines · Parth Dixit
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen. Configure and build numa for x86 architecture only.
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
In reply to Parth DixitQuoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen.
This doesn't represent a valid reason for the code to be disabled, the more that ARM will want to support NUMA sooner or later. A valid reason would be if you'd have to introduce _a lot_ of code on the ARM side in order to make this build - if that's the case, please say so in the description, as from an architectural pov the absence of the respective ACPI tables should be no issue at all.
Jan
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen.
This doesn't represent a valid reason for the code to be disabled, the more that ARM will want to support NUMA sooner or later. A valid reason would be if you'd have to introduce _a
lot_of code on the ARM side in order to make this build - if that's the case, please say so in the description, as from an architectural pov the absence of the respective ACPI tables should be no issue at all.
The acpi/numa.c is calling a lot of arch specific function implemented in (arch/x86/srat.c). The code in acpi/numa.c is very x86 related (such as x2apic).
I think disable the compilation is preferable for now given that there is no board for testing the changes.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 17:21, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen.
This doesn't represent a valid reason for the code to be disabled, the more that ARM will want to support NUMA sooner or later. A valid reason would be if you'd have to introduce _a
lot_of code on the ARM side in order to make this build - if that's the case, please say so in the description, as from an architectural pov the absence of the respective ACPI tables should be no issue at all.
Quoted 6 lines
The
acpi/numa.cis calling a lot of arch specific function implemented in (arch/x86/srat.c). The code inacpi/numa.cis very x86 related (such as x2apic).I think disable the compilation is preferable for now given that there is no board for testing the changes.
Or, as said in reply to patch 2, stubbing out the missing pieces in ARM code. As said there - let's not make more spaghetti of common code than it already is.
Jan
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 17:21, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
From: Naresh Bhat <[email protected]>
Numa is currently not supported for arm in xen.
This doesn't represent a valid reason for the code to be disabled, the more that ARM will want to support NUMA sooner or later. A valid reason would be if you'd have to introduce _a
lot_of code on the ARM side in order to make this build - if that's the case, please say so in the description, as from an architectural pov the absence of the respective ACPI tables should be no issue at all.The
acpi/numa.cis calling a lot of arch specific function implemented in (arch/x86/srat.c). The code inacpi/numa.cis very x86 related (such as x2apic).
Quoted 6 lines
Quoted 2 lines
I think disable the compilation is preferable for now given that there is no board for testing the changes.
Or, as said in reply to patch 2, stubbing out the missing pieces in ARM code. As said there - let's not make more spaghetti of common code than it already is.
That would mean we will build a code that won't be use on ARM until we decide to implement NUMA. This is because the main function acpi_numa_init is not called and should not be called until someone figure out this is valid on ARM.
What about defining a new define HAVE_NUMA?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 17:49, <[email protected]> wrote:
What about defining a new define
HAVE_NUMA?
That might be an acceptable compromise.
Jan
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
+shannon
Quoted 7 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 17:49, <[email protected]> wrote:
What about defining a new define
HAVE_NUMA?That might be an acceptable compromise.
Jan
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Hi,
Quoted 1 line · Parth Dixit
+shannon
I've just received ~50 mails "+shannon". Couldn't you have forward all the email privately rather replying to every single mail and cc shannon?
Archives also exists for Xen devel, and it's even possible to download them in order to answer to the mail....
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
Quoted 9 lines · Julien Grall
Hi,
Quoted 2 lines · Parth Dixit
+shannon
I've just received ~50 mails "+shannon". Couldn't you have forward all the email privately rather replying to every single mail and cc shannon?
I thought about FWD'ing initially but thought it would be better to CC , in case he has any questions he can continue with the same mail chain and others would also be aware that he is working on it otherwise it may lead to confusion.
Sorry for the trouble..
Quoted 7 lines
Archives also exists for Xen devel, and it's even possible to download them in order to answer to the mail....
Regards,
--
Julien Grall
Re: [PATCH v2 01/41] arm/acpi: Build numa for x86 only
In reply to Julien GrallQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 05.07.15 at 19:39, <[email protected]> wrote:
Quoted 1 line · Parth Dixit
+shannon
I've just received ~50 mails "+shannon". Couldn't you have forward all the email privately rather replying to every single mail and cc shannon?
Seconded. Considering this I simply deleted all the mails by you on that thread and on that day. Should there have been anything that I indeed needed to look at, please point this out specifically.
Jan
PATCH v2 2/41 arm/acpi: Build pmstat for x86 only
In reply to Parth DixitPmstat is currently not supported for arm in xen. Configure and build pmstat for x86 architecture only.
--- xen/common/sysctl.c | 2 ++ xen/drivers/acpi/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
xen/common/sysctl.c +2 -0
@@ -170,6 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) op->u.availheap.avail_bytes <<=PAGE_SHIFT ;break ; +#ifdef CONFIG_X86 #ifdef HAS_ACPI case XEN_SYSCTL_get_pmstat: ret =do_get_pm_info (&op->u.get_pmstat);
@@ -181,6 +182,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) copyback =1 ;break ;#endif +#endif case XEN_SYSCTL_page_offline_op: {
xen/drivers/acpi/Makefile +1 -1
@@ -5,7 +5,7 @@ subdir-$(x86) += apei obj-bin-y += tables.init.o obj-$(x86) += numa.o obj-y += osl.o -obj-y += pmstat.o +obj-$(x86) += pmstat.o obj-$(x86) += hwregs.o obj-$(x86) += reboot.o
Signature · 1 line
1.9.1
Re: [PATCH v2 02/41] arm/acpi: Build pmstat for x86 only
Hi Parth,
Quoted 14 lines · Parth Dixit
Pmstat is currently not supported for arm in xen. Configure and build pmstat for x86 architecture only.
Signed-off-by Parth Dixit <[email protected]>--- xen/common/sysctl.c | 2 ++ xen/drivers/acpi/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)xen/common/sysctl.c +0
-0
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 173
Quoted 4 lines
xen/common/sysctl.c +1
-0@@ -170,6 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) op->u.availheap.avail_bytes <<=PAGE_SHIFT ;break ; +#ifdef CONFIG_X86
pmstat seems to be tight with cpufreq, so I would use HAS_CPUFREQ.
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 174
Quoted 1 line
xen/common/sysctl.c +0
-0#ifdef HAS_ACPI
And combine the two #ifdef.
Quoted 15 lines
xen/common/sysctl.c +1
-0case XEN_SYSCTL_get_pmstat: ret =do_get_pm_info (&op->u.get_pmstat);@@ -181,6 +182,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) copyback =1 ;break ;#endif +#endif case XEN_SYSCTL_page_offline_op: {xen/drivers/acpi/Makefile +0
-0
xen/drivers/acpi/Makefile subdir-$(x86) += apei · line 8
Quoted 5 lines
xen/drivers/acpi/Makefile +1
-1@@ -5,7 +5,7 @@ subdir-$(x86) += apei obj-bin-y += tables.init.o obj-$(x86) += numa.o obj-y += osl.o -obj-y += pmstat.o +obj-$(x86) += pmstat.o
obj-$(HAS_CPUFREQ)
xen/drivers/acpi/Makefile subdir-$(x86) += apei
Quoted 4 lines
xen/drivers/acpi/Makefile +0
-0obj-$(x86) += hwregs.o obj-$(x86) += reboot.o
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 02/41] arm/acpi: Build pmstat for x86 only
In reply to Parth DixitQuoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Pmstat is currently not supported for arm in xen. Configure and build pmstat for x86 architecture only.
Same here as for patch 1. If the architecture can be expected to eventually support a feature, I'd generally prefer the architecture to get necessary stubs added over fiddling with common code.
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 176
Quoted 10 lines
xen/common/sysctl.c +1
-0@@ -170,6 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) op->u.availheap.avail_bytes <<=PAGE_SHIFT ;break ; +#ifdef CONFIG_X86 #ifdef HAS_ACPI case XEN_SYSCTL_get_pmstat: ret =do_get_pm_info (&op->u.get_pmstat);
Please fold the two #if-s into one, or even replace the HAS_ACPI one if this really needs to be done.
Jan
Re: [PATCH v2 02/41] arm/acpi: Build pmstat for x86 only
Quoted 22 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Pmstat is currently not supported for arm in xen. Configure and build pmstat for x86 architecture only.
Same here as for patch 1. If the architecture can be expected to eventually support a feature, I'd generally prefer the architecture to get necessary stubs added over fiddling with common code.
ok, will add stubs in next patchset.
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t)
Quoted 3 lines
xen/common/sysctl.c +0
-0@@ -170,6 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t)
u_sysctl)xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 176
Quoted 7 lines
xen/common/sysctl.c +1
-0op->u.availheap.avail_bytes <<=PAGE_SHIFT ;break ; +#ifdef CONFIG_X86 #ifdef HAS_ACPI case XEN_SYSCTL_get_pmstat: ret =do_get_pm_info (&op->u.get_pmstat);
Quoted 6 lines
Please fold the two #if-s into one, or even replace the
HAS_ACPIone if this really needs to be done.Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 02/41] arm/acpi: Build pmstat for x86 only
+shannon
Quoted 32 lines · Parth Dixit
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines · On 17.05.15 at 22:03, <[email protected]> wrote:
Pmstat is currently not supported for arm in xen. Configure and build pmstat for x86 architecture only.
Same here as for patch 1. If the architecture can be expected to eventually support a feature, I'd generally prefer the architecture to get necessary stubs added over fiddling with common code.
ok, will add stubs in next patchset.
Quoted 18 lines
Quoted 11 lines
xen/common/sysctl.c +1
-0@@ -170,6 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) op->u.availheap.avail_bytes <<= PAGE_SHIFT;break ; +#ifdef CONFIG_X86 #ifdef HAS_ACPI case XEN_SYSCTL_get_pmstat:Quoted 1 line
ret = do_get_pm_info(&op->u.get_pmstat);Please fold the two #if-s into one, or even replace the
HAS_ACPIone if this really needs to be done.Jan
PATCH v2 3/41 arm/acpi : emulate io ports for arm
In reply to Parth Dixitadd macros to emulate x86 style ports for arm.
This avoids modification in common code for acpi.
--- xen/include/asm-arm/arm64/io.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
xen/include/asm-arm/arm64/io.h +14 -0
@@ -20,6 +20,7 @@#ifndef _ARM_ARM64_IO_H#define _ARM_ARM64_IO_H +#include <asm/system.h> #include <asm/byteorder.h> /*
@@ -109,4 +110,17 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)#define writel (v,c) ({ __iowmb(); writel_relaxed((v),(c)); })#define writeq (v,c) ({ __iowmb(); writeq_relaxed((v),(c)); }) +/* +* Emulate x86 io ports for arm. +*/ +#define __armio (addr) ( (void __iomem *)addr ) + +#define inb (c) ( readb( __armio(c) ) ) +#define inw (c) ( readw( __armio(c) ) ) +#define inl (c) ( readl( __armio(c) ) ) + +#define outb (v, c) ( writeb(v, __armio(c) ) ) +#define outw (v, c) ( writew(v, __armio(c) ) ) +#define outl (v, c) ( writel(v, __armio(c) ) ) +#endif /* _ARM_ARM64_IO_H */
Signature · 1 line
1.9.1
Re: [PATCH v2 03/41] arm/acpi : emulate io ports for arm
Hi Parth,
Quoted 2 lines · Parth Dixit
add macros to emulate x86 style ports for arm.
This avoids modification in common code for acpi.
This patch looks wrong to me. On ARM ioport access is done using the PCI address space.
If it's not easy to have a correct implementation, I still prefer modification in common ACPI code.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 03/41] arm/acpi : emulate io ports for arm
+shannon
Quoted 16 lines · Julien Grall
Hi Parth,
Quoted 2 lines · Parth Dixit
add macros to emulate x86 style ports for arm.
This avoids modification in common code for acpi.This patch looks wrong to me. On ARM ioport access is done using the PCI address space.
If it's not easy to have a correct implementation, I still prefer modification in common ACPI code.
Regards,
--
Julien Grall
PATCH v2 4/41 arm/acpi : add arm specific acpi header file
In reply to Parth Dixitadd architecture specific definitions and calls
required for acpi in new header file
--- xen/include/asm-arm/acpi.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 xen/include/asm-arm/acpi.h
xen/include/asm-arm/acpi.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2014, Naresh Bhat <[email protected]> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +#ifndef _ASM_ARM64_ACPI_H +#define _ASM_ARM64_ACPI_H + +#include <xen/init.h> + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long + +extern bool_t acpi_disabled; +/* Basic configuration for ACPI */ +static inline void disable_acpi (void ) +{ + acpi_disabled =1 ; +} + +#endif /*_ASM_ARM_ACPI_H*/
Signature · 1 line
1.9.1
Re: [PATCH v2 04/41] arm/acpi : add arm specific acpi header file
Hi Parth,
xen/include/asm-arm/acpi.h line 24
Quoted 2 lines · Parth Dixit
xen/include/asm-arm/acpi.h new file +2
-0+#ifndef _ASM_ARM64_ACPI_H +#define _ASM_ARM64_ACPI_H
s/_ASM_ARM64_ACPI_H/_ASM_ARM_ACPI_H/
xen/include/asm-arm/acpi.h line 36
Quoted 12 lines
xen/include/asm-arm/acpi.h new file +12
-0+ +#include <xen/init.h> + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long + +extern bool_t acpi_disabled; +/* Basic configuration for ACPI */ +static inline void disable_acpi (void ) +{ + acpi_disabled =1 ; +}
It makes a little sense to add the prototype of acpi_disabled without effectively declaring it.
Also, the code is very similar to the x86. It would make sense to factorize it (disable_acpi, acpi parameters...) in a common place.
Quoted 2 lines
+#endif /*_ASM_ARM_ACPI_H*/
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 04/41] arm/acpi : add arm specific acpi header file
Quoted 29 lines · Julien Grall
Hi Parth,
xen/include/asm-arm/acpi.h line 24
Quoted 2 lines · Parth Dixit
xen/include/asm-arm/acpi.h new file +2
-0+#ifndef _ASM_ARM64_ACPI_H +#define _ASM_ARM64_ACPI_Hs/_ASM_ARM64_ACPI_H/_ASM_ARM_ACPI_H/
xen/include/asm-arm/acpi.h line 36
Quoted 12 lines
xen/include/asm-arm/acpi.h new file +12
-0+ +#include <xen/init.h> + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long + +extern bool_t acpi_disabled; +/* Basic configuration for ACPI */ +static inline void disable_acpi (void ) +{ + acpi_disabled =1 ; +}It makes a little sense to add the prototype of
acpi_disabledwithout effectively declaring it.Also, the code is very similar to the x86. It would make sense to factorize it (
disable_acpi, acpi parameters...) in a common place.sure, i will take care in next patch set.
Quoted 8 lines
Quoted 2 lines
+#endif /*_ASM_ARM_ACPI_H*/
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 04/41] arm/acpi : add arm specific acpi header file
+shannon
Quoted 42 lines · Parth Dixit
Quoted 25 lines · Julien Grall
Hi Parth,
xen/include/asm-arm/acpi.h line 24
Quoted 2 lines · Parth Dixit
xen/include/asm-arm/acpi.h new file +2
-0+#ifndef _ASM_ARM64_ACPI_H +#define _ASM_ARM64_ACPI_Hs/_ASM_ARM64_ACPI_H/_ASM_ARM_ACPI_H/
xen/include/asm-arm/acpi.h line 36
Quoted 12 lines
xen/include/asm-arm/acpi.h new file +12
-0+ +#include <xen/init.h> + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long + +extern bool_t acpi_disabled; +/* Basic configuration for ACPI */ +static inline void disable_acpi (void ) +{ + acpi_disabled =1 ; +}It makes a little sense to add the prototype of
acpi_disabledwithout effectively declaring it.Quoted 3 lines
Also, the code is very similar to the x86. It would make sense to factorize it (
disable_acpi, acpi parameters...) in a common place.sure, i will take care in next patch set.
Quoted 8 lines
Quoted 3 lines
+#endif /*_ASM_ARM_ACPI_H*/
Regards,
--
Julien Grall
PATCH v2 5/41 acpi : add helper function for mapping memory
In reply to Parth Dixitcommon acpi code for memory mapping is specific to x86. Add a new helper function for mapping memory based on architecture.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/acpi/Makefile | 1 + xen/arch/arm/acpi/lib.c | 8 ++++++++ xen/arch/x86/acpi/lib.c | 15 +++++++++++++++ xen/drivers/acpi/osl.c | 11 +---------- xen/include/xen/acpi.h | 2 ++ 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 xen/arch/arm/acpi/Makefile create mode 100644 xen/arch/arm/acpi/lib.c
xen/arch/arm/Makefile +1 -0
@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32 subdir-$(arm64) += arm64 subdir-y += platforms subdir-$(arm64) += efi +subdir-$(HAS_ACPI) += acpi obj-$(EARLY_PRINTK) += early_printk.o obj-y += cpu.o
xen/arch/arm/acpi/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += lib.o
xen/arch/arm/acpi/lib.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <xen/acpi.h> +#include <asm/mm.h> + +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +return __va (phys); +}
xen/arch/x86/acpi/lib.c +15 -0
@@ -34,6 +34,21 @@ u8 __read_mostly acpi_disable_value;u32 __read_mostly x86_acpiid_to_apicid[MAX_MADT_ENTRIES ] = {[0 ...MAX_MADT_ENTRIES -1 ] =BAD_APICID }; +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +if (system_state >= SYS_STATE_active) { +unsigned long pfn =PFN_DOWN (phys); +unsigned int offs = phys & (PAGE_SIZE -1 ); + +/* The low first Mb is always mapped. */ +if ( !((phys + size -1 ) >>20 ) ) +return __va (phys); +return __vmap (&pfn,PFN_UP (offs + size),1 ,1 ,PAGE_HYPERVISOR_NOCACHE ) + offs; + } +return __acpi_map_table (phys, size); +} +/* * Important Safety Note: The fixed ACPI page numbers are *subtracted* * from the fixed base. That's why we start at FIX_ACPI_END and
xen/drivers/acpi/osl.c +1 -10
@@ -87,16 +87,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)void __iomem *acpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -if (system_state >= SYS_STATE_active) { -unsigned long pfn =PFN_DOWN (phys); -unsigned int offs = phys & (PAGE_SIZE -1 ); - -/* The low first Mb is always mapped. */ -if ( !((phys + size -1 ) >>20 ) ) -return __va (phys); -return __vmap (&pfn,PFN_UP (offs + size),1 ,1 ,PAGE_HYPERVISOR_NOCACHE ) + offs; - } -return __acpi_map_table (phys, size); +return acpi_os_map_iomem (phys, size); }void acpi_os_unmap_memory (void __iomem * virt,acpi_size size)
xen/include/xen/acpi.h +2 -0
@@ -55,6 +55,8 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);typedef int (*acpi_table_entry_handler ) (struct acpi_subtable_header *header,const unsigned long end); +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size);unsigned int acpi_get_processor_id (unsigned int cpu);char *__acpi_map_table (paddr_t phys_addr,unsigned long size);int acpi_boot_init (void );
Signature · 1 line
1.9.1
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Hi Parth,
Quoted 25 lines · Parth Dixit
xen/arch/arm/Makefile +1
-0@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32 subdir-$(arm64) += arm64 subdir-y += platforms subdir-$(arm64) += efi +subdir-$(HAS_ACPI) += acpi obj-$(EARLY_PRINTK) += early_printk.o obj-y += cpu.oxen/arch/arm/acpi/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-y += lib.oxen/arch/arm/acpi/lib.c new file +0
-0
xen/arch/arm/acpi/lib.c line 8
Quoted 8 lines
xen/arch/arm/acpi/lib.c new file +8
-0@@ -0,0 +1,8 @@ +#include <xen/acpi.h> +#include <asm/mm.h> + +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +return __va (phys); +}
I would have prefer two distinct patch: one for the refactoring of acpi_os_map_memory and the other for implementing the ARM part explaining why only using __va.
__va should only be used when the memory is direct-mapped to Xen (i.e accessible directly). On ARM64, this only the case for the RAM. Can you confirm that ACPI will always reside to the RAM?
I already asked the same question on the previous version but got no answer from you...
Quoted 12 lines
/*
* Important Safety Note: The fixed ACPI page numbers are *subtracted*
* from the fixed base. That's why we start atFIX_ACPI_ENDandxen/drivers/acpi/osl.c +0
-1@@ -87,16 +87,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)void __iomem *acpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -if (system_state >= SYS_STATE_active) {
xen/drivers/acpi/osl.c acpi_physical_address __init acpi_os_get_root_pointer(void) · line 90
Quoted 10 lines
xen/drivers/acpi/osl.c +1
-9-unsigned long pfn =PFN_DOWN (phys); -unsigned int offs = phys & (PAGE_SIZE -1 ); - -/* The low first Mb is always mapped. */ -if ( !((phys + size -1 ) >>20 ) ) -return __va (phys); -return __vmap (&pfn,PFN_UP (offs + size),1 ,1 ,PAGE_HYPERVISOR_NOCACHE ) + offs; - } -return __acpi_map_table (phys, size); +return acpi_os_map_iomem (phys, size);
The naming is wrong. It's really hard to differentiate acpi_os_map_memory from acpi_os_map_iomem. I would rename to something more meaningful such as arch_acpi_os_map_memory.
Although, given that acpi_os_map_memory only call acpi_os_map_iomem. I would move acpi_os_map_memory per-architecture. FWIW, it's what Linux does.
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 18.05.15 at 15:26, <[email protected]> wrote:
xen/arch/arm/acpi/lib.c line 8
Quoted 11 lines · Parth Dixit
xen/arch/arm/acpi/lib.c new file +8
-0@@ -0,0 +1,8 @@ +#include <xen/acpi.h> +#include <asm/mm.h> + +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +return __va (phys); +}I would have prefer two distinct patch: one for the refactoring of
acpi_os_map_memoryand the other for implementing the ARM part explaining why only using__va.
+1
Quoted 2 lines
Although, given that
acpi_os_map_memoryonly callacpi_os_map_iomem. I would moveacpi_os_map_memoryper-architecture. FWIW, it's what Linux does.
In which Linux version did you see this to be the case? Certainly not 4.1-rc or anything recent... What I'm trying to get at is that we should please be very careful with deviating from the ACPI CA derived naming as well as with what is to live in os.c.
Jan
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Quoted 20 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 18.05.15 at 15:26, <[email protected]> wrote:
xen/arch/arm/acpi/lib.c line 8
Quoted 11 lines · Parth Dixit
xen/arch/arm/acpi/lib.c new file +8
-0@@ -0,0 +1,8 @@ +#include <xen/acpi.h> +#include <asm/mm.h> + +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +return __va (phys); +}I would have prefer two distinct patch: one for the refactoring of
acpi_os_map_memoryand the other for implementing the ARM part explaining why only using__va.+1
Quoted 7 lines
Quoted 2 lines
Although, given that
acpi_os_map_memoryonly callacpi_os_map_iomem. I would moveacpi_os_map_memoryper-architecture. FWIW, it's what Linux does.In which Linux version did you see this to be the case? Certainly not 4.1-rc or anything recent... What I'm trying to get at is that we should please be very careful with deviating from the ACPI CA derived naming as well as with what is to live in
os.c.
Sorry, I had in mind an older version of the ACPI series for Linux. I forgot to check what was really done.
Although, acpi_os_map_iomem is also part of the ACPI CA. Would a function arch_acpi_os_map_memory suit for you?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 18.05.15 at 16:20, <[email protected]> wrote:
Although,
acpi_os_map_iomemis also part of the ACPI CA. Would a functionarch_acpi_os_map_memorysuit for you?
Only if we - other than Linux - really need this to be arch dependent.
Jan
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 18.05.15 at 16:20, <[email protected]> wrote:
Although,
acpi_os_map_iomemis also part of the ACPI CA. Would a functionarch_acpi_os_map_memorysuit for you?Only if we - other than Linux - really need this to be arch dependent.
The current implementation of acpi_os_map_iomem is not valid on ARM:
the first MB is not always mapped and we already have mapped the table if it lives in RAM.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
In reply to Julien GrallQuoted 41 lines · Julien Grall
Hi Parth,
Quoted 25 lines · Parth Dixit
xen/arch/arm/Makefile +1
-0@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32 subdir-$(arm64) += arm64 subdir-y += platforms subdir-$(arm64) += efi +subdir-$(HAS_ACPI) += acpi obj-$(EARLY_PRINTK) += early_printk.o obj-y += cpu.oxen/arch/arm/acpi/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-y += lib.oxen/arch/arm/acpi/lib.c new file +0
-0xen/arch/arm/acpi/lib.c line 8
Quoted 8 lines
xen/arch/arm/acpi/lib.c new file +8
-0@@ -0,0 +1,8 @@ +#include <xen/acpi.h> +#include <asm/mm.h> + +void __iomem * +acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) +{ +return __va (phys); +}I would have prefer two distinct patch: one for the refactoring of
acpi_os_map_memoryand the other for implementing the ARM part explaining why only using__va.
Quoted 8 lines
__vashould only be used when the memory is direct-mapped to Xen (i.e accessible directly). On ARM64, this only the case for the RAM. Can you confirm that ACPI will always reside to the RAM?I already asked the same question on the previous version but got no answer from you...
I did not found any document which says it will always reside in RAM or
otherwise..
Quoted 29 lines
xen/drivers/acpi/osl.c acpi_physical_address __init
Quoted 8 lines
/*
* Important Safety Note: The fixed ACPI page numbers are *subtracted*
* from the fixed base. That's why we start atFIX_ACPI_ENDandxen/drivers/acpi/osl.c +0
-0@@ -87,16 +87,7 @@ acpi_physical_address __init
acpi_os_get_root_pointer(void)xen/drivers/acpi/osl.c acpi_physical_address __init acpi_os_get_root_pointer(void)
Quoted 11 lines
xen/drivers/acpi/osl.c +0
-8void __iomem *acpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -if (system_state >= SYS_STATE_active) { -unsigned long pfn =PFN_DOWN (phys); -unsigned int offs = phys & (PAGE_SIZE -1 ); - -/* The low first Mb is always mapped. */ -if ( !((phys + size -1 ) >>20 ) ) -return __va (phys); - return __vmap(&pfn, PFN_UP(offs + size), 1, 1,
PAGE_HYPERVISOR_NOCACHE) + offs;xen/drivers/acpi/osl.c acpi_physical_address __init acpi_os_get_root_pointer(void) · line 90
Quoted 3 lines
xen/drivers/acpi/osl.c +1
-2- } -return __acpi_map_table (phys, size); +return acpi_os_map_iomem (phys, size);The naming is wrong. It's really hard to differentiate
acpi_os_map_memoryfromacpi_os_map_iomem. I would rename to something more meaningful such asarch_acpi_os_map_memory.
Quoted 6 lines
Although, given that
acpi_os_map_memoryonly callacpi_os_map_iomem. I would moveacpi_os_map_memoryper-architecture. FWIW, it's what Linux does.--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Hi Parth,
Quoted 46 lines · Parth Dixit
On 17/05/15 21:03, Parth Dixit wrote:
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 935999e..096e9ef 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
> subdir-$(arm64) += arm64
> subdir-y += platforms
> subdir-$(arm64) += efi
> +subdir-$(HAS_ACPI) += acpi
>
> obj-$(EARLY_PRINTK) += early_printk.o
> obj-y += cpu.o
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> new file mode 100644
> index 0000000..b5be22d
> --- /dev/null
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -0,0 +1 @@
> +obj-y += lib.o
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> new file mode 100644
> index 0000000..650beed
> --- /dev/null
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -0,0 +1,8 @@
> +#include <xen/acpi.h>
> +#include <asm/mm.h>
> +
> +void __iomem *
> +acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
> +{
> + return __va(phys);
> +}
I would have prefer two distinct patch: one for the refactoring of
acpi_os_map_memory and the other for implementing the ARM part
explaining why only using __va.
__va should only be used when the memory is direct-mapped to Xen (i.e
accessible directly). On ARM64, this only the case for the RAM. Can you
confirm that ACPI will always reside to the RAM?
I already asked the same question on the previous version but got no
answer from you...Quoted 2 lines
I did not found any document which says it will always reside in RAM or otherwise..
If so, you have use vmap or ioremap_cache as suggested by Jan.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
+shannon
Quoted 62 lines · Julien Grall
Hi Parth,
Quoted 43 lines · Parth Dixit
On 17/05/15 21:03, Parth Dixit wrote: > diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile > index 935999e..096e9ef 100644 > --- a/xen/arch/arm/Makefile > +++ b/xen/arch/arm/Makefile > @@ -2,6 +2,7 @@ subdir-$(arm32) += arm32 > subdir-$(arm64) += arm64 > subdir-y += platforms > subdir-$(arm64) += efi > +subdir-$(HAS_ACPI) += acpi > > obj-$(EARLY_PRINTK) += early_printk.o > obj-y += cpu.o > diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile > new file mode 100644 > index 0000000..b5be22d > --- /dev/null > +++ b/xen/arch/arm/acpi/Makefile > @@ -0,0 +1 @@ > +obj-y += lib.o > diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c > new file mode 100644 > index 0000000..650beed > --- /dev/null > +++ b/xen/arch/arm/acpi/lib.c > @@ -0,0 +1,8 @@ > +#include <xen/acpi.h> > +#include <asm/mm.h> > + > +void __iomem * > +acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) > +{ > + return __va(phys); > +} I would have prefer two distinct patch: one for the refactoring of acpi_os_map_memory and the other for implementing the ARM part explaining why only using __va. __va should only be used when the memory is direct-mapped to Xen (i.e accessible directly). On ARM64, this only the case for the RAM. CanQuoted 8 lines
you
confirm that ACPI will always reside to the RAM?I already asked the same question on the previous version but got no answer from you...
I did not found any document which says it will always reside in RAM or otherwise..
If so, you have use vmap or
ioremap_cacheas suggested by Jan.Regards,
--
Julien Grall
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
In reply to Parth DixitQuoted 9 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/drivers/acpi/osl.c +0
-2@@ -87,16 +87,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)void __iomem *acpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -if (system_state >= SYS_STATE_active) { -unsigned long pfn =PFN_DOWN (phys);
xen/drivers/acpi/osl.c acpi_physical_address __init acpi_os_get_root_pointer(void) · line 91
Quoted 10 lines
xen/drivers/acpi/osl.c +1
-8-unsigned int offs = phys & (PAGE_SIZE -1 ); - -/* The low first Mb is always mapped. */ -if ( !((phys + size -1 ) >>20 ) ) -return __va (phys); -return __vmap (&pfn,PFN_UP (offs + size),1 ,1 ,PAGE_HYPERVISOR_NOCACHE ) + offs; - } -return __acpi_map_table (phys, size); +return acpi_os_map_iomem (phys, size); }
I think ioremap() (or maybe ioremap_cache()) should be used here, and tweaked suitably on x86 if need be.
Jan
Re: [PATCH v2 05/41] acpi : add helper function for mapping memory
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/drivers/acpi/osl.c +0
-7@@ -87,16 +87,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)void __iomem *acpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -if (system_state >= SYS_STATE_active) { -unsigned long pfn =PFN_DOWN (phys); -unsigned int offs = phys & (PAGE_SIZE -1 ); - -/* The low first Mb is always mapped. */ -if ( !((phys + size -1 ) >>20 ) ) -return __va (phys);
Quoted 8 lines
xen/drivers/acpi/osl.c acpi_physical_address __init acpi_os_get_root_pointer(void) · line 91
Quoted 5 lines
xen/drivers/acpi/osl.c +1
-3-return __vmap (&pfn,PFN_UP (offs + size),1 ,1 ,PAGE_HYPERVISOR_NOCACHE ) + offs; - } -return __acpi_map_table (phys, size); +return acpi_os_map_iomem (phys, size); }I think
ioremap()(or maybeioremap_cache()) should be used here, and tweaked suitably on x86 if need be.
ioremap_cache is most suitable for ARM.
ioremap (i.e ioremap_nocache) is mapping the region with device attribute. Any unaligned access will result to a data abort.
Regards,
Signature · 1 line
Julien Grall
PATCH v2 6/41 arm/acpi : Add basic ACPI initialization
In reply to Parth Dixitacpi_boot_table_init() will be called in start_xen to get the RSDP and all the table pointers. with this patch, we can get ACPI boot-time tables from firmware on ARM64.
--- xen/arch/arm/acpi/Makefile | 1 + xen/arch/arm/acpi/boot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 13 +++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/acpi/boot.c
xen/arch/arm/acpi/Makefile +1 -0
@@ -1 +1,2 @@ obj-y += lib.o +obj-y += boot.o
xen/arch/arm/acpi/boot.c new file +56 -0
56 lines not on this page · raw message
xen/arch/arm/setup.c +11 -2
@@ -36,6 +36,7 @@#include <xen/pfn.h> #include <xen/vmap.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> #include <asm/page.h> #include <asm/current.h> #include <asm/setup.h>
@@ -45,10 +46,12 @@#include <asm/procinfo.h> #include <asm/setup.h> #include <xsm/xsm.h> +#include <asm/acpi.h> struct bootinfo __initdata bootinfo;struct cpuinfo_arm __read_mostly boot_cpu_data; +bool_t acpi_disabled;#ifdef CONFIG_ARM_32 static unsigned long opt_xenheap_megabytes__initdata ;
@@ -610,7 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)init_xenheap_pages (pfn_to_paddr (xenheap_mfn_start), pfn_to_paddr(boot_mfn_start)); - end_boot_allocator(); }#else /* CONFIG_ARM_64 */ static void __init setup_mm (unsigned long dtb_paddr,size_t dtb_size)
@@ -680,7 +682,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)setup_frametable_mappings (ram_start, ram_end); max_page = PFN_DOWN(ram_end); - end_boot_allocator(); }#endif
@@ -751,6 +752,14 @@ void __init start_xen(unsigned long boot_phys_offset,setup_mm (fdt_paddr, fdt_size); +/* +* Parse the ACPI tables for possible boot-time configuration +*/ +if ( !acpi_disabled ) +acpi_boot_table_init (); + +end_boot_allocator (); +vm_init ();dt_unflatten_host_device_tree ();
Signature · 1 line
1.9.1
Re: [PATCH v2 06/41] arm/acpi : Add basic ACPI initialization
Hi Parth,
Quoted 26 lines · Parth Dixit
acpi_boot_table_init()will be called instart_xento get the RSDP and all the table pointers. with this patch, we can get ACPI boot-time tables from firmware on ARM64.Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/Makefile | 1 + xen/arch/arm/acpi/boot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 13 +++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/acpi/boot.cxen/arch/arm/acpi/Makefile +1
-0@@ -1 +1,2 @@ obj-y += lib.o +obj-y += boot.oxen/arch/arm/acpi/boot.c new file +0
-0
xen/arch/arm/acpi/boot.c line 2
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0@@ -0,0 +1,56 @@ +/* +* ARM64 Specific Low-Level ACPI Boot Support
This code is not ARM64 specific:
s/ARM64/ARM/
xen/arch/arm/acpi/boot.c line 4
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* Copyright (C) 2014, Naresh Bhat <[email protected]>
The code within this file is a copy of arch/x86/acpi/boot.c.
Please retain the copyright and add yours if necessary.
Quoted 22 lines
xen/arch/arm/acpi/boot.c new file +22
-0+* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +#include <xen/init.h> +#include <xen/acpi.h>
xen/arch/arm/acpi/boot.c line 36
Quoted 10 lines
xen/arch/arm/acpi/boot.c new file +10
-0+ +#include <asm/acpi.h> + +/* +* acpi_boot_table_init() called from setup_arch(), always. +* 1. find RSDP and get its address, and then find XSDT +* 2. extract all tables and checksums them all +* +* We can parse ACPI boot-time tables such as FADT, MADT after +* this function is called.
It's worth to expand the commit message as done in the x86 version to explain the return value.
xen/arch/arm/acpi/boot.c line 47
Quoted 11 lines
xen/arch/arm/acpi/boot.c new file +11
-0+*/ +int __init acpi_boot_table_init (void ) +{ +int error; + +/* If acpi_disabled, bail out */ +if ( acpi_disabled ) +return 1 ; + +/* Initialize the ACPI boot-time table parser. */ + error =acpi_table_init ();
I didn't find a better place for this comment. Though it's related to the ACPI initialization...
You need to change_acpi_os_get_root_pointer, the current behavior is to fallback on the legacy method (i.e scanning the first MB of memory) when efi_enabled 0.
Quoted 43 lines
xen/arch/arm/acpi/boot.c new file +9
-0+if ( error ) + { +disable_acpi (); +return error; + } + +return 0 ; +} +xen/arch/arm/setup.c +3
-1@@ -36,6 +36,7 @@#include <xen/pfn.h> #include <xen/vmap.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> #include <asm/page.h> #include <asm/current.h> #include <asm/setup.h> @@ -45,10 +46,12 @@#include <asm/procinfo.h> #include <asm/setup.h> #include <xsm/xsm.h> +#include <asm/acpi.h> struct bootinfo __initdata bootinfo;struct cpuinfo_arm __read_mostly boot_cpu_data; +bool_t acpi_disabled;#ifdef CONFIG_ARM_32 static unsigned long opt_xenheap_megabytes__initdata ;@@ -610,7 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)init_xenheap_pages (pfn_to_paddr (xenheap_mfn_start), pfn_to_paddr(boot_mfn_start)); - end_boot_allocator(); }#else /* CONFIG_ARM_64 */ static void __init setup_mm (unsigned long dtb_paddr,size_t dtb_size)
xen/arch/arm/setup.c static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) · line 683
Quoted 4 lines
xen/arch/arm/setup.c +0
-1@@ -680,7 +682,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)setup_frametable_mappings (ram_start, ram_end); max_page =PFN_DOWN (ram_end); -end_boot_allocator ();
You need to explain in the commit message why this is necessary (see [1]).
Anybody who didn't follow/remember the thread will think this is wrong...
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 757
Quoted 10 lines
xen/arch/arm/setup.c +3
-0}#endif @@ -751,6 +752,14 @@ void __init start_xen(unsigned long boot_phys_offset,setup_mm (fdt_paddr, fdt_size); +/* +* Parse the ACPI tables for possible boot-time configuration +*/
Coding style.
/*
* Foo
* bar
*/
Although the comment is fitting in a single line so /* foo bar */
Bu
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 758
Quoted 1 line
xen/arch/arm/setup.c +1
-0+if ( !acpi_disabled )
The if is not necessary.
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 765
Quoted 8 lines
xen/arch/arm/setup.c +4
-0+acpi_boot_table_init (); + +end_boot_allocator (); +vm_init ();dt_unflatten_host_device_tree ();
Regards,
[1]
http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg01152.html
Signature · 1 line
Julien Grall
Re: [PATCH v2 06/41] arm/acpi : Add basic ACPI initialization
Quoted 199 lines · Julien Grall
Hi Parth,
Quoted 9 lines · Parth Dixit
acpi_boot_table_init()will be called instart_xento get the RSDP and all the table pointers. with this patch, we can get ACPI boot-time tables from firmware on ARM64.Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/Makefile | 1 + xen/arch/arm/acpi/boot.c | 56++++++++++++++++++++++++++++++++++++++++++++++
Quoted 17 lines
xen/arch/arm/setup.c | 13 +++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/acpi/boot.cxen/arch/arm/acpi/Makefile +1
-0@@ -1 +1,2 @@ obj-y += lib.o +obj-y += boot.oxen/arch/arm/acpi/boot.c new file +0
-0xen/arch/arm/acpi/boot.c line 2
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0@@ -0,0 +1,56 @@ +/* +* ARM64 Specific Low-Level ACPI Boot Support This code is not ARM64 specific:
s/ARM64/ARM/
xen/arch/arm/acpi/boot.c line 4
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* Copyright (C) 2014, Naresh Bhat <[email protected]> The code within this file is a copy of
arch/x86/acpi/boot.c.Please retain the copyright and add yours if necessary.
xen/arch/arm/acpi/boot.c line 6
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines
xen/arch/arm/acpi/boot.c new file +4
-0+* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or xen/arch/arm/acpi/boot.c
Quoted 10 lines
xen/arch/arm/acpi/boot.c new file +10
-0+* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
xen/arch/arm/acpi/boot.c line 22
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines
xen/arch/arm/acpi/boot.c new file +4
-0+*/ + +#include <xen/init.h> +#include <xen/acpi.h> xen/arch/arm/acpi/boot.c line 36
Quoted 10 lines
xen/arch/arm/acpi/boot.c new file +10
-0+ +#include <asm/acpi.h> + +/* +* acpi_boot_table_init() called from setup_arch(), always. +* 1. find RSDP and get its address, and then find XSDT +* 2. extract all tables and checksums them all +* +* We can parse ACPI boot-time tables such as FADT, MADT after +* this function is called. It's worth to expand the commit message as done in the x86 version to explain the return value.
xen/arch/arm/acpi/boot.c line 47
Quoted 11 lines
xen/arch/arm/acpi/boot.c new file +11
-0+*/ +int __init acpi_boot_table_init (void ) +{ +int error; + +/* If acpi_disabled, bail out */ +if ( acpi_disabled ) +return 1 ; + +/* Initialize the ACPI boot-time table parser. */ + error =acpi_table_init ();I didn't find a better place for this comment. Though it's related to the ACPI initialization...
You need to
change_acpi_os_get_root_pointer, the current behavior is to fallback on the legacy method (i.e scanning the first MB of memory) whenefi_enabled0.sure, will take care in next patchset.
xen/arch/arm/setup.c static void __init setup_mm(unsigned long dtb_paddr,
Quoted 35 lines
xen/arch/arm/acpi/boot.c new file +9
-0+if ( error ) + { +disable_acpi (); +return error; + } + +return 0 ; +} +xen/arch/arm/setup.c +3
-0@@ -36,6 +36,7 @@#include <xen/pfn.h> #include <xen/vmap.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> #include <asm/page.h> #include <asm/current.h> #include <asm/setup.h> @@ -45,10 +46,12 @@#include <asm/procinfo.h> #include <asm/setup.h> #include <xsm/xsm.h> +#include <asm/acpi.h> struct bootinfo __initdata bootinfo;struct cpuinfo_arm __read_mostly boot_cpu_data; +bool_t acpi_disabled;#ifdef CONFIG_ARM_32 static unsigned long opt_xenheap_megabytes__initdata ;@@ -610,7 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr,
size_tdtb_size)xen/arch/arm/setup.c static void __init setup_mm(unsigned long dtb_paddr,
Quoted 8 lines
xen/arch/arm/setup.c +0
-1init_xenheap_pages (pfn_to_paddr (xenheap_mfn_start), pfn_to_paddr(boot_mfn_start)); - end_boot_allocator(); }#else /* CONFIG_ARM_64 */ static void __init setup_mm (unsigned long dtb_paddr,size_t dtb_size)@@ -680,7 +682,6 @@ static void __init setup_mm(unsigned long dtb_paddr,
size_tdtb_size)xen/arch/arm/setup.c static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) · line 683
Quoted 4 lines
xen/arch/arm/setup.c +0
-1setup_frametable_mappings (ram_start, ram_end); max_page =PFN_DOWN (ram_end); -end_boot_allocator ();You need to explain in the commit message why this is necessary (see [1]).
Anybody who didn't follow/remember the thread will think this is wrong...
ok, will take care in next patchset.
xen/arch/arm/setup.c void __init start_xen(unsigned long
Quoted 4 lines
xen/arch/arm/setup.c +0
-0}#endif @@ -751,6 +752,14 @@ void __init start_xen(unsigned long
boot_phys_offset,xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 757
Quoted 6 lines
xen/arch/arm/setup.c +3
-0setup_mm (fdt_paddr, fdt_size); +/* +* Parse the ACPI tables for possible boot-time configuration +*/ Coding style.
/*
* Foo
* bar
*/Although the comment is fitting in a single line so /* foo bar */
Bu
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 758
Quoted 1 line
xen/arch/arm/setup.c +1
-0+if ( !acpi_disabled )The if is not necessary.
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset,
Quoted 8 lines
xen/arch/arm/setup.c +4
-0+acpi_boot_table_init (); + +end_boot_allocator (); +vm_init ();dt_unflatten_host_device_tree ();Regards,
Quoted 6 lines
[1]
http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg01152.html--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 06/41] arm/acpi : Add basic ACPI initialization
+shannon
Quoted 212 lines · Parth Dixit
Quoted 101 lines · Julien Grall
Hi Parth,
Quoted 27 lines · Parth Dixit
acpi_boot_table_init()will be called instart_xento get the RSDP and all the table pointers. with this patch, we can get ACPI boot-time tables from firmware on ARM64.Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/Makefile | 1 + xen/arch/arm/acpi/boot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 13 +++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/acpi/boot.cxen/arch/arm/acpi/Makefile +1
-0@@ -1 +1,2 @@ obj-y += lib.o +obj-y += boot.oxen/arch/arm/acpi/boot.c new file +0
-0xen/arch/arm/acpi/boot.c line 2
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0@@ -0,0 +1,56 @@ +/* +* ARM64 Specific Low-Level ACPI Boot Support This code is not ARM64 specific:
s/ARM64/ARM/
xen/arch/arm/acpi/boot.c line 4
Quoted 2 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* Copyright (C) 2014, Naresh Bhat <[email protected]> The code within this file is a copy of
arch/x86/acpi/boot.c.Please retain the copyright and add yours if necessary.
Quoted 27 lines
xen/arch/arm/acpi/boot.c new file +2
-0+* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA
+ *
+ *
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */xen/arch/arm/acpi/boot.c new file +3
-0+ +#include <xen/init.h> +#include <xen/acpi.h> xen/arch/arm/acpi/boot.c line 36
Quoted 10 lines
xen/arch/arm/acpi/boot.c new file +10
-0+ +#include <asm/acpi.h> + +/* +* acpi_boot_table_init() called from setup_arch(), always. +* 1. find RSDP and get its address, and then find XSDT +* 2. extract all tables and checksums them all +* +* We can parse ACPI boot-time tables such as FADT, MADT after +* this function is called. It's worth to expand the commit message as done in the x86 version to explain the return value.
xen/arch/arm/acpi/boot.c line 47
Quoted 11 lines
+ */
xen/arch/arm/acpi/boot.c new file +10
-0+int __init acpi_boot_table_init (void ) +{ +int error; + +/* If acpi_disabled, bail out */ +if ( acpi_disabled ) +return 1 ; + +/* Initialize the ACPI boot-time table parser. */ + error =acpi_table_init ();I didn't find a better place for this comment. Though it's related to the ACPI initialization...
Quoted 4 lines
You need to
change_acpi_os_get_root_pointer, the current behavior is to fallback on the legacy method (i.e scanning the first MB of memory) whenefi_enabled0.sure, will take care in next patchset.
Quoted 49 lines
Quoted 49 lines
xen/arch/arm/acpi/boot.c new file +9
-0+if ( error ) + { +disable_acpi (); +return error; + } + +return 0 ; +} +xen/arch/arm/setup.c +3
-1@@ -36,6 +36,7 @@#include <xen/pfn.h> #include <xen/vmap.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> #include <asm/page.h> #include <asm/current.h> #include <asm/setup.h> @@ -45,10 +46,12 @@#include <asm/procinfo.h> #include <asm/setup.h> #include <xsm/xsm.h> +#include <asm/acpi.h> struct bootinfo __initdata bootinfo;struct cpuinfo_arm __read_mostly boot_cpu_data; +bool_t acpi_disabled;#ifdef CONFIG_ARM_32 static unsigned long opt_xenheap_megabytes__initdata ;@@ -610,7 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)init_xenheap_pages (pfn_to_paddr (xenheap_mfn_start ), pfn_to_paddr(boot_mfn_start)); - end_boot_allocator(); }#else /* CONFIG_ARM_64 */ static void
__initsetup_mm(unsigned long dtb_paddr, size_t dtb_size)xen/arch/arm/setup.c +0
-0@@ -680,7 +682,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)setup_frametable_mappings (ram_start ,ram_end ); max_page =PFN_DOWN (ram_end);Quoted 6 lines
xen/arch/arm/setup.c static void __init setup_mm(unsigned long dtb_paddr, · line 684
Quoted 1 line
xen/arch/arm/setup.c +0
-1-end_boot_allocator ();You need to explain in the commit message why this is necessary (see [1]).
Anybody who didn't follow/remember the thread will think this is wrong...
ok, will take care in next patchset.
Quoted 45 lines
xen/arch/arm/setup.c void __init start_xen(unsigned long · line 758
Quoted 12 lines
xen/arch/arm/setup.c +3
-0}#endif @@ -751,6 +752,14 @@ void __init start_xen(unsigned long boot_phys_offset,setup_mm (fdt_paddr, fdt_size); +/* +* Parse the ACPI tables for possible boot-time configuration +*/ Coding style.
/*
* Foo
* bar
*/Although the comment is fitting in a single line so /* foo bar */
Bu
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 758
Quoted 1 line
xen/arch/arm/setup.c +1
-0+if ( !acpi_disabled )The if is not necessary.
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 764
Quoted 8 lines
xen/arch/arm/setup.c +4
-0+acpi_boot_table_init (); + +end_boot_allocator (); +vm_init ();dt_unflatten_host_device_tree ();Regards,
[1]
http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg01152.html--
Julien Grall
PATCH v2 7/41 arm/acpi : Introduce ARM Boot Architecture Flags in FADT
In reply to Parth DixitThe Power State Coordination Interface (PSCI) defines an API that can be used to coordinate power control amongst the various supervisory systems concurrently running on a device. ACPI support for this technology would require the addition of two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).
An ARM Boot Architecture Flags structure to support new ARM hardware was introduced in FADT in ACPI 5.1, add the code accordingly to implement that in ACPICA core.
Since ACPI 5.1 doesn't support self defined PSCI function IDs, which means that only PSCI 0.2+ is supported in ACPI.
--- xen/include/acpi/actbl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
xen/include/acpi/actbl.h +8 -2
@@ -244,7 +244,8 @@ struct acpi_table_fadt {u32 flags;/* Miscellaneous flag bits (see below for individual flags) */ struct acpi_generic_address reset_register;/* 64-bit address of the Reset register */ u8 reset_value;/* Value to write to the reset_register port to reset the system */ -u8 reserved4[3 ];/* Reserved, must be zero */ +u16 arm_boot_flags;/* ARM Boot Architecture Flags (see below for individual flags) */ +u8 minor_revision;/* Minor version of this FADT structure */ u64 Xfacs;/* 64-bit physical address of FACS */ u64 Xdsdt;/* 64-bit physical address of DSDT */ struct acpi_generic_address xpm1a_event_block;/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
@@ -270,6 +271,11 @@ struct acpi_table_fadt {#define FADT2_REVISION_ID 3 +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) */ + +#define ACPI_FADT_PSCI_COMPLIANT (1)/* 00: PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1)/* 01: HVC must be used instead of SMC as the PSCI conduit */ +/* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1)/* 00: [V1] The wbinvd instruction works properly */
@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {* FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4) -#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (arm_boot_flags) + 3)#define ACPI_FADT_V3_SIZE (u32) (ACPI_FADT_OFFSET (sleep_control))#define ACPI_FADT_V5_SIZE (u32) (sizeof (struct acpi_table_fadt))
Signature · 1 line
1.9.1
Re: [PATCH v2 07/41] arm/acpi : Introduce ARM Boot Architecture Flags in FADT
Hi Parth,
Quoted 27 lines · Parth Dixit
The Power State Coordination Interface (PSCI) defines an API that can be used to coordinate power control amongst the various supervisory systems concurrently running on a device. ACPI support for this technology would require the addition of two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).An ARM Boot Architecture Flags structure to support new ARM hardware was introduced in FADT in ACPI 5.1, add the code accordingly to implement that in ACPICA core.
Since ACPI 5.1 doesn't support self defined PSCI function IDs, which means that only PSCI 0.2+ is supported in ACPI.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/include/acpi/actbl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)xen/include/acpi/actbl.h +0
-0
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 248
Quoted 6 lines
xen/include/acpi/actbl.h +2
-1@@ -244,7 +244,8 @@ struct acpi_table_fadt {u32 flags;/* Miscellaneous flag bits (see below for individual flags) */ struct acpi_generic_address reset_register;/* 64-bit address of the Reset register */ u8 reset_value;/* Value to write to the reset_register port to reset the system */ -u8 reserved4[3 ];/* Reserved, must be zero */ +u16 arm_boot_flags;/* ARM Boot Architecture Flags (see below for individual flags) */ +u8 minor_revision;/* Minor version of this FADT structure */
Wrong indentation. The file is using hard tab.
Quoted 16 lines
xen/include/acpi/actbl.h +5
-0u64 Xfacs;/* 64-bit physical address of FACS */ u64 Xdsdt;/* 64-bit physical address of DSDT */ struct acpi_generic_address xpm1a_event_block;/* 64-bit Extended Power Mgt 1a Event Reg Blk address */ @@ -270,6 +271,11 @@ struct acpi_table_fadt {#define FADT2_REVISION_ID 3 +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) */ + +#define ACPI_FADT_PSCI_COMPLIANT (1)/* 00: PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1)/* 01: HVC must be used instead of SMC as the PSCI conduit */ +/* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1)/* 00: [V1] The wbinvd instruction works properly */
xen/include/acpi/actbl.h enum acpi_prefered_pm_profiles { · line 354
Quoted 5 lines
xen/include/acpi/actbl.h +1
-1@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {* FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4) -#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (arm_boot_flags) + 3)
Linux is using ACPI_FADT_OFFSET(minor_revision) + 1. Can you use the same here?
Also, I've notice that the patch (see 9eb1105) is slightly different. Mostly documenting the ACPI version for the fields.
Can you update the patch based on Linux code to use the latest version (i.e the version upstreamed)?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 07/41] arm/acpi : Introduce ARM Boot Architecture Flags in FADT
Quoted 80 lines · Julien Grall
Hi Parth,
Quoted 27 lines · Parth Dixit
The Power State Coordination Interface (PSCI) defines an API that can be used to coordinate power control amongst the various supervisory systems concurrently running on a device. ACPI support for this technology would require the addition of two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).An ARM Boot Architecture Flags structure to support new ARM hardware was introduced in FADT in ACPI 5.1, add the code accordingly to implement that in ACPICA core.
Since ACPI 5.1 doesn't support self defined PSCI function IDs, which means that only PSCI 0.2+ is supported in ACPI.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/include/acpi/actbl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)xen/include/acpi/actbl.h +0
-0xen/include/acpi/actbl.h struct acpi_table_fadt { · line 244
Quoted 1 line
xen/include/acpi/actbl.h +0
-0@@ -244,7 +244,8 @@ struct acpi_table_fadt {u32 flags;/* Miscellaneous flag bits (see below for individual flags) */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 245
Quoted 1 line
xen/include/acpi/actbl.h +0
-0struct acpi_generic_address reset_register;/* 64-bit address of the Reset register */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 246
Quoted 1 line
xen/include/acpi/actbl.h +0
-0u8 reset_value;/* Value to write to the reset_register port to reset the system */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 247
Quoted 2 lines
xen/include/acpi/actbl.h +1
-1-u8 reserved4[3 ];/* Reserved, must be zero */ +u16 arm_boot_flags;/* ARM Boot Architecture Flags (see below for individual flags) */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 248
Quoted 1 line
xen/include/acpi/actbl.h +1
-0+u8 minor_revision;/* Minor version of this FADT structure */ Wrong indentation. The file is using hard tab.
xen/include/acpi/actbl.h struct acpi_table_fadt {
Quoted 3 lines
xen/include/acpi/actbl.h +0
-0u64 Xfacs;/* 64-bit physical address of FACS */ u64 Xdsdt;/* 64-bit physical address of DSDT */ struct acpi_generic_address xpm1a_event_block;/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 276
Quoted 7 lines
xen/include/acpi/actbl.h +3
-0@@ -270,6 +271,11 @@ struct acpi_table_fadt {#define FADT2_REVISION_ID 3 +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) */ + +#define ACPI_FADT_PSCI_COMPLIANT (1)/* 00: PSCI 0.2+ is implemented */
xen/include/acpi/actbl.h struct acpi_table_fadt { · line 277
Quoted 1 line
xen/include/acpi/actbl.h +1
-0+#define ACPI_FADT_PSCI_USE_HVC (1<<1)/* 01: HVC must be used instead of SMC as the PSCI conduit */
xen/include/acpi/actbl.h struct acpi_table_fadt {
Quoted 4 lines
xen/include/acpi/actbl.h +1
-0+/* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1)/* 00: [V1] The wbinvd instruction works properly */
xen/include/acpi/actbl.h enum acpi_prefered_pm_profiles { · line 348
Quoted 5 lines
xen/include/acpi/actbl.h +0
-1@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {* FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4) -#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0])+ 3)
xen/include/acpi/actbl.h enum acpi_prefered_pm_profiles { · line 354
Quoted 1 line
xen/include/acpi/actbl.h +1
-0+#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET(
arm_boot_flags) + 3)Linux is using
ACPI_FADT_OFFSET(minor_revision)+ 1. Can you use the same here?Also, I've notice that the patch (see 9eb1105) is slightly different. Mostly documenting the ACPI version for the fields.
Can you update the patch based on Linux code to use the latest version (i.e the version upstreamed)?
Quoted 7 lines
sure, i'll update it to be in sync with linux.
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 07/41] arm/acpi : Introduce ARM Boot Architecture Flags in FADT
+shannon
Quoted 92 lines · Parth Dixit
Quoted 75 lines · Julien Grall
Hi Parth,
Quoted 35 lines · Parth Dixit
The Power State Coordination Interface (PSCI) defines an API that can be used to coordinate power control amongst the various supervisory systems concurrently running on a device. ACPI support for this technology would require the addition of two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).An ARM Boot Architecture Flags structure to support new ARM hardware was introduced in FADT in ACPI 5.1, add the code accordingly to implement that in ACPICA core.
Since ACPI 5.1 doesn't support self defined PSCI function IDs, which means that only PSCI 0.2+ is supported in ACPI.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/include/acpi/actbl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)xen/include/acpi/actbl.h +0
-0@@ -244,7 +244,8 @@ struct acpi_table_fadt {u32 flags;/* Miscellaneous flag bits (see below for individual flags) */
structacpi_generic_addressreset_register; /* 64-bit address
of the Reset register */
u8reset_value; /* Value to write to thereset_register
port to reset the system */xen/include/acpi/actbl.h +1
-1-u8 reserved4[3 ];/* Reserved, must be zero */ +u16 arm_boot_flags;/* ARM Boot Architecture Flags (see below Quoted 2 lines
for individual flags) */
+ u8minor_revision; /* Minor version of this FADT structure */Wrong indentation. The file is using hard tab.
Quoted 20 lines
u64 Xfacs; /* 64-bit physical address of FACS */
u64 Xdsdt; /* 64-bit physical address of DSDT */
structacpi_generic_addressxpm1a_event_block; /* 64-bit Extended
Power Mgt 1a Event Reg Blk address */xen/include/acpi/actbl.h +3
-0@@ -270,6 +271,11 @@ struct acpi_table_fadt {#define FADT2_REVISION_ID 3 +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) */ + +#define ACPI_FADT_PSCI_COMPLIANT (1)/* 00: PSCI 0.2+ is implemented */
+#defineACPI_FADT_PSCI_USE_HVC(1<<1) /* 01: HVC must be used
instead of SMC as the PSCI conduit */
+
/* Masks for FADT flags */#define
ACPI_FADT_WBINVD(1) /* 00: [V1] The wbinvd
instruction works properly */xen/include/acpi/actbl.h enum acpi_prefered_pm_profiles { · line 356
Quoted 7 lines
xen/include/acpi/actbl.h +2
-1@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {* FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4) -#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (arm_boot_flags) + 3)Linux is using
ACPI_FADT_OFFSET(minor_revision)+ 1. Can you use the same here?Quoted 6 lines
Also, I've notice that the patch (see 9eb1105) is slightly different. Mostly documenting the ACPI version for the fields.
Can you update the patch based on Linux code to use the latest version (i.e the version upstreamed)?
sure, i'll update it to be in sync with linux.
Quoted 5 lines
Regards,
--
Julien Grall
PATCH v2 8/41 arm/acpi : Parse FADT table and get PSCI flags
In reply to Parth DixitThere are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).
FADT table contains such information, parse FADT to get the flags for furture usage. At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, so we will check the version and only parse FADT table with version >= 5.1.
If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 5.1.
Modify FADT table before passing it to Dom0.
Set PSCI_COMPLIANT and PSCI_USE_HVC.
--- xen/arch/arm/acpi/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 11 +++++++++++ xen/include/asm-arm/acpi.h | 11 +++++++++++ 3 files changed, 60 insertions(+)
xen/arch/arm/acpi/boot.c +38 -0
@@ -24,9 +24,40 @@#include <xen/init.h> #include <xen/acpi.h> +#include <xen/errno.h> +#include <acpi/actables.h> +#include <xen/mm.h> #include <asm/acpi.h> +static int __init acpi_parse_fadt (struct acpi_table_header *table) +{ +struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table; +u8 checksum; + +/* +* Revision in table header is the FADT Major revision, and there +* is a minor revision of FADT which was introduced by ACPI 5.1, +* we only deal with ACPI 5.1 or newer revision to get GIC and SMP +* boot protocol configuration data, or we will disable ACPI. +*/ +if ( table->revision >5 || + ( table->revision ==5 && fadt->minor_revision >=1 ) ) + { + fadt->arm_boot_flags |= (ACPI_FADT_PSCI_COMPLIANT |ACPI_FADT_PSCI_USE_HVC ); + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, fadt), fadt->header.length); + fadt->header.checksum -= checksum; +clean_dcache_va_range (fadt,sizeof (struct acpi_table_fadt )); +return 0 ; + } + +printk ("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n" , + table->revision, fadt->minor_revision); +disable_acpi (); + +return -EINVAL ; +} +/* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT
@@ -51,6 +82,13 @@ int __init acpi_boot_table_init(void)return error; } +if (acpi_table_parse (ACPI_SIG_FADT , acpi_parse_fadt) ) + { +/* disable ACPI if no FADT is found */ +disable_acpi (); +printk ("Can't find FADT\n" ); + } +return 0 ; }
xen/arch/arm/acpi/lib.c +11 -0
@@ -6,3 +6,14 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) {return __va (phys); } +/* 1 to indicate PSCI 0.2+ is implemented */ +inline bool_t acpi_psci_present (void ) +{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_COMPLIANT ; +} + +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +inline bool_t acpi_psci_hvc_present (void ) +{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; +}
xen/include/asm-arm/acpi.h +11 -0
@@ -29,6 +29,17 @@#define COMPILER_DEPENDENT_UINT64 unsigned long longextern bool_t acpi_disabled; + +#ifdef CONFIG_ACPI +/* 1 to indicate PSCI 0.2+ is implemented */ +bool_t acpi_psci_present (void ); +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +bool_t acpi_psci_hvc_present (void ); +#else +static inline bool_t acpi_psci_present (void ) {return false; } +static inline bool_t acpi_psci_hvc_present (void ) {return false; } +#endif /* CONFIG_ACPI */ +/* Basic configuration for ACPI */ static inline void disable_acpi (void ) {
Signature · 1 line
1.9.1
Re: [PATCH v2 08/41] arm/acpi : Parse FADT table and get PSCI flags
Hi Parth,
Quoted 45 lines · Parth Dixit
There are two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).FADT table contains such information, parse FADT to get the flags for furture usage. At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, so we will check the version and only parse FADT table with version >= 5.1.
If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 5.1.
Modify FADT table before passing it to Dom0.
SetPSCI_COMPLIANTandPSCI_USE_HVC.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 11 +++++++++++ xen/include/asm-arm/acpi.h | 11 +++++++++++ 3 files changed, 60 insertions(+)xen/arch/arm/acpi/boot.c +6
-0@@ -24,9 +24,40 @@#include <xen/init.h> #include <xen/acpi.h> +#include <xen/errno.h> +#include <acpi/actables.h> +#include <xen/mm.h> #include <asm/acpi.h> +static int __init acpi_parse_fadt (struct acpi_table_header *table) +{ +struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
xen/arch/arm/acpi/boot.c line 45
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+u8 checksum; + +/* +* Revision in table header is the FADT Major revision, and there +* is a minor revision of FADT which was introduced by ACPI 5.1, +* we only deal with ACPI 5.1 or newer revision to get GIC and SMP +* boot protocol configuration data, or we will disable ACPI. +*/ +if ( table->revision >5 || + ( table->revision ==5 && fadt->minor_revision >=1 ) )
The indentation looks wrong here.
xen/arch/arm/acpi/boot.c line 50
Quoted 5 lines
xen/arch/arm/acpi/boot.c +5
-0+ { + fadt->arm_boot_flags |= (ACPI_FADT_PSCI_COMPLIANT |ACPI_FADT_PSCI_USE_HVC ); + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, fadt), fadt->header.length); + fadt->header.checksum -= checksum; +clean_dcache_va_range (fadt,sizeof (struct acpi_table_fadt ));
Most of this patch is dealing with setting up correctly DOM0 FADT although the title doesn't mention it and there is only 2 lines in the commit message. This would also need comment in the need explaining what this code does.
Furthermore, I don't think this code should live here. The function is called by acpi_boot_table_init which should initialize ACPI and not trying to modify the ACPI table.
We should have a specific dom0 acpi function to modify/add ACPI table when it's necessary.
Quoted 14 lines
xen/arch/arm/acpi/boot.c +10
-0+return 0 ; + } + +printk ("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n" , + table->revision, fadt->minor_revision); +disable_acpi (); + +return -EINVAL ; +} +/* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT
xen/arch/arm/acpi/boot.c int __init acpi_boot_table_init(void) · line 91
Quoted 10 lines
xen/arch/arm/acpi/boot.c +7
-0@@ -51,6 +82,13 @@ int __init acpi_boot_table_init(void)return error; } +if (acpi_table_parse (ACPI_SIG_FADT , acpi_parse_fadt) ) + { +/* disable ACPI if no FADT is found */ +disable_acpi (); +printk ("Can't find FADT\n" ); + } +
I think the code readability will be improved if we introduce acpi_get_table_with_size.
Although, this is not implemented by ACPICA but only Linux. Jan may not be agree to import it.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 8
Quoted 11 lines
xen/arch/arm/acpi/boot.c +0
-0return 0 ; }xen/arch/arm/acpi/lib.c +0
-0@@ -6,3 +6,14 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) {return __va (phys); }
missing blank line
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 10
Quoted 2 lines
xen/arch/arm/acpi/lib.c +2
-0+/* 1 to indicate PSCI 0.2+ is implemented */ +inline bool_t acpi_psci_present (void )
inline is not necessary. Although, I would move the function in the header because it's very simple.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 16
Quoted 6 lines
xen/arch/arm/acpi/lib.c +6
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_COMPLIANT ; +} + +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +inline bool_t acpi_psci_hvc_present (void )
Ditto.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 19
Quoted 3 lines
xen/arch/arm/acpi/lib.c +3
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; +}
Regards,
Signature · 2 lines
-- Julien Grall
Re: [PATCH v2 08/41] arm/acpi : Parse FADT table and get PSCI flags
Quoted 74 lines · Julien Grall
Hi Parth,
Quoted 45 lines · Parth Dixit
There are two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).FADT table contains such information, parse FADT to get the flags for furture usage. At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, so we will check the version and only parse FADT table with version >= 5.1.
If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 5.1.
Modify FADT table before passing it to Dom0.
SetPSCI_COMPLIANTandPSCI_USE_HVC.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 11 +++++++++++ xen/include/asm-arm/acpi.h | 11 +++++++++++ 3 files changed, 60 insertions(+)xen/arch/arm/acpi/boot.c +6
-0@@ -24,9 +24,40 @@#include <xen/init.h> #include <xen/acpi.h> +#include <xen/errno.h> +#include <acpi/actables.h> +#include <xen/mm.h> #include <asm/acpi.h> +static int __init acpi_parse_fadt (struct acpi_table_header *table) +{ +struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;xen/arch/arm/acpi/boot.c line 45
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+u8 checksum; + +/* +* Revision in table header is the FADT Major revision, and there +* is a minor revision of FADT which was introduced by ACPI 5.1, +* we only deal with ACPI 5.1 or newer revision to get GIC and SMP +* boot protocol configuration data, or we will disable ACPI. +*/ +if ( table->revision >5 || + ( table->revision ==5 && fadt->minor_revision >=1 ) )The indentation looks wrong here.
xen/arch/arm/acpi/boot.c line 47
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ { + fadt->arm_boot_flags |= ( ACPI_FADT_PSCI_COMPLIANT |
ACPI_FADT_PSCI_USE_HVC);xen/arch/arm/acpi/boot.c line 48
Quoted 1 line
xen/arch/arm/acpi/boot.c +1
-0+ checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt),
fadt->header.length);xen/arch/arm/acpi/boot.c line 50
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ fadt->header.checksum -= checksum; +clean_dcache_va_range (fadt,sizeof (struct acpi_table_fadt ));Most of this patch is dealing with setting up correctly DOM0 FADT although the title doesn't mention it and there is only 2 lines in the commit message. This would also need comment in the need explaining what this code does.
Quoted 5 lines
Furthermore, I don't think this code should live here. The function is called by
acpi_boot_table_initwhich should initialize ACPI and not trying to modify the ACPI table.i'll split it into two patches with modifying of fadt going into seperate
patch.
Quoted 71 lines
We should have a specific dom0 acpi function to modify/add ACPI table when it's necessary.
xen/arch/arm/acpi/boot.c
Quoted 4 lines
xen/arch/arm/acpi/boot.c +4
-0+return 0 ; + } + + printk("Unsupported FADT revision %d.%d, should be 5.1+, willdisable ACPI\n",
Quoted 10 lines
xen/arch/arm/acpi/boot.c +6
-0+ table->revision, fadt->minor_revision); +disable_acpi (); + +return -EINVAL ; +} +/* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT xen/arch/arm/acpi/boot.c int __init acpi_boot_table_init(void) · line 91
Quoted 10 lines
xen/arch/arm/acpi/boot.c +7
-0@@ -51,6 +82,13 @@ int __init acpi_boot_table_init(void)return error; } +if (acpi_table_parse (ACPI_SIG_FADT , acpi_parse_fadt) ) + { +/* disable ACPI if no FADT is found */ +disable_acpi (); +printk ("Can't find FADT\n" ); + } +I think the code readability will be improved if we introduce
acpi_get_table_with_size.Although, this is not implemented by ACPICA but only Linux. Jan may not be agree to import it.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size
Quoted 8 lines
xen/arch/arm/acpi/boot.c +0
-0return 0 ; }xen/arch/arm/acpi/lib.c +0
-0@@ -6,3 +6,14 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_sizesize)
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 8
Quoted 3 lines
xen/arch/arm/acpi/lib.c +0
-0{return __va (phys); }missing blank line
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 10
Quoted 2 lines
xen/arch/arm/acpi/lib.c +2
-0+/* 1 to indicate PSCI 0.2+ is implemented */ +inline bool_t acpi_psci_present (void )inline is not necessary. Although, I would move the function in the header because it's very simple.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 16
Quoted 6 lines
xen/arch/arm/acpi/lib.c +6
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_COMPLIANT ; +} + +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +inline bool_t acpi_psci_hvc_present (void )Ditto.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 19
Quoted 3 lines
xen/arch/arm/acpi/lib.c +3
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; +}Regards,
Quoted 4 lines
--
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 08/41] arm/acpi : Parse FADT table and get PSCI flags
+shannon
Quoted 161 lines · Parth Dixit
Quoted 70 lines · Julien Grall
Hi Parth,
Quoted 45 lines · Parth Dixit
There are two flags:
PSCI_COMPLIANTandPSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).FADT table contains such information, parse FADT to get the flags for furture usage. At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, so we will check the version and only parse FADT table with version >= 5.1.
If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 5.1.
Modify FADT table before passing it to Dom0.
SetPSCI_COMPLIANTandPSCI_USE_HVC.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 11 +++++++++++ xen/include/asm-arm/acpi.h | 11 +++++++++++ 3 files changed, 60 insertions(+)xen/arch/arm/acpi/boot.c +6
-0@@ -24,9 +24,40 @@#include <xen/init.h> #include <xen/acpi.h> +#include <xen/errno.h> +#include <acpi/actables.h> +#include <xen/mm.h> #include <asm/acpi.h> +static int __init acpi_parse_fadt (struct acpi_table_header *table) +{ +struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;xen/arch/arm/acpi/boot.c line 45
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+u8 checksum; + +/* +* Revision in table header is the FADT Major revision, and there +* is a minor revision of FADT which was introduced by ACPI 5.1, +* we only deal with ACPI 5.1 or newer revision to get GIC and SMP +* boot protocol configuration data, or we will disable ACPI. +*/ +if ( table->revision >5 || + ( table->revision ==5 && fadt->minor_revision >=1 ) )The indentation looks wrong here.
xen/arch/arm/acpi/boot.c line 52
Quoted 7 lines
xen/arch/arm/acpi/boot.c +5
-0+ { + fadt->arm_boot_flags |= (ACPI_FADT_PSCI_COMPLIANT |ACPI_FADT_PSCI_USE_HVC ); + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, fadt), fadt->header.length); + fadt->header.checksum -= checksum; +clean_dcache_va_range (fadt,sizeof (struct acpi_table_fadt ));Quoted 9 lines
Most of this patch is dealing with setting up correctly DOM0 FADT although the title doesn't mention it and there is only 2 lines in the commit message. This would also need comment in the need explaining what this code does.
Furthermore, I don't think this code should live here. The function is called by
acpi_boot_table_initwhich should initialize ACPI and not trying to modify the ACPI table.i'll split it into two patches with modifying of fadt going into seperate patch.
Quoted 75 lines
We should have a specific dom0 acpi function to modify/add ACPI table when it's necessary.
Quoted 15 lines
xen/arch/arm/acpi/boot.c +10
-0+return 0 ; + } + + printk("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n", + table->revision, fadt->minor_revision); +disable_acpi (); + +return -EINVAL ; +} +/*
*acpi_boot_table_init()called fromsetup_arch(), always.
* 1. find RSDP and get its address, and then find XSDTxen/arch/arm/acpi/boot.c int __init acpi_boot_table_init(void) · line 91
Quoted 10 lines
xen/arch/arm/acpi/boot.c +7
-0@@ -51,6 +82,13 @@ int __init acpi_boot_table_init(void)return error; } +if (acpi_table_parse (ACPI_SIG_FADT , acpi_parse_fadt) ) + { +/* disable ACPI if no FADT is found */ +disable_acpi (); +printk ("Can't find FADT\n" ); + } +I think the code readability will be improved if we introduce
acpi_get_table_with_size.Although, this is not implemented by ACPICA but only Linux. Jan may not be agree to import it.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size · line 8
Quoted 12 lines
xen/arch/arm/acpi/boot.c +0
-0return 0 ; }xen/arch/arm/acpi/lib.c +0
-0@@ -6,3 +6,14 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) {return __va (phys); }missing blank line
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 10
Quoted 2 lines
xen/arch/arm/acpi/lib.c +2
-0+/* 1 to indicate PSCI 0.2+ is implemented */ +inline bool_t acpi_psci_present (void )inline is not necessary. Although, I would move the function in the header because it's very simple.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 16
Quoted 6 lines
xen/arch/arm/acpi/lib.c +6
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_COMPLIANT ; +} + +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +inline bool_t acpi_psci_hvc_present (void )Ditto.
xen/arch/arm/acpi/lib.c acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) · line 19
Quoted 3 lines
xen/arch/arm/acpi/lib.c +3
-0+{ +return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; +}Regards,
--
--
Julien Grall
PATCH v2 9/41 arm/acpi : Add Generic Interrupt and Distributor struct
In reply to Parth DixitAdd Generic Interrupt and Distributor (ACPI 5.0) structure. Add new features for MADT introduced by ACPI 5.1. Comment on the GIC ID field of the GIC structure which is replaced by CPU Interface Number.
Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR. Add new structures for GIC MSI frame and GICR.
Add flag definition for GICC flags.
--- xen/include/acpi/actbl1.h | 62 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-)
xen/include/acpi/actbl1.h +60 -2
@@ -639,7 +639,11 @@ enum acpi_madt_type {ACPI_MADT_TYPE_INTERRUPT_SOURCE =8 ,ACPI_MADT_TYPE_LOCAL_X2APIC =9 ,ACPI_MADT_TYPE_LOCAL_X2APIC_NMI =10 , - ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ +ACPI_MADT_TYPE_GENERIC_INTERRUPT =11 , +ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR =12 , +ACPI_MADT_TYPE_GIC_MSI_FRAME =13 , +ACPI_MADT_TYPE_GIC_REDISTRIBUTOR =14 , + ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */ };/*
@@ -760,14 +764,68 @@ struct acpi_madt_local_x2apic_nmi {u8 reserved[3 ]; }; +/* 11: Generic Interrupt (ACPI 5.1) */ + +struct acpi_madt_generic_interrupt { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_id;/* it was renamed to cpu interface number in ACPI 5.1 */ +u32 uid; +u32 flags; +u32 parking_version; +u32 performance_interrupt; +u64 parked_address; +u64 base_address; +u64 gicv_base_address; +u64 gich_base_address; +u32 vgic_maintenance_interrupt; +u64 redist_base_address; +u64 mpidr; + +}; + +/* 12: Generic Distributor (ACPI 5.0) */ + +struct acpi_madt_generic_distributor { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_id; +u64 base_address; +u32 global_irq_base; +u32 reserved2;/* reserved - must be zero */ +}; + +/* 13: GIC MSI Frame (ACPI 5.1) */ + +struct acpi_madt_gic_msi_frame { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_msi_frame_id; +u64 base_address; +}; + +/* 14: GIC Redistributor (ACPI 5.1) */ + +struct acpi_madt_gic_redistributor { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u64 base_address; +u32 region_size; +}; +/* * Common flags fields for MADT subtables */ -/* MADT Local APIC flags (lapic_flags) */ +/* MADT Local APIC flags (lapic_flags) and GICC flags */ #define ACPI_MADT_ENABLED (1)/* 00: Processor is usable if set */ +/* MADT GICC flags only */ + +#define ACPI_MADT_PERF_INT_MODE (1<<1)/* 01: Performance Interrupt Mode */ +#define ACPI_MADT_VGIC (1<<2)/* 02: VGIC Maintenance interrupt mode */ +/* MADT MPS INTI flags (inti_flags) */ #define ACPI_MADT_POLARITY_MASK (3)/* 00-01: Polarity of APIC I/O input signals */
Signature · 1 line
1.9.1
Re: [PATCH v2 09/41] arm/acpi : Add Generic Interrupt and Distributor struct
+shannon
Quoted 106 lines · Parth Dixit
Add Generic Interrupt and Distributor (ACPI 5.0) structure. Add new features for MADT introduced by ACPI 5.1. Comment on the GIC ID field of the GIC structure which is replaced by CPU Interface Number.
Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR. Add new structures for GIC MSI frame and GICR.
Add flag definition for GICC flags.Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/include/acpi/actbl1.h | 62 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-)xen/include/acpi/actbl1.h +60
-3@@ -639,7 +639,11 @@ enum acpi_madt_type {ACPI_MADT_TYPE_INTERRUPT_SOURCE =8 ,ACPI_MADT_TYPE_LOCAL_X2APIC =9 ,ACPI_MADT_TYPE_LOCAL_X2APIC_NMI =10 , - ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ +ACPI_MADT_TYPE_GENERIC_INTERRUPT =11 , +ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR =12 , +ACPI_MADT_TYPE_GIC_MSI_FRAME =13 , +ACPI_MADT_TYPE_GIC_REDISTRIBUTOR =14 , + ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */ };/* @@ -760,14 +764,68 @@ struct acpi_madt_local_x2apic_nmi {u8 reserved[3 ]; }; +/* 11: Generic Interrupt (ACPI 5.1) */ + +struct acpi_madt_generic_interrupt { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_id;/* it was renamed to cpu interface number in ACPI 5.1 */ +u32 uid; +u32 flags; +u32 parking_version; +u32 performance_interrupt; +u64 parked_address; +u64 base_address; +u64 gicv_base_address; +u64 gich_base_address; +u32 vgic_maintenance_interrupt; +u64 redist_base_address; +u64 mpidr; + +}; + +/* 12: Generic Distributor (ACPI 5.0) */ + +struct acpi_madt_generic_distributor { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_id; +u64 base_address; +u32 global_irq_base; +u32 reserved2;/* reserved - must be zero */ +}; + +/* 13: GIC MSI Frame (ACPI 5.1) */ + +struct acpi_madt_gic_msi_frame { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u32 gic_msi_frame_id; +u64 base_address; +}; + +/* 14: GIC Redistributor (ACPI 5.1) */ + +struct acpi_madt_gic_redistributor { +struct acpi_subtable_header header; +u16 reserved;/* reserved - must be zero */ +u64 base_address; +u32 region_size; +}; +/* * Common flags fields for MADT subtables */ -/* MADT Local APIC flags (lapic_flags) */ +/* MADT Local APIC flags (lapic_flags) and GICC flags */ #define ACPI_MADT_ENABLED (1)/* 00: Processor is usable if set */ +/* MADT GICC flags only */ + +#define ACPI_MADT_PERF_INT_MODE (1<<1)/* 01: Performance Interrupt Mode */ +#define ACPI_MADT_VGIC (1<<2)/* 02: VGIC Maintenance interrupt mode */ +/* MADT MPS INTI flags (inti_flags) */ #define ACPI_MADT_POLARITY_MASK (3)/* 00-01: Polarity of APIC I/O input signals */ --1.9.1
PATCH v2 10/41 arm/acpi : Print GIC information when MADT is parsed
In reply to Parth DixitFrom: Naresh Bhat <[email protected]>
When MADT is parsed, print GIC information to make the boot log look pretty.
--- xen/drivers/acpi/tables.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
xen/drivers/acpi/tables.c +39 -0
@@ -190,6 +190,45 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) }break ; +case ACPI_MADT_TYPE_GENERIC_INTERRUPT : + { +struct acpi_madt_generic_interrupt *p = + (struct acpi_madt_generic_interrupt *)header; + printk(KERN_INFO PREFIX +"GIC (acpi_id[0x%04x] gic_id[0x%04x] %s)\n" , + p->uid, p->gic_id, + (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); + } +break ; + +case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR : + { +struct acpi_madt_generic_distributor *p = + (struct acpi_madt_generic_distributor *)header; + printk(KERN_INFO PREFIX +"GIC Distributor (id[0x%04x] address[0x%08llx] gsi_base[%d])\n" , + p->gic_id, (long long unsigned int)p->base_address, p->global_irq_base); + } +break ; + +case ACPI_MADT_TYPE_GIC_MSI_FRAME : + { +struct acpi_madt_gic_msi_frame *p = + (struct acpi_madt_gic_msi_frame *)header; +printk ("GIC MSI Frame (address[0x%08llx] msi_fame_id[%d])\n" , + (long long unsigned int )p->base_address, p->gic_msi_frame_id); + } +break ; + +case ACPI_MADT_TYPE_GIC_REDISTRIBUTOR : + { +struct acpi_madt_gic_redistributor *p = + (struct acpi_madt_gic_redistributor *)header; +printk ("GIC Redistributor (address[0x%08llx] region_size[0x%x])\n" , + (long long unsigned int )p->base_address, p->region_size); + } +break ; +default : printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = %#x)\n",
Signature · 1 line
1.9.1
Re: [PATCH v2 10/41] arm/acpi : Print GIC information when MADT is parsed
Hi Parth,
Quoted 18 lines · Parth Dixit
From: Naresh Bhat <[email protected]>
When MADT is parsed, print GIC information to make the boot log look pretty.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/drivers/acpi/tables.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)xen/drivers/acpi/tables.c +0
-0@@ -190,6 +190,45 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) }
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 200
Quoted 10 lines
xen/drivers/acpi/tables.c +8
-0break ; +case ACPI_MADT_TYPE_GENERIC_INTERRUPT : + { +struct acpi_madt_generic_interrupt *p = + (struct acpi_madt_generic_interrupt *)header; + printk(KERN_INFO PREFIX +"GIC (acpi_id[0x%04x] gic_id[0x%04x] %s)\n" , + p->uid, p->gic_id, + (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
Printk indentation:
printk(KERN_INFO PREFIX
"GIC ...
...);Also, it seems that the indentation doesn't match the rest of the switch case.
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 210
Quoted 10 lines
xen/drivers/acpi/tables.c +10
-0+ } +break ; + +case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR : + { +struct acpi_madt_generic_distributor *p = + (struct acpi_madt_generic_distributor *)header; + printk(KERN_INFO PREFIX +"GIC Distributor (id[0x%04x] address[0x%08llx] gsi_base[%d])\n" , + p->gic_id, (long long unsigned int)p->base_address, p->global_irq_base);
Ditto
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 219
Quoted 9 lines
xen/drivers/acpi/tables.c +9
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_MSI_FRAME : + { +struct acpi_madt_gic_msi_frame *p = + (struct acpi_madt_gic_msi_frame *)header; +printk ("GIC MSI Frame (address[0x%08llx] msi_fame_id[%d])\n" , + (long long unsigned int )p->base_address, p->gic_msi_frame_id);
Ditto & missing KERN_INFO PREFIX
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 228
Quoted 9 lines
xen/drivers/acpi/tables.c +9
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_REDISTRIBUTOR : + { +struct acpi_madt_gic_redistributor *p = + (struct acpi_madt_gic_redistributor *)header; +printk ("GIC Redistributor (address[0x%08llx] region_size[0x%x])\n" , + (long long unsigned int )p->base_address, p->region_size);
Ditto & missing KERN_INFO PREFIX
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 234
Quoted 7 lines
xen/drivers/acpi/tables.c +3
-0+ } +break ; +default : printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = %#x)\n",
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 10/41] arm/acpi : Print GIC information when MADT is parsed
Quoted 80 lines · Julien Grall
Hi Parth,
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct
Quoted 17 lines · Parth Dixit
From: Naresh Bhat <[email protected]>
When MADT is parsed, print GIC information to make the boot log look pretty.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/drivers/acpi/tables.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)xen/drivers/acpi/tables.c +0
-0@@ -190,6 +190,45 @@ void __init acpi_table_print_madt_entry(struct
acpi_subtable_header*header)xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
Quoted 11 lines
xen/drivers/acpi/tables.c +8
-0}break ; +case ACPI_MADT_TYPE_GENERIC_INTERRUPT : + { +struct acpi_madt_generic_interrupt *p = + (struct acpi_madt_generic_interrupt *)header; + printk(KERN_INFO PREFIX +"GIC (acpi_id[0x%04x] gic_id[0x%04x] %s)\n" , + p->uid, p->gic_id, + (p->flags & ACPI_MADT_ENABLED) ? "enabled" :"disabled");
Printk indentation:
printk(KERN_INFO PREFIX
"GIC ... ...);Also, it seems that the indentation doesn't match the rest of the switch case.
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
Quoted 9 lines
xen/drivers/acpi/tables.c +9
-0+ } +break ; + +case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR : + { +struct acpi_madt_generic_distributor *p = + (struct acpi_madt_generic_distributor *)header; + printk(KERN_INFO PREFIX + "GIC Distributor (id[0x%04x] address[0x%08llx]gsi_base[%d])\n",
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct · line 210
Quoted 1 line
xen/drivers/acpi/tables.c +1
-0+ p->gic_id, (long long unsigned int)p->base_address,
p->global_irq_base);Ditto
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
Quoted 8 lines
xen/drivers/acpi/tables.c +8
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_MSI_FRAME : + { +struct acpi_madt_gic_msi_frame *p = + (struct acpi_madt_gic_msi_frame *)header; + printk("GIC MSI Frame (address[0x%08llx]msi_fame_id[%d])\n",
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct · line 219
Quoted 1 line
xen/drivers/acpi/tables.c +1
-0+ (long long unsigned int)p->base_address,
p->gic_msi_frame_id);Ditto & missing
KERN_INFOPREFIXxen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
Quoted 8 lines
xen/drivers/acpi/tables.c +8
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_REDISTRIBUTOR : + { +struct acpi_madt_gic_redistributor *p = + (struct acpi_madt_gic_redistributor *)header; + printk("GIC Redistributor (address[0x%08llx]
Quoted 6 lines
region_size[0x%x])\n",
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct · line 228
Quoted 1 line
xen/drivers/acpi/tables.c +1
-0+ (long long unsigned int)p->base_address,
p->region_size);Ditto & missing
KERN_INFOPREFIX
will take care in next patchset.
Quoted 9 lines
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 234
Quoted 8 lines
xen/drivers/acpi/tables.c +3
-0+ } +break ; +default : printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = %#x)\n",
Quoted 5 lines
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 10/41] arm/acpi : Print GIC information when MADT is parsed
+shannon
Quoted 107 lines · Parth Dixit
Quoted 85 lines · Julien Grall
Hi Parth,
Quoted 20 lines · Parth Dixit
From: Naresh Bhat <[email protected]>
When MADT is parsed, print GIC information to make the boot log look pretty.
Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Naresh Bhat <[email protected]>--- xen/drivers/acpi/tables.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)xen/drivers/acpi/tables.c +0
-0@@ -190,6 +190,45 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) }break ;xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct · line 202
Quoted 10 lines
xen/drivers/acpi/tables.c +8
-0+case ACPI_MADT_TYPE_GENERIC_INTERRUPT : + { +struct acpi_madt_generic_interrupt *p = + (struct acpi_madt_generic_interrupt *)header; + printk(KERN_INFO PREFIX +"GIC (acpi_id[0x%04x] gic_id[0x%04x] %s)\n" , + p->uid, p->gic_id, + (p->flags &ACPI_MADT_ENABLED ) ?"enabled" : "disabled");Printk indentation:
printk(KERN_INFO PREFIX
"GIC ... ...);Also, it seems that the indentation doesn't match the rest of the switch case.
Quoted 11 lines
xen/drivers/acpi/tables.c +10
-0+ } +break ; + +case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR : + { +struct acpi_madt_generic_distributor *p = + (struct acpi_madt_generic_distributor *)header; + printk(KERN_INFO PREFIX + "GIC Distributor (id[0x%04x] address[0x%08llx] gsi_base[%d])\n", + p->gic_id, (long long unsigned int)p->base_address,Quoted 1 line
p->global_irq_base);Ditto
Quoted 11 lines
xen/drivers/acpi/tables.c +8
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_MSI_FRAME : + { +struct acpi_madt_gic_msi_frame *p = + (struct acpi_madt_gic_msi_frame *)header; + printk("GIC MSI Frame (address[0x%08llx]msi_fame_id[%d])\n",
+ (long long unsigned int)p->base_address,p->gic_msi_frame_id);Ditto & missing
KERN_INFOPREFIXQuoted 11 lines
xen/drivers/acpi/tables.c +8
-0+ } +break ; + +case ACPI_MADT_TYPE_GIC_REDISTRIBUTOR : + { +struct acpi_madt_gic_redistributor *p = + (struct acpi_madt_gic_redistributor *)header; + printk("GIC Redistributor (address[0x%08llx]region_size[0x%x])\n",
+ (long long unsigned int)p->base_address,p->region_size);Quoted 1 line
Ditto & missing
KERN_INFOPREFIXwill take care in next patchset.
Quoted 14 lines
xen/drivers/acpi/tables.c void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 234
Quoted 9 lines
xen/drivers/acpi/tables.c +3
-0+ } +break ; +default : printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = %#x)\n",Regards,
--
Julien Grall
PATCH v2 11/41 arm/acpi : add GTDT support updated by ACPI 5.1
In reply to Parth DixitWith ACPI 5.0, we got per-processor timer support in GTDT, and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed for the spec change.
--- xen/include/acpi/actbl3.h | 92 +++++++++++++++++++++++++++++++++++++++------- xen/include/asm-arm/acpi.h | 2 + 2 files changed, 80 insertions(+), 14 deletions(-)
xen/include/acpi/actbl3.h +78 -14
@@ -241,33 +241,97 @@ struct acpi_s3pt_suspend {/******************************************************************************* * -* GTDT - Generic Timer Description Table (ACPI 5.0) +* GTDT - Generic Timer Description Table (ACPI 5.1) * Version 1 * ******************************************************************************/ struct acpi_table_gtdt {struct acpi_table_header header;/* Common ACPI table header */ -u64 address; -u32 flags; -u32 secure_pl1_interrupt; -u32 secure_pl1_flags; -u32 non_secure_pl1_interrupt; -u32 non_secure_pl1_flags; +u64 cnt_control_base_address; +u32 reserved; +u32 secure_el1_interrupt; +u32 secure_el1_flags; +u32 non_secure_el1_interrupt; +u32 non_secure_el1_flags;u32 virtual_timer_interrupt;u32 virtual_timer_flags; -u32 non_secure_pl2_interrupt; -u32 non_secure_pl2_flags; +u32 non_secure_el2_interrupt; +u32 non_secure_el2_flags; +u64 cnt_read_base_address; +u32 platform_timer_count; +u32 platform_timer_offset; }; -/* Values for Flags field above */ +/* Values for all "TimerFlags" fields above */ -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 +#define ACPI_GTDT_INTERRUPT_MODE ( 1 << 0 ) +#define ACPI_GTDT_INTERRUPT_POLARITY ( 1 << 1 ) -/* Values for all "TimerFlags" fields above */ +#define ACPI_GTDT_ALWAYS_ON ( 1 << 2 ) + +/* Values for GTDT subtable type in struct acpi_subtable_header */ + +enum acpi_gtdt_type { +ACPI_GTDT_TYPE_GT_BLOCK =0 ,/* memory-mapped generic timer */ +ACPI_GTDT_TYPE_SBSA_GENERIC_WATCHDOG =1 , +ACPI_GTDT_TYPE_RESERVED =2 /* 2 and greater are reserved */ +}; + +/* +* GTDT Subtables, correspond to Type in struct acpi_subtable_header +*/ + +/* 0: Generic Timer Block */ + +struct acpi_gtdt_gt_block { +struct acpi_subtable_header header; +u16 reserved; +u64 gt_block_address; +u32 gt_block_timer_count;/* must be less than or equal to 8 */ +u32 gt_block_timer_offset; +}; + +/* GT Block Timer Structure */ + +struct acpi_gt_block_timer { +u8 gt_frame_number; +u8 reseved[3 ]; +u64 cnt_base_address; +u64 cnt_el0_base_adress; +u32 physical_timer_interrupt; +u32 physical_timer_flags; +u32 vitual_timer_interrupt; +u32 vitual_timer_flags; +u32 timer_common_flags; +}; + +/* Flag Definitions: GT Block Physical Timers and Virtual timers */ + +#define ACPI_GT_BLOCK_INTERRUPT_MODE ( 1 << 0 ) +#define ACPI_GT_BLOCK_INTERRUPT_POLARITY ( 1 << 1 ) + +/* Flag Definitions: Common Flags */ + +#define ACPI_GT_BLOCK_IS_SECURE_TIMER ( 1 << 0 ) +#define ACPI_GT_BLOCK_ALWAYS_ON ( 1 << 1 ) + +/* 1: SBSA Generic Watchdog Structure */ + +struct acpi_sbsa_generic_watchdog { +struct acpi_subtable_header header; +u16 reserved; +u64 refresh_frame_address; +u64 control_frame_address; +u32 interrupt; +u32 flags; +}; + +/* Flag Definitions: SBSA Generic Watchdog */ -#define ACPI_GTDT_INTERRUPT_MODE 1 -#define ACPI_GTDT_INTERRUPT_POLARITY 2 +#define ACPI_SBSA_WATCHDOG_INTERRUPT_MODE ( 1 << 0 ) +#define ACPI_SBSA_WATCHDOG_INTERRUPT_POLARITY ( 1 << 1 ) +#define ACPI_SBSA_WATCHDOG_IS_SECURE_TIMER ( 1 << 2 )/******************************************************************************* *
xen/include/asm-arm/acpi.h +2 -0
@@ -46,4 +46,6 @@ static inline void disable_acpi(void) acpi_disabled = 1; } +#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY ) +#endif /*_ASM_ARM_ACPI_H*/
Signature · 1 line
1.9.1
Re: [PATCH v2 11/41] arm/acpi : add GTDT support updated by ACPI 5.1
Hi Parth,
Quoted 26 lines · Parth Dixit
With ACPI 5.0, we got per-processor timer support in GTDT, and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed for the spec change.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/include/acpi/actbl3.h | 92 +++++++++++++++++++++++++++++++++++++++------- xen/include/asm-arm/acpi.h | 2 + 2 files changed, 80 insertions(+), 14 deletions(-)xen/include/acpi/actbl3.h +1
-1@@ -241,33 +241,97 @@ struct acpi_s3pt_suspend {/******************************************************************************* * -* GTDT - Generic Timer Description Table (ACPI 5.0) +* GTDT - Generic Timer Description Table (ACPI 5.1) * Version 1 * ******************************************************************************/
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 251
Quoted 10 lines
xen/include/acpi/actbl3.h +1
-6struct acpi_table_gtdt {struct acpi_table_header header;/* Common ACPI table header */ -u64 address; -u32 flags; -u32 secure_pl1_interrupt; -u32 secure_pl1_flags; -u32 non_secure_pl1_interrupt; -u32 non_secure_pl1_flags; +u64 cnt_control_base_address;
This patch is out-of-sync compare to the Linux one (naming different, comment...). Can you update it?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 11/41] arm/acpi : add GTDT support updated by ACPI 5.1
Quoted 47 lines · Julien Grall
Hi Parth,
Quoted 10 lines · Parth Dixit
With ACPI 5.0, we got per-processor timer support in GTDT, and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed for the spec change.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/include/acpi/actbl3.h | 92+++++++++++++++++++++++++++++++++++++++-------
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 242
Quoted 10 lines
xen/include/asm-arm/acpi.h | 2 + 2 files changed, 80 insertions(+), 14 deletions(-)xen/include/acpi/actbl3.h +0
-0@@ -241,33 +241,97 @@ struct acpi_s3pt_suspend {/*******************************************************************************
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 248
Quoted 6 lines
xen/include/acpi/actbl3.h +1
-1* -* GTDT - Generic Timer Description Table (ACPI 5.0) +* GTDT - Generic Timer Description Table (ACPI 5.1) * Version 1 * ******************************************************************************/
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 249
Quoted 3 lines
xen/include/acpi/actbl3.h +0
-0struct acpi_table_gtdt {struct acpi_table_header header;/* Common ACPI table header */
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 251
Quoted 7 lines
xen/include/acpi/actbl3.h +1
-6-u64 address; -u32 flags; -u32 secure_pl1_interrupt; -u32 secure_pl1_flags; -u32 non_secure_pl1_interrupt; -u32 non_secure_pl1_flags; +u64 cnt_control_base_address;This patch is out-of-sync compare to the Linux one (naming different, comment...). Can you update it?
Quoted 7 lines
sure, i'll take care in next patchset.
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 11/41] arm/acpi : add GTDT support updated by ACPI 5.1
+shannon
Quoted 59 lines · Parth Dixit
Quoted 34 lines · Julien Grall
Hi Parth,
Quoted 30 lines · Parth Dixit
With ACPI 5.0, we got per-processor timer support in GTDT, and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed for the spec change.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/include/acpi/actbl3.h | 92 +++++++++++++++++++++++++++++++++++++++------- xen/include/asm-arm/acpi.h | 2 + 2 files changed, 80 insertions(+), 14 deletions(-)xen/include/acpi/actbl3.h +1
-1@@ -241,33 +241,97 @@ struct acpi_s3pt_suspend {/******************************************************************************* * -* GTDT - Generic Timer Description Table (ACPI 5.0) +* GTDT - Generic Timer Description Table (ACPI 5.1) * Version 1 * ******************************************************************************/ Quoted 14 lines
xen/include/acpi/actbl3.h struct acpi_s3pt_suspend { · line 251
Quoted 10 lines
xen/include/acpi/actbl3.h +0
-0struct acpi_table_gtdt {struct acpi_table_header header;/* Common ACPI table header */
xen/include/acpi/actbl3.h +1
-6-u64 address; -u32 flags; -u32 secure_pl1_interrupt; -u32 secure_pl1_flags; -u32 non_secure_pl1_interrupt; -u32 non_secure_pl1_flags; +u64 cnt_control_base_address;This patch is out-of-sync compare to the Linux one (naming different, comment...). Can you update it?
sure, i'll take care in next patchset.
Quoted 5 lines
Regards,
--
Julien Grall
PATCH v2 12/41 arm : move dt specific code in smp to seperate functions
In reply to Parth Dixitpartition smp initialization functions into generic and dt specific parts, this will be useful when introducing new functions for smp initialization based on acpi
--- xen/arch/arm/arm64/smpboot.c | 7 ++++++- xen/arch/arm/smpboot.c | 28 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-)
xen/arch/arm/arm64/smpboot.c +6 -1
@@ -70,7 +70,7 @@ int __init arch_smp_init(void)return 0 ; } -int __init arch_cpu_init (int cpu,struct dt_device_node *dn) +static int __init dt_arch_cpu_init (int cpu,struct dt_device_node *dn) {const char *enable_method;
@@ -94,6 +94,11 @@ int __init arch_cpu_init(int cpu, struct dt_device_node *dn)return 0 ; } +int __init arch_cpu_init (int cpu,struct dt_device_node *dn) +{ +return dt_arch_cpu_init (cpu, dn); +} +int __init arch_cpu_up (int cpu) {if ( !smp_enable_ops[cpu].prepare_cpu )
xen/arch/arm/smpboot.c +17 -11
@@ -92,7 +92,7 @@ smp_clear_cpu_maps (void)* MPIDR values related to logical cpus * Code base on Linux arch/arm/kernel/devtree.c */ -void __init smp_init_cpus (void ) +static void __init dt_smp_init_cpus (void ) {register_t mpidr;struct dt_device_node *cpus =dt_find_node_by_path ("/cpus" );
@@ -106,16 +106,6 @@ void __init smp_init_cpus(void)bool_t bootcpu_valid =0 ;int rc; -/* scan the DTB for a PSCI node and set a global variable */ -psci_init (); - -if ( (rc =arch_smp_init ()) <0 ) - { -printk (XENLOG_WARNING "SMP init failed (%d)\n" -"Using only 1 CPU\n" , rc); -return ; - } - mpidr = boot_cpu_data.mpidr.bits &MPIDR_HWID_MASK ;if ( !cpus )
@@ -243,6 +233,22 @@ void __init smp_init_cpus(void) } } +void __init smp_init_cpus (void ) +{ +int rc; +/* initialize PSCI and set a global variable */ +psci_init (); + +if ( (rc =arch_smp_init ()) <0 ) + { +printk (XENLOG_WARNING "SMP init failed (%d)\n" +"Using only 1 CPU\n" , rc); +return ; + } + +dt_smp_init_cpus (); +} +int __init smp_get_max_cpus (void ) {
Signature · 1 line
1.9.1
Re: [PATCH v2 12/41] arm : move dt specific code in smp to seperate functions
Hi Parth,
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 238
Quoted 3 lines · Parth Dixit
xen/arch/arm/smpboot.c +3
-0+void __init smp_init_cpus (void ) +{ +int rc;
Missing blank line here.
Quoted 7 lines
xen/arch/arm/smpboot.c +6
-0+/* initialize PSCI and set a global variable */ +psci_init (); + +if ( (rc =arch_smp_init ()) <0 ) + { + printk(XENLOG_WARNING "SMP init failed (%d)\n"
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 254
Quoted 10 lines
xen/arch/arm/smpboot.c +7
-0+ "Using only 1 CPU\n", rc); +return ; + } + +dt_smp_init_cpus (); +} +int __init smp_get_max_cpus (void ) {
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 12/41] arm : move dt specific code in smp to seperate functions
+shannon
Quoted 32 lines · Julien Grall
Hi Parth,
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 238
Quoted 3 lines · Parth Dixit
xen/arch/arm/smpboot.c +3
-0+void __init smp_init_cpus (void ) +{ +int rc;Missing blank line here.
Quoted 7 lines
xen/arch/arm/smpboot.c +6
-0+/* initialize PSCI and set a global variable */ +psci_init (); + +if ( (rc =arch_smp_init ()) <0 ) + { + printk(XENLOG_WARNING "SMP init failed (%d)\n"xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 254
Quoted 10 lines
xen/arch/arm/smpboot.c +7
-0+ "Using only 1 CPU\n", rc); +return ; + } + +dt_smp_init_cpus (); +} +int __init smp_get_max_cpus (void ) {Regards,
--
Julien Grall
PATCH v2 13/41 arm/acpi : parse MADT to map logical cpu to MPIDR and get cpu_possible_map
In reply to Parth DixitMADT contains the information for MPIDR which is essential for SMP initialization, parse the GIC cpu interface structures to get the MPIDR value and map it to cpu_logical_map(), and add enabled cpu with valid MPIDR into cpu_possible_map.
--- xen/arch/arm/acpi/boot.c | 135 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/smpboot.c | 7 ++- xen/arch/arm/psci.c | 16 +++++ xen/arch/arm/smpboot.c | 7 ++- xen/include/asm-arm/acpi.h | 2 + xen/include/xen/acpi.h | 5 ++ 6 files changed, 170 insertions(+), 2 deletions(-)
xen/arch/arm/acpi/boot.c +135 -0
@@ -29,6 +29,141 @@#include <xen/mm.h> #include <asm/acpi.h> +#include <asm/smp.h> + +/* Processors with enabled flag and sane MPIDR */ +static int enabled_cpus; + +/* Boot CPU is valid or not in MADT */ +static bool_t __initdata bootcpu_valid; + +/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ +static unsigned int total_cpus =0 ; + +/* +* acpi_map_gic_cpu_interface - generates a logical cpu number +* and map to MPIDR represented by GICC structure +* @mpidr: CPU's hardware id to register, MPIDR represented in MADT +* @enabled: this cpu is enabled or not +* +* Returns the logical cpu number which maps to MPIDR +*/ +static int __init acpi_map_gic_cpu_interface (u64 mpidr,u8 enabled) +{ +int i; + +if ( mpidr ==MPIDR_INVALID ) + { +printk ("Skip MADT cpu entry with invalid MPIDR\n" ); +return -EINVAL ; + } + + total_cpus++; +if ( !enabled ) +return -EINVAL ; + +if ( enabled_cpus >=NR_CPUS ) + { +printk ("NR_CPUS limit of %d reached, Processor %d/0x%" PRIx64" ignored.\n" , +NR_CPUS , total_cpus, mpidr); +return -EINVAL ; + } + +/* Check if GICC structure of boot CPU is available in the MADT */ +if (cpu_logical_map (0 ) == mpidr ) + { +if ( bootcpu_valid ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + + bootcpu_valid = TRUE; + } + +/* +* Duplicate MPIDRs are a recipe for disaster. Scan +* all initialized entries and check for +* duplicates. If any is found just ignore the CPU. +*/ +for ( i =1 ; i < enabled_cpus; i++ ) + { +if (cpu_logical_map (i) == mpidr ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + } + +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ; + +/* CPU 0 was already initialized */ +if ( enabled_cpus ) + { +if (arch_cpu_init (enabled_cpus,NULL ) <0 ) +return -EOPNOTSUPP ; + +/* map the logical cpu id to cpu MPIDR */ +cpu_logical_map (enabled_cpus) = mpidr; + } + + enabled_cpus++; +return enabled_cpus; +} + +static int __init +acpi_parse_gic_cpu_interface (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end) ) +return -EINVAL ; + +acpi_table_print_madt_entry (header); + +acpi_map_gic_cpu_interface (processor->mpidr &MPIDR_HWID_MASK , + processor->flags &ACPI_MADT_ENABLED ); + +return 0 ; +} + +/* Parse GIC cpu interface entries in MADT for SMP init */ +void __init acpi_init_cpus (void ) +{ +int count, i; + +/* +* do a partial walk of MADT to determine how many CPUs +* we have including disabled CPUs, and get information +* we need for SMP init +*/ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + acpi_parse_gic_cpu_interface,0 ); + +if ( count <0 ) + { +printk ("Error parsing GIC CPU interface entry\n" ); +return ; + } + +if ( !bootcpu_valid ) + { +printk ("MADT missing boot CPU MPIDR, not enabling secondaries\n" ); +return ; + } + +for ( i =0 ; i < enabled_cpus; i++ ) +cpumask_set_cpu (i, &cpu_possible_map); + +/* Make boot-up look pretty */ +printk ("%d CPUs enabled, %d CPUs total\n" , enabled_cpus, total_cpus); +}static int __init acpi_parse_fadt (struct acpi_table_header *table) {
xen/arch/arm/arm64/smpboot.c +6 -1
@@ -7,6 +7,7 @@#include <xen/vmap.h> #include <asm/io.h> #include <asm/psci.h> +#include <asm/acpi.h> struct smp_enable_ops {int (*prepare_cpu)(int );
@@ -94,9 +95,13 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)return 0 ; } +/* acpi only supports psci at present */ int __init arch_cpu_init (int cpu,struct dt_device_node *dn) { -return dt_arch_cpu_init (cpu, dn); +if ( acpi_disabled ) +return dt_arch_cpu_init (cpu, dn); +else +return smp_psci_init (cpu); }int __init arch_cpu_up (int cpu)
xen/arch/arm/psci.c +16 -0
@@ -22,6 +22,7 @@#include <xen/mm.h> #include <xen/smp.h> #include <asm/psci.h> +#include <asm/acpi.h> uint32_t psci_ver;
@@ -74,6 +75,9 @@ int __init psci_init_0_1(void)int ret;const struct dt_device_node *psci; +if ( !acpi_disabled ) +return -EINVAL ; + psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci" );if ( !psci )return -EOPNOTSUPP ;
@@ -98,6 +102,9 @@ int __init psci_init_0_1(void)int __init psci_init_0_2 (void ) {int ret; + +if ( acpi_disabled ) + {const struct dt_device_node *psci; psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci-0.2" );
@@ -107,6 +114,15 @@ int __init psci_init_0_2(void) ret =psci_is_smc_method (psci);if ( ret )return -EINVAL ; + } +else + { +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ; + +if (acpi_psci_hvc_present () ) +return -EINVAL ; + } psci_ver =call_smc (PSCI_0_2_FN_PSCI_VERSION ,0 ,0 ,0 );
xen/arch/arm/smpboot.c +6 -1
@@ -31,6 +31,7 @@#include <xen/console.h> #include <asm/gic.h> #include <asm/psci.h> +#include <asm/acpi.h> cpumask_t cpu_online_map;cpumask_t cpu_present_map;
@@ -246,7 +247,11 @@ void __init smp_init_cpus(void)return ; } -dt_smp_init_cpus (); +if ( acpi_disabled ) +dt_smp_init_cpus (); +else +acpi_init_cpus (); + }int __init
xen/include/asm-arm/acpi.h +2 -0
@@ -35,9 +35,11 @@ extern bool_t acpi_disabled;bool_t acpi_psci_present (void );/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void ); +void __init acpi_init_cpus (void );#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; } +static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */
xen/include/xen/acpi.h +5 -0
@@ -40,6 +40,10 @@#define ACPI_MADT_GET_POLARITY (inti) ACPI_MADT_GET_(POLARITY, inti)#define ACPI_MADT_GET_TRIGGER (inti) ACPI_MADT_GET_(TRIGGER, inti) +#define BAD_MADT_ENTRY (entry, end) ( \ + (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ + ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) +#ifdef CONFIG_ACPI_BOOT enum acpi_interrupt_id {
@@ -57,6 +61,7 @@ typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, covoid __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size); +unsigned int acpi_get_processor_id (unsigned int cpu);char *__acpi_map_table (paddr_t phys_addr,unsigned long size);int acpi_boot_init (void );
Signature · 1 line
1.9.1
Re: [PATCH v2 13/41] arm/acpi : parse MADT to map logical cpu to MPIDR and get cpu_possible_map
xen/include/xen/acpi.h line 45
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/include/xen/acpi.h +3
-0@@ -40,6 +40,10 @@#define ACPI_MADT_GET_POLARITY (inti) ACPI_MADT_GET_(POLARITY, inti)#define ACPI_MADT_GET_TRIGGER (inti) ACPI_MADT_GET_(TRIGGER, inti) +#define BAD_MADT_ENTRY (entry, end) ( \ + (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ + ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
This shouldn't be added here without the original getting removed from xen/arch/x86/acpi/boot.c. And the latest when moving this to a global header it needs to be properly parenthesized.
Jan
Re: [PATCH v2 13/41] arm/acpi : parse MADT to map logical cpu to MPIDR and get cpu_possible_map
In reply to Parth DixitHi Parth,
Quoted 9 lines · Parth Dixit
MADT contains the information for MPIDR which is essential for SMP initialization, parse the GIC cpu interface structures to get the MPIDR value and map it to
cpu_logical_map(), and add enabled cpu with valid MPIDR intocpu_possible_map.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>
This patch looks very similar to Linux. Unless you say that we have to diverge, I would prefer if you important the patch as it is from Linux (i.e no coding style changes, stubbing out necessary code) and modify only a little bit.
It will be easier to backport fixes from Linux. There are other patches where this comment apply.
Also, please check that we are using the latest version of the patch.
Quoted 17 lines
--- xen/arch/arm/acpi/boot.c | 135 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/smpboot.c | 7 ++- xen/arch/arm/psci.c | 16 +++++ xen/arch/arm/smpboot.c | 7 ++- xen/include/asm-arm/acpi.h | 2 + xen/include/xen/acpi.h | 5 ++ 6 files changed, 170 insertions(+), 2 deletions(-)xen/arch/arm/acpi/boot.c +0
-0@@ -29,6 +29,141 @@#include <xen/mm.h> #include <asm/acpi.h>
xen/arch/arm/acpi/boot.c line 41
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+#include <asm/smp.h> + +/* Processors with enabled flag and sane MPIDR */ +static int enabled_cpus; + +/* Boot CPU is valid or not in MADT */ +static bool_t __initdata bootcpu_valid; + +/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ +static unsigned int total_cpus =0 ;
Given the usage within this file, the comment is wrong.
Also, please add __init as it's only used during initialization.
xen/arch/arm/acpi/boot.c line 51
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+ +/* +* acpi_map_gic_cpu_interface - generates a logical cpu number +* and map to MPIDR represented by GICC structure +* @mpidr: CPU's hardware id to register, MPIDR represented in MADT +* @enabled: this cpu is enabled or not +* +* Returns the logical cpu number which maps to MPIDR +*/ +static int __init acpi_map_gic_cpu_interface (u64 mpidr,u8 enabled)
You never use the return value. Please make this function void.
xen/arch/arm/acpi/boot.c line 63
Quoted 12 lines
xen/arch/arm/acpi/boot.c +12
-0+{ +int i; + +if ( mpidr ==MPIDR_INVALID ) + { +printk ("Skip MADT cpu entry with invalid MPIDR\n" ); +return -EINVAL ; + } + + total_cpus++; +if ( !enabled ) +return -EINVAL ;
You are skipping the CPU if it's not enabled. How would that fit with CPU hotplug?
It looks like that on x86 we allocate disabled CPUs in the possible map (see acpi_parse_lapic in arch/x86/acpi/boot.c).
Quoted 40 lines
xen/arch/arm/acpi/boot.c +40
-0+ +if ( enabled_cpus >=NR_CPUS ) + { +printk ("NR_CPUS limit of %d reached, Processor %d/0x%" PRIx64" ignored.\n" , +NR_CPUS , total_cpus, mpidr); +return -EINVAL ; + } + +/* Check if GICC structure of boot CPU is available in the MADT */ +if (cpu_logical_map (0 ) == mpidr ) + { +if ( bootcpu_valid ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + + bootcpu_valid = TRUE; + } + +/* +* Duplicate MPIDRs are a recipe for disaster. Scan +* all initialized entries and check for +* duplicates. If any is found just ignore the CPU. +*/ +for ( i =1 ; i < enabled_cpus; i++ ) + { +if (cpu_logical_map (i) == mpidr ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + } + +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ; + +/* CPU 0 was already initialized */
xen/arch/arm/acpi/boot.c line 113
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+if ( enabled_cpus ) + { +if (arch_cpu_init (enabled_cpus,NULL ) <0 ) +return -EOPNOTSUPP ; + +/* map the logical cpu id to cpu MPIDR */ +cpu_logical_map (enabled_cpus) = mpidr; + } + + enabled_cpus++;
Missing new line.
xen/arch/arm/acpi/boot.c line 119
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+return enabled_cpus; +} + +static int __init +acpi_parse_gic_cpu_interface (struct acpi_subtable_header *header, +const unsigned long end)
The indentation looks wrong.
xen/arch/arm/acpi/boot.c line 131
Quoted 12 lines
xen/arch/arm/acpi/boot.c +12
-0+{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end) ) +return -EINVAL ; + +acpi_table_print_madt_entry (header); + +acpi_map_gic_cpu_interface (processor->mpidr &MPIDR_HWID_MASK , + processor->flags &ACPI_MADT_ENABLED );
It would be cleaner if you pass directly processor to the function (as Linux does).
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ +return 0 ; +} + +/* Parse GIC cpu interface entries in MADT for SMP init */ +void __init acpi_init_cpus (void )
xen/arch/arm/acpi/boot.c line 147
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+{ +int count, i; + +/* +* do a partial walk of MADT to determine how many CPUs +* we have including disabled CPUs, and get information +* we need for SMP init +*/ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + acpi_parse_gic_cpu_interface,0 );
Wrong indentation.
xen/arch/arm/acpi/boot.c line 153
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ +if ( count <0 ) + { +printk ("Error parsing GIC CPU interface entry\n" ); +return ; + }
What about the case where count == 0?
xen/arch/arm/arm64/smpboot.c
Quoted 20 lines
xen/arch/arm/acpi/boot.c +13
-0+ +if ( !bootcpu_valid ) + { +printk ("MADT missing boot CPU MPIDR, not enabling secondaries\n" ); +return ; + } + +for ( i =0 ; i < enabled_cpus; i++ ) +cpumask_set_cpu (i, &cpu_possible_map); + +/* Make boot-up look pretty */ +printk ("%d CPUs enabled, %d CPUs total\n" , enabled_cpus, total_cpus); +}static int __init acpi_parse_fadt (struct acpi_table_header *table) {xen/arch/arm/arm64/smpboot.c +0
-0
All the changes within this file and arm/psci.c is not mentioned in the commit message.
As it's related to this patch, it would be better to have a separate patch for it.
xen/arch/arm/arm64/smpboot.c static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn) · line 98
Quoted 13 lines
xen/arch/arm/arm64/smpboot.c +2
-0@@ -7,6 +7,7 @@#include <xen/vmap.h> #include <asm/io.h> #include <asm/psci.h> +#include <asm/acpi.h> struct smp_enable_ops {int (*prepare_cpu)(int );@@ -94,9 +95,13 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)return 0 ; } +/* acpi only supports psci at present */
This comment should be in the else part below.
Quoted 33 lines
xen/arch/arm/arm64/smpboot.c +4
-1int __init arch_cpu_init (int cpu,struct dt_device_node *dn) { -return dt_arch_cpu_init (cpu, dn); +if ( acpi_disabled ) +return dt_arch_cpu_init (cpu, dn); +else +return smp_psci_init (cpu); }int __init arch_cpu_up (int cpu)xen/arch/arm/psci.c +4
-0@@ -22,6 +22,7 @@#include <xen/mm.h> #include <xen/smp.h> #include <asm/psci.h> +#include <asm/acpi.h> uint32_t psci_ver;@@ -74,6 +75,9 @@ int __init psci_init_0_1(void)int ret;const struct dt_device_node *psci; +if ( !acpi_disabled ) +return -EINVAL ; + psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci" );if ( !psci )return -EOPNOTSUPP ;
xen/arch/arm/psci.c int __init psci_init_0_1(void) · line 108
Quoted 7 lines
xen/arch/arm/psci.c +3
-0@@ -98,6 +102,9 @@ int __init psci_init_0_1(void)int __init psci_init_0_2 (void ) {int ret; + +if ( acpi_disabled ) + {const struct dt_device_node *psci;
The block within the if should be indented correctly. Although, why didn't you refactor the code as you did on some other part?
xen/arch/arm/psci.c int __init psci_init_0_2(void) · line 121
Quoted 10 lines
xen/arch/arm/psci.c +5
-0psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci-0.2" );@@ -107,6 +114,15 @@ int __init psci_init_0_2(void) ret =psci_is_smc_method (psci);if ( ret )return -EINVAL ; + } +else + { +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ;
This should be done in psci_init and not here.
Quoted 64 lines
xen/arch/arm/psci.c +4
-0+ +if (acpi_psci_hvc_present () ) +return -EINVAL ; + } psci_ver =call_smc (PSCI_0_2_FN_PSCI_VERSION ,0 ,0 ,0 );xen/arch/arm/smpboot.c +6
-1@@ -31,6 +31,7 @@#include <xen/console.h> #include <asm/gic.h> #include <asm/psci.h> +#include <asm/acpi.h> cpumask_t cpu_online_map;cpumask_t cpu_present_map;@@ -246,7 +247,11 @@ void __init smp_init_cpus(void)return ; } -dt_smp_init_cpus (); +if ( acpi_disabled ) +dt_smp_init_cpus (); +else +acpi_init_cpus (); + }int __init xen/include/asm-arm/acpi.h +2
-0@@ -35,9 +35,11 @@ extern bool_t acpi_disabled;bool_t acpi_psci_present (void );/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void ); +void __init acpi_init_cpus (void );#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; } +static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */ xen/include/xen/acpi.h +4
-0@@ -40,6 +40,10 @@#define ACPI_MADT_GET_POLARITY (inti) ACPI_MADT_GET_(POLARITY, inti)#define ACPI_MADT_GET_TRIGGER (inti) ACPI_MADT_GET_(TRIGGER, inti) +#define BAD_MADT_ENTRY (entry, end) ( \ + (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ + ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) +#ifdef CONFIG_ACPI_BOOT enum acpi_interrupt_id {
xen/include/xen/acpi.h typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, co · line 64
Quoted 4 lines
xen/include/xen/acpi.h +1
-0@@ -57,6 +61,7 @@ typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, covoid __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size); +
Spurious change
xen/include/xen/acpi.h typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, co · line 67
Quoted 4 lines
xen/include/xen/acpi.h +0
-0unsigned int acpi_get_processor_id (unsigned int cpu);char *__acpi_map_table (paddr_t phys_addr,unsigned long size);int acpi_boot_init (void );
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 13/41] arm/acpi : parse MADT to map logical cpu to MPIDR and get cpu_possible_map
+shannon
Quoted 374 lines · Julien Grall
Hi Parth,
Quoted 9 lines · Parth Dixit
MADT contains the information for MPIDR which is essential for SMP initialization, parse the GIC cpu interface structures to get the MPIDR value and map it to
cpu_logical_map(), and add enabled cpu with valid MPIDR intocpu_possible_map.Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>This patch looks very similar to Linux. Unless you say that we have to diverge, I would prefer if you important the patch as it is from Linux (i.e no coding style changes, stubbing out necessary code) and modify only a little bit.
It will be easier to backport fixes from Linux. There are other patches where this comment apply.
Also, please check that we are using the latest version of the patch.
Quoted 17 lines
--- xen/arch/arm/acpi/boot.c | 135 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/smpboot.c | 7 ++- xen/arch/arm/psci.c | 16 +++++ xen/arch/arm/smpboot.c | 7 ++- xen/include/asm-arm/acpi.h | 2 + xen/include/xen/acpi.h | 5 ++ 6 files changed, 170 insertions(+), 2 deletions(-)xen/arch/arm/acpi/boot.c +0
-0@@ -29,6 +29,141 @@#include <xen/mm.h> #include <asm/acpi.h> xen/arch/arm/acpi/boot.c line 41
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+#include <asm/smp.h> + +/* Processors with enabled flag and sane MPIDR */ +static int enabled_cpus; + +/* Boot CPU is valid or not in MADT */ +static bool_t __initdata bootcpu_valid; + +/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ +static unsigned int total_cpus =0 ;Given the usage within this file, the comment is wrong.
Also, please add
__initas it's only used during initialization.xen/arch/arm/acpi/boot.c line 51
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+ +/* +* acpi_map_gic_cpu_interface - generates a logical cpu number +* and map to MPIDR represented by GICC structure +* @mpidr: CPU's hardware id to register, MPIDR represented in MADT +* @enabled: this cpu is enabled or not +* +* Returns the logical cpu number which maps to MPIDR +*/ +static int __init acpi_map_gic_cpu_interface (u64 mpidr,u8 enabled)You never use the return value. Please make this function void.
xen/arch/arm/acpi/boot.c line 63
Quoted 12 lines
xen/arch/arm/acpi/boot.c +12
-0+{ +int i; + +if ( mpidr ==MPIDR_INVALID ) + { +printk ("Skip MADT cpu entry with invalid MPIDR\n" ); +return -EINVAL ; + } + + total_cpus++; +if ( !enabled ) +return -EINVAL ;You are skipping the CPU if it's not enabled. How would that fit with CPU hotplug?
It looks like that on x86 we allocate disabled CPUs in the possible map (see
acpi_parse_lapicinarch/x86/acpi/boot.c).Quoted 40 lines
xen/arch/arm/acpi/boot.c +40
-0+ +if ( enabled_cpus >=NR_CPUS ) + { +printk ("NR_CPUS limit of %d reached, Processor %d/0x%" PRIx64" ignored.\n" , +NR_CPUS , total_cpus, mpidr); +return -EINVAL ; + } + +/* Check if GICC structure of boot CPU is available in the MADT */ +if (cpu_logical_map (0 ) == mpidr ) + { +if ( bootcpu_valid ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + + bootcpu_valid = TRUE; + } + +/* +* Duplicate MPIDRs are a recipe for disaster. Scan +* all initialized entries and check for +* duplicates. If any is found just ignore the CPU. +*/ +for ( i =1 ; i < enabled_cpus; i++ ) + { +if (cpu_logical_map (i) == mpidr ) + { +printk ("Firmware bug, duplicate CPU MPIDR: 0x%" PRIx64" in MADT\n" , + mpidr); +return -EINVAL ; + } + } + +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ; + +/* CPU 0 was already initialized */ xen/arch/arm/acpi/boot.c line 113
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+if ( enabled_cpus ) + { +if (arch_cpu_init (enabled_cpus,NULL ) <0 ) +return -EOPNOTSUPP ; + +/* map the logical cpu id to cpu MPIDR */ +cpu_logical_map (enabled_cpus) = mpidr; + } + + enabled_cpus++;Missing new line.
xen/arch/arm/acpi/boot.c line 119
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+return enabled_cpus; +} + +static int __init +acpi_parse_gic_cpu_interface (struct acpi_subtable_header *header, +const unsigned long end)The indentation looks wrong.
xen/arch/arm/acpi/boot.c line 131
Quoted 12 lines
xen/arch/arm/acpi/boot.c +12
-0+{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end) ) +return -EINVAL ; + +acpi_table_print_madt_entry (header); + +acpi_map_gic_cpu_interface (processor->mpidr &MPIDR_HWID_MASK , + processor->flags &ACPI_MADT_ENABLED );It would be cleaner if you pass directly processor to the function (as Linux does).
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ +return 0 ; +} + +/* Parse GIC cpu interface entries in MADT for SMP init */ +void __init acpi_init_cpus (void )xen/arch/arm/acpi/boot.c line 147
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+{ +int count, i; + +/* +* do a partial walk of MADT to determine how many CPUs +* we have including disabled CPUs, and get information +* we need for SMP init +*/ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + acpi_parse_gic_cpu_interface,0 );Wrong indentation.
xen/arch/arm/acpi/boot.c line 153
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ +if ( count <0 ) + { +printk ("Error parsing GIC CPU interface entry\n" ); +return ; + }What about the case where count == 0?
xen/arch/arm/arm64/smpboot.c
Quoted 20 lines
xen/arch/arm/acpi/boot.c +13
-0+ +if ( !bootcpu_valid ) + { +printk ("MADT missing boot CPU MPIDR, not enabling secondaries\n" ); +return ; + } + +for ( i =0 ; i < enabled_cpus; i++ ) +cpumask_set_cpu (i, &cpu_possible_map); + +/* Make boot-up look pretty */ +printk ("%d CPUs enabled, %d CPUs total\n" , enabled_cpus, total_cpus); +}static int __init acpi_parse_fadt (struct acpi_table_header *table) {xen/arch/arm/arm64/smpboot.c +0
-0All the changes within this file and
arm/psci.cis not mentioned in the commit message.As it's related to this patch, it would be better to have a separate patch for it.
xen/arch/arm/arm64/smpboot.c static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn) · line 98
Quoted 13 lines
xen/arch/arm/arm64/smpboot.c +2
-0@@ -7,6 +7,7 @@#include <xen/vmap.h> #include <asm/io.h> #include <asm/psci.h> +#include <asm/acpi.h> struct smp_enable_ops {int (*prepare_cpu)(int );@@ -94,9 +95,13 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)return 0 ; } +/* acpi only supports psci at present */ This comment should be in the else part below.
Quoted 33 lines
xen/arch/arm/arm64/smpboot.c +4
-1int __init arch_cpu_init (int cpu,struct dt_device_node *dn) { -return dt_arch_cpu_init (cpu, dn); +if ( acpi_disabled ) +return dt_arch_cpu_init (cpu, dn); +else +return smp_psci_init (cpu); }int __init arch_cpu_up (int cpu)xen/arch/arm/psci.c +4
-0@@ -22,6 +22,7 @@#include <xen/mm.h> #include <xen/smp.h> #include <asm/psci.h> +#include <asm/acpi.h> uint32_t psci_ver;@@ -74,6 +75,9 @@ int __init psci_init_0_1(void)int ret;const struct dt_device_node *psci; +if ( !acpi_disabled ) +return -EINVAL ; + psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci" );if ( !psci )return -EOPNOTSUPP ;xen/arch/arm/psci.c int __init psci_init_0_1(void) · line 108
Quoted 7 lines
xen/arch/arm/psci.c +3
-0@@ -98,6 +102,9 @@ int __init psci_init_0_1(void)int __init psci_init_0_2 (void ) {int ret; + +if ( acpi_disabled ) + {const struct dt_device_node *psci;The block within the if should be indented correctly. Although, why didn't you refactor the code as you did on some other part?
xen/arch/arm/psci.c int __init psci_init_0_2(void) · line 121
Quoted 10 lines
xen/arch/arm/psci.c +5
-0psci =dt_find_compatible_node (NULL ,NULL ,"arm,psci-0.2" );@@ -107,6 +114,15 @@ int __init psci_init_0_2(void) ret =psci_is_smc_method (psci);if ( ret )return -EINVAL ; + } +else + { +if ( !acpi_psci_present () ) +return -EOPNOTSUPP ;This should be done in
psci_initand not here.Quoted 64 lines
xen/arch/arm/psci.c +4
-0+ +if (acpi_psci_hvc_present () ) +return -EINVAL ; + } psci_ver =call_smc (PSCI_0_2_FN_PSCI_VERSION ,0 ,0 ,0 );xen/arch/arm/smpboot.c +6
-1@@ -31,6 +31,7 @@#include <xen/console.h> #include <asm/gic.h> #include <asm/psci.h> +#include <asm/acpi.h> cpumask_t cpu_online_map;cpumask_t cpu_present_map;@@ -246,7 +247,11 @@ void __init smp_init_cpus(void)return ; } -dt_smp_init_cpus (); +if ( acpi_disabled ) +dt_smp_init_cpus (); +else +acpi_init_cpus (); + }int __init xen/include/asm-arm/acpi.h +2
-0@@ -35,9 +35,11 @@ extern bool_t acpi_disabled;bool_t acpi_psci_present (void );/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void ); +void __init acpi_init_cpus (void );#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; } +static inline void acpi_init_cpus (void ) { }#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */ xen/include/xen/acpi.h +4
-0@@ -40,6 +40,10 @@#define ACPI_MADT_GET_POLARITY (inti) ACPI_MADT_GET_(POLARITY, inti)#define ACPI_MADT_GET_TRIGGER (inti) ACPI_MADT_GET_(TRIGGER, inti) +#define BAD_MADT_ENTRY (entry, end) ( \ + (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ + ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) +#ifdef CONFIG_ACPI_BOOT enum acpi_interrupt_id {xen/include/xen/acpi.h typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, co · line 64
Quoted 4 lines
xen/include/xen/acpi.h +1
-0@@ -57,6 +61,7 @@ typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, covoid __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size); +Spurious change
xen/include/xen/acpi.h typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, co · line 67
Quoted 4 lines
xen/include/xen/acpi.h +0
-0unsigned int acpi_get_processor_id (unsigned int cpu);char *__acpi_map_table (paddr_t phys_addr,unsigned long size);int acpi_boot_init (void );Regards,
--
Julien Grall
PATCH v2 14/41 arm : acpi add helper function for setting interrupt type
In reply to Parth Dixitset edge/level type information for an interrupt
--- xen/arch/arm/irq.c | 17 +++++++++++++++++ xen/include/asm-arm/acpi.h | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/irq.h | 2 ++ 3 files changed, 45 insertions(+)
xen/arch/arm/irq.c +17 -0
@@ -679,6 +679,23 @@ int platform_get_irq(const struct dt_device_node *device, int index)return irq; } +int set_irq_type (int irq,int type) +{ +int res; + +/* Setup the IRQ type */ +if ( irq <NR_LOCAL_IRQS ) + res =irq_local_set_type (irq, type); +else + res =irq_set_spi_type (irq, type); + +if ( res ) +return -1 ; + +return 0 ; + +} +/* * Local variables: * mode: C
xen/include/asm-arm/acpi.h +26 -0
@@ -50,4 +50,30 @@ static inline void disable_acpi(void)#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY ) +/** +* IRQ line type. +* +* ACPI_IRQ_TYPE_NONE - default, unspecified type +* ACPI_IRQ_TYPE_EDGE_RISING - rising edge triggered +* ACPI_IRQ_TYPE_EDGE_FALLING - falling edge triggered +* ACPI_IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered +* ACPI_IRQ_TYPE_LEVEL_HIGH - high level triggered +* ACPI_IRQ_TYPE_LEVEL_LOW - low level triggered +* ACPI_IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits +* ACPI_IRQ_TYPE_SENSE_MASK - Mask for all the above bits +* ACPI_IRQ_TYPE_INVALID - Use to initialize the type +*/ +#define ACPI_IRQ_TYPE_NONE 0x00000000 +#define ACPI_IRQ_TYPE_EDGE_RISING 0x00000001 +#define ACPI_IRQ_TYPE_EDGE_FALLING 0x00000002 +#define ACPI_IRQ_TYPE_EDGE_BOTH \ + (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING) +#define ACPI_IRQ_TYPE_LEVEL_HIGH 0x00000004 +#define ACPI_IRQ_TYPE_LEVEL_LOW 0x00000008 +#define ACPI_IRQ_TYPE_LEVEL_MASK \ + (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH) +#define ACPI_IRQ_TYPE_SENSE_MASK 0x0000000f + +#define ACPI_IRQ_TYPE_INVALID 0x00000010 +#endif /*_ASM_ARM_ACPI_H*/
xen/include/asm-arm/irq.h +2 -0
@@ -51,6 +51,8 @@ void arch_move_irqs(struct vcpu *v);/* Set IRQ type for an SPI */ int irq_set_spi_type (unsigned int spi,unsigned int type); +int set_irq_type (int irq,int type); +int platform_get_irq (const struct dt_device_node *device,int index);void irq_set_affinity (struct irq_desc *desc,const cpumask_t *cpu_mask);
Signature · 1 line
1.9.1
Re: [PATCH v2 14/41] arm : acpi add helper function for setting interrupt type
Hi,
Quoted 14 lines · Parth Dixit
set edge/level type information for an interrupt
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/irq.c | 17 +++++++++++++++++ xen/include/asm-arm/acpi.h | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/irq.h | 2 ++ 3 files changed, 45 insertions(+)xen/arch/arm/irq.c +0
-0
xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 682
Quoted 4 lines
xen/arch/arm/irq.c +1
-0@@ -679,6 +679,23 @@ int platform_get_irq(const struct dt_device_node *device, int index)return irq; } +int set_irq_type (int irq,int type)
int set_irq_type(unsigned int irq, unsigned int type)
xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 693
Quoted 11 lines
xen/arch/arm/irq.c +11
-0+{ +int res; + +/* Setup the IRQ type */ +if ( irq <NR_LOCAL_IRQS ) + res =irq_local_set_type (irq, type); +else + res =irq_set_spi_type (irq, type); + +if ( res ) +return -1 ;
It would be better to return res which contain a more meaningful error than -1.
xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 698
Quoted 5 lines
xen/arch/arm/irq.c +5
-0+ +return 0 ; + +} +
At the same time, please call this function from platform_get_irq as the code is the same.
Furthermore, please move the function code with the other irq_set_* function and rename it to irq_set_type in order to keep the same naming convention.
Quoted 27 lines
xen/arch/arm/irq.c +0
-0/* * Local variables: * mode: C xen/include/asm-arm/acpi.h +16
-0@@ -50,4 +50,30 @@ static inline void disable_acpi(void)#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY ) +/** +* IRQ line type. +* +* ACPI_IRQ_TYPE_NONE - default, unspecified type +* ACPI_IRQ_TYPE_EDGE_RISING - rising edge triggered +* ACPI_IRQ_TYPE_EDGE_FALLING - falling edge triggered +* ACPI_IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered +* ACPI_IRQ_TYPE_LEVEL_HIGH - high level triggered +* ACPI_IRQ_TYPE_LEVEL_LOW - low level triggered +* ACPI_IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits +* ACPI_IRQ_TYPE_SENSE_MASK - Mask for all the above bits +* ACPI_IRQ_TYPE_INVALID - Use to initialize the type +*/ +#define ACPI_IRQ_TYPE_NONE 0x00000000 +#define ACPI_IRQ_TYPE_EDGE_RISING 0x00000001 +#define ACPI_IRQ_TYPE_EDGE_FALLING 0x00000002
xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 78
Quoted 10 lines
xen/include/asm-arm/acpi.h +10
-0+#define ACPI_IRQ_TYPE_EDGE_BOTH \ + (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING) +#define ACPI_IRQ_TYPE_LEVEL_HIGH 0x00000004 +#define ACPI_IRQ_TYPE_LEVEL_LOW 0x00000008 +#define ACPI_IRQ_TYPE_LEVEL_MASK \ + (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH) +#define ACPI_IRQ_TYPE_SENSE_MASK 0x0000000f + +#define ACPI_IRQ_TYPE_INVALID 0x00000010 +
While having a function to set the type is a good idea. Using a separate set a define and mixing them together is wrong.
In Xen we only care about edge vs level.
Although, if you really want to keep all these types. It should be firmware agnostic.
xen/include/asm-arm/irq.h void arch_move_irqs(struct vcpu *v); · line 54
Quoted 10 lines
xen/include/asm-arm/acpi.h +0
-0#endif /*_ASM_ARM_ACPI_H*/ xen/include/asm-arm/irq.h +1
-0@@ -51,6 +51,8 @@ void arch_move_irqs(struct vcpu *v);/* Set IRQ type for an SPI */ int irq_set_spi_type (unsigned int spi,unsigned int type); +int set_irq_type (int irq,int type);
int set_irq_type(unsigned int irq, unsigned int type);
xen/include/asm-arm/irq.h void arch_move_irqs(struct vcpu *v); · line 58
Quoted 5 lines
xen/include/asm-arm/irq.h +1
-0+int platform_get_irq (const struct dt_device_node *device,int index);void irq_set_affinity (struct irq_desc *desc,const cpumask_t *cpu_mask);
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 14/41] arm : acpi add helper function for setting interrupt type
+shannon
Quoted 123 lines · Julien Grall
Hi,
Quoted 14 lines · Parth Dixit
set edge/level type information for an interrupt
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/irq.c | 17 +++++++++++++++++ xen/include/asm-arm/acpi.h | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/irq.h | 2 ++ 3 files changed, 45 insertions(+)xen/arch/arm/irq.c +0
-0xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 682
Quoted 4 lines
xen/arch/arm/irq.c +1
-0@@ -679,6 +679,23 @@ int platform_get_irq(const struct dt_device_node *device, int index)return irq; } +int set_irq_type (int irq,int type)int
set_irq_type(unsigned int irq, unsigned int type)xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 693
Quoted 11 lines
xen/arch/arm/irq.c +11
-0+{ +int res; + +/* Setup the IRQ type */ +if ( irq <NR_LOCAL_IRQS ) + res =irq_local_set_type (irq, type); +else + res =irq_set_spi_type (irq, type); + +if ( res ) +return -1 ;It would be better to return res which contain a more meaningful error than -1.
xen/arch/arm/irq.c int platform_get_irq(const struct dt_device_node *device, int index) · line 698
Quoted 5 lines
xen/arch/arm/irq.c +5
-0+ +return 0 ; + +} +At the same time, please call this function from
platform_get_irqas the code is the same.Furthermore, please move the function code with the other irq_set_* function and rename it to
irq_set_typein order to keep the same naming convention.Quoted 27 lines
xen/arch/arm/irq.c +0
-0/* * Local variables: * mode: C xen/include/asm-arm/acpi.h +16
-0@@ -50,4 +50,30 @@ static inline void disable_acpi(void)#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY ) +/** +* IRQ line type. +* +* ACPI_IRQ_TYPE_NONE - default, unspecified type +* ACPI_IRQ_TYPE_EDGE_RISING - rising edge triggered +* ACPI_IRQ_TYPE_EDGE_FALLING - falling edge triggered +* ACPI_IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered +* ACPI_IRQ_TYPE_LEVEL_HIGH - high level triggered +* ACPI_IRQ_TYPE_LEVEL_LOW - low level triggered +* ACPI_IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits +* ACPI_IRQ_TYPE_SENSE_MASK - Mask for all the above bits +* ACPI_IRQ_TYPE_INVALID - Use to initialize the type +*/ +#define ACPI_IRQ_TYPE_NONE 0x00000000 +#define ACPI_IRQ_TYPE_EDGE_RISING 0x00000001 +#define ACPI_IRQ_TYPE_EDGE_FALLING 0x00000002xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 78
Quoted 10 lines
xen/include/asm-arm/acpi.h +10
-0+#define ACPI_IRQ_TYPE_EDGE_BOTH \ + (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING) +#define ACPI_IRQ_TYPE_LEVEL_HIGH 0x00000004 +#define ACPI_IRQ_TYPE_LEVEL_LOW 0x00000008 +#define ACPI_IRQ_TYPE_LEVEL_MASK \ + (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH) +#define ACPI_IRQ_TYPE_SENSE_MASK 0x0000000f + +#define ACPI_IRQ_TYPE_INVALID 0x00000010 +While having a function to set the type is a good idea. Using a separate set a define and mixing them together is wrong.
In Xen we only care about edge vs level.
Although, if you really want to keep all these types. It should be firmware agnostic.
xen/include/asm-arm/irq.h void arch_move_irqs(struct vcpu *v); · line 54
Quoted 10 lines
xen/include/asm-arm/acpi.h +0
-0#endif /*_ASM_ARM_ACPI_H*/ xen/include/asm-arm/irq.h +1
-0@@ -51,6 +51,8 @@ void arch_move_irqs(struct vcpu *v);/* Set IRQ type for an SPI */ int irq_set_spi_type (unsigned int spi,unsigned int type); +int set_irq_type (int irq,int type);int
set_irq_type(unsigned int irq, unsigned int type);xen/include/asm-arm/irq.h void arch_move_irqs(struct vcpu *v); · line 58
Quoted 5 lines
xen/include/asm-arm/irq.h +1
-0+int platform_get_irq (const struct dt_device_node *device,int index);void irq_set_affinity (struct irq_desc *desc,const cpumask_t *cpu_mask);Regards,
--
Julien Grall
PATCH v2 15/41 arm : acpi parse GTDT to initialize timer
In reply to Parth DixitParse GTDT (Generic Timer Descriptor Table) to initialize timer. Using the information presented by GTDT to initialize the arch timer (not memory-mapped).
Clear all el2 fields in GTDT table after initialization for passing it to Dom0.
--- xen/arch/arm/acpi/boot.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++---------- xen/include/asm-arm/acpi.h | 2 ++ 3 files changed, 79 insertions(+), 11 deletions(-)
xen/arch/arm/acpi/boot.c +50 -0
@@ -30,6 +30,8 @@#include <asm/acpi.h> #include <asm/smp.h> +#include <asm/irq.h> +#include <asm/time.h> /* Processors with enabled flag and sane MPIDR */ static int enabled_cpus;
@@ -40,6 +42,54 @@ static bool_t __initdata bootcpu_valid;/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ static unsigned int total_cpus =0 ; +/* Initialize per-processor generic timer */ +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]) +{ +int type; +struct acpi_table_gtdt *gtdt=NULL ; +u8 checksum; +static const int GTDT_INTRL_TAB [] = + { +ACPI_IRQ_TYPE_LEVEL_HIGH , +ACPI_IRQ_TYPE_EDGE_RISING , +ACPI_IRQ_TYPE_LEVEL_LOW , +ACPI_IRQ_TYPE_EDGE_FALLING + }; + +acpi_get_table (ACPI_SIG_GTDT ,0 , (struct acpi_table_header **)>dt); + +if ( gtdt ) + { +/* Initialize all the generic timer IRQ variable from GTDT table */ + + type =GTDT_INTRL_TAB [gtdt->non_secure_el1_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->non_secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_NONSECURE_PPI ] = + gtdt->non_secure_el1_interrupt; + + type =GTDT_INTRL_TAB [gtdt->secure_el1_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_SECURE_PPI ] = + gtdt->secure_el1_interrupt; + + type =GTDT_INTRL_TAB [gtdt->non_secure_el2_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->non_secure_el2_interrupt, type); + generic_timer_irq[TIMER_HYP_PPI ] = + gtdt->non_secure_el2_interrupt; + + type =GTDT_INTRL_TAB [gtdt->virtual_timer_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->virtual_timer_interrupt, type); + generic_timer_irq[TIMER_VIRT_PPI ] = + gtdt->virtual_timer_interrupt; + + gtdt->non_secure_el2_interrupt =0 ; + gtdt->non_secure_el2_flags =0 ; + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, gtdt), gtdt->header.length); + gtdt->header.checksum -= checksum; +clean_dcache_va_range (gtdt,sizeof (struct acpi_table_gtdt )); + } +} +/* * acpi_map_gic_cpu_interface - generates a logical cpu number * and map to MPIDR represented by GICC structure
xen/arch/arm/time.c +27 -11
@@ -29,6 +29,7 @@#include <xen/time.h> #include <xen/sched.h> #include <xen/event.h> +#include <xen/acpi.h> #include <asm/system.h> #include <asm/time.h> #include <asm/gic.h>
@@ -64,7 +65,7 @@ unsigned int timer_get_irq(enum timer_ppi ppi)static __initdata struct dt_device_node *timer;/* Set up the timer on the boot CPU (early init function) */ -void __init preinit_xen_time (void ) +static void __init dt_preinit_xen_time (void ) {static const struct dt_device_match timer_ids[]__initconst = {
@@ -72,7 +73,6 @@ void __init preinit_xen_time(void) { /* sentinel */ }, };int res; -u32 rate; timer =dt_find_matching_node (NULL , timer_ids);if ( !timer )
@@ -84,8 +84,21 @@ void __init preinit_xen_time(void)if ( res )panic ("Timer: Cannot initialize platform timer" ); - res =dt_property_read_u32 (timer,"clock-frequency" , &rate); -if ( res ) +} + + + +void __init preinit_xen_time (void ) +{ +u32 rate; + +/* Initialize all the generic timers presented in GTDT */ +if ( acpi_disabled ) +dt_preinit_xen_time (); +else +acpi_preinit_xen_time (timer_irq); + +if ( acpi_disabled &&dt_property_read_u32 (timer,"clock-frequency" , &rate) ) cpu_khz = rate /1000 ;else cpu_khz =READ_SYSREG32 (CNTFRQ_EL0 ) /1000 ;
@@ -99,14 +112,17 @@ int __init init_xen_time(void)int res;unsigned int i; -/* Retrieve all IRQs for the timer */ -for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) +if ( acpi_disabled ) { - res =platform_get_irq (timer, i); - -if ( res <0 ) -panic ("Timer: Unable to retrieve IRQ %u from the device tree" , i); - timer_irq[i] = res; +/* Retrieve all IRQs for the timer */ +for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) + { + res =platform_get_irq (timer, i); + +if ( res <0 ) +panic ("Timer: Unable to retrieve IRQ %u from the device tree" , i); + timer_irq[i] = res; + } }/* Check that this CPU supports the Generic Timer interface */
xen/include/asm-arm/acpi.h +2 -0
@@ -36,10 +36,12 @@ bool_t acpi_psci_present(void);/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void );void __init acpi_init_cpus (void ); +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]);#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; }static inline void acpi_init_cpus (void ) { } +static inline void acpi_preinit_xen_time (unsigned int generic_timer_irq[]){ }#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */
Signature · 1 line
1.9.1
Re: [PATCH v2 15/41] arm : acpi parse GTDT to initialize timer
Hi Parth,
Quoted 29 lines · Parth Dixit
Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using the information presented by GTDT to initialize the arch timer (not memory-mapped).
Clear all el2 fields in GTDT table after initialization for passing it to Dom0.
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++---------- xen/include/asm-arm/acpi.h | 2 ++ 3 files changed, 79 insertions(+), 11 deletions(-)xen/arch/arm/acpi/boot.c +2
-0@@ -30,6 +30,8 @@#include <asm/acpi.h> #include <asm/smp.h> +#include <asm/irq.h> +#include <asm/time.h> /* Processors with enabled flag and sane MPIDR */ static int enabled_cpus;
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 46
Quoted 5 lines
xen/arch/arm/acpi/boot.c +2
-0@@ -40,6 +42,54 @@ static bool_t __initdata bootcpu_valid;/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ static unsigned int total_cpus =0 ; +/* Initialize per-processor generic timer */ +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[])
acpi/boot.c begin to be a junk room for all ACPI code. It would have been more logic to have this code in arch/arm/time.c with proper #ifdef.
This would have drop the generic_timer_irq which is difficult to understand.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 49
Quoted 3 lines
xen/arch/arm/acpi/boot.c +3
-0+{ +int type; +struct acpi_table_gtdt *gtdt=NULL ;
*gtdt = NULL;
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 51
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+u8 checksum; + static const int GTDT_INTRL_TAB[] =
all uppercase name are used for define.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 57
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ { +ACPI_IRQ_TYPE_LEVEL_HIGH , +ACPI_IRQ_TYPE_EDGE_RISING , +ACPI_IRQ_TYPE_LEVEL_LOW , + ACPI_IRQ_TYPE_EDGE_FALLING + };
It took me a while to understand how this work.
I would prefer an helper which check each field and return/set the correct interrupt type.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 62
Quoted 5 lines
xen/arch/arm/acpi/boot.c +5
-0+ +acpi_get_table (ACPI_SIG_GTDT ,0 , (struct acpi_table_header **)>dt); + +if ( gtdt ) + {
If gtdt is NULL you will continue without any warning and potentially crash later.
Also please do:
if ( !gtdt ) {
/* handle error */
return;
}
/* setup the timer */
It's easier to understand and remove one indentation.
Quoted 17 lines
xen/arch/arm/acpi/boot.c +17
-0+/* Initialize all the generic timer IRQ variable from GTDT table */ + + type =GTDT_INTRL_TAB [gtdt->non_secure_el1_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->non_secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_NONSECURE_PPI ] = + gtdt->non_secure_el1_interrupt; + + type =GTDT_INTRL_TAB [gtdt->secure_el1_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_SECURE_PPI ] = + gtdt->secure_el1_interrupt; + + type =GTDT_INTRL_TAB [gtdt->non_secure_el2_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->non_secure_el2_interrupt, type); + generic_timer_irq[TIMER_HYP_PPI ] = + gtdt->non_secure_el2_interrupt; +
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 89
Quoted 10 lines
xen/arch/arm/acpi/boot.c +10
-0+ type =GTDT_INTRL_TAB [gtdt->virtual_timer_flags &ACPI_GTDT_INTR_MASK ]; +set_irq_type (gtdt->virtual_timer_interrupt, type); + generic_timer_irq[TIMER_VIRT_PPI ] = + gtdt->virtual_timer_interrupt; + + gtdt->non_secure_el2_interrupt =0 ; + gtdt->non_secure_el2_flags =0 ; + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, gtdt), gtdt->header.length); + gtdt->header.checksum -= checksum; +clean_dcache_va_range (gtdt,sizeof (struct acpi_table_gtdt ));
Similar comment as on the MADT, this function is initializing the timer and not modifying the ACPI table.
I would prefer a separate function which is called during DOM0 building. It would be easier to know how the ACPI table has been modified for DOM0.
Also, please add a comment to explain this block smth like /* Hide EL2 interrupt to DOM0 */. Maybe explaining that the table is re-used.
Furthermore, are you sure that the ACPI table will always be in R/W memory? If not, we should duplicate the table and update the field.
Quoted 36 lines
xen/arch/arm/acpi/boot.c +3
-0+ } +} +/* * acpi_map_gic_cpu_interface - generates a logical cpu number * and map to MPIDR represented by GICC structure xen/arch/arm/time.c +2
-2@@ -29,6 +29,7 @@#include <xen/time.h> #include <xen/sched.h> #include <xen/event.h> +#include <xen/acpi.h> #include <asm/system.h> #include <asm/time.h> #include <asm/gic.h> @@ -64,7 +65,7 @@ unsigned int timer_get_irq(enum timer_ppi ppi)static __initdata struct dt_device_node *timer;/* Set up the timer on the boot CPU (early init function) */ -void __init preinit_xen_time (void ) +static void __init dt_preinit_xen_time (void ) {static const struct dt_device_match timer_ids[]__initconst = {@@ -72,7 +73,6 @@ void __init preinit_xen_time(void) { /* sentinel */ }, };int res; -u32 rate; timer =dt_find_matching_node (NULL , timer_ids);if ( !timer )
xen/arch/arm/time.c void __init preinit_xen_time(void) · line 90
Quoted 9 lines
xen/arch/arm/time.c +4
-2@@ -84,8 +84,21 @@ void __init preinit_xen_time(void)if ( res )panic ("Timer: Cannot initialize platform timer" ); - res =dt_property_read_u32 (timer,"clock-frequency" , &rate); -if ( res ) +} + + +
Only one blank line is enough.
xen/arch/arm/time.c void __init preinit_xen_time(void) · line 101
Quoted 11 lines
xen/arch/arm/time.c +11
-0+void __init preinit_xen_time (void ) +{ +u32 rate; + +/* Initialize all the generic timers presented in GTDT */ +if ( acpi_disabled ) +dt_preinit_xen_time (); +else +acpi_preinit_xen_time (timer_irq); + +if ( acpi_disabled &&dt_property_read_u32 (timer,"clock-frequency" , &rate) )
A such check calls for more refactoring...
xen/arch/arm/time.c void __init preinit_xen_time(void) · line 104
Quoted 3 lines
xen/arch/arm/time.c +0
-0cpu_khz = rate /1000 ; else cpu_khz =READ_SYSREG32 (CNTFRQ_EL0 ) /1000 ;
Duplicating this line wouldn't have been too bad compare to the check.
Quoted 12 lines
xen/arch/arm/time.c +1
-6@@ -99,14 +112,17 @@ int __init init_xen_time(void)int res;unsigned int i; -/* Retrieve all IRQs for the timer */ -for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) +if ( acpi_disabled ) { - res =platform_get_irq (timer, i); - -if ( res <0 ) -panic ("Timer: Unable to retrieve IRQ %u from the device tree" , i);
xen/arch/arm/time.c int __init init_xen_time(void) · line 125
Quoted 10 lines
xen/arch/arm/time.c +9
-1- timer_irq[i] = res; +/* Retrieve all IRQs for the timer */ +for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) + { + res =platform_get_irq (timer, i); + +if ( res <0 ) +panic ("Timer: Unable to retrieve IRQ %u from the device tree" , i); + timer_irq[i] = res; + }
Another helper for this device tree code?
Quoted 11 lines
xen/arch/arm/time.c +0
-0}/* Check that this CPU supports the Generic Timer interface */ xen/include/asm-arm/acpi.h +0
-0@@ -36,10 +36,12 @@ bool_t acpi_psci_present(void);/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void );
xen/include/asm-arm/acpi.h bool_t acpi_psci_present(void); · line 47
Quoted 10 lines
xen/include/asm-arm/acpi.h +2
-0void __init acpi_init_cpus (void ); +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]);#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; }static inline void acpi_init_cpus (void ) { } +static inline void acpi_preinit_xen_time (unsigned int generic_timer_irq[]){ }#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 15/41] arm : acpi parse GTDT to initialize timer
Quoted 255 lines · Julien Grall
Hi Parth,
Quoted 11 lines · Parth Dixit
Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using the information presented by GTDT to initialize the arch timer (not memory-mapped).
Clear all el2 fields in GTDT table after initialization for passing it to Dom0.
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 50++++++++++++++++++++++++++++++++++++++++++++++
Quoted 18 lines
xen/arch/arm/time.c | 38 +++++++++++++++++++++++++---------- xen/include/asm-arm/acpi.h | 2 ++ 3 files changed, 79 insertions(+), 11 deletions(-)xen/arch/arm/acpi/boot.c +2
-0@@ -30,6 +30,8 @@#include <asm/acpi.h> #include <asm/smp.h> +#include <asm/irq.h> +#include <asm/time.h> /* Processors with enabled flag and sane MPIDR */ static int enabled_cpus;xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 42
Quoted 1 line
xen/arch/arm/acpi/boot.c +0
-0@@ -40,6 +42,54 @@ static bool_t __initdata bootcpu_valid;/* arch-optional setting to enable display of offline cpus >=
nr_cpu_ids*/xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 46
Quoted 4 lines
xen/arch/arm/acpi/boot.c +2
-0static unsigned int total_cpus =0 ; +/* Initialize per-processor generic timer */ +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[])
acpi/boot.cbegin to be a junk room for all ACPI code. It would have been more logic to have this code inarch/arm/time.cwith proper #ifdef.This would have drop the
generic_timer_irqwhich is difficult to understand.xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 49
Quoted 3 lines
xen/arch/arm/acpi/boot.c +3
-0+{ +int type; +struct acpi_table_gtdt *gtdt=NULL ;*gtdt = NULL;
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 51
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+u8 checksum; + static const int GTDT_INTRL_TAB[] =all uppercase name are used for define.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 57
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ { +ACPI_IRQ_TYPE_LEVEL_HIGH , +ACPI_IRQ_TYPE_EDGE_RISING , +ACPI_IRQ_TYPE_LEVEL_LOW , + ACPI_IRQ_TYPE_EDGE_FALLING + };It took me a while to understand how this work.
I would prefer an helper which check each field and return/set the correct interrupt type.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 59
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ + acpi_get_table(ACPI_SIG_GTDT, 0, (struct acpi_table_header**)>dt);
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 62
Quoted 3 lines
xen/arch/arm/acpi/boot.c +3
-0+ +if ( gtdt ) + {If gtdt is NULL you will continue without any warning and potentially crash later.
Also please do:
if ( !gtdt ) {
/* handle error */
return;
}/* setup the timer */
It's easier to understand and remove one indentation.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 63
Quoted 1 line
xen/arch/arm/acpi/boot.c +1
-0+/* Initialize all the generic timer IRQ variable from GTDT table */
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 65
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ + type = GTDT_INTRL_TAB[gtdt->non_secure_el1_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid;
Quoted 5 lines
xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->non_secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_NONSECURE_PPI ] = + gtdt->non_secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->secure_el1_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid;
Quoted 5 lines
xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_SECURE_PPI ] = + gtdt->secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->non_secure_el2_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid;
Quoted 5 lines
xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->non_secure_el2_interrupt, type); + generic_timer_irq[TIMER_HYP_PPI ] = + gtdt->non_secure_el2_interrupt; + + type = GTDT_INTRL_TAB[gtdt->virtual_timer_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid;
Quoted 7 lines
xen/arch/arm/acpi/boot.c +7
-0+set_irq_type (gtdt->virtual_timer_interrupt, type); + generic_timer_irq[TIMER_VIRT_PPI ] = + gtdt->virtual_timer_interrupt; + + gtdt->non_secure_el2_interrupt =0 ; + gtdt->non_secure_el2_flags =0 ; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, gtdt),
gtdt->header.length);xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 89
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ gtdt->header.checksum -= checksum; +clean_dcache_va_range (gtdt,sizeof (struct acpi_table_gtdt ));Similar comment as on the MADT, this function is initializing the timer and not modifying the ACPI table.
I would prefer a separate function which is called during DOM0 building. It would be easier to know how the ACPI table has been modified for DOM0.
Also, please add a comment to explain this block smth like /* Hide EL2 interrupt to DOM0 */. Maybe explaining that the table is re-used.
Furthermore, are you sure that the ACPI table will always be in R/W memory? If not, we should duplicate the table and update the field.
Quoted 36 lines
xen/arch/arm/acpi/boot.c +3
-0+ } +} +/* * acpi_map_gic_cpu_interface - generates a logical cpu number * and map to MPIDR represented by GICC structure xen/arch/arm/time.c +2
-2@@ -29,6 +29,7 @@#include <xen/time.h> #include <xen/sched.h> #include <xen/event.h> +#include <xen/acpi.h> #include <asm/system.h> #include <asm/time.h> #include <asm/gic.h> @@ -64,7 +65,7 @@ unsigned int timer_get_irq(enum timer_ppi ppi)static __initdata struct dt_device_node *timer;/* Set up the timer on the boot CPU (early init function) */ -void __init preinit_xen_time (void ) +static void __init dt_preinit_xen_time (void ) {static const struct dt_device_match timer_ids[]__initconst = {@@ -72,7 +73,6 @@ void __init preinit_xen_time(void) { /* sentinel */ }, };int res; -u32 rate; timer =dt_find_matching_node (NULL , timer_ids);if ( !timer )xen/arch/arm/time.c void __init preinit_xen_time(void) · line 90
Quoted 9 lines
xen/arch/arm/time.c +4
-2@@ -84,8 +84,21 @@ void __init preinit_xen_time(void)if ( res )panic ("Timer: Cannot initialize platform timer" ); - res =dt_property_read_u32 (timer,"clock-frequency" , &rate); -if ( res ) +} + + +Only one blank line is enough.
xen/arch/arm/time.c void __init preinit_xen_time(void)
Quoted 11 lines
xen/arch/arm/time.c +11
-0+void __init preinit_xen_time(void) +{ + u32 rate; + + /* Initialize all the generic timers presented in GTDT */ + if ( acpi_disabled ) + dt_preinit_xen_time(); + else + acpi_preinit_xen_time(timer_irq); + + if( acpi_disabled && dt_property_read_u32(timer, "clock-frequency",&rate) )
A such check calls for more refactoring...
xen/arch/arm/time.c void __init preinit_xen_time(void) · line 104
Quoted 3 lines
xen/arch/arm/time.c +0
-0cpu_khz = rate /1000 ; else cpu_khz =READ_SYSREG32 (CNTFRQ_EL0 ) /1000 ;Duplicating this line wouldn't have been too bad compare to the check.
xen/arch/arm/time.c int __init init_xen_time(void) · line 108
Quoted 12 lines
xen/arch/arm/time.c +1
-6@@ -99,14 +112,17 @@ int __init init_xen_time(void)int res;unsigned int i; -/* Retrieve all IRQs for the timer */ -for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) +if ( acpi_disabled ) { - res =platform_get_irq (timer, i); - -if ( res <0 ) - panic("Timer: Unable to retrieve IRQ %u from the devicetree", i);
xen/arch/arm/time.c int __init init_xen_time(void)
Quoted 8 lines
xen/arch/arm/time.c +7
-1- timer_irq[i] = res; +/* Retrieve all IRQs for the timer */ +for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) + { + res =platform_get_irq (timer, i); + +if ( res <0 ) + panic("Timer: Unable to retrieve IRQ %u from the devicetree", i);
xen/arch/arm/time.c int __init init_xen_time(void) · line 125
Quoted 2 lines
xen/arch/arm/time.c +2
-0+ timer_irq[i] = res; + }Another helper for this device tree code?
Quoted 8 lines
xen/arch/arm/time.c +0
-0}/* Check that this CPU supports the Generic Timer interface */ xen/include/asm-arm/acpi.h +0
-0xen/include/asm-arm/acpi.h bool_t acpi_psci_present(void); · line 44
Quoted 9 lines
xen/include/asm-arm/acpi.h +2
-0@@ -36,10 +36,12 @@ bool_t acpi_psci_present(void);/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void );void __init acpi_init_cpus (void ); +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]);#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; }static inline void acpi_init_cpus (void ) { } +static inline void acpi_preinit_xen_time(unsigned intgeneric_timer_irq[]){ }
xen/include/asm-arm/acpi.h bool_t acpi_psci_present(void); · line 47
Quoted 4 lines
xen/include/asm-arm/acpi.h +0
-0#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */
Quoted 7 lines
sure, will take care in next patchset.
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 15/41] arm : acpi parse GTDT to initialize timer
+shannon
Quoted 267 lines · Parth Dixit
Quoted 253 lines · Julien Grall
Hi Parth,
Quoted 34 lines · Parth Dixit
Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using the information presented by GTDT to initialize the arch timer (not memory-mapped).
Clear all el2 fields in GTDT table after initialization for passing it to Dom0.
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/boot.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++---------- xen/include/asm-arm/acpi.h | 2 ++ 3 files changed, 79 insertions(+), 11 deletions(-)xen/arch/arm/acpi/boot.c +2
-0@@ -30,6 +30,8 @@#include <asm/acpi.h> #include <asm/smp.h> +#include <asm/irq.h> +#include <asm/time.h> /* Processors with enabled flag and sane MPIDR */ static int enabled_cpus;@@ -40,6 +42,54 @@ static bool_t __initdata bootcpu_valid;/* arch-optional setting to enable display of offline cpus >=
nr_cpu_ids*/
static unsigned inttotal_cpus= 0;xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 46
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+/* Initialize per-processor generic timer */ +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[])
acpi/boot.cbegin to be a junk room for all ACPI code. It would have been more logic to have this code inarch/arm/time.cwith proper #ifdef.This would have drop the
generic_timer_irqwhich is difficult to understand.xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 49
Quoted 3 lines
xen/arch/arm/acpi/boot.c +3
-0+{ +int type; +struct acpi_table_gtdt *gtdt=NULL ;*gtdt = NULL;
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 51
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+u8 checksum; + static const int GTDT_INTRL_TAB[] =all uppercase name are used for define.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 57
Quoted 6 lines
xen/arch/arm/acpi/boot.c +6
-0+ { +ACPI_IRQ_TYPE_LEVEL_HIGH , +ACPI_IRQ_TYPE_EDGE_RISING , +ACPI_IRQ_TYPE_LEVEL_LOW , + ACPI_IRQ_TYPE_EDGE_FALLING + };It took me a while to understand how this work.
I would prefer an helper which check each field and return/set the correct interrupt type.
xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 62
Quoted 6 lines
xen/arch/arm/acpi/boot.c +2
-0+ + acpi_get_table(ACPI_SIG_GTDT, 0, (struct acpi_table_header**)>dt);
xen/arch/arm/acpi/boot.c +3
-0+ +if ( gtdt ) + {If gtdt is NULL you will continue without any warning and potentially crash later.
Also please do:
if ( !gtdt ) {
/* handle error */
return;
}/* setup the timer */
It's easier to understand and remove one indentation.
Quoted 31 lines
+ /* Initialize all the generic timer IRQ variable from GTDT
table */xen/arch/arm/acpi/boot.c +2
-0+ + type = GTDT_INTRL_TAB[gtdt->non_secure_el1_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->non_secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_NONSECURE_PPI ] = + gtdt->non_secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->secure_el1_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->secure_el1_interrupt, type); + generic_timer_irq[TIMER_PHYS_SECURE_PPI ] = + gtdt->secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->non_secure_el2_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c +5
-0+set_irq_type (gtdt->non_secure_el2_interrupt, type); + generic_timer_irq[TIMER_HYP_PPI ] = + gtdt->non_secure_el2_interrupt; + + type = GTDT_INTRL_TAB[gtdt->virtual_timer_flags &
ACPI_GTDT_INTR_MASK];xen/arch/arm/acpi/boot.c +7
-0+set_irq_type (gtdt->virtual_timer_interrupt, type); + generic_timer_irq[TIMER_VIRT_PPI ] = + gtdt->virtual_timer_interrupt; + + gtdt->non_secure_el2_interrupt =0 ; + gtdt->non_secure_el2_flags =0 ; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, gtdt),
gtdt->header.length);xen/arch/arm/acpi/boot.c static bool_t __initdata bootcpu_valid; · line 89
Quoted 2 lines
xen/arch/arm/acpi/boot.c +2
-0+ gtdt->header.checksum -= checksum; +clean_dcache_va_range (gtdt,sizeof (struct acpi_table_gtdt ));Similar comment as on the MADT, this function is initializing the timer and not modifying the ACPI table.
I would prefer a separate function which is called during DOM0 building. It would be easier to know how the ACPI table has been modified for DOM0.
Also, please add a comment to explain this block smth like /* Hide EL2 interrupt to DOM0 */. Maybe explaining that the table is re-used.
Furthermore, are you sure that the ACPI table will always be in R/W memory? If not, we should duplicate the table and update the field.
Quoted 36 lines
xen/arch/arm/acpi/boot.c +3
-0+ } +} +/* * acpi_map_gic_cpu_interface - generates a logical cpu number * and map to MPIDR represented by GICC structure xen/arch/arm/time.c +2
-2@@ -29,6 +29,7 @@#include <xen/time.h> #include <xen/sched.h> #include <xen/event.h> +#include <xen/acpi.h> #include <asm/system.h> #include <asm/time.h> #include <asm/gic.h> @@ -64,7 +65,7 @@ unsigned int timer_get_irq(enum timer_ppi ppi)static __initdata struct dt_device_node *timer;/* Set up the timer on the boot CPU (early init function) */ -void __init preinit_xen_time (void ) +static void __init dt_preinit_xen_time (void ) {static const struct dt_device_match timer_ids[]__initconst = {@@ -72,7 +73,6 @@ void __init preinit_xen_time(void) { /* sentinel */ }, };int res; -u32 rate; timer =dt_find_matching_node (NULL , timer_ids);if ( !timer )xen/arch/arm/time.c void __init preinit_xen_time(void) · line 90
Quoted 9 lines
xen/arch/arm/time.c +4
-2@@ -84,8 +84,21 @@ void __init preinit_xen_time(void)if ( res )panic ("Timer: Cannot initialize platform timer" ); - res =dt_property_read_u32 (timer,"clock-frequency" , &rate); -if ( res ) +} + + +Only one blank line is enough.
xen/arch/arm/time.c void __init preinit_xen_time(void)
Quoted 12 lines
xen/arch/arm/time.c +11
-0+void __init preinit_xen_time (void ) +{ +u32 rate; + +/* Initialize all the generic timers presented in GTDT */ +if ( acpi_disabled ) +dt_preinit_xen_time (); +else +acpi_preinit_xen_time (timer_irq); + +if ( acpi_disabled &&dt_property_read_u32 (timer,"clock-frequency" , &rate) )A such check calls for more refactoring...
Quoted 3 lines
xen/arch/arm/time.c +0
-0cpu_khz = rate /1000 ; elsecpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;Duplicating this line wouldn't have been too bad compare to the check.
Quoted 14 lines
xen/arch/arm/time.c +1
-7@@ -99,14 +112,17 @@ int __init init_xen_time(void)int res;unsigned int i; -/* Retrieve all IRQs for the timer */ -for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) +if ( acpi_disabled ) { - res =platform_get_irq (timer, i); - -if ( res <0 ) -panic ("Timer: Unable to retrieve IRQ %u from the device tree", i); - timer_irq[i] = res;xen/arch/arm/time.c int __init init_xen_time(void) · line 127
Quoted 10 lines
xen/arch/arm/time.c +9
-0+/* Retrieve all IRQs for the timer */ +for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) + { + res =platform_get_irq (timer, i); + +if ( res <0 ) +panic ("Timer: Unable to retrieve IRQ %u from the device tree", i); + timer_irq[i] = res; + }Another helper for this device tree code?
Quoted 20 lines
xen/arch/arm/time.c +0
-0}/* Check that this CPU supports the Generic Timer interface */xen/include/asm-arm/acpi.h +2
-0@@ -36,10 +36,12 @@ bool_t acpi_psci_present(void);/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ bool_t acpi_psci_hvc_present (void );void __init acpi_init_cpus (void ); +void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]);#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; }static inline void acpi_init_cpus (void ) { } +static inline void acpi_preinit_xen_time (unsigned int generic_timer_irq[]){ }#endif /* CONFIG_ACPI */ Quoted 3 lines
Quoted 2 lines
/* Basic configuration for ACPI */
sure, will take care in next patchset.
Quoted 5 lines
Regards,
--
Julien Grall
PATCH v2 16/41 acpi : Introduce acpi_parse_entries
In reply to Parth Dixitadd new function acpi_parse_entries which takes acpi table as argument. This will avoid fetching table everytime in acpi_table_parse_entries.
--- xen/drivers/acpi/tables.c | 60 +++++++++++++++++++++++++++++++++-------------- xen/include/xen/acpi.h | 3 +++ 2 files changed, 45 insertions(+), 18 deletions(-)
xen/drivers/acpi/tables.c +42 -18
@@ -237,31 +237,29 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) } } -int __init -acpi_table_parse_entries (char *id, -unsigned long table_size, -int entry_id, -acpi_table_entry_handler handler, -unsigned int max_entries) +acpi_parse_entries (char *id, +unsigned long table_size, +acpi_table_entry_handler handler, +struct acpi_table_header *table_header, +int entry_id, +unsigned int max_entries) { -struct acpi_table_header *table_header =NULL ; -struct acpi_subtable_header *entry; +struct acpi_subtable_header *entry;unsigned int count =0 ;unsigned long table_end; -if (!handler) -return -EINVAL ; +if ( !handler ) +return -EINVAL ; -if (strncmp (id,ACPI_SIG_MADT ,4 ) ==0 ) -acpi_get_table (id, acpi_apic_instance, &table_header); -else -acpi_get_table (id,0 , &table_header); +if ( !table_size ) +return -EINVAL ; -if (!table_header) { - printk(KERN_WARNING PREFIX "%4.4s not present\n", id); -return -ENODEV ; - } +if ( !table_header ) + { +printk ("Table header not present\n" ); +return -ENODEV ; + } table_end = (unsigned long )table_header + table_header->length;
@@ -292,6 +290,32 @@ acpi_table_parse_entries(char *id, }return count; + +} +int __init +acpi_table_parse_entries (char *id, +unsigned long table_size, +int entry_id, +acpi_table_entry_handler handler, +unsigned int max_entries) +{ +struct acpi_table_header *table_header =NULL ; + +if (!handler) +return -EINVAL ; + +if (strncmp (id,ACPI_SIG_MADT ,4 ) ==0 ) +acpi_get_table (id, acpi_apic_instance, &table_header); +else +acpi_get_table (id,0 , &table_header); + +if (!table_header) { + printk(KERN_WARNING PREFIX "%4.4s not present\n", id); +return -ENODEV ; + } + +return acpi_parse_entries (id, table_size, handler, table_header, + entry_id, max_entries); }int __init
xen/include/xen/acpi.h +3 -0
@@ -74,6 +74,9 @@ int acpi_table_init (void);int acpi_table_parse (char *id,acpi_table_handler handler);int acpi_table_parse_entries (char *id,unsigned long table_size,int entry_id,acpi_table_entry_handler handler,unsigned int max_entries); +int acpi_parse_entries (char *id,unsigned long table_size, +acpi_table_entry_handler handler,struct acpi_table_header *table_header, +int entry_id,unsigned int max_entries);int acpi_table_parse_madt (enum acpi_madt_type id,acpi_table_entry_handler handler,unsigned int max_entries);int acpi_table_parse_srat (int id,acpi_madt_entry_handler handler,unsigned int max_entries);
Signature · 1 line
1.9.1
Re: [PATCH v2 16/41] acpi : Introduce acpi_parse_entries
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add new function
acpi_parse_entrieswhich takes acpi table as argument. This will avoid fetching table everytime inacpi_table_parse_entries.
This explanation doesn't make a lot of sense to me - I don't see you save anything. Am I missing anything? Are you intending to use the new function separately? Also, please don't break indentation like you do here (and elsewhere).
Jan
Re: [PATCH v2 16/41] acpi : Introduce acpi_parse_entries
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add new function
acpi_parse_entrieswhich takes acpi table as argument. This will avoid fetching table everytime inacpi_table_parse_entries.This explanation doesn't make a lot of sense to me - I don't see you save anything. Am I missing anything? Are you intending to use the new function separately? Also, please don't break indentation like
yes, i am fetching the table once and parsing it with this function in acpi_gicv2_init function in the patch given below
http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.html
Quoted 7 lines
you do here (and elsewhere).
sure, i'll take care of the indentation.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 16/41] acpi : Introduce acpi_parse_entries
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 11:14, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add new function
acpi_parse_entrieswhich takes acpi table as argument. This will avoid fetching table everytime inacpi_table_parse_entries.
Quoted 7 lines
Quoted 4 lines
This explanation doesn't make a lot of sense to me - I don't see you save anything. Am I missing anything? Are you intending to use the new function separately? Also, please don't break indentation like
yes, i am fetching the table once and parsing it with this function in
acpi_gicv2_initfunction in the patch given below
http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.html
So - just like elsewhere - please correct the patch description then.
Jan
Re: [PATCH v2 16/41] acpi : Introduce acpi_parse_entries
+shannon
Quoted 20 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 11:14, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add new function
acpi_parse_entrieswhich takes acpi table as argument. This will avoid fetching table everytime inacpi_table_parse_entries.Quoted 7 lines
Quoted 4 lines
This explanation doesn't make a lot of sense to me - I don't see you save anything. Am I missing anything? Are you intending to use the new function separately? Also, please don't break indentation like
yes, i am fetching the table once and parsing it with this function in
acpi_gicv2_initfunction in the patch given below
http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.htmlSo - just like elsewhere - please correct the patch description then.
Jan
PATCH v2 17/41 arm : refactor gic into generic and dt specific parts
In reply to Parth Dixitrefactor gic related functions into dt and generic parts this will be helpful when adding acpi support for gic
--- xen/arch/arm/gic-v2.c | 13 ++++++++++--- xen/arch/arm/gic.c | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-)
xen/arch/arm/gic-v2.c +10 -3
@@ -663,7 +663,7 @@ static hw_irq_controller gicv2_guest_irq_type = { .set_affinity = gicv2_irq_set_affinity, }; -static int __init gicv2_init (void ) +static int __init dt_gicv2_init (void ) {int res;const struct dt_device_node *node = gicv2_info.node;
@@ -689,6 +689,13 @@ static int __init gicv2_init(void)panic ("GICv2: Cannot find the maintenance IRQ" ); gicv2_info.maintenance_irq = res; +return 0 ; +} + +static int gicv2_init (void ) +{ +dt_gicv2_init (); +/* TODO: Add check on distributor, cpu size */ printk("GICv2 initialization:\n"
@@ -763,7 +770,7 @@ const static struct gic_hw_operations gicv2_ops = { };/* Set up the GIC */ -static int __init gicv2_preinit (struct dt_device_node *node,const void *data) +static int __init dt_gicv2_preinit (struct dt_device_node *node,const void *data) { gicv2_info.hw_version =GIC_V2 ; gicv2_info.node = node;
@@ -781,7 +788,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =DT_DEVICE_START (gicv2,"GICv2" ,DEVICE_GIC ) .dt_match = gicv2_dt_match, - .init = gicv2_preinit, + .init = dt_gicv2_preinit,DT_DEVICE_END /*
xen/arch/arm/gic.c +6 -1
@@ -231,7 +231,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,/* Find the interrupt controller and set up the callback to translate * device tree IRQ. */ -void __init gic_preinit (void ) +void __init dt_gic_preinit (void ) {int rc;struct dt_device_node *node;
@@ -261,6 +261,11 @@ void __init gic_preinit(void)dt_device_set_used_by (node,DOMID_XEN ); } +void __init gic_preinit (void ) +{ +dt_gic_preinit (); +} +/* Set up the GIC */ void __init gic_init (void ) {
Signature · 1 line
1.9.1
Re: [PATCH v2 17/41] arm : refactor gic into generic and dt specific parts
Hi Parth,
Quoted 2 lines · Parth Dixit
refactor gic related functions into dt and generic parts this will be helpful when adding acpi support for gic
Please explain why you don't refactor neither gic-hip04 and gic-v3.
Quoted 20 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/gic-v2.c | 13 ++++++++++--- xen/arch/arm/gic.c | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-)xen/arch/arm/gic-v2.c +1
-1@@ -663,7 +663,7 @@ static hw_irq_controller gicv2_guest_irq_type = { .set_affinity = gicv2_irq_set_affinity, }; -static int __init gicv2_init (void ) +static int __init dt_gicv2_init (void ) {int res;const struct dt_device_node *node = gicv2_info.node;
xen/arch/arm/gic-v2.c static int __init gicv2_init(void) · line 695
Quoted 7 lines
xen/arch/arm/gic-v2.c +4
-0@@ -689,6 +689,13 @@ static int __init gicv2_init(void)panic ("GICv2: Cannot find the maintenance IRQ" ); gicv2_info.maintenance_irq = res; +return 0 ; +} + +static int gicv2_init (void )
static init __init
xen/arch/arm/gic-v2.c const static struct gic_hw_operations gicv2_ops = { · line 773
Quoted 12 lines
xen/arch/arm/gic-v2.c +4
-1+{ +dt_gicv2_init (); +/* TODO: Add check on distributor, cpu size */ printk("GICv2 initialization:\n"@@ -763,7 +770,7 @@ const static struct gic_hw_operations gicv2_ops = { };/* Set up the GIC */ -static int __init gicv2_preinit (struct dt_device_node *node,const void *data) +static int __init dt_gicv2_preinit (struct dt_device_node *node,const void *data)
This line is too long now.
Quoted 17 lines
xen/arch/arm/gic-v2.c +1
-1{ gicv2_info.hw_version =GIC_V2 ; gicv2_info.node = node;@@ -781,7 +788,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =DT_DEVICE_START (gicv2,"GICv2" ,DEVICE_GIC ) .dt_match = gicv2_dt_match, - .init = gicv2_preinit, + .init = dt_gicv2_preinit,DT_DEVICE_END /* xen/arch/arm/gic.c +0
-0
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 234
Quoted 5 lines
xen/arch/arm/gic.c +1
-1@@ -231,7 +231,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,/* Find the interrupt controller and set up the callback to translate * device tree IRQ. */ -void __init gic_preinit (void ) +void __init dt_gic_preinit (void )
This function is not exported, so it should be static.
Quoted 6 lines
xen/arch/arm/gic.c +0
-0{int rc;struct dt_device_node *node;@@ -261,6 +261,11 @@ void __init gic_preinit(void)dt_device_set_used_by (node,DOMID_XEN );
xen/arch/arm/gic.c void __init gic_preinit(void) · line 271
Quoted 10 lines
xen/arch/arm/gic.c +5
-0} +void __init gic_preinit (void ) +{ +dt_gic_preinit (); +} +/* Set up the GIC */ void __init gic_init (void ) {
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 17/41] arm : refactor gic into generic and dt specific parts
In reply to Parth DixitQuoted 23 lines · Parth Dixit
refactor gic related functions into dt and generic parts this will be helpful when adding acpi support for gic
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/gic-v2.c | 13 ++++++++++--- xen/arch/arm/gic.c | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-)xen/arch/arm/gic-v2.c +1
-1@@ -663,7 +663,7 @@ static hw_irq_controller gicv2_guest_irq_type = { .set_affinity = gicv2_irq_set_affinity, }; -static int __init gicv2_init (void ) +static int __init dt_gicv2_init (void ) {int res;const struct dt_device_node *node = gicv2_info.node;
xen/arch/arm/gic-v2.c static int __init gicv2_init(void) · line 698
Quoted 10 lines
xen/arch/arm/gic-v2.c +7
-0@@ -689,6 +689,13 @@ static int __init gicv2_init(void)panic ("GICv2: Cannot find the maintenance IRQ" ); gicv2_info.maintenance_irq = res; +return 0 ; +} + +static int gicv2_init (void ) +{ +dt_gicv2_init (); +
I forgot it on the first review. dt_gicv2_init is returning an error code. You should not ignore it.
If it's not useful (because everything paniced), then the function should return void.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 17/41] arm : refactor gic into generic and dt specific parts
+shannon
Quoted 45 lines · Julien Grall
Quoted 23 lines · Parth Dixit
refactor gic related functions into dt and generic parts this will be helpful when adding acpi support for gic
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/gic-v2.c | 13 ++++++++++--- xen/arch/arm/gic.c | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-)xen/arch/arm/gic-v2.c +1
-1@@ -663,7 +663,7 @@ static hw_irq_controller gicv2_guest_irq_type = { .set_affinity = gicv2_irq_set_affinity, }; -static int __init gicv2_init (void ) +static int __init dt_gicv2_init (void ) {int res;const struct dt_device_node *node = gicv2_info.node;xen/arch/arm/gic-v2.c static int __init gicv2_init(void) · line 698
Quoted 10 lines
xen/arch/arm/gic-v2.c +7
-0@@ -689,6 +689,13 @@ static int __init gicv2_init(void)panic ("GICv2: Cannot find the maintenance IRQ" ); gicv2_info.maintenance_irq = res; +return 0 ; +} + +static int gicv2_init (void ) +{ +dt_gicv2_init (); +I forgot it on the first review.
dt_gicv2_initis returning an error code. You should not ignore it.If it's not useful (because everything paniced), then the function should return void.
Regards,
--
Julien Grall
PATCH v2 18/41 arm: Introduce a generic way to use a device from acpi
In reply to Parth Dixitadd generic way to use device from acpi similar to the way it is supported in device tree.
--- xen/arch/arm/device.c | 19 +++++++++++++++++++ xen/arch/arm/xen.lds.S | 7 +++++++ xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
xen/arch/arm/device.c +19 -0
@@ -22,6 +22,7 @@#include <xen/lib.h> extern const struct device_desc _sdevice[], _edevice[]; +extern const struct acpi_device_desc _asdevice[], _aedevice[];int __init device_init (struct dt_device_node *dev,enum device_class class,const void *data)
@@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,return -EBADF ; } +int __init acpi_device_init (enum device_class class,const void *data,int class_type) +{ +const struct acpi_device_desc *desc; + +for ( desc = _asdevice; desc != _aedevice; desc++ ) + { +if ( ( desc->class != class ) && ( desc->class_type != class_type ) ) +continue ; + + +ASSERT (desc->init !=NULL ); + +return desc->init (data); + } + +return -EBADF ; +} +enum device_class device_get_class (const struct dt_device_node *dev) {const struct device_desc *desc;
xen/arch/arm/xen.lds.S +7 -0
@@ -100,6 +100,13 @@ SECTIONS _edevice = .; } :text + . = ALIGN(8); + .adev.info : { + _asdevice = .; + *(.adev.info) + _aedevice = .; + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : {
xen/include/asm-arm/device.h +30 -0
@@ -50,6 +50,27 @@ struct device_desc {int (*init)(struct dt_device_node *dev,const void *data); }; +struct acpi_device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; +/* type of device supported by the driver */ +const int class_type; +/* Device initialization */ +int (*init)(const void *data); +}; + +/** +* acpi_device_init - Initialize a device +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int __init acpi_device_init (enum device_class class, +const void *data,int class_type); +/** * device_init - Initialize a device * @dev: device to initialize
@@ -78,6 +99,15 @@ __attribute__((__section__(".dev.info"))) = { \#define DT_DEVICE_END \ }; +#define ACPI_DEVICE_START (_name, _namestr, _class) \ +static const struct acpi_device_desc __dev_desc_##_name __used \ +__attribute__((__section__(".adev.info"))) = { \ + .name = _namestr, \ + .class = _class, \ + +#define ACPI_DEVICE_END \ +}; +#endif /* __ASM_ARM_DEVICE_H */ /*
Signature · 1 line
1.9.1
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Hi Parth,
Quoted 23 lines · Parth Dixit
add generic way to use device from acpi similar to the way it is supported in device tree.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/device.c | 19 +++++++++++++++++++ xen/arch/arm/xen.lds.S | 7 +++++++ xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)xen/arch/arm/device.c +1
-0@@ -22,6 +22,7 @@#include <xen/lib.h> extern const struct device_desc _sdevice[], _edevice[]; +extern const struct acpi_device_desc _asdevice[], _aedevice[];int __init device_init (struct dt_device_node *dev,enum device_class class,const void *data)
xen/arch/arm/device.c int __init device_init(struct dt_device_node *dev, enum device_class class, · line 54
Quoted 4 lines
xen/arch/arm/device.c +1
-0@@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,return -EBADF ; } +int __init acpi_device_init (enum device_class class,const void *data,int class_type)
Please explain what means class_type and how this will fit with every ACPI device tables.
AFAICT, it does only works for SPCR table used for UART device. For the GIC you've hardcoded the value and I can't find any version number in the table.
You may need to introduce another way to find the device such as a callback taking the table in parameter.
Quoted 46 lines
xen/arch/arm/device.c +17
-0+{ +const struct acpi_device_desc *desc; + +for ( desc = _asdevice; desc != _aedevice; desc++ ) + { +if ( ( desc->class != class ) && ( desc->class_type != class_type ) ) +continue ; + + +ASSERT (desc->init !=NULL ); + +return desc->init (data); + } + +return -EBADF ; +} +enum device_class device_get_class (const struct dt_device_node *dev) {const struct device_desc *desc;xen/arch/arm/xen.lds.S +7
-0@@ -100,6 +100,13 @@ SECTIONS _edevice = .; } :text + . = ALIGN(8); + .adev.info : { + _asdevice = .; + *(.adev.info) + _aedevice = .; + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : {xen/include/asm-arm/device.h +0
-0@@ -50,6 +50,27 @@ struct device_desc {int (*init)(struct dt_device_node *dev,const void *data); };
xen/include/asm-arm/device.h struct device_desc { · line 62
Quoted 10 lines
xen/include/asm-arm/device.h +10
-0+struct acpi_device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; +/* type of device supported by the driver */ +const int class_type; +/* Device initialization */ +int (*init)(const void *data); +};
Given that the number of device will be minimal in Xen, I would prefer to merge this structure into device_desc by adding the ACPI fields.
It would avoid to duplicate everything for only 2 fields changes.
Quoted 1 line
From the drivers point of view it would look like
DEVICE_START(....)
.dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ...
#endifDEVICE_END
Or something like
DEVICE_START(...)
DT_INIT(...) ACPI_INIT(...)
DEVICE_END
And ACPI_INIT will be a no-op when CONFIG_ACPI is not enabled.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Quoted 118 lines · Julien Grall
Hi Parth,
Quoted 15 lines · Parth Dixit
add generic way to use device from acpi similar to the way it is supported in device tree.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/device.c | 19 +++++++++++++++++++ xen/arch/arm/xen.lds.S | 7 +++++++ xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)xen/arch/arm/device.c +0
-0xen/arch/arm/device.c line 27
Quoted 6 lines
xen/arch/arm/device.c +1
-0@@ -22,6 +22,7 @@#include <xen/lib.h> extern const struct device_desc _sdevice[], _edevice[]; +extern const struct acpi_device_desc _asdevice[], _aedevice[]; int __init device_init(struct dt_device_node *dev, enum device_classclass,
xen/arch/arm/device.c int __init device_init(struct dt_device_node *dev,
Quoted 2 lines
xen/arch/arm/device.c +0
-0const void *data)@@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev,enum
device_classclass,xen/arch/arm/device.c int __init device_init(struct dt_device_node *dev, enum device_class class,
Quoted 4 lines
xen/arch/arm/device.c +1
-0return -EBADF ; } +int __init acpi_device_init(enum device_class class, const void *data,int
class_type)Please explain what means
class_typeand how this will fit with every ACPI device tables.AFAICT, it does only works for SPCR table used for UART device. For the GIC you've hardcoded the value and I can't find any version number in the table.
You may need to introduce another way to find the device such as a callback taking the table in parameter.
xen/arch/arm/device.c int __init device_init(struct dt_device_node *dev, enum device_class class,
Quoted 6 lines
xen/arch/arm/device.c +6
-0+{ +const struct acpi_device_desc *desc; + +for ( desc = _asdevice; desc != _aedevice; desc++ ) + { + if ( ( desc->class != class ) && ( desc->class_type !=
class_type) )Quoted 40 lines
xen/arch/arm/device.c +11
-0+continue ; + + +ASSERT (desc->init !=NULL ); + +return desc->init (data); + } + +return -EBADF ; +} +enum device_class device_get_class (const struct dt_device_node *dev) {const struct device_desc *desc;xen/arch/arm/xen.lds.S +7
-0@@ -100,6 +100,13 @@ SECTIONS _edevice = .; } :text + . = ALIGN(8); + .adev.info : { + _asdevice = .; + *(.adev.info) + _aedevice = .; + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : {xen/include/asm-arm/device.h +0
-0@@ -50,6 +50,27 @@ struct device_desc {int (*init)(struct dt_device_node *dev,const void *data); };xen/include/asm-arm/device.h struct device_desc { · line 62
Quoted 10 lines
xen/include/asm-arm/device.h +10
-0+struct acpi_device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; +/* type of device supported by the driver */ +const int class_type; +/* Device initialization */ +int (*init)(const void *data); +};Given that the number of device will be minimal in Xen, I would prefer to merge this structure into
device_descby adding the ACPI fields.It would avoid to duplicate everything for only 2 fields changes.
From the drivers point of view it would look like
DEVICE_START(....).dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ...#endif
DEVICE_ENDOr something like
Quoted 8 lines
DEVICE_START(...)DT_INIT(...) ACPI_INIT(...)
DEVICE_ENDAnd
ACPI_INITwill be a no-op whenCONFIG_ACPIis not enabled.I think we agreed not to use common structure as it had some dt specific
entries and there was scope of confusion.
Quoted 5 lines
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Hi Parth,
Quoted 34 lines · Parth Dixit
> +struct acpi_device_desc {
> + /* Device name */
> + const char *name;
> + /* Device class */
> + enum device_class class;
> + /* type of device supported by the driver */
> + const int class_type;
> + /* Device initialization */
> + int (*init)(const void *data);
> +};
Given that the number of device will be minimal in Xen, I would prefer
to merge this structure into device_desc by adding the ACPI fields.
It would avoid to duplicate everything for only 2 fields changes.
From the drivers point of view it would look like
DEVICE_START(....)
.dt_init = ...
#ifdef CONFIG_ACPI
.acpi_init = ...
#endif
DEVICE_END
Or something like
DEVICE_START(...)
DT_INIT(...)
ACPI_INIT(...)
DEVICE_END
And ACPI_INIT will be a no-op when CONFIG_ACPI is not enabled.Quoted 2 lines
I think we agreed not to use common structure as it had some dt specific entries and there was scope of confusion.
I don't remember a such agreement. So far, only compatible and init are DT specific. The rest (most of the fields) are device agnostic.
If you prefix the DT callback by dt_ (or smth else), there would be confusion and a smaller code.
Anyway, I will let Ian and Stefano gives their opinion on it.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Quoted 37 lines · Julien Grall
Hi Parth,
Quoted 33 lines · Parth Dixit
> +struct acpi_device_desc { > + /* Device name */ > + const char *name; > + /* Device class */ > + enum device_class class; > + /* type of device supported by the driver */ > + const int class_type; > + /* Device initialization */ > + int (*init)(const void *data); > +}; Given that the number of device will be minimal in Xen, I would prefer to merge this structure into device_desc by adding the ACPI fields. It would avoid to duplicate everything for only 2 fields changes. From the drivers point of view it would look like DEVICE_START(....) .dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ... #endif DEVICE_END Or something like DEVICE_START(...) DT_INIT(...) ACPI_INIT(...) DEVICE_END
Quoted 8 lines
Quoted 4 lines
And
ACPI_INITwill be a no-op whenCONFIG_ACPIis not enabled.I think we agreed not to use common structure as it had some dt specific entries and there was scope of confusion.
I don't remember a such agreement. So far, only compatible and init are DT specific. The rest (most of the fields) are device agnostic.
Adding attachment of the previous discussion
Quoted 9 lines
If you prefix the DT callback by
dt_(or smth else), there would be confusion and a smaller code.Anyway, I will let Ian and Stefano gives their opinion on it.
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Hi Parth,
Quoted 37 lines · Parth Dixit
Quoted 36 lines · Julien Grall
Quoted 35 lines · Parth Dixit
> +struct acpi_device_desc { > + /* Device name */ > + const char *name; > + /* Device class */ > + enum device_class class; > + /* type of device supported by the driver */ > + const int class_type; > + /* Device initialization */ > + int (*init)(const void *data); > +}; Given that the number of device will be minimal in Xen, I would prefer to merge this structure into device_desc by adding the ACPI fields. It would avoid to duplicate everything for only 2 fields changes. From the drivers point of view it would look like DEVICE_START(....) .dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ... #endif DEVICE_END Or something like DEVICE_START(...) DT_INIT(...) ACPI_INIT(...) DEVICE_END And ACPI_INIT will be a no-op when CONFIG_ACPI is not enabled.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
I think we agreed not to use common structure as it had some dt specific entries and there was scope of confusion.
I don't remember a such agreement. So far, only compatible and init are DT specific. The rest (most of the fields) are device agnostic.
Adding attachment of the previous discussion
Thanks. Please a give link to the conversation (such as a mail archive) rather than an attachment. I had to look on the archive to find the context of this conversation...
Also, that something useful to add in the notes of the patch (after ---).
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
Quoted 53 lines · Julien Grall
Hi Parth,
Quoted 50 lines · Parth Dixit
Quoted 47 lines · Julien Grall
Quoted 37 lines · Parth Dixit
> +struct acpi_device_desc { > + /* Device name */ > + const char *name; > + /* Device class */ > + enum device_class class; > + /* type of device supported by the driver */ > + const int class_type; > + /* Device initialization */ > + int (*init)(const void *data); > +}; Given that the number of device will be minimal in Xen, I would prefer to merge this structure into device_desc by adding the ACPI fields. It would avoid to duplicate everything for only 2 fields changes. From the drivers point of view it would look like DEVICE_START(....) .dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ... #endif DEVICE_END Or something like DEVICE_START(...) DT_INIT(...) ACPI_INIT(...) DEVICE_END And ACPI_INIT will be a no-op when CONFIG_ACPI is not enabled.Quoted 2 lines
I think we agreed not to use common structure as it had some dt specific entries and there was scope of confusion.
I don't remember a such agreement. So far, only compatible and init are DT
specific. The rest (most of the fields) are device agnostic.
Quoted 6 lines
Quoted 1 line
Adding attachment of the previous discussion
Thanks. Please a give link to the conversation (such as a mail archive) rather than an attachment. I had to look on the archive to find the context of this conversation...
ah, sorry about that, i keep forgetting that this conversation is also available in public list and i can provide a link to it.
Quoted 6 lines
Also, that something useful to add in the notes of the patch (after ---).
Regards,
--
Julien Grall
Re: [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi
+shannon
Quoted 68 lines · Parth Dixit
Quoted 53 lines · Julien Grall
Hi Parth,
Quoted 50 lines · Parth Dixit
Quoted 47 lines · Julien Grall
Quoted 37 lines · Parth Dixit
> +struct acpi_device_desc { > + /* Device name */ > + const char *name; > + /* Device class */ > + enum device_class class; > + /* type of device supported by the driver */ > + const int class_type; > + /* Device initialization */ > + int (*init)(const void *data); > +}; Given that the number of device will be minimal in Xen, I would prefer to merge this structure into device_desc by adding the ACPI fields. It would avoid to duplicate everything for only 2 fields changes. From the drivers point of view it would look like DEVICE_START(....) .dt_init = ... #ifdef CONFIG_ACPI .acpi_init = ... #endif DEVICE_END Or something like DEVICE_START(...) DT_INIT(...) ACPI_INIT(...) DEVICE_END And ACPI_INIT will be a no-op when CONFIG_ACPI is not enabled.Quoted 2 lines
I think we agreed not to use common structure as it had some dt specific entries and there was scope of confusion.
I don't remember a such agreement. So far, only compatible and init are DT
specific. The rest (most of the fields) are device agnostic.Quoted 6 lines
Quoted 1 line
Adding attachment of the previous discussion
Thanks. Please a give link to the conversation (such as a mail archive) rather than an attachment. I had to look on the archive to find the context of this conversation...
ah, sorry about that, i keep forgetting that this conversation is also available in public list and i can provide a link to it.
Quoted 6 lines
Also, that something useful to add in the notes of the patch (after ---).
Regards,
--
Julien Grall
PATCH v2 19/41 arm : acpi Add GIC specific ACPI boot support
In reply to Parth DixitACPI on Xen hypervisor uses MADT table for proper GIC initialization. It needs to parse GIC related subtables, collect CPU interface and distributor addresses and call driver initialization function (which is hardware abstraction agnostic). In a similar way, FDT initialize GICv2.
Modify MADT table to clear GICH and GICV which are not needed in Dom0.
NOTE: This commit allow to initialize GICv2 only.
--- xen/arch/arm/gic-v2.c | 132 +++++++++++++++++++++++++++++++++++++++++- xen/arch/arm/gic.c | 18 +++++- xen/drivers/char/arm-uart.c | 136 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 xen/drivers/char/arm-uart.c
xen/arch/arm/gic-v2.c +131 -1
@@ -28,6 +28,8 @@#include <xen/list.h> #include <xen/device_tree.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> +#include <acpi/actables.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h>
@@ -35,6 +37,7 @@#include <asm/io.h> #include <asm/gic.h> +#include <asm/acpi.h> /* * LR register definitions are GIC v2 specific.
@@ -692,9 +695,122 @@ static int __init dt_gicv2_init(void)return 0 ; } +#ifdef CONFIG_ACPI +static int __init +gic_acpi_parse_madt_cpu (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end)) +return -EINVAL ; + +/* Read from APIC table and fill up the GIC variables */ + + gicv2.cbase = processor->base_address; + gicv2.hbase = processor->gich_base_address; + gicv2.vbase = processor->gicv_base_address; + gicv2_info.maintenance_irq = processor->vgic_maintenance_interrupt; +if ( processor->flags &ACPI_MADT_ENABLED ) + { +if ( processor->flags &ACPI_MADT_VGIC ) +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_EDGE_BOTH ); +else +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_LEVEL_MASK ); + } + + processor->gich_base_address =0 ; + processor->gicv_base_address =0 ; + processor->vgic_maintenance_interrupt =0 ; +clean_dcache_va_range (processor,sizeof (struct acpi_madt_generic_interrupt )); + +return 0 ; +} + +static int __init +gic_acpi_parse_madt_distributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_distributor *dist; + + dist = (struct acpi_madt_generic_distributor *)header; + +if (BAD_MADT_ENTRY (dist, end)) +return -EINVAL ; + + gicv2.dbase = dist->base_address; + +return 0 ; +} + +static int __init acpi_gicv2_init (void ) +{ +acpi_status status; +struct acpi_table_header *table; +u8 checksum; +int res; + + status =acpi_get_table (ACPI_SIG_MADT ,0 , &table); + +if (ACPI_FAILURE (status) ) + { +const char *msg =acpi_format_exception (status); +printk ("\nFailed to get MADT table, %s\n" , msg); +return 1 ; + } + +/* Collect CPU base addresses */ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_cpu, table, +ACPI_MADT_TYPE_GENERIC_INTERRUPT , +0 ); +if ( res <0 ) + { +printk ("Error during GICC entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" ); +return -EINVAL ; + } + +/* +* Find distributor base address. We expect one distributor entry since +* ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. +*/ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_distributor, table, +ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , +0 ); + +if ( res <0 ) + { +printk ("Error during GICD entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" ); +return -EINVAL ; + } + + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, table), table->length); + table->checksum -= checksum; +clean_dcache_va_range (table,sizeof (struct acpi_table_header )); + +return 0 ; +} +#else +static int __init acpi_gicv2_init (void ) +{ +/* Should never reach here */ +return -EINVAL ; +} +#endif +static int gicv2_init (void ) { -dt_gicv2_init (); +if ( acpi_disabled ) +dt_gicv2_init (); +else +acpi_gicv2_init ();/* TODO: Add check on distributor, cpu size */
@@ -790,7 +906,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) .dt_match = gicv2_dt_match, .init = dt_gicv2_preinit, DT_DEVICE_END +#ifdef CONFIG_ACPI +/* Set up the GIC */ +static int __init acpi_gicv2_preinit (const void *data) +{ + gicv2_info.hw_version =GIC_V2 ; +register_gic_ops (&gicv2_ops); + +return 0 ; +} +ACPI_DEVICE_START (agicv2,"GICv2" ,DEVICE_GIC ) + .class_type = GIC_V2, + .init = acpi_gicv2_preinit, +ACPI_DEVICE_END +#endif /* * Local variables: * mode: C
xen/arch/arm/gic.c +17 -1
@@ -27,6 +27,7 @@#include <xen/softirq.h> #include <xen/list.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h>
@@ -34,6 +35,7 @@#include <asm/io.h> #include <asm/gic.h> #include <asm/vgic.h> +#include <asm/acpi.h> static void gic_restore_pending_irqs (struct vcpu *v);
@@ -261,9 +263,23 @@ void __init dt_gic_preinit(void)dt_device_set_used_by (node,DOMID_XEN ); } +static void __init acpi_gic_init (void ) +{ +int rc; + +/* NOTE: Only one GIC is supported */ +/* hardcode to gic v2 for now */ + rc =acpi_device_init (DEVICE_GIC ,NULL ,GIC_V2 ); +if ( rc ) +panic ("Unable to find compatible GIC in the ACPI table" ); +} +void __init gic_preinit (void ) { -dt_gic_preinit (); +if ( acpi_disabled ) +dt_gic_preinit (); +else +acpi_gic_init (); }/* Set up the GIC */
xen/drivers/char/arm-uart.c new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v2 19/41] arm : acpi Add GIC specific ACPI boot support
Hi Parth,
Quoted 46 lines · Parth Dixit
ACPI on Xen hypervisor uses MADT table for proper GIC initialization. It needs to parse GIC related subtables, collect CPU interface and distributor addresses and call driver initialization function (which is hardware abstraction agnostic). In a similar way, FDT initialize GICv2.
Modify MADT table to clear GICH and GICV which are not needed in Dom0.
NOTE: This commit allow to initialize GICv2 only.
Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/gic-v2.c | 132 +++++++++++++++++++++++++++++++++++++++++- xen/arch/arm/gic.c | 18 +++++- xen/drivers/char/arm-uart.c | 136 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 xen/drivers/char/arm-uart.cxen/arch/arm/gic-v2.c +3
-0@@ -28,6 +28,8 @@#include <xen/list.h> #include <xen/device_tree.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> +#include <acpi/actables.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> @@ -35,6 +37,7 @@#include <asm/io.h> #include <asm/gic.h> +#include <asm/acpi.h> /* * LR register definitions are GIC v2 specific. @@ -692,9 +695,122 @@ static int __init dt_gicv2_init(void)return 0 ; }
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 707
Quoted 10 lines
xen/arch/arm/gic-v2.c +10
-0+#ifdef CONFIG_ACPI +static int __init +gic_acpi_parse_madt_cpu (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end))
if ( ... )
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 708
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return -EINVAL ;
The indentation looks wrong.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 714
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+ +/* Read from APIC table and fill up the GIC variables */ + + gicv2.cbase = processor->base_address; + gicv2.hbase = processor->gich_base_address; + gicv2.vbase = processor->gicv_base_address;
This is per processor right? The value should be the same on each CPU as we don't support non-banked GIC.
You would have to check that each value is the same on every CPU.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 716
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ gicv2_info.maintenance_irq = processor->vgic_maintenance_interrupt; +if ( processor->flags &ACPI_MADT_ENABLED )
The check doesn't seem necessary,
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 721
Quoted 5 lines
xen/arch/arm/gic-v2.c +5
-0+ { +if ( processor->flags &ACPI_MADT_VGIC ) +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_EDGE_BOTH ); +else +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_LEVEL_MASK );
set_irq_type for local IRQ is very expensive. This should be done only one.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 727
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+ } + + processor->gich_base_address =0 ; + processor->gicv_base_address =0 ; + processor->vgic_maintenance_interrupt =0 ; +clean_dcache_va_range (processor,sizeof (struct acpi_madt_generic_interrupt ));
Same remark as for the GTDT and MADT table. This doesn't belong to the GIC initialization but DOM0 building.
Furthermore, the number of CPU for domain may be different as long as the processor->flags.
Overall, I think this table should be recreated for DOM0.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 740
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+return 0 ; +} + +static int __init +gic_acpi_parse_madt_distributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_distributor *dist; + + dist = (struct acpi_madt_generic_distributor *)header; + +if (BAD_MADT_ENTRY (dist, end))
if ( ... )
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 740
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return -EINVAL ;
The indentation looks wrong
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 753
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+ + gicv2.dbase = dist->base_address; + +return 0 ; +} + +static int __init acpi_gicv2_init (void ) +{ +acpi_status status; +struct acpi_table_header *table; +u8 checksum; +int res;
Given the usage of this variable I would rename it to count.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 754
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ + status =acpi_get_table (ACPI_SIG_MADT ,0 , &table);
For a generic ACPI device code it would make sense to pass the ACPI table in parameter as you will likely have to retrieve the same table within the same class of device (see Serial too).
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 758
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+ +if (ACPI_FAILURE (status) ) + {
Wrong indentation within the block.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 759
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+const char *msg =acpi_format_exception (status);
Missing blank line
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 760
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+printk ("\nFailed to get MADT table, %s\n" , msg);
The first "\n" is not necessary.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 761
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return 1 ;
Please return a meaningful error code.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 769
Quoted 8 lines
xen/arch/arm/gic-v2.c +8
-0+ } + +/* Collect CPU base addresses */ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_cpu, table, +ACPI_MADT_TYPE_GENERIC_INTERRUPT , +0 );
Wrong indentation
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 769
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+if ( res <0 )
0 means the no GICC which should be throwing an error too. I would replace the check by
res <= 0
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 773
Quoted 4 lines
xen/arch/arm/gic-v2.c +3
-0+ { +printk ("Error during GICC entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" );
One single printk("No valid GICC entries exists\n") would have been enough.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 785
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+return -EINVAL ; + } + +/* +* Find distributor base address. We expect one distributor entry since +* ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. +*/ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_distributor, table, +ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , +0 );
Wrong indentation
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 787
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ +if ( res <0 )
0 means no distributor which means the ACPI is not valid. I would replace the check by
res <= 0
You also need to check that we don't have multiple GICD entry.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 790
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+ { +printk ("Error during GICD entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" );
One single printk is enough.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 796
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+return -EINVAL ; + } + + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, table), table->length); + table->checksum -= checksum; +clean_dcache_va_range (table,sizeof (struct acpi_table_header ));
This is coming out of nowhere without any explanation.
I guess this is related to the change in the ACPI table for DOM0, right? If so, this should not be in the GIC initialization but in a specific DOM0 building code.
Quoted 7 lines
xen/arch/arm/gic-v2.c +7
-0+ return 0; +} +#else +static int __init acpi_gicv2_init (void ) +{ +/* Should never reach here */ +return -EINVAL ;
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 813
Quoted 10 lines
xen/arch/arm/gic-v2.c +7
-1+} +#endif +static int gicv2_init (void ) { -dt_gicv2_init (); +if ( acpi_disabled ) +dt_gicv2_init (); +else +acpi_gicv2_init ();
acpi_gicv2_init is returning an error code. You should not ignore it.
xen/arch/arm/gic-v2.c DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) · line 908
Quoted 7 lines
xen/arch/arm/gic-v2.c +0
-0/* TODO: Add check on distributor, cpu size */ @@ -790,7 +906,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) .dt_match = gicv2_dt_match, .init = dt_gicv2_preinit,DT_DEVICE_END
Missing blank line.
Quoted 39 lines
xen/arch/arm/gic-v2.c +14
-0+#ifdef CONFIG_ACPI +/* Set up the GIC */ +static int __init acpi_gicv2_preinit (const void *data) +{ + gicv2_info.hw_version =GIC_V2 ; +register_gic_ops (&gicv2_ops); + +return 0 ; +} +ACPI_DEVICE_START (agicv2,"GICv2" ,DEVICE_GIC ) + .class_type = GIC_V2, + .init = acpi_gicv2_preinit, +ACPI_DEVICE_END +#endif /* * Local variables: * mode: C xen/arch/arm/gic.c +2
-0@@ -27,6 +27,7 @@#include <xen/softirq.h> #include <xen/list.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> @@ -34,6 +35,7 @@#include <asm/io.h> #include <asm/gic.h> #include <asm/vgic.h> +#include <asm/acpi.h> static void gic_restore_pending_irqs (struct vcpu *v);
xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 266
Quoted 4 lines
xen/arch/arm/gic.c +1
-0@@ -261,9 +263,23 @@ void __init dt_gic_preinit(void)dt_device_set_used_by (node,DOMID_XEN ); } +static void __init acpi_gic_init (void )
This function should be called acpi_gic_preinit as it's used during pre-initialization.
xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 272
Quoted 6 lines
xen/arch/arm/gic.c +6
-0+{ +int rc; + +/* NOTE: Only one GIC is supported */ +/* hardcode to gic v2 for now */ + rc =acpi_device_init (DEVICE_GIC ,NULL ,GIC_V2 );
This won't work for multiple GIC later. You should not try to use a generic implementation just because it's there.
If you don't find a way to deal with genericity, I prefer a call to acpi_gicv2_preinit directly.
xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 274
Quoted 2 lines
xen/arch/arm/gic.c +2
-0+if ( rc ) +panic ("Unable to find compatible GIC in the ACPI table" );
This is not true. You check the presence of the GIC ACPI table later.
xen/drivers/char/arm-uart.c
Quoted 17 lines
xen/arch/arm/gic.c +6
-1+} +void __init gic_preinit (void ) { -dt_gic_preinit (); +if ( acpi_disabled ) +dt_gic_preinit (); +else +acpi_gic_init (); }/* Set up the GIC */ xen/drivers/char/arm-uart.c new file +0
-0
This file doesn't belong to this patch. I will review it when it will be placed in the right patch.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 19/41] arm : acpi Add GIC specific ACPI boot support
+shannon
Quoted 355 lines · Julien Grall
Hi Parth,
Quoted 46 lines · Parth Dixit
ACPI on Xen hypervisor uses MADT table for proper GIC initialization. It needs to parse GIC related subtables, collect CPU interface and distributor addresses and call driver initialization function (which is hardware abstraction agnostic). In a similar way, FDT initialize GICv2.
Modify MADT table to clear GICH and GICV which are not needed in Dom0.
NOTE: This commit allow to initialize GICv2 only.
Signed-off-by Tomasz Nowicki <[email protected]>Signed-off-by Hanjun Guo <[email protected]>Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/gic-v2.c | 132 +++++++++++++++++++++++++++++++++++++++++- xen/arch/arm/gic.c | 18 +++++- xen/drivers/char/arm-uart.c | 136 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 xen/drivers/char/arm-uart.cxen/arch/arm/gic-v2.c +3
-0@@ -28,6 +28,8 @@#include <xen/list.h> #include <xen/device_tree.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> +#include <acpi/actables.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> @@ -35,6 +37,7 @@#include <asm/io.h> #include <asm/gic.h> +#include <asm/acpi.h> /* * LR register definitions are GIC v2 specific. @@ -692,9 +695,122 @@ static int __init dt_gicv2_init(void)return 0 ; }xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 707
Quoted 10 lines
xen/arch/arm/gic-v2.c +10
-0+#ifdef CONFIG_ACPI +static int __init +gic_acpi_parse_madt_cpu (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + +if (BAD_MADT_ENTRY (processor, end))if ( ... )
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 708
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return -EINVAL ;The indentation looks wrong.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 714
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+ +/* Read from APIC table and fill up the GIC variables */ + + gicv2.cbase = processor->base_address; + gicv2.hbase = processor->gich_base_address; + gicv2.vbase = processor->gicv_base_address;This is per processor right? The value should be the same on each CPU as we don't support non-banked GIC.
You would have to check that each value is the same on every CPU.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 716
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ gicv2_info.maintenance_irq = processor->vgic_maintenance_interrupt; +if ( processor->flags &ACPI_MADT_ENABLED )The check doesn't seem necessary,
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 721
Quoted 5 lines
xen/arch/arm/gic-v2.c +5
-0+ { +if ( processor->flags &ACPI_MADT_VGIC ) +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_EDGE_BOTH ); +else +set_irq_type (gicv2_info.maintenance_irq,ACPI_IRQ_TYPE_LEVEL_MASK );
set_irq_typefor local IRQ is very expensive. This should be done only one.xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 727
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+ } + + processor->gich_base_address =0 ; + processor->gicv_base_address =0 ; + processor->vgic_maintenance_interrupt =0 ; +clean_dcache_va_range (processor,sizeof (struct acpi_madt_generic_interrupt ));Same remark as for the GTDT and MADT table. This doesn't belong to the GIC initialization but DOM0 building.
Furthermore, the number of CPU for domain may be different as long as the
processor->flags.Overall, I think this table should be recreated for DOM0.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 740
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+return 0 ; +} + +static int __init +gic_acpi_parse_madt_distributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_distributor *dist; + + dist = (struct acpi_madt_generic_distributor *)header; + +if (BAD_MADT_ENTRY (dist, end))if ( ... )
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 740
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return -EINVAL ;The indentation looks wrong
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 753
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+ + gicv2.dbase = dist->base_address; + +return 0 ; +} + +static int __init acpi_gicv2_init (void ) +{ +acpi_status status; +struct acpi_table_header *table; +u8 checksum; +int res;Given the usage of this variable I would rename it to count.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 754
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ + status =acpi_get_table (ACPI_SIG_MADT ,0 , &table);For a generic ACPI device code it would make sense to pass the ACPI table in parameter as you will likely have to retrieve the same table within the same class of device (see Serial too).
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 758
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+ +if (ACPI_FAILURE (status) ) + {Wrong indentation within the block.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 759
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+const char *msg =acpi_format_exception (status);Missing blank line
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 760
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+printk ("\nFailed to get MADT table, %s\n" , msg);The first "\n" is not necessary.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 761
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+return 1 ;Please return a meaningful error code.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 769
Quoted 8 lines
xen/arch/arm/gic-v2.c +8
-0+ } + +/* Collect CPU base addresses */ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_cpu, table, +ACPI_MADT_TYPE_GENERIC_INTERRUPT , +0 );Wrong indentation
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 769
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+if ( res <0 )0 means the no GICC which should be throwing an error too. I would replace the check by
res <= 0
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 773
Quoted 4 lines
xen/arch/arm/gic-v2.c +3
-0+ { +printk ("Error during GICC entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" );One single
printk("No valid GICC entries exists\n")would have been enough.xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 785
Quoted 12 lines
xen/arch/arm/gic-v2.c +12
-0+return -EINVAL ; + } + +/* +* Find distributor base address. We expect one distributor entry since +* ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. +*/ + res =acpi_parse_entries (ACPI_SIG_MADT , +sizeof (struct acpi_table_madt ), + gic_acpi_parse_madt_distributor, table, +ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , +0 );Wrong indentation
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 787
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ +if ( res <0 )0 means no distributor which means the ACPI is not valid. I would replace the check by
res <= 0
You also need to check that we don't have multiple GICD entry.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 790
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+ { +printk ("Error during GICD entries parsing\n" ); +printk ("\nFailed to initialize GIC IRQ controller\n" );One single printk is enough.
xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 796
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+return -EINVAL ; + } + + checksum =acpi_tb_checksum (ACPI_CAST_PTR (u8, table), table->length); + table->checksum -= checksum; +clean_dcache_va_range (table,sizeof (struct acpi_table_header ));This is coming out of nowhere without any explanation.
I guess this is related to the change in the ACPI table for DOM0, right? If so, this should not be in the GIC initialization but in a specific DOM0 building code.
Quoted 7 lines
xen/arch/arm/gic-v2.c +7
-0+ return 0; +} +#else +static int __init acpi_gicv2_init (void ) +{ +/* Should never reach here */ +return -EINVAL ;xen/arch/arm/gic-v2.c static int __init dt_gicv2_init(void) · line 813
Quoted 10 lines
xen/arch/arm/gic-v2.c +7
-1+} +#endif +static int gicv2_init (void ) { -dt_gicv2_init (); +if ( acpi_disabled ) +dt_gicv2_init (); +else +acpi_gicv2_init ();
acpi_gicv2_initis returning an error code. You should not ignore it.xen/arch/arm/gic-v2.c DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) · line 908
Quoted 7 lines
xen/arch/arm/gic-v2.c +0
-0/* TODO: Add check on distributor, cpu size */ @@ -790,7 +906,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC) .dt_match = gicv2_dt_match, .init = dt_gicv2_preinit,DT_DEVICE_END Missing blank line.
Quoted 39 lines
xen/arch/arm/gic-v2.c +14
-0+#ifdef CONFIG_ACPI +/* Set up the GIC */ +static int __init acpi_gicv2_preinit (const void *data) +{ + gicv2_info.hw_version =GIC_V2 ; +register_gic_ops (&gicv2_ops); + +return 0 ; +} +ACPI_DEVICE_START (agicv2,"GICv2" ,DEVICE_GIC ) + .class_type = GIC_V2, + .init = acpi_gicv2_preinit, +ACPI_DEVICE_END +#endif /* * Local variables: * mode: C xen/arch/arm/gic.c +2
-0@@ -27,6 +27,7 @@#include <xen/softirq.h> #include <xen/list.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> @@ -34,6 +35,7 @@#include <asm/io.h> #include <asm/gic.h> #include <asm/vgic.h> +#include <asm/acpi.h> static void gic_restore_pending_irqs (struct vcpu *v);xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 266
Quoted 4 lines
xen/arch/arm/gic.c +1
-0@@ -261,9 +263,23 @@ void __init dt_gic_preinit(void)dt_device_set_used_by (node,DOMID_XEN ); } +static void __init acpi_gic_init (void )This function should be called
acpi_gic_preinitas it's used during pre-initialization.xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 272
Quoted 6 lines
xen/arch/arm/gic.c +6
-0+{ +int rc; + +/* NOTE: Only one GIC is supported */ +/* hardcode to gic v2 for now */ + rc =acpi_device_init (DEVICE_GIC ,NULL ,GIC_V2 );This won't work for multiple GIC later. You should not try to use a generic implementation just because it's there.
If you don't find a way to deal with genericity, I prefer a call to
acpi_gicv2_preinitdirectly.xen/arch/arm/gic.c void __init dt_gic_preinit(void) · line 274
Quoted 2 lines
xen/arch/arm/gic.c +2
-0+if ( rc ) +panic ("Unable to find compatible GIC in the ACPI table" );This is not true. You check the presence of the GIC ACPI table later.
xen/drivers/char/arm-uart.c
Quoted 17 lines
xen/arch/arm/gic.c +6
-1+} +void __init gic_preinit (void ) { -dt_gic_preinit (); +if ( acpi_disabled ) +dt_gic_preinit (); +else +acpi_gic_init (); }/* Set up the GIC */ xen/drivers/char/arm-uart.c new file +0
-0This file doesn't belong to this patch. I will review it when it will be placed in the right patch.
Regards,
--
Julien Grall
PATCH v2 20/41 arm : create generic uart initialization function
In reply to Parth DixitRename dt-uart.c to arm-uart.c and create new generic uart init function. move dt_uart_init to uart_init. Refactor pl011 driver to dt and common initialization parts. This will be useful later when acpi specific uart initialization function is introduced.
--- xen/arch/arm/setup.c | 2 +- xen/drivers/char/Makefile | 2 +- xen/drivers/char/dt-uart.c | 107 --------------------------------------------- xen/drivers/char/pl011.c | 47 ++++++++++++-------- xen/include/xen/serial.h | 3 +- 5 files changed, 33 insertions(+), 128 deletions(-) delete mode 100644 xen/drivers/char/dt-uart.c
xen/arch/arm/setup.c +1 -1
@@ -771,7 +771,7 @@ void __init start_xen(unsigned long boot_phys_offset,gic_preinit (); -dt_uart_init (); +uart_init ();console_init_preirq ();console_init_ring ();
xen/drivers/char/Makefile +1 -1
@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.o
xen/drivers/char/dt-uart.c deleted +0 -107
107 lines not on this page · raw message
xen/drivers/char/pl011.c +29 -18
76 lines not on this page · raw message
xen/include/xen/serial.h +2 -1
@@ -98,6 +98,7 @@ struct uart_driver {#define SERHND_HI (1<<2)/* Mux/demux each transferred char by MSB. */ #define SERHND_LO (1<<3)/* Ditto, except that the MSB is cleared. */ #define SERHND_COOKED (1<<4)/* Newline/carriage-return translation? */ +#define SERHND_UART (0<<0)/* handler configured from ACPI */ /* Two-stage initialisation (before/after IRQ-subsystem initialisation). */ void serial_init_preirq (void );
@@ -170,7 +171,7 @@ struct ns16550_defaults {void ns16550_init (int index,struct ns16550_defaults *defaults);void ehci_dbgp_init (void ); -void __init dt_uart_init (void ); +void __init uart_init (void );struct physdev_dbgp_op ;int dbgp_op (const struct physdev_dbgp_op *);
Signature · 1 line
1.9.1
Re: [PATCH v2 20/41] arm : create generic uart initialization function
xen/drivers/char/Makefile obj-$(HAS_EXYNOS4210) += exynos4210-uart.o · line 9
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/drivers/char/Makefile +1
-1@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.o
The patch is missing the corresponding source file.
Also. uart_init() being (presumably) implemented in that file is in no way "generic" - it's still ARM specific, and hence it should be named that way.
Jan
Re: [PATCH v2 20/41] arm : create generic uart initialization function
Hi,
Quoted 11 lines · Jan Beulich
xen/drivers/char/Makefile obj-$(HAS_EXYNOS4210) += exynos4210-uart.o · line 9
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/drivers/char/Makefile +1
-1@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.oThe patch is missing the corresponding source file.
Parth, the file can be found in a previous unrelated patch:
http://lists.xen.org/archives/html/xen-devel/2015-05/msg02208.html
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 20/41] arm : create generic uart initialization function
In reply to Parth DixitHi Parth,
Quoted 4 lines · Parth Dixit
Rename
dt-uart.ctoarm-uart.cand create new generic uart init function. movedt_uart_initto uart_init.Refactor pl011 driver to dt and common initialization parts. This will be useful later when acpi specific uart initialization function is introduced.
There is 2 distinct changes in this patch:
- Introduction of the generic UART
- Refactoring of PL011
Each changes should be in a separate patch for helping the review.
Quoted 15 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/setup.c | 2 +- xen/drivers/char/Makefile | 2 +- xen/drivers/char/dt-uart.c | 107 --------------------------------------------- xen/drivers/char/pl011.c | 47 ++++++++++++-------- xen/include/xen/serial.h | 3 +- 5 files changed, 33 insertions(+), 128 deletions(-) delete mode 100644 xen/drivers/char/dt-uart.cxen/arch/arm/setup.c +0
-0
xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 774
Quoted 5 lines
xen/arch/arm/setup.c +1
-1@@ -771,7 +771,7 @@ void __init start_xen(unsigned long boot_phys_offset,gic_preinit (); -dt_uart_init (); +uart_init ();
As said by Jan, this is arm specific. I would rename into arm_uart_init.
Quoted 67 lines
xen/arch/arm/setup.c +0
-0console_init_preirq ();console_init_ring ();xen/drivers/char/Makefile +1
-1@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.oxen/drivers/char/pl011.c +24
-7@@ -225,9 +225,32 @@ static struct uart_driver __read_mostly pl011_driver = { .stop_tx = pl011_tx_stop, .vuart_info = pl011_vuart, }; +static int __init pl011_uart_init (struct pl011 *uart,u64 addr,u64 size) +{ + uart->clock_hz =0x16e3600 ; + uart->baud =BAUD_AUTO ; + uart->data_bits =8 ; + uart->parity =PARITY_NONE ; + uart->stop_bits =1 ; + + uart->regs =ioremap_nocache (addr, size); +if ( !uart->regs ) + { +printk ("pl011: Unable to map the UART memory\n" ); +return -ENOMEM ; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off =DR ; + uart->vuart.status_off =FR ; + uart->vuart.status =0 ; + +return 0 ; +}/* TODO: Parse UART config from the command line */ -static int __init pl011_uart_init (struct dt_device_node *dev, +static int __init dt_pl011_uart_init (struct dt_device_node *dev,const void *data) {const char *config = data;@@ -242,12 +265,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev, uart = &pl011_com; - uart->clock_hz =0x16e3600 ; - uart->baud =BAUD_AUTO ; - uart->data_bits =8 ; - uart->parity =PARITY_NONE ; - uart->stop_bits =1 ; - res =dt_device_get_address (dev,0 , &addr, &size);if ( res ) {
xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node *dev, · line 282
Quoted 2 lines
xen/drivers/char/pl011.c +0
-0@@ -264,19 +281,13 @@ static int __init pl011_uart_init(struct dt_device_node *dev, } uart->irq = res;
IRQ can be passed as parameters of pl011_uart_init.
Quoted 10 lines
xen/drivers/char/pl011.c +4
-4- uart->regs =ioremap_nocache (addr, size); -if ( !uart->regs ) + res =pl011_uart_init (uart, addr, size); +if ( res <0 ) { -printk ("pl011: Unable to map the UART memory\n" ); -return -ENOMEM ; +printk ("pl011: Unable to initialize\n" ); +return res;
xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node *dev, · line 292
Quoted 10 lines
xen/drivers/char/pl011.c +0
-6} - uart->vuart.base_addr = addr; - uart->vuart.size = size; - uart->vuart.data_off =DR ; - uart->vuart.status_off =FR ; - uart->vuart.status =0 ; -/* Register with generic serial driver. */ serial_register_uart (SERHND_DTUART , &pl011_driver, uart);
This could be moved in pl011_uart_init. With the other changes suggested above, you don't need anymore the variable uart here and the code would be more compact.
Quoted 15 lines
xen/drivers/char/pl011.c +1
-1@@ -293,7 +304,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst =DT_DEVICE_START (pl011,"PL011 UART" ,DEVICE_SERIAL ) .dt_match = pl011_dt_match, - .init = pl011_uart_init, + .init = dt_pl011_uart_init,DT_DEVICE_END /* xen/include/xen/serial.h +0
-0
xen/include/xen/serial.h struct uart_driver { · line 101
Quoted 4 lines
xen/include/xen/serial.h +1
-0@@ -98,6 +98,7 @@ struct uart_driver {#define SERHND_HI (1<<2)/* Mux/demux each transferred char by MSB. */ #define SERHND_LO (1<<3)/* Ditto, except that the MSB is cleared. */ #define SERHND_COOKED (1<<4)/* Newline/carriage-return translation? */ +#define SERHND_UART (0<<0)/* handler configured from ACPI */
Why did you introduce a new SERHND rather than renaming SERHND_DTUART?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 20/41] arm : create generic uart initialization function
Quoted 163 lines · Julien Grall
Hi Parth,
Quoted 4 lines · Parth Dixit
Rename
dt-uart.ctoarm-uart.cand create new generic uart init function. movedt_uart_initto uart_init.Refactor pl011 driver to dt and common initialization parts. This will be useful later when acpi specific uart initialization function is introduced.There is 2 distinct changes in this patch:
- Introduction of the generic UART
- Refactoring of PL011Each changes should be in a separate patch for helping the review.
ok, will move into seperate patches.
Quoted 5 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/setup.c | 2 +- xen/drivers/char/Makefile | 2 +- xen/drivers/char/dt-uart.c | 107---------------------------------------------
Quoted 10 lines
xen/drivers/char/pl011.c | 47 ++++++++++++-------- xen/include/xen/serial.h | 3 +- 5 files changed, 33 insertions(+), 128 deletions(-) delete mode 100644 xen/drivers/char/dt-uart.cxen/arch/arm/setup.c +0
-0xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 774
Quoted 5 lines
xen/arch/arm/setup.c +1
-1@@ -771,7 +771,7 @@ void __init start_xen(unsigned long boot_phys_offset,gic_preinit (); -dt_uart_init (); +uart_init ();As said by Jan, this is arm specific. I would rename into
arm_uart_init.xen/drivers/char/pl011.c static struct uart_driver __read_mostly
Quoted 20 lines
xen/arch/arm/setup.c +0
-0console_init_preirq ();console_init_ring ();xen/drivers/char/Makefile +1
-1@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.oxen/drivers/char/pl011.c +0
-0@@ -225,9 +225,32 @@ static struct uart_driver __read_mostly
pl011_driver= {xen/drivers/char/pl011.c static struct uart_driver __read_mostly pl011_driver = {
Quoted 4 lines
xen/drivers/char/pl011.c +1
-0.stop_tx = pl011_tx_stop, .vuart_info = pl011_vuart, }; +static int __init pl011_uart_init(struct pl011 *uart, u64 addr, u64size)
xen/drivers/char/pl011.c static int __init pl011_uart_init(struct
Quoted 30 lines
xen/drivers/char/pl011.c +23
-1+{ + uart->clock_hz =0x16e3600 ; + uart->baud =BAUD_AUTO ; + uart->data_bits =8 ; + uart->parity =PARITY_NONE ; + uart->stop_bits =1 ; + + uart->regs =ioremap_nocache (addr, size); +if ( !uart->regs ) + { +printk ("pl011: Unable to map the UART memory\n" ); +return -ENOMEM ; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off =DR ; + uart->vuart.status_off =FR ; + uart->vuart.status =0 ; + +return 0 ; +}/* TODO: Parse UART config from the command line */ -static int __init pl011_uart_init (struct dt_device_node *dev, +static int __init dt_pl011_uart_init (struct dt_device_node *dev,const void *data) {const char *config = data;@@ -242,12 +265,6 @@ static int __init pl011_uart_init(struct
dt_device_node*dev,xen/drivers/char/pl011.c static int __init pl011_uart_init(struct
Quoted 13 lines
xen/drivers/char/pl011.c +0
-6uart = &pl011_com; - uart->clock_hz =0x16e3600 ; - uart->baud =BAUD_AUTO ; - uart->data_bits =8 ; - uart->parity =PARITY_NONE ; - uart->stop_bits =1 ; - res =dt_device_get_address (dev,0 , &addr, &size);if ( res ) {@@ -264,19 +281,13 @@ static int __init pl011_uart_init(struct
dt_device_node*dev,xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node *dev, · line 282
Quoted 2 lines
xen/drivers/char/pl011.c +0
-0} uart->irq = res;IRQ can be passed as parameters of
pl011_uart_init.Quoted 10 lines
xen/drivers/char/pl011.c +4
-4- uart->regs =ioremap_nocache (addr, size); -if ( !uart->regs ) + res =pl011_uart_init (uart, addr, size); +if ( res <0 ) { -printk ("pl011: Unable to map the UART memory\n" ); -return -ENOMEM ; +printk ("pl011: Unable to initialize\n" ); +return res;xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node *dev, · line 292
Quoted 10 lines
xen/drivers/char/pl011.c +0
-6} - uart->vuart.base_addr = addr; - uart->vuart.size = size; - uart->vuart.data_off =DR ; - uart->vuart.status_off =FR ; - uart->vuart.status =0 ; -/* Register with generic serial driver. */ serial_register_uart (SERHND_DTUART , &pl011_driver, uart);This could be moved in
pl011_uart_init. With the other changes suggested above, you don't need anymore the variable uart here and the code would be more compact.xen/drivers/char/pl011.c static const struct dt_device_match pl011_dt_match[]
Quoted 2 lines
xen/drivers/char/pl011.c +0
-0@@ -293,7 +304,7 @@ static const struct dt_device_match pl011_dt_match[]
__initconst=Quoted 13 lines
xen/drivers/char/pl011.c +1
-1DT_DEVICE_START (pl011,"PL011 UART" ,DEVICE_SERIAL ) .dt_match = pl011_dt_match, - .init = pl011_uart_init, + .init = dt_pl011_uart_init,DT_DEVICE_END /* xen/include/xen/serial.h +0
-0xen/include/xen/serial.h struct uart_driver { · line 98
Quoted 1 line
xen/include/xen/serial.h +0
-0@@ -98,6 +98,7 @@ struct uart_driver {#define SERHND_HI (1<<2)/* Mux/demux each transferred char by MSB. */
xen/include/xen/serial.h struct uart_driver { · line 99
Quoted 1 line
xen/include/xen/serial.h +0
-0#define SERHND_LO (1<<3)/* Ditto, except that the MSB is cleared. */
xen/include/xen/serial.h struct uart_driver { · line 100
Quoted 1 line
xen/include/xen/serial.h +0
-0#define SERHND_COOKED (1<<4)/* Newline/carriage-return translation? */
Quoted 9 lines
xen/include/xen/serial.h struct uart_driver { · line 101
Quoted 1 line
xen/include/xen/serial.h +1
-0+#define SERHND_UART (0<<0)/* handler configured from ACPI */ Why did you introduce a new SERHND rather than renaming
SERHND_DTUART?Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 20/41] arm : create generic uart initialization function
Quoted 13 lines · Parth Dixit
On 21 May 2015 at 16:58, Julien Grall <[email protected] <mailto:[email protected]>> wrote:
Hi Parth,
On 17/05/15 21:03, Parth Dixit wrote:
> Renamedt-uart.ctoarm-uart.cand create new generic uart init function.
> movedt_uart_initto uart_init.Refactor pl011 driver to dt and common
> initialization parts. This will be useful later when acpi specific > uart initialization function is introduced.
Quoted 7 lines
There is 2 distinct changes in this patch:
- Introduction of the generic UART
- Refactoring of PL011Each changes should be in a separate patch for helping the review.
ok, will move into seperate patches.
Thank you. It would make sense to gather all the re-factoring patches in the beginning of the series. So we could push them without waiting the rest of the series.
BTW, it seems that your mail client is using tabulation for quoting which is difficult to read after a couple of back and forth. Can you try to configure it correctly to use ">"? Maybe it's because of HTML mail?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 20/41] arm : create generic uart initialization function
+shannon
Quoted 39 lines · Julien Grall
Quoted 16 lines · Parth Dixit
On 21 May 2015 at 16:58, Julien Grall <[email protected] <mailto:[email protected]>> wrote:
Hi Parth,
On 17/05/15 21:03, Parth Dixit wrote:
> Renamedt-uart.ctoarm-uart.cand create new generic uart init
function.
> movedt_uart_initto uart_init.Refactor pl011 driver to dt and
commonQuoted 2 lines
initialization parts. This will be useful later when acpi specific uart initialization function is introduced.
Quoted 7 lines
There is 2 distinct changes in this patch:
- Introduction of the generic UART
- Refactoring of PL011Each changes should be in a separate patch for helping the review.
ok, will move into seperate patches.
Thank you. It would make sense to gather all the re-factoring patches in the beginning of the series. So we could push them without waiting the rest of the series.
BTW, it seems that your mail client is using tabulation for quoting which is difficult to read after a couple of back and forth. Can you try to configure it correctly to use ">"? Maybe it's because of HTML mail?
Regards,
--
Julien Grall
PATCH v2 21/41 arm : acpi Initialize serial port from ACPI SPCR table
In reply to Parth DixitParse ACPI SPCR (Serial Port Console Redirection table) table and initialize the serial port pl011.
--- xen/drivers/char/pl011.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ xen/include/acpi/actbl2.h | 5 +++++ 2 files changed, 54 insertions(+)
xen/drivers/char/pl011.c +49 -0
@@ -27,6 +27,7 @@#include <asm/device.h> #include <xen/mm.h> #include <xen/vmap.h> +#include <xen/acpi.h> #include <asm/pl011-uart.h> #include <asm/io.h>
@@ -307,6 +308,54 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .init = dt_pl011_uart_init, DT_DEVICE_END +#ifdef CONFIG_ACPI +static int __init acpi_pl011_uart_init (const void *data) +{ +struct pl011 *uart; +acpi_status status; +struct acpi_table_spcr *spcr=NULL ; +int res; + + status =acpi_get_table (ACPI_SIG_SPCR ,0 , + (struct acpi_table_header **)&spcr); + +if (ACPI_FAILURE (status) ) + { +printk ("\nFailed to get SPCR table \n" ); +return 1 ; + } + + uart = &pl011_com; + +if ( spcr->interrupt <0 ) + { +printk ("pl011: Unable to retrieve the IRQ\n" ); +return -EINVAL ; + } + + uart->irq = spcr->interrupt; +/* trigger/polarity information is not available in spcr */ +set_irq_type (uart->irq,ACPI_IRQ_TYPE_EDGE_BOTH ); + + res =pl011_uart_init (uart, spcr->serial_port.address,PAGE_SIZE ); +if ( res <0 ) + { +printk ("pl011: Unable to initialize\n" ); +return res; + } + +/* Register with generic serial driver. */ +serial_register_uart (SERHND_UART , &pl011_driver, uart); + +return 0 ; +} + +ACPI_DEVICE_START (apl011,"PL011 UART" ,DEVICE_SERIAL ) + .class_type = ACPI_SPCR_TYPE_PL011, + .init = acpi_pl011_uart_init, +ACPI_DEVICE_END +#endif +/* * Local variables: * mode: C
xen/include/acpi/actbl2.h +5 -0
@@ -815,6 +815,11 @@ struct acpi_table_spcr {#define ACPI_SPCR_DO_NOT_DISABLE (1) +/* UART Interface type */ +#define ACPI_SPCR_TYPE_16550 0 +#define ACPI_SPCR_TYPE_16550_SUB 1 +#define ACPI_SPCR_TYPE_PL011 3 +/******************************************************************************* * * SPMI - Server Platform Management Interface table
Signature · 1 line
1.9.1
Re: [PATCH v2 21/41] arm : acpi Initialize serial port from ACPI SPCR table
Hi Parth,
Quoted 4 lines · Parth Dixit
xen/drivers/char/pl011.c +0
-0@@ -307,6 +308,54 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .init = dt_pl011_uart_init,DT_DEVICE_END
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 320
Quoted 10 lines
xen/drivers/char/pl011.c +10
-0+#ifdef CONFIG_ACPI +static int __init acpi_pl011_uart_init (const void *data) +{ +struct pl011 *uart; +acpi_status status; +struct acpi_table_spcr *spcr=NULL ; +int res; + + status =acpi_get_table (ACPI_SIG_SPCR ,0 , + (struct acpi_table_header **)&spcr);
Indentation.
And I think this could have been done in the generic UART code. Every UART driver will likely need to get the SPCR table.
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 324
Quoted 4 lines
xen/drivers/char/pl011.c +4
-0+ +if (ACPI_FAILURE (status) ) + { +printk ("\nFailed to get SPCR table \n" );
No need of the first newline and the last space.
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 330
Quoted 6 lines
xen/drivers/char/pl011.c +6
-0+return 1 ; + } + + uart = &pl011_com; + +if ( spcr->interrupt <0 )
No need of the check, the field interrupt is an u32. Is there any other way to find check if the interrupt is valid?
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 337
Quoted 7 lines
xen/drivers/char/pl011.c +7
-0+ { +printk ("pl011: Unable to retrieve the IRQ\n" ); +return -EINVAL ; + } + + uart->irq = spcr->interrupt; +/* trigger/polarity information is not available in spcr */
If so, how did you find/device that the interrupt is edge? Shouldn't we just avoid to configure it?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 21/41] arm : acpi Initialize serial port from ACPI SPCR table
+shannon
Quoted 60 lines · Julien Grall
Hi Parth,
Quoted 5 lines · Parth Dixit
xen/drivers/char/pl011.c +0
-0@@ -307,6 +308,54 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .init = dt_pl011_uart_init,DT_DEVICE_END xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 320
Quoted 10 lines
xen/drivers/char/pl011.c +10
-0+#ifdef CONFIG_ACPI +static int __init acpi_pl011_uart_init (const void *data) +{ +struct pl011 *uart; +acpi_status status; +struct acpi_table_spcr *spcr=NULL ; +int res; + + status =acpi_get_table (ACPI_SIG_SPCR ,0 , + (struct acpi_table_header **)&spcr);Indentation.
And I think this could have been done in the generic UART code. Every UART driver will likely need to get the SPCR table.
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 324
Quoted 4 lines
xen/drivers/char/pl011.c +4
-0+ +if (ACPI_FAILURE (status) ) + { +printk ("\nFailed to get SPCR table \n" );No need of the first newline and the last space.
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 330
Quoted 6 lines
xen/drivers/char/pl011.c +6
-0+return 1 ; + } + + uart = &pl011_com; + +if ( spcr->interrupt <0 )No need of the check, the field interrupt is an u32. Is there any other way to find check if the interrupt is valid?
xen/drivers/char/pl011.c DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) · line 337
Quoted 7 lines
xen/drivers/char/pl011.c +7
-0+ { +printk ("pl011: Unable to retrieve the IRQ\n" ); +return -EINVAL ; + } + + uart->irq = spcr->interrupt; +/* trigger/polarity information is not available in spcr */ If so, how did you find/device that the interrupt is edge? Shouldn't we just avoid to configure it?
Regards,
--
Julien Grall
PATCH v2 22/41 arm : acpi create min DT stub for DOM0
In reply to Parth DixitCreate a DT for DOM0 for ACPI-case only.
DT contains minmal required informations such as DOM0 bootargs, initrd, efi description table and address of uefi memory table.
Add placeholder for tables to be marked as reserved in efi table. This is requird for DT function's signature.
--- xen/arch/arm/domain_build.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/acpi.h | 10 ++++++ 2 files changed, 84 insertions(+), 1 deletion(-)
xen/arch/arm/domain_build.c +74 -1
@@ -9,6 +9,7 @@#include <asm/regs.h> #include <xen/errno.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <xen/libfdt/libfdt.h> #include <xen/guest_access.h> #include <xen/iocap.h>
@@ -18,6 +19,7 @@#include <asm/psci.h> #include <asm/setup.h> #include <asm/cpufeature.h> +#include <asm/acpi.h> #include <asm/gic.h> #include <xen/irq.h>
@@ -61,6 +63,11 @@ custom_param("dom0_mem", parse_dom0_mem);*/ #define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry)) +#ifdef CONFIG_ACPI +/* Reserve DOM0 FDT size in ACPI case only */ +#define DOM0_FDT_MIN_SIZE 4096 +#endif +struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0) {if ( opt_dom0_max_vcpus ==0 )
@@ -1211,7 +1218,68 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; } +#ifdef CONFIG_ACPI +/* +* Prepare a minimal DTB for DOM0 which contains +* bootargs, initrd, memory information, +* EFI table. +*/ +static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int new_size; +int ret; + +DPRINT ("Prepare a min DTB for DOM0\n" ); + +/* Allocate min size for DT */ + new_size =DOM0_FDT_MIN_SIZE ; + kinfo->fdt =xmalloc_bytes (DOM0_FDT_MIN_SIZE ); + +if ( kinfo->fdt ==NULL ) +return -ENOMEM ; + +/* Create a new empty DT for DOM0 */ + ret =fdt_create (kinfo->fdt, new_size); +if ( ret <0 ) + goto err; + + ret =fdt_finish_reservemap (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_begin_node (kinfo->fdt,"/" ); +if ( ret <0 ) + goto err; + + ret =fdt_property_cell (kinfo->fdt,"#address-cells" ,2 ); +if ( ret ) +return ret; + ret =fdt_property_cell (kinfo->fdt,"#size-cells" ,1 ); +if ( ret ) +return ret; + + ret =fdt_end_node (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_finish (kinfo->fdt); +if ( ret <0 ) + goto err; + +return 0 ; + + err: +printk ("Device tree generation failed (%d).\n" , ret); +xfree (kinfo->fdt); +return -EINVAL ; +} +#else +static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +return -EINVAL ; +} +#endif static int prepare_dtb (struct domain *d,struct kernel_info *kinfo) {const void *fdt;
@@ -1370,6 +1438,7 @@ int construct_dom0(struct domain *d)struct kernel_info kinfo = {};struct vcpu *saved_current;int rc, i, cpu; +struct membank tbl_add[TBL_MMAX ] = {};struct vcpu *v = d->vcpu[0 ];struct cpu_user_regs *regs = &v->arch.cpu_info->guest_cpu_user_regs;
@@ -1403,7 +1472,11 @@ int construct_dom0(struct domain *d)allocate_memory (d, &kinfo); - rc =prepare_dtb (d, &kinfo); +if (acpi_disabled) + rc =prepare_dtb (d, &kinfo); +else + rc =create_acpi_dtb (d, &kinfo, tbl_add); +if ( rc <0 )return rc;
xen/include/asm-arm/acpi.h +10 -0
@@ -50,6 +50,16 @@ static inline void disable_acpi(void) acpi_disabled =1 ; } +/* Tables marked as reserved in efi table */ +enum EFI_MEM_RES { +TBL_STAO , +TBL_XENV , +TBL_XSDT , +TBL_EFIT , +TBL_MMAP , +TBL_MMAX , +}; +#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )/**
Signature · 1 line
1.9.1
Re: [PATCH v2 22/41] arm : acpi create min DT stub for DOM0
Hi Parth,
Quoted 2 lines · Parth Dixit
Create a DT for DOM0 for ACPI-case only.
DT contains minmal required informations such as
s/minmal/minimal/
Quoted 4 lines
DOM0 bootargs, initrd, efi description table and address of uefi memory table.
Add placeholder for tables to be marked as reserved in efi table. This is requird for
s/requird/required/
Quoted 1 line
DT function's signature.
Well, you can modify later the prototype. It's usually better to define where it's used because we can understand why you need this how you will use it.
Also, a link the description of the minimal DT in the Linux doc would have been nice.
Quoted 20 lines
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/acpi.h | 10 ++++++ 2 files changed, 84 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +1
-0@@ -9,6 +9,7 @@#include <asm/regs.h> #include <xen/errno.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <xen/libfdt/libfdt.h> #include <xen/guest_access.h> #include <xen/iocap.h>
xen/arch/arm/domain_build.c line 22
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -18,6 +19,7 @@#include <asm/psci.h> #include <asm/setup.h> #include <asm/cpufeature.h> +#include <asm/acpi.h>
Not necessary, xen/acpi.h already includes asm/acpi.h
xen/arch/arm/domain_build.c custom_param("dom0_mem", parse_dom0_mem); · line 68
Quoted 10 lines
xen/arch/arm/domain_build.c +3
-0#include <asm/gic.h> #include <xen/irq.h> @@ -61,6 +63,11 @@ custom_param("dom0_mem", parse_dom0_mem);*/ #define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry)) +#ifdef CONFIG_ACPI +/* Reserve DOM0 FDT size in ACPI case only */ +#define DOM0_FDT_MIN_SIZE 4096
This can be moved within the big #ifdef CONFIG_ACPI below. Also please rename the define to show that it's ACPI specific.
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1220
Quoted 9 lines
xen/arch/arm/domain_build.c +2
-0+#endif +struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0) {if ( opt_dom0_max_vcpus ==0 )@@ -1211,7 +1218,68 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }
Newline.
Quoted 6 lines
xen/arch/arm/domain_build.c +6
-0+#ifdef CONFIG_ACPI +/* +* Prepare a minimal DTB for DOM0 which contains +* bootargs, initrd, memory information, +* EFI table. +*/
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1236
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int new_size; +int ret; + +DPRINT ("Prepare a min DTB for DOM0\n" ); + +/* Allocate min size for DT */ + new_size =DOM0_FDT_MIN_SIZE ; + kinfo->fdt =xmalloc_bytes (DOM0_FDT_MIN_SIZE );
Why not using new_size here? It would be less error-prone.
Quoted 33 lines
xen/arch/arm/domain_build.c +32
-0+ +if ( kinfo->fdt ==NULL ) +return -ENOMEM ; + +/* Create a new empty DT for DOM0 */ + ret =fdt_create (kinfo->fdt, new_size); +if ( ret <0 ) + goto err; + + ret =fdt_finish_reservemap (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_begin_node (kinfo->fdt,"/" ); +if ( ret <0 ) + goto err; + + ret =fdt_property_cell (kinfo->fdt,"#address-cells" ,2 ); +if ( ret ) +return ret; + ret =fdt_property_cell (kinfo->fdt,"#size-cells" ,1 ); +if ( ret ) +return ret; + + ret =fdt_end_node (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_finish (kinfo->fdt); +if ( ret <0 ) + goto err; +
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1279
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+return 0 ; + + err: +printk ("Device tree generation failed (%d).\n" , ret); +xfree (kinfo->fdt); + return -EINVAL; +} +#else +static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{
Please add a comment and a BUG_ON to make clear this should never be called.
Quoted 15 lines
xen/arch/arm/domain_build.c +4
-0+ return -EINVAL; +} +#endif static int prepare_dtb (struct domain *d,struct kernel_info *kinfo) {const void *fdt;@@ -1370,6 +1438,7 @@ int construct_dom0(struct domain *d)struct kernel_info kinfo = {};struct vcpu *saved_current;int rc, i, cpu; +struct membank tbl_add[TBL_MMAX ] = {};struct vcpu *v = d->vcpu[0 ];struct cpu_user_regs *regs = &v->arch.cpu_info->guest_cpu_user_regs;
xen/arch/arm/domain_build.c int construct_dom0(struct domain *d) · line 1475
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1403,7 +1472,11 @@ int construct_dom0(struct domain *d)allocate_memory (d, &kinfo); - rc =prepare_dtb (d, &kinfo); +if (acpi_disabled)
if ( ... )
Quoted 15 lines
xen/arch/arm/domain_build.c +4
-0+ rc =prepare_dtb (d, &kinfo); + else + rc =create_acpi_dtb (d, &kinfo, tbl_add); +if ( rc <0 )return rc;xen/include/asm-arm/acpi.h +0
-0@@ -50,6 +50,16 @@ static inline void disable_acpi(void) acpi_disabled =1 ; }
xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 62
Quoted 10 lines
xen/include/asm-arm/acpi.h +10
-0+/* Tables marked as reserved in efi table */ +enum EFI_MEM_RES { +TBL_STAO , +TBL_XENV , +TBL_XSDT , +TBL_EFIT , +TBL_MMAP , +TBL_MMAX , +}; +
This doesn't belong to this patch ...
xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 65
Quoted 4 lines
xen/include/asm-arm/acpi.h +0
-0#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )/**
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 22/41] arm : acpi create min DT stub for DOM0
+shannon
Quoted 202 lines · Julien Grall
Hi Parth,
Quoted 2 lines · Parth Dixit
Create a DT for DOM0 for ACPI-case only.
DT contains minmal required informations such ass/minmal/minimal/
Quoted 4 lines
DOM0 bootargs, initrd, efi description table and address of uefi memory table.
Add placeholder for tables to be marked as reserved in efi table. This is requird fors/requird/required/
Quoted 1 line
DT function's signature.
Well, you can modify later the prototype. It's usually better to define where it's used because we can understand why you need this how you will use it.
Also, a link the description of the minimal DT in the Linux doc would have been nice.
Quoted 20 lines
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/acpi.h | 10 ++++++ 2 files changed, 84 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +1
-0@@ -9,6 +9,7 @@#include <asm/regs.h> #include <xen/errno.h> #include <xen/device_tree.h> +#include <xen/acpi.h> #include <xen/libfdt/libfdt.h> #include <xen/guest_access.h> #include <xen/iocap.h> xen/arch/arm/domain_build.c line 22
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -18,6 +19,7 @@#include <asm/psci.h> #include <asm/setup.h> #include <asm/cpufeature.h> +#include <asm/acpi.h> Not necessary,
xen/acpi.halready includesasm/acpi.hxen/arch/arm/domain_build.c custom_param("dom0_mem", parse_dom0_mem); · line 68
Quoted 10 lines
xen/arch/arm/domain_build.c +3
-0#include <asm/gic.h> #include <xen/irq.h> @@ -61,6 +63,11 @@ custom_param("dom0_mem", parse_dom0_mem);*/ #define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry)) +#ifdef CONFIG_ACPI +/* Reserve DOM0 FDT size in ACPI case only */ +#define DOM0_FDT_MIN_SIZE 4096This can be moved within the big #ifdef
CONFIG_ACPIbelow. Also please rename the define to show that it's ACPI specific.xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1220
Quoted 9 lines
xen/arch/arm/domain_build.c +2
-0+#endif +struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0) {if ( opt_dom0_max_vcpus ==0 )@@ -1211,7 +1218,68 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }Newline.
Quoted 6 lines
xen/arch/arm/domain_build.c +6
-0+#ifdef CONFIG_ACPI +/* +* Prepare a minimal DTB for DOM0 which contains +* bootargs, initrd, memory information, +* EFI table. +*/ xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1236
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int new_size; +int ret; + +DPRINT ("Prepare a min DTB for DOM0\n" ); + +/* Allocate min size for DT */ + new_size =DOM0_FDT_MIN_SIZE ; + kinfo->fdt =xmalloc_bytes (DOM0_FDT_MIN_SIZE );Why not using
new_sizehere? It would be less error-prone.Quoted 33 lines
xen/arch/arm/domain_build.c +32
-0+ +if ( kinfo->fdt ==NULL ) +return -ENOMEM ; + +/* Create a new empty DT for DOM0 */ + ret =fdt_create (kinfo->fdt, new_size); +if ( ret <0 ) + goto err; + + ret =fdt_finish_reservemap (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_begin_node (kinfo->fdt,"/" ); +if ( ret <0 ) + goto err; + + ret =fdt_property_cell (kinfo->fdt,"#address-cells" ,2 ); +if ( ret ) +return ret; + ret =fdt_property_cell (kinfo->fdt,"#size-cells" ,1 ); +if ( ret ) +return ret; + + ret =fdt_end_node (kinfo->fdt); +if ( ret <0 ) + goto err; + + ret =fdt_finish (kinfo->fdt); +if ( ret <0 ) + goto err; +xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1279
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+return 0 ; + + err: +printk ("Device tree generation failed (%d).\n" , ret); +xfree (kinfo->fdt); + return -EINVAL; +} +#else +static int create_acpi_dtb (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{Please add a comment and a
BUG_ONto make clear this should never be called.Quoted 15 lines
xen/arch/arm/domain_build.c +4
-0+ return -EINVAL; +} +#endif static int prepare_dtb (struct domain *d,struct kernel_info *kinfo) {const void *fdt;@@ -1370,6 +1438,7 @@ int construct_dom0(struct domain *d)struct kernel_info kinfo = {};struct vcpu *saved_current;int rc, i, cpu; +struct membank tbl_add[TBL_MMAX ] = {};struct vcpu *v = d->vcpu[0 ];struct cpu_user_regs *regs = &v->arch.cpu_info->guest_cpu_user_regs;xen/arch/arm/domain_build.c int construct_dom0(struct domain *d) · line 1475
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1403,7 +1472,11 @@ int construct_dom0(struct domain *d)allocate_memory (d, &kinfo); - rc =prepare_dtb (d, &kinfo); +if (acpi_disabled)if ( ... )
Quoted 15 lines
xen/arch/arm/domain_build.c +4
-0+ rc =prepare_dtb (d, &kinfo); + else + rc =create_acpi_dtb (d, &kinfo, tbl_add); +if ( rc <0 )return rc;xen/include/asm-arm/acpi.h +0
-0@@ -50,6 +50,16 @@ static inline void disable_acpi(void) acpi_disabled =1 ; }xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 62
Quoted 10 lines
xen/include/asm-arm/acpi.h +10
-0+/* Tables marked as reserved in efi table */ +enum EFI_MEM_RES { +TBL_STAO , +TBL_XENV , +TBL_XSDT , +TBL_EFIT , +TBL_MMAP , +TBL_MMAX , +}; +This doesn't belong to this patch ...
xen/include/asm-arm/acpi.h static inline void disable_acpi(void) · line 65
Quoted 4 lines
xen/include/asm-arm/acpi.h +0
-0#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )/** Regards,
--
Julien Grall
PATCH v2 23/41 arm : acpi create chosen node for DOM0
In reply to Parth DixitCreate a chosen node for DOM0 with
- bootargs
- initrd
--- xen/arch/arm/domain_build.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
xen/arch/arm/domain_build.c +46 -0
@@ -1219,6 +1219,47 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +static int make_chosen_node (struct domain *d,const struct kernel_info *kinfo) +{ +int res =0 ; +const char *bootargs =NULL ; +const struct bootmodule *mod = kinfo->kernel_bootmodule; +void *fdt = kinfo->fdt; + +DPRINT ("Create bootargs chosen node\n" ); + +if ( mod && mod->cmdline[0 ] ) + bootargs = &mod->cmdline[0 ]; + + res =fdt_begin_node (fdt,"chosen" ); +if ( res ) +return res; + + res =fdt_property (fdt,"bootargs" , bootargs, (strlen (bootargs)+1 )); +if ( res ) +return res; + +/* +* If the bootloader provides an initrd, we must create a placeholder +* for the initrd properties. The values will be replaced later. +*/ +if ( mod && mod->size ) + { +u64 a =0 ; + res =fdt_property (kinfo->fdt,"linux,initrd-start" , &a,sizeof (a)); +if ( res ) +return res; + + res =fdt_property (kinfo->fdt,"linux,initrd-end" , &a,sizeof (a)); +if ( res ) +return res; + } + + res =fdt_end_node (fdt); + +return res; +} +/* * Prepare a minimal DTB for DOM0 which contains * bootargs, initrd, memory information,
@@ -1259,6 +1300,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct mif ( ret )return ret; +/* Create a chosen node for DOM0 */ + ret =make_chosen_node (d, kinfo); +if ( ret ) + goto err; + ret =fdt_end_node (kinfo->fdt);if ( ret <0 ) goto err;
Signature · 1 line
1.9.1
Re: [PATCH v2 23/41] arm : acpi create chosen node for DOM0
Hi Parth,
Quoted 3 lines · Parth Dixit
Create a chosen node for DOM0 with
- bootargs
- initrd
I would have merge this patch with #22. It doesn't contain controversial/difficult code.
Quoted 11 lines
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1224
Quoted 6 lines
xen/arch/arm/domain_build.c +3
-0@@ -1219,6 +1219,47 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +static int make_chosen_node (struct domain *d,const struct kernel_info *kinfo) +{ +int res =0 ;
Not necessary to initialize.
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1229
Quoted 5 lines
xen/arch/arm/domain_build.c +5
-0+const char *bootargs =NULL ; +const struct bootmodule *mod = kinfo->kernel_bootmodule; +void *fdt = kinfo->fdt; + +DPRINT ("Create bootargs chosen node\n" );
The name of the node is "chosen" not "bootargs chosen".
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1238
Quoted 8 lines
xen/arch/arm/domain_build.c +8
-0+ +if ( mod && mod->cmdline[0 ] ) + bootargs = &mod->cmdline[0 ]; + res =fdt_begin_node (fdt,"chosen" ); +if ( res ) +return res; + + res =fdt_property (fdt,"bootargs" , bootargs, (strlen (bootargs)+1 ));
strlen(bootargs) + 1. And the ( ) around it is not necessary.
Furthermore, you are assuming that bootargs is always present here. Although if the module is not present, the variable will be NULL (see your check above) and Xen will crash.
Quoted 30 lines
xen/arch/arm/domain_build.c +24
-0+if ( res ) +return res; + +/* +* If the bootloader provides an initrd, we must create a placeholder +* for the initrd properties. The values will be replaced later. +*/ +if ( mod && mod->size ) + { +u64 a =0 ; + res =fdt_property (kinfo->fdt,"linux,initrd-start" , &a,sizeof (a)); +if ( res ) +return res; + + res =fdt_property (kinfo->fdt,"linux,initrd-end" , &a,sizeof (a)); +if ( res ) +return res; + } + + res =fdt_end_node (fdt); + +return res; +} +/* * Prepare a minimal DTB for DOM0 which contains * bootargs, initrd, memory information, @@ -1259,6 +1300,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct mif ( ret )
xen/arch/arm/domain_build.c static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct m · line 1310
Quoted 10 lines
xen/arch/arm/domain_build.c +5
-0return ret; +/* Create a chosen node for DOM0 */ + ret =make_chosen_node (d, kinfo); +if ( ret ) + goto err; + ret =fdt_end_node (kinfo->fdt);if ( ret <0 ) goto err;
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 23/41] arm : acpi create chosen node for DOM0
+shannon
Quoted 98 lines · Julien Grall
Hi Parth,
Quoted 3 lines · Parth Dixit
Create a chosen node for DOM0 with
- bootargs
- initrdI would have merge this patch with #22. It doesn't contain controversial/difficult code.
Quoted 11 lines
Signed-off-by Naresh Bhat <[email protected]>Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1224
Quoted 6 lines
xen/arch/arm/domain_build.c +3
-0@@ -1219,6 +1219,47 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +static int make_chosen_node (struct domain *d,const struct kernel_info *kinfo) +{ +int res =0 ;Not necessary to initialize.
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1229
Quoted 5 lines
xen/arch/arm/domain_build.c +5
-0+const char *bootargs =NULL ; +const struct bootmodule *mod = kinfo->kernel_bootmodule; +void *fdt = kinfo->fdt; + +DPRINT ("Create bootargs chosen node\n" );The name of the node is "chosen" not "bootargs chosen".
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1238
Quoted 8 lines
xen/arch/arm/domain_build.c +8
-0+ +if ( mod && mod->cmdline[0 ] ) + bootargs = &mod->cmdline[0 ]; + res =fdt_begin_node (fdt,"chosen" ); +if ( res ) +return res; + + res =fdt_property (fdt,"bootargs" , bootargs, (strlen (bootargs)+1 ));strlen(bootargs) + 1. And the ( ) around it is not necessary.
Furthermore, you are assuming that bootargs is always present here. Although if the module is not present, the variable will be NULL (see your check above) and Xen will crash.
Quoted 30 lines
xen/arch/arm/domain_build.c +24
-0+if ( res ) +return res; + +/* +* If the bootloader provides an initrd, we must create a placeholder +* for the initrd properties. The values will be replaced later. +*/ +if ( mod && mod->size ) + { +u64 a =0 ; + res =fdt_property (kinfo->fdt,"linux,initrd-start" , &a,sizeof (a)); +if ( res ) +return res; + + res =fdt_property (kinfo->fdt,"linux,initrd-end" , &a,sizeof (a)); +if ( res ) +return res; + } + + res =fdt_end_node (fdt); + +return res; +} +/* * Prepare a minimal DTB for DOM0 which contains * bootargs, initrd, memory information, @@ -1259,6 +1300,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct mif ( ret )xen/arch/arm/domain_build.c static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct m · line 1310
Quoted 10 lines
xen/arch/arm/domain_build.c +5
-0return ret; +/* Create a chosen node for DOM0 */ + ret =make_chosen_node (d, kinfo); +if ( ret ) + goto err; + ret =fdt_end_node (kinfo->fdt);if ( ret <0 ) goto err;Regards,
--
Julien Grall
PATCH v2 24/41 arm : acpi create efi node for DOM0
In reply to Parth DixitRSDP and memory map will be passed via efi table. DTB wil contain the address of EFI table, starting address of memory map desctiption table and description size.
Address of EFI table and memory map description is not available at the time creation of DT. Create stub entries which will be fixed later
--- xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/efi.h | 11 +++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)
xen/arch/arm/domain_build.c +50 -0
@@ -10,6 +10,7 @@#include <xen/errno.h> #include <xen/device_tree.h> #include <xen/acpi.h> +#include <xen/efi.h> #include <xen/libfdt/libfdt.h> #include <xen/guest_access.h> #include <xen/iocap.h>
@@ -1219,6 +1220,51 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +/* +* Create place holder for efi values. +* Actual values will be replaced later +*/ +static int make_efi_nodes (struct domain *d,void *fdt, +const struct kernel_info *kinfo) +{ +u64 fdt_val64; +u32 fdt_val32; +int desc_size =sizeof (struct efi_memory_desc ); +int desc_ver =EFI_MEM_DESC_V1 ; +int res; +u64 addr =0 ; + + fdt_val64 =cpu_to_fdt64 ((u64 )(uintptr_t )addr); + res =fdt_property (fdt,"linux,uefi-system-table" , + &fdt_val64,sizeof (fdt_val64)); +if ( res ) +return res; + + fdt_val64 =cpu_to_fdt64 ((u64 )(uintptr_t )addr); + res =fdt_property (fdt,"linux,uefi-mmap-start" , + &fdt_val64,sizeof (fdt_val64)); +if ( res ) +return res; + + fdt_val32 =cpu_to_fdt32 (desc_size); + res =fdt_property (fdt,"linux,uefi-mmap-size" , + &fdt_val32,sizeof (fdt_val32)); +if ( res ) +return res; + + fdt_val32 =cpu_to_fdt32 (desc_size); + res =fdt_property (fdt,"linux,uefi-mmap-desc-size" , + &fdt_val32,sizeof (fdt_val32)); +if ( res ) +return res; + + fdt_val32 =cpu_to_fdt32 (desc_ver); + res =fdt_property (fdt,"linux,uefi-mmap-desc-ver" , + &fdt_val32,sizeof (fdt_val32)); + +return res; +} +static int make_chosen_node (struct domain *d,const struct kernel_info *kinfo) {int res =0 ;
@@ -1255,6 +1301,10 @@ static int make_chosen_node(struct domain *d, const struct kernel_info *kinfo)return res; } + res =make_efi_nodes (d, fdt, kinfo); +if ( res ) +return res; + res =fdt_end_node (fdt);return res;
xen/include/xen/efi.h +10 -1
@@ -8,7 +8,7 @@extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) - +#define EFI_MEM_DESC_V1 1/* Add fields here only if they need to be referenced from non-EFI code. */ struct efi {unsigned long mps;/* MPS table */
@@ -20,6 +20,15 @@ struct efi {extern struct efi efi; +struct efi_memory_desc { +u32 type; +u32 pad; +u64 phys_addr; +u64 virt_addr; +u64 num_pages; +u64 attribute; +}; +#ifndef __ASSEMBLY__union xenpf_efi_info ;
Signature · 1 line
1.9.1
Jan Beulich
NAKRe: [PATCH v2 24/41] arm : acpi create efi node for DOM0
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/include/xen/efi.h +3
-1@@ -8,7 +8,7 @@extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) - +#define EFI_MEM_DESC_V1 1/* Add fields here only if they need to be referenced from non-EFI code. */ struct efi {unsigned long mps;/* MPS table */ @@ -20,6 +20,15 @@ struct efi {extern struct efi efi; +struct efi_memory_desc { +u32 type;
xen/include/xen/efi.h struct efi { · line 34
Quoted 10 lines
xen/include/xen/efi.h +7
-0+u32 pad; +u64 phys_addr; +u64 virt_addr; +u64 num_pages; +u64 attribute; +}; +#ifndef __ASSEMBLY__union xenpf_efi_info ;
NAK - you're supposed to use what is already there, or give a good reason why redundant declarations are needed.
Jan
Re: [PATCH v2 24/41] arm : acpi create efi node for DOM0
Quoted 28 lines · Jan Beulich
xen/include/xen/efi.h line 12
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/include/xen/efi.h +1
-1@@ -8,7 +8,7 @@extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) - +#define EFI_MEM_DESC_V1 1/* Add fields here only if they need to be referenced from non-EFI code. */
Quoted 17 lines
xen/include/xen/efi.h +9
-0struct efi {unsigned long mps;/* MPS table */ @@ -20,6 +20,15 @@ struct efi {extern struct efi efi; +struct efi_memory_desc { +u32 type; +u32 pad; +u64 phys_addr; +u64 virt_addr; +u64 num_pages; +u64 attribute; +}; +#ifndef __ASSEMBLY__
Quoted 6 lines
xen/include/xen/efi.h struct efi { · line 34
Quoted 1 line
xen/include/xen/efi.h +0
-0union xenpf_efi_info ;NAK - you're supposed to use what is already there, or give a good reason why redundant declarations are needed.
I thought efi fields that need to be refreneced from non-efi code can be
added here.
Is this not correct?
Although i am rethinking about the design so that efi tables are extracted in the common efi code and passed
to non efi code as it is done in case of device tree. I'll post rfc for that would that be okay?
Quoted 3 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 24/41] arm : acpi create efi node for DOM0
Quoted 36 lines
Quoted 1 line
Quoted 1 line · On 24.05.15 at 08:30, <[email protected]> wrote:
Quoted 33 lines · Jan Beulich
xen/include/xen/efi.h line 12
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/include/xen/efi.h +1
-1@@ -8,7 +8,7 @@extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) - +#define EFI_MEM_DESC_V1 1/* Add fields here only if they need to be referenced from non-EFI code. */
Quoted 8 lines
xen/include/xen/efi.h +2
-0struct efi {unsigned long mps;/* MPS table */ @@ -20,6 +20,15 @@ struct efi {extern struct efi efi; +struct efi_memory_desc { +u32 type;xen/include/xen/efi.h struct efi { · line 34
Quoted 10 lines
xen/include/xen/efi.h +7
-0+u32 pad; +u64 phys_addr; +u64 virt_addr; +u64 num_pages; +u64 attribute; +}; +#ifndef __ASSEMBLY__union xenpf_efi_info ;NAK - you're supposed to use what is already there, or give a good reason why redundant declarations are needed.
Quoted 7 lines
Quoted 1 line
I thought efi fields that need to be refreneced from non-efi code can be
added here.
Is this not correct?
Although i am rethinking about the design so that efi tables are extracted in the common efi code and passed
to non efi code as it is done in case of device tree. I'll post rfc for that would that be okay?
At the first glance this would seem to be the right approach.
Btw - please correct your reply style such that it is immediately clear which parts comprise your response and which parts are what you respond to (you have a misguiding > on the first line of your reply text here as well as in the reply to 02/41).
Jan
Re: [PATCH v2 24/41] arm : acpi create efi node for DOM0
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 10:21, <[email protected]> wrote:
Btw - please correct your reply style such that it is immediately clear which parts comprise your response and which parts are what you respond to (you have a misguiding > on the first line of your reply text here as well as in the reply to 02/41).
Ah, looks like this is a result of you sending HTML mails. Please stop doing so.
Jan
Re: [PATCH v2 24/41] arm : acpi create efi node for DOM0
In reply to Jan Beulich+shannon
Quoted 53 lines · Jan Beulich
Quoted 36 lines
Quoted 1 line
Quoted 1 line · On 24.05.15 at 08:30, <[email protected]> wrote:
Quoted 33 lines · Jan Beulich
xen/include/xen/efi.h line 12
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
xen/include/xen/efi.h +1
-1@@ -8,7 +8,7 @@extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) - +#define EFI_MEM_DESC_V1 1/* Add fields here only if they need to be referenced from non-EFI code. */
Quoted 8 lines
xen/include/xen/efi.h +2
-0struct efi {unsigned long mps;/* MPS table */ @@ -20,6 +20,15 @@ struct efi {extern struct efi efi; +struct efi_memory_desc { +u32 type;xen/include/xen/efi.h struct efi { · line 34
Quoted 10 lines
xen/include/xen/efi.h +7
-0+u32 pad; +u64 phys_addr; +u64 virt_addr; +u64 num_pages; +u64 attribute; +}; +#ifndef __ASSEMBLY__union xenpf_efi_info ;NAK - you're supposed to use what is already there, or give a good reason why redundant declarations are needed.
Quoted 7 lines
Quoted 1 line
I thought efi fields that need to be refreneced from non-efi code can be
added here.
Is this not correct?
Although i am rethinking about the design so that efi tables are extracted in the common efi code and passed
to non efi code as it is done in case of device tree. I'll post rfc for that would that be okay?At the first glance this would seem to be the right approach.
Btw - please correct your reply style such that it is immediately clear which parts comprise your response and which parts are what you respond to (you have a misguiding > on the first line of your reply text here as well as in the reply to 02/41).
Jan
PATCH v2 25/41 arm : acpi add status override table
In reply to Parth DixitStatus override table is used to hide devices from DOM0 that are used by xen
--- xen/include/acpi/actbl2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
xen/include/acpi/actbl2.h +14 -0
@@ -79,6 +79,7 @@#define ACPI_SIG_WDAT "WDAT"/* Watchdog Action Table */ #define ACPI_SIG_WDDT "WDDT"/* Watchdog Timer Description Table */ #define ACPI_SIG_WDRT "WDRT"/* Watchdog Resource Table */ +#define ACPI_SIG_STAO "STAO"/* Status Override Table */ #ifdef ACPI_UNDEFINED_TABLES /*
@@ -894,6 +895,19 @@ struct acpi_table_uefi { };/******************************************************************************* +* +* STAO - Status Override Table +* Version 0.3 +* +******************************************************************************/ + +struct acpi_table_stao { +struct acpi_table_header header;/* Common ACPI table header */ +u8 uart;/* Indicates presence of SPCR table */ +u8 devpath[1 ];/* Full namepath of uart device in ACPI namespace */ +}; + +/******************************************************************************* * * WAET - Windows ACPI Emulated devices Table * Version 1
Signature · 1 line
1.9.1
Re: [PATCH v2 25/41] arm : acpi add status override table
+shannon
Quoted 43 lines · Parth Dixit
Status override table is used to hide devices from DOM0 that are used by xen
Signed-off-by Parth Dixit <[email protected]>--- xen/include/acpi/actbl2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)xen/include/acpi/actbl2.h +14
-1@@ -79,6 +79,7 @@#define ACPI_SIG_WDAT "WDAT"/* Watchdog Action Table */ #define ACPI_SIG_WDDT "WDDT"/* Watchdog Timer Description Table */ #define ACPI_SIG_WDRT "WDRT"/* Watchdog Resource Table */ +#define ACPI_SIG_STAO "STAO"/* Status Override Table */ #ifdef ACPI_UNDEFINED_TABLES /* @@ -894,6 +895,19 @@ struct acpi_table_uefi { };/******************************************************************************* +* +* STAO - Status Override Table +* Version 0.3 +* +******************************************************************************/ + +struct acpi_table_stao { +struct acpi_table_header header;/* Common ACPI table header */ +u8 uart;/* Indicates presence of SPCR table */ +u8 devpath[1 ];/* Full namepath of uart device in ACPI namespace */ +}; + +/******************************************************************************* * * WAET - Windows ACPI Emulated devices Table * Version 1 -- 1.9.1
PATCH v2 26/41 arm : acpi add xen environment table
In reply to Parth DixitXen environment table is ACPI table that is used to pass grant table and event channel interrupt information to dom0.
--- xen/include/acpi/actbl2.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xen/include/acpi/actbl2.h +20 -0
@@ -80,6 +80,7 @@#define ACPI_SIG_WDDT "WDDT"/* Watchdog Timer Description Table */ #define ACPI_SIG_WDRT "WDRT"/* Watchdog Resource Table */ #define ACPI_SIG_STAO "STAO"/* Status Override Table */ +#define ACPI_SIG_XENV "XENV"/* Xen Environment Table */ #ifdef ACPI_UNDEFINED_TABLES /*
@@ -909,6 +910,25 @@ struct acpi_table_stao {/******************************************************************************* * +* XENV - Xen Environment Table +* Version 0.2 +* +******************************************************************************/ + +struct acpi_table_xenv { +struct acpi_table_header header;/* Common ACPI table header */ +u64 gnt_start;/* Starting address of Xen grant table region */ +u64 gnt_size;/* Size of Xen grant table region */ +u32 evt_intr;/* Xen event channel interrupt */ +u8 evt_intr_flag;/* Flags for event channel interrupt */ +}; + +/* Event Channel Interrupt Flags */ +#define EVT_CHN_INTR_MODE (1 << 0) +#define EVT_CHN_INTR_TRIG (1 << 1) + +/******************************************************************************* +* * WAET - Windows ACPI Emulated devices Table * Version 1 *
Signature · 1 line
1.9.1
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Xen environment table is ACPI table that is used to pass grant table and event channel interrupt information to dom0.
The documents linked to by the uefi.org web site don't look like these are final, formally acceptable definitions. I'm not sure we want to include potentially in flux things in the hypervisor when it is not clear whether by the next release these would get finalized.
Apart from that I could do with an explanation of why the XENV table is needed in the first place, considering that on x86 we get away without.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Hi Jan,
Quoted 8 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Xen environment table is ACPI table that is used to pass grant table and event channel interrupt information to dom0.
The documents linked to by the uefi.org web site don't look like these are final, formally acceptable definitions. I'm not sure we want to include potentially in flux things in the hypervisor when it is not clear whether by the next release these would get finalized.
What do you mean by "formally acceptable definitions"?
The XENV table is final and accepted as a separate table handle by Xen Project.
I would have to dig into my mail to find why we decide to only give a URL...
Quoted 3 lines
Apart from that I could do with an explanation of why the XENV table is needed in the first place, considering that on x86 we get away without.
When you boot DOM0 on ARM there is no way to know that we are running on Xen (no cpuid like, no specific boot path,...). For the device tree, we include a new node. For ACPI, this table allow us to know the we are running on Xen.
Furthermore, on x86 all these informations are passed via the start_info structure which doesn't exits on ARM. And there would be no easy way to pass it to DOM0 at startup (the memory layout is different from every board).
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 19:00, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Xen environment table is ACPI table that is used to pass grant table and event channel interrupt information to dom0.
Quoted 6 lines
Quoted 4 lines
The documents linked to by the uefi.org web site don't look like these are final, formally acceptable definitions. I'm not sure we want to include potentially in flux things in the hypervisor when it is not clear whether by the next release these would get finalized.
What do you mean by "formally acceptable definitions"?
Oops, sorry - s/acceptable/accepted/.
Quoted 4 lines
The XENV table is final and accepted as a separate table handle by Xen Project.
I would have to dig into my mail to find why we decide to only give a URL...
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
Quoted 6 lines
Quoted 3 lines
Apart from that I could do with an explanation of why the XENV table is needed in the first place, considering that on x86 we get away without.
When you boot DOM0 on ARM there is no way to know that we are running on Xen (no cpuid like, no specific boot path,...).
Iirc ARM has a CPUID like identification mechanism - why can't that be used? And if it can't be used, considering that namely ARM64 basically has virtualization support designed in from the beginning, doesn't this look like a design flaw? After all - do you really see each hypervisor kind to define their own ACPI table as a proper, scalable mechanism?
Quoted 3 lines
For the device tree, we
include a new node. For ACPI, this table allow us to know the we are running on Xen.
Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
Quoted 4 lines
Furthermore, on x86 all these informations are passed via the
start_infostructure which doesn't exits on ARM. And there would be no easy way to pass it to DOM0 at startup (the memory layout is different from every board).
There's no start_info structure for x86 HVM. And passing a pointer to the entry point in a register, or via EFI GUID (as you seem to tie together ACPI and EFI presence) could have done the same.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Hi Jan,
Quoted 15 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.05.15 at 19:00, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
Xen environment table is ACPI table that is used to pass grant table and event channel interrupt information to dom0.
Quoted 6 lines
Quoted 4 lines
The documents linked to by the uefi.org web site don't look like these are final, formally acceptable definitions. I'm not sure we want to include potentially in flux things in the hypervisor when it is not clear whether by the next release these would get finalized.
What do you mean by "formally acceptable definitions"?
Oops, sorry - s/acceptable/accepted/.
Quoted 8 lines
Quoted 4 lines
The XENV table is final and accepted as a separate table handle by Xen Project.
I would have to dig into my mail to find why we decide to only give a URL...
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Apart from that I could do with an explanation of why the XENV table is needed in the first place, considering that on x86 we get away without.
When you boot DOM0 on ARM there is no way to know that we are running on Xen (no cpuid like, no specific boot path,...).
Quoted 6 lines
Iirc ARM has a CPUID like identification mechanism - why can't that be used? And if it can't be used, considering that namely ARM64 basically has virtualization support designed in from the beginning, doesn't this look like a design flaw? After all - do you really see each hypervisor kind to define their own ACPI table as a proper, scalable mechanism?
The ARM CPUID describe the hardware but doesn't offer the opportunity to extend it as x86 in order to expose Hypervisor specific CPUID.
I know there was some discussion about adding Hypervisor CPUID but so far it's not in the spec. We have to deal with it.
Quoted 8 lines
Quoted 3 lines
For the device tree, we
include a new node. For ACPI, this table allow us to know the we are running on Xen.Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
The "OEMx" could have clashed with the one provided by the hardware.
With a separate signature reserved ("XENV" is reserved since ACPI 6.0) we avoid any clash.
Quoted 8 lines
Quoted 4 lines
Furthermore, on x86 all these informations are passed via the
start_infostructure which doesn't exits on ARM. And there would be no easy way to pass it to DOM0 at startup (the memory layout is different from every board).There's no
start_infostructure for x86 HVM. And passing a pointer to the entry point in a register, or via EFI GUID (as you seem to tie together ACPI and EFI presence) could have done the same.
The entry point register is not an option. The current impact of XEN ARM in the OS is very miminal and mostly self-contained. We would like to keep the same impact with the ACPI support.
There was some concerns about exposing start_info to ARM. I don't exactly remember which one. I will let Ian, Stefano answer to this.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
And Citriy+Linaro are the standardizing body here? With no-one else involved?
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
For the device tree, we
include a new node. For ACPI, this table allow us to know the we are running on Xen.Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
And Citriy+Linaro are the standardizing body here? With no-one else involved?
The content of this table is handled by Xen Project and can be modified at our convenience during the review process.
Quoted 1 line
From the ACPI perspective, only the signature has been reserved in order
to avoid someone else using it.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
For the device tree, we
include a new node. For ACPI, this table allow us to know the we are running on Xen.Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
Quoted 4 lines
Quoted 2 lines
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
It would still be necessary to expose the event channel, grant table region...
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:52, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
And Citriy+Linaro are the standardizing body here? With no-one else involved?
The content of this table is handled by Xen Project and can be modified at our convenience during the review process.
Now that reads as if the table contents and layout are _not_ stable yet.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
It would still be necessary to expose the event channel, grant table region...
Sure, but once you know you run on Xen you could retrieve it via hypercall if there's no other means.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:52, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
And Citriy+Linaro are the standardizing body here? With no-one else involved?
The content of this table is handled by Xen Project and can be modified at our convenience during the review process.
Now that reads as if the table contents and layout are _not_ stable yet.
Sorry for been confusing.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
If at all possible - yes please, in favor of any custom tables.
It would still be necessary to expose the event channel, grant table region...
Sure, but once you know you run on Xen you could retrieve it via hypercall if there's no other means.
Good point.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 36 lines · Julien Grall
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:52, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
And Citriy+Linaro are the standardizing body here? With no-one else involved?
The content of this table is handled by Xen Project and can be modified at our convenience during the review process.
Now that reads as if the table contents and layout are _not_ stable yet.
Sorry for been confusing.
Quoted 13 lines
Quoted 12 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
It would still be necessary to expose the event channel, grant table region...
Quoted 6 lines
Quoted 2 lines
Sure, but once you know you run on Xen you could retrieve it via hypercall if there's no other means.
Good point.
ok, so to summarize we are going with hypercall based approach for
retreiving xen env. specific info instead of XENV table?
if yes, i'll remove xenv table and add a new patch for hypercall, please confirm.
Quoted 5 lines
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 41 lines · Parth Dixit
On 21 May 2015 at 17:11, Julien Grall <[email protected] <mailto:[email protected]>> wrote:
On 21/05/15 12:38, Jan Beulich wrote:
>>>> On 21.05.15 at 12:52, <[email protected] <mailto:[email protected]>> wrote:
>> On 21/05/15 11:46, Jan Beulich wrote:
>>>>>> On 21.05.15 at 12:34, <[email protected] <mailto:[email protected]>> wrote:
>>>> On 21/05/15 07:22, Jan Beulich wrote:
>>>>> The linked to document (on our wiki) is versioned 0.<something>,
>>>>> which doesn't look like a final stable version. The same applies to >>>>> the other (STAO?) one.
>>>>
>>>> That's a mistake in the version number. Those tables has been reviewed >>>> by Citrix and Linaro people and we agreed about the final tables.
>>>
>>> And Citriy+Linaro are the standardizing body here? With no-one
>>> else involved?
>>
>> The content of this table is handled by Xen Project and can be modified
>> at our convenience during the review process.
>
> Now that reads as if the table contents and layout are _not_
> stable yet.Sorry for been confusing.
>>>>> Which seems superseded by 6.0's hypervisor vendor identification >>>>> in FADT. And the OEM IDs in various table headers could have >>>>> served such identification purposes too, as could have "OEMx" >>>>> tables.
>>>>
>>>> ACPI 6.0 has been released few months after Parth and Naresh began to >>>> implement ACPI for Xen. We could take advantage of this new field. >>>
>>> If at all possible - yes please, in favor of any custom tables. >>
>> It would still be necessary to expose the event channel, grant table >> region...
>
Quoted 7 lines
> Sure, but once you know you run on Xen you could retrieve it via > hypercall if there's no other means.
Good point.
ok, so to summarize we are going with hypercall based approach for retreiving xen env. specific info instead of XENV table?
I would wait input from Stefano and Ian.
As we are talking about boot protocol, some maintainers such as Jan comes from the x86 world which as a different way to boot... They are not aware of all the background talk (during connect and by mail) we had and the requirements in order to make this series. Can you provide an up to date doc/wiki page to explain how every components works together (i.e UEFI, boot protocol, DT, requirements...)?
Quoted 2 lines
if yes, i'll remove xenv table and add a new patch for hypercall, please confirm.
I think we should make a consensus on the boot protocol before doing any change on this series.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 26/41] arm : acpi add xen environment table
In reply to Jan BeulichQuoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
The linked to document (on our wiki) is versioned 0.<something>, which doesn't look like a final stable version. The same applies to the other (STAO?) one.
That's a mistake in the version number. Those tables has been reviewed by Citrix and Linaro people and we agreed about the final tables.
And Citriy+Linaro are the standardizing body here? With no-one else involved?
Sorry Jan, it would have been far nicer to discuss this in public with the community, but unfortunately one needs to be a UEFI Forum member to be able to submit requests to it. Both Citrix and Linaro are.
But the good news is that now that we positively reserved a signature ("XENV") and we established that the relative table is externally handled by Xen Project, we can safely discuss the evolution of the spec in public.
But we should have sent an email to xen-devel about this sooner, sorry.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
For the device tree, we
include a new node. For ACPI, this table allow us to know the we are running on Xen.Which seems superseded by 6.0's hypervisor vendor identification in FADT. And the OEM IDs in various table headers could have served such identification purposes too, as could have "OEMx" tables.
Quoted 4 lines
Quoted 2 lines
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
Let me give you some more context.
As Julien pointed out, neither the "cpuid" like mechanism nor the existing ACPI tables seemed to fit the bill, so we thought that the best way forward was to simply add one more ACPI table to advertise the presence of Xen on the platform.
Since we have a table in our hands, we might as well use it to pass some useful information, specifically we thought that the existing information passed via device tree would be a good place to start. This is how we got to the XENV table that we have now.
In general I think that passing information via tables or data trees, that are made for this purpose, is nicer compared to using hypercalls.
Regarding stable vs non-stable, the discussion is off point. What matters is the version number. We can implement the current version of the spec, v0.2, or we can make changes to it, introduce a new version and implement that one instead. We can pick any version number we like.
I am biased because I contributed to the current spec, so I think that the version we have is reasonable, but if we want to change it that's also OK for me. In fact if you like it, I guess we could try to make it arch-independent and use it on x86 too.
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 19:34, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
Let me give you some more context.
As Julien pointed out, neither the "cpuid" like mechanism nor the existing ACPI tables seemed to fit the bill, so we thought that the best way forward was to simply add one more ACPI table to advertise the presence of Xen on the platform.
Quoted 7 lines
Since we have a table in our hands, we might as well use it to pass some useful information, specifically we thought that the existing information passed via device tree would be a good place to start. This is how we got to the XENV table that we have now.
In general I think that passing information via tables or data trees, that are made for this purpose, is nicer compared to using hypercalls.
There are certainly up and down sides to each of them. For ACPI tables, I'm particularly puzzled by the need to re-write XSDT/RSDT if you want to add a table of your own to what came from firmware. Which in turn requires the EFI configuration table to be modified or replaced. Doable, but I doubt this is a very clean approach.
If this was only for DomU (where the tables gets crafted from scratch anyway) it would be a different thing. But my understanding so far was that this is particularly also (if not exclusively) for Dom0.
Quoted 4 lines
Regarding stable vs non-stable, the discussion is off point. What matters is the version number. We can implement the current version of the spec, v0.2, or we can make changes to it, introduce a new version and implement that one instead. We can pick any version number we like.
Prior to a first consumer implementation - yes. But afterwards you need to remain backwards compatible.
Quoted 4 lines
I am biased because I contributed to the current spec, so I think that the version we have is reasonable, but if we want to change it that's also OK for me. In fact if you like it, I guess we could try to make it arch-independent and use it on x86 too.
As you may already have guessed from my earlier response - I'd rather not, unless unavoidable.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 26.05.15 at 19:34, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 21.05.15 at 12:34, <[email protected]> wrote:
ACPI 6.0 has been released few months after Parth and Naresh began to implement ACPI for Xen. We could take advantage of this new field.
If at all possible - yes please, in favor of any custom tables.
Let me give you some more context.
As Julien pointed out, neither the "cpuid" like mechanism nor the existing ACPI tables seemed to fit the bill, so we thought that the best way forward was to simply add one more ACPI table to advertise the presence of Xen on the platform.
Since we have a table in our hands, we might as well use it to pass some useful information, specifically we thought that the existing information passed via device tree would be a good place to start. This is how we got to the XENV table that we have now.
Quoted 8 lines
Quoted 2 lines
In general I think that passing information via tables or data trees, that are made for this purpose, is nicer compared to using hypercalls.
There are certainly up and down sides to each of them. For ACPI tables, I'm particularly puzzled by the need to re-write XSDT/RSDT if you want to add a table of your own to what came from firmware. Which in turn requires the EFI configuration table to be modified or replaced. Doable, but I doubt this is a very clean approach.
We already have to do stuff like that on ARM for other things too, for example we modify the GIC and timer tables.
Quoted 3 lines
If this was only for DomU (where the tables gets crafted from scratch anyway) it would be a different thing. But my understanding so far was that this is particularly also (if not exclusively) for Dom0.
Yes, your understanding is correct.
Quoted 7 lines
Quoted 4 lines
Regarding stable vs non-stable, the discussion is off point. What matters is the version number. We can implement the current version of the spec, v0.2, or we can make changes to it, introduce a new version and implement that one instead. We can pick any version number we like.
Prior to a first consumer implementation - yes. But afterwards you need to remain backwards compatible.
But this would be the same as for the hypercall, right? Except that I guess it is easier to version a table than an hypercall.
Quoted 7 lines
Quoted 4 lines
I am biased because I contributed to the current spec, so I think that the version we have is reasonable, but if we want to change it that's also OK for me. In fact if you like it, I guess we could try to make it arch-independent and use it on x86 too.
As you may already have guessed from my earlier response - I'd rather not, unless unavoidable.
Sure, we don't have to do the same thing here between x86 and ARM here. For Xen on ARM we have been trying to export a set of ACPI tables that actually matches the combination of virtual or physical hardware that Dom0 is seeing. On x86 things are different.
Let's take a closer look at this table. After the boilierplate, these are the interesting fields:
GNT Start, GNT Size
Evtchn Intr, Evtchn Intr Flags
After the table, it is clearly stated:
"The Grant Table region is optional."
and
"The Event Channel Interrupt is optional."
So I think there is no problem: we don't want to pass any info in that table? Sure, let's not pass any. We can still use it to flag the presence of Xen on the platform.
If we agree to that, we can move on to discussing whether we prefer to pass the grant table region and evtchn interrupt via XENV or another mechanism.
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 12:58, <[email protected]> wrote:
Let's take a closer look at this table. After the boilierplate, these are the interesting fields:
GNT Start, GNT Size
Evtchn Intr, Evtchn Intr FlagsAfter the table, it is clearly stated:
"The Grant Table region is optional."
Quoted 7 lines
and
"The Event Channel Interrupt is optional."
So I think there is no problem: we don't want to pass any info in that table? Sure, let's not pass any. We can still use it to flag the presence of Xen on the platform.
Even more so a reason to use what base ACPI has, without any custom table.
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 12:58, <[email protected]> wrote:
Let's take a closer look at this table. After the boilierplate, these are the interesting fields:
GNT Start, GNT Size
Evtchn Intr, Evtchn Intr FlagsAfter the table, it is clearly stated:
"The Grant Table region is optional."
and
Quoted 8 lines
Quoted 5 lines
"The Event Channel Interrupt is optional."
So I think there is no problem: we don't want to pass any info in that table? Sure, let's not pass any. We can still use it to flag the presence of Xen on the platform.
Even more so a reason to use what base ACPI has, without any custom table.
Could you please make a concrete suggestion with table names and fields?
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 14:12, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 12:58, <[email protected]> wrote:
Let's take a closer look at this table. After the boilierplate, these are the interesting fields:
GNT Start, GNT Size
Evtchn Intr, Evtchn Intr FlagsAfter the table, it is clearly stated:
"The Grant Table region is optional."
and
"The Event Channel Interrupt is optional."
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
So I think there is no problem: we don't want to pass any info in that table? Sure, let's not pass any. We can still use it to flag the presence of Xen on the platform.
Even more so a reason to use what base ACPI has, without any custom table.
Could you please make a concrete suggestion with table names and fields?
I already pointed you at 6.0's new FADT field "Hypervisor Vendor Identity".
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 14:12, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 12:58, <[email protected]> wrote:
Let's take a closer look at this table. After the boilierplate, these are the interesting fields:
GNT Start, GNT Size
Evtchn Intr, Evtchn Intr FlagsAfter the table, it is clearly stated:
"The Grant Table region is optional."
and
"The Event Channel Interrupt is optional."
So I think there is no problem: we don't want to pass any info in that table? Sure, let's not pass any. We can still use it to flag the presence of Xen on the platform.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Even more so a reason to use what base ACPI has, without any custom table.
Could you please make a concrete suggestion with table names and fields?
I already pointed you at 6.0's new FADT field "Hypervisor Vendor Identity".
OK, that is a decent alternative.
We don't have a suitable hypercall to retrieve the evtchn PPI but we could add one. Overall I still prefer the table approach, but if you really don't want it, I can live with the hypercalls.
Re: [PATCH v2 26/41] arm : acpi add xen environment table
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 12:31, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 14:12, <[email protected]> wrote:
Could you please make a concrete suggestion with table names and fields?
Quoted 8 lines
Quoted 2 lines
I already pointed you at 6.0's new FADT field "Hypervisor Vendor Identity".
OK, that is a decent alternative.
We don't have a suitable hypercall to retrieve the evtchn PPI but we could add one. Overall I still prefer the table approach, but if you really don't want it, I can live with the hypercalls.
I'm clearly not in the position to force any design decision onto the ARM side of Xen. But I continue to be of the opinion that custom tables should be a last resort approach only, which isn't warranted here (anymore).
Jan
Re: [PATCH v2 26/41] arm : acpi add xen environment table
+shannon
Quoted 21 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 12:31, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.05.15 at 14:12, <[email protected]> wrote:
Could you please make a concrete suggestion with table names and fields?
Quoted 8 lines
Quoted 2 lines
I already pointed you at 6.0's new FADT field "Hypervisor Vendor Identity".
OK, that is a decent alternative.
We don't have a suitable hypercall to retrieve the evtchn PPI but we could add one. Overall I still prefer the table approach, but if you really don't want it, I can live with the hypercalls.
I'm clearly not in the position to force any design decision onto the ARM side of Xen. But I continue to be of the opinion that custom tables should be a last resort approach only, which isn't warranted here (anymore).
Jan
PATCH v2 27/41 arm : add helper functions to map memory regions
In reply to Parth Dixitcreates a helper function for mapping with cached attributes
--- xen/arch/arm/p2m.c | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 10 ++++++++++ 2 files changed, 36 insertions(+)
xen/arch/arm/p2m.c +26 -0
@@ -1140,6 +1140,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr, +unsigned long mfn) +{ +return apply_p2m_changes (d,INSERT , +pfn_to_paddr (start_gfn), +pfn_to_paddr (start_gfn + nr), +pfn_to_paddr (mfn), +MATTR_MEM ,0 , p2m_mmio_direct, + d->arch.p2m.default_access); +} + +int unmap_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr, +unsigned long mfn) +{ +return apply_p2m_changes (d,REMOVE , +pfn_to_paddr (start_gfn), +pfn_to_paddr (start_gfn + nr), +pfn_to_paddr (mfn), +MATTR_MEM ,0 , p2m_invalid, + d->arch.p2m.default_access); +} + int map_mmio_regions(struct domain *d, unsigned long start_gfn, unsigned long nr,
xen/include/asm-arm/p2m.h +10 -0
@@ -152,6 +152,16 @@ int p2m_cache_flush(struct domain *d, xen_pfn_t start_mfn, xen_pfn_t end_mfn);/* Setup p2m RAM mapping for domain d from start-end. */ int p2m_populate_ram (struct domain *d,paddr_t start,paddr_t end); +int map_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr_mfns, +unsigned long mfn); + +int unmap_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr_mfns, +unsigned long mfn); + int guest_physmap_add_entry(struct domain *d, unsigned long gfn, unsigned long mfn,
Signature · 1 line
1.9.1
Re: [PATCH v2 27/41] arm : add helper functions to map memory regions
Hi Parth,
Quoted 13 lines · Parth Dixit
creates a helper function for mapping with cached attributes
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/p2m.c | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 10 ++++++++++ 2 files changed, 36 insertions(+)xen/arch/arm/p2m.c +0
-0
xen/arch/arm/p2m.c int p2m_populate_ram(struct domain *d, · line 1146
Quoted 7 lines
xen/arch/arm/p2m.c +4
-0@@ -1140,6 +1140,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr, +unsigned long mfn)
The name doesn't match the behavior. How the user will know that map_regions is actually using cached attribute.
Also, I would prefer a function taking the caching attribute in parameter. I would be more generic that trying to introduce a new function every time is a new attribute is required.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 27/41] arm : add helper functions to map memory regions
+shannon
Quoted 37 lines · Julien Grall
Hi Parth,
Quoted 14 lines · Parth Dixit
creates a helper function for mapping with cached attributes
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/p2m.c | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 10 ++++++++++ 2 files changed, 36 insertions(+)xen/arch/arm/p2m.c +0
-0xen/arch/arm/p2m.c int p2m_populate_ram(struct domain *d, · line 1146
Quoted 7 lines
xen/arch/arm/p2m.c +4
-0@@ -1140,6 +1140,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions (struct domain *d, +unsigned long start_gfn, +unsigned long nr, +unsigned long mfn)The name doesn't match the behavior. How the user will know that
map_regionsis actually using cached attribute.Also, I would prefer a function taking the caching attribute in parameter. I would be more generic that trying to introduce a new function every time is a new attribute is required.
Regards,
--
Julien Grall
PATCH v2 28/41 arm : acpi add efi structures to common efi header
In reply to Parth Dixitadd efi table and memory descriptor structures
to common efi header file and pass efi system table address retrieved from uefi.This is required for
creating efi table and passing memory information to DOM0
--- xen/common/efi/boot.c | 2 ++ xen/include/xen/efi.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
xen/common/efi/boot.c +2 -0
@@ -1009,6 +1009,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi.smbios3 = (long )efi_ct[i].VendorTable; } + efi.est = (long )SystemTable; +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */ dmi_efi_get_table(efi.smbios != EFI_INVALID_TABLE_ADDR ? (void *)(long)efi.smbios : NULL,
xen/include/xen/efi.h +54 -0
70 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v2 28/41] arm : acpi add efi structures to common efi header
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add efi table and memory descriptor structures
to common efi header file and pass efi system table address retrieved from uefi.This is required for
creating efi table and passing memory information to DOM0
I may be missing some background here, but from a conceptional pov I don't buy any of this. And I certainly don't agree with all of this being done in common code.
Jan
Re: [PATCH v2 28/41] arm : acpi add efi structures to common efi header
+shannon
Quoted 13 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.05.15 at 22:03, <[email protected]> wrote:
add efi table and memory descriptor structures
to common efi header file and pass efi system table address retrieved from uefi.This is required for
creating efi table and passing memory information to DOM0I may be missing some background here, but from a conceptional pov I don't buy any of this. And I certainly don't agree with all of this being done in common code.
Jan
PATCH v2 29/41 arm : acpi read acpi memory info from uefi
In reply to Parth DixitACPI memory is seperate from conventional memory and should be marked as reserved while passing to DOM0. Create a new meminfo structure to store all the acpi tables listed in uefi.
--- xen/arch/arm/domain_build.c | 2 ++ xen/arch/arm/efi/efi-boot.h | 20 +++++++++++++++++--- xen/include/asm-arm/setup.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +2 -0
@@ -42,6 +42,8 @@ static void __init parse_dom0_mem(const char *s) }custom_param ("dom0_mem" , parse_dom0_mem); +struct meminfo __initdata acpi_mem; +//#define DEBUG_DT #ifdef DEBUG_DT
xen/arch/arm/efi/efi-boot.h +17 -3
@@ -127,14 +127,16 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * {int Index;int i =0 ; +int j =0 ;EFI_MEMORY_DESCRIPTOR *desc_ptr = map;for ( Index =0 ; Index < (mmap_size / desc_size); Index++ ) { -if ( desc_ptr->Type == EfiConventionalMemory - || desc_ptr->Type == EfiBootServicesCode - || desc_ptr->Type == EfiBootServicesData ) +switch ( desc_ptr->Type ) { +case EfiConventionalMemory: +case EfiBootServicesCode: +case EfiBootServicesData:if ( i >=NR_MEM_BANKS ) { PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
@@ -144,11 +146,23 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart; bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; ++i; +break ; +case EfiACPIReclaimMemory: +if ( j >=NR_MEM_BANKS ) + { + PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS) +" acpi meminfo mem banks exhausted.\r\n" ); +break ; + } + acpi_mem.bank[j].start = desc_ptr->PhysicalStart; + acpi_mem.bank[j].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; + ++j; } desc_ptr =NextMemoryDescriptor (desc_ptr, desc_size); } bootinfo.mem.nr_banks = i; + acpi_mem.nr_banks = j;return EFI_SUCCESS ; }
xen/include/asm-arm/setup.h +1 -0
@@ -46,6 +46,7 @@ struct bootinfo { };extern struct bootinfo bootinfo; +extern struct meminfo acpi_mem;void arch_init_memory (void );
Signature · 1 line
1.9.1
Re: [PATCH v2 29/41] arm : acpi read acpi memory info from uefi
Hi Parth,
Quoted 1 line · Parth Dixit
ACPI memory is seperate from conventional memory and should
s/seperate/separate/
Quoted 15 lines
be marked as reserved while passing to DOM0. Create a new meminfo structure to store all the acpi tables listed in uefi.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 2 ++ xen/arch/arm/efi/efi-boot.h | 20 +++++++++++++++++--- xen/include/asm-arm/setup.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c static void __init parse_dom0_mem(const char *s) · line 46
Quoted 5 lines
xen/arch/arm/domain_build.c +2
-0@@ -42,6 +42,8 @@ static void __init parse_dom0_mem(const char *s) }custom_param ("dom0_mem" , parse_dom0_mem); +struct meminfo __initdata acpi_mem; +
Please protect it with an CONFIG_ACPI and please keep all the ACPI variable in the same place within this file.
Quoted 28 lines
xen/arch/arm/domain_build.c +0
-0//#define DEBUG_DT #ifdef DEBUG_DT xen/arch/arm/efi/efi-boot.h +5
-3@@ -127,14 +127,16 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * {int Index;int i =0 ; +int j =0 ;EFI_MEMORY_DESCRIPTOR *desc_ptr = map;for ( Index =0 ; Index < (mmap_size / desc_size); Index++ ) { -if ( desc_ptr->Type == EfiConventionalMemory - || desc_ptr->Type == EfiBootServicesCode - || desc_ptr->Type == EfiBootServicesData ) +switch ( desc_ptr->Type ) { +case EfiConventionalMemory: +case EfiBootServicesCode: +case EfiBootServicesData:if ( i >=NR_MEM_BANKS ) { PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
xen/arch/arm/efi/efi-boot.h static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * · line 149
Quoted 4 lines
xen/arch/arm/efi/efi-boot.h +1
-0@@ -144,11 +146,23 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart; bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; ++i; +break ;
#ifdef CONFIG_ACPI
xen/arch/arm/efi/efi-boot.h static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * · line 154
Quoted 5 lines
xen/arch/arm/efi/efi-boot.h +5
-0+case EfiACPIReclaimMemory: +if ( j >=NR_MEM_BANKS ) + { + PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS) +" acpi meminfo mem banks exhausted.\r\n" );
DOM0 will likely fail to boot if one of the ACPI region is not present because there is not enough place in the array.
Either you allocate dynamically the array or you stop booting on the platform. But a warning is not enough...
Quoted 19 lines
xen/arch/arm/efi/efi-boot.h +6
-0+break ; + } + acpi_mem.bank[j].start = desc_ptr->PhysicalStart; + acpi_mem.bank[j].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; + ++j; } desc_ptr =NextMemoryDescriptor (desc_ptr, desc_size); } bootinfo.mem.nr_banks = i; + acpi_mem.nr_banks = j;return EFI_SUCCESS ; }xen/include/asm-arm/setup.h +0
-0
xen/include/asm-arm/setup.h struct bootinfo { · line 49
Quoted 4 lines
xen/include/asm-arm/setup.h +1
-0@@ -46,6 +46,7 @@ struct bootinfo { };extern struct bootinfo bootinfo; +extern struct meminfo acpi_mem;
#ifdef CONFIG_ACPI
...
#endif
Quoted 4 lines
xen/include/asm-arm/setup.h +0
-0void arch_init_memory (void );
Signature · 1 line
Julien Grall
Re: [PATCH v2 29/41] arm : acpi read acpi memory info from uefi
+shannon
Quoted 124 lines · Julien Grall
Hi Parth,
Quoted 2 lines · Parth Dixit
ACPI memory is seperate from conventional memory and should
s/seperate/separate/
Quoted 15 lines
be marked as reserved while passing to DOM0. Create a new meminfo structure to store all the acpi tables listed in uefi.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 2 ++ xen/arch/arm/efi/efi-boot.h | 20 +++++++++++++++++--- xen/include/asm-arm/setup.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c static void __init parse_dom0_mem(const char *s) · line 46
Quoted 5 lines
xen/arch/arm/domain_build.c +2
-0@@ -42,6 +42,8 @@ static void __init parse_dom0_mem(const char *s) }custom_param ("dom0_mem" , parse_dom0_mem); +struct meminfo __initdata acpi_mem; +Please protect it with an
CONFIG_ACPIand please keep all the ACPI variable in the same place within this file.Quoted 30 lines
xen/arch/arm/domain_build.c +0
-0//#define DEBUG_DT #ifdef DEBUG_DT xen/arch/arm/efi/efi-boot.h +0
-0@@ -127,14 +127,16 @@ static EFI_STATUS __initefi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
{ int Index; int i = 0;xen/arch/arm/efi/efi-boot.h +5
-3+int j =0 ;EFI_MEMORY_DESCRIPTOR *desc_ptr = map;for ( Index =0 ; Index < (mmap_size / desc_size); Index++ ) { -if ( desc_ptr->Type == EfiConventionalMemory - || desc_ptr->Type == EfiBootServicesCode - || desc_ptr->Type == EfiBootServicesData ) +switch ( desc_ptr->Type ) { +case EfiConventionalMemory: +case EfiBootServicesCode: +case EfiBootServicesData:if ( i >=NR_MEM_BANKS ) { PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)@@ -144,11 +146,23 @@ static EFI_STATUS __initefi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
Quoted 5 lines
bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart; bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE; ++i;+ break;
#ifdef
CONFIG_ACPIxen/arch/arm/efi/efi-boot.h static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * · line 154
Quoted 5 lines
xen/arch/arm/efi/efi-boot.h +5
-0+case EfiACPIReclaimMemory: +if ( j >=NR_MEM_BANKS ) + { + PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS) +" acpi meminfo mem banks exhausted.\r\n" );DOM0 will likely fail to boot if one of the ACPI region is not present because there is not enough place in the array.
Either you allocate dynamically the array or you stop booting on the platform. But a warning is not enough...
Quoted 20 lines
xen/arch/arm/efi/efi-boot.h +4
-0+break ; + } + acpi_mem.bank[j].start = desc_ptr->PhysicalStart; + acpi_mem.bank[j].size = desc_ptr->NumberOfPages *
EFI_PAGE_SIZE;xen/arch/arm/efi/efi-boot.h +2
-0+ ++j; } desc_ptr =NextMemoryDescriptor (desc_ptr, desc_size); } bootinfo.mem.nr_banks = i; + acpi_mem.nr_banks = j;return EFI_SUCCESS ; }xen/include/asm-arm/setup.h +0
-0xen/include/asm-arm/setup.h struct bootinfo { · line 49
Quoted 4 lines
xen/include/asm-arm/setup.h +1
-0@@ -46,6 +46,7 @@ struct bootinfo { };extern struct bootinfo bootinfo; +extern struct meminfo acpi_mem;#ifdef
CONFIG_ACPI
...
#endifxen/include/asm-arm/setup.h struct bootinfo {
Quoted 4 lines
xen/include/asm-arm/setup.h +0
-0void arch_init_memory (void );--
Julien Grall
PATCH v2 30/41 arm : acpi add placeholder for acpi load address
In reply to Parth DixitEFI table, memory description table and some of acpi tables will reside in DOM0 memory. Add placeholder for starting address for loading in DOM0 and get/set acpi size helpers.
--- xen/arch/arm/acpi/lib.c | 12 ++++++++++++ xen/arch/arm/kernel.c | 5 ++++- xen/arch/arm/kernel.h | 1 + xen/include/asm-arm/acpi.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-)
xen/arch/arm/acpi/lib.c +12 -0
@@ -1,6 +1,8 @@#include <xen/acpi.h> #include <asm/mm.h> +static int acpi_len =0 ; +void __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) {
@@ -17,3 +19,13 @@ inline bool_t acpi_psci_hvc_present(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; } + +inline int get_acpi_size (void ) +{ +return acpi_len; +} + +inline void set_acpi_size (int size) +{ + acpi_len = size; +}
xen/arch/arm/kernel.c +4 -1
@@ -13,6 +13,7 @@#include <asm/byteorder.h> #include <asm/setup.h> #include <xen/libfdt/libfdt.h> +#include <xen/acpi.h> #include "kernel.h"
@@ -74,7 +75,8 @@ static void place_modules(struct kernel_info *info,const struct bootmodule *mod = info->initrd_bootmodule;const paddr_t initrd_len =ROUNDUP (mod ? mod->size :0 ,MB (2 ));const paddr_t dtb_len =ROUNDUP (fdt_totalsize (info->fdt),MB (2 )); -const paddr_t modsize = initrd_len + dtb_len; +const paddr_t acpi_len =ROUNDUP (get_acpi_size (),MB (2 )); +const paddr_t modsize = initrd_len + dtb_len + acpi_len;/* Convenient */ const paddr_t rambase = info->mem.bank[0 ].start;
@@ -119,6 +121,7 @@ static void place_modules(struct kernel_info *info, info->dtb_paddr = modbase; info->initrd_paddr = info->dtb_paddr + dtb_len; + info->acpi_paddr = info->initrd_paddr + initrd_len; }static paddr_t kernel_zimage_place (struct kernel_info *info)
xen/arch/arm/kernel.h +1 -0
@@ -26,6 +26,7 @@ struct kernel_info {const struct bootmodule *kernel_bootmodule, *initrd_bootmodule;paddr_t dtb_paddr;paddr_t initrd_paddr; +paddr_t acpi_paddr;/* loader to use for this kernel */ void (*load)(struct kernel_info *info);
xen/include/asm-arm/acpi.h +4 -0
@@ -37,11 +37,15 @@ bool_t acpi_psci_present(void);bool_t acpi_psci_hvc_present (void );void __init acpi_init_cpus (void );void __init acpi_preinit_xen_time (unsigned int generic_timer_irq[]); +int get_acpi_size (void ); +void set_acpi_size (int size);#else static inline bool_t acpi_psci_present (void ) {return false; }static inline bool_t acpi_psci_hvc_present (void ) {return false; }static inline void acpi_init_cpus (void ) { }static inline void acpi_preinit_xen_time (unsigned int generic_timer_irq[]){ } +static inline int get_acpi_size (void ){return 0 ;} +static inline void set_acpi_size (int size){}#endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */
Signature · 1 line
1.9.1
Re: [PATCH v2 30/41] arm : acpi add placeholder for acpi load address
Hi Parth,
Quoted 17 lines · Parth Dixit
EFI table, memory description table and some of acpi tables will reside in DOM0 memory. Add placeholder for starting address for loading in DOM0 and get/set acpi size helpers.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/lib.c | 12 ++++++++++++ xen/arch/arm/kernel.c | 5 ++++- xen/arch/arm/kernel.h | 1 + xen/include/asm-arm/acpi.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-)xen/arch/arm/acpi/lib.c +0
-0
xen/arch/arm/acpi/lib.c line 5
Quoted 5 lines
xen/arch/arm/acpi/lib.c +2
-0@@ -1,6 +1,8 @@#include <xen/acpi.h> #include <asm/mm.h> +static int acpi_len =0 ; +
There is no reason to type this variable signed int. Please use unsigned int.
Even better, paddr_t as you use like that after.
Quoted 7 lines
xen/arch/arm/acpi/lib.c +0
-0void __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) {@@ -17,3 +19,13 @@ inline bool_t acpi_psci_hvc_present(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; }
xen/arch/arm/acpi/lib.c inline bool_t acpi_psci_hvc_present(void) · line 31
Quoted 10 lines
xen/arch/arm/acpi/lib.c +10
-0+ +inline int get_acpi_size (void ) +{ +return acpi_len; +} + +inline void set_acpi_size (int size) +{ + acpi_len = size; +}
The variable name is misleading, acpi_len doesn't correspond to the real size of the ACPI but only whole size of the table generated by Xen.
Furthermore, based the usage I was able to find within the other patch, this variable is only used during dom0 creation and should live in kinfo.
Signature · 1 line
Julien Grall
Re: [PATCH v2 30/41] arm : acpi add placeholder for acpi load address
+shannon
Quoted 60 lines · Julien Grall
Hi Parth,
Quoted 18 lines · Parth Dixit
EFI table, memory description table and some of acpi tables will reside in DOM0 memory. Add placeholder for starting address for loading in DOM0 and get/set acpi size helpers.
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/acpi/lib.c | 12 ++++++++++++ xen/arch/arm/kernel.c | 5 ++++- xen/arch/arm/kernel.h | 1 + xen/include/asm-arm/acpi.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-)xen/arch/arm/acpi/lib.c +0
-0xen/arch/arm/acpi/lib.c line 5
Quoted 5 lines
xen/arch/arm/acpi/lib.c +2
-0@@ -1,6 +1,8 @@#include <xen/acpi.h> #include <asm/mm.h> +static int acpi_len =0 ; +There is no reason to type this variable signed int. Please use unsigned int.
Even better,
paddr_tas you use like that after.Quoted 7 lines
xen/arch/arm/acpi/lib.c +0
-0void __iomem *acpi_os_map_iomem (acpi_physical_address phys,acpi_size size) {@@ -17,3 +19,13 @@ inline bool_t acpi_psci_hvc_present(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; }xen/arch/arm/acpi/lib.c inline bool_t acpi_psci_hvc_present(void) · line 31
Quoted 10 lines
xen/arch/arm/acpi/lib.c +10
-0+ +inline int get_acpi_size (void ) +{ +return acpi_len; +} + +inline void set_acpi_size (int size) +{ + acpi_len = size; +}The variable name is misleading,
acpi_lendoesn't correspond to the real size of the ACPI but only whole size of the table generated by Xen.Furthermore, based the usage I was able to find within the other patch, this variable is only used during dom0 creation and should live in kinfo.
--
Julien Grall
PATCH v2 31/41 arm : acpi estimate memory required for acpi/efi tables
In reply to Parth DixitEstimate the memory required for loading acpi/efi tablee in DOM0. Initialize the size of acpi/efi tables.
--- xen/arch/arm/domain_build.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
xen/arch/arm/domain_build.c +53 -1
@@ -69,6 +69,9 @@ struct meminfo __initdata acpi_mem;#ifdef CONFIG_ACPI /* Reserve DOM0 FDT size in ACPI case only */ #define DOM0_FDT_MIN_SIZE 4096 +#define NR_NEW_XEN_TABLES 2 +/* Constant to indicate "Xen" in unicode u16 format */ +static const u16 XEN_EFI_FW_VENDOR [] ={0x0058 ,0x0065 ,0x006E ,0x0000 };#endif struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0)
@@ -1222,6 +1225,51 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +static int estimate_acpi_size (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int size =0 ; +u64 addr; +struct acpi_table_header *table; +struct acpi_table_rsdp *rsdp_tbl; + +set_acpi_size (size); + tbl_add[TBL_EFIT ].size =sizeof (struct efi_system_table ) + +sizeof (struct efi_config_table ) + +sizeof (XEN_EFI_FW_VENDOR ); + + tbl_add[TBL_MMAP ].size =sizeof (struct efi_memory_desc ) + *(kinfo->mem.nr_banks + acpi_mem.nr_banks +TBL_MMAX ); + tbl_add[TBL_XENV ].size =sizeof (struct acpi_table_xenv ); + tbl_add[TBL_STAO ].size =sizeof (struct acpi_table_stao ); + + addr =acpi_os_get_root_pointer (); +if ( !addr ) +return -ENODEV ; + + rsdp_tbl =acpi_os_map_memory (addr,sizeof (struct acpi_table_rsdp )); +if ( !rsdp_tbl ) +return -ENOMEM ; + + table =acpi_os_map_memory (rsdp_tbl->xsdt_physical_address, +sizeof (struct acpi_table_header )); +if ( !table ) +return -ENOMEM ; + + tbl_add[TBL_XSDT ].size = table->length + +(NR_NEW_XEN_TABLES *sizeof (acpi_native_uint) ); + tbl_add[TBL_XSDT ].start = rsdp_tbl->xsdt_physical_address; +acpi_os_unmap_memory (table,sizeof (struct acpi_table_header )); +acpi_os_unmap_memory (rsdp_tbl,sizeof (struct acpi_table_rsdp )); + size = tbl_add[TBL_EFIT ].size + + tbl_add[TBL_MMAP ].size + + tbl_add[TBL_XENV ].size + + tbl_add[TBL_STAO ].size + + tbl_add[TBL_XSDT ].size; + +set_acpi_size (size); +return 0 ; +} +/* * Create place holder for efi values. * Actual values will be replaced later
@@ -1365,7 +1413,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct mif ( ret <0 ) goto err; -return 0 ; + ret =estimate_acpi_size (d, kinfo, tbl_add); +if ( ret <0 ) + goto err; + +return 0 ; err:printk ("Device tree generation failed (%d).\n" , ret);
Signature · 1 line
1.9.1
Re: [PATCH v2 31/41] arm : acpi estimate memory required for acpi/efi tables
Hi Parth,
I think it misses a ":" between acpi and estimate.
Quoted 2 lines · Parth Dixit
Estimate the memory required for loading acpi/efi tablee in DOM0. Initialize the size of acpi/efi tables.
It needs more description...
Quoted 11 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c struct meminfo __initdata acpi_mem; · line 72
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -69,6 +69,9 @@ struct meminfo __initdata acpi_mem;#ifdef CONFIG_ACPI /* Reserve DOM0 FDT size in ACPI case only */ #define DOM0_FDT_MIN_SIZE 4096 +#define NR_NEW_XEN_TABLES 2
New table of what?
xen/arch/arm/domain_build.c struct meminfo __initdata acpi_mem; · line 74
Quoted 2 lines
xen/arch/arm/domain_build.c +2
-0+/* Constant to indicate "Xen" in unicode u16 format */ +static const u16 XEN_EFI_FW_VENDOR [] ={0x0058 ,0x0065 ,0x006E ,0x0000 };
I think you have to rework the order of your patch in this series. This kind of variable should appear where you add the EFI table and not where you estimate the size.
It would be easier to understand what it's used for.
Quoted 29 lines
xen/arch/arm/domain_build.c +22
-0#endif struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0)@@ -1222,6 +1225,51 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,return res; }#ifdef CONFIG_ACPI +static int estimate_acpi_size (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int size =0 ; +u64 addr; +struct acpi_table_header *table; +struct acpi_table_rsdp *rsdp_tbl; + +set_acpi_size (size); + tbl_add[TBL_EFIT ].size =sizeof (struct efi_system_table ) + +sizeof (struct efi_config_table ) + +sizeof (XEN_EFI_FW_VENDOR ); + + tbl_add[TBL_MMAP ].size =sizeof (struct efi_memory_desc ) + *(kinfo->mem.nr_banks + acpi_mem.nr_banks +TBL_MMAX ); + tbl_add[TBL_XENV ].size =sizeof (struct acpi_table_xenv ); + tbl_add[TBL_STAO ].size =sizeof (struct acpi_table_stao ); + + addr =acpi_os_get_root_pointer (); +if ( !addr ) +return -ENODEV ; + + rsdp_tbl =acpi_os_map_memory (addr,sizeof (struct acpi_table_rsdp ));
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1259
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+if ( !rsdp_tbl ) +return -ENOMEM ; + + table =acpi_os_map_memory (rsdp_tbl->xsdt_physical_address, +sizeof (struct acpi_table_header )); +if ( !table ) +return -ENOMEM ; + + tbl_add[TBL_XSDT ].size = table->length + +(NR_NEW_XEN_TABLES *sizeof (acpi_native_uint) );
Coding style:
+ (NR_NEW_XEN_TABLES * sizeof(acpi_native_uint);
This is also needs some explanation of the acpi_native_uint. We should be able to understand the code without have to search on the web. A reference to the doc would works too...
xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1263
Quoted 4 lines
xen/arch/arm/domain_build.c +4
-0+ tbl_add[TBL_XSDT ].start = rsdp_tbl->xsdt_physical_address; +acpi_os_unmap_memory (table,sizeof (struct acpi_table_header )); +acpi_os_unmap_memory (rsdp_tbl,sizeof (struct acpi_table_rsdp )); + size = tbl_add[TBL_EFIT ].size
The size is used to set acpi_size but this is EFI table... Please be consistent.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 31/41] arm : acpi estimate memory required for acpi/efi tables
+shannon
Quoted 107 lines · Julien Grall
Hi Parth,
I think it misses a ":" between acpi and estimate.
Quoted 3 lines · Parth Dixit
Estimate the memory required for loading acpi/efi tablee in DOM0. Initialize the size of acpi/efi tables.
It needs more description...
Quoted 12 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain_build.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c struct meminfo __initdata acpi_mem; · line 72
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -69,6 +69,9 @@ struct meminfo __initdata acpi_mem;#ifdef CONFIG_ACPI /* Reserve DOM0 FDT size in ACPI case only */ #define DOM0_FDT_MIN_SIZE 4096 +#define NR_NEW_XEN_TABLES 2New table of what?
xen/arch/arm/domain_build.c struct meminfo __initdata acpi_mem; · line 74
Quoted 2 lines
xen/arch/arm/domain_build.c +2
-0+/* Constant to indicate "Xen" in unicode u16 format */ +static const u16 XEN_EFI_FW_VENDOR [] ={0x0058 ,0x0065 ,0x006E ,0x0000 };I think you have to rework the order of your patch in this series. This kind of variable should appear where you add the EFI table and not where you estimate the size.
It would be easier to understand what it's used for.
Quoted 31 lines
xen/arch/arm/domain_build.c +22
-0#endif struct vcpu *__init alloc_dom0_vcpu0 (struct domain *dom0)@@ -1222,6 +1225,51 @@ static int handle_node(struct domain *d, structkernel_info *kinfo, return res; }#ifdef CONFIG_ACPI +static int estimate_acpi_size (struct domain *d,struct kernel_info *kinfo,struct membank tbl_add[]) +{ +int size =0 ; +u64 addr; +struct acpi_table_header *table; +struct acpi_table_rsdp *rsdp_tbl; + +set_acpi_size (size); + tbl_add[TBL_EFIT ].size =sizeof (struct efi_system_table ) + +sizeof (struct efi_config_table ) + +sizeof (XEN_EFI_FW_VENDOR ); + + tbl_add[TBL_MMAP ].size =sizeof (struct efi_memory_desc ) + *(kinfo->mem.nr_banks + acpi_mem.nr_banks +TBL_MMAX ); + tbl_add[TBL_XENV ].size =sizeof (struct acpi_table_xenv ); + tbl_add[TBL_STAO ].size =sizeof (struct acpi_table_stao ); + + addr =acpi_os_get_root_pointer (); +if ( !addr ) +return -ENODEV ; + + rsdp_tbl =acpi_os_map_memory (addr,sizeof (struct acpi_table_rsdp ));xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct · line 1261
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+if ( !rsdp_tbl ) +return -ENOMEM ; + + table =acpi_os_map_memory (rsdp_tbl->xsdt_physical_address, +sizeof (struct acpi_table_header )); +if ( !table ) +return -ENOMEM ; + + tbl_add[TBL_XSDT ].size = table->length + +(NR_NEW_XEN_TABLES *sizeof (acpi_native_uint) );Coding style:
+ (
NR_NEW_XEN_TABLES*sizeof(acpi_native_uint);This is also needs some explanation of the
acpi_native_uint. We should be able to understand the code without have to search on the web. A reference to the doc would works too...xen/arch/arm/domain_build.c static int handle_node(struct domain *d, struct kernel_info *kinfo, · line 1263
Quoted 4 lines
xen/arch/arm/domain_build.c +4
-0+ tbl_add[TBL_XSDT ].start = rsdp_tbl->xsdt_physical_address; +acpi_os_unmap_memory (table,sizeof (struct acpi_table_header )); +acpi_os_unmap_memory (rsdp_tbl,sizeof (struct acpi_table_rsdp )); + size = tbl_add[TBL_EFIT ].sizeThe size is used to set
acpi_sizebut this is EFI table... Please be consistent.Regards,
--
Julien Grall
PATCH v2 32/41 arm : acpi dynamically map mmio regions
In reply to Parth DixitIn ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
--- xen/arch/arm/traps.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)
xen/arch/arm/traps.c +50 -1
@@ -31,6 +31,7 @@#include <xen/softirq.h> #include <xen/domain_page.h> #include <xen/perfc.h> +#include <xen/acpi.h> #include <public/sched.h> #include <public/xen.h> #include <asm/debugger.h>
@@ -46,6 +47,7 @@#include "vtimer.h" #include <asm/gic.h> #include <asm/vgic.h> +#include <xen/iocap.h> /* The base of the stack must always be double-word aligned, which means * that both the kernel half of struct cpu_user_regs (which is pushed in
@@ -2336,6 +2338,47 @@ bad_insn_abort:inject_iabt_exception (regs, gva, hsr.len); } +#ifdef CONFIG_ACPI +static int map_mmio_dsdt (struct cpu_user_regs *regs, +mmio_info_t *info) +{ +int res; +u64 addr,size; +struct domain * d = current->domain; + +if ( !is_hardware_domain (d) ) +return 0 ; + + addr = info->gpa; + size =PAGE_SIZE ; + + res =iomem_permit_access (d,paddr_to_pfn (addr &PAGE_MASK ), +paddr_to_pfn (PAGE_ALIGN (addr + size -1 ))); +if ( res ) + { +printk (XENLOG_ERR "Unable to permit to dom%d access to" +" 0x%" PRIx64" - 0x%" PRIx64"\n" , + d->domain_id, + addr &PAGE_MASK ,PAGE_ALIGN (addr + size) -1 ); +return 0 ; + } + res =map_mmio_regions (d, +paddr_to_pfn (addr &PAGE_MASK ), +DIV_ROUND_UP (size,PAGE_SIZE ), +paddr_to_pfn (addr &PAGE_MASK )); +if ( res ) + { +printk (XENLOG_ERR "Unable to map 0x%" PRIx64 +" - 0x%" PRIx64" in domain %d\n" , + addr &PAGE_MASK ,PAGE_ALIGN (addr + size) -1 , + d->domain_id); +return 0 ; + } + +return 1 ; +} +#endif +static void do_trap_data_abort_guest (struct cpu_user_regs *regs,const union hsr hsr) {
@@ -2411,7 +2454,13 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs,advance_pc (regs, hsr);return ; } - +#ifdef CONFIG_ACPI +if ( !acpi_disabled ) + { +if (map_mmio_dsdt (regs, &info) ) +return ; + } +#endif bad_data_abort:inject_dabt_exception (regs, info.gva, hsr.len); }
Signature · 1 line
1.9.1
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Hi Parth,
Quoted 3 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
I'm against a such solution. Even though it's DOM0 we should avoid to allow him to map anything (RAM,...) on data abort.
During DOM0 creation, we should map anything that is not RAM and not used by Xen to DOM0. IIRC, this is how it works on x86.
I'm nearly sure we talked about it during the Linaro Connect. Please give details if you thing it won't work...
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Quoted 11 lines · Julien Grall
Hi Parth,
Quoted 4 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
I'm against a such solution. Even though it's DOM0 we should avoid to allow him to map anything (RAM,...) on data abort.
I think we agreed to this solution
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.html
Quoted 10 lines
During DOM0 creation, we should map anything that is not RAM and not used by Xen to DOM0. IIRC, this is how it works on x86.
I'm nearly sure we talked about it during the Linaro Connect. Please give details if you thing it won't work...
Regards,
--
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Hi Parth,
Quoted 10 lines · Parth Dixit
Quoted 9 lines · Julien Grall
Hi Parth,
Quoted 4 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
Quoted 4 lines
Quoted 2 lines
I'm against a such solution. Even though it's DOM0 we should avoid to allow him to map anything (RAM,...) on data abort.
I think we agreed to this solution
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.html
Firstly, this kind of link should have been put in the changelog of the patch (after ---). It helps the reviewer to know what was decided (or not) on the previous discussion. It's more true with a series of more than 40 patches...
Secondly, the thread you pointed as some discussion on it but no formal agreement about what to do. If there is no answer, it's better to do a resume and ask if anyone are agree.
Finally, what you've implemented and what was suggested by Ian is different. You are allowing any region to be mapped in DOM0 via this way. Only MMIO should be allowed.
Concerning the mapping attribute used. Based on Ard answer "The UEFI spec mandates that the memory map describes all memory in the system, so if dom0 accesses any ranges outside of that, it makes sense to just use device mappings for stage 2.". We should use by default Device Stage 2, it's safer. If it doesn't work later (because some PCI BAR may be memory, which if I wasn't able to prove), then we can think differently.
For the mapping of the MMIO to DOM0, I believe we can map any non-RAM (and any non-RAM not used by Xen) regions to DOM0 at boot time (I think x86 does that). It would keep the ACPI code contained at boot time and no difference during runtime.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
+shannon
Quoted 54 lines · Julien Grall
Hi Parth,
Quoted 14 lines · Parth Dixit
Quoted 12 lines · Julien Grall
Hi Parth,
Quoted 5 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
Quoted 6 lines
Quoted 3 lines
I'm against a such solution. Even though it's DOM0 we should avoid to allow
him to map anything (RAM,...) on data abort.I think we agreed to this solution
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.htmlFirstly, this kind of link should have been put in the changelog of the patch (after ---). It helps the reviewer to know what was decided (or not) on the previous discussion. It's more true with a series of more than 40 patches...
Secondly, the thread you pointed as some discussion on it but no formal agreement about what to do. If there is no answer, it's better to do a resume and ask if anyone are agree.
Finally, what you've implemented and what was suggested by Ian is different. You are allowing any region to be mapped in DOM0 via this way. Only MMIO should be allowed.
Concerning the mapping attribute used. Based on Ard answer "The UEFI spec mandates that the memory map describes all memory in the system, so if dom0 accesses any ranges outside of that, it makes sense
to just use device mappings for stage 2.". We should use by default Device Stage 2, it's safer. If it doesn't work later (because some PCI BAR may be memory, which if I wasn't able to prove), then we can think differently.For the mapping of the MMIO to DOM0, I believe we can map any non-RAM (and any non-RAM not used by Xen) regions to DOM0 at boot time (I think x86 does that). It would keep the ACPI code contained at boot time and no difference during runtime.
Regards,
--
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Quoted 53 lines · Parth Dixit
+shannon
Quoted 50 lines · Julien Grall
Hi Parth,
Quoted 14 lines · Parth Dixit
Quoted 12 lines · Julien Grall
Hi Parth,
Quoted 5 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
Quoted 6 lines
Quoted 3 lines
I'm against a such solution. Even though it's DOM0 we should avoid to allow
him to map anything (RAM,...) on data abort.I think we agreed to this solution
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.htmlFirstly, this kind of link should have been put in the changelog of the patch (after ---). It helps the reviewer to know what was decided (or not) on the previous discussion. It's more true with a series of more than 40 patches...
Secondly, the thread you pointed as some discussion on it but no formal agreement about what to do. If there is no answer, it's better to do a resume and ask if anyone are agree.
Finally, what you've implemented and what was suggested by Ian is different. You are allowing any region to be mapped in DOM0 via this way. Only MMIO should be allowed.
Concerning the mapping attribute used. Based on Ard answer "The UEFI spec mandates that the memory map describes all memory in the system, so if dom0 accesses any ranges outside of that, it makes sense
to just use device mappings for stage 2.". We should use by default Device Stage 2, it's safer. If it doesn't work later (because some PCI BAR may be memory, which if I wasn't able to prove), then we can think differently.For the mapping of the MMIO to DOM0, I believe we can map any non-RAM (and any non-RAM not used by Xen) regions to DOM0 at boot time (I think x86 does that). It would keep the ACPI code contained at boot time and no difference during runtime.
But How do we get the MMIO information of the devices in DSDT table? If we want to parse DSDT table, we must introduce AML interpreter, IIUC.
Julien, do you have any other ideas?
Thanks,
Signature · 1 line
Shannon
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Hi Shannon,
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.
regards
parth
Quoted 65 lines · Shannon Zhao
Quoted 53 lines · Parth Dixit
+shannon
Quoted 50 lines · Julien Grall
Hi Parth,
Quoted 14 lines · Parth Dixit
Quoted 12 lines · Julien Grall
Hi Parth,
Quoted 5 lines · Parth Dixit
In ACPI mmio regions are described in DSDT which requires AML interpreter. Defer the mapping of mmio until DSDT is parsed in DOM0 and map mmio's dynamically at the time of request.
Quoted 6 lines
Quoted 3 lines
I'm against a such solution. Even though it's DOM0 we should avoid to allow
him to map anything (RAM,...) on data abort.I think we agreed to this solution
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.htmlFirstly, this kind of link should have been put in the changelog of the patch (after ---). It helps the reviewer to know what was decided (or not) on the previous discussion. It's more true with a series of more than 40 patches...
Secondly, the thread you pointed as some discussion on it but no formal agreement about what to do. If there is no answer, it's better to do a resume and ask if anyone are agree.
Finally, what you've implemented and what was suggested by Ian is different. You are allowing any region to be mapped in DOM0 via this way. Only MMIO should be allowed.
Concerning the mapping attribute used. Based on Ard answer "The UEFI spec mandates that the memory map describes all memory in the system, so if dom0 accesses any ranges outside of that, it makes sense
to just use device mappings for stage 2.". We should use by default Device Stage 2, it's safer. If it doesn't work later (because some PCI BAR may be memory, which if I wasn't able to prove), then we can think differently.For the mapping of the MMIO to DOM0, I believe we can map any non-RAM (and any non-RAM not used by Xen) regions to DOM0 at boot time (I think x86 does that). It would keep the ACPI code contained at boot time and no difference during runtime.
But How do we get the MMIO information of the devices in DSDT table? If we want to parse DSDT table, we must introduce AML interpreter, IIUC.
Julien, do you have any other ideas?
Thanks,
--
Shannon
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Hi,
Quoted 5 lines · Parth Dixit
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.
Which page are you talking about? I only found [1] speaking about ACPI. Although, there is nothing related to MMIO mapping.
Anyway, it's not possible to get the list of MMIOs regions for the UEFI System Memory Map (see the mail you forward on the ML [2]).
Although, based on the RAM region we could deduce a possible set of MMIO regions. It would be fine to mapped unused region in memory and we could take advantage of super page.
While you are speaking about the wiki page. Can one of you update the wiki page about the boot protocol? Jan had some concerns about the solution you choose (see [3] to not mention the whole thread).
We need to agree on the boot protocol before going further on this series.
To speed up the upstreaming process, it would be nice if you start a thread about the boot protocol for ACPI with relevant people in CCed. The main goal will be to explain why you choose this way. This will be the base to talk about improvement and/or answer concerns for other people.
FWIW, Jan also suggested a different boot protocol based on the x86 one. It may be good for you to see whether it would fit ACPI on ARM.
Regards,
[1] https://wiki.linaro.org/LEG/Engineering/Virtualization/ACPI_on_Xen
[2]
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.html
[3] http://lists.xen.org/archives/html/xen-devel/2015-05/msg02736.html
Signature · 1 line
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Quoted 11 lines · Julien Grall
Hi,
Quoted 5 lines · Parth Dixit
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.Which page are you talking about? I only found [1] speaking about ACPI. Although, there is nothing related to MMIO mapping.
I was talking about the reasons for not using aml interpreter in xen.
Quoted 31 lines
Anyway, it's not possible to get the list of MMIOs regions for the UEFI System Memory Map (see the mail you forward on the ML [2]). Although, based on the RAM region we could deduce a possible set of MMIO regions. It would be fine to mapped unused region in memory and we could take advantage of super page.
While you are speaking about the wiki page. Can one of you update the wiki page about the boot protocol? Jan had some concerns about the solution you choose (see [3] to not mention the whole thread).
We need to agree on the boot protocol before going further on this series.
To speed up the upstreaming process, it would be nice if you start a thread about the boot protocol for ACPI with relevant people in CCed. The main goal will be to explain why you choose this way. This will be the base to talk about improvement and/or answer concerns for other people.
FWIW, Jan also suggested a different boot protocol based on the x86 one. It may be good for you to see whether it would fit ACPI on ARM.
Regards,
[1] https://wiki.linaro.org/LEG/Engineering/Virtualization/ACPI_on_Xen
[2]
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.html[3] http://lists.xen.org/archives/html/xen-devel/2015-05/msg02736.html
--
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
In reply to Julien GrallQuoted 9 lines · Julien Grall
Hi,
Quoted 5 lines · Parth Dixit
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.
Quoted 8 lines
Which page are you talking about? I only found [1] speaking about ACPI. Although, there is nothing related to MMIO mapping.
Anyway, it's not possible to get the list of MMIOs regions for the UEFI System Memory Map (see the mail you forward on the ML [2]).
Although, based on the RAM region we could deduce a possible set of MMIO regions.
But I guess this will get the all regions except RAM region. And some of the regions may not exist on hardware. Is it ok to map the non-exist region to DOM0? Doesn't the map function fail?
Quoted 7 lines
It would be fine to mapped unused region in memory and we could take advantage of super page.
While you are speaking about the wiki page. Can one of you update the wiki page about the boot protocol? Jan had some concerns about the solution you choose (see [3] to not mention the whole thread).
About the XENV table, from the discussions of the thread, it seems we reach an agreement on using hypercall to tell DOM0 the grant table info and event channel irq. Right?
Quoted 7 lines
We need to agree on the boot protocol before going further on this series.
To speed up the upstreaming process, it would be nice if you start a thread about the boot protocol for ACPI with relevant people in CCed. The main goal will be to explain why you choose this way. This will be the base to talk about improvement and/or answer concerns for other people.
Ok, it's good to reach an agreement before action.
Quoted 3 lines
FWIW, Jan also suggested a different boot protocol based on the x86 one. It may be good for you to see whether it would fit ACPI on ARM.
Which boot protocol? Could you point it out? Thanks. :)
Quoted 9 lines
Regards,
[1] https://wiki.linaro.org/LEG/Engineering/Virtualization/ACPI_on_Xen
[2]
http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02059.html[3] http://lists.xen.org/archives/html/xen-devel/2015-05/msg02736.html
Signature · 1 line
Shannon
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Hi Shannon,
Quoted 13 lines · Shannon Zhao
Quoted 10 lines · Julien Grall
Quoted 5 lines · Parth Dixit
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.Which page are you talking about? I only found [1] speaking about ACPI. Although, there is nothing related to MMIO mapping.
Quoted 8 lines
Quoted 5 lines
Anyway, it's not possible to get the list of MMIOs regions for the UEFI System Memory Map (see the mail you forward on the ML [2]).
Although, based on the RAM region we could deduce a possible set of MMIO regions.
But I guess this will get the all regions except RAM region. And some of the regions may not exist on hardware. Is it ok to map the non-exist region to DOM0? Doesn't the map function fail?
I don't see a problem for it. I'm not sure what the others think about it.
The map function doesn't know if the physical region is valid or not. It's only setup the page table to allow the guest using the physical region.
If DOM0 is trying to access invalid region, it will receive a data/prefetch abort.
Quoted 4 lines
Quoted 4 lines
It would be fine to mapped unused region in memory and we could take advantage of super page.
Quoted 8 lines
Quoted 4 lines
While you are speaking about the wiki page. Can one of you update the wiki page about the boot protocol? Jan had some concerns about the solution you choose (see [3] to not mention the whole thread).
About the XENV table, from the discussions of the thread, it seems we reach an agreement on using hypercall to tell DOM0 the grant table info and event channel irq. Right?
People have different opinion on what should be the way to boot DOM0 with ACPI on ARM. A design document would help here to understand what are the possibilities to boot DOM0 (i.e hypercall based, XENV...) and which one would be the most suitable for ARM.
Quoted 9 lines
Quoted 8 lines
We need to agree on the boot protocol before going further on this series.
To speed up the upstreaming process, it would be nice if you start a thread about the boot protocol for ACPI with relevant people in CCed. The main goal will be to explain why you choose this way. This will be the base to talk about improvement and/or answer concerns for other people.
Quoted 7 lines
Ok, it's good to reach an agreement before action.
Quoted 3 lines
FWIW, Jan also suggested a different boot protocol based on the x86 one. It may be good for you to see whether it would fit ACPI on ARM.
Which boot protocol? Could you point it out? Thanks. :)
The way to boot DOM0 with ACPI. There is a page on the Linaro wiki [1], but the content is quite out of date now.
Regards,
[1] https://wiki.linaro.org/LEG/Engineering/Virtualization/ACPI_on_Xen
Signature · 1 line
Julien Grall
Re: [PATCH v2 32/41] arm : acpi dynamically map mmio regions
Quoted 25 lines · Julien Grall
Hi Shannon,
Quoted 13 lines · Shannon Zhao
Quoted 10 lines · Julien Grall
Quoted 5 lines · Parth Dixit
instead of getting mmio information for individual
devices from dsdt, we will map all the non-ram regions described in uefi. AML interpreter option was discussed earlier and it was decided not to go with that approach. You can find more details in the linaro xen wiki for the reasoning behind it.Which page are you talking about? I only found [1] speaking about ACPI. Although, there is nothing related to MMIO mapping.
Quoted 8 lines
Quoted 5 lines
Anyway, it's not possible to get the list of MMIOs regions for the UEFI System Memory Map (see the mail you forward on the ML [2]).
Although, based on the RAM region we could deduce a possible set of MMIO regions.
But I guess this will get the all regions except RAM region. And some of the regions may not exist on hardware. Is it ok to map the non-exist region to DOM0? Doesn't the map function fail?
Quoted 7 lines
I don't see a problem for it. I'm not sure what the others think about it.
The map function doesn't know if the physical region is valid or not. It's only setup the page table to allow the guest using the physical region.
If DOM0 is trying to access invalid region, it will receive a data/prefetch abort.
I don't think there is a problem with mapping inexistent memory to dom0. The only issue is that mapping very large amounts of memory to dom0 takes a lot of memory to store the pagetables themselves in Xen. If we do that we should definitely use page sizes greater than 4K: 2M or 1G.
I think that starting out with simply relying on the UEFI System Memory Map would be OK, even though we know that it is not complete. I would recommend to just do that in the next version of this series and leave this problem for later. Although I think it should be solved before completing this work, I wouldn't want everything else to get stuck because of this. Maybe you could sort out the other issues while we are still discussing this one.
One option going forward is to map MMIO regions in Dom0 on demand when trapping in Xen with a data abort. Specifically in xen/arch/arm/traps.c:do_trap_data_abort_guest we could check that the guest is dom0 and that the address correspond to a non-ram region not owned by Xen. If the checks succeed then we map the page in Dom0.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
It would be fine to mapped unused region in memory and we could take advantage of super page.
While you are speaking about the wiki page. Can one of you update the wiki page about the boot protocol? Jan had some concerns about the solution you choose (see [3] to not mention the whole thread).
Quoted 8 lines
Quoted 3 lines
About the XENV table, from the discussions of the thread, it seems we reach an agreement on using hypercall to tell DOM0 the grant table info and event channel irq. Right?
People have different opinion on what should be the way to boot DOM0 with ACPI on ARM. A design document would help here to understand what are the possibilities to boot DOM0 (i.e hypercall based, XENV...) and which one would be the most suitable for ARM.
As I wrote previously
(http://marc.info/?i=alpine.DEB.2.02.1505291102390.8130%40kaball.uk.xensource.com),
although I prefer tables, I am OK with hypercalls too, and for the sake of moving this work forward in the quickest way possible, let's just do that. This is a minor point on the grand scheme of things.
I suggest you introduce two new hvm params to get the grant table address and event channel ppi, see xen/include/public/hvm/params.h. They can be retrieved using the HVMOP_get_param hypercall.
Also remember that if we avoid the XENV table, then we need to set the new FADT field "Hypervisor Vendor Identity" appropriately to advertise the presence of Xen on the platform.
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines
We need to agree on the boot protocol before going further on this series.
To speed up the upstreaming process, it would be nice if you start a thread about the boot protocol for ACPI with relevant people in CCed. The main goal will be to explain why you choose this way. This will be the base to talk about improvement and/or answer concerns for other people.
Ok, it's good to reach an agreement before action.
Quoted 3 lines
FWIW, Jan also suggested a different boot protocol based on the x86 one. It may be good for you to see whether it would fit ACPI on ARM.
Quoted 8 lines
Quoted 1 line
Which boot protocol? Could you point it out? Thanks. :)
The way to boot DOM0 with ACPI. There is a page on the Linaro wiki [1], but the content is quite out of date now.
Regards,
[1] https://wiki.linaro.org/LEG/Engineering/Virtualization/ACPI_on_Xen
http://marc.info/?i=1431893048-5214-1-git-send-email-parth.dixit%40linaro.org
is a good start, but it needs more details. The important thing to clear out is which information is passed to Dom0 and how, because it will become a supported external interface going forward.
Specifically:
- what information is passed via the small device tree to dom0 and in what format
- how the acpi tables are given to dom0
* mapped or copied?
* how do we pass a pointer to them to the kernel?
- if some tables are changed by Xen before passing them on, it would be good to list what was changed
* what tables have been modified
* what tables have been added
* what tables have been removed
- how is the memory map passed to Dom0
* how do we find out the list of MMIO regions, both temporary and future solutions
* how to we tell dom0 where they are