search for: dma_zalloc_coherent

Displaying 20 results from an estimated 45 matches for "dma_zalloc_coherent".

Did you mean: dma_alloc_coherent
2015 Nov 02
1
[PATCH 1/3] Provide simple noop dma ops
...*dma_handle, gfp_t gfp, > + struct dma_attrs *attrs) > +{ > + void *ret; > + > + ret = (void *)__get_free_pages(gfp, get_order(size)); > + if (ret) { > + memset(ret, 0, size); There is no need to zero out the memory here. If the user wants initialized memory it can call dma_zalloc_coherent. Having the memset here means to clear the memory twice in the dma_zalloc_coherent path. Otherwise it looks good. Joerg
2015 Nov 02
1
[PATCH 1/3] Provide simple noop dma ops
...*dma_handle, gfp_t gfp, > + struct dma_attrs *attrs) > +{ > + void *ret; > + > + ret = (void *)__get_free_pages(gfp, get_order(size)); > + if (ret) { > + memset(ret, 0, size); There is no need to zero out the memory here. If the user wants initialized memory it can call dma_zalloc_coherent. Having the memset here means to clear the memory twice in the dma_zalloc_coherent path. Otherwise it looks good. Joerg
2014 Aug 27
2
[PATCH 3/3] virtio_pci: Use the DMA API for virtqueues
...index, > info->num = num; > info->msix_vector = msix_vec; > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, GFP_KERNEL); > if (info->queue == NULL) { > err = -ENOMEM; > goto out_info; > } > > /* activate the queue */ > - iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT, &...
2014 Aug 27
2
[PATCH 3/3] virtio_pci: Use the DMA API for virtqueues
...index, > info->num = num; > info->msix_vector = msix_vec; > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, GFP_KERNEL); > if (info->queue == NULL) { > err = -ENOMEM; > goto out_info; > } > > /* activate the queue */ > - iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT, &...
2016 Feb 02
1
[PATCH v6 6/9] virtio: Add improved queue allocation API
...um & (num - 1)) { > + dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); > + return NULL; > + } > + > + /* TODO: allocate each queue chunk individually */ > + for (; num && vring_size(num, vring_align) > PAGE_SIZE; num /= 2) { > + queue = dma_zalloc_coherent( > + vdev->dev.parent, vring_size(num, vring_align), > + &dma_addr, GFP_KERNEL|__GFP_NOWARN); I think that we should teach this one to use regular kmalloc if vring_use_dma_api is cleared. Not a must but it seems cleaner at this stage. > + if (queue) > + break; > + } &...
2016 Feb 02
1
[PATCH v6 6/9] virtio: Add improved queue allocation API
...um & (num - 1)) { > + dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); > + return NULL; > + } > + > + /* TODO: allocate each queue chunk individually */ > + for (; num && vring_size(num, vring_align) > PAGE_SIZE; num /= 2) { > + queue = dma_zalloc_coherent( > + vdev->dev.parent, vring_size(num, vring_align), > + &dma_addr, GFP_KERNEL|__GFP_NOWARN); I think that we should teach this one to use regular kmalloc if vring_use_dma_api is cleared. Not a must but it seems cleaner at this stage. > + if (queue) > + break; > + } &...
2016 Feb 01
0
[PATCH v6 6/9] virtio: Add improved queue allocation API
...ume num is a power of 2. */ + if (num & (num - 1)) { + dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); + return NULL; + } + + /* TODO: allocate each queue chunk individually */ + for (; num && vring_size(num, vring_align) > PAGE_SIZE; num /= 2) { + queue = dma_zalloc_coherent( + vdev->dev.parent, vring_size(num, vring_align), + &dma_addr, GFP_KERNEL|__GFP_NOWARN); + if (queue) + break; + } + + if (!num) + return NULL; + + if (!queue) { + /* Try to get a single page. You are my only hope! */ + queue = dma_zalloc_coherent( + vdev->dev.parent, vring_s...
2015 Oct 30
13
[PATCH v4 0/6] virtio core DMA API conversion
This switches virtio to use the DMA API unconditionally. I'm sure it breaks things, but it seems to work on x86 using virtio-pci, with and without Xen, and using both the modern 1.0 variant and the legacy variant. This appears to work on native and Xen x86_64 using both modern and legacy virtio-pci. It also appears to work on arm and arm64. It definitely won't work as-is on s390x, and
2015 Oct 30
13
[PATCH v4 0/6] virtio core DMA API conversion
This switches virtio to use the DMA API unconditionally. I'm sure it breaks things, but it seems to work on x86 using virtio-pci, with and without Xen, and using both the modern 1.0 variant and the legacy variant. This appears to work on native and Xen x86_64 using both modern and legacy virtio-pci. It also appears to work on arm and arm64. It definitely won't work as-is on s390x, and
2013 Aug 20
2
[PATCH] VMXNET3: Add support for virtual IOMMU
We can't just do virt_to_phys() on memory that we pass to the device and expect it to work in presence of a virtual IOMMU. We need to add IOMMU mappings for such DMAs to work correctly. Fix that with pci_alloc_consistent() where possible, or pci_map_single() where the mapping is short-lived or we don't control the allocation (netdev). Also fix two small bugs: 1) use after free of
2013 Aug 20
2
[PATCH] VMXNET3: Add support for virtual IOMMU
We can't just do virt_to_phys() on memory that we pass to the device and expect it to work in presence of a virtual IOMMU. We need to add IOMMU mappings for such DMAs to work correctly. Fix that with pci_alloc_consistent() where possible, or pci_map_single() where the mapping is short-lived or we don't control the allocation (netdev). Also fix two small bugs: 1) use after free of
2014 Sep 17
4
[PATCH v5 2/3] virtio_pci: Use the DMA API for virtqueues when possible
...fo->use_dma_api = vp_use_dma_api(); > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + if (info->use_dma_api) { > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, > + GFP_KERNEL); > + } else { > + info->queue = alloc_pages_exact(PAGE_ALIGN(size), > + GFP_KERNEL|__GFP_ZERO); > + info->queue_dma_addr = virt_to_phys(info->queue); > + } > if (info...
2014 Sep 17
4
[PATCH v5 2/3] virtio_pci: Use the DMA API for virtqueues when possible
...fo->use_dma_api = vp_use_dma_api(); > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + if (info->use_dma_api) { > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, > + GFP_KERNEL); > + } else { > + info->queue = alloc_pages_exact(PAGE_ALIGN(size), > + GFP_KERNEL|__GFP_ZERO); > + info->queue_dma_addr = virt_to_phys(info->queue); > + } > if (info...
2014 Sep 17
1
[PATCH v5 2/3] virtio_pci: Use the DMA API for virtqueues when possible
...fo->use_dma_api = vp_use_dma_api(); > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + if (info->use_dma_api) { > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, > + GFP_KERNEL); > + } else { > + info->queue = alloc_pages_exact(PAGE_ALIGN(size), > + GFP_KERNEL|__GFP_ZERO); > + info->queue_dma_addr = virt_to_phys(info->queue); > + } > if (info...
2014 Sep 17
1
[PATCH v5 2/3] virtio_pci: Use the DMA API for virtqueues when possible
...fo->use_dma_api = vp_use_dma_api(); > > - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); > - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); > + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); > + if (info->use_dma_api) { > + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, > + &info->queue_dma_addr, > + GFP_KERNEL); > + } else { > + info->queue = alloc_pages_exact(PAGE_ALIGN(size), > + GFP_KERNEL|__GFP_ZERO); > + info->queue_dma_addr = virt_to_phys(info->queue); > + } > if (info...
2013 Aug 21
0
[PATCH] VMXNET3: Add support for virtual IOMMU
...oy() > 2) a cpu_to_le32() that should have been a cpu_to_le64() > > Acked-by: George Zhang <georgezhang at vmware.com> > Acked-by: Aditya Sarwade <asarwade at vmware.com> > Signed-off-by: Andy King <acking at vmware.com> Please use dma_alloc_coherent() (or in fact dma_zalloc_coherent()), dma_map_single() et al., because they are preferred and in particular allow specification of GFP_* flags.
2014 Aug 26
0
[PATCH 3/3] virtio_pci: Use the DMA API for virtqueues
...truct virtio_device *vdev, unsigned index, info->num = num; info->msix_vector = msix_vec; - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, + &info->queue_dma_addr, GFP_KERNEL); if (info->queue == NULL) { err = -ENOMEM; goto out_info; } /* activate the queue */ - iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT, + iowrite32(info->queue_dma_addr >&...
2014 Aug 27
0
[PATCH 3/3] virtio_pci: Use the DMA API for virtqueues
...; info->msix_vector = msix_vec; >> >> - size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); >> - info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); >> + size = vring_size(num, VIRTIO_PCI_VRING_ALIGN); >> + info->queue = dma_zalloc_coherent(vdev->dev.parent, size, >> + &info->queue_dma_addr, GFP_KERNEL); >> if (info->queue == NULL) { >> err = -ENOMEM; >> goto out_info; >> } >> >> /* activate the qu...
2015 Oct 30
8
[PATCHv2 0/3] dma ops and virtio
here is the 2nd version of providing an DMA API for s390. There are some attempts to unify the dma ops (Christoph) as well as some attempts to make virtio use the dma API (Andy). At kernel summit we concluded that we want to use the same code on all platforms, whereever possible, so having a dummy dma_op might be the easiest solution to keep virtio-ccw as similar as possible to
2015 Oct 30
8
[PATCHv2 0/3] dma ops and virtio
here is the 2nd version of providing an DMA API for s390. There are some attempts to unify the dma ops (Christoph) as well as some attempts to make virtio use the dma API (Andy). At kernel summit we concluded that we want to use the same code on all platforms, whereever possible, so having a dummy dma_op might be the easiest solution to keep virtio-ccw as similar as possible to