Skip to content

Commit 2a1497c

Browse files
committedSep 11, 2012
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lliubbo/blackfin
Pull blackfin updates from Bob Liu: "One kbuild and a smp build fix." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lliubbo/blackfin: kbuild: add symbol prefix arg to kallsyms blackfin: smp: adapt to generic smp helpers
2 parents 1a95620 + 6895f97 commit 2a1497c

File tree

5 files changed

+75
-159
lines changed

5 files changed

+75
-159
lines changed
 

‎arch/blackfin/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config BLACKFIN
3838
select GENERIC_ATOMIC64
3939
select GENERIC_IRQ_PROBE
4040
select IRQ_PER_CPU if SMP
41+
select USE_GENERIC_SMP_HELPERS if SMP
4142
select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
4243
select GENERIC_SMP_IDLE_THREAD
4344
select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS

‎arch/blackfin/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ endif
2020
KBUILD_AFLAGS += $(call cc-option,-mno-fdpic)
2121
KBUILD_CFLAGS_MODULE += -mlong-calls
2222
LDFLAGS += -m elf32bfin
23-
KALLSYMS += --symbol-prefix=_
2423

2524
KBUILD_DEFCONFIG := BF537-STAMP_defconfig
2625

‎arch/blackfin/include/asm/smp.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#define raw_smp_processor_id() blackfin_core_id()
1919

2020
extern void bfin_relocate_coreb_l1_mem(void);
21+
extern void arch_send_call_function_single_ipi(int cpu);
22+
extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
2123

2224
#if defined(CONFIG_SMP) && defined(CONFIG_ICACHE_FLUSH_L1)
2325
asmlinkage void blackfin_icache_flush_range_l1(unsigned long *ptr);

‎arch/blackfin/mach-common/smp.c

+66-157
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ unsigned long blackfin_iflush_l1_entry[NR_CPUS];
4848

4949
struct blackfin_initial_pda __cpuinitdata initial_pda_coreb;
5050

51-
#define BFIN_IPI_TIMER 0
52-
#define BFIN_IPI_RESCHEDULE 1
53-
#define BFIN_IPI_CALL_FUNC 2
54-
#define BFIN_IPI_CPU_STOP 3
51+
enum ipi_message_type {
52+
BFIN_IPI_TIMER,
53+
BFIN_IPI_RESCHEDULE,
54+
BFIN_IPI_CALL_FUNC,
55+
BFIN_IPI_CALL_FUNC_SINGLE,
56+
BFIN_IPI_CPU_STOP,
57+
};
5558

5659
struct blackfin_flush_data {
5760
unsigned long start;
@@ -60,35 +63,20 @@ struct blackfin_flush_data {
6063

6164
void *secondary_stack;
6265

63-
64-
struct smp_call_struct {
65-
void (*func)(void *info);
66-
void *info;
67-
int wait;
68-
cpumask_t *waitmask;
69-
};
70-
7166
static struct blackfin_flush_data smp_flush_data;
7267

7368
static DEFINE_SPINLOCK(stop_lock);
7469

75-
struct ipi_message {
76-
unsigned long type;
77-
struct smp_call_struct call_struct;
78-
};
79-
8070
/* A magic number - stress test shows this is safe for common cases */
8171
#define BFIN_IPI_MSGQ_LEN 5
8272

8373
/* Simple FIFO buffer, overflow leads to panic */
84-
struct ipi_message_queue {
85-
spinlock_t lock;
74+
struct ipi_data {
8675
unsigned long count;
87-
unsigned long head; /* head of the queue */
88-
struct ipi_message ipi_message[BFIN_IPI_MSGQ_LEN];
76+
unsigned long bits;
8977
};
9078

91-
static DEFINE_PER_CPU(struct ipi_message_queue, ipi_msg_queue);
79+
static DEFINE_PER_CPU(struct ipi_data, bfin_ipi);
9280

9381
static void ipi_cpu_stop(unsigned int cpu)
9482
{
@@ -129,28 +117,6 @@ static void ipi_flush_icache(void *info)
129117
blackfin_icache_flush_range(fdata->start, fdata->end);
130118
}
131119

132-
static void ipi_call_function(unsigned int cpu, struct ipi_message *msg)
133-
{
134-
int wait;
135-
void (*func)(void *info);
136-
void *info;
137-
func = msg->call_struct.func;
138-
info = msg->call_struct.info;
139-
wait = msg->call_struct.wait;
140-
func(info);
141-
if (wait) {
142-
#ifdef __ARCH_SYNC_CORE_DCACHE
143-
/*
144-
* 'wait' usually means synchronization between CPUs.
145-
* Invalidate D cache in case shared data was changed
146-
* by func() to ensure cache coherence.
147-
*/
148-
resync_core_dcache();
149-
#endif
150-
cpumask_clear_cpu(cpu, msg->call_struct.waitmask);
151-
}
152-
}
153-
154120
/* Use IRQ_SUPPLE_0 to request reschedule.
155121
* When returning from interrupt to user space,
156122
* there is chance to reschedule */
@@ -172,152 +138,95 @@ void ipi_timer(void)
172138

173139
static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
174140
{
175-
struct ipi_message *msg;
176-
struct ipi_message_queue *msg_queue;
141+
struct ipi_data *bfin_ipi_data;
177142
unsigned int cpu = smp_processor_id();
178-
unsigned long flags;
143+
unsigned long pending;
144+
unsigned long msg;
179145

180146
platform_clear_ipi(cpu, IRQ_SUPPLE_1);
181147

182-
msg_queue = &__get_cpu_var(ipi_msg_queue);
183-
184-
spin_lock_irqsave(&msg_queue->lock, flags);
185-
186-
while (msg_queue->count) {
187-
msg = &msg_queue->ipi_message[msg_queue->head];
188-
switch (msg->type) {
189-
case BFIN_IPI_TIMER:
190-
ipi_timer();
191-
break;
192-
case BFIN_IPI_RESCHEDULE:
193-
scheduler_ipi();
194-
break;
195-
case BFIN_IPI_CALL_FUNC:
196-
ipi_call_function(cpu, msg);
197-
break;
198-
case BFIN_IPI_CPU_STOP:
199-
ipi_cpu_stop(cpu);
200-
break;
201-
default:
202-
printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%lx\n",
203-
cpu, msg->type);
204-
break;
205-
}
206-
msg_queue->head++;
207-
msg_queue->head %= BFIN_IPI_MSGQ_LEN;
208-
msg_queue->count--;
148+
bfin_ipi_data = &__get_cpu_var(bfin_ipi);
149+
150+
while ((pending = xchg(&bfin_ipi_data->bits, 0)) != 0) {
151+
msg = 0;
152+
do {
153+
msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1);
154+
switch (msg) {
155+
case BFIN_IPI_TIMER:
156+
ipi_timer();
157+
break;
158+
case BFIN_IPI_RESCHEDULE:
159+
scheduler_ipi();
160+
break;
161+
case BFIN_IPI_CALL_FUNC:
162+
generic_smp_call_function_interrupt();
163+
break;
164+
165+
case BFIN_IPI_CALL_FUNC_SINGLE:
166+
generic_smp_call_function_single_interrupt();
167+
break;
168+
169+
case BFIN_IPI_CPU_STOP:
170+
ipi_cpu_stop(cpu);
171+
break;
172+
}
173+
} while (msg < BITS_PER_LONG);
174+
175+
smp_mb();
209176
}
210-
spin_unlock_irqrestore(&msg_queue->lock, flags);
211177
return IRQ_HANDLED;
212178
}
213179

214-
static void ipi_queue_init(void)
180+
static void bfin_ipi_init(void)
215181
{
216182
unsigned int cpu;
217-
struct ipi_message_queue *msg_queue;
183+
struct ipi_data *bfin_ipi_data;
218184
for_each_possible_cpu(cpu) {
219-
msg_queue = &per_cpu(ipi_msg_queue, cpu);
220-
spin_lock_init(&msg_queue->lock);
221-
msg_queue->count = 0;
222-
msg_queue->head = 0;
185+
bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
186+
bfin_ipi_data->bits = 0;
187+
bfin_ipi_data->count = 0;
223188
}
224189
}
225190

226-
static inline void smp_send_message(cpumask_t callmap, unsigned long type,
227-
void (*func) (void *info), void *info, int wait)
191+
void send_ipi(const struct cpumask *cpumask, enum ipi_message_type msg)
228192
{
229193
unsigned int cpu;
230-
struct ipi_message_queue *msg_queue;
231-
struct ipi_message *msg;
232-
unsigned long flags, next_msg;
233-
cpumask_t waitmask; /* waitmask is shared by all cpus */
234-
235-
cpumask_copy(&waitmask, &callmap);
236-
for_each_cpu(cpu, &callmap) {
237-
msg_queue = &per_cpu(ipi_msg_queue, cpu);
238-
spin_lock_irqsave(&msg_queue->lock, flags);
239-
if (msg_queue->count < BFIN_IPI_MSGQ_LEN) {
240-
next_msg = (msg_queue->head + msg_queue->count)
241-
% BFIN_IPI_MSGQ_LEN;
242-
msg = &msg_queue->ipi_message[next_msg];
243-
msg->type = type;
244-
if (type == BFIN_IPI_CALL_FUNC) {
245-
msg->call_struct.func = func;
246-
msg->call_struct.info = info;
247-
msg->call_struct.wait = wait;
248-
msg->call_struct.waitmask = &waitmask;
249-
}
250-
msg_queue->count++;
251-
} else
252-
panic("IPI message queue overflow\n");
253-
spin_unlock_irqrestore(&msg_queue->lock, flags);
194+
struct ipi_data *bfin_ipi_data;
195+
unsigned long flags;
196+
197+
local_irq_save(flags);
198+
199+
for_each_cpu(cpu, cpumask) {
200+
bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
201+
smp_mb();
202+
set_bit(msg, &bfin_ipi_data->bits);
203+
bfin_ipi_data->count++;
254204
platform_send_ipi_cpu(cpu, IRQ_SUPPLE_1);
255205
}
256206

257-
if (wait) {
258-
while (!cpumask_empty(&waitmask))
259-
blackfin_dcache_invalidate_range(
260-
(unsigned long)(&waitmask),
261-
(unsigned long)(&waitmask));
262-
#ifdef __ARCH_SYNC_CORE_DCACHE
263-
/*
264-
* Invalidate D cache in case shared data was changed by
265-
* other processors to ensure cache coherence.
266-
*/
267-
resync_core_dcache();
268-
#endif
269-
}
207+
local_irq_restore(flags);
270208
}
271209

272-
int smp_call_function(void (*func)(void *info), void *info, int wait)
210+
void arch_send_call_function_single_ipi(int cpu)
273211
{
274-
cpumask_t callmap;
275-
276-
preempt_disable();
277-
cpumask_copy(&callmap, cpu_online_mask);
278-
cpumask_clear_cpu(smp_processor_id(), &callmap);
279-
if (!cpumask_empty(&callmap))
280-
smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
281-
282-
preempt_enable();
283-
284-
return 0;
212+
send_ipi(cpumask_of(cpu), BFIN_IPI_CALL_FUNC_SINGLE);
285213
}
286-
EXPORT_SYMBOL_GPL(smp_call_function);
287214

288-
int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
289-
int wait)
215+
void arch_send_call_function_ipi_mask(const struct cpumask *mask)
290216
{
291-
unsigned int cpu = cpuid;
292-
cpumask_t callmap;
293-
294-
if (cpu_is_offline(cpu))
295-
return 0;
296-
cpumask_clear(&callmap);
297-
cpumask_set_cpu(cpu, &callmap);
298-
299-
smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
300-
301-
return 0;
217+
send_ipi(mask, BFIN_IPI_CALL_FUNC);
302218
}
303-
EXPORT_SYMBOL_GPL(smp_call_function_single);
304219

305220
void smp_send_reschedule(int cpu)
306221
{
307-
cpumask_t callmap;
308-
/* simply trigger an ipi */
309-
310-
cpumask_clear(&callmap);
311-
cpumask_set_cpu(cpu, &callmap);
312-
313-
smp_send_message(callmap, BFIN_IPI_RESCHEDULE, NULL, NULL, 0);
222+
send_ipi(cpumask_of(cpu), BFIN_IPI_RESCHEDULE);
314223

315224
return;
316225
}
317226

318227
void smp_send_msg(const struct cpumask *mask, unsigned long type)
319228
{
320-
smp_send_message(*mask, type, NULL, NULL, 0);
229+
send_ipi(mask, type);
321230
}
322231

323232
void smp_timer_broadcast(const struct cpumask *mask)
@@ -333,7 +242,7 @@ void smp_send_stop(void)
333242
cpumask_copy(&callmap, cpu_online_mask);
334243
cpumask_clear_cpu(smp_processor_id(), &callmap);
335244
if (!cpumask_empty(&callmap))
336-
smp_send_message(callmap, BFIN_IPI_CPU_STOP, NULL, NULL, 0);
245+
send_ipi(&callmap, BFIN_IPI_CPU_STOP);
337246

338247
preempt_enable();
339248

@@ -436,7 +345,7 @@ void __init smp_prepare_boot_cpu(void)
436345
void __init smp_prepare_cpus(unsigned int max_cpus)
437346
{
438347
platform_prepare_cpus(max_cpus);
439-
ipi_queue_init();
348+
bfin_ipi_init();
440349
platform_request_ipi(IRQ_SUPPLE_0, ipi_handler_int0);
441350
platform_request_ipi(IRQ_SUPPLE_1, ipi_handler_int1);
442351
}

‎scripts/link-vmlinux.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ kallsyms()
7474
info KSYM ${2}
7575
local kallsymopt;
7676

77+
if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then
78+
kallsymopt="${kallsymopt} \
79+
--symbol-prefix=${CONFIG_SYMBOL_PREFIX}"
80+
fi
81+
7782
if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
78-
kallsymopt=--all-symbols
83+
kallsymopt="${kallsymopt} --all-symbols"
7984
fi
8085

8186
local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \

0 commit comments

Comments
 (0)
Please sign in to comment.