Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469246pxj; Mon, 10 May 2021 03:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq6ryTkAVI1ZbHpVcCkHI8aANqwvKA97JKs6ikq5HIToXRJtfCZk4B7r26gHXwFkuWPFCY X-Received: by 2002:a02:90cd:: with SMTP id c13mr20814947jag.18.1620643929298; Mon, 10 May 2021 03:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643929; cv=none; d=google.com; s=arc-20160816; b=oT2VOT8o7g2m7qb7eurGm3VwWyyLEhWZSW9/mxxxepLgqVdj13ZO8VsE0j60WwXAD7 K2ZFxxRNvQF56AEEPpIm+ZGLDbJpAbwxwpI8vJNkR93GLl3BKpY6WQ9XslUlw+Tbh9e2 uc3TJyUL6az/YiZE6rpta0CQA6eAV+t2dDVJWoMszibLnBvFrPPDyQJ03c8DBNpZ1gqv 7fup2yHm2864MdepMm8b3evNw3hWnKxQgKyTJfrVXj6WgP/audn80dc5LgCoW4iD9bGx YCklQLUIMGQHApu1NEzkngIsvonmnoiMG3vBhon+ZnhSfv3mlBE+Ycd7/fiis+M9QXAg IHWg== 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=npMy3wCzmRX0ZSVr8DcVMKNcfz64mij00wZBAfqPvew=; b=ut2YPaZkzvyswtRoub2Dn1r/zFFLhd4SoP0hDp0wdNpNLu8WIMMOI2OklxBrZKgew/ CdltdkCsWdc0HA653DjrSb0RMSQnHKXgNQQ6zM3/Unuw8KUXny5v6X8ofsxhEODsJY/W HH4DyLuwdb+Yy6lSYQrz/fNhziRG6P2wQN9yuuVG9e+Me0TahYVQDg6sYqOYDTskqa+A VqMRhGtwFVPpqQusMuAAEL40zojPqcllP/TOY7xQYxa0c7nfat1iyik9wt1FTnldIfa/ Qs56GN6OTEhy5QUULRNbDjUB5EqkdH5YjskY94Udk1tbYvD5Q518Gn3yFcx8n+Huh9y3 aUkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EI2F3HQi; 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 i25si5412529ila.96.2021.05.10.03.51.57; Mon, 10 May 2021 03:52:09 -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=EI2F3HQi; 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 S232910AbhEJKv3 (ORCPT + 99 others); Mon, 10 May 2021 06:51:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:50390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232344AbhEJKlK (ORCPT ); Mon, 10 May 2021 06:41:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CAD0561966; Mon, 10 May 2021 10:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642720; bh=dVDuS0/JAk3BBVKWAnP1KZ9W/o1EEu+0rnNq1zwcQUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EI2F3HQisLPfUS+/INT8Qv+ivvy9Iz7oacFdkzq1+OuPkiN8fCI88R2SloaqQ0DhR OVQca4gMK3N03QXcu/t7qLFINmElwvwg2RTePn22pb7KA2K+d6v/BKUkRnRYlA3BY9 fW/LOyNVbRKWrf3vtVk2EwMxDnCgg5QdwBgM3eOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Kerello , Mark Brown Subject: [PATCH 5.10 024/299] spi: stm32-qspi: fix pm_runtime usage_count counter Date: Mon, 10 May 2021 12:17:01 +0200 Message-Id: <20210510102005.650747244@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Christophe Kerello commit 102e9d1936569d43f55dd1ea89be355ad207143c upstream. 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 Link: https://lore.kernel.org/r/20210419121541.11617-2-patrice.chotard@foss.st.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-stm32-qspi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -727,21 +727,31 @@ static int __maybe_unused stm32_qspi_sus { 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; }