main.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /* Generic MTRR (Memory Type Range Register) driver.
  2. Copyright (C) 1997-2000 Richard Gooch
  3. Copyright (c) 2002 Patrick Mochel
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. Richard Gooch may be reached by email at rgooch@atnf.csiro.au
  16. The postal address is:
  17. Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
  18. Source: "Pentium Pro Family Developer's Manual, Volume 3:
  19. Operating System Writer's Guide" (Intel document number 242692),
  20. section 11.11.7
  21. This was cleaned and made readable by Patrick Mochel <mochel@osdl.org>
  22. on 6-7 March 2002.
  23. Source: Intel Architecture Software Developers Manual, Volume 3:
  24. System Programming Guide; Section 9.11. (1997 edition - PPro).
  25. */
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/pci.h>
  29. #include <linux/smp.h>
  30. #include <linux/cpu.h>
  31. #include <asm/mtrr.h>
  32. #include <asm/uaccess.h>
  33. #include <asm/processor.h>
  34. #include <asm/msr.h>
  35. #include "mtrr.h"
  36. #define MTRR_VERSION "2.0 (20020519)"
  37. u32 num_var_ranges = 0;
  38. unsigned int *usage_table;
  39. static DECLARE_MUTEX(main_lock);
  40. u32 size_or_mask, size_and_mask;
  41. static struct mtrr_ops * mtrr_ops[X86_VENDOR_NUM] = {};
  42. struct mtrr_ops * mtrr_if = NULL;
  43. static void set_mtrr(unsigned int reg, unsigned long base,
  44. unsigned long size, mtrr_type type);
  45. extern int arr3_protected;
  46. void set_mtrr_ops(struct mtrr_ops * ops)
  47. {
  48. if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
  49. mtrr_ops[ops->vendor] = ops;
  50. }
  51. /* Returns non-zero if we have the write-combining memory type */
  52. static int have_wrcomb(void)
  53. {
  54. struct pci_dev *dev;
  55. u8 rev;
  56. if ((dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
  57. /* ServerWorks LE chipsets < rev 6 have problems with write-combining
  58. Don't allow it and leave room for other chipsets to be tagged */
  59. if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
  60. dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) {
  61. pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
  62. if (rev <= 5) {
  63. printk(KERN_INFO "mtrr: Serverworks LE rev < 6 detected. Write-combining disabled.\n");
  64. pci_dev_put(dev);
  65. return 0;
  66. }
  67. }
  68. /* Intel 450NX errata # 23. Non ascending cacheline evictions to
  69. write combining memory may resulting in data corruption */
  70. if (dev->vendor == PCI_VENDOR_ID_INTEL &&
  71. dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
  72. printk(KERN_INFO "mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
  73. pci_dev_put(dev);
  74. return 0;
  75. }
  76. pci_dev_put(dev);
  77. }
  78. return (mtrr_if->have_wrcomb ? mtrr_if->have_wrcomb() : 0);
  79. }
  80. /* This function returns the number of variable MTRRs */
  81. static void __init set_num_var_ranges(void)
  82. {
  83. unsigned long config = 0, dummy;
  84. if (use_intel()) {
  85. rdmsr(MTRRcap_MSR, config, dummy);
  86. } else if (is_cpu(AMD))
  87. config = 2;
  88. else if (is_cpu(CYRIX) || is_cpu(CENTAUR))
  89. config = 8;
  90. num_var_ranges = config & 0xff;
  91. }
  92. static void __init init_table(void)
  93. {
  94. int i, max;
  95. max = num_var_ranges;
  96. if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL))
  97. == NULL) {
  98. printk(KERN_ERR "mtrr: could not allocate\n");
  99. return;
  100. }
  101. for (i = 0; i < max; i++)
  102. usage_table[i] = 1;
  103. }
  104. struct set_mtrr_data {
  105. atomic_t count;
  106. atomic_t gate;
  107. unsigned long smp_base;
  108. unsigned long smp_size;
  109. unsigned int smp_reg;
  110. mtrr_type smp_type;
  111. };
  112. #ifdef CONFIG_SMP
  113. static void ipi_handler(void *info)
  114. /* [SUMMARY] Synchronisation handler. Executed by "other" CPUs.
  115. [RETURNS] Nothing.
  116. */
  117. {
  118. struct set_mtrr_data *data = info;
  119. unsigned long flags;
  120. local_irq_save(flags);
  121. atomic_dec(&data->count);
  122. while(!atomic_read(&data->gate))
  123. cpu_relax();
  124. /* The master has cleared me to execute */
  125. if (data->smp_reg != ~0U)
  126. mtrr_if->set(data->smp_reg, data->smp_base,
  127. data->smp_size, data->smp_type);
  128. else
  129. mtrr_if->set_all();
  130. atomic_dec(&data->count);
  131. while(atomic_read(&data->gate))
  132. cpu_relax();
  133. atomic_dec(&data->count);
  134. local_irq_restore(flags);
  135. }
  136. #endif
  137. /**
  138. * set_mtrr - update mtrrs on all processors
  139. * @reg: mtrr in question
  140. * @base: mtrr base
  141. * @size: mtrr size
  142. * @type: mtrr type
  143. *
  144. * This is kinda tricky, but fortunately, Intel spelled it out for us cleanly:
  145. *
  146. * 1. Send IPI to do the following:
  147. * 2. Disable Interrupts
  148. * 3. Wait for all procs to do so
  149. * 4. Enter no-fill cache mode
  150. * 5. Flush caches
  151. * 6. Clear PGE bit
  152. * 7. Flush all TLBs
  153. * 8. Disable all range registers
  154. * 9. Update the MTRRs
  155. * 10. Enable all range registers
  156. * 11. Flush all TLBs and caches again
  157. * 12. Enter normal cache mode and reenable caching
  158. * 13. Set PGE
  159. * 14. Wait for buddies to catch up
  160. * 15. Enable interrupts.
  161. *
  162. * What does that mean for us? Well, first we set data.count to the number
  163. * of CPUs. As each CPU disables interrupts, it'll decrement it once. We wait
  164. * until it hits 0 and proceed. We set the data.gate flag and reset data.count.
  165. * Meanwhile, they are waiting for that flag to be set. Once it's set, each
  166. * CPU goes through the transition of updating MTRRs. The CPU vendors may each do it
  167. * differently, so we call mtrr_if->set() callback and let them take care of it.
  168. * When they're done, they again decrement data->count and wait for data.gate to
  169. * be reset.
  170. * When we finish, we wait for data.count to hit 0 and toggle the data.gate flag.
  171. * Everyone then enables interrupts and we all continue on.
  172. *
  173. * Note that the mechanism is the same for UP systems, too; all the SMP stuff
  174. * becomes nops.
  175. */
  176. static void set_mtrr(unsigned int reg, unsigned long base,
  177. unsigned long size, mtrr_type type)
  178. {
  179. struct set_mtrr_data data;
  180. unsigned long flags;
  181. data.smp_reg = reg;
  182. data.smp_base = base;
  183. data.smp_size = size;
  184. data.smp_type = type;
  185. atomic_set(&data.count, num_booting_cpus() - 1);
  186. atomic_set(&data.gate,0);
  187. /* Start the ball rolling on other CPUs */
  188. if (smp_call_function(ipi_handler, &data, 1, 0) != 0)
  189. panic("mtrr: timed out waiting for other CPUs\n");
  190. local_irq_save(flags);
  191. while(atomic_read(&data.count))
  192. cpu_relax();
  193. /* ok, reset count and toggle gate */
  194. atomic_set(&data.count, num_booting_cpus() - 1);
  195. atomic_set(&data.gate,1);
  196. /* do our MTRR business */
  197. /* HACK!
  198. * We use this same function to initialize the mtrrs on boot.
  199. * The state of the boot cpu's mtrrs has been saved, and we want
  200. * to replicate across all the APs.
  201. * If we're doing that @reg is set to something special...
  202. */
  203. if (reg != ~0U)
  204. mtrr_if->set(reg,base,size,type);
  205. /* wait for the others */
  206. while(atomic_read(&data.count))
  207. cpu_relax();
  208. atomic_set(&data.count, num_booting_cpus() - 1);
  209. atomic_set(&data.gate,0);
  210. /*
  211. * Wait here for everyone to have seen the gate change
  212. * So we're the last ones to touch 'data'
  213. */
  214. while(atomic_read(&data.count))
  215. cpu_relax();
  216. local_irq_restore(flags);
  217. }
  218. /**
  219. * mtrr_add_page - Add a memory type region
  220. * @base: Physical base address of region in pages (4 KB)
  221. * @size: Physical size of region in pages (4 KB)
  222. * @type: Type of MTRR desired
  223. * @increment: If this is true do usage counting on the region
  224. *
  225. * Memory type region registers control the caching on newer Intel and
  226. * non Intel processors. This function allows drivers to request an
  227. * MTRR is added. The details and hardware specifics of each processor's
  228. * implementation are hidden from the caller, but nevertheless the
  229. * caller should expect to need to provide a power of two size on an
  230. * equivalent power of two boundary.
  231. *
  232. * If the region cannot be added either because all regions are in use
  233. * or the CPU cannot support it a negative value is returned. On success
  234. * the register number for this entry is returned, but should be treated
  235. * as a cookie only.
  236. *
  237. * On a multiprocessor machine the changes are made to all processors.
  238. * This is required on x86 by the Intel processors.
  239. *
  240. * The available types are
  241. *
  242. * %MTRR_TYPE_UNCACHABLE - No caching
  243. *
  244. * %MTRR_TYPE_WRBACK - Write data back in bursts whenever
  245. *
  246. * %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
  247. *
  248. * %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
  249. *
  250. * BUGS: Needs a quiet flag for the cases where drivers do not mind
  251. * failures and do not wish system log messages to be sent.
  252. */
  253. int mtrr_add_page(unsigned long base, unsigned long size,
  254. unsigned int type, char increment)
  255. {
  256. int i;
  257. mtrr_type ltype;
  258. unsigned long lbase;
  259. unsigned int lsize;
  260. int error;
  261. if (!mtrr_if)
  262. return -ENXIO;
  263. if ((error = mtrr_if->validate_add_page(base,size,type)))
  264. return error;
  265. if (type >= MTRR_NUM_TYPES) {
  266. printk(KERN_WARNING "mtrr: type: %u invalid\n", type);
  267. return -EINVAL;
  268. }
  269. /* If the type is WC, check that this processor supports it */
  270. if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) {
  271. printk(KERN_WARNING
  272. "mtrr: your processor doesn't support write-combining\n");
  273. return -ENOSYS;
  274. }
  275. if (base & size_or_mask || size & size_or_mask) {
  276. printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
  277. return -EINVAL;
  278. }
  279. error = -EINVAL;
  280. /* Search for existing MTRR */
  281. down(&main_lock);
  282. for (i = 0; i < num_var_ranges; ++i) {
  283. mtrr_if->get(i, &lbase, &lsize, &ltype);
  284. if (base >= lbase + lsize)
  285. continue;
  286. if ((base < lbase) && (base + size <= lbase))
  287. continue;
  288. /* At this point we know there is some kind of overlap/enclosure */
  289. if ((base < lbase) || (base + size > lbase + lsize)) {
  290. printk(KERN_WARNING
  291. "mtrr: 0x%lx000,0x%lx000 overlaps existing"
  292. " 0x%lx000,0x%x000\n", base, size, lbase,
  293. lsize);
  294. goto out;
  295. }
  296. /* New region is enclosed by an existing region */
  297. if (ltype != type) {
  298. if (type == MTRR_TYPE_UNCACHABLE)
  299. continue;
  300. printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
  301. base, size, mtrr_attrib_to_str(ltype),
  302. mtrr_attrib_to_str(type));
  303. goto out;
  304. }
  305. if (increment)
  306. ++usage_table[i];
  307. error = i;
  308. goto out;
  309. }
  310. /* Search for an empty MTRR */
  311. i = mtrr_if->get_free_region(base, size);
  312. if (i >= 0) {
  313. set_mtrr(i, base, size, type);
  314. usage_table[i] = 1;
  315. } else
  316. printk(KERN_INFO "mtrr: no more MTRRs available\n");
  317. error = i;
  318. out:
  319. up(&main_lock);
  320. return error;
  321. }
  322. static int mtrr_check(unsigned long base, unsigned long size)
  323. {
  324. if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
  325. printk(KERN_WARNING
  326. "mtrr: size and base must be multiples of 4 kiB\n");
  327. printk(KERN_DEBUG
  328. "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
  329. dump_stack();
  330. return -1;
  331. }
  332. return 0;
  333. }
  334. /**
  335. * mtrr_add - Add a memory type region
  336. * @base: Physical base address of region
  337. * @size: Physical size of region
  338. * @type: Type of MTRR desired
  339. * @increment: If this is true do usage counting on the region
  340. *
  341. * Memory type region registers control the caching on newer Intel and
  342. * non Intel processors. This function allows drivers to request an
  343. * MTRR is added. The details and hardware specifics of each processor's
  344. * implementation are hidden from the caller, but nevertheless the
  345. * caller should expect to need to provide a power of two size on an
  346. * equivalent power of two boundary.
  347. *
  348. * If the region cannot be added either because all regions are in use
  349. * or the CPU cannot support it a negative value is returned. On success
  350. * the register number for this entry is returned, but should be treated
  351. * as a cookie only.
  352. *
  353. * On a multiprocessor machine the changes are made to all processors.
  354. * This is required on x86 by the Intel processors.
  355. *
  356. * The available types are
  357. *
  358. * %MTRR_TYPE_UNCACHABLE - No caching
  359. *
  360. * %MTRR_TYPE_WRBACK - Write data back in bursts whenever
  361. *
  362. * %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
  363. *
  364. * %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
  365. *
  366. * BUGS: Needs a quiet flag for the cases where drivers do not mind
  367. * failures and do not wish system log messages to be sent.
  368. */
  369. int
  370. mtrr_add(unsigned long base, unsigned long size, unsigned int type,
  371. char increment)
  372. {
  373. if (mtrr_check(base, size))
  374. return -EINVAL;
  375. return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
  376. increment);
  377. }
  378. /**
  379. * mtrr_del_page - delete a memory type region
  380. * @reg: Register returned by mtrr_add
  381. * @base: Physical base address
  382. * @size: Size of region
  383. *
  384. * If register is supplied then base and size are ignored. This is
  385. * how drivers should call it.
  386. *
  387. * Releases an MTRR region. If the usage count drops to zero the
  388. * register is freed and the region returns to default state.
  389. * On success the register is returned, on failure a negative error
  390. * code.
  391. */
  392. int mtrr_del_page(int reg, unsigned long base, unsigned long size)
  393. {
  394. int i, max;
  395. mtrr_type ltype;
  396. unsigned long lbase;
  397. unsigned int lsize;
  398. int error = -EINVAL;
  399. if (!mtrr_if)
  400. return -ENXIO;
  401. max = num_var_ranges;
  402. down(&main_lock);
  403. if (reg < 0) {
  404. /* Search for existing MTRR */
  405. for (i = 0; i < max; ++i) {
  406. mtrr_if->get(i, &lbase, &lsize, &ltype);
  407. if (lbase == base && lsize == size) {
  408. reg = i;
  409. break;
  410. }
  411. }
  412. if (reg < 0) {
  413. printk(KERN_DEBUG "mtrr: no MTRR for %lx000,%lx000 found\n", base,
  414. size);
  415. goto out;
  416. }
  417. }
  418. if (reg >= max) {
  419. printk(KERN_WARNING "mtrr: register: %d too big\n", reg);
  420. goto out;
  421. }
  422. if (is_cpu(CYRIX) && !use_intel()) {
  423. if ((reg == 3) && arr3_protected) {
  424. printk(KERN_WARNING "mtrr: ARR3 cannot be changed\n");
  425. goto out;
  426. }
  427. }
  428. mtrr_if->get(reg, &lbase, &lsize, &ltype);
  429. if (lsize < 1) {
  430. printk(KERN_WARNING "mtrr: MTRR %d not used\n", reg);
  431. goto out;
  432. }
  433. if (usage_table[reg] < 1) {
  434. printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
  435. goto out;
  436. }
  437. if (--usage_table[reg] < 1)
  438. set_mtrr(reg, 0, 0, 0);
  439. error = reg;
  440. out:
  441. up(&main_lock);
  442. return error;
  443. }
  444. /**
  445. * mtrr_del - delete a memory type region
  446. * @reg: Register returned by mtrr_add
  447. * @base: Physical base address
  448. * @size: Size of region
  449. *
  450. * If register is supplied then base and size are ignored. This is
  451. * how drivers should call it.
  452. *
  453. * Releases an MTRR region. If the usage count drops to zero the
  454. * register is freed and the region returns to default state.
  455. * On success the register is returned, on failure a negative error
  456. * code.
  457. */
  458. int
  459. mtrr_del(int reg, unsigned long base, unsigned long size)
  460. {
  461. if (mtrr_check(base, size))
  462. return -EINVAL;
  463. return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
  464. }
  465. EXPORT_SYMBOL(mtrr_add);
  466. EXPORT_SYMBOL(mtrr_del);
  467. /* HACK ALERT!
  468. * These should be called implicitly, but we can't yet until all the initcall
  469. * stuff is done...
  470. */
  471. extern void amd_init_mtrr(void);
  472. extern void cyrix_init_mtrr(void);
  473. extern void centaur_init_mtrr(void);
  474. static void __init init_ifs(void)
  475. {
  476. amd_init_mtrr();
  477. cyrix_init_mtrr();
  478. centaur_init_mtrr();
  479. }
  480. static void __init init_other_cpus(void)
  481. {
  482. if (use_intel())
  483. get_mtrr_state();
  484. /* bring up the other processors */
  485. set_mtrr(~0U,0,0,0);
  486. if (use_intel()) {
  487. finalize_mtrr_state();
  488. mtrr_state_warn();
  489. }
  490. }
  491. struct mtrr_value {
  492. mtrr_type ltype;
  493. unsigned long lbase;
  494. unsigned int lsize;
  495. };
  496. static struct mtrr_value * mtrr_state;
  497. static int mtrr_save(struct sys_device * sysdev, u32 state)
  498. {
  499. int i;
  500. int size = num_var_ranges * sizeof(struct mtrr_value);
  501. mtrr_state = kmalloc(size,GFP_ATOMIC);
  502. if (mtrr_state)
  503. memset(mtrr_state,0,size);
  504. else
  505. return -ENOMEM;
  506. for (i = 0; i < num_var_ranges; i++) {
  507. mtrr_if->get(i,
  508. &mtrr_state[i].lbase,
  509. &mtrr_state[i].lsize,
  510. &mtrr_state[i].ltype);
  511. }
  512. return 0;
  513. }
  514. static int mtrr_restore(struct sys_device * sysdev)
  515. {
  516. int i;
  517. for (i = 0; i < num_var_ranges; i++) {
  518. if (mtrr_state[i].lsize)
  519. set_mtrr(i,
  520. mtrr_state[i].lbase,
  521. mtrr_state[i].lsize,
  522. mtrr_state[i].ltype);
  523. }
  524. kfree(mtrr_state);
  525. return 0;
  526. }
  527. static struct sysdev_driver mtrr_sysdev_driver = {
  528. .suspend = mtrr_save,
  529. .resume = mtrr_restore,
  530. };
  531. /**
  532. * mtrr_init - initialize mtrrs on the boot CPU
  533. *
  534. * This needs to be called early; before any of the other CPUs are
  535. * initialized (i.e. before smp_init()).
  536. *
  537. */
  538. static int __init mtrr_init(void)
  539. {
  540. init_ifs();
  541. if (cpu_has_mtrr) {
  542. mtrr_if = &generic_mtrr_ops;
  543. size_or_mask = 0xff000000; /* 36 bits */
  544. size_and_mask = 0x00f00000;
  545. /* This is an AMD specific MSR, but we assume(hope?) that
  546. Intel will implement it to when they extend the address
  547. bus of the Xeon. */
  548. if (cpuid_eax(0x80000000) >= 0x80000008) {
  549. u32 phys_addr;
  550. phys_addr = cpuid_eax(0x80000008) & 0xff;
  551. size_or_mask = ~((1 << (phys_addr - PAGE_SHIFT)) - 1);
  552. size_and_mask = ~size_or_mask & 0xfff00000;
  553. } else if (boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR &&
  554. boot_cpu_data.x86 == 6) {
  555. /* VIA C* family have Intel style MTRRs, but
  556. don't support PAE */
  557. size_or_mask = 0xfff00000; /* 32 bits */
  558. size_and_mask = 0;
  559. }
  560. } else {
  561. switch (boot_cpu_data.x86_vendor) {
  562. case X86_VENDOR_AMD:
  563. if (cpu_has_k6_mtrr) {
  564. /* Pre-Athlon (K6) AMD CPU MTRRs */
  565. mtrr_if = mtrr_ops[X86_VENDOR_AMD];
  566. size_or_mask = 0xfff00000; /* 32 bits */
  567. size_and_mask = 0;
  568. }
  569. break;
  570. case X86_VENDOR_CENTAUR:
  571. if (cpu_has_centaur_mcr) {
  572. mtrr_if = mtrr_ops[X86_VENDOR_CENTAUR];
  573. size_or_mask = 0xfff00000; /* 32 bits */
  574. size_and_mask = 0;
  575. }
  576. break;
  577. case X86_VENDOR_CYRIX:
  578. if (cpu_has_cyrix_arr) {
  579. mtrr_if = mtrr_ops[X86_VENDOR_CYRIX];
  580. size_or_mask = 0xfff00000; /* 32 bits */
  581. size_and_mask = 0;
  582. }
  583. break;
  584. default:
  585. break;
  586. }
  587. }
  588. printk(KERN_INFO "mtrr: v%s\n",MTRR_VERSION);
  589. if (mtrr_if) {
  590. set_num_var_ranges();
  591. init_table();
  592. init_other_cpus();
  593. return sysdev_driver_register(&cpu_sysdev_class,
  594. &mtrr_sysdev_driver);
  595. }
  596. return -ENXIO;
  597. }
  598. subsys_initcall(mtrr_init);