Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp502622rdb; Tue, 19 Sep 2023 01:43:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEydagPIXShE0Qk1elKbp0UVi4dbtRmt2FqDA29Ry18eBK7njoWTWXy+0I1prBwPGC9ZrOg X-Received: by 2002:a17:903:244a:b0:1c5:6f43:9502 with SMTP id l10-20020a170903244a00b001c56f439502mr2755047pls.14.1695113026173; Tue, 19 Sep 2023 01:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695113026; cv=none; d=google.com; s=arc-20160816; b=M30eRSpWvNtVX9Hk0LAKdNQGVUgjymcshN+2Ap1doRzrICA4ZaoERs2GCDfRk8yHZt ItDC2SM4wY5n6nINt2idkZSq+nkr1D7gzq9PTusQvFQTtm/hvEY0oNO5VlWFLn/xzHdN CLD9MehbS2yEO3Q7KZk17pDq/tRRJKZnpCYeWbscHJ5VvSDRJR635zFxkqeA4CpG/vnk BRmyApm0fL5RSNY61g9OP2k93cCWmXzi/8gr2MBJ/UllMCHyj3jjk4lLKRh4+EV7DdH3 Y9drV8P161b9XrzEiKT2z4I8gTFKpCh/8ra7+qJgpSrDw3fbNBCpHa5n2cgWXUx4qY38 re8w== 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=vLQ4KOtaryBKThnioRomc1jUGGeLm0uzBjJ4XDaBko4=; fh=82A0H/MrcEWYyQIf2roNVDf/yRc+QOM5AvwnlA85mko=; b=PzZkKFFcuZ9CW/7oMX3O2C9BKTtTJGaOO3oWORWlRbTngkaeq2yZTy5ItVr2lVYPZc qfXKycttgaf5Q4RghcS3hAjMt5ge/cw87C/tpjjRytRPyI/z9IUtoUtnRXES3tQFtX4o 6oXu42uptKH+TXiH+0wOC3MXm13UexXLMw/cSo05t/nen1IvT7GegwO8bCdADU5gQNoC mFJ+tRVvq6/jr38xMHvPi8OvRxEj/PCW+gC0ye/IXbCthO9D8GEgGZr91HeN92/Y7jXw hWOBGfRvSDmWUjOjmwkzKcECM2UGhW09db6Do6oOEoCDD0/T9SVlKDuS7q9aWoyZ6xec U2TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uqPF0RdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u13-20020a170902e80d00b001b84f9263e7si9694374plg.325.2023.09.19.01.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uqPF0RdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ADC4482C5169; Tue, 19 Sep 2023 01:34:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbjISIer (ORCPT + 99 others); Tue, 19 Sep 2023 04:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjISIee (ORCPT ); Tue, 19 Sep 2023 04:34:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AAA711A; Tue, 19 Sep 2023 01:34:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C7EEC433C8; Tue, 19 Sep 2023 08:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695112467; bh=Gd2j5BZkeceRCAPRB3Ed88hy2OH7X0D2yLIWo8KBQt4=; h=From:To:Cc:Subject:Date:From; b=uqPF0RdFSUuPHVS9uiiuFZK/NONs5bMVKha5RE3q0SLUU0w+qAvrDIqMjUqQmdzL8 ar/7hr5tE7F5RNzFvjqx6ZOR7L/5gylxJ0cfFf3Q6G80TxwfRUtxdK4l3EINQ46+Qx ykMh6tdZLaO+7192I177MDjhLtRLRVHG7TzZwV1G62tRsii/GzaeNhjPSfnobNIGGR nihUFbhJTPDE8cwus1Y+9hAXGbdBngDLPA96rsZCF/OfxyZvWe+8FK1MQUNVNRO0p9 nOxm2ywFG4b8rCaotz49XsGAs+b1EoeOHErYMvbFRAsxLqMJ5pw125LEnRdzIN69am a0hvgybCE0j5g== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qiWBs-0006tO-2x; Tue, 19 Sep 2023 10:34:40 +0200 From: Johan Hovold To: Mark Brown Cc: Michal Simek , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Naga Sureshkumar Relli , Shubhrajyoti Datta Subject: [PATCH RESEND] spi: zynqmp-gqspi: fix clock imbalance on probe failure Date: Tue, 19 Sep 2023 10:34:01 +0200 Message-ID: <20230919083401.26454-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 19 Sep 2023 01:34:53 -0700 (PDT) Make sure that the device is not runtime suspended before explicitly disabling the clocks on probe failure and on driver unbind to avoid a clock enable-count imbalance. Fixes: 9e3a000362ae ("spi: zynqmp: Add pm runtime support") Cc: stable@vger.kernel.org # 4.19 Cc: Naga Sureshkumar Relli Cc: Shubhrajyoti Datta Signed-off-by: Johan Hovold --- Hi Mark, This patch ended up sitting in your for-next and for-6.4 branches for a few releases but was never sent on to Linus as I reported here: https://lore.kernel.org/lkml/ZOy0l6sXyYib59ej@finisterre.sirena.org.uk/ Now it appears to have been dropped from linux-next so resending. Johan drivers/spi/spi-zynqmp-gqspi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 94d9a33d9af5..9a46b2478f4e 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -1340,9 +1340,9 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) return 0; clk_dis_all: - pm_runtime_put_sync(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); clk_disable_unprepare(xqspi->refclk); clk_dis_pclk: clk_disable_unprepare(xqspi->pclk); @@ -1366,11 +1366,15 @@ static void zynqmp_qspi_remove(struct platform_device *pdev) { struct zynqmp_qspi *xqspi = platform_get_drvdata(pdev); + pm_runtime_get_sync(&pdev->dev); + zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0); + + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); clk_disable_unprepare(xqspi->refclk); clk_disable_unprepare(xqspi->pclk); - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_disable(&pdev->dev); } MODULE_DEVICE_TABLE(of, zynqmp_qspi_of_match); -- 2.41.0