Skip to contentSkip to conversation

EDD build error

PATCH In review Randy Dunlap 5 participants 18 messages Jun 26, 2007 – Jun 28, 2007 1 message not in the archive PCI

lore
Share & tools
lore
#0 lore raw

Hi,

CONFIG_EDD does not depend on PCI, but edd.c uses pci_* interface functions, resulting in:

CC [M] drivers/firmware/edd.o
drivers/firmware/edd.c: In function 'edd_get_pci_dev':
drivers/firmware/edd.c:672: warning: implicit declaration of function 'pci_get_bus_and_slot' drivers/firmware/edd.c:673: warning: return makes pointer from integer without a cast
...
ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined!
make[1]: *** [__modpost] Error 1

Should EDD depend on PCI or should some parts of edd.c be stubbed?

(This is in 2.6.22-rc4-mm2 FWIW.)

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#1 lore raw
Quoted 4 lines · Randy Dunlap

ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined! make[1]: *** [__modpost] Error 1

Should EDD depend on PCI or should some parts of edd.c be stubbed?

I'd suggest to simply stub it, as attached (untested, as my crap-Awarded BIOS only has 2.1). It may not be nice to pull in the PCI defs and then return NULL regardless, but should be safe in your case. Does that work?

Torsten

firmware/edd.c renamed from firmware/edd.c.orig +4 -0
@@ -669,10 +669,14 @@
 	struct edd_info *info = edd_dev_get_info(edev);
 
 	if (edd_dev_is_type(edev, "PCI")) {
+#ifdef CONFIG_PCI
 		return pci_find_slot(info->params.interface_path.pci.bus,
 				     PCI_DEVFN(info->params.interface_path.pci.slot,
 					       info->params.interface_path.pci.
 					       function));
+#else
+		printk(KERN_WARNING "EDD referenced a PCI device for drive 0x%02x, but PCI is not configured\n", edev->index);
+#endif
 	}
 	return NULL;
 }
#2 lore raw
Quoted 5 lines · On Wed, 27 Jun 2007 00:16:44 +0200 Torsten Duwe wrote:
Quoted 3 lines · Randy Dunlap

ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined! make[1]: *** [__modpost] Error 1

Quoted 8 lines
Quoted 1 line

Should EDD depend on PCI or should some parts of edd.c be stubbed?

I'd suggest to simply stub it, as attached (untested, as my crap-Awarded BIOS only has 2.1). It may not be nice to pull in the PCI defs and then return NULL regardless, but should be safe in your case. Does that work?

From original email:

(This is in 2.6.22-rc4-mm2 FWIW.)

so quilt+patch says:

Applying patch EDD.diff
patching file drivers/firmware/edd.c
Hunk #1 FAILED at 669.
1 out of 1 hunk FAILED -- rejects in file drivers/firmware/edd.c Patch EDD.diff does not apply (enforce with -f)

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#3 lore raw
Quoted 3 lines · Randy Dunlap

From original email:
(This is in 2.6.22-rc4-mm2 FWIW.)

Sorry. This one should be better.
I've moved the edd_info, to avoid the -Wunused.

Torsten

drivers/firmware/edd.c renamed from drivers/firmware/edd.c.orig +5 -1
@@ -666,13 +666,17 @@ edd_dev_is_type(struct edd_device *edev,
 static struct pci_dev *
 edd_get_pci_dev(struct edd_device *edev)
 {
-	struct edd_info *info = edd_dev_get_info(edev);
 
 	if (edd_dev_is_type(edev, "PCI")) {
+#ifdef CONFIG_PCI
+		struct edd_info *info = edd_dev_get_info(edev);
 		return pci_get_bus_and_slot(info->params.interface_path.pci.bus,
 				     PCI_DEVFN(info->params.interface_path.pci.slot,
 					       info->params.interface_path.pci.
 					       function));
+#else
+		printk(KERN_WARNING "EDD referenced a PCI device for drive 0x%02x, but PCI is not configured\n", edev->index);
+#endif
 	}
 	return NULL;
 }
#4 lore raw
Quoted 7 lines · On Wed, 27 Jun 2007 00:44:02 +0200 Torsten Duwe wrote:
Quoted 3 lines · Randy Dunlap

From original email:
(This is in 2.6.22-rc4-mm2 FWIW.)

Sorry. This one should be better.
I've moved the edd_info, to avoid the -Wunused.

Yes, that one works fine. Thanks.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 5 lines · Matt Domsch
Quoted 1 line · Randy Dunlap

ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined!

It should be stubbed, in include/linux/pci.h where all the other PCI functions are stubbed for the !CONFIG_PCI case.

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

#7 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 10 lines · On Wed, 27 Jun 2007 05:30:48 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 5 lines · Matt Domsch
Quoted 1 line · Randy Dunlap

ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined!

It should be stubbed, in include/linux/pci.h where all the other PCI functions are stubbed for the !CONFIG_PCI case.

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

But requires you have a bus pointer to hand which is often not the case. Do we need pci_get_domain_bus_and_slot() ?

Alan

#8 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 8 lines · Alan Cox
Quoted 3 lines · On Wed, 27 Jun 2007 05:30:48 -0600 Matthew Wilcox <[email protected]> wrote:

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

But requires you have a bus pointer to hand which is often not the case. Do we need pci_get_domain_bus_and_slot() ?

We have pci_find_bus(domain, busnr) which will get you the bus pointer.

#9 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 11 lines · On Wed, 27 Jun 2007 08:03:05 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 8 lines · Alan Cox
Quoted 3 lines · On Wed, 27 Jun 2007 05:30:48 -0600 Matthew Wilcox <[email protected]> wrote:

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

But requires you have a bus pointer to hand which is often not the case. Do we need pci_get_domain_bus_and_slot() ?

We have pci_find_bus(domain, busnr) which will get you the bus pointer.

So the answer is "yes" we should then, and move from pci_get_bus_and_slot to pci_get_bus_domain_and_slot() [or just add an argument]. The point of the functions is to be easy to use, so it should be handled internally.

Alan

#10 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 10 lines · Alan Cox
Quoted 7 lines · On Wed, 27 Jun 2007 08:03:05 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 6 lines · Alan Cox
Quoted 3 lines · On Wed, 27 Jun 2007 05:30:48 -0600 Matthew Wilcox <[email protected]> wrote:

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

But requires you have a bus pointer to hand which is often not the case. Do we need pci_get_domain_bus_and_slot() ?

We have pci_find_bus(domain, busnr) which will get you the bus pointer.

So the answer is "yes" we should then, and move from pci_get_bus_and_slot to pci_get_bus_domain_and_slot() [or just add an argument]. The point of the functions is to be easy to use, so it should be handled internally.

My point was that code which doesn't currently keep the bus pointer to hand should keep the bus pointer to hand instead of the bus number. That's easier to use, particularly if you want to actually do any pci config accesses.

#11 lore raw

Re: pci.h stubs (was: EDD build error)

Quoted 8 lines
Quoted 3 lines

So the answer is "yes" we should then, and move from pci_get_bus_and_slot to pci_get_bus_domain_and_slot() [or just add an argument]. The point of the functions is to be easy to use, so it should be handled internally.

My point was that code which doesn't currently keep the bus pointer to hand should keep the bus pointer to hand instead of the bus number. That's easier to use, particularly if you want to actually do any pci config accesses.

If you've got the bus pointer yes. If you don't then teaching pci_get_bus_and_slot() to handle it makes sense.

Another problem here - which bus has the legacy decode mappings ? That will matter for ATA which also uses pci_get_bus_and_slot...

#12 lore raw

Re: pci.h stubs

In reply to Alan Cox
Quoted 6 lines · Alan Cox
Quoted 3 lines · On Wed, 27 Jun 2007 05:30:48 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 2 lines · Matt Domsch
Quoted 1 line · Randy Dunlap

ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined!

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

It should be stubbed, in include/linux/pci.h where all the other PCI functions are stubbed for the !CONFIG_PCI case.

pci_get_bus_and_slot() shouldn't be used because it fails to work on systems with multiple domains. pci_get_slot() avoids this problem (and is much faster too).

But requires you have a bus pointer to hand which is often not the case. Do we need pci_get_domain_bus_and_slot() ?

Note that EDD has no way of referencing anything but the zero domain (which is presumably the one which is addressed by I/O ports CF8/CFC on the BSP.) So in this particular case I would say pci_get_bus_and_slot() is fine.

-hpa

#13 lore raw

Re: pci.h stubs

Quoted 4 lines · H. Peter Anvin

Note that EDD has no way of referencing anything but the zero domain (which is presumably the one which is addressed by I/O ports CF8/CFC on the BSP.) So in this particular case I would say pci_get_bus_and_slot() is fine.

Except that you're not guaranteed to get the bus that's in domain zero.

#14 lore raw

Re: pci.h stubs

Quoted 7 lines · On Wed, 27 Jun 2007 10:54:30 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 4 lines · H. Peter Anvin

Note that EDD has no way of referencing anything but the zero domain (which is presumably the one which is addressed by I/O ports CF8/CFC on the BSP.) So in this particular case I would say pci_get_bus_and_slot() is fine.

Except that you're not guaranteed to get the bus that's in domain zero.

Which is trivial to fix

#15 lore raw

Re: pci.h stubs

Quoted 8 lines · Alan Cox
Quoted 3 lines · On Wed, 27 Jun 2007 10:54:30 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 1 line · H. Peter Anvin

Note that EDD has no way of referencing anything but the zero domain (which is presumably the one which is addressed by I/O ports CF8/CFC on the BSP.) So in this particular case I would say pci_get_bus_and_slot() is fine.

Except that you're not guaranteed to get the bus that's in domain zero.

Which is trivial to fix

Yes, and that's probably the only sane definition of that API.

-hpa

#16 lore raw

PATCH 1/1 PCI: limit pci_get_bus_and_slot to domain 0

Quoted 9 lines · On Wed, 27 Jun 2007 14:34:03 -0400 H. Peter Anvin wrote:
Quoted 8 lines · Alan Cox
Quoted 5 lines · On Wed, 27 Jun 2007 10:54:30 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 4 lines · H. Peter Anvin

Note that EDD has no way of referencing anything but the zero domain (which is presumably the one which is addressed by I/O ports CF8/CFC on the BSP.) So in this particular case I would say pci_get_bus_and_slot() is fine.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Except that you're not guaranteed to get the bus that's in domain zero.

Which is trivial to fix

Yes, and that's probably the only sane definition of that API.

Is this what you mean?
---

From: Randy Dunlap <[email protected]>

Limit pci_get_bus_and_slot() to domain (segment) 0 since domain is not specified in the function call and defaulting to domain 0 is the only reasonable thing to do (rather than returning a device from some other unknown domain).

---
 drivers/pci/search.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/search.c +5 -2
@@ -173,12 +173,14 @@ struct pci_dev * pci_get_slot(struct pci
 }
 
 /**
- * pci_get_bus_and_slot - locate PCI device from a given PCI slot
+ * pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot
  * @bus: number of PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI
  * device resides and the logical device number within that slot
  * in case of multi-function devices.
  *
+ * Note: the bus/slot search is limited to PCI domain (segment) 0.
+ *
  * Given a PCI bus and slot/function number, the desired PCI device
  * is located in system global list of PCI devices.  If the device
  * is found, a pointer to its data structure is returned.  If no
@@ -191,7 +193,8 @@ struct pci_dev * pci_get_bus_and_slot(un
 	struct pci_dev *dev = NULL;
 
 	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-		if (dev->bus->number == bus && dev->devfn == devfn)
+		if (pci_domain_nr(dev->bus) == 0 &&
+		   (dev->bus->number == bus && dev->devfn == devfn))
 			return dev;
 	}
 	return NULL;
#18 lore raw

PATCH 1/1 pci.h stubs (for EDD build error)

In reply to a message not in the archive
Quoted 22 lines · On Tue, 26 Jun 2007 21:45:05 -0500 Matt Domsch wrote:
Quoted 14 lines · Randy Dunlap

Hi,

CONFIG_EDD does not depend on PCI, but edd.c uses pci_* interface functions, resulting in:

CC [M] drivers/firmware/edd.o
drivers/firmware/edd.c: In function 'edd_get_pci_dev':
drivers/firmware/edd.c:672: warning: implicit declaration of function 'pci_get_bus_and_slot' drivers/firmware/edd.c:673: warning: return makes pointer from integer without a cast
...
ERROR: "pci_get_bus_and_slot" [drivers/firmware/edd.ko] undefined!
make[1]: *** [__modpost] Error 1

Quoted 1 line

Should EDD depend on PCI or should some parts of edd.c be stubbed?

Good catch, thanks.

It should be stubbed, in include/linux/pci.h where all the other PCI functions are stubbed for the !CONFIG_PCI case.

Quoted 8 lines

There are several functions in include/linux/pci.h that have been added in the CONFIG_PCI case, but not stubbed in !CONFIG_PCI. pci_get_bus_and_slot() is just one of those. That list appears to include:

struct pci_bus *pci_find_next_bus(const struct pci_bus *from); struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn);

Did those -- patch is below.

Get clean build of drivers/firmware/edd.c with this patch even when CONFIG_PCI=n.

Quoted 4 lines

Perhaps arguably, functions that take a struct pci_dev * as an argument need not be stubbed, as they shouldn't be called with a null pointer argument in the first place. These include:

Quoted 8 lines

int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); static inline int pci_is_managed(struct pci_dev *pdev)

I'm out of the office this week and next, but will add to my (growing) list of cleanups to do when I'm back and more online, unless you or someone wants to get to it first. :-)

From: Randy Dunlap <[email protected]>

Provide stubs for more PCI bus/slot functions when CONFIG_PCI=n.

---
 include/linux/pci.h |   11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/pci.h +11 -0
@@ -748,6 +748,17 @@ static inline void pci_release_regions(s
 static inline void pci_block_user_cfg_access(struct pci_dev *dev) { }
 static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { }
 
+static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
+{ return NULL; }
+
+static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
+						unsigned int devfn)
+{ return NULL; }
+
+static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
+						unsigned int devfn)
+{ return NULL; }
+
 #endif /* CONFIG_PCI */
 
 /* Include architecture-dependent settings and functions */