summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch
new file mode 100644
index 00000000..b09d80fb
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0100-hwmon-fam15h_power-fix-bogus-values-with-current-BIO.patch
@@ -0,0 +1,93 @@
1From 9c1a0e414fb67307c1e9e7c7a81f5aa32fb3165d Mon Sep 17 00:00:00 2001
2From: Andre Przywara <andre.przywara@amd.com>
3Date: Mon, 9 Apr 2012 18:16:34 -0400
4Subject: [PATCH 100/165] hwmon: fam15h_power: fix bogus values with current
5 BIOSes
6
7commit 00250ec90963b7ef6678438888f3244985ecde14 upstream.
8
9Newer BKDG[1] versions recommend a different initialization value for
10the running average range register in the northbridge. This improves
11the power reading by avoiding counter saturations resulting in bogus
12values for anything below about 80% of TDP power consumption.
13Updated BIOSes will have this new value set up from the beginning,
14but meanwhile we correct this value ourselves.
15This needs to be done on all northbridges, even on those where the
16driver itself does not register at.
17
18This fixes the driver on all current machines to provide proper
19values for idle load.
20
21[1]
22http://support.amd.com/us/Processor_TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdf
23Chapter 3.8: D18F5xE0 Processor TDP Running Average (p. 452)
24
25Signed-off-by: Andre Przywara <andre.przywara@amd.com>
26Acked-by: Jean Delvare <khali@linux-fr.org>
27[guenter.roeck@ericsson.com: Removed unnecessary return statement]
28Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
29Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
30---
31 drivers/hwmon/fam15h_power.c | 39 +++++++++++++++++++++++++++++++++++++++
32 1 files changed, 39 insertions(+), 0 deletions(-)
33
34diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
35index 930370d..99aaf2e 100644
36--- a/drivers/hwmon/fam15h_power.c
37+++ b/drivers/hwmon/fam15h_power.c
38@@ -122,6 +122,38 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
39 return true;
40 }
41
42+/*
43+ * Newer BKDG versions have an updated recommendation on how to properly
44+ * initialize the running average range (was: 0xE, now: 0x9). This avoids
45+ * counter saturations resulting in bogus power readings.
46+ * We correct this value ourselves to cope with older BIOSes.
47+ */
48+static void __devinit tweak_runavg_range(struct pci_dev *pdev)
49+{
50+ u32 val;
51+ const struct pci_device_id affected_device = {
52+ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) };
53+
54+ /*
55+ * let this quirk apply only to the current version of the
56+ * northbridge, since future versions may change the behavior
57+ */
58+ if (!pci_match_id(&affected_device, pdev))
59+ return;
60+
61+ pci_bus_read_config_dword(pdev->bus,
62+ PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
63+ REG_TDP_RUNNING_AVERAGE, &val);
64+ if ((val & 0xf) != 0xe)
65+ return;
66+
67+ val &= ~0xf;
68+ val |= 0x9;
69+ pci_bus_write_config_dword(pdev->bus,
70+ PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
71+ REG_TDP_RUNNING_AVERAGE, val);
72+}
73+
74 static void __devinit fam15h_power_init_data(struct pci_dev *f4,
75 struct fam15h_power_data *data)
76 {
77@@ -155,6 +187,13 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
78 struct device *dev;
79 int err;
80
81+ /*
82+ * though we ignore every other northbridge, we still have to
83+ * do the tweaking on _each_ node in MCM processors as the counters
84+ * are working hand-in-hand
85+ */
86+ tweak_runavg_range(pdev);
87+
88 if (!fam15h_power_is_internal_node0(pdev)) {
89 err = -ENODEV;
90 goto exit;
91--
921.7.7.6
93