From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>,
han.xu@nxp.com, linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2] mtd: nand: gpmi: Release DMA channels on failure
Date: Sat, 6 Jan 2018 11:03:04 +0100 [thread overview]
Message-ID: <20180106110304.6bf8df65@bbrezillon> (raw)
In-Reply-To: <1514485078-19762-1-git-send-email-festevam@gmail.com>
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
prev parent reply other threads:[~2018-01-06 10:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180106110304.6bf8df65@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=fabio.estevam@nxp.com \
--cc=festevam@gmail.com \
--cc=han.xu@nxp.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox