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

Configure Feed

Select the types of activity you want to include in your feed.

firmware: arm_scmi: imx: Support getting syslog of MISC protocol

MISC protocol supports getting system log regarding system sleep latency,
wakeup interrupt and etc. Add the API for user to retrieve the information
from SM.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>

authored by

Peng Fan and committed by
Shawn Guo
4fa62e80 8f0b4cce

+85
+83
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
··· 28 28 SCMI_IMX_MISC_DISCOVER_BUILD_INFO = 0x6, 29 29 SCMI_IMX_MISC_CTRL_NOTIFY = 0x8, 30 30 SCMI_IMX_MISC_CFG_INFO_GET = 0xC, 31 + SCMI_IMX_MISC_SYSLOG_GET = 0xD, 31 32 SCMI_IMX_MISC_BOARD_INFO = 0xE, 32 33 }; 33 34 ··· 88 87 __le32 msel; 89 88 #define MISC_MAX_CFGNAME 16 90 89 u8 cfgname[MISC_MAX_CFGNAME]; 90 + }; 91 + 92 + struct scmi_imx_misc_syslog_in { 93 + __le32 flags; 94 + __le32 index; 95 + }; 96 + 97 + #define REMAINING(x) le32_get_bits((x), GENMASK(31, 20)) 98 + #define RETURNED(x) le32_get_bits((x), GENMASK(11, 0)) 99 + 100 + struct scmi_imx_misc_syslog_out { 101 + __le32 numlogflags; 102 + __le32 syslog[]; 91 103 }; 92 104 93 105 static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph, ··· 385 371 return ret; 386 372 } 387 373 374 + struct scmi_imx_misc_syslog_ipriv { 375 + u32 *array; 376 + u16 *size; 377 + }; 378 + 379 + static void iter_misc_syslog_prepare_message(void *message, u32 desc_index, 380 + const void *priv) 381 + { 382 + struct scmi_imx_misc_syslog_in *msg = message; 383 + 384 + msg->flags = cpu_to_le32(0); 385 + msg->index = cpu_to_le32(desc_index); 386 + } 387 + 388 + static int iter_misc_syslog_update_state(struct scmi_iterator_state *st, 389 + const void *response, void *priv) 390 + { 391 + const struct scmi_imx_misc_syslog_out *r = response; 392 + struct scmi_imx_misc_syslog_ipriv *p = priv; 393 + 394 + st->num_returned = RETURNED(r->numlogflags); 395 + st->num_remaining = REMAINING(r->numlogflags); 396 + *p->size = st->num_returned + st->num_remaining; 397 + 398 + return 0; 399 + } 400 + 401 + static int 402 + iter_misc_syslog_process_response(const struct scmi_protocol_handle *ph, 403 + const void *response, 404 + struct scmi_iterator_state *st, void *priv) 405 + { 406 + const struct scmi_imx_misc_syslog_out *r = response; 407 + struct scmi_imx_misc_syslog_ipriv *p = priv; 408 + 409 + p->array[st->desc_index + st->loop_idx] = 410 + le32_to_cpu(r->syslog[st->loop_idx]); 411 + 412 + return 0; 413 + } 414 + 415 + static int scmi_imx_misc_syslog_get(const struct scmi_protocol_handle *ph, u16 *size, 416 + void *array) 417 + { 418 + struct scmi_iterator_ops ops = { 419 + .prepare_message = iter_misc_syslog_prepare_message, 420 + .update_state = iter_misc_syslog_update_state, 421 + .process_response = iter_misc_syslog_process_response, 422 + }; 423 + struct scmi_imx_misc_syslog_ipriv ipriv = { 424 + .array = array, 425 + .size = size, 426 + }; 427 + void *iter; 428 + 429 + if (!array || !size || !*size) 430 + return -EINVAL; 431 + 432 + iter = ph->hops->iter_response_init(ph, &ops, *size, SCMI_IMX_MISC_SYSLOG_GET, 433 + sizeof(struct scmi_imx_misc_syslog_in), 434 + &ipriv); 435 + if (IS_ERR(iter)) 436 + return PTR_ERR(iter); 437 + 438 + /* If firmware return NOT SUPPORTED, propagate value to caller */ 439 + return ph->hops->iter_response_run(iter); 440 + } 441 + 388 442 static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = { 389 443 .misc_ctrl_set = scmi_imx_misc_ctrl_set, 390 444 .misc_ctrl_get = scmi_imx_misc_ctrl_get, 391 445 .misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify, 446 + .misc_syslog = scmi_imx_misc_syslog_get, 392 447 }; 393 448 394 449 static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)
+2
include/linux/scmi_imx_protocol.h
··· 59 59 u32 *num, u32 *val); 60 60 int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph, 61 61 u32 ctrl_id, u32 evt_id, u32 flags); 62 + int (*misc_syslog)(const struct scmi_protocol_handle *ph, u16 *size, 63 + void *array); 62 64 }; 63 65 64 66 /* See LMM_ATTRIBUTES in imx95.rst */