Skip to content

Commit ddab533

Browse files
committed
Merge tag 'dma-mapping-5.2' of git://git.infradead.org/users/hch/dma-mapping
Pull DMA mapping updates from Christoph Hellwig: - remove the already broken support for NULL dev arguments to the DMA API calls - Kconfig tidyups * tag 'dma-mapping-5.2' of git://git.infradead.org/users/hch/dma-mapping: dma-mapping: add a Kconfig symbol to indicate arch_dma_prep_coherent presence dma-mapping: remove an unnecessary NULL check x86/dma: Remove the x86_dma_fallback_dev hack dma-mapping: remove leftover NULL device support arm: use a dummy struct device for ISA DMA use of the DMA API pxa3xx-gcu: pass struct device to dma_mmap_coherent gbefb: switch to managed version of the DMA allocator da8xx-fb: pass struct device to DMA API functions parport_ip32: pass struct device to DMA API functions dma: select GENERIC_ALLOCATOR for DMA_REMAP
2 parents e57ccca + 13bf5ce commit ddab533

17 files changed

Lines changed: 65 additions & 88 deletions

File tree

‎Documentation/DMA-API-HOWTO.txt‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,12 @@ __get_free_pages() (but takes size instead of a page order). If your
365365
driver needs regions sized smaller than a page, you may prefer using
366366
the dma_pool interface, described below.
367367

368-
The consistent DMA mapping interfaces, for non-NULL dev, will by
369-
default return a DMA address which is 32-bit addressable. Even if the
370-
device indicates (via DMA mask) that it may address the upper 32-bits,
371-
consistent allocation will only return > 32-bit addresses for DMA if
372-
the consistent DMA mask has been explicitly changed via
373-
dma_set_coherent_mask(). This is true of the dma_pool interface as
374-
well.
368+
The consistent DMA mapping interfaces, will by default return a DMA address
369+
which is 32-bit addressable. Even if the device indicates (via the DMA mask)
370+
that it may address the upper 32-bits, consistent allocation will only
371+
return > 32-bit addresses for DMA if the consistent DMA mask has been
372+
explicitly changed via dma_set_coherent_mask(). This is true of the
373+
dma_pool interface as well.
375374

376375
dma_alloc_coherent() returns two values: the virtual address which you
377376
can use to access it from the CPU and dma_handle which you pass to the

‎arch/arm/kernel/dma-isa.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ static int isa_get_dma_residue(unsigned int chan, dma_t *dma)
5555
return chan < 4 ? count : (count << 1);
5656
}
5757

58+
static struct device isa_dma_dev = {
59+
.init_name = "fallback device",
60+
.coherent_dma_mask = ~(dma_addr_t)0,
61+
.dma_mask = &isa_dma_dev.coherent_dma_mask,
62+
};
63+
5864
static void isa_enable_dma(unsigned int chan, dma_t *dma)
5965
{
6066
if (dma->invalid) {
@@ -89,7 +95,7 @@ static void isa_enable_dma(unsigned int chan, dma_t *dma)
8995
dma->sg = &dma->buf;
9096
dma->sgcount = 1;
9197
dma->buf.length = dma->count;
92-
dma->buf.dma_address = dma_map_single(NULL,
98+
dma->buf.dma_address = dma_map_single(&isa_dma_dev,
9399
dma->addr, dma->count,
94100
direction);
95101
}

‎arch/arm/mach-rpc/dma.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ static void iomd_free_dma(unsigned int chan, dma_t *dma)
151151
free_irq(idma->irq, idma);
152152
}
153153

154+
static struct device isa_dma_dev = {
155+
.init_name = "fallback device",
156+
.coherent_dma_mask = ~(dma_addr_t)0,
157+
.dma_mask = &isa_dma_dev.coherent_dma_mask,
158+
};
159+
154160
static void iomd_enable_dma(unsigned int chan, dma_t *dma)
155161
{
156162
struct iomd_dma *idma = container_of(dma, struct iomd_dma, dma);
@@ -168,7 +174,7 @@ static void iomd_enable_dma(unsigned int chan, dma_t *dma)
168174
idma->dma.sg = &idma->dma.buf;
169175
idma->dma.sgcount = 1;
170176
idma->dma.buf.length = idma->dma.count;
171-
idma->dma.buf.dma_address = dma_map_single(NULL,
177+
idma->dma.buf.dma_address = dma_map_single(&isa_dma_dev,
172178
idma->dma.addr, idma->dma.count,
173179
idma->dma.dma_mode == DMA_MODE_READ ?
174180
DMA_FROM_DEVICE : DMA_TO_DEVICE);

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config ARM64
1313
select ARCH_HAS_DEVMEM_IS_ALLOWED
1414
select ARCH_HAS_DMA_COHERENT_TO_PFN
1515
select ARCH_HAS_DMA_MMAP_PGPROT
16+
select ARCH_HAS_DMA_PREP_COHERENT
1617
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
1718
select ARCH_HAS_ELF_RANDOMIZE
1819
select ARCH_HAS_FAST_MULTIPLIER

‎arch/csky/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config CSKY
22
def_bool y
33
select ARCH_32BIT_OFF_T
4+
select ARCH_HAS_DMA_PREP_COHERENT
45
select ARCH_HAS_SYNC_DMA_FOR_CPU
56
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
67
select ARCH_USE_BUILTIN_BSWAP

‎arch/x86/include/asm/dma-mapping.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
#include <asm/swiotlb.h>
1414
#include <linux/dma-contiguous.h>
1515

16-
#ifdef CONFIG_ISA
17-
# define ISA_DMA_BIT_MASK DMA_BIT_MASK(24)
18-
#else
19-
# define ISA_DMA_BIT_MASK DMA_BIT_MASK(32)
20-
#endif
21-
2216
extern int iommu_merge;
23-
extern struct device x86_dma_fallback_dev;
2417
extern int panic_on_overflow;
2518

2619
extern const struct dma_map_ops *dma_ops;
@@ -30,7 +23,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
3023
return dma_ops;
3124
}
3225

33-
bool arch_dma_alloc_attrs(struct device **dev);
34-
#define arch_dma_alloc_attrs arch_dma_alloc_attrs
35-
3626
#endif

‎arch/x86/kernel/amd_gart_64.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ static dma_addr_t gart_map_page(struct device *dev, struct page *page,
233233
unsigned long bus;
234234
phys_addr_t paddr = page_to_phys(page) + offset;
235235

236-
if (!dev)
237-
dev = &x86_dma_fallback_dev;
238-
239236
if (!need_iommu(dev, paddr, size))
240237
return paddr;
241238

@@ -392,9 +389,6 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
392389
if (nents == 0)
393390
return 0;
394391

395-
if (!dev)
396-
dev = &x86_dma_fallback_dev;
397-
398392
out = 0;
399393
start = 0;
400394
start_sg = sg;

‎arch/x86/kernel/pci-dma.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ int iommu_pass_through __read_mostly;
5151

5252
extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
5353

54-
/* Dummy device used for NULL arguments (normally ISA). */
55-
struct device x86_dma_fallback_dev = {
56-
.init_name = "fallback device",
57-
.coherent_dma_mask = ISA_DMA_BIT_MASK,
58-
.dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
59-
};
60-
EXPORT_SYMBOL(x86_dma_fallback_dev);
61-
6254
void __init pci_iommu_alloc(void)
6355
{
6456
struct iommu_table_entry *p;
@@ -77,18 +69,6 @@ void __init pci_iommu_alloc(void)
7769
}
7870
}
7971

80-
bool arch_dma_alloc_attrs(struct device **dev)
81-
{
82-
if (!*dev)
83-
*dev = &x86_dma_fallback_dev;
84-
85-
if (!is_device_dma_capable(*dev))
86-
return false;
87-
return true;
88-
89-
}
90-
EXPORT_SYMBOL(arch_dma_alloc_attrs);
91-
9272
/*
9373
* See <Documentation/x86/x86_64/boot-options.txt> for the iommu kernel
9474
* parameter documentation.

‎drivers/parport/parport_ip32.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,16 @@ static irqreturn_t parport_ip32_merr_interrupt(int irq, void *dev_id)
568568

569569
/**
570570
* parport_ip32_dma_start - begins a DMA transfer
571+
* @p: partport to work on
571572
* @dir: DMA direction: DMA_TO_DEVICE or DMA_FROM_DEVICE
572573
* @addr: pointer to data buffer
573574
* @count: buffer size
574575
*
575576
* Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
576577
* correctly balanced.
577578
*/
578-
static int parport_ip32_dma_start(enum dma_data_direction dir,
579-
void *addr, size_t count)
579+
static int parport_ip32_dma_start(struct parport *p,
580+
enum dma_data_direction dir, void *addr, size_t count)
580581
{
581582
unsigned int limit;
582583
u64 ctrl;
@@ -601,7 +602,7 @@ static int parport_ip32_dma_start(enum dma_data_direction dir,
601602

602603
/* Prepare DMA pointers */
603604
parport_ip32_dma.dir = dir;
604-
parport_ip32_dma.buf = dma_map_single(NULL, addr, count, dir);
605+
parport_ip32_dma.buf = dma_map_single(&p->bus_dev, addr, count, dir);
605606
parport_ip32_dma.len = count;
606607
parport_ip32_dma.next = parport_ip32_dma.buf;
607608
parport_ip32_dma.left = parport_ip32_dma.len;
@@ -625,11 +626,12 @@ static int parport_ip32_dma_start(enum dma_data_direction dir,
625626

626627
/**
627628
* parport_ip32_dma_stop - ends a running DMA transfer
629+
* @p: partport to work on
628630
*
629631
* Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
630632
* correctly balanced.
631633
*/
632-
static void parport_ip32_dma_stop(void)
634+
static void parport_ip32_dma_stop(struct parport *p)
633635
{
634636
u64 ctx_a;
635637
u64 ctx_b;
@@ -685,8 +687,8 @@ static void parport_ip32_dma_stop(void)
685687
enable_irq(MACEISA_PAR_CTXB_IRQ);
686688
parport_ip32_dma.irq_on = 1;
687689

688-
dma_unmap_single(NULL, parport_ip32_dma.buf, parport_ip32_dma.len,
689-
parport_ip32_dma.dir);
690+
dma_unmap_single(&p->bus_dev, parport_ip32_dma.buf,
691+
parport_ip32_dma.len, parport_ip32_dma.dir);
690692
}
691693

692694
/**
@@ -1445,7 +1447,7 @@ static size_t parport_ip32_fifo_write_block_dma(struct parport *p,
14451447

14461448
priv->irq_mode = PARPORT_IP32_IRQ_HERE;
14471449

1448-
parport_ip32_dma_start(DMA_TO_DEVICE, (void *)buf, len);
1450+
parport_ip32_dma_start(p, DMA_TO_DEVICE, (void *)buf, len);
14491451
reinit_completion(&priv->irq_complete);
14501452
parport_ip32_frob_econtrol(p, ECR_DMAEN | ECR_SERVINTR, ECR_DMAEN);
14511453

@@ -1461,7 +1463,7 @@ static size_t parport_ip32_fifo_write_block_dma(struct parport *p,
14611463
if (ecr & ECR_SERVINTR)
14621464
break; /* DMA transfer just finished */
14631465
}
1464-
parport_ip32_dma_stop();
1466+
parport_ip32_dma_stop(p);
14651467
written = len - parport_ip32_dma_get_residue();
14661468

14671469
priv->irq_mode = PARPORT_IP32_IRQ_FWD;

‎drivers/video/fbdev/da8xx-fb.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,9 +1097,9 @@ static int fb_remove(struct platform_device *dev)
10971097

10981098
unregister_framebuffer(info);
10991099
fb_dealloc_cmap(&info->cmap);
1100-
dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base,
1100+
dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
11011101
par->p_palette_base);
1102-
dma_free_coherent(NULL, par->vram_size, par->vram_virt,
1102+
dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
11031103
par->vram_phys);
11041104
pm_runtime_put_sync(&dev->dev);
11051105
pm_runtime_disable(&dev->dev);
@@ -1425,7 +1425,7 @@ static int fb_probe(struct platform_device *device)
14251425
par->vram_size = roundup(par->vram_size/8, ulcm);
14261426
par->vram_size = par->vram_size * LCD_NUM_BUFFERS;
14271427

1428-
par->vram_virt = dma_alloc_coherent(NULL,
1428+
par->vram_virt = dma_alloc_coherent(par->dev,
14291429
par->vram_size,
14301430
&par->vram_phys,
14311431
GFP_KERNEL | GFP_DMA);
@@ -1446,7 +1446,7 @@ static int fb_probe(struct platform_device *device)
14461446
da8xx_fb_fix.line_length - 1;
14471447

14481448
/* allocate palette buffer */
1449-
par->v_palette_base = dma_alloc_coherent(NULL, PALETTE_SIZE,
1449+
par->v_palette_base = dma_alloc_coherent(par->dev, PALETTE_SIZE,
14501450
&par->p_palette_base,
14511451
GFP_KERNEL | GFP_DMA);
14521452
if (!par->v_palette_base) {
@@ -1532,11 +1532,12 @@ static int fb_probe(struct platform_device *device)
15321532
fb_dealloc_cmap(&da8xx_fb_info->cmap);
15331533

15341534
err_release_pl_mem:
1535-
dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base,
1535+
dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
15361536
par->p_palette_base);
15371537

15381538
err_release_fb_mem:
1539-
dma_free_coherent(NULL, par->vram_size, par->vram_virt, par->vram_phys);
1539+
dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
1540+
par->vram_phys);
15401541

15411542
err_release_fb:
15421543
framebuffer_release(da8xx_fb_info);

0 commit comments

Comments
 (0)