public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Allen Martin <amartin@nvidia.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/3] USB: make usb_kbd obey USB DMA alignment requirements
Date: Tue, 23 Oct 2012 14:58:39 -0700	[thread overview]
Message-ID: <20121023215838.GG13201@badger> (raw)
In-Reply-To: <50871179.4060901@wwwdotorg.org>

On Tue, Oct 23, 2012 at 02:51:53PM -0700, Stephen Warren wrote:
> On 10/23/2012 03:37 PM, Allen Martin wrote:
> > Change usb_kbd driver to obey alignment requirements for USB DMA on
> > the buffer used for data transfer.  This is necessary for
> > architectures that enable dcache and enable USB DMA.
> 
> > diff --git a/common/usb_kbd.c b/common/usb_kbd.c
> 
> > +/*
> > + * This structure must be aligned to USB_DMA_MINALIGN to allow DMA to
> > + * buffer "new" below.
> > + */
> >  struct usb_kbd_pdata {
> > +	uint8_t		new[8];
> > +	uint8_t		old[8];
> 
> Oh, one more thought on this: Those fields should both be aligned, and
> their size be aligned too, at least to cache size. In particular, if we
> have HW write to new[], then invalidate the cache that contains new[]
> because it just did, we want to make sure that fields after new[] (i.e.
> old[], ...) don't get invalidate too, in case the cache contained stale
> data for those fields. That's one of the things that the (stack-based)
> ALLOC_CACHE_ALIGN_BUFFER handles. Perhaps make those two fields
> pointers, and point those at a memalign()-allocated blob, where the size
> of those blobs are something like ROUND_UP(USB_DMA_MINALIGN, 8)?
> 
> Sorry for forgetting about this before!

That's a good point.  We also don't want to touch old[] from the CPU
right after we just flushed new[] and dirty the cacheline again.  It
does seem like these should be dynamically allocated, then I can avoid
the memalign() on the whole structure and don't have to worry if a new
member gets added in front of new[] later.

-Allen
-- 
nvpublic

      reply	other threads:[~2012-10-23 21:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 21:37 [U-Boot] [PATCH v3 1/3] USB: make usb_kbd obey USB DMA alignment requirements Allen Martin
2012-10-23 21:37 ` [U-Boot] [PATCH v3 2/3] tegra: move TEGRA_DEVICE_SETTINGS to tegra-common-post.h Allen Martin
2012-10-23 21:37 ` [U-Boot] [PATCH v3 3/3] tegra: Enable USB keyboard Allen Martin
2012-10-23 21:51 ` [U-Boot] [PATCH v3 1/3] USB: make usb_kbd obey USB DMA alignment requirements Stephen Warren
2012-10-23 21:58   ` Allen Martin [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=20121023215838.GG13201@badger \
    --to=amartin@nvidia.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