amd64_edac_dbg.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #include "amd64_edac.h"
  2. /*
  3. * accept a hex value and store it into the virtual error register file, field:
  4. * nbeal and nbeah. Assume virtual error values have already been set for: NBSL,
  5. * NBSH and NBCFG. Then proceed to map the error values to a MC, CSROW and
  6. * CHANNEL
  7. */
  8. static ssize_t amd64_nbea_store(struct mem_ctl_info *mci, const char *data,
  9. size_t count)
  10. {
  11. struct amd64_pvt *pvt = mci->pvt_info;
  12. unsigned long long value;
  13. int ret = 0;
  14. ret = strict_strtoull(data, 16, &value);
  15. if (ret != -EINVAL) {
  16. debugf0("received NBEA= 0x%llx\n", value);
  17. /* place the value into the virtual error packet */
  18. pvt->ctl_error_info.nbeal = (u32) value;
  19. value >>= 32;
  20. pvt->ctl_error_info.nbeah = (u32) value;
  21. /* Process the Mapping request */
  22. /* TODO: Add race prevention */
  23. amd64_process_error_info(mci, &pvt->ctl_error_info, 1);
  24. return count;
  25. }
  26. return ret;
  27. }
  28. /* display back what the last NBEA (MCA NB Address (MC4_ADDR)) was written */
  29. static ssize_t amd64_nbea_show(struct mem_ctl_info *mci, char *data)
  30. {
  31. struct amd64_pvt *pvt = mci->pvt_info;
  32. u64 value;
  33. value = pvt->ctl_error_info.nbeah;
  34. value <<= 32;
  35. value |= pvt->ctl_error_info.nbeal;
  36. return sprintf(data, "%llx\n", value);
  37. }
  38. /* store the NBSL (MCA NB Status Low (MC4_STATUS)) value user desires */
  39. static ssize_t amd64_nbsl_store(struct mem_ctl_info *mci, const char *data,
  40. size_t count)
  41. {
  42. struct amd64_pvt *pvt = mci->pvt_info;
  43. unsigned long value;
  44. int ret = 0;
  45. ret = strict_strtoul(data, 16, &value);
  46. if (ret != -EINVAL) {
  47. debugf0("received NBSL= 0x%lx\n", value);
  48. pvt->ctl_error_info.nbsl = (u32) value;
  49. return count;
  50. }
  51. return ret;
  52. }
  53. /* display back what the last NBSL value written */
  54. static ssize_t amd64_nbsl_show(struct mem_ctl_info *mci, char *data)
  55. {
  56. struct amd64_pvt *pvt = mci->pvt_info;
  57. u32 value;
  58. value = pvt->ctl_error_info.nbsl;
  59. return sprintf(data, "%x\n", value);
  60. }
  61. /* store the NBSH (MCA NB Status High) value user desires */
  62. static ssize_t amd64_nbsh_store(struct mem_ctl_info *mci, const char *data,
  63. size_t count)
  64. {
  65. struct amd64_pvt *pvt = mci->pvt_info;
  66. unsigned long value;
  67. int ret = 0;
  68. ret = strict_strtoul(data, 16, &value);
  69. if (ret != -EINVAL) {
  70. debugf0("received NBSH= 0x%lx\n", value);
  71. pvt->ctl_error_info.nbsh = (u32) value;
  72. return count;
  73. }
  74. return ret;
  75. }
  76. /* display back what the last NBSH value written */
  77. static ssize_t amd64_nbsh_show(struct mem_ctl_info *mci, char *data)
  78. {
  79. struct amd64_pvt *pvt = mci->pvt_info;
  80. u32 value;
  81. value = pvt->ctl_error_info.nbsh;
  82. return sprintf(data, "%x\n", value);
  83. }
  84. /* accept and store the NBCFG (MCA NB Configuration) value user desires */
  85. static ssize_t amd64_nbcfg_store(struct mem_ctl_info *mci,
  86. const char *data, size_t count)
  87. {
  88. struct amd64_pvt *pvt = mci->pvt_info;
  89. unsigned long value;
  90. int ret = 0;
  91. ret = strict_strtoul(data, 16, &value);
  92. if (ret != -EINVAL) {
  93. debugf0("received NBCFG= 0x%lx\n", value);
  94. pvt->ctl_error_info.nbcfg = (u32) value;
  95. return count;
  96. }
  97. return ret;
  98. }
  99. /* various show routines for the controls of a MCI */
  100. static ssize_t amd64_nbcfg_show(struct mem_ctl_info *mci, char *data)
  101. {
  102. struct amd64_pvt *pvt = mci->pvt_info;
  103. return sprintf(data, "%x\n", pvt->ctl_error_info.nbcfg);
  104. }
  105. static ssize_t amd64_dhar_show(struct mem_ctl_info *mci, char *data)
  106. {
  107. struct amd64_pvt *pvt = mci->pvt_info;
  108. return sprintf(data, "%x\n", pvt->dhar);
  109. }
  110. static ssize_t amd64_dbam_show(struct mem_ctl_info *mci, char *data)
  111. {
  112. struct amd64_pvt *pvt = mci->pvt_info;
  113. return sprintf(data, "%x\n", pvt->dbam0);
  114. }
  115. static ssize_t amd64_topmem_show(struct mem_ctl_info *mci, char *data)
  116. {
  117. struct amd64_pvt *pvt = mci->pvt_info;
  118. return sprintf(data, "%llx\n", pvt->top_mem);
  119. }
  120. static ssize_t amd64_topmem2_show(struct mem_ctl_info *mci, char *data)
  121. {
  122. struct amd64_pvt *pvt = mci->pvt_info;
  123. return sprintf(data, "%llx\n", pvt->top_mem2);
  124. }
  125. static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
  126. {
  127. u64 hole_base = 0;
  128. u64 hole_offset = 0;
  129. u64 hole_size = 0;
  130. amd64_get_dram_hole_info(mci, &hole_base, &hole_offset, &hole_size);
  131. return sprintf(data, "%llx %llx %llx\n", hole_base, hole_offset,
  132. hole_size);
  133. }
  134. /*
  135. * update NUM_DBG_ATTRS in case you add new members
  136. */
  137. struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
  138. {
  139. .attr = {
  140. .name = "nbea_ctl",
  141. .mode = (S_IRUGO | S_IWUSR)
  142. },
  143. .show = amd64_nbea_show,
  144. .store = amd64_nbea_store,
  145. },
  146. {
  147. .attr = {
  148. .name = "nbsl_ctl",
  149. .mode = (S_IRUGO | S_IWUSR)
  150. },
  151. .show = amd64_nbsl_show,
  152. .store = amd64_nbsl_store,
  153. },
  154. {
  155. .attr = {
  156. .name = "nbsh_ctl",
  157. .mode = (S_IRUGO | S_IWUSR)
  158. },
  159. .show = amd64_nbsh_show,
  160. .store = amd64_nbsh_store,
  161. },
  162. {
  163. .attr = {
  164. .name = "nbcfg_ctl",
  165. .mode = (S_IRUGO | S_IWUSR)
  166. },
  167. .show = amd64_nbcfg_show,
  168. .store = amd64_nbcfg_store,
  169. },
  170. {
  171. .attr = {
  172. .name = "dhar",
  173. .mode = (S_IRUGO)
  174. },
  175. .show = amd64_dhar_show,
  176. .store = NULL,
  177. },
  178. {
  179. .attr = {
  180. .name = "dbam",
  181. .mode = (S_IRUGO)
  182. },
  183. .show = amd64_dbam_show,
  184. .store = NULL,
  185. },
  186. {
  187. .attr = {
  188. .name = "topmem",
  189. .mode = (S_IRUGO)
  190. },
  191. .show = amd64_topmem_show,
  192. .store = NULL,
  193. },
  194. {
  195. .attr = {
  196. .name = "topmem2",
  197. .mode = (S_IRUGO)
  198. },
  199. .show = amd64_topmem2_show,
  200. .store = NULL,
  201. },
  202. {
  203. .attr = {
  204. .name = "dram_hole",
  205. .mode = (S_IRUGO)
  206. },
  207. .show = amd64_hole_show,
  208. .store = NULL,
  209. },
  210. };