Skip to content

Commit 2bc06ff

Browse files
committed
firmware: arm_scmi: Use asynchronous CLOCK_RATE_SET when possible
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: [email protected] Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent d0aba11 commit 2bc06ff

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/firmware/arm_scmi/clock.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct scmi_msg_resp_clock_describe_rates {
5656
struct scmi_clock_set_rate {
5757
__le32 flags;
5858
#define CLOCK_SET_ASYNC BIT(0)
59-
#define CLOCK_SET_DELAYED BIT(1)
59+
#define CLOCK_SET_IGNORE_RESP BIT(1)
6060
#define CLOCK_SET_ROUND_UP BIT(2)
6161
#define CLOCK_SET_ROUND_AUTO BIT(3)
6262
__le32 id;
@@ -67,6 +67,7 @@ struct scmi_clock_set_rate {
6767
struct clock_info {
6868
int num_clocks;
6969
int max_async_req;
70+
atomic_t cur_async_req;
7071
struct scmi_clock_info *clk;
7172
};
7273

@@ -221,21 +222,33 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
221222
u64 rate)
222223
{
223224
int ret;
225+
u32 flags = 0;
224226
struct scmi_xfer *t;
225227
struct scmi_clock_set_rate *cfg;
228+
struct clock_info *ci = handle->clk_priv;
226229

227230
ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK,
228231
sizeof(*cfg), 0, &t);
229232
if (ret)
230233
return ret;
231234

235+
if (ci->max_async_req &&
236+
atomic_inc_return(&ci->cur_async_req) < ci->max_async_req)
237+
flags |= CLOCK_SET_ASYNC;
238+
232239
cfg = t->tx.buf;
233-
cfg->flags = cpu_to_le32(0);
240+
cfg->flags = cpu_to_le32(flags);
234241
cfg->id = cpu_to_le32(clk_id);
235242
cfg->value_low = cpu_to_le32(rate & 0xffffffff);
236243
cfg->value_high = cpu_to_le32(rate >> 32);
237244

238-
ret = scmi_do_xfer(handle, t);
245+
if (flags & CLOCK_SET_ASYNC)
246+
ret = scmi_do_xfer_with_response(handle, t);
247+
else
248+
ret = scmi_do_xfer(handle, t);
249+
250+
if (ci->max_async_req)
251+
atomic_dec(&ci->cur_async_req);
239252

240253
scmi_xfer_put(handle, t);
241254
return ret;

0 commit comments

Comments
 (0)