Received: by 10.223.185.116 with SMTP id b49csp178695wrg; Fri, 2 Mar 2018 16:21:24 -0800 (PST) X-Google-Smtp-Source: AG47ELv5j2uwnO6PCKYQvGq7gO/s4CacyjtOCTaIO9tnvYpsvGt797LVDps0WPY4CB9eoEkmrdtS X-Received: by 10.98.73.89 with SMTP id w86mr7246898pfa.227.1520036483895; Fri, 02 Mar 2018 16:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520036483; cv=none; d=google.com; s=arc-20160816; b=PM9dxrnXUBM2kM8ZOYMT2WQARrtXBOFGzFBrvLNr2GyCkyAh2mb81N5DNArqlNf6H/ Yc6fRb2+QtRwenatch7BYhiEcHfxNr8MZq2msqL36qabBMbpvvMFDV55kaMuc9/W+U/y IaXswlyjAh3LdL6lvJNkpknbx310sdQ5WP1plt71hPh+NEb2Ga2gtpyWyWEdOLc23rSW r9EasyQ5t9J/pgbuYKb9ODIDc0rNpYbZN80rDwuTzTomcY5NMsYFgLs05C7AQcYuc6Zn /o/64EKUM95MF1N8rLyEwCNRwnQaPad8kpVgWXyVTsl2LCTeJZlhwMW6yK8kvngu581P pRrg== 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=RDNfo3Cie5MPyCDPzhDdLDRvgv5TSiNnYEfl7HLZxf0=; b=FmQvFt7IgAI13bKzfGapUHKQT6fRwhvU+bx7FOxuDKAIJm/l81OWM1xfTZvVVvSXht 49b+Rr8efTnlj1EvjBxLtsYuTqiQfWmsGWWU63KaIAvbtAccSSMTlCWjbfXyY8zHN332 uBbmtrTswVa65J+CyRvEIxuD/sSgx1IrYUXoklqab8LwxKIdCgINd+PV5l1Z6QdLyep7 SIPNKJx3MMtwKKvZuVaiFAV0tZxPPXgfzCLQH87rH50gDygECV4qXSbOKgGSFeiXacm5 +HyNvJ+klmvAH0JuBuxeRqrI8mjhxUaOPM9xA83q+ajW+3PQtO1L/O+hHYvBVEcTvszX fI9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=MTFCYvG0; dkim=pass header.i=@codeaurora.org header.s=default header.b=ILwAivxL; 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 15-v6si4052187pla.342.2018.03.02.16.21.09; Fri, 02 Mar 2018 16:21:23 -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=MTFCYvG0; dkim=pass header.i=@codeaurora.org header.s=default header.b=ILwAivxL; 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 S1422786AbeCBQnv (ORCPT + 99 others); Fri, 2 Mar 2018 11:43:51 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:41074 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967981AbeCBQni (ORCPT ); Fri, 2 Mar 2018 11:43:38 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4BCE9601EA; Fri, 2 Mar 2018 16:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520009018; bh=3kh0jkky3ac4HB7YuTQ/QWoayr4qC7/orBKgw9FQXf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MTFCYvG0AAAgE1htXw1RuzcXTKTp02wpBNWgV7mbYvbxWgbprs/gE5QUXDfunv2mQ qJPhFBfWz89H1nTi0OlEfvZ79ljezSYXnqO5Fzf7GqhfREL/WPJyK5Rk7u65bU6LNs oQK8uYNJLADbH6fyWg54mLLrPBNGE8La9xqnQRrk= 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 8A0ED60867; Fri, 2 Mar 2018 16:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520009017; bh=3kh0jkky3ac4HB7YuTQ/QWoayr4qC7/orBKgw9FQXf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ILwAivxLYRWcGBKSbTNL3b5bTD4jF5ka0Xh2zMfGcm1LsYCUE8gPaxo2gjVWp/Pa/ jUTqtcV4qyZ1dlwe5zyQyq/aGzKv1fRyE5LnK7jtZl6jJALF6rzKtwdh8gs0U+zidU gKDjINZODBPB1++ZdvdBycjLW7WjRucLjhl6A22c= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8A0ED60867 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 v3 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Fri, 2 Mar 2018 09:43:13 -0700 Message-Id: <20180302164317.10554-7-ilina@codeaurora.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302164317.10554-1-ilina@codeaurora.org> References: <20180302164317.10554-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 65dfe1716265..d2f73788a24d 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -90,6 +90,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 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); + 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