aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch
blob: d6dd5f0aaeadf16689cfdbddaed6e0eb8df4ddb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From: George Kashperko <george@znau.edu.ua>

broadcom-wl driver bound to ssb device with ssb driver probe
have osh handle struct pdev pointer value initialized with
ssb_device pointer. Later on pdev is used with legacy pci
dma api as pci_dev thus causing oops sometimes.

The patch replaces legacy pci dma api and pass relevant
device struct pointer to avoid crashes.
Signed-off-by: George Kashperko <george@znau.edu.ua>
---
 driver/linux_osl.c |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -25,6 +25,9 @@
 #include <asm/paccess.h>
 #endif /* mips */
 #include <pcicfg.h>
+#ifdef CONFIG_SSB
+#include <linux/ssb/ssb.h>
+#endif
 
 #define PCI_CFG_RETRY 		10
 
@@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
 	return (PAGE_SIZE);
 }
 
+static struct device *
+osl_get_dmadev(osl_t *osh)
+{
+#ifdef CONFIG_SSB
+	if (osh->bustype == SI_BUS) {
+		/* This can be SiliconBackplane emulated as pci with Broadcom or
+		 * ssb device. Less harmful is to check for pci_bus_type and if
+		 * no match then assume we got ssb */
+		if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
+			return ((struct ssb_device *)osh->pdev)->dma_dev;
+	}
+#endif
+	return &((struct pci_dev *)osh->pdev)->dev;
+}
+
 void*
 osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
 {
 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
 
-	return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
+	return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
 }
 
 void
@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
 {
 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
 
-	pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
+	dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
 }
 
 uint BCMFASTPATH
@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
 
 	if (direction == DMA_TX)
-		return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
+		return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
 	else {
 #ifdef mips
 		dma_cache_inv((uint)va, size);
 		return (virt_to_phys(va));
 #else /* mips */
-		return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
+		return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
 #endif /* mips */
 	}
 }
@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
 
 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
 	dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
-	pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
+	dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
 }
 
 
s="nv">$$(if $$(_PROFILE_SET),legacy-images,install-disabled) $$(if $$(_PROFILE_SET),install: legacy-images-make) ifndef IB $$(if $$(_PROFILE_SET),kernel_prepare: legacy-images-prepare-make) endif endef ifdef TARGET_PER_DEVICE_ROOTFS define Image/Build/Profile/Filesystem cp $(KDIR)/root.$(2)+pkg=$(3) $(KDIR)/root.$(2) $(call Image/Build/Profile,$(1),$(2)) endef else Image/Build/Profile/Filesystem = $(Image/Build/Profile) endif define LegacyDevice/Build $$(_TARGET): legacy-image-$(1) $$(_TARGET_PREPARE): legacy-image-prepare-$(1) .PHONY: legacy-image-prepare-$(1) legacy-image-$(1) legacy-image-prepare-$(1): $$(call Image/Prepare/Profile,$(1)) ifndef IB ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS ROOTFS/$(1) := $(foreach fs,$(TARGET_FILESYSTEMS), \ $(KDIR)/root.$(fs)$$(strip $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1)))) \ ) $$(ROOTFS/$(1)): target-dir-$$(ROOTFS_ID/$(1)) legacy-images-make: $$(if $$(_PROFILE_SET),$$(ROOTFS/$(1))) endif endif legacy-image-$(1): $$(call Image/BuildKernel/Profile,$(1)) $(foreach fs,$(TARGET_FILESYSTEMS), $$(call Image/Build/Profile/Filesystem,$(1),$(fs),$$(ROOTFS_ID/$(1))) ) endef define LegacyDevice $(call Device/InitProfile,$(1)) $(call Device/Default,$(1)) $(call LegacyDevice/Default,$(1)) $(call LegacyDevice/$(1),$(1)) $(call LegacyDevice/Check,$(1)) $(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1)) endef