Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1911915pxu; Tue, 24 Nov 2020 11:53:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXkje7uiUHlqribQhHhHEN2xEkOg0r9fZenzNRHtZ14F2gM6LnqqEupv83i5627SntRm9d X-Received: by 2002:a05:6402:b02:: with SMTP id bm2mr90546edb.299.1606247598032; Tue, 24 Nov 2020 11:53:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606247598; cv=none; d=google.com; s=arc-20160816; b=ZokN4kaaLc8rti4DW2Ha3nmz9FmTtrZy84r+BxfVahkNdHcuhqbl6AAHzvdw8t04Cn ErS6hyqP0Oq5dP870A7bVVYD/ABIsMm3dfHeJ8TT1QzTWqXA3PU17sDb7Fj6jQEiBFEq /sutmS1rWEk9PX6jsl6T1uDbHu42IUUmWASqnBAZ599NAcYy1pWcJp3ez6DgT4yAmeu2 ScFTiMX95S4Rsckxe4undya2m0sKSDzeusHfEaU+EIFFHQfRXQTt8vt9o5++DOL65/TY RRoEBYCrZSoFeP0tuEYgf7GeFs7NF9w41hLm919/1u7MwuxBrh6QKKxWbpObk7KG92Xk TbsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=r2KNcUaierxJmn5CHPmfvgAFLmybeWsl3U3JcN5rG88=; b=Ei8wdexBz9uJarv9l+frUkUgvInJmccnxHpSo9CaULxeIcWJVe/o52IMwQ8hcL1boT DFVYXh2WB65smAWJb+wGCA8zHzKO1IYPDoxWLDJLrTEmo8jVFjUiJXt7hkEEp8WSvoT3 4aoIbonxbJsJcFTB6AO7EeXT/k6h0zwxdT87aeHca7sLfuuXjtwBm+JWyyFyoHxulmhr nTF9L5g5zvwArSfY9k/0oajInyLI/zbOhWIAJ5Z12r/LauAqREBGXgNndQm21vqgbW8i Upbzl2hUYm+xkuFeTOm3nzbYbuY59dsUyv0K1yRaM28VHQZFWKXlN3LyPsdgm1OCWBLL Tysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Cvrxzt02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si9172105edx.424.2020.11.24.11.52.54; Tue, 24 Nov 2020 11:53:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Cvrxzt02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730077AbgKXHby (ORCPT + 99 others); Tue, 24 Nov 2020 02:31:54 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:54049 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729951AbgKXHbw (ORCPT ); Tue, 24 Nov 2020 02:31:52 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1606203112; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=r2KNcUaierxJmn5CHPmfvgAFLmybeWsl3U3JcN5rG88=; b=Cvrxzt02HvH3aNWRIkWhKfaAe+mgXwZ29HsBMSo5oNRzkn+ooaQz99bQ9nw7dkQeXYMZbKRh Im616bZMlhO/xGgpbtvvyQ0/BLHSejfVQjQ7SapnuvbOhRaEntNSOe3/EJ2+FD/D/vgUIxba l9llK0F7y8r+SB0Cy3kVn01xKb4= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-west-2.postgun.com with SMTP id 5fbcb6e4c6fdb18c636a512d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 24 Nov 2020 07:31:48 GMT Sender: mkshah=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 02C9AC43460; Tue, 24 Nov 2020 07:31:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mkshah-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 24C64C433ED; Tue, 24 Nov 2020 07:31:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 24C64C433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, agross@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dianders@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v2] soc: qcom: rpmh: Remove serialization of TCS commands Date: Tue, 24 Nov 2020 13:01:26 +0530 Message-Id: <1606203086-31218-1-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lina Iyer Requests sent to RPMH can be sent as fire-n-forget or response required, with the latter ensuring the command has been completed by the hardware accelerator. Commands in a request with tcs_cmd::wait set, would ensure that those select commands are sent as response required, even though the actual TCS request may be fire-n-forget. Also, commands with .wait flag were also guaranteed to be complete before the following command in the TCS is sent. This means that the next command of the same request blocked until the current request is completed. This could mean waiting for a voltage to settle or series of NOCs be configured before the next command is sent. But drivers using this feature have never cared about the serialization aspect. By not enforcing the serialization we can allow the hardware to run in parallel improving the performance. Let's clarify the usage of this member in the tcs_cmd structure to mean only completion and not serialization. This should also improve the performance of bus requests where changes could happen in parallel. Also, CPU resume from deep idle may see benefits from certain wake requests. Signed-off-by: Lina Iyer Signed-off-by: Maulik Shah --- Changes in v2: - Add SoB of self - Fix typo in comment - Update comment as Doug suggested - Remove write to RSC_DRV_CMD_WAIT_FOR_CMPL in tcs_write() and tcs_invalidate() --- drivers/soc/qcom/rpmh-rsc.c | 25 ++++++++++--------------- include/soc/qcom/tcs.h | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 37969dc..9a06099 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -231,10 +231,9 @@ static void tcs_invalidate(struct rsc_drv *drv, int type) if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) return; - for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0); - write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0); - } + bitmap_zero(tcs->slots, MAX_TCS_SLOTS); } @@ -423,8 +422,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p) cmd = &req->cmds[j]; sts = read_tcs_cmd(drv, RSC_DRV_CMD_STATUS, i, j); if (!(sts & CMD_STATUS_ISSUED) || - ((req->wait_for_compl || cmd->wait) && - !(sts & CMD_STATUS_COMPL))) { + (cmd->wait && !(sts & CMD_STATUS_COMPL))) { pr_err("Incomplete request: %s: addr=%#x data=%#x", drv->name, cmd->addr, cmd->data); err = -EIO; @@ -443,7 +441,6 @@ static irqreturn_t tcs_tx_done(int irq, void *p) skip: /* Reclaim the TCS */ write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0); - write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0); writel_relaxed(BIT(i), drv->tcs_base + RSC_DRV_IRQ_CLEAR); spin_lock(&drv->lock); clear_bit(i, drv->tcs_in_use); @@ -476,23 +473,23 @@ static irqreturn_t tcs_tx_done(int irq, void *p) static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, const struct tcs_request *msg) { - u32 msgid, cmd_msgid; + u32 msgid; + u32 cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE; u32 cmd_enable = 0; - u32 cmd_complete; struct tcs_cmd *cmd; int i, j; - cmd_msgid = CMD_MSGID_LEN; + /* Convert all commands to RR when the request has wait_for_compl set */ cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0; - cmd_msgid |= CMD_MSGID_WRITE; - - cmd_complete = read_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, tcs_id); for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) { cmd = &msg->cmds[i]; cmd_enable |= BIT(j); - cmd_complete |= cmd->wait << j; msgid = cmd_msgid; + /* + * Additionally, if the cmd->wait is set, make the command + * response reqd even if the overall request was fire-n-forget. + */ msgid |= cmd->wait ? CMD_MSGID_RESP_REQ : 0; write_tcs_cmd(drv, RSC_DRV_CMD_MSGID, tcs_id, j, msgid); @@ -501,7 +498,6 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, trace_rpmh_send_msg(drv, tcs_id, j, msgid, cmd); } - write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, tcs_id, cmd_complete); cmd_enable |= read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, tcs_id); write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, tcs_id, cmd_enable); } @@ -652,7 +648,6 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() */ write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, tcs_id, 0); - write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, tcs_id, 0); enable_tcs_irq(drv, tcs_id, true); } spin_unlock_irqrestore(&drv->lock, flags); diff --git a/include/soc/qcom/tcs.h b/include/soc/qcom/tcs.h index 7a2a055..eb5cb35 100644 --- a/include/soc/qcom/tcs.h +++ b/include/soc/qcom/tcs.h @@ -30,7 +30,7 @@ enum rpmh_state { * * @addr: the address of the resource slv_id:18:16 | offset:0:15 * @data: the resource state request - * @wait: wait for this request to be complete before sending the next + * @wait: ensure that this command is complete before returning */ struct tcs_cmd { u32 addr; @@ -43,6 +43,7 @@ struct tcs_cmd { * * @state: state for the request. * @wait_for_compl: wait until we get a response from the h/w accelerator + * (same as setting cmd->wait for all commands in the request) * @num_cmds: the number of @cmds in this request * @cmds: an array of tcs_cmds */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation