Skip to content

Commit dea7384

Browse files
Athira Rajeevmaddy-kerneldev
authored andcommitted
powerpc/pseries/htmdump: Add htm info support to htmdump module
Support dumping system processor configuration from Hardware Trace Macro (HTM) function via debugfs interface. Under debugfs folder "/sys/kernel/debug/powerpc/htmdump", add file "htminfo". The interface allows only read of this file which will present the content of HTM buffer from the hcall. The 16th offset of HTM buffer has value for the number of entries for array of processors. Use this information to copy data to the debugfs file 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 627cf58 commit dea7384

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
static void *htm_buf;
1515
static void *htm_status_buf;
16+
static void *htm_info_buf;
1617
static u32 nodeindex;
1718
static u32 nodalchipindex;
1819
static u32 coreindexonchip;
@@ -253,6 +254,48 @@ static const struct file_operations htmstatus_fops = {
253254
.open = simple_open,
254255
};
255256

257+
static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
258+
size_t count, loff_t *ppos)
259+
{
260+
void *htm_info_buf = filp->private_data;
261+
long rc, ret;
262+
u64 *num_entries;
263+
u64 to_copy;
264+
265+
/*
266+
* Invoke H_HTM call with:
267+
* - operation as htm status (H_HTM_OP_STATUS)
268+
* - last three values as addr, size and offset
269+
*/
270+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
271+
htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),
272+
PAGE_SIZE, 0);
273+
274+
ret = htm_return_check(rc);
275+
if (ret <= 0) {
276+
pr_debug("H_HTM hcall failed for op: H_HTM_OP_DUMP_SYSPROC_CONF, returning %ld\n", ret);
277+
return ret;
278+
}
279+
280+
/*
281+
* HTM status buffer, start of buffer + 0x10 gives the
282+
* number of HTM entries in the buffer. Each entry of processor
283+
* is 16 bytes.
284+
*
285+
* So total count to copy is:
286+
* 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
287+
*/
288+
num_entries = htm_info_buf + 0x10;
289+
to_copy = 32 + (be64_to_cpu(*num_entries) * 16);
290+
return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);
291+
}
292+
293+
static const struct file_operations htminfo_fops = {
294+
.llseek = NULL,
295+
.read = htminfo_read,
296+
.open = simple_open,
297+
};
298+
256299
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
257300
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
258301

@@ -290,7 +333,15 @@ static int htmdump_init_debugfs(void)
290333
return -ENOMEM;
291334
}
292335

336+
/* Debugfs interface file to present System Processor Configuration */
337+
htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
338+
if (!htm_info_buf) {
339+
pr_err("Failed to allocate htm info buf\n");
340+
return -ENOMEM;
341+
}
342+
293343
debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
344+
debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
294345

295346
return 0;
296347
}

0 commit comments

Comments
 (0)