From patchwork Mon Jul 22 21:53:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 11053553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA7C1912 for ; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A947F22362 for ; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AE4B26E40; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 141C922362 for ; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731580AbfGVVxy (ORCPT ); Mon, 22 Jul 2019 17:53:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36528 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730704AbfGVVxy (ORCPT ); Mon, 22 Jul 2019 17:53:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8AA8C616B9; Mon, 22 Jul 2019 21:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832433; bh=be9/QsL0swCk3x3llqIibWSVJSbE8k9VDv03K/wu/Fc=; h=From:To:Cc:Subject:Date:From; b=NTlEin5mIThygbNaJX/yGWRbwSku1nLraSYm8sQmFu3Kb7rWrO+Q3FuSPI59T18QY UQTl/WTjhZAeFFwtH5am8sHqJ49BuYeZy65ZbPZU1nMunwVNymTu+Sg7aPzVrVVw42 ut8Of7huOXAwof3USLZy59CQ2zarSmFf1tJrGIc0= 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 3112B604BE; Mon, 22 Jul 2019 21:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832433; bh=be9/QsL0swCk3x3llqIibWSVJSbE8k9VDv03K/wu/Fc=; h=From:To:Cc:Subject:Date:From; b=NTlEin5mIThygbNaJX/yGWRbwSku1nLraSYm8sQmFu3Kb7rWrO+Q3FuSPI59T18QY UQTl/WTjhZAeFFwtH5am8sHqJ49BuYeZy65ZbPZU1nMunwVNymTu+Sg7aPzVrVVw42 ut8Of7huOXAwof3USLZy59CQ2zarSmFf1tJrGIc0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3112B604BE 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: agross@kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, mkshah@codeaurora.org, "Raju P.L.S.S.S.N" , Lina Iyer Subject: [PATCH V2 1/4] drivers: qcom: rpmh-rsc: simplify TCS locking Date: Mon, 22 Jul 2019 15:53:37 -0600 Message-Id: <20190722215340.3071-1-ilina@codeaurora.org> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Raju P.L.S.S.S.N" The tcs->lock was introduced to serialize access with in TCS group. But, drv->lock is still needed to synchronize core aspects of the communication. This puts the drv->lock in the critical and high latency path of sending a request. drv->lock provides the all necessary synchronization. So remove locking around TCS group and simply use the drv->lock instead. Signed-off-by: Raju P.L.S.S.S.N [ilina: split patch into multiple files, update commit text] Signed-off-by: Lina Iyer --- Changes in v2: - Split the patches into multiple - Optimzation to remove reundant TCS access - Split the rpmh library changes into its own patch - Remove locks in IRQ handler - Update commit text - Remove fixes in commit text --- drivers/soc/qcom/rpmh-internal.h | 2 -- drivers/soc/qcom/rpmh-rsc.c | 32 ++++++++++++-------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index a7bbbb67991c..969d5030860e 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -28,7 +28,6 @@ struct rsc_drv; * @offset: start of the TCS group relative to the TCSes in the RSC * @num_tcs: number of TCSes in this type * @ncpt: number of commands in each TCS - * @lock: lock for synchronizing this TCS writes * @req: requests that are sent from the TCS * @cmd_cache: flattened cache of cmds in sleep/wake TCS * @slots: indicates which of @cmd_addr are occupied @@ -40,7 +39,6 @@ struct tcs_group { u32 offset; int num_tcs; int ncpt; - spinlock_t lock; const struct tcs_request *req[MAX_TCS_PER_TYPE]; u32 *cmd_cache; DECLARE_BITMAP(slots, MAX_TCS_SLOTS); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index e278fc11fe5c..5ede8d6de3ad 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -106,26 +106,26 @@ static int tcs_invalidate(struct rsc_drv *drv, int type) { int m; struct tcs_group *tcs; + int ret = 0; tcs = get_tcs_of_type(drv, type); - spin_lock(&tcs->lock); - if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) { - spin_unlock(&tcs->lock); - return 0; - } + spin_lock(&drv->lock); + if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) + goto done_invalidate; for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { if (!tcs_is_free(drv, m)) { - spin_unlock(&tcs->lock); - return -EAGAIN; + ret = -EAGAIN; + goto done_invalidate; } write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0); write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0); } bitmap_zero(tcs->slots, MAX_TCS_SLOTS); - spin_unlock(&tcs->lock); +done_invalidate: + spin_unlock(&drv->lock); return 0; } @@ -349,41 +349,35 @@ static int tcs_write(struct rsc_drv *drv, const struct tcs_request *msg) { struct tcs_group *tcs; int tcs_id; - unsigned long flags; int ret; tcs = get_tcs_for_msg(drv, msg); if (IS_ERR(tcs)) return PTR_ERR(tcs); - spin_lock_irqsave(&tcs->lock, flags); spin_lock(&drv->lock); /* * The h/w does not like if we send a request to the same address, * when one is already in-flight or being processed. */ ret = check_for_req_inflight(drv, tcs, msg); - if (ret) { - spin_unlock(&drv->lock); + if (ret) goto done_write; - } tcs_id = find_free_tcs(tcs); if (tcs_id < 0) { ret = tcs_id; - spin_unlock(&drv->lock); goto done_write; } tcs->req[tcs_id - tcs->offset] = msg; set_bit(tcs_id, drv->tcs_in_use); - spin_unlock(&drv->lock); __tcs_buffer_write(drv, tcs_id, 0, msg); __tcs_trigger(drv, tcs_id); done_write: - spin_unlock_irqrestore(&tcs->lock, flags); + spin_unlock(&drv->lock); return ret; } @@ -481,19 +475,18 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const struct tcs_request *msg) { struct tcs_group *tcs; int tcs_id = 0, cmd_id = 0; - unsigned long flags; int ret; tcs = get_tcs_for_msg(drv, msg); if (IS_ERR(tcs)) return PTR_ERR(tcs); - spin_lock_irqsave(&tcs->lock, flags); + spin_lock(&drv->lock); /* find the TCS id and the command in the TCS to write to */ ret = find_slots(tcs, msg, &tcs_id, &cmd_id); if (!ret) __tcs_buffer_write(drv, tcs_id, cmd_id, msg); - spin_unlock_irqrestore(&tcs->lock, flags); + spin_unlock(&drv->lock); return ret; } @@ -584,7 +577,6 @@ static int rpmh_probe_tcs_config(struct platform_device *pdev, tcs->type = tcs_cfg[i].type; tcs->num_tcs = tcs_cfg[i].n; tcs->ncpt = ncpt; - spin_lock_init(&tcs->lock); if (!tcs->num_tcs || tcs->type == CONTROL_TCS) continue; From patchwork Mon Jul 22 21:53:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 11053559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F234912 for ; Mon, 22 Jul 2019 21:54:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 500DF22362 for ; Mon, 22 Jul 2019 21:54:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43B7E26E40; Mon, 22 Jul 2019 21:54:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC60922362 for ; Mon, 22 Jul 2019 21:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732971AbfGVVx4 (ORCPT ); Mon, 22 Jul 2019 17:53:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36626 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732959AbfGVVxz (ORCPT ); Mon, 22 Jul 2019 17:53:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B735561785; Mon, 22 Jul 2019 21:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832434; bh=RlWL48UI3PgO6diXYD1un69eisGSJ5AGaNNzhzZW95k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gYjXWSiOZnE5/llNK5rwCFyUSOKNROo4GVMKSCUU9apa2IYoWJOPXiUuEs2lXTkKf mIteqbWYc1Zleo5AgcfOmRCqxJK7ZODSLn6wwFeeh2NsMLh9eKJObncLSEmm+AtADL nplkvMDSHyX4nKwRr3ur54Dvr7v5ZGUXiHlR3m84= 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 49E7060FEB; Mon, 22 Jul 2019 21:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832434; bh=RlWL48UI3PgO6diXYD1un69eisGSJ5AGaNNzhzZW95k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gYjXWSiOZnE5/llNK5rwCFyUSOKNROo4GVMKSCUU9apa2IYoWJOPXiUuEs2lXTkKf mIteqbWYc1Zleo5AgcfOmRCqxJK7ZODSLn6wwFeeh2NsMLh9eKJObncLSEmm+AtADL nplkvMDSHyX4nKwRr3ur54Dvr7v5ZGUXiHlR3m84= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 49E7060FEB 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: agross@kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, mkshah@codeaurora.org, Lina Iyer Subject: [PATCH V2 2/4] drivers: qcom: rpmh-rsc: avoid locking in the interrupt handler Date: Mon, 22 Jul 2019 15:53:38 -0600 Message-Id: <20190722215340.3071-2-ilina@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190722215340.3071-1-ilina@codeaurora.org> References: <20190722215340.3071-1-ilina@codeaurora.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid locking in the interrupt context to improve latency. Since we don't lock in the interrupt context, it is possible that we now could race with the DRV_CONTROL register that writes the enable register and cleared by the interrupt handler. For fire-n-forget requests, the interrupt may be raised as soon as the TCS is triggered and the IRQ handler may clear the enable bit before the DRV_CONTROL is read back. Use the non-sync variant when enabling the TCS register to avoid reading back a value that may been cleared because the interrupt handler ran immediately after triggering the TCS. Signed-off-by: Lina Iyer --- drivers/soc/qcom/rpmh-rsc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 5ede8d6de3ad..694ba881624e 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -242,9 +242,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p) write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0); write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0); write_tcs_reg(drv, RSC_DRV_IRQ_CLEAR, 0, BIT(i)); - spin_lock(&drv->lock); clear_bit(i, drv->tcs_in_use); - spin_unlock(&drv->lock); if (req) rpmh_tx_done(req, err); } @@ -304,7 +302,7 @@ static void __tcs_trigger(struct rsc_drv *drv, int tcs_id) enable = TCS_AMC_MODE_ENABLE; write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); enable |= TCS_AMC_MODE_TRIGGER; - write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); + write_tcs_reg(drv, RSC_DRV_CONTROL, tcs_id, enable); } static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, From patchwork Mon Jul 22 21:53:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 11053565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E532B6C5 for ; Mon, 22 Jul 2019 21:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D798B22362 for ; Mon, 22 Jul 2019 21:54:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB8223E64; Mon, 22 Jul 2019 21:54:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6594028508 for ; Mon, 22 Jul 2019 21:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731621AbfGVVyG (ORCPT ); Mon, 22 Jul 2019 17:54:06 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36700 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730704AbfGVVx4 (ORCPT ); Mon, 22 Jul 2019 17:53:56 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B57696178B; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832435; bh=68C2u8fpsqFhT6IQyKhGhREqY4z0D2JwTGvXninivrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBMZhOKFMKlHm8XM2/zAkcHXBeuOu4OLdVAF6gZ/o6JZQONZUeoOGqRMOxfQv7F7j OkJWx6/JyDORDJqHq+MhOzk5/KZ7BwlIDsECVdU/5yjyLUpZaPyBeRNdbVxwf9ICuy OMipWyLgsP/A+eRsIOdbN3fAtZ1NznE7pNJ37MXM= 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 4EB4F615E6; Mon, 22 Jul 2019 21:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832435; bh=68C2u8fpsqFhT6IQyKhGhREqY4z0D2JwTGvXninivrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBMZhOKFMKlHm8XM2/zAkcHXBeuOu4OLdVAF6gZ/o6JZQONZUeoOGqRMOxfQv7F7j OkJWx6/JyDORDJqHq+MhOzk5/KZ7BwlIDsECVdU/5yjyLUpZaPyBeRNdbVxwf9ICuy OMipWyLgsP/A+eRsIOdbN3fAtZ1NznE7pNJ37MXM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4EB4F615E6 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: agross@kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, mkshah@codeaurora.org, "Raju P.L.S.S.S.N" , Lina Iyer Subject: [PATCH V2 3/4] drivers: qcom: rpmh: switch over from spinlock irq variants Date: Mon, 22 Jul 2019 15:53:39 -0600 Message-Id: <20190722215340.3071-3-ilina@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190722215340.3071-1-ilina@codeaurora.org> References: <20190722215340.3071-1-ilina@codeaurora.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Raju P.L.S.S.S.N" Switch over from using _irqsave/_irqrestore variants since we no longer race with a lock from the interrupt handler. While we are at it, rename the cache_lock to just lock to allow use of the lock to synchronize controller access. Signed-off-by: Raju P.L.S.S.S.N Signed-off-by: Lina Iyer --- drivers/soc/qcom/rpmh-internal.h | 4 ++-- drivers/soc/qcom/rpmh-rsc.c | 2 +- drivers/soc/qcom/rpmh.c | 21 ++++++++------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 969d5030860e..93d59db435bb 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -67,13 +67,13 @@ struct rpmh_request { * struct rpmh_ctrlr: our representation of the controller * * @cache: the list of cached requests - * @cache_lock: synchronize access to the cache data + * @lock: synchronize access to the controller data * @dirty: was the cache updated since flush * @batch_cache: Cache sleep and wake requests sent as batch */ struct rpmh_ctrlr { struct list_head cache; - spinlock_t cache_lock; + spinlock_t lock; bool dirty; struct list_head batch_cache; }; diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 694ba881624e..add5e84751c9 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -656,7 +656,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev) /* Enable the active TCS to send requests immediately */ write_tcs_reg(drv, RSC_DRV_IRQ_ENABLE, 0, drv->tcs[ACTIVE_TCS].mask); - spin_lock_init(&drv->client.cache_lock); + spin_lock_init(&drv->client.lock); INIT_LIST_HEAD(&drv->client.cache); INIT_LIST_HEAD(&drv->client.batch_cache); diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 035091fd44b8..d6fb254a4b57 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -118,9 +118,8 @@ static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr, struct tcs_cmd *cmd) { struct cache_req *req; - unsigned long flags; - spin_lock_irqsave(&ctrlr->cache_lock, flags); + spin_lock(&ctrlr->lock); req = __find_req(ctrlr, cmd->addr); if (req) goto existing; @@ -154,7 +153,7 @@ static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr, ctrlr->dirty = true; unlock: - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + spin_unlock(&ctrlr->lock); return req; } @@ -283,23 +282,20 @@ EXPORT_SYMBOL(rpmh_write); static void cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) { - unsigned long flags; - - spin_lock_irqsave(&ctrlr->cache_lock, flags); + spin_lock(&ctrlr->lock); list_add_tail(&req->list, &ctrlr->batch_cache); - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + spin_unlock(&ctrlr->lock); } static int flush_batch(struct rpmh_ctrlr *ctrlr) { struct batch_cache_req *req; const struct rpmh_request *rpm_msg; - unsigned long flags; int ret = 0; int i; /* Send Sleep/Wake requests to the controller, expect no response */ - spin_lock_irqsave(&ctrlr->cache_lock, flags); + spin_lock(&ctrlr->lock); list_for_each_entry(req, &ctrlr->batch_cache, list) { for (i = 0; i < req->count; i++) { rpm_msg = req->rpm_msgs + i; @@ -309,7 +305,7 @@ static int flush_batch(struct rpmh_ctrlr *ctrlr) break; } } - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + spin_unlock(&ctrlr->lock); return ret; } @@ -317,13 +313,12 @@ static int flush_batch(struct rpmh_ctrlr *ctrlr) static void invalidate_batch(struct rpmh_ctrlr *ctrlr) { struct batch_cache_req *req, *tmp; - unsigned long flags; - spin_lock_irqsave(&ctrlr->cache_lock, flags); + spin_lock(&ctrlr->lock); list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) kfree(req); INIT_LIST_HEAD(&ctrlr->batch_cache); - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + spin_unlock(&ctrlr->lock); } /** From patchwork Mon Jul 22 21:53:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 11053555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E75F912 for ; Mon, 22 Jul 2019 21:54:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BCE722362 for ; Mon, 22 Jul 2019 21:54:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DB4B28508; Mon, 22 Jul 2019 21:54:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B06B922362 for ; Mon, 22 Jul 2019 21:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732982AbfGVVx6 (ORCPT ); Mon, 22 Jul 2019 17:53:58 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36820 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732976AbfGVVx5 (ORCPT ); Mon, 22 Jul 2019 17:53:57 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1095161797; Mon, 22 Jul 2019 21:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832437; bh=WpCgEOoGvhbJ0VBx0zgHnAYDeYg4fRD+EEEeXF83K7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kigNPpsLEDWvA2sOZdchiIzG5y+kYbkgspozzhWGmMnXP2bzip3Rse+vP+DO4TD/b 0T1b1GWC5hhksYodKN8KHA7kTv1KyJ0ilr9TgmuVl81Zo0ShHqT1kpbwUcUw5U4uea YNZGY/YaysLIbLKu+x8PhXOVbWoqNBrtYmn27p0c= 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 641E861779; Mon, 22 Jul 2019 21:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563832436; bh=WpCgEOoGvhbJ0VBx0zgHnAYDeYg4fRD+EEEeXF83K7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=StB3Yl4TvVkl2cyDH2O50knw+oTV/Xm/C4wMqyWFR24GVSuJFQQ0bfUH91o/v1xBN gMRQ1wIppWk7O9qozF/dXTec0c9c2Eh1wWfWwF1Qr2Uayj+SYTvlhuVNH2UGTnbA28 YS1hChsyqMaDnU7SQfuFl2gki915JFFK/VnI54LY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 641E861779 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: agross@kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, mkshah@codeaurora.org, Lina Iyer Subject: [PATCH V2 4/4] drivers: qcom: rpmh-rsc: remove redundant register access Date: Mon, 22 Jul 2019 15:53:40 -0600 Message-Id: <20190722215340.3071-4-ilina@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190722215340.3071-1-ilina@codeaurora.org> References: <20190722215340.3071-1-ilina@codeaurora.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since drv->tcs_in_use is updated when the DRV_STATUS is updated, we could simply use the former to determine if the TCS is idle or not. Therefore, remove redundant TCS register read. Signed-off-by: Lina Iyer --- drivers/soc/qcom/rpmh-rsc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index add5e84751c9..b04cd2d2910c 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -93,8 +93,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id, static bool tcs_is_free(struct rsc_drv *drv, int tcs_id) { - return !test_bit(tcs_id, drv->tcs_in_use) && - read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id, 0); + return !test_bit(tcs_id, drv->tcs_in_use); } static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type)