From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: Geert Uytterhoeven
<geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] [RFC] spi: rspi: Handle dmaengine_prep_slave_sg() failures gracefully
Date: Thu, 10 Jul 2014 13:05:35 +0200 [thread overview]
Message-ID: <6218596.RTFxRvYFXy@avalon> (raw)
In-Reply-To: <1404901583-31366-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Hi Geert,
Thank you for the patch.
On Wednesday 09 July 2014 12:26:22 Geert Uytterhoeven wrote:
> As typically a shmobile SoC has less DMA channels than devices that can use
> DMA, we may want to prioritize access to the DMA channels in the future.
> This means that dmaengine_prep_slave_sg() may start failing arbitrarily.
>
> Handle dmaengine_prep_slave_sg() failures gracefully by falling back to
> PIO.
Just a random thought, do you think there would be performance-sensitive cases
where failing the transfer completely would be better than using PIO ?
> Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
-EAGAIN might not be the best error code to return in this case, as it would
imply that the caller should just call rspi_dma_transfer() again. On the other
hand I don't see another error code that would be a perfect match, so
Acked-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> ---
> drivers/spi/spi-rspi.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 38fd938d6360..c850dfdfa9e3 100644
> --- 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;
>
> irq_mask |= SPCR_SPRIE;
> }
> @@ -540,6 +540,12 @@ static int rspi_dma_transfer(struct rspi_data *rspi,
> struct sg_table *tx, enable_irq(rspi->rx_irq);
>
> return ret;
> +
> +no_dma:
> + pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
> + dev_driver_string(&rspi->master->dev),
> + dev_name(&rspi->master->dev));
> + return -EAGAIN;
> }
>
> static void rspi_receive_init(const struct rspi_data *rspi)
> @@ -593,8 +599,10 @@ static int rspi_common_transfer(struct rspi_data *rspi,
>
> if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
> /* rx_buf can be NULL on RSPI on SH in TX-only Mode */
> - return rspi_dma_transfer(rspi, &xfer->tx_sg,
> - xfer->rx_buf ? &xfer->rx_sg : NULL);
> + ret = rspi_dma_transfer(rspi, &xfer->tx_sg,
> + xfer->rx_buf ? &xfer->rx_sg : NULL);
> + if (ret != -EAGAIN)
> + return ret;
> }
>
> ret = rspi_pio_transfer(rspi, xfer->tx_buf, xfer->rx_buf, xfer->len);
> @@ -648,8 +656,11 @@ static int qspi_transfer_out(struct rspi_data *rspi,
> struct spi_transfer *xfer) {
> int ret;
>
> - if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer))
> - return rspi_dma_transfer(rspi, &xfer->tx_sg, NULL);
> + if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
> + ret = rspi_dma_transfer(rspi, &xfer->tx_sg, NULL);
> + if (ret != -EAGAIN)
> + return ret;
> + }
>
> ret = rspi_pio_transfer(rspi, xfer->tx_buf, NULL, xfer->len);
> if (ret < 0)
> @@ -663,8 +674,11 @@ static int qspi_transfer_out(struct rspi_data *rspi,
> struct spi_transfer *xfer)
>
> static int qspi_transfer_in(struct rspi_data *rspi, struct spi_transfer
> *xfer) {
> - if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer))
> - return rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
> + if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
> + int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
> + if (ret != -EAGAIN)
> + return ret;
> + }
>
> return rspi_pio_transfer(rspi, NULL, xfer->rx_buf, xfer->len);
> }
--
Regards,
Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-07-10 11:05 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
[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 ` Laurent Pinchart [this message]
2014-07-10 11:36 ` [PATCH 1/2] [RFC] spi: rspi: Handle dmaengine_prep_slave_sg() " Geert Uytterhoeven
2014-07-16 21:42 ` Mark Brown
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
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
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=6218596.RTFxRvYFXy@avalon \
--to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@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).