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: 38787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5032044wrt; Wed, 4 Jan 2023 00:32:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXu/KfRDWGw5tMQNWvEgQ3pbWMeoBeiV6wSzNkyNTAxmCE0CZZhsSktHHA57+pT0Sm/TrmXJ X-Received: by 2002:a17:90a:4581:b0:213:8550:2dd5 with SMTP id v1-20020a17090a458100b0021385502dd5mr65126932pjg.43.1672821164203; Wed, 04 Jan 2023 00:32:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672821164; cv=none; d=google.com; s=arc-20160816; b=oeorTRn4OGBtPTwGS4YoAatZdut5UBfVvxg7U0yWFSEI98YMmRNST8ktrrfqMfTjVw mSc7UJUyT5fkf9+zFq38FXgm/FL2J8pP6WVYR4ERAMnuQ9DivhclfcYErR1BB+3YZRku KPEaR5aLfPsa9nD55Pyn9bbyYTbvZJxckOv1ptOuntp0XnkCg+nxVpd9ThkkFDN93PUy c0CTP5FSqxYgj37BH0SAYgMbjgh8MLPWI4NfBnBoNWqo7yurBIVyWkOTa48z9v+xqW5M P4nEW+a1ZIHPJmjMSc8ajQaAdRPAxqt2MRzQm82yQ7a4kWsx10M5the0qpwnaeS8KLd6 B2OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4+dLuHlcC9jnNQMQw94DnzReVIGUmjOcxr5KvYMev8U=; b=HsUtv+SzX8XcHsC9GmL+vyA8AtGoTiWUGqKvr2tnujUMhBpyXiwRbtq62NRI35Cr2H uml/t0Blp9CzKkPSirjDcTI/HtDrcQIgo9yD/AbJmaatMZvfpwkVNJwot/oy2wJ3i8lv EjS6BQf8lu+tqQx7kSRh+byaEquHPExcFMKWLsvsQiv+mzkpUrd1GJTMRdvCkg2nXUnO KHHsnfluQT5PI28VqQQDFLJirxpBg5zArmhy0EDvRUhl1iRzUqTrgiaKcKE+aaQ7x3Gn imFEzgMeNqTHFGx5e8xbznR+SYEKU0hqxX7Qda5qg2qhgPvGRMqFlMBjCgC/UTB+5V3S b+bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y6p8ZQAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n64-20020a632743000000b004773bf41b74si37380372pgn.30.2023.01.04.00.32.32; Wed, 04 Jan 2023 00:32:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y6p8ZQAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbjADIbp (ORCPT + 99 others); Wed, 4 Jan 2023 03:31:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234011AbjADIb2 (ORCPT ); Wed, 4 Jan 2023 03:31:28 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EFE186AA for ; Wed, 4 Jan 2023 00:31:26 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id g16so25541405plq.12 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=UlJ4aIqtSwaH1V8NqkThLALIwl0b1wQweIpKgSe6z8t2D3/5m2QSYf5MYqpRBJbS+W AYgyPviBVpcLOozI84v+SpEUdLST3e2JJRWrUdM2I8DoFtuOTtTU8Zf4K9uWmeY4fuws Gw5yuU5z2WLcUBcr43zmX6bmKn6GFdZ5zCBjI1vYnhR/mXqpqWcAPT4nM2lxMnFooJrW SPXoUe8oqfguTppL7MhSzF0omQziZATx6H18enfJXAENRmpLOUj158/nGo3AipTqZFdN hv+sTzp9R/q5MmxVo3Qrn1FYpSgvngnS8V+ClO7rNaxfeUUbVXU6yhnGpW0vzeTLr8pz nPmg== X-Gm-Message-State: AFqh2kpRCGYgpmetwB1iYSTsWLtFYfs3YajtatPnuZSdWtOM3Z2+W5by Q9VDSAeDIF0hDwLdVK1+gmqZSw== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754080124932173694?= X-GMAIL-MSGID: =?utf-8?q?1754080124932173694?= 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; }