aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/idle/i7300_idle.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/idle/i7300_idle.c')
-rw-r--r--drivers/idle/i7300_idle.c105
1 files changed, 20 insertions, 85 deletions
diff --git a/drivers/idle/i7300_idle.c b/drivers/idle/i7300_idle.c
index 59d1bbc3cd3c..fb176f6ef9f8 100644
--- a/drivers/idle/i7300_idle.c
+++ b/drivers/idle/i7300_idle.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/debugfs.h> 26#include <linux/debugfs.h>
27#include <linux/stop_machine.h> 27#include <linux/stop_machine.h>
28#include <linux/i7300_idle.h>
28 29
29#include <asm/idle.h> 30#include <asm/idle.h>
30 31
@@ -34,6 +35,8 @@
34#define I7300_IDLE_DRIVER_VERSION "1.55" 35#define I7300_IDLE_DRIVER_VERSION "1.55"
35#define I7300_PRINT "i7300_idle:" 36#define I7300_PRINT "i7300_idle:"
36 37
38#define MAX_STOP_RETRIES 10
39
37static int debug; 40static int debug;
38module_param_named(debug, debug, uint, 0644); 41module_param_named(debug, debug, uint, 0644);
39MODULE_PARM_DESC(debug, "Enable debug printks in this driver"); 42MODULE_PARM_DESC(debug, "Enable debug printks in this driver");
@@ -46,12 +49,12 @@ MODULE_PARM_DESC(debug, "Enable debug printks in this driver");
46 * 0 = No throttling 49 * 0 = No throttling
47 * 1 = Throttle when > 4 activations per eval window (Maximum throttling) 50 * 1 = Throttle when > 4 activations per eval window (Maximum throttling)
48 * 2 = Throttle when > 8 activations 51 * 2 = Throttle when > 8 activations
49 * 168 = Throttle when > 168 activations (Minimum throttling) 52 * 168 = Throttle when > 672 activations (Minimum throttling)
50 */ 53 */
51#define MAX_THRTLWLIMIT 168 54#define MAX_THROTTLE_LOW_LIMIT 168
52static uint i7300_idle_thrtlowlm = 1; 55static uint throttle_low_limit = 1;
53module_param_named(thrtlwlimit, i7300_idle_thrtlowlm, uint, 0644); 56module_param_named(throttle_low_limit, throttle_low_limit, uint, 0644);
54MODULE_PARM_DESC(thrtlwlimit, 57MODULE_PARM_DESC(throttle_low_limit,
55 "Value for THRTLOWLM activation field " 58 "Value for THRTLOWLM activation field "
56 "(0 = disable throttle, 1 = Max throttle, 168 = Min throttle)"); 59 "(0 = disable throttle, 1 = Max throttle, 168 = Min throttle)");
57 60
@@ -110,9 +113,9 @@ static int i7300_idle_ioat_start(void)
110static void i7300_idle_ioat_stop(void) 113static void i7300_idle_ioat_stop(void)
111{ 114{
112 int i; 115 int i;
113 u8 sts; 116 u64 sts;
114 117
115 for (i = 0; i < 5; i++) { 118 for (i = 0; i < MAX_STOP_RETRIES; i++) {
116 writeb(IOAT_CHANCMD_RESET, 119 writeb(IOAT_CHANCMD_RESET,
117 ioat_chanbase + IOAT1_CHANCMD_OFFSET); 120 ioat_chanbase + IOAT1_CHANCMD_OFFSET);
118 121
@@ -126,9 +129,10 @@ static void i7300_idle_ioat_stop(void)
126 129
127 } 130 }
128 131
129 if (i == 5) 132 if (i == MAX_STOP_RETRIES) {
130 dprintk("failed to suspend+reset I/O AT after 5 retries\n"); 133 dprintk("failed to stop I/O AT after %d retries\n",
131 134 MAX_STOP_RETRIES);
135 }
132} 136}
133 137
134/* Test I/O AT by copying 1024 byte from 2k to 1k */ 138/* Test I/O AT by copying 1024 byte from 2k to 1k */
@@ -275,7 +279,7 @@ static void __exit i7300_idle_ioat_exit(void)
275 i7300_idle_ioat_stop(); 279 i7300_idle_ioat_stop();
276 280
277 /* Wait for a while for the channel to halt before releasing */ 281 /* Wait for a while for the channel to halt before releasing */
278 for (i = 0; i < 10; i++) { 282 for (i = 0; i < MAX_STOP_RETRIES; i++) {
279 writeb(IOAT_CHANCMD_RESET, 283 writeb(IOAT_CHANCMD_RESET,
280 ioat_chanbase + IOAT1_CHANCMD_OFFSET); 284 ioat_chanbase + IOAT1_CHANCMD_OFFSET);
281 285
@@ -389,9 +393,9 @@ static void i7300_idle_start(void)
389 new_ctl = i7300_idle_thrtctl_saved & ~DIMM_THRTCTL_THRMHUNT; 393 new_ctl = i7300_idle_thrtctl_saved & ~DIMM_THRTCTL_THRMHUNT;
390 pci_write_config_byte(fbd_dev, DIMM_THRTCTL, new_ctl); 394 pci_write_config_byte(fbd_dev, DIMM_THRTCTL, new_ctl);
391 395
392 limit = i7300_idle_thrtlowlm; 396 limit = throttle_low_limit;
393 if (unlikely(limit > MAX_THRTLWLIMIT)) 397 if (unlikely(limit > MAX_THROTTLE_LOW_LIMIT))
394 limit = MAX_THRTLWLIMIT; 398 limit = MAX_THROTTLE_LOW_LIMIT;
395 399
396 pci_write_config_byte(fbd_dev, DIMM_THRTLOW, limit); 400 pci_write_config_byte(fbd_dev, DIMM_THRTLOW, limit);
397 401
@@ -440,7 +444,7 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val,
440 static ktime_t idle_begin_time; 444 static ktime_t idle_begin_time;
441 static int time_init = 1; 445 static int time_init = 1;
442 446
443 if (!i7300_idle_thrtlowlm) 447 if (!throttle_low_limit)
444 return 0; 448 return 0;
445 449
446 if (unlikely(time_init)) { 450 if (unlikely(time_init)) {
@@ -505,77 +509,8 @@ static struct notifier_block i7300_idle_nb = {
505 .notifier_call = i7300_idle_notifier, 509 .notifier_call = i7300_idle_notifier,
506}; 510};
507 511
508/*
509 * I/O AT controls (PCI bus 0 device 8 function 0)
510 * DIMM controls (PCI bus 0 device 16 function 1)
511 */
512#define IOAT_BUS 0
513#define IOAT_DEVFN PCI_DEVFN(8, 0)
514#define MEMCTL_BUS 0
515#define MEMCTL_DEVFN PCI_DEVFN(16, 1)
516
517struct fbd_ioat {
518 unsigned int vendor;
519 unsigned int ioat_dev;
520};
521
522/*
523 * The i5000 chip-set has the same hooks as the i7300
524 * but support is disabled by default because this driver
525 * has not been validated on that platform.
526 */
527#define SUPPORT_I5000 0
528
529static const struct fbd_ioat fbd_ioat_list[] = {
530 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB},
531#if SUPPORT_I5000
532 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT},
533#endif
534 {0, 0}
535};
536
537/* table of devices that work with this driver */
538static const struct pci_device_id pci_tbl[] = {
539 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_FBD_CNB) },
540#if SUPPORT_I5000
541 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
542#endif
543 { } /* Terminating entry */
544};
545
546MODULE_DEVICE_TABLE(pci, pci_tbl); 512MODULE_DEVICE_TABLE(pci, pci_tbl);
547 513
548/* Check for known platforms with I/O-AT */
549static int __init i7300_idle_platform_probe(void)
550{
551 int i;
552
553 fbd_dev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
554 if (!fbd_dev)
555 return -ENODEV;
556
557 for (i = 0; pci_tbl[i].vendor != 0; i++) {
558 if (fbd_dev->vendor == pci_tbl[i].vendor &&
559 fbd_dev->device == pci_tbl[i].device) {
560 break;
561 }
562 }
563 if (pci_tbl[i].vendor == 0)
564 return -ENODEV;
565
566 ioat_dev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
567 if (!ioat_dev)
568 return -ENODEV;
569
570 for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
571 if (ioat_dev->vendor == fbd_ioat_list[i].vendor &&
572 ioat_dev->device == fbd_ioat_list[i].ioat_dev) {
573 return 0;
574 }
575 }
576 return -ENODEV;
577}
578
579int stats_open_generic(struct inode *inode, struct file *fp) 514int stats_open_generic(struct inode *inode, struct file *fp)
580{ 515{
581 fp->private_data = inode->i_private; 516 fp->private_data = inode->i_private;
@@ -617,7 +552,7 @@ static int __init i7300_idle_init(void)
617 cpus_clear(idle_cpumask); 552 cpus_clear(idle_cpumask);
618 total_us = 0; 553 total_us = 0;
619 554
620 if (i7300_idle_platform_probe()) 555 if (i7300_idle_platform_probe(&fbd_dev, &ioat_dev))
621 return -ENODEV; 556 return -ENODEV;
622 557
623 if (i7300_idle_thrt_save()) 558 if (i7300_idle_thrt_save())