006-generic-dma-api.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From: George Kashperko <george@znau.edu.ua>
  2. broadcom-wl driver bound to ssb device with ssb driver probe
  3. have osh handle struct pdev pointer value initialized with
  4. ssb_device pointer. Later on pdev is used with legacy pci
  5. dma api as pci_dev thus causing oops sometimes.
  6. The patch replaces legacy pci dma api and pass relevant
  7. device struct pointer to avoid crashes.
  8. Signed-off-by: George Kashperko <george@znau.edu.ua>
  9. ---
  10. driver/linux_osl.c | 28 +++++++++++++++++++++++-----
  11. 1 file changed, 23 insertions(+), 5 deletions(-)
  12. --- a/driver/linux_osl.c
  13. +++ b/driver/linux_osl.c
  14. @@ -25,6 +25,9 @@
  15. #include <asm/paccess.h>
  16. #endif /* mips */
  17. #include <pcicfg.h>
  18. +#ifdef CONFIG_SSB
  19. +#include <linux/ssb/ssb.h>
  20. +#endif
  21. #define PCI_CFG_RETRY 10
  22. @@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
  23. return (PAGE_SIZE);
  24. }
  25. +static struct device *
  26. +osl_get_dmadev(osl_t *osh)
  27. +{
  28. +#ifdef CONFIG_SSB
  29. + if (osh->bustype == SI_BUS) {
  30. + /* This can be SiliconBackplane emulated as pci with Broadcom or
  31. + * ssb device. Less harmful is to check for pci_bus_type and if
  32. + * no match then assume we got ssb */
  33. + if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
  34. + return ((struct ssb_device *)osh->pdev)->dma_dev;
  35. + }
  36. +#endif
  37. + return &((struct pci_dev *)osh->pdev)->dev;
  38. +}
  39. +
  40. void*
  41. osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
  42. {
  43. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  44. - return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
  45. + return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
  46. }
  47. void
  48. @@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
  49. {
  50. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  51. - pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
  52. + dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
  53. }
  54. uint BCMFASTPATH
  55. @@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
  56. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  57. if (direction == DMA_TX)
  58. - return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
  59. + return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
  60. else {
  61. #ifdef mips
  62. dma_cache_inv((uint)va, size);
  63. return (virt_to_phys(va));
  64. #else /* mips */
  65. - return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
  66. + return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
  67. #endif /* mips */
  68. }
  69. }
  70. @@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
  71. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  72. dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
  73. - pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
  74. + dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
  75. }