Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Linus Torvalds committed Apr 7, 2020
2 parents 498ff42 + 255a69a commit 12782fb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 34 deletions.
15 changes: 2 additions & 13 deletions arch/sparc/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@
#ifndef ___ASM_SPARC_DMA_MAPPING_H
#define ___ASM_SPARC_DMA_MAPPING_H

#include <asm/cpu_type.h>

extern const struct dma_map_ops *dma_ops;

extern struct bus_type pci_bus_type;

static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
{
#ifdef CONFIG_SPARC_LEON
if (sparc_cpu_model == sparc_leon)
return NULL;
#endif
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
if (bus == &pci_bus_type)
return NULL;
#endif
return dma_ops;
/* sparc32 uses per-device dma_ops */
return IS_ENABLED(CONFIG_SPARC64) ? dma_ops : NULL;
}

#endif
3 changes: 0 additions & 3 deletions arch/sparc/kernel/ioport.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,6 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
dma_make_coherent(paddr, PAGE_ALIGN(size));
}

const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

#ifdef CONFIG_PROC_FS

static int sparc_io_proc_show(struct seq_file *m, void *v)
Expand Down
1 change: 1 addition & 0 deletions arch/sparc/kernel/of_device_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void of_propagate_archdata(struct platform_device *bus)
op->dev.archdata.stc = bus_sd->stc;
op->dev.archdata.host_controller = bus_sd->host_controller;
op->dev.archdata.numa_node = bus_sd->numa_node;
op->dev.dma_ops = bus->dev.dma_ops;

if (dp->child)
of_propagate_archdata(op);
Expand Down
9 changes: 4 additions & 5 deletions arch/sparc/mm/io-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)

static const struct dma_map_ops iounit_dma_ops;

static void __init iounit_iommu_init(struct platform_device *op)
{
struct iounit_struct *iounit;
Expand Down Expand Up @@ -70,6 +72,8 @@ static void __init iounit_iommu_init(struct platform_device *op)
xptend = iounit->page_table + (16 * PAGE_SIZE) / sizeof(iopte_t);
for (; xpt < xptend; xpt++)
sbus_writel(0, xpt);

op->dev.dma_ops = &iounit_dma_ops;
}

static int __init iounit_init(void)
Expand Down Expand Up @@ -288,8 +292,3 @@ static const struct dma_map_ops iounit_dma_ops = {
.map_sg = iounit_map_sg,
.unmap_sg = iounit_unmap_sg,
};

void __init ld_mmu_iounit(void)
{
dma_ops = &iounit_dma_ops;
}
15 changes: 8 additions & 7 deletions arch/sparc/mm/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */
#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)

static const struct dma_map_ops sbus_iommu_dma_gflush_ops;
static const struct dma_map_ops sbus_iommu_dma_pflush_ops;

static void __init sbus_iommu_init(struct platform_device *op)
{
struct iommu_struct *iommu;
Expand Down Expand Up @@ -129,6 +132,11 @@ static void __init sbus_iommu_init(struct platform_device *op)
(int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES);

op->dev.archdata.iommu = iommu;

if (flush_page_for_dma_global)
op->dev.dma_ops = &sbus_iommu_dma_gflush_ops;
else
op->dev.dma_ops = &sbus_iommu_dma_pflush_ops;
}

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

void __init ld_mmu_iommu(void)
{
if (flush_page_for_dma_global) {
/* flush_page_for_dma flushes everything, no matter of what page is it */
dma_ops = &sbus_iommu_dma_gflush_ops;
} else {
dma_ops = &sbus_iommu_dma_pflush_ops;
}

if (viking_mxcc_present || srmmu_modtype == HyperSparc) {
dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
ioperm_noc = IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID;
Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/mm/mm_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ void __init srmmu_paging_init(void);

/* iommu.c */
void ld_mmu_iommu(void);

/* io-unit.c */
void ld_mmu_iounit(void);
4 changes: 1 addition & 3 deletions arch/sparc/mm/srmmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,9 +1865,7 @@ void __init load_mmu(void)
&smp_cachetlb_ops;
#endif

if (sparc_cpu_model == sun4d)
ld_mmu_iounit();
else
if (sparc_cpu_model != sun4d)
ld_mmu_iommu();
#ifdef CONFIG_SMP
if (sparc_cpu_model == sun4d)
Expand Down

0 comments on commit 12782fb

Please sign in to comment.