Skip to content

Commit 12782fb

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull sparc update from David Miller: "A per-device DMA ops conversion for sparc32 by Chrstioph Hellwig" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc32: use per-device dma_ops
2 parents 498ff42 + 255a69a commit 12782fb

File tree

7 files changed

+16
-34
lines changed

7 files changed

+16
-34
lines changed

arch/sparc/include/asm/dma-mapping.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22
#ifndef ___ASM_SPARC_DMA_MAPPING_H
33
#define ___ASM_SPARC_DMA_MAPPING_H
44

5-
#include <asm/cpu_type.h>
6-
75
extern const struct dma_map_ops *dma_ops;
86

9-
extern struct bus_type pci_bus_type;
10-
117
static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
128
{
13-
#ifdef CONFIG_SPARC_LEON
14-
if (sparc_cpu_model == sparc_leon)
15-
return NULL;
16-
#endif
17-
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
18-
if (bus == &pci_bus_type)
19-
return NULL;
20-
#endif
21-
return dma_ops;
9+
/* sparc32 uses per-device dma_ops */
10+
return IS_ENABLED(CONFIG_SPARC64) ? dma_ops : NULL;
2211
}
2312

2413
#endif

arch/sparc/kernel/ioport.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,6 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
373373
dma_make_coherent(paddr, PAGE_ALIGN(size));
374374
}
375375

376-
const struct dma_map_ops *dma_ops;
377-
EXPORT_SYMBOL(dma_ops);
378-
379376
#ifdef CONFIG_PROC_FS
380377

381378
static int sparc_io_proc_show(struct seq_file *m, void *v)

arch/sparc/kernel/of_device_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void of_propagate_archdata(struct platform_device *bus)
6767
op->dev.archdata.stc = bus_sd->stc;
6868
op->dev.archdata.host_controller = bus_sd->host_controller;
6969
op->dev.archdata.numa_node = bus_sd->numa_node;
70+
op->dev.dma_ops = bus->dev.dma_ops;
7071

7172
if (dp->child)
7273
of_propagate_archdata(op);

arch/sparc/mm/io-unit.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
3939
#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)
4040

41+
static const struct dma_map_ops iounit_dma_ops;
42+
4143
static void __init iounit_iommu_init(struct platform_device *op)
4244
{
4345
struct iounit_struct *iounit;
@@ -70,6 +72,8 @@ static void __init iounit_iommu_init(struct platform_device *op)
7072
xptend = iounit->page_table + (16 * PAGE_SIZE) / sizeof(iopte_t);
7173
for (; xpt < xptend; xpt++)
7274
sbus_writel(0, xpt);
75+
76+
op->dev.dma_ops = &iounit_dma_ops;
7377
}
7478

7579
static int __init iounit_init(void)
@@ -288,8 +292,3 @@ static const struct dma_map_ops iounit_dma_ops = {
288292
.map_sg = iounit_map_sg,
289293
.unmap_sg = iounit_unmap_sg,
290294
};
291-
292-
void __init ld_mmu_iounit(void)
293-
{
294-
dma_ops = &iounit_dma_ops;
295-
}

arch/sparc/mm/iommu.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */
5454
#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
5555
#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)
5656

57+
static const struct dma_map_ops sbus_iommu_dma_gflush_ops;
58+
static const struct dma_map_ops sbus_iommu_dma_pflush_ops;
59+
5760
static void __init sbus_iommu_init(struct platform_device *op)
5861
{
5962
struct iommu_struct *iommu;
@@ -129,6 +132,11 @@ static void __init sbus_iommu_init(struct platform_device *op)
129132
(int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES);
130133

131134
op->dev.archdata.iommu = iommu;
135+
136+
if (flush_page_for_dma_global)
137+
op->dev.dma_ops = &sbus_iommu_dma_gflush_ops;
138+
else
139+
op->dev.dma_ops = &sbus_iommu_dma_pflush_ops;
132140
}
133141

134142
static int __init iommu_init(void)
@@ -445,13 +453,6 @@ static const struct dma_map_ops sbus_iommu_dma_pflush_ops = {
445453

446454
void __init ld_mmu_iommu(void)
447455
{
448-
if (flush_page_for_dma_global) {
449-
/* flush_page_for_dma flushes everything, no matter of what page is it */
450-
dma_ops = &sbus_iommu_dma_gflush_ops;
451-
} else {
452-
dma_ops = &sbus_iommu_dma_pflush_ops;
453-
}
454-
455456
if (viking_mxcc_present || srmmu_modtype == HyperSparc) {
456457
dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
457458
ioperm_noc = IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID;

arch/sparc/mm/mm_32.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ void __init srmmu_paging_init(void);
2020

2121
/* iommu.c */
2222
void ld_mmu_iommu(void);
23-
24-
/* io-unit.c */
25-
void ld_mmu_iounit(void);

arch/sparc/mm/srmmu.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,9 +1865,7 @@ void __init load_mmu(void)
18651865
&smp_cachetlb_ops;
18661866
#endif
18671867

1868-
if (sparc_cpu_model == sun4d)
1869-
ld_mmu_iounit();
1870-
else
1868+
if (sparc_cpu_model != sun4d)
18711869
ld_mmu_iommu();
18721870
#ifdef CONFIG_SMP
18731871
if (sparc_cpu_model == sun4d)

0 commit comments

Comments
 (0)