Skip to contentSkip to conversation

Reduce TI-SCI driver size to fix am65x_evm_r5 build

PATCH In review Andrew Davis 2 participants 9 messages Jul 26, 2022 – Aug 26, 2022 Texas instruments' system control interface (TISCI) protocol driver

lore
Share & tools
lore
#0 lore raw

cover Reduce TI-SCI driver size to fix am65x_evm_r5 build

Hi All,

The am65x_evm_r5_defconfig build was overflowing the SRAM area by 16 bytes on the latest master with the gcc-arm-9.2-2019.12 compiler. Lets do some simple cleanups in one of the largest drivers on these K3 systems and give us some more headroom for new features.

$ ./tools/buildman/buildman -o ../buildman -b upstream/dev/ti-sci-size --step 0 -sS
Summary of 2 commits for 1223 boards (32 threads, 1 job per thread)
01: configs: Resync with savedefconfig
   aarch64:  w+   am62x_evm_a53 am64x_evm_a53 am65x_evm_a53 am65x_hs_evm_a53 j7200_evm_a72 j721e_evm_a72 j721e_hs_evm_a72 j721s2_evm_a72
       arm:  w+   am62x_evm_r5 am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc am65x_hs_evm_r5 j7200_evm_r5 j721e_evm_r5 j721e_hs_evm_r5 j721s2_evm_r5 +   am65x_evm_r5
05: firmware: ti_sci: Move ACK checking to ti_sci_do_xfer() function
       arm:  w+   am65x_evm_r5
   aarch64: (for 8/345 boards) all -20333.0 rodata -409.0 spl/u-boot-spl:all -20333.0 spl/u-boot-spl:rodata -409.0 spl/u-boot-spl:text -19924.0 text -19924.0
       arm: (for 10/649 boards) all -16503.0 bss -3.6 rodata -409.0 spl/u-boot-spl:all -13894.6 spl/u-boot-spl:rodata -409.0 spl/u-boot-spl:text -13485.6 text -16090.4

Andrew

Andrew Davis (4):
firmware: ti_sci: Reduce output on ti_sci_do_xfer error
firmware: ti_sci: Factor out message alloc failed message
firmware: ti_sci: Remove inline keyword from functions
firmware: ti_sci: Move ACK checking to ti_sci_do_xfer() function

 drivers/firmware/ti_sci.c | 341 +++++++-------------------------------
 1 file changed, 64 insertions(+), 277 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH 1/4 firmware: ti_sci: Reduce output on ti_sci_do_xfer error

This ti_sci_do_xfer() function already prints out the reason for the failure, and the caller of each of these functions should also notify the user of the failed task. Remove this extra level of error message.

---
 drivers/firmware/ti_sci.c | 132 ++++++++++----------------------------
 1 file changed, 34 insertions(+), 98 deletions(-)
drivers/firmware/ti_sci.c +34 -98
index 0b6ba35b59..85db3f05fd 100644
@@ -287,10 +287,8 @@ static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
 	}
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox communication fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	rev_info = (struct ti_sci_msg_resp_version *)xfer->tx_message.buf;
 
@@ -356,10 +354,8 @@ static int cmd_set_board_config_using_msg(const struct ti_sci_handle *handle,
 	req.boardcfg_size = size;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -516,10 +512,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -572,7 +566,7 @@ static int ti_sci_set_device_state_no_wait(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret)
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
 
 	return ret;
 }
@@ -619,10 +613,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_device_state *)xfer->tx_message.buf;
 	if (!ti_sci_is_response_ack(resp))
@@ -908,10 +900,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -979,10 +969,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1036,10 +1024,8 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,
 	req.clk_id = clk_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->tx_message.buf;
 
@@ -1253,10 +1239,8 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,
 	req.parent_id = parent_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1305,10 +1289,8 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,
 	req.clk_id = clk_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->tx_message.buf;
 
@@ -1360,10 +1342,8 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,
 	req.clk_id = clk_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_clock_num_parents *)
 							xfer->tx_message.buf;
@@ -1428,10 +1408,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->tx_message.buf;
 
@@ -1493,10 +1471,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1545,10 +1521,8 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,
 	req.clk_id = clk_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->tx_message.buf;
 
@@ -1592,10 +1566,8 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
 	req.domain = 0;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1650,10 +1622,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->tx_message.buf;
 	if (!ti_sci_is_response_ack(resp)) {
@@ -1774,10 +1744,8 @@ static int ti_sci_cmd_query_msmc(const struct ti_sci_handle *handle,
 	}
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_query_msmc *)xfer->tx_message.buf;
 
@@ -1826,10 +1794,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1873,10 +1839,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1924,10 +1888,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(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -1981,10 +1943,8 @@ static int ti_sci_cmd_set_proc_boot_cfg(const struct ti_sci_handle *handle,
 	req.config_flags_clear = config_flags_clear;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -2034,10 +1994,8 @@ static int ti_sci_cmd_set_proc_boot_ctrl(const struct ti_sci_handle *handle,
 	req.control_flags_clear = control_flags_clear;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -2088,10 +2046,8 @@ static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
 				TISCI_ADDR_HIGH_SHIFT;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_proc_auth_boot_image *)xfer->tx_message.buf;
 
@@ -2141,10 +2097,8 @@ static int ti_sci_cmd_get_proc_boot_status(const struct ti_sci_handle *handle,
 	req.processor_id = proc_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_resp_get_proc_boot_status *)
 							xfer->tx_message.buf;
@@ -2240,7 +2194,7 @@ ti_sci_proc_wait_boot_status_no_wait(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret)
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
 
 	return ret;
 }
@@ -2354,10 +2308,8 @@ static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
 	req.order_id = order_id;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "RM_RA:Mbox config send fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp = (struct ti_sci_msg_rm_ring_cfg_resp *)xfer->tx_message.buf;
 
@@ -2397,10 +2349,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(info->dev, "RM_PSIL:Mbox send fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 	ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
@@ -2440,10 +2390,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(info->dev, "RM_PSIL:Mbox send fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 	ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
@@ -2501,10 +2449,8 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(
 	req.extended_ch_type = params->extended_ch_type;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send TX_CH_CFG fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp =
 	      (struct ti_sci_msg_rm_udmap_tx_ch_cfg_resp *)xfer->tx_message.buf;
@@ -2559,10 +2505,8 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(
 	req.rx_ignore_long = params->rx_ignore_long;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send RX_CH_CFG fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp =
 	      (struct ti_sci_msg_rm_udmap_rx_ch_cfg_resp *)xfer->tx_message.buf;
@@ -2624,10 +2568,8 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
 	req.rx_ps_location = params->rx_ps_location;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "RX_FL_CFG: Mbox send fail %d\n", ret);
+	if (ret)
 		goto fail;
-	}
 
 	resp =
 	       (struct ti_sci_msg_rm_udmap_flow_cfg_resp *)xfer->tx_message.buf;
@@ -2681,10 +2623,8 @@ static int ti_sci_cmd_set_fwl_region(const struct ti_sci_handle *handle,
 	req.end_address = region->end_address;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 
@@ -2731,10 +2671,8 @@ static int ti_sci_cmd_get_fwl_region(const struct ti_sci_handle *handle,
 	req.n_permission_regs = region->n_permission_regs;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_fwl_get_firewall_region_resp *)xfer->tx_message.buf;
 
@@ -2791,10 +2729,8 @@ static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle,
 	req.owner_index = owner->owner_index;
 
 	ret = ti_sci_do_xfer(info, xfer);
-	if (ret) {
-		dev_err(info->dev, "Mbox send fail %d\n", ret);
+	if (ret)
 		return ret;
-	}
 
 	resp = (struct ti_sci_msg_fwl_change_owner_info_resp *)xfer->tx_message.buf;
 
Signature · 1 line
2.36.1
#2 lore raw

Re: [PATCH 1/4] firmware: ti_sci: Reduce output on ti_sci_do_xfer error

Quoted 5 lines · Andrew Davis

This ti_sci_do_xfer() function already prints out the reason for the failure, and the caller of each of these functions should also notify the user of the failed task. Remove this extra level of error message.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 2/4 firmware: ti_sci: Factor out message alloc failed message

In reply to Andrew Davis

We don't need to print the same message in every location, just print it in the function that fails and remove all the extra message printouts.

---
 drivers/firmware/ti_sci.c | 40 ++++-----------------------------------
 1 file changed, 4 insertions(+), 36 deletions(-)
drivers/firmware/ti_sci.c +4 -36
index 85db3f05fd..687acbf2b4 100644
@@ -134,8 +134,11 @@ static struct ti_sci_xfer *ti_sci_setup_one_xfer(struct ti_sci_info *info,
 	if (rx_message_size > info->desc->max_msg_size ||
 	    tx_message_size > info->desc->max_msg_size ||
 	    (rx_message_size > 0 && rx_message_size < sizeof(*hdr)) ||
-	    tx_message_size < sizeof(*hdr))
+	    tx_message_size < sizeof(*hdr)) {
+		dev_err(info->dev, "TI-SCI message transfer size not sane\n");
 		return ERR_PTR(-ERANGE);
+	}
+
 
 	info->seq = ~info->seq;
 	xfer->tx_message.buf = buf;
@@ -282,7 +285,6 @@ static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
 				     sizeof(*rev_info));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -346,7 +348,6 @@ static int cmd_set_board_config_using_msg(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.boardcfgp_high = (addr >> 32) & 0xffffffff;
@@ -505,7 +506,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.id = id;
@@ -558,7 +558,6 @@ static int ti_sci_set_device_state_no_wait(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), 0);
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.id = id;
@@ -607,7 +606,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.id = id;
@@ -893,7 +891,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.id = id;
@@ -961,7 +958,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1017,7 +1013,6 @@ static int ti_sci_cmd_get_clock_state(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1231,7 +1226,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1282,7 +1276,6 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1335,7 +1328,6 @@ static int ti_sci_cmd_clk_get_num_parents(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1398,7 +1390,6 @@ static int ti_sci_cmd_clk_get_match_freq(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1461,7 +1452,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1514,7 +1504,6 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.dev_id = dev_id;
@@ -1560,7 +1549,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.domain = 0;
@@ -1613,7 +1601,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -1739,7 +1726,6 @@ static int ti_sci_cmd_query_msmc(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -1788,7 +1774,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -1833,7 +1818,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -1881,7 +1865,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -1932,7 +1915,6 @@ static int ti_sci_cmd_set_proc_boot_cfg(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -1986,7 +1968,6 @@ static int ti_sci_cmd_set_proc_boot_ctrl(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -2038,7 +2019,6 @@ static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.cert_addr_low = *image_addr & TISCI_ADDR_LOW_MASK;
@@ -2091,7 +2071,6 @@ static int ti_sci_cmd_get_proc_boot_status(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -2179,7 +2158,6 @@ ti_sci_proc_wait_boot_status_no_wait(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), 0);
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.processor_id = proc_id;
@@ -2294,7 +2272,6 @@ static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "RM_RA:Message config failed(%d)\n", ret);
 		return ret;
 	}
 	req.valid_params = valid_params;
@@ -2341,7 +2318,6 @@ static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "RM_PSIL:Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.nav_id = nav_id;
@@ -2382,7 +2358,6 @@ static int ti_sci_cmd_rm_psil_unpair(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "RM_PSIL:Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.nav_id = nav_id;
@@ -2424,7 +2399,6 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message TX_CH_CFG alloc failed(%d)\n", ret);
 		return ret;
 	}
 	req.valid_params = params->valid_params;
@@ -2483,7 +2457,6 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message RX_CH_CFG alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -2539,8 +2512,6 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "RX_FL_CFG: Message alloc failed(%d)\n",
-			ret);
 		return ret;
 	}
 
@@ -2608,7 +2579,6 @@ static int ti_sci_cmd_set_fwl_region(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -2662,7 +2632,6 @@ static int ti_sci_cmd_get_fwl_region(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -2720,7 +2689,6 @@ static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
Signature · 1 line
2.36.1
#4 lore raw

Re: [PATCH 2/4] firmware: ti_sci: Factor out message alloc failed message

Quoted 5 lines · Andrew Davis

We don't need to print the same message in every location, just print it in the function that fails and remove all the extra message printouts.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 3/4 firmware: ti_sci: Remove inline keyword from functions

In reply to Andrew Davis

The inline hint is not needed here, the compiler will do the right thing based on if we are compiling for speed or for code size. In this case the inline causes this function to be placed inside each callsite which is not the right thing to do for either speed nor size. There is no performance benefit to this due to the larger function size reducing cache locality, but there is a huge size penalty. Remove inline keyword.

---
 drivers/firmware/ti_sci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/ti_sci.c +3 -3
index 687acbf2b4..facc0709ae 100644
@@ -164,7 +164,7 @@ static struct ti_sci_xfer *ti_sci_setup_one_xfer(struct ti_sci_info *info,
  *	   return corresponding error, else if all goes well,
  *	   return 0.
  */
-static inline int ti_sci_get_response(struct ti_sci_info *info,
+static int ti_sci_get_response(struct ti_sci_info *info,
 				      struct ti_sci_xfer *xfer,
 				      struct mbox_chan *chan)
 {
@@ -218,7 +218,7 @@ static inline int ti_sci_get_response(struct ti_sci_info *info,
  *
  * Return: 0 if all went fine, else return appropriate error.
  */
-static inline int ti_sci_do_xfer(struct ti_sci_info *info,
+static int ti_sci_do_xfer(struct ti_sci_info *info,
 				 struct ti_sci_xfer *xfer)
 {
 	struct k3_sec_proxy_msg *msg = &xfer->tx_message;
@@ -310,7 +310,7 @@ static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
  *
  * Return: true if the response was an ACK, else returns false.
  */
-static inline bool ti_sci_is_response_ack(void *r)
+static bool ti_sci_is_response_ack(void *r)
 {
 	struct ti_sci_msg_hdr *hdr = r;
 
Signature · 1 line
2.36.1
#6 lore raw

Re: [PATCH 3/4] firmware: ti_sci: Remove inline keyword from functions

Quoted 8 lines · Andrew Davis

The inline hint is not needed here, the compiler will do the right thing based on if we are compiling for speed or for code size. In this case the inline causes this function to be placed inside each callsite which is not the right thing to do for either speed nor size. There is no performance benefit to this due to the larger function size reducing cache locality, but there is a huge size penalty. Remove inline keyword.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#7 lore raw

PATCH 4/4 firmware: ti_sci: Move ACK checking to ti_sci_do_xfer() function

In reply to Andrew Davis

We can check if the message was acknowledged in the common ti_sci_do_xfer() which lets us remove it from after each call to this function. This simplifies the code and reduces binary size.

---
 drivers/firmware/ti_sci.c | 165 ++++++--------------------------------
 1 file changed, 24 insertions(+), 141 deletions(-)
drivers/firmware/ti_sci.c +24 -141
index facc0709ae..727e090e8a 100644
@@ -211,6 +211,19 @@ static int ti_sci_get_response(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 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
@@ -249,8 +262,13 @@ static int ti_sci_do_xfer(struct ti_sci_info *info,
 	}
 
 	/* Get response if requested */
-	if (xfer->rx_len)
+	if (xfer->rx_len) {
 		ret = ti_sci_get_response(info, xfer, &info->chan_rx);
+		if (!ti_sci_is_response_ack(xfer->tx_message.buf)) {
+			dev_err(info->dev, "Message not acknowledged");
+			ret = -ENODEV;
+		}
+	}
 
 	return ret;
 }
@@ -304,19 +322,6 @@ static int ti_sci_cmd_get_revision(struct ti_sci_handle *handle)
 	return 0;
 }
 
-/**
- * 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 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;
-}
-
 /**
  * cmd_set_board_config_using_msg() - Common command to send board configuration
  *                                    message
@@ -358,11 +363,6 @@ static int cmd_set_board_config_using_msg(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -515,11 +515,6 @@ static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	if (state == MSG_DEVICE_SW_STATE_AUTO_OFF)
 		ti_sci_delete_exclusive_dev(info, id);
 	else if (flags & MSG_FLAG_DEVICE_EXCLUSIVE)
@@ -615,8 +610,6 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
 		return ret;
 
 	resp = (struct ti_sci_msg_resp_get_device_state *)xfer->tx_message.buf;
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
 
 	if (clcnt)
 		*clcnt = resp->context_loss_count;
@@ -900,11 +893,6 @@ static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -968,11 +956,6 @@ static int ti_sci_set_clock_state(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -1024,9 +1007,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->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	if (programmed_state)
 		*programmed_state = resp->programmed_state;
 	if (current_state)
@@ -1236,11 +1216,6 @@ static int ti_sci_cmd_clk_set_parent(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -1285,12 +1260,7 @@ static int ti_sci_cmd_clk_get_parent(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-	else
-		*parent_id = resp->parent_id;
+	*parent_id = resp->parent_id;
 
 	return ret;
 }
@@ -1340,10 +1310,7 @@ 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->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-	else
-		*num_parents = resp->num_parents;
+	*num_parents = resp->num_parents;
 
 	return ret;
 }
@@ -1404,10 +1371,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->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-	else
-		*match_freq = resp->freq_hz;
+	*match_freq = resp->freq_hz;
 
 	return ret;
 }
@@ -1464,11 +1428,6 @@ static int ti_sci_cmd_clk_set_freq(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -1515,10 +1474,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->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-	else
-		*freq = resp->freq_hz;
+	*freq = resp->freq_hz;
 
 	return ret;
 }
@@ -1557,11 +1513,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return ret;
 }
 
@@ -1613,9 +1564,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
 		goto fail;
 
 	resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->tx_message.buf;
-	if (!ti_sci_is_response_ack(resp)) {
-		ret = -ENODEV;
-	} else if (!resp->range_start && !resp->range_num) {
+	if (!resp->range_start && !resp->range_num) {
 		ret = -ENODEV;
 	} else {
 		*range_start = resp->range_start;
@@ -1735,9 +1684,6 @@ static int ti_sci_cmd_query_msmc(const struct ti_sci_handle *handle,
 
 	resp = (struct ti_sci_msg_resp_query_msmc *)xfer->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	*msmc_start = ((u64)resp->msmc_start_high << TISCI_ADDR_HIGH_SHIFT) |
 			resp->msmc_start_low;
 	*msmc_end = ((u64)resp->msmc_end_high << TISCI_ADDR_HIGH_SHIFT) |
@@ -1782,11 +1728,6 @@ static int ti_sci_cmd_proc_request(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-
 	return ret;
 }
 
@@ -1826,11 +1767,6 @@ static int ti_sci_cmd_proc_release(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-
 	return ret;
 }
 
@@ -1874,11 +1810,6 @@ static int ti_sci_cmd_proc_handover(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-
 	return ret;
 }
 
@@ -1928,11 +1859,6 @@ static int ti_sci_cmd_set_proc_boot_cfg(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-
 	return ret;
 }
 
@@ -1978,11 +1904,6 @@ static int ti_sci_cmd_set_proc_boot_ctrl(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
-
 	return ret;
 }
 
@@ -2031,9 +1952,6 @@ static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
 
 	resp = (struct ti_sci_msg_resp_proc_auth_boot_image *)xfer->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	*image_addr = (resp->image_addr_low & TISCI_ADDR_LOW_MASK) |
 			(((u64)resp->image_addr_high <<
 			  TISCI_ADDR_HIGH_SHIFT) & TISCI_ADDR_HIGH_MASK);
@@ -2082,8 +2000,6 @@ static int ti_sci_cmd_get_proc_boot_status(const struct ti_sci_handle *handle,
 	resp = (struct ti_sci_msg_resp_get_proc_boot_status *)
 							xfer->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
 	*bv = (resp->bootvector_low & TISCI_ADDR_LOW_MASK) |
 			(((u64)resp->bootvector_high  <<
 			  TISCI_ADDR_HIGH_SHIFT) & TISCI_ADDR_HIGH_MASK);
@@ -2288,10 +2204,6 @@ static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
 	if (ret)
 		goto fail;
 
-	resp = (struct ti_sci_msg_rm_ring_cfg_resp *)xfer->tx_message.buf;
-
-	ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
-
 fail:
 	dev_dbg(info->dev, "RM_RA:config ring %u ret:%d\n", index, ret);
 	return ret;
@@ -2328,9 +2240,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->tx_message.buf;
-	ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
-
 fail:
 	dev_dbg(info->dev, "RM_PSIL: nav: %u link pair %u->%u ret:%u\n",
 		nav_id, src_thread, dst_thread, ret);
@@ -2368,9 +2277,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->tx_message.buf;
-	ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
-
 fail:
 	dev_dbg(info->dev, "RM_PSIL: link unpair %u->%u ret:%u\n",
 		src_thread, dst_thread, ret);
@@ -2426,10 +2332,6 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(
 	if (ret)
 		goto fail;
 
-	resp =
-	      (struct ti_sci_msg_rm_udmap_tx_ch_cfg_resp *)xfer->tx_message.buf;
-	ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
-
 fail:
 	dev_dbg(info->dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret);
 	return ret;
@@ -2481,10 +2383,6 @@ static int ti_sci_cmd_rm_udmap_rx_ch_cfg(
 	if (ret)
 		goto fail;
 
-	resp =
-	      (struct ti_sci_msg_rm_udmap_rx_ch_cfg_resp *)xfer->tx_message.buf;
-	ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
-
 fail:
 	dev_dbg(info->dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret);
 	return ret;
@@ -2542,10 +2440,6 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
 	if (ret)
 		goto fail;
 
-	resp =
-	       (struct ti_sci_msg_rm_udmap_flow_cfg_resp *)xfer->tx_message.buf;
-	ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
-
 fail:
 	dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret);
 	return ret;
@@ -2596,11 +2490,6 @@ static int ti_sci_cmd_set_fwl_region(const struct ti_sci_handle *handle,
 	if (ret)
 		return ret;
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
-
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	return 0;
 }
 
@@ -2645,9 +2534,6 @@ static int ti_sci_cmd_get_fwl_region(const struct ti_sci_handle *handle,
 
 	resp = (struct ti_sci_msg_fwl_get_firewall_region_resp *)xfer->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	region->fwl_id = resp->fwl_id;
 	region->region = resp->region;
 	region->n_permission_regs = resp->n_permission_regs;
@@ -2702,9 +2588,6 @@ static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle,
 
 	resp = (struct ti_sci_msg_fwl_change_owner_info_resp *)xfer->tx_message.buf;
 
-	if (!ti_sci_is_response_ack(resp))
-		return -ENODEV;
-
 	owner->fwl_id = resp->fwl_id;
 	owner->region = resp->region;
 	owner->owner_index = resp->owner_index;
Signature · 1 line
2.36.1
#8 lore raw

Re: [PATCH 4/4] firmware: ti_sci: Move ACK checking to ti_sci_do_xfer() function

Quoted 5 lines · Andrew Davis

We can check if the message was acknowledged in the common ti_sci_do_xfer() which lets us remove it from after each call to this function. This simplifies the code and reduces binary size.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom