Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4835315imm; Tue, 11 Sep 2018 19:23:57 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb+ZMhvInh7H8Kr+sGztNMY3kDS5ghB4x4rx9RgQ4TkDLA9NL6/UQA2tprc8FFozQEZwFog X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr29638974plb.210.1536719037197; Tue, 11 Sep 2018 19:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536719037; cv=none; d=google.com; s=arc-20160816; b=VApRzl6tgkGGX+5TBiboaw3iKOsmUmWvHW2Btzhx1/w5Ev3UEQRsLnYWo6EpKUYmf2 eTch53SeBosVp+/cG4zKpBmzkGcNgxldwzeY4/tG4Hld5+QEWdRKrHHcqYFPb4nJKFsn 7p5/OSCwg8UrNCHArlA5hu7nqH6FSMuFF+57Y6UAbXnQIzeXNE8+adgCoHhj5CYGpIJ+ ptWcgaXwmWqHKH9SmGAFmuLCl3F2J3K0DtG5omceKCkEbMQfZYFvmvhN4N0TbbMnzua3 f5p36P8b49E5LkbtO8NoZNwNC2BqxkFHKlgmZg3a0wQBdCNun0+6cB5OIpjrCspYJU6+ 5Ksg== 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=ocyYAGHyHtPhNO4sxcaOYMxW4M1MZhKtbWg3B8qUGzU=; b=tQPWXpCsaiLcfdNSzpbh3LpxCjF0Zof/l06hPdKTiyma5vicoRAT/6WvAR0d8at+x5 Vet8CW7wzkw9A3EyHPXY0btNCeLG+jItmgVOMg0VUSJa3lk37dZ9G1Am8P6YPb1UhaUq 9XGSvuODs6/J/VnEL+qY48TdkTbEJhhYkXof58bAIpLEQWxBohqhPcunYFi0Zxx+QCXf dXn0uA7QdvMkBUoH5HGevxOqOfIG+h2oOY6u3jadV3qp4PfPhUrUrIZGarkqfC1jthw3 XJh1U9SCaOdquvS7fqr+Vof5PmVtDHWRBgKvQQ0EJ2b6H0pk2wsCk3L3Pnrz8kG63nBy scdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ck0Lt2GO; dkim=pass header.i=@codeaurora.org header.s=default header.b=AYuhKCAI; 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 d38-v6si21307634pla.422.2018.09.11.19.23.42; Tue, 11 Sep 2018 19:23:57 -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=Ck0Lt2GO; dkim=pass header.i=@codeaurora.org header.s=default header.b=AYuhKCAI; 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 S1728161AbeILHYQ (ORCPT + 99 others); Wed, 12 Sep 2018 03:24:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54980 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727752AbeILHYQ (ORCPT ); Wed, 12 Sep 2018 03:24:16 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 52132608C1; Wed, 12 Sep 2018 02:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536718926; bh=rdu6P+RtGeTxImILfFKjcn4ZQYhNbV03QwlhXS8+3/0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ck0Lt2GO1gBdGvWis5zogpGMU2PMHhD5Bkzlg8VNzJjuEwLKuhcidjBwJNTvRVz79 iZ54zzI/myYf4YxHprKGGGwBJUbkSrCXh248A7qHz9nEnaSsxAHjpirGU4tBZqtOeH VOCuBm2BaVyg1VQFN4cQ8MwLaFQKfuR8yhD+34i0= 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 5E9ED607DD; Wed, 12 Sep 2018 02:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536718925; bh=rdu6P+RtGeTxImILfFKjcn4ZQYhNbV03QwlhXS8+3/0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AYuhKCAIYnhENCS857LfgFYr5anmGSWQ43wFxJYl9lLD608a6hgk5CYKzD7j0cQns 2t+9O29TaM7vjZ6VeFlhlUIqQxlzBPTc9khLvlZ8NuPiZPwFfWvQ9HXmk/T1M0C2xz Z+VdqkXF2xt8bM803lJtcZinSqFIjNpP78L5FYVQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5E9ED607DD 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:22:04 -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 3/6] drivers: qcom: rpmh: disallow active requests in solver mode Message-ID: <20180912022204.GI15710@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> <1532685889-31345-4-git-send-email-rplsssn@codeaurora.org> <20180911230203.GI22824@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180911230203.GI22824@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 17:02 -0600, Matthias Kaehlcke wrote: >Hi Raju/Lina, > >On Fri, Jul 27, 2018 at 03:34:46PM +0530, Raju P L S S S N wrote: >> From: Lina Iyer >> >> Controllers may be in 'solver' state, where they could be in autonomous >> mode executing low power modes for their hardware and as such are not >> available for sending active votes. Device driver may notify RPMH API >> that the controller is in solver mode and when in such mode, disallow >> requests from platform drivers for state change using the RSC. >> >> Signed-off-by: Lina Iyer >> Signed-off-by: Raju P.L.S.S.S.N >> --- >> drivers/soc/qcom/rpmh-internal.h | 2 ++ >> drivers/soc/qcom/rpmh.c | 59 ++++++++++++++++++++++++++++++++++++++++ >> include/soc/qcom/rpmh.h | 5 ++++ >> 3 files changed, 66 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h >> index 4ff43bf..6cd2f78 100644 >> --- a/drivers/soc/qcom/rpmh-internal.h >> +++ b/drivers/soc/qcom/rpmh-internal.h >> @@ -72,12 +72,14 @@ struct rpmh_request { >> * @cache_lock: synchronize access to the cache data >> * @dirty: was the cache updated since flush >> * @batch_cache: Cache sleep and wake requests sent as batch >> + * @in_solver_mode: Controller is busy in solver mode >> */ >> struct rpmh_ctrlr { >> struct list_head cache; >> spinlock_t cache_lock; >> bool dirty; >> struct list_head batch_cache; >> + bool in_solver_mode; >> }; >> >> /** >> diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c >> index 2382276..0d276fd 100644 >> --- a/drivers/soc/qcom/rpmh.c >> +++ b/drivers/soc/qcom/rpmh.c >> @@ -5,6 +5,7 @@ >> >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -75,6 +76,50 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) >> return &drv->client; >> } >> >> +static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state) >> +{ >> + unsigned long flags; >> + int ret = 0; >> + >> + /* Do not allow setting active votes when in solver mode */ >> + spin_lock_irqsave(&ctrlr->cache_lock, flags); >> + if (ctrlr->in_solver_mode && state == RPMH_ACTIVE_ONLY_STATE) >> + ret = -EBUSY; >> + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); >> + >> + return ret; >> +} >> + >> +/** >> + * rpmh_mode_solver_set: Indicate that the RSC controller hardware has >> + * been configured to be in solver mode >> + * >> + * @dev: the device making the request >> + * @enable: Boolean value indicating if the controller is in solver mode. >> + * >> + * When solver mode is enabled, passthru API will not be able to send wake >> + * votes, just awake and active votes. >> + */ >> +int rpmh_mode_solver_set(const struct device *dev, bool enable) >> +{ >> + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); >> + unsigned long flags; >> + >> + for (;;) { >> + spin_lock_irqsave(&ctrlr->cache_lock, flags); >> + if (rpmh_rsc_ctrlr_is_idle(ctrlr_to_drv(ctrlr))) { >> + ctrlr->in_solver_mode = enable; > >As commented on '[v2,1/6] drivers: qcom: rpmh-rsc: return if the >controller is idle', this seems potentially >racy. _is_idle() could report the controller as idle, even though some >TCSes are in use (after _is_idle() visited them). > >Additional locking may be needed or a comment if this situation should >never happen on a sane system (I don't know enough about RPMh and its >clients to judge if this is the case). Hmm.. Forgot that we call from here. May be a lock might be helpful. -- Lina