blacklist.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /*
  2. * blacklist.c
  3. *
  4. * Check to see if the given machine has a known bad ACPI BIOS
  5. * or if the BIOS is too old.
  6. * Check given machine against acpi_osi_dmi_table[].
  7. *
  8. * Copyright (C) 2004 Len Brown <len.brown@intel.com>
  9. * Copyright (C) 2002 Andy Grover <andrew.grover@intel.com>
  10. *
  11. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or (at
  16. * your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful, but
  19. * WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  26. *
  27. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/init.h>
  32. #include <linux/acpi.h>
  33. #include <acpi/acpi_bus.h>
  34. #include <linux/dmi.h>
  35. enum acpi_blacklist_predicates {
  36. all_versions,
  37. less_than_or_equal,
  38. equal,
  39. greater_than_or_equal,
  40. };
  41. struct acpi_blacklist_item {
  42. char oem_id[7];
  43. char oem_table_id[9];
  44. u32 oem_revision;
  45. char *table;
  46. enum acpi_blacklist_predicates oem_revision_predicate;
  47. char *reason;
  48. u32 is_critical_error;
  49. };
  50. static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
  51. /*
  52. * POLICY: If *anything* doesn't work, put it on the blacklist.
  53. * If they are critical errors, mark it critical, and abort driver load.
  54. */
  55. static struct acpi_blacklist_item acpi_blacklist[] __initdata = {
  56. /* Compaq Presario 1700 */
  57. {"PTLTD ", " DSDT ", 0x06040000, ACPI_SIG_DSDT, less_than_or_equal,
  58. "Multiple problems", 1},
  59. /* Sony FX120, FX140, FX150? */
  60. {"SONY ", "U0 ", 0x20010313, ACPI_SIG_DSDT, less_than_or_equal,
  61. "ACPI driver problem", 1},
  62. /* Compaq Presario 800, Insyde BIOS */
  63. {"INT440", "SYSFexxx", 0x00001001, ACPI_SIG_DSDT, less_than_or_equal,
  64. "Does not use _REG to protect EC OpRegions", 1},
  65. /* IBM 600E - _ADR should return 7, but it returns 1 */
  66. {"IBM ", "TP600E ", 0x00000105, ACPI_SIG_DSDT, less_than_or_equal,
  67. "Incorrect _ADR", 1},
  68. {""}
  69. };
  70. #if CONFIG_ACPI_BLACKLIST_YEAR
  71. static int __init blacklist_by_year(void)
  72. {
  73. int year = dmi_get_year(DMI_BIOS_DATE);
  74. /* Doesn't exist? Likely an old system */
  75. if (year == -1) {
  76. printk(KERN_ERR PREFIX "no DMI BIOS year, "
  77. "acpi=force is required to enable ACPI\n" );
  78. return 1;
  79. }
  80. /* 0? Likely a buggy new BIOS */
  81. if (year == 0) {
  82. printk(KERN_ERR PREFIX "DMI BIOS year==0, "
  83. "assuming ACPI-capable machine\n" );
  84. return 0;
  85. }
  86. if (year < CONFIG_ACPI_BLACKLIST_YEAR) {
  87. printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), "
  88. "acpi=force is required to enable ACPI\n",
  89. year, CONFIG_ACPI_BLACKLIST_YEAR);
  90. return 1;
  91. }
  92. return 0;
  93. }
  94. #else
  95. static inline int blacklist_by_year(void)
  96. {
  97. return 0;
  98. }
  99. #endif
  100. int __init acpi_blacklisted(void)
  101. {
  102. int i = 0;
  103. int blacklisted = 0;
  104. struct acpi_table_header table_header;
  105. while (acpi_blacklist[i].oem_id[0] != '\0') {
  106. if (acpi_get_table_header(acpi_blacklist[i].table, 0, &table_header)) {
  107. i++;
  108. continue;
  109. }
  110. if (strncmp(acpi_blacklist[i].oem_id, table_header.oem_id, 6)) {
  111. i++;
  112. continue;
  113. }
  114. if (strncmp
  115. (acpi_blacklist[i].oem_table_id, table_header.oem_table_id,
  116. 8)) {
  117. i++;
  118. continue;
  119. }
  120. if ((acpi_blacklist[i].oem_revision_predicate == all_versions)
  121. || (acpi_blacklist[i].oem_revision_predicate ==
  122. less_than_or_equal
  123. && table_header.oem_revision <=
  124. acpi_blacklist[i].oem_revision)
  125. || (acpi_blacklist[i].oem_revision_predicate ==
  126. greater_than_or_equal
  127. && table_header.oem_revision >=
  128. acpi_blacklist[i].oem_revision)
  129. || (acpi_blacklist[i].oem_revision_predicate == equal
  130. && table_header.oem_revision ==
  131. acpi_blacklist[i].oem_revision)) {
  132. printk(KERN_ERR PREFIX
  133. "Vendor \"%6.6s\" System \"%8.8s\" "
  134. "Revision 0x%x has a known ACPI BIOS problem.\n",
  135. acpi_blacklist[i].oem_id,
  136. acpi_blacklist[i].oem_table_id,
  137. acpi_blacklist[i].oem_revision);
  138. printk(KERN_ERR PREFIX
  139. "Reason: %s. This is a %s error\n",
  140. acpi_blacklist[i].reason,
  141. (acpi_blacklist[i].
  142. is_critical_error ? "non-recoverable" :
  143. "recoverable"));
  144. blacklisted = acpi_blacklist[i].is_critical_error;
  145. break;
  146. } else {
  147. i++;
  148. }
  149. }
  150. blacklisted += blacklist_by_year();
  151. dmi_check_system(acpi_osi_dmi_table);
  152. return blacklisted;
  153. }
  154. #ifdef CONFIG_DMI
  155. static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
  156. {
  157. acpi_dmi_osi_linux(1, d); /* enable */
  158. return 0;
  159. }
  160. static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
  161. {
  162. printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
  163. acpi_osi_setup("!Windows 2006");
  164. return 0;
  165. }
  166. static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
  167. {
  168. .callback = dmi_disable_osi_vista,
  169. .ident = "Fujitsu Siemens",
  170. .matches = {
  171. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  172. DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
  173. },
  174. },
  175. {
  176. .callback = dmi_disable_osi_vista,
  177. .ident = "Sony VGN-NS10J_S",
  178. .matches = {
  179. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  180. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS10J_S"),
  181. },
  182. },
  183. {
  184. .callback = dmi_disable_osi_vista,
  185. .ident = "Sony VGN-SR290J",
  186. .matches = {
  187. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  188. DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"),
  189. },
  190. },
  191. /*
  192. * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
  193. * Linux ignores it, except for the machines enumerated below.
  194. */
  195. /*
  196. * Lenovo has a mix of systems OSI(Linux) situations
  197. * and thus we can not wildcard the vendor.
  198. *
  199. * _OSI(Linux) helps sound
  200. * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"),
  201. * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"),
  202. * _OSI(Linux) has Linux specific hooks
  203. * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
  204. * _OSI(Linux) is a NOP:
  205. * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
  206. * DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"),
  207. */
  208. {
  209. .callback = dmi_enable_osi_linux,
  210. .ident = "Lenovo ThinkPad R61",
  211. .matches = {
  212. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  213. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"),
  214. },
  215. },
  216. {
  217. .callback = dmi_enable_osi_linux,
  218. .ident = "Lenovo ThinkPad T61",
  219. .matches = {
  220. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  221. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"),
  222. },
  223. },
  224. {
  225. .callback = dmi_enable_osi_linux,
  226. .ident = "Lenovo ThinkPad X61",
  227. .matches = {
  228. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  229. DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
  230. },
  231. },
  232. {}
  233. };
  234. #endif /* CONFIG_DMI */