Skip to content

Commit ceaf481

Browse files
author
Christoph Hellwig
committed
sparc: implement ->mapping_error
DMA_ERROR_CODE is going to go away, so don't rely on it. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: David S. Miller <davem@davemloft.net>
1 parent 81cac18 commit ceaf481

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

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

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

8-
#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
9-
108
#define HAVE_ARCH_DMA_SUPPORTED 1
119
int dma_supported(struct device *dev, u64 mask);
1210

arch/sparc/kernel/iommu.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static dma_addr_t dma_4u_map_page(struct device *dev, struct page *page,
314314
bad_no_ctx:
315315
if (printk_ratelimit())
316316
WARN_ON(1);
317-
return DMA_ERROR_CODE;
317+
return SPARC_MAPPING_ERROR;
318318
}
319319

320320
static void strbuf_flush(struct strbuf *strbuf, struct iommu *iommu,
@@ -547,7 +547,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
547547

548548
if (outcount < incount) {
549549
outs = sg_next(outs);
550-
outs->dma_address = DMA_ERROR_CODE;
550+
outs->dma_address = SPARC_MAPPING_ERROR;
551551
outs->dma_length = 0;
552552
}
553553

@@ -573,7 +573,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
573573
iommu_tbl_range_free(&iommu->tbl, vaddr, npages,
574574
IOMMU_ERROR_CODE);
575575

576-
s->dma_address = DMA_ERROR_CODE;
576+
s->dma_address = SPARC_MAPPING_ERROR;
577577
s->dma_length = 0;
578578
}
579579
if (s == outs)
@@ -741,6 +741,11 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
741741
spin_unlock_irqrestore(&iommu->lock, flags);
742742
}
743743

744+
static int dma_4u_mapping_error(struct device *dev, dma_addr_t dma_addr)
745+
{
746+
return dma_addr == SPARC_MAPPING_ERROR;
747+
}
748+
744749
static const struct dma_map_ops sun4u_dma_ops = {
745750
.alloc = dma_4u_alloc_coherent,
746751
.free = dma_4u_free_coherent,
@@ -750,6 +755,7 @@ static const struct dma_map_ops sun4u_dma_ops = {
750755
.unmap_sg = dma_4u_unmap_sg,
751756
.sync_single_for_cpu = dma_4u_sync_single_for_cpu,
752757
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
758+
.mapping_error = dma_4u_mapping_error,
753759
};
754760

755761
const struct dma_map_ops *dma_ops = &sun4u_dma_ops;

arch/sparc/kernel/iommu_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ static inline int is_span_boundary(unsigned long entry,
4747
return iommu_is_span_boundary(entry, nr, shift, boundary_size);
4848
}
4949

50+
#define SPARC_MAPPING_ERROR (~(dma_addr_t)0x0)
51+
5052
#endif /* _IOMMU_COMMON_H */

arch/sparc/kernel/pci_sun4v.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page,
412412
bad:
413413
if (printk_ratelimit())
414414
WARN_ON(1);
415-
return DMA_ERROR_CODE;
415+
return SPARC_MAPPING_ERROR;
416416

417417
iommu_map_fail:
418418
local_irq_restore(flags);
419419
iommu_tbl_range_free(tbl, bus_addr, npages, IOMMU_ERROR_CODE);
420-
return DMA_ERROR_CODE;
420+
return SPARC_MAPPING_ERROR;
421421
}
422422

423423
static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr,
@@ -590,7 +590,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
590590

591591
if (outcount < incount) {
592592
outs = sg_next(outs);
593-
outs->dma_address = DMA_ERROR_CODE;
593+
outs->dma_address = SPARC_MAPPING_ERROR;
594594
outs->dma_length = 0;
595595
}
596596

@@ -607,7 +607,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
607607
iommu_tbl_range_free(tbl, vaddr, npages,
608608
IOMMU_ERROR_CODE);
609609
/* XXX demap? XXX */
610-
s->dma_address = DMA_ERROR_CODE;
610+
s->dma_address = SPARC_MAPPING_ERROR;
611611
s->dma_length = 0;
612612
}
613613
if (s == outs)
@@ -669,13 +669,19 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
669669
local_irq_restore(flags);
670670
}
671671

672+
static int dma_4v_mapping_error(struct device *dev, dma_addr_t dma_addr)
673+
{
674+
return dma_addr == SPARC_MAPPING_ERROR;
675+
}
676+
672677
static const struct dma_map_ops sun4v_dma_ops = {
673678
.alloc = dma_4v_alloc_coherent,
674679
.free = dma_4v_free_coherent,
675680
.map_page = dma_4v_map_page,
676681
.unmap_page = dma_4v_unmap_page,
677682
.map_sg = dma_4v_map_sg,
678683
.unmap_sg = dma_4v_unmap_sg,
684+
.mapping_error = dma_4v_mapping_error,
679685
};
680686

681687
static void pci_sun4v_scan_bus(struct pci_pbm_info *pbm, struct device *parent)

0 commit comments

Comments
 (0)