Skip to content

Commit b02c2b0

Browse files
author
Christoph Hellwig
committed
sparc: remove arch specific dma_supported implementations
Usually dma_supported decisions are done by the dma_map_ops instance. Switch sparc to that model by providing a ->dma_supported instance for sbus that always returns false, and implementations tailored to the sun4u and sun4v cases for sparc64, and leave it unimplemented for PCI on sparc32, which means always supported. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: David S. Miller <davem@davemloft.net>
1 parent c6d333e commit b02c2b0

File tree

4 files changed

+39
-43
lines changed

4 files changed

+39
-43
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include <linux/mm.h>
66
#include <linux/dma-debug.h>
77

8-
#define HAVE_ARCH_DMA_SUPPORTED 1
9-
int dma_supported(struct device *dev, u64 mask);
10-
118
static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
129
enum dma_data_direction dir)
1310
{

arch/sparc/kernel/iommu.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,21 @@ static int dma_4u_mapping_error(struct device *dev, dma_addr_t dma_addr)
746746
return dma_addr == SPARC_MAPPING_ERROR;
747747
}
748748

749+
static int dma_4u_supported(struct device *dev, u64 device_mask)
750+
{
751+
struct iommu *iommu = dev->archdata.iommu;
752+
753+
if (device_mask > DMA_BIT_MASK(32))
754+
return 0;
755+
if ((device_mask & iommu->dma_addr_mask) == iommu->dma_addr_mask)
756+
return 1;
757+
#ifdef CONFIG_PCI
758+
if (dev_is_pci(dev))
759+
return pci64_dma_supported(to_pci_dev(dev), device_mask);
760+
#endif
761+
return 0;
762+
}
763+
749764
static const struct dma_map_ops sun4u_dma_ops = {
750765
.alloc = dma_4u_alloc_coherent,
751766
.free = dma_4u_free_coherent,
@@ -755,32 +770,9 @@ static const struct dma_map_ops sun4u_dma_ops = {
755770
.unmap_sg = dma_4u_unmap_sg,
756771
.sync_single_for_cpu = dma_4u_sync_single_for_cpu,
757772
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
773+
.dma_supported = dma_4u_supported,
758774
.mapping_error = dma_4u_mapping_error,
759775
};
760776

761777
const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
762778
EXPORT_SYMBOL(dma_ops);
763-
764-
int dma_supported(struct device *dev, u64 device_mask)
765-
{
766-
struct iommu *iommu = dev->archdata.iommu;
767-
u64 dma_addr_mask = iommu->dma_addr_mask;
768-
769-
if (device_mask > DMA_BIT_MASK(32)) {
770-
if (iommu->atu)
771-
dma_addr_mask = iommu->atu->dma_addr_mask;
772-
else
773-
return 0;
774-
}
775-
776-
if ((device_mask & dma_addr_mask) == dma_addr_mask)
777-
return 1;
778-
779-
#ifdef CONFIG_PCI
780-
if (dev_is_pci(dev))
781-
return pci64_dma_supported(to_pci_dev(dev), device_mask);
782-
#endif
783-
784-
return 0;
785-
}
786-
EXPORT_SYMBOL(dma_supported);

arch/sparc/kernel/ioport.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
401401
BUG();
402402
}
403403

404+
static int sbus_dma_supported(struct device *dev, u64 mask)
405+
{
406+
return 0;
407+
}
408+
404409
static const struct dma_map_ops sbus_dma_ops = {
405410
.alloc = sbus_alloc_coherent,
406411
.free = sbus_free_coherent,
@@ -410,6 +415,7 @@ static const struct dma_map_ops sbus_dma_ops = {
410415
.unmap_sg = sbus_unmap_sg,
411416
.sync_sg_for_cpu = sbus_sync_sg_for_cpu,
412417
.sync_sg_for_device = sbus_sync_sg_for_device,
418+
.dma_supported = sbus_dma_supported,
413419
};
414420

415421
static int __init sparc_register_ioport(void)
@@ -655,22 +661,6 @@ EXPORT_SYMBOL(pci32_dma_ops);
655661
const struct dma_map_ops *dma_ops = &sbus_dma_ops;
656662
EXPORT_SYMBOL(dma_ops);
657663

658-
659-
/*
660-
* Return whether the given PCI device DMA address mask can be
661-
* supported properly. For example, if your device can only drive the
662-
* low 24-bits during PCI bus mastering, then you would pass
663-
* 0x00ffffff as the mask to this function.
664-
*/
665-
int dma_supported(struct device *dev, u64 mask)
666-
{
667-
if (dev_is_pci(dev))
668-
return 1;
669-
670-
return 0;
671-
}
672-
EXPORT_SYMBOL(dma_supported);
673-
674664
#ifdef CONFIG_PROC_FS
675665

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

arch/sparc/kernel/pci_sun4v.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "pci_impl.h"
2626
#include "iommu_common.h"
27+
#include "kernel.h"
2728

2829
#include "pci_sun4v.h"
2930

@@ -669,6 +670,21 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
669670
local_irq_restore(flags);
670671
}
671672

673+
static int dma_4v_supported(struct device *dev, u64 device_mask)
674+
{
675+
struct iommu *iommu = dev->archdata.iommu;
676+
u64 dma_addr_mask;
677+
678+
if (device_mask > DMA_BIT_MASK(32) && iommu->atu)
679+
dma_addr_mask = iommu->atu->dma_addr_mask;
680+
else
681+
dma_addr_mask = iommu->dma_addr_mask;
682+
683+
if ((device_mask & dma_addr_mask) == dma_addr_mask)
684+
return 1;
685+
return pci64_dma_supported(to_pci_dev(dev), device_mask);
686+
}
687+
672688
static int dma_4v_mapping_error(struct device *dev, dma_addr_t dma_addr)
673689
{
674690
return dma_addr == SPARC_MAPPING_ERROR;
@@ -681,6 +697,7 @@ static const struct dma_map_ops sun4v_dma_ops = {
681697
.unmap_page = dma_4v_unmap_page,
682698
.map_sg = dma_4v_map_sg,
683699
.unmap_sg = dma_4v_unmap_sg,
700+
.dma_supported = dma_4v_supported,
684701
.mapping_error = dma_4v_mapping_error,
685702
};
686703

0 commit comments

Comments
 (0)