Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4832785imm; Tue, 11 Sep 2018 19:20:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdabCDafQe8VCJ2fNIf3XYvqovMaSorqJMyifw2euIZx5I23oM6bZcfND16QzuNKLmFPGVq+ X-Received: by 2002:a63:d518:: with SMTP id c24-v6mr29994770pgg.357.1536718840192; Tue, 11 Sep 2018 19:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536718840; cv=none; d=google.com; s=arc-20160816; b=KiHSM8HBpNRAh1K0fGqW3/T82Dez89qyaTNY5yKgcfhMs8lU9mlSmSWFFOfwTpWnAX Oka8rtTtsBoEe4gTS6B/Fn8bD61UaUQQFlmMnZfj+e96UBTEAxfXvNnjQknwiJEM4z2f yyAiR1zeUUJXuVkreGPFRKuTtoakyzQ6OY2wahHo4xz40XvlENeHoMQPyQRPjQTOsHk0 jvAIBkKRAWIHfWGbNO8+vG6yVl0WhBBjWRv4ua31CTcsCzsCk2OtCrdLuFFYL588V3HJ r3qScyTqZbhsXamKtUDJkpP94ufjmSba0n+NO5mno+Lcs5i+0LA6VxjmL/PFXBQ8/wvm SqeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature; bh=IQZ/f3IXzgSckEo1Vjn4GWqEde5mCivgvgbtDYetcmE=; b=TSDoVt3OtPhY7TTBPtGsH7jyrWR96/Q7PFCRkSEpcl6F8BbR0DMOj5nUqSTtTbA0QQ mUiG7EuEFxORpu2mnpJKgJNEHsSVAUabKd7KvD1A+4diVwY8GWdwAQ+TRcXfwpGLdyR0 9xVsWIe8cZeX7byqMtGpmR4RJiL4qDe66eheiBRFH6hAFFmp1B3edciu01Bz9uF3m9wa YdDCBwDV31mxs8UnnWLa9Y7aUxSYYYippj5dySyM3XFojU8C82zuDGRAsH5ey5uBkuh6 WEFWJwI7GJTWmUANclznSBHb8Ar1zJIfMMWA7327M62yJ8CmNALlAqKWkSGLDgeE0zyD hJmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lBtv3np9; dkim=pass header.i=@codeaurora.org header.s=default header.b=O2nQRM9c; 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 k185-v6si21411161pgd.523.2018.09.11.19.20.10; Tue, 11 Sep 2018 19:20:40 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=lBtv3np9; dkim=pass header.i=@codeaurora.org header.s=default header.b=O2nQRM9c; 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 S1728012AbeILHWP (ORCPT + 99 others); Wed, 12 Sep 2018 03:22:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54390 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbeILHWO (ORCPT ); Wed, 12 Sep 2018 03:22:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3AAA160912; Wed, 12 Sep 2018 02:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536718804; bh=JDHtearcuCTxjqbOVoeXcpTUwd5A8cSLPtqqDHt7EpE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lBtv3np9NXwfT3xV5b08/H2YljiSxkOx2Jd0Qd0ndHNhHfhtLL8LbzWOGLlek+7Tr 4ghZfzG5298chy9VkwpNynwjB02ggIb/Ej8v5JrZuJjWwhHNlokgPmreQ4JSrhWt+l 7A0db28ScF8BRpElDzSV3XmE3N8uAcT/Nhuqtu/0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3F3FD607DD; Wed, 12 Sep 2018 02:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536718803; bh=JDHtearcuCTxjqbOVoeXcpTUwd5A8cSLPtqqDHt7EpE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O2nQRM9cYBTUkj3GdU2GK5Q86vmTzGY0FhwZK4kFAMB9MvlgzV2dP6vJTPPsdnk5T thxtKnRkF2Y6Qt/uqpWH26IlZiUM7JyWjYB89ckAeVo1M+BIGwrWmvykeGwkejUDSj OOxpeRRlp8ft5UfOa1jwxQcxG6er/5fVmNtRqDxc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3F3FD607DD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org Date: Tue, 11 Sep 2018 20:20:02 -0600 From: Lina Iyer To: Matthias Kaehlcke Cc: Raju P L S S S N , andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org Subject: Re: [PATCH v2 1/6] drivers: qcom: rpmh-rsc: return if the controller is idle Message-ID: <20180912022002.GH15710@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> <1532685889-31345-2-git-send-email-rplsssn@codeaurora.org> <20180911223910.GH22824@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180911223910.GH22824@google.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 11 2018 at 16:39 -0600, Matthias Kaehlcke wrote: >Hi Raju/Lina, > >On Fri, Jul 27, 2018 at 03:34:44PM +0530, Raju P L S S S N wrote: >> From: Lina Iyer >> >> Allow the controller status be queried. The controller is busy if it is >> actively processing request. >> >> Signed-off-by: Lina Iyer >> Signed-off-by: Raju P.L.S.S.S.N >> --- >> Changes in v2: >> - Remove unnecessary EXPORT_SYMBOL >> --- >> drivers/soc/qcom/rpmh-internal.h | 1 + >> drivers/soc/qcom/rpmh-rsc.c | 20 ++++++++++++++++++++ >> 2 files changed, 21 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h >> index a7bbbb6..4ff43bf 100644 >> --- a/drivers/soc/qcom/rpmh-internal.h >> +++ b/drivers/soc/qcom/rpmh-internal.h >> @@ -108,6 +108,7 @@ struct rsc_drv { >> int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, >> const struct tcs_request *msg); >> int rpmh_rsc_invalidate(struct rsc_drv *drv); >> +bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv); >> >> void rpmh_tx_done(const struct tcs_request *msg, int r); >> >> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c >> index 33fe9f9..42d0041 100644 >> --- a/drivers/soc/qcom/rpmh-rsc.c >> +++ b/drivers/soc/qcom/rpmh-rsc.c >> @@ -496,6 +496,26 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const struct tcs_request *msg) >> } >> >> /** >> + * rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy. >> + * >> + * @drv: The controller >> + * >> + * Returns true if the TCSes are engaged in handling requests. >> + */ >> +bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv) >> +{ >> + int m; >> + struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS); >> + >> + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { >> + if (!tcs_is_free(drv, m)) >> + return false; >> + } >> + >> + return true; >> +} > >This looks racy, tcs_write() could be running simultaneously and use >TCSes that were seen as free by _is_idle(). This could be fixed by >holding tcs->lock (assuming this doesn't cause lock ordering problems). >However even with this tcs_write() could run right after releasing the >lock, using TCSes and the caller of _is_idle() would consider the >controller to be idle. We could run this without the lock, since we are only reading a status. Generally, this function is called from the idle code of the last CPU and no CPU or active TCS request should be in progress, but if it were, then this function would let the caller know we are not ready to do idle. If there were no requests that were running at that time we read the registers, we would not be making one after, since we are already in the idle code and no requests are made there. I understand, how it might appear racy, the context of the callling function helps resolve that. -- Lina