SMP support for msm
Subsystems (3)
cover SMP support for msm
This series adds support for SMP on msm targets, and specifically adds support for SMP on the msm8x60.
Jeff Ohlstein (3):
msm: timer: SMP timer support for msm
msm: hotplug: support cpu hotplug on msm
msm: add SMP support for msm
Stepan Moskovchenko (1):
msm: scm-boot: Support for setting cold/warm boot addresses
Stephen Boyd (1):
msm: Secure Channel Manager (SCM) support
arch/arm/mach-msm/Kconfig | 5 + arch/arm/mach-msm/Makefile | 4 + arch/arm/mach-msm/headsmp.S | 43 ++++ arch/arm/mach-msm/hotplug.c | 101 ++++++++ arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 6 +- arch/arm/mach-msm/include/mach/smp.h | 2 + arch/arm/mach-msm/io.c | 1 + arch/arm/mach-msm/platsmp.c | 147 ++++++++++++ arch/arm/mach-msm/scm-boot.c | 40 ++++ arch/arm/mach-msm/scm-boot.h | 38 +++ arch/arm/mach-msm/scm.c | 280 +++++++++++++++++++++++ arch/arm/mach-msm/scm.h | 41 ++++ arch/arm/mach-msm/timer.c | 139 +++++++++++- 13 files changed, 837 insertions(+), 10 deletions(-) create mode 100644 arch/arm/mach-msm/headsmp.S create mode 100644 arch/arm/mach-msm/hotplug.c create mode 100644 arch/arm/mach-msm/platsmp.c create mode 100644 arch/arm/mach-msm/scm-boot.c create mode 100644 arch/arm/mach-msm/scm-boot.h create mode 100644 arch/arm/mach-msm/scm.c create mode 100644 arch/arm/mach-msm/scm.h
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 1/5 msm: Secure Channel Manager (SCM) support
From: Stephen Boyd <[email protected]>
SCM is the protocol used to communicate between the secure and non-secure code executing on the applications processor. The non-secure side uses a physically contiguous buffer to pass information to the secure side; where the buffer conforms to a format that is agreed upon by both sides. The use of a buffer allows multiple pending requests to be in flight on the secure side. It also benefits use cases where the command or response buffer contains large chunks of data.
--- arch/arm/mach-msm/Kconfig | 4 + arch/arm/mach-msm/Makefile | 1 + arch/arm/mach-msm/scm.c | 280 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-msm/scm.h | 41 +++++++ 4 files changed, 326 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/scm.c create mode 100644 arch/arm/mach-msm/scm.h
arch/arm/mach-msm/Kconfig +4 -0
@@ -44,6 +44,7 @@ config ARCH_MSM8X60 select CPU_V7 select MSM_V2_TLMM select MSM_GPIOMUX + select MSM_SCM if SMP endchoice
@@ -164,4 +165,7 @@ config MSM_GPIOMUX config MSM_V2_TLMM bool + +config MSM_SCM + bool endif
arch/arm/mach-msm/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_MSM_PROC_COMM) += clock.o obj-$(CONFIG_ARCH_QSD8X50) += sirc.o obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o obj-$(CONFIG_MSM_SMD) += last_radio_log.o +obj-$(CONFIG_MSM_SCM) += scm.o obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o
arch/arm/mach-msm/scm.c new file +280 -0
280 lines not on this page · raw message
arch/arm/mach-msm/scm.h new file +41 -0
41 lines not on this page · raw message
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 1/5] msm: Secure Channel Manager (SCM) support
Quoted 2 lines · Jeff Ohlstein
SCM is the protocol used to communicate between the secure and non-secure code executing on the applications processor.
Does the presence of SCM hardware imply SMP? From reading this, it's unclear why the dependence on SMP - it looks like scm.c is something that hardware that has one ARM processor and a 'secure processor' would still want. Or is the 'secure processor' just another (arbitrarily labeled) ARM CPU participating as a full SMP processor?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101206/de2939f6/attachment.sig>
Re: [PATCH 1/5] msm: Secure Channel Manager (SCM) support
Quoted 10 lines · Valdis.Kletnieks at vt.edu
Quoted 2 lines · Jeff Ohlstein
SCM is the protocol used to communicate between the secure and non-secure code executing on the applications processor.
Does the presence of SCM hardware imply SMP? From reading this, it's unclear why the dependence on SMP - it looks like
scm.cis something that hardware that has one ARM processor and a 'secure processor' would still want. Or is the 'secure processor' just another (arbitrarily labeled) ARM CPU participating as a full SMP processor?
It's referring to the secure mode, which is a separate address space and system running on the same CPU.
Re: [PATCH 1/5] msm: Secure Channel Manager (SCM) support
In reply to Jeff OhlsteinHi!
arch/arm/mach-msm/scm.c line 79
Quoted 11 lines
arch/arm/mach-msm/scm.c new file +11
-0+/** +* struct scm_response - one SCM response buffer +* @len: total available memory for response +* @buf_offset: start of response data relative to start of scm_response +* @is_complete: indicates if the command has finished processing +*/ +struct scm_response { +u32 len; +u32 buf_offset; +u32 is_complete; +};
Alignment is off here.
arch/arm/mach-msm/scm.c line 175
Quoted 6 lines
arch/arm/mach-msm/scm.c new file +6
-0+static u32 smc (dma_addr_t cmd_addr) +{ +int context_id; + register u32 r0 asm("r0") = 1; + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = (u32)cmd_addr;
Are these neccessary?
Quoted 8 lines
arch/arm/mach-msm/scm.c new file +8
-0+ asm( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2)
arch/arm/mach-msm/scm.c
Quoted 10 lines
arch/arm/mach-msm/scm.c new file +9
-0+ : "r3"); +return r0; +} +u32 scm_get_version (void ) +{ +int context_id; +static u32 version =-1 ; + register u32 r0 asm("r0") = 0x1 << 8; + register u32 r1 asm("r1") = (u32)&context_id;
And does this even work?
Quoted 17 lines
arch/arm/mach-msm/scm.c new file +17
-0+if (version !=-1 ) +return version; + +mutex_lock (&scm_lock); + asm( + __asmeq("%0", "r1") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + "smc #0 @ switch to secure world\n" + : "=r" (r1) + : "r" (r0), "r" (r1) + : "r2", "r3"); + version = r1; +mutex_unlock (&scm_lock); + +return version; +}
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 1/5] msm: Secure Channel Manager (SCM) support
Quoted 8 lines · Pavel Machek
arch/arm/mach-msm/scm.c line 175
Quoted 6 lines
arch/arm/mach-msm/scm.c new file +6
-0+static u32 smc (dma_addr_t cmd_addr) +{ +int context_id; + register u32 r0 asm("r0") = 1; + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = (u32)cmd_addr;Are these neccessary?
The values have to be in specific registers. Without them it doesn't generate the right code.
Quoted 12 lines
Quoted 11 lines
arch/arm/mach-msm/scm.c new file +11
-0+ asm( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2) + : "r3"); +return r0; +}
Quoted 8 lines
arch/arm/mach-msm/scm.c line 261
Quoted 6 lines
arch/arm/mach-msm/scm.c new file +6
-0+u32 scm_get_version (void ) +{ +int context_id; +static u32 version =-1 ; + register u32 r0 asm("r0") = 0x1 << 8; + register u32 r1 asm("r1") = (u32)&context_id;And does this even work?
In what sense? It generates the desired code.
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-msm/scm.c new file +17
-0+if (version !=-1 ) +return version; + +mutex_lock (&scm_lock); + asm( + __asmeq("%0", "r1") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + "smc #0 @ switch to secure world\n" + : "=r" (r1) + : "r" (r0), "r" (r1) + : "r2", "r3"); + version = r1; +mutex_unlock (&scm_lock); + +return version; +}
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 1/5] msm: Secure Channel Manager (SCM) support
Quoted 13 lines · David Brown
Quoted 8 lines · Pavel Machek
arch/arm/mach-msm/scm.c line 175
Quoted 6 lines
arch/arm/mach-msm/scm.c new file +6
-0+static u32 smc (dma_addr_t cmd_addr) +{ +int context_id; + register u32 r0 asm("r0") = 1; + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = (u32)cmd_addr;Are these neccessary?
The values have to be in specific registers. Without them it doesn't generate the right code.
...
Quoted 8 lines
Quoted 6 lines
arch/arm/mach-msm/scm.c line 261
Quoted 4 lines
arch/arm/mach-msm/scm.c new file +4
-0+int context_id; +static u32 version =-1 ; + register u32 r0 asm("r0") = 0x1 << 8; + register u32 r1 asm("r1") = (u32)&context_id;And does this even work?
In what sense? It generates the desired code.
What you're doing is entirely valid and supported by gcc. There's no problem with it.
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-msm/scm.c line 270
Quoted 5 lines
arch/arm/mach-msm/scm.c new file +5
-0+mutex_lock (&scm_lock); + asm( + __asmeq("%0", "r1") + __asmeq("%1", "r0") +__asmeq ("%2" ,"r1" )
And even if you use an older gcc version where this trips over bugs, these asmeq() will save you from having silently generated wrong code.
So don't worry about this, you're not doing anything wrong.
PATCH 2/5 msm: scm-boot: Support for setting cold/warm boot addresses
In reply to Jeff OhlsteinFrom: Stepan Moskovchenko <[email protected]>
Add support for setting the cold boot address of core 1 and the warm boot addresses of cores 0 and 1 using a secure domain call.
--- arch/arm/mach-msm/Makefile | 2 +- arch/arm/mach-msm/scm-boot.c | 40 ++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-msm/scm-boot.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletions(-) create mode 100644 arch/arm/mach-msm/scm-boot.c create mode 100644 arch/arm/mach-msm/scm-boot.h
arch/arm/mach-msm/Makefile +1 -1
@@ -18,7 +18,7 @@ obj-$(CONFIG_MSM_PROC_COMM) += clock.o obj-$(CONFIG_ARCH_QSD8X50) += sirc.o obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o obj-$(CONFIG_MSM_SMD) += last_radio_log.o -obj-$(CONFIG_MSM_SCM) += scm.o +obj-$(CONFIG_MSM_SCM) += scm.o scm-boot.o obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o
arch/arm/mach-msm/scm-boot.c new file +40 -0
@@ -0,0 +1,40 @@ +/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/module.h> +#include <linux/slab.h> + +#include "scm.h" +#include "scm-boot.h" + +/* +* Set the cold/warm boot address for one of the CPU cores. +*/ +int scm_set_boot_addr (void *addr,int flags) +{ +struct { +unsigned int flags; +void *addr; + } cmd; + + cmd.addr = addr; + cmd.flags = flags; +return scm_call (SCM_SVC_BOOT ,SCM_BOOT_ADDR , + &cmd,sizeof (cmd),NULL ,0 ); +} +EXPORT_SYMBOL (scm_set_boot_addr); +
arch/arm/mach-msm/scm-boot.h new file +38 -0
@@ -0,0 +1,38 @@ +/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of Code Aurora Forum, Inc. nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef __MACH_SCM_BOOT_H +#define __MACH_SCM_BOOT_H + +#define SCM_BOOT_ADDR 0x1 +#define SCM_FLAG_COLDBOOT_CPU1 0x1 +#define SCM_FLAG_WARMBOOT_CPU1 0x2 +#define SCM_FLAG_WARMBOOT_CPU0 0x4 + +int scm_set_boot_addr (void *addr,int flags); + +#endif
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 3/5 msm: timer: SMP timer support for msm
In reply to Jeff Ohlstein--- arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 6 +- arch/arm/mach-msm/io.c | 1 + arch/arm/mach-msm/timer.c | 139 +++++++++++++++++++++-- 3 files changed, 136 insertions(+), 10 deletions(-)
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +5 -1
@@ -60,7 +60,11 @@#define MSM_TMR_BASE IOMEM(0xF0200000)#define MSM_TMR_PHYS 0x02000000 -#define MSM_TMR_SIZE (SZ_1M) +#define MSM_TMR_SIZE SZ_4K + +#define MSM_TMR0_BASE IOMEM(0xF0201000) +#define MSM_TMR0_PHYS 0x02040000 +#define MSM_TMR0_SIZE SZ_4K#define MSM_GPT_BASE (MSM_TMR_BASE + 0x4)#define MSM_DGT_BASE (MSM_TMR_BASE + 0x24)
arch/arm/mach-msm/io.c +1 -0
@@ -105,6 +105,7 @@ static struct map_desc msm8x60_io_desc[] __initdata = {MSM_DEVICE (QGIC_DIST ),MSM_DEVICE (QGIC_CPU ),MSM_DEVICE (TMR ), +MSM_DEVICE (TMR0 ),MSM_DEVICE (ACC ), MSM_DEVICE(GCC), };
arch/arm/mach-msm/timer.c +130 -9
193 lines not on this page · raw message
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
arch/arm/mach-msm/timer.c struct msm_clock { · line 97
Quoted 9 lines · Jeff Ohlstein
arch/arm/mach-msm/timer.c +6
-0+ +static struct msm_clock msm_clocks[]; +static struct clock_event_device *local_clock_event; +static irqreturn_t msm_timer_interrupt (int irq,void *dev_id) {struct clock_event_device *evt = dev_id; +if (smp_processor_id () !=0 ) + evt = local_clock_event;
Why is dev_id not pointing to the correct device in the first place?
Quoted 7 lines
arch/arm/mach-msm/timer.c +3
-0+if (evt->event_handler ==NULL ) +return IRQ_HANDLED ; evt->event_handler (evt);return IRQ_HANDLED ; } +static uint32_t msm_read_timer_count(struct msm_clock *clock,
arch/arm/mach-msm/timer.c struct msm_clock { · line 114
Quoted 10 lines
arch/arm/mach-msm/timer.c +10
-0+ enum timer_location global) +{ +uint32_t t1; + +if (global) + t1 =readl (clock->regbase +TIMER_COUNT_VAL +MSM_TMR_GLOBAL ); +else + t1 =readl (clock->regbase +TIMER_COUNT_VAL ); + +return t1;
Adding such conditionals into a fast path is brilliant. Granted, gcc might optimize it out, but I'm not sure given the number of call sites.
What's the point of this exercise ?
arch/arm/mach-msm/timer.c struct msm_clock { · line 121
Quoted 7 lines
arch/arm/mach-msm/timer.c +4
-1+} +static cycle_t msm_gpt_read (struct clocksource *cs) { -return readl (MSM_GPT_BASE +TIMER_COUNT_VAL ); +struct msm_clock *clock = &msm_clocks[MSM_CLOCK_GPT ]; +return msm_read_timer_count (clock,GLOBAL_TIMER );
Why don't you store the address of the read register including the shift value into the msm_clock structure ?
clock->counter_reg
clock->counter_shiftAnd then embedd the clocksource struct there as well, so you can dereference msm_clock with container_of() and reduce the 3 read functions to a single one.
Quoted 7 lines
}
static
cycle_tmsm_dgt_read(struct clocksource *cs){arch/arm/mach-msm/timer.c +2
-1-return readl (MSM_DGT_BASE +TIMER_COUNT_VAL ) >>MSM_DGT_SHIFT ; +struct msm_clock *clock = &msm_clocks[MSM_CLOCK_DGT ]; +
arch/arm/mach-msm/timer.c struct msm_clock { · line 137
Quoted 10 lines
arch/arm/mach-msm/timer.c +10
-0+return msm_read_timer_count (clock,GLOBAL_TIMER ) >>MSM_DGT_SHIFT ; +} + +static struct msm_clock *clockevent_to_clock (struct clock_event_device *evt) +{ +#ifdef CONFIG_SMP +int i; +for (i =0 ; i <NR_TIMERS ; i++) +if (evt == &(msm_clocks[i].clockevent)) +return &msm_clocks[i];
Why don't you use container_of here as well ?
Quoted 24 lines
arch/arm/mach-msm/timer.c +8
-5+return &msm_clocks[MSM_GLOBAL_TIMER ]; +#else + return container_of(evt, struct msm_clock, clockevent); +#endif }static int msm_timer_set_next_event (unsigned long cycles,struct clock_event_device *evt) { - struct msm_clock *clock = container_of(evt, struct msm_clock, clockevent); -uint32_t now =readl (clock->regbase +TIMER_COUNT_VAL ); +struct msm_clock *clock =clockevent_to_clock (evt); +uint32_t now =msm_read_timer_count (clock,LOCAL_TIMER );uint32_t alarm = now + (cycles << clock->shift);int late;writel (alarm, clock->regbase +TIMER_MATCH_VAL ); - now =readl (clock->regbase +TIMER_COUNT_VAL ); + + now =msm_read_timer_count (clock,LOCAL_TIMER ); late = now - alarm;if (late >= (-2 << clock->shift) && late <DGT_HZ *5 ) { - printk(KERN_NOTICE "msm_timer_set_next_event(%lu) clock %s, " - "alarm already expired, now %x, alarm %x, late %d\n",
arch/arm/mach-msm/timer.c struct msm_clock { · line 165
Quoted 10 lines
arch/arm/mach-msm/timer.c +9
-1- cycles, clock->clockevent.name, now, alarm, late); +static int print_limit =10 ; +if (print_limit >0 ) { + print_limit--; +printk (KERN_NOTICE "msm_timer_set_next_event(%lu) " +"clock %s, alarm already expired, now %x, " +"alarm %x, late %d%s\n" , + cycles, clock->clockevent.name, now, alarm, late, + print_limit ?"" :" stop printing" ); + }
The generic clockevents layer has already a check for this. No need for extra printk spam.
arch/arm/mach-msm/timer.c static int msm_timer_set_next_event(unsigned long cycles, · line 177
Quoted 12 lines
arch/arm/mach-msm/timer.c +4
-1return -ETIME ; }return 0 ;@@ -107,7 +171,11 @@ static int msm_timer_set_next_event(unsigned long cycles,static void msm_timer_set_mode (enum clock_event_mode mode,struct clock_event_device *evt) { - struct msm_clock *clock = container_of(evt, struct msm_clock, clockevent); +struct msm_clock *clock =clockevent_to_clock (evt); +unsigned long irq_flags; + +local_irq_save (irq_flags);
Always called with interrupts disabled.
Quoted 38 lines
arch/arm/mach-msm/timer.c +24
-0+switch (mode) {case CLOCK_EVT_MODE_RESUME :case CLOCK_EVT_MODE_PERIODIC :@@ -120,6 +188,7 @@ static void msm_timer_set_mode(enum clock_event_mode mode,writel (0 , clock->regbase +TIMER_ENABLE );break ; } +local_irq_restore (irq_flags); }static struct msm_clock msm_clocks[] = {@@ -220,6 +289,58 @@ static void __init msm_timer_init(void) } } +#ifdef CONFIG_SMP +void local_timer_setup (struct clock_event_device *evt) +{ +unsigned long flags; +struct msm_clock *clock = &msm_clocks[MSM_GLOBAL_TIMER ]; + +#ifdef CONFIG_ARCH_MSM8X60 +writel (DGT_CLK_CTL_DIV_4 ,MSM_TMR_BASE +DGT_CLK_CTL ); +#endif + +if (!local_clock_event) { +writel (0 , clock->regbase +TIMER_ENABLE ); +writel (0 , clock->regbase +TIMER_CLEAR ); +writel (~0 , clock->regbase +TIMER_MATCH_VAL ); + } + evt->irq = clock->irq.irq; + evt->name ="local_timer" ; + evt->features =CLOCK_EVT_FEAT_ONESHOT ; + evt->rating = clock->clockevent.rating; + evt->set_mode = msm_timer_set_mode; + evt->set_next_event = msm_timer_set_next_event; + evt->shift = clock->clockevent.shift;
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 323
Quoted 10 lines
arch/arm/mach-msm/timer.c +10
-0+ evt->mult =div_sc (clock->freq,NSEC_PER_SEC , evt->shift); + evt->max_delta_ns = +clockevent_delta2ns (0xf0000000 >> clock->shift, evt); + evt->min_delta_ns =clockevent_delta2ns (4 , evt); + evt->cpumask =cpumask_of (smp_processor_id ()); + + local_clock_event = evt; + +local_irq_save (flags); +get_irq_chip (clock->irq.irq)->unmask (clock->irq.irq);
Why are you fiddling wiht the irqchip functions directly ? Please use disable_irq/enable_irq if at all.
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 331
Quoted 8 lines
arch/arm/mach-msm/timer.c +8
-0+local_irq_restore (flags); + +clockevents_register_device (evt); +} + +int local_timer_ack (void ) +{ +return 1 ;
Shouldn't that be an inline ? Why calling code which the compiler could optimize out.
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 337
Quoted 6 lines
arch/arm/mach-msm/timer.c +6
-0+} + +#ifdef CONFIG_HOTPLUG_CPU +void __cpuexit local_timer_stop(void) +{ + local_clock_event->set_mode (CLOCK_EVT_MODE_SHUTDOWN , local_clock_event);
Aarg. No. The generic code already handles cpu hotplug.
Thanks,
tglx
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
Quoted 5 lines · Thomas Gleixner
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 323
Quoted 2 lines
arch/arm/mach-msm/timer.c +2
-0+local_irq_save (flags); +get_irq_chip (clock->irq.irq)->unmask (clock->irq.irq);Why are you fiddling wiht the irqchip functions directly ? Please use disable_irq/enable_irq if at all.
PPI. The interrupt has to be enabled by the very same CPU that wants to receive the interrupt. Other CPUs on the system do not have access to the interrupt enable bits for PPIs.
That's something which genirq can't handle because it doesn't _actually_ support real per-CPU interrupts - iow, ones which are truely private to CPU N.
Eg, if IRQ 29 is the local timer interrupt, then CPU0 has its own IRQ29 which is distinctly different - and has separate enable registers and ultimately different timer hardware - from CPU1's IRQ29.
On the other SMP platforms, these interrupts aren't handled by genirq, but we do control them via code like the above (which I'm about to kill off and move that detail into gic.c.)
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
Quoted 10 lines · Russell King - ARM Linux
Quoted 5 lines · Thomas Gleixner
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 323
Quoted 2 lines
arch/arm/mach-msm/timer.c +2
-0+local_irq_save (flags); +get_irq_chip (clock->irq.irq)->unmask (clock->irq.irq);Why are you fiddling wiht the irqchip functions directly ? Please use disable_irq/enable_irq if at all.
PPI. The interrupt has to be enabled by the very same CPU that wants to receive the interrupt. Other CPUs on the system do not have access to the interrupt enable bits for PPIs.
That's fine, but the code is called on that very cpu anyway, so enable_irq() ends up calling the very same chip->unmask()
Quoted 3 lines
That's something which genirq can't handle because it doesn't _actually_ support real per-CPU interrupts - iow, ones which are truely private to CPU N.
So what you want to avoid are the enable/disable_irq() side effects (setting/clearing the IRQ_DISABLED flags etc.) as they would apply to the other cpus as well - which would be bogus of course.
We could actually solve that in the genirq code in a halfways simple way. Now that we get the references to the irq descriptors via irq_to_desc() we could add a function which marks an irq as percpu and use the main irq descriptor as a place holder which allocates percpu memory for the real descriptors. irq_to_desc() would lookup the main descriptor and hand back the one for the current cpu if the percpu pointer is set. That would allow you to use the generic functions at least with some care (functions need to be called from migration disabled code).
Thanks,
tglx
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
In reply to Thomas GleixnerQuoted 8 lines · Thomas Gleixner
arch/arm/mach-msm/timer.c struct msm_clock { · line 97
Quoted 5 lines · Jeff Ohlstein
static
irqreturn_tmsm_timer_interrupt(int irq, void *dev_id){arch/arm/mach-msm/timer.c +2
-0struct clock_event_device *evt = dev_id; +if (smp_processor_id () !=0 ) + evt = local_clock_event;Why is
dev_idnot pointing to the correct device in the first place?
dev_id is specified per struct irqaction, which is registered once per irq number. However, each core has a separate clock_event_device. Since the timer irq has the same irq number on both cores, we need to know what core we are on to know which clock_event_device is the correct one.
Quoted 16 lines
arch/arm/mach-msm/timer.c struct msm_clock { · line 114
Quoted 12 lines
arch/arm/mach-msm/timer.c +11
-0+static uint32_t msm_read_timer_count (struct msm_clock *clock, +enum timer_location global) +{ +uint32_t t1; + +if (global) + t1 =readl (clock->regbase +TIMER_COUNT_VAL +MSM_TMR_GLOBAL ); +else + t1 =readl (clock->regbase +TIMER_COUNT_VAL ); + +return t1;Adding such conditionals into a fast path is brilliant. Granted, gcc might optimize it out, but I'm not sure given the number of call sites.
Quoted 1 line
What's the point of this exercise ?
The reason is I had a common function for reading a timer count, but sometimes we want to read the cpu local timer, such as in the case of set_next_event, but sometimes I want to read a global timer, which is at a different address. However, you are right that it is silly to put a conditional there, especially when which branch I want is static at the callsite.
Quoted 11 lines
arch/arm/mach-msm/timer.c struct msm_clock { · line 121
Quoted 7 lines
arch/arm/mach-msm/timer.c +4
-1+} +static cycle_t msm_gpt_read (struct clocksource *cs) { -return readl (MSM_GPT_BASE +TIMER_COUNT_VAL ); +struct msm_clock *clock = &msm_clocks[MSM_CLOCK_GPT ]; +return msm_read_timer_count (clock,GLOBAL_TIMER );Why don't you store the address of the read register including the shift value into the
msm_clockstructure ?
Quoted 6 lines
clock->counter_reg clock->counter_shiftAnd then embedd the clocksource struct there as well, so you can dereference
msm_clockwithcontainer_of()and reduce the 3 read functions to a single one.
Done.
Quoted 9 lines
arch/arm/mach-msm/timer.c struct msm_clock { · line 137
Quoted 7 lines
arch/arm/mach-msm/timer.c +7
-0+static struct msm_clock *clockevent_to_clock (struct clock_event_device *evt) +{ +#ifdef CONFIG_SMP +int i; +for (i =0 ; i <NR_TIMERS ; i++) +if (evt == &(msm_clocks[i].clockevent)) +return &msm_clocks[i];Why don't you use
container_ofhere as well ?
The clockevent could be the local_clock_event, which is not embedded into a struct msm_clock. However, its parameters will be the same as one of the existing msm_clock entries, so use that.
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-msm/timer.c +4
-3if (late >= (-2 << clock->shift) && late <DGT_HZ *5 ) { -printk (KERN_NOTICE "msm_timer_set_next_event(%lu) clock %s, " -"alarm already expired, now %x, alarm %x, late %d\n" , - cycles, clock->clockevent.name, now, alarm, late); +static int print_limit =10 ; +if (print_limit >0 ) { + print_limit--; + printk(KERN_NOTICE "msm_timer_set_next_event(%lu) "
Quoted 8 lines
arch/arm/mach-msm/timer.c struct msm_clock { · line 165
Quoted 5 lines
arch/arm/mach-msm/timer.c +5
-0+"clock %s, alarm already expired, now %x, " +"alarm %x, late %d%s\n" , + cycles, clock->clockevent.name, now, alarm, late, + print_limit ? "" : " stop printing"); + }The generic clockevents layer has already a check for this. No need for extra printk spam.
Done.
Quoted 11 lines
arch/arm/mach-msm/timer.c static int msm_timer_set_next_event(unsigned long cycles, · line 177
Quoted 9 lines
arch/arm/mach-msm/timer.c +4
-1@@ -107,7 +171,11 @@ static int msm_timer_set_next_event(unsigned long cycles,static void msm_timer_set_mode (enum clock_event_mode mode,struct clock_event_device *evt) { - struct msm_clock *clock = container_of(evt, struct msm_clock, clockevent); +struct msm_clock *clock =clockevent_to_clock (evt); +unsigned long irq_flags; + +local_irq_save (irq_flags);Always called with interrupts disabled.
Done.
Quoted 6 lines
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 323
Quoted 4 lines
arch/arm/mach-msm/timer.c +4
-0+ local_clock_event = evt; + +local_irq_save (flags); +get_irq_chip (clock->irq.irq)->unmask (clock->irq.irq);Why are you fiddling wiht the irqchip functions directly ? Please use disable_irq/enable_irq if at all.
As stated by Russell, this is due to the fact that the timer interrupts are private to each core, and share the same irq number on each core.
Quoted 6 lines
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 331
Quoted 3 lines
arch/arm/mach-msm/timer.c +3
-0+int local_timer_ack (void ) +{ +return 1 ;Shouldn't that be an inline ? Why calling code which the compiler could optimize out.
Done.
Quoted 6 lines
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 337
Quoted 4 lines
arch/arm/mach-msm/timer.c +4
-0+#ifdef CONFIG_HOTPLUG_CPU +void __cpuexit local_timer_stop(void) +{ + local_clock_event->set_mode (CLOCK_EVT_MODE_SHUTDOWN , local_clock_event);Aarg. No. The generic code already handles cpu hotplug.
So what needs to be done in local_timer_stop? Just stopping the timer from ticking? Aren't I going to want to do all the same things my set_mode function does in the shutdown case? I understand not calling into the clockevents functions, would you be opposed to me directly calling my set_mode function?
-Jeff
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
In reply to Thomas GleixnerQuoted 7 lines · Thomas Gleixner
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 337
Quoted 4 lines · Jeff Ohlstein
arch/arm/mach-msm/timer.c +4
-0+#ifdef CONFIG_HOTPLUG_CPU +void __cpuexit local_timer_stop(void) +{ + local_clock_event->set_mode (CLOCK_EVT_MODE_SHUTDOWN , local_clock_event);Aarg. No. The generic code already handles cpu hotplug.
Can you show where this is handled by the generic code? I can't find where this is handled.
Re: [PATCH 3/5] msm: timer: SMP timer support for msm
Quoted 11 lines · Russell King - ARM Linux
Quoted 7 lines · Thomas Gleixner
arch/arm/mach-msm/timer.c static void __init msm_timer_init(void) · line 337
Quoted 4 lines · Jeff Ohlstein
arch/arm/mach-msm/timer.c +4
-0+#ifdef CONFIG_HOTPLUG_CPU +void __cpuexit local_timer_stop(void) +{ + local_clock_event->set_mode (CLOCK_EVT_MODE_SHUTDOWN , local_clock_event);Aarg. No. The generic code already handles cpu hotplug.
Can you show where this is handled by the generic code? I can't find where this is handled.
Having checked this on Versatile Express with a printk in the ->set_mode callback, the generic code does not handle shutting down clock event devices on CPU hot-unplug.
I've analyzed why this is:
The hrtimer() code hooks into the hotplug notifier list, and when it receives a CPU_DEAD or CPU_DEAD_FROZEN message, it calls clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DEAD).
The clockevents code calls its own notifier list, which ultimately calls tick_notify(). This eventually calls tick_shutdown().
tick_shutdown() looks up the per-cpu tick device, uncouples the clock event device from the tick device, and sets the clock event device mode to CLOCK_EVT_MODE_UNUSED. Note this comment:
/*
* Prevent that the clock events layer tries to call
* the set mode function!
*/
dev->mode = CLOCK_EVT_MODE_UNUSED;translating that into English:
"Prevent the clock events layer calling the set_mode function"
That might be it - to confirm:
It then calls clockevents_exchange_device(dev, NULL).
clockevents_exchange_device(old,new) calls clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED), which then does:
if (dev->mode != mode) {However, as dev->mode was set to CLOCK_EVT_MODE_UNUSED, and mode is CLOCK_EVT_MODE_UNUSED, we don't call into the code which supplies the clock event device at all, leaving it with no way to fully shutdown its hardware. It seems this is done on purpose, though it's not clear why.
This is why arch code, such as ARM, has to implement its own solution to shutdown clock event devices external to the generic clockevents code. Until we have a generic solution, I think I'm going to take the above code extract into the ARM generic local timer code and kill off the local_timer_stop() function.
PATCH 4/5 msm: hotplug: support cpu hotplug on msm
In reply to Jeff Ohlstein--- arch/arm/mach-msm/Makefile | 2 + arch/arm/mach-msm/hotplug.c | 101 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/hotplug.c
arch/arm/mach-msm/Makefile +2 -0
@@ -20,6 +20,8 @@ obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o obj-$(CONFIG_MSM_SMD) += last_radio_log.o obj-$(CONFIG_MSM_SCM) += scm.o scm-boot.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o + obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o
arch/arm/mach-msm/hotplug.c new file +101 -0
101 lines not on this page · raw message
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 5/5 msm: add SMP support for msm
In reply to Jeff Ohlstein--- arch/arm/mach-msm/Kconfig | 1 + arch/arm/mach-msm/Makefile | 1 + arch/arm/mach-msm/headsmp.S | 43 ++++++++++ arch/arm/mach-msm/include/mach/smp.h | 2 + arch/arm/mach-msm/platsmp.c | 147 ++++++++++++++++++++++++++++++++++ 5 files changed, 194 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/headsmp.S create mode 100644 arch/arm/mach-msm/platsmp.c
arch/arm/mach-msm/Kconfig +1 -0
@@ -40,6 +40,7 @@ config ARCH_MSM8X60 bool "MSM8X60" select MACH_MSM8X60_SURF if (!MACH_MSM8X60_RUMI3 && !MACH_MSM8X60_SIM \ && !MACH_MSM8X60_FFA) + select ARCH_MSM_SCORPIONMP select ARM_GIC select CPU_V7 select MSM_V2_TLMM
arch/arm/mach-msm/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_MSM_SMD) += last_radio_log.o obj-$(CONFIG_MSM_SCM) += scm.o scm-boot.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o +obj-$(CONFIG_SMP) += headsmp.o platsmp.o obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o
arch/arm/mach-msm/headsmp.S new file +43 -0
43 lines not on this page · raw message
arch/arm/mach-msm/include/mach/smp.h +2 -0
@@ -36,4 +36,6 @@ static inline void smp_cross_call(const struct cpumask *mask) gic_raise_softirq(mask, 1); } +extern int pen_release; +extern void msm_secondary_startup (void );#endif
arch/arm/mach-msm/platsmp.c new file +147 -0
147 lines not on this page · raw message
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.