From: Greg KH <greg@kroah.com>
To: "Antti Seppälä" <a.seppala@gmail.com>
Cc: stable@vger.kernel.org, Felipe Balbi <felipe.balbi@linux.intel.com>
Subject: Re: [PATCH] usb: dwc2: Fix DMA alignment to start at allocated boundary
Date: Sat, 28 Jul 2018 10:09:23 +0200 [thread overview]
Message-ID: <20180728080923.GA18082@kroah.com> (raw)
In-Reply-To: <20180727185217.27435-1-a.seppala@gmail.com>
On Fri, Jul 27, 2018 at 09:52:17PM +0300, Antti Sepp�l� wrote:
> commit 56406e017a883b54b339207b230f85599f4d70ae upstream.
>
> The commit 3bc04e28a030 ("usb: dwc2: host: Get aligned DMA in a more
> supported way") introduced a common way to align DMA allocations.
> The code in the commit aligns the struct dma_aligned_buffer but the
> actual DMA address pointed by data[0] gets aligned to an offset from
> the allocated boundary by the kmalloc_ptr and the old_xfer_buffer
> pointers.
>
> This is against the recommendation in Documentation/DMA-API.txt which
> states:
>
> Therefore, it is recommended that driver writers who don't take
> special care to determine the cache line size at run time only map
> virtual regions that begin and end on page boundaries (which are
> guaranteed also to be cache line boundaries).
>
> The effect of this is that architectures with non-coherent DMA caches
> may run into memory corruption or kernel crashes with Unhandled
> kernel unaligned accesses exceptions.
>
> Fix the alignment by positioning the DMA area in front of the allocation
> and use memory at the end of the area for storing the orginal
> transfer_buffer pointer. This may have the added benefit of increased
> performance as the DMA area is now fully aligned on all architectures.
>
> Tested with Lantiq xRX200 (MIPS) and RPi Model B Rev 2 (ARM).
>
> Fixes: 3bc04e28a030 ("usb: dwc2: host: Get aligned DMA in a more supported way")
> Cc: <stable@vger.kernel.org>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
> [ Antti: backported to 4.9: edited difference in whitespace ]
> Signed-off-by: Antti Sepp�l� <a.seppala@gmail.com>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
>
> Notes:
> This is the same patch already applied upstream and queued for stable kernels
> 4.14 and 4.17 but with a minor whitespace edit to make it apply also on 4.9.
Now applied, thanks.
greg k-h
prev parent reply other threads:[~2018-07-28 9:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 18:52 [PATCH] usb: dwc2: Fix DMA alignment to start at allocated boundary Antti Seppälä
2018-07-28 8:09 ` Greg KH [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=20180728080923.GA18082@kroah.com \
--to=greg@kroah.com \
--cc=a.seppala@gmail.com \
--cc=felipe.balbi@linux.intel.com \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.