Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10571091rwd; Thu, 22 Jun 2023 01:35:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SsvweXr+zfs+ARJ850O+Fx1pOSp+79evyVzFSSeGOEioMadEx6QHZZx/+cuM0NgMipMn0 X-Received: by 2002:a17:902:da91:b0:1ae:6cf0:94eb with SMTP id j17-20020a170902da9100b001ae6cf094ebmr18162641plx.5.1687422959188; Thu, 22 Jun 2023 01:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687422959; cv=none; d=google.com; s=arc-20160816; b=rWc/NoKLjr5rPMYI+/FOI3Weuovpk05/WZ0CFS8cuiOmp6bb5Z2XYB7p7pNoY6W0ZA lEz4xkaM0Jm3ioiEzV8Chm0++2KHF1m1WlzV+cyVctfE5fgqyFzmZQKnRu2celySLo5a kDT84vw7eLpN9pgcG+RJESGAGlgeIA7D2kR2fPR1660Q/ghbXIsLDUFZnR0fhu9iu/oQ gSp/acV46JzzT4kpG0QkdyGCWaQk7t/WTz5CE2Xa4DOOBM9ECIWim55doXAThK85jn+H S0AHPP1jGqltVbOAJ9xn+xi+/o3gpJkhoQ2AOoEm2XcK+VjtGZpPSOskLTq9ar29/JWQ RErw== 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=pV10EWjfUTLqAb2bE4FTQh/hx8OHC+QKPxeY4Fml9fw=; b=GfFygNIpEFxpdHZdd9lvMkA5FdyT8hgNvh88K0f+jj+k2kVpSs+KtZwc/O0EVuiWuD WiiVoMhkbkgAQNQWbdXTwfyOeS6VJh7k4N3Xj3ajNcJ9MzOV7lqw7ydWNKS04rVbwUmY QF5tYzY0Wlct73Yemu5U2m+0jtdvjoab/MjkGTvvyb5hOHH+NBtx838JHIIZIaA80tvN 4LGoptaf0l/DRc2BOLdxdYi7z20CSuUpLSOLoJLqd+6gVBait+kqsibpQByeWHPFViiy Ny5ffcsEwXHlontYziJXUsCcLGHyTELDoMnsH/XRRpJuKFyjtY2qeSXP0OG9tj+ZUjWc 5GDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MAbC5Crn; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a17090301cb00b001b672af6244si6919313plh.266.2023.06.22.01.35.47; Thu, 22 Jun 2023 01:35:59 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=MAbC5Crn; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbjFVIZ0 (ORCPT + 99 others); Thu, 22 Jun 2023 04:25:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbjFVIZZ (ORCPT ); Thu, 22 Jun 2023 04:25:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40CCA1BD0; Thu, 22 Jun 2023 01:25:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA9A661783; Thu, 22 Jun 2023 08:25:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA8BC433C9; Thu, 22 Jun 2023 08:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687422323; bh=kT1iIRFCb/FngiibBFp/oj+CcwR6QPaSbU5bJ8Db0PI=; h=From:To:Cc:Subject:Date:From; b=MAbC5CrnuU+abGtqx92u/WmSNcxhtdTj+Ss7+80MMiTRQOQaRj3H5ELz7Thn0kxGZ 07bi/WjYBczBDXSk0pVrH8olmqVSWc8SJVNzc71C8axWUek65iVkMNpZNndKVFaj/M 4xyydAcNokrUc+j0wMLXZ0qVTQe+lO0Ktm7y/gTr52xwCWuT+9NP37LYA35kekHa33 n/ko1TdlNEUCCuWpWb5qJbFaRD1WJPiNbsgqhGmEfIBdf+qw6BF37tqXpShR90KwzM DMeIZF48Yfm5BCfAHegfLSjUrap/Uw/UpYru+8YsXLfpcEX3cHTckYb6AEjqZzgOAm oKyqc03Q7QSpg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1qCFdA-00023c-Gw; Thu, 22 Jun 2023 10:25:28 +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] spi: zynqmp-gqspi: fix clock imbalance on probe failure Date: Thu, 22 Jun 2023 10:24:35 +0200 Message-Id: <20230622082435.7873-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 --- 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 fb2ca9b90eab..c309dedfd602 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -1342,9 +1342,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); @@ -1368,11 +1368,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.39.3