From patchwork Fri Jul 26 13:51:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 169844 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp91836ilk; Fri, 26 Jul 2019 06:54:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpwMV2PcSFtTMjuXjSBUYotI8hcOy/8dwpeHoL7ins/49m92uIMkMKpRCF2fkrYPneGNf1 X-Received: by 2002:a65:64ce:: with SMTP id t14mr25556271pgv.137.1564149125733; Fri, 26 Jul 2019 06:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564149125; cv=none; d=google.com; s=arc-20160816; b=PFN8N6m+vcipSw6HfkeIp0VEgbamGc4/00WJAG/9Glni1XSUaPOyS7zFqzp3CgKGaJ iTf7o+0mUwd/EiIG2AZOQQ3oBDquTsn09GwyB5gtpMG6/lTDek4w5uan+wa25NhjPolW E5zI75e0Nt+tmKkI4mwZrSKpOnvWxBtNkO+LFHDXXEAGwP7LDjDZp1I3y4ACq2Fq+VXT mxXPTziSqQi4wjTFw7ASGMm5F3NpeNmtDorkYSk8e2T3omiKrZlfQkB+WV/mC8337J1G ma5nAF9+74JTJk+TAQEtONG1CO1PL3QJhPnpLeqQl7eO6X5HAfcRpRjWgoq8WW67QjQH AUIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+vmXwVNFXPnCvFS3ZhNUB5tnHvEooIec2+iUvbHCeOA=; b=JT+QCAU5L02N1P8wiorYrAc4SgUdZE/PYH//b53wUOAf0aty9ZLG5mH6cmhaLzN9WD I9d4ya15i57YBqCkGjcL9yZ4hniSYzz4z7zsjIbmZeOhG/4+Es8ykU5y/3Su9TLMI6hs UxRT7zKL8fFCh4/K2/gQpBSYdKuOZrdAP5b0V948c55Ub48WUtkiSxSheUH3d8kcn9l2 KB+2yMZYytcMB3+F4juuwcJutM5EkqHMwEyv6ApB5v+trLs1Ol/3nNmZIu7q7LdbMYDg uqSaWx83lc4c8wkLv+BIW7G8hzmGSupasZ+0fML8Rl7e4tLo6u3qFLoAW7nQgyR4oRDo MIjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si5924042pgh.434.2019.07.26.06.52.05; Fri, 26 Jul 2019 06:52:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388777AbfGZNwE (ORCPT + 29 others); Fri, 26 Jul 2019 09:52:04 -0400 Received: from foss.arm.com ([217.140.110.172]:44550 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388680AbfGZNwC (ORCPT ); Fri, 26 Jul 2019 09:52:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06B9F152D; Fri, 26 Jul 2019 06:52:02 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8C9303F694; Fri, 26 Jul 2019 06:52:00 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Peng Fan , linux-kernel@vger.kernel.org, Bo Zhang , Jim Quinlan , Volodymyr Babchuk , Gaku Inami , Etienne Carriere , Stephen Boyd , linux-clk@vger.kernel.org Subject: [PATCH v2 10/10] firmware: arm_scmi: Use asynchronous CLOCK_RATE_SET when possible Date: Fri, 26 Jul 2019 14:51:38 +0100 Message-Id: <20190726135138.9858-11-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726135138.9858-1-sudeep.holla@arm.com> References: <20190726135138.9858-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CLOCK_PROTOCOL_ATTRIBUTES provides attributes to indicate the maximum number of pending asynchronous clock rate changes supported by the platform. If it's non-zero, then we should be able to use asynchronous clock rate set for any clocks until the maximum limit is reached. Tracking the current count of pending asynchronous clock set rate requests, we can decide if the incoming/new request for clock set rate can be handled asynchronously or not until the maximum limit is reached. Cc: Stephen Boyd Cc: linux-clk@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/clock.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Stephen Boyd diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index dd215bd11a58..4a32ae1822a3 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -56,7 +56,7 @@ struct scmi_msg_resp_clock_describe_rates { struct scmi_clock_set_rate { __le32 flags; #define CLOCK_SET_ASYNC BIT(0) -#define CLOCK_SET_DELAYED BIT(1) +#define CLOCK_SET_IGNORE_RESP BIT(1) #define CLOCK_SET_ROUND_UP BIT(2) #define CLOCK_SET_ROUND_AUTO BIT(3) __le32 id; @@ -67,6 +67,7 @@ struct scmi_clock_set_rate { struct clock_info { int num_clocks; int max_async_req; + atomic_t cur_async_req; struct scmi_clock_info *clk; }; @@ -221,21 +222,33 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, u64 rate) { int ret; + u32 flags = 0; struct scmi_xfer *t; struct scmi_clock_set_rate *cfg; + struct clock_info *ci = handle->clk_priv; ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK, sizeof(*cfg), 0, &t); if (ret) return ret; + if (ci->max_async_req && + atomic_inc_return(&ci->cur_async_req) < ci->max_async_req) + flags |= CLOCK_SET_ASYNC; + cfg = t->tx.buf; - cfg->flags = cpu_to_le32(0); + cfg->flags = cpu_to_le32(flags); cfg->id = cpu_to_le32(clk_id); cfg->value_low = cpu_to_le32(rate & 0xffffffff); cfg->value_high = cpu_to_le32(rate >> 32); - ret = scmi_do_xfer(handle, t); + if (flags & CLOCK_SET_ASYNC) + ret = scmi_do_xfer_with_response(handle, t); + else + ret = scmi_do_xfer(handle, t); + + if (ci->max_async_req) + atomic_dec(&ci->cur_async_req); scmi_xfer_put(handle, t); return ret;