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

cdx: Replace custom mcdi logging with print_hex_dump_debug()

Replace custom mcdi logging for send and receive requests
with dynamic debug method print_hex_dump_debug().

Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Message-ID: <20230613084318.27996-1-abhijit.gangurde@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Abhijit Gangurde and committed by
Greg Kroah-Hartman
b1c8ea3c b8c5ff76

+9 -93
-10
drivers/cdx/controller/Kconfig
··· 18 18 19 19 If unsure, say N. 20 20 21 - config MCDI_LOGGING 22 - bool "MCDI Logging for the CDX controller" 23 - depends on CDX_CONTROLLER 24 - help 25 - Enable MCDI Logging for 26 - the CDX Controller for debug 27 - purpose. 28 - 29 - If unsure, say N. 30 - 31 21 endif
+9 -77
drivers/cdx/controller/mcdi.c
··· 31 31 struct cdx_dword buffer[DIV_ROUND_UP(MCDI_CTL_SDU_LEN_MAX, 4)]; 32 32 }; 33 33 34 - #ifdef CONFIG_MCDI_LOGGING 35 - #define LOG_LINE_MAX (1024 - 32) 36 - #endif 37 - 38 34 static void cdx_mcdi_cancel_cmd(struct cdx_mcdi *cdx, struct cdx_mcdi_cmd *cmd); 39 35 static void cdx_mcdi_wait_for_cleanup(struct cdx_mcdi *cdx); 40 36 static int cdx_mcdi_rpc_async_internal(struct cdx_mcdi *cdx, ··· 115 119 mcdi = cdx_mcdi_if(cdx); 116 120 mcdi->cdx = cdx; 117 121 118 - #ifdef CONFIG_MCDI_LOGGING 119 - mcdi->logging_buffer = kmalloc(LOG_LINE_MAX, GFP_KERNEL); 120 - if (!mcdi->logging_buffer) 121 - goto fail2; 122 - #endif 123 122 mcdi->workqueue = alloc_ordered_workqueue("mcdi_wq", 0); 124 123 if (!mcdi->workqueue) 125 - goto fail3; 124 + goto fail2; 126 125 mutex_init(&mcdi->iface_lock); 127 126 mcdi->mode = MCDI_MODE_EVENTS; 128 127 INIT_LIST_HEAD(&mcdi->cmd_list); ··· 126 135 mcdi->new_epoch = true; 127 136 128 137 return 0; 129 - fail3: 130 - #ifdef CONFIG_MCDI_LOGGING 131 - kfree(mcdi->logging_buffer); 132 138 fail2: 133 - #endif 134 139 kfree(cdx->mcdi); 135 140 cdx->mcdi = NULL; 136 141 fail: ··· 142 155 return; 143 156 144 157 cdx_mcdi_wait_for_cleanup(cdx); 145 - 146 - #ifdef CONFIG_MCDI_LOGGING 147 - kfree(mcdi->logging_buffer); 148 - #endif 149 158 150 159 destroy_workqueue(mcdi->workqueue); 151 160 kfree(cdx->mcdi); ··· 229 246 size_t hdr_len; 230 247 bool not_epoch; 231 248 u32 xflags; 232 - #ifdef CONFIG_MCDI_LOGGING 233 - char *buf; 234 - #endif 235 249 236 250 if (!mcdi) 237 251 return; 238 - #ifdef CONFIG_MCDI_LOGGING 239 - buf = mcdi->logging_buffer; /* page-sized */ 240 - #endif 241 252 242 253 mcdi->prev_seq = cmd->seq; 243 254 mcdi->seq_held_by[cmd->seq] = cmd; ··· 258 281 MC_CMD_V2_EXTN_IN_MCDI_MESSAGE_TYPE_PLATFORM); 259 282 hdr_len = 8; 260 283 261 - #ifdef CONFIG_MCDI_LOGGING 262 - if (!WARN_ON_ONCE(!buf)) { 263 - const struct cdx_dword *frags[] = { hdr, inbuf }; 264 - const size_t frag_len[] = { hdr_len, round_up(inlen, 4) }; 265 - int bytes = 0; 266 - int i, j; 267 - 268 - for (j = 0; j < ARRAY_SIZE(frags); j++) { 269 - const struct cdx_dword *frag; 270 - 271 - frag = frags[j]; 272 - for (i = 0; 273 - i < frag_len[j] / 4; 274 - i++) { 275 - /* 276 - * Do not exceed the internal printk limit. 277 - * The string before that is just over 70 bytes. 278 - */ 279 - if ((bytes + 75) > LOG_LINE_MAX) { 280 - pr_info("MCDI RPC REQ:%s \\\n", buf); 281 - bytes = 0; 282 - } 283 - bytes += snprintf(buf + bytes, 284 - LOG_LINE_MAX - bytes, " %08x", 285 - le32_to_cpu(frag[i].cdx_u32)); 286 - } 287 - } 288 - 289 - pr_info("MCDI RPC REQ:%s\n", buf); 290 - } 291 - #endif 292 284 hdr[0].cdx_u32 |= (__force __le32)(cdx_mcdi_payload_csum(hdr, hdr_len, inbuf, inlen) << 293 285 MCDI_HEADER_XFLAGS_LBN); 286 + 287 + print_hex_dump_debug("MCDI REQ HEADER: ", DUMP_PREFIX_NONE, 32, 4, hdr, hdr_len, false); 288 + print_hex_dump_debug("MCDI REQ PAYLOAD: ", DUMP_PREFIX_NONE, 32, 4, inbuf, inlen, false); 289 + 294 290 cdx->mcdi_ops->mcdi_request(cdx, hdr, hdr_len, inbuf, inlen); 295 291 296 292 mcdi->new_epoch = false; ··· 650 700 resp_data_len = 0; 651 701 } 652 702 653 - #ifdef CONFIG_MCDI_LOGGING 654 - if (!WARN_ON_ONCE(!mcdi->logging_buffer)) { 655 - char *log = mcdi->logging_buffer; 656 - int i, bytes = 0; 657 - size_t rlen; 658 - 659 - WARN_ON_ONCE(resp_hdr_len % 4); 660 - 661 - rlen = resp_hdr_len / 4 + DIV_ROUND_UP(resp_data_len, 4); 662 - 663 - for (i = 0; i < rlen; i++) { 664 - if ((bytes + 75) > LOG_LINE_MAX) { 665 - pr_info("MCDI RPC RESP:%s \\\n", log); 666 - bytes = 0; 667 - } 668 - bytes += snprintf(log + bytes, LOG_LINE_MAX - bytes, 669 - " %08x", le32_to_cpu(outbuf[i].cdx_u32)); 670 - } 671 - 672 - pr_info("MCDI RPC RESP:%s\n", log); 673 - } 674 - #endif 703 + print_hex_dump_debug("MCDI RESP HEADER: ", DUMP_PREFIX_NONE, 32, 4, 704 + outbuf, resp_hdr_len, false); 705 + print_hex_dump_debug("MCDI RESP PAYLOAD: ", DUMP_PREFIX_NONE, 32, 4, 706 + outbuf + (resp_hdr_len / 4), resp_data_len, false); 675 707 676 708 if (error && resp_data_len == 0) { 677 709 /* MC rebooted during command */
-6
drivers/cdx/controller/mcdi.h
··· 153 153 * @mode: Poll for mcdi completion, or wait for an mcdi_event 154 154 * @prev_seq: The last used sequence number 155 155 * @new_epoch: Indicates start of day or start of MC reboot recovery 156 - * @logging_buffer: Buffer that may be used to build MCDI tracing messages 157 - * @logging_enabled: Whether to trace MCDI 158 156 */ 159 157 struct cdx_mcdi_iface { 160 158 struct cdx_mcdi *cdx; ··· 168 170 enum cdx_mcdi_mode mode; 169 171 u8 prev_seq; 170 172 bool new_epoch; 171 - #ifdef CONFIG_MCDI_LOGGING 172 - bool logging_enabled; 173 - char *logging_buffer; 174 - #endif 175 173 }; 176 174 177 175 /**