Skip to content

Commit cd984a5

Browse files
committed
Merge tag 'xtensa-20190201' of git://github.com/jcmvbkbc/linux-xtensa
Pull xtensa fixes from Max Filippov: - fix ccount_timer_shutdown for secondary CPUs - fix secondary CPU initialization - fix secondary CPU reset vector clash with double exception vector - fix present CPUs when booting with 'maxcpus' parameter - limit possible CPUs by configured NR_CPUS - issue a warning if xtensa PIC is asked to retrigger anything other than software IRQ - fix masking/unmasking of the first two IRQs on xtensa MX PIC - fix typo in Kconfig description for user space unaligned access feature - fix Kconfig warning for selecting BUILTIN_DTB * tag 'xtensa-20190201' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: SMP: limit number of possible CPUs by NR_CPUS xtensa: rename BUILTIN_DTB to BUILTIN_DTB_SOURCE xtensa: Fix typo use space=>user space drivers/irqchip: xtensa-mx: fix mask and unmask drivers/irqchip: xtensa: add warning to irq_retrigger xtensa: SMP: mark each possible CPU as present xtensa: smp_lx200_defconfig: fix vectors clash xtensa: SMP: fix secondary CPU initialization xtensa: SMP: fix ccount_timer_shutdown
2 parents 8b050fe + 25384ce commit cd984a5

File tree

12 files changed

+73
-42
lines changed

12 files changed

+73
-42
lines changed

arch/xtensa/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ config XTENSA_FAKE_NMI
164164
If unsure, say N.
165165

166166
config XTENSA_UNALIGNED_USER
167-
bool "Unaligned memory access in use space"
167+
bool "Unaligned memory access in user space"
168168
help
169169
The Xtensa architecture currently does not handle unaligned
170170
memory accesses in hardware but through an exception handler.
@@ -451,7 +451,7 @@ config USE_OF
451451
help
452452
Include support for flattened device tree machine descriptions.
453453

454-
config BUILTIN_DTB
454+
config BUILTIN_DTB_SOURCE
455455
string "DTB to build into the kernel image"
456456
depends on OF
457457

arch/xtensa/boot/dts/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#
88
#
99

10-
BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB)).dtb.o
11-
ifneq ($(CONFIG_BUILTIN_DTB),"")
12-
obj-$(CONFIG_OF) += $(BUILTIN_DTB)
10+
BUILTIN_DTB_SOURCE := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
11+
ifneq ($(CONFIG_BUILTIN_DTB_SOURCE),"")
12+
obj-$(CONFIG_OF) += $(BUILTIN_DTB_SOURCE)
1313
endif
1414

1515
# for CONFIG_OF_ALL_DTBS test

arch/xtensa/configs/audio_kc705_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
3434
CONFIG_CMDLINE_BOOL=y
3535
CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000@0"
3636
CONFIG_USE_OF=y
37-
CONFIG_BUILTIN_DTB="kc705"
37+
CONFIG_BUILTIN_DTB_SOURCE="kc705"
3838
# CONFIG_COMPACTION is not set
3939
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
4040
CONFIG_PM=y

arch/xtensa/configs/cadence_csp_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CONFIG_HIGHMEM=y
3838
# CONFIG_PCI is not set
3939
CONFIG_XTENSA_PLATFORM_XTFPGA=y
4040
CONFIG_USE_OF=y
41-
CONFIG_BUILTIN_DTB="csp"
41+
CONFIG_BUILTIN_DTB_SOURCE="csp"
4242
# CONFIG_COMPACTION is not set
4343
CONFIG_XTFPGA_LCD=y
4444
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set

arch/xtensa/configs/generic_kc705_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
3333
CONFIG_CMDLINE_BOOL=y
3434
CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000@0"
3535
CONFIG_USE_OF=y
36-
CONFIG_BUILTIN_DTB="kc705"
36+
CONFIG_BUILTIN_DTB_SOURCE="kc705"
3737
# CONFIG_COMPACTION is not set
3838
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
3939
CONFIG_NET=y

arch/xtensa/configs/nommu_kc705_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
3939
CONFIG_CMDLINE_BOOL=y
4040
CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0x9d050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=256M@0x60000000"
4141
CONFIG_USE_OF=y
42-
CONFIG_BUILTIN_DTB="kc705_nommu"
42+
CONFIG_BUILTIN_DTB_SOURCE="kc705_nommu"
4343
CONFIG_BINFMT_FLAT=y
4444
CONFIG_NET=y
4545
CONFIG_PACKET=y

arch/xtensa/configs/smp_lx200_defconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ CONFIG_SMP=y
3333
CONFIG_HOTPLUG_CPU=y
3434
# CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX is not set
3535
# CONFIG_PCI is not set
36+
CONFIG_VECTORS_OFFSET=0x00002000
3637
CONFIG_XTENSA_PLATFORM_XTFPGA=y
3738
CONFIG_CMDLINE_BOOL=y
3839
CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=96M@0"
3940
CONFIG_USE_OF=y
40-
CONFIG_BUILTIN_DTB="lx200mx"
41+
CONFIG_BUILTIN_DTB_SOURCE="lx200mx"
4142
# CONFIG_COMPACTION is not set
4243
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
4344
CONFIG_NET=y

arch/xtensa/kernel/head.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,13 @@ should_never_return:
276276

277277
movi a2, cpu_start_ccount
278278
1:
279+
memw
279280
l32i a3, a2, 0
280281
beqi a3, 0, 1b
281282
movi a3, 0
282283
s32i a3, a2, 0
283-
memw
284284
1:
285+
memw
285286
l32i a3, a2, 0
286287
beqi a3, 0, 1b
287288
wsr a3, ccount
@@ -317,11 +318,13 @@ ENTRY(cpu_restart)
317318
rsr a0, prid
318319
neg a2, a0
319320
movi a3, cpu_start_id
321+
memw
320322
s32i a2, a3, 0
321323
#if XCHAL_DCACHE_IS_WRITEBACK
322324
dhwbi a3, 0
323325
#endif
324326
1:
327+
memw
325328
l32i a2, a3, 0
326329
dhi a3, 0
327330
bne a2, a0, 1b

arch/xtensa/kernel/smp.c

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
8383
{
8484
unsigned i;
8585

86-
for (i = 0; i < max_cpus; ++i)
86+
for_each_possible_cpu(i)
8787
set_cpu_present(i, true);
8888
}
8989

@@ -96,6 +96,11 @@ void __init smp_init_cpus(void)
9696
pr_info("%s: Core Count = %d\n", __func__, ncpus);
9797
pr_info("%s: Core Id = %d\n", __func__, core_id);
9898

99+
if (ncpus > NR_CPUS) {
100+
ncpus = NR_CPUS;
101+
pr_info("%s: limiting core count by %d\n", __func__, ncpus);
102+
}
103+
99104
for (i = 0; i < ncpus; ++i)
100105
set_cpu_possible(i, true);
101106
}
@@ -195,9 +200,11 @@ static int boot_secondary(unsigned int cpu, struct task_struct *ts)
195200
int i;
196201

197202
#ifdef CONFIG_HOTPLUG_CPU
198-
cpu_start_id = cpu;
199-
system_flush_invalidate_dcache_range(
200-
(unsigned long)&cpu_start_id, sizeof(cpu_start_id));
203+
WRITE_ONCE(cpu_start_id, cpu);
204+
/* Pairs with the third memw in the cpu_restart */
205+
mb();
206+
system_flush_invalidate_dcache_range((unsigned long)&cpu_start_id,
207+
sizeof(cpu_start_id));
201208
#endif
202209
smp_call_function_single(0, mx_cpu_start, (void *)cpu, 1);
203210

@@ -206,18 +213,21 @@ static int boot_secondary(unsigned int cpu, struct task_struct *ts)
206213
ccount = get_ccount();
207214
while (!ccount);
208215

209-
cpu_start_ccount = ccount;
216+
WRITE_ONCE(cpu_start_ccount, ccount);
210217

211-
while (time_before(jiffies, timeout)) {
218+
do {
219+
/*
220+
* Pairs with the first two memws in the
221+
* .Lboot_secondary.
222+
*/
212223
mb();
213-
if (!cpu_start_ccount)
214-
break;
215-
}
224+
ccount = READ_ONCE(cpu_start_ccount);
225+
} while (ccount && time_before(jiffies, timeout));
216226

217-
if (cpu_start_ccount) {
227+
if (ccount) {
218228
smp_call_function_single(0, mx_cpu_stop,
219-
(void *)cpu, 1);
220-
cpu_start_ccount = 0;
229+
(void *)cpu, 1);
230+
WRITE_ONCE(cpu_start_ccount, 0);
221231
return -EIO;
222232
}
223233
}
@@ -237,6 +247,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
237247
pr_debug("%s: Calling wakeup_secondary(cpu:%d, idle:%p, sp: %08lx)\n",
238248
__func__, cpu, idle, start_info.stack);
239249

250+
init_completion(&cpu_running);
240251
ret = boot_secondary(cpu, idle);
241252
if (ret == 0) {
242253
wait_for_completion_timeout(&cpu_running,
@@ -298,8 +309,10 @@ void __cpu_die(unsigned int cpu)
298309
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
299310
while (time_before(jiffies, timeout)) {
300311
system_invalidate_dcache_range((unsigned long)&cpu_start_id,
301-
sizeof(cpu_start_id));
302-
if (cpu_start_id == -cpu) {
312+
sizeof(cpu_start_id));
313+
/* Pairs with the second memw in the cpu_restart */
314+
mb();
315+
if (READ_ONCE(cpu_start_id) == -cpu) {
303316
platform_cpu_kill(cpu);
304317
return;
305318
}

arch/xtensa/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int ccount_timer_shutdown(struct clock_event_device *evt)
8989
container_of(evt, struct ccount_timer, evt);
9090

9191
if (timer->irq_enabled) {
92-
disable_irq(evt->irq);
92+
disable_irq_nosync(evt->irq);
9393
timer->irq_enabled = 0;
9494
}
9595
return 0;

drivers/irqchip/irq-xtensa-mx.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,35 @@ static void xtensa_mx_irq_mask(struct irq_data *d)
7171
unsigned int mask = 1u << d->hwirq;
7272

7373
if (mask & (XCHAL_INTTYPE_MASK_EXTERN_EDGE |
74-
XCHAL_INTTYPE_MASK_EXTERN_LEVEL)) {
75-
set_er(1u << (xtensa_get_ext_irq_no(d->hwirq) -
76-
HW_IRQ_MX_BASE), MIENG);
77-
} else {
78-
mask = __this_cpu_read(cached_irq_mask) & ~mask;
79-
__this_cpu_write(cached_irq_mask, mask);
80-
xtensa_set_sr(mask, intenable);
74+
XCHAL_INTTYPE_MASK_EXTERN_LEVEL)) {
75+
unsigned int ext_irq = xtensa_get_ext_irq_no(d->hwirq);
76+
77+
if (ext_irq >= HW_IRQ_MX_BASE) {
78+
set_er(1u << (ext_irq - HW_IRQ_MX_BASE), MIENG);
79+
return;
80+
}
8181
}
82+
mask = __this_cpu_read(cached_irq_mask) & ~mask;
83+
__this_cpu_write(cached_irq_mask, mask);
84+
xtensa_set_sr(mask, intenable);
8285
}
8386

8487
static void xtensa_mx_irq_unmask(struct irq_data *d)
8588
{
8689
unsigned int mask = 1u << d->hwirq;
8790

8891
if (mask & (XCHAL_INTTYPE_MASK_EXTERN_EDGE |
89-
XCHAL_INTTYPE_MASK_EXTERN_LEVEL)) {
90-
set_er(1u << (xtensa_get_ext_irq_no(d->hwirq) -
91-
HW_IRQ_MX_BASE), MIENGSET);
92-
} else {
93-
mask |= __this_cpu_read(cached_irq_mask);
94-
__this_cpu_write(cached_irq_mask, mask);
95-
xtensa_set_sr(mask, intenable);
92+
XCHAL_INTTYPE_MASK_EXTERN_LEVEL)) {
93+
unsigned int ext_irq = xtensa_get_ext_irq_no(d->hwirq);
94+
95+
if (ext_irq >= HW_IRQ_MX_BASE) {
96+
set_er(1u << (ext_irq - HW_IRQ_MX_BASE), MIENGSET);
97+
return;
98+
}
9699
}
100+
mask |= __this_cpu_read(cached_irq_mask);
101+
__this_cpu_write(cached_irq_mask, mask);
102+
xtensa_set_sr(mask, intenable);
97103
}
98104

99105
static void xtensa_mx_irq_enable(struct irq_data *d)
@@ -113,7 +119,11 @@ static void xtensa_mx_irq_ack(struct irq_data *d)
113119

114120
static int xtensa_mx_irq_retrigger(struct irq_data *d)
115121
{
116-
xtensa_set_sr(1 << d->hwirq, intset);
122+
unsigned int mask = 1u << d->hwirq;
123+
124+
if (WARN_ON(mask & ~XCHAL_INTTYPE_MASK_SOFTWARE))
125+
return 0;
126+
xtensa_set_sr(mask, intset);
117127
return 1;
118128
}
119129

drivers/irqchip/irq-xtensa-pic.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ static void xtensa_irq_ack(struct irq_data *d)
7070

7171
static int xtensa_irq_retrigger(struct irq_data *d)
7272
{
73-
xtensa_set_sr(1 << d->hwirq, intset);
73+
unsigned int mask = 1u << d->hwirq;
74+
75+
if (WARN_ON(mask & ~XCHAL_INTTYPE_MASK_SOFTWARE))
76+
return 0;
77+
xtensa_set_sr(mask, intset);
7478
return 1;
7579
}
7680

0 commit comments

Comments
 (0)