Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries/htmdump: Add htm setup support to htmdump module

Add htm setup support to htmdump module. To use the
HTM (Hardware Trace Macro), HTM buffer has to be allocated.
Support setup of HTM buffers via debugfs interface. Under
debugfs folder, "/sys/kernel/debug/powerpc/htmdump", add file
"htmsetup". The interface allows setup of HTM buffer by writing
size of HTM buffer in power of 2 to the "htmsetup" file

Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250420180844.53128-7-atrajeev@linux.ibm.com

authored by

Athira Rajeev and committed by
Madhavan Srinivasan
78fb17ac dea7384e

+38
+38
arch/powerpc/platforms/pseries/htmdump.c
··· 20 20 static u32 htmtype; 21 21 static u32 htmconfigure; 22 22 static u32 htmstart; 23 + static u32 htmsetup; 24 + 23 25 static struct dentry *htmdump_debugfs_dir; 24 26 #define HTM_ENABLE 1 25 27 #define HTM_DISABLE 0 ··· 298 296 .open = simple_open, 299 297 }; 300 298 299 + static int htmsetup_set(void *data, u64 val) 300 + { 301 + long rc, ret; 302 + 303 + /* 304 + * Input value: HTM buffer size in the power of 2 305 + * example: hex value 0x21 ( decimal: 33 ) is for 306 + * 8GB 307 + * Invoke H_HTM call with: 308 + * - operation as htm start (H_HTM_OP_SETUP) 309 + * - parameter 1 set to input value. 310 + * - last two values are unused, hence set to zero 311 + */ 312 + rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 313 + htmtype, H_HTM_OP_SETUP, val, 0, 0); 314 + 315 + ret = htm_return_check(rc); 316 + if (ret <= 0) { 317 + pr_debug("H_HTM hcall failed for op: H_HTM_OP_SETUP, returning %ld\n", ret); 318 + return ret; 319 + } 320 + 321 + /* Set htmsetup if H_HTM_OP_SETUP operation succeeds */ 322 + htmsetup = val; 323 + 324 + return 0; 325 + } 326 + 327 + static int htmsetup_get(void *data, u64 *val) 328 + { 329 + *val = htmsetup; 330 + return 0; 331 + } 332 + 301 333 DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n"); 302 334 DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n"); 335 + DEFINE_SIMPLE_ATTRIBUTE(htmsetup_fops, htmsetup_get, htmsetup_set, "%llu\n"); 303 336 304 337 static int htmdump_init_debugfs(void) 305 338 { ··· 362 325 */ 363 326 debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops); 364 327 debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops); 328 + debugfs_create_file("htmsetup", 0600, htmdump_debugfs_dir, NULL, &htmsetup_fops); 365 329 366 330 /* Debugfs interface file to present status of HTM */ 367 331 htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);