All of lore.kernel.org
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: linux-arm-kernel@lists.infradead.org
Subject: Problem with non aligned DMA in usbnet on ARM
Date: Wed, 11 Aug 2010 10:42:38 -0700	[thread overview]
Message-ID: <20100811174238.GA12382@kroah.com> (raw)
In-Reply-To: <AANLkTimmJDKbh3_pRY_ASKvjsf4YuuUMh3edh5LvDv-p@mail.gmail.com>

On Wed, Aug 11, 2010 at 06:08:43PM +0200, Martin Fuzzey wrote:
> On Wed, Aug 11, 2010 at 5:04 PM, Greg KH <greg@kroah.com> wrote:
> >> Here is a pointer to the thread where it was stated that HCD's don't
> >> have to handle this.
> >>
> >> http://kerneltrap.org/mailarchive/linux-usb/2009/4/20/5528164
> >
> > No, that thread is about stack vs. heap allocations, not about alignment
> > issues.
> >
> 
> Well although the issue discussed in that thread was caused by a stack
> allocation isn't the issue here the same?
> 
> My understanding is that a heap allocation as returned by kmalloc() will be:
> 1) correctly aligned for DMA
> and
> 2) in a memory zone accessible to DMA
> 
> whereas a stack allocation is not guaranteed to have either of these properties.
> 
> The problem I described in that thread was due to case 1
> (misalignment) rather than the stack memory zone not being accessible
> at all to DMA.
> To which was the reply was basically "use a heap allocation".
> 
> So the question is are hcds expected to accept arbitarilly aligned but
> heap allocated pointers (such as the result of kmalloc() + 1)?

It sounds like your HCD doesn't like this, so perhaps we should make
that rule :)

If you allocate the urb with a kmalloc() call with no offset, does it
all work properly?  The driver should be calling usb_alloc_urb() which
does this automatically for them, right?  Or is it trying to allocate
things on its own somehow?

thanks,

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
To: Martin Fuzzey <mfuzzey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Russell King - ARM Linux
	<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	linux-usb <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: Problem with non aligned DMA in usbnet on ARM
Date: Wed, 11 Aug 2010 10:42:38 -0700	[thread overview]
Message-ID: <20100811174238.GA12382@kroah.com> (raw)
In-Reply-To: <AANLkTimmJDKbh3_pRY_ASKvjsf4YuuUMh3edh5LvDv-p-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Wed, Aug 11, 2010 at 06:08:43PM +0200, Martin Fuzzey wrote:
> On Wed, Aug 11, 2010 at 5:04 PM, Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> wrote:
> >> Here is a pointer to the thread where it was stated that HCD's don't
> >> have to handle this.
> >>
> >> http://kerneltrap.org/mailarchive/linux-usb/2009/4/20/5528164
> >
> > No, that thread is about stack vs. heap allocations, not about alignment
> > issues.
> >
> 
> Well although the issue discussed in that thread was caused by a stack
> allocation isn't the issue here the same?
> 
> My understanding is that a heap allocation as returned by kmalloc() will be:
> 1) correctly aligned for DMA
> and
> 2) in a memory zone accessible to DMA
> 
> whereas a stack allocation is not guaranteed to have either of these properties.
> 
> The problem I described in that thread was due to case 1
> (misalignment) rather than the stack memory zone not being accessible
> at all to DMA.
> To which was the reply was basically "use a heap allocation".
> 
> So the question is are hcds expected to accept arbitarilly aligned but
> heap allocated pointers (such as the result of kmalloc() + 1)?

It sounds like your HCD doesn't like this, so perhaps we should make
that rule :)

If you allocate the urb with a kmalloc() call with no offset, does it
all work properly?  The driver should be calling usb_alloc_urb() which
does this automatically for them, right?  Or is it trying to allocate
things on its own somehow?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-08-11 17:42 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11  9:41 Problem with non aligned DMA in usbnet on ARM Martin Fuzzey
2010-08-11  9:41 ` Martin Fuzzey
2010-08-11  9:54 ` Russell King - ARM Linux
2010-08-11  9:54   ` Russell King - ARM Linux
2010-08-11 10:11   ` Martin Fuzzey
2010-08-11 10:11     ` Martin Fuzzey
2010-08-11 15:04     ` Greg KH
2010-08-11 15:04       ` Greg KH
2010-08-11 16:08       ` Martin Fuzzey
2010-08-11 16:08         ` Martin Fuzzey
2010-08-11 17:42         ` Greg KH [this message]
2010-08-11 17:42           ` Greg KH
2010-08-11 19:07           ` Martin Fuzzey
2010-08-11 19:07             ` Martin Fuzzey
2010-08-11 20:13             ` Greg KH
2010-08-11 20:13               ` Greg KH
2010-08-11 22:31               ` Martin Fuzzey
2010-08-11 22:31                 ` Martin Fuzzey
2010-08-12 17:01                 ` Matthieu CASTET
2010-08-12 17:01                   ` Matthieu CASTET
2010-08-11 19:10           ` Oliver Neukum
2010-08-11 19:10             ` Oliver Neukum
2010-08-11  9:59 ` Matthieu CASTET
2010-08-11  9:59   ` Matthieu CASTET
2010-08-11 11:38   ` Martin Fuzzey
2010-08-11 11:38     ` Martin Fuzzey
2010-08-11 15:54     ` Gary King
2010-08-11 20:35       ` Russell King - ARM Linux
2010-08-11 22:20         ` Martin Fuzzey
2010-08-11 22:20           ` Martin Fuzzey
2010-08-11 22:47           ` Russell King - ARM Linux
2010-08-11 22:47             ` Russell King - ARM Linux
2010-08-12 17:08           ` Matthieu CASTET
2010-08-12 17:08             ` Matthieu CASTET
2010-08-13 10:06             ` Martin Fuzzey
2010-08-13 10:06               ` Martin Fuzzey
2010-08-13 10:58               ` Oliver Neukum
2010-08-13 10:58                 ` Oliver Neukum
2010-08-13 13:42                 ` David Brownell
2010-08-13 13:42                   ` David Brownell
2010-08-13 13:53                   ` Oliver Neukum
2010-08-13 13:53                     ` Oliver Neukum

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=20100811174238.GA12382@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-arm-kernel@lists.infradead.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.