diff options
author | Todd Poynor <toddpoynor@google.com> | 2018-07-28 01:21:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-28 03:24:10 -0400 |
commit | 758c579ec631ce5efd8de3d3d35483416ae2cad1 (patch) | |
tree | e3ae6cda6005fca797f4f20d31a898735e9de0b4 | |
parent | 14d70229777f17fe3c22deb559821038663bae78 (diff) |
staging: gasket: page table: remove code for "no dma_ops"
Remove code with TODOs on it for working around apparent problems
previously seen in a qemu environment where dma_ops was not set
correctly. There is no user of this in the current code.
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/gasket/gasket_core.c | 2 | ||||
-rw-r--r-- | drivers/staging/gasket/gasket_page_table.c | 58 | ||||
-rw-r--r-- | drivers/staging/gasket/gasket_page_table.h | 3 |
3 files changed, 8 insertions, 55 deletions
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index f44805c38159..859a6df9e12d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c | |||
@@ -916,7 +916,7 @@ static int gasket_enable_dev( | |||
916 | &gasket_dev->bar_data[ | 916 | &gasket_dev->bar_data[ |
917 | driver_desc->page_table_bar_index], | 917 | driver_desc->page_table_bar_index], |
918 | &driver_desc->page_table_configs[tbl_idx], | 918 | &driver_desc->page_table_configs[tbl_idx], |
919 | gasket_dev->dev, gasket_dev->pci_dev, true); | 919 | gasket_dev->dev, gasket_dev->pci_dev); |
920 | if (ret) { | 920 | if (ret) { |
921 | dev_err(gasket_dev->dev, | 921 | dev_err(gasket_dev->dev, |
922 | "Couldn't init page table %d: %d\n", | 922 | "Couldn't init page table %d: %d\n", |
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 32f1c1e10c7e..722839603f20 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c | |||
@@ -212,12 +212,6 @@ struct gasket_page_table { | |||
212 | * gasket_mmap function, so user_virt belongs in the driver anyhow. | 212 | * gasket_mmap function, so user_virt belongs in the driver anyhow. |
213 | */ | 213 | */ |
214 | struct gasket_coherent_page_entry *coherent_pages; | 214 | struct gasket_coherent_page_entry *coherent_pages; |
215 | |||
216 | /* | ||
217 | * Whether the page table uses arch specific dma_ops or | ||
218 | * whether the driver is supplying its own. | ||
219 | */ | ||
220 | bool dma_ops; | ||
221 | }; | 215 | }; |
222 | 216 | ||
223 | /* Mapping declarations */ | 217 | /* Mapping declarations */ |
@@ -290,7 +284,7 @@ int gasket_page_table_init( | |||
290 | struct gasket_page_table **ppg_tbl, | 284 | struct gasket_page_table **ppg_tbl, |
291 | const struct gasket_bar_data *bar_data, | 285 | const struct gasket_bar_data *bar_data, |
292 | const struct gasket_page_table_config *page_table_config, | 286 | const struct gasket_page_table_config *page_table_config, |
293 | struct device *device, struct pci_dev *pci_dev, bool has_dma_ops) | 287 | struct device *device, struct pci_dev *pci_dev) |
294 | { | 288 | { |
295 | ulong bytes; | 289 | ulong bytes; |
296 | struct gasket_page_table *pg_tbl; | 290 | struct gasket_page_table *pg_tbl; |
@@ -353,7 +347,6 @@ int gasket_page_table_init( | |||
353 | bar_data->virt_base[page_table_config->extended_reg]); | 347 | bar_data->virt_base[page_table_config->extended_reg]); |
354 | pg_tbl->device = device; | 348 | pg_tbl->device = device; |
355 | pg_tbl->pci_dev = pci_dev; | 349 | pg_tbl->pci_dev = pci_dev; |
356 | pg_tbl->dma_ops = has_dma_ops; | ||
357 | 350 | ||
358 | dev_dbg(device, "Page table initialized successfully\n"); | 351 | dev_dbg(device, "Page table initialized successfully\n"); |
359 | 352 | ||
@@ -760,33 +753,6 @@ static int gasket_map_extended_pages( | |||
760 | } | 753 | } |
761 | 754 | ||
762 | /* | 755 | /* |
763 | * TODO: dma_map_page() is not plugged properly when running under qemu. i.e. | ||
764 | * dma_ops are not set properly, which causes the kernel to assert. | ||
765 | * | ||
766 | * This temporary hack allows the driver to work on qemu, but need to be fixed: | ||
767 | * - either manually set the dma_ops for the architecture (which incidentally | ||
768 | * can't be done in an out-of-tree module) - or get qemu to fill the device tree | ||
769 | * properly so as linux plug the proper dma_ops or so as the driver can detect | ||
770 | * that it is runnig on qemu | ||
771 | */ | ||
772 | static inline dma_addr_t _no_op_dma_map_page( | ||
773 | struct device *dev, struct page *page, size_t offset, size_t size, | ||
774 | enum dma_data_direction dir) | ||
775 | { | ||
776 | /* | ||
777 | * struct dma_map_ops *ops = get_dma_ops(dev); | ||
778 | * dma_addr_t addr; | ||
779 | * | ||
780 | * kmemcheck_mark_initialized(page_address(page) + offset, size); | ||
781 | * BUG_ON(!valid_dma_direction(dir)); | ||
782 | * addr = ops->map_page(dev, page, offset, size, dir, NULL); | ||
783 | * debug_dma_map_page(dev, page, offset, size, dir, addr, false); | ||
784 | */ | ||
785 | |||
786 | return page_to_phys(page); | ||
787 | } | ||
788 | |||
789 | /* | ||
790 | * Get and map last level page table buffers. | 756 | * Get and map last level page table buffers. |
791 | * @pg_tbl: Gasket page table pointer. | 757 | * @pg_tbl: Gasket page table pointer. |
792 | * @ptes: Array of page table entries to describe this mapping, one per | 758 | * @ptes: Array of page table entries to describe this mapping, one per |
@@ -856,16 +822,9 @@ static int gasket_perform_mapping( | |||
856 | ptes[i].offset = offset; | 822 | ptes[i].offset = offset; |
857 | 823 | ||
858 | /* Map the page into DMA space. */ | 824 | /* Map the page into DMA space. */ |
859 | if (pg_tbl->dma_ops) { | 825 | ptes[i].dma_addr = |
860 | /* hook in to kernel map functions */ | 826 | dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE, |
861 | ptes[i].dma_addr = dma_map_page(pg_tbl->device, | 827 | DMA_BIDIRECTIONAL); |
862 | page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
863 | } else { | ||
864 | ptes[i].dma_addr = _no_op_dma_map_page( | ||
865 | pg_tbl->device, page, 0, PAGE_SIZE, | ||
866 | DMA_BIDIRECTIONAL); | ||
867 | } | ||
868 | |||
869 | dev_dbg(pg_tbl->device, | 828 | dev_dbg(pg_tbl->device, |
870 | "%s i %d pte %p pfn %p -> mapped %llx\n", | 829 | "%s i %d pte %p pfn %p -> mapped %llx\n", |
871 | __func__, i, &ptes[i], | 830 | __func__, i, &ptes[i], |
@@ -1042,13 +1001,8 @@ static int gasket_alloc_extended_subtable( | |||
1042 | } | 1001 | } |
1043 | 1002 | ||
1044 | /* Map the page into DMA space. */ | 1003 | /* Map the page into DMA space. */ |
1045 | if (pg_tbl->dma_ops) { | 1004 | pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, |
1046 | pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, | 1005 | DMA_BIDIRECTIONAL); |
1047 | PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
1048 | } else { | ||
1049 | pte->dma_addr = _no_op_dma_map_page(pg_tbl->device, pte->page, | ||
1050 | 0, PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
1051 | } | ||
1052 | /* Wait until the page is mapped. */ | 1006 | /* Wait until the page is mapped. */ |
1053 | mb(); | 1007 | mb(); |
1054 | 1008 | ||
diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 0e8afdb8c113..765588649365 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h | |||
@@ -37,7 +37,6 @@ struct gasket_page_table; | |||
37 | * translation table. | 37 | * translation table. |
38 | * @device: Device structure for the underlying device. Only used for logging. | 38 | * @device: Device structure for the underlying device. Only used for logging. |
39 | * @pci_dev: PCI system descriptor for the underlying device. | 39 | * @pci_dev: PCI system descriptor for the underlying device. |
40 | * @bool has_dma_ops: Whether the page table uses arch specific dma_ops or | ||
41 | * whether the driver will supply its own. | 40 | * whether the driver will supply its own. |
42 | * | 41 | * |
43 | * Description: Allocates and initializes data to track address translation - | 42 | * Description: Allocates and initializes data to track address translation - |
@@ -51,7 +50,7 @@ int gasket_page_table_init( | |||
51 | struct gasket_page_table **ppg_tbl, | 50 | struct gasket_page_table **ppg_tbl, |
52 | const struct gasket_bar_data *bar_data, | 51 | const struct gasket_bar_data *bar_data, |
53 | const struct gasket_page_table_config *page_table_config, | 52 | const struct gasket_page_table_config *page_table_config, |
54 | struct device *device, struct pci_dev *pci_dev, bool dma_ops); | 53 | struct device *device, struct pci_dev *pci_dev); |
55 | 54 | ||
56 | /* | 55 | /* |
57 | * Deallocate and cleanup page table data. | 56 | * Deallocate and cleanup page table data. |