Skip to content

Commit 98b6926

Browse files
AlisonSchofielddjbw
authored andcommitted
cxl/memdev: Trace inject and clear poison as cxl_poison events
The cxl_poison trace event allows users to view the history of poison list reads. With the addition of inject and clear poison capabilities, users will expect similar tracing. Add trace types 'Inject' and 'Clear' to the cxl_poison trace_event and trace successful operations only. If the driver finds that the DPA being injected or cleared of poison is mapped in a region, that region info is included in the cxl_poison trace event. Region reconfigurations can make this extra info useless if the debug operations are not carefully managed. Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/e20eb7c3029137b480ece671998c183da0477e2e.1681874357.git.alison.schofield@intel.com Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 0a105ab commit 98b6926

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

drivers/cxl/core/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ void cxl_mbox_init(void);
7171

7272
enum cxl_poison_trace_type {
7373
CXL_POISON_TRACE_LIST,
74+
CXL_POISON_TRACE_INJECT,
75+
CXL_POISON_TRACE_CLEAR,
7476
};
7577

7678
#endif /* __CXL_CORE_H__ */

drivers/cxl/core/memdev.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/idr.h>
77
#include <linux/pci.h>
88
#include <cxlmem.h>
9+
#include "trace.h"
910
#include "core.h"
1011

1112
static DECLARE_RWSEM(cxl_memdev_rwsem);
@@ -232,6 +233,7 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
232233
{
233234
struct cxl_dev_state *cxlds = cxlmd->cxlds;
234235
struct cxl_mbox_inject_poison inject;
236+
struct cxl_poison_record record;
235237
struct cxl_mbox_cmd mbox_cmd;
236238
struct cxl_region *cxlr;
237239
int rc;
@@ -262,6 +264,12 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
262264
dev_warn_once(cxlds->dev,
263265
"poison inject dpa:%#llx region: %s\n", dpa,
264266
dev_name(&cxlr->dev));
267+
268+
record = (struct cxl_poison_record) {
269+
.address = cpu_to_le64(dpa),
270+
.length = cpu_to_le32(1),
271+
};
272+
trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_INJECT);
265273
out:
266274
up_read(&cxl_dpa_rwsem);
267275

@@ -273,6 +281,7 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
273281
{
274282
struct cxl_dev_state *cxlds = cxlmd->cxlds;
275283
struct cxl_mbox_clear_poison clear;
284+
struct cxl_poison_record record;
276285
struct cxl_mbox_cmd mbox_cmd;
277286
struct cxl_region *cxlr;
278287
int rc;
@@ -311,6 +320,12 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
311320
if (cxlr)
312321
dev_warn_once(cxlds->dev, "poison clear dpa:%#llx region: %s\n",
313322
dpa, dev_name(&cxlr->dev));
323+
324+
record = (struct cxl_poison_record) {
325+
.address = cpu_to_le64(dpa),
326+
.length = cpu_to_le32(1),
327+
};
328+
trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_CLEAR);
314329
out:
315330
up_read(&cxl_dpa_rwsem);
316331

drivers/cxl/core/trace.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,11 @@ TRACE_EVENT(cxl_memory_module,
602602
)
603603
);
604604

605-
#define show_poison_trace_type(type) \
606-
__print_symbolic(type, \
607-
{ CXL_POISON_TRACE_LIST, "List" })
605+
#define show_poison_trace_type(type) \
606+
__print_symbolic(type, \
607+
{ CXL_POISON_TRACE_LIST, "List" }, \
608+
{ CXL_POISON_TRACE_INJECT, "Inject" }, \
609+
{ CXL_POISON_TRACE_CLEAR, "Clear" })
608610

609611
#define __show_poison_source(source) \
610612
__print_symbolic(source, \

0 commit comments

Comments
 (0)