diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-10-26 16:20:44 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-04 11:47:10 -0500 |
commit | ac1aa47b131416a6ff37eb1005a0a1d2541aad6c (patch) | |
tree | 1d7efa15a16f61664a240520970e729b1a47e4a5 /drivers/pci/quirks.c | |
parent | 99935a7a59eaca0292c1a5880e10bae03f4a5e3d (diff) |
PCI: determine CLS more intelligently
Till now, CLS has been determined either by arch code or as
L1_CACHE_BYTES. Only x86 and ia64 set CLS explicitly and x86 doesn't
always get it right. On most configurations, the chance is that
firmware configures the correct value during boot.
This patch makes pci_init() determine CLS by looking at what firmware
has configured. It scans all devices and if all non-zero values
agree, the value is used. If none is configured or there is a
disagreement, pci_dfl_cache_line_size is used. arch can set the dfl
value (via PCI_CACHE_LINE_BYTES or pci_dfl_cache_line_size) or
override the actual one.
ia64, x86 and sparc64 updated to set the default cls instead of the
actual one.
While at it, declare pci_cache_line_size and pci_dfl_cache_line_size
in pci.h and drop private declarations from arch code.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David Miller <davem@davemloft.net>
Acked-by: Greg KH <gregkh@suse.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/quirks.c')
-rw-r--r-- | drivers/pci/quirks.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 245d2cdb4765..1812ae7698de 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -2595,9 +2595,37 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | |||
2595 | static int __init pci_apply_final_quirks(void) | 2595 | static int __init pci_apply_final_quirks(void) |
2596 | { | 2596 | { |
2597 | struct pci_dev *dev = NULL; | 2597 | struct pci_dev *dev = NULL; |
2598 | u8 cls = 0; | ||
2599 | u8 tmp; | ||
2600 | |||
2601 | if (pci_cache_line_size) | ||
2602 | printk(KERN_DEBUG "PCI: CLS %u bytes\n", | ||
2603 | pci_cache_line_size << 2); | ||
2598 | 2604 | ||
2599 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 2605 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
2600 | pci_fixup_device(pci_fixup_final, dev); | 2606 | pci_fixup_device(pci_fixup_final, dev); |
2607 | /* | ||
2608 | * If arch hasn't set it explicitly yet, use the CLS | ||
2609 | * value shared by all PCI devices. If there's a | ||
2610 | * mismatch, fall back to the default value. | ||
2611 | */ | ||
2612 | if (!pci_cache_line_size) { | ||
2613 | pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &tmp); | ||
2614 | if (!cls) | ||
2615 | cls = tmp; | ||
2616 | if (!tmp || cls == tmp) | ||
2617 | continue; | ||
2618 | |||
2619 | printk(KERN_DEBUG "PCI: CLS mismatch (%u != %u), " | ||
2620 | "using %u bytes\n", cls << 2, tmp << 2, | ||
2621 | pci_dfl_cache_line_size << 2); | ||
2622 | pci_cache_line_size = pci_dfl_cache_line_size; | ||
2623 | } | ||
2624 | } | ||
2625 | if (!pci_cache_line_size) { | ||
2626 | printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n", | ||
2627 | cls << 2, pci_dfl_cache_line_size << 2); | ||
2628 | pci_cache_line_size = cls; | ||
2601 | } | 2629 | } |
2602 | 2630 | ||
2603 | return 0; | 2631 | return 0; |