tioca_provider.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (c) 2003-2005 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #ifndef _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H
  9. #define _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H
  10. #include <asm/sn/tioca.h>
  11. /*
  12. * WAR enables
  13. * Defines for individual WARs. Each is a bitmask of applicable
  14. * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B,
  15. * (3 << 1) == (rev A or rev B), etc
  16. */
  17. #define TIOCA_WAR_ENABLED(pv, tioca_common) \
  18. ((1 << tioca_common->ca_rev) & pv)
  19. /* TIO:ICE:FRZ:Freezer loses a PIO data ucred on PIO RD RSP with CW error */
  20. #define PV907908 (1 << 1)
  21. /* ATI config space problems after BIOS execution starts */
  22. #define PV908234 (1 << 1)
  23. /* CA:AGPDMA write request data mismatch with ABC1CL merge */
  24. #define PV895469 (1 << 1)
  25. /* TIO:CA TLB invalidate of written GART entries possibly not occurring in CA*/
  26. #define PV910244 (1 << 1)
  27. struct tioca_dmamap{
  28. struct list_head cad_list; /* headed by ca_list */
  29. dma_addr_t cad_dma_addr; /* Linux dma handle */
  30. uint cad_gart_entry; /* start entry in ca_gart_pagemap */
  31. uint cad_gart_size; /* #entries for this map */
  32. };
  33. /*
  34. * Kernel only fields. Prom may look at this stuff for debugging only.
  35. * Access this structure through the ca_kernel_private ptr.
  36. */
  37. struct tioca_common ;
  38. struct tioca_kernel {
  39. struct tioca_common *ca_common; /* tioca this belongs to */
  40. struct list_head ca_list; /* list of all ca's */
  41. struct list_head ca_dmamaps;
  42. spinlock_t ca_lock; /* Kernel lock */
  43. cnodeid_t ca_closest_node;
  44. struct list_head *ca_devices; /* bus->devices */
  45. /*
  46. * General GART stuff
  47. */
  48. u64 ca_ap_size; /* size of aperature in bytes */
  49. u32 ca_gart_entries; /* # u64 entries in gart */
  50. u32 ca_ap_pagesize; /* aperature page size in bytes */
  51. u64 ca_ap_bus_base; /* bus address of CA aperature */
  52. u64 ca_gart_size; /* gart size in bytes */
  53. u64 *ca_gart; /* gart table vaddr */
  54. u64 ca_gart_coretalk_addr; /* gart coretalk addr */
  55. u8 ca_gart_iscoherent; /* used in tioca_tlbflush */
  56. /* PCI GART convenience values */
  57. u64 ca_pciap_base; /* pci aperature bus base address */
  58. u64 ca_pciap_size; /* pci aperature size (bytes) */
  59. u64 ca_pcigart_base; /* gfx GART bus base address */
  60. u64 *ca_pcigart; /* gfx GART vm address */
  61. u32 ca_pcigart_entries;
  62. u32 ca_pcigart_start; /* PCI start index in ca_gart */
  63. void *ca_pcigart_pagemap;
  64. /* AGP GART convenience values */
  65. u64 ca_gfxap_base; /* gfx aperature bus base address */
  66. u64 ca_gfxap_size; /* gfx aperature size (bytes) */
  67. u64 ca_gfxgart_base; /* gfx GART bus base address */
  68. u64 *ca_gfxgart; /* gfx GART vm address */
  69. u32 ca_gfxgart_entries;
  70. u32 ca_gfxgart_start; /* agpgart start index in ca_gart */
  71. };
  72. /*
  73. * Common tioca info shared between kernel and prom
  74. *
  75. * DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES
  76. * TO THE PROM VERSION.
  77. */
  78. struct tioca_common {
  79. struct pcibus_bussoft ca_common; /* common pciio header */
  80. u32 ca_rev;
  81. u32 ca_closest_nasid;
  82. u64 ca_prom_private;
  83. u64 ca_kernel_private;
  84. };
  85. /**
  86. * tioca_paddr_to_gart - Convert an SGI coretalk address to a CA GART entry
  87. * @paddr: page address to convert
  88. *
  89. * Convert a system [coretalk] address to a GART entry. GART entries are
  90. * formed using the following:
  91. *
  92. * data = ( (1<<63) | ( (REMAP_NODE_ID << 40) | (MD_CHIPLET_ID << 38) |
  93. * (REMAP_SYS_ADDR) ) >> 12 )
  94. *
  95. * DATA written to 1 GART TABLE Entry in system memory is remapped system
  96. * addr for 1 page
  97. *
  98. * The data is for coretalk address format right shifted 12 bits with a
  99. * valid bit.
  100. *
  101. * GART_TABLE_ENTRY [ 25:0 ] -- REMAP_SYS_ADDRESS[37:12].
  102. * GART_TABLE_ENTRY [ 27:26 ] -- SHUB MD chiplet id.
  103. * GART_TABLE_ENTRY [ 41:28 ] -- REMAP_NODE_ID.
  104. * GART_TABLE_ENTRY [ 63 ] -- Valid Bit
  105. */
  106. static inline u64
  107. tioca_paddr_to_gart(unsigned long paddr)
  108. {
  109. /*
  110. * We are assuming right now that paddr already has the correct
  111. * format since the address from xtalk_dmaXXX should already have
  112. * NODE_ID, CHIPLET_ID, and SYS_ADDR in the correct locations.
  113. */
  114. return ((paddr) >> 12) | (1UL << 63);
  115. }
  116. /**
  117. * tioca_physpage_to_gart - Map a host physical page for SGI CA based DMA
  118. * @page_addr: system page address to map
  119. */
  120. static inline unsigned long
  121. tioca_physpage_to_gart(u64 page_addr)
  122. {
  123. u64 coretalk_addr;
  124. coretalk_addr = PHYS_TO_TIODMA(page_addr);
  125. if (!coretalk_addr) {
  126. return 0;
  127. }
  128. return tioca_paddr_to_gart(coretalk_addr);
  129. }
  130. /**
  131. * tioca_tlbflush - invalidate cached SGI CA GART TLB entries
  132. * @tioca_kernel: CA context
  133. *
  134. * Invalidate tlb entries for a given CA GART. Main complexity is to account
  135. * for revA bug.
  136. */
  137. static inline void
  138. tioca_tlbflush(struct tioca_kernel *tioca_kernel)
  139. {
  140. volatile u64 tmp;
  141. volatile struct tioca __iomem *ca_base;
  142. struct tioca_common *tioca_common;
  143. tioca_common = tioca_kernel->ca_common;
  144. ca_base = (struct tioca __iomem *)tioca_common->ca_common.bs_base;
  145. /*
  146. * Explicit flushes not needed if GART is in cached mode
  147. */
  148. if (tioca_kernel->ca_gart_iscoherent) {
  149. if (TIOCA_WAR_ENABLED(PV910244, tioca_common)) {
  150. /*
  151. * PV910244: RevA CA needs explicit flushes.
  152. * Need to put GART into uncached mode before
  153. * flushing otherwise the explicit flush is ignored.
  154. *
  155. * Alternate WAR would be to leave GART cached and
  156. * touch every CL aligned GART entry.
  157. */
  158. __sn_clrq_relaxed(&ca_base->ca_control2, CA_GART_MEM_PARAM);
  159. __sn_setq_relaxed(&ca_base->ca_control2, CA_GART_FLUSH_TLB);
  160. __sn_setq_relaxed(&ca_base->ca_control2,
  161. (0x2ull << CA_GART_MEM_PARAM_SHFT));
  162. tmp = __sn_readq_relaxed(&ca_base->ca_control2);
  163. }
  164. return;
  165. }
  166. /*
  167. * Gart in uncached mode ... need an explicit flush.
  168. */
  169. __sn_setq_relaxed(&ca_base->ca_control2, CA_GART_FLUSH_TLB);
  170. tmp = __sn_readq_relaxed(&ca_base->ca_control2);
  171. }
  172. extern u32 tioca_gart_found;
  173. extern struct list_head tioca_list;
  174. extern int tioca_init_provider(void);
  175. extern void tioca_fastwrite_enable(struct tioca_kernel *tioca_kern);
  176. #endif /* _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H */