All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: David Laight <David.Laight@ACULAB.COM>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Matthias Lange <matthias.lange@kernkonzept.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 6/8] xhci: remove GFP_DMA flag from allocation
Date: Fri, 19 May 2017 12:49:11 +0300	[thread overview]
Message-ID: <591EBF97.7010200@linux.intel.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DCFFFA8F7@AcuExch.aculab.com>

On 19.05.2017 12:10, David Laight wrote:
> From: Mathias Nyman
>> Sent: 17 May 2017 16:32
>> There is no reason to restrict allocations to the first 16MB ISA DMA
>> addresses.
>>
>> It is causing problems in a virtualization setup with enabled IOMMU
>> (x86_64). The result is that USB is not working in the VM.
> ...
>> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
>> index 12b573c..1f1687e 100644
>> --- a/drivers/usb/host/xhci-mem.c
>> +++ b/drivers/usb/host/xhci-mem.c
>> @@ -56,7 +56,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
>>   	}
>>
>>   	if (max_packet) {
>> -		seg->bounce_buf = kzalloc(max_packet, flags | GFP_DMA);
>> +		seg->bounce_buf = kzalloc(max_packet, flags);
>
> This might allocate memory that the device cannot access.
> So can only work if dma_map_single() itself allocates a bounce buffer.
> There must be a sane way to do this that doesn't ever require
> double copies.
>

We are using dma_map_single()
This allocated memory is used as the processor virtual memory required by dma_map_single()
i.e. the "void *cpu_addr" part of dma_map_single, see DMA-API.txt:


dma_map_single(struct device *dev, void *cpu_addr, size_t size,
                       enum dma_data_direction direction)

Maps a piece of processor virtual memory so it can be accessed by the
device and returns the DMA address of the memory.

...

Notes:  Not all memory regions in a machine can be mapped by this API.
Further, contiguous kernel virtual space may not be contiguous as
physical memory.  Since this API does not provide any scatter/gather
capability, it will fail if the user tries to map a non-physically
contiguous piece of memory.  For this reason, memory to be mapped by
this API should be obtained from sources which guarantee it to be
physically contiguous (like kmalloc).

I'm not fully sure I understand yout concern, are you thinking the driver should
doublecheck the dma address returned by dma_map_single() and make sure it's within the
dma mask set for the device?

-Mathias

  reply	other threads:[~2017-05-19  9:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1495035126-29091-1-git-send-email-mathias.nyman@linux.intel.com>
2017-05-17 15:32 ` [PATCH 2/8] xhci: apply PME_STUCK_QUIRK and MISSING_CAS quirk for Denverton Mathias Nyman
2017-05-17 15:32 ` [PATCH 3/8] usb: host: xhci-mem: allocate zeroed Scratchpad Buffer Mathias Nyman
2017-05-17 15:32 ` [PATCH 5/8] USB: xhci: fix lock-inversion problem Mathias Nyman
2017-05-17 15:32 ` [PATCH 6/8] xhci: remove GFP_DMA flag from allocation Mathias Nyman
2017-05-19  9:10   ` David Laight
2017-05-19  9:49     ` Mathias Nyman [this message]
2017-05-19 13:54       ` David Laight
2017-05-17 15:32 ` [PATCH 7/8] xhci: Fix command ring stop regression in 4.11 Mathias Nyman
2017-05-17 15:32 ` [PATCH 8/8] usb: host: xhci-plat: propagate return value of platform_get_irq() Mathias Nyman

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=591EBF97.7010200@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matthias.lange@kernkonzept.com \
    --cc=stable@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 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.