From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Cc: Geert Uytterhoeven
<geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux-sh list <linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] [RFC] spi: rspi: Handle dmaengine_prep_slave_sg() failures gracefully
Date: Thu, 10 Jul 2014 23:47:52 +0000 [thread overview]
Message-ID: <1976766.LYbV6saU9X@avalon> (raw)
In-Reply-To: <CAMuHMdXj=Y0w39iyY9GPjUJPXC7UgPyeqk7+G+zZeAvGoE1fGg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hi Geert,
On Thursday 10 July 2014 13:55:43 Geert Uytterhoeven wrote:
> On Thu, Jul 10, 2014 at 1:08 PM, Laurent Pinchart wrote:
> >> --- a/drivers/spi/spi-rspi.c
> >> +++ b/drivers/spi/spi-rspi.c
> >> @@ -477,7 +477,7 @@ static int rspi_dma_transfer(struct rspi_data *rspi,
> >> struct sg_table *tx, tx->sgl, tx->nents, DMA_TO_DEVICE,
> >> DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> >> if (!desc_tx)
> >> - return -EIO;
> >> + goto no_dma;
> >> irq_mask |= SPCR_SPTIE;
> >> }
> >>
> >> @@ -486,7 +486,7 @@ static int rspi_dma_transfer(struct rspi_data *rspi,
> >> struct sg_table *tx, rx->sgl, rx->nents, DMA_FROM_DEVICE,
> >> DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> >> if (!desc_rx)
> >> - return -EIO;
> >> + goto no_dma;
> >
> > This is not a new issue introduced by this patch, but aren't you leaking
> > desc_tx here ?
>
> AFAIK, descriptors are cleaned up automatically after use, and the only
> function that takes a dma_async_tx_descriptor is dmaengine_submit().
>
> But indeed, if you don't use them, that doesn't happen.
> So calling dmaengine_terminate_all() seems appropriate to fix this.
>
> But, Documentation/dmaengine.txt says:
>
> desc = dmaengine_prep_slave_sg(chan, sgl, nr_sg, direction, flags);
>
> Once a descriptor has been obtained, the callback information can be
> added and the descriptor must then be submitted. Some DMA engine
> drivers may hold a spinlock between a successful preparation and
> submission so it is important that these two operations are closely
> paired.
>
> W.r.t. the spinlock, is it safe to call dmaengine_terminate_all() for a
> prepared but not submitted transfer?
> Is there another/better way?
Basically, I have no idea. I'm pretty sure some drivers will support it,
others won't. Reading the code won't help much, as there's no available
information regarding what the expected behaviour is. Welcome to the wonderful
world of the undocumented DMA engine API :-)
The best way to move forward would be to decide on a behaviour and document
it. If nobody objects, drivers that don't implement the correct behaviour
could be considered as broken, and should be fixed. If someone objects, then a
discussion should spring up, and hopefully an agreement will be achieved on
what the correct behaviour is.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2014-07-10 23:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 10:26 [PATCH 1/2] [RFC] spi: rspi: Handle dmaengine_prep_slave_sg() failures gracefully Geert Uytterhoeven
2014-07-10 11:08 ` Laurent Pinchart
2014-07-10 11:55 ` Geert Uytterhoeven
[not found] ` <CAMuHMdXj=Y0w39iyY9GPjUJPXC7UgPyeqk7+G+zZeAvGoE1fGg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-10 23:47 ` Laurent Pinchart [this message]
2014-07-11 13:22 ` Geert Uytterhoeven
2014-07-11 13:27 ` Laurent Pinchart
2014-07-11 13:58 ` Geert Uytterhoeven
[not found] ` <CAMuHMdWw6BZn5HnvkxbEbbG+j52YcJhtxHoL=PVjUC0kag=-tw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-11 14:06 ` Laurent Pinchart
[not found] ` <1404901583-31366-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-07-09 10:26 ` [PATCH 2/2] [RFC] spi: sh-msiof: Handle dmaengine_prep_slave_single() " Geert Uytterhoeven
[not found] ` <1404901583-31366-2-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-07-10 11:09 ` Laurent Pinchart
2014-07-10 11:05 ` [PATCH 1/2] [RFC] spi: rspi: Handle dmaengine_prep_slave_sg() " Laurent Pinchart
2014-07-10 11:36 ` Geert Uytterhoeven
2014-07-16 21:42 ` Mark Brown
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=1976766.LYbV6saU9X@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org \
--cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).