main.c 18 KB

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