From: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
To: fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Cc: rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org,
lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
marc.zyngier-5wv7dgnIgG8@public.gmane.org,
sudeep.holla-5wv7dgnIgG8@public.gmane.org,
hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linaro-acpi-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
rruigrok-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
harba-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
cov-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
graeme.gregory-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
al.stone-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
wei-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
arnd-r2nGTMty4D4@public.gmane.org,
wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org,
catalin.marinas-5wv7dgnIgG8@public.gmane.org,
will.deacon-5wv7dgnIgG8@public.gmane.org,
Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org,
leo.duran-5C7GfCeVMHo@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
mchehab-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
jslaby-AlSwsSmVLrQ@public.gmane.org,
christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
julien.grall-5wv7dgnIgG8@public.gmane.org
Subject: Re: [PATCH v7 7/9] acpi/arm64: Add memory-mapped timer support in GTDT driver
Date: Thu, 14 Jul 2016 14:42:52 +0100 [thread overview]
Message-ID: <20160714134251.GA30657@red-moon> (raw)
In-Reply-To: <1468432402-4872-8-git-send-email-fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On Thu, Jul 14, 2016 at 01:53:20AM +0800, fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org wrote:
> From: Fu Wei <fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> This driver adds support for parsing memory-mapped timer in GTDT:
> provide a kernel APIs to parse GT Block Structure in GTDT,
> export all the info by filling the struct which provided
> by parameter(pointer of the struct).
>
> By this driver, we can add ACPI support for memory-mapped timer in
> arm_arch_timer drivers, and separate the ACPI GTDT knowledge from it.
>
> Signed-off-by: Fu Wei <fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Signed-off-by: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> drivers/acpi/arm64/acpi_gtdt.c | 90 ++++++++++++++++++++++++++++++++++++
> include/clocksource/arm_arch_timer.h | 15 ++++++
> include/linux/acpi.h | 1 +
> 3 files changed, 106 insertions(+)
>
> diff --git a/drivers/acpi/arm64/acpi_gtdt.c b/drivers/acpi/arm64/acpi_gtdt.c
> index 9ee977d..ff62953 100644
> --- a/drivers/acpi/arm64/acpi_gtdt.c
> +++ b/drivers/acpi/arm64/acpi_gtdt.c
> @@ -168,3 +168,93 @@ int __init gtdt_arch_timer_init(struct acpi_table_header *table)
>
> return -EINVAL;
> }
> +
> +/*
> + * Helper function for getting the pointer of a timer frame in GT block.
> + */
> +static void __init *gtdt_gt_timer_frame(struct acpi_gtdt_timer_block *gt_block,
> + int index)
> +{
> + void *timer_frame = (void *)gt_block + gt_block->timer_offset +
> + sizeof(struct acpi_gtdt_timer_entry) * index;
> +
> + if (timer_frame <= (void *)gt_block + gt_block->header.length -
> + sizeof(struct acpi_gtdt_timer_entry))
> + return timer_frame;
Nit: gt_block is an array, right ? I think it would be much simpler
if you treat is as such, so that indexing into it would be done
automatically by the compiler. Actually, I do not even think you
would need this function at all if you treat gt_block as an array,
the length check could be done in gtdt_parse_gt_block() straight
away.
> +
> + return NULL;
> +}
> +
> +static int __init gtdt_parse_gt_block(void *platform_timer, int index,
> + void *data)
> +{
> + struct acpi_gtdt_timer_block *block;
> + struct acpi_gtdt_timer_entry *frame;
> + struct gt_block_data *block_data;
> + int i, j;
> +
> + if (!platform_timer || !data)
> + return -EINVAL;
> +
> + block = platform_timer;
> + block_data = data + sizeof(struct gt_block_data) * index;
Nit: See above, data is a struct gt_block_data[] right ? These void
pointers parameters are not really great, the caller context
knows what they are and it can pass them as pointer to typed
array elements anyway unless I am missing something.
> + if (!block->block_address || !block->timer_count) {
> + pr_err(FW_BUG "invalid GT Block data.\n");
> + return -EINVAL;
> + }
> + block_data->cntctlbase_phy = (phys_addr_t)block->block_address;
> + block_data->timer_count = block->timer_count;
> +
> + /*
> + * Get the GT timer Frame data for every GT Block Timer
> + */
> + for (i = 0, j = 0; i < block->timer_count; i++) {
What's j needed for (ie can't you use just i instead ?) ?
> + frame = gtdt_gt_timer_frame(block, i);
> + if (!frame || !frame->base_address || !frame->timer_interrupt) {
> + pr_err(FW_BUG "invalid GT Block Timer data.\n");
> + return -EINVAL;
> + }
> + block_data->timer[j].frame_nr = frame->frame_number;
> + block_data->timer[j].cntbase_phy = frame->base_address;
> + block_data->timer[j].irq = map_generic_timer_interrupt(
> + frame->timer_interrupt,
> + frame->timer_flags);
> + if (frame->virtual_timer_interrupt)
> + block_data->timer[j].virt_irq =
> + map_generic_timer_interrupt(
> + frame->virtual_timer_interrupt,
> + frame->virtual_timer_flags);
> + j++;
> + }
> +
> + if (j)
> + return 0;
> +
> + block_data->cntctlbase_phy = (phys_addr_t)NULL;
This is wrong. NULL is not meant to be used as a physical address,
you must not do that. Is not zeroeing timer_count enough ? I have
to understand why you need this because casting NULL into it is
not safe, at all.
> + block_data->timer_count = 0;
> +
> + return -EINVAL;
> +}
> +
> +/*
> + * Get the GT block info for memory-mapped timer from GTDT table.
> + * Please make sure we have called gtdt_arch_timer_init, because it helps to
> + * init the global variables.
It is a helper function that you call once at boot, you easily
determine when it is called, it is not meant to be used in different
contexts from different subsystems; I think that this comment
is not clear so either you make it clearer or you remove it.
> + */
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data)
> +{
> + void *platform_timer;
> + int index = 0;
> +
> + for_each_platform_timer(platform_timer) {
> + if (is_timer_block(platform_timer) &&
> + !gtdt_parse_gt_block(platform_timer, index, data))
Passing around these opaque void* is a tad ugly, see my comments
above about this.
Apart from the NULL pointer assignment, everything else is just code
clean-up.
Thanks,
Lorenzo
> + index++;
> + }
> +
> + if (index)
> + pr_info("found %d memory-mapped timer block.\n", index);
> +
> + return index;
> +}
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 16dcd10..ece6b3b 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -56,6 +56,8 @@ enum spi_nr {
> #define ARCH_TIMER_MEM_PHYS_ACCESS 2
> #define ARCH_TIMER_MEM_VIRT_ACCESS 3
>
> +#define ARCH_TIMER_MEM_MAX_FRAME 8
> +
> #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */
> #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */
> #define ARCH_TIMER_VIRT_EVT_EN (1 << 2)
> @@ -71,6 +73,19 @@ struct arch_timer_kvm_info {
> int virtual_irq;
> };
>
> +struct gt_timer_data {
> + int frame_nr;
> + phys_addr_t cntbase_phy;
> + int irq;
> + int virt_irq;
> +};
> +
> +struct gt_block_data {
> + phys_addr_t cntctlbase_phy;
> + int timer_count;
> + struct gt_timer_data timer[ARCH_TIMER_MEM_MAX_FRAME];
> +};
> +
> #ifdef CONFIG_ARM_ARCH_TIMER
>
> extern u32 arch_timer_get_rate(void);
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 8439579..b1cacbc 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -536,6 +536,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *);
> int __init gtdt_arch_timer_init(struct acpi_table_header *table);
> int __init acpi_gtdt_map_ppi(int type);
> int __init acpi_gtdt_c3stop(void);
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data);
> #endif
>
> #else /* !CONFIG_ACPI */
> --
> 2.5.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: fu.wei@linaro.org
Cc: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org,
tglx@linutronix.de, marc.zyngier@arm.com, sudeep.holla@arm.com,
hanjun.guo@linaro.org, linux-arm-kernel@lists.infradead.org,
linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org, rruigrok@codeaurora.org,
harba@codeaurora.org, cov@codeaurora.org, timur@codeaurora.org,
graeme.gregory@linaro.org, al.stone@linaro.org, jcm@redhat.com,
wei@redhat.com, arnd@arndb.de, wim@iguana.be,
catalin.marinas@arm.com, will.deacon@arm.com,
Suravee.Suthikulpanit@amd.com, leo.duran@amd.com,
linux@roeck-us.net, linux-watchdog@vger.kernel.org,
davem@davemloft.net, akpm@linux-foundation.org,
gregkh@linuxfoundation.org, kvalo@codeaurora.org,
mchehab@kernel.org, jslaby@suse.cz, christoffer.dall@linaro.org,
julien.grall@arm.com
Subject: Re: [PATCH v7 7/9] acpi/arm64: Add memory-mapped timer support in GTDT driver
Date: Thu, 14 Jul 2016 14:42:52 +0100 [thread overview]
Message-ID: <20160714134251.GA30657@red-moon> (raw)
In-Reply-To: <1468432402-4872-8-git-send-email-fu.wei@linaro.org>
On Thu, Jul 14, 2016 at 01:53:20AM +0800, fu.wei@linaro.org wrote:
> From: Fu Wei <fu.wei@linaro.org>
>
> This driver adds support for parsing memory-mapped timer in GTDT:
> provide a kernel APIs to parse GT Block Structure in GTDT,
> export all the info by filling the struct which provided
> by parameter(pointer of the struct).
>
> By this driver, we can add ACPI support for memory-mapped timer in
> arm_arch_timer drivers, and separate the ACPI GTDT knowledge from it.
>
> Signed-off-by: Fu Wei <fu.wei@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
> drivers/acpi/arm64/acpi_gtdt.c | 90 ++++++++++++++++++++++++++++++++++++
> include/clocksource/arm_arch_timer.h | 15 ++++++
> include/linux/acpi.h | 1 +
> 3 files changed, 106 insertions(+)
>
> diff --git a/drivers/acpi/arm64/acpi_gtdt.c b/drivers/acpi/arm64/acpi_gtdt.c
> index 9ee977d..ff62953 100644
> --- a/drivers/acpi/arm64/acpi_gtdt.c
> +++ b/drivers/acpi/arm64/acpi_gtdt.c
> @@ -168,3 +168,93 @@ int __init gtdt_arch_timer_init(struct acpi_table_header *table)
>
> return -EINVAL;
> }
> +
> +/*
> + * Helper function for getting the pointer of a timer frame in GT block.
> + */
> +static void __init *gtdt_gt_timer_frame(struct acpi_gtdt_timer_block *gt_block,
> + int index)
> +{
> + void *timer_frame = (void *)gt_block + gt_block->timer_offset +
> + sizeof(struct acpi_gtdt_timer_entry) * index;
> +
> + if (timer_frame <= (void *)gt_block + gt_block->header.length -
> + sizeof(struct acpi_gtdt_timer_entry))
> + return timer_frame;
Nit: gt_block is an array, right ? I think it would be much simpler
if you treat is as such, so that indexing into it would be done
automatically by the compiler. Actually, I do not even think you
would need this function at all if you treat gt_block as an array,
the length check could be done in gtdt_parse_gt_block() straight
away.
> +
> + return NULL;
> +}
> +
> +static int __init gtdt_parse_gt_block(void *platform_timer, int index,
> + void *data)
> +{
> + struct acpi_gtdt_timer_block *block;
> + struct acpi_gtdt_timer_entry *frame;
> + struct gt_block_data *block_data;
> + int i, j;
> +
> + if (!platform_timer || !data)
> + return -EINVAL;
> +
> + block = platform_timer;
> + block_data = data + sizeof(struct gt_block_data) * index;
Nit: See above, data is a struct gt_block_data[] right ? These void
pointers parameters are not really great, the caller context
knows what they are and it can pass them as pointer to typed
array elements anyway unless I am missing something.
> + if (!block->block_address || !block->timer_count) {
> + pr_err(FW_BUG "invalid GT Block data.\n");
> + return -EINVAL;
> + }
> + block_data->cntctlbase_phy = (phys_addr_t)block->block_address;
> + block_data->timer_count = block->timer_count;
> +
> + /*
> + * Get the GT timer Frame data for every GT Block Timer
> + */
> + for (i = 0, j = 0; i < block->timer_count; i++) {
What's j needed for (ie can't you use just i instead ?) ?
> + frame = gtdt_gt_timer_frame(block, i);
> + if (!frame || !frame->base_address || !frame->timer_interrupt) {
> + pr_err(FW_BUG "invalid GT Block Timer data.\n");
> + return -EINVAL;
> + }
> + block_data->timer[j].frame_nr = frame->frame_number;
> + block_data->timer[j].cntbase_phy = frame->base_address;
> + block_data->timer[j].irq = map_generic_timer_interrupt(
> + frame->timer_interrupt,
> + frame->timer_flags);
> + if (frame->virtual_timer_interrupt)
> + block_data->timer[j].virt_irq =
> + map_generic_timer_interrupt(
> + frame->virtual_timer_interrupt,
> + frame->virtual_timer_flags);
> + j++;
> + }
> +
> + if (j)
> + return 0;
> +
> + block_data->cntctlbase_phy = (phys_addr_t)NULL;
This is wrong. NULL is not meant to be used as a physical address,
you must not do that. Is not zeroeing timer_count enough ? I have
to understand why you need this because casting NULL into it is
not safe, at all.
> + block_data->timer_count = 0;
> +
> + return -EINVAL;
> +}
> +
> +/*
> + * Get the GT block info for memory-mapped timer from GTDT table.
> + * Please make sure we have called gtdt_arch_timer_init, because it helps to
> + * init the global variables.
It is a helper function that you call once at boot, you easily
determine when it is called, it is not meant to be used in different
contexts from different subsystems; I think that this comment
is not clear so either you make it clearer or you remove it.
> + */
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data)
> +{
> + void *platform_timer;
> + int index = 0;
> +
> + for_each_platform_timer(platform_timer) {
> + if (is_timer_block(platform_timer) &&
> + !gtdt_parse_gt_block(platform_timer, index, data))
Passing around these opaque void* is a tad ugly, see my comments
above about this.
Apart from the NULL pointer assignment, everything else is just code
clean-up.
Thanks,
Lorenzo
> + index++;
> + }
> +
> + if (index)
> + pr_info("found %d memory-mapped timer block.\n", index);
> +
> + return index;
> +}
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 16dcd10..ece6b3b 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -56,6 +56,8 @@ enum spi_nr {
> #define ARCH_TIMER_MEM_PHYS_ACCESS 2
> #define ARCH_TIMER_MEM_VIRT_ACCESS 3
>
> +#define ARCH_TIMER_MEM_MAX_FRAME 8
> +
> #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */
> #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */
> #define ARCH_TIMER_VIRT_EVT_EN (1 << 2)
> @@ -71,6 +73,19 @@ struct arch_timer_kvm_info {
> int virtual_irq;
> };
>
> +struct gt_timer_data {
> + int frame_nr;
> + phys_addr_t cntbase_phy;
> + int irq;
> + int virt_irq;
> +};
> +
> +struct gt_block_data {
> + phys_addr_t cntctlbase_phy;
> + int timer_count;
> + struct gt_timer_data timer[ARCH_TIMER_MEM_MAX_FRAME];
> +};
> +
> #ifdef CONFIG_ARM_ARCH_TIMER
>
> extern u32 arch_timer_get_rate(void);
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 8439579..b1cacbc 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -536,6 +536,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *);
> int __init gtdt_arch_timer_init(struct acpi_table_header *table);
> int __init acpi_gtdt_map_ppi(int type);
> int __init acpi_gtdt_c3stop(void);
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data);
> #endif
>
> #else /* !CONFIG_ACPI */
> --
> 2.5.5
>
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 7/9] acpi/arm64: Add memory-mapped timer support in GTDT driver
Date: Thu, 14 Jul 2016 14:42:52 +0100 [thread overview]
Message-ID: <20160714134251.GA30657@red-moon> (raw)
In-Reply-To: <1468432402-4872-8-git-send-email-fu.wei@linaro.org>
On Thu, Jul 14, 2016 at 01:53:20AM +0800, fu.wei at linaro.org wrote:
> From: Fu Wei <fu.wei@linaro.org>
>
> This driver adds support for parsing memory-mapped timer in GTDT:
> provide a kernel APIs to parse GT Block Structure in GTDT,
> export all the info by filling the struct which provided
> by parameter(pointer of the struct).
>
> By this driver, we can add ACPI support for memory-mapped timer in
> arm_arch_timer drivers, and separate the ACPI GTDT knowledge from it.
>
> Signed-off-by: Fu Wei <fu.wei@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
> drivers/acpi/arm64/acpi_gtdt.c | 90 ++++++++++++++++++++++++++++++++++++
> include/clocksource/arm_arch_timer.h | 15 ++++++
> include/linux/acpi.h | 1 +
> 3 files changed, 106 insertions(+)
>
> diff --git a/drivers/acpi/arm64/acpi_gtdt.c b/drivers/acpi/arm64/acpi_gtdt.c
> index 9ee977d..ff62953 100644
> --- a/drivers/acpi/arm64/acpi_gtdt.c
> +++ b/drivers/acpi/arm64/acpi_gtdt.c
> @@ -168,3 +168,93 @@ int __init gtdt_arch_timer_init(struct acpi_table_header *table)
>
> return -EINVAL;
> }
> +
> +/*
> + * Helper function for getting the pointer of a timer frame in GT block.
> + */
> +static void __init *gtdt_gt_timer_frame(struct acpi_gtdt_timer_block *gt_block,
> + int index)
> +{
> + void *timer_frame = (void *)gt_block + gt_block->timer_offset +
> + sizeof(struct acpi_gtdt_timer_entry) * index;
> +
> + if (timer_frame <= (void *)gt_block + gt_block->header.length -
> + sizeof(struct acpi_gtdt_timer_entry))
> + return timer_frame;
Nit: gt_block is an array, right ? I think it would be much simpler
if you treat is as such, so that indexing into it would be done
automatically by the compiler. Actually, I do not even think you
would need this function at all if you treat gt_block as an array,
the length check could be done in gtdt_parse_gt_block() straight
away.
> +
> + return NULL;
> +}
> +
> +static int __init gtdt_parse_gt_block(void *platform_timer, int index,
> + void *data)
> +{
> + struct acpi_gtdt_timer_block *block;
> + struct acpi_gtdt_timer_entry *frame;
> + struct gt_block_data *block_data;
> + int i, j;
> +
> + if (!platform_timer || !data)
> + return -EINVAL;
> +
> + block = platform_timer;
> + block_data = data + sizeof(struct gt_block_data) * index;
Nit: See above, data is a struct gt_block_data[] right ? These void
pointers parameters are not really great, the caller context
knows what they are and it can pass them as pointer to typed
array elements anyway unless I am missing something.
> + if (!block->block_address || !block->timer_count) {
> + pr_err(FW_BUG "invalid GT Block data.\n");
> + return -EINVAL;
> + }
> + block_data->cntctlbase_phy = (phys_addr_t)block->block_address;
> + block_data->timer_count = block->timer_count;
> +
> + /*
> + * Get the GT timer Frame data for every GT Block Timer
> + */
> + for (i = 0, j = 0; i < block->timer_count; i++) {
What's j needed for (ie can't you use just i instead ?) ?
> + frame = gtdt_gt_timer_frame(block, i);
> + if (!frame || !frame->base_address || !frame->timer_interrupt) {
> + pr_err(FW_BUG "invalid GT Block Timer data.\n");
> + return -EINVAL;
> + }
> + block_data->timer[j].frame_nr = frame->frame_number;
> + block_data->timer[j].cntbase_phy = frame->base_address;
> + block_data->timer[j].irq = map_generic_timer_interrupt(
> + frame->timer_interrupt,
> + frame->timer_flags);
> + if (frame->virtual_timer_interrupt)
> + block_data->timer[j].virt_irq =
> + map_generic_timer_interrupt(
> + frame->virtual_timer_interrupt,
> + frame->virtual_timer_flags);
> + j++;
> + }
> +
> + if (j)
> + return 0;
> +
> + block_data->cntctlbase_phy = (phys_addr_t)NULL;
This is wrong. NULL is not meant to be used as a physical address,
you must not do that. Is not zeroeing timer_count enough ? I have
to understand why you need this because casting NULL into it is
not safe, at all.
> + block_data->timer_count = 0;
> +
> + return -EINVAL;
> +}
> +
> +/*
> + * Get the GT block info for memory-mapped timer from GTDT table.
> + * Please make sure we have called gtdt_arch_timer_init, because it helps to
> + * init the global variables.
It is a helper function that you call once at boot, you easily
determine when it is called, it is not meant to be used in different
contexts from different subsystems; I think that this comment
is not clear so either you make it clearer or you remove it.
> + */
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data)
> +{
> + void *platform_timer;
> + int index = 0;
> +
> + for_each_platform_timer(platform_timer) {
> + if (is_timer_block(platform_timer) &&
> + !gtdt_parse_gt_block(platform_timer, index, data))
Passing around these opaque void* is a tad ugly, see my comments
above about this.
Apart from the NULL pointer assignment, everything else is just code
clean-up.
Thanks,
Lorenzo
> + index++;
> + }
> +
> + if (index)
> + pr_info("found %d memory-mapped timer block.\n", index);
> +
> + return index;
> +}
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 16dcd10..ece6b3b 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -56,6 +56,8 @@ enum spi_nr {
> #define ARCH_TIMER_MEM_PHYS_ACCESS 2
> #define ARCH_TIMER_MEM_VIRT_ACCESS 3
>
> +#define ARCH_TIMER_MEM_MAX_FRAME 8
> +
> #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */
> #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */
> #define ARCH_TIMER_VIRT_EVT_EN (1 << 2)
> @@ -71,6 +73,19 @@ struct arch_timer_kvm_info {
> int virtual_irq;
> };
>
> +struct gt_timer_data {
> + int frame_nr;
> + phys_addr_t cntbase_phy;
> + int irq;
> + int virt_irq;
> +};
> +
> +struct gt_block_data {
> + phys_addr_t cntctlbase_phy;
> + int timer_count;
> + struct gt_timer_data timer[ARCH_TIMER_MEM_MAX_FRAME];
> +};
> +
> #ifdef CONFIG_ARM_ARCH_TIMER
>
> extern u32 arch_timer_get_rate(void);
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 8439579..b1cacbc 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -536,6 +536,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *);
> int __init gtdt_arch_timer_init(struct acpi_table_header *table);
> int __init acpi_gtdt_map_ppi(int type);
> int __init acpi_gtdt_c3stop(void);
> +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data);
> #endif
>
> #else /* !CONFIG_ACPI */
> --
> 2.5.5
>
next prev parent reply other threads:[~2016-07-14 13:42 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 17:53 [PATCH v7 0/9] acpi, clocksource: add GTDT driver and GTDT support in arm_arch_timer fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` [PATCH v7 2/9] clocksource/drivers/arm_arch_timer: Add a new enum for spi type fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
[not found] ` <1468432402-4872-1-git-send-email-fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-07-13 17:53 ` [PATCH v7 1/9] clocksource/drivers/arm_arch_timer: Move enums and defines to header file fu.wei-QSEj5FYQhm4dnm+yROfE0A
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
2016-07-13 17:53 ` [PATCH v7 3/9] clocksource/drivers/arm_arch_timer: Improve printk relevant code fu.wei-QSEj5FYQhm4dnm+yROfE0A
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
2016-07-13 17:53 ` [PATCH v7 4/9] acpi/arm64: Add GTDT table parse driver fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
[not found] ` <1468432402-4872-5-git-send-email-fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-07-13 20:30 ` Rafael J. Wysocki
2016-07-13 20:30 ` Rafael J. Wysocki
2016-07-13 20:30 ` Rafael J. Wysocki
[not found] ` <CAJZ5v0i-1NysCiDFX4ST_uBBeYF2YNzWztgDP=u9a4S1OdpWuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-13 20:39 ` Rafael J. Wysocki
2016-07-13 20:39 ` Rafael J. Wysocki
2016-07-13 20:39 ` Rafael J. Wysocki
2016-07-15 7:33 ` Fu Wei
2016-07-15 7:33 ` Fu Wei
2016-07-15 7:33 ` Fu Wei
2016-07-13 21:08 ` Guenter Roeck
2016-07-13 21:08 ` Guenter Roeck
2016-07-13 21:08 ` Guenter Roeck
[not found] ` <20160713210857.GA9500-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-07-13 21:43 ` Rafael J. Wysocki
2016-07-13 21:43 ` Rafael J. Wysocki
2016-07-13 21:43 ` Rafael J. Wysocki
[not found] ` <CAJZ5v0jnNqjpcY1CGkHxbJFwX1MuRi-U=jTCKWavMdEH4bKR3g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-15 7:45 ` Fu Wei
2016-07-15 7:45 ` Fu Wei
2016-07-15 7:45 ` Fu Wei
2016-07-15 12:11 ` Rafael J. Wysocki
2016-07-15 12:11 ` Rafael J. Wysocki
2016-07-15 12:11 ` Rafael J. Wysocki
2016-07-15 16:13 ` Fu Wei
2016-07-15 16:13 ` Fu Wei
2016-07-15 16:13 ` Fu Wei
2016-07-15 7:32 ` Fu Wei
2016-07-15 7:32 ` Fu Wei
2016-07-15 7:32 ` Fu Wei
2016-07-15 12:15 ` Rafael J. Wysocki
2016-07-15 12:15 ` Rafael J. Wysocki
2016-07-15 12:15 ` Rafael J. Wysocki
2016-07-15 13:07 ` Rafael J. Wysocki
2016-07-15 13:07 ` Rafael J. Wysocki
2016-07-15 13:07 ` Rafael J. Wysocki
2016-07-15 16:32 ` Fu Wei
2016-07-15 16:32 ` Fu Wei
2016-07-15 16:32 ` Fu Wei
[not found] ` <CADyBb7sXxY_a+tJQoH01eUk5-xvg9jRZtzyhB-tDstWoBAWfLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-15 21:22 ` Rafael J. Wysocki
2016-07-15 21:22 ` Rafael J. Wysocki
2016-07-15 21:22 ` Rafael J. Wysocki
2016-07-16 2:24 ` Fu Wei
2016-07-16 2:24 ` Fu Wei
2016-07-16 2:24 ` Fu Wei
2016-07-16 12:35 ` Rafael J. Wysocki
2016-07-16 12:35 ` Rafael J. Wysocki
2016-07-16 12:35 ` Rafael J. Wysocki
[not found] ` <16716612.zdLA2RMyjn-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2016-07-19 18:25 ` Fu Wei
2016-07-19 18:25 ` Fu Wei
2016-07-19 18:25 ` Fu Wei
2016-07-14 20:33 ` Paul Gortmaker
2016-07-14 20:33 ` Paul Gortmaker
2016-07-14 20:33 ` Paul Gortmaker
2016-07-15 7:46 ` Fu Wei
2016-07-15 7:46 ` Fu Wei
2016-07-15 7:46 ` Fu Wei
2016-07-13 17:53 ` [PATCH v7 5/9] MAINTAINERS / ACPI: add the ARM64-specific ACPI Support maintainers fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
2016-07-13 20:16 ` Rafael J. Wysocki
2016-07-13 20:16 ` Rafael J. Wysocki
2016-07-13 20:16 ` Rafael J. Wysocki
[not found] ` <CAJZ5v0gut2uCFHa7hr8iKY4ioP4q17yo=gBxJEeZf5WvVNM7pQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-15 1:02 ` Fu Wei
2016-07-15 1:02 ` Fu Wei
2016-07-15 1:02 ` Fu Wei
2016-07-13 17:53 ` [PATCH v7 6/9] clocksource/drivers/arm_arch_timer: Simplify ACPI support code fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
2016-07-13 17:53 ` [PATCH v7 7/9] acpi/arm64: Add memory-mapped timer support in GTDT driver fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
[not found] ` <1468432402-4872-8-git-send-email-fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-07-14 13:42 ` Lorenzo Pieralisi [this message]
2016-07-14 13:42 ` Lorenzo Pieralisi
2016-07-14 13:42 ` Lorenzo Pieralisi
2016-07-19 18:28 ` Fu Wei
2016-07-19 18:28 ` Fu Wei
2016-07-19 18:28 ` Fu Wei
2016-07-13 17:53 ` [PATCH v7 8/9] clocksource/drivers/arm_arch_timer: Add GTDT support for memory-mapped timer fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
2016-07-13 17:53 ` fu.wei
2016-07-13 17:53 ` [PATCH v7 9/9] acpi/arm64: Add SBSA Generic Watchdog support in GTDT driver fu.wei
2016-07-13 17:53 ` fu.wei at linaro.org
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=20160714134251.GA30657@red-moon \
--to=lorenzo.pieralisi-5wv7dgnigg8@public.gmane.org \
--cc=Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=al.stone-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
--cc=christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=cov-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=graeme.gregory-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=harba-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
--cc=julien.grall-5wv7dgnIgG8@public.gmane.org \
--cc=kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=leo.duran-5C7GfCeVMHo@public.gmane.org \
--cc=linaro-acpi-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=marc.zyngier-5wv7dgnIgG8@public.gmane.org \
--cc=mchehab-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
--cc=rruigrok-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=sudeep.holla-5wv7dgnIgG8@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=wei-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
--cc=wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.