请教大侠关于pci probe的问题
小弟在probe里面第一行先调用pci_enable_device,结果总是报PCI: Device 0000:05:00.0 not available because of resource collisions
probe of 0000:05:00.0 failed with error -22
第一行是pcibios_enable_resources 打印的,第二行是驱动里面自己打印的。
分析了一下pcibios_enable_resources的代码发现resource的start地址为0. 测试机器是intel的,内核版本2.6.9,而相同的驱动代码、相同的内核版本在另一台AMD的机器上是可以运行的,另外如果把intel的机器装成2.6.18也是没问题的。请问resource结构的start成员变量是什么赋值的? 多谢!
static inline int
pcibios_enable_resources (struct pci_dev *dev, int mask)
{
u16 cmd, old_cmd;
int idx;
struct resource *r;
unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
if (!dev)
return -EINVAL;
pci_read_config_word(dev, PCI_COMMAND, &cmd);
old_cmd = cmd;
for (idx=0; idx<PCI_NUM_RESOURCES; idx++) {
/* Only set up the desired resources.*/
if (!(mask & (1 << idx)))
continue;
r = &dev->resource;
if (!(r->flags & type_mask))
continue;
if ((idx == PCI_ROM_RESOURCE) &&
(!(r->flags & IORESOURCE_ROM_ENABLE)))
continue;
if (!r->start && r->end) {
printk(KERN_ERR
"PCI: Device %s not available because of resource collisions\n",
pci_name(dev));
return -EINVAL;
}
if (r->flags & IORESOURCE_IO)
cmd |= PCI_COMMAND_IO;
if (r->flags & IORESOURCE_MEM)
cmd |= PCI_COMMAND_MEMORY;
}
if (cmd != old_cmd) {
printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
return 0;
回复 #1 superfisha 的帖子
跟踪发现系统启动时打印Nov 21 14:45:05 turbo kernel: PCI: Cannot allocate resource region 0 of device 0000:03:00.0
Nov 21 14:45:05 turbo kernel: PCI: Cannot allocate resource region 2 of device 0000:03:00.0
Nov 21 14:45:05 turbo kernel: PCI: Cannot allocate resource region 4 of device 0000:03:00.0
Nov 21 14:45:05 turbo kernel: PCI-DMA: Disabling IOMMU.
Nov 21 14:45:05 turbo kernel: PCI: Failed to allocate mem resource #0:0@0 for 0000:03:00.0
Nov 21 14:45:05 turbo kernel: PCI: Failed to allocate mem resource #2:0@0 for 0000:03:00.0
Nov 21 14:45:05 turbo kernel: PCI: Failed to allocate mem resource #4:0@0 for 0000:03:00.0
lspci -v输出:
# lspci -v
pcilib: Resource 0 in /sys/bus/pci/devices/0000:03:00.0/resource has a 64-bit address, ignoring
pcilib: Resource 2 in /sys/bus/pci/devices/0000:03:00.0/resource has a 64-bit address, ignoring
pcilib: Resource 4 in /sys/bus/pci/devices/0000:03:00.0/resource has a 64-bit address, ignoring
03:00.0 Class aa00: Unknown device abcd (rev 00)
Flags: bus master, fast devsel, latency 0, IRQ 132
Memory at <ignored> (64-bit, prefetchable)
Memory at <ignored> (64-bit, prefetchable)
Memory at <ignored> (64-bit, prefetchable)
Capabilities: Power Management version 3
Capabilities: Message Signalled Interrupts: 64bit+ Queue=0/0 Enable-
Capabilities: Express Endpoint IRQ 0
Capabilities: Advanced Error Reporting
页:
[1]