Enable mmconf access to PCI ECS for all AMD fam10h systems
Yinghai,
We would like to enable ECS for all fam10h systems. What was the reason for patch 5f0b2976 that enables it for Sun systems only? If there are no objections, this patch should be reverted.
Thomas,
is there a chance to revert the patch for 2.6.26?
Thanks,
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Quoted 5 lines · Robert Richter
Yinghai,
We would like to enable ECS for all fam10h systems. What was the reason for patch
5f0b2976that enables it for Sun systems only? If there are no objections, this patch should be reverted.
Someone express the concern about touching MSR. Arjan or Andi?
for those of system that doesn't have MCFG table there, they could use pci=check_enable_amd_mmconf to enable it forcely.
YH
Quoted 15 lines
Thomas,
is there a chance to revert the patch for 2.6.26?
Thanks,
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]
Quoted 4 lines · On Fri, 23 May 2008 10:57:22 -0700 "Yinghai Lu" <[email protected]> wrote:
Quoted 2 lines · Robert Richter
Yinghai,
Quoted 8 lines
Quoted 3 lines
We would like to enable ECS for all fam10h systems. What was the reason for patch
5f0b2976that enables it for Sun systems only? If there are no objections, this patch should be reverted.Someone express the concern about touching MSR. Arjan or Andi?
for those of system that doesn't have MCFG table there, they could use pci=check_enable_amd_mmconf to enable it forcely.
using MMIO if the bios doesn't allow it via MCFG is a huge mistake and shouldn't be done.
Using the extended port IO version is actually perfectly reasonable to me and I would encourage that to be in the kernel (and be used in favor of MCFG if the port IO method is there)
Quoted 16 lines · Arjan van de Ven
Quoted 4 lines · On Fri, 23 May 2008 10:57:22 -0700 "Yinghai Lu" <[email protected]> wrote:
Quoted 2 lines · Robert Richter
Yinghai,
Quoted 8 lines
Quoted 3 lines
We would like to enable ECS for all fam10h systems. What was the reason for patch
5f0b2976that enables it for Sun systems only? If there are no objections, this patch should be reverted.Someone express the concern about touching MSR. Arjan or Andi?
for those of system that doesn't have MCFG table there, they could use pci=check_enable_amd_mmconf to enable it forcely.
Quoted 6 lines
using MMIO if the bios doesn't allow it via MCFG is a huge mistake and shouldn't be done.
Using the extended port IO version is actually perfectly reasonable to me and I would encourage that to be in the kernel (and be used in favor of MCFG if the port IO method is there)
that extend access via port IO on AMD Fam10h doesn't support pci domain other than domain 0.
YH
Thanks Yinghai and Arjan,
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines · On Fri, 23 May 2008 10:57:22 -0700 "Yinghai Lu" <[email protected]> wrote:
Someone express the concern about touching MSR. Arjan or Andi?
for those of system that doesn't have MCFG table there, they could use pci=check_enable_amd_mmconf to enable it forcely.
using MMIO if the bios doesn't allow it via MCFG is a huge mistake and shouldn't be done.
I see your concerns here, though it could possibly be save for access to processor config space only. Andi also stated before the BIOS should do the work.
Quoted 3 lines
Using the extended port IO version is actually perfectly reasonable to me and I would encourage that to be in the kernel (and be used in favor of MCFG if the port IO method is there)
Glad to hear that IO access code is also accepted to access ECS, at least for segment 0. I already submitted patches for this some times ago and will send an update. This would ensure access to ECS of processor config space if MMCONFIG is disabled. Also, this could be a solution for 32bit code.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
PATCH 1/1 x86: Add PCI extended config space access for AMD Barcelona
This patch implements PCI extended configuration space access for AMD's Barcelona CPUs. It extends the method using CF8/CFC IO addresses. An x86 capability bit has been introduced that is set for CPUs supporting PCI extended config space accesses.
--- arch/x86/kernel/cpu/amd.c | 4 ++++ arch/x86/kernel/setup.c | 13 +++++++++++++ arch/x86/kernel/setup.h | 26 ++++++++++++++++++++++++++ arch/x86/kernel/setup_64.c | 5 +++++ arch/x86/pci/direct.c | 21 +++++++++++++++------ include/asm-x86/cpufeature.h | 2 ++ 6 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 arch/x86/kernel/setup.h
arch/x86/kernel/cpu/amd.c +4 -0
@@ -6,6 +6,7 @@#include <asm/apic.h> #include <mach_apic.h> +#include "../setup.h" #include "cpu.h" /*
@@ -308,6 +309,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (cpu_has_xmm2)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); + +if (c->x86 ==0x10 ) +amd_enable_pci_ext_cfg (c); }static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 *c,unsigned int size)
arch/x86/kernel/setup.c +13 -0
@@ -136,4 +136,17 @@ void __init setup_per_cpu_areas(void) setup_cpumask_of_cpu(); } +#define ENABLE_CF8_EXT_CFG (1ULL << 46) + +void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c) +{ +u64 reg; +rdmsrl (MSR_AMD64_NB_CFG , reg); +if (!(reg &ENABLE_CF8_EXT_CFG )) { + reg |=ENABLE_CF8_EXT_CFG ; +wrmsrl (MSR_AMD64_NB_CFG , reg); + } +set_cpu_cap (c,X86_FEATURE_PCI_EXT_CFG ); +} +#endif
arch/x86/kernel/setup.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Internal declarations for shared x86 setup code. +* +* Copyright (c) 2008 Advanced Micro Devices, Inc. +* Contributed by Robert Richter <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +* 02111-1307 USA +*/ + +#ifndef _ARCH_X86_KERNEL_SETUP_H + +extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c); + +#endif /* _ARCH_X86_KERNEL_SETUP_H */
arch/x86/kernel/setup_64.c +5 -0
@@ -72,6 +72,8 @@#include <asm/trampoline.h> #include <asm/pat.h> +#include "setup.h" +#include <mach_apic.h> #ifdef CONFIG_PARAVIRT #include <asm/paravirt.h>
@@ -790,6 +792,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 ==0x10 )fam10h_check_enable_mmcfg (); +if (c->x86 ==0x10 ) +amd_enable_pci_ext_cfg (c); +if (amd_apic_timer_broken ()) disable_apic_timer =1 ;
arch/x86/pci/direct.c +15 -6
@@ -8,18 +8,21 @@#include "pci.h" /* -* Functions for accessing PCI configuration space with type 1 accesses +* Functions for accessing PCI base (first 256 bytes) and extended +* (4096 bytes per PCI function) configuration space with type 1 +* accesses. */ #define PCI_CONF1_ADDRESS (bus, devfn, reg) \ - (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) + (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) \ + | (devfn << 8) | (reg & 0xFC))static int pci_conf1_read (unsigned int seg,unsigned int bus,unsigned int devfn,int reg,int len,u32 *value) {unsigned long flags; -if ((bus >255 ) || (devfn >255 ) || (reg >255 )) { +if ((bus >255 ) || (devfn >255 ) || (reg >4095 )) { *value =-1 ;return -EINVAL ; }
@@ -50,7 +53,7 @@ static int pci_conf1_write(unsigned int seg, unsigned int bus, {unsigned long flags; -if ((bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ;spin_lock_irqsave (&pci_config_lock, flags);
@@ -260,10 +263,16 @@ void __init pci_direct_init(int type)return ;printk (KERN_INFO "PCI: Using configuration type %d for base access\n" , type); -if (type ==1 ) +if (type ==1 ) { raw_pci_ops = &pci_direct_conf1; -else +if (!raw_pci_ext_ops && cpu_has_pci_ext_cfg) { +printk (KERN_INFO "PCI: Using configuration type 1 " +"for extended access\n" ); + raw_pci_ext_ops = &pci_direct_conf1; + } + }else { raw_pci_ops = &pci_direct_conf2; + } }int __init pci_direct_probe (void )
include/asm-x86/cpufeature.h +2 -0
@@ -79,6 +79,7 @@#define X86_FEATURE_REP_GOOD (3*32+16)/* rep microcode works well on this CPU */ #define X86_FEATURE_MFENCE_RDTSC (3*32+17)/* Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC (3*32+18)/* Lfence synchronizes RDTSC */ +#define X86_FEATURE_PCI_EXT_CFG (3*32+19)/* PCI extended cfg access */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */
@@ -187,6 +188,7 @@ extern const char * const x86_power_flags[32];#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT) +#define cpu_has_pci_ext_cfg boot_cpu_has(X86_FEATURE_PCI_EXT_CFG)#if defined(CONFIG_X86_INVLPG ) || defined(CONFIG_X86_64 )# define cpu_has_invlpg 1
Signature · 1 line
1.5.3.7
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
On Mon, 3 Sep 2007 10:17:39 +0200
Robert Richter <[email protected]> wrote:
Hi,
As said before, I like the general approach. I have two comments below though...
arch/x86/pci/direct.c static int pci_conf1_write(unsigned int seg, unsigned int bus, · line 57
Quoted 5 lines
arch/x86/pci/direct.c +1
-1-if ((bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ;
Comment 1:
Can we make the 256/4096 thing conditional on actually having the feature somehow? (while not making the code TOO ugly)
Comment 2:
The cpu_has_XXX is a bit dubious; while it's dependent on your cpu model right now, I'm a bit hesitant to consider a PCI feature something that belongs in the cpu_has_XXX namespace. (Yes I know PCI is moving into the cpu package, but on a logical level it seems just the wrong place).
Do we need a platform_has_XXX namespace for things like this?
Signature · 3 lines
If you want to reach me at my work email, use [email protected] For development, discussion and tips for power savings, visit http://www.lesswatts.org
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
Arjan,
Quoted 3 lines · Arjan van de Ven
Comment 1:
Can we make the 256/4096 thing conditional on actually having the feature somehow? (while not making the code TOO ugly)
In the first version I had 2 functions also. The patch have had lots of duplicate code or inline functions. Since the conditional check is already in raw_pci_* I decided to not implement an additional check and use only one function.
int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val)
{
if (reg < 256 && raw_pci_ops)
return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
if (raw_pci_ext_ops)
return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
return -EINVAL;
}That leaves as a difference to the basic access is the shift left of bits 8:11 in the PCI_CONF1_ADDRESS macro. Functional the new macro is the same and the overhead for this is small. So I see keeping all code in one function as the best solution.
Quoted 7 lines
Comment 2:
Thecpu_has_XXXis a bit dubious; while it's dependent on your cpu model right now, I'm a bit hesitant to consider a PCI feature something that belongs in thecpu_has_XXXnamespace. (Yes I know PCI is moving into the cpu package, but on a logical level it seems just the wrong place).
Do we need aplatform_has_XXXnamespace for things like this?
An alternative implementation would be here to use a check something like pci_probe & PCI_HAS_EXT_CFG. If needed, I will send an updated patch.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
Quoted 11 lines · On Mon, 2 Jun 2008 16:19:29 +0200 Robert Richter <[email protected]> wrote:
Arjan,
Quoted 3 lines · Arjan van de Ven
Comment 1:
Can we make the 256/4096 thing conditional on actually having the feature somehow? (while not making the code TOO ugly)In the first version I had 2 functions also. The patch have had lots of duplicate code or inline functions. Since the conditional check is already in raw_pci_* I decided to not implement an additional check and use only one function.
ok fair enough.
Quoted 9 lines
Quoted 8 lines
Comment 2:
Thecpu_has_XXXis a bit dubious; while it's dependent on your cpu model right now, I'm a bit hesitant to consider a PCI feature something that belongs in thecpu_has_XXXnamespace. (Yes I know PCI is moving into the cpu package, but on a logical level it seems just the wrong place).
Do we need aplatform_has_XXXnamespace for things like this?
Quoted 3 lines
An alternative implementation would be here to use a check something like
pci_probe&PCI_HAS_EXT_CFG. If needed, I will send an updated patch.
I kind of prefer this, since logically this is a PCI not a CPU property. Would you mind doing this ?
(not that your current patch is wrong, it's just nicer to keep CPU stuff with the CPU and PCI stuff with PCI :)
(This wouldn't need to stop inclusion of your current patch, it can just be an incremental cleanup)
Signature · 3 lines
If you want to reach me at my work email, use [email protected] For development, discussion and tips for power savings, visit http://www.lesswatts.org
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
Quoted 10 lines · Arjan van de Ven
Quoted 3 lines
An alternative implementation would be here to use a check something like
pci_probe&PCI_HAS_EXT_CFG. If needed, I will send an updated patch.I kind of prefer this, since logically this is a PCI not a CPU property. Would you mind doing this ?
(not that your current patch is wrong, it's just nicer to keep CPU stuff with the CPU and PCI stuff with PCI :)
(This wouldn't need to stop inclusion of your current patch, it can just be an incremental cleanup)
Ok, I will send a follow on patch of this.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
PATCH 1/2 x86/pci: Renaming k8-bus_64.c to amd_bus.c
The name fits better since this is code not only for K8.
--- arch/x86/pci/Makefile_64 | 2 +- arch/x86/pci/amd_bus.c | 528 ++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/pci/k8-bus_64.c | 528 ---------------------------------------------- 3 files changed, 529 insertions(+), 529 deletions(-) create mode 100644 arch/x86/pci/amd_bus.c delete mode 100644 arch/x86/pci/k8-bus_64.c
arch/x86/pci/Makefile_64 +1 -1
@@ -13,5 +13,5 @@ obj-y += legacy.o irq.o common.o early.o # mmconfig has a 64bit special obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_64.o direct.o mmconfig-shared.o -obj-y += k8-bus_64.o +obj-y += amd_bus.o
arch/x86/pci/amd_bus.c new file +528 -0
528 lines not on this page · raw message
arch/x86/pci/k8-bus_64.c deleted +0 -528
528 lines not on this page · raw message
Signature · 1 line
1.5.5.3
Re: [PATCH 1/2] x86/pci: Renaming k8-bus_64.c to amd_bus.c
Quoted 16 lines · Robert Richter
The name fits better since this is code not only for K8.
Signed-off-by Robert Richter <[email protected]>--- arch/x86/pci/Makefile_64 | 2 +- arch/x86/pci/amd_bus.c | 528 ++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/pci/k8-bus_64.c | 528 ---------------------------------------------- 3 files changed, 529 insertions(+), 529 deletions(-) create mode 100644 arch/x86/pci/amd_bus.c delete mode 100644 arch/x86/pci/k8-bus_64.carch/x86/pci/Makefile_64 +0
-0
arch/x86/pci/Makefile_64 obj-y += legacy.o irq.o common.o early.o · line 16
Quoted 5 lines
arch/x86/pci/Makefile_64 +1
-1@@ -13,5 +13,5 @@ obj-y += legacy.o irq.o common.o early.o # mmconfig has a 64bit special obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_64.o direct.o mmconfig-shared.o -obj-y += k8-bus_64.o +obj-y += amd_bus.o
can we keep the _64?
It is used by 64bit only at this time.
YH
Re: [PATCH 1/2] x86/pci: Renaming k8-bus_64.c to amd_bus.c
Quoted 6 lines · Yinghai Lu
arch/x86/pci/Makefile_64 obj-y += legacy.o irq.o common.o early.o · line 16
Quoted 2 lines
arch/x86/pci/Makefile_64 +1
-1-obj-y += k8-bus_64.o +obj-y += amd_bus.ocan we keep the _64?
It is used by 64bit only at this time.
Patch 2/2 will introduce code that works also for 32 bit.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Ingo Molnar
AppliedRe: [PATCH 1/2] x86/pci: Renaming k8-bus_64.c to amd_bus.c
In reply to Robert RichterQuoted 3 lines · Robert Richter
The name fits better since this is code not only for K8.
Signed-off-by Robert Richter <[email protected]>
applied to tip/x86/cpu, thanks Robert.
Ingo
Re: [PATCH 1/2] x86/pci: Renaming k8-bus_64.c to amd_bus.c
In reply to Robert RichterQuoted 10 lines · Robert Richter
The name fits better since this is code not only for K8.
Signed-off-by Robert Richter <[email protected]>--- arch/x86/pci/Makefile_64 | 2 +- arch/x86/pci/amd_bus.c | 528 ++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/pci/k8-bus_64.c | 528 ---------------------------------------------- 3 files changed, 529 insertions(+), 529 deletions(-) create mode 100644 arch/x86/pci/amd_bus.c delete mode 100644 arch/x86/pci/k8-bus_64.c
I accidentally resent the patches, please igore.
Thanks,
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
PATCH 2/2 x86: Move PCI IO ECS code to x86/pci
In reply to Robert Richter"Form follows function". Code is now where it belongs to.
--- arch/x86/kernel/cpu/amd.c | 3 --- arch/x86/kernel/cpu/amd_64.c | 4 ---- arch/x86/kernel/cpu/cpu.h | 2 -- arch/x86/kernel/setup.c | 13 ------------- arch/x86/pci/Makefile_32 | 1 + arch/x86/pci/amd_bus.c | 32 ++++++++++++++++++++++++++++++++ arch/x86/pci/direct.c | 16 +++++++++------- arch/x86/pci/pci.h | 1 + include/asm-x86/cpufeature.h | 2 -- 9 files changed, 43 insertions(+), 31 deletions(-)
arch/x86/kernel/cpu/amd.c +0 -3
@@ -266,9 +266,6 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (cpu_has_xmm2)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); - -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); }static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 *c,unsigned int size)
arch/x86/kernel/cpu/amd_64.c +0 -4
@@ -6,7 +6,6 @@#include <asm/cacheflush.h> #include <mach_apic.h> -#include "cpu.h" extern int __cpuinit get_model_name (struct cpuinfo_x86 *c);extern void __cpuinit display_cacheinfo (struct cpuinfo_x86 *c);
@@ -187,9 +186,6 @@ void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 ==0x10 )fam10h_check_enable_mmcfg (); -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); -if (c == &boot_cpu_data && c->x86 >=0xf && c->x86 <=0x11 ) {unsigned long long tseg;
arch/x86/kernel/cpu/cpu.h +0 -2
@@ -39,5 +39,3 @@ extern int get_model_name(struct cpuinfo_x86 *c);extern void display_cacheinfo (struct cpuinfo_x86 *c);#endif /* CONFIG_X86_32 */ - -extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c);
arch/x86/kernel/setup.c +0 -13
@@ -137,16 +137,3 @@ void __init setup_per_cpu_areas(void) }#endif -#define ENABLE_CF8_EXT_CFG (1ULL << 46) - -void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c) -{ -u64 reg; -rdmsrl (MSR_AMD64_NB_CFG , reg); -if (!(reg &ENABLE_CF8_EXT_CFG )) { - reg |=ENABLE_CF8_EXT_CFG ; -wrmsrl (MSR_AMD64_NB_CFG , reg); - } -set_cpu_cap (c,X86_FEATURE_PCI_EXT_CFG ); -} -
arch/x86/pci/Makefile_32 +1 -0
@@ -22,3 +22,4 @@ pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o pci-$(CONFIG_NUMA) += mp_bus_to_node.o obj-y += $(pci-y) common.o early.o +obj-y += amd_bus.o
arch/x86/pci/amd_bus.c +32 -0
@@ -1,5 +1,9 @@#include <linux/init.h> #include <linux/pci.h> +#include "pci.h" + +#ifdef CONFIG_X86_64 +#include <asm/pci-direct.h> #include <asm/mpspec.h> #include <linux/cpumask.h>
@@ -526,3 +530,31 @@ static int __init early_fill_mp_bus_info(void) }postcore_initcall (early_fill_mp_bus_info); + +#endif + +/* common 32/64 bit code */ + +#define ENABLE_CF8_EXT_CFG (1ULL << 46) + +static void enable_pci_io_ecs_per_cpu (void *unused) +{ +u64 reg; +rdmsrl (MSR_AMD64_NB_CFG , reg); +if (!(reg &ENABLE_CF8_EXT_CFG )) { + reg |=ENABLE_CF8_EXT_CFG ; +wrmsrl (MSR_AMD64_NB_CFG , reg); + } +} + +static int __init enable_pci_io_ecs (void ) +{ +/* assume all cpus from fam10h have IO ECS */ +if (boot_cpu_data.x86 <0x10 ) +return 0 ; +on_each_cpu (enable_pci_io_ecs_per_cpu,NULL ,1 ,1 ); + pci_probe |=PCI_HAS_IO_ECS ; +return 0 ; +} + +postcore_initcall (enable_pci_io_ecs);
arch/x86/pci/direct.c +9 -7
@@ -265,14 +265,16 @@ void __init pci_direct_init(int type) type);if (type ==1 ) { raw_pci_ops = &pci_direct_conf1; -if (!raw_pci_ext_ops && cpu_has_pci_ext_cfg) { -printk (KERN_INFO "PCI: Using configuration type 1 " -"for extended access\n" ); - raw_pci_ext_ops = &pci_direct_conf1; - } - }else { - raw_pci_ops = &pci_direct_conf2; +if (raw_pci_ext_ops) +return ; +if (!(pci_probe &PCI_HAS_IO_ECS )) +return ; +printk (KERN_INFO "PCI: Using configuration type 1 " +"for extended access\n" ); + raw_pci_ext_ops = &pci_direct_conf1; +return ; } + raw_pci_ops = &pci_direct_conf2; }int __init pci_direct_probe (void )
arch/x86/pci/pci.h +1 -0
@@ -27,6 +27,7 @@#define PCI_CAN_SKIP_ISA_ALIGN 0x8000#define PCI_USE__CRS 0x10000#define PCI_CHECK_ENABLE_AMD_MMCONF 0x20000 +#define PCI_HAS_IO_ECS 0x40000extern unsigned int pci_probe;extern unsigned long pirq_table_addr;
include/asm-x86/cpufeature.h +0 -2
@@ -79,7 +79,6 @@#define X86_FEATURE_REP_GOOD (3*32+16)/* rep microcode works well on this CPU */ #define X86_FEATURE_MFENCE_RDTSC (3*32+17)/* Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC (3*32+18)/* Lfence synchronizes RDTSC */ -#define X86_FEATURE_PCI_EXT_CFG (3*32+19)/* PCI extended cfg access */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */
@@ -188,7 +187,6 @@ extern const char * const x86_power_flags[32];#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT) -#define cpu_has_pci_ext_cfg boot_cpu_has(X86_FEATURE_PCI_EXT_CFG)#if defined(CONFIG_X86_INVLPG ) || defined(CONFIG_X86_64 )# define cpu_has_invlpg 1
Signature · 1 line
1.5.5.3
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
Quoted 122 lines · Robert Richter
"Form follows function". Code is now where it belongs to.
Signed-off-by Robert Richter <[email protected]>--- arch/x86/kernel/cpu/amd.c | 3 --- arch/x86/kernel/cpu/amd_64.c | 4 ---- arch/x86/kernel/cpu/cpu.h | 2 -- arch/x86/kernel/setup.c | 13 ------------- arch/x86/pci/Makefile_32 | 1 + arch/x86/pci/amd_bus.c | 32 ++++++++++++++++++++++++++++++++ arch/x86/pci/direct.c | 16 +++++++++------- arch/x86/pci/pci.h | 1 + include/asm-x86/cpufeature.h | 2 -- 9 files changed, 43 insertions(+), 31 deletions(-)arch/x86/kernel/cpu/amd.c +0
-3@@ -266,9 +266,6 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (cpu_has_xmm2)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); - -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); }static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 *c,unsigned int size)arch/x86/kernel/cpu/amd_64.c +0
-4@@ -6,7 +6,6 @@#include <asm/cacheflush.h> #include <mach_apic.h> -#include "cpu.h" extern int __cpuinit get_model_name (struct cpuinfo_x86 *c);extern void __cpuinit display_cacheinfo (struct cpuinfo_x86 *c);@@ -187,9 +186,6 @@ void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 ==0x10 )fam10h_check_enable_mmcfg (); -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); -if (c == &boot_cpu_data && c->x86 >=0xf && c->x86 <=0x11 ) {unsigned long long tseg;arch/x86/kernel/cpu/cpu.h +0
-2@@ -39,5 +39,3 @@ extern int get_model_name(struct cpuinfo_x86 *c);extern void display_cacheinfo (struct cpuinfo_x86 *c);#endif /* CONFIG_X86_32 */ - -extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c);arch/x86/kernel/setup.c +0
-13@@ -137,16 +137,3 @@ void __init setup_per_cpu_areas(void) }#endif -#define ENABLE_CF8_EXT_CFG (1ULL << 46) - -void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c) -{ -u64 reg; -rdmsrl (MSR_AMD64_NB_CFG , reg); -if (!(reg &ENABLE_CF8_EXT_CFG )) { - reg |=ENABLE_CF8_EXT_CFG ; -wrmsrl (MSR_AMD64_NB_CFG , reg); - } -set_cpu_cap (c,X86_FEATURE_PCI_EXT_CFG ); -} -arch/x86/pci/Makefile_32 +1
-0@@ -22,3 +22,4 @@ pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o pci-$(CONFIG_NUMA) += mp_bus_to_node.o obj-y += $(pci-y) common.o early.o +obj-y += amd_bus.oarch/x86/pci/amd_bus.c +17
-0@@ -1,5 +1,9 @@#include <linux/init.h> #include <linux/pci.h> +#include "pci.h" + +#ifdef CONFIG_X86_64 +#include <asm/pci-direct.h> #include <asm/mpspec.h> #include <linux/cpumask.h> @@ -526,3 +530,31 @@ static int __init early_fill_mp_bus_info(void) }postcore_initcall (early_fill_mp_bus_info); + +#endif + +/* common 32/64 bit code */ + +#define ENABLE_CF8_EXT_CFG (1ULL << 46) + +static void enable_pci_io_ecs_per_cpu (void *unused) +{ +u64 reg; +rdmsrl (MSR_AMD64_NB_CFG , reg); +if (!(reg &ENABLE_CF8_EXT_CFG )) { + reg |=ENABLE_CF8_EXT_CFG ;
arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info(void) · line 555
Quoted 10 lines
arch/x86/pci/amd_bus.c +10
-0+wrmsrl (MSR_AMD64_NB_CFG , reg); + } +} + +static int __init enable_pci_io_ecs (void ) +{ +/* assume all cpus from fam10h have IO ECS */ +if (boot_cpu_data.x86 <0x10 ) +return 0 ; +on_each_cpu (enable_pci_io_ecs_per_cpu,NULL ,1 ,1 );
how about some cpu hotplug? i mean if you limit that when booting and later use "echo 1 > /sys/.../online" etc to get it online.
YH
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
Quoted 9 lines · Yinghai Lu
arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info(void) · line 555
Quoted 6 lines
arch/x86/pci/amd_bus.c +6
-0+static int __init enable_pci_io_ecs (void ) +{ +/* assume all cpus from fam10h have IO ECS */ +if (boot_cpu_data.x86 <0x10 ) +return 0 ; +on_each_cpu (enable_pci_io_ecs_per_cpu,NULL ,1 ,1 );how about some cpu hotplug? i mean if you limit that when booting and later use "echo 1 >
/sys/.../online" etc to get it online.
Yinghai, will look at this.
Thanks,
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
In reply to Robert RichterQuoted 96 lines · Robert Richter
"Form follows function". Code is now where it belongs to.
Signed-off-by Robert Richter <[email protected]>--- arch/x86/kernel/cpu/amd.c | 3 --- arch/x86/kernel/cpu/amd_64.c | 4 ---- arch/x86/kernel/cpu/cpu.h | 2 -- arch/x86/kernel/setup.c | 13 ------------- arch/x86/pci/Makefile_32 | 1 + arch/x86/pci/amd_bus.c | 32 ++++++++++++++++++++++++++++++++ arch/x86/pci/direct.c | 16 +++++++++------- arch/x86/pci/pci.h | 1 + include/asm-x86/cpufeature.h | 2 -- 9 files changed, 43 insertions(+), 31 deletions(-)arch/x86/kernel/cpu/amd.c +0
-3@@ -266,9 +266,6 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (cpu_has_xmm2)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); - -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); }static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 *c,unsigned int size)arch/x86/kernel/cpu/amd_64.c +0
-4@@ -6,7 +6,6 @@#include <asm/cacheflush.h> #include <mach_apic.h> -#include "cpu.h" extern int __cpuinit get_model_name (struct cpuinfo_x86 *c);extern void __cpuinit display_cacheinfo (struct cpuinfo_x86 *c);@@ -187,9 +186,6 @@ void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 ==0x10 )fam10h_check_enable_mmcfg (); -if (c->x86 ==0x10 ) -amd_enable_pci_ext_cfg (c); -if (c == &boot_cpu_data && c->x86 >=0xf && c->x86 <=0x11 ) {unsigned long long tseg;arch/x86/kernel/cpu/cpu.h +0
-2@@ -39,5 +39,3 @@ extern int get_model_name(struct cpuinfo_x86 *c);extern void display_cacheinfo (struct cpuinfo_x86 *c);#endif /* CONFIG_X86_32 */ - -extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c);arch/x86/kernel/setup.c +0
-13@@ -137,16 +137,3 @@ void __init setup_per_cpu_areas(void) }#endif -#define ENABLE_CF8_EXT_CFG (1ULL << 46) - -void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c) -{ -u64 reg; -rdmsrl (MSR_AMD64_NB_CFG , reg); -if (!(reg &ENABLE_CF8_EXT_CFG )) { - reg |=ENABLE_CF8_EXT_CFG ; -wrmsrl (MSR_AMD64_NB_CFG , reg); - } -set_cpu_cap (c,X86_FEATURE_PCI_EXT_CFG ); -} -arch/x86/pci/Makefile_32 +1
-0@@ -22,3 +22,4 @@ pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o pci-$(CONFIG_NUMA) += mp_bus_to_node.o obj-y += $(pci-y) common.o early.o +obj-y += amd_bus.oarch/x86/pci/amd_bus.c +0
-0
arch/x86/pci/amd_bus.c line 5
Quoted 5 lines
arch/x86/pci/amd_bus.c +3
-0@@ -1,5 +1,9 @@#include <linux/init.h> #include <linux/pci.h> +#include "pci.h" + +#ifdef CONFIG_X86_64
Please, don't do that. We are in an ongoing effort to cleanup the remaining ifdefs in x86 code, and adding more of them would just make it harder.
If you really need it, move the common part to a separate file (avoid the _32 and _64 naming), and have it compiled conditionally on your architecture.
Quoted 105 lines
arch/x86/pci/amd_bus.c +28
-0#include <asm/pci-direct.h> #include <asm/mpspec.h> #include <linux/cpumask.h> @@ -526,3 +530,31 @@ static int __init early_fill_mp_bus_info(void) }postcore_initcall (early_fill_mp_bus_info); + +#endif + +/* common 32/64 bit code */ + +#define ENABLE_CF8_EXT_CFG (1ULL << 46) + +static void enable_pci_io_ecs_per_cpu (void *unused) +{ +u64 reg; +rdmsrl (MSR_AMD64_NB_CFG , reg); +if (!(reg &ENABLE_CF8_EXT_CFG )) { + reg |=ENABLE_CF8_EXT_CFG ; +wrmsrl (MSR_AMD64_NB_CFG , reg); + } +} + +static int __init enable_pci_io_ecs (void ) +{ +/* assume all cpus from fam10h have IO ECS */ +if (boot_cpu_data.x86 <0x10 ) +return 0 ; +on_each_cpu (enable_pci_io_ecs_per_cpu,NULL ,1 ,1 ); + pci_probe |=PCI_HAS_IO_ECS ; +return 0 ; +} + +postcore_initcall (enable_pci_io_ecs);arch/x86/pci/direct.c +9
-7@@ -265,14 +265,16 @@ void __init pci_direct_init(int type) type);if (type ==1 ) { raw_pci_ops = &pci_direct_conf1; -if (!raw_pci_ext_ops && cpu_has_pci_ext_cfg) { -printk (KERN_INFO "PCI: Using configuration type 1 " -"for extended access\n" ); - raw_pci_ext_ops = &pci_direct_conf1; - } - }else { - raw_pci_ops = &pci_direct_conf2; +if (raw_pci_ext_ops) +return ; +if (!(pci_probe &PCI_HAS_IO_ECS )) +return ; +printk (KERN_INFO "PCI: Using configuration type 1 " +"for extended access\n" ); + raw_pci_ext_ops = &pci_direct_conf1; +return ; } + raw_pci_ops = &pci_direct_conf2; }int __init pci_direct_probe (void )arch/x86/pci/pci.h +1
-0@@ -27,6 +27,7 @@#define PCI_CAN_SKIP_ISA_ALIGN 0x8000#define PCI_USE__CRS 0x10000#define PCI_CHECK_ENABLE_AMD_MMCONF 0x20000 +#define PCI_HAS_IO_ECS 0x40000extern unsigned int pci_probe;extern unsigned long pirq_table_addr;include/asm-x86/cpufeature.h +0
-3@@ -79,7 +79,6 @@#define X86_FEATURE_REP_GOOD (3*32+16)/* rep microcode works well on this CPU */ #define X86_FEATURE_MFENCE_RDTSC (3*32+17)/* Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC (3*32+18)/* Lfence synchronizes RDTSC */ -#define X86_FEATURE_PCI_EXT_CFG (3*32+19)/* PCI extended cfg access */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */ @@ -188,7 +187,6 @@ extern const char * const x86_power_flags[32];#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT) -#define cpu_has_pci_ext_cfg boot_cpu_has(X86_FEATURE_PCI_EXT_CFG)#if defined(CONFIG_X86_INVLPG ) || defined(CONFIG_X86_64 )# define cpu_has_invlpg 1 --1.5.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
Quoted 9 lines · Glauber Costa
Quoted 9 lines
arch/x86/pci/amd_bus.c +2
-0@@ -1,5 +1,9 @@#include <linux/init.h> #include <linux/pci.h> +#include "pci.h" +
Quoted 8 lines
arch/x86/pci/amd_bus.c line 5
Quoted 1 line
arch/x86/pci/amd_bus.c +1
-0+#ifdef CONFIG_X86_64 Please, don't do that. We are in an ongoing effort to cleanup the remaining ifdefs in x86 code, and adding more of them would just make it harder.
If you really need it, move the common part to a separate file (avoid the _32 and _64 naming), and have it compiled conditionally on your architecture.
Ok, so what about shared code? Keep all this in separate files:amd_bus.c, (amd_bus_32.c), amd_bus_64.c, (amd_bus.h)?
Is the strategy to avoid #ifdefs and instead use the flags in Makefiles? My intention was to coalesce the files. Maybe I was wrong here.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
Quoted 19 lines · Robert Richter
Quoted 9 lines · Glauber Costa
Quoted 9 lines
arch/x86/pci/amd_bus.c +2
-0@@ -1,5 +1,9 @@#include <linux/init.h> #include <linux/pci.h> +#include "pci.h" +Quoted 8 lines
arch/x86/pci/amd_bus.c line 5
Quoted 1 line
arch/x86/pci/amd_bus.c +1
-0+#ifdef CONFIG_X86_64 Please, don't do that. We are in an ongoing effort to cleanup the remaining ifdefs in x86 code, and adding more of them would just make it harder.
If you really need it, move the common part to a separate file (avoid the _32 and _64 naming), and have it compiled conditionally on your architecture.
Quoted 6 lines
Ok, so what about shared code? Keep all this in separate files:
amd_bus.c, (amd_bus_32.c),amd_bus_64.c, (amd_bus.h)?Is the strategy to avoid #ifdefs and instead use the flags in Makefiles? My intention was to coalesce the files. Maybe I was wrong here.
The strategy is to coalesce the files if they do the same thing. If you can find an implementation that is shared
between both, it is surely the most preferable option among them all. Even if it takes more time.
For some of them, this is obviously not intrinsically possible. That's the case for example, of the .S files that touch deep details of the architectures. (ok, ok, _some_ of that code might well be shared in the future). Another example, is the page headers. Part of it were kept in page_32.h and page_64.h.
If not, ifdefs in the .h file are probably okay, if they can be used to avoid them in .c code.
But of course, those things are not carved in stone. If you really think that ifdef should go there, feel free to do it, with a good justification.
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
In reply to Robert RichterQuoted 6 lines · Robert Richter
Ok, so what about shared code? Keep all this in separate files:
amd_bus.c, (amd_bus_32.c),amd_bus_64.c, (amd_bus.h)?Is the strategy to avoid #ifdefs and instead use the flags in Makefiles? My intention was to coalesce the files. Maybe I was wrong here.
What you did is fine - first step is to move the variants as close to each other as possible, in an as obvious and mechanic step as possible.
If anything breaks due to your patches then they were probably too large, but lets be optimistic and try your current splitup first :)
Then we can start eliminating any leftover #ifdefs, step by step. Please send very, very small patches for that (put them into a git tree on kernel.org if there's more than say a dozen of them), we'll test them, and if the changes break anything it's all bisectable to an individual change.
Ingo
Ingo Molnar
AppliedRe: [PATCH 2/2] x86: Move PCI IO ECS code to x86/pci
In reply to Robert RichterQuoted 1 line · Robert Richter
"Form follows function". Code is now where it belongs to.
applied to tip/x86/cpu - thanks.
Ingo
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
In reply to Robert RichterQuoted 4 lines · Robert Richter
This patch implements PCI extended configuration space access for AMD's Barcelona CPUs. It extends the method using CF8/CFC IO addresses. An x86 capability bit has been introduced that is set for CPUs supporting PCI extended config space accesses.
applied to -tip for more testing, thanks Robert. It needed some porting (64-bit setup code got restructured in -tip) and the trivial build fix below.
Ingo
------------->
commit fe8aef82b5040c39fb3bee28047db5c896421382
Author: Ingo Molnar <[email protected]> Date: Mon Jun 2 10:54:16 2008 +0200
fix build bug in "x86: add PCI extended config space access for AMD Barcelona"
include/asm-x86/mmconfig.h +2 -0
@@ -9,4 +9,6 @@ static inline void fam10h_check_enable_mmcfg(void) { }static inline void check_enable_amd_mmconf_dmi (void ) { }#endif +extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c); +#endif
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
include/asm-x86/mmconfig.h static inline void fam10h_check_enable_mmcfg(void) { } · line 14
Quoted 11 lines · Ingo Molnar
include/asm-x86/mmconfig.h +2
-0@@ -9,4 +9,6 @@ static inline void fam10h_check_enable_mmcfg(void) { }static inline void check_enable_amd_mmconf_dmi (void ) { }#endif +extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c); +#endif
It's better to add #include "../setup.h" to arch/x86/kernel/cpu/amd_64.c since this is already defined there and it is actually no mmconf code.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
In reply to Robert RichterQuoted 155 lines · Robert Richter
This patch implements PCI extended configuration space access for AMD's Barcelona CPUs. It extends the method using CF8/CFC IO addresses. An x86 capability bit has been introduced that is set for CPUs supporting PCI extended config space accesses.
Signed-off-by Robert Richter <[email protected]>--- arch/x86/kernel/cpu/amd.c | 4 ++++ arch/x86/kernel/setup.c | 13 +++++++++++++ arch/x86/kernel/setup.h | 26 ++++++++++++++++++++++++++ arch/x86/kernel/setup_64.c | 5 +++++ arch/x86/pci/direct.c | 21 +++++++++++++++------ include/asm-x86/cpufeature.h | 2 ++ 6 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 arch/x86/kernel/setup.harch/x86/kernel/cpu/amd.c +4
-0@@ -6,6 +6,7 @@#include <asm/apic.h> #include <mach_apic.h> +#include "../setup.h" #include "cpu.h" /* @@ -308,6 +309,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (cpu_has_xmm2)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); + +if (c->x86 ==0x10 ) +amd_enable_pci_ext_cfg (c); }static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 *c,unsigned int size)arch/x86/kernel/setup.c +13
-0@@ -136,4 +136,17 @@ void __init setup_per_cpu_areas(void) setup_cpumask_of_cpu(); } +#define ENABLE_CF8_EXT_CFG (1ULL << 46) + +void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c) +{ +u64 reg; +rdmsrl (MSR_AMD64_NB_CFG , reg); +if (!(reg &ENABLE_CF8_EXT_CFG )) { + reg |=ENABLE_CF8_EXT_CFG ; +wrmsrl (MSR_AMD64_NB_CFG , reg); + } +set_cpu_cap (c,X86_FEATURE_PCI_EXT_CFG ); +} +#endif arch/x86/kernel/setup.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* Internal declarations for shared x86 setup code. +* +* Copyright (c) 2008 Advanced Micro Devices, Inc. +* Contributed by Robert Richter <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +* 02111-1307 USA +*/ + +#ifndef _ARCH_X86_KERNEL_SETUP_H + +extern void __cpuinit amd_enable_pci_ext_cfg (struct cpuinfo_x86 *c); + +#endif /* _ARCH_X86_KERNEL_SETUP_H */ arch/x86/kernel/setup_64.c +5
-0@@ -72,6 +72,8 @@#include <asm/trampoline.h> #include <asm/pat.h> +#include "setup.h" +#include <mach_apic.h> #ifdef CONFIG_PARAVIRT #include <asm/paravirt.h> @@ -790,6 +792,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 ==0x10 )fam10h_check_enable_mmcfg (); +if (c->x86 ==0x10 ) +amd_enable_pci_ext_cfg (c); +if (amd_apic_timer_broken ()) disable_apic_timer =1 ;arch/x86/pci/direct.c +7
-4@@ -8,18 +8,21 @@#include "pci.h" /* -* Functions for accessing PCI configuration space with type 1 accesses +* Functions for accessing PCI base (first 256 bytes) and extended +* (4096 bytes per PCI function) configuration space with type 1 +* accesses. */ #define PCI_CONF1_ADDRESS (bus, devfn, reg) \ - (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) + (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) \ + | (devfn << 8) | (reg & 0xFC))static int pci_conf1_read (unsigned int seg,unsigned int bus,unsigned int devfn,int reg,int len,u32 *value) {unsigned long flags; -if ((bus >255 ) || (devfn >255 ) || (reg >255 )) { +if ((bus >255 ) || (devfn >255 ) || (reg >4095 )) { *value =-1 ;return -EINVAL ; }@@ -50,7 +53,7 @@ static int pci_conf1_write(unsigned int seg, unsigned int bus, {unsigned long flags; -if ((bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ;spin_lock_irqsave (&pci_config_lock, flags);@@ -260,10 +263,16 @@ void __init pci_direct_init(int type)return ;
arch/x86/pci/direct.c void __init pci_direct_init(int type) · line 271
Quoted 10 lines
arch/x86/pci/direct.c +5
-2printk (KERN_INFO "PCI: Using configuration type %d for base access\n" , type); -if (type ==1 ) +if (type ==1 ) { raw_pci_ops = &pci_direct_conf1; -else +if (!raw_pci_ext_ops && cpu_has_pci_ext_cfg) { +printk (KERN_INFO "PCI: Using configuration type 1 " +"for extended access\n" ); + raw_pci_ext_ops = &pci_direct_conf1;
can you add extra pci_direct_ext_conf1 intead?
so don't need change reg size in pci_direct_conf1
also if could avoid cpu_has_pci_ext_cfg, it would be great...
YH
Quoted 32 lines
arch/x86/pci/direct.c +3
-0+ } + }else { raw_pci_ops = &pci_direct_conf2; + } }int __init pci_direct_probe (void )include/asm-x86/cpufeature.h +2
-1@@ -79,6 +79,7 @@#define X86_FEATURE_REP_GOOD (3*32+16)/* rep microcode works well on this CPU */ #define X86_FEATURE_MFENCE_RDTSC (3*32+17)/* Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC (3*32+18)/* Lfence synchronizes RDTSC */ +#define X86_FEATURE_PCI_EXT_CFG (3*32+19)/* PCI extended cfg access */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */ @@ -187,6 +188,7 @@ extern const char * const x86_power_flags[32];#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT) +#define cpu_has_pci_ext_cfg boot_cpu_has(X86_FEATURE_PCI_EXT_CFG)#if defined(CONFIG_X86_INVLPG ) || defined(CONFIG_X86_64 )# define cpu_has_invlpg 1 --1.5.3.7
Re: [PATCH] x86: Add PCI extended config space access for AMD Barcelona
Quoted 8 lines · Yinghai Lu
arch/x86/pci/direct.c void __init pci_direct_init(int type) · line 271
Quoted 4 lines
arch/x86/pci/direct.c +4
-0+if (!raw_pci_ext_ops && cpu_has_pci_ext_cfg) { +printk (KERN_INFO "PCI: Using configuration type 1 " +"for extended access\n" ); + raw_pci_ext_ops = &pci_direct_conf1;can you add extra
pci_direct_ext_conf1intead?so don't need change reg size in
pci_direct_conf1
The reg size check is already in raw_pci_*. Both functions would be almost identical. See my previous mail.
Quoted 1 line
also if could avoid
cpu_has_pci_ext_cfg, it would be great...
I intend to implement pci_probe & PCI_HAS_EXT_CFG in a follow on patch instead.
-Robert
Signature · 3 lines
Advanced Micro Devices, Inc. Operating System Research Center email: [email protected]