Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1668202ybs; Tue, 26 May 2020 00:10:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrlDGBrHtu0gqnzCYjLKu24s2ves0RXMZmjMu0mOEQq/w+5WZKjuXS2PigKYRersYjXkCn X-Received: by 2002:aa7:d590:: with SMTP id r16mr17939076edq.304.1590477034036; Tue, 26 May 2020 00:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590477034; cv=none; d=google.com; s=arc-20160816; b=frjMEV44xUno2i53CuhWCWRUJY14l5Mxd599aIVATpKU/DAkZtcNugZieBiDr48c6O 5rU9tGYCj+e1iN1+sUq+oiEjd/x38DCcatNmXG4eKeUv4w0Gv/jDV/g5wl05fg2ULlAZ RNdtCqvwwp8Z8aVzaJMDI4cL3zJsn4eO0lX82kPYF44eym7zxyULlxlPbCAubXlttige TbVWT16erK87dai/WyUDu3W+xrB1xZ1eFlP2LubPPtltros80FRWH+qXcZaTijqBDHid f3Cu4bk6AT0e3CtBAEPi6zUgxH9kEey1VENqhWG/WhFd6AaUOp/6NBk7b7iCZ6pxpnNR M1RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=O6QvaVi3YfaFHLoCHa9DEncvz1BtpP9wyBrbMVGNqGk=; b=pHrItBySvY6jhFLEkllCGB+zrQQYK2q5AJRiXUH7vcCSYgibCrSUuYV9yq+OOldn29 DsBF45x7PbKtG7zpncGz/cRnoA6wmcCTaogW1xrhzVFiT4bvUlYKhIXfdpU2K2Lq/dtX VsHXYvey9nF5k9/0dpzK2m3lrmKsDZYz6D5MQL97a0FLnGFBt++o6hnMfzfn6IEme1ix 1VYVS6swGDh7s2bO74blwgWu/NAWtOyn44dvRDfJJKOBqrkYuaH7GgwZol9CBf2uRCn/ oq/oQrurU5OlQweFHy8Ym4gvooe+IcK66XBpcaX9SOORXXWm0Kqz1UKE6ozfNCIIY5H+ iwnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=G6AZHxhG; 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 d21si357198edy.606.2020.05.26.00.10.10; Tue, 26 May 2020 00:10:34 -0700 (PDT) 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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=G6AZHxhG; 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 S1731494AbgEZHHQ (ORCPT + 99 others); Tue, 26 May 2020 03:07:16 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:16573 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbgEZHHP (ORCPT ); Tue, 26 May 2020 03:07:15 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1590476834; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=O6QvaVi3YfaFHLoCHa9DEncvz1BtpP9wyBrbMVGNqGk=; b=G6AZHxhG4U1eP0BDrH4AXwoVG07QAKvjEU82FO3++aG/X0t2hFZZiB05J6k+7rJRmU65e9N2 AVPqiXslMcU4FaTBHQfG+/U53AcnfZje0hajjvJTYGPAP2V3GUdAW2Jkse4+DncXZTdot/wy 3b7GgdsAY6mAGsBww0ZTCrjTk8c= X-Mailgun-Sending-Ip: 104.130.122.27 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-n01.prod.us-east-1.postgun.com with SMTP id 5eccc0212dd9e15ae3969aa2 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 26 May 2020 07:07:13 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B48AEC433C6; Tue, 26 May 2020 07:07:12 +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=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.43.137] (unknown [106.213.171.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 89482C433C9; Tue, 26 May 2020 07:07:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 89482C433C9 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=none smtp.mailfrom=mkshah@codeaurora.org Subject: Re: [PATCHv3/RESEND 1/3] soc: qcom: rpmh-rsc: Remove tcs_is_free() API To: Stephen Boyd , Andy Gross , Bjorn Andersson Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Douglas Anderson References: <20200521060425.24285-1-swboyd@chromium.org> <20200521060425.24285-2-swboyd@chromium.org> From: Maulik Shah Message-ID: Date: Tue, 26 May 2020 12:37:06 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200521060425.24285-2-swboyd@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Reviewed-by: Maulik Shah Thanks, Maulik On 5/21/2020 11:34 AM, Stephen Boyd wrote: > This API does very little. Let's replace all the callsites with the > normal operations that would be done on top of the bitmap that > tcs_in_use is. This simplifies and reduces the code size. > > Cc: Maulik Shah > Cc: Douglas Anderson > Signed-off-by: Stephen Boyd > --- > drivers/soc/qcom/rpmh-rsc.c | 59 +++++++++++++------------------------ > 1 file changed, 20 insertions(+), 39 deletions(-) > > diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c > index 076fd27f3081..60fc56987659 100644 > --- a/drivers/soc/qcom/rpmh-rsc.c > +++ b/drivers/soc/qcom/rpmh-rsc.c > @@ -184,22 +184,6 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, > data, tcs_id, reg); > } > > -/** > - * tcs_is_free() - Return if a TCS is totally free. > - * @drv: The RSC controller. > - * @tcs_id: The global ID of this TCS. > - * > - * Returns true if nobody has claimed this TCS (by setting tcs_in_use). > - * > - * Context: Must be called with the drv->lock held. > - * > - * Return: true if the given TCS is free. > - */ > -static bool tcs_is_free(struct rsc_drv *drv, int tcs_id) > -{ > - return !test_bit(tcs_id, drv->tcs_in_use); > -} > - > /** > * tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake). > * @drv: The RSC controller. > @@ -512,7 +496,7 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, > * > * Return: 0 if nothing in flight or -EBUSY if we should try again later. > * The caller must re-enable interrupts between tries since that's > - * the only way tcs_is_free() will ever return true and the only way > + * the only way tcs_in_use will ever be updated and the only way > * RSC_DRV_CMD_ENABLE will ever be cleared. > */ > static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, > @@ -520,17 +504,14 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, > { > unsigned long curr_enabled; > u32 addr; > - int i, j, k; > - int tcs_id = tcs->offset; > + int j, k; > + int i = tcs->offset; > > - for (i = 0; i < tcs->num_tcs; i++, tcs_id++) { > - if (tcs_is_free(drv, tcs_id)) > - continue; > - > - curr_enabled = read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, tcs_id); > + for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) { > + curr_enabled = read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i); > > for_each_set_bit(j, &curr_enabled, MAX_CMDS_PER_TCS) { > - addr = read_tcs_cmd(drv, RSC_DRV_CMD_ADDR, tcs_id, j); > + addr = read_tcs_cmd(drv, RSC_DRV_CMD_ADDR, i, j); > for (k = 0; k < msg->num_cmds; k++) { > if (addr == msg->cmds[k].addr) > return -EBUSY; > @@ -548,18 +529,19 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, > * > * Must be called with the drv->lock held since that protects tcs_in_use. > * > - * Return: The first tcs that's free. > + * Return: The first tcs that's free or -EBUSY if all in use. > */ > static int find_free_tcs(struct tcs_group *tcs) > { > - int i; > + const struct rsc_drv *drv = tcs->drv; > + unsigned long i; > + unsigned long max = tcs->offset + tcs->num_tcs; > > - for (i = 0; i < tcs->num_tcs; i++) { > - if (tcs_is_free(tcs->drv, tcs->offset + i)) > - return tcs->offset + i; > - } > + i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset); > + if (i >= max) > + return -EBUSY; > > - return -EBUSY; > + return i; > } > > /** > @@ -757,8 +739,9 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) > */ > static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) > { > - int m; > - struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS]; > + unsigned long set; > + const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS]; > + unsigned long max; > > /* > * If we made an active request on a RSC that does not have a > @@ -769,12 +752,10 @@ static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) > if (!tcs->num_tcs) > tcs = &drv->tcs[WAKE_TCS]; > > - for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { > - if (!tcs_is_free(drv, m)) > - return true; > - } > + max = tcs->offset + tcs->num_tcs; > + set = find_next_bit(drv->tcs_in_use, max, tcs->offset); > > - return false; > + return set < max; > } > > /** -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation