Skip to content

Commit 9bcf28c

Browse files
Ian Munsiempe
authored andcommitted
cxl: Add tracepoints
This patch adds tracepoints throughout the cxl driver, which can provide insight into: - Context lifetimes - Commands sent to the PSL and AFU and their completion status - Segment and page table misses and their resolution - PSL and AFU interrupts - slbia calls from the powerpc copro_fault code These tracepoints are mostly intended to aid in debugging (particularly for new AFU designs), and may be useful standalone or in conjunction with hardware traces collected by the PSL (read out via the trace interface in debugfs) and AFUs. Signed-off-by: Ian Munsie <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent d3383aa commit 9bcf28c

File tree

8 files changed

+520
-9
lines changed

8 files changed

+520
-9
lines changed

drivers/misc/cxl/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
cxl-y += main.o file.o irq.o fault.o native.o context.o sysfs.o debugfs.o pci.o
1+
cxl-y += main.o file.o irq.o fault.o native.o context.o sysfs.o debugfs.o pci.o trace.o
22
obj-$(CONFIG_CXL) += cxl.o
33
obj-$(CONFIG_CXL_BASE) += base.o
4+
5+
# For tracepoints to include our trace.h from tracepoint infrastructure:
6+
CFLAGS_trace.o := -I$(src)

drivers/misc/cxl/fault.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <asm/mmu.h>
2121

2222
#include "cxl.h"
23+
#include "trace.h"
2324

2425
static bool sste_matches(struct cxl_sste *sste, struct copro_slb *slb)
2526
{
@@ -75,6 +76,7 @@ static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb)
7576

7677
pr_devel("CXL Populating SST[%li]: %#llx %#llx\n",
7778
sste - ctx->sstp, slb->vsid, slb->esid);
79+
trace_cxl_ste_write(ctx, sste - ctx->sstp, slb->esid, slb->vsid);
7880

7981
sste->vsid_data = cpu_to_be64(slb->vsid);
8082
sste->esid_data = cpu_to_be64(slb->esid);
@@ -116,6 +118,7 @@ static int cxl_handle_segment_miss(struct cxl_context *ctx,
116118
int rc;
117119

118120
pr_devel("CXL interrupt: Segment fault pe: %i ea: %#llx\n", ctx->pe, ea);
121+
trace_cxl_ste_miss(ctx, ea);
119122

120123
if ((rc = cxl_fault_segment(ctx, mm, ea)))
121124
cxl_ack_ae(ctx);
@@ -135,6 +138,8 @@ static void cxl_handle_page_fault(struct cxl_context *ctx,
135138
int result;
136139
unsigned long access, flags, inv_flags = 0;
137140

141+
trace_cxl_pte_miss(ctx, dsisr, dar);
142+
138143
if ((result = copro_handle_mm_fault(mm, dar, dsisr, &flt))) {
139144
pr_devel("copro_handle_mm_fault failed: %#x\n", result);
140145
return cxl_ack_ae(ctx);

drivers/misc/cxl/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <asm/copro.h>
2424

2525
#include "cxl.h"
26+
#include "trace.h"
2627

2728
#define CXL_NUM_MINORS 256 /* Total to reserve */
2829
#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */
@@ -184,6 +185,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
184185
*/
185186
ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID));
186187

188+
trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);
189+
187190
if ((rc = cxl_attach_process(ctx, false, work.work_element_descriptor,
188191
amr))) {
189192
afu_release_irqs(ctx);

drivers/misc/cxl/irq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <misc/cxl.h>
1818

1919
#include "cxl.h"
20+
#include "trace.h"
2021

2122
/* XXX: This is implementation specific */
2223
static irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, u64 errstat)
@@ -100,6 +101,8 @@ static irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info)
100101
dsisr = irq_info->dsisr;
101102
dar = irq_info->dar;
102103

104+
trace_cxl_psl_irq(ctx, irq, dsisr, dar);
105+
103106
pr_devel("CXL interrupt %i for afu pe: %i DSISR: %#llx DAR: %#llx\n", irq, ctx->pe, dsisr, dar);
104107

105108
if (dsisr & CXL_PSL_DSISR_An_DS) {
@@ -237,6 +240,7 @@ static irqreturn_t cxl_irq_afu(int irq, void *data)
237240
return IRQ_HANDLED;
238241
}
239242

243+
trace_cxl_afu_irq(ctx, afu_irq, irq, hwirq);
240244
pr_devel("Received AFU interrupt %i for pe: %i (virq %i hwirq %lx)\n",
241245
afu_irq, ctx->pe, irq, hwirq);
242246

drivers/misc/cxl/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <misc/cxl.h>
2424

2525
#include "cxl.h"
26+
#include "trace.h"
2627

2728
static DEFINE_SPINLOCK(adapter_idr_lock);
2829
static DEFINE_IDR(cxl_adapter_idr);
@@ -48,6 +49,7 @@ static inline void _cxl_slbia(struct cxl_context *ctx, struct mm_struct *mm)
4849
ctx->afu->adapter->adapter_num, ctx->afu->slice, ctx->pe);
4950

5051
spin_lock_irqsave(&ctx->sste_lock, flags);
52+
trace_cxl_slbia(ctx);
5153
memset(ctx->sstp, 0, ctx->sst_size);
5254
spin_unlock_irqrestore(&ctx->sste_lock, flags);
5355
mb();

drivers/misc/cxl/native.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,28 @@
1818
#include <misc/cxl.h>
1919

2020
#include "cxl.h"
21+
#include "trace.h"
2122

2223
static int afu_control(struct cxl_afu *afu, u64 command,
2324
u64 result, u64 mask, bool enabled)
2425
{
2526
u64 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An);
2627
unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
28+
int rc = 0;
2729

2830
spin_lock(&afu->afu_cntl_lock);
2931
pr_devel("AFU command starting: %llx\n", command);
3032

33+
trace_cxl_afu_ctrl(afu, command);
34+
3135
cxl_p2n_write(afu, CXL_AFU_Cntl_An, AFU_Cntl | command);
3236

3337
AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An);
3438
while ((AFU_Cntl & mask) != result) {
3539
if (time_after_eq(jiffies, timeout)) {
3640
dev_warn(&afu->dev, "WARNING: AFU control timed out!\n");
37-
spin_unlock(&afu->afu_cntl_lock);
38-
return -EBUSY;
41+
rc = -EBUSY;
42+
goto out;
3943
}
4044
pr_devel_ratelimited("AFU control... (0x%.16llx)\n",
4145
AFU_Cntl | command);
@@ -44,9 +48,11 @@ static int afu_control(struct cxl_afu *afu, u64 command,
4448
};
4549
pr_devel("AFU command complete: %llx\n", command);
4650
afu->enabled = enabled;
51+
out:
52+
trace_cxl_afu_ctrl_done(afu, command, rc);
4753
spin_unlock(&afu->afu_cntl_lock);
4854

49-
return 0;
55+
return rc;
5056
}
5157

5258
static int afu_enable(struct cxl_afu *afu)
@@ -91,6 +97,9 @@ int cxl_psl_purge(struct cxl_afu *afu)
9197
u64 dsisr, dar;
9298
u64 start, end;
9399
unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
100+
int rc = 0;
101+
102+
trace_cxl_psl_ctrl(afu, CXL_PSL_SCNTL_An_Pc);
94103

95104
pr_devel("PSL purge request\n");
96105

@@ -107,7 +116,8 @@ int cxl_psl_purge(struct cxl_afu *afu)
107116
== CXL_PSL_SCNTL_An_Ps_Pending) {
108117
if (time_after_eq(jiffies, timeout)) {
109118
dev_warn(&afu->dev, "WARNING: PSL Purge timed out!\n");
110-
return -EBUSY;
119+
rc = -EBUSY;
120+
goto out;
111121
}
112122
dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An);
113123
pr_devel_ratelimited("PSL purging... PSL_CNTL: 0x%.16llx PSL_DSISR: 0x%.16llx\n", PSL_CNTL, dsisr);
@@ -128,7 +138,9 @@ int cxl_psl_purge(struct cxl_afu *afu)
128138

129139
cxl_p1n_write(afu, CXL_PSL_SCNTL_An,
130140
PSL_CNTL & ~CXL_PSL_SCNTL_An_Pc);
131-
return 0;
141+
out:
142+
trace_cxl_psl_ctrl_done(afu, CXL_PSL_SCNTL_An_Pc, rc);
143+
return rc;
132144
}
133145

134146
static int spa_max_procs(int spa_size)
@@ -279,6 +291,9 @@ static int do_process_element_cmd(struct cxl_context *ctx,
279291
{
280292
u64 state;
281293
unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
294+
int rc = 0;
295+
296+
trace_cxl_llcmd(ctx, cmd);
282297

283298
WARN_ON(!ctx->afu->enabled);
284299

@@ -290,12 +305,14 @@ static int do_process_element_cmd(struct cxl_context *ctx,
290305
while (1) {
291306
if (time_after_eq(jiffies, timeout)) {
292307
dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n");
293-
return -EBUSY;
308+
rc = -EBUSY;
309+
goto out;
294310
}
295311
state = be64_to_cpup(ctx->afu->sw_command_status);
296312
if (state == ~0ULL) {
297313
pr_err("cxl: Error adding process element to AFU\n");
298-
return -1;
314+
rc = -1;
315+
goto out;
299316
}
300317
if ((state & (CXL_SPA_SW_CMD_MASK | CXL_SPA_SW_STATE_MASK | CXL_SPA_SW_LINK_MASK)) ==
301318
(cmd | (cmd >> 16) | ctx->pe))
@@ -310,7 +327,9 @@ static int do_process_element_cmd(struct cxl_context *ctx,
310327
schedule();
311328

312329
}
313-
return 0;
330+
out:
331+
trace_cxl_llcmd_done(ctx, cmd, rc);
332+
return rc;
314333
}
315334

316335
static int add_process_element(struct cxl_context *ctx)
@@ -630,6 +649,8 @@ static inline int detach_process_native_afu_directed(struct cxl_context *ctx)
630649

631650
int cxl_detach_process(struct cxl_context *ctx)
632651
{
652+
trace_cxl_detach(ctx);
653+
633654
if (ctx->afu->current_mode == CXL_MODE_DEDICATED)
634655
return detach_process_native_dedicated(ctx);
635656

@@ -668,6 +689,7 @@ static void recover_psl_err(struct cxl_afu *afu, u64 errstat)
668689

669690
int cxl_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask)
670691
{
692+
trace_cxl_psl_irq_ack(ctx, tfc);
671693
if (tfc)
672694
cxl_p2n_write(ctx->afu, CXL_PSL_TFC_An, tfc);
673695
if (psl_reset_mask)

drivers/misc/cxl/trace.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2015 IBM Corp.
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version
7+
* 2 of the License, or (at your option) any later version.
8+
*/
9+
10+
#ifndef __CHECKER__
11+
#define CREATE_TRACE_POINTS
12+
#include "trace.h"
13+
#endif

0 commit comments

Comments
 (0)