diff options
author | Christoph Hellwig <hch@lst.de> | 2016-01-20 18:01:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-20 20:09:18 -0500 |
commit | 79387179e2e4fede52326e4c4e26145dbd6b505c (patch) | |
tree | 1ba83f9abcb6592b13ff4539df64211be1fb1de8 /drivers/parisc | |
parent | eae075196305549513335c2fc7d5d63712246bfd (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')
-rw-r--r-- | drivers/parisc/ccio-dma.c | 57 | ||||
-rw-r--r-- | drivers/parisc/sba_iommu.c | 52 |
2 files changed, 60 insertions, 49 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 | |||
790 | static dma_addr_t | ||
791 | ccio_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 | */ |
798 | static void | 807 | static void |
799 | ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size, | 808 | ccio_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 | */ |
836 | static void * | 845 | static void * |
837 | ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) | 846 | ccio_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 | */ |
869 | static void | 879 | static void |
870 | ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr, | 880 | ccio_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 | */ |
898 | static int | 908 | static int |
899 | ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | 909 | ccio_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 | */ |
975 | static void | 985 | static void |
976 | ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, | 986 | ccio_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 | ||
1004 | static struct hppa_dma_ops ccio_ops = { | 1014 | static 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", |
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c index 225049b492e5..42ec4600b7e4 100644 --- a/drivers/parisc/sba_iommu.c +++ b/drivers/parisc/sba_iommu.c | |||
@@ -780,8 +780,18 @@ sba_map_single(struct device *dev, void *addr, size_t size, | |||
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | static dma_addr_t | ||
784 | sba_map_page(struct device *dev, struct page *page, unsigned long offset, | ||
785 | size_t size, enum dma_data_direction direction, | ||
786 | struct dma_attrs *attrs) | ||
787 | { | ||
788 | return sba_map_single(dev, page_address(page) + offset, size, | ||
789 | direction); | ||
790 | } | ||
791 | |||
792 | |||
783 | /** | 793 | /** |
784 | * sba_unmap_single - unmap one IOVA and free resources | 794 | * sba_unmap_page - unmap one IOVA and free resources |
785 | * @dev: instance of PCI owned by the driver that's asking. | 795 | * @dev: instance of PCI owned by the driver that's asking. |
786 | * @iova: IOVA of driver buffer previously mapped. | 796 | * @iova: IOVA of driver buffer previously mapped. |
787 | * @size: number of bytes mapped in driver buffer. | 797 | * @size: number of bytes mapped in driver buffer. |
@@ -790,8 +800,8 @@ sba_map_single(struct device *dev, void *addr, size_t size, | |||
790 | * See Documentation/DMA-API-HOWTO.txt | 800 | * See Documentation/DMA-API-HOWTO.txt |
791 | */ | 801 | */ |
792 | static void | 802 | static void |
793 | sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, | 803 | sba_unmap_page(struct device *dev, dma_addr_t iova, size_t size, |
794 | enum dma_data_direction direction) | 804 | enum dma_data_direction direction, struct dma_attrs *attrs) |
795 | { | 805 | { |
796 | struct ioc *ioc; | 806 | struct ioc *ioc; |
797 | #if DELAYED_RESOURCE_CNT > 0 | 807 | #if DELAYED_RESOURCE_CNT > 0 |
@@ -858,15 +868,15 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, | |||
858 | 868 | ||
859 | 869 | ||
860 | /** | 870 | /** |
861 | * sba_alloc_consistent - allocate/map shared mem for DMA | 871 | * sba_alloc - allocate/map shared mem for DMA |
862 | * @hwdev: instance of PCI owned by the driver that's asking. | 872 | * @hwdev: instance of PCI owned by the driver that's asking. |
863 | * @size: number of bytes mapped in driver buffer. | 873 | * @size: number of bytes mapped in driver buffer. |
864 | * @dma_handle: IOVA of new buffer. | 874 | * @dma_handle: IOVA of new buffer. |
865 | * | 875 | * |
866 | * See Documentation/DMA-API-HOWTO.txt | 876 | * See Documentation/DMA-API-HOWTO.txt |
867 | */ | 877 | */ |
868 | static void *sba_alloc_consistent(struct device *hwdev, size_t size, | 878 | static void *sba_alloc(struct device *hwdev, size_t size, dma_addr_t *dma_handle, |
869 | dma_addr_t *dma_handle, gfp_t gfp) | 879 | gfp_t gfp, struct dma_attrs *attrs) |
870 | { | 880 | { |
871 | void *ret; | 881 | void *ret; |
872 | 882 | ||
@@ -888,7 +898,7 @@ static void *sba_alloc_consistent(struct device *hwdev, size_t size, | |||
888 | 898 | ||
889 | 899 | ||
890 | /** | 900 | /** |
891 | * sba_free_consistent - free/unmap shared mem for DMA | 901 | * sba_free - free/unmap shared mem for DMA |
892 | * @hwdev: instance of PCI owned by the driver that's asking. | 902 | * @hwdev: instance of PCI owned by the driver that's asking. |
893 | * @size: number of bytes mapped in driver buffer. | 903 | * @size: number of bytes mapped in driver buffer. |
894 | * @vaddr: virtual address IOVA of "consistent" buffer. | 904 | * @vaddr: virtual address IOVA of "consistent" buffer. |
@@ -897,10 +907,10 @@ static void *sba_alloc_consistent(struct device *hwdev, size_t size, | |||
897 | * See Documentation/DMA-API-HOWTO.txt | 907 | * See Documentation/DMA-API-HOWTO.txt |
898 | */ | 908 | */ |
899 | static void | 909 | static void |
900 | sba_free_consistent(struct device *hwdev, size_t size, void *vaddr, | 910 | sba_free(struct device *hwdev, size_t size, void *vaddr, |
901 | dma_addr_t dma_handle) | 911 | dma_addr_t dma_handle, struct dma_attrs *attrs) |
902 | { | 912 | { |
903 | sba_unmap_single(hwdev, dma_handle, size, 0); | 913 | sba_unmap_page(hwdev, dma_handle, size, 0, NULL); |
904 | free_pages((unsigned long) vaddr, get_order(size)); | 914 | free_pages((unsigned long) vaddr, get_order(size)); |
905 | } | 915 | } |
906 | 916 | ||
@@ -933,7 +943,7 @@ int dump_run_sg = 0; | |||
933 | */ | 943 | */ |
934 | static int | 944 | static int |
935 | sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | 945 | sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, |
936 | enum dma_data_direction direction) | 946 | enum dma_data_direction direction, struct dma_attrs *attrs) |
937 | { | 947 | { |
938 | struct ioc *ioc; | 948 | struct ioc *ioc; |
939 | int coalesced, filled = 0; | 949 | int coalesced, filled = 0; |
@@ -1016,7 +1026,7 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
1016 | */ | 1026 | */ |
1017 | static void | 1027 | static void |
1018 | sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, | 1028 | sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, |
1019 | enum dma_data_direction direction) | 1029 | enum dma_data_direction direction, struct dma_attrs *attrs) |
1020 | { | 1030 | { |
1021 | struct ioc *ioc; | 1031 | struct ioc *ioc; |
1022 | #ifdef ASSERT_PDIR_SANITY | 1032 | #ifdef ASSERT_PDIR_SANITY |
@@ -1040,7 +1050,8 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
1040 | 1050 | ||
1041 | while (sg_dma_len(sglist) && nents--) { | 1051 | while (sg_dma_len(sglist) && nents--) { |
1042 | 1052 | ||
1043 | sba_unmap_single(dev, sg_dma_address(sglist), sg_dma_len(sglist), direction); | 1053 | sba_unmap_page(dev, sg_dma_address(sglist), sg_dma_len(sglist), |
1054 | direction, NULL); | ||
1044 | #ifdef SBA_COLLECT_STATS | 1055 | #ifdef SBA_COLLECT_STATS |
1045 | ioc->usg_pages += ((sg_dma_address(sglist) & ~IOVP_MASK) + sg_dma_len(sglist) + IOVP_SIZE - 1) >> PAGE_SHIFT; | 1056 | ioc->usg_pages += ((sg_dma_address(sglist) & ~IOVP_MASK) + sg_dma_len(sglist) + IOVP_SIZE - 1) >> PAGE_SHIFT; |
1046 | ioc->usingle_calls--; /* kluge since call is unmap_sg() */ | 1057 | ioc->usingle_calls--; /* kluge since call is unmap_sg() */ |
@@ -1058,19 +1069,14 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
1058 | 1069 | ||
1059 | } | 1070 | } |
1060 | 1071 | ||
1061 | static struct hppa_dma_ops sba_ops = { | 1072 | static struct dma_map_ops sba_ops = { |
1062 | .dma_supported = sba_dma_supported, | 1073 | .dma_supported = sba_dma_supported, |
1063 | .alloc_consistent = sba_alloc_consistent, | 1074 | .alloc = sba_alloc, |
1064 | .alloc_noncoherent = sba_alloc_consistent, | 1075 | .free = sba_free, |
1065 | .free_consistent = sba_free_consistent, | 1076 | .map_page = sba_map_page, |
1066 | .map_single = sba_map_single, | 1077 | .unmap_page = sba_unmap_page, |
1067 | .unmap_single = sba_unmap_single, | ||
1068 | .map_sg = sba_map_sg, | 1078 | .map_sg = sba_map_sg, |
1069 | .unmap_sg = sba_unmap_sg, | 1079 | .unmap_sg = sba_unmap_sg, |
1070 | .dma_sync_single_for_cpu = NULL, | ||
1071 | .dma_sync_single_for_device = NULL, | ||
1072 | .dma_sync_sg_for_cpu = NULL, | ||
1073 | .dma_sync_sg_for_device = NULL, | ||
1074 | }; | 1080 | }; |
1075 | 1081 | ||
1076 | 1082 | ||