Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7790460ybi; Mon, 22 Jul 2019 20:52:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwQhS5L4rQLiUAcq5XjdXhRf/NkhmTzFZCcf5bSM7XzCRfFf3ZqIIJN+NlaGmBJqbj3AOA X-Received: by 2002:a62:63c7:: with SMTP id x190mr3442219pfb.181.1563853927302; Mon, 22 Jul 2019 20:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563853927; cv=none; d=google.com; s=arc-20160816; b=00fhVsLDMLIfsxaVYFI/RBd2QFrYjAdj1MRU1JcVBp/jO/9mZRXtIDZInSJEiGm4Mw UVg9wPfNUjN0XD5p3+haTMKMg1hfIWieMwIXxpMY3urRkNxn6VKs1GMkqP4mBSqqYlrp hL3dZmvLEnXJFw6hMWREj5whqjmlVYHLwFIXCBs7cKpjnAxb+p6Cb3LKgcaJ1G0Cs4xW 9xNHai5cAPUQwQikMTDibMakmkOP0lPvaXq7Ld4kI0TOLBKDU2W50bpHnHjjlBuhrdUI pxtvq3anTj+klKAyhwz77TGs37mtdZJptcOoGwOUJjN9Xum5FhiIPPpcqeYYwQY4A/JH qvag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature; bh=DAKOMz3y4jNisD5dAzbGeky4zcRB3dAilnZBygQGezw=; b=zkDW7h2wTqPAcwQV8zE4DIZdcaoeaJaGR+JIBdIgBA3f+ZHEDu55ez+96igrtaOb2u r7qzT/1ACkFOSmvQ39+LIBnU/ZoaIyB9TBtwLYvLMRjfMeBuZvX/qRK2HaXfX3wDJgAw sqaN+ZnDuoeeF7PiALKOqhX+xmtOM8Fv/cL6w55ree3Ahh6+11uz+t1/ZoMuEE6qL6Pc MULfIfisYGRGZ7DjF+dinovCc9HoN/MZ21jJ3TB5odPxmvCNLt9Ppeg5dVOYxeoEIiQX zPERfu0MY420vW4GXsOOQHnKhTk97QY+5UMm2OeKYmjaD66mCCH/DeuK/11pS+QwFUPb m5pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBMZhOKF; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBMZhOKF; 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 g11si12987084plo.433.2019.07.22.20.51.50; Mon, 22 Jul 2019 20:52:07 -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=YBMZhOKF; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBMZhOKF; 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 S1731701AbfGVVyG (ORCPT + 99 others); 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= 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.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE 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 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } /** -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project