Cleanup and Refactor TI-SCI driver
v3 cover Cleanup and Refactor TI-SCI driver
This series does a lot of cleanups and refactoring of the TI-SCI driver.
Patches 01-11:
The first part of the series refactors a lot of common code from each of the TI-SCI message functions into a single place (get_one_xfer() and do_xfer()). Result is removal of net ~740 lines (~20% of the whole driver
size) without changing functionality.
Patches 12-15:
The second part of the series does some preparatory work for being able to break down the single large TI-SCI file into smaller files.
Patches 16-22:
The third and final part of the series breaks down the single large ti_sci.c file into smaller logical files: ti_sci core, device, clock, pm, rm, and proc. This allows for better readability and maintenance.
Note:
All dependencies for this patch series have now been merged.
v3: Changelog:
1. Carry Kendall's R/B in [PATCH v3 15/22].
2. Correct API name in dev_err() string in [PATCH v3 20/22]. (Kendall)
3. Rename ti_sci.c to ti_sci_core.c earlier in the patch series in [PATCH v3 16/22]. (Andrew)
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. Fix build for arm32 platforms like keystone by including appropriate headers in ti_sci_rm.c in [PATCH v2 21/22].
Link to v1:
https://lore.kernel.org/all/[email protected]/
Testing Done:
- Boot tested on all TI K3 SoCs.
- Boot tested on Keystone platforms like K2G-EVM, K2G-ICE, K2HK-EVM.
- Tested some of the Core, Device, Clock, and Proc ops with remoteproc
- Tested each patch for no new warnings or errors.
Logs:
https://gist.github.com/3V3RYONE/b8ef9d63eaa45db251dc84306b1451e0
Andrew Davis (18):
firmware: ti_sci: Move error message handling into
ti_sci_get_one_xfer()
firmware: ti_sci: Move error message handling into ti_sci_do_xfer()
firmware: ti_sci: Move check for ACK into ti_sci_do_xfer()
firmware: ti_sci: Remove out of place RM debug messages
firmware: ti_sci: Name response variable resp for consistency
firmware: ti_sci: Handle xfer cleanup inside ti_sci_do_xfer()
firmware: ti_sci: Pass request struct into ti_sci_do_xfer()
firmware: ti_sci: Combine xfer allocation and transfer functions
firmware: ti_sci: Fetch info struct from handle inside
ti_sci_do_xfer() firmware: ti_sci: Use tx_message as message buffer directly
firmware: ti_sci: Use rx_message as message receive buffer
firmware: ti_sci: Do not export reboot control
firmware: ti_sci: Move the huge ti_sci file into its own directory
firmware: ti: ti_sci: Add missing includes for self-contained headers
firmware: ti: ti_sci_device: Move device ops into its own file
firmware: ti: ti_sci_clock: Move clock ops into its own file
firmware: ti: ti_sci_pm: Move pm ops into its own file
firmware: ti: ti_sci_rm: Move rm ops into its own file
Beleswar Padhi (4):
firmware: ti_sci: Fix some kernel-doc references in structs
soc: ti: ti_sci_protocol.h: Add missing documentation for structs
firmware: ti_sci: Use pmops fxn pointers in suspend/resume hooks
firmware: ti: ti_sci_proc: Move processor ops into its own file
MAINTAINERS | 2 +-
drivers/firmware/Kconfig | 17 +-
drivers/firmware/Makefile | 2 +-
drivers/firmware/ti/Kconfig | 17 +
drivers/firmware/ti/Makefile | 9 +
drivers/firmware/{ => ti}/ti_sci.h | 258 +-
drivers/firmware/ti/ti_sci_clock.c | 553 +++
drivers/firmware/ti/ti_sci_core.c | 1320 ++++++++
drivers/firmware/ti/ti_sci_device.c | 388 +++
drivers/firmware/ti/ti_sci_pm.c | 145 +
drivers/firmware/ti/ti_sci_proc.c | 214 ++
drivers/firmware/ti/ti_sci_rm.c | 910 +++++
drivers/firmware/ti_sci.c | 4259 ------------------------
include/linux/soc/ti/ti_sci_protocol.h | 389 ++-
14 files changed, 4121 insertions(+), 4362 deletions(-)
create mode 100644 drivers/firmware/ti/Kconfig
create mode 100644 drivers/firmware/ti/Makefile
rename drivers/firmware/{ => ti}/ti_sci.h (89%)
create mode 100644 drivers/firmware/ti/ti_sci_clock.c
create mode 100644 drivers/firmware/ti/ti_sci_core.c
create mode 100644 drivers/firmware/ti/ti_sci_device.c
create mode 100644 drivers/firmware/ti/ti_sci_pm.c
create mode 100644 drivers/firmware/ti/ti_sci_proc.c
create mode 100644 drivers/firmware/ti/ti_sci_rm.c
delete mode 100644 drivers/firmware/ti_sci.cSignature · 1 line
2.34.1
PATCH v3 1/22 firmware: ti_sci: Move error message handling into ti_sci_get_one_xfer()
From: Andrew Davis <[email protected]>
This allows for more exact error message than just "Message alloc failed", and also removes the redundant message printing code from each call site.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 278 +++++++++++++++----------------------- 1 file changed, 106 insertions(+), 172 deletions(-)
drivers/firmware/ti_sci.c +106 -172
@@ -315,6 +315,7 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, size_t rx_message_size) {struct ti_sci_xfers_info *minfo = &info->minfo; +struct device *dev = info->dev;struct ti_sci_xfer *xfer;struct ti_sci_msg_hdr *hdr;unsigned long flags;
@@ -326,8 +327,11 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info,/* Ensure we have sane transfer sizes */ if (rx_message_size > info->desc->max_msg_size || tx_message_size > info->desc->max_msg_size || - rx_message_size <sizeof (*hdr) || tx_message_size <sizeof (*hdr)) + rx_message_size <sizeof (*hdr) || tx_message_size <sizeof (*hdr)) { +dev_err (dev,"TI-SCI message size out of range (caller: %pS)\n" , + (void *)_RET_IP_);return ERR_PTR (-ERANGE ); + }/* * Ensure we have only controlled number of pending messages.
@@ -336,8 +340,11 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info,*/ timeout =msecs_to_jiffies (info->desc->max_rx_timeout_ms) *5 ; ret =down_timeout (&minfo->sem_xfer_count, timeout); -if (ret <0 ) +if (ret <0 ) { +dev_err (dev,"TI-SCI timeout waiting for transfer semaphore (caller: %pS)\n" , + (void *)_RET_IP_);return ERR_PTR (ret); + }/* Keep the locked section as small as possible */ spin_lock_irqsave (&minfo->xfer_lock, flags);
@@ -481,11 +488,8 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), sizeof(*rev_info)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf;
@@ -549,11 +553,9 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; req->id = id; req->state = state;
@@ -610,11 +612,9 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; req->id = id;
@@ -912,11 +912,9 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; req->id = id; req->resets = reset_state;
@@ -987,11 +985,9 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1055,11 +1051,9 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1286,11 +1280,9 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1354,11 +1346,9 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1424,11 +1414,9 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1503,11 +1491,9 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1579,11 +1565,9 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1644,11 +1628,9 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; req->dev_id = dev_id;if (clk_id <255 ) {
@@ -1711,11 +1693,8 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , msg_flags,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf; req->mode = mode;
@@ -1775,11 +1754,8 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), sizeof(*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1832,11 +1808,9 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_io_isolation *)xfer->xfer_buf; req->state = state;
@@ -1890,11 +1864,8 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), sizeof(*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1954,11 +1925,9 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_lpm_set_device_constraint *)xfer->xfer_buf; req->id = id; req->state = state;
@@ -2011,11 +1980,9 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_lpm_set_latency_constraint *)xfer->xfer_buf; req->latency = latency; req->state = state;
@@ -2056,11 +2023,9 @@ static int ti_sci_cmd_lpm_abort(struct device *dev) xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_ABORT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_do_xfer (info, xfer);
@@ -2100,11 +2065,9 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SYS_RESET ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; ret =ti_sci_do_xfer (info, xfer);
@@ -2162,11 +2125,8 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; req->secondary_host = s_host;
@@ -2283,11 +2243,9 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; req->valid_params = valid_params; req->src_id = src_id;
@@ -2607,11 +2565,9 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_RING_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"RM_RA:Message config failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; req->valid_params = params->valid_params; req->nav_id = params->nav_id;
@@ -2671,11 +2627,9 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"RM_PSIL:Message reconfig failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; req->nav_id = nav_id; req->src_thread = src_thread;
@@ -2727,11 +2681,9 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"RM_PSIL:Message reconfig failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; req->nav_id = nav_id; req->src_thread = src_thread;
@@ -2782,11 +2734,9 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message TX_CH_CFG alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; req->valid_params = params->valid_params; req->nav_id = params->nav_id;
@@ -2854,11 +2804,9 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message RX_CH_CFG alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; req->valid_params = params->valid_params; req->nav_id = params->nav_id;
@@ -2923,11 +2871,9 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"RX_FL_CFG: Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; req->valid_params = params->valid_params; req->nav_id = params->nav_id;
@@ -2995,11 +2941,9 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_REQUEST ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; req->processor_id = proc_id;
@@ -3047,11 +2991,9 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_RELEASE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; req->processor_id = proc_id;
@@ -3102,11 +3044,9 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_HANDOVER ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; req->processor_id = proc_id; req->host_id = host_id;
@@ -3161,11 +3101,9 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CONFIG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; req->processor_id = proc_id; req->bootvector_low = bootvector &TI_SCI_ADDR_LOW_MASK ;
@@ -3222,11 +3160,9 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CTRL ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; req->processor_id = proc_id; req->control_flags_set = control_flags_set;
@@ -3281,11 +3217,9 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_STATUS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp)); -if (IS_ERR (xfer)) { - ret =PTR_ERR (xfer); -dev_err (dev,"Message alloc failed(%d)\n" , ret); -return ret; - } +if (IS_ERR (xfer)) +return PTR_ERR (xfer); + req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; req->processor_id = proc_id;
Signature · 1 line
2.34.1
PATCH v3 2/22 firmware: ti_sci: Move error message handling into ti_sci_do_xfer()
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
This allows for more exact error message than just "Mbox send fail", which might not even be the correct error in cases when the send works but we timeout waiting for the response. This also removes redundant message printing code from each call site.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 187 ++++++++------------------------------ 1 file changed, 37 insertions(+), 150 deletions(-)
drivers/firmware/ti_sci.c +37 -150
@@ -431,8 +431,10 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,bool done_state = true; ret =mbox_send_message (info->chan_tx, &xfer->tx_message); -if (ret <0 ) +if (ret <0 ) { +dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, (void *)_RET_IP_);return ret; + } ret =0 ;
@@ -477,7 +479,6 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,*/ static int ti_sci_cmd_get_revision (struct ti_sci_info *info) { -struct device *dev = info->dev;struct ti_sci_handle *handle = &info->handle;struct ti_sci_version_info *ver = &handle->version;struct ti_sci_msg_resp_version *rev_info;
@@ -494,10 +495,8 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info) rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } ver->abi_major = rev_info->abi_major; ver->abi_minor = rev_info->abi_minor;
@@ -539,7 +538,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_device_state *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -548,7 +546,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_DEVICE_STATE, flags | TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -561,10 +558,8 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -595,7 +590,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_device_state *req;struct ti_sci_msg_resp_get_device_state *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -607,7 +601,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_DEVICE_STATE, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -619,10 +612,8 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, req->id = id; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf;if (!ti_sci_is_response_ack (resp)) {
@@ -898,7 +889,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_device_resets *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -907,7 +897,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_DEVICE_RESETS, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -920,10 +909,8 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, req->resets = reset_state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -971,7 +958,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_clock_state *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -980,7 +966,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_CLOCK_STATE, flags | TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -999,10 +984,8 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, req->request_state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1034,7 +1017,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_clock_state *req;struct ti_sci_msg_resp_get_clock_state *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1046,7 +1028,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_CLOCK_STATE, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1064,10 +1045,8 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, } ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf;
@@ -1266,7 +1245,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_clock_parent *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1275,7 +1253,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_CLOCK_PARENT, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1299,10 +1276,8 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, } ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1332,7 +1307,6 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_clock_parent *req;struct ti_sci_msg_resp_get_clock_parent *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1341,7 +1315,6 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_CLOCK_PARENT, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1359,10 +1332,8 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, } ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf;
@@ -1400,7 +1371,6 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_clock_num_parents *req;struct ti_sci_msg_resp_get_clock_num_parents *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1409,7 +1379,6 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1427,10 +1396,8 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, } ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf;
@@ -1477,7 +1444,6 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle,struct ti_sci_msg_req_query_clock_freq *req;struct ti_sci_msg_resp_query_clock_freq *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1486,7 +1452,6 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_QUERY_CLOCK_FREQ, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1507,10 +1472,8 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, req->max_freq_hz = max_freq; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf;
@@ -1551,7 +1514,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_clock_freq *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1560,7 +1522,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_CLOCK_FREQ, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1581,10 +1542,8 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, req->max_freq_hz = max_freq; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1614,7 +1573,6 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_clock_freq *req;struct ti_sci_msg_resp_get_clock_freq *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -1623,7 +1581,6 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_CLOCK_FREQ, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -1641,10 +1598,8 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, } ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf;
@@ -1703,10 +1658,8 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, req->debug_flags = debug_flags; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - }if (msg_flags ==TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ) { resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1758,10 +1711,8 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf;
@@ -1815,10 +1766,8 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1868,10 +1817,8 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle,return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_lpm_wake_reason *)xfer->xfer_buf;
@@ -1933,10 +1880,8 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -1988,10 +1933,8 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -2029,10 +1972,8 @@ static int ti_sci_cmd_lpm_abort(struct device *dev) req = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -2051,7 +1992,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)struct ti_sci_msg_req_reboot *req;struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -2060,7 +2000,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SYS_RESET, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2071,10 +2010,8 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -2111,7 +2048,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_resource_range *req;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -2120,7 +2056,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_RESOURCE_RANGE, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2134,10 +2069,8 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, req->subtype = subtype &MSG_RM_RESOURCE_SUBTYPE_MASK ; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf;
@@ -2230,7 +2163,6 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -2239,7 +2171,6 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer =ti_sci_get_one_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (*req),sizeof (*resp));
@@ -2259,10 +2190,8 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, req->secondary_host = s_host; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
@@ -2582,10 +2511,8 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, req->asel = params->asel; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"RM_RA:Mbox config send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2613,7 +2540,6 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -2622,7 +2548,6 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_PSIL_PAIR, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2636,10 +2561,8 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, req->dst_thread = dst_thread; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"RM_PSIL:Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2667,7 +2590,6 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR (handle))
@@ -2676,7 +2598,6 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_PSIL_UNPAIR, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2690,10 +2611,8 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, req->dst_thread = dst_thread; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"RM_PSIL:Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2760,10 +2679,8 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, req->extended_ch_type = params->extended_ch_type; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send TX_CH_CFG fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2827,10 +2744,8 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, req->rx_burst_size = params->rx_burst_size; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send RX_CH_CFG fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2859,14 +2774,12 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR_OR_NULL (handle))return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TISCI_MSG_RM_UDMAP_FLOW_CFG, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2899,10 +2812,8 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, req->rx_ps_location = params->rx_ps_location; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"RX_FL_CFG: Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ;
@@ -2927,7 +2838,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -2936,7 +2846,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PROC_REQUEST, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2948,10 +2857,8 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, req->processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
@@ -2977,7 +2884,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -2986,7 +2892,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PROC_RELEASE, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2998,10 +2903,8 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, req->processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
@@ -3030,7 +2933,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -3039,7 +2941,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PROC_HANDOVER, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -3052,10 +2953,8 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, req->host_id = host_id; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
@@ -3087,7 +2986,6 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -3096,7 +2994,6 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_CONFIG, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -3113,10 +3010,8 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, req->config_flags_clear = config_flags_clear; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
@@ -3146,7 +3041,6 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -3155,7 +3049,6 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_CTRL, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -3169,10 +3062,8 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, req->control_flags_clear = control_flags_clear; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
@@ -3203,7 +3094,6 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle,struct ti_sci_msg_req_get_status *req;struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct device *dev;int ret =0 ;if (!handle)
@@ -3212,7 +3102,6 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle,return PTR_ERR (handle); info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_STATUS, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -3224,10 +3113,8 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, req->processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer); -if (ret) { -dev_err (dev,"Mbox send fail %d\n" , ret); +if (ret) goto fail; - } resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf;
Signature · 1 line
2.34.1
PATCH v3 3/22 firmware: ti_sci: Move check for ACK into ti_sci_do_xfer()
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Move ti_sci_is_response_ack() function up so it can be used in ti_sci_do_xfer(). As we know if a response is expected we can check the response in one spot removing the need to check that at every call site.
Note: This changes the error code returned on a NACK for the ring config, PSI-L pair/unpair, and UDMAP TX/RX channel and RX flow config helpers from -EINVAL to -ENODEV, making them consistent with all other TI-SCI message helpers. The users of these helpers (k3-ringacc and k3-udma) only check for a non-zero return and propagate it, so no functional change.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 239 ++++++++++---------------------------- 1 file changed, 60 insertions(+), 179 deletions(-)
drivers/firmware/ti_sci.c +60 -179
@@ -410,14 +410,28 @@ static void ti_sci_put_one_xfer(struct ti_sci_xfers_info *minfo,up (&minfo->sem_xfer_count); } +/** +* ti_sci_is_response_ack() - Generic ACK/NACK message checkup +* @r: pointer to response buffer +* +* Return: true if the response was an ACK, else returns false. +*/ +static inline bool ti_sci_is_response_ack (void *r) +{ +struct ti_sci_msg_hdr *hdr = r; + +return hdr->flags &TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; +} +/** * ti_sci_do_xfer() - Do one transfer * @info: Pointer to SCI entity information * @xfer: Transfer to initiate and wait for response * -* Return: -ETIMEDOUT in case of no response, if transmit error, -* return corresponding error, else if all goes well, -* return 0. +* Return: -ETIMEDOUT in case of no response, or +* -ENODEV in case of a NACK response, or +* corresponding error if transmit fails, or +* return 0, if all goes well. */ static inline int ti_sci_do_xfer (struct ti_sci_info *info,struct ti_sci_xfer *xfer)
@@ -466,6 +480,18 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,*/ mbox_client_txdone (info->chan_tx, ret); +/* +* If we expect a response and are not otherwise already in an error +* state, then ensure that the response is an ACK +*/ +if (response_expected && ret ==0 ) { +if (!ti_sci_is_response_ack (xfer->xfer_buf)) { +dev_warn (dev,"Message response not acknowledged (caller: %pS)\n" , + (void *)_RET_IP_); + ret = -ENODEV ; + } + } +return ret; }
@@ -509,19 +535,6 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)return ret; } -/** -* ti_sci_is_response_ack() - Generic ACK/NACK message checkup -* @r: pointer to response buffer -* -* Return: true if the response was an ACK, else returns false. -*/ -static inline bool ti_sci_is_response_ack (void *r) -{ -struct ti_sci_msg_hdr *hdr = r; - -return hdr->flags &TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; -} -/** * ti_sci_set_device_state() - Set device state helper * @handle: pointer to TI SCI handle
@@ -561,10 +574,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -616,10 +625,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, goto fail; resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - goto fail; - }if (clcnt) *clcnt = resp->context_loss_count;
@@ -912,10 +917,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -987,10 +988,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1050,11 +1047,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - goto fail; - } -if (programmed_state) *programmed_state = resp->programmed_state;if (current_state)
@@ -1279,10 +1271,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1337,14 +1325,10 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - }else { -if (resp->parent_id <255 ) - *parent_id = resp->parent_id; -else - *parent_id = resp->parent_id_32; - } +if (resp->parent_id <255 ) + *parent_id = resp->parent_id; +else + *parent_id = resp->parent_id_32; fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1401,14 +1385,10 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - }else { -if (resp->num_parents <255 ) - *num_parents = resp->num_parents; -else - *num_parents = resp->num_parents_32; - } +if (resp->num_parents <255 ) + *num_parents = resp->num_parents; +else + *num_parents = resp->num_parents_32; fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1477,10 +1457,7 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) - ret = -ENODEV ; -else - *match_freq = resp->freq_hz; + *match_freq = resp->freq_hz; fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1545,10 +1522,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1603,10 +1576,7 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) - ret = -ENODEV ; -else - *freq = resp->freq_hz; + *freq = resp->freq_hz; fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -1658,15 +1628,9 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, req->debug_flags = debug_flags; ret =ti_sci_do_xfer (info, xfer); -if (ret) +if (ret) { +dev_err (dev,"Failed to prepare sleep\n" ); goto fail; - -if (msg_flags ==TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ) { - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { -dev_err (dev,"Failed to prepare sleep\n" ); - ret = -ENODEV ; - } } fail:
@@ -1711,17 +1675,13 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer); -if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) { +if (ret) {dev_err (dev,"Failed to get capabilities\n" ); - ret = -ENODEV ; goto fail; } + resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; +if (fw_caps) *fw_caps = resp->fw_caps;
@@ -1766,14 +1726,9 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) - goto fail; - - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) { +if (ret) {dev_err (dev,"Failed to set IO isolation\n" ); - ret = -ENODEV ; + goto fail; } fail:
@@ -1817,17 +1772,13 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle,return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer); -if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_lpm_wake_reason *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) { +if (ret) {dev_err (dev,"Failed to get wake reason\n" ); - ret = -ENODEV ; goto fail; } + resp = (struct ti_sci_msg_resp_lpm_wake_reason *)xfer->xfer_buf; +if (source) *source = resp->wake_source;if (timestamp)
@@ -1880,14 +1831,9 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) - goto fail; - - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) { +if (ret) {dev_err (dev,"Failed to set device constraint\n" ); - ret = -ENODEV ; + goto fail; } fail:
@@ -1933,14 +1879,9 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, req->state = state; ret =ti_sci_do_xfer (info, xfer); -if (ret) - goto fail; - - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) { +if (ret) {dev_err (dev,"Failed to set device constraint\n" ); - ret = -ENODEV ; + goto fail; } fail:
@@ -1975,11 +1916,6 @@ static int ti_sci_cmd_lpm_abort(struct device *dev)if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) - ret = -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2013,13 +1949,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - -if (!ti_sci_is_response_ack (resp)) - ret = -ENODEV ; -else - ret =0 ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2074,9 +2003,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - }else if (!resp->range_num && !resp->range_num_sec) { +if (!resp->range_num && !resp->range_num_sec) {/* Neither of the two resource range is valid */ ret = -ENODEV ; }else {
@@ -2193,10 +2120,6 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2514,9 +2437,6 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);dev_dbg (dev,"RM_RA:config ring %u ret:%d\n" , params->index, ret);
@@ -2564,9 +2484,6 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2614,9 +2531,6 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2682,9 +2596,6 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);dev_dbg (dev,"TX_CH_CFG: chn %u ret:%u\n" , params->index, ret);
@@ -2747,9 +2658,6 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);dev_dbg (dev,"RX_CH_CFG: chn %u ret:%d\n" , params->index, ret);
@@ -2815,9 +2723,6 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_is_response_ack (resp) ?0 : -EINVAL ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);dev_dbg (info->dev,"RX_FL_CFG: %u ret:%d\n" , params->flow_index, ret);
@@ -2860,10 +2765,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2906,10 +2807,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -2956,10 +2853,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -3013,10 +2906,6 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -3065,10 +2954,6 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle,if (ret) goto fail; - resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; - - ret =ti_sci_is_response_ack (resp) ?0 : -ENODEV ; - fail:ti_sci_put_one_xfer (&info->minfo, xfer);
@@ -3118,16 +3003,12 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; -if (!ti_sci_is_response_ack (resp)) { - ret = -ENODEV ; - }else { - *bv = (resp->bootvector_low &TI_SCI_ADDR_LOW_MASK ) | - (((u64 )resp->bootvector_high <<TI_SCI_ADDR_HIGH_SHIFT ) & -TI_SCI_ADDR_HIGH_MASK ); - *cfg_flags = resp->config_flags; - *ctrl_flags = resp->control_flags; - *sts_flags = resp->status_flags; - } + *bv = (resp->bootvector_low &TI_SCI_ADDR_LOW_MASK ) | + (((u64 )resp->bootvector_high <<TI_SCI_ADDR_HIGH_SHIFT ) & +TI_SCI_ADDR_HIGH_MASK ); + *cfg_flags = resp->config_flags; + *ctrl_flags = resp->control_flags; + *sts_flags = resp->status_flags; fail:ti_sci_put_one_xfer (&info->minfo, xfer);
Signature · 1 line
2.34.1
PATCH v3 4/22 firmware: ti_sci: Remove out of place RM debug messages
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
These debug messages only print out the index param that was passed in from the calling drivers. This does not add any additional info that wouldn't work better in the calling drivers themselves (k3-ringacc.c and k3-udma.c). These also make later cleanup around device fetching more difficult, remove these debug prints.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/firmware/ti_sci.c +4 -10
@@ -2405,14 +2405,12 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR_OR_NULL (handle))return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_RING_CFG, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2439,7 +2437,7 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, fail:ti_sci_put_one_xfer (&info->minfo, xfer); -dev_dbg (dev,"RM_RA:config ring %u ret:%d\n" , params->index, ret); +return ret; }
@@ -2555,14 +2553,12 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR_OR_NULL (handle))return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TISCI_MSG_RM_UDMAP_TX_CH_CFG, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2598,7 +2594,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, fail:ti_sci_put_one_xfer (&info->minfo, xfer); -dev_dbg (dev,"TX_CH_CFG: chn %u ret:%u\n" , params->index, ret); +return ret; }
@@ -2620,14 +2616,12 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle,struct ti_sci_msg_hdr *resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info; -struct device *dev;int ret =0 ;if (IS_ERR_OR_NULL (handle))return -EINVAL ; info =handle_to_ti_sci_info (handle); - dev = info->dev; xfer = ti_sci_get_one_xfer(info, TISCI_MSG_RM_UDMAP_RX_CH_CFG, TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
@@ -2660,7 +2654,7 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, fail:ti_sci_put_one_xfer (&info->minfo, xfer); -dev_dbg (dev,"RX_CH_CFG: chn %u ret:%d\n" , params->index, ret); +return ret; }
@@ -2725,7 +2719,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, fail:ti_sci_put_one_xfer (&info->minfo, xfer); -dev_dbg (info->dev,"RX_FL_CFG: %u ret:%d\n" , params->flow_index, ret); +return ret; }
Signature · 1 line
2.34.1
PATCH v3 5/22 firmware: ti_sci: Name response variable resp for consistency
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
All other TI-SCI call functions call the response variable "resp" except ti_sci_cmd_get_revision(), fix this here. Also get assign the response variable pointer after the transfer, again for consistency. No functional change but does make later cleanups easier.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/firmware/ti_sci.c +8 -8
@@ -507,27 +507,27 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info) {struct ti_sci_handle *handle = &info->handle;struct ti_sci_version_info *ver = &handle->version; -struct ti_sci_msg_resp_version *rev_info; +struct ti_sci_msg_resp_version *resp;struct ti_sci_xfer *xfer;int ret; xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_VERSION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), -sizeof (*rev_info)); +sizeof (*resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; - ret =ti_sci_do_xfer (info, xfer);if (ret) goto fail; - ver->abi_major = rev_info->abi_major; - ver->abi_minor = rev_info->abi_minor; - ver->firmware_revision = rev_info->firmware_revision; -strscpy (ver->firmware_description, rev_info->firmware_description, + resp = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; + + ver->abi_major = resp->abi_major; + ver->abi_minor = resp->abi_minor; + ver->firmware_revision = resp->firmware_revision; +strscpy (ver->firmware_description, resp->firmware_description,sizeof (ver->firmware_description)); fail:
Signature · 1 line
2.34.1
PATCH v3 6/22 firmware: ti_sci: Handle xfer cleanup inside ti_sci_do_xfer()
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Pass the response struct to ti_sci_do_xfer() and have it fill it when a response is received. This makes the xfer struct no longer needed after this point and so it can be cleaned up after the transfer. This prevents accidentally not freeing the xfer by the caller and after a follow up patch makes allocation and free of xfers handled entirely inside the ti_sci_do_xfer() function.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 471 +++++++++++++++----------------------- 1 file changed, 179 insertions(+), 292 deletions(-)
drivers/firmware/ti_sci.c +179 -292
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(ti_sci_list_mutex);/** * struct ti_sci_xfer - Structure representing a message flow * @tx_message: Transmit message +* @rx_buf: Pointer to store received message * @rx_len: Receive message length * @xfer_buf: Preallocated buffer to store receive message * Since we work with request-ACK protocol, we can
@@ -52,6 +53,7 @@ static DEFINE_MUTEX(ti_sci_list_mutex);*/ struct ti_sci_xfer {struct ti_msgmgr_message tx_message; +void *rx_buf;u8 rx_len;u8 *xfer_buf;struct completion done;
@@ -298,6 +300,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)* @msg_type: Message type * @msg_flags: Flag to set for the message * @tx_message_size: transmit message size +* @rx_message: receive message storage location * @rx_message_size: receive message size * * Helper function which is used by various command functions that are
@@ -312,7 +315,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)static struct ti_sci_xfer *ti_sci_get_one_xfer (struct ti_sci_info *info,u16 msg_type,u32 msg_flags,size_t tx_message_size, -size_t rx_message_size) +void *rx_message,size_t rx_message_size) {struct ti_sci_xfers_info *minfo = &info->minfo;struct device *dev = info->dev;
@@ -368,6 +371,7 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, xfer->tx_message.len = tx_message_size; xfer->tx_message.chan_rx = info->chan_rx; xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; + xfer->rx_buf = rx_message; xfer->rx_len = (u8 )rx_message_size;reinit_completion (&xfer->done);
@@ -447,7 +451,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info, ret =mbox_send_message (info->chan_tx, &xfer->tx_message);if (ret <0 ) {dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, (void *)_RET_IP_); -return ret; + goto fail; } ret =0 ;
@@ -489,9 +493,14 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,dev_warn (dev,"Message response not acknowledged (caller: %pS)\n" , (void *)_RET_IP_); ret = -ENODEV ; + }else { +memcpy (xfer->rx_buf, xfer->xfer_buf, xfer->rx_len); } } +fail: +ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; }
@@ -507,32 +516,28 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info) {struct ti_sci_handle *handle = &info->handle;struct ti_sci_version_info *ver = &handle->version; -struct ti_sci_msg_resp_version *resp; +struct ti_sci_msg_resp_version resp;struct ti_sci_xfer *xfer;int ret; xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_VERSION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), -sizeof (*resp)); + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; +return ret; - ver->abi_major = resp->abi_major; - ver->abi_minor = resp->abi_minor; - ver->firmware_revision = resp->firmware_revision; -strscpy (ver->firmware_description, resp->firmware_description, + ver->abi_major = resp.abi_major; + ver->abi_minor = resp.abi_minor; + ver->firmware_revision = resp.firmware_revision; +strscpy (ver->firmware_description, resp.firmware_description,sizeof (ver->firmware_description)); -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); -return ret; +return 0 ; }/**
@@ -549,7 +554,7 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_device_state *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -562,7 +567,7 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -572,12 +577,9 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -597,7 +599,7 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_get_device_state *req; -struct ti_sci_msg_resp_get_device_state *resp; +struct ti_sci_msg_resp_get_device_state resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -613,7 +615,7 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -622,22 +624,18 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; +return ret;if (clcnt) - *clcnt = resp->context_loss_count; + *clcnt = resp.context_loss_count;if (resets) - *resets = resp->resets; + *resets = resp.resets;if (p_state) - *p_state = resp->programmed_state; + *p_state = resp.programmed_state;if (c_state) - *c_state = resp->current_state; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); + *c_state = resp.current_state; -return ret; +return 0 ; }/**
@@ -892,7 +890,7 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_device_resets *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -905,7 +903,7 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -915,12 +913,9 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -957,7 +952,7 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_state *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -970,7 +965,7 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -986,12 +981,9 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -1012,7 +1004,7 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_state *req; -struct ti_sci_msg_resp_get_clock_state *resp; +struct ti_sci_msg_resp_get_clock_state resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1028,7 +1020,7 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1043,19 +1035,14 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; +return ret;if (programmed_state) - *programmed_state = resp->programmed_state; + *programmed_state = resp.programmed_state;if (current_state) - *current_state = resp->current_state; + *current_state = resp.current_state; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1235,7 +1222,7 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_parent *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1248,7 +1235,7 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1269,12 +1256,9 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -1293,7 +1277,7 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_parent *req; -struct ti_sci_msg_resp_get_clock_parent *resp; +struct ti_sci_msg_resp_get_clock_parent resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1306,7 +1290,7 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1321,19 +1305,14 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; +return ret; -if (resp->parent_id <255 ) - *parent_id = resp->parent_id; +if (resp.parent_id <255 ) + *parent_id = resp.parent_id;else - *parent_id = resp->parent_id_32; + *parent_id = resp.parent_id_32; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1353,7 +1332,7 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_num_parents *req; -struct ti_sci_msg_resp_get_clock_num_parents *resp; +struct ti_sci_msg_resp_get_clock_num_parents resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1366,7 +1345,7 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1381,19 +1360,14 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; +return ret; -if (resp->num_parents <255 ) - *num_parents = resp->num_parents; +if (resp.num_parents <255 ) + *num_parents = resp.num_parents;else - *num_parents = resp->num_parents_32; + *num_parents = resp.num_parents_32; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1422,7 +1396,7 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_query_clock_freq *req; -struct ti_sci_msg_resp_query_clock_freq *resp; +struct ti_sci_msg_resp_query_clock_freq resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1435,7 +1409,7 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1453,16 +1427,11 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; - - *match_freq = resp->freq_hz; +return ret; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); + *match_freq = resp.freq_hz; -return ret; +return 0 ; }/**
@@ -1489,7 +1458,7 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_freq *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1502,7 +1471,7 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1520,12 +1489,9 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -1544,7 +1510,7 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_freq *req; -struct ti_sci_msg_resp_get_clock_freq *resp; +struct ti_sci_msg_resp_get_clock_freq resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1557,7 +1523,7 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1572,16 +1538,11 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; - - *freq = resp->freq_hz; +return ret; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); + *freq = resp.freq_hz; -return ret; +return 0 ; }/**
@@ -1602,7 +1563,7 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ;struct ti_sci_info *info;struct ti_sci_msg_req_prepare_sleep *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1617,7 +1578,7 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , msg_flags, -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1630,13 +1591,10 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to prepare sleep\n" ); - goto fail; +return ret; } -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1655,7 +1613,7 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct ti_sci_msg_resp_query_fw_caps *resp; +struct ti_sci_msg_resp_query_fw_caps resp;struct device *dev;int ret =0 ;
@@ -1670,25 +1628,20 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_FW_CAPS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), -sizeof (*resp)); + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to get capabilities\n" ); - goto fail; +return ret; } - resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; -if (fw_caps) - *fw_caps = resp->fw_caps; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); + *fw_caps = resp.fw_caps; -return ret; +return 0 ; }/**
@@ -1703,7 +1656,7 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_set_io_isolation *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1718,7 +1671,7 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1728,13 +1681,10 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to set IO isolation\n" ); - goto fail; +return ret; } -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1752,7 +1702,7 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_xfer *xfer; -struct ti_sci_msg_resp_lpm_wake_reason *resp; +struct ti_sci_msg_resp_lpm_wake_reason resp;struct device *dev;int ret =0 ;
@@ -1767,31 +1717,26 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_WAKE_REASON ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ,sizeof (struct ti_sci_msg_hdr ), -sizeof (*resp)); + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to get wake reason\n" ); - goto fail; +return ret; } - resp = (struct ti_sci_msg_resp_lpm_wake_reason *)xfer->xfer_buf; -if (source) - *source = resp->wake_source; + *source = resp.wake_source;if (timestamp) - *timestamp = resp->wake_timestamp; + *timestamp = resp.wake_timestamp;if (pin) - *pin = resp->wake_pin; + *pin = resp.wake_pin;if (mode) - *mode = resp->mode; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); + *mode = resp.mode; -return ret; +return 0 ; }/**
@@ -1807,7 +1752,7 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_device_constraint *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1822,7 +1767,7 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1833,13 +1778,10 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to set device constraint\n" ); - goto fail; +return ret; } -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1855,7 +1797,7 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_latency_constraint *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1870,7 +1812,7 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1881,13 +1823,10 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) {dev_err (dev,"Failed to set device constraint\n" ); - goto fail; +return ret; } -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/**
@@ -1900,13 +1839,13 @@ static int ti_sci_cmd_lpm_abort(struct device *dev) {struct ti_sci_info *info =dev_get_drvdata (dev);struct ti_sci_msg_hdr *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ; xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_ABORT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1914,19 +1853,16 @@ static int ti_sci_cmd_lpm_abort(struct device *dev) ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }static int ti_sci_cmd_core_reboot (const struct ti_sci_handle *handle) {struct ti_sci_info *info;struct ti_sci_msg_req_reboot *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1939,7 +1875,7 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SYS_RESET ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1947,12 +1883,9 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -1973,7 +1906,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, u32 dev_id, u8 subtype, u8 s_host, struct ti_sci_resource_desc *desc) { - struct ti_sci_msg_resp_get_resource_range *resp; + struct ti_sci_msg_resp_get_resource_range resp;struct ti_sci_msg_req_get_resource_range *req;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -1988,7 +1921,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1999,23 +1932,18 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; +return ret; -if (!resp->range_num && !resp->range_num_sec) { +if (!resp.range_num && !resp.range_num_sec) {/* Neither of the two resource range is valid */ ret = -ENODEV ; }else { - desc->start = resp->range_start; - desc->num = resp->range_num; - desc->start_sec = resp->range_start_sec; - desc->num_sec = resp->range_num_sec; + desc->start = resp.range_start; + desc->num = resp.range_num; + desc->start_sec = resp.range_start_sec; + desc->num_sec = resp.range_num_sec; } -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); -return ret; }
@@ -2087,7 +2015,7 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, u16 type) {struct ti_sci_msg_req_manage_irq *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2100,7 +2028,7 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); xfer =ti_sci_get_one_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2118,12 +2046,9 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2402,7 +2327,7 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, const struct ti_sci_msg_rm_ring_cfg *params) {struct ti_sci_msg_rm_ring_cfg_req *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2414,7 +2339,7 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_RING_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2433,12 +2358,9 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2455,7 +2377,7 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, u32 nav_id, u32 src_thread, u32 dst_thread) { struct ti_sci_msg_psil_pair *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2469,7 +2391,7 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2480,12 +2402,9 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2502,7 +2421,7 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, u32 nav_id, u32 src_thread, u32 dst_thread) { struct ti_sci_msg_psil_unpair *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2516,7 +2435,7 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2527,12 +2446,9 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2550,7 +2466,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, const struct ti_sci_msg_rm_udmap_tx_ch_cfg *params) {struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2562,7 +2478,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2590,12 +2506,9 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2613,7 +2526,7 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, const struct ti_sci_msg_rm_udmap_rx_ch_cfg *params) {struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2625,7 +2538,7 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2650,12 +2563,9 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2673,7 +2583,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, const struct ti_sci_msg_rm_udmap_flow_cfg *params) {struct ti_sci_msg_rm_udmap_flow_cfg_req *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2685,7 +2595,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2715,12 +2625,9 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2734,7 +2641,7 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, u8 proc_id) {struct ti_sci_msg_req_proc_request *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2748,7 +2655,7 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_REQUEST ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2757,12 +2664,9 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2776,7 +2680,7 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, u8 proc_id) {struct ti_sci_msg_req_proc_release *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2790,7 +2694,7 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_RELEASE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2799,12 +2703,9 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2821,7 +2722,7 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, u8 proc_id, u8 host_id) {struct ti_sci_msg_req_proc_handover *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2835,7 +2736,7 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_HANDOVER ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2845,12 +2746,9 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2870,7 +2768,7 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, u32 config_flags_clear) {struct ti_sci_msg_req_set_config *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2884,7 +2782,7 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CONFIG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2898,12 +2796,9 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2921,7 +2816,7 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, u32 control_flags_clear) {struct ti_sci_msg_req_set_ctrl *req; -struct ti_sci_msg_hdr *resp; +struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2935,7 +2830,7 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CTRL ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2946,12 +2841,9 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); +return ret; -return ret; +return 0 ; }/**
@@ -2969,7 +2861,7 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, u8 proc_id, u64 *bv, u32 *cfg_flags, u32 *ctrl_flags, u32 *sts_flags) { - struct ti_sci_msg_resp_get_status *resp; + struct ti_sci_msg_resp_get_status resp;struct ti_sci_msg_req_get_status *req;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2984,7 +2876,7 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_STATUS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req),sizeof (*resp)); +sizeof (*req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -2993,21 +2885,16 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, ret =ti_sci_do_xfer (info, xfer);if (ret) - goto fail; - - resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; +return ret; - *bv = (resp->bootvector_low &TI_SCI_ADDR_LOW_MASK ) | - (((u64 )resp->bootvector_high <<TI_SCI_ADDR_HIGH_SHIFT ) & + *bv = (resp.bootvector_low &TI_SCI_ADDR_LOW_MASK ) | + (((u64 )resp.bootvector_high <<TI_SCI_ADDR_HIGH_SHIFT ) &TI_SCI_ADDR_HIGH_MASK ); - *cfg_flags = resp->config_flags; - *ctrl_flags = resp->control_flags; - *sts_flags = resp->status_flags; + *cfg_flags = resp.config_flags; + *ctrl_flags = resp.control_flags; + *sts_flags = resp.status_flags; -fail: -ti_sci_put_one_xfer (&info->minfo, xfer); - -return ret; +return 0 ; }/*
Signature · 1 line
2.34.1
PATCH v3 7/22 firmware: ti_sci: Pass request struct into ti_sci_do_xfer()
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
In the same way the previous patch moved the response handling into ti_sci_do_xfer(), we can do the same for the request data. While this does add a memcpy() of a few additional bytes, that overhead is removed in later patches, and the code cleanup it unlocks justifies it.
Note: Previously, callers built their requests directly in a buffer handed out by ti_sci_get_one_xfer() from a pool that is allocated once at probe time and reused for every message. This buffer is never cleared between messages, so any request field that a caller did not explicitly assign held leftover bytes from an earlier TI SCI message.
With this patch, callers build their requests in on-stack structs, so such fields now hold uninitialized stack contents instead. The only difference is where the leftover bytes come from (stack rather than a reused message buffer); whether they are zero or not is unchanged. Hence this patch does not change the data seen by the system firmware in any meaningful way, and no memset() is added on the local request structs.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 523 +++++++++++++++++++------------------- 1 file changed, 266 insertions(+), 257 deletions(-)
drivers/firmware/ti_sci.c +266 -257
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(ti_sci_list_mutex);/** * struct ti_sci_xfer - Structure representing a message flow * @tx_message: Transmit message +* @tx_buf: Pointer to the message to send * @rx_buf: Pointer to store received message * @rx_len: Receive message length * @xfer_buf: Preallocated buffer to store receive message
@@ -53,6 +54,7 @@ static DEFINE_MUTEX(ti_sci_list_mutex);*/ struct ti_sci_xfer {struct ti_msgmgr_message tx_message; +void *tx_buf;void *rx_buf;u8 rx_len;u8 *xfer_buf;
@@ -299,6 +301,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)* @info: Pointer to SCI entity information * @msg_type: Message type * @msg_flags: Flag to set for the message +* @tx_message: transmit message storage location * @tx_message_size: transmit message size * @rx_message: receive message storage location * @rx_message_size: receive message size
@@ -314,7 +317,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)*/ static struct ti_sci_xfer *ti_sci_get_one_xfer (struct ti_sci_info *info,u16 msg_type,u32 msg_flags, -size_t tx_message_size, +void *tx_message,size_t tx_message_size,void *rx_message,size_t rx_message_size) {struct ti_sci_xfers_info *minfo = &info->minfo;
@@ -371,6 +374,7 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, xfer->tx_message.len = tx_message_size; xfer->tx_message.chan_rx = info->chan_rx; xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; + xfer->tx_buf = tx_message; xfer->rx_buf = rx_message; xfer->rx_len = (u8 )rx_message_size;
@@ -448,6 +452,10 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,struct device *dev = info->dev;bool done_state = true; +memcpy (xfer->xfer_buf +sizeof (struct ti_sci_msg_hdr ), + xfer->tx_buf +sizeof (struct ti_sci_msg_hdr ), + xfer->tx_message.len -sizeof (struct ti_sci_msg_hdr )); + ret =mbox_send_message (info->chan_tx, &xfer->tx_message);if (ret <0 ) {dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, (void *)_RET_IP_);
@@ -516,13 +524,14 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info) {struct ti_sci_handle *handle = &info->handle;struct ti_sci_version_info *ver = &handle->version; +struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_version resp;struct ti_sci_xfer *xfer;int ret; xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_VERSION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (struct ti_sci_msg_hdr ), + &req,sizeof (req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -553,7 +562,7 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, u32 id, u32 flags, u8 state) { struct ti_sci_info *info; -struct ti_sci_msg_req_set_device_state *req; +struct ti_sci_msg_req_set_device_state req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -567,13 +576,13 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; - req->id = id; - req->state = state; + req.id = id; + req.state = state; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -598,7 +607,7 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, u8 *p_state, u8 *c_state) {struct ti_sci_info *info; -struct ti_sci_msg_req_get_device_state *req; +struct ti_sci_msg_req_get_device_state req;struct ti_sci_msg_resp_get_device_state resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -615,12 +624,12 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; - req->id = id; + req.id = id; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -889,7 +898,7 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, u32 id, u32 reset_state) {struct ti_sci_info *info; -struct ti_sci_msg_req_set_device_resets *req; +struct ti_sci_msg_req_set_device_resets req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -903,13 +912,13 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; - req->id = id; - req->resets = reset_state; + req.id = id; + req.resets = reset_state; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -951,7 +960,7 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, u32 flags, u8 state) {struct ti_sci_info *info; -struct ti_sci_msg_req_set_clock_state *req; +struct ti_sci_msg_req_set_clock_state req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -965,19 +974,19 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } - req->request_state = state; + req.request_state = state; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -1003,7 +1012,7 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, u8 *programmed_state, u8 *current_state) {struct ti_sci_info *info; -struct ti_sci_msg_req_get_clock_state *req; +struct ti_sci_msg_req_get_clock_state req;struct ti_sci_msg_resp_get_clock_state resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1020,17 +1029,17 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } ret =ti_sci_do_xfer (info, xfer);
@@ -1221,7 +1230,7 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u32 parent_id) { struct ti_sci_info *info; -struct ti_sci_msg_req_set_clock_parent *req; +struct ti_sci_msg_req_set_clock_parent req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1235,23 +1244,23 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; }if (parent_id <255 ) { - req->parent_id = parent_id; + req.parent_id = parent_id; }else { - req->parent_id =255 ; - req->parent_id_32 = parent_id; + req.parent_id =255 ; + req.parent_id_32 = parent_id; } ret =ti_sci_do_xfer (info, xfer);
@@ -1276,7 +1285,7 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u32 *parent_id) { struct ti_sci_info *info; -struct ti_sci_msg_req_get_clock_parent *req; +struct ti_sci_msg_req_get_clock_parent req;struct ti_sci_msg_resp_get_clock_parent resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1290,17 +1299,17 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } ret =ti_sci_do_xfer (info, xfer);
@@ -1331,7 +1340,7 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, u32 *num_parents) {struct ti_sci_info *info; -struct ti_sci_msg_req_get_clock_num_parents *req; +struct ti_sci_msg_req_get_clock_num_parents req;struct ti_sci_msg_resp_get_clock_num_parents resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1345,17 +1354,17 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } ret =ti_sci_do_xfer (info, xfer);
@@ -1395,7 +1404,7 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, u64 *match_freq) {struct ti_sci_info *info; -struct ti_sci_msg_req_query_clock_freq *req; +struct ti_sci_msg_req_query_clock_freq req;struct ti_sci_msg_resp_query_clock_freq resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1409,21 +1418,21 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } - req->min_freq_hz = min_freq; - req->target_freq_hz = target_freq; - req->max_freq_hz = max_freq; + req.min_freq_hz = min_freq; + req.target_freq_hz = target_freq; + req.max_freq_hz = max_freq; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -1457,7 +1466,7 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, u64 target_freq, u64 max_freq) {struct ti_sci_info *info; -struct ti_sci_msg_req_set_clock_freq *req; +struct ti_sci_msg_req_set_clock_freq req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1471,21 +1480,21 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } - req->min_freq_hz = min_freq; - req->target_freq_hz = target_freq; - req->max_freq_hz = max_freq; + req.min_freq_hz = min_freq; + req.target_freq_hz = target_freq; + req.max_freq_hz = max_freq; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -1509,7 +1518,7 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u64 *freq) { struct ti_sci_info *info; -struct ti_sci_msg_req_get_clock_freq *req; +struct ti_sci_msg_req_get_clock_freq req;struct ti_sci_msg_resp_get_clock_freq resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1523,17 +1532,17 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; - req->dev_id = dev_id; + req.dev_id = dev_id;if (clk_id <255 ) { - req->clk_id = clk_id; + req.clk_id = clk_id; }else { - req->clk_id =255 ; - req->clk_id_32 = clk_id; + req.clk_id =255 ; + req.clk_id_32 = clk_id; } ret =ti_sci_do_xfer (info, xfer);
@@ -1562,7 +1571,7 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, TI_SCI_FLAG_REQ_GENERIC_NORESPONSE :TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ;struct ti_sci_info *info; -struct ti_sci_msg_req_prepare_sleep *req; +struct ti_sci_msg_req_prepare_sleep req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;
@@ -1578,15 +1587,15 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , msg_flags, -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf; - req->mode = mode; - req->ctx_lo = ctx_lo; - req->ctx_hi = ctx_hi; - req->debug_flags = debug_flags; + req.mode = mode; + req.ctx_lo = ctx_lo; + req.ctx_hi = ctx_hi; + req.debug_flags = debug_flags; ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1613,6 +1622,7 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_xfer *xfer; +struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_query_fw_caps resp;struct device *dev;int ret =0 ;
@@ -1627,7 +1637,7 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_FW_CAPS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (struct ti_sci_msg_hdr ), + &req,sizeof (req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1655,7 +1665,7 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, u8 state) {struct ti_sci_info *info; -struct ti_sci_msg_req_set_io_isolation *req; +struct ti_sci_msg_req_set_io_isolation req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;
@@ -1671,12 +1681,12 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_io_isolation *)xfer->xfer_buf; - req->state = state; + req.state = state; ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1702,6 +1712,7 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, {struct ti_sci_info *info;struct ti_sci_xfer *xfer; +struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_lpm_wake_reason resp;struct device *dev;int ret =0 ;
@@ -1716,7 +1727,7 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_WAKE_REASON ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (struct ti_sci_msg_hdr ), + &req,sizeof (req), &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer);
@@ -1751,7 +1762,7 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, u32 id, u8 state) {struct ti_sci_info *info; -struct ti_sci_msg_req_lpm_set_device_constraint *req; +struct ti_sci_msg_req_lpm_set_device_constraint req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;
@@ -1767,13 +1778,13 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_lpm_set_device_constraint *)xfer->xfer_buf; - req->id = id; - req->state = state; + req.id = id; + req.state = state; ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1796,7 +1807,7 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, u16 latency, u8 state) {struct ti_sci_info *info; -struct ti_sci_msg_req_lpm_set_latency_constraint *req; +struct ti_sci_msg_req_lpm_set_latency_constraint req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct device *dev;
@@ -1812,13 +1823,13 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_lpm_set_latency_constraint *)xfer->xfer_buf; - req->latency = latency; - req->state = state; + req.latency = latency; + req.state = state; ret =ti_sci_do_xfer (info, xfer);if (ret) {
@@ -1838,19 +1849,18 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle,static int ti_sci_cmd_lpm_abort (struct device *dev) {struct ti_sci_info *info =dev_get_drvdata (dev); -struct ti_sci_msg_hdr *req; +struct ti_sci_msg_hdr req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ; xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_ABORT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_hdr *)xfer->xfer_buf; - ret =ti_sci_do_xfer (info, xfer);if (ret)return ret;
@@ -1861,7 +1871,7 @@ static int ti_sci_cmd_lpm_abort(struct device *dev)static int ti_sci_cmd_core_reboot (const struct ti_sci_handle *handle) {struct ti_sci_info *info; -struct ti_sci_msg_req_reboot *req; +struct ti_sci_msg_req_reboot req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -1875,12 +1885,11 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SYS_RESET ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; - ret =ti_sci_do_xfer (info, xfer);if (ret)return ret;
@@ -1907,7 +1916,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, struct ti_sci_resource_desc *desc) {struct ti_sci_msg_resp_get_resource_range resp; -struct ti_sci_msg_req_get_resource_range *req; +struct ti_sci_msg_req_get_resource_range req;struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -1921,14 +1930,14 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; - req->secondary_host = s_host; - req->type = dev_id &MSG_RM_RESOURCE_TYPE_MASK ; - req->subtype = subtype &MSG_RM_RESOURCE_SUBTYPE_MASK ; + req.secondary_host = s_host; + req.type = dev_id &MSG_RM_RESOURCE_TYPE_MASK ; + req.subtype = subtype &MSG_RM_RESOURCE_SUBTYPE_MASK ; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2014,7 +2023,7 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, u16 global_event, u8 vint_status_bit, u8 s_host, u16 type) { - struct ti_sci_msg_req_manage_irq *req; + struct ti_sci_msg_req_manage_irq req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2028,21 +2037,21 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); xfer =ti_sci_get_one_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; - req->valid_params = valid_params; - req->src_id = src_id; - req->src_index = src_index; - req->dst_id = dst_id; - req->dst_host_irq = dst_host_irq; - req->ia_id = ia_id; - req->vint = vint; - req->global_event = global_event; - req->vint_status_bit = vint_status_bit; - req->secondary_host = s_host; + req.valid_params = valid_params; + req.src_id = src_id; + req.src_index = src_index; + req.dst_id = dst_id; + req.dst_host_irq = dst_host_irq; + req.ia_id = ia_id; + req.vint = vint; + req.global_event = global_event; + req.vint_status_bit = vint_status_bit; + req.secondary_host = s_host; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2326,7 +2335,7 @@ static int ti_sci_cmd_free_event_map(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_ring_cfg (const struct ti_sci_handle *handle,const struct ti_sci_msg_rm_ring_cfg *params) { -struct ti_sci_msg_rm_ring_cfg_req *req; +struct ti_sci_msg_rm_ring_cfg_req req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2339,22 +2348,22 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_RING_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; - req->valid_params = params->valid_params; - req->nav_id = params->nav_id; - req->index = params->index; - req->addr_lo = params->addr_lo; - req->addr_hi = params->addr_hi; - req->count = params->count; - req->mode = params->mode; - req->size = params->size; - req->order_id = params->order_id; - req->virtid = params->virtid; - req->asel = params->asel; + req.valid_params = params->valid_params; + req.nav_id = params->nav_id; + req.index = params->index; + req.addr_lo = params->addr_lo; + req.addr_hi = params->addr_hi; + req.count = params->count; + req.mode = params->mode; + req.size = params->size; + req.order_id = params->order_id; + req.virtid = params->virtid; + req.asel = params->asel; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2376,7 +2385,7 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_psil_pair (const struct ti_sci_handle *handle,u32 nav_id,u32 src_thread,u32 dst_thread) { -struct ti_sci_msg_psil_pair *req; +struct ti_sci_msg_psil_pair req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2391,14 +2400,14 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; - req->nav_id = nav_id; - req->src_thread = src_thread; - req->dst_thread = dst_thread; + req.nav_id = nav_id; + req.src_thread = src_thread; + req.dst_thread = dst_thread; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2420,7 +2429,7 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_psil_unpair (const struct ti_sci_handle *handle,u32 nav_id,u32 src_thread,u32 dst_thread) { -struct ti_sci_msg_psil_unpair *req; +struct ti_sci_msg_psil_unpair req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2435,14 +2444,14 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; - req->nav_id = nav_id; - req->src_thread = src_thread; - req->dst_thread = dst_thread; + req.nav_id = nav_id; + req.src_thread = src_thread; + req.dst_thread = dst_thread; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2465,7 +2474,7 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_udmap_tx_ch_cfg (const struct ti_sci_handle *handle,const struct ti_sci_msg_rm_udmap_tx_ch_cfg *params) { -struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *req; +struct ti_sci_msg_rm_udmap_tx_ch_cfg_req req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2478,31 +2487,31 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; - req->valid_params = params->valid_params; - req->nav_id = params->nav_id; - req->index = params->index; - req->tx_pause_on_err = params->tx_pause_on_err; - req->tx_filt_einfo = params->tx_filt_einfo; - req->tx_filt_pswords = params->tx_filt_pswords; - req->tx_atype = params->tx_atype; - req->tx_chan_type = params->tx_chan_type; - req->tx_supr_tdpkt = params->tx_supr_tdpkt; - req->tx_fetch_size = params->tx_fetch_size; - req->tx_credit_count = params->tx_credit_count; - req->txcq_qnum = params->txcq_qnum; - req->tx_priority = params->tx_priority; - req->tx_qos = params->tx_qos; - req->tx_orderid = params->tx_orderid; - req->fdepth = params->fdepth; - req->tx_sched_priority = params->tx_sched_priority; - req->tx_burst_size = params->tx_burst_size; - req->tx_tdtype = params->tx_tdtype; - req->extended_ch_type = params->extended_ch_type; + req.valid_params = params->valid_params; + req.nav_id = params->nav_id; + req.index = params->index; + req.tx_pause_on_err = params->tx_pause_on_err; + req.tx_filt_einfo = params->tx_filt_einfo; + req.tx_filt_pswords = params->tx_filt_pswords; + req.tx_atype = params->tx_atype; + req.tx_chan_type = params->tx_chan_type; + req.tx_supr_tdpkt = params->tx_supr_tdpkt; + req.tx_fetch_size = params->tx_fetch_size; + req.tx_credit_count = params->tx_credit_count; + req.txcq_qnum = params->txcq_qnum; + req.tx_priority = params->tx_priority; + req.tx_qos = params->tx_qos; + req.tx_orderid = params->tx_orderid; + req.fdepth = params->fdepth; + req.tx_sched_priority = params->tx_sched_priority; + req.tx_burst_size = params->tx_burst_size; + req.tx_tdtype = params->tx_tdtype; + req.extended_ch_type = params->extended_ch_type; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2525,7 +2534,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_udmap_rx_ch_cfg (const struct ti_sci_handle *handle,const struct ti_sci_msg_rm_udmap_rx_ch_cfg *params) { -struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *req; +struct ti_sci_msg_rm_udmap_rx_ch_cfg_req req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2538,28 +2547,28 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; - req->valid_params = params->valid_params; - req->nav_id = params->nav_id; - req->index = params->index; - req->rx_fetch_size = params->rx_fetch_size; - req->rxcq_qnum = params->rxcq_qnum; - req->rx_priority = params->rx_priority; - req->rx_qos = params->rx_qos; - req->rx_orderid = params->rx_orderid; - req->rx_sched_priority = params->rx_sched_priority; - req->flowid_start = params->flowid_start; - req->flowid_cnt = params->flowid_cnt; - req->rx_pause_on_err = params->rx_pause_on_err; - req->rx_atype = params->rx_atype; - req->rx_chan_type = params->rx_chan_type; - req->rx_ignore_short = params->rx_ignore_short; - req->rx_ignore_long = params->rx_ignore_long; - req->rx_burst_size = params->rx_burst_size; + req.valid_params = params->valid_params; + req.nav_id = params->nav_id; + req.index = params->index; + req.rx_fetch_size = params->rx_fetch_size; + req.rxcq_qnum = params->rxcq_qnum; + req.rx_priority = params->rx_priority; + req.rx_qos = params->rx_qos; + req.rx_orderid = params->rx_orderid; + req.rx_sched_priority = params->rx_sched_priority; + req.flowid_start = params->flowid_start; + req.flowid_cnt = params->flowid_cnt; + req.rx_pause_on_err = params->rx_pause_on_err; + req.rx_atype = params->rx_atype; + req.rx_chan_type = params->rx_chan_type; + req.rx_ignore_short = params->rx_ignore_short; + req.rx_ignore_long = params->rx_ignore_long; + req.rx_burst_size = params->rx_burst_size; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2582,7 +2591,7 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle,static int ti_sci_cmd_rm_udmap_rx_flow_cfg (const struct ti_sci_handle *handle,const struct ti_sci_msg_rm_udmap_flow_cfg *params) { -struct ti_sci_msg_rm_udmap_flow_cfg_req *req; +struct ti_sci_msg_rm_udmap_flow_cfg_req req;struct ti_sci_msg_hdr resp;struct ti_sci_xfer *xfer;struct ti_sci_info *info;
@@ -2595,33 +2604,33 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; - req->valid_params = params->valid_params; - req->nav_id = params->nav_id; - req->flow_index = params->flow_index; - req->rx_einfo_present = params->rx_einfo_present; - req->rx_psinfo_present = params->rx_psinfo_present; - req->rx_error_handling = params->rx_error_handling; - req->rx_desc_type = params->rx_desc_type; - req->rx_sop_offset = params->rx_sop_offset; - req->rx_dest_qnum = params->rx_dest_qnum; - req->rx_src_tag_hi = params->rx_src_tag_hi; - req->rx_src_tag_lo = params->rx_src_tag_lo; - req->rx_dest_tag_hi = params->rx_dest_tag_hi; - req->rx_dest_tag_lo = params->rx_dest_tag_lo; - req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; - req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; - req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; - req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; - req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; - req->rx_fdq1_qnum = params->rx_fdq1_qnum; - req->rx_fdq2_qnum = params->rx_fdq2_qnum; - req->rx_fdq3_qnum = params->rx_fdq3_qnum; - req->rx_ps_location = params->rx_ps_location; + req.valid_params = params->valid_params; + req.nav_id = params->nav_id; + req.flow_index = params->flow_index; + req.rx_einfo_present = params->rx_einfo_present; + req.rx_psinfo_present = params->rx_psinfo_present; + req.rx_error_handling = params->rx_error_handling; + req.rx_desc_type = params->rx_desc_type; + req.rx_sop_offset = params->rx_sop_offset; + req.rx_dest_qnum = params->rx_dest_qnum; + req.rx_src_tag_hi = params->rx_src_tag_hi; + req.rx_src_tag_lo = params->rx_src_tag_lo; + req.rx_dest_tag_hi = params->rx_dest_tag_hi; + req.rx_dest_tag_lo = params->rx_dest_tag_lo; + req.rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; + req.rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; + req.rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; + req.rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; + req.rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; + req.rx_fdq1_qnum = params->rx_fdq1_qnum; + req.rx_fdq2_qnum = params->rx_fdq2_qnum; + req.rx_fdq3_qnum = params->rx_fdq3_qnum; + req.rx_ps_location = params->rx_ps_location; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2640,7 +2649,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle,static int ti_sci_cmd_proc_request (const struct ti_sci_handle *handle,u8 proc_id) { -struct ti_sci_msg_req_proc_request *req; +struct ti_sci_msg_req_proc_request req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2655,12 +2664,12 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_REQUEST ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; - req->processor_id = proc_id; + req.processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2679,7 +2688,7 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,static int ti_sci_cmd_proc_release (const struct ti_sci_handle *handle,u8 proc_id) { -struct ti_sci_msg_req_proc_release *req; +struct ti_sci_msg_req_proc_release req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2694,12 +2703,12 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_RELEASE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; - req->processor_id = proc_id; + req.processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2721,7 +2730,7 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,static int ti_sci_cmd_proc_handover (const struct ti_sci_handle *handle,u8 proc_id,u8 host_id) { -struct ti_sci_msg_req_proc_handover *req; +struct ti_sci_msg_req_proc_handover req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2736,13 +2745,13 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_HANDOVER ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; - req->processor_id = proc_id; - req->host_id = host_id; + req.processor_id = proc_id; + req.host_id = host_id; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2767,7 +2776,7 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, u32 config_flags_set, u32 config_flags_clear) { -struct ti_sci_msg_req_set_config *req; +struct ti_sci_msg_req_set_config req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2782,17 +2791,17 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CONFIG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; - req->processor_id = proc_id; - req->bootvector_low = bootvector &TI_SCI_ADDR_LOW_MASK ; - req->bootvector_high = (bootvector &TI_SCI_ADDR_HIGH_MASK ) >> + req.processor_id = proc_id; + req.bootvector_low = bootvector &TI_SCI_ADDR_LOW_MASK ; + req.bootvector_high = (bootvector &TI_SCI_ADDR_HIGH_MASK ) >>TI_SCI_ADDR_HIGH_SHIFT ; - req->config_flags_set = config_flags_set; - req->config_flags_clear = config_flags_clear; + req.config_flags_set = config_flags_set; + req.config_flags_clear = config_flags_clear; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2815,7 +2824,7 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, u8 proc_id, u32 control_flags_set, u32 control_flags_clear) { - struct ti_sci_msg_req_set_ctrl *req; + struct ti_sci_msg_req_set_ctrl req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info;struct ti_sci_xfer *xfer;
@@ -2830,14 +2839,14 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CTRL ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; - req->processor_id = proc_id; - req->control_flags_set = control_flags_set; - req->control_flags_clear = control_flags_clear; + req.processor_id = proc_id; + req.control_flags_set = control_flags_set; + req.control_flags_clear = control_flags_clear; ret =ti_sci_do_xfer (info, xfer);if (ret)
@@ -2862,7 +2871,7 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, u32 *ctrl_flags, u32 *sts_flags) {struct ti_sci_msg_resp_get_status resp; -struct ti_sci_msg_req_get_status *req; +struct ti_sci_msg_req_get_status req;struct ti_sci_info *info;struct ti_sci_xfer *xfer;int ret =0 ;
@@ -2876,12 +2885,12 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_STATUS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , -sizeof (*req), &resp,sizeof (resp)); + &req,sizeof (req), + &resp,sizeof (resp));if (IS_ERR (xfer))return PTR_ERR (xfer); - req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; - req->processor_id = proc_id; + req.processor_id = proc_id; ret =ti_sci_do_xfer (info, xfer);if (ret)
Signature · 1 line
2.34.1
PATCH v3 8/22 firmware: ti_sci: Combine xfer allocation and transfer functions
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
In each TI-SCI message function we allocate a xfer struct and use it to perform a message transfer. There is now no reason to do these in two steps. Instead make the ti_sci_do_xfer() function do the allocation internally. That function already does the xfer free so it make sense to have it also do the allocation. This reduces the complexity of all the individual message functions.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 487 +++++++++++++------------------------- 1 file changed, 170 insertions(+), 317 deletions(-)
drivers/firmware/ti_sci.c +170 -317
@@ -305,6 +305,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)* @tx_message_size: transmit message size * @rx_message: receive message storage location * @rx_message_size: receive message size +* @caller: Address of the command function, used in error messages * * Helper function which is used by various command functions that are * exposed to clients of this driver for allocating a message traffic event.
@@ -318,7 +319,8 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)static struct ti_sci_xfer *ti_sci_get_one_xfer (struct ti_sci_info *info,u16 msg_type,u32 msg_flags,void *tx_message,size_t tx_message_size, -void *rx_message,size_t rx_message_size) +void *rx_message,size_t rx_message_size, +void *caller) {struct ti_sci_xfers_info *minfo = &info->minfo;struct device *dev = info->dev;
@@ -335,7 +337,7 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, tx_message_size > info->desc->max_msg_size || rx_message_size < sizeof(*hdr) || tx_message_size < sizeof(*hdr)) {dev_err (dev,"TI-SCI message size out of range (caller: %pS)\n" , - (void *)_RET_IP_); + caller);return ERR_PTR (-ERANGE ); }
@@ -348,7 +350,7 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, ret =down_timeout (&minfo->sem_xfer_count, timeout);if (ret <0 ) {dev_err (dev,"TI-SCI timeout waiting for transfer semaphore (caller: %pS)\n" , - (void *)_RET_IP_); + caller);return ERR_PTR (ret); }
@@ -434,23 +436,45 @@ static inline bool ti_sci_is_response_ack(void *r)/** * ti_sci_do_xfer() - Do one transfer * @info: Pointer to SCI entity information -* @xfer: Transfer to initiate and wait for response +* @msg_type: Message type +* @msg_flags: Flag to set for the message +* @tx_message: transmit message storage location +* @tx_message_size: transmit message size +* @rx_message: receive message storage location +* @rx_message_size: receive message size * * Return: -ETIMEDOUT in case of no response, or * -ENODEV in case of a NACK response, or +* corresponding error if xfer allocation fails, or * corresponding error if transmit fails, or * return 0, if all goes well. */ static inline int ti_sci_do_xfer (struct ti_sci_info *info, -struct ti_sci_xfer *xfer) +u16 msg_type,u32 msg_flags, +void *tx_message,size_t tx_message_size, +void *rx_message,size_t rx_message_size) { -struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; -bool response_expected = !!(hdr->flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED | -TI_SCI_FLAG_REQ_ACK_ON_RECEIVED )); +struct ti_sci_xfer *xfer; +bool response_expected = !!(msg_flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED | +TI_SCI_FLAG_REQ_ACK_ON_RECEIVED ));int ret;int timeout;struct device *dev = info->dev;bool done_state = true; +void *caller; + +/* +* Address of the TI SCI command function, used in error messages. +* This is only accurate if this function is not inlined, otherwise +* the caller of the command function is reported instead. +*/ + caller = (void *)_RET_IP_; + + xfer =ti_sci_get_one_xfer (info, msg_type, msg_flags, + tx_message, tx_message_size, + rx_message, rx_message_size, caller); +if (IS_ERR (xfer)) +return PTR_ERR (xfer); memcpy(xfer->xfer_buf + sizeof(struct ti_sci_msg_hdr), xfer->tx_buf + sizeof(struct ti_sci_msg_hdr),
@@ -458,7 +482,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info, ret =mbox_send_message (info->chan_tx, &xfer->tx_message);if (ret <0 ) { -dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, (void *)_RET_IP_); +dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, caller); goto fail; }
@@ -481,8 +505,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info, }if (ret == -ETIMEDOUT ) -dev_err (dev,"Mbox timedout in resp(caller: %pS)\n" , - (void *)_RET_IP_); +dev_err (dev,"Mbox timedout in resp(caller: %pS)\n" , caller);/* * NOTE: we might prefer not to need the mailbox ticker to manage the
@@ -499,7 +522,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,if (response_expected && ret ==0 ) {if (!ti_sci_is_response_ack (xfer->xfer_buf)) {dev_warn (dev,"Message response not acknowledged (caller: %pS)\n" , - (void *)_RET_IP_); + caller); ret = -ENODEV ; }else {memcpy (xfer->rx_buf, xfer->xfer_buf, xfer->rx_len);
@@ -526,17 +549,12 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)struct ti_sci_version_info *ver = &handle->version;struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_version resp; -struct ti_sci_xfer *xfer;int ret; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_VERSION , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_VERSION , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -564,7 +582,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_device_state req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -574,17 +591,13 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , - flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.id = id; req.state = state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , + flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -609,7 +622,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_get_device_state req;struct ti_sci_msg_resp_get_device_state resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -622,16 +634,12 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.id = id; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -900,7 +908,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_device_resets req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -910,17 +917,13 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.id = id; req.resets = reset_state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -962,7 +965,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_state req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -972,13 +974,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , - flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -988,7 +983,10 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, } req.request_state = state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , + flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1014,7 +1012,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_state req;struct ti_sci_msg_resp_get_clock_state resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1027,13 +1024,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1042,7 +1032,10 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1232,7 +1225,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_parent req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1242,13 +1234,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1263,7 +1248,10 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, req.parent_id_32 = parent_id; } - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1287,7 +1275,6 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_parent req;struct ti_sci_msg_resp_get_clock_parent resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1297,13 +1284,6 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1312,7 +1292,10 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1342,7 +1325,6 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_num_parents req;struct ti_sci_msg_resp_get_clock_num_parents resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1352,13 +1334,6 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1367,7 +1342,10 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1406,7 +1384,6 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_query_clock_freq req;struct ti_sci_msg_resp_query_clock_freq resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1416,13 +1393,6 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1434,7 +1404,10 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, req.target_freq_hz = target_freq; req.max_freq_hz = max_freq; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1468,7 +1441,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_freq req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1478,13 +1450,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1496,7 +1461,10 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, req.target_freq_hz = target_freq; req.max_freq_hz = max_freq; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1520,7 +1488,6 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_freq req;struct ti_sci_msg_resp_get_clock_freq resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1530,13 +1497,6 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1545,7 +1505,10 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1573,7 +1536,6 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode,struct ti_sci_info *info;struct ti_sci_msg_req_prepare_sleep req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1585,19 +1547,15 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , - msg_flags, - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.mode = mode; req.ctx_lo = ctx_lo; req.ctx_hi = ctx_hi; req.debug_flags = debug_flags; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , + msg_flags, + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to prepare sleep\n" );return ret;
@@ -1621,7 +1579,6 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, u64 *fw_caps) {struct ti_sci_info *info; -struct ti_sci_xfer *xfer;struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_query_fw_caps resp;struct device *dev;
@@ -1635,14 +1592,10 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_QUERY_FW_CAPS , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_QUERY_FW_CAPS , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to get capabilities\n" );return ret;
@@ -1667,7 +1620,6 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_set_io_isolation req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1679,16 +1631,12 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.state = state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to set IO isolation\n" );return ret;
@@ -1711,7 +1659,6 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, u32 *source, u64 *timestamp, u8 *pin, u8 *mode) {struct ti_sci_info *info; -struct ti_sci_xfer *xfer;struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_lpm_wake_reason resp;struct device *dev;
@@ -1725,14 +1672,10 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_WAKE_REASON , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_WAKE_REASON , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to get wake reason\n" );return ret;
@@ -1764,7 +1707,6 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_device_constraint req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1776,17 +1718,13 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.id = id; req.state = state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to set device constraint\n" );return ret;
@@ -1809,7 +1747,6 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle,struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_latency_constraint req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct device *dev;int ret =0 ;
@@ -1821,17 +1758,13 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); dev = info->dev; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.latency = latency; req.state = state; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret) {dev_err (dev,"Failed to set device constraint\n" );return ret;
@@ -1851,17 +1784,12 @@ static int ti_sci_cmd_lpm_abort(struct device *dev)struct ti_sci_info *info =dev_get_drvdata (dev);struct ti_sci_msg_hdr req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ; - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_LPM_ABORT , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_ABORT , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1873,7 +1801,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)struct ti_sci_info *info;struct ti_sci_msg_req_reboot req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;int ret =0 ;if (IS_ERR (handle))
@@ -1883,14 +1810,10 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SYS_RESET , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SYS_RESET , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -1917,7 +1840,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, {struct ti_sci_msg_resp_get_resource_range resp;struct ti_sci_msg_req_get_resource_range req; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -1928,18 +1850,14 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.secondary_host = s_host; req.type = dev_id &MSG_RM_RESOURCE_TYPE_MASK ; req.subtype = subtype &MSG_RM_RESOURCE_SUBTYPE_MASK ; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2025,7 +1943,6 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_manage_irq req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2036,12 +1953,6 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.valid_params = valid_params; req.src_id = src_id; req.src_index = src_index;
@@ -2053,7 +1964,9 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, req.vint_status_bit = vint_status_bit; req.secondary_host = s_host; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2337,7 +2250,6 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_ring_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2346,13 +2258,6 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_RING_CFG , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2365,7 +2270,10 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, req.virtid = params->virtid; req.asel = params->asel; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_RING_CFG , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2387,7 +2295,6 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, {struct ti_sci_msg_psil_pair req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2398,18 +2305,14 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.nav_id = nav_id; req.src_thread = src_thread; req.dst_thread = dst_thread; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2431,7 +2334,6 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, {struct ti_sci_msg_psil_unpair req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2442,18 +2344,14 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.nav_id = nav_id; req.src_thread = src_thread; req.dst_thread = dst_thread; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2476,7 +2374,6 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_tx_ch_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2485,13 +2382,6 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2513,7 +2403,10 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, req.tx_tdtype = params->tx_tdtype; req.extended_ch_type = params->extended_ch_type; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2536,7 +2429,6 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_rx_ch_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2545,13 +2437,6 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2570,7 +2455,10 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, req.rx_ignore_long = params->rx_ignore_long; req.rx_burst_size = params->rx_burst_size; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2593,7 +2481,6 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_flow_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_xfer *xfer;struct ti_sci_info *info;int ret =0 ;
@@ -2602,13 +2489,6 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.flow_index = params->flow_index;
@@ -2632,7 +2512,10 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, req.rx_fdq3_qnum = params->rx_fdq3_qnum; req.rx_ps_location = params->rx_ps_location; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2652,7 +2535,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,struct ti_sci_msg_req_proc_request req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2662,16 +2544,12 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_REQUEST , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_REQUEST , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2691,7 +2569,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,struct ti_sci_msg_req_proc_release req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2701,16 +2578,12 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_RELEASE , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_RELEASE , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2733,7 +2606,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,struct ti_sci_msg_req_proc_handover req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2743,17 +2615,13 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_PROC_HANDOVER , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; req.host_id = host_id; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_HANDOVER , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2779,7 +2647,6 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_config req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2789,13 +2656,6 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CONFIG , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; req.bootvector_low = bootvector &TI_SCI_ADDR_LOW_MASK ; req.bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >>
@@ -2803,7 +2663,10 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, req.config_flags_set = config_flags_set; req.config_flags_clear = config_flags_clear; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CONFIG , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2827,7 +2690,6 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle,struct ti_sci_msg_req_set_ctrl req;struct ti_sci_msg_hdr resp;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2837,18 +2699,14 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_SET_CTRL , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; req.control_flags_set = control_flags_set; req.control_flags_clear = control_flags_clear; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CTRL , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
@@ -2873,7 +2731,6 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle,struct ti_sci_msg_resp_get_status resp;struct ti_sci_msg_req_get_status req;struct ti_sci_info *info; -struct ti_sci_xfer *xfer;int ret =0 ;if (!handle)
@@ -2883,16 +2740,12 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, info =handle_to_ti_sci_info (handle); - xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_STATUS , -TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , - &req,sizeof (req), - &resp,sizeof (resp)); -if (IS_ERR (xfer)) -return PTR_ERR (xfer); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info, xfer); + ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_STATUS , +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + &req,sizeof (req), + &resp,sizeof (resp));if (ret)return ret;
Signature · 1 line
2.34.1
PATCH v3 9/22 firmware: ti_sci: Fetch info struct from handle inside ti_sci_do_xfer()
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
As the only use for the handle is to fetch the info struct, which is only used by the ti_sci_do_xfer() function, move the info struct retrieval into that function. This also allows us to move the handle validity check inside also, saving us from needing to do this at each message function.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 306 ++++++++------------------------------ 1 file changed, 60 insertions(+), 246 deletions(-)
drivers/firmware/ti_sci.c +60 -246
@@ -435,7 +435,7 @@ static inline bool ti_sci_is_response_ack(void *r)/** * ti_sci_do_xfer() - Do one transfer -* @info: Pointer to SCI entity information +* @handle: Pointer to TI SCI handle * @msg_type: Message type * @msg_flags: Flag to set for the message * @tx_message: transmit message storage location
@@ -443,23 +443,26 @@ static inline bool ti_sci_is_response_ack(void *r)* @rx_message: receive message storage location * @rx_message_size: receive message size * -* Return: -ETIMEDOUT in case of no response, or +* Return: -EINVAL if @handle is NULL, or +* PTR_ERR(@handle) if @handle is an error pointer, or +* -ETIMEDOUT in case of no response, or * -ENODEV in case of a NACK response, or * corresponding error if xfer allocation fails, or * corresponding error if transmit fails, or * return 0, if all goes well. */ -static inline int ti_sci_do_xfer (struct ti_sci_info *info, +static inline int ti_sci_do_xfer (const struct ti_sci_handle *handle,u16 msg_type,u32 msg_flags,void *tx_message,size_t tx_message_size,void *rx_message,size_t rx_message_size) { +struct ti_sci_info *info;struct ti_sci_xfer *xfer;bool response_expected = !!(msg_flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED |TI_SCI_FLAG_REQ_ACK_ON_RECEIVED ));int ret;int timeout; -struct device *dev = info->dev; +struct device *dev;bool done_state = true;void *caller;
@@ -470,6 +473,14 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,*/ caller = (void *)_RET_IP_; +if (IS_ERR (handle)) +return PTR_ERR (handle); +if (!handle) +return -EINVAL ; + + info =handle_to_ti_sci_info (handle); + dev = info->dev; + xfer =ti_sci_get_one_xfer (info, msg_type, msg_flags, tx_message, tx_message_size, rx_message, rx_message_size, caller);
@@ -551,7 +562,7 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)struct ti_sci_msg_resp_version resp;int ret; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_VERSION , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_VERSION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -579,22 +590,14 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)static int ti_sci_set_device_state (const struct ti_sci_handle *handle,u32 id,u32 flags,u8 state) { -struct ti_sci_info *info;struct ti_sci_msg_req_set_device_state req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.id = id; req.state = state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_DEVICE_STATE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_DEVICE_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -619,24 +622,16 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle, u32 id, u32 *clcnt, u32 *resets, u8 *p_state, u8 *c_state) { - struct ti_sci_info *info; struct ti_sci_msg_req_get_device_state req;struct ti_sci_msg_resp_get_device_state resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; -if (!clcnt && !resets && !p_state && !c_state)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.id = id; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_DEVICE_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -905,22 +900,14 @@ static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id,static int ti_sci_cmd_set_device_resets (const struct ti_sci_handle *handle,u32 id,u32 reset_state) { -struct ti_sci_info *info;struct ti_sci_msg_req_set_device_resets req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.id = id; req.resets = reset_state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_DEVICE_RESETS , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_DEVICE_RESETS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -962,18 +949,10 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u32 flags, u8 state) { - struct ti_sci_info *info; struct ti_sci_msg_req_set_clock_state req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -983,7 +962,7 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle, } req.request_state = state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_STATE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_CLOCK_STATE , flags |TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1009,21 +988,13 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u8 *programmed_state, u8 *current_state) { - struct ti_sci_info *info; struct ti_sci_msg_req_get_clock_state req;struct ti_sci_msg_resp_get_clock_state resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; -if (!programmed_state && !current_state)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1032,7 +1003,7 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_STATE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_CLOCK_STATE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1222,18 +1193,10 @@ static int ti_sci_cmd_clk_is_off(const struct ti_sci_handle *handle, u32 dev_id,static int ti_sci_cmd_clk_set_parent (const struct ti_sci_handle *handle,u32 dev_id,u32 clk_id,u32 parent_id) { -struct ti_sci_info *info;struct ti_sci_msg_req_set_clock_parent req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1248,7 +1211,7 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle, req.parent_id_32 = parent_id; } - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_PARENT , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1272,18 +1235,13 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,static int ti_sci_cmd_clk_get_parent (const struct ti_sci_handle *handle,u32 dev_id,u32 clk_id,u32 *parent_id) { -struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_parent req;struct ti_sci_msg_resp_get_clock_parent resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle || !parent_id) +if (!parent_id)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1292,7 +1250,7 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_PARENT , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_CLOCK_PARENT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1322,18 +1280,13 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u32 *num_parents) { - struct ti_sci_info *info; struct ti_sci_msg_req_get_clock_num_parents req;struct ti_sci_msg_resp_get_clock_num_parents resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle || !num_parents) +if (!num_parents)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1342,7 +1295,7 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_NUM_CLOCK_PARENTS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1381,18 +1334,13 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, u64 target_freq, u64 max_freq, u64 *match_freq) { - struct ti_sci_info *info; struct ti_sci_msg_req_query_clock_freq req;struct ti_sci_msg_resp_query_clock_freq resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle || !match_freq) +if (!match_freq)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1404,7 +1352,7 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle, req.target_freq_hz = target_freq; req.max_freq_hz = max_freq; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_QUERY_CLOCK_FREQ , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_QUERY_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1438,18 +1386,10 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, u32 dev_id, u32 clk_id, u64 min_freq, u64 target_freq, u64 max_freq) { - struct ti_sci_info *info; struct ti_sci_msg_req_set_clock_freq req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1461,7 +1401,7 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle, req.target_freq_hz = target_freq; req.max_freq_hz = max_freq; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CLOCK_FREQ , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1485,18 +1425,13 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,static int ti_sci_cmd_clk_get_freq (const struct ti_sci_handle *handle,u32 dev_id,u32 clk_id,u64 *freq) { -struct ti_sci_info *info;struct ti_sci_msg_req_get_clock_freq req;struct ti_sci_msg_resp_get_clock_freq resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle || !freq) +if (!freq)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.dev_id = dev_id;if (clk_id <255 ) { req.clk_id = clk_id;
@@ -1505,7 +1440,7 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, req.clk_id_32 = clk_id; } - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_CLOCK_FREQ , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_CLOCK_FREQ ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1533,7 +1468,6 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode,u32 msg_flags = mode ==TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO ?TI_SCI_FLAG_REQ_GENERIC_NORESPONSE :TI_SCI_FLAG_REQ_ACK_ON_PROCESSED ; -struct ti_sci_info *info;struct ti_sci_msg_req_prepare_sleep req;struct ti_sci_msg_hdr resp;struct device *dev;
@@ -1544,15 +1478,14 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; req.mode = mode; req.ctx_lo = ctx_lo; req.ctx_hi = ctx_hi; req.debug_flags = debug_flags; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_PREPARE_SLEEP , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_PREPARE_SLEEP , msg_flags, &req,sizeof (req), &resp,sizeof (resp));
@@ -1578,7 +1511,6 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode,static int ti_sci_msg_cmd_query_fw_caps (const struct ti_sci_handle *handle,u64 *fw_caps) { -struct ti_sci_info *info;struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_query_fw_caps resp;struct device *dev;
@@ -1589,10 +1521,9 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_QUERY_FW_CAPS , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_QUERY_FW_CAPS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1617,7 +1548,6 @@ static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,static int ti_sci_cmd_set_io_isolation (const struct ti_sci_handle *handle,u8 state) { -struct ti_sci_info *info;struct ti_sci_msg_req_set_io_isolation req;struct ti_sci_msg_hdr resp;struct device *dev;
@@ -1628,12 +1558,11 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; req.state = state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_IO_ISOLATION , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_IO_ISOLATION ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1658,7 +1587,6 @@ static int ti_sci_cmd_set_io_isolation(const struct ti_sci_handle *handle,static int ti_sci_msg_cmd_lpm_wake_reason (const struct ti_sci_handle *handle,u32 *source,u64 *timestamp,u8 *pin,u8 *mode) { -struct ti_sci_info *info;struct ti_sci_msg_hdr req;struct ti_sci_msg_resp_lpm_wake_reason resp;struct device *dev;
@@ -1669,10 +1597,9 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_WAKE_REASON , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_LPM_WAKE_REASON ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1704,7 +1631,6 @@ static int ti_sci_msg_cmd_lpm_wake_reason(const struct ti_sci_handle *handle,static int ti_sci_cmd_set_device_constraint (const struct ti_sci_handle *handle,u32 id,u8 state) { -struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_device_constraint req;struct ti_sci_msg_hdr resp;struct device *dev;
@@ -1715,13 +1641,12 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; req.id = id; req.state = state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1744,7 +1669,6 @@ static int ti_sci_cmd_set_device_constraint(const struct ti_sci_handle *handle,static int ti_sci_cmd_set_latency_constraint (const struct ti_sci_handle *handle,u16 latency,u8 state) { -struct ti_sci_info *info;struct ti_sci_msg_req_lpm_set_latency_constraint req;struct ti_sci_msg_hdr resp;struct device *dev;
@@ -1755,13 +1679,12 @@ static int ti_sci_cmd_set_latency_constraint(const struct ti_sci_handle *handle,if (!handle)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - dev = info->dev; + dev =handle_to_ti_sci_info (handle)->dev; req.latency = latency; req.state = state; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1786,7 +1709,7 @@ static int ti_sci_cmd_lpm_abort(struct device *dev)struct ti_sci_msg_hdr resp;int ret =0 ; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_LPM_ABORT , + ret =ti_sci_do_xfer (&info->handle,TI_SCI_MSG_LPM_ABORT ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1798,19 +1721,11 @@ static int ti_sci_cmd_lpm_abort(struct device *dev)static int ti_sci_cmd_core_reboot (const struct ti_sci_handle *handle) { -struct ti_sci_info *info;struct ti_sci_msg_req_reboot req;struct ti_sci_msg_hdr resp;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SYS_RESET , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SYS_RESET ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1840,21 +1755,16 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, {struct ti_sci_msg_resp_get_resource_range resp;struct ti_sci_msg_req_get_resource_range req; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle || !desc) +if (!desc)return -EINVAL ; - info =handle_to_ti_sci_info (handle); - req.secondary_host = s_host; req.type = dev_id &MSG_RM_RESOURCE_TYPE_MASK ; req.subtype = subtype &MSG_RM_RESOURCE_SUBTYPE_MASK ; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_RESOURCE_RANGE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_RESOURCE_RANGE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -1943,16 +1853,8 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_manage_irq req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.valid_params = valid_params; req.src_id = src_id; req.src_index = src_index;
@@ -1964,7 +1866,7 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, req.vint_status_bit = vint_status_bit; req.secondary_host = s_host; - ret =ti_sci_do_xfer (info, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , + ret =ti_sci_do_xfer (handle, type,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));if (ret)
@@ -2250,14 +2152,8 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_ring_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR_OR_NULL (handle)) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2270,7 +2166,7 @@ static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, req.virtid = params->virtid; req.asel = params->asel; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_RING_CFG , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_RM_RING_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2295,21 +2191,13 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle, {struct ti_sci_msg_psil_pair req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.nav_id = nav_id; req.src_thread = src_thread; req.dst_thread = dst_thread; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_PSIL_PAIR , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_RM_PSIL_PAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2334,21 +2222,13 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle, {struct ti_sci_msg_psil_unpair req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR (handle)) -return PTR_ERR (handle); -if (!handle) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.nav_id = nav_id; req.src_thread = src_thread; req.dst_thread = dst_thread; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_RM_PSIL_UNPAIR , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_RM_PSIL_UNPAIR ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2374,14 +2254,8 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_tx_ch_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR_OR_NULL (handle)) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2403,7 +2277,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle, req.tx_tdtype = params->tx_tdtype; req.extended_ch_type = params->extended_ch_type; - ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_TX_CH_CFG , + ret =ti_sci_do_xfer (handle,TISCI_MSG_RM_UDMAP_TX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2429,14 +2303,8 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_rx_ch_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR_OR_NULL (handle)) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.index = params->index;
@@ -2455,7 +2323,7 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(const struct ti_sci_handle *handle, req.rx_ignore_long = params->rx_ignore_long; req.rx_burst_size = params->rx_burst_size; - ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_RX_CH_CFG , + ret =ti_sci_do_xfer (handle,TISCI_MSG_RM_UDMAP_RX_CH_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2481,14 +2349,8 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, {struct ti_sci_msg_rm_udmap_flow_cfg_req req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (IS_ERR_OR_NULL (handle)) -return -EINVAL ; - - info =handle_to_ti_sci_info (handle); - req.valid_params = params->valid_params; req.nav_id = params->nav_id; req.flow_index = params->flow_index;
@@ -2512,7 +2374,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(const struct ti_sci_handle *handle, req.rx_fdq3_qnum = params->rx_fdq3_qnum; req.rx_ps_location = params->rx_ps_location; - ret =ti_sci_do_xfer (info,TISCI_MSG_RM_UDMAP_FLOW_CFG , + ret =ti_sci_do_xfer (handle,TISCI_MSG_RM_UDMAP_FLOW_CFG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2534,19 +2396,11 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_proc_request req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_REQUEST , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_PROC_REQUEST ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2568,19 +2422,11 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_proc_release req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_RELEASE , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_PROC_RELEASE ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2605,20 +2451,12 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_proc_handover req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; req.host_id = host_id; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_PROC_HANDOVER , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_PROC_HANDOVER ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2646,16 +2484,8 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_set_config req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; req.bootvector_low = bootvector &TI_SCI_ADDR_LOW_MASK ; req.bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >>
@@ -2663,7 +2493,7 @@ static int ti_sci_cmd_proc_set_config(const struct ti_sci_handle *handle, req.config_flags_set = config_flags_set; req.config_flags_clear = config_flags_clear; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CONFIG , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_CONFIG ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2689,21 +2519,13 @@ static int ti_sci_cmd_proc_set_control(const struct ti_sci_handle *handle, {struct ti_sci_msg_req_set_ctrl req;struct ti_sci_msg_hdr resp; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; req.control_flags_set = control_flags_set; req.control_flags_clear = control_flags_clear; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_SET_CTRL , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_SET_CTRL ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
@@ -2730,19 +2552,11 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle, {struct ti_sci_msg_resp_get_status resp;struct ti_sci_msg_req_get_status req; -struct ti_sci_info *info;int ret =0 ; -if (!handle) -return -EINVAL ; -if (IS_ERR (handle)) -return PTR_ERR (handle); - - info =handle_to_ti_sci_info (handle); - req.processor_id = proc_id; - ret =ti_sci_do_xfer (info,TI_SCI_MSG_GET_STATUS , + ret =ti_sci_do_xfer (handle,TI_SCI_MSG_GET_STATUS ,TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , &req,sizeof (req), &resp,sizeof (resp));
Signature · 1 line
2.34.1
PATCH v3 10/22 firmware: ti_sci: Use tx_message as message buffer directly
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
As we now have the tx_message during the whole xfer process we can use that as our message buffer to be sent. This removes an extra copy.
Note: the mailbox framework keeps only a pointer to tx_message and may submit it after ti_sci_do_xfer() returns if it was queued behind other messages. But, this cannot happen in practice: messages expecting a response are always submitted before their callers return, and the only no-response message (PREPARE_SLEEP for Partial-IO) is sent from the power-off handler with other CPUs stopped, after which nothing else uses the TX channel.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/firmware/ti_sci.c +2 -12
@@ -43,18 +43,13 @@ static DEFINE_MUTEX(ti_sci_list_mutex);/** * struct ti_sci_xfer - Structure representing a message flow * @tx_message: Transmit message -* @tx_buf: Pointer to the message to send * @rx_buf: Pointer to store received message * @rx_len: Receive message length * @xfer_buf: Preallocated buffer to store receive message -* Since we work with request-ACK protocol, we can -* reuse the same buffer for the rx path as we -* use for the tx path. * @done: completion event */ struct ti_sci_xfer {struct ti_msgmgr_message tx_message; -void *tx_buf;void *rx_buf;u8 rx_len;u8 *xfer_buf;
@@ -372,16 +367,16 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info, xfer = &minfo->xfer_block[xfer_id]; - hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; xfer->tx_message.len = tx_message_size; xfer->tx_message.chan_rx = info->chan_rx; xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; - xfer->tx_buf = tx_message; + xfer->tx_message.buf = tx_message; xfer->rx_buf = rx_message; xfer->rx_len = (u8 )rx_message_size;reinit_completion (&xfer->done); + hdr = (struct ti_sci_msg_hdr *)tx_message; hdr->seq = xfer_id; hdr->type = msg_type; hdr->host = info->host_id;
@@ -487,10 +482,6 @@ static inline int ti_sci_do_xfer(const struct ti_sci_handle *handle,if (IS_ERR (xfer))return PTR_ERR (xfer); -memcpy (xfer->xfer_buf +sizeof (struct ti_sci_msg_hdr ), - xfer->tx_buf +sizeof (struct ti_sci_msg_hdr ), - xfer->tx_message.len -sizeof (struct ti_sci_msg_hdr )); - ret =mbox_send_message (info->chan_tx, &xfer->tx_message);if (ret <0 ) {dev_err (dev,"Mbox send fail %d (caller: %pS)\n" , ret, caller);
@@ -3396,7 +3387,6 @@ static int ti_sci_probe(struct platform_device *pdev)if (!xfer->xfer_buf)return -ENOMEM ; - xfer->tx_message.buf = xfer->xfer_buf;init_completion (&xfer->done); }
Signature · 1 line
2.34.1
PATCH v3 11/22 firmware: ti_sci: Use rx_message as message receive buffer
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Previously we allocated a message buffer big enough for the largest message we could receive for every message we could have concurrently in flight. Now have the rx_message buffer during the whole xfer process we can use that as our message receive buffer. This removes an extra copy and the amount of memory we need to pre-allocate.
Note: rx_buf now points to the caller's on-stack response buffer. If the system firmware replies after ti_sci_do_xfer() has timed out, the rx callback can race with the caller returning and write into a stale stack frame. A reply that arrives after the timeout means the system firmware is not responding within its specified bounds, after which the system cannot be expected to operate correctly anyway, so this is not handled.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/firmware/ti_sci.c +5 -16
@@ -45,14 +45,12 @@ static DEFINE_MUTEX(ti_sci_list_mutex);* @tx_message: Transmit message * @rx_buf: Pointer to store received message * @rx_len: Receive message length -* @xfer_buf: Preallocated buffer to store receive message * @done: completion event */ struct ti_sci_xfer {struct ti_msgmgr_message tx_message;void *rx_buf;u8 rx_len; -u8 *xfer_buf;struct completion done; };
@@ -287,7 +285,7 @@ static void ti_sci_rx_callback(struct mbox_client *cl, void *m)ti_sci_dump_header_dbg (dev, hdr);/* Take a copy to the rx buffer.. */ -memcpy (xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); +memcpy (xfer->rx_buf, mbox_msg->buf, xfer->rx_len);complete (&xfer->done); }
@@ -522,12 +520,10 @@ static inline int ti_sci_do_xfer(const struct ti_sci_handle *handle,* state, then ensure that the response is an ACK */ if (response_expected && ret ==0 ) { -if (!ti_sci_is_response_ack (xfer->xfer_buf)) { +if (!ti_sci_is_response_ack (xfer->rx_buf)) {dev_warn (dev,"Message response not acknowledged (caller: %pS)\n" , caller); ret = -ENODEV ; - }else { -memcpy (xfer->rx_buf, xfer->xfer_buf, xfer->rx_len); } }
@@ -3326,7 +3322,6 @@ static int ti_sci_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;const struct ti_sci_desc *desc; -struct ti_sci_xfer *xfer;struct ti_sci_info *info =NULL ;struct ti_sci_xfers_info *minfo;struct mbox_client *cl;
@@ -3380,15 +3375,9 @@ static int ti_sci_probe(struct platform_device *pdev)if (!minfo->xfer_alloc_table)return -ENOMEM ; -/* Pre-initialize the buffer pointer to pre-allocated buffers */ -for (i =0 , xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { - xfer->xfer_buf =devm_kzalloc (dev, desc->max_msg_size, -GFP_KERNEL ); -if (!xfer->xfer_buf) -return -ENOMEM ; - -init_completion (&xfer->done); - } +/* Initialize the xfer completions */ +for (i =0 ; i < desc->max_msgs; i++) +init_completion (&minfo->xfer_block[i].done); ret =ti_sci_debugfs_create (pdev, info);if (ret)
Signature · 1 line
2.34.1
PATCH v3 12/22 firmware: ti_sci: Fix some kernel-doc references in structs
In reply to Beleswar PadhiThe valid_params descriptions of the RM ring and UDMAP tx/rx channel and rx flow config messages refer to struct members through structs that do not exist, the wrong struct, or syntax that kernel-doc does not understand. Refer to the members of the struct being documented directly instead.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.h | 126 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 63 deletions(-)
drivers/firmware/ti_sci.h +63 -63
@@ -813,14 +813,14 @@ struct ti_sci_msg_req_manage_irq {* The ring configuration fields are not valid, and will not be used for * ring configuration, if their corresponding valid bit is zero. * Valid bit usage: -* 0 - Valid bit for @tisci_msg_rm_ring_cfg_req addr_lo -* 1 - Valid bit for @tisci_msg_rm_ring_cfg_req addr_hi -* 2 - Valid bit for @tisci_msg_rm_ring_cfg_req count -* 3 - Valid bit for @tisci_msg_rm_ring_cfg_req mode -* 4 - Valid bit for @tisci_msg_rm_ring_cfg_req size -* 5 - Valid bit for @tisci_msg_rm_ring_cfg_req order_id -* 6 - Valid bit for @tisci_msg_rm_ring_cfg_req virtid -* 7 - Valid bit for @tisci_msg_rm_ring_cfg_req ASEL +* 0 - Valid bit for @addr_lo +* 1 - Valid bit for @addr_hi +* 2 - Valid bit for @count +* 3 - Valid bit for @mode +* 4 - Valid bit for @size +* 5 - Valid bit for @order_id +* 6 - Valid bit for @virtid +* 7 - Valid bit for @asel * @nav_id: Device ID of Navigator Subsystem from which the ring is allocated * @index: ring index to be configured. * @addr_lo: 32 LSBs of ring base address to be programmed into the ring's
@@ -1023,23 +1023,23 @@ struct rm_ti_sci_msg_udmap_rx_flow_opt_cfg {* parameters. The tx channel configuration fields are not valid, and will not * be used for ch configuration, if their corresponding valid bit is zero. * Valid bit usage: -* 0 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_pause_on_err -* 1 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_atype -* 2 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_chan_type -* 3 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_fetch_size -* 4 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::txcq_qnum -* 5 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_priority -* 6 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_qos -* 7 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_orderid -* 8 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_sched_priority -* 9 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_filt_einfo -* 10 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_filt_pswords -* 11 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_supr_tdpkt -* 12 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_credit_count -* 13 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::fdepth -* 14 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_burst_size -* 15 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_tdtype -* 16 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::extended_ch_type +* 0 - Valid bit for @tx_pause_on_err +* 1 - Valid bit for @tx_atype +* 2 - Valid bit for @tx_chan_type +* 3 - Valid bit for @tx_fetch_size +* 4 - Valid bit for @txcq_qnum +* 5 - Valid bit for @tx_priority +* 6 - Valid bit for @tx_qos +* 7 - Valid bit for @tx_orderid +* 8 - Valid bit for @tx_sched_priority +* 9 - Valid bit for @tx_filt_einfo +* 10 - Valid bit for @tx_filt_pswords +* 11 - Valid bit for @tx_supr_tdpkt +* 12 - Valid bit for @tx_credit_count +* 13 - Valid bit for @fdepth +* 14 - Valid bit for @tx_burst_size +* 15 - Valid bit for @tx_tdtype +* 16 - Valid bit for @extended_ch_type * * @nav_id: SoC device ID of Navigator Subsystem where tx channel is located *
@@ -1153,20 +1153,20 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg_req {* The rx channel configuration fields are not valid, and will not be used for * ch configuration, if their corresponding valid bit is zero. * Valid bit usage: -* 0 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_pause_on_err -* 1 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_atype -* 2 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_chan_type -* 3 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_fetch_size -* 4 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rxcq_qnum -* 5 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_priority -* 6 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_qos -* 7 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_orderid -* 8 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_sched_priority -* 9 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::flowid_start -* 10 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::flowid_cnt -* 11 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_ignore_short -* 12 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_ignore_long -* 14 - Valid bit for @ti_sci_msg_rm_udmap_rx_ch_cfg_req::rx_burst_size +* 0 - Valid bit for @rx_pause_on_err +* 1 - Valid bit for @rx_atype +* 2 - Valid bit for @rx_chan_type +* 3 - Valid bit for @rx_fetch_size +* 4 - Valid bit for @rxcq_qnum +* 5 - Valid bit for @rx_priority +* 6 - Valid bit for @rx_qos +* 7 - Valid bit for @rx_orderid +* 8 - Valid bit for @rx_sched_priority +* 9 - Valid bit for @flowid_start +* 10 - Valid bit for @flowid_cnt +* 11 - Valid bit for @rx_ignore_short +* 12 - Valid bit for @rx_ignore_long +* 14 - Valid bit for @rx_burst_size * * @nav_id: SoC device ID of Navigator Subsystem where rx channel is located *
@@ -1197,9 +1197,9 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg_req {* @flowid_start: UDMAP receive channel additional flows starting index * configuration to program into the flow_start field of the RCHAN_RFLOW_RNG * register. Specifies the starting index for flow IDs the receive channel is to -* make use of beyond the default flow. flowid_start and @ref flowid_cnt must be +* make use of beyond the default flow. flowid_start and @flowid_cnt must be * set as valid and configured together. The starting flow ID set by -* @ref flowid_cnt must be a flow index within the Navigator Subsystem's subset +* @flowid_start must be a flow index within the Navigator Subsystem's subset * of flows beyond the default flows statically mapped to receive channels. * The additional flows must be assigned to the host, or a subordinate of the * host, requesting configuration of the receive channel.
@@ -1207,10 +1207,10 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg_req {* @flowid_cnt: UDMAP receive channel additional flows count configuration to * program into the flowid_cnt field of the RCHAN_RFLOW_RNG register. * This field specifies how many flow IDs are in the additional contiguous range -* of legal flow IDs for the channel. @ref flowid_start and flowid_cnt must be +* of legal flow IDs for the channel. @flowid_start and flowid_cnt must be * set as valid and configured together. Disabling the valid_params field bit * for flowid_cnt indicates no flow IDs other than the default are to be -* allocated and used by the receive channel. @ref flowid_start plus flowid_cnt +* allocated and used by the receive channel. @flowid_start plus flowid_cnt * cannot be greater than the number of receive flows in the receive channel's * Navigator Subsystem. The additional flows must be assigned to the host, or a * subordinate of the host, requesting configuration of the receive channel.
@@ -1274,25 +1274,25 @@ struct ti_sci_msg_rm_udmap_rx_ch_cfg_req {* Bitfield defining validity of rx flow configuration parameters. The * rx flow configuration fields are not valid, and will not be used for flow * configuration, if their corresponding valid bit is zero. Valid bit usage: -* 0 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_einfo_present -* 1 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_psinfo_present -* 2 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_error_handling -* 3 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_desc_type -* 4 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_sop_offset -* 5 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_dest_qnum -* 6 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_src_tag_hi -* 7 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_src_tag_lo -* 8 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_dest_tag_hi -* 9 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_dest_tag_lo -* 10 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_src_tag_hi_sel -* 11 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_src_tag_lo_sel -* 12 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_dest_tag_hi_sel -* 13 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_dest_tag_lo_sel -* 14 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_fdq0_sz0_qnum -* 15 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_fdq1_sz0_qnum -* 16 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_fdq2_sz0_qnum -* 17 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_fdq3_sz0_qnum -* 18 - Valid bit for @tisci_msg_rm_udmap_flow_cfg_req::rx_ps_location +* 0 - Valid bit for @rx_einfo_present +* 1 - Valid bit for @rx_psinfo_present +* 2 - Valid bit for @rx_error_handling +* 3 - Valid bit for @rx_desc_type +* 4 - Valid bit for @rx_sop_offset +* 5 - Valid bit for @rx_dest_qnum +* 6 - Valid bit for @rx_src_tag_hi +* 7 - Valid bit for @rx_src_tag_lo +* 8 - Valid bit for @rx_dest_tag_hi +* 9 - Valid bit for @rx_dest_tag_lo +* 10 - Valid bit for @rx_src_tag_hi_sel +* 11 - Valid bit for @rx_src_tag_lo_sel +* 12 - Valid bit for @rx_dest_tag_hi_sel +* 13 - Valid bit for @rx_dest_tag_lo_sel +* 14 - Valid bit for @rx_fdq0_sz0_qnum +* 15 - Valid bit for @rx_fdq1_qnum +* 16 - Valid bit for @rx_fdq2_qnum +* 17 - Valid bit for @rx_fdq3_qnum +* 18 - Valid bit for @rx_ps_location * * @nav_id: SoC device ID of Navigator Subsystem from which the receive flow is * allocated
@@ -1313,7 +1313,7 @@ struct ti_sci_msg_rm_udmap_rx_ch_cfg_req {* * @rx_desc_type: * UDMAP receive flow descriptor type configuration to be programmed into the -* rx_desc_type field field of the flow's RFLOW_RFA register. +* rx_desc_type field of the flow's RFLOW_RFA register. * * @rx_sop_offset: * UDMAP receive flow start of packet offset configuration to be programmed
Signature · 1 line
2.34.1
PATCH v3 13/22 soc: ti: ti_sci_protocol.h: Add missing documentation for structs
In reply to Beleswar PadhiSome of the structs defined in ti_sci_protocol.h were missing documentation and some were not in correct style. Clean these up to resolve static warnings.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
include/linux/soc/ti/ti_sci_protocol.h | 374 ++++++++++++++++++++++++- 1 file changed, 363 insertions(+), 11 deletions(-)
include/linux/soc/ti/ti_sci_protocol.h +363 -11
@@ -42,9 +42,17 @@ struct ti_sci_core_ops {* @get_device: Command to request for device managed by TISCI * Returns 0 for successful exclusive request, else returns * corresponding error message. +* @get_device_exclusive: Command to request for device managed by TISCI that is +* exclusively owned by the requesting host. +* Returns 0 for successful exclusive request, else returns +* corresponding error message. * @idle_device: Command to idle a device managed by TISCI * Returns 0 for successful exclusive request, else returns * corresponding error message. +* @idle_device_exclusive: Command to idle a device managed by TISCI that is +* exclusively owned by requesting host. +* Returns 0 for successful exclusive request, else returns +* corresponding error message. * @put_device: Command to release a device managed by TISCI * Returns 0 for successful release, else returns corresponding * error message.
@@ -243,7 +251,7 @@ struct ti_sci_resource_desc {/** * struct ti_sci_rm_core_ops - Resource management core operations * @get_range: Get a range of resources belonging to ti sci host. -* @get_rage_from_shost: Get a range of resources belonging to +* @get_range_from_shost: Get a range of resources belonging to * specified host id. * - s_host: Host processing entity to which the * resources are allocated
@@ -322,6 +330,35 @@ struct ti_sci_rm_irq_ops {* * Parameters for Navigator Subsystem ring configuration * See @ti_sci_msg_rm_ring_cfg_req +* +* @valid_params: Bitfield defining validity of ring configuration parameters. +* The ring configuration fields are not valid, and will not be used for +* ring configuration, if their corresponding valid bit is zero. +* Valid bit usage: +* 0 - Valid bit for @addr_lo +* 1 - Valid bit for @addr_hi +* 2 - Valid bit for @count +* 3 - Valid bit for @mode +* 4 - Valid bit for @size +* 5 - Valid bit for @order_id +* 6 - Valid bit for @virtid +* 7 - Valid bit for @asel +* @nav_id: Device ID of Navigator Subsystem from which the ring is allocated +* @index: ring index to be configured. +* @addr_lo: 32 LSBs of ring base address to be programmed into the ring's +* RING_BA_LO register +* @addr_hi: 16 MSBs of ring base address to be programmed into the ring's +* RING_BA_HI register. +* @count: Number of ring elements. Must be even if mode is CREDENTIALS or QM +* modes. +* @mode: Specifies the mode the ring is to be configured. +* @size: Specifies encoded ring element size. To calculate the encoded size use +* the formula (log2(size_bytes) - 2), where size_bytes cannot be +* greater than 256. +* @order_id: Specifies the ring's bus order ID. +* @virtid: Ring virt ID value +* @asel: Ring ASEL (address select) value to be set into the ASEL field of the +* ring's RING_BA_HI register. */ struct ti_sci_msg_rm_ring_cfg {u32 valid_params;
@@ -397,10 +434,102 @@ struct ti_sci_rm_psil_ops {#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_BURST_SIZE_VALID BIT(14)/** -* Configures a Navigator Subsystem UDMAP transmit channel +* struct ti_sci_msg_rm_udmap_tx_ch_cfg - Configures a Navigator Subsystem UDMAP +* transmit channel +* +* @valid_params: Bitfield defining validity of tx channel configuration +* parameters. The tx channel configuration fields are not valid, and will not +* be used for ch configuration, if their corresponding valid bit is zero. +* Valid bit usage: +* 0 - Valid bit for @tx_pause_on_err +* 1 - Valid bit for @tx_atype +* 2 - Valid bit for @tx_chan_type +* 3 - Valid bit for @tx_fetch_size +* 4 - Valid bit for @txcq_qnum +* 5 - Valid bit for @tx_priority +* 6 - Valid bit for @tx_qos +* 7 - Valid bit for @tx_orderid +* 8 - Valid bit for @tx_sched_priority +* 9 - Valid bit for @tx_filt_einfo +* 10 - Valid bit for @tx_filt_pswords +* 11 - Valid bit for @tx_supr_tdpkt +* 12 - Valid bit for @tx_credit_count +* 13 - Valid bit for @fdepth +* 14 - Valid bit for @tx_burst_size +* 15 - Valid bit for @tx_tdtype +* 16 - Valid bit for @extended_ch_type +* +* @nav_id: SoC device ID of Navigator Subsystem where tx channel is located +* +* @index: UDMAP transmit channel index. +* +* @tx_pause_on_err: UDMAP transmit channel pause on error configuration to +* be programmed into the tx_pause_on_err field of the channel's TCHAN_TCFG +* register. +* +* @tx_filt_einfo: UDMAP transmit channel extended packet information passing +* configuration to be programmed into the tx_filt_einfo field of the +* channel's TCHAN_TCFG register. +* +* @tx_filt_pswords: UDMAP transmit channel protocol specific word passing +* configuration to be programmed into the tx_filt_pswords field of the +* channel's TCHAN_TCFG register. +* +* @tx_atype: UDMAP transmit channel non Ring Accelerator access pointer +* interpretation configuration to be programmed into the tx_atype field of +* the channel's TCHAN_TCFG register. +* +* @tx_chan_type: UDMAP transmit channel functional channel type and work +* passing mechanism configuration to be programmed into the tx_chan_type +* field of the channel's TCHAN_TCFG register. +* +* @tx_supr_tdpkt: UDMAP transmit channel teardown packet generation suppression +* configuration to be programmed into the tx_supr_tdpkt field of the channel's +* TCHAN_TCFG register. +* +* @tx_fetch_size: UDMAP transmit channel number of 32-bit descriptor words to +* fetch configuration to be programmed into the tx_fetch_size field of the +* channel's TCHAN_TCFG register. The user must make sure to set the maximum +* word count that can pass through the channel for any allowed descriptor type. +* +* @tx_credit_count: UDMAP transmit channel transfer request credit count +* configuration to be programmed into the count field of the TCHAN_TCREDIT +* register. Specifies how many credits for complete TRs are available. * -* Configures a Navigator Subsystem UDMAP transmit channel registers. -* See @ti_sci_msg_rm_udmap_tx_ch_cfg_req +* @txcq_qnum: UDMAP transmit channel completion queue configuration to be +* programmed into the txcq_qnum field of the TCHAN_TCQ register. The specified +* completion queue must be assigned to the host, or a subordinate of the host, +* requesting configuration of the transmit channel. +* +* @tx_priority: UDMAP transmit channel transmit priority value to be programmed +* into the priority field of the channel's TCHAN_TPRI_CTRL register. +* +* @tx_qos: UDMAP transmit channel transmit qos value to be programmed into the +* qos field of the channel's TCHAN_TPRI_CTRL register. +* +* @tx_orderid: UDMAP transmit channel bus order id value to be programmed into +* the orderid field of the channel's TCHAN_TPRI_CTRL register. +* +* @fdepth: UDMAP transmit channel FIFO depth configuration to be programmed +* into the fdepth field of the TCHAN_TFIFO_DEPTH register. Sets the number of +* Tx FIFO bytes which are allowed to be stored for the channel. Check the UDMAP +* section of the TRM for restrictions regarding this parameter. +* +* @tx_sched_priority: UDMAP transmit channel tx scheduling priority +* configuration to be programmed into the priority field of the channel's +* TCHAN_TST_SCHED register. +* +* @tx_burst_size: UDMAP transmit channel burst size configuration to be +* programmed into the tx_burst_size field of the TCHAN_TCFG register. +* +* @tx_tdtype: UDMAP transmit channel teardown type configuration to be +* programmed into the tdtype field of the TCHAN_TCFG register: +* 0 - Return immediately +* 1 - Wait for completion message from remote peer +* +* @extended_ch_type: Valid for BCDMA. +* 0 - the channel is split tx channel (tchan) +* 1 - the channel is block copy channel (bchan) */ struct ti_sci_msg_rm_udmap_tx_ch_cfg {u32 valid_params;
@@ -433,10 +562,96 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg { };/** -* Configures a Navigator Subsystem UDMAP receive channel +* struct ti_sci_msg_rm_udmap_rx_ch_cfg - Configures a Navigator Subsystem UDMAP +* receive channel +* +* @valid_params: Bitfield defining validity of rx channel configuration +* parameters. +* The rx channel configuration fields are not valid, and will not be used for +* ch configuration, if their corresponding valid bit is zero. +* Valid bit usage: +* 0 - Valid bit for @rx_pause_on_err +* 1 - Valid bit for @rx_atype +* 2 - Valid bit for @rx_chan_type +* 3 - Valid bit for @rx_fetch_size +* 4 - Valid bit for @rxcq_qnum +* 5 - Valid bit for @rx_priority +* 6 - Valid bit for @rx_qos +* 7 - Valid bit for @rx_orderid +* 8 - Valid bit for @rx_sched_priority +* 9 - Valid bit for @flowid_start +* 10 - Valid bit for @flowid_cnt +* 11 - Valid bit for @rx_ignore_short +* 12 - Valid bit for @rx_ignore_long +* 14 - Valid bit for @rx_burst_size +* +* @nav_id: SoC device ID of Navigator Subsystem where rx channel is located +* +* @index: UDMAP receive channel index. +* +* @rx_fetch_size: UDMAP receive channel number of 32-bit descriptor words to +* fetch configuration to be programmed into the rx_fetch_size field of the +* channel's RCHAN_RCFG register. +* +* @rxcq_qnum: UDMAP receive channel completion queue configuration to be +* programmed into the rxcq_qnum field of the RCHAN_RCQ register. +* The specified completion queue must be assigned to the host, or a subordinate +* of the host, requesting configuration of the receive channel. +* +* @rx_priority: UDMAP receive channel receive priority value to be programmed +* into the priority field of the channel's RCHAN_RPRI_CTRL register. +* +* @rx_qos: UDMAP receive channel receive qos value to be programmed into the +* qos field of the channel's RCHAN_RPRI_CTRL register. * -* Configures a Navigator Subsystem UDMAP receive channel registers. -* See @ti_sci_msg_rm_udmap_rx_ch_cfg_req +* @rx_orderid: UDMAP receive channel bus order id value to be programmed into +* the orderid field of the channel's RCHAN_RPRI_CTRL register. +* +* @rx_sched_priority: UDMAP receive channel rx scheduling priority +* configuration to be programmed into the priority field of the channel's +* RCHAN_RST_SCHED register. +* +* @flowid_start: UDMAP receive channel additional flows starting index +* configuration to program into the flow_start field of the RCHAN_RFLOW_RNG +* register. Specifies the starting index for flow IDs the receive channel is to +* make use of beyond the default flow. flowid_start and @flowid_cnt must be +* set as valid and configured together. The starting flow ID set by +* @flowid_start must be a flow index within the Navigator Subsystem's subset +* of flows beyond the default flows statically mapped to receive channels. +* The additional flows must be assigned to the host, or a subordinate of the +* host, requesting configuration of the receive channel. +* +* @flowid_cnt: UDMAP receive channel additional flows count configuration to +* program into the flowid_cnt field of the RCHAN_RFLOW_RNG register. +* This field specifies how many flow IDs are in the additional contiguous range +* of legal flow IDs for the channel. @flowid_start and flowid_cnt must be +* set as valid and configured together. Disabling the valid_params field bit +* for flowid_cnt indicates no flow IDs other than the default are to be +* allocated and used by the receive channel. @flowid_start plus flowid_cnt +* cannot be greater than the number of receive flows in the receive channel's +* Navigator Subsystem. The additional flows must be assigned to the host, or a +* subordinate of the host, requesting configuration of the receive channel. +* +* @rx_pause_on_err: UDMAP receive channel pause on error configuration to be +* programmed into the rx_pause_on_err field of the channel's RCHAN_RCFG +* register. +* +* @rx_atype: UDMAP receive channel non Ring Accelerator access pointer +* interpretation configuration to be programmed into the rx_atype field of the +* channel's RCHAN_RCFG register. +* +* @rx_chan_type: UDMAP receive channel functional channel type and work passing +* mechanism configuration to be programmed into the rx_chan_type field of the +* channel's RCHAN_RCFG register. +* +* @rx_ignore_short: UDMAP receive channel short packet treatment configuration +* to be programmed into the rx_ignore_short field of the RCHAN_RCFG register. +* +* @rx_ignore_long: UDMAP receive channel long packet treatment configuration to +* be programmed into the rx_ignore_long field of the RCHAN_RCFG register. +* +* @rx_burst_size: UDMAP receive channel burst size configuration to be +* programmed into the rx_burst_size field of the RCHAN_RCFG register. */ struct ti_sci_msg_rm_udmap_rx_ch_cfg {u32 valid_params;
@@ -463,10 +678,142 @@ struct ti_sci_msg_rm_udmap_rx_ch_cfg { };/** -* Configures a Navigator Subsystem UDMAP receive flow +* struct ti_sci_msg_rm_udmap_flow_cfg - Configures a Navigator Subsystem UDMAP +* receive flow +* +* @valid_params: +* Bitfield defining validity of rx flow configuration parameters. The +* rx flow configuration fields are not valid, and will not be used for flow +* configuration, if their corresponding valid bit is zero. Valid bit usage: +* 0 - Valid bit for @rx_einfo_present +* 1 - Valid bit for @rx_psinfo_present +* 2 - Valid bit for @rx_error_handling +* 3 - Valid bit for @rx_desc_type +* 4 - Valid bit for @rx_sop_offset +* 5 - Valid bit for @rx_dest_qnum +* 6 - Valid bit for @rx_src_tag_hi +* 7 - Valid bit for @rx_src_tag_lo +* 8 - Valid bit for @rx_dest_tag_hi +* 9 - Valid bit for @rx_dest_tag_lo +* 10 - Valid bit for @rx_src_tag_hi_sel +* 11 - Valid bit for @rx_src_tag_lo_sel +* 12 - Valid bit for @rx_dest_tag_hi_sel +* 13 - Valid bit for @rx_dest_tag_lo_sel +* 14 - Valid bit for @rx_fdq0_sz0_qnum +* 15 - Valid bit for @rx_fdq1_qnum +* 16 - Valid bit for @rx_fdq2_qnum +* 17 - Valid bit for @rx_fdq3_qnum +* 18 - Valid bit for @rx_ps_location +* +* @nav_id: SoC device ID of Navigator Subsystem from which the receive flow is +* allocated +* +* @flow_index: UDMAP receive flow index for non-optional configuration. +* +* @rx_einfo_present: +* UDMAP receive flow extended packet info present configuration to be +* programmed into the rx_einfo_present field of the flow's RFLOW_RFA register. +* +* @rx_psinfo_present: +* UDMAP receive flow PS words present configuration to be programmed into the +* rx_psinfo_present field of the flow's RFLOW_RFA register. +* +* @rx_error_handling: +* UDMAP receive flow error handling configuration to be programmed into the +* rx_error_handling field of the flow's RFLOW_RFA register. +* +* @rx_desc_type: +* UDMAP receive flow descriptor type configuration to be programmed into the +* rx_desc_type field of the flow's RFLOW_RFA register. +* +* @rx_sop_offset: +* UDMAP receive flow start of packet offset configuration to be programmed +* into the rx_sop_offset field of the RFLOW_RFA register. See the UDMAP +* section of the TRM for more information on this setting. Valid values for +* this field are 0-255 bytes. +* +* @rx_dest_qnum: +* UDMAP receive flow destination queue configuration to be programmed into the +* rx_dest_qnum field of the flow's RFLOW_RFA register. The specified +* destination queue must be valid within the Navigator Subsystem and must be +* owned by the host, or a subordinate of the host, requesting allocation and +* configuration of the receive flow. +* +* @rx_src_tag_hi: +* UDMAP receive flow source tag high byte constant configuration to be +* programmed into the rx_src_tag_hi field of the flow's RFLOW_RFB register. +* See the UDMAP section of the TRM for more information on this setting. +* +* @rx_src_tag_lo: +* UDMAP receive flow source tag low byte constant configuration to be +* programmed into the rx_src_tag_lo field of the flow's RFLOW_RFB register. +* See the UDMAP section of the TRM for more information on this setting. +* +* @rx_dest_tag_hi: +* UDMAP receive flow destination tag high byte constant configuration to be +* programmed into the rx_dest_tag_hi field of the flow's RFLOW_RFB register. +* See the UDMAP section of the TRM for more information on this setting. +* +* @rx_dest_tag_lo: +* UDMAP receive flow destination tag low byte constant configuration to be +* programmed into the rx_dest_tag_lo field of the flow's RFLOW_RFB register. +* See the UDMAP section of the TRM for more information on this setting. +* +* @rx_src_tag_hi_sel: +* UDMAP receive flow source tag high byte selector configuration to be +* programmed into the rx_src_tag_hi_sel field of the RFLOW_RFC register. See +* the UDMAP section of the TRM for more information on this setting. +* +* @rx_src_tag_lo_sel: +* UDMAP receive flow source tag low byte selector configuration to be +* programmed into the rx_src_tag_lo_sel field of the RFLOW_RFC register. See +* the UDMAP section of the TRM for more information on this setting. +* +* @rx_dest_tag_hi_sel: +* UDMAP receive flow destination tag high byte selector configuration to be +* programmed into the rx_dest_tag_hi_sel field of the RFLOW_RFC register. See +* the UDMAP section of the TRM for more information on this setting. +* +* @rx_dest_tag_lo_sel: +* UDMAP receive flow destination tag low byte selector configuration to be +* programmed into the rx_dest_tag_lo_sel field of the RFLOW_RFC register. See +* the UDMAP section of the TRM for more information on this setting. +* +* @rx_fdq0_sz0_qnum: +* UDMAP receive flow free descriptor queue 0 configuration to be programmed +* into the rx_fdq0_sz0_qnum field of the flow's RFLOW_RFD register. See the +* UDMAP section of the TRM for more information on this setting. The specified +* free queue must be valid within the Navigator Subsystem and must be owned +* by the host, or a subordinate of the host, requesting allocation and +* configuration of the receive flow. +* +* @rx_fdq1_qnum: +* UDMAP receive flow free descriptor queue 1 configuration to be programmed +* into the rx_fdq1_qnum field of the flow's RFLOW_RFD register. See the +* UDMAP section of the TRM for more information on this setting. The specified +* free queue must be valid within the Navigator Subsystem and must be owned +* by the host, or a subordinate of the host, requesting allocation and +* configuration of the receive flow. +* +* @rx_fdq2_qnum: +* UDMAP receive flow free descriptor queue 2 configuration to be programmed +* into the rx_fdq2_qnum field of the flow's RFLOW_RFE register. See the +* UDMAP section of the TRM for more information on this setting. The specified +* free queue must be valid within the Navigator Subsystem and must be owned +* by the host, or a subordinate of the host, requesting allocation and +* configuration of the receive flow. +* +* @rx_fdq3_qnum: +* UDMAP receive flow free descriptor queue 3 configuration to be programmed +* into the rx_fdq3_qnum field of the flow's RFLOW_RFE register. See the +* UDMAP section of the TRM for more information on this setting. The specified +* free queue must be valid within the Navigator Subsystem and must be owned +* by the host, or a subordinate of the host, requesting allocation and +* configuration of the receive flow. * -* Configures a Navigator Subsystem UDMAP receive flow's registers. -* See @tis_ci_msg_rm_udmap_flow_cfg_req +* @rx_ps_location: +* UDMAP receive flow PS words location configuration to be programmed into the +* rx_ps_location field of the flow's RFLOW_RFA register. */ struct ti_sci_msg_rm_udmap_flow_cfg {u32 valid_params;
@@ -516,7 +863,7 @@ struct ti_sci_msg_rm_udmap_flow_cfg {* struct ti_sci_rm_udmap_ops - UDMA Management operations * @tx_ch_cfg: configure SoC Navigator Subsystem UDMA transmit channel. * @rx_ch_cfg: configure SoC Navigator Subsystem UDMA receive channel. -* @rx_flow_cfg1: configure SoC Navigator Subsystem UDMA receive flow. +* @rx_flow_cfg: configure SoC Navigator Subsystem UDMA receive flow. */ struct ti_sci_rm_udmap_ops { int (*tx_ch_cfg)(const struct ti_sci_handle *handle,
@@ -558,10 +905,15 @@ struct ti_sci_proc_ops {/** * struct ti_sci_ops - Function support for TI SCI +* @core_ops: SoC core operations * @dev_ops: Device specific operations * @clk_ops: Clock specific operations +* @pm_ops: Low Power Mode (LPM) control operations * @rm_core_ops: Resource management core operations. * @rm_irq_ops: IRQ management specific operations +* @rm_ring_ops: Ring Accelerator Management operations +* @rm_psil_ops: PSI-L thread operations +* @rm_udmap_ops: UDMA Management operations * @proc_ops: Processor Control specific operations */ struct ti_sci_ops {
Signature · 1 line
2.34.1
PATCH v3 14/22 firmware: ti_sci: Do not export reboot control
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
This function is only to be used by the TI-SCI driver itself through its registered restart handler, exporting this control to any TI-SCI consumer is not needed nor probably a good idea.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 3 --- include/linux/soc/ti/ti_sci_protocol.h | 12 ------------ 2 files changed, 15 deletions(-)
drivers/firmware/ti_sci.c +0 -3
@@ -2567,7 +2567,6 @@ static int ti_sci_cmd_proc_get_status(const struct ti_sci_handle *handle,static void ti_sci_setup_ops (struct ti_sci_info *info) {struct ti_sci_ops *ops = &info->handle.ops; -struct ti_sci_core_ops *core_ops = &ops->core_ops;struct ti_sci_dev_ops *dops = &ops->dev_ops;struct ti_sci_clk_ops *cops = &ops->clk_ops;struct ti_sci_pm_ops *pmops = &ops->pm_ops;
@@ -2578,8 +2577,6 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops;struct ti_sci_proc_ops *pops = &ops->proc_ops; - core_ops->reboot_device = ti_sci_cmd_core_reboot; - dops->get_device = ti_sci_cmd_get_device; dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; dops->idle_device = ti_sci_cmd_idle_device;
include/linux/soc/ti/ti_sci_protocol.h +0 -12
@@ -27,16 +27,6 @@ struct ti_sci_version_info {struct ti_sci_handle ; -/** -* struct ti_sci_core_ops - SoC Core Operations -* @reboot_device: Reboot the SoC -* Returns 0 for successful request(ideally should never return), -* else returns corresponding error value. -*/ -struct ti_sci_core_ops { -int (*reboot_device)(const struct ti_sci_handle *handle); -}; -/** * struct ti_sci_dev_ops - Device control operations * @get_device: Command to request for device managed by TISCI
@@ -905,7 +895,6 @@ struct ti_sci_proc_ops {/** * struct ti_sci_ops - Function support for TI SCI -* @core_ops: SoC core operations * @dev_ops: Device specific operations * @clk_ops: Clock specific operations * @pm_ops: Low Power Mode (LPM) control operations
@@ -917,7 +906,6 @@ struct ti_sci_proc_ops {* @proc_ops: Processor Control specific operations */ struct ti_sci_ops { -struct ti_sci_core_ops core_ops;struct ti_sci_dev_ops dev_ops;struct ti_sci_clk_ops clk_ops;struct ti_sci_pm_ops pm_ops;
Signature · 1 line
2.34.1
PATCH v3 15/22 firmware: ti_sci: Use pmops fxn pointers in suspend/resume hooks
In reply to Beleswar PadhiThe suspend/resume hooks invoke ti_sci_cmd_set_latency_constraint() and ti_sci_msg_cmd_lpm_wake_reason() functions directly. These functions are already exposed via pmops function pointers and pmops is available by the time suspend/resume hooks are executed. Therefore, switch to using the pmops function pointers instead of directly invoking the functions. This also helps in a cleanup later.
Since commit 60357991f6b9 ("firmware: ti_sci: Introduce Power Management Ops"), pmops->lpm_wake_reason is only populated when the firmware reports MSG_FLAG_CAPS_LPM_DM_MANAGED, but the resume hook bypassed that by calling ti_sci_msg_cmd_lpm_wake_reason() unconditionally. Guard the call with the same fw_caps check which should be the correct behaviour.
---
v3: Changelog:
1. Carried R/B tag from Kendall.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti_sci.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/firmware/ti_sci.c +13 -8
@@ -3154,6 +3154,7 @@ static int ti_sci_suspend(struct device *dev) {struct ti_sci_info *info =dev_get_drvdata (dev);struct device *cpu_dev, *cpu_dev_max =NULL ; +struct ti_sci_pm_ops *pmops = &info->handle.ops.pm_ops;s32 val, cpu_lat =0 ;u16 cpu_lat_ms;int i, ret;
@@ -3175,9 +3176,9 @@ static int ti_sci_suspend(struct device *dev) cpu_lat_ms = cpu_lat /USEC_PER_MSEC ;dev_dbg (cpu_dev_max,"%s: sending max CPU latency=%u ms\n" , __func__, cpu_lat_ms); - ret =ti_sci_cmd_set_latency_constraint (&info->handle, - cpu_lat_ms, -TISCI_MSG_CONSTRAINT_SET ); + ret = pmops->set_latency_constraint (&info->handle, + cpu_lat_ms, +TISCI_MSG_CONSTRAINT_SET );if (ret)return ret; }
@@ -3209,6 +3210,7 @@ static int ti_sci_resume_noirq(struct device *dev)struct ti_sci_info *info =dev_get_drvdata (dev);struct ti_sci_msg_req_manage_irq *irq_desc;struct ti_sci_irq *irq; +struct ti_sci_pm_ops *pmops = &info->handle.ops.pm_ops;struct hlist_node *tmp_node;int ret =0 , err =0 , i;u32 source;
@@ -3262,11 +3264,14 @@ static int ti_sci_resume_noirq(struct device *dev)break ; } - ret =ti_sci_msg_cmd_lpm_wake_reason (&info->handle, &source, &time, &pin, &mode); -/* Do not fail to resume on error as the wake reason is not critical */ -if (!ret) -dev_info (dev,"ti_sci: wakeup source:0x%x, pin:0x%x, mode:0x%x\n" , - source, pin, mode); +if (info->fw_caps &MSG_FLAG_CAPS_LPM_DM_MANAGED ) { + ret = pmops->lpm_wake_reason (&info->handle, &source, &time, &pin, + &mode); +/* Do not fail to resume on error as the wake reason is not critical */ +if (!ret) +dev_info (dev,"ti_sci: wakeup source:0x%x, pin:0x%x, mode:0x%x\n" , + source, pin, mode); + }return err; }
Signature · 1 line
2.34.1
PATCH v3 16/22 firmware: ti_sci: Move the huge ti_sci file into its own directory
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Move the huge ti_sci.c file and its header into its own "ti" sub-directory. While at it, rename the file to ti_sci_core.c as this file will be broken down into smaller files tied to operations as part of future cleanups.
---
v3: Changelog:
1. Rename ti_sci.c to ti_sci_core.c while refactoring the files. [Andrew]
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
MAINTAINERS | 2 +-
drivers/firmware/Kconfig | 17 +----------------
drivers/firmware/Makefile | 2 +-
drivers/firmware/ti/Kconfig | 17 +++++++++++++++++
drivers/firmware/ti/Makefile | 4 ++++
drivers/firmware/{ => ti}/ti_sci.h | 0
drivers/firmware/{ti_sci.c => ti/ti_sci_core.c} | 0
7 files changed, 24 insertions(+), 18 deletions(-)
create mode 100644 drivers/firmware/ti/Kconfig
create mode 100644 drivers/firmware/ti/Makefile
rename drivers/firmware/{ => ti}/ti_sci.h (100%)
rename drivers/firmware/{ti_sci.c => ti/ti_sci_core.c} (100%)MAINTAINERS +1 -1
@@ -27774,7 +27774,7 @@ F: Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml F: Documentation/devicetree/bindings/reset/ti,sci-reset.yaml F: Documentation/devicetree/bindings/soc/ti/sci-pm-domain.yaml F: drivers/clk/keystone/sci-clk.c -F: drivers/firmware/ti_sci* +F: drivers/firmware/ti/* F: drivers/irqchip/irq-ti-sci-inta.c F: drivers/irqchip/irq-ti-sci-intr.c F: drivers/reset/reset-ti-sci.c
drivers/firmware/Kconfig +1 -16
@@ -236,22 +236,6 @@ config TH1520_AON_PROTOCOL the kernel through the Always-On protocol, using hardware mailbox as a medium. Say yes if you need such capabilities. -config TI_SCI_PROTOCOL - tristate "TI System Control Interface (TISCI) Message Protocol" - depends on TI_MESSAGE_MANAGER - default ARCH_K3 - help - TI System Control Interface (TISCI) Message Protocol is used to manage - compute systems such as ARM, DSP etc with the system controller in - complex System on Chip(SoC) such as those found on certain keystone - generation SoC from TI. - - System controller provides various facilities including power - management function support. - - This protocol library is used by client drivers to use the features - provided by the system controller. - config TRUSTED_FOUNDATIONS bool "Trusted Foundations secure monitor support" depends on ARM && CPU_V7
@@ -313,6 +297,7 @@ source "drivers/firmware/qcom/Kconfig" source "drivers/firmware/samsung/Kconfig" source "drivers/firmware/smccc/Kconfig" source "drivers/firmware/tegra/Kconfig" +source "drivers/firmware/ti/Kconfig" source "drivers/firmware/xilinx/Kconfig" endmenu
drivers/firmware/Makefile +1 -1
@@ -21,7 +21,6 @@ obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o obj-$(CONFIG_SYSFB) += sysfb.o obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o -obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o
@@ -40,4 +39,5 @@ obj-y += qcom/ obj-y += samsung/ obj-y += smccc/ obj-y += tegra/ +obj-y += ti/ obj-y += xilinx/
drivers/firmware/ti/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config TI_SCI_PROTOCOL + tristate "TI System Control Interface (TISCI) Message Protocol" + depends on TI_MESSAGE_MANAGER + default ARCH_K3 + help + TI System Control Interface (TISCI) Message Protocol is used to manage + compute systems such as ARM, DSP etc with the system controller in + complex System on Chip(SoC) such as those found on certain keystone + generation SoC from TI. + + System controller provides various facilities including power + management function support. + + This protocol library is used by client drivers to use the features + provided by the system controller.
drivers/firmware/ti/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +ti_sci-y := ti_sci_core.o +obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h renamed from drivers/firmware/ti_sci.h +0 -0
drivers/firmware/ti/ti_sci_core.c renamed from drivers/firmware/ti_sci.c +0 -0
Signature · 1 line
2.34.1
Nishanth Menon
maintainerRe: [PATCH v3 16/22] firmware: ti_sci: Move the huge ti_sci file into its own directory
Quoted 10 lines · Beleswar Padhi
From: Andrew Davis <[email protected]>
Move the huge
ti_sci.cfile and its header into its own "ti" sub-directory. While at it, rename the file toti_sci_core.cas this file will be broken down into smaller files tied to operations as part of future cleanups.Signed-off-by Andrew Davis <[email protected]>Signed-off-by Beleswar Padhi <[email protected]>---
This patch conflicts with v7.4-rc2 as below -> could you rebase the series to latest linux-next or v7.4-rc2?
0af298e62e5c treewide: refresh kmalloc_obj() conversions4dd10fbbeb9c treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family
Signature · 4 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D https://ti.com/opensource
PATCH v3 17/22 firmware: ti: ti_sci: Add missing includes for self-contained headers
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
ti_sci.h and ti_sci_protocol.h do not directly include the headers that define the types and helpers they use. They currently build only because every file that includes them happens to also pull in linux/mailbox_client.h or similar headers first, which transitively provide these definitions.
Make both headers self-contained by adding the missing includes, so that they no longer depend on include order or on other headers being pulled in first. This is needed ahead of the following commits, which split ti_sci.c into several new source files that will include ti_sci.h directly.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/ti_sci.h | 3 +++ include/linux/soc/ti/ti_sci_protocol.h | 5 +++++ 2 files changed, 8 insertions(+)
drivers/firmware/ti/ti_sci.h +3 -0
@@ -12,6 +12,9 @@#ifndef __TI_SCI_H#define __TI_SCI_H +#include <linux/compiler_types.h> +#include <linux/types.h> +/* Generic Messages */ #define TI_SCI_MSG_ENABLE_WDT 0x0000#define TI_SCI_MSG_WAKE_RESET 0x0001
include/linux/soc/ti/ti_sci_protocol.h +5 -0
@@ -9,6 +9,11 @@#ifndef __TISCI_PROTOCOL_H#define __TISCI_PROTOCOL_H +#include <linux/device.h> +#include <linux/err.h> +#include <linux/types.h> +#include <linux/spinlock.h> +/** * struct ti_sci_version_info - version information structure * @abi_major: Major ABI version. Change here implies risk of backward
Signature · 1 line
2.34.1
PATCH v3 18/22 firmware: ti: ti_sci_device: Move device ops into its own file
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Extract the device operations related functions and services from ti_sci_core.c into its own file. This breaks down the single large file into smaller logical files for better readability and maintenance.
---
v3: Changelog:
1. Update commit message to remove ti_sci_core.c file renaming as that is already done in [PATCH v3 16/22] now.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/Makefile | 1 + drivers/firmware/ti/ti_sci.h | 7 + drivers/firmware/ti/ti_sci_core.c | 378 +-------------------------- drivers/firmware/ti/ti_sci_device.c | 388 ++++++++++++++++++++++++++++ 4 files changed, 401 insertions(+), 373 deletions(-) create mode 100644 drivers/firmware/ti/ti_sci_device.c
drivers/firmware/ti/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only ti_sci-y := ti_sci_core.o +ti_sci-y += ti_sci_device.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h +7 -0
@@ -1560,4 +1560,11 @@ struct ti_sci_msg_resp_get_status { u32 status_flags; } __packed; +int ti_sci_do_xfer (const struct ti_sci_handle *handle, +u16 msg_type,u32 msg_flags, +void *tx_message,size_t tx_message_size, +void *rx_message,size_t rx_message_size); + +void ti_sci_setup_device_ops (struct ti_sci_dev_ops *dops); +#endif /* __TI_SCI_H */
drivers/firmware/ti/ti_sci_core.c +5 -373
396 lines not on this page · raw message
drivers/firmware/ti/ti_sci_device.c new file +388 -0
388 lines not on this page · raw message
Signature · 1 line
2.34.1
Nishanth Menon
maintainerRe: [PATCH v3 18/22] firmware: ti: ti_sci_device: Move device ops into its own file
drivers/firmware/ti/ti_sci_device.c line 3
Quoted 9 lines · Beleswar Padhi
drivers/firmware/ti/ti_sci_device.c new file +3
-0@@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Texas Instruments System Control Interface Protocol Driver
^^ Fix this please while at it, please state what the driver is for (device control for example here)
btw, Andrew, Beleswar, thank you for cleaning this up.
Signature · 4 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D https://ti.com/opensource
PATCH v3 19/22 firmware: ti: ti_sci_clock: Move clock ops into its own file
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Extract the clock operations related functions and services from ti_sci_core.c into its own file. This breaks down the single large file into smaller logical files for better readability and maintenance.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/Makefile | 1 + drivers/firmware/ti/ti_sci.h | 1 + drivers/firmware/ti/ti_sci_clock.c | 553 +++++++++++++++++++++++++++++ drivers/firmware/ti/ti_sci_core.c | 535 +--------------------------- 4 files changed, 556 insertions(+), 534 deletions(-) create mode 100644 drivers/firmware/ti/ti_sci_clock.c
drivers/firmware/ti/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only ti_sci-y := ti_sci_core.o +ti_sci-y += ti_sci_clock.o ti_sci-y += ti_sci_device.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h +1 -0
@@ -1566,5 +1566,6 @@ int ti_sci_do_xfer(const struct ti_sci_handle *handle, void *rx_message, size_t rx_message_size);void ti_sci_setup_device_ops (struct ti_sci_dev_ops *dops); +void ti_sci_setup_clock_ops (struct ti_sci_clk_ops *cops);#endif /* __TI_SCI_H */
drivers/firmware/ti/ti_sci_clock.c new file +553 -0
553 lines not on this page · raw message
drivers/firmware/ti/ti_sci_core.c +1 -534
547 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 20/22 firmware: ti: ti_sci_pm: Move pm ops into its own file
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Extract the power management operations related functions and services from ti_sci_core.c into its own file. This breaks down the single large file into smaller logical files for better readability and maintenance.
The pm ops need access to the TI SCI instance to get the device used for error reporting. Move struct ti_sci_xfer, struct ti_sci_xfers_info, struct ti_sci_desc, struct ti_sci_info and handle_to_ti_sci_info() from ti_sci_core.c into ti_sci.h, along with the includes they need, so that they can be shared with the split files. Upcoming splits also need access to the instance state, so this is done once here.
---
v3: Changelog:
1. Correct API name in dev_err() string forti_sci_cmd_set_latency_constraint(). [Kendall]
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/Makefile | 1 + drivers/firmware/ti/ti_sci.h | 100 ++++++++++++++ drivers/firmware/ti/ti_sci_core.c | 220 +----------------------------- drivers/firmware/ti/ti_sci_pm.c | 145 ++++++++++++++++++++ 4 files changed, 247 insertions(+), 219 deletions(-) create mode 100644 drivers/firmware/ti/ti_sci_pm.c
drivers/firmware/ti/Makefile +1 -0
@@ -3,4 +3,5 @@ ti_sci-y := ti_sci_core.o ti_sci-y += ti_sci_clock.o ti_sci-y += ti_sci_device.o +ti_sci-y += ti_sci_pm.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h +100 -0
113 lines not on this page · raw message
drivers/firmware/ti/ti_sci_core.c +1 -219
261 lines not on this page · raw message
drivers/firmware/ti/ti_sci_pm.c new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 21/22 firmware: ti: ti_sci_rm: Move rm ops into its own file
In reply to Beleswar PadhiFrom: Andrew Davis <[email protected]>
Extract the resource management operations related functions and services from ti_sci_core.c into its own file. This breaks down the single large file into smaller logical files for better readability and maintenance.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. Include headers: <linux/bitmap.h>, <linux/of.h> and <linux/slab.h> to be able to build ti_sci_rm.c standalone for arm32 platforms like keystone.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/Makefile | 1 + drivers/firmware/ti/ti_sci.h | 20 + drivers/firmware/ti/ti_sci_core.c | 875 +--------------------------- drivers/firmware/ti/ti_sci_rm.c | 910 ++++++++++++++++++++++++++++++ 4 files changed, 936 insertions(+), 870 deletions(-) create mode 100644 drivers/firmware/ti/ti_sci_rm.c
drivers/firmware/ti/Makefile +1 -0
@@ -4,4 +4,5 @@ ti_sci-y := ti_sci_core.o ti_sci-y += ti_sci_clock.o ti_sci-y += ti_sci_device.o ti_sci-y += ti_sci_pm.o +ti_sci-y += ti_sci_rm.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h +20 -0
@@ -112,6 +112,7 @@ struct ti_sci_info {int users; }; +#define cl_to_ti_sci_info (c) container_of(c, struct ti_sci_info, cl)#define handle_to_ti_sci_info (h) container_of(h, struct ti_sci_info, handle)/* Generic Messages */
@@ -906,6 +907,16 @@ struct ti_sci_msg_req_manage_irq {u8 secondary_host; } __packed; +/** +* struct ti_sci_irq - Description of allocated irqs +* @node: Link to hash table +* @desc: Description of the irq +*/ +struct ti_sci_irq { +struct hlist_node node; +struct ti_sci_msg_req_manage_irq desc; +}; +/** * struct ti_sci_msg_rm_ring_cfg_req - Configure a Navigator Subsystem ring *
@@ -1667,5 +1678,14 @@ int ti_sci_do_xfer(const struct ti_sci_handle *handle,void ti_sci_setup_device_ops (struct ti_sci_dev_ops *dops);void ti_sci_setup_clock_ops (struct ti_sci_clk_ops *cops);void ti_sci_setup_pm_ops (struct ti_sci_pm_ops *pmops); +void ti_sci_setup_rm_core_ops (struct ti_sci_rm_core_ops *rm_core_ops); +void ti_sci_setup_rm_irq_ops (struct ti_sci_rm_irq_ops *iops); +void ti_sci_setup_rm_ringacc_ops (struct ti_sci_rm_ringacc_ops *rops); +void ti_sci_setup_rm_psil_ops (struct ti_sci_rm_psil_ops *psilops); +void ti_sci_setup_rm_udmap_ops (struct ti_sci_rm_udmap_ops *udmap_ops); +int ti_sci_manage_irq (const struct ti_sci_handle *handle,u32 valid_params, +u16 src_id,u16 src_index,u16 dst_id,u16 dst_host_irq, +u16 ia_id,u16 vint,u16 global_event,u8 vint_status_bit, +u8 s_host,u16 type);#endif /* __TI_SCI_H */
drivers/firmware/ti/ti_sci_core.c +5 -870
899 lines not on this page · raw message
drivers/firmware/ti/ti_sci_rm.c new file +910 -0
910 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 22/22 firmware: ti: ti_sci_proc: Move processor ops into its own file
In reply to Beleswar PadhiExtract the processor operations related functions and services from ti_sci_core.c into its own file. This breaks down the single large file into smaller logical files for better readability and maintenance.
---
v3: Changelog:
1. None to this patch.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. None to this patch.
Link to v1:
https://lore.kernel.org/all/[email protected]/
drivers/firmware/ti/Makefile | 1 + drivers/firmware/ti/ti_sci.h | 1 + drivers/firmware/ti/ti_sci_core.c | 197 +-------------------------- drivers/firmware/ti/ti_sci_proc.c | 214 ++++++++++++++++++++++++++++++ 4 files changed, 217 insertions(+), 196 deletions(-) create mode 100644 drivers/firmware/ti/ti_sci_proc.c
drivers/firmware/ti/Makefile +1 -0
@@ -4,5 +4,6 @@ ti_sci-y := ti_sci_core.o ti_sci-y += ti_sci_clock.o ti_sci-y += ti_sci_device.o ti_sci-y += ti_sci_pm.o +ti_sci-y += ti_sci_proc.o ti_sci-y += ti_sci_rm.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
drivers/firmware/ti/ti_sci.h +1 -0
@@ -1687,5 +1687,6 @@ int ti_sci_manage_irq(const struct ti_sci_handle *handle, u32 valid_params, u16 src_id, u16 src_index, u16 dst_id, u16 dst_host_irq, u16 ia_id, u16 vint, u16 global_event, u8 vint_status_bit, u8 s_host, u16 type); +void ti_sci_setup_proc_ops (struct ti_sci_proc_ops *pops);#endif /* __TI_SCI_H */
drivers/firmware/ti/ti_sci_core.c +1 -196
209 lines not on this page · raw message
drivers/firmware/ti/ti_sci_proc.c new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
2.34.1