Skip to content

Commit 143a258

Browse files
Athira Rajeevmaddy-kerneldev
authored andcommitted
powerpc/pseries/htmdump: Add htm capabilities support to htmdump module
Support dumping HTM capabilities information from Hardware Trace Macro (HTM) function via debugfs interface. Under debugfs folder "/sys/kernel/debug/powerpc/htmdump", add file "htmcaps". The interface allows only read of this file which will present the content of HTM buffer from the hcall. Signed-off-by: Athira Rajeev <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent d3f24bf commit 143a258

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
static void *htm_buf;
1515
static void *htm_status_buf;
1616
static void *htm_info_buf;
17+
static void *htm_caps_buf;
1718
static u32 nodeindex;
1819
static u32 nodalchipindex;
1920
static u32 coreindexonchip;
@@ -304,12 +305,43 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
304305
return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);
305306
}
306307

308+
static ssize_t htmcaps_read(struct file *filp, char __user *ubuf,
309+
size_t count, loff_t *ppos)
310+
{
311+
void *htm_caps_buf = filp->private_data;
312+
long rc, ret;
313+
314+
/*
315+
* Invoke H_HTM call with:
316+
* - operation as htm capabilities (H_HTM_OP_CAPABILITIES)
317+
* - last three values as addr, size (0x80 for Capabilities Output Buffer
318+
* and zero
319+
*/
320+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
321+
htmtype, H_HTM_OP_CAPABILITIES, virt_to_phys(htm_caps_buf),
322+
0x80, 0);
323+
324+
ret = htm_return_check(rc);
325+
if (ret <= 0) {
326+
pr_debug("H_HTM hcall failed for op: H_HTM_OP_CAPABILITIES, returning %ld\n", ret);
327+
return ret;
328+
}
329+
330+
return simple_read_from_buffer(ubuf, count, ppos, htm_caps_buf, 0x80);
331+
}
332+
307333
static const struct file_operations htminfo_fops = {
308334
.llseek = NULL,
309335
.read = htminfo_read,
310336
.open = simple_open,
311337
};
312338

339+
static const struct file_operations htmcaps_fops = {
340+
.llseek = NULL,
341+
.read = htmcaps_read,
342+
.open = simple_open,
343+
};
344+
313345
static int htmsetup_set(void *data, u64 val)
314346
{
315347
long rc, ret;
@@ -417,8 +449,16 @@ static int htmdump_init_debugfs(void)
417449
return -ENOMEM;
418450
}
419451

452+
/* Debugfs interface file to present HTM capabilities */
453+
htm_caps_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
454+
if (!htm_caps_buf) {
455+
pr_err("Failed to allocate htm caps buf\n");
456+
return -ENOMEM;
457+
}
458+
420459
debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
421460
debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
461+
debugfs_create_file("htmcaps", 0400, htmdump_debugfs_dir, htm_caps_buf, &htmcaps_fops);
422462

423463
return 0;
424464
}

0 commit comments

Comments
 (0)