Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp609531ybl; Fri, 24 Jan 2020 06:23:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxTHI5SffihubQZjBcyaWtjeN/HOjflLBD0IrQdzHBuJF0w8VKrlJp6ZQIhIdIcR9JvpA6i X-Received: by 2002:a9d:70d9:: with SMTP id w25mr2967725otj.231.1579875793015; Fri, 24 Jan 2020 06:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579875793; cv=none; d=google.com; s=arc-20160816; b=DcR0AfrWewdWS/3jfqUdoK8fMI2ODfldmPJNZSwIFjVDbvTwdZbiKxEbAv+RZqDwaK YylQgKqE7dUujPH1pa1DxcaPS5RcMgk4/n12GuuOzJ5a4CAIsc9RGCXwfLpIweIcelYL jH7JLWB/bbiAMRPOaLYXB0zgEcAU6uMxQ1XVOgWKQoywtOVWCcVF8e1PKEg6KwNOGoLx hybnEdgztYgvD28C2rCvcOvOHkKYQk0Yp/xF2zHEYuAgUsX9aCCX64OGjzVpahpEVJ4q j5l6SXrHCckgB3+UzHY6HzC1/fklwmrEbIAPgLFfAKxUimqt+smymL5Fc7LthHPcmZxO tT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RWOpSdl4yyz3qxQY9ZyX2JakjC8GArkL5xoEGS0mrZM=; b=0MrH6Xvc5lt4hYD9wRqF5TZhW5Gezlv1l6EguXkVP4OTqC3kGDecpJcxyQtN813Wbx vJamtzxB8UGoJ/T/GTl1rSoa002p+lS7etcpdbj2fkjrwp9F07yrg8+ZAgX3gtMopTge Iv3nQAj0wIEcrpxQfNjHadn93KL5wrde03XibULpLb8vkPUzpYF8PGqdZKhq4HKSYriM nG8yE6XgtGP4l/zeIJ9hT8sUEeb/q9bepEu5z36QPGYpkdvVi0JnhtH1MDv5ySYzF3OB t4b8RMw+lUTVETgP8bMgWUtdxSAQ7CH2x7se8m62pqB++bYcVLzFY/of6ZSUpeiLPqxV EfuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lvCc1i+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x68si2507546oia.227.2020.01.24.06.23.01; Fri, 24 Jan 2020 06:23:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lvCc1i+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389058AbgAXLGl (ORCPT + 99 others); Fri, 24 Jan 2020 06:06:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:41500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732370AbgAXLGj (ORCPT ); Fri, 24 Jan 2020 06:06:39 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2FDFC2071A; Fri, 24 Jan 2020 11:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579863998; bh=aXybBSRr/3UKszq/j/eDcQDpiER95lQUlcUgFdzIOkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvCc1i+leH5WnkPTigWvmGOs0AIWzQkfno1PXBc+aEu1382gWbgD20iAxIwrq715P gSTO1lYFHHs0v6/VVWtzuUgxUXwIZkGi1Dbr/xTcDcSLqV9chRANmsgNqFQGmPyjxJ vo/boK9dqsM9PuOB/7QM3nLtL2aNKY4BfVKtDOi8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 4.19 129/639] spi: cadence: Correct initialisation of runtime PM Date: Fri, 24 Jan 2020 10:24:59 +0100 Message-Id: <20200124093103.456601203@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Charles Keepax [ Upstream commit 734882a8bf984c2ac8a57d8ac3ee53230bd0bed8 ] Currently the driver calls pm_runtime_put_autosuspend but without ever having done a pm_runtime_get, this causes the reference count in the pm runtime core to become -1. The bad reference count causes the core to sometimes suspend whilst an active SPI transfer is in progress. arizona spi0.1: SPI transfer timed out spi_master spi0: failed to transfer one message from queue The correct proceedure is to do all the initialisation that requires the hardware to be powered up before enabling the PM runtime, then enable the PM runtime having called pm_runtime_set_active to inform it that the hardware is currently powered up. The core will then power it down at it's leisure and no explicit pm_runtime_put is required. Fixes: d36ccd9f7ea4 ("spi: cadence: Runtime pm adaptation") Signed-off-by: Charles Keepax Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-cadence.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 7c88f74f7f470..94cc0a152449f 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -584,11 +584,6 @@ 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_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; @@ -603,8 +598,10 @@ static int cdns_spi_probe(struct platform_device *pdev) /* SPI controller initializations */ cdns_spi_init_hw(xspi); - pm_runtime_mark_last_busy(&pdev->dev); - pm_runtime_put_autosuspend(&pdev->dev); + 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) { -- 2.20.1