* [PATCH v2] mtd: nand: gpmi: Release DMA channels on failure
@ 2017-12-28 18:17 Fabio Estevam
2018-01-06 10:03 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2017-12-28 18:17 UTC (permalink / raw)
To: boris.brezillon; +Cc: han.xu, linux-mtd, Fabio Estevam
From: Fabio Estevam <fabio.estevam@nxp.com>
release_dma_channels() should be called in the case of error in
gpmi_init() or bch_set_geometry(), because acquire_dma_channels() has
been called previously.
Handle the error cases correctly.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v1:
- Remove extra blank line
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 2ef8979..db0d924 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -2137,20 +2137,24 @@ static int gpmi_pm_resume(struct device *dev)
ret = gpmi_init(this);
if (ret) {
dev_err(this->dev, "Error setting GPMI : %d\n", ret);
- return ret;
+ goto release_dma_channels;
}
/* re-init the BCH registers */
ret = bch_set_geometry(this);
if (ret) {
dev_err(this->dev, "Error setting BCH : %d\n", ret);
- return ret;
+ goto release_dma_channels;
}
/* re-init others */
gpmi_extra_init(this);
return 0;
+
+release_dma_channels:
+ release_dma_channels(this);
+ return ret;
}
#endif /* CONFIG_PM_SLEEP */
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mtd: nand: gpmi: Release DMA channels on failure
2017-12-28 18:17 [PATCH v2] mtd: nand: gpmi: Release DMA channels on failure Fabio Estevam
@ 2018-01-06 10:03 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2018-01-06 10:03 UTC (permalink / raw)
To: Fabio Estevam; +Cc: Fabio Estevam, han.xu, linux-mtd
On Thu, 28 Dec 2017 16:17:58 -0200
Fabio Estevam <festevam@gmail.com> wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> release_dma_channels() should be called in the case of error in
> gpmi_init() or bch_set_geometry(), because acquire_dma_channels() has
> been called previously.
I'm really not sure this is a good idea. According to [1], the error
code returned by PM hooks is not taken into account, and the device
will be considered as functional by the system even if
->suspend() returns an error. This means, next time we enter suspend,
gpmi_pm_suspend() will be called which will lead to an unbalanced
release_dma_channels()/acquire_dma_channels().
>
> Handle the error cases correctly.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> Changes since v1:
> - Remove extra blank line
>
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 2ef8979..db0d924 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -2137,20 +2137,24 @@ static int gpmi_pm_resume(struct device *dev)
> ret = gpmi_init(this);
> if (ret) {
> dev_err(this->dev, "Error setting GPMI : %d\n", ret);
> - return ret;
> + goto release_dma_channels;
> }
>
> /* re-init the BCH registers */
> ret = bch_set_geometry(this);
> if (ret) {
> dev_err(this->dev, "Error setting BCH : %d\n", ret);
> - return ret;
> + goto release_dma_channels;
> }
>
> /* re-init others */
> gpmi_extra_init(this);
>
> return 0;
> +
> +release_dma_channels:
> + release_dma_channels(this);
> + return ret;
> }
> #endif /* CONFIG_PM_SLEEP */
>
[1]https://elixir.free-electrons.com/linux/v4.15-rc6/source/include/linux/pm.h#L262
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-06 10:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28 18:17 [PATCH v2] mtd: nand: gpmi: Release DMA channels on failure Fabio Estevam
2018-01-06 10:03 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).