Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4608833pxj; Wed, 12 May 2021 09:10:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgQ28TH4Ro2qIw40dc97QaZtyXJ0HbvnYpi7FthWgFxHREcnMfbpnMmH6+r6aLQAD/wHbs X-Received: by 2002:a05:6402:3546:: with SMTP id f6mr44567817edd.267.1620835809251; Wed, 12 May 2021 09:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835809; cv=none; d=google.com; s=arc-20160816; b=X23opqkaL6cAsw5VLSas2OKnfAbojP/WzKjAPbxG0mXbnmvl9T8gOZL/mUiwCqY7pd 8hD4spWeaZW/E+ak5dv7PNHdflQlx1Jw/OKzaYGB2VhY7zwF0n6CnpwDJ8kRmtwKgLcv mljSb3ABJotCWOJfzYRSRx5w6m2YbLivKe5PBfNF4lGm+T5D0upZJy+PcpizlEfo9PjT FAhiUOygmJfy2xRU/hRGrf6kB6ft5qk9SWrSdK7Jqg0CWpe9HlUR+bIoQdDg4Q0jB05d /pkMJWIP2L7oXKw1ugaKz0bnQQGvH72DOqUgq7QmM4wMmDF7hJWF8LAwztlk02jACc5W RVGQ== 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=VCJl67e+EKNs15Ln3QlF6iDWr5XxghAA+H/Dsb7c7g8=; b=nisU2PvuBblJwytNJwE5xgd42QKwmp808GJR33zw9J/GVkyyUQlTnX9lBrc2QiVIBm r4p0Q5lt8ym9ynYqzG0VfOWI10rEDNnG4lSKPu+07mqXKNQiVRRpQ5uAyd0x1amPf6CM 47cW3az76an9GITZd7QBJCgxjyIcuklRZwUiDEV+7XtDX70mwNTECCpRf/qnvWceD9Ce 7D35mLGrRFKvnJEfDTShsApeCzIOwPb26Hg4p1YlqwYAcgRJrf8aK2J/MH2GSFt9Gj7d LAPUCdVSaNsMrF9v2p1xG4iApv4vstrAewPIWzEsmLyI8gnuEeJT1a68Tp34lE9xJPUI +D9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="D6u/N1HB"; 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 u10si262077ejh.112.2021.05.12.09.09.44; Wed, 12 May 2021 09:10: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="D6u/N1HB"; 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 S239394AbhELQH6 (ORCPT + 99 others); Wed, 12 May 2021 12:07:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:38508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235696AbhELP2q (ORCPT ); Wed, 12 May 2021 11:28:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 48E476144A; Wed, 12 May 2021 15:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832483; bh=su0atcwJBS8RELHRlRBeui+HOCQ3P+7FGGWXnQe13PI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D6u/N1HB79ufGEMdEbelB3xtdcsQS00u1yvSwvcNnLcdV+jZQyx4yx5ytEP/MEHX1 KANXbzmqfcuka1QEENeZfFjouTgNCh1kEB+9NpHCbPL0KlwEvMN3M3TCwATTiiE90R +l9t6jIskM0CFbEMS5a4ONKnfpNEHRNtFQYboqB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quanyang Wang , Mark Brown , Sasha Levin Subject: [PATCH 5.10 263/530] spi: spi-zynqmp-gqspi: fix hang issue when suspend/resume Date: Wed, 12 May 2021 16:46:13 +0200 Message-Id: <20210512144828.470507719@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Quanyang Wang [ Upstream commit 799f923f0a66a9c99f0a3eaa078b306db7a8b33a ] After calling platform_set_drvdata(pdev, xqspi) in probe, the return value of dev_get_drvdata(dev) is a pointer to struct zynqmp_qspi but not struct spi_controller. A wrong structure type passing to the functions spi_controller_suspend/resume will hang the system. And we should check the return value of spi_controller_suspend, if an error is returned, return it to PM subsystem to stop suspend. Also, GQSPI_EN_MASK should be written to GQSPI_EN_OFST to enable the spi controller in zynqmp_qspi_resume since it was disabled in zynqmp_qspi_suspend before. Fixes: 1c26372e5aa9 ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework") Signed-off-by: Quanyang Wang Link: https://lore.kernel.org/r/20210416004652.2975446-3-quanyang.wang@windriver.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-zynqmp-gqspi.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 31d266cfbb4c..d6ac8fe145a1 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -157,6 +157,7 @@ enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; * @data_completion: completion structure */ struct zynqmp_qspi { + struct spi_controller *ctlr; void __iomem *regs; struct clk *refclk; struct clk *pclk; @@ -827,10 +828,13 @@ static void zynqmp_qspi_read_op(struct zynqmp_qspi *xqspi, u8 rx_nbits, */ static int __maybe_unused zynqmp_qspi_suspend(struct device *dev) { - struct spi_controller *ctlr = dev_get_drvdata(dev); - struct zynqmp_qspi *xqspi = spi_controller_get_devdata(ctlr); + struct zynqmp_qspi *xqspi = dev_get_drvdata(dev); + struct spi_controller *ctlr = xqspi->ctlr; + int ret; - spi_controller_suspend(ctlr); + ret = spi_controller_suspend(ctlr); + if (ret) + return ret; zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0); @@ -848,7 +852,10 @@ static int __maybe_unused zynqmp_qspi_suspend(struct device *dev) */ static int __maybe_unused zynqmp_qspi_resume(struct device *dev) { - struct spi_controller *ctlr = dev_get_drvdata(dev); + struct zynqmp_qspi *xqspi = dev_get_drvdata(dev); + struct spi_controller *ctlr = xqspi->ctlr; + + zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, GQSPI_EN_MASK); spi_controller_resume(ctlr); @@ -865,7 +872,7 @@ static int __maybe_unused zynqmp_qspi_resume(struct device *dev) */ static int __maybe_unused zynqmp_runtime_suspend(struct device *dev) { - struct zynqmp_qspi *xqspi = (struct zynqmp_qspi *)dev_get_drvdata(dev); + struct zynqmp_qspi *xqspi = dev_get_drvdata(dev); clk_disable_unprepare(xqspi->refclk); clk_disable_unprepare(xqspi->pclk); @@ -883,7 +890,7 @@ static int __maybe_unused zynqmp_runtime_suspend(struct device *dev) */ static int __maybe_unused zynqmp_runtime_resume(struct device *dev) { - struct zynqmp_qspi *xqspi = (struct zynqmp_qspi *)dev_get_drvdata(dev); + struct zynqmp_qspi *xqspi = dev_get_drvdata(dev); int ret; ret = clk_prepare_enable(xqspi->pclk); @@ -1090,6 +1097,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) xqspi = spi_controller_get_devdata(ctlr); xqspi->dev = dev; + xqspi->ctlr = ctlr; platform_set_drvdata(pdev, xqspi); xqspi->regs = devm_platform_ioremap_resource(pdev, 0); -- 2.30.2