summaryrefslogtreecommitdiffstats
path: root/drivers/parisc/ccio-dma.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-01-20 18:01:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-20 20:09:18 -0500
commit79387179e2e4fede52326e4c4e26145dbd6b505c (patch)
tree1ba83f9abcb6592b13ff4539df64211be1fb1de8 /drivers/parisc/ccio-dma.c
parenteae075196305549513335c2fc7d5d63712246bfd (diff)
parisc: convert to dma_map_ops
Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Helge Deller <deller@gmx.de> Acked-by: Helge Deller <deller@gmx.de> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/parisc/ccio-dma.c')
-rw-r--r--drivers/parisc/ccio-dma.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 8e11fb2831cd..e24b05996a1b 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -786,18 +786,27 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
786 return CCIO_IOVA(iovp, offset); 786 return CCIO_IOVA(iovp, offset);
787} 787}
788 788
789
790static dma_addr_t
791ccio_map_page(struct device *dev, struct page *page, unsigned long offset,
792 size_t size, enum dma_data_direction direction,
793 struct dma_attrs *attrs)
794{
795 return ccio_map_single(dev, page_address(page) + offset, size,
796 direction);
797}
798
799
789/** 800/**
790 * ccio_unmap_single - Unmap an address range from the IOMMU. 801 * ccio_unmap_page - Unmap an address range from the IOMMU.
791 * @dev: The PCI device. 802 * @dev: The PCI device.
792 * @addr: The start address of the DMA region. 803 * @addr: The start address of the DMA region.
793 * @size: The length of the DMA region. 804 * @size: The length of the DMA region.
794 * @direction: The direction of the DMA transaction (to/from device). 805 * @direction: The direction of the DMA transaction (to/from device).
795 *
796 * This function implements the pci_unmap_single function.
797 */ 806 */
798static void 807static void
799ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size, 808ccio_unmap_page(struct device *dev, dma_addr_t iova, size_t size,
800 enum dma_data_direction direction) 809 enum dma_data_direction direction, struct dma_attrs *attrs)
801{ 810{
802 struct ioc *ioc; 811 struct ioc *ioc;
803 unsigned long flags; 812 unsigned long flags;
@@ -826,7 +835,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
826} 835}
827 836
828/** 837/**
829 * ccio_alloc_consistent - Allocate a consistent DMA mapping. 838 * ccio_alloc - Allocate a consistent DMA mapping.
830 * @dev: The PCI device. 839 * @dev: The PCI device.
831 * @size: The length of the DMA region. 840 * @size: The length of the DMA region.
832 * @dma_handle: The DMA address handed back to the device (not the cpu). 841 * @dma_handle: The DMA address handed back to the device (not the cpu).
@@ -834,7 +843,8 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
834 * This function implements the pci_alloc_consistent function. 843 * This function implements the pci_alloc_consistent function.
835 */ 844 */
836static void * 845static void *
837ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) 846ccio_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag,
847 struct dma_attrs *attrs)
838{ 848{
839 void *ret; 849 void *ret;
840#if 0 850#if 0
@@ -858,7 +868,7 @@ ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, g
858} 868}
859 869
860/** 870/**
861 * ccio_free_consistent - Free a consistent DMA mapping. 871 * ccio_free - Free a consistent DMA mapping.
862 * @dev: The PCI device. 872 * @dev: The PCI device.
863 * @size: The length of the DMA region. 873 * @size: The length of the DMA region.
864 * @cpu_addr: The cpu address returned from the ccio_alloc_consistent. 874 * @cpu_addr: The cpu address returned from the ccio_alloc_consistent.
@@ -867,10 +877,10 @@ ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, g
867 * This function implements the pci_free_consistent function. 877 * This function implements the pci_free_consistent function.
868 */ 878 */
869static void 879static void
870ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr, 880ccio_free(struct device *dev, size_t size, void *cpu_addr,
871 dma_addr_t dma_handle) 881 dma_addr_t dma_handle, struct dma_attrs *attrs)
872{ 882{
873 ccio_unmap_single(dev, dma_handle, size, 0); 883 ccio_unmap_page(dev, dma_handle, size, 0, NULL);
874 free_pages((unsigned long)cpu_addr, get_order(size)); 884 free_pages((unsigned long)cpu_addr, get_order(size));
875} 885}
876 886
@@ -897,7 +907,7 @@ ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr,
897 */ 907 */
898static int 908static int
899ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents, 909ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
900 enum dma_data_direction direction) 910 enum dma_data_direction direction, struct dma_attrs *attrs)
901{ 911{
902 struct ioc *ioc; 912 struct ioc *ioc;
903 int coalesced, filled = 0; 913 int coalesced, filled = 0;
@@ -974,7 +984,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
974 */ 984 */
975static void 985static void
976ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, 986ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
977 enum dma_data_direction direction) 987 enum dma_data_direction direction, struct dma_attrs *attrs)
978{ 988{
979 struct ioc *ioc; 989 struct ioc *ioc;
980 990
@@ -993,27 +1003,22 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
993#ifdef CCIO_COLLECT_STATS 1003#ifdef CCIO_COLLECT_STATS
994 ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; 1004 ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT;
995#endif 1005#endif
996 ccio_unmap_single(dev, sg_dma_address(sglist), 1006 ccio_unmap_page(dev, sg_dma_address(sglist),
997 sg_dma_len(sglist), direction); 1007 sg_dma_len(sglist), direction, NULL);
998 ++sglist; 1008 ++sglist;
999 } 1009 }
1000 1010
1001 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents); 1011 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
1002} 1012}
1003 1013
1004static struct hppa_dma_ops ccio_ops = { 1014static struct dma_map_ops ccio_ops = {
1005 .dma_supported = ccio_dma_supported, 1015 .dma_supported = ccio_dma_supported,
1006 .alloc_consistent = ccio_alloc_consistent, 1016 .alloc = ccio_alloc,
1007 .alloc_noncoherent = ccio_alloc_consistent, 1017 .free = ccio_free,
1008 .free_consistent = ccio_free_consistent, 1018 .map_page = ccio_map_page,
1009 .map_single = ccio_map_single, 1019 .unmap_page = ccio_unmap_page,
1010 .unmap_single = ccio_unmap_single,
1011 .map_sg = ccio_map_sg, 1020 .map_sg = ccio_map_sg,
1012 .unmap_sg = ccio_unmap_sg, 1021 .unmap_sg = ccio_unmap_sg,
1013 .dma_sync_single_for_cpu = NULL, /* NOP for U2/Uturn */
1014 .dma_sync_single_for_device = NULL, /* NOP for U2/Uturn */
1015 .dma_sync_sg_for_cpu = NULL, /* ditto */
1016 .dma_sync_sg_for_device = NULL, /* ditto */
1017}; 1022};
1018 1023
1019#ifdef CONFIG_PROC_FS 1024#ifdef CONFIG_PROC_FS
@@ -1062,7 +1067,7 @@ static int ccio_proc_info(struct seq_file *m, void *p)
1062 ioc->msingle_calls, ioc->msingle_pages, 1067 ioc->msingle_calls, ioc->msingle_pages,
1063 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); 1068 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls));
1064 1069
1065 /* KLUGE - unmap_sg calls unmap_single for each mapped page */ 1070 /* KLUGE - unmap_sg calls unmap_page for each mapped page */
1066 min = ioc->usingle_calls - ioc->usg_calls; 1071 min = ioc->usingle_calls - ioc->usg_calls;
1067 max = ioc->usingle_pages - ioc->usg_pages; 1072 max = ioc->usingle_pages - ioc->usg_pages;
1068 seq_printf(m, "pci_unmap_single: %8ld calls %8ld pages (avg %d/1000)\n", 1073 seq_printf(m, "pci_unmap_single: %8ld calls %8ld pages (avg %d/1000)\n",