Received: by 10.223.185.116 with SMTP id b49csp532937wrg; Fri, 16 Feb 2018 03:07:28 -0800 (PST) X-Google-Smtp-Source: AH8x226Qd0cgmUTy7EhOXv+btxJ6OYfgGYHRZh6BVxV2VbO/QRcZfuIb9VMZd8TO6KrWp/73pZkH X-Received: by 2002:a17:902:a50a:: with SMTP id s10-v6mr2736706plq.107.1518779247967; Fri, 16 Feb 2018 03:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518779247; cv=none; d=google.com; s=arc-20160816; b=RuaCRcoyg8UkFLtLmeaVx/VeFNM25vv7QKzf8ATdyqaiM0ke1GaihlfV4jrDGxV60b 9y4SChm1aKUDCKk641qaIg2QoRTRcawoRl0RK54fo24DWW9dWwY0OU0L5rJs7xiwsCSz LwiNJmKJxbRiO4OZNOfaYf/uBX7ex+vKDkMi9FuIFDGSKeLnA+ZausKhacA+GgDpRhfl s1BCc4xOi4XLa2A+9RazLcRvvv/cxh8Msg0Ll5EysbL4CK7Xa47811sG6QgfdUvUw1ZZ vxmq+wbjnFwA602YIEPRkwaEldFB8lbPx9Y6CDeu3woQjFAFHNmzBXMVq5mGBisvulFS mX0w== 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=EbZfGIKC6DfHsVzeqJP23alUVkdzHSkYtOaHaS6DUno=; b=PllLN1zFnfuPM5MXPkTuy+sfQYutWMjErwaP1x88DB3/UzM+mi9R5mrRHZtEqN0OQG RXDl58M8mGK1KZyu61//3JKXjn/M0tOF0iFgcatzu5XPehwK6YhBI9uz6xbbgEI1Mvlu bYKWZaKxpJpLvnf7j4vQLGCySylWZg7GkXKFIwqBdmFHMbbtis1qiNrAku0fhe+ufVpD yldstu3hbF3IfD/4TWQowuOiFcSKyW44mf77R7Uu1ri9jnf+Gq3LCtbn8AWU0vbc7xab SRdGNiRzgxdoBzaXBNOKaE/OeHKWCqD+dUc7fW+bvp9ajMh7enryFF4VpXIOPR4zra66 MgNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Mlyd9yTV; dkim=pass header.i=@codeaurora.org header.s=default header.b=YCCoUlqf; 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 k1si1283572pgp.751.2018.02.16.03.07.03; Fri, 16 Feb 2018 03:07:27 -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=Mlyd9yTV; dkim=pass header.i=@codeaurora.org header.s=default header.b=YCCoUlqf; 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 S1427426AbeBORfb (ORCPT + 99 others); Thu, 15 Feb 2018 12:35:31 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:43404 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427393AbeBORfZ (ORCPT ); Thu, 15 Feb 2018 12:35:25 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2B70760F6E; Thu, 15 Feb 2018 17:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518716125; bh=bVPvWuQ1uF1UVIoggu+p4HZq71rNI2BjdcZ5n7gIc0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mlyd9yTVezrR2QnvkZCObN8nv8iFshzP+MUmOqBiTw5sH8SE3UXnQbKWOq6yav54/ pjO92cu/CrVADQeUq1EvJX2PTR94e49oUTrZ8RNbCjxpY32tN14lDH2P7aEmAJ07k2 Uem7kY52IYdYjjEjJtTBGEzsia40y7Cekntx2N8Q= 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 E1E19608BF; Thu, 15 Feb 2018 17:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518716124; bh=bVPvWuQ1uF1UVIoggu+p4HZq71rNI2BjdcZ5n7gIc0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCCoUlqfhXcHAS1h9xtTR+dyDd6Kzfmauqb/+VVqrreMksCbDQ5B4Uyj+HljQGfbg uLLByWBNvqDBATfig7GRoraZvepkDGNt6jtiscPSBSGgejg5t5BFvDNr3uRFLdo+AA GuJKwiSbWBs3GuJYP6bkBrk0D4jpTJ5aNQzmKI3Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E1E19608BF 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, Lina Iyer Subject: [PATCH v2 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Thu, 15 Feb 2018 10:35:03 -0700 Message-Id: <20180215173507.10989-7-ilina@codeaurora.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215173507.10989-1-ilina@codeaurora.org> References: <20180215173507.10989-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 --- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh-rsc.c | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 957b1a79c4c8..fa1d36f796b0 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -89,6 +89,7 @@ struct rsc_drv { int rpmh_rsc_send_data(struct rsc_drv *drv, struct tcs_request *msg); int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, struct tcs_request *msg); +int rpmh_rsc_invalidate(struct rsc_drv *drv); void rpmh_tx_done(struct tcs_request *msg, int r); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index ae555fdc3ab7..951b797a8cc7 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); + 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); + } +drv_unlock: + spin_unlock_irqrestore(&drv->drv_lock, drv_flags); + + return ret; +} +EXPORT_SYMBOL(rpmh_rsc_invalidate); + static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, struct tcs_request *msg) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project