netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
To: Ming Lei <tom.leiming@gmail.com>
Cc: linux-usb@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Network Development <netdev@vger.kernel.org>
Subject: Re: [RFC PATCH] usb: hcd: warn about URB buffers that are not DMA aligned and are about to be DMA mapped
Date: Sat, 15 Jun 2013 16:22:30 +0300	[thread overview]
Message-ID: <51BC6A96.7030707@iki.fi> (raw)
In-Reply-To: <51BC67D7.90006@iki.fi>

On 15.06.2013 16:10, Jussi Kivilinna wrote:
[...]
>>
>>>
>>>>
>>>>>
>>>>> Instead of fixing host drivers, users end up posting bug reports against
>>>>> those USB device drivers that use unaligned buffers for URB; such as with
>>>>> rtl8192cu (http://thread.gmane.org/gmane.linux.kernel.wireless.general/105631).
>>>>
>>>> Not only rtl8192cu driver, all USB network device drivers have the problem.
>>>>
>>>>>
>>>>> Patch makes this issue more visible at core level, and hopefully gives hint
>>>>> for future hcd driver implementors about this problem.
>>>>
>>>> So please find the root cause first, and don't add the noise now.
>>>
>>> I think the root cause is that host driver is letting pass non-aligned buffers
>>> to core on archs that have ARCH_DMA_MINALIGN set.
>>
>> No, I don't think so, about the problem, the dma alignment requirement should
>> be from your host controller.
>>
>> As I said above, dma mapping/unmapping should be capable of dealing with
>> the unaligned buffer if no one touches memory which shares cacheline with
>> URB->transfer_buffer during URB transfer.
> 
> How can you guarantee that when you allow unaligned URB buffers?
> 
> You can have the buffer as part of some larger structure and send out async URB.
> Then while buffer is DMA mapped and send async to hw, you use other parts of
> that structure even if it shares cacheline with the buffer. You might issue
> multiple URBs with transfer buffers within same cacheline. I would expect that
> to be acceptable or URB documentation should say something against such.
> 

Hm.. rethink this a bit.

Transfer buffer might be dma aligned but shorter than cacheline and end of cacheline
used as something else. Manual alignment by host driver does not catch that
or fix that.
So, yes.. dma mapping should work with unaligned buffers, but maybe the actual
problem is multiple buffers from same cacheline.

-Jussi

  reply	other threads:[~2013-06-15 13:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20130614133803.25747.98705.stgit@localhost6.localdomain6>
     [not found] ` <20130614133803.25747.98705.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2013-06-15  7:41   ` [RFC PATCH] usb: hcd: warn about URB buffers that are not DMA aligned and are about to be DMA mapped Ming Lei
2013-06-15 10:19     ` Jussi Kivilinna
     [not found]       ` <51BC3F9E.3010605-X3B1VOXEql0@public.gmane.org>
2013-06-15 12:07         ` Ming Lei
     [not found]           ` <CACVXFVMe9fgdiDTRC0rWvwZJM8aT7AZY8Q1MwiOTc4ks0PQPOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-15 13:10             ` Jussi Kivilinna
2013-06-15 13:22               ` Jussi Kivilinna [this message]
     [not found]                 ` <51BC6A96.7030707-X3B1VOXEql0@public.gmane.org>
2013-06-16  8:21                   ` Oliver Neukum
2013-06-16 10:35                     ` Jussi Kivilinna
2013-06-28 12:39                       ` Jussi Kivilinna
2013-06-28 12:58                         ` Oliver Neukum
2013-06-15 13:47               ` Ming Lei
2013-06-16 10:34                 ` Jussi Kivilinna

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=51BC6A96.7030707@iki.fi \
    --to=jussi.kivilinna@iki.fi \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom.leiming@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).