From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC7A3C433EF for ; Tue, 26 Jul 2022 01:25:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A66AB84125; Tue, 26 Jul 2022 03:25:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="IjudRyqb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89C8C83EF2; Tue, 26 Jul 2022 03:25:18 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EC2BA84015 for ; Tue, 26 Jul 2022 03:25:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=afd@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 26Q1PACS075585; Mon, 25 Jul 2022 20:25:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1658798710; bh=DVEPbfwt5v7/02xYnf+xw3twwJGJlOpcTog0Bk+ym3Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IjudRyqblgzWR9e4zWYK6pu+TRqaZfJ9XJNyQqV8+M7JEER/6CX8fwT1H5JeI+fZz uRI7rOdeAwbNCDMDZeNgQlwyS9Il3H6gDTfSKHyJj2nj+Gb2FhIkysGPL3URNgQiQW TmHU0UdL2pO5s8pSybcWsKU/P+xnXSCrUSNYzzwA= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 26Q1PADC086922 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 Jul 2022 20:25:10 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 25 Jul 2022 20:25:09 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 25 Jul 2022 20:25:09 -0500 Received: from ula0226330.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 26Q1P61h120671; Mon, 25 Jul 2022 20:25:09 -0500 From: Andrew Davis To: Simon Glass , Tom Rini , CC: Andrew Davis Subject: [PATCH 4/4] firmware: ti_sci: Move ACK checking to ti_sci_do_xfer() function Date: Mon, 25 Jul 2022 20:25:06 -0500 Message-ID: <20220726012506.19368-5-afd@ti.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220726012506.19368-1-afd@ti.com> References: <20220726012506.19368-1-afd@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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. Signed-off-by: Andrew Davis --- drivers/firmware/ti_sci.c | 165 ++++++-------------------------------- 1 file changed, 24 insertions(+), 141 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index facc0709ae..727e090e8a 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -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; -- 2.36.1