Received: by 10.223.185.116 with SMTP id b49csp49993wrg; Thu, 8 Mar 2018 12:41:22 -0800 (PST) X-Google-Smtp-Source: AG47ELsAQWiZTNiCF8JjxcvmVfc4xj8UBxrUXJnsJS8ZJAUgaSS+YmtuEpQYHBCH+AtIDtZ5lLse X-Received: by 2002:a17:902:ab84:: with SMTP id f4-v6mr25537214plr.239.1520541682621; Thu, 08 Mar 2018 12:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520541682; cv=none; d=google.com; s=arc-20160816; b=N94HqpY9QjeeUJHvDUUbzPtje5HAnr4PbO+Cu5gHMUQmB9xKLyaf5bakV+uZEe5UKc tIRkPyixA9qcse7HlLPQVOunJu8bEqp14yfskMAZopPQ2OY7Qk2HNazNc0TQEfdXd3j5 ERbwDVkg1VnUSORyzv277Lh8b/hhkMTJHUABn4QspMYUB/lvnKXgBP8EQmj2gwuoVOQ+ 6T6nUd68nxi77b/Ep0mrJJUVgZ3ka49PtzKv4cQ2dY9OwwcZRa/kxNrUrtiKkZ90e4sx +B+nHF7jAPzh9ReCAsOJ3LVeLmL4rZtB5kj/B0ktpqZCVf9/IhpfANX/b4mD2lSFejyH QS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=aRdb8U3lGnVSb1F0rI4uyW+AHhF/sPTDCNtFbf3LEyc=; b=dwtr3igHnridZltMPlt72axuNYjM9kBNNVGUHSLApKqyq43S7UrivSA+k9YjAsDRWZ Uu/7TqmadHAB2XdexjkUcMTPBks46tjJz8C2UZ4xTDKELpL0fBQR2RpHSrefVJDSeNB/ 6ra+V+4fd2/kewXZWVXEvYAUY5odlb87kPiOUVD6HK1VRXm+TtGsIFrZhwwCkV2228pF 0JKbd8xw7K+WfvVuxCDEFrHH8RQS8ZgM9rgWSPszN+Sl+ZkoKwRGsTFBZ3y89UAPLkkk iO8Mn7ikFzzbIPLzqjAnSg9B/pGiyOlPrk5JecfaLR+ADcJiz96uuvy/GyzIZa+62ECu zMng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Eypeh3dK; 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 u19-v6si15356495plq.120.2018.03.08.12.41.08; Thu, 08 Mar 2018 12:41:22 -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=@chromium.org header.s=google header.b=Eypeh3dK; 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 S1751114AbeCHUkO (ORCPT + 99 others); Thu, 8 Mar 2018 15:40:14 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41037 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbeCHUkM (ORCPT ); Thu, 8 Mar 2018 15:40:12 -0500 Received: by mail-pf0-f195.google.com with SMTP id f80so380043pfa.8 for ; Thu, 08 Mar 2018 12:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date; bh=aRdb8U3lGnVSb1F0rI4uyW+AHhF/sPTDCNtFbf3LEyc=; b=Eypeh3dKPgpKeGOHlSxpN1Et74DwTsRkW3le/W6ZcCiu/IkmPL4EU0nUD5Xl+Smn/F pUTWo+3+wPYLasMDWkAEgwzJxFwXjjpoysC3Pddw7iMNt91eZorubMGeG0ik7dmhumR/ caqycVLQhQ70+F+ivsWeNnLe5vPtpcJDWWLo4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=aRdb8U3lGnVSb1F0rI4uyW+AHhF/sPTDCNtFbf3LEyc=; b=pIj+VHWi3UKKrSrnNbNOARE0VGnnZZ5g6gWt4XWY9BsXio73kPwLfM7SuomkRDCzrx g1XGPNrbUtmUvDwCw8EOgxOZID7M+aCuBl0YkCUzlHLKFyuGR3PCUgWgHytwR9cmbVrE giQVbb7TAdxG+cjyaz5NTHyLk/RbGMLh6VH8jzvZ8+yXxWekymK+Vagj9MB5VPpTiL7F QbS4am457TU4YKdPIrKWlwlpldl2EpzTzMGMVs/zradE++K7AlGM2usgt+X+tMzxtVgf BsNm4t7R8arlbyl7QcpzL4MQ2Ae2+nWHLXSUoj1L+MCBppNwZLO0dKahr0k4Hp4W+POC 41Jw== X-Gm-Message-State: APf1xPAxa8gcMzcgsnQqUUPYtNv+3yMlwb7zGrB+rflMqY4ACCwy7VLV Nh79ZrB8grqU1HJvsQpUs1oAHQ== X-Received: by 10.98.13.24 with SMTP id v24mr27331241pfi.89.1520541611480; Thu, 08 Mar 2018 12:40:11 -0800 (PST) Received: from localhost ([2620:0:1000:1501:422f:ca5c:71a2:c3b3]) by smtp.gmail.com with ESMTPSA id h75sm43631632pfh.28.2018.03.08.12.40.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 12:40:10 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Lina Iyer , andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org From: Stephen Boyd In-Reply-To: <20180302164317.10554-7-ilina@codeaurora.org> Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, Lina Iyer References: <20180302164317.10554-1-ilina@codeaurora.org> <20180302164317.10554-7-ilina@codeaurora.org> Message-ID: <152054160996.219802.12202813950978900157@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v3 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Thu, 08 Mar 2018 12:40:09 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 =3D 0; > + int inv_types[] =3D { 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 =3D 0; type < ARRAY_SIZE(inv_types); type++) { > + tcs =3D 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. > + 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 =3D tcs->tcs_offset; > + m < tcs->tcs_offset + tcs->num_tcs; m++) { > + if (!tcs_is_free(drv, m)) { > + spin_unlock_irqrestore(&tcs->tcs_lock, fl= ags); > + ret =3D -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 =3D rpmh_tcs_invalidate(drv, WAKE_TCS); if (!ret) ret =3D rpmh_tcs_invalidate(drv, SLEEP_TCS); unlock()