Skip to content

Commit b955a91

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
David writes: "Sparc fixes 1) Revert the %pOF change, it causes regressions. 2) Wire up io_pgetevents(). 3) Fix perf events on single-PCR sparc64 cpus. 4) Do proper perf event throttling like arm and x86." * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: Revert "sparc: Convert to using %pOFn instead of device_node.name" sparc64: Set %l4 properly on trap return after handling signals. sparc64: Make proc_id signed. sparc: Throttle perf events properly. sparc: Fix single-pcr perf event counter management. sparc: Wire up io_pgetevents system call. sunvdc: Remove VLA usage
2 parents a886199 + a06ecbf commit b955a91

File tree

11 files changed

+91
-65
lines changed

11 files changed

+91
-65
lines changed

arch/sparc/include/asm/cpudata_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct {
2828
unsigned short sock_id; /* physical package */
2929
unsigned short core_id;
3030
unsigned short max_cache_id; /* groupings of highest shared cache */
31-
unsigned short proc_id; /* strand (aka HW thread) id */
31+
signed short proc_id; /* strand (aka HW thread) id */
3232
} cpuinfo_sparc;
3333

3434
DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);

arch/sparc/include/uapi/asm/unistd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,9 @@
427427
#define __NR_preadv2 358
428428
#define __NR_pwritev2 359
429429
#define __NR_statx 360
430+
#define __NR_io_pgetevents 361
430431

431-
#define NR_syscalls 361
432+
#define NR_syscalls 362
432433

433434
/* Bitmask values returned from kern_features system call. */
434435
#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001

arch/sparc/kernel/auxio_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static int auxio_probe(struct platform_device *dev)
115115
auxio_devtype = AUXIO_TYPE_SBUS;
116116
size = 1;
117117
} else {
118-
printk("auxio: Unknown parent bus type [%pOFn]\n",
119-
dp->parent);
118+
printk("auxio: Unknown parent bus type [%s]\n",
119+
dp->parent->name);
120120
return -ENODEV;
121121
}
122122
auxio_register = of_ioremap(&dev->resource[0], 0, size, "auxio");

arch/sparc/kernel/perf_event.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/cpudata.h>
2525
#include <linux/uaccess.h>
2626
#include <linux/atomic.h>
27+
#include <linux/sched/clock.h>
2728
#include <asm/nmi.h>
2829
#include <asm/pcr.h>
2930
#include <asm/cacheflush.h>
@@ -927,6 +928,8 @@ static void read_in_all_counters(struct cpu_hw_events *cpuc)
927928
sparc_perf_event_update(cp, &cp->hw,
928929
cpuc->current_idx[i]);
929930
cpuc->current_idx[i] = PIC_NO_INDEX;
931+
if (cp->hw.state & PERF_HES_STOPPED)
932+
cp->hw.state |= PERF_HES_ARCH;
930933
}
931934
}
932935
}
@@ -959,10 +962,12 @@ static void calculate_single_pcr(struct cpu_hw_events *cpuc)
959962

960963
enc = perf_event_get_enc(cpuc->events[i]);
961964
cpuc->pcr[0] &= ~mask_for_index(idx);
962-
if (hwc->state & PERF_HES_STOPPED)
965+
if (hwc->state & PERF_HES_ARCH) {
963966
cpuc->pcr[0] |= nop_for_index(idx);
964-
else
967+
} else {
965968
cpuc->pcr[0] |= event_encoding(enc, idx);
969+
hwc->state = 0;
970+
}
966971
}
967972
out:
968973
cpuc->pcr[0] |= cpuc->event[0]->hw.config_base;
@@ -988,6 +993,9 @@ static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc)
988993

989994
cpuc->current_idx[i] = idx;
990995

996+
if (cp->hw.state & PERF_HES_ARCH)
997+
continue;
998+
991999
sparc_pmu_start(cp, PERF_EF_RELOAD);
9921000
}
9931001
out:
@@ -1079,6 +1087,8 @@ static void sparc_pmu_start(struct perf_event *event, int flags)
10791087
event->hw.state = 0;
10801088

10811089
sparc_pmu_enable_event(cpuc, &event->hw, idx);
1090+
1091+
perf_event_update_userpage(event);
10821092
}
10831093

10841094
static void sparc_pmu_stop(struct perf_event *event, int flags)
@@ -1371,9 +1381,9 @@ static int sparc_pmu_add(struct perf_event *event, int ef_flags)
13711381
cpuc->events[n0] = event->hw.event_base;
13721382
cpuc->current_idx[n0] = PIC_NO_INDEX;
13731383

1374-
event->hw.state = PERF_HES_UPTODATE;
1384+
event->hw.state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
13751385
if (!(ef_flags & PERF_EF_START))
1376-
event->hw.state |= PERF_HES_STOPPED;
1386+
event->hw.state |= PERF_HES_ARCH;
13771387

13781388
/*
13791389
* If group events scheduling transaction was started,
@@ -1603,6 +1613,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16031613
struct perf_sample_data data;
16041614
struct cpu_hw_events *cpuc;
16051615
struct pt_regs *regs;
1616+
u64 finish_clock;
1617+
u64 start_clock;
16061618
int i;
16071619

16081620
if (!atomic_read(&active_events))
@@ -1616,6 +1628,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16161628
return NOTIFY_DONE;
16171629
}
16181630

1631+
start_clock = sched_clock();
1632+
16191633
regs = args->regs;
16201634

16211635
cpuc = this_cpu_ptr(&cpu_hw_events);
@@ -1654,6 +1668,10 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16541668
sparc_pmu_stop(event, 0);
16551669
}
16561670

1671+
finish_clock = sched_clock();
1672+
1673+
perf_sample_event_took(finish_clock - start_clock);
1674+
16571675
return NOTIFY_STOP;
16581676
}
16591677

arch/sparc/kernel/power.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static int power_probe(struct platform_device *op)
4141

4242
power_reg = of_ioremap(res, 0, 0x4, "power");
4343

44-
printk(KERN_INFO "%pOFn: Control reg at %llx\n",
45-
op->dev.of_node, res->start);
44+
printk(KERN_INFO "%s: Control reg at %llx\n",
45+
op->dev.of_node->name, res->start);
4646

4747
if (has_button_interrupt(irq, op->dev.of_node)) {
4848
if (request_irq(irq,

arch/sparc/kernel/prom_32.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)
6868
return;
6969

7070
regs = rprop->value;
71-
sprintf(tmp_buf, "%pOFn@%x,%x",
72-
dp,
71+
sprintf(tmp_buf, "%s@%x,%x",
72+
dp->name,
7373
regs->which_io, regs->phys_addr);
7474
}
7575

@@ -84,8 +84,8 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
8484
return;
8585

8686
regs = prop->value;
87-
sprintf(tmp_buf, "%pOFn@%x,%x",
88-
dp,
87+
sprintf(tmp_buf, "%s@%x,%x",
88+
dp->name,
8989
regs->which_io,
9090
regs->phys_addr);
9191
}
@@ -104,13 +104,13 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
104104
regs = prop->value;
105105
devfn = (regs->phys_hi >> 8) & 0xff;
106106
if (devfn & 0x07) {
107-
sprintf(tmp_buf, "%pOFn@%x,%x",
108-
dp,
107+
sprintf(tmp_buf, "%s@%x,%x",
108+
dp->name,
109109
devfn >> 3,
110110
devfn & 0x07);
111111
} else {
112-
sprintf(tmp_buf, "%pOFn@%x",
113-
dp,
112+
sprintf(tmp_buf, "%s@%x",
113+
dp->name,
114114
devfn >> 3);
115115
}
116116
}
@@ -127,8 +127,8 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
127127

128128
regs = prop->value;
129129

130-
sprintf(tmp_buf, "%pOFn@%x,%x",
131-
dp,
130+
sprintf(tmp_buf, "%s@%x,%x",
131+
dp->name,
132132
regs->which_io, regs->phys_addr);
133133
}
134134

@@ -167,8 +167,8 @@ static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf)
167167
return;
168168
device = prop->value;
169169

170-
sprintf(tmp_buf, "%pOFn:%d:%d@%x,%x",
171-
dp, *vendor, *device,
170+
sprintf(tmp_buf, "%s:%d:%d@%x,%x",
171+
dp->name, *vendor, *device,
172172
*intr, reg0);
173173
}
174174

@@ -201,7 +201,7 @@ char * __init build_path_component(struct device_node *dp)
201201
tmp_buf[0] = '\0';
202202
__build_path_component(dp, tmp_buf);
203203
if (tmp_buf[0] == '\0')
204-
snprintf(tmp_buf, sizeof(tmp_buf), "%pOFn", dp);
204+
strcpy(tmp_buf, dp->name);
205205

206206
n = prom_early_alloc(strlen(tmp_buf) + 1);
207207
strcpy(n, tmp_buf);

arch/sparc/kernel/prom_64.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
8282

8383
regs = rprop->value;
8484
if (!of_node_is_root(dp->parent)) {
85-
sprintf(tmp_buf, "%pOFn@%x,%x",
86-
dp,
85+
sprintf(tmp_buf, "%s@%x,%x",
86+
dp->name,
8787
(unsigned int) (regs->phys_addr >> 32UL),
8888
(unsigned int) (regs->phys_addr & 0xffffffffUL));
8989
return;
@@ -97,17 +97,17 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
9797
const char *prefix = (type == 0) ? "m" : "i";
9898

9999
if (low_bits)
100-
sprintf(tmp_buf, "%pOFn@%s%x,%x",
101-
dp, prefix,
100+
sprintf(tmp_buf, "%s@%s%x,%x",
101+
dp->name, prefix,
102102
high_bits, low_bits);
103103
else
104-
sprintf(tmp_buf, "%pOFn@%s%x",
105-
dp,
104+
sprintf(tmp_buf, "%s@%s%x",
105+
dp->name,
106106
prefix,
107107
high_bits);
108108
} else if (type == 12) {
109-
sprintf(tmp_buf, "%pOFn@%x",
110-
dp, high_bits);
109+
sprintf(tmp_buf, "%s@%x",
110+
dp->name, high_bits);
111111
}
112112
}
113113

@@ -122,8 +122,8 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
122122

123123
regs = prop->value;
124124
if (!of_node_is_root(dp->parent)) {
125-
sprintf(tmp_buf, "%pOFn@%x,%x",
126-
dp,
125+
sprintf(tmp_buf, "%s@%x,%x",
126+
dp->name,
127127
(unsigned int) (regs->phys_addr >> 32UL),
128128
(unsigned int) (regs->phys_addr & 0xffffffffUL));
129129
return;
@@ -138,8 +138,8 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
138138
if (tlb_type >= cheetah)
139139
mask = 0x7fffff;
140140

141-
sprintf(tmp_buf, "%pOFn@%x,%x",
142-
dp,
141+
sprintf(tmp_buf, "%s@%x,%x",
142+
dp->name,
143143
*(u32 *)prop->value,
144144
(unsigned int) (regs->phys_addr & mask));
145145
}
@@ -156,8 +156,8 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
156156
return;
157157

158158
regs = prop->value;
159-
sprintf(tmp_buf, "%pOFn@%x,%x",
160-
dp,
159+
sprintf(tmp_buf, "%s@%x,%x",
160+
dp->name,
161161
regs->which_io,
162162
regs->phys_addr);
163163
}
@@ -176,13 +176,13 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
176176
regs = prop->value;
177177
devfn = (regs->phys_hi >> 8) & 0xff;
178178
if (devfn & 0x07) {
179-
sprintf(tmp_buf, "%pOFn@%x,%x",
180-
dp,
179+
sprintf(tmp_buf, "%s@%x,%x",
180+
dp->name,
181181
devfn >> 3,
182182
devfn & 0x07);
183183
} else {
184-
sprintf(tmp_buf, "%pOFn@%x",
185-
dp,
184+
sprintf(tmp_buf, "%s@%x",
185+
dp->name,
186186
devfn >> 3);
187187
}
188188
}
@@ -203,8 +203,8 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
203203
if (!prop)
204204
return;
205205

206-
sprintf(tmp_buf, "%pOFn@%x,%x",
207-
dp,
206+
sprintf(tmp_buf, "%s@%x,%x",
207+
dp->name,
208208
*(u32 *) prop->value,
209209
(unsigned int) (regs->phys_addr & 0xffffffffUL));
210210
}
@@ -221,7 +221,7 @@ static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)
221221

222222
regs = prop->value;
223223

224-
sprintf(tmp_buf, "%pOFn@%x", dp, *regs);
224+
sprintf(tmp_buf, "%s@%x", dp->name, *regs);
225225
}
226226

227227
/* "name@addrhi,addrlo" */
@@ -236,8 +236,8 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
236236

237237
regs = prop->value;
238238

239-
sprintf(tmp_buf, "%pOFn@%x,%x",
240-
dp,
239+
sprintf(tmp_buf, "%s@%x,%x",
240+
dp->name,
241241
(unsigned int) (regs->phys_addr >> 32UL),
242242
(unsigned int) (regs->phys_addr & 0xffffffffUL));
243243
}
@@ -257,8 +257,8 @@ static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)
257257
/* This actually isn't right... should look at the #address-cells
258258
* property of the i2c bus node etc. etc.
259259
*/
260-
sprintf(tmp_buf, "%pOFn@%x,%x",
261-
dp, regs[0], regs[1]);
260+
sprintf(tmp_buf, "%s@%x,%x",
261+
dp->name, regs[0], regs[1]);
262262
}
263263

264264
/* "name@reg0[,reg1]" */
@@ -274,11 +274,11 @@ static void __init usb_path_component(struct device_node *dp, char *tmp_buf)
274274
regs = prop->value;
275275

276276
if (prop->length == sizeof(u32) || regs[1] == 1) {
277-
sprintf(tmp_buf, "%pOFn@%x",
278-
dp, regs[0]);
277+
sprintf(tmp_buf, "%s@%x",
278+
dp->name, regs[0]);
279279
} else {
280-
sprintf(tmp_buf, "%pOFn@%x,%x",
281-
dp, regs[0], regs[1]);
280+
sprintf(tmp_buf, "%s@%x,%x",
281+
dp->name, regs[0], regs[1]);
282282
}
283283
}
284284

@@ -295,11 +295,11 @@ static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf
295295
regs = prop->value;
296296

297297
if (regs[2] || regs[3]) {
298-
sprintf(tmp_buf, "%pOFn@%08x%08x,%04x%08x",
299-
dp, regs[0], regs[1], regs[2], regs[3]);
298+
sprintf(tmp_buf, "%s@%08x%08x,%04x%08x",
299+
dp->name, regs[0], regs[1], regs[2], regs[3]);
300300
} else {
301-
sprintf(tmp_buf, "%pOFn@%08x%08x",
302-
dp, regs[0], regs[1]);
301+
sprintf(tmp_buf, "%s@%08x%08x",
302+
dp->name, regs[0], regs[1]);
303303
}
304304
}
305305

@@ -361,7 +361,7 @@ char * __init build_path_component(struct device_node *dp)
361361
tmp_buf[0] = '\0';
362362
__build_path_component(dp, tmp_buf);
363363
if (tmp_buf[0] == '\0')
364-
snprintf(tmp_buf, sizeof(tmp_buf), "%pOFn", dp);
364+
strcpy(tmp_buf, dp->name);
365365

366366
n = prom_early_alloc(strlen(tmp_buf) + 1);
367367
strcpy(n, tmp_buf);

arch/sparc/kernel/rtrap_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ __handle_signal:
8484
ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
8585
sethi %hi(0xf << 20), %l4
8686
and %l1, %l4, %l4
87+
andn %l1, %l4, %l1
8788
ba,pt %xcc, __handle_preemption_continue
88-
andn %l1, %l4, %l1
89+
srl %l4, 20, %l4
8990

9091
/* When returning from a NMI (%pil==15) interrupt we want to
9192
* avoid running softirqs, doing IRQ tracing, preempting, etc.

arch/sparc/kernel/systbls_32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ sys_call_table:
9090
/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
9191
/*350*/ .long sys_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
9292
/*355*/ .long sys_setsockopt, sys_mlock2, sys_copy_file_range, sys_preadv2, sys_pwritev2
93-
/*360*/ .long sys_statx
93+
/*360*/ .long sys_statx, sys_io_pgetevents

0 commit comments

Comments
 (0)