Received: by 10.223.185.111 with SMTP id b44csp516502wrg; Fri, 9 Mar 2018 08:42:44 -0800 (PST) X-Google-Smtp-Source: AG47ELtEBCqIeDmtNLtjDWr22WgTUtfdUDZ+XFzSnVmnv6Y2bWkZ6DeGGt0OCB4qyz90FLcEBdzI X-Received: by 2002:a17:902:6c01:: with SMTP id q1-v6mr18704314plk.142.1520613764512; Fri, 09 Mar 2018 08:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520613764; cv=none; d=google.com; s=arc-20160816; b=blwZgI0zckBv9jjTccBtCZCrou6kK2U5P1wB7ZSxiZ6/a2i9wW9hFXA2yBdMbVUV7g yGjseDhwK8VvnngrechvDwFG3COByOjR5boFylWic1Rd+MKUNPvuorcNdLMfJM3zR2gl plQeVtvLb2+6YiRbqc2T4tvJfySddak6ctGIoloY7H7byH1aPpjzZoADIzcDhSl3bmIC mT2mJxpxftDcnGTyDdZLfjfNmICTSz2/lBXZdP3KaBgMxaNTR7YnmHhJ3uyP85yKpTer bLHFuMLkqYPrpBhH7q1wkGpbTM5bmPB2/ZatVSDbB3VD4HTExPGInryrTd7XHpUx4QuF wQhA== 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 :arc-authentication-results; bh=t13RWFjIjVYZSkMswrjEhpT5bjkeR8to8nkTnnYah/Y=; b=MmdPHrhr+6ZePwau1fAfkqlEgbXVY2zwelthqCSMy0HOHK3WmyJsWcQTjVkgS71ABX gllL6vL+9uafRMxnRRMR9QZLpjAvSEZ5jSalnNJJ3FPyQ4ZYfZXzg8KKHhDbb9LDa61z IHV4ISyeUVA8s9MBYlvZ4NQcLSPBwM/pNz9MnhUAs8d0pxJMveJWsoVBaCgqGvAeRf6F xTwFszkXq9kejoy90HlVb26Gkauzz9Zb5mbMJ2JGnDcS7K5dMYhrG+epXnY5t32g1+Dn 9hF/6KcXe8KBAhEnvLx06ICVc0OG42tzcLp5AiASG7VNq0tjThgED55smFnTcMZBxmAE pOyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Rj3+qQZ8; dkim=pass header.i=@codeaurora.org header.s=default header.b=Rj3+qQZ8; 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 k80si1110417pfh.260.2018.03.09.08.42.29; Fri, 09 Mar 2018 08:42:44 -0800 (PST) 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=Rj3+qQZ8; dkim=pass header.i=@codeaurora.org header.s=default header.b=Rj3+qQZ8; 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 S932133AbeCIQlh (ORCPT + 99 others); Fri, 9 Mar 2018 11:41:37 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:45202 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbeCIQlg (ORCPT ); Fri, 9 Mar 2018 11:41:36 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 98B1C60618; Fri, 9 Mar 2018 16:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520613695; bh=8L3aE2dIZnaywek8JWXApCKOkrAFmUykYYS2uAF8254=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rj3+qQZ8aD4xtgFSzKwKSzIj0tjRcO39Edyup5U2AeixYFdwrI1xPP2P2XWjmVKzi xOy13WLDAc+4xnE8firXp67/3uR79K0lhZdpADCWrKwiZF+V9+HK9xMt6VR/m1Iv3g CZi1yTPUumnDoy9ilwzP0m6kFPY9LOJSVtQd9aEw= 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 EA2BD6038E; Fri, 9 Mar 2018 16:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520613695; bh=8L3aE2dIZnaywek8JWXApCKOkrAFmUykYYS2uAF8254=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rj3+qQZ8aD4xtgFSzKwKSzIj0tjRcO39Edyup5U2AeixYFdwrI1xPP2P2XWjmVKzi xOy13WLDAc+4xnE8firXp67/3uR79K0lhZdpADCWrKwiZF+V9+HK9xMt6VR/m1Iv3g CZi1yTPUumnDoy9ilwzP0m6kFPY9LOJSVtQd9aEw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EA2BD6038E 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: Fri, 9 Mar 2018 09:41:34 -0700 From: Lina Iyer To: Stephen Boyd 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 Subject: Re: [PATCH v3 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Message-ID: <20180309164134.GE3577@codeaurora.org> References: <20180302164317.10554-1-ilina@codeaurora.org> <20180302164317.10554-7-ilina@codeaurora.org> <152054160996.219802.12202813950978900157@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <152054160996.219802.12202813950978900157@swboyd.mtv.corp.google.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 08 2018 at 13:40 -0700, Stephen Boyd wrote: >Quoting Lina Iyer (2018-03-02 08:43:13) >> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c >> index 34e780d9670f..e9f5a1f387fd 100644 >> --- a/drivers/soc/qcom/rpmh-rsc.c >> +++ b/drivers/soc/qcom/rpmh-rsc.c >> @@ -170,6 +170,52 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type) >> return tcs; >> } >> >> +/** >> + * rpmh_rsc_invalidate - Invalidate sleep and wake TCSes >> + * >> + * @drv: the mailbox controller >> + */ >> +int rpmh_rsc_invalidate(struct rsc_drv *drv) >> +{ >> + struct tcs_group *tcs; >> + int m, type, ret = 0; >> + int inv_types[] = { WAKE_TCS, SLEEP_TCS }; >> + unsigned long drv_flags, flags; >> + >> + /* Lock the DRV and clear sleep and wake TCSes */ >> + spin_lock_irqsave(&drv->drv_lock, drv_flags); >> + for (type = 0; type < ARRAY_SIZE(inv_types); type++) { >> + tcs = get_tcs_of_type(drv, inv_types[type]); >> + if (IS_ERR(tcs)) >> + continue; >> + >> + spin_lock_irqsave(&tcs->tcs_lock, flags); > >Should just be a spin_lock() because we already irq saved a few lines above. > Agreed. >> + if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) { >> + spin_unlock_irqrestore(&tcs->tcs_lock, flags); >> + continue; >> + } >> + >> + /* Clear the enable register for each TCS of the type */ >> + for (m = tcs->tcs_offset; >> + m < tcs->tcs_offset + tcs->num_tcs; m++) { >> + if (!tcs_is_free(drv, m)) { >> + spin_unlock_irqrestore(&tcs->tcs_lock, flags); >> + ret = -EAGAIN; >> + goto drv_unlock; >> + } >> + write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0, 0); >> + /* Mark the TCS slots as free */ >> + bitmap_zero(tcs->slots, MAX_TCS_SLOTS); >> + } >> + spin_unlock_irqrestore(&tcs->tcs_lock, flags); > >Maybe make another function called rpmh_tcs_invalidate(drv, enum TCS_FOO) >and put this logic inside it? And then change from a for loop to two >direct calls: > > lock() > ret = rpmh_tcs_invalidate(drv, WAKE_TCS); > if (!ret) > ret = rpmh_tcs_invalidate(drv, SLEEP_TCS); > unlock() > Agreed. That will be better. Will fix. -- Lina