From: Julien Grall <julien.grall@citrix.com>
To: Parth Dixit <parth.dixit@linaro.org>, xen-devel@lists.xen.org
Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com,
tim@xen.org, julien.grall@citrix.com,
stefano.stabellini@citrix.com, jbeulich@suse.com,
christoffer.dall@linaro.org
Subject: Re: [PATCH v2 15/41] arm : acpi parse GTDT to initialize timer
Date: Wed, 20 May 2015 19:03:53 +0100 [thread overview]
Message-ID: <555CCC89.6030907@citrix.com> (raw)
In-Reply-To: <1431893048-5214-16-git-send-email-parth.dixit@linaro.org>
Hi Parth,
On 17/05/15 21:03, Parth Dixit wrote:
> 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 <naresh.bhat@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> ---
> 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(-)
>
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index 7d9758f..a8311ae 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -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[])
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.
> +{
> + int type;
> + struct acpi_table_gtdt *gtdt=NULL;
*gtdt = NULL;
> + u8 checksum;
> + static const int GTDT_INTRL_TAB[] =
all uppercase name are used for define.
> + {
> + 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.
> +
> + 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.
> + /* 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));
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.
> + }
> +}
> +
> /*
> * acpi_map_gic_cpu_interface - generates a logical cpu number
> * and map to MPIDR represented by GICC structure
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index ce6d3fd..bff95ab 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -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 )
> +}
> +
> +
> +
Only one blank line is enough.
> +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...
> cpu_khz = rate / 1000;
> else
> cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;
Duplicating this line wouldn't have been too bad compare to the check.
> @@ -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;
> + }
Another helper for this device tree code?
> }
>
> /* Check that this CPU supports the Generic Timer interface */
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 1767143..482cc5b 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -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 */
>
Regards,
--
Julien Grall
next prev parent reply other threads:[~2015-05-20 18:03 UTC|newest]
Thread overview: 194+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-17 20:03 [PATCH v2 00/41] Add ACPI support for arm64 on Xen Parth Dixit
2015-05-17 20:03 ` [PATCH v2 01/41] arm/acpi: Build numa for x86 only Parth Dixit
2015-05-18 12:51 ` Julien Grall
2015-05-20 15:07 ` Jan Beulich
2015-05-20 15:21 ` Julien Grall
2015-05-20 15:41 ` Jan Beulich
2015-05-20 15:49 ` Julien Grall
2015-05-20 16:31 ` Jan Beulich
2015-07-05 12:59 ` Parth Dixit
2015-07-05 17:39 ` Julien Grall
2015-07-05 17:49 ` Parth Dixit
2015-07-06 10:49 ` Jan Beulich
2015-05-17 20:03 ` [PATCH v2 02/41] arm/acpi: Build pmstat " Parth Dixit
2015-05-18 12:54 ` Julien Grall
2015-05-20 15:12 ` Jan Beulich
2015-05-24 6:10 ` Parth Dixit
2015-07-05 13:01 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 03/41] arm/acpi : emulate io ports for arm Parth Dixit
2015-05-18 13:03 ` Julien Grall
2015-07-05 13:02 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 04/41] arm/acpi : add arm specific acpi header file Parth Dixit
2015-05-18 13:12 ` Julien Grall
2015-05-24 5:59 ` Parth Dixit
2015-07-05 13:02 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 05/41] acpi : add helper function for mapping memory Parth Dixit
2015-05-18 13:26 ` Julien Grall
2015-05-18 14:01 ` Jan Beulich
2015-05-18 14:20 ` Julien Grall
2015-05-18 14:32 ` Jan Beulich
2015-05-18 14:35 ` Julien Grall
2015-05-24 6:40 ` Parth Dixit
2015-05-24 7:31 ` Julien Grall
2015-07-05 13:03 ` Parth Dixit
2015-05-20 16:03 ` Jan Beulich
2015-05-20 17:06 ` Julien Grall
2015-05-17 20:03 ` [PATCH v2 06/41] arm/acpi : Add basic ACPI initialization Parth Dixit
2015-05-18 14:11 ` Julien Grall
2015-05-24 6:02 ` Parth Dixit
2015-07-05 13:04 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 07/41] arm/acpi : Introduce ARM Boot Architecture Flags in FADT Parth Dixit
2015-05-18 14:29 ` Julien Grall
2015-05-24 6:03 ` Parth Dixit
2015-07-05 13:04 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 08/41] arm/acpi : Parse FADT table and get PSCI flags Parth Dixit
2015-05-18 14:58 ` Julien Grall
2015-05-24 6:05 ` Parth Dixit
2015-07-05 13:05 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 09/41] arm/acpi : Add Generic Interrupt and Distributor struct Parth Dixit
2015-07-05 13:06 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 10/41] arm/acpi : Print GIC information when MADT is parsed Parth Dixit
2015-05-18 15:06 ` Julien Grall
2015-05-24 6:09 ` Parth Dixit
2015-07-05 13:07 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 11/41] arm/acpi : add GTDT support updated by ACPI 5.1 Parth Dixit
2015-05-18 15:11 ` Julien Grall
2015-05-24 6:06 ` Parth Dixit
2015-07-05 13:07 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 12/41] arm : move dt specific code in smp to seperate functions Parth Dixit
2015-05-20 15:43 ` Julien Grall
2015-07-05 13:08 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 13/41] arm/acpi : parse MADT to map logical cpu to MPIDR and get cpu_possible_map Parth Dixit
2015-05-20 16:08 ` Jan Beulich
2015-05-20 16:38 ` Julien Grall
2015-07-05 13:09 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 14/41] arm : acpi add helper function for setting interrupt type Parth Dixit
2015-05-20 17:21 ` Julien Grall
2015-07-05 13:09 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 15/41] arm : acpi parse GTDT to initialize timer Parth Dixit
2015-05-20 18:03 ` Julien Grall [this message]
2015-05-24 7:00 ` Parth Dixit
2015-07-05 13:10 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 16/41] acpi : Introduce acpi_parse_entries Parth Dixit
2015-05-20 16:13 ` Jan Beulich
2015-05-21 9:14 ` Parth Dixit
2015-05-21 9:20 ` Jan Beulich
2015-07-05 13:11 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 17/41] arm : refactor gic into generic and dt specific parts Parth Dixit
2015-05-21 11:06 ` Julien Grall
2015-05-21 12:22 ` Julien Grall
2015-07-05 13:12 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi Parth Dixit
2015-05-21 11:19 ` Julien Grall
2015-05-24 7:06 ` Parth Dixit
2015-05-24 7:40 ` Julien Grall
2015-05-25 5:58 ` Parth Dixit
2015-05-25 10:00 ` Julien Grall
2015-05-25 11:38 ` Parth Dixit
2015-07-05 13:12 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 19/41] arm : acpi Add GIC specific ACPI boot support Parth Dixit
2015-05-21 12:29 ` Julien Grall
2015-07-05 13:13 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 20/41] arm : create generic uart initialization function Parth Dixit
2015-05-18 8:20 ` Jan Beulich
2015-05-20 18:11 ` Julien Grall
2015-05-21 11:28 ` Julien Grall
2015-05-24 7:07 ` Parth Dixit
2015-05-24 7:48 ` Julien Grall
2015-07-05 13:14 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 21/41] arm : acpi Initialize serial port from ACPI SPCR table Parth Dixit
2015-05-26 15:04 ` Julien Grall
2015-07-05 13:14 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 22/41] arm : acpi create min DT stub for DOM0 Parth Dixit
2015-06-02 17:27 ` Julien Grall
2015-07-05 13:15 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 23/41] arm : acpi create chosen node " Parth Dixit
2015-06-02 17:40 ` Julien Grall
2015-07-05 13:16 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 24/41] arm : acpi create efi " Parth Dixit
2015-05-20 16:16 ` Jan Beulich
2015-05-24 6:30 ` Parth Dixit
2015-05-26 8:21 ` Jan Beulich
2015-05-26 8:39 ` Jan Beulich
2015-07-05 13:17 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 25/41] arm : acpi add status override table Parth Dixit
2015-07-05 13:18 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 26/41] arm : acpi add xen environment table Parth Dixit
2015-05-20 16:22 ` Jan Beulich
2015-05-20 17:00 ` Julien Grall
2015-05-21 6:22 ` Jan Beulich
2015-05-21 10:34 ` Julien Grall
2015-05-21 10:46 ` Jan Beulich
2015-05-21 10:52 ` Julien Grall
2015-05-21 11:38 ` Jan Beulich
2015-05-21 11:41 ` Julien Grall
2015-05-24 7:16 ` Parth Dixit
2015-05-26 17:13 ` Julien Grall
2015-05-26 17:34 ` Stefano Stabellini
2015-05-27 11:53 ` Jan Beulich
2015-05-28 10:58 ` Stefano Stabellini
2015-05-28 12:07 ` Jan Beulich
2015-05-28 12:12 ` Stefano Stabellini
2015-05-28 12:22 ` Jan Beulich
2015-05-29 10:31 ` Stefano Stabellini
2015-05-29 10:43 ` Jan Beulich
2015-07-05 13:19 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 27/41] arm : add helper functions to map memory regions Parth Dixit
2015-06-08 14:05 ` Julien Grall
2015-07-05 13:19 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 28/41] arm : acpi add efi structures to common efi header Parth Dixit
2015-05-20 16:25 ` Jan Beulich
2015-07-05 13:27 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 29/41] arm : acpi read acpi memory info from uefi Parth Dixit
2015-06-08 16:09 ` Julien Grall
2015-07-05 13:28 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 30/41] arm : acpi add placeholder for acpi load address Parth Dixit
2015-06-08 16:19 ` Julien Grall
2015-07-05 13:28 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 31/41] arm : acpi estimate memory required for acpi/efi tables Parth Dixit
2015-06-08 16:44 ` Julien Grall
2015-07-05 13:29 ` Parth Dixit
2015-05-17 20:03 ` [PATCH v2 32/41] arm : acpi dynamically map mmio regions Parth Dixit
2015-06-08 16:50 ` Julien Grall
2015-06-14 15:27 ` Parth Dixit
2015-06-15 1:19 ` Julien Grall
2015-07-05 13:30 ` Parth Dixit
2015-07-30 12:19 ` Shannon Zhao
2015-07-30 18:02 ` Parth Dixit
2015-07-30 18:31 ` Julien Grall
2015-07-30 20:02 ` Parth Dixit
2015-07-31 1:30 ` Shannon Zhao
2015-07-31 12:42 ` Julien Grall
2015-07-31 14:09 ` Stefano Stabellini
2015-07-31 16:24 ` Stefano Stabellini
2015-07-31 16:50 ` Ian Campbell
2015-08-03 12:08 ` Christoffer Dall
2015-07-31 1:15 ` Shannon Zhao
2015-05-17 20:04 ` [PATCH v2 33/41] arm : acpi prepare acpi tables for dom0 Parth Dixit
2015-06-08 16:54 ` Julien Grall
2015-07-05 13:31 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 34/41] arm : acpi create and map acpi tables Parth Dixit
2015-07-05 13:31 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 35/41] arm : acpi add helper function to calculate crc32 Parth Dixit
2015-06-08 16:59 ` Julien Grall
2015-07-05 13:33 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 36/41] arm : acpi pass rsdp and memory via efi table Parth Dixit
2015-07-05 13:34 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 37/41] arm : acpi add acpi parameter to enable/disable acpi Parth Dixit
2015-06-08 16:35 ` Julien Grall
2015-06-11 13:38 ` Julien Grall
2015-05-17 20:04 ` [PATCH v2 38/41] arm : acpi enable efi for acpi Parth Dixit
2015-05-20 16:27 ` Jan Beulich
2015-07-05 13:35 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 39/41] arm : acpi configure interrupts dynamically Parth Dixit
2015-06-08 17:39 ` Julien Grall
2015-07-05 13:36 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 40/41] xen: arm64: Add ACPI support Parth Dixit
2015-07-05 13:37 ` Parth Dixit
2015-05-17 20:04 ` [PATCH v2 41/41] arm : acpi route irq's at time of boot Parth Dixit
2015-06-08 17:44 ` Julien Grall
2015-07-05 13:37 ` Parth Dixit
2015-05-17 21:11 ` [PATCH v2 00/41] Add ACPI support for arm64 on Xen Julien Grall
[not found] ` <CABy3MNkMvpM21L5JtiKebCGdvPxJA_5m18c=t_OEExUjgaPRkQ@mail.gmail.com>
2015-05-18 12:46 ` Julien Grall
2015-05-18 8:25 ` Jan Beulich
2015-05-18 8:27 ` Parth Dixit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555CCC89.6030907@citrix.com \
--to=julien.grall@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=christoffer.dall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=parth.dixit@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).