From patchwork Wed Jan 4 08:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13088280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CE7BC46467 for ; Wed, 4 Jan 2023 08:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=yZIie5cggpGU8wBOREewT1/5EliqYu60W/DnxaBC5Bk=; b=15vVP7wyGZMPfX vR2iuTnYWDdOzYrDfyNAdxQwjwMDJomz7EoRKpi6aq9aESiBzsKJsRooBdpW9jcivVZ0kJ1LBQdNv XM2LD9PB5IaLZVXOfezId+qpypWi3fWdEqH6FCbxGJcTK0V/4PEEzMOGgimkt3phlwolT2yx8soWF mIrp+1ZG31bXIH8UVDgTAHp9Bpc0w9EKnIFrQgBDV3Vbt357XXPyl3C+9hzAyobU6xCbRWExY2g5e DvmpRvbrFxzleNDlvBdsUelaDfeVOFNN9rMKU0yd3rOYP8Z/wjySqIzPFymj6NDNH6sXqUmrnIQT3 oxV6WFcbk4aZbBNKjQBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCzCB-007f5T-He; Wed, 04 Jan 2023 08:32:23 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCzBM-007eqw-98 for linux-arm-kernel@lists.infradead.org; Wed, 04 Jan 2023 08:31:34 +0000 Received: by mail-pl1-x62c.google.com with SMTP id 17so35260855pll.0 for ; Wed, 04 Jan 2023 00:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4+dLuHlcC9jnNQMQw94DnzReVIGUmjOcxr5KvYMev8U=; b=Y6p8ZQAFtVMjaWUXOOmJW3dVg7sTCZDpqgmsww1yv78ELTsTvUOzzh1vI4HKCoA/I/ YDKeO3dbrEB3Uxq4ikf+PWOZI49nPxuRhtLY//2wK2Jj4JLmZE8cxt4ADlPRaqFJRfJd LTxf/SNUMnvBAqj9hsojG7XuTAN2ANr3weauE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4+dLuHlcC9jnNQMQw94DnzReVIGUmjOcxr5KvYMev8U=; b=k2YH0cuUOAJ5vZya2SaAfS97RTSZ2j5WsV5a8f3fY64jrLnb7S74gb3c6CW5YgAVbZ 7nYkVCloYhJ1PrPB+uCxYBAVR0KTcbY2+J5Kqem3P626Flr0nXxyLDFJVK7FzobvgBJj g7VnZ2OXT/458BIKAtIznp1n+o6tD/smKWTj6ZC9OlqdQ2CVfUDzmck+Urwquc6i8Imv NHQTAKjMtdYHOawbRda/laRp3ZUdRgtwxNdnzbLDDPBS+LGJfr8qvLhKTVGE2rnuBtDx 4dDP6gEorVOvvtte4OatAG+iA4wQ0wFyWWi3DwT+RsUnN/JiwSvEftP87ZhWFI0zNixQ 73pQ== X-Gm-Message-State: AFqh2kqnckLb6z8QKpnOyiKd/VUZY51x5Mnw9r3m1bWclwEYOjaBum1K po3PY9w0cm54OU6ziwEanx3UIA== X-Google-Smtp-Source: AMrXdXujFnG7dDV9MJtsjkA59x1G95RzXq9CimM7pdZKe0Di/GVPavoCYPnyhRWzT/EOvKLsFiYF/g== X-Received: by 2002:a05:6a20:1e55:b0:a2:a636:70c2 with SMTP id cy21-20020a056a201e5500b000a2a63670c2mr66048817pzb.24.1672821085870; Wed, 04 Jan 2023 00:31:25 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:9ef5:c3c1:77a5:2cd]) by smtp.gmail.com with ESMTPSA id g16-20020a63fa50000000b0046b1dabf9a8sm19781604pgk.70.2023.01.04.00.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:31:25 -0800 (PST) From: Chen-Yu Tsai To: Bjorn Andersson , Mathieu Poirier , Matthias Brugger Cc: Chen-Yu Tsai , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Tinghan Shen , Tzung-Bi Shih , AngeloGioacchino Del Regno , Allen-KH Cheng Subject: [PATCH] remoteproc/mtk_scp: Move clk ops outside send_lock Date: Wed, 4 Jan 2023 16:31:10 +0800 Message-Id: <20230104083110.736377-1-wenst@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230104_003132_423934_D3BC6226 X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clocks are properly reference counted and do not need to be inside the lock range. Right now this triggers a false-positive lockdep warning on MT8192 based Chromebooks, through a combination of mtk-scp that has a cros-ec-rpmsg sub-device, the (actual) cros-ec I2C adapter registration, I2C client (not on cros-ec) probe doing i2c transfers and enabling clocks. This is a false positive because the cros-ec-rpmsg under mtk-scp does not have an I2C adapter, and also each I2C adapter and cros-ec instance have their own mutex. Move the clk operations outside of the send_lock range. Fixes: ("63c13d61eafe remoteproc/mediatek: add SCP support for mt8183") Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp_ipi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/mtk_scp_ipi.c b/drivers/remoteproc/mtk_scp_ipi.c index 00f041ebcde6..4c0d121c2f54 100644 --- a/drivers/remoteproc/mtk_scp_ipi.c +++ b/drivers/remoteproc/mtk_scp_ipi.c @@ -164,21 +164,21 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, WARN_ON(len > sizeof(send_obj->share_buf)) || WARN_ON(!buf)) return -EINVAL; - mutex_lock(&scp->send_lock); - ret = clk_prepare_enable(scp->clk); if (ret) { dev_err(scp->dev, "failed to enable clock\n"); - goto unlock_mutex; + return ret; } + mutex_lock(&scp->send_lock); + /* Wait until SCP receives the last command */ timeout = jiffies + msecs_to_jiffies(2000); do { if (time_after(jiffies, timeout)) { dev_err(scp->dev, "%s: IPI timeout!\n", __func__); ret = -ETIMEDOUT; - goto clock_disable; + goto unlock_mutex; } } while (readl(scp->reg_base + scp->data->host_to_scp_reg)); @@ -205,10 +205,9 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, ret = 0; } -clock_disable: - clk_disable_unprepare(scp->clk); unlock_mutex: mutex_unlock(&scp->send_lock); + clk_disable_unprepare(scp->clk); return ret; }