pci-nommu.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Fallback functions when the main IOMMU code is not compiled in. This
  2. code is roughly equivalent to i386. */
  3. #include <linux/mm.h>
  4. #include <linux/init.h>
  5. #include <linux/pci.h>
  6. #include <linux/string.h>
  7. #include <asm/proto.h>
  8. #include <asm/processor.h>
  9. int iommu_merge = 0;
  10. EXPORT_SYMBOL(iommu_merge);
  11. dma_addr_t bad_dma_address;
  12. EXPORT_SYMBOL(bad_dma_address);
  13. int iommu_bio_merge = 0;
  14. EXPORT_SYMBOL(iommu_bio_merge);
  15. int iommu_sac_force = 0;
  16. EXPORT_SYMBOL(iommu_sac_force);
  17. /*
  18. * Dummy IO MMU functions
  19. */
  20. void *dma_alloc_coherent(struct device *hwdev, size_t size,
  21. dma_addr_t *dma_handle, unsigned gfp)
  22. {
  23. void *ret;
  24. u64 mask;
  25. int order = get_order(size);
  26. if (hwdev)
  27. mask = hwdev->coherent_dma_mask & *hwdev->dma_mask;
  28. else
  29. mask = 0xffffffff;
  30. for (;;) {
  31. ret = (void *)__get_free_pages(gfp, order);
  32. if (ret == NULL)
  33. return NULL;
  34. *dma_handle = virt_to_bus(ret);
  35. if ((*dma_handle & ~mask) == 0)
  36. break;
  37. free_pages((unsigned long)ret, order);
  38. if (gfp & GFP_DMA)
  39. return NULL;
  40. gfp |= GFP_DMA;
  41. }
  42. memset(ret, 0, size);
  43. return ret;
  44. }
  45. EXPORT_SYMBOL(dma_alloc_coherent);
  46. void dma_free_coherent(struct device *hwdev, size_t size,
  47. void *vaddr, dma_addr_t dma_handle)
  48. {
  49. free_pages((unsigned long)vaddr, get_order(size));
  50. }
  51. EXPORT_SYMBOL(dma_free_coherent);
  52. int dma_supported(struct device *hwdev, u64 mask)
  53. {
  54. /*
  55. * we fall back to GFP_DMA when the mask isn't all 1s,
  56. * so we can't guarantee allocations that must be
  57. * within a tighter range than GFP_DMA..
  58. * RED-PEN this won't work for pci_map_single. Caller has to
  59. * use GFP_DMA in the first place.
  60. */
  61. if (mask < 0x00ffffff)
  62. return 0;
  63. return 1;
  64. }
  65. EXPORT_SYMBOL(dma_supported);
  66. int dma_get_cache_alignment(void)
  67. {
  68. return boot_cpu_data.x86_clflush_size;
  69. }
  70. EXPORT_SYMBOL(dma_get_cache_alignment);
  71. static int __init check_ram(void)
  72. {
  73. if (end_pfn >= 0xffffffff>>PAGE_SHIFT) {
  74. printk(
  75. KERN_ERR "WARNING more than 4GB of memory but IOMMU not compiled in.\n"
  76. KERN_ERR "WARNING 32bit PCI may malfunction.\n");
  77. }
  78. return 0;
  79. }
  80. __initcall(check_ram);