Received: by 10.192.165.148 with SMTP id m20csp142472imm; Wed, 9 May 2018 10:06:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZomNh2Tag4UuzHTCF4hxW/W711MPxeWnxJRACCZKJrgKE2NktK9HqIg37sKf7rGn0qhkKnf X-Received: by 2002:a65:5504:: with SMTP id f4-v6mr21875471pgr.177.1525885593947; Wed, 09 May 2018 10:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885593; cv=none; d=google.com; s=arc-20160816; b=hgi/QyLF5mPkz7kPlpQwqf+pRtR0UOX+ihlpRw3u9ENjMainvhfDoGfTTcS8oi3fFE aUMVSq3FxKsNnWZTaaoSydD0L63+SKlhXQccskGjYJy62eafN9jo6w2U0elTBm4Ruh/x rYCG1MV9lID/qp5I/jDiwgfBh9Aq3AaXqTsHFa0C3jcRshzHv2+isCI3dzoBKtn39bYn dt0RuOGyCazRHLPPxgZvidfy2U06kD0mvwoeVomcYDYwQ8wz5uiGkNLd8L2JbzvYfcAG Rldv3Afmfg2CeToPpOkhY+GfDam5rF/ynjLCHVh/LTWrZTQKIzTCQfCM8iunWjcnd2VX 5FzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=m1NX92/Qfr8oHK7/+ieT8hqcqdBjbXT6EEbtXsTBamg=; b=y4RTps27PbJtn5Mpz7n8/1zfvIB7mteg0iuCqpwc9fNMKf3qhH3I/EL5MLrjFu0DBB YsMm+O+el6Yf4RcqiCUvvgYEqkSIp5fjbSmozxEDg/QTAbE28vzkYFjaPiVrKezc7lw8 8AUbSEKJ4eUEIJ8iY04MCZ1Vuq/N8/Cy/2hy5etYzZrZjVXW+SkWx3EWf9MBU6FQMIsV yseUiATXPe+raMFwRCyL8V+xevbQfOKd9cG+GOGpUe9HggFVoIzGSW3PgLvnN4/qNFBv SDIAIAwYRjnhTCTbXdYg1OMdbKmcimhcVYk5QeAQbulYH5+nt5UOuieM6XjWt0QInrcq 4GFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Sg5BoJYA; dkim=pass header.i=@codeaurora.org header.s=default header.b=PqWAPGWA; 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 1-v6si11838865plx.236.2018.05.09.10.06.06; Wed, 09 May 2018 10:06:33 -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=Sg5BoJYA; dkim=pass header.i=@codeaurora.org header.s=default header.b=PqWAPGWA; 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 S935521AbeEIRDl (ORCPT + 99 others); Wed, 9 May 2018 13:03:41 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57000 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965715AbeEIRCN (ORCPT ); Wed, 9 May 2018 13:02:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 812106022C; Wed, 9 May 2018 17:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525885332; bh=8J1CAJlEsRaRqAuxg+xHipkGBqvsgC4RW4neju4umBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sg5BoJYAg2VFG8Mvt2/Gdu7kACNq5fgtC+YMNCNCMtXQ+DuO97NYksyz6E8H/ZiX0 VX7FJnjnh+WtmH0182qnD7hgzS170ZnRlv4/fgfucPg4OLBWSzHKXyrGYgZmI8EoS7 2ynafLeeWENKtG3PyBdycUpS1etkbKHlaA7V8JfA= 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 codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DCB216022C; Wed, 9 May 2018 17:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525885331; bh=8J1CAJlEsRaRqAuxg+xHipkGBqvsgC4RW4neju4umBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PqWAPGWAuPUWzj8D2oC8i2TES4VmcxtvrtGadaFC1ZwrlkC8fjvC/zKYMvsIG6cJL LHYSi1KqISBMMQd+bX8V8sBOtp0T1H7IwqF9nXJS2ZHR6Lewj0GBu1AR07y4lNi+TF d4eYMKZOWzKW+E4Pk9x2Ag0Ggxsuvo3XCKkQ3Uus= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DCB216022C 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 From: Lina Iyer To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, rplsssn@codeaurora.org, Lina Iyer Subject: [PATCH v8 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Wed, 9 May 2018 11:01:55 -0600 Message-Id: <20180509170159.29682-7-ilina@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509170159.29682-1-ilina@codeaurora.org> References: <20180509170159.29682-1-ilina@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow sleep and wake commands to be cleared from the respective TCSes, so that they can be re-populated. Signed-off-by: Lina Iyer --- Changes in v7: - Move bitmap_zero() outside the loop Changes in v6: - remove unnecessary locks around __tcs_invalidate - rename function to tcs_invaldiate Changes in v4: - refactored the rphm_rsc_invalidate() --- drivers/soc/qcom/rpmh-rsc.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index b5894b001ae1..68c25ebbbe09 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -104,6 +104,51 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type) return &drv->tcs[type]; } +static int tcs_invalidate(struct rsc_drv *drv, int type) +{ + int m; + struct tcs_group *tcs; + + tcs = get_tcs_of_type(drv, type); + if (IS_ERR(tcs)) + return PTR_ERR(tcs); + + spin_lock(&tcs->lock); + if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) { + spin_unlock(&tcs->lock); + return 0; + } + + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { + if (!tcs_is_free(drv, m)) { + spin_unlock(&tcs->lock); + return -EAGAIN; + } + write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0); + } + bitmap_zero(tcs->slots, MAX_TCS_SLOTS); + spin_unlock(&tcs->lock); + + return 0; +} + +/** + * rpmh_rsc_invalidate - Invalidate sleep and wake TCSes + * + * @drv: the RSC controller + */ +int rpmh_rsc_invalidate(struct rsc_drv *drv) +{ + int ret; + + ret = tcs_invalidate(drv, SLEEP_TCS); + if (!ret) + ret = tcs_invalidate(drv, WAKE_TCS); + + return ret; +} +EXPORT_SYMBOL(rpmh_rsc_invalidate); + static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, const struct tcs_request *msg) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project