Skip to content

Commit e6251f0

Browse files
committed
Merge tag 'arc-4.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
Pull ARC fixes from Vineet Gupta: - mmap handler for dma ops as generic handler no longer works for us [Alexey] - Fixes for EZChip platform [Noam] - Fix RTC clocksource driver build issue - ARC IRQ handling fixes [Yuriy] - Revert a recent makefile change which doesn't go well with oldish tools out in the wild * tag 'arc-4.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: ARCv2: MCIP: Use IDU_M_DISTRI_DEST mode if there is only 1 destination core ARC: IRQ: Do not use hwirq as virq and vice versa ARC: [plat-eznps] set default baud for early console ARC: [plat-eznps] remove IPI clear from SMP operations Revert "ARC: build: retire old toggles" ARC: timer: rtc: implement read loop in "C" vs. inline asm ARC: change return value of userspace cmpxchg assist syscall arc: Implement arch-specific dma_map_ops.mmap ARC: [SMP] avoid overriding present cpumask ARC: Enable PERF_EVENTS in nSIM driven platforms
2 parents e3d183c + 0a0a047 commit e6251f0

19 files changed

+104
-49
lines changed

arch/arc/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ atleast_gcc44 := $(call cc-ifversion, -ge, 0404, y)
5050

5151
cflags-$(atleast_gcc44) += -fsection-anchors
5252

53+
cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
54+
cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
55+
5356
ifdef CONFIG_ISA_ARCV2
5457

5558
ifndef CONFIG_ARC_HAS_LL64

arch/arc/boot/dts/axc001.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
reg-io-width = <4>;
7272
};
7373

74-
arcpmu0: pmu {
74+
arcpct0: pct {
7575
compatible = "snps,arc700-pct";
7676
};
7777
};

arch/arc/boot/dts/nsim_700.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
};
7070
};
7171

72-
arcpmu0: pmu {
72+
arcpct0: pct {
7373
compatible = "snps,arc700-pct";
7474
};
7575
};

arch/arc/boot/dts/nsimosci.dts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@
8383
reg = <0xf0003000 0x44>;
8484
interrupts = <7>;
8585
};
86+
87+
arcpct0: pct {
88+
compatible = "snps,arc700-pct";
89+
};
8690
};
8791
};

arch/arc/configs/nsim_700_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_BLK_DEV_INITRD=y
1414
CONFIG_INITRAMFS_SOURCE="../arc_initramfs/"
1515
CONFIG_KALLSYMS_ALL=y
1616
CONFIG_EMBEDDED=y
17+
CONFIG_PERF_EVENTS=y
1718
# CONFIG_SLUB_DEBUG is not set
1819
# CONFIG_COMPAT_BRK is not set
1920
CONFIG_KPROBES=y

arch/arc/configs/nsim_hs_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_BLK_DEV_INITRD=y
1414
CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
1515
CONFIG_KALLSYMS_ALL=y
1616
CONFIG_EMBEDDED=y
17+
CONFIG_PERF_EVENTS=y
1718
# CONFIG_SLUB_DEBUG is not set
1819
# CONFIG_COMPAT_BRK is not set
1920
CONFIG_KPROBES=y

arch/arc/configs/nsim_hs_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CONFIG_BLK_DEV_INITRD=y
1212
CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
1313
CONFIG_KALLSYMS_ALL=y
1414
CONFIG_EMBEDDED=y
15+
CONFIG_PERF_EVENTS=y
1516
# CONFIG_SLUB_DEBUG is not set
1617
# CONFIG_COMPAT_BRK is not set
1718
CONFIG_KPROBES=y

arch/arc/configs/nsimosci_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_BLK_DEV_INITRD=y
1414
CONFIG_INITRAMFS_SOURCE="../arc_initramfs/"
1515
CONFIG_KALLSYMS_ALL=y
1616
CONFIG_EMBEDDED=y
17+
CONFIG_PERF_EVENTS=y
1718
# CONFIG_SLUB_DEBUG is not set
1819
# CONFIG_COMPAT_BRK is not set
1920
CONFIG_KPROBES=y

arch/arc/configs/nsimosci_hs_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_BLK_DEV_INITRD=y
1414
CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
1515
CONFIG_KALLSYMS_ALL=y
1616
CONFIG_EMBEDDED=y
17+
CONFIG_PERF_EVENTS=y
1718
# CONFIG_SLUB_DEBUG is not set
1819
# CONFIG_COMPAT_BRK is not set
1920
CONFIG_KPROBES=y

arch/arc/configs/nsimosci_hs_smp_defconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_IKCONFIG_PROC=y
1010
# CONFIG_PID_NS is not set
1111
CONFIG_BLK_DEV_INITRD=y
1212
CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
13+
CONFIG_PERF_EVENTS=y
1314
# CONFIG_COMPAT_BRK is not set
1415
CONFIG_KPROBES=y
1516
CONFIG_MODULES=y
@@ -34,7 +35,6 @@ CONFIG_INET=y
3435
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
3536
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
3637
# CONFIG_INET_XFRM_MODE_BEET is not set
37-
# CONFIG_INET_LRO is not set
3838
# CONFIG_IPV6 is not set
3939
# CONFIG_WIRELESS is not set
4040
CONFIG_DEVTMPFS=y
@@ -72,7 +72,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
7272
# CONFIG_HWMON is not set
7373
CONFIG_DRM=y
7474
CONFIG_DRM_ARCPGU=y
75-
CONFIG_FRAMEBUFFER_CONSOLE=y
7675
CONFIG_LOGO=y
7776
# CONFIG_HID is not set
7877
# CONFIG_USB_SUPPORT is not set

arch/arc/include/asm/arcregs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@
4343
#define STATUS_AE_BIT 5 /* Exception active */
4444
#define STATUS_DE_BIT 6 /* PC is in delay slot */
4545
#define STATUS_U_BIT 7 /* User/Kernel mode */
46+
#define STATUS_Z_BIT 11
4647
#define STATUS_L_BIT 12 /* Loop inhibit */
4748

4849
/* These masks correspond to the status word(STATUS_32) bits */
4950
#define STATUS_AE_MASK (1<<STATUS_AE_BIT)
5051
#define STATUS_DE_MASK (1<<STATUS_DE_BIT)
5152
#define STATUS_U_MASK (1<<STATUS_U_BIT)
53+
#define STATUS_Z_MASK (1<<STATUS_Z_BIT)
5254
#define STATUS_L_MASK (1<<STATUS_L_BIT)
5355

5456
/*

arch/arc/include/asm/smp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ extern const char *arc_platform_smp_cpuinfo(void);
3737
* API expected BY platform smp code (FROM arch smp code)
3838
*
3939
* smp_ipi_irq_setup:
40-
* Takes @cpu and @irq to which the arch-common ISR is hooked up
40+
* Takes @cpu and @hwirq to which the arch-common ISR is hooked up
4141
*/
42-
extern int smp_ipi_irq_setup(int cpu, int irq);
42+
extern int smp_ipi_irq_setup(int cpu, irq_hw_number_t hwirq);
4343

4444
/*
4545
* struct plat_smp_ops - SMP callbacks provided by platform to ARC SMP

arch/arc/kernel/devtree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ static void __init arc_set_early_base_baud(unsigned long dt_root)
3131
arc_base_baud = 166666666; /* Fixed 166.6MHz clk (TB10x) */
3232
else if (of_flat_dt_is_compatible(dt_root, "snps,arc-sdp"))
3333
arc_base_baud = 33333333; /* Fixed 33MHz clk (AXS10x) */
34+
else if (of_flat_dt_is_compatible(dt_root, "ezchip,arc-nps"))
35+
arc_base_baud = 800000000; /* Fixed 800MHz clk (NPS) */
3436
else
3537
arc_base_baud = 50000000; /* Fixed default 50MHz */
3638
}

arch/arc/kernel/mcip.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,24 @@ idu_irq_set_affinity(struct irq_data *data, const struct cpumask *cpumask,
181181
{
182182
unsigned long flags;
183183
cpumask_t online;
184+
unsigned int destination_bits;
185+
unsigned int distribution_mode;
184186

185187
/* errout if no online cpu per @cpumask */
186188
if (!cpumask_and(&online, cpumask, cpu_online_mask))
187189
return -EINVAL;
188190

189191
raw_spin_lock_irqsave(&mcip_lock, flags);
190192

191-
idu_set_dest(data->hwirq, cpumask_bits(&online)[0]);
192-
idu_set_mode(data->hwirq, IDU_M_TRIG_LEVEL, IDU_M_DISTRI_RR);
193+
destination_bits = cpumask_bits(&online)[0];
194+
idu_set_dest(data->hwirq, destination_bits);
195+
196+
if (ffs(destination_bits) == fls(destination_bits))
197+
distribution_mode = IDU_M_DISTRI_DEST;
198+
else
199+
distribution_mode = IDU_M_DISTRI_RR;
200+
201+
idu_set_mode(data->hwirq, IDU_M_TRIG_LEVEL, distribution_mode);
193202

194203
raw_spin_unlock_irqrestore(&mcip_lock, flags);
195204

@@ -207,16 +216,15 @@ static struct irq_chip idu_irq_chip = {
207216

208217
};
209218

210-
static int idu_first_irq;
219+
static irq_hw_number_t idu_first_hwirq;
211220

212221
static void idu_cascade_isr(struct irq_desc *desc)
213222
{
214-
struct irq_domain *domain = irq_desc_get_handler_data(desc);
215-
unsigned int core_irq = irq_desc_get_irq(desc);
216-
unsigned int idu_irq;
223+
struct irq_domain *idu_domain = irq_desc_get_handler_data(desc);
224+
irq_hw_number_t core_hwirq = irqd_to_hwirq(irq_desc_get_irq_data(desc));
225+
irq_hw_number_t idu_hwirq = core_hwirq - idu_first_hwirq;
217226

218-
idu_irq = core_irq - idu_first_irq;
219-
generic_handle_irq(irq_find_mapping(domain, idu_irq));
227+
generic_handle_irq(irq_find_mapping(idu_domain, idu_hwirq));
220228
}
221229

222230
static int idu_irq_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq)
@@ -282,7 +290,7 @@ idu_of_init(struct device_node *intc, struct device_node *parent)
282290
struct irq_domain *domain;
283291
/* Read IDU BCR to confirm nr_irqs */
284292
int nr_irqs = of_irq_count(intc);
285-
int i, irq;
293+
int i, virq;
286294
struct mcip_bcr mp;
287295

288296
READ_BCR(ARC_REG_MCIP_BCR, mp);
@@ -303,11 +311,11 @@ idu_of_init(struct device_node *intc, struct device_node *parent)
303311
* however we need it to get the parent virq and set IDU handler
304312
* as first level isr
305313
*/
306-
irq = irq_of_parse_and_map(intc, i);
314+
virq = irq_of_parse_and_map(intc, i);
307315
if (!i)
308-
idu_first_irq = irq;
316+
idu_first_hwirq = irqd_to_hwirq(irq_get_irq_data(virq));
309317

310-
irq_set_chained_handler_and_data(irq, idu_cascade_isr, domain);
318+
irq_set_chained_handler_and_data(virq, idu_cascade_isr, domain);
311319
}
312320

313321
__mcip_cmd(CMD_IDU_ENABLE, 0);

arch/arc/kernel/process.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ SYSCALL_DEFINE0(arc_gettls)
4343

4444
SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
4545
{
46-
int uval;
47-
int ret;
46+
struct pt_regs *regs = current_pt_regs();
47+
int uval = -EFAULT;
4848

4949
/*
5050
* This is only for old cores lacking LLOCK/SCOND, which by defintion
@@ -54,24 +54,26 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
5454
*/
5555
WARN_ON_ONCE(IS_ENABLED(CONFIG_SMP));
5656

57+
/* Z indicates to userspace if operation succeded */
58+
regs->status32 &= ~STATUS_Z_MASK;
59+
5760
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
5861
return -EFAULT;
5962

6063
preempt_disable();
6164

62-
ret = __get_user(uval, uaddr);
63-
if (ret)
65+
if (__get_user(uval, uaddr))
6466
goto done;
6567

66-
if (uval != expected)
67-
ret = -EAGAIN;
68-
else
69-
ret = __put_user(new, uaddr);
68+
if (uval == expected) {
69+
if (!__put_user(new, uaddr))
70+
regs->status32 |= STATUS_Z_MASK;
71+
}
7072

7173
done:
7274
preempt_enable();
7375

74-
return ret;
76+
return uval;
7577
}
7678

7779
void arch_cpu_idle(void)

arch/arc/kernel/smp.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/atomic.h>
2323
#include <linux/cpumask.h>
2424
#include <linux/reboot.h>
25+
#include <linux/irqdomain.h>
2526
#include <asm/processor.h>
2627
#include <asm/setup.h>
2728
#include <asm/mach_desc.h>
@@ -67,11 +68,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
6768
int i;
6869

6970
/*
70-
* Initialise the present map, which describes the set of CPUs
71-
* actually populated at the present time.
71+
* if platform didn't set the present map already, do it now
72+
* boot cpu is set to present already by init/main.c
7273
*/
73-
for (i = 0; i < max_cpus; i++)
74-
set_cpu_present(i, true);
74+
if (num_present_cpus() <= 1) {
75+
for (i = 0; i < max_cpus; i++)
76+
set_cpu_present(i, true);
77+
}
7578
}
7679

7780
void __init smp_cpus_done(unsigned int max_cpus)
@@ -351,20 +354,24 @@ irqreturn_t do_IPI(int irq, void *dev_id)
351354
*/
352355
static DEFINE_PER_CPU(int, ipi_dev);
353356

354-
int smp_ipi_irq_setup(int cpu, int irq)
357+
int smp_ipi_irq_setup(int cpu, irq_hw_number_t hwirq)
355358
{
356359
int *dev = per_cpu_ptr(&ipi_dev, cpu);
360+
unsigned int virq = irq_find_mapping(NULL, hwirq);
361+
362+
if (!virq)
363+
panic("Cannot find virq for root domain and hwirq=%lu", hwirq);
357364

358365
/* Boot cpu calls request, all call enable */
359366
if (!cpu) {
360367
int rc;
361368

362-
rc = request_percpu_irq(irq, do_IPI, "IPI Interrupt", dev);
369+
rc = request_percpu_irq(virq, do_IPI, "IPI Interrupt", dev);
363370
if (rc)
364-
panic("Percpu IRQ request failed for %d\n", irq);
371+
panic("Percpu IRQ request failed for %u\n", virq);
365372
}
366373

367-
enable_percpu_irq(irq, 0);
374+
enable_percpu_irq(virq, 0);
368375

369376
return 0;
370377
}

arch/arc/kernel/time.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,17 @@ static cycle_t arc_read_rtc(struct clocksource *cs)
152152
cycle_t full;
153153
} stamp;
154154

155-
156-
__asm__ __volatile(
157-
"1: \n"
158-
" lr %0, [AUX_RTC_LOW] \n"
159-
" lr %1, [AUX_RTC_HIGH] \n"
160-
" lr %2, [AUX_RTC_CTRL] \n"
161-
" bbit0.nt %2, 31, 1b \n"
162-
: "=r" (stamp.low), "=r" (stamp.high), "=r" (status));
155+
/*
156+
* hardware has an internal state machine which tracks readout of
157+
* low/high and updates the CTRL.status if
158+
* - interrupt/exception taken between the two reads
159+
* - high increments after low has been read
160+
*/
161+
do {
162+
stamp.low = read_aux_reg(AUX_RTC_LOW);
163+
stamp.high = read_aux_reg(AUX_RTC_HIGH);
164+
status = read_aux_reg(AUX_RTC_CTRL);
165+
} while (!(status & _BITUL(31)));
163166

164167
return stamp.full;
165168
}

arch/arc/mm/dma.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,31 @@ static void arc_dma_free(struct device *dev, size_t size, void *vaddr,
105105
__free_pages(page, get_order(size));
106106
}
107107

108+
static int arc_dma_mmap(struct device *dev, struct vm_area_struct *vma,
109+
void *cpu_addr, dma_addr_t dma_addr, size_t size,
110+
unsigned long attrs)
111+
{
112+
unsigned long user_count = vma_pages(vma);
113+
unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
114+
unsigned long pfn = __phys_to_pfn(plat_dma_to_phys(dev, dma_addr));
115+
unsigned long off = vma->vm_pgoff;
116+
int ret = -ENXIO;
117+
118+
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
119+
120+
if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret))
121+
return ret;
122+
123+
if (off < count && user_count <= (count - off)) {
124+
ret = remap_pfn_range(vma, vma->vm_start,
125+
pfn + off,
126+
user_count << PAGE_SHIFT,
127+
vma->vm_page_prot);
128+
}
129+
130+
return ret;
131+
}
132+
108133
/*
109134
* streaming DMA Mapping API...
110135
* CPU accesses page via normal paddr, thus needs to explicitly made
@@ -193,6 +218,7 @@ static int arc_dma_supported(struct device *dev, u64 dma_mask)
193218
struct dma_map_ops arc_dma_ops = {
194219
.alloc = arc_dma_alloc,
195220
.free = arc_dma_free,
221+
.mmap = arc_dma_mmap,
196222
.map_page = arc_dma_map_page,
197223
.map_sg = arc_dma_map_sg,
198224
.sync_single_for_device = arc_dma_sync_single_for_device,

arch/arc/plat-eznps/smp.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,10 @@ static void eznps_init_per_cpu(int cpu)
140140
mtm_enable_core(cpu);
141141
}
142142

143-
static void eznps_ipi_clear(int irq)
144-
{
145-
write_aux_reg(CTOP_AUX_IACK, 1 << irq);
146-
}
147-
148143
struct plat_smp_ops plat_smp_ops = {
149144
.info = smp_cpuinfo_buf,
150145
.init_early_smp = eznps_init_cpumasks,
151146
.cpu_kick = eznps_smp_wakeup_cpu,
152147
.ipi_send = eznps_ipi_send,
153148
.init_per_cpu = eznps_init_per_cpu,
154-
.ipi_clear = eznps_ipi_clear,
155149
};

0 commit comments

Comments
 (0)