Received: by 10.213.65.68 with SMTP id h4csp2124910imn; Thu, 5 Apr 2018 09:21:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx498e604zxaVXtYbjjr0s2ed6fhX4ikrVQ1f27Kii71EIi6BaQaXW/NIMYIjimVZAh9rmF95 X-Received: by 2002:a17:902:bd91:: with SMTP id q17-v6mr21709973pls.330.1522945309303; Thu, 05 Apr 2018 09:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945309; cv=none; d=google.com; s=arc-20160816; b=P0TvE8gPR1aSzbhxaznpF3qOA8BdudF0KNigBn096D+4B4Q8y+E08/BpjC1TmTdVWw heQZ6ZTc2THGHw9DlUES7bNxSzW2QoiTGIyNH47QiT9lNMfEgPNRDCzMONJ7VVmVssl8 XOFKzpwzMbjMB3OQzKvL9coBV37imj5kAToWpUGfGcDVCkY7dj2bwsJ/4yXm1aG0vftP KxQhGjKIz0bLadW51B0Z31AuLz1/NJn7Gfk14KI51Ax6FH/qNdZxOfTtZBN49w1gnU4I fqdvDiTg64gMjtQoRikVHEHMoKJsGoCjuJhBskzeUp8uN0AwlVzyGNfIbBwTHJHNJhej pLpA== 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=uXUza353dQYs2psRpdW3QfRLOR7XyVKcGhbV7gk63fI=; b=te7hMaUfU9PLuLqR1xlATEHFb3JR/RZpu8FSWUP8mBt3GbU4uz6LhSzDBbSdNKQZY9 umM07DY8wYOb5t1AwFqOMuRv55h59KRU7egBSurkPG35lydtRRT5DbmFyN3QqjuLDzFh QJAE6AnKPYK9jvGpxkMi5bnzPDPX/gv4hK6aiYJ9Qvoajy9dYQQPkWp1L6zI1XUVotRY gi3o5pTf2ZyUmejR8kum46GL7Ubbf18fX5smTgF6Y+rmHxGSiabywPJWRpiIwy8tfH8E LQXNRFo6ogwQzA8f428hkdTqMlPFs8GC6TnM9QWaDWKmVR7eqp3kpWCG9s5tX3IN9z/J QaaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=dOGEllCr; dkim=pass header.i=@codeaurora.org header.s=default header.b=pBr4fmOo; 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 j21si6388625pfe.132.2018.04.05.09.21.35; Thu, 05 Apr 2018 09:21:49 -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=dOGEllCr; dkim=pass header.i=@codeaurora.org header.s=default header.b=pBr4fmOo; 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 S1752210AbeDEQS6 (ORCPT + 99 others); Thu, 5 Apr 2018 12:18:58 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41872 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752164AbeDEQSw (ORCPT ); Thu, 5 Apr 2018 12:18:52 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C6DC860FA9; Thu, 5 Apr 2018 16:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522945131; bh=fazVnUwl4HkIiuE0FvewI8jphSrIJZAK5R/VlKxDzSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dOGEllCrYgNnGqNxMbrhul6hpfSssoeQ1j/e9GC/bGbGq30Z0xiKEN0ZacfNWK+X9 vufeMPlUYCytin3tREyKDv4MJ7d5AgyfL2xYE4zkH/Hp+POVWbZQUpLCv8TnfKPZkw K+qUm9EAvlz5aw5Iz/GxtznxVhSm/HYL7Eu21UA0= 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 8908B6055B; Thu, 5 Apr 2018 16:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522945127; bh=fazVnUwl4HkIiuE0FvewI8jphSrIJZAK5R/VlKxDzSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBr4fmOoSh54Yv0LimbyTAIhdhLpWFOA3j+R42MerSX+LfN2wlvR2rbwV2NU+UG2A DVwzBm37DLzNGEn2+qGldzmURPtyvInpUkCcIdsqi8tnAZNK1RDcc3IPHSKZYb9dFJ mHJW4nmuTcUA1ml1gEc84+ZFO1PTRHIUlcseQy4U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8908B6055B 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, Lina Iyer Subject: [PATCH v5 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Thu, 5 Apr 2018 10:18:30 -0600 Message-Id: <20180405161834.3850-7-ilina@codeaurora.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180405161834.3850-1-ilina@codeaurora.org> References: <20180405161834.3850-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 v4: - refactored the rphm_rsc_invalidate() --- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh-rsc.c | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 638662721086..3fab86a01f14 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -92,6 +92,7 @@ struct rsc_drv { int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); +int rpmh_rsc_invalidate(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 58fc7254b6f3..1dbccc4d0605 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -162,6 +162,54 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type) return tcs; } +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, 0); + bitmap_zero(tcs->slots, MAX_TCS_SLOTS); + } + spin_unlock(&tcs->lock); + + return 0; +} + +/** + * rpmh_rsc_invalidate - Invalidate sleep and wake TCSes + * + * @drv: the mailbox controller + */ +int rpmh_rsc_invalidate(struct rsc_drv *drv) +{ + unsigned long flags; + int ret; + + spin_lock_irqsave(&drv->drv_lock, flags); + ret = __tcs_invalidate(drv, SLEEP_TCS); + if (!ret) + ret = __tcs_invalidate(drv, WAKE_TCS); + spin_unlock_irqrestore(&drv->drv_lock, flags); + + 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