LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86 pci: remove checking type for mmconfig probe
@ 2008-02-28 0:39 Yinghai Lu
2008-02-29 7:56 ` [PATCH] x86 pci: remove checking type for mmconfig probe v2 Yinghai Lu
0 siblings, 1 reply; 7+ messages in thread
From: Yinghai Lu @ 2008-02-28 0:39 UTC (permalink / raw)
To: Ingo Molnar, Greg KH, Andrew Morton; +Cc: Linux Kernel Mailing List
don't need to check if it is type1 or type2. we can use raw_pci_ops dirctly.
also make pci_direct_conf1 static again.
anyway is there system with type 2 and mmconf support?
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/arch/x86/pci/direct.c b/arch/x86/pci/direct.c
index 42f3e4c..739ce26 100644
--- a/arch/x86/pci/direct.c
+++ b/arch/x86/pci/direct.c
@@ -76,7 +76,7 @@ static int pci_conf1_write(unsigned int seg, unsigned int bus,
#undef PCI_CONF1_ADDRESS
-struct pci_raw_ops pci_direct_conf1 = {
+static struct pci_raw_ops pci_direct_conf1 = {
.read = pci_conf1_read,
.write = pci_conf1_write,
};
@@ -258,7 +258,8 @@ void __init pci_direct_init(int type)
{
if (type == 0)
return;
- printk(KERN_INFO "PCI: Using configuration type %d\n", type);
+ printk(KERN_INFO "PCI: Using configuration type %d for base access\n",
+ type);
if (type == 1)
raw_pci_ops = &pci_direct_conf1;
else
@@ -275,8 +276,10 @@ int __init pci_direct_probe(void)
if (!region)
goto type2;
- if (pci_check_type1())
+ if (pci_check_type1()) {
+ raw_pci_ops = &pci_direct_conf1;
return 1;
+ }
release_resource(region);
type2:
@@ -290,7 +293,6 @@ int __init pci_direct_probe(void)
goto fail2;
if (pci_check_type2()) {
- printk(KERN_INFO "PCI: Using configuration type 2\n");
raw_pci_ops = &pci_direct_conf2;
return 2;
}
diff --git a/arch/x86/pci/init.c b/arch/x86/pci/init.c
index 2080b04..b4083dc 100644
--- a/arch/x86/pci/init.c
+++ b/arch/x86/pci/init.c
@@ -6,12 +6,12 @@
in the right sequence from here. */
static __init int pci_access_init(void)
{
- int type __maybe_unused = 0;
-
#ifdef CONFIG_PCI_DIRECT
+ int type = 0;
+
type = pci_direct_probe();
#endif
- pci_mmcfg_early_init(type);
+ pci_mmcfg_early_init();
if (raw_pci_ops)
return 0;
#ifdef CONFIG_PCI_BIOS
@@ -26,7 +26,7 @@ static __init int pci_access_init(void)
#ifdef CONFIG_PCI_DIRECT
pci_direct_init(type);
#endif
- if (!raw_pci_ops)
+ if (!raw_pci_ops && !raw_pci_ext_ops)
printk(KERN_ERR
"PCI: Fatal: No config space access function found\n");
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 1dbc101..16f610b 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -28,7 +28,7 @@ static int __initdata pci_mmcfg_resources_inserted;
static const char __init *pci_mmcfg_e7520(void)
{
u32 win;
- pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win);
+ raw_pci_ops->read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win);
win = win & 0xf000;
if(win == 0x0000 || win == 0xf000)
@@ -53,7 +53,7 @@ static const char __init *pci_mmcfg_intel_945(void)
pci_mmcfg_config_num = 1;
- pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar);
+ raw_pci_ops->read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar);
/* Enable bit */
if (!(pciexbar & 1))
@@ -179,6 +179,9 @@ static int __init pci_mmcfg_check_hostbridge(void)
int i;
const char *name;
+ if (!raw_pci_ops)
+ return 0;
+
pci_mmcfg_config_num = 0;
pci_mmcfg_config = NULL;
name = NULL;
@@ -186,7 +189,7 @@ static int __init pci_mmcfg_check_hostbridge(void)
for (i = 0; !name && i < ARRAY_SIZE(pci_mmcfg_probes); i++) {
bus = pci_mmcfg_probes[i].bus;
devfn = pci_mmcfg_probes[i].devfn;
- pci_direct_conf1.read(0, bus, devfn, 0, 4, &l);
+ raw_pci_ops->read(0, bus, devfn, 0, 4, &l);
vendor = l & 0xffff;
device = (l >> 16) & 0xffff;
@@ -304,7 +307,7 @@ static int __init is_acpi_reserved(unsigned long start, unsigned long end)
return mcfg_res.flags;
}
-static void __init pci_mmcfg_reject_broken(int type, int early)
+static void __init pci_mmcfg_reject_broken(int early)
{
typeof(pci_mmcfg_config[0]) *cfg;
int i;
@@ -342,8 +345,8 @@ static void __init pci_mmcfg_reject_broken(int type, int early)
" reserved in ACPI motherboard resources\n",
cfg->address);
/* Don't try to do this check unless configuration
- type 1 is available. */
- if (type == 1 && e820_all_mapped(cfg->address,
+ type 1 is available. how about type 2 ?*/
+ if (raw_pci_ops && e820_all_mapped(cfg->address,
cfg->address + size - 1,
E820_RESERVED)) {
printk(KERN_NOTICE
@@ -368,7 +371,7 @@ reject:
static int __initdata known_bridge;
-void __init __pci_mmcfg_init(int type, int early)
+void __init __pci_mmcfg_init(int early)
{
/* MMCONFIG disabled */
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
@@ -382,7 +385,7 @@ void __init __pci_mmcfg_init(int type, int early)
if (known_bridge)
return;
- if (early && type == 1) {
+ if (early) {
if (pci_mmcfg_check_hostbridge())
known_bridge = 1;
#if 0
@@ -394,7 +397,7 @@ void __init __pci_mmcfg_init(int type, int early)
if (!known_bridge) {
acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
- pci_mmcfg_reject_broken(type, early);
+ pci_mmcfg_reject_broken(early);
}
if ((pci_mmcfg_config_num == 0) ||
@@ -415,19 +418,14 @@ void __init __pci_mmcfg_init(int type, int early)
}
}
-void __init pci_mmcfg_early_init(int type)
+void __init pci_mmcfg_early_init(void)
{
- __pci_mmcfg_init(type, 1);
+ __pci_mmcfg_init(1);
}
void __init pci_mmcfg_late_init(void)
{
- int type = 0;
-
- if (pci_probe & PCI_PROBE_CONF1)
- type = 1;
-
- __pci_mmcfg_init(type, 0);
+ __pci_mmcfg_init(0);
}
static int __init pci_mmcfg_late_insert_resources(void)
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h
index c9fb637..d345661 100644
--- a/arch/x86/pci/pci.h
+++ b/arch/x86/pci/pci.h
@@ -95,8 +95,6 @@ struct pci_raw_ops {
extern struct pci_raw_ops *raw_pci_ops;
extern struct pci_raw_ops *raw_pci_ext_ops;
-extern struct pci_raw_ops pci_direct_conf1;
-
extern int pci_direct_probe(void);
extern void pci_direct_init(int type);
extern void pci_pcbios_init(void);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f9ab5fe..8c76066 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1052,10 +1052,10 @@ extern unsigned long pci_cardbus_mem_size;
extern int pcibios_add_platform_entries(struct pci_dev *dev);
#ifdef CONFIG_PCI_MMCONFIG
-extern void __init pci_mmcfg_early_init(int type);
+extern void __init pci_mmcfg_early_init(void);
extern void __init pci_mmcfg_late_init(void);
#else
-static inline void pci_mmcfg_early_init(int type) { }
+static inline void pci_mmcfg_early_init(void) { }
static inline void pci_mmcfg_late_init(void) { }
#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-02-28 0:39 [PATCH] x86 pci: remove checking type for mmconfig probe Yinghai Lu
@ 2008-02-29 7:56 ` Yinghai Lu
2008-02-29 19:17 ` Ingo Molnar
2008-03-01 6:02 ` Greg KH
0 siblings, 2 replies; 7+ messages in thread
From: Yinghai Lu @ 2008-02-29 7:56 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Greg KH, Andrew Morton, Linux Kernel Mailing List
doesn't need to check if it is type1 or type2. we can use raw_pci_ops dirctly.
also make pci_direct_conf1 static again.
anyway is there system with type 2 and mmconf support?
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Index: linux-2.6/arch/x86/pci/direct.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/direct.c
+++ linux-2.6/arch/x86/pci/direct.c
@@ -76,7 +76,7 @@ static int pci_conf1_write(unsigned int
#undef PCI_CONF1_ADDRESS
-struct pci_raw_ops pci_direct_conf1 = {
+static struct pci_raw_ops pci_direct_conf1 = {
.read = pci_conf1_read,
.write = pci_conf1_write,
};
@@ -258,7 +258,8 @@ void __init pci_direct_init(int type)
{
if (type == 0)
return;
- printk(KERN_INFO "PCI: Using configuration type %d\n", type);
+ printk(KERN_INFO "PCI: Using configuration type %d for base access\n",
+ type);
if (type == 1)
raw_pci_ops = &pci_direct_conf1;
else
@@ -275,8 +276,10 @@ int __init pci_direct_probe(void)
if (!region)
goto type2;
- if (pci_check_type1())
+ if (pci_check_type1()) {
+ raw_pci_ops = &pci_direct_conf1;
return 1;
+ }
release_resource(region);
type2:
@@ -290,7 +293,6 @@ int __init pci_direct_probe(void)
goto fail2;
if (pci_check_type2()) {
- printk(KERN_INFO "PCI: Using configuration type 2\n");
raw_pci_ops = &pci_direct_conf2;
return 2;
}
Index: linux-2.6/arch/x86/pci/init.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/init.c
+++ linux-2.6/arch/x86/pci/init.c
@@ -6,14 +6,13 @@
in the right sequence from here. */
static __init int pci_access_init(void)
{
- int type __maybe_unused = 0;
-
#ifdef CONFIG_PCI_DIRECT
+ int type = 0;
+
type = pci_direct_probe();
#endif
- pci_mmcfg_early_init(type);
- if (raw_pci_ops)
- return 0;
+ pci_mmcfg_early_init();
+
#ifdef CONFIG_PCI_BIOS
pci_pcbios_init();
#endif
@@ -26,7 +25,7 @@ static __init int pci_access_init(void)
#ifdef CONFIG_PCI_DIRECT
pci_direct_init(type);
#endif
- if (!raw_pci_ops)
+ if (!raw_pci_ops && !raw_pci_ext_ops)
printk(KERN_ERR
"PCI: Fatal: No config space access function found\n");
Index: linux-2.6/arch/x86/pci/mmconfig-shared.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/mmconfig-shared.c
+++ linux-2.6/arch/x86/pci/mmconfig-shared.c
@@ -28,7 +28,7 @@ static int __initdata pci_mmcfg_resource
static const char __init *pci_mmcfg_e7520(void)
{
u32 win;
- pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win);
+ raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0xce, 2, &win);
win = win & 0xf000;
if(win == 0x0000 || win == 0xf000)
@@ -53,7 +53,7 @@ static const char __init *pci_mmcfg_inte
pci_mmcfg_config_num = 1;
- pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar);
+ raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0x48, 4, &pciexbar);
/* Enable bit */
if (!(pciexbar & 1))
@@ -179,6 +179,9 @@ static int __init pci_mmcfg_check_hostbr
int i;
const char *name;
+ if (!raw_pci_ops)
+ return 0;
+
pci_mmcfg_config_num = 0;
pci_mmcfg_config = NULL;
name = NULL;
@@ -186,7 +189,7 @@ static int __init pci_mmcfg_check_hostbr
for (i = 0; !name && i < ARRAY_SIZE(pci_mmcfg_probes); i++) {
bus = pci_mmcfg_probes[i].bus;
devfn = pci_mmcfg_probes[i].devfn;
- pci_direct_conf1.read(0, bus, devfn, 0, 4, &l);
+ raw_pci_ops->read(0, bus, devfn, 0, 4, &l);
vendor = l & 0xffff;
device = (l >> 16) & 0xffff;
@@ -304,7 +307,7 @@ static int __init is_acpi_reserved(unsig
return mcfg_res.flags;
}
-static void __init pci_mmcfg_reject_broken(int type, int early)
+static void __init pci_mmcfg_reject_broken(int early)
{
typeof(pci_mmcfg_config[0]) *cfg;
int i;
@@ -342,8 +345,8 @@ static void __init pci_mmcfg_reject_brok
" reserved in ACPI motherboard resources\n",
cfg->address);
/* Don't try to do this check unless configuration
- type 1 is available. */
- if (type == 1 && e820_all_mapped(cfg->address,
+ type 1 is available. how about type 2 ?*/
+ if (raw_pci_ops && e820_all_mapped(cfg->address,
cfg->address + size - 1,
E820_RESERVED)) {
printk(KERN_NOTICE
@@ -368,7 +371,7 @@ reject:
static int __initdata known_bridge;
-void __init __pci_mmcfg_init(int type, int early)
+void __init __pci_mmcfg_init(int early)
{
/* MMCONFIG disabled */
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
@@ -382,7 +385,7 @@ void __init __pci_mmcfg_init(int type, i
if (known_bridge)
return;
- if (early && type == 1) {
+ if (early) {
if (pci_mmcfg_check_hostbridge())
known_bridge = 1;
#if 0
@@ -394,7 +397,7 @@ void __init __pci_mmcfg_init(int type, i
if (!known_bridge) {
acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
- pci_mmcfg_reject_broken(type, early);
+ pci_mmcfg_reject_broken(early);
}
if ((pci_mmcfg_config_num == 0) ||
@@ -415,19 +418,14 @@ void __init __pci_mmcfg_init(int type, i
}
}
-void __init pci_mmcfg_early_init(int type)
+void __init pci_mmcfg_early_init(void)
{
- __pci_mmcfg_init(type, 1);
+ __pci_mmcfg_init(1);
}
void __init pci_mmcfg_late_init(void)
{
- int type = 0;
-
- if (pci_probe & PCI_PROBE_CONF1)
- type = 1;
-
- __pci_mmcfg_init(type, 0);
+ __pci_mmcfg_init(0);
}
static int __init pci_mmcfg_late_insert_resources(void)
Index: linux-2.6/arch/x86/pci/pci.h
===================================================================
--- linux-2.6.orig/arch/x86/pci/pci.h
+++ linux-2.6/arch/x86/pci/pci.h
@@ -95,8 +95,6 @@ struct pci_raw_ops {
extern struct pci_raw_ops *raw_pci_ops;
extern struct pci_raw_ops *raw_pci_ext_ops;
-extern struct pci_raw_ops pci_direct_conf1;
-
extern int pci_direct_probe(void);
extern void pci_direct_init(int type);
extern void pci_pcbios_init(void);
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1052,10 +1052,10 @@ extern unsigned long pci_cardbus_mem_siz
extern int pcibios_add_platform_entries(struct pci_dev *dev);
#ifdef CONFIG_PCI_MMCONFIG
-extern void __init pci_mmcfg_early_init(int type);
+extern void __init pci_mmcfg_early_init(void);
extern void __init pci_mmcfg_late_init(void);
#else
-static inline void pci_mmcfg_early_init(int type) { }
+static inline void pci_mmcfg_early_init(void) { }
static inline void pci_mmcfg_late_init(void) { }
#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-02-29 7:56 ` [PATCH] x86 pci: remove checking type for mmconfig probe v2 Yinghai Lu
@ 2008-02-29 19:17 ` Ingo Molnar
2008-02-29 19:21 ` H. Peter Anvin
2008-03-01 6:02 ` Greg KH
1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2008-02-29 19:17 UTC (permalink / raw)
To: Yinghai Lu
Cc: Greg KH, Andrew Morton, Linux Kernel Mailing List,
Thomas Gleixner, H. Peter Anvin, Arjan van de Ven
* Yinghai Lu <Yinghai.Lu@Sun.COM> wrote:
> doesn't need to check if it is type1 or type2. we can use raw_pci_ops
> dirctly.
>
> also make pci_direct_conf1 static again.
>
> anyway is there system with type 2 and mmconf support?
i've picked it up into x86.git#testing so it gets test coverage, but it
would be nice to hear what Greg and the other PCI folks think about
this.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-02-29 19:17 ` Ingo Molnar
@ 2008-02-29 19:21 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2008-02-29 19:21 UTC (permalink / raw)
To: Ingo Molnar
Cc: Yinghai Lu, Greg KH, Andrew Morton, Linux Kernel Mailing List,
Thomas Gleixner, Arjan van de Ven
Ingo Molnar wrote:
> * Yinghai Lu <Yinghai.Lu@Sun.COM> wrote:
>
>> doesn't need to check if it is type1 or type2. we can use raw_pci_ops
>> dirctly.
>>
>> also make pci_direct_conf1 static again.
>>
>> anyway is there system with type 2 and mmconf support?
>
> i've picked it up into x86.git#testing so it gets test coverage, but it
> would be nice to hear what Greg and the other PCI folks think about
> this.
There *shouldn't* be any system with type 2 and mmconf, since type 1 was
made mandatory long before mmconf was created.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-02-29 7:56 ` [PATCH] x86 pci: remove checking type for mmconfig probe v2 Yinghai Lu
2008-02-29 19:17 ` Ingo Molnar
@ 2008-03-01 6:02 ` Greg KH
2008-03-01 8:36 ` Yinghai Lu
1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2008-03-01 6:02 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Ingo Molnar, Andrew Morton, Linux Kernel Mailing List
On Thu, Feb 28, 2008 at 11:56:50PM -0800, Yinghai Lu wrote:
>
> doesn't need to check if it is type1 or type2. we can use raw_pci_ops dirctly.
Why? is this because the ops are already set up? It would be nice to
add the "why this change is necessary and/or possible now" for the
changelog.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-03-01 6:02 ` Greg KH
@ 2008-03-01 8:36 ` Yinghai Lu
2008-03-04 6:23 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Yinghai Lu @ 2008-03-01 8:36 UTC (permalink / raw)
To: Greg KH; +Cc: Ingo Molnar, Andrew Morton, Linux Kernel Mailing List
On Fri, Feb 29, 2008 at 10:02 PM, Greg KH <greg@kroah.com> wrote:
> On Thu, Feb 28, 2008 at 11:56:50PM -0800, Yinghai Lu wrote:
> >
> > doesn't need to check if it is type1 or type2. we can use raw_pci_ops dirctly.
>
> Why? is this because the ops are already set up? It would be nice to
> add the "why this change is necessary and/or possible now" for the
> changelog.
yes.
raw_pci_ops got assigned when check direct_type1 and direct_type2.
and could used in hostbridge check to get MMCONF base.
make mmconfig probe clean
with checking if raw_pci_ops is assigned instead of passing type or
checking type.
YH
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 pci: remove checking type for mmconfig probe v2
2008-03-01 8:36 ` Yinghai Lu
@ 2008-03-04 6:23 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2008-03-04 6:23 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Ingo Molnar, Andrew Morton, Linux Kernel Mailing List
On Sat, Mar 01, 2008 at 12:36:50AM -0800, Yinghai Lu wrote:
> On Fri, Feb 29, 2008 at 10:02 PM, Greg KH <greg@kroah.com> wrote:
> > On Thu, Feb 28, 2008 at 11:56:50PM -0800, Yinghai Lu wrote:
> > >
> > > doesn't need to check if it is type1 or type2. we can use raw_pci_ops dirctly.
> >
> > Why? is this because the ops are already set up? It would be nice to
> > add the "why this change is necessary and/or possible now" for the
> > changelog.
> yes.
> raw_pci_ops got assigned when check direct_type1 and direct_type2.
> and could used in hostbridge check to get MMCONF base.
>
> make mmconfig probe clean
> with checking if raw_pci_ops is assigned instead of passing type or
> checking type.
Ah, ok, that makes sense, thanks.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-03-04 6:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-28 0:39 [PATCH] x86 pci: remove checking type for mmconfig probe Yinghai Lu
2008-02-29 7:56 ` [PATCH] x86 pci: remove checking type for mmconfig probe v2 Yinghai Lu
2008-02-29 19:17 ` Ingo Molnar
2008-02-29 19:21 ` H. Peter Anvin
2008-03-01 6:02 ` Greg KH
2008-03-01 8:36 ` Yinghai Lu
2008-03-04 6:23 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).