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

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

Under debugfs folder, "/sys/kernel/debug/powerpc/htmdump", add file
"htmflags". Currently supported flag value is to enable/disable
HTM buffer wrap. wrap is used along with "configure" to prevent
HTM buffer from wrapping. Writing 1 will set noWrap while
configuring HTM

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-8-atrajeev@linux.ibm.com

authored by

Athira Rajeev and committed by
Madhavan Srinivasan
d3f24bf2 78fb17ac

+50 -11
+2 -2
arch/powerpc/include/asm/plpar_wrappers.h
··· 81 81 param1, param2, param3); 82 82 } 83 83 84 - static inline long htm_hcall_wrapper(unsigned long nodeindex, 84 + static inline long htm_hcall_wrapper(unsigned long flags, unsigned long nodeindex, 85 85 unsigned long nodalchipindex, unsigned long coreindexonchip, 86 86 unsigned long type, unsigned long htm_op, unsigned long param1, unsigned long param2, 87 87 unsigned long param3) 88 88 { 89 - return htm_call(H_HTM_FLAGS_HARDWARE_TARGET, 89 + return htm_call(H_HTM_FLAGS_HARDWARE_TARGET | flags, 90 90 H_HTM_TARGET_NODE_INDEX(nodeindex) | 91 91 H_HTM_TARGET_NODAL_CHIP_INDEX(nodalchipindex) | 92 92 H_HTM_TARGET_CORE_INDEX_ON_CHIP(coreindexonchip),
+48 -9
arch/powerpc/platforms/pseries/htmdump.c
··· 21 21 static u32 htmconfigure; 22 22 static u32 htmstart; 23 23 static u32 htmsetup; 24 + static u64 htmflags; 24 25 25 26 static struct dentry *htmdump_debugfs_dir; 26 27 #define HTM_ENABLE 1 27 28 #define HTM_DISABLE 0 29 + #define HTM_NOWRAP 1 30 + #define HTM_WRAP 0 28 31 29 32 /* 30 33 * Check the return code for H_HTM hcall. ··· 97 94 * - operation as htm dump (H_HTM_OP_DUMP_DATA) 98 95 * - last three values are address, size and offset 99 96 */ 100 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 97 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 101 98 htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf), 102 99 PAGE_SIZE, page); 103 100 ··· 122 119 static int htmconfigure_set(void *data, u64 val) 123 120 { 124 121 long rc, ret; 122 + unsigned long param1 = -1, param2 = -1; 125 123 126 124 /* 127 125 * value as 1 : configure HTM. ··· 133 129 /* 134 130 * Invoke H_HTM call with: 135 131 * - operation as htm configure (H_HTM_OP_CONFIGURE) 132 + * - If htmflags is set, param1 and param2 will be -1 133 + * which is an indicator to use default htm mode reg mask 134 + * and htm mode reg value. 136 135 * - last three values are unused, hence set to zero 137 136 */ 138 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 139 - htmtype, H_HTM_OP_CONFIGURE, 0, 0, 0); 137 + if (!htmflags) { 138 + param1 = 0; 139 + param2 = 0; 140 + } 141 + 142 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 143 + htmtype, H_HTM_OP_CONFIGURE, param1, param2, 0); 140 144 } else if (val == HTM_DISABLE) { 141 145 /* 142 146 * Invoke H_HTM call with: 143 147 * - operation as htm deconfigure (H_HTM_OP_DECONFIGURE) 144 148 * - last three values are unused, hence set to zero 145 149 */ 146 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 150 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 147 151 htmtype, H_HTM_OP_DECONFIGURE, 0, 0, 0); 148 152 } else 149 153 return -EINVAL; ··· 189 177 * - operation as htm start (H_HTM_OP_START) 190 178 * - last three values are unused, hence set to zero 191 179 */ 192 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 180 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 193 181 htmtype, H_HTM_OP_START, 0, 0, 0); 194 182 195 183 } else if (val == HTM_DISABLE) { ··· 198 186 * - operation as htm stop (H_HTM_OP_STOP) 199 187 * - last three values are unused, hence set to zero 200 188 */ 201 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 189 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 202 190 htmtype, H_HTM_OP_STOP, 0, 0, 0); 203 191 } else 204 192 return -EINVAL; ··· 235 223 * - operation as htm status (H_HTM_OP_STATUS) 236 224 * - last three values as addr, size and offset 237 225 */ 238 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 226 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 239 227 htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf), 240 228 PAGE_SIZE, 0); 241 229 ··· 281 269 * - operation as htm status (H_HTM_OP_STATUS) 282 270 * - last three values as addr, size and offset 283 271 */ 284 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 272 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 285 273 htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf), 286 274 PAGE_SIZE, 0); 287 275 ··· 323 311 * - parameter 1 set to input value. 324 312 * - last two values are unused, hence set to zero 325 313 */ 326 - rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, 314 + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, 327 315 htmtype, H_HTM_OP_SETUP, val, 0, 0); 328 316 329 317 ret = htm_return_check(rc); ··· 344 332 return 0; 345 333 } 346 334 335 + static int htmflags_set(void *data, u64 val) 336 + { 337 + /* 338 + * Input value: 339 + * Currently supported flag value is to enable/disable 340 + * HTM buffer wrap. wrap is used along with "configure" 341 + * to prevent HTM buffer from wrapping. 342 + * Writing 1 will set noWrap while configuring HTM 343 + */ 344 + if (val == HTM_NOWRAP) 345 + htmflags = H_HTM_FLAGS_NOWRAP; 346 + else if (val == HTM_WRAP) 347 + htmflags = 0; 348 + else 349 + return -EINVAL; 350 + 351 + return 0; 352 + } 353 + 354 + static int htmflags_get(void *data, u64 *val) 355 + { 356 + *val = htmflags; 357 + return 0; 358 + } 359 + 347 360 DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n"); 348 361 DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n"); 349 362 DEFINE_SIMPLE_ATTRIBUTE(htmsetup_fops, htmsetup_get, htmsetup_set, "%llu\n"); 363 + DEFINE_SIMPLE_ATTRIBUTE(htmflags_fops, htmflags_get, htmflags_set, "%llu\n"); 350 364 351 365 static int htmdump_init_debugfs(void) 352 366 { ··· 401 363 debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops); 402 364 debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops); 403 365 debugfs_create_file("htmsetup", 0600, htmdump_debugfs_dir, NULL, &htmsetup_fops); 366 + debugfs_create_file("htmflags", 0600, htmdump_debugfs_dir, NULL, &htmflags_fops); 404 367 405 368 /* Debugfs interface file to present status of HTM */ 406 369 htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);