Commit fe276d38 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] mtrr fixes

Fix cyrix mtrr ((Zoltán Böszörményi)
Back port 2.4 handling for the Intel bug
Add printk levels
parent 82d1036b
...@@ -64,7 +64,7 @@ __initdata char *mtrr_if_name[] = { ...@@ -64,7 +64,7 @@ __initdata char *mtrr_if_name[] = {
static void set_mtrr(unsigned int reg, unsigned long base, static void set_mtrr(unsigned int reg, unsigned long base,
unsigned long size, mtrr_type type); unsigned long size, mtrr_type type);
static unsigned int arr3_protected; extern int arr3_protected;
void set_mtrr_ops(struct mtrr_ops * ops) void set_mtrr_ops(struct mtrr_ops * ops)
{ {
...@@ -75,20 +75,22 @@ void set_mtrr_ops(struct mtrr_ops * ops) ...@@ -75,20 +75,22 @@ void set_mtrr_ops(struct mtrr_ops * ops)
/* Returns non-zero if we have the write-combining memory type */ /* Returns non-zero if we have the write-combining memory type */
static int have_wrcomb(void) static int have_wrcomb(void)
{ {
struct pci_dev *dev = NULL; struct pci_dev *dev;
/* WTF is this?
* Someone, please shoot me.
*/
if ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
/* ServerWorks LE chipsets have problems with write-combining /* ServerWorks LE chipsets have problems with write-combining
Don't allow it and leave room for other chipsets to be tagged */ Don't allow it and leave room for other chipsets to be tagged */
if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
if ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) { dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) {
if ((dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && printk(KERN_INFO "mtrr: Serverworks LE detected. Write-combining disabled.\n");
(dev->device == PCI_DEVICE_ID_SERVERWORKS_LE)) { return 0;
printk(KERN_INFO }
"mtrr: Serverworks LE detected. Write-combining disabled.\n"); /* Intel 450NX errata # 23. Non ascending cachline evictions to
write combining memory may resulting in data corruption */
if (dev->vendor == PCI_VENDOR_ID_INTEL &&
dev->device == PCI_DEVICE_ID_INTEL_82451NX)
{
printk(KERN_INFO "mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
return 0; return 0;
} }
} }
...@@ -121,7 +123,7 @@ static void init_table(void) ...@@ -121,7 +123,7 @@ static void init_table(void)
max = num_var_ranges; max = num_var_ranges;
if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL)) if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL))
== NULL) { == NULL) {
printk("mtrr: could not allocate\n"); printk(KERN_ERR "mtrr: could not allocate\n");
return; return;
} }
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
...@@ -310,7 +312,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -310,7 +312,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
return error; return error;
if (type >= MTRR_NUM_TYPES) { if (type >= MTRR_NUM_TYPES) {
printk("mtrr: type: %u illegal\n", type); printk(KERN_WARNING "mtrr: type: %u invalid\n", type);
return -EINVAL; return -EINVAL;
} }
...@@ -322,7 +324,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -322,7 +324,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
} }
if (base & size_or_mask || size & size_or_mask) { if (base & size_or_mask || size & size_or_mask) {
printk("mtrr: base or size exceeds the MTRR width\n"); printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
return -EINVAL; return -EINVAL;
} }
...@@ -348,7 +350,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -348,7 +350,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
if (ltype != type) { if (ltype != type) {
if (type == MTRR_TYPE_UNCACHABLE) if (type == MTRR_TYPE_UNCACHABLE)
continue; continue;
printk ("mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n", printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
base, size, attrib_to_str(ltype), base, size, attrib_to_str(ltype),
attrib_to_str(type)); attrib_to_str(type));
goto out; goto out;
...@@ -364,7 +366,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -364,7 +366,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
set_mtrr(i, base, size, type); set_mtrr(i, base, size, type);
usage_table[i] = 1; usage_table[i] = 1;
} else } else
printk("mtrr: no more MTRRs available\n"); printk(KERN_INFO "mtrr: no more MTRRs available\n");
error = i; error = i;
out: out:
up(&main_lock); up(&main_lock);
...@@ -412,8 +414,8 @@ mtrr_add(unsigned long base, unsigned long size, unsigned int type, ...@@ -412,8 +414,8 @@ mtrr_add(unsigned long base, unsigned long size, unsigned int type,
char increment) char increment)
{ {
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
printk("mtrr: size and base must be multiples of 4 kiB\n"); printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
printk("mtrr: size: 0x%lx base: 0x%lx\n", size, base); printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
return -EINVAL; return -EINVAL;
} }
return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
...@@ -458,28 +460,28 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) ...@@ -458,28 +460,28 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
} }
} }
if (reg < 0) { if (reg < 0) {
printk("mtrr: no MTRR for %lx000,%lx000 found\n", base, printk(KERN_DEBUG "mtrr: no MTRR for %lx000,%lx000 found\n", base,
size); size);
goto out; goto out;
} }
} }
if (reg >= max) { if (reg >= max) {
printk("mtrr: register: %d too big\n", reg); printk(KERN_WARNING "mtrr: register: %d too big\n", reg);
goto out; goto out;
} }
if (is_cpu(CYRIX) && !use_intel()) { if (is_cpu(CYRIX) && !use_intel()) {
if ((reg == 3) && arr3_protected) { if ((reg == 3) && arr3_protected) {
printk("mtrr: ARR3 cannot be changed\n"); printk(KERN_WARNING "mtrr: ARR3 cannot be changed\n");
goto out; goto out;
} }
} }
mtrr_if->get(reg, &lbase, &lsize, &ltype); mtrr_if->get(reg, &lbase, &lsize, &ltype);
if (lsize < 1) { if (lsize < 1) {
printk("mtrr: MTRR %d not used\n", reg); printk(KERN_WARNING "mtrr: MTRR %d not used\n", reg);
goto out; goto out;
} }
if (usage_table[reg] < 1) { if (usage_table[reg] < 1) {
printk("mtrr: reg: %d has count=0\n", reg); printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
goto out; goto out;
} }
if (--usage_table[reg] < 1) if (--usage_table[reg] < 1)
...@@ -508,8 +510,8 @@ int ...@@ -508,8 +510,8 @@ int
mtrr_del(int reg, unsigned long base, unsigned long size) mtrr_del(int reg, unsigned long base, unsigned long size)
{ {
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
printk("mtrr: size and base must be multiples of 4 kiB\n"); printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
printk("mtrr: size: 0x%lx base: 0x%lx\n", size, base); printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
return -EINVAL; return -EINVAL;
} }
return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
...@@ -677,7 +679,7 @@ static int __init mtrr_init(void) ...@@ -677,7 +679,7 @@ static int __init mtrr_init(void)
break; break;
} }
} }
printk("mtrr: v%s\n",MTRR_VERSION); printk(KERN_INFO "mtrr: v%s\n",MTRR_VERSION);
if (mtrr_if) { if (mtrr_if) {
set_num_var_ranges(); set_num_var_ranges();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment