Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3694378pxv; Mon, 26 Jul 2021 09:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHHogkWGcpI48LIVum1Nxf0wDm5E4oHV5lNXH82NgpDIo3EKfY9Df4Vlo91tHxi+oN7wKz X-Received: by 2002:a02:2382:: with SMTP id u124mr16944480jau.138.1627317225831; Mon, 26 Jul 2021 09:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317225; cv=none; d=google.com; s=arc-20160816; b=kaSpQcoPooM9WrOBpSLPCVuHs363+F4x/U/e3tuuwDuc4u72qs4M7is/e5p78+zxrU 9blZ6+Hky2JB+/MBDbCx1FSnrP+6+sA9rJJzo2VqLjFiIRF9+c6lxYCEBzFXDVSqYmuS Q0dDZDj3z+MRvutLkpFtSZQnHBh5/oUTWP3dyy0dkh8PGZ+oD8egxO6xGvRhrYPBOf1u HGyUJRzxmkTWECTZKuqUTQPng7T7MmanygX9BLVDLTFBp2V0AoBMZ0MFf64KPD9ZMdxG lnLtFlN7B2KgQSkDJILIKj9cdFxpiMFxUESgeB09xCmVu0w4iIHW2ENvoS4u17M0adGh muug== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aGcJMVb1jHgEbC6YhSrJEZ7j3imfKpnBjJpuFgTHeng=; b=DzesmDBXLaQ+kmFP1LcrvoVVGzPnK+sJWWpMtYbxMWeV+eopJUMXjog5tMaZLXxpl4 X8ooyHgOebDB68Nr48lUXS6xgfXINjlEvxxEvju8uItE6eW3SgzVO5/SFWtDlEUvYGrA JlxEtl+kR2cCjJnI4zEqhFOs9/7Rrmt4Xa/J2RY1nuPy7f+qUkR9NHK7vbYBz5JGTh7J dZEx7yLoaCxRuQ4p3kZVFK1mbAa2ISCbtKDRAgp7PYEaXWsDxJZ5wzHiiCqyHgUsneSx wKTUP7ya0YT98S4CGtOULa/aZItQ4BVPG7uYqh50DiqTVoFlpPx87zTzWaHMjRTyibbx vQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IefYr4gO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si342804ion.22.2021.07.26.09.33.32; Mon, 26 Jul 2021 09:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IefYr4gO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239311AbhGZPvj (ORCPT + 99 others); Mon, 26 Jul 2021 11:51:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:46644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbhGZPas (ORCPT ); Mon, 26 Jul 2021 11:30:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9308160C40; Mon, 26 Jul 2021 16:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315876; bh=nu9HSbVDtzUnXxN8axmqDqNWOmNMTz0F8iLHUC/jB3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IefYr4gO2PIT7nEEekpAfqkiLE6resCPBuOfk6z+usNLa3hAprhbhlqohcLorHf5Q i9fYf7/5cF26D/i8fpU9cjuEvgvzWTHQjX1EGFLyslXOczZPSKZiAPXQUg7PIslyQR OUz3qOuLBEWkumrwAchEkD3s2xQQ9EmJpIn8oyas= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.13 100/223] spi: cadence: Correct initialisation of runtime PM again Date: Mon, 26 Jul 2021 17:38:12 +0200 Message-Id: <20210726153849.539793671@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Vasut [ Upstream commit 56912da7a68c8356df6a6740476237441b0b792a ] The original implementation of RPM handling in probe() was mostly correct, except it failed to call pm_runtime_get_*() to activate the hardware. The subsequent fix, 734882a8bf98 ("spi: cadence: Correct initialisation of runtime PM"), breaks the implementation further, to the point where the system using this hard IP on ZynqMP hangs on boot, because it accesses hardware which is gated off. Undo 734882a8bf98 ("spi: cadence: Correct initialisation of runtime PM") and instead add missing pm_runtime_get_noresume() and move the RPM disabling all the way to the end of probe(). That makes ZynqMP not hang on boot yet again. Fixes: 734882a8bf98 ("spi: cadence: Correct initialisation of runtime PM") Signed-off-by: Marek Vasut Cc: Charles Keepax Cc: Mark Brown Link: https://lore.kernel.org/r/20210716182133.218640-1-marex@denx.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-cadence.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index a3afd1b9ac56..ceb16e70d235 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -517,6 +517,12 @@ static int cdns_spi_probe(struct platform_device *pdev) goto clk_dis_apb; } + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs); if (ret < 0) master->num_chipselect = CDNS_SPI_DEFAULT_NUM_CS; @@ -531,11 +537,6 @@ static int cdns_spi_probe(struct platform_device *pdev) /* SPI controller initializations */ cdns_spi_init_hw(xspi); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); - irq = platform_get_irq(pdev, 0); if (irq <= 0) { ret = -ENXIO; @@ -566,6 +567,9 @@ static int cdns_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_MASK(8); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + ret = spi_register_master(master); if (ret) { dev_err(&pdev->dev, "spi_register_master failed\n"); -- 2.30.2