Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3674424pxv; Mon, 26 Jul 2021 09:09:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEqIa3yIHsHgqYNtdIv86+QVqMbd4vNyiCjzHP3lnu7417KLJr8Z6FHrBqzeO7q7p2CVrO X-Received: by 2002:a17:906:56ca:: with SMTP id an10mr12843274ejc.90.1627315794503; Mon, 26 Jul 2021 09:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315794; cv=none; d=google.com; s=arc-20160816; b=cENx0LfRbXgYIzeGkDhK8djMMjYPEhGnVVIgd8KtknNn44SCJGHxvMSdVEYirB9X8X BCdqkM0w4hwmpuPXLZ//cNZgrWFKiDfIER9dHTvhRRb86OUkF/IyTgIY1tPBHPKU0r5v 3jaBdfJ6ZmYXNfBtDCWrlOMY/TX9iMhMrCiH5Wx+eX5zEq91u4j6zT+Nuzj3T2c6RtsW 3rSseX746V8j/B1uRK6r0otyq8S+3OzxA4Dg1nlRgT1rRZJd6WQWW/FJqCzUAAmXVYfw FMW6fT2vziuOktNSiz8rCPBd71SrkREv/k7bYVrDpoycgSvURjfjjJyYO0a/SAddkUjz Pv5w== 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=ezdtjlxONKMCmJohtjEWQksrKbD/wKkLJ2QmEgPbytc=; b=fezZ2mkIN+uzXC1w15RkWDsFWJvnzV755zqWZe7aBuLLZH2/cYuvwO7zKAR2xzD6/E +V+OYiltveG9Zxg4RhjbFQJ7uszl128+7sRai0jYLuAkW4HQaX2bfBfPdFHuS8SfGuAZ hJZYaEM8ATdWkPKe8o9QeLPm3Jpnur52sOjKI/stf8uUNhXgqcQEHqH+B02ifrqekhhG 3TQ6qvbhbf5kIvgq+GtTTVRzpaI5qa06AbI7R8QZWqFBBZjBoQIpEX7eKq8ETydAB61H ALF7T6x6phS+6Bvp2zYKHMsap1aptqsfFklwuZ9oOvv+dJ559mHH0sD0e/vKZDK8y0Og AWGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ylU2QcbM; 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 b13si312696ede.583.2021.07.26.09.09.30; Mon, 26 Jul 2021 09:09:54 -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=ylU2QcbM; 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 S238189AbhGZPZI (ORCPT + 99 others); Mon, 26 Jul 2021 11:25:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:55788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237661AbhGZPQQ (ORCPT ); Mon, 26 Jul 2021 11:16:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C5CD60F02; Mon, 26 Jul 2021 15:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315005; bh=uOywpBAuVfjRfxNZcXgH+CoNeQ185n7HwhNdfBCsRyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ylU2QcbM+owdGdKkSm5/uxrDNVDI/Gfs28SKMIiRPMU1fKt89u4fnoFDfLwKa3T8e nZYgU+uWeqlwjwsO6I1zr9u5/zZr4uZ9gyRsgW/u7BN7sTtyqwDcG/BwG3nGRohnXv BPPUV7dIUK1iaY6XU/DAxTe0d3oR8hlRcpqDv/Qo= 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.4 050/108] spi: cadence: Correct initialisation of runtime PM again Date: Mon, 26 Jul 2021 17:38:51 +0200 Message-Id: <20210726153833.287505952@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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 1d0c335b0bf8..5ac60d06c674 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