From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH 1/8] serial: sh-sci: Use correct device for DMA mapping with IOMMU
Date: Wed, 15 Jul 2015 20:30:51 +0000 [thread overview]
Message-ID: <1503866.L25viQpzPd@avalon> (raw)
In-Reply-To: <1432145174-11534-2-git-send-email-geert+renesas@glider.be>
Hi Geert,
On Wednesday 15 July 2015 13:37:36 Geert Uytterhoeven wrote:
> On Sat, May 23, 2015 at 9:01 PM, Laurent Pinchart wrote:
> > On Wednesday 20 May 2015 20:06:07 Geert Uytterhoeven wrote:
> >> To function correctly in the presence of an IOMMU, the DMA buffers must
> >> be managed using the DMA channel's device instead of the platform
> >> device's device.
> >>
> >> Make sure to free the DMA memory before releasing the channel, and avoid
> >> freeing it twice (when DMA initialization succeeded before, but failed
> >> partially on next open).
> >>
> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >> ---
> >>
> >> drivers/tty/serial/sh-sci.c | 17 +++++++++++------
> >> 1 file changed, 11 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> >> index 583aa563d4038f8b..8756d186e86891ac 100644
> >> --- a/drivers/tty/serial/sh-sci.c
> >> +++ b/drivers/tty/serial/sh-sci.c
> >> @@ -1372,10 +1372,13 @@ static void sci_rx_dma_release(struct sci_port
> >> *s, bool enable_pio)
> >>
> >> s->chan_rx = NULL;
> >> s->cookie_rx[0] = s->cookie_rx[1] = -EINVAL;
> >>
> >> + if (sg_dma_address(&s->sg_rx[0])) {
> >
> > 0 is a valid DMA address. You should use dma_mapping_error() to test for
>
> 0 is not a valid DMA addresss on sh...
It is on ARM though.
> > invalid addresses. I'm afraid we don't have any API to set a DMA address
> > to an invalid value, but we can probably use DMA_ERROR_CODE for now even
> > if it's limited to ARM.
>
> There's no DMA_ERROR_CODE on sh.
>
> Furthermore, while dma_mapping_error() on ARM checks for DMA_ERROR_CODE
> (~0), sh checks for zero...
That's why drivers are supposed to use dma_mapping_error(). The problem is the
lack of an API to set a DMA address to an invalid value in an architecture-
independent way.
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2015-07-15 20:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 18:06 [PATCH 1/8] serial: sh-sci: Use correct device for DMA mapping with IOMMU Geert Uytterhoeven
2015-05-23 19:01 ` Laurent Pinchart
2015-07-15 11:37 ` Geert Uytterhoeven
2015-07-15 20:30 ` Laurent Pinchart [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=1503866.L25viQpzPd@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-sh@vger.kernel.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