Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4651462imm; Tue, 11 Sep 2018 15:39:39 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda4IVVw+SmYmjX24/0IJJWr2DJvb+VQ9mmMAqAFah7CZQKOj8wMqPDwJA4P+5VNGohvyu3J X-Received: by 2002:a17:902:b60b:: with SMTP id b11-v6mr28717738pls.301.1536705579604; Tue, 11 Sep 2018 15:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536705579; cv=none; d=google.com; s=arc-20160816; b=Co0FtasN28nZ/8RzRqSMfZzrlrifayFC3N4Mt0wAX5QJHGuY4FOrea6jRmBQE6CA4S w8wEX5tLcKIe/faR5xx9huJbaNlkLF2NN7GGvKV26Rme3CeDIz8xmbDYJiXMqNUQ70iz yRxXvgHk85QJuW8F67t5DBytAMHhTZ3OPAWKnoVNDkHwR6UcGFbs0Oey8o9vHF9+aLWZ WnqhjKO7y94d+ADyTJk9dJ3JUt5ydktCKI6GbD2WceYC0VVdhIq7a0IRZeJLHELApgqj 7d7dA3V1Wb4Wd5qD77lEa5TT8K4TpMJ9TtJbH8JexY2Ikocxkz0gokzKJDiPYWwCVXo8 7NVw== 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:dkim-signature; bh=QAo+lfi4UkZbHn0OT8dblft3rx2f+yRve0t+mV2m+94=; b=ITGYpu3VunZp7oHCVQxyQIj4uCNSr/a3eakBLQlLPWal4LLIxcp+eikN3CG1M+RDKe Fyuhm6FeNB7W2kr2W3DPnX2Ss2owAk0gLMcdIjqTA5PeubDseif3hY/NIoXCeROCmuoc YP/1H8ncRieMODaMupfkauCI7yoEUDHIbb40iKgV+/tI9dD7aappgOWHUIXPFiBlrObA Z++UKZuiw83YIZuBhzkv48FLIiFuGWXYcXk8IrKM5uuCu9lZkNdyhSVf9vEuZExZq7KU SMYarKack67/b7A5P5eJJKGEKzZcXoL9epUjJrjBcC5TLVNCC4BZf4N5uJXpc3llUOh+ 1SUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hbweQ94S; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65-v6si11872489pgc.20.2018.09.11.15.39.24; Tue, 11 Sep 2018 15:39:39 -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=@chromium.org header.s=google header.b=hbweQ94S; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbeILDki (ORCPT + 99 others); Tue, 11 Sep 2018 23:40:38 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33288 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbeILDki (ORCPT ); Tue, 11 Sep 2018 23:40:38 -0400 Received: by mail-pg1-f195.google.com with SMTP id s7-v6so12979792pgc.0 for ; Tue, 11 Sep 2018 15:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QAo+lfi4UkZbHn0OT8dblft3rx2f+yRve0t+mV2m+94=; b=hbweQ94STvBvzTZKlD/30RonElDr+Khjd/keYPUS7GP6TbATD54vWzSMobYtwKIuU5 TWDMxD3noZmTJFM5j3EiXSvLejnkf3cZhyDAt2XXOiinO+r/WvKNEkW0nldtilKPaMxe GegKV3q0TALDD8y1zrmge4cmrIqkt7EaLRnr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QAo+lfi4UkZbHn0OT8dblft3rx2f+yRve0t+mV2m+94=; b=e6tvgSgAcR+6huRJ6Rc4tEtlYcHXCYszgLUeM/t4D5k/mtHfCm6Ub0dRy59JP5E8BE LQbCzv8dwk09rADLKQblh8hAd0eVuKqMWYw6qeC3E3u1iZ5SLAP/x8v/IkFZwG3Lz/XS aRoxjb92tX1kZOhXA+3KqOqQX3FXYrYqfrlH7wxtfV5nXEwcozgUAoHqQIKMUAYVYe8i Em4wqoTkElZtspgyBi0LKQiGuSacs8WjymzB+ArTY+KITucReKo0+oW7ADif/JUxnM4S eV9XnsV8vwDGnWWnHOUpu66WMvGXw0yTFgWamiEWoLqoflVADxgn4DjS3wRL0BV7tABh Yhow== X-Gm-Message-State: APzg51BybenZF6kOxrJ3Er4GdcIfykGpwJMiHbrmYGd5v9Htww8+irhu CnfJ/qEgQP4GceIKx+KATtuGxQ== X-Received: by 2002:a63:5465:: with SMTP id e37-v6mr30835134pgm.316.1536705551196; Tue, 11 Sep 2018 15:39:11 -0700 (PDT) Received: from localhost ([2620:15c:202:1:b6af:f85:ed6c:ac6a]) by smtp.gmail.com with ESMTPSA id b203-v6sm28048461pfb.174.2018.09.11.15.39.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 15:39:10 -0700 (PDT) Date: Tue, 11 Sep 2018 15:39:10 -0700 From: Matthias Kaehlcke To: Raju P L S S S N Cc: 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, ilina@codeaurora.org Subject: Re: [PATCH v2 1/6] drivers: qcom: rpmh-rsc: return if the controller is idle Message-ID: <20180911223910.GH22824@google.com> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> <1532685889-31345-2-git-send-email-rplsssn@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1532685889-31345-2-git-send-email-rplsssn@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.