From patchwork Mon Apr 19 12:15:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 12211727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B00EC433ED for ; Mon, 19 Apr 2021 12:18:03 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC4DF6101E for ; Mon, 19 Apr 2021 12:18:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC4DF6101E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EoPFpgHv9uBkI7SJ3h1HvdfMJ8h9YefB5hP8M++d0Yc=; b=QMs68NrWtWxOL1cYuLtTEdvYu nPqru/dZW3UYvh+EsYMa7OEc33UIJF8ofzHbYCUs1/5b202A6WTcUv/DpIe9bIqzUzGIHtxJB6g67 GdfyfOI1U3ZMSjd+Dp5vBfsTyNxWIXev1L3b7KHUbkWHqZZQsO+VYX1YKMUGlZTCBRQKnaKI+5FLV Dft23tEy5UKMLVUeCuWLPbKqakLbjtEDGZ4BIU4EmC4Ab3T3qpa3EBI+nY825WQckJUsKkrNMFp9S wkgDHFvMr4a40w108aMXNLf0KlS+D7MyLUPkuZwWo4Gm+boHpu3Woc/ByiKueFHuNMkPAAcKwgAM4 K0osT/WXQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYSor-009pcK-Ho; Mon, 19 Apr 2021 12:16:01 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYSon-009pbq-PZ for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 12:15:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oP6bwnD9fv0xHxu6w27iRBSjRpt2R2DDkqvUICCFy/4=; b=TvBnu4IZslc4fDY0M1yWFZx951 JHqknPB6gMqdMS+v3wxDHfXQq4qVpj0qdV4v+DBEIQxz7Y5HIwP7rDBy1DkYVaHRjj+McRnYrmVS2 s+aHYmiFKP/T7DzqGtRo97J9MJTvW8BaLimhNVYID7WelNazmERHd1IDLpAupzj6vRUf/qHCVp1py 1zHLkd4NGlHZBkyPJexSNMkjZ4QFXYGI2JzIm5ScY1mqqawJ4//hwVVca3nC5j+NI9OvNfhqHF/2l EONUTiRUP5jXkWvcGdBv5NnPhAIiNqlkaWVL2ySRkUm7KOInBrCh3FE0GQ+CLh6tLG21i/xlPpS2G ihuSEF9A==; Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYSoi-00BLGo-Le for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 12:15:56 +0000 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JCBMi6028003; Mon, 19 Apr 2021 14:15:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=oP6bwnD9fv0xHxu6w27iRBSjRpt2R2DDkqvUICCFy/4=; b=bVKVh8BeTuYDAxy5Xq+u3JtMEofaEcOoQulghesa8YNcIGBvjjvxXB1e6aFLeaCXRCL0 s6+/ARF7zJNuJ8AJJUGA9HbNImOfstcfwgrgmAXQc3Dxa0W/efQvaX8a7WQ2z2G738M6 CgLgRfl/pfolhevKctYmrB5ctnVATwqq0946vLEoIul8GgCHQbabRmabmGcqt0jpDJTp pxNs4oCt4EHFwevT43AbefFfXCc3gQJVWGBCdvuz/lyY8bTwXC/Bs29XJ/XFyNYLJQy4 +sDR881ZsfGPVzkB942cx8rFmKw3mUhI23yjz7JCUoUXHBulUpXMw4aU5o9C6cP35grn qQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 380wj63h0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 14:15:44 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BC2B6100034; Mon, 19 Apr 2021 14:15:43 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B10192139BE; Mon, 19 Apr 2021 14:15:43 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 19 Apr 2021 14:15:43 +0200 From: To: Mark Brown , Alexandre Torgue CC: , , , , , , Subject: [PATCH 1/3] spi: stm32-qspi: fix pm_runtime usage_count counter Date: Mon, 19 Apr 2021 14:15:39 +0200 Message-ID: <20210419121541.11617-2-patrice.chotard@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210419121541.11617-1-patrice.chotard@foss.st.com> References: <20210419121541.11617-1-patrice.chotard@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-19_07:2021-04-16, 2021-04-19 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210419_051553_033222_4372E158 X-CRM114-Status: GOOD ( 17.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Christophe Kerello pm_runtime usage_count counter is not well managed. pm_runtime_put_autosuspend callback drops the usage_counter but this one has never been increased. Add pm_runtime_get_sync callback to bump up the usage counter. It is also needed to use pm_runtime_force_suspend and pm_runtime_force_resume APIs to handle properly the clock. Fixes: 9d282c17b023 ("spi: stm32-qspi: Add pm_runtime support") Signed-off-by: Christophe Kerello Cc: stable@vger.kernel.org --- drivers/spi/spi-stm32-qspi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c index 947e6b9dc9f4..2786470a5201 100644 --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -727,21 +727,31 @@ static int __maybe_unused stm32_qspi_suspend(struct device *dev) { pinctrl_pm_select_sleep_state(dev); - return 0; + return pm_runtime_force_suspend(dev); } static int __maybe_unused stm32_qspi_resume(struct device *dev) { struct stm32_qspi *qspi = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; pinctrl_pm_select_default_state(dev); - clk_prepare_enable(qspi->clk); + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } writel_relaxed(qspi->cr_reg, qspi->io_base + QSPI_CR); writel_relaxed(qspi->dcr_reg, qspi->io_base + QSPI_DCR); - pm_runtime_mark_last_busy(qspi->dev); - pm_runtime_put_autosuspend(qspi->dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return 0; }