mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
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>
This commit is contained in:
parent
b8c5ff7605
commit
b1c8ea3c09
3 changed files with 9 additions and 93 deletions
|
@ -18,14 +18,4 @@ config CDX_CONTROLLER
|
||||||
|
|
||||||
If unsure, say N.
|
If unsure, say N.
|
||||||
|
|
||||||
config MCDI_LOGGING
|
|
||||||
bool "MCDI Logging for the CDX controller"
|
|
||||||
depends on CDX_CONTROLLER
|
|
||||||
help
|
|
||||||
Enable MCDI Logging for
|
|
||||||
the CDX Controller for debug
|
|
||||||
purpose.
|
|
||||||
|
|
||||||
If unsure, say N.
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -31,10 +31,6 @@ struct cdx_mcdi_copy_buffer {
|
||||||
struct cdx_dword buffer[DIV_ROUND_UP(MCDI_CTL_SDU_LEN_MAX, 4)];
|
struct cdx_dword buffer[DIV_ROUND_UP(MCDI_CTL_SDU_LEN_MAX, 4)];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
#define LOG_LINE_MAX (1024 - 32)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void cdx_mcdi_cancel_cmd(struct cdx_mcdi *cdx, struct cdx_mcdi_cmd *cmd);
|
static void cdx_mcdi_cancel_cmd(struct cdx_mcdi *cdx, struct cdx_mcdi_cmd *cmd);
|
||||||
static void cdx_mcdi_wait_for_cleanup(struct cdx_mcdi *cdx);
|
static void cdx_mcdi_wait_for_cleanup(struct cdx_mcdi *cdx);
|
||||||
static int cdx_mcdi_rpc_async_internal(struct cdx_mcdi *cdx,
|
static int cdx_mcdi_rpc_async_internal(struct cdx_mcdi *cdx,
|
||||||
|
@ -119,14 +115,9 @@ int cdx_mcdi_init(struct cdx_mcdi *cdx)
|
||||||
mcdi = cdx_mcdi_if(cdx);
|
mcdi = cdx_mcdi_if(cdx);
|
||||||
mcdi->cdx = cdx;
|
mcdi->cdx = cdx;
|
||||||
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
mcdi->logging_buffer = kmalloc(LOG_LINE_MAX, GFP_KERNEL);
|
|
||||||
if (!mcdi->logging_buffer)
|
|
||||||
goto fail2;
|
|
||||||
#endif
|
|
||||||
mcdi->workqueue = alloc_ordered_workqueue("mcdi_wq", 0);
|
mcdi->workqueue = alloc_ordered_workqueue("mcdi_wq", 0);
|
||||||
if (!mcdi->workqueue)
|
if (!mcdi->workqueue)
|
||||||
goto fail3;
|
goto fail2;
|
||||||
mutex_init(&mcdi->iface_lock);
|
mutex_init(&mcdi->iface_lock);
|
||||||
mcdi->mode = MCDI_MODE_EVENTS;
|
mcdi->mode = MCDI_MODE_EVENTS;
|
||||||
INIT_LIST_HEAD(&mcdi->cmd_list);
|
INIT_LIST_HEAD(&mcdi->cmd_list);
|
||||||
|
@ -135,11 +126,7 @@ int cdx_mcdi_init(struct cdx_mcdi *cdx)
|
||||||
mcdi->new_epoch = true;
|
mcdi->new_epoch = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail3:
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
kfree(mcdi->logging_buffer);
|
|
||||||
fail2:
|
fail2:
|
||||||
#endif
|
|
||||||
kfree(cdx->mcdi);
|
kfree(cdx->mcdi);
|
||||||
cdx->mcdi = NULL;
|
cdx->mcdi = NULL;
|
||||||
fail:
|
fail:
|
||||||
|
@ -156,10 +143,6 @@ void cdx_mcdi_finish(struct cdx_mcdi *cdx)
|
||||||
|
|
||||||
cdx_mcdi_wait_for_cleanup(cdx);
|
cdx_mcdi_wait_for_cleanup(cdx);
|
||||||
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
kfree(mcdi->logging_buffer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
destroy_workqueue(mcdi->workqueue);
|
destroy_workqueue(mcdi->workqueue);
|
||||||
kfree(cdx->mcdi);
|
kfree(cdx->mcdi);
|
||||||
cdx->mcdi = NULL;
|
cdx->mcdi = NULL;
|
||||||
|
@ -246,15 +229,9 @@ static void cdx_mcdi_send_request(struct cdx_mcdi *cdx,
|
||||||
size_t hdr_len;
|
size_t hdr_len;
|
||||||
bool not_epoch;
|
bool not_epoch;
|
||||||
u32 xflags;
|
u32 xflags;
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
char *buf;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!mcdi)
|
if (!mcdi)
|
||||||
return;
|
return;
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
buf = mcdi->logging_buffer; /* page-sized */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mcdi->prev_seq = cmd->seq;
|
mcdi->prev_seq = cmd->seq;
|
||||||
mcdi->seq_held_by[cmd->seq] = cmd;
|
mcdi->seq_held_by[cmd->seq] = cmd;
|
||||||
|
@ -281,39 +258,12 @@ static void cdx_mcdi_send_request(struct cdx_mcdi *cdx,
|
||||||
MC_CMD_V2_EXTN_IN_MCDI_MESSAGE_TYPE_PLATFORM);
|
MC_CMD_V2_EXTN_IN_MCDI_MESSAGE_TYPE_PLATFORM);
|
||||||
hdr_len = 8;
|
hdr_len = 8;
|
||||||
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
if (!WARN_ON_ONCE(!buf)) {
|
|
||||||
const struct cdx_dword *frags[] = { hdr, inbuf };
|
|
||||||
const size_t frag_len[] = { hdr_len, round_up(inlen, 4) };
|
|
||||||
int bytes = 0;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (j = 0; j < ARRAY_SIZE(frags); j++) {
|
|
||||||
const struct cdx_dword *frag;
|
|
||||||
|
|
||||||
frag = frags[j];
|
|
||||||
for (i = 0;
|
|
||||||
i < frag_len[j] / 4;
|
|
||||||
i++) {
|
|
||||||
/*
|
|
||||||
* Do not exceed the internal printk limit.
|
|
||||||
* The string before that is just over 70 bytes.
|
|
||||||
*/
|
|
||||||
if ((bytes + 75) > LOG_LINE_MAX) {
|
|
||||||
pr_info("MCDI RPC REQ:%s \\\n", buf);
|
|
||||||
bytes = 0;
|
|
||||||
}
|
|
||||||
bytes += snprintf(buf + bytes,
|
|
||||||
LOG_LINE_MAX - bytes, " %08x",
|
|
||||||
le32_to_cpu(frag[i].cdx_u32));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("MCDI RPC REQ:%s\n", buf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
hdr[0].cdx_u32 |= (__force __le32)(cdx_mcdi_payload_csum(hdr, hdr_len, inbuf, inlen) <<
|
hdr[0].cdx_u32 |= (__force __le32)(cdx_mcdi_payload_csum(hdr, hdr_len, inbuf, inlen) <<
|
||||||
MCDI_HEADER_XFLAGS_LBN);
|
MCDI_HEADER_XFLAGS_LBN);
|
||||||
|
|
||||||
|
print_hex_dump_debug("MCDI REQ HEADER: ", DUMP_PREFIX_NONE, 32, 4, hdr, hdr_len, false);
|
||||||
|
print_hex_dump_debug("MCDI REQ PAYLOAD: ", DUMP_PREFIX_NONE, 32, 4, inbuf, inlen, false);
|
||||||
|
|
||||||
cdx->mcdi_ops->mcdi_request(cdx, hdr, hdr_len, inbuf, inlen);
|
cdx->mcdi_ops->mcdi_request(cdx, hdr, hdr_len, inbuf, inlen);
|
||||||
|
|
||||||
mcdi->new_epoch = false;
|
mcdi->new_epoch = false;
|
||||||
|
@ -700,28 +650,10 @@ static bool cdx_mcdi_complete_cmd(struct cdx_mcdi_iface *mcdi,
|
||||||
resp_data_len = 0;
|
resp_data_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
print_hex_dump_debug("MCDI RESP HEADER: ", DUMP_PREFIX_NONE, 32, 4,
|
||||||
if (!WARN_ON_ONCE(!mcdi->logging_buffer)) {
|
outbuf, resp_hdr_len, false);
|
||||||
char *log = mcdi->logging_buffer;
|
print_hex_dump_debug("MCDI RESP PAYLOAD: ", DUMP_PREFIX_NONE, 32, 4,
|
||||||
int i, bytes = 0;
|
outbuf + (resp_hdr_len / 4), resp_data_len, false);
|
||||||
size_t rlen;
|
|
||||||
|
|
||||||
WARN_ON_ONCE(resp_hdr_len % 4);
|
|
||||||
|
|
||||||
rlen = resp_hdr_len / 4 + DIV_ROUND_UP(resp_data_len, 4);
|
|
||||||
|
|
||||||
for (i = 0; i < rlen; i++) {
|
|
||||||
if ((bytes + 75) > LOG_LINE_MAX) {
|
|
||||||
pr_info("MCDI RPC RESP:%s \\\n", log);
|
|
||||||
bytes = 0;
|
|
||||||
}
|
|
||||||
bytes += snprintf(log + bytes, LOG_LINE_MAX - bytes,
|
|
||||||
" %08x", le32_to_cpu(outbuf[i].cdx_u32));
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("MCDI RPC RESP:%s\n", log);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (error && resp_data_len == 0) {
|
if (error && resp_data_len == 0) {
|
||||||
/* MC rebooted during command */
|
/* MC rebooted during command */
|
||||||
|
|
|
@ -153,8 +153,6 @@ struct cdx_mcdi_cmd {
|
||||||
* @mode: Poll for mcdi completion, or wait for an mcdi_event
|
* @mode: Poll for mcdi completion, or wait for an mcdi_event
|
||||||
* @prev_seq: The last used sequence number
|
* @prev_seq: The last used sequence number
|
||||||
* @new_epoch: Indicates start of day or start of MC reboot recovery
|
* @new_epoch: Indicates start of day or start of MC reboot recovery
|
||||||
* @logging_buffer: Buffer that may be used to build MCDI tracing messages
|
|
||||||
* @logging_enabled: Whether to trace MCDI
|
|
||||||
*/
|
*/
|
||||||
struct cdx_mcdi_iface {
|
struct cdx_mcdi_iface {
|
||||||
struct cdx_mcdi *cdx;
|
struct cdx_mcdi *cdx;
|
||||||
|
@ -170,10 +168,6 @@ struct cdx_mcdi_iface {
|
||||||
enum cdx_mcdi_mode mode;
|
enum cdx_mcdi_mode mode;
|
||||||
u8 prev_seq;
|
u8 prev_seq;
|
||||||
bool new_epoch;
|
bool new_epoch;
|
||||||
#ifdef CONFIG_MCDI_LOGGING
|
|
||||||
bool logging_enabled;
|
|
||||||
char *logging_buffer;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue