3 * Copyright (C) 2001 Dave Engebretsen & Todd Inglett IBM Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/init.h>
21 #include <linux/pci.h>
22 #include <linux/proc_fs.h>
23 #include <linux/bootmem.h>
25 #include <linux/rbtree.h>
26 #include <linux/spinlock.h>
27 #include <linux/seq_file.h>
29 #include <asm/processor.h>
32 #include <asm/machdep.h>
33 #include <asm/pgtable.h>
39 #define BUID_HI(buid) ((buid) >> 32)
40 #define BUID_LO(buid) ((buid) & 0xffffffff)
41 #define CONFIG_ADDR(busno, devfn) \
42 (((((busno) & 0xff) << 8) | ((devfn) & 0xf8)) << 8)
45 static int ibm_set_eeh_option;
46 static int ibm_set_slot_reset;
47 static int ibm_read_slot_reset_state;
48 static int ibm_slot_error_detail;
50 static int eeh_subsystem_enabled;
51 #define EEH_MAX_OPTS 4096
52 static char *eeh_opts;
53 static int eeh_opts_last;
55 /* Buffer for reporting slot-error-detail rtas calls */
56 static unsigned char slot_errbuf[RTAS_ERROR_LOG_MAX];
57 static spinlock_t slot_errbuf_lock = SPIN_LOCK_UNLOCKED;
58 static int eeh_error_buf_size;
60 /* System monitoring statistics */
61 static DEFINE_PER_CPU(unsigned long, total_mmio_ffs);
62 static DEFINE_PER_CPU(unsigned long, false_positives);
63 static DEFINE_PER_CPU(unsigned long, ignored_failures);
65 static int eeh_check_opts_config(struct device_node *dn, int class_code,
66 int vendor_id, int device_id,
70 * The pci address cache subsystem. This subsystem places
71 * PCI device address resources into a red-black tree, sorted
72 * according to the address range, so that given only an i/o
73 * address, the corresponding PCI device can be **quickly**
76 * Currently, the only customer of this code is the EEH subsystem;
77 * thus, this code has been somewhat tailored to suit EEH better.
78 * In particular, the cache does *not* hold the addresses of devices
79 * for which EEH is not enabled.
81 * (Implementation Note: The RB tree seems to be better/faster
82 * than any hash algo I could think of for this problem, even
83 * with the penalty of slow pointer chases for d-cache misses).
85 struct pci_io_addr_range
87 struct rb_node rb_node;
88 unsigned long addr_lo;
89 unsigned long addr_hi;
90 struct pci_dev *pcidev;
94 static struct pci_io_addr_cache
96 struct rb_root rb_root;
98 } pci_io_addr_cache_root;
100 static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr)
102 struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node;
105 struct pci_io_addr_range *piar;
106 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
108 if (addr < piar->addr_lo) {
111 if (addr > piar->addr_hi) {
114 pci_dev_get(piar->pcidev);
124 * pci_get_device_by_addr - Get device, given only address
125 * @addr: mmio (PIO) phys address or i/o port number
127 * Given an mmio phys address, or a port number, find a pci device
128 * that implements this address. Be sure to pci_dev_put the device
129 * when finished. I/O port numbers are assumed to be offset
130 * from zero (that is, they do *not* have pci_io_addr added in).
131 * It is safe to call this function within an interrupt.
133 static struct pci_dev *pci_get_device_by_addr(unsigned long addr)
138 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
139 dev = __pci_get_device_by_addr(addr);
140 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
146 * Handy-dandy debug print routine, does nothing more
147 * than print out the contents of our addr cache.
149 static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
154 n = rb_first(&cache->rb_root);
156 struct pci_io_addr_range *piar;
157 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
158 printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s %s\n",
159 (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
160 piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev),
161 pci_pretty_name(piar->pcidev));
168 /* Insert address range into the rb tree. */
169 static struct pci_io_addr_range *
170 pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
171 unsigned long ahi, unsigned int flags)
173 struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node;
174 struct rb_node *parent = NULL;
175 struct pci_io_addr_range *piar;
177 /* Walk tree, find a place to insert into tree */
180 piar = rb_entry(parent, struct pci_io_addr_range, rb_node);
181 if (alo < piar->addr_lo) {
182 p = &parent->rb_left;
183 } else if (ahi > piar->addr_hi) {
184 p = &parent->rb_right;
186 if (dev != piar->pcidev ||
187 alo != piar->addr_lo || ahi != piar->addr_hi) {
188 printk(KERN_WARNING "PIAR: overlapping address range\n");
193 piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC);
202 rb_link_node(&piar->rb_node, parent, p);
203 rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root);
208 static void __pci_addr_cache_insert_device(struct pci_dev *dev)
210 struct device_node *dn;
213 dn = pci_device_to_OF_node(dev);
215 printk(KERN_WARNING "PCI: no pci dn found for dev=%s %s\n",
216 pci_name(dev), pci_pretty_name(dev));
220 /* Skip any devices for which EEH is not enabled. */
221 if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) ||
222 dn->eeh_mode & EEH_MODE_NOCHECK) {
224 printk(KERN_INFO "PCI: skip building address cache for=%s %s\n",
225 pci_name(dev), pci_pretty_name(dev));
230 /* The cache holds a reference to the device... */
233 /* Walk resources on this device, poke them into the tree */
234 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
235 unsigned long start = pci_resource_start(dev,i);
236 unsigned long end = pci_resource_end(dev,i);
237 unsigned int flags = pci_resource_flags(dev,i);
239 /* We are interested only bus addresses, not dma or other stuff */
240 if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM)))
242 if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
244 pci_addr_cache_insert(dev, start, end, flags);
249 * pci_addr_cache_insert_device - Add a device to the address cache
250 * @dev: PCI device whose I/O addresses we are interested in.
252 * In order to support the fast lookup of devices based on addresses,
253 * we maintain a cache of devices that can be quickly searched.
254 * This routine adds a device to that cache.
256 void pci_addr_cache_insert_device(struct pci_dev *dev)
260 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
261 __pci_addr_cache_insert_device(dev);
262 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
265 static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
270 n = rb_first(&pci_io_addr_cache_root.rb_root);
272 struct pci_io_addr_range *piar;
273 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
275 if (piar->pcidev == dev) {
276 rb_erase(n, &pci_io_addr_cache_root.rb_root);
283 /* The cache no longer holds its reference to this device... */
288 * pci_addr_cache_remove_device - remove pci device from addr cache
289 * @dev: device to remove
291 * Remove a device from the addr-cache tree.
292 * This is potentially expensive, since it will walk
293 * the tree multiple times (once per resource).
294 * But so what; device removal doesn't need to be that fast.
296 void pci_addr_cache_remove_device(struct pci_dev *dev)
300 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
301 __pci_addr_cache_remove_device(dev);
302 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
306 * pci_addr_cache_build - Build a cache of I/O addresses
308 * Build a cache of pci i/o addresses. This cache will be used to
309 * find the pci device that corresponds to a given address.
310 * This routine scans all pci busses to build the cache.
311 * Must be run late in boot process, after the pci controllers
312 * have been scaned for devices (after all device resources are known).
314 void __init pci_addr_cache_build(void)
316 struct pci_dev *dev = NULL;
318 spin_lock_init(&pci_io_addr_cache_root.piar_lock);
320 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
321 /* Ignore PCI bridges ( XXX why ??) */
322 if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) {
325 pci_addr_cache_insert_device(dev);
329 /* Verify tree built up above, echo back the list of addrs. */
330 pci_addr_cache_print(&pci_io_addr_cache_root);
335 * eeh_token_to_phys - convert EEH address token to phys address
336 * @token i/o token, should be address in the form 0xA....
338 * Converts EEH address tokens into physical addresses. Note that
339 * ths routine does *not* convert I/O BAR addresses (which start
340 * with 0xE...) to phys addresses!
342 static unsigned long eeh_token_to_phys(unsigned long token)
345 unsigned long pa, vaddr;
347 if (REGION_ID(token) == EEH_REGION_ID)
348 vaddr = IO_TOKEN_TO_ADDR(token);
352 ptep = find_linux_pte(ioremap_mm.pgd, vaddr);
353 pa = pte_pfn(*ptep) << PAGE_SHIFT;
355 return pa | (vaddr & (PAGE_SIZE-1));
359 * eeh_check_failure - check if all 1's data is due to EEH slot freeze
360 * @token i/o token, should be address in the form 0xA....
361 * @val value, should be all 1's (XXX why do we need this arg??)
363 * Check for an eeh failure at the given token address.
364 * The given value has been read and it should be 1's (0xff, 0xffff or
367 * Probe to determine if an error actually occurred. If not return val.
370 * Note this routine might be called in an interrupt context ...
372 unsigned long eeh_check_failure(void *token, unsigned long val)
376 struct device_node *dn;
381 __get_cpu_var(total_mmio_ffs)++;
383 if (!eeh_subsystem_enabled)
386 /* Finding the phys addr + pci device; this is pretty quick. */
387 addr = eeh_token_to_phys((unsigned long)token);
388 dev = pci_get_device_by_addr(addr);
392 dn = pci_device_to_OF_node(dev);
398 /* Access to IO BARs might get this far and still not want checking. */
399 if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) ||
400 dn->eeh_mode & EEH_MODE_NOCHECK) {
405 if (!dn->eeh_config_addr) {
411 * Now test for an EEH failure. This is VERY expensive.
412 * Note that the eeh_config_addr may be a parent device
413 * in the case of a device behind a bridge, or it may be
414 * function zero of a multi-function device.
415 * In any case they must share a common PHB.
417 ret = rtas_call(ibm_read_slot_reset_state, 3, 3, rets,
418 dn->eeh_config_addr, BUID_HI(dn->phb->buid),
419 BUID_LO(dn->phb->buid));
421 if (ret == 0 && rets[1] == 1 && rets[0] >= 2) {
424 spin_lock_irqsave(&slot_errbuf_lock, flags);
425 memset(slot_errbuf, 0, eeh_error_buf_size);
427 log_event = rtas_call(ibm_slot_error_detail,
428 8, 1, NULL, dn->eeh_config_addr,
429 BUID_HI(dn->phb->buid),
430 BUID_LO(dn->phb->buid), NULL, 0,
431 virt_to_phys(slot_errbuf),
433 2 /* Permanent Error */);
436 log_error(slot_errbuf, ERR_TYPE_RTAS_LOG,
439 spin_unlock_irqrestore(&slot_errbuf_lock, flags);
442 * XXX We should create a separate sysctl for this.
444 * Since the panic_on_oops sysctl is used to halt
445 * the system in light of potential corruption, we
449 panic("EEH: MMIO failure (%d) on device:%s %s\n",
450 rets[0], pci_name(dev), pci_pretty_name(dev));
452 __get_cpu_var(ignored_failures)++;
453 printk(KERN_INFO "EEH: MMIO failure (%d) on device:%s %s\n",
454 rets[0], pci_name(dev), pci_pretty_name(dev));
457 __get_cpu_var(false_positives)++;
463 EXPORT_SYMBOL(eeh_check_failure);
465 struct eeh_early_enable_info {
466 unsigned int buid_hi;
467 unsigned int buid_lo;
471 /* Enable eeh for the given device node. */
472 static void *early_enable_eeh(struct device_node *dn, void *data)
474 struct eeh_early_enable_info *info = data;
476 char *status = get_property(dn, "status", NULL);
477 u32 *class_code = (u32 *)get_property(dn, "class-code", NULL);
478 u32 *vendor_id = (u32 *)get_property(dn, "vendor-id", NULL);
479 u32 *device_id = (u32 *)get_property(dn, "device-id", NULL);
485 if (status && strcmp(status, "ok") != 0)
486 return NULL; /* ignore devices with bad status */
488 /* Ignore bad nodes. */
489 if (!class_code || !vendor_id || !device_id)
492 /* There is nothing to check on PCI to ISA bridges */
493 if (dn->type && !strcmp(dn->type, "isa")) {
494 dn->eeh_mode |= EEH_MODE_NOCHECK;
499 * Now decide if we are going to "Disable" EEH checking
500 * for this device. We still run with the EEH hardware active,
501 * but we won't be checking for ff's. This means a driver
502 * could return bad data (very bad!), an interrupt handler could
503 * hang waiting on status bits that won't change, etc.
504 * But there are a few cases like display devices that make sense.
506 enable = 1; /* i.e. we will do checking */
507 if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
510 if (!eeh_check_opts_config(dn, *class_code, *vendor_id, *device_id,
513 printk(KERN_WARNING "EEH: %s user requested to run "
514 "without EEH checking.\n", dn->full_name);
519 if (!enable || info->force_off) {
520 dn->eeh_mode |= EEH_MODE_NOCHECK;
523 /* Ok... see if this device supports EEH. Some do, some don't,
524 * and the only way to find out is to check each and every one. */
525 regs = (u32 *)get_property(dn, "reg", NULL);
527 /* First register entry is addr (00BBSS00) */
528 /* Try to enable eeh */
529 ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
530 regs[0], info->buid_hi, info->buid_lo,
533 eeh_subsystem_enabled = 1;
534 dn->eeh_mode |= EEH_MODE_SUPPORTED;
535 dn->eeh_config_addr = regs[0];
537 printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name);
541 /* This device doesn't support EEH, but it may have an
542 * EEH parent, in which case we mark it as supported. */
543 if (dn->parent && (dn->parent->eeh_mode & EEH_MODE_SUPPORTED)) {
544 /* Parent supports EEH. */
545 dn->eeh_mode |= EEH_MODE_SUPPORTED;
546 dn->eeh_config_addr = dn->parent->eeh_config_addr;
551 printk(KERN_WARNING "EEH: %s: unable to get reg property.\n",
559 * Initialize EEH by trying to enable it for all of the adapters in the system.
560 * As a side effect we can determine here if eeh is supported at all.
561 * Note that we leave EEH on so failed config cycles won't cause a machine
562 * check. If a user turns off EEH for a particular adapter they are really
563 * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
564 * grant access to a slot if EEH isn't enabled, and so we always enable
565 * EEH for all slots/all devices.
567 * The eeh-force-off option disables EEH checking globally, for all slots.
568 * Even if force-off is set, the EEH hardware is still enabled, so that
569 * newer systems can boot.
571 void __init eeh_init(void)
573 struct device_node *phb, *np;
574 struct eeh_early_enable_info info;
575 char *eeh_force_off = strstr(saved_command_line, "eeh-force-off");
577 init_pci_config_tokens();
579 np = of_find_node_by_path("/rtas");
581 printk(KERN_WARNING "EEH: RTAS not found !\n");
585 ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
586 ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
587 ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
588 ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
590 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
593 eeh_error_buf_size = rtas_token("rtas-error-log-max");
594 if (eeh_error_buf_size == RTAS_UNKNOWN_SERVICE) {
595 eeh_error_buf_size = 1024;
597 if (eeh_error_buf_size > RTAS_ERROR_LOG_MAX) {
598 printk(KERN_WARNING "EEH: rtas-error-log-max is bigger than allocated "
599 "buffer ! (%d vs %d)", eeh_error_buf_size, RTAS_ERROR_LOG_MAX);
600 eeh_error_buf_size = RTAS_ERROR_LOG_MAX;
605 printk(KERN_WARNING "EEH: WARNING: PCI Enhanced I/O Error "
606 "Handling is user disabled\n");
610 /* Enable EEH for all adapters. Note that eeh requires buid's */
611 for (phb = of_find_node_by_name(NULL, "pci"); phb;
612 phb = of_find_node_by_name(phb, "pci")) {
615 buid = get_phb_buid(phb);
619 info.buid_lo = BUID_LO(buid);
620 info.buid_hi = BUID_HI(buid);
621 traverse_pci_devices(phb, early_enable_eeh, &info);
624 if (eeh_subsystem_enabled) {
625 printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n");
627 printk(KERN_WARNING "EEH: disabled PCI Enhanced I/O Error Handling\n");
632 * eeh_add_device_early - enable EEH for the indicated device_node
633 * @dn: device node for which to set up EEH
635 * This routine must be used to perform EEH initialization for PCI
636 * devices that were added after system boot (e.g. hotplug, dlpar).
637 * This routine must be called before any i/o is performed to the
638 * adapter (inluding any config-space i/o).
639 * Whether this actually enables EEH or not for this device depends
640 * on the CEC architecture, type of the device, on earlier boot
641 * command-line arguments & etc.
643 void eeh_add_device_early(struct device_node *dn)
645 struct pci_controller *phb;
646 struct eeh_early_enable_info info;
648 if (!dn || !eeh_subsystem_enabled)
651 if (NULL == phb || 0 == phb->buid) {
652 printk(KERN_WARNING "EEH: Expected buid but found none\n");
656 info.buid_hi = BUID_HI(phb->buid);
657 info.buid_lo = BUID_LO(phb->buid);
658 early_enable_eeh(dn, &info);
660 EXPORT_SYMBOL(eeh_add_device_early);
663 * eeh_add_device_late - perform EEH initialization for the indicated pci device
664 * @dev: pci device for which to set up EEH
666 * This routine must be used to complete EEH initialization for PCI
667 * devices that were added after system boot (e.g. hotplug, dlpar).
669 void eeh_add_device_late(struct pci_dev *dev)
671 if (!dev || !eeh_subsystem_enabled)
675 printk(KERN_DEBUG "EEH: adding device %s %s\n", pci_name(dev),
676 pci_pretty_name(dev));
679 pci_addr_cache_insert_device (dev);
681 EXPORT_SYMBOL(eeh_add_device_late);
684 * eeh_remove_device - undo EEH setup for the indicated pci device
685 * @dev: pci device to be removed
687 * This routine should be when a device is removed from a running
688 * system (e.g. by hotplug or dlpar).
690 void eeh_remove_device(struct pci_dev *dev)
692 if (!dev || !eeh_subsystem_enabled)
695 /* Unregister the device with the EEH/PCI address search system */
697 printk(KERN_DEBUG "EEH: remove device %s %s\n", pci_name(dev),
698 pci_pretty_name(dev));
700 pci_addr_cache_remove_device(dev);
702 EXPORT_SYMBOL(eeh_remove_device);
705 * If EEH is implemented, find the PCI device using given phys addr
706 * and check to see if eeh failure checking is disabled.
707 * Remap the addr (trivially) to the EEH region if EEH checking enabled.
708 * For addresses not known to PCI the vaddr is simply returned unchanged.
710 void *eeh_ioremap(unsigned long addr, void *vaddr)
713 struct device_node *dn;
715 if (!eeh_subsystem_enabled)
718 dev = pci_get_device_by_addr(addr);
722 dn = pci_device_to_OF_node(dev);
728 if (dn->eeh_mode & EEH_MODE_NOCHECK) {
734 return (void *)IO_ADDR_TO_TOKEN(vaddr);
737 static int proc_eeh_show(struct seq_file *m, void *v)
740 unsigned long ffs = 0, positives = 0, failures = 0;
743 ffs += per_cpu(total_mmio_ffs, cpu);
744 positives += per_cpu(false_positives, cpu);
745 failures += per_cpu(ignored_failures, cpu);
748 if (0 == eeh_subsystem_enabled) {
749 seq_printf(m, "EEH Subsystem is globally disabled\n");
750 seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs);
752 seq_printf(m, "EEH Subsystem is enabled\n");
753 seq_printf(m, "eeh_total_mmio_ffs=%ld\n"
754 "eeh_false_positives=%ld\n"
755 "eeh_ignored_failures=%ld\n",
756 ffs, positives, failures);
762 static int proc_eeh_open(struct inode *inode, struct file *file)
764 return single_open(file, proc_eeh_show, NULL);
767 static struct file_operations proc_eeh_operations = {
768 .open = proc_eeh_open,
771 .release = single_release,
774 static int __init eeh_init_proc(void)
776 struct proc_dir_entry *e;
778 if (systemcfg->platform & PLATFORM_PSERIES) {
779 e = create_proc_entry("ppc64/eeh", 0, NULL);
781 e->proc_fops = &proc_eeh_operations;
786 __initcall(eeh_init_proc);
789 * Test if "dev" should be configured on or off.
790 * This processes the options literally from left to right.
791 * This lets the user specify stupid combinations of options,
792 * but at least the result should be very predictable.
794 static int eeh_check_opts_config(struct device_node *dn,
795 int class_code, int vendor_id, int device_id,
798 char devname[32], classname[32];
801 int ret = default_state;
803 /* Build list of strings to match */
805 s = (char *)get_property(dn, "ibm,loc-code", NULL);
808 sprintf(devname, "dev%04x:%04x", vendor_id, device_id);
809 strs[nstrs++] = devname;
810 sprintf(classname, "class%04x", class_code);
811 strs[nstrs++] = classname;
812 strs[nstrs++] = ""; /* yes, this matches the empty string */
815 * Now see if any string matches the eeh_opts list.
816 * The eeh_opts list entries start with + or -.
818 for (s = eeh_opts; s && (s < (eeh_opts + eeh_opts_last));
820 for (i = 0; i < nstrs; i++) {
821 if (strcasecmp(strs[i], s+1) == 0) {
822 ret = (strs[i][0] == '+') ? 1 : 0;
830 * Handle kernel eeh-on & eeh-off cmd line options for eeh.
833 * eeh-off=loc1,loc2,loc3...
835 * and this option can be repeated so
836 * eeh-off=loc1,loc2 eeh-off=loc3
837 * is the same as eeh-off=loc1,loc2,loc3
839 * loc is an IBM location code that can be found in a manual or
840 * via openfirmware (or the Hardware Management Console).
842 * We also support these additional "loc" values:
844 * dev#:# vendor:device id in hex (e.g. dev1022:2000)
845 * class# class id in hex (e.g. class0200)
847 * If no location code is specified all devices are assumed
848 * so eeh-off means eeh by default is off.
852 * This is implemented as a null separated list of strings.
853 * Each string looks like this: "+X" or "-X"
854 * where X is a loc code, vendor:device, class (as shown above)
855 * or empty which is used to indicate all.
857 * We interpret this option string list so that it will literally
858 * behave left-to-right even if some combinations don't make sense.
860 static int __init eeh_parm(char *str, int state)
862 char *s, *cur, *curend;
865 eeh_opts = alloc_bootmem(EEH_MAX_OPTS);
866 eeh_opts[eeh_opts_last++] = '+'; /* default */
867 eeh_opts[eeh_opts_last++] = '\0';
870 eeh_opts[eeh_opts_last++] = state ? '+' : '-';
871 eeh_opts[eeh_opts_last++] = '\0';
876 for (s = str; s && *s != '\0'; s = curend) {
878 /* ignore empties. Don't treat as "all-on" or "all-off" */
881 curend = strchr(cur, ',');
883 curend = cur + strlen(cur);
885 int curlen = curend-cur;
886 if (eeh_opts_last + curlen > EEH_MAX_OPTS-2) {
887 printk(KERN_WARNING "EEH: sorry...too many "
888 "eeh cmd line options\n");
891 eeh_opts[eeh_opts_last++] = state ? '+' : '-';
892 strncpy(eeh_opts+eeh_opts_last, cur, curlen);
893 eeh_opts_last += curlen;
894 eeh_opts[eeh_opts_last++] = '\0';
901 static int __init eehoff_parm(char *str)
903 return eeh_parm(str, 0);
906 static int __init eehon_parm(char *str)
908 return eeh_parm(str, 1);
911 __setup("eeh-off", eehoff_parm);
912 __setup("eeh-on", eehon_parm);