Skip to content

Commit fffad3e

Browse files
committed
Merge tag 'xtensa-next-20160320' of git://github.com/czankel/xtensa-linux
Pull Xtensa updates from Chris Zankel: "Xtensa improvements for 4.6: - control whether perf IRQ is treated as NMI from Kconfig - implement ioremap for regions outside KIO segment - fix ISS serial port behaviour when EOF is reached - fix preemption in {clear,copy}_user_highpage - fix endianness issues for XTFPGA devices, big-endian cores are now fully functional - clean up debug infrastructure and add support for hardware breakpoints and watchpoints - add processor configurations for Three Core HiFi-2 MX and HiFi3 cpus" * tag 'xtensa-next-20160320' of git://github.com/czankel/xtensa-linux: xtensa: add test_kc705_hifi variant xtensa: add Three Core HiFi-2 MX Variant. xtensa: support hardware breakpoints/watchpoints xtensa: use context structure for debug exceptions xtensa: remove remaining non-functional KGDB bits xtensa: clear all DBREAKC registers on start xtensa: xtfpga: fix earlycon endianness xtensa: xtfpga: fix i2c controller register width and endianness xtensa: xtfpga: fix ethernet controller endianness xtensa: xtfpga: fix serial port register width and endianness xtensa: define CONFIG_CPU_{BIG,LITTLE}_ENDIAN xtensa: fix preemption in {clear,copy}_user_highpage xtensa: ISS: don't hang if stdin EOF is reached xtensa: support ioremap for memory outside KIO region xtensa: use XTENSA_INT_LEVEL macro in asm/timex.h xtensa: make fake NMI configurable
2 parents 1e75a9f + 9da8320 commit fffad3e

33 files changed

Lines changed: 2593 additions & 78 deletions

File tree

‎arch/xtensa/Kconfig‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ config XTENSA
1717
select HAVE_DMA_API_DEBUG
1818
select HAVE_FUNCTION_TRACER
1919
select HAVE_FUTEX_CMPXCHG if !MMU
20+
select HAVE_HW_BREAKPOINT if PERF_EVENTS
2021
select HAVE_IRQ_TIME_ACCOUNTING
2122
select HAVE_OPROFILE
2223
select HAVE_PERF_EVENTS
@@ -138,6 +139,22 @@ config XTENSA_VARIANT_HAVE_PERF_EVENTS
138139

139140
If unsure, say N.
140141

142+
config XTENSA_FAKE_NMI
143+
bool "Treat PMM IRQ as NMI"
144+
depends on XTENSA_VARIANT_HAVE_PERF_EVENTS
145+
default n
146+
help
147+
If PMM IRQ is the only IRQ at EXCM level it is safe to
148+
treat it as NMI, which improves accuracy of profiling.
149+
150+
If there are other interrupts at or above PMM IRQ priority level
151+
but not above the EXCM level, PMM IRQ still may be treated as NMI,
152+
but only if these IRQs are not used. There will be a build warning
153+
saying that this is not safe, and a bugcheck if one of these IRQs
154+
actually fire.
155+
156+
If unsure, say N.
157+
141158
config XTENSA_UNALIGNED_USER
142159
bool "Unaligned memory access in use space"
143160
help

‎arch/xtensa/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ endif
5353

5454
ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
5555
CHECKFLAGS += -D__XTENSA_EB__
56+
KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
5657
endif
5758
ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
5859
CHECKFLAGS += -D__XTENSA_EL__
60+
KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
5961
endif
6062

6163
vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))

‎arch/xtensa/boot/dts/kc705.dts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/ {
66
compatible = "cdns,xtensa-kc705";
77
chosen {
8-
bootargs = "earlycon=uart8250,mmio32,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000";
8+
bootargs = "earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000";
99
};
1010
memory@0 {
1111
device_type = "memory";

‎arch/xtensa/boot/dts/xtfpga.dtsi‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
interrupt-parent = <&pic>;
66

77
chosen {
8-
bootargs = "earlycon=uart8250,mmio32,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug";
8+
bootargs = "earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug";
99
};
1010

1111
memory@0 {
@@ -60,13 +60,16 @@
6060
no-loopback-test;
6161
reg = <0x0d050020 0x20>;
6262
reg-shift = <2>;
63+
reg-io-width = <4>;
64+
native-endian;
6365
interrupts = <0 1>; /* external irq 0 */
6466
clocks = <&osc>;
6567
};
6668

6769
enet0: ethoc@0d030000 {
6870
compatible = "opencores,ethoc";
6971
reg = <0x0d030000 0x4000 0x0d800000 0x4000>;
72+
native-endian;
7073
interrupts = <1 1>; /* external irq 1 */
7174
local-mac-address = [00 50 c2 13 6f 00];
7275
clocks = <&osc>;
@@ -86,7 +89,8 @@
8689
#size-cells = <0>;
8790
reg = <0x0d090000 0x20>;
8891
reg-shift = <2>;
89-
reg-io-width = <1>;
92+
reg-io-width = <4>;
93+
native-endian;
9094
interrupts = <4 1>;
9195
clocks = <&osc>;
9296

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Xtensa hardware breakpoints/watchpoints handling functions
3+
*
4+
* This file is subject to the terms and conditions of the GNU General Public
5+
* License. See the file "COPYING" in the main directory of this archive
6+
* for more details.
7+
*
8+
* Copyright (C) 2016 Cadence Design Systems Inc.
9+
*/
10+
11+
#ifndef __ASM_XTENSA_HW_BREAKPOINT_H
12+
#define __ASM_XTENSA_HW_BREAKPOINT_H
13+
14+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
15+
16+
#include <linux/kdebug.h>
17+
#include <linux/types.h>
18+
#include <uapi/linux/hw_breakpoint.h>
19+
20+
/* Breakpoint */
21+
#define XTENSA_BREAKPOINT_EXECUTE 0
22+
23+
/* Watchpoints */
24+
#define XTENSA_BREAKPOINT_LOAD 1
25+
#define XTENSA_BREAKPOINT_STORE 2
26+
27+
struct arch_hw_breakpoint {
28+
unsigned long address;
29+
u16 len;
30+
u16 type;
31+
};
32+
33+
struct perf_event;
34+
struct pt_regs;
35+
struct task_struct;
36+
37+
int hw_breakpoint_slots(int type);
38+
int arch_check_bp_in_kernelspace(struct perf_event *bp);
39+
int arch_validate_hwbkpt_settings(struct perf_event *bp);
40+
int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
41+
unsigned long val, void *data);
42+
43+
int arch_install_hw_breakpoint(struct perf_event *bp);
44+
void arch_uninstall_hw_breakpoint(struct perf_event *bp);
45+
void hw_breakpoint_pmu_read(struct perf_event *bp);
46+
int check_hw_breakpoint(struct pt_regs *regs);
47+
void clear_ptrace_hw_breakpoint(struct task_struct *tsk);
48+
49+
#else
50+
51+
struct task_struct;
52+
53+
static inline void clear_ptrace_hw_breakpoint(struct task_struct *tsk)
54+
{
55+
}
56+
57+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
58+
#endif /* __ASM_XTENSA_HW_BREAKPOINT_H */

‎arch/xtensa/include/asm/io.h‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525

2626
#ifdef CONFIG_MMU
2727

28+
void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
29+
void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
30+
void xtensa_iounmap(volatile void __iomem *addr);
31+
2832
/*
2933
* Return the virtual address for the specified bus memory.
30-
* Note that we currently don't support any address outside the KIO segment.
3134
*/
3235
static inline void __iomem *ioremap_nocache(unsigned long offset,
3336
unsigned long size)
@@ -36,7 +39,7 @@ static inline void __iomem *ioremap_nocache(unsigned long offset,
3639
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
3740
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
3841
else
39-
BUG();
42+
return xtensa_ioremap_nocache(offset, size);
4043
}
4144

4245
static inline void __iomem *ioremap_cache(unsigned long offset,
@@ -46,7 +49,7 @@ static inline void __iomem *ioremap_cache(unsigned long offset,
4649
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
4750
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
4851
else
49-
BUG();
52+
return xtensa_ioremap_cache(offset, size);
5053
}
5154
#define ioremap_cache ioremap_cache
5255

@@ -60,6 +63,13 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
6063

6164
static inline void iounmap(volatile void __iomem *addr)
6265
{
66+
unsigned long va = (unsigned long) addr;
67+
68+
if (!(va >= XCHAL_KIO_CACHED_VADDR &&
69+
va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
70+
!(va >= XCHAL_KIO_BYPASS_VADDR &&
71+
va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
72+
xtensa_iounmap(addr);
6373
}
6474

6575
#define virt_to_bus virt_to_phys

‎arch/xtensa/include/asm/irqflags.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define _XTENSA_IRQFLAGS_H
1414

1515
#include <linux/types.h>
16+
#include <asm/processor.h>
1617

1718
static inline unsigned long arch_local_save_flags(void)
1819
{

‎arch/xtensa/include/asm/processor.h‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,20 @@
7878
#define XTENSA_INTLEVEL_MASK(level) _XTENSA_INTLEVEL_MASK(level)
7979
#define _XTENSA_INTLEVEL_MASK(level) (XCHAL_INTLEVEL##level##_MASK)
8080

81-
#define IS_POW2(v) (((v) & ((v) - 1)) == 0)
81+
#define XTENSA_INTLEVEL_ANDBELOW_MASK(l) _XTENSA_INTLEVEL_ANDBELOW_MASK(l)
82+
#define _XTENSA_INTLEVEL_ANDBELOW_MASK(l) (XCHAL_INTLEVEL##l##_ANDBELOW_MASK)
8283

8384
#define PROFILING_INTLEVEL XTENSA_INT_LEVEL(XCHAL_PROFILING_INTERRUPT)
8485

8586
/* LOCKLEVEL defines the interrupt level that masks all
8687
* general-purpose interrupts.
8788
*/
88-
#if defined(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) && \
89-
defined(XCHAL_PROFILING_INTERRUPT) && \
90-
PROFILING_INTLEVEL == XCHAL_EXCM_LEVEL && \
91-
XCHAL_EXCM_LEVEL > 1 && \
92-
IS_POW2(XTENSA_INTLEVEL_MASK(PROFILING_INTLEVEL))
93-
#define LOCKLEVEL (XCHAL_EXCM_LEVEL - 1)
89+
#if defined(CONFIG_XTENSA_FAKE_NMI) && defined(XCHAL_PROFILING_INTERRUPT)
90+
#define LOCKLEVEL (PROFILING_INTLEVEL - 1)
9491
#else
9592
#define LOCKLEVEL XCHAL_EXCM_LEVEL
9693
#endif
94+
9795
#define TOPLEVEL XCHAL_EXCM_LEVEL
9896
#define XTENSA_FAKE_NMI (LOCKLEVEL < TOPLEVEL)
9997

@@ -132,11 +130,10 @@ struct thread_struct {
132130
unsigned long bad_vaddr; /* last user fault */
133131
unsigned long bad_uaddr; /* last kernel fault accessing user space */
134132
unsigned long error_code;
135-
136-
unsigned long ibreak[XCHAL_NUM_IBREAK];
137-
unsigned long dbreaka[XCHAL_NUM_DBREAK];
138-
unsigned long dbreakc[XCHAL_NUM_DBREAK];
139-
133+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
134+
struct perf_event *ptrace_bp[XCHAL_NUM_IBREAK];
135+
struct perf_event *ptrace_wp[XCHAL_NUM_DBREAK];
136+
#endif
140137
/* Make structure 16 bytes aligned. */
141138
int align[0] __attribute__ ((aligned(16)));
142139
};

‎arch/xtensa/include/asm/regs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
/* Special registers. */
2929

3030
#define SREG_MR 32
31+
#define SREG_IBREAKENABLE 96
3132
#define SREG_IBREAKA 128
3233
#define SREG_DBREAKA 144
3334
#define SREG_DBREAKC 160
@@ -103,6 +104,8 @@
103104

104105
/* DEBUGCAUSE register fields. */
105106

107+
#define DEBUGCAUSE_DBNUM_MASK 0xf00
108+
#define DEBUGCAUSE_DBNUM_SHIFT 8 /* First bit of DBNUM field */
106109
#define DEBUGCAUSE_DEBUGINT_BIT 5 /* External debug interrupt */
107110
#define DEBUGCAUSE_BREAKN_BIT 4 /* BREAK.N instruction */
108111
#define DEBUGCAUSE_BREAK_BIT 3 /* BREAK instruction */

‎arch/xtensa/include/asm/thread_info.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static inline struct thread_info *current_thread_info(void)
111111
#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
112112
#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
113113
#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
114+
#define TIF_DB_DISABLED 8 /* debug trap disabled for syscall */
114115

115116
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
116117
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)

0 commit comments

Comments
 (0)