Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3713922pxv; Mon, 26 Jul 2021 10:03:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE1ce9bBJAiYk0gr/hp2BY4TSxR/1g/m+2s1MFLhJEALX+q35NIGFGrvymkbXE8fqPxxSo X-Received: by 2002:a17:906:2817:: with SMTP id r23mr17736395ejc.285.1627319008109; Mon, 26 Jul 2021 10:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319008; cv=none; d=google.com; s=arc-20160816; b=xJklpYbpNKgE9Z8fRJW0ToAC41HKhyjOz1O2DVtKEaPgcSuCypaspQuvY4VFy8G5LG 849EOF6x5lGUVIZi+7mnOM64qGQKP7H9oJSd6rMYi0T06RWPUxIjfRG/DtiYZQnbJGVM oGg/pMABmNicLCgSB/dxC1HynyD08euhPS9iLq1QyXTIxacziTMuzDsf3Br78DPLz/VV HPGPjQIFyMGuvP2yUxUUyZvGzqpD7LE5USreyPTeG6dP4XxI4Y3eoLRYpEFkilyXKIgc Y0otAoAuPMSsY2sNl98NhrhpJQTIQQhW2Zwo10ge/a75WsHGi+bzwim3GacFEtND7/GQ 8qZQ== 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=z8Ih5At9DtJzOuGDnjP6Zqz0bE/+CkNn1dJkGtFN72E=; b=WhHVP7fRhKnaDhCZJHKR8t0O4Sj9GiXMWjZGOThS8f41/338u3WxluO95iIl/+G5BS UEjOhHTTGCyMzZnhntKaVu8c5ygaQ/Yiewf4cC7c5I4fqjEbEvEdOBXUoJdkh1KihGMw mUWqA9gn2SNxovsqPe7VtqC0VN365MeHHLgTLWhW3yKWV7cLCKJANN/xeolOqcTMttb0 XrVyjCldgDVvRPfDit8nJe2XhUi3fumTlpme3tyb6TEN8Gp9Pg2e4bmPy7lJ3WjkT45D u3uFG4jl4lio96czBidgN0R6OYmuyvFSxJf0QiuSBD5ksGejoYcaWbr+4eSA9/kyccDx EgLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=skHuA5jN; 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 b8si483074ede.407.2021.07.26.10.03.03; Mon, 26 Jul 2021 10:03:28 -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=skHuA5jN; 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 S234766AbhGZPh1 (ORCPT + 99 others); Mon, 26 Jul 2021 11:37:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:35766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236599AbhGZPVc (ORCPT ); Mon, 26 Jul 2021 11:21:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E3DB460E09; Mon, 26 Jul 2021 16:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315320; bh=uOX4OaURtWMQzPsBzVLUPfZ+2s99oQaxC0K7nUTWB5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=skHuA5jNdte9dhUpCbsqxyZd7TmQBeBML+4E0EdDbnKswqItJmtue1Fqd2sbx0FCS 91cfaj+x2mcaXv+CLNBGQex5RG3fe6Z/MBvGqTTFW6HHCDV7rAU/g6Zdsca5zX3ZHU C5n/2I8pFfiRNA3XMcNDJJB51eYxX7XY5UghZW20= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amelie Delaunay , Alain Volmat , Mark Brown , Sasha Levin Subject: [PATCH 5.10 050/167] spi: stm32: fixes pm_runtime calls in probe/remove Date: Mon, 26 Jul 2021 17:38:03 +0200 Message-Id: <20210726153841.075969290@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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: Alain Volmat [ Upstream commit 7999d2555c9f879d006ea8469d74db9cdb038af0 ] Add pm_runtime calls in probe/probe error path and remove in order to be consistent in all places in ordering and ensure that pm_runtime is disabled prior to resources used by the SPI controller. This patch also fixes the 2 following warnings on driver remove: WARNING: CPU: 0 PID: 743 at drivers/clk/clk.c:594 clk_core_disable_lock+0x18/0x24 WARNING: CPU: 0 PID: 743 at drivers/clk/clk.c:476 clk_unprepare+0x24/0x2c Fixes: 038ac869c9d2 ("spi: stm32: add runtime PM support") Signed-off-by: Amelie Delaunay Signed-off-by: Alain Volmat Link: https://lore.kernel.org/r/1625646426-5826-2-git-send-email-alain.volmat@foss.st.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-stm32.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 0318f02d6212..8f91f8705eee 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -1946,6 +1946,7 @@ static int stm32_spi_probe(struct platform_device *pdev) master->can_dma = stm32_spi_can_dma; pm_runtime_set_active(&pdev->dev); + pm_runtime_get_noresume(&pdev->dev); pm_runtime_enable(&pdev->dev); ret = spi_register_master(master); @@ -1967,6 +1968,8 @@ static int stm32_spi_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); err_dma_release: if (spi->dma_tx) dma_release_channel(spi->dma_tx); @@ -1983,9 +1986,14 @@ static int stm32_spi_remove(struct platform_device *pdev) struct spi_master *master = platform_get_drvdata(pdev); struct stm32_spi *spi = spi_master_get_devdata(master); + pm_runtime_get_sync(&pdev->dev); + spi_unregister_master(master); spi->cfg->disable(spi); + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); if (master->dma_tx) dma_release_channel(master->dma_tx); if (master->dma_rx) @@ -1993,7 +2001,6 @@ static int stm32_spi_remove(struct platform_device *pdev) clk_disable_unprepare(spi->clk); - pm_runtime_disable(&pdev->dev); pinctrl_pm_select_sleep_state(&pdev->dev); -- 2.30.2