* [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs
@ 2016-06-30 8:23 Krzysztof Kozlowski
[not found] ` <1467275171-6298-1-git-send-email-k.kozlowski@samsung.com>
2016-07-12 12:16 ` [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs Daniel Vetter
0 siblings, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-30 8:23 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, hch, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz,
linux-doc, linux-alpha, linux-snps-arc, linux-arm-kernel,
xen-devel, linux-c6x-dev, linux-cris-kernel, linux-hexagon,
linux-ia64, linux-m68k, linux-metag, linux-mips, linux-parisc,
linuxppc-dev, linux-s390, linux-sh, sparclinux, linux-pci,
linux-xtensa, dri-devel, linux-samsung-soc, linux-mediatek,
linux-arm-msm, freedreno, nouveau, linux-rockchip, linux-rdma,
iommu, linux-media, linux-omap, linux-fbdev
Hi,
This is fifth approach for replacing struct dma_attrs with unsigned
long.
The main patch (1/44) doing the change is split into many subpatches
for easier review (2-42). They should be squashed together when
applying.
Rebased on v4.7-rc5.
For easier testing the patchset is available here:
repo: https://github.com/krzk/linux
branch: for-next/dma-attrs-const-v5
Changes since v4
================
1. Collect some acks. Still need more.
2. Minor fixes pointed by Robin Murphy.
3. Applied changes from Bart Van Assche's comment.
4. More tests and builds (using https://www.kernel.org/pub/tools/crosstool/).
Changes since v3
================
1. Collect some acks.
2. Drop wrong patch 1/45 ("powerpc: dma-mapping: Don't hard-code
the value of DMA_ATTR_WEAK_ORDERING").
3. Minor fix pointed out by Michael Ellerman.
Changes since v2
================
1. Follow Christoph Hellwig's comments (don't use BIT add
documentation, remove dma_get_attr).
Rationale
=========
The dma-mapping core and the implementations do not change the
DMA attributes passed by pointer. Thus the pointer can point to const
data. However the attributes do not have to be a bitfield. Instead
unsigned long will do fine:
1. This is just simpler. Both in terms of reading the code and setting
attributes. Instead of initializing local attributes on the stack
and passing pointer to it to dma_set_attr(), just set the bits.
2. It brings safeness and checking for const correctness because the
attributes are passed by value.
Best regards,
Krzysztof
Krzysztof Kozlowski (44):
dma-mapping: Use unsigned long for dma_attrs
alpha: dma-mapping: Use unsigned long for dma_attrs
arc: dma-mapping: Use unsigned long for dma_attrs
ARM: dma-mapping: Use unsigned long for dma_attrs
arm64: dma-mapping: Use unsigned long for dma_attrs
avr32: dma-mapping: Use unsigned long for dma_attrs
blackfin: dma-mapping: Use unsigned long for dma_attrs
c6x: dma-mapping: Use unsigned long for dma_attrs
cris: dma-mapping: Use unsigned long for dma_attrs
frv: dma-mapping: Use unsigned long for dma_attrs
drm/exynos: dma-mapping: Use unsigned long for dma_attrs
drm/mediatek: dma-mapping: Use unsigned long for dma_attrs
drm/msm: dma-mapping: Use unsigned long for dma_attrs
drm/nouveau: dma-mapping: Use unsigned long for dma_attrs
drm/rockship: dma-mapping: Use unsigned long for dma_attrs
infiniband: dma-mapping: Use unsigned long for dma_attrs
iommu: dma-mapping: Use unsigned long for dma_attrs
[media] dma-mapping: Use unsigned long for dma_attrs
xen: dma-mapping: Use unsigned long for dma_attrs
swiotlb: dma-mapping: Use unsigned long for dma_attrs
powerpc: dma-mapping: Use unsigned long for dma_attrs
video: dma-mapping: Use unsigned long for dma_attrs
x86: dma-mapping: Use unsigned long for dma_attrs
iommu: intel: dma-mapping: Use unsigned long for dma_attrs
h8300: dma-mapping: Use unsigned long for dma_attrs
hexagon: dma-mapping: Use unsigned long for dma_attrs
ia64: dma-mapping: Use unsigned long for dma_attrs
m68k: dma-mapping: Use unsigned long for dma_attrs
metag: dma-mapping: Use unsigned long for dma_attrs
microblaze: dma-mapping: Use unsigned long for dma_attrs
mips: dma-mapping: Use unsigned long for dma_attrs
mn10300: dma-mapping: Use unsigned long for dma_attrs
nios2: dma-mapping: Use unsigned long for dma_attrs
openrisc: dma-mapping: Use unsigned long for dma_attrs
parisc: dma-mapping: Use unsigned long for dma_attrs
misc: mic: dma-mapping: Use unsigned long for dma_attrs
s390: dma-mapping: Use unsigned long for dma_attrs
sh: dma-mapping: Use unsigned long for dma_attrs
sparc: dma-mapping: Use unsigned long for dma_attrs
tile: dma-mapping: Use unsigned long for dma_attrs
unicore32: dma-mapping: Use unsigned long for dma_attrs
xtensa: dma-mapping: Use unsigned long for dma_attrs
dma-mapping: Remove dma_get_attr
dma-mapping: Document the DMA attributes next to the declaration
Documentation/DMA-API.txt | 33 +++---
Documentation/DMA-attributes.txt | 2 +-
arch/alpha/include/asm/dma-mapping.h | 2 -
arch/alpha/kernel/pci-noop.c | 2 +-
arch/alpha/kernel/pci_iommu.c | 12 +-
arch/arc/mm/dma.c | 12 +-
arch/arm/common/dmabounce.c | 4 +-
arch/arm/include/asm/dma-mapping.h | 13 +--
arch/arm/include/asm/xen/page-coherent.h | 16 +--
arch/arm/mm/dma-mapping.c | 117 +++++++++----------
arch/arm/xen/mm.c | 8 +-
arch/arm64/mm/dma-mapping.c | 66 +++++------
arch/avr32/mm/dma-coherent.c | 12 +-
arch/blackfin/kernel/dma-mapping.c | 8 +-
arch/c6x/include/asm/dma-mapping.h | 4 +-
arch/c6x/kernel/dma.c | 9 +-
arch/c6x/mm/dma-coherent.c | 4 +-
arch/cris/arch-v32/drivers/pci/dma.c | 9 +-
arch/frv/mb93090-mb00/pci-dma-nommu.c | 8 +-
arch/frv/mb93090-mb00/pci-dma.c | 9 +-
arch/h8300/kernel/dma.c | 8 +-
arch/hexagon/include/asm/dma-mapping.h | 1 -
arch/hexagon/kernel/dma.c | 8 +-
arch/ia64/hp/common/sba_iommu.c | 22 ++--
arch/ia64/include/asm/machvec.h | 1 -
arch/ia64/kernel/pci-swiotlb.c | 4 +-
arch/ia64/sn/pci/pci_dma.c | 22 ++--
arch/m68k/kernel/dma.c | 12 +-
arch/metag/kernel/dma.c | 16 +--
arch/microblaze/include/asm/dma-mapping.h | 1 -
arch/microblaze/kernel/dma.c | 12 +-
arch/mips/cavium-octeon/dma-octeon.c | 8 +-
arch/mips/loongson64/common/dma-swiotlb.c | 10 +-
arch/mips/mm/dma-default.c | 20 ++--
arch/mips/netlogic/common/nlm-dma.c | 4 +-
arch/mn10300/mm/dma-alloc.c | 8 +-
arch/nios2/mm/dma-mapping.c | 12 +-
arch/openrisc/kernel/dma.c | 21 ++--
arch/parisc/kernel/pci-dma.c | 18 +--
arch/powerpc/include/asm/dma-mapping.h | 7 +-
arch/powerpc/include/asm/iommu.h | 10 +-
arch/powerpc/kernel/dma-iommu.c | 12 +-
arch/powerpc/kernel/dma.c | 18 +--
arch/powerpc/kernel/ibmebus.c | 12 +-
arch/powerpc/kernel/iommu.c | 12 +-
arch/powerpc/kernel/vio.c | 12 +-
arch/powerpc/platforms/cell/iommu.c | 28 ++---
arch/powerpc/platforms/pasemi/iommu.c | 2 +-
arch/powerpc/platforms/powernv/npu-dma.c | 8 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 4 +-
arch/powerpc/platforms/powernv/pci.c | 2 +-
arch/powerpc/platforms/powernv/pci.h | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 18 +--
arch/powerpc/platforms/pseries/iommu.c | 6 +-
arch/powerpc/sysdev/dart_iommu.c | 2 +-
arch/s390/include/asm/dma-mapping.h | 1 -
arch/s390/pci/pci_dma.c | 23 ++--
arch/sh/include/asm/dma-mapping.h | 4 +-
arch/sh/kernel/dma-nommu.c | 4 +-
arch/sh/mm/consistent.c | 4 +-
arch/sparc/kernel/iommu.c | 12 +-
arch/sparc/kernel/ioport.c | 24 ++--
arch/sparc/kernel/pci_sun4v.c | 12 +-
arch/tile/kernel/pci-dma.c | 28 ++---
arch/unicore32/mm/dma-swiotlb.c | 4 +-
arch/x86/include/asm/dma-mapping.h | 5 +-
arch/x86/include/asm/swiotlb.h | 4 +-
arch/x86/include/asm/xen/page-coherent.h | 9 +-
arch/x86/kernel/amd_gart_64.c | 20 ++--
arch/x86/kernel/pci-calgary_64.c | 14 +--
arch/x86/kernel/pci-dma.c | 4 +-
arch/x86/kernel/pci-nommu.c | 4 +-
arch/x86/kernel/pci-swiotlb.c | 4 +-
arch/x86/pci/sta2x11-fixup.c | 2 +-
arch/x86/pci/vmd.c | 16 +--
arch/xtensa/kernel/pci-dma.c | 12 +-
drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
drivers/gpu/drm/exynos/exynos_drm_g2d.c | 12 +-
drivers/gpu/drm/exynos/exynos_drm_gem.c | 20 ++--
drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 +-
drivers/gpu/drm/mediatek/mtk_drm_gem.c | 13 +--
drivers/gpu/drm/mediatek/mtk_drm_gem.h | 2 +-
drivers/gpu/drm/msm/msm_drv.c | 13 +--
.../gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 13 +--
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++-
drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 2 +-
drivers/infiniband/core/umem.c | 7 +-
drivers/iommu/amd_iommu.c | 12 +-
drivers/iommu/dma-iommu.c | 8 +-
drivers/iommu/intel-iommu.c | 12 +-
drivers/media/platform/sti/bdisp/bdisp-hw.c | 26 ++---
drivers/media/v4l2-core/videobuf2-dma-contig.c | 30 ++---
drivers/media/v4l2-core/videobuf2-dma-sg.c | 19 +--
drivers/misc/mic/host/mic_boot.c | 20 ++--
drivers/parisc/ccio-dma.c | 16 +--
drivers/parisc/sba_iommu.c | 16 +--
drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 12 +-
drivers/video/fbdev/omap2/omapfb/omapfb.h | 3 +-
drivers/xen/swiotlb-xen.c | 14 +--
include/linux/dma-attrs.h | 71 ------------
include/linux/dma-iommu.h | 6 +-
include/linux/dma-mapping.h | 128 ++++++++++++++-------
include/linux/swiotlb.h | 10 +-
include/media/videobuf2-dma-contig.h | 7 +-
include/rdma/ib_verbs.h | 8 +-
include/xen/swiotlb-xen.h | 12 +-
lib/dma-noop.c | 9 +-
lib/swiotlb.c | 13 ++-
108 files changed, 689 insertions(+), 789 deletions(-)
delete mode 100644 include/linux/dma-attrs.h
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 18/44] [media] dma-mapping: Use unsigned long for dma_attrs
[not found] ` <1467275171-6298-1-git-send-email-k.kozlowski@samsung.com>
@ 2016-06-30 8:25 ` Krzysztof Kozlowski
2016-06-30 9:48 ` Marek Szyprowski
2016-06-30 8:26 ` [PATCH v5 43/44] dma-mapping: Remove dma_get_attr Krzysztof Kozlowski
1 sibling, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-30 8:25 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, hch, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz,
Fabien Dessenne, Mauro Carvalho Chehab, Pawel Osciak,
Marek Szyprowski, Kyungmin Park, linux-media
Split out subsystem specific changes for easier reviews. This will be
squashed with main commit.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[for bdisp]
Acked-by: Fabien Dessenne <fabien.dessenne@st.com>
---
drivers/media/platform/sti/bdisp/bdisp-hw.c | 26 +++++++---------------
drivers/media/v4l2-core/videobuf2-dma-contig.c | 30 +++++++++++---------------
drivers/media/v4l2-core/videobuf2-dma-sg.c | 19 ++++------------
include/media/videobuf2-dma-contig.h | 7 ++----
4 files changed, 26 insertions(+), 56 deletions(-)
diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c
index 052c932ac942..d86ba40eec8d 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
@@ -125,14 +125,11 @@ int bdisp_hw_get_and_clear_irq(struct bdisp_dev *bdisp)
*/
void bdisp_hw_free_nodes(struct bdisp_ctx *ctx)
{
- if (ctx && ctx->node[0]) {
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
+ if (ctx && ctx->node[0])
dma_free_attrs(ctx->bdisp_dev->dev,
sizeof(struct bdisp_node) * MAX_NB_NODE,
- ctx->node[0], ctx->node_paddr[0], &attrs);
- }
+ ctx->node[0], ctx->node_paddr[0],
+ DMA_ATTR_WRITE_COMBINE);
}
/**
@@ -150,12 +147,10 @@ int bdisp_hw_alloc_nodes(struct bdisp_ctx *ctx)
unsigned int i, node_size = sizeof(struct bdisp_node);
void *base;
dma_addr_t paddr;
- DEFINE_DMA_ATTRS(attrs);
/* Allocate all the nodes within a single memory page */
- dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
base = dma_alloc_attrs(dev, node_size * MAX_NB_NODE, &paddr,
- GFP_KERNEL | GFP_DMA, &attrs);
+ GFP_KERNEL | GFP_DMA, DMA_ATTR_WRITE_COMBINE);
if (!base) {
dev_err(dev, "%s no mem\n", __func__);
return -ENOMEM;
@@ -188,13 +183,9 @@ void bdisp_hw_free_filters(struct device *dev)
{
int size = (BDISP_HF_NB * NB_H_FILTER) + (BDISP_VF_NB * NB_V_FILTER);
- if (bdisp_h_filter[0].virt) {
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
+ if (bdisp_h_filter[0].virt)
dma_free_attrs(dev, size, bdisp_h_filter[0].virt,
- bdisp_h_filter[0].paddr, &attrs);
- }
+ bdisp_h_filter[0].paddr, DMA_ATTR_WRITE_COMBINE);
}
/**
@@ -211,12 +202,11 @@ int bdisp_hw_alloc_filters(struct device *dev)
unsigned int i, size;
void *base;
dma_addr_t paddr;
- DEFINE_DMA_ATTRS(attrs);
/* Allocate all the filters within a single memory page */
size = (BDISP_HF_NB * NB_H_FILTER) + (BDISP_VF_NB * NB_V_FILTER);
- dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
- base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA, &attrs);
+ base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
+ DMA_ATTR_WRITE_COMBINE);
if (!base)
return -ENOMEM;
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 5361197f3e57..8009a582326b 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -23,7 +23,7 @@
struct vb2_dc_conf {
struct device *dev;
- struct dma_attrs attrs;
+ unsigned long attrs;
};
struct vb2_dc_buf {
@@ -32,7 +32,7 @@ struct vb2_dc_buf {
unsigned long size;
void *cookie;
dma_addr_t dma_addr;
- struct dma_attrs attrs;
+ unsigned long attrs;
enum dma_data_direction dma_dir;
struct sg_table *dma_sgt;
struct frame_vector *vec;
@@ -135,7 +135,7 @@ static void vb2_dc_put(void *buf_priv)
kfree(buf->sgt_base);
}
dma_free_attrs(buf->dev, buf->size, buf->cookie, buf->dma_addr,
- &buf->attrs);
+ buf->attrs);
put_device(buf->dev);
kfree(buf);
}
@@ -153,14 +153,14 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
buf->attrs = conf->attrs;
buf->cookie = dma_alloc_attrs(dev, size, &buf->dma_addr,
- GFP_KERNEL | gfp_flags, &buf->attrs);
+ GFP_KERNEL | gfp_flags, buf->attrs);
if (!buf->cookie) {
dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
kfree(buf);
return ERR_PTR(-ENOMEM);
}
- if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->attrs))
+ if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, buf->attrs))
buf->vaddr = buf->cookie;
/* Prevent the device from being released while the buffer is used */
@@ -194,7 +194,7 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
vma->vm_pgoff = 0;
ret = dma_mmap_attrs(buf->dev, vma, buf->cookie,
- buf->dma_addr, buf->size, &buf->attrs);
+ buf->dma_addr, buf->size, buf->attrs);
if (ret) {
pr_err("Remapping memory failed, error: %d\n", ret);
@@ -377,7 +377,7 @@ static struct sg_table *vb2_dc_get_base_sgt(struct vb2_dc_buf *buf)
}
ret = dma_get_sgtable_attrs(buf->dev, sgt, buf->cookie, buf->dma_addr,
- buf->size, &buf->attrs);
+ buf->size, buf->attrs);
if (ret < 0) {
dev_err(buf->dev, "failed to get scatterlist from DMA API\n");
kfree(sgt);
@@ -426,15 +426,12 @@ static void vb2_dc_put_userptr(void *buf_priv)
struct page **pages;
if (sgt) {
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
/*
* No need to sync to CPU, it's already synced to the CPU
* since the finish() memop will have been called before this.
*/
dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
pages = frame_vector_pages(buf->vec);
/* sgt should exist only if vector contains pages... */
BUG_ON(IS_ERR(pages));
@@ -490,9 +487,6 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
struct sg_table *sgt;
unsigned long contig_size;
unsigned long dma_align = dma_get_cache_alignment();
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
/* Only cache aligned DMA transfers are reliable */
if (!IS_ALIGNED(vaddr | size, dma_align)) {
@@ -554,7 +548,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
* prepare() memop is called.
*/
sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
if (sgt->nents <= 0) {
pr_err("failed to map scatterlist\n");
ret = -EIO;
@@ -578,7 +572,7 @@ out:
fail_map_sg:
dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
fail_sgt_init:
sg_free_table(sgt);
@@ -730,7 +724,7 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
- struct dma_attrs *attrs)
+ unsigned long attrs)
{
struct vb2_dc_conf *conf;
@@ -740,7 +734,7 @@ void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
conf->dev = dev;
if (attrs)
- conf->attrs = *attrs;
+ conf->attrs = attrs;
return conf;
}
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 9985c89f0513..94f24e610fe7 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -107,9 +107,6 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
struct sg_table *sgt;
int ret;
int num_pages;
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
if (WARN_ON(alloc_ctx == NULL))
return NULL;
@@ -148,7 +145,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
* prepare() memop is called.
*/
sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
if (!sgt->nents)
goto fail_map;
@@ -183,13 +180,10 @@ static void vb2_dma_sg_put(void *buf_priv)
int i = buf->num_pages;
if (atomic_dec_and_test(&buf->refcount)) {
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
dprintk(1, "%s: Freeing buffer of %d pages\n", __func__,
buf->num_pages);
dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
if (buf->vaddr)
vm_unmap_ram(buf->vaddr, buf->num_pages);
sg_free_table(buf->dma_sgt);
@@ -233,10 +227,8 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
struct vb2_dma_sg_conf *conf = alloc_ctx;
struct vb2_dma_sg_buf *buf;
struct sg_table *sgt;
- DEFINE_DMA_ATTRS(attrs);
struct frame_vector *vec;
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
buf = kzalloc(sizeof *buf, GFP_KERNEL);
if (!buf)
return NULL;
@@ -267,7 +259,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
* prepare() memop is called.
*/
sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir, &attrs);
+ buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
if (!sgt->nents)
goto userptr_fail_map;
@@ -291,14 +283,11 @@ static void vb2_dma_sg_put_userptr(void *buf_priv)
struct vb2_dma_sg_buf *buf = buf_priv;
struct sg_table *sgt = &buf->sg_table;
int i = buf->num_pages;
- DEFINE_DMA_ATTRS(attrs);
-
- dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
dprintk(1, "%s: Releasing userspace buffer of %d pages\n",
__func__, buf->num_pages);
dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir,
- &attrs);
+ DMA_ATTR_SKIP_CPU_SYNC);
if (buf->vaddr)
vm_unmap_ram(buf->vaddr, buf->num_pages);
sg_free_table(buf->dma_sgt);
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
index 2087c9a68be3..048df1320451 100644
--- a/include/media/videobuf2-dma-contig.h
+++ b/include/media/videobuf2-dma-contig.h
@@ -16,8 +16,6 @@
#include <media/videobuf2-v4l2.h>
#include <linux/dma-mapping.h>
-struct dma_attrs;
-
static inline dma_addr_t
vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
{
@@ -26,12 +24,11 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
return *addr;
}
-void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
- struct dma_attrs *attrs);
+void *vb2_dma_contig_init_ctx_attrs(struct device *dev, unsigned long attrs);
static inline void *vb2_dma_contig_init_ctx(struct device *dev)
{
- return vb2_dma_contig_init_ctx_attrs(dev, NULL);
+ return vb2_dma_contig_init_ctx_attrs(dev, 0);
}
void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v5 43/44] dma-mapping: Remove dma_get_attr
[not found] ` <1467275171-6298-1-git-send-email-k.kozlowski@samsung.com>
2016-06-30 8:25 ` [PATCH v5 18/44] [media] " Krzysztof Kozlowski
@ 2016-06-30 8:26 ` Krzysztof Kozlowski
1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-30 8:26 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, hch, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz,
Jonathan Corbet, Vineet Gupta, Russell King, Stefano Stabellini,
Catalin Marinas, Will Deacon, Haavard Skinnemoen,
Hans-Christian Egtvedt, Tony Luck, Fenghua Yu, James Hogan,
Ralf Baechle, Jonas Bonn, James E.J. Bottomley, Helge Deller,
Arnd Bergmann, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Mark Yao, David Airlie, Heiko Stuebner,
Joerg Roedel, Pawel Osciak, Marek Szyprowski, Kyungmin Park,
Mauro Carvalho Chehab, linux-doc, linux-snps-arc,
linux-arm-kernel, xen-devel, linux-ia64, linux-metag, linux-mips,
linux-parisc, linuxppc-dev, dri-devel, linux-rockchip, iommu,
linux-media
After switching DMA attributes to unsigned long it is easier to just
compare the bits.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[for avr32]
Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>
[for arc]
Acked-by: Vineet Gupta <vgupta@synopsys.com>
[for arm64 and dma-iommu]
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
Documentation/DMA-API.txt | 4 +--
arch/arc/mm/dma.c | 4 +--
arch/arm/mm/dma-mapping.c | 36 ++++++++++++--------------
arch/arm/xen/mm.c | 4 +--
arch/arm64/mm/dma-mapping.c | 10 +++----
arch/avr32/mm/dma-coherent.c | 4 +--
arch/ia64/sn/pci/pci_dma.c | 10 ++-----
arch/metag/kernel/dma.c | 2 +-
arch/mips/mm/dma-default.c | 6 ++---
arch/openrisc/kernel/dma.c | 4 +--
arch/parisc/kernel/pci-dma.c | 2 +-
arch/powerpc/platforms/cell/iommu.c | 12 ++++-----
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +-
drivers/iommu/dma-iommu.c | 2 +-
drivers/media/v4l2-core/videobuf2-dma-contig.c | 2 +-
include/linux/dma-mapping.h | 10 -------
16 files changed, 47 insertions(+), 67 deletions(-)
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 24f9688bb98a..1d26eeb6b5f6 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -422,9 +422,7 @@ void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr,
unsigned long attrs)
{
....
- int foo = dma_get_attr(DMA_ATTR_FOO, attrs);
- ....
- if (foo)
+ if (attrs & DMA_ATTR_FOO)
/* twizzle the frobnozzle */
....
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 3d1f467d1792..74bbe68dce9d 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -46,7 +46,7 @@ static void *arc_dma_alloc(struct device *dev, size_t size,
* (vs. always going to memory - thus are faster)
*/
if ((is_isa_arcv2() && ioc_exists) ||
- dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs))
+ (attrs & DMA_ATTR_NON_CONSISTENT))
need_coh = 0;
/*
@@ -95,7 +95,7 @@ static void arc_dma_free(struct device *dev, size_t size, void *vaddr,
struct page *page = virt_to_page(dma_handle);
int is_non_coh = 1;
- is_non_coh = dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs) ||
+ is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT) ||
(is_isa_arcv2() && ioc_exists);
if (PageHighMem(page) || !is_non_coh)
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index ebb3fde99043..43e03b5293d0 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -126,7 +126,7 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_cpu_to_dev(page, offset, size, dir);
return pfn_to_dma(dev, page_to_pfn(page)) + offset;
}
@@ -155,7 +155,7 @@ static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *pag
static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, unsigned long attrs)
{
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
handle & ~PAGE_MASK, size, dir);
}
@@ -622,9 +622,9 @@ static void __free_from_contiguous(struct device *dev, struct page *page,
static inline pgprot_t __get_dma_pgprot(unsigned long attrs, pgprot_t prot)
{
- prot = dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs) ?
- pgprot_writecombine(prot) :
- pgprot_dmacoherent(prot);
+ prot = (attrs & DMA_ATTR_WRITE_COMBINE) ?
+ pgprot_writecombine(prot) :
+ pgprot_dmacoherent(prot);
return prot;
}
@@ -744,7 +744,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
.gfp = gfp,
.prot = prot,
.caller = caller,
- .want_vaddr = !dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs),
+ .want_vaddr = ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0),
};
#ifdef CONFIG_DMA_API_DEBUG
@@ -887,7 +887,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
.size = PAGE_ALIGN(size),
.cpu_addr = cpu_addr,
.page = page,
- .want_vaddr = !dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs),
+ .want_vaddr = ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0),
};
buf = arm_dma_buffer_find(cpu_addr);
@@ -1267,7 +1267,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
if (!pages)
return NULL;
- if (dma_get_attr(DMA_ATTR_FORCE_CONTIGUOUS, attrs))
+ if (attrs & DMA_ATTR_FORCE_CONTIGUOUS)
{
unsigned long order = get_order(size);
struct page *page;
@@ -1285,7 +1285,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
}
/* Go straight to 4K chunks if caller says it's OK. */
- if (dma_get_attr(DMA_ATTR_ALLOC_SINGLE_PAGES, attrs))
+ if (attrs & DMA_ATTR_ALLOC_SINGLE_PAGES)
order_idx = ARRAY_SIZE(iommu_order_array) - 1;
/*
@@ -1346,7 +1346,7 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages,
int count = size >> PAGE_SHIFT;
int i;
- if (dma_get_attr(DMA_ATTR_FORCE_CONTIGUOUS, attrs)) {
+ if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
dma_release_from_contiguous(dev, pages[0], count);
} else {
for (i = 0; i < count; i++)
@@ -1445,7 +1445,7 @@ static struct page **__iommu_get_pages(void *cpu_addr, unsigned long attrs)
if (__in_atomic_pool(cpu_addr, PAGE_SIZE))
return __atomic_get_pages(cpu_addr);
- if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
+ if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
return cpu_addr;
area = find_vm_area(cpu_addr);
@@ -1512,7 +1512,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
if (*handle == DMA_ERROR_CODE)
goto err_buffer;
- if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
+ if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
return pages;
addr = __iommu_alloc_remap(pages, size, gfp, prot,
@@ -1583,7 +1583,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
return;
}
- if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) {
+ if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0) {
dma_common_free_remap(cpu_addr, size,
VM_ARM_DMA_CONSISTENT | VM_USERMAP);
}
@@ -1653,8 +1653,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
phys_addr_t phys = page_to_phys(sg_page(s));
unsigned int len = PAGE_ALIGN(s->offset + s->length);
- if (!is_coherent &&
- !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if (!is_coherent && (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
prot = __dma_direction_to_prot(dir);
@@ -1767,8 +1766,7 @@ static void __iommu_unmap_sg(struct device *dev, struct scatterlist *sg,
if (sg_dma_len(s))
__iommu_remove_mapping(dev, sg_dma_address(s),
sg_dma_len(s));
- if (!is_coherent &&
- !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if (!is_coherent && (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_dev_to_cpu(sg_page(s), s->offset,
s->length, dir);
}
@@ -1892,7 +1890,7 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_cpu_to_dev(page, offset, size, dir);
return arm_coherent_iommu_map_page(dev, page, offset, size, dir, attrs);
@@ -1943,7 +1941,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
if (!iova)
return;
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_dev_to_cpu(page, offset, size, dir);
iommu_unmap(mapping->domain, iova, len);
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index fc67ed236a10..d062f08f5020 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -102,7 +102,7 @@ void __xen_dma_map_page(struct device *hwdev, struct page *page,
{
if (is_device_dma_coherent(hwdev))
return;
- if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
return;
__xen_dma_page_cpu_to_dev(hwdev, dev_addr, size, dir);
@@ -115,7 +115,7 @@ void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
{
if (is_device_dma_coherent(hwdev))
return;
- if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
return;
__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 65f69943b1cb..e82763af137f 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -32,7 +32,7 @@
static pgprot_t __get_dma_pgprot(unsigned long attrs, pgprot_t prot,
bool coherent)
{
- if (!coherent || dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs))
+ if (!coherent || (attrs & DMA_ATTR_WRITE_COMBINE))
return pgprot_writecombine(prot);
return prot;
}
@@ -701,7 +701,7 @@ static dma_addr_t __iommu_map_page(struct device *dev, struct page *page,
dma_addr_t dev_addr = iommu_dma_map_page(dev, page, offset, size, prot);
if (!iommu_dma_mapping_error(dev, dev_addr) &&
- !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__iommu_sync_single_for_device(dev, dev_addr, size, dir);
return dev_addr;
@@ -711,7 +711,7 @@ static void __iommu_unmap_page(struct device *dev, dma_addr_t dev_addr,
size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__iommu_sync_single_for_cpu(dev, dev_addr, size, dir);
iommu_dma_unmap_page(dev, dev_addr, size, dir, attrs);
@@ -751,7 +751,7 @@ static int __iommu_map_sg_attrs(struct device *dev, struct scatterlist *sgl,
{
bool coherent = is_device_dma_coherent(dev);
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__iommu_sync_sg_for_device(dev, sgl, nelems, dir);
return iommu_dma_map_sg(dev, sgl, nelems,
@@ -763,7 +763,7 @@ static void __iommu_unmap_sg_attrs(struct device *dev,
enum dma_data_direction dir,
unsigned long attrs)
{
- if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+ if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__iommu_sync_sg_for_cpu(dev, sgl, nelems, dir);
iommu_dma_unmap_sg(dev, sgl, nelems, dir, attrs);
diff --git a/arch/avr32/mm/dma-coherent.c b/arch/avr32/mm/dma-coherent.c
index fc51f4421933..58610d0df7ed 100644
--- a/arch/avr32/mm/dma-coherent.c
+++ b/arch/avr32/mm/dma-coherent.c
@@ -109,7 +109,7 @@ static void *avr32_dma_alloc(struct device *dev, size_t size,
return NULL;
phys = page_to_phys(page);
- if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs)) {
+ if (attrs & DMA_ATTR_WRITE_COMBINE) {
/* Now, map the page into P3 with write-combining turned on */
*handle = phys;
return __ioremap(phys, size, _PAGE_BUFFER);
@@ -123,7 +123,7 @@ static void avr32_dma_free(struct device *dev, size_t size,
{
struct page *page;
- if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs)) {
+ if (attrs & DMA_ATTR_WRITE_COMBINE) {
iounmap(cpu_addr);
page = phys_to_page(handle);
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 6b78fc953c4b..74c934a997bb 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -183,14 +183,11 @@ static dma_addr_t sn_dma_map_page(struct device *dev, struct page *page,
unsigned long phys_addr;
struct pci_dev *pdev = to_pci_dev(dev);
struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
- int dmabarr;
-
- dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs);
BUG_ON(!dev_is_pci(dev));
phys_addr = __pa(cpu_addr);
- if (dmabarr)
+ if (attrs & DMA_ATTR_WRITE_BARRIER)
dma_addr = provider->dma_map_consistent(pdev, phys_addr,
size, SN_DMA_ADDR_PHYS);
else
@@ -280,9 +277,6 @@ static int sn_dma_map_sg(struct device *dev, struct scatterlist *sgl,
struct pci_dev *pdev = to_pci_dev(dev);
struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
int i;
- int dmabarr;
-
- dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs);
BUG_ON(!dev_is_pci(dev));
@@ -292,7 +286,7 @@ static int sn_dma_map_sg(struct device *dev, struct scatterlist *sgl,
for_each_sg(sgl, sg, nhwentries, i) {
dma_addr_t dma_addr;
phys_addr = SG_ENT_PHYS_ADDRESS(sg);
- if (dmabarr)
+ if (attrs & DMA_ATTR_WRITE_BARRIER)
dma_addr = provider->dma_map_consistent(pdev,
phys_addr,
sg->length,
diff --git a/arch/metag/kernel/dma.c b/arch/metag/kernel/dma.c
index d68f498e82a1..0db31e24c541 100644
--- a/arch/metag/kernel/dma.c
+++ b/arch/metag/kernel/dma.c
@@ -337,7 +337,7 @@ static int metag_dma_mmap(struct device *dev, struct vm_area_struct *vma,
struct metag_vm_region *c;
int ret = -ENXIO;
- if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs))
+ if (attrs & DMA_ATTR_WRITE_COMBINE)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 0ed9000dc1ff..b2eadd6fa9a1 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -141,7 +141,7 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
* XXX: seems like the coherent and non-coherent implementations could
* be consolidated.
*/
- if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs))
+ if (attrs & DMA_ATTR_NON_CONSISTENT)
return mips_dma_alloc_noncoherent(dev, size, dma_handle, gfp);
gfp = massage_gfp_flags(dev, gfp);
@@ -182,7 +182,7 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
struct page *page = NULL;
- if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
+ if (attrs & DMA_ATTR_NON_CONSISTENT) {
mips_dma_free_noncoherent(dev, size, vaddr, dma_handle);
return;
}
@@ -214,7 +214,7 @@ static int mips_dma_mmap(struct device *dev, struct vm_area_struct *vma,
pfn = page_to_pfn(virt_to_page((void *)addr));
- if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs))
+ if (attrs & DMA_ATTR_WRITE_COMBINE)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
index 50eb1f26c540..140c99140649 100644
--- a/arch/openrisc/kernel/dma.c
+++ b/arch/openrisc/kernel/dma.c
@@ -100,7 +100,7 @@ or1k_dma_alloc(struct device *dev, size_t size,
va = (unsigned long)page;
- if (!dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
+ if ((attrs & DMA_ATTR_NON_CONSISTENT) == 0) {
/*
* We need to iterate through the pages, clearing the dcache for
* them and setting the cache-inhibit bit.
@@ -124,7 +124,7 @@ or1k_dma_free(struct device *dev, size_t size, void *vaddr,
.mm = &init_mm
};
- if (!dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
+ if ((attrs & DMA_ATTR_NON_CONSISTENT) == 0) {
/* walk_page_range shouldn't be able to fail here */
WARN_ON(walk_page_range(va, va + size, &walk));
}
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 845fdd52e4c5..02d9ed0f3949 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -581,7 +581,7 @@ static void *pcx_dma_alloc(struct device *dev, size_t size,
{
void *addr;
- if (!dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs))
+ if ((attrs & DMA_ATTR_NON_CONSISTENT) == 0)
return NULL;
addr = (void *)__get_free_pages(flag, get_order(size));
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index c8e11e020335..6128bdb428b2 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -193,7 +193,7 @@ static int tce_build_cell(struct iommu_table *tbl, long index, long npages,
base_pte = CBE_IOPTE_PP_W | CBE_IOPTE_PP_R | CBE_IOPTE_M |
CBE_IOPTE_SO_RW | (window->ioid & CBE_IOPTE_IOID_Mask);
#endif
- if (unlikely(dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs)))
+ if (unlikely(attrs & DMA_ATTR_WEAK_ORDERING))
base_pte &= ~CBE_IOPTE_SO_RW;
io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
@@ -600,7 +600,7 @@ static dma_addr_t dma_fixed_map_page(struct device *dev, struct page *page,
enum dma_data_direction direction,
unsigned long attrs)
{
- if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+ if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING))
return dma_direct_ops.map_page(dev, page, offset, size,
direction, attrs);
else
@@ -613,7 +613,7 @@ static void dma_fixed_unmap_page(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction direction,
unsigned long attrs)
{
- if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+ if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING))
dma_direct_ops.unmap_page(dev, dma_addr, size, direction,
attrs);
else
@@ -625,7 +625,7 @@ static int dma_fixed_map_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction direction,
unsigned long attrs)
{
- if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+ if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING))
return dma_direct_ops.map_sg(dev, sg, nents, direction, attrs);
else
return ppc_iommu_map_sg(dev, cell_get_iommu_table(dev), sg,
@@ -637,7 +637,7 @@ static void dma_fixed_unmap_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction direction,
unsigned long attrs)
{
- if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+ if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING))
dma_direct_ops.unmap_sg(dev, sg, nents, direction, attrs);
else
ppc_iommu_unmap_sg(cell_get_iommu_table(dev), sg, nents,
@@ -1162,7 +1162,7 @@ static int __init setup_iommu_fixed(char *str)
pciep = of_find_node_by_type(NULL, "pcie-endpoint");
if (strcmp(str, "weak") == 0 || (pciep && strcmp(str, "strong") != 0))
- iommu_fixed_is_weak = 1;
+ iommu_fixed_is_weak = DMA_ATTR_WEAK_ORDERING;
of_node_put(pciep);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 7b1788e2a808..4a28d6348c76 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -273,7 +273,7 @@ void *rockchip_gem_prime_vmap(struct drm_gem_object *obj)
{
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
- if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, rk_obj->dma_attrs))
+ if (rk_obj->dma_attrs & DMA_ATTR_NO_KERNEL_MAPPING)
return NULL;
return rk_obj->kvaddr;
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 6c1bda504fb1..08a1e2f3690f 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -306,7 +306,7 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp,
} else {
size = ALIGN(size, min_size);
}
- if (dma_get_attr(DMA_ATTR_ALLOC_SINGLE_PAGES, attrs))
+ if (attrs & DMA_ATTR_ALLOC_SINGLE_PAGES)
alloc_sizes = min_size;
count = PAGE_ALIGN(size) >> PAGE_SHIFT;
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 8009a582326b..d2ab541614b8 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -160,7 +160,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
return ERR_PTR(-ENOMEM);
}
- if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, buf->attrs))
+ if ((buf->attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0)
buf->vaddr = buf->cookie;
/* Prevent the device from being released while the buffer is used */
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 1fd9860487b1..d8fb67783cb7 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -101,16 +101,6 @@ static inline int is_device_dma_capable(struct device *dev)
return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
}
-/**
- * dma_get_attr - check for a specific attribute
- * @attr: attribute to look for
- * @attrs: attributes to check within
- */
-static inline bool dma_get_attr(unsigned long attr, unsigned long attrs)
-{
- return !!(attr & attrs);
-}
-
#ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
/*
* These three functions are only for dma allocator.
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v5 18/44] [media] dma-mapping: Use unsigned long for dma_attrs
2016-06-30 8:25 ` [PATCH v5 18/44] [media] " Krzysztof Kozlowski
@ 2016-06-30 9:48 ` Marek Szyprowski
0 siblings, 0 replies; 6+ messages in thread
From: Marek Szyprowski @ 2016-06-30 9:48 UTC (permalink / raw)
To: Krzysztof Kozlowski, Andrew Morton
Cc: linux-kernel, hch, Bartlomiej Zolnierkiewicz, Fabien Dessenne,
Mauro Carvalho Chehab, Pawel Osciak, Kyungmin Park, linux-media,
Hans Verkuil
Hello,
On 2016-06-30 10:25, Krzysztof Kozlowski wrote:
> Split out subsystem specific changes for easier reviews. This will be
> squashed with main commit.
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[for vb2-core]
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Please note that vb2 code is being modified now by Hans Verkuil, who is
working on complete removal of allocator contexts from vb2 queue.
You can check his patches here:
https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=context3
> [for bdisp]
> Acked-by: Fabien Dessenne <fabien.dessenne@st.com>
> ---
> drivers/media/platform/sti/bdisp/bdisp-hw.c | 26 +++++++---------------
> drivers/media/v4l2-core/videobuf2-dma-contig.c | 30 +++++++++++---------------
> drivers/media/v4l2-core/videobuf2-dma-sg.c | 19 ++++------------
> include/media/videobuf2-dma-contig.h | 7 ++----
> 4 files changed, 26 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index 052c932ac942..d86ba40eec8d 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -125,14 +125,11 @@ int bdisp_hw_get_and_clear_irq(struct bdisp_dev *bdisp)
> */
> void bdisp_hw_free_nodes(struct bdisp_ctx *ctx)
> {
> - if (ctx && ctx->node[0]) {
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
> + if (ctx && ctx->node[0])
> dma_free_attrs(ctx->bdisp_dev->dev,
> sizeof(struct bdisp_node) * MAX_NB_NODE,
> - ctx->node[0], ctx->node_paddr[0], &attrs);
> - }
> + ctx->node[0], ctx->node_paddr[0],
> + DMA_ATTR_WRITE_COMBINE);
> }
>
> /**
> @@ -150,12 +147,10 @@ int bdisp_hw_alloc_nodes(struct bdisp_ctx *ctx)
> unsigned int i, node_size = sizeof(struct bdisp_node);
> void *base;
> dma_addr_t paddr;
> - DEFINE_DMA_ATTRS(attrs);
>
> /* Allocate all the nodes within a single memory page */
> - dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
> base = dma_alloc_attrs(dev, node_size * MAX_NB_NODE, &paddr,
> - GFP_KERNEL | GFP_DMA, &attrs);
> + GFP_KERNEL | GFP_DMA, DMA_ATTR_WRITE_COMBINE);
> if (!base) {
> dev_err(dev, "%s no mem\n", __func__);
> return -ENOMEM;
> @@ -188,13 +183,9 @@ void bdisp_hw_free_filters(struct device *dev)
> {
> int size = (BDISP_HF_NB * NB_H_FILTER) + (BDISP_VF_NB * NB_V_FILTER);
>
> - if (bdisp_h_filter[0].virt) {
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
> + if (bdisp_h_filter[0].virt)
> dma_free_attrs(dev, size, bdisp_h_filter[0].virt,
> - bdisp_h_filter[0].paddr, &attrs);
> - }
> + bdisp_h_filter[0].paddr, DMA_ATTR_WRITE_COMBINE);
> }
>
> /**
> @@ -211,12 +202,11 @@ int bdisp_hw_alloc_filters(struct device *dev)
> unsigned int i, size;
> void *base;
> dma_addr_t paddr;
> - DEFINE_DMA_ATTRS(attrs);
>
> /* Allocate all the filters within a single memory page */
> size = (BDISP_HF_NB * NB_H_FILTER) + (BDISP_VF_NB * NB_V_FILTER);
> - dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
> - base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA, &attrs);
> + base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
> + DMA_ATTR_WRITE_COMBINE);
> if (!base)
> return -ENOMEM;
>
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> index 5361197f3e57..8009a582326b 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> @@ -23,7 +23,7 @@
>
> struct vb2_dc_conf {
> struct device *dev;
> - struct dma_attrs attrs;
> + unsigned long attrs;
> };
>
> struct vb2_dc_buf {
> @@ -32,7 +32,7 @@ struct vb2_dc_buf {
> unsigned long size;
> void *cookie;
> dma_addr_t dma_addr;
> - struct dma_attrs attrs;
> + unsigned long attrs;
> enum dma_data_direction dma_dir;
> struct sg_table *dma_sgt;
> struct frame_vector *vec;
> @@ -135,7 +135,7 @@ static void vb2_dc_put(void *buf_priv)
> kfree(buf->sgt_base);
> }
> dma_free_attrs(buf->dev, buf->size, buf->cookie, buf->dma_addr,
> - &buf->attrs);
> + buf->attrs);
> put_device(buf->dev);
> kfree(buf);
> }
> @@ -153,14 +153,14 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
>
> buf->attrs = conf->attrs;
> buf->cookie = dma_alloc_attrs(dev, size, &buf->dma_addr,
> - GFP_KERNEL | gfp_flags, &buf->attrs);
> + GFP_KERNEL | gfp_flags, buf->attrs);
> if (!buf->cookie) {
> dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
> kfree(buf);
> return ERR_PTR(-ENOMEM);
> }
>
> - if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->attrs))
> + if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, buf->attrs))
> buf->vaddr = buf->cookie;
>
> /* Prevent the device from being released while the buffer is used */
> @@ -194,7 +194,7 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
> vma->vm_pgoff = 0;
>
> ret = dma_mmap_attrs(buf->dev, vma, buf->cookie,
> - buf->dma_addr, buf->size, &buf->attrs);
> + buf->dma_addr, buf->size, buf->attrs);
>
> if (ret) {
> pr_err("Remapping memory failed, error: %d\n", ret);
> @@ -377,7 +377,7 @@ static struct sg_table *vb2_dc_get_base_sgt(struct vb2_dc_buf *buf)
> }
>
> ret = dma_get_sgtable_attrs(buf->dev, sgt, buf->cookie, buf->dma_addr,
> - buf->size, &buf->attrs);
> + buf->size, buf->attrs);
> if (ret < 0) {
> dev_err(buf->dev, "failed to get scatterlist from DMA API\n");
> kfree(sgt);
> @@ -426,15 +426,12 @@ static void vb2_dc_put_userptr(void *buf_priv)
> struct page **pages;
>
> if (sgt) {
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
> /*
> * No need to sync to CPU, it's already synced to the CPU
> * since the finish() memop will have been called before this.
> */
> dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
> pages = frame_vector_pages(buf->vec);
> /* sgt should exist only if vector contains pages... */
> BUG_ON(IS_ERR(pages));
> @@ -490,9 +487,6 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
> struct sg_table *sgt;
> unsigned long contig_size;
> unsigned long dma_align = dma_get_cache_alignment();
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
>
> /* Only cache aligned DMA transfers are reliable */
> if (!IS_ALIGNED(vaddr | size, dma_align)) {
> @@ -554,7 +548,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
> * prepare() memop is called.
> */
> sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
> if (sgt->nents <= 0) {
> pr_err("failed to map scatterlist\n");
> ret = -EIO;
> @@ -578,7 +572,7 @@ out:
>
> fail_map_sg:
> dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
>
> fail_sgt_init:
> sg_free_table(sgt);
> @@ -730,7 +724,7 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
> EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
>
> void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
> - struct dma_attrs *attrs)
> + unsigned long attrs)
> {
> struct vb2_dc_conf *conf;
>
> @@ -740,7 +734,7 @@ void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
>
> conf->dev = dev;
> if (attrs)
> - conf->attrs = *attrs;
> + conf->attrs = attrs;
>
> return conf;
> }
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
> index 9985c89f0513..94f24e610fe7 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
> @@ -107,9 +107,6 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
> struct sg_table *sgt;
> int ret;
> int num_pages;
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
>
> if (WARN_ON(alloc_ctx == NULL))
> return NULL;
> @@ -148,7 +145,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
> * prepare() memop is called.
> */
> sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
> if (!sgt->nents)
> goto fail_map;
>
> @@ -183,13 +180,10 @@ static void vb2_dma_sg_put(void *buf_priv)
> int i = buf->num_pages;
>
> if (atomic_dec_and_test(&buf->refcount)) {
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
> dprintk(1, "%s: Freeing buffer of %d pages\n", __func__,
> buf->num_pages);
> dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
> if (buf->vaddr)
> vm_unmap_ram(buf->vaddr, buf->num_pages);
> sg_free_table(buf->dma_sgt);
> @@ -233,10 +227,8 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
> struct vb2_dma_sg_conf *conf = alloc_ctx;
> struct vb2_dma_sg_buf *buf;
> struct sg_table *sgt;
> - DEFINE_DMA_ATTRS(attrs);
> struct frame_vector *vec;
>
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
> buf = kzalloc(sizeof *buf, GFP_KERNEL);
> if (!buf)
> return NULL;
> @@ -267,7 +259,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
> * prepare() memop is called.
> */
> sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
> - buf->dma_dir, &attrs);
> + buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
> if (!sgt->nents)
> goto userptr_fail_map;
>
> @@ -291,14 +283,11 @@ static void vb2_dma_sg_put_userptr(void *buf_priv)
> struct vb2_dma_sg_buf *buf = buf_priv;
> struct sg_table *sgt = &buf->sg_table;
> int i = buf->num_pages;
> - DEFINE_DMA_ATTRS(attrs);
> -
> - dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs);
>
> dprintk(1, "%s: Releasing userspace buffer of %d pages\n",
> __func__, buf->num_pages);
> dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir,
> - &attrs);
> + DMA_ATTR_SKIP_CPU_SYNC);
> if (buf->vaddr)
> vm_unmap_ram(buf->vaddr, buf->num_pages);
> sg_free_table(buf->dma_sgt);
> diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
> index 2087c9a68be3..048df1320451 100644
> --- a/include/media/videobuf2-dma-contig.h
> +++ b/include/media/videobuf2-dma-contig.h
> @@ -16,8 +16,6 @@
> #include <media/videobuf2-v4l2.h>
> #include <linux/dma-mapping.h>
>
> -struct dma_attrs;
> -
> static inline dma_addr_t
> vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
> {
> @@ -26,12 +24,11 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
> return *addr;
> }
>
> -void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
> - struct dma_attrs *attrs);
> +void *vb2_dma_contig_init_ctx_attrs(struct device *dev, unsigned long attrs);
>
> static inline void *vb2_dma_contig_init_ctx(struct device *dev)
> {
> - return vb2_dma_contig_init_ctx_attrs(dev, NULL);
> + return vb2_dma_contig_init_ctx_attrs(dev, 0);
> }
>
> void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs
2016-06-30 8:23 [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs Krzysztof Kozlowski
[not found] ` <1467275171-6298-1-git-send-email-k.kozlowski@samsung.com>
@ 2016-07-12 12:16 ` Daniel Vetter
2016-07-12 12:19 ` Krzysztof Kozlowski
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2016-07-12 12:16 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Andrew Morton, linux-mips, linux-ia64, linux-doc, linux-pci,
linux-fbdev, dri-devel, sparclinux, linux-s390, linux-samsung-soc,
linux-c6x-dev, linux-rdma, linux-hexagon, linux-sh, hch,
linux-rockchip, nouveau, xen-devel, linux-snps-arc, linux-media,
linux-xtensa, Bartlomiej Zolnierkiewicz, linux-arm-msm,
linux-m68k, linux-mediatek, linux-omap, linux-metag,
linux-arm-kernel, linux-parisc, linux-cris-kernel, freedreno,
linux-kernel, iommu, linux-alpha, linuxppc-dev
On Thu, Jun 30, 2016 at 10:23:39AM +0200, Krzysztof Kozlowski wrote:
> Hi,
>
>
> This is fifth approach for replacing struct dma_attrs with unsigned
> long.
>
> The main patch (1/44) doing the change is split into many subpatches
> for easier review (2-42). They should be squashed together when
> applying.
For all the drm driver patches:
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Should I pull these in through drm-misc, or do you prefer to merge them
through a special topic branch (with everything else) instead on your own?
-Daniel
>
>
> Rebased on v4.7-rc5.
>
> For easier testing the patchset is available here:
> repo: https://github.com/krzk/linux
> branch: for-next/dma-attrs-const-v5
>
>
> Changes since v4
> ================
> 1. Collect some acks. Still need more.
> 2. Minor fixes pointed by Robin Murphy.
> 3. Applied changes from Bart Van Assche's comment.
> 4. More tests and builds (using https://www.kernel.org/pub/tools/crosstool/).
>
>
> Changes since v3
> ================
> 1. Collect some acks.
> 2. Drop wrong patch 1/45 ("powerpc: dma-mapping: Don't hard-code
> the value of DMA_ATTR_WEAK_ORDERING").
> 3. Minor fix pointed out by Michael Ellerman.
>
>
> Changes since v2
> ================
> 1. Follow Christoph Hellwig's comments (don't use BIT add
> documentation, remove dma_get_attr).
>
>
> Rationale
> =========
> The dma-mapping core and the implementations do not change the
> DMA attributes passed by pointer. Thus the pointer can point to const
> data. However the attributes do not have to be a bitfield. Instead
> unsigned long will do fine:
>
> 1. This is just simpler. Both in terms of reading the code and setting
> attributes. Instead of initializing local attributes on the stack
> and passing pointer to it to dma_set_attr(), just set the bits.
>
> 2. It brings safeness and checking for const correctness because the
> attributes are passed by value.
>
>
> Best regards,
> Krzysztof
>
>
> Krzysztof Kozlowski (44):
> dma-mapping: Use unsigned long for dma_attrs
> alpha: dma-mapping: Use unsigned long for dma_attrs
> arc: dma-mapping: Use unsigned long for dma_attrs
> ARM: dma-mapping: Use unsigned long for dma_attrs
> arm64: dma-mapping: Use unsigned long for dma_attrs
> avr32: dma-mapping: Use unsigned long for dma_attrs
> blackfin: dma-mapping: Use unsigned long for dma_attrs
> c6x: dma-mapping: Use unsigned long for dma_attrs
> cris: dma-mapping: Use unsigned long for dma_attrs
> frv: dma-mapping: Use unsigned long for dma_attrs
> drm/exynos: dma-mapping: Use unsigned long for dma_attrs
> drm/mediatek: dma-mapping: Use unsigned long for dma_attrs
> drm/msm: dma-mapping: Use unsigned long for dma_attrs
> drm/nouveau: dma-mapping: Use unsigned long for dma_attrs
> drm/rockship: dma-mapping: Use unsigned long for dma_attrs
> infiniband: dma-mapping: Use unsigned long for dma_attrs
> iommu: dma-mapping: Use unsigned long for dma_attrs
> [media] dma-mapping: Use unsigned long for dma_attrs
> xen: dma-mapping: Use unsigned long for dma_attrs
> swiotlb: dma-mapping: Use unsigned long for dma_attrs
> powerpc: dma-mapping: Use unsigned long for dma_attrs
> video: dma-mapping: Use unsigned long for dma_attrs
> x86: dma-mapping: Use unsigned long for dma_attrs
> iommu: intel: dma-mapping: Use unsigned long for dma_attrs
> h8300: dma-mapping: Use unsigned long for dma_attrs
> hexagon: dma-mapping: Use unsigned long for dma_attrs
> ia64: dma-mapping: Use unsigned long for dma_attrs
> m68k: dma-mapping: Use unsigned long for dma_attrs
> metag: dma-mapping: Use unsigned long for dma_attrs
> microblaze: dma-mapping: Use unsigned long for dma_attrs
> mips: dma-mapping: Use unsigned long for dma_attrs
> mn10300: dma-mapping: Use unsigned long for dma_attrs
> nios2: dma-mapping: Use unsigned long for dma_attrs
> openrisc: dma-mapping: Use unsigned long for dma_attrs
> parisc: dma-mapping: Use unsigned long for dma_attrs
> misc: mic: dma-mapping: Use unsigned long for dma_attrs
> s390: dma-mapping: Use unsigned long for dma_attrs
> sh: dma-mapping: Use unsigned long for dma_attrs
> sparc: dma-mapping: Use unsigned long for dma_attrs
> tile: dma-mapping: Use unsigned long for dma_attrs
> unicore32: dma-mapping: Use unsigned long for dma_attrs
> xtensa: dma-mapping: Use unsigned long for dma_attrs
> dma-mapping: Remove dma_get_attr
> dma-mapping: Document the DMA attributes next to the declaration
>
> Documentation/DMA-API.txt | 33 +++---
> Documentation/DMA-attributes.txt | 2 +-
> arch/alpha/include/asm/dma-mapping.h | 2 -
> arch/alpha/kernel/pci-noop.c | 2 +-
> arch/alpha/kernel/pci_iommu.c | 12 +-
> arch/arc/mm/dma.c | 12 +-
> arch/arm/common/dmabounce.c | 4 +-
> arch/arm/include/asm/dma-mapping.h | 13 +--
> arch/arm/include/asm/xen/page-coherent.h | 16 +--
> arch/arm/mm/dma-mapping.c | 117 +++++++++----------
> arch/arm/xen/mm.c | 8 +-
> arch/arm64/mm/dma-mapping.c | 66 +++++------
> arch/avr32/mm/dma-coherent.c | 12 +-
> arch/blackfin/kernel/dma-mapping.c | 8 +-
> arch/c6x/include/asm/dma-mapping.h | 4 +-
> arch/c6x/kernel/dma.c | 9 +-
> arch/c6x/mm/dma-coherent.c | 4 +-
> arch/cris/arch-v32/drivers/pci/dma.c | 9 +-
> arch/frv/mb93090-mb00/pci-dma-nommu.c | 8 +-
> arch/frv/mb93090-mb00/pci-dma.c | 9 +-
> arch/h8300/kernel/dma.c | 8 +-
> arch/hexagon/include/asm/dma-mapping.h | 1 -
> arch/hexagon/kernel/dma.c | 8 +-
> arch/ia64/hp/common/sba_iommu.c | 22 ++--
> arch/ia64/include/asm/machvec.h | 1 -
> arch/ia64/kernel/pci-swiotlb.c | 4 +-
> arch/ia64/sn/pci/pci_dma.c | 22 ++--
> arch/m68k/kernel/dma.c | 12 +-
> arch/metag/kernel/dma.c | 16 +--
> arch/microblaze/include/asm/dma-mapping.h | 1 -
> arch/microblaze/kernel/dma.c | 12 +-
> arch/mips/cavium-octeon/dma-octeon.c | 8 +-
> arch/mips/loongson64/common/dma-swiotlb.c | 10 +-
> arch/mips/mm/dma-default.c | 20 ++--
> arch/mips/netlogic/common/nlm-dma.c | 4 +-
> arch/mn10300/mm/dma-alloc.c | 8 +-
> arch/nios2/mm/dma-mapping.c | 12 +-
> arch/openrisc/kernel/dma.c | 21 ++--
> arch/parisc/kernel/pci-dma.c | 18 +--
> arch/powerpc/include/asm/dma-mapping.h | 7 +-
> arch/powerpc/include/asm/iommu.h | 10 +-
> arch/powerpc/kernel/dma-iommu.c | 12 +-
> arch/powerpc/kernel/dma.c | 18 +--
> arch/powerpc/kernel/ibmebus.c | 12 +-
> arch/powerpc/kernel/iommu.c | 12 +-
> arch/powerpc/kernel/vio.c | 12 +-
> arch/powerpc/platforms/cell/iommu.c | 28 ++---
> arch/powerpc/platforms/pasemi/iommu.c | 2 +-
> arch/powerpc/platforms/powernv/npu-dma.c | 8 +-
> arch/powerpc/platforms/powernv/pci-ioda.c | 4 +-
> arch/powerpc/platforms/powernv/pci.c | 2 +-
> arch/powerpc/platforms/powernv/pci.h | 2 +-
> arch/powerpc/platforms/ps3/system-bus.c | 18 +--
> arch/powerpc/platforms/pseries/iommu.c | 6 +-
> arch/powerpc/sysdev/dart_iommu.c | 2 +-
> arch/s390/include/asm/dma-mapping.h | 1 -
> arch/s390/pci/pci_dma.c | 23 ++--
> arch/sh/include/asm/dma-mapping.h | 4 +-
> arch/sh/kernel/dma-nommu.c | 4 +-
> arch/sh/mm/consistent.c | 4 +-
> arch/sparc/kernel/iommu.c | 12 +-
> arch/sparc/kernel/ioport.c | 24 ++--
> arch/sparc/kernel/pci_sun4v.c | 12 +-
> arch/tile/kernel/pci-dma.c | 28 ++---
> arch/unicore32/mm/dma-swiotlb.c | 4 +-
> arch/x86/include/asm/dma-mapping.h | 5 +-
> arch/x86/include/asm/swiotlb.h | 4 +-
> arch/x86/include/asm/xen/page-coherent.h | 9 +-
> arch/x86/kernel/amd_gart_64.c | 20 ++--
> arch/x86/kernel/pci-calgary_64.c | 14 +--
> arch/x86/kernel/pci-dma.c | 4 +-
> arch/x86/kernel/pci-nommu.c | 4 +-
> arch/x86/kernel/pci-swiotlb.c | 4 +-
> arch/x86/pci/sta2x11-fixup.c | 2 +-
> arch/x86/pci/vmd.c | 16 +--
> arch/xtensa/kernel/pci-dma.c | 12 +-
> drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
> drivers/gpu/drm/exynos/exynos_drm_g2d.c | 12 +-
> drivers/gpu/drm/exynos/exynos_drm_gem.c | 20 ++--
> drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 +-
> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 13 +--
> drivers/gpu/drm/mediatek/mtk_drm_gem.h | 2 +-
> drivers/gpu/drm/msm/msm_drv.c | 13 +--
> .../gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 13 +--
> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++-
> drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 2 +-
> drivers/infiniband/core/umem.c | 7 +-
> drivers/iommu/amd_iommu.c | 12 +-
> drivers/iommu/dma-iommu.c | 8 +-
> drivers/iommu/intel-iommu.c | 12 +-
> drivers/media/platform/sti/bdisp/bdisp-hw.c | 26 ++---
> drivers/media/v4l2-core/videobuf2-dma-contig.c | 30 ++---
> drivers/media/v4l2-core/videobuf2-dma-sg.c | 19 +--
> drivers/misc/mic/host/mic_boot.c | 20 ++--
> drivers/parisc/ccio-dma.c | 16 +--
> drivers/parisc/sba_iommu.c | 16 +--
> drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 12 +-
> drivers/video/fbdev/omap2/omapfb/omapfb.h | 3 +-
> drivers/xen/swiotlb-xen.c | 14 +--
> include/linux/dma-attrs.h | 71 ------------
> include/linux/dma-iommu.h | 6 +-
> include/linux/dma-mapping.h | 128 ++++++++++++++-------
> include/linux/swiotlb.h | 10 +-
> include/media/videobuf2-dma-contig.h | 7 +-
> include/rdma/ib_verbs.h | 8 +-
> include/xen/swiotlb-xen.h | 12 +-
> lib/dma-noop.c | 9 +-
> lib/swiotlb.c | 13 ++-
> 108 files changed, 689 insertions(+), 789 deletions(-)
> delete mode 100644 include/linux/dma-attrs.h
>
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs
2016-07-12 12:16 ` [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs Daniel Vetter
@ 2016-07-12 12:19 ` Krzysztof Kozlowski
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2016-07-12 12:19 UTC (permalink / raw)
To: Andrew Morton, linux-mips, linux-ia64, linux-doc, linux-pci,
linux-fbdev, dri-devel, sparclinux, linux-s390, linux-samsung-soc,
linux-c6x-dev, linux-rdma, linux-hexagon, linux-sh, hch,
linux-rockchip, nouveau, xen-devel, linux-snps-arc, linux-media,
linux-xtensa, Bartlomiej Zolnierkiewicz, linux-arm-msm,
linux-m68k, linux-mediatek, linux-omap, linux-metag,
linux-arm-kernel, linux-parisc, linux-cris-kernel, freedreno,
linux-kernel, iommu, linux-alpha, linuxppc-dev
On 07/12/2016 02:16 PM, Daniel Vetter wrote:
> On Thu, Jun 30, 2016 at 10:23:39AM +0200, Krzysztof Kozlowski wrote:
>> Hi,
>>
>>
>> This is fifth approach for replacing struct dma_attrs with unsigned
>> long.
>>
>> The main patch (1/44) doing the change is split into many subpatches
>> for easier review (2-42). They should be squashed together when
>> applying.
>
> For all the drm driver patches:
>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Should I pull these in through drm-misc, or do you prefer to merge them
> through a special topic branch (with everything else) instead on your own?
> -Daniel
Thanks. I saw today that Andrew Morton applied the patchset so I think
he will handle it.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-12 12:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-30 8:23 [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs Krzysztof Kozlowski
[not found] ` <1467275171-6298-1-git-send-email-k.kozlowski@samsung.com>
2016-06-30 8:25 ` [PATCH v5 18/44] [media] " Krzysztof Kozlowski
2016-06-30 9:48 ` Marek Szyprowski
2016-06-30 8:26 ` [PATCH v5 43/44] dma-mapping: Remove dma_get_attr Krzysztof Kozlowski
2016-07-12 12:16 ` [PATCH v5 00/44] dma-mapping: Use unsigned long for dma_attrs Daniel Vetter
2016-07-12 12:19 ` Krzysztof Kozlowski
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).