Программное "охлаждение" процессоров AMD Athlon/Duron под Linux. (amd cpu kernel linux patch idle hardware)
Ключевые слова: amd, cpu, kernel, linux, patch, idle, hardware,  (найти похожие документы)
From: Daniel Nofftz <[email protected]>
Newsgroups: mlist.linux.kernel
Subject: Программное "охлаждение" процессоров AMD Athlon/Duron под Linux.
Патчи подходят для процессоров AMD Athlon/Duron/AthlonXP,
Поддерживаемые чипсеты: VIA kt133/kx133/kt133a, kt266/kt266a
Athlon-Powersaving-HOWTO: 
            http://cip.uni-trier.de/nofftz/linux/Athlon-Powersaving-HOWTO.html
Страница автора патча: 
            http://cip.uni-trier.de/nofftz/linux/
Утилита для user-level охлаждения (Via KT133 и KX133 (VT8363 и VT8371/VT82C686x)): 
            http://mpet.freeservers.com/LVCool.html
Для работы патча необходимо активировать ACPI при сборке ядра. 
 cd /usr/src/
 cat amd_cool.diff | patch -p0
 cd linux
 make menuconfig
 В  "general.setup" активируем  "acpi subsystem", "acpi bus" и "acpi Processor entry" 
  (Внимание, при включенном ACPI не будет работать APM). 
 В lilo.conf пропишите: append=" amd_disconnect=yes". 
Можно обойтись без патча, переключая режимы acpi при помощи утилиты setpci.
Для этого необходимо включить ACPI в ядре, как было описано выше.
Для kt133/133a и kx133:
Включить "охлаждение": setpci -v -H1 -s 0:0.0 52=EB
Выключить: setpci -v -H1 -s 0:0.0 52=6B
Для kt266/266a:
Включить: setpci -v -H1 -s 0:0.0 92=EB
Выключить: setpci -v -H1 -s 0:0.0 92=6B
Две версии патча (для linux ядра 2.4.17):
amd_cool.diff
--- linux-2.4.17-orig/drivers/pci/quirks.c	Sun Nov 11 19:09:33 2001
+++ linux/drivers/pci/quirks.c	Tue Jan 22 16:50:05 2002
@@ -21,6 +21,23 @@
 
 #undef DEBUG
 
+/* Power Saving for Athlon/Duron CPUs on Via Chipsets has to be enabled by 
+ * kernel-boot-option "amd_disconnect=yes" . This is cause it looks like 
+ * there are some stability problems on some boards when this option is 
+ * enabled.
+ */
+
+int enable_amd_disconnect;
+
+static int __init amd_disconnect_setup (char *str) {
+        if(!strncmp(str,"yes",3)) {
+                enable_amd_disconnect=1;
+					                                                }
+        return 1;
+}
+
+__setup("amd_disconnect=", amd_disconnect_setup);
+
 /* Deal with broken BIOS'es that neglect to enable passive release,
    which can cause problems in combination with the 82441FX/PPro MTRRs */
 static void __init quirk_passive_release(struct pci_dev *dev)
@@ -146,6 +163,47 @@
 	printk(KERN_INFO "Applying VIA southbridge workaround.\n");
 }
 
+/* Power Saving for Athlon/Duron/AthonXP CPUs on Via Chipsets.
+ * Found in the net and modified for supporting KT266/KT266A chipsets
+ * by Daniel Nofftz <[email protected]>
+ * This Funktion must be enabled by kernel booting option "via_disconnect=yes"!
+ */
+
+static void __init quirk_amddisconnect(struct pci_dev *dev)
+{
+	u16 did;
+	u32 res32;
+	
+	if(!enable_amd_disconnect) return;
+
+        pci_read_config_word(dev,PCI_DEVICE_ID,&did);
+
+	
+	if(did==PCI_DEVICE_ID_VIA_8367_0)
+	{
+		pci_read_config_dword(dev,0x92&0xfc,&res32);
+		if ((res32&0x00800000)==0) 
+		{
+			printk(KERN_INFO "Enabling disconnect in VIA northbridge: KT266/266A chipset found.\n");
+			res32|=0x00800000;
+			pci_write_config_dword(dev,0x92&0xfc,res32);
+		} else
+			printk(KERN_INFO "Disconnect already anabled in VIA northbridge.\n");
+
+	}
+	else if((did==PCI_DEVICE_ID_VIA_8363_0)||(did==PCI_DEVICE_ID_VIA_8371_0))
+	{
+		pci_read_config_dword(dev,0x52&0xfc,&res32);
+	        if ((res32&0x00800000)==0) 
+		{	
+			printk(KERN_INFO "Enabling disconnect in VIA northbridge: KT133/KX133 chipset found\n");
+			res32|=0x00800000;
+			pci_write_config_dword(dev,0x52&0xfc,res32);
+		} else
+			printk(KERN_INFO "Disconnect already anabled in VIA northbridge.\n");
+		
+	}
+}
 /*
  *	VIA Apollo VP3 needs ETBF on BT848/878
  */
@@ -485,6 +543,9 @@
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8363_0,	quirk_vialatency },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8371_1,	quirk_vialatency },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	0x3112	/* Not out yet ? */,	quirk_vialatency },
+	{ PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8367_0,	quirk_amddisconnect },
+        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8363_0,       quirk_amddisconnect },
+        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8371_0,       quirk_amddisconnect },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C576,	quirk_vsfx },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_viaetbf },
 	{ PCI_FIXUP_HEADER,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_vt82c598_id },
amd_cool_new.diff
--- linux-2.4.17-orig/drivers/pci/quirks.c	Sun Nov 11 19:09:33 2001
+++ linux/drivers/pci/quirks.c	Wed Jan 30 09:57:20 2002
@@ -18,9 +18,36 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <asm/msr.h>
 
 #undef DEBUG
 
+/* Power Saving for Athlon/Duron CPUs on Via Chipsets has to be enabled by 
+ * kernel-boot-option "amd_disconnect=yes" . This is cause it looks like 
+ * there are some stability problems on some boards when this option is 
+ * enabled.
+ */
+
+int enable_amd_disconnect = 0;
+int force_amd_clk = 0;
+
+
+static int __init force_amd_clk_setup (char *str) {
+        if(!strncmp(str,"yes",3)) {
+                force_amd_clk=1;
+					                                                }
+        return 1;
+}
+static int __init amd_disconnect_setup (char *str) {
+        if(!strncmp(str,"yes",3)) {
+                enable_amd_disconnect=1;
+					                                                }
+        return 1;
+}
+
+__setup("amd_disconnect=", amd_disconnect_setup);
+__setup("force_amd_clk=", force_amd_clk_setup);
+
 /* Deal with broken BIOS'es that neglect to enable passive release,
    which can cause problems in combination with the 82441FX/PPro MTRRs */
 static void __init quirk_passive_release(struct pci_dev *dev)
@@ -146,6 +173,58 @@
 	printk(KERN_INFO "Applying VIA southbridge workaround.\n");
 }
 
+/* Power Saving for Athlon/Duron/AthonXP CPUs on Via Chipsets.
+ * Found in the net and modified for supporting KT266/KT266A chipsets
+ * by Daniel Nofftz <[email protected]>
+ * This Funktion must be enabled by kernel booting option "via_disconnect=yes"!
+ */
+
+static void __init quirk_amddisconnect(struct pci_dev *dev)
+{
+	u16 did;
+	u32 res32;
+	u32 eins, zwei;
+	
+	if(!enable_amd_disconnect) return;
+
+        pci_read_config_word(dev,PCI_DEVICE_ID,&did);
+ 
+	rdmsr(0xc001001b , eins, zwei);	
+
+	printk(KERN_INFO "Athlon/Duron CLK_Ctrl Value found : %x\n", eins);
+	if(force_amd_clk)
+	{
+		wrmsr(0xc001001b, 0xfff0d22f, 0xd22f);
+		rdmsr(0xc001001b , eins, zwei);	
+
+		printk(KERN_INFO "Athlon/Duron CLK_Ctrl Value set to : %x\n", eins);
+	
+	}
+	if(did==PCI_DEVICE_ID_VIA_8367_0)
+	{
+		pci_read_config_dword(dev,0x92&0xfc,&res32);
+		if ((res32&0x00800000)==0) 
+		{
+			printk(KERN_INFO "Enabling disconnect in VIA northbridge: KT266/266A chipset found.\n");
+			res32|=0x00800000;
+			pci_write_config_dword(dev,0x92&0xfc,res32);
+		} else
+			printk(KERN_INFO "Disconnect already anabled in VIA northbridge.\n");
+
+	}
+	else if((did==PCI_DEVICE_ID_VIA_8363_0)||(did==PCI_DEVICE_ID_VIA_8371_0))
+	{
+		pci_read_config_dword(dev,0x52&0xfc,&res32);
+	        if ((res32&0x00800000)==0) 
+		{	
+			printk(KERN_INFO "Enabling disconnect in VIA northbridge: KT133/KX133 chipset found\n");
+			res32|=0x00800000;
+			pci_write_config_dword(dev,0x52&0xfc,res32);
+		} else
+			printk(KERN_INFO "Disconnect already anabled in VIA northbridge.\n");
+		
+	}
+}
 /*
  *	VIA Apollo VP3 needs ETBF on BT848/878
  */
@@ -485,6 +564,9 @@
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8363_0,	quirk_vialatency },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8371_1,	quirk_vialatency },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	0x3112	/* Not out yet ? */,	quirk_vialatency },
+	{ PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8367_0,	quirk_amddisconnect },
+        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8363_0,       quirk_amddisconnect },
+        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8371_0,       quirk_amddisconnect },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C576,	quirk_vsfx },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_viaetbf },
 	{ PCI_FIXUP_HEADER,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_vt82c598_id },