public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 4/8] ehci-hcd: fix external buffer cache handling
Date: Mon, 16 Jul 2012 02:29:59 +0200	[thread overview]
Message-ID: <201207160229.59740.marek.vasut@gmail.com> (raw)
In-Reply-To: <1342363433-9284-5-git-send-email-ilya.yanok@cogentembedded.com>

Dear Ilya Yanok,

> Buffer coming from upper layers should be cacheline aligned/padded
> to perform safe cache operations. For now we don't do bounce
> buffering so getting unaligned buffer is an upper layer error.
> We can't check if the buffer is properly padded with current
> interface so just assume it is (consider changing with in the
> future). The following changes are done:
> 
> 1. Remove useless length alignment check. We get actual transfer
> length not the size of the underlying buffer so it's perfectly
> valid for it to be unaligned.
> 2. Move flush_dcache_range() out of while loop or it will
> flush too much.
> 3. Don't try to fix buffer address before calling invalidate:
> if it's unaligned it's an error anyway so let cache subsystem
> cry about that.
> 4. Fix end buffer address to be cacheline aligned assuming upper
> layer reserved enough space. This is potentially dangerous
> operation so upper layers should be careful about that.
> 
> Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
> ---
>  drivers/usb/host/ehci-hcd.c |   23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 59039f4..a6cd5e3 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -175,18 +175,15 @@ static int ehci_td_buffer(struct qTD *td, void *buf,
> size_t sz) {
>  	uint32_t delta, next;
>  	uint32_t addr = (uint32_t)buf;
> -	size_t rsz = roundup(sz, 32);
>  	int idx;
> 
> -	if (sz != rsz)
> -		debug("EHCI-HCD: Misaligned buffer size (%08x)\n", sz);

Shall we not also test if addr + sz is aligned?

> -	if (addr & 31)
> +	if (addr != ALIGN(addr, ARCH_DMA_MINALIGN))
>  		debug("EHCI-HCD: Misaligned buffer address (%p)\n", buf);
[...]

Best regards,
Marek Vasut

  reply	other threads:[~2012-07-16  0:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-15 14:43 [U-Boot] [PATCH V2 0/8] Fixes to EHCI cache handling & smsc95xx Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 1/8] ehci-omap: Do not call dcache_off from omap_ehci_hcd_init Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 2/8] common.h: Introduce DEFINE_CACHE_ALIGN_BUFFER Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 3/8] ehci-hcd.c, musb_core, usb.h: Add USB_DMA_MINALIGN define for cache alignment Ilya Yanok
2012-07-15 14:59   ` Marek Vasut
2012-07-15 15:51     ` Ilya Yanok
2012-07-15 17:12       ` Marek Vasut
2012-07-16  8:09         ` Ilya Yanok
2012-07-16  8:12           ` [U-Boot] [PATCH] ehci-hcd: program asynclistaddr before every transfer Ilya Yanok
2012-07-16  8:14           ` [U-Boot] [PATCH V2a 3/8] ehci-hcd.c, musb_core, usb.h: Add USB_DMA_MINALIGN define for cache alignment Ilya Yanok
2012-07-16 10:47           ` [U-Boot] [PATCH V2 " Marek Vasut
2012-07-17 17:58             ` Ilya Yanok
2012-07-18 12:52           ` Marek Vasut
2012-07-15 14:43 ` [U-Boot] [PATCH V2 4/8] ehci-hcd: fix external buffer cache handling Ilya Yanok
2012-07-16  0:29   ` Marek Vasut [this message]
2012-07-15 14:43 ` [U-Boot] [PATCH V2 5/8] usb: pass cache-aligned buffer to usb_get_descriptor() Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 6/8] usb: check return value of submit_{control, bulk}_msg Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 7/8] ehci-hcd: change debug() to printf() in case of errors Ilya Yanok
2012-07-15 14:43 ` [U-Boot] [PATCH V2 8/8] smsc95xx: align buffers to cache line size Ilya Yanok

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=201207160229.59740.marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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