linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Li <gavinli@thegavinli.com>
To: David Laight <David.Laight@aculab.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Gavin Li <git@thegavinli.com>
Subject: Re: [PATCH] usb: devio: fix mmap() on non-coherent DMA architectures
Date: Mon, 5 Aug 2019 11:33:21 -0700	[thread overview]
Message-ID: <CA+GxvY4jXRH3i2q+bVxEOSCVrZmnJy-MKXMASagkEZG=YOWutw@mail.gmail.com> (raw)
In-Reply-To: <95109056461d4721bc2d2742b18b97ee@AcuMS.aculab.com>

The purpose of this section of code is to map that memory into
userspace, and the code before this patch would incorrectly calculate
the pfn required to do so. This patch simply changes it to use the
correct function to do so rather than doing it from scratch.

On Mon, Aug 5, 2019 at 4:37 AM David Laight <David.Laight@aculab.com> wrote:
>
> From: gavinli@thegavinli.com
> > Sent: 01 August 2019 23:02
> >
> > On architectures that are not (or are optionally) DMA coherent,
> > dma_alloc_coherent() returns an address into the vmalloc space,
> > and calling virt_to_phys() on this address returns an unusable
> > physical address.
>
> So? what is the code trying to use the return value of virt_to_phys() for?
>
> The 'cpu physical address' isn't (usually) a very interesting number.
> The value you normally want is the address the hardware should use
> in order to access the memory - this isn't (in general) the same value.
> (It might be different for different devices.)
>
> ISTR that dma_alloc_coherent() returns this value to the caller.
>
>         David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>

  reply	other threads:[~2019-08-05 18:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 22:01 [PATCH] usb: devio: fix mmap() on non-coherent DMA architectures gavinli
2019-08-05 11:37 ` David Laight
2019-08-05 18:33   ` Gavin Li [this message]
2019-08-01 22:04 gavinli
2019-08-02 12:14 ` Greg KH
2019-08-02 17:57   ` Gavin Li
2019-08-05 15:17     ` Greg KH
2019-09-04  7:05       ` Greg KH

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='CA+GxvY4jXRH3i2q+bVxEOSCVrZmnJy-MKXMASagkEZG=YOWutw@mail.gmail.com' \
    --to=gavinli@thegavinli.com \
    --cc=David.Laight@aculab.com \
    --cc=git@thegavinli.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@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 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).