Received: by 10.223.185.111 with SMTP id b44csp863560wrg; Fri, 9 Mar 2018 15:29:21 -0800 (PST) X-Google-Smtp-Source: AG47ELuvWqxORjhS81FoG52V6CcgPqNhBBxrnGovbH3BWZ/RB+Y0E0beFwLOLwkhNEimfBXJxBAG X-Received: by 10.98.7.129 with SMTP id 1mr181681pfh.133.1520638161331; Fri, 09 Mar 2018 15:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520638161; cv=none; d=google.com; s=arc-20160816; b=czgTajODbk0KVzuIFC8DC9nBvuiHfmIvBVKWf3v7a4yRi4WtgPueuc+IWHE+mysnZA d7C6bO48M2mgOqZftV0+rsYaSckaTskwgWJ7mWzvn4jklLVYvVnP9DZhtbdhKrmteLAq 56sqkcNFirLeR0+Hb2yaii2CzTjzO4eGxuhGbQLs+Nn3tjVSRLll7GfmyIila7gii3OV HoxELDGunzsDcoanYodYzMKFD8JFQ7zQs0FwkL89lxoxmWmYEbmYHc/u4cnm6nGA8l9m ufKTZLFQT8gseXDyEgZLumdaIXN35PWtOS/D9buh2E/PptopZ+NYVb+Q2FJSZ9Q+jwXI N8QQ== 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=VoIBXDpvDABYL/+TQQG4S8nmufXd/P7/MMpxnePTJDpkw+3Ww7OcDSVvtU1FiJ2M9a RCVEBdOuxKkrjAl/PjXozZZSRcVIemMBeiue4NBAkxJZKA7m+rx/jaha1Bs0XtB4TfEb eXVPjP+IvKTNGDRXgd/qQ38Ib+OreicJu5xuMz3peGHBP0Jx9VhsEV4XjBwY76m33107 oGJAeEOXddr5DVQZB+g4LzCv7Fm7nh7jlCxkR7va74M4H3FKdnby7fQ0zKRyKHY4PSiB OTvS4Pdc+NFFBgEU2N8AAVABcFNNMh03VSmlTiDvlU2554WMUg5q4f19pa6JynDMmezL qpbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=A4lotYHk; dkim=pass header.i=@codeaurora.org header.s=default header.b=A4lotYHk; 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 v1-v6si1662662plp.680.2018.03.09.15.29.06; Fri, 09 Mar 2018 15:29:21 -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=A4lotYHk; dkim=pass header.i=@codeaurora.org header.s=default header.b=A4lotYHk; 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 S1751822AbeCIX1u (ORCPT + 99 others); Fri, 9 Mar 2018 18:27:50 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:53746 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932764AbeCIXZ4 (ORCPT ); Fri, 9 Mar 2018 18:25:56 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E187B60A5F; Fri, 9 Mar 2018 23:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520637955; bh=fazVnUwl4HkIiuE0FvewI8jphSrIJZAK5R/VlKxDzSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4lotYHkHknNLE3PagFPpn6FX5TBy1YfEtboSGO88YfHCmoUSiOJSRPrCbq3S3NRv kam8y8XHdbm26KujuL7UDlnnOVPVn1m3E3kTuBIL4YUqPe+z2fZyLorEd93cXASjEf G2zsni2oKfY8qBkTKkb2N22H+5EC3zW63KTUab98= 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 ACDFC60854; Fri, 9 Mar 2018 23:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520637955; bh=fazVnUwl4HkIiuE0FvewI8jphSrIJZAK5R/VlKxDzSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4lotYHkHknNLE3PagFPpn6FX5TBy1YfEtboSGO88YfHCmoUSiOJSRPrCbq3S3NRv kam8y8XHdbm26KujuL7UDlnnOVPVn1m3E3kTuBIL4YUqPe+z2fZyLorEd93cXASjEf G2zsni2oKfY8qBkTKkb2N22H+5EC3zW63KTUab98= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org ACDFC60854 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 Cc: linux-soc@vger.kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, Lina Iyer Subject: [PATCH v4 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Date: Fri, 9 Mar 2018 16:25:39 -0700 Message-Id: <20180309232543.24636-7-ilina@codeaurora.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180309232543.24636-1-ilina@codeaurora.org> References: <20180309232543.24636-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