9069-Revert-arm64-simplify-dma_get_ops.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 4885eb650b27f5639c8c72b8d4daa37f533b0b4d Mon Sep 17 00:00:00 2001
  2. From: Yutang Jiang <yutang.jiang@nxp.com>
  3. Date: Fri, 22 Jul 2016 01:03:29 +0800
  4. Subject: [PATCH 69/70] Revert "arm64: simplify dma_get_ops"
  5. This reverts commit 1dccb598df549d892b6450c261da54cdd7af44b4.
  6. ---
  7. arch/arm64/include/asm/dma-mapping.h | 13 ++++++++++---
  8. arch/arm64/mm/dma-mapping.c | 16 ++++++++++++----
  9. 2 files changed, 22 insertions(+), 7 deletions(-)
  10. --- a/arch/arm64/include/asm/dma-mapping.h
  11. +++ b/arch/arm64/include/asm/dma-mapping.h
  12. @@ -18,6 +18,7 @@
  13. #ifdef __KERNEL__
  14. +#include <linux/acpi.h>
  15. #include <linux/types.h>
  16. #include <linux/vmalloc.h>
  17. @@ -25,16 +26,22 @@
  18. #include <asm/xen/hypervisor.h>
  19. #define DMA_ERROR_CODE (~(dma_addr_t)0)
  20. +extern struct dma_map_ops *dma_ops;
  21. extern struct dma_map_ops dummy_dma_ops;
  22. static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
  23. {
  24. - if (dev && dev->archdata.dma_ops)
  25. + if (unlikely(!dev))
  26. + return dma_ops;
  27. + else if (dev->archdata.dma_ops)
  28. return dev->archdata.dma_ops;
  29. + else if (acpi_disabled)
  30. + return dma_ops;
  31. /*
  32. - * We expect no ISA devices, and all other DMA masters are expected to
  33. - * have someone call arch_setup_dma_ops at device creation time.
  34. + * When ACPI is enabled, if arch_set_dma_ops is not called,
  35. + * we will disable device DMA capability by setting it
  36. + * to dummy_dma_ops.
  37. */
  38. return &dummy_dma_ops;
  39. }
  40. --- a/arch/arm64/mm/dma-mapping.c
  41. +++ b/arch/arm64/mm/dma-mapping.c
  42. @@ -18,7 +18,6 @@
  43. */
  44. #include <linux/gfp.h>
  45. -#include <linux/acpi.h>
  46. #include <linux/export.h>
  47. #include <linux/slab.h>
  48. #include <linux/genalloc.h>
  49. @@ -29,6 +28,9 @@
  50. #include <asm/cacheflush.h>
  51. +struct dma_map_ops *dma_ops;
  52. +EXPORT_SYMBOL(dma_ops);
  53. +
  54. static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
  55. bool coherent)
  56. {
  57. @@ -513,7 +515,13 @@ EXPORT_SYMBOL(dummy_dma_ops);
  58. static int __init arm64_dma_init(void)
  59. {
  60. - return atomic_pool_init();
  61. + int ret;
  62. +
  63. + dma_ops = &swiotlb_dma_ops;
  64. +
  65. + ret = atomic_pool_init();
  66. +
  67. + return ret;
  68. }
  69. arch_initcall(arm64_dma_init);
  70. @@ -987,8 +995,8 @@ static void __iommu_setup_dma_ops(struct
  71. void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
  72. struct iommu_ops *iommu, bool coherent)
  73. {
  74. - if (!dev->archdata.dma_ops)
  75. - dev->archdata.dma_ops = &swiotlb_dma_ops;
  76. + if (!acpi_disabled && !dev->archdata.dma_ops)
  77. + dev->archdata.dma_ops = dma_ops;
  78. dev->archdata.dma_coherent = coherent;
  79. __iommu_setup_dma_ops(dev, dma_base, size, iommu);