Hi Tiejun,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Firstly I think we'd better print the BAR0 and BAR1 on the probe function of<br>

your device driver because you have to make sure if a8000000-a803ffff is<br>
assigned to BAR0 and 0xa8040000-0xa807ffff for BAR1 as we expect.<br>
<br>
u32 value;<br>
pci_read_config_word(pdev, PCI_BASE_ADDRESS_0, &value); printk...<br>
pci_read_config_word(pdev, PCI_BASE_ADDRESS_1, &value); printk....<br>
<br></blockquote><div><br>Both the BAR's values are coming out to be zero. <br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
And you can print this pci_resource_start(pdev, bar), pci_resource_len(pdev,<br>
<div class="im">bar) from the function, __pci_request_region, on the file drivers/pci/pci.c.<br>
Please check this as well.<br></div></blockquote><div><br>I have done the changes in the __pci_request_region. But as you suggested earlier that one should call pci_request_regions() after pci_enable_device() in the driver code. My driver is failing at the pci_enable_device() only. Hence __pci_request_region() is not getting called. If, just for RND, I call pci_request_regions() before pci_enable_device(), it give me the following O/P.<br>
<br>__pci_request_region : Base Address = 0<br>__pci_request_region : Length Address = 1125903130362788<br>__pci_request_region : Base Address = 0<br>__pci_request_region : Length Address = 1125903130362788<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
And currently we have to debug this so on the function, __pci_assign_resource,<br>
from the file drivers/pci/setup-res.c, we can force skipping temporarily<br>
pci_bus_alloc_resource for bus 0001:01 since that will call pci_update_resource<br>
for bus 0001:01.<br>
<br>
static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,<br>
                                 int resno)<br>
{<br>
        struct resource *res = dev->resource + resno;<br>
        resource_size_t size, min, align;<br>
        int ret;<br>
<br>
        size = resource_size(res);<br>
        min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;<br>
        align = pci_resource_alignment(dev, res);<br>
-------<br>
        if (bus->number == 0x01) {<br>
                ret = -ENOMEM<br>
                return ret;<br>
        }<br>
-------<br>
<br>
I means we don't want to assign resource as the below line on the log.<br>
------<br>
<div class="im">pci 0001:01:00.0: BAR 8: assigned [mem 0xa8000000-0xa80fffff]<br>
<br>
</div>I expect the following output:<br>
------<br>
pci 0001:01:00.0: BAR 8: can't assign mem pref (size 0x100000)<br>
<br></blockquote><div> </div><div>This I have done successfully.<br><br>Dmesg<br>================================================================<br>Using MPC837x RDB/WLAN machine description<br>Initializing cgroup subsys cpuset<br>
Initializing cgroup subsys cpu<br>Linux version 2.6.35 (okapi@okapi) (gcc version 4.2.3 (Sourcery G++ Lite 4.2-171)) #35 Mon Sep 13 13:43:01 IST 2010<br>Found initrd at 0xcf46d000:0xcf7b15b7<br>Found legacy serial port 0 for /immr@e0000000/serial@4500<br>
  mem=e0004500, taddr=e0004500, irq=0, clk=400000002, speed=0<br>Found legacy serial port 1 for /immr@e0000000/serial@4600<br>  mem=e0004600, taddr=e0004600, irq=0, clk=400000002, speed=0<br>bootconsole [udbg0] enabled<br>
Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0<br>PCI host bridge /pci@e0008500 (primary) ranges:<br> MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 <br> MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch<br>
  IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000<br>No pci config register base in dev tree, using default<br>Found FSL PCI host bridge at 0x00000000e0009000. Firmware bus number: 0->255<br>PCI host bridge /pcie@e0009000  ranges:<br>
 MEM 0x00000000a8000000..0x00000000b7ffffff -> 0x00000000a8000000 <br>  IO 0x00000000b8000000..0x00000000b87fffff -> 0x0000000000000000<br>No pci config register base in dev tree, using default<br>Found FSL PCI host bridge at 0x00000000e000a000. Firmware bus number: 0->255<br>
PCI host bridge /pcie@e000a000  ranges:<br> MEM 0x00000000c8000000..0x00000000d7ffffff -> 0x00000000c8000000 <br>  IO 0x00000000d8000000..0x00000000d87fffff -> 0x0000000000000000<br>Top of RAM: 0x10000000, Total RAM: 0x10000000<br>
Memory hole size: 0MB<br>Zone PFN ranges:<br>  DMA      0x00000000 -> 0x00010000<br>  Normal   empty<br>  HighMem  empty<br>Movable zone start PFN for each node<br>early_node_map[1] active PFN ranges<br>    0: 0x00000000 -> 0x00010000<br>
On node 0 totalpages: 65536<br>free_area_init_node: node 0, pgdat c042d978, node_mem_map c0800000<br>  DMA zone: 512 pages used for memmap<br>  DMA zone: 0 pages reserved<br>  DMA zone: 65024 pages, LIFO batch:15<br>Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024<br>
Kernel command line: root=/dev/ram ramdisk_size=120000 rw ip=10.20.50.230:10.20.50.70:10.20.50.50:255.255.0.0:PowerQUICC:eth0:off console=ttyS0,115200 mtdparts=nand:4m(kernel),-(jffs2)<br>PID hash table entries: 1024 (order: 0, 4096 bytes)<br>
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)<br>Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)<br>High memory: 0k<br>Memory: 249920k/262144k available (4092k kernel code, 12224k reserved, 248k data, 2207k bss, 192k init)<br>
Kernel virtual memory layout:<br>  * 0xfffcf000..0xfffff000  : fixmap<br>  * 0xff800000..0xffc00000  : highmem PTEs<br>  * 0xfe6f7000..0xff800000  : early ioremap<br>  * 0xd1000000..0xfe6f7000  : vmalloc & ioremap<br>
Hierarchical RCU implementation.<br>    RCU-based detection of stalled CPUs is disabled.<br>    Verbose stalled-CPUs detection is disabled.<br>NR_IRQS:512<br>IPIC (128 IRQ sources) at d1000700<br>time_init: decrementer frequency = 100.000000 MHz<br>
time_init: processor frequency   = 800.000004 MHz<br>clocksource: timebase mult[2800000] shift[22] registered<br>clockevent: decrementer mult[19999999] shift[32] cpu[0]<br>Console: colour dummy device 80x25<br>pid_max: default: 32768 minimum: 301<br>
Security Framework initialized<br>SELinux:  Disabled at boot.<br>Mount-cache hash table entries: 512<br>Initializing cgroup subsys ns<br>Initializing cgroup subsys cpuacct<br>Initializing cgroup subsys devices<br>NET: Registered protocol family 16<br>
irq: irq 38 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 38<br>__irq_set_trigger: setting type, irq = 38, flags = 8<br>ipic_set_irq_type function, with virq = 38, flow = 8<br>irq: irq 74 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 74<br>
__irq_set_trigger: setting type, irq = 74, flags = 8<br>ipic_set_irq_type function, with virq = 74, flow = 8<br>irq: irq 75 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 75<br>__irq_set_trigger: setting type, irq = 75, flags = 8<br>
ipic_set_irq_type function, with virq = 75, flow = 8<br>PCI: Probing PCI hardware<br>PCI: Scanning PHB /pci@e0008500<br>PCI: PHB IO resource    = 0000000000000000-00000000000fffff [100]<br>PCI: PHB MEM resource 0 = 0000000090000000-000000009fffffff [200]<br>
PCI: PHB MEM resource 1 = 0000000080000000-000000008fffffff [2200]<br>PCI: PHB MEM offset     = 0000000000000000<br>PCI: PHB IO  offset     = 00000000<br>    probe mode: 0<br>pci_bus 0000:00: scanning bus<br>pci : vendor id = 0x1957<br>
pci 0000:00:00.0: found [1957:00c6] class 000b20 header type 00<br>pci 0000:00:00.0: reg 10: [mem 0x00000000-0x000fffff]<br>pci 0000:00:00.0: reg 18: [mem 0x00000000-0x0fffffff 64bit pref]<br>pci 0000:00:00.0: calling fixup_hide_host_resource_fsl+0x0/0x58<br>
pci 0000:00:00.0: calling pcibios_fixup_resources+0x0/0x180<br>pci 0000:00:00.0: calling quirk_fsl_pcie_header+0x0/0x48<br>pci 0000:00:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>pci 0000:00:00.0: supports D1 D2<br>
pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot<br>pci 0000:00:00.0: PME# disabled<br>pci_bus 0000:00: fixups for bus<br>PCI: Fixup bus devices 0 (PHB)<br>PCI: Try to map irq for 0000:00:00.0...<br>pci_bus 0000:00: bus scan returning with max=00<br>
PCI: Scanning PHB /pcie@e0009000<br>PCI: PHB IO resource    = 00000000ff7fe000-00000000ffffdfff [100]<br>PCI: PHB MEM resource 0 = 00000000a8000000-00000000b7ffffff [200]<br>PCI: PHB MEM offset     = 0000000000000000<br>PCI: PHB IO  offset     = ff7fe000<br>
    probe mode: 0<br>pci_bus 0001:01: scanning bus<br>pci : vendor id = 0x1957<br>pci 0001:01:00.0: found [1957:00c6] class 000b20 header type 01<br>pci 0001:01:00.0: ignoring class b20 (doesn't match header type 01)<br>
pci 0001:01:00.0: calling fixup_hide_host_resource_fsl+0x0/0x58<br>pci 0001:01:00.0: calling pcibios_fixup_resources+0x0/0x180<br>pci 0001:01:00.0: calling quirk_fsl_pcie_header+0x0/0x48<br>pci 0001:01:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>
pci 0001:01:00.0: supports D1 D2<br>pci 0001:01:00.0: PME# supported from D0 D1 D2 D3hot<br>pci 0001:01:00.0: PME# disabled<br>pci_bus 0001:01: fixups for bus<br>PCI: Fixup bus devices 1 (PHB)<br>PCI: Try to map irq for 0001:01:00.0...<br>
pci 0001:01:00.0: scanning [bus 01-ff] behind bridge, pass 0<br>pci 0001:01:00.0: bus configuration invalid, reconfiguring<br>pci 0001:01:00.0: scanning [bus 00-00] behind bridge, pass 1<br>pci_bus 0001:02: scanning bus<br>
pci : vendor id = 0x1204<br>pci 0001:02:00.0: trying to set all zeros in BARs<br>pci 0001:02:00.0: found [1204:e250] class 000000 header type 00<br>pci 0001:02:00.0: reg 10: [mem 0x00000000-0x0003ffff]<br>pci 0001:02:00.0: reg 14: [mem 0x00000000-0x0003ffff]<br>
pci 0001:02:00.0: calling pcibios_fixup_resources+0x0/0x180<br>PCI:0001:02:00.0 Resource 0 0000000000000000-000000000003ffff [40200] is unassigned<br>PCI:0001:02:00.0 Resource 1 0000000000000000-000000000003ffff [40200] is unassigned<br>
pci 0001:02:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>pci_bus 0001:02: fixups for bus<br>pci 0001:01:00.0: PCI bridge to [bus 02-ff]<br>pci 0001:01:00.0:   bridge window [io  0x0000-0x0000] (disabled)<br>pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff] (disabled)<br>
pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff pref] (disabled)<br>PCI: Fixup bus devices 2 (0001:01:00.0)<br>PCI: Try to map irq for 0001:02:00.0...<br> Got one, spec 2 cells (0x00000001 0x00000008...) on /immr@e0000000/interrupt-controller@700<br>
irq: irq 1 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 16<br>__irq_set_trigger: setting type, irq = 16, flags = 8<br>ipic_set_irq_type function, with virq = 16, flow = 8<br> Mapped to linux irq 16<br>
pci_bus 0001:02: bus scan returning with max=02<br>pci_bus 0001:01: bus scan returning with max=02<br>PCI: Scanning PHB /pcie@e000a000<br>PCI: PHB IO resource    = 00000000feffc000-00000000ff7fbfff [100]<br>PCI: PHB MEM resource 0 = 00000000c8000000-00000000d7ffffff [200]<br>
PCI: PHB MEM offset     = 0000000000000000<br>PCI: PHB IO  offset     = feffc000<br>    probe mode: 0<br>pci_bus 0002:03: scanning bus<br>pci_bus 0002:03: fixups for bus<br>PCI: Fixup bus devices 3 (PHB)<br>pci_bus 0002:03: bus scan returning with max=03<br>
PCI->OF bus map:<br>0 -> 0<br>1 -> 0<br>3 -> 0<br>PCI: Allocating bus resources for 0000:00...<br>PCI: PHB (bus 0) bridge rsrc 0: 0000000000000000-00000000000fffff [0x100], parent c0405660 (PCI IO)<br>PCI: PHB (bus 0) bridge rsrc 1: 0000000090000000-000000009fffffff [0x200], parent c0405644 (PCI mem)<br>
PCI: PHB (bus 0) bridge rsrc 2: 0000000080000000-000000008fffffff [0x2200], parent c0405644 (PCI mem)<br>PCI: Allocating bus resources for 0001:01...<br>PCI: PHB (bus 1) bridge rsrc 0: 00000000ff7fe000-00000000ffffdfff [0x100], parent c0405660 (PCI IO)<br>
PCI: PHB (bus 1) bridge rsrc 1: 00000000a8000000-00000000b7ffffff [0x200], parent c0405644 (PCI mem)<br>PCI: Allocating bus resources for 0001:02...<br>PCI: Allocating bus resources for 0002:03...<br>PCI: PHB (bus 3) bridge rsrc 0: 00000000feffc000-00000000ff7fbfff [0x100], parent c0405660 (PCI IO)<br>
PCI: PHB (bus 3) bridge rsrc 1: 00000000c8000000-00000000d7ffffff [0x200], parent c0405644 (PCI mem)<br>Reserving legacy ranges for domain 0000<br>Candidate legacy IO: [io  0x0000-0x0fff]<br>hose mem offset: 0000000000000000<br>
hose mem res: [mem 0x90000000-0x9fffffff]<br>hose mem res: [mem 0x80000000-0x8fffffff pref]<br>Reserving legacy ranges for domain 0001<br>Candidate legacy IO: [io  0xff7fe000-0xff7fefff]<br>hose mem offset: 0000000000000000<br>
hose mem res: [mem 0xa8000000-0xb7ffffff]<br>Reserving legacy ranges for domain 0002<br>Candidate legacy IO: [io  0xfeffc000-0xfeffcfff]<br>hose mem offset: 0000000000000000<br>hose mem res: [mem 0xc8000000-0xd7ffffff]<br>
PCI: Assigning unassigned resources...<br>pci 0001:01:00.0: BAR 8: can't assign mem (size 0x100000)<br>pci 0001:01:00.0: PCI bridge to [bus 02-02]<br>pci 0001:01:00.0: __pci_setup_bridge: Disabling prefetch window.<br>
pci 0001:01:00.0: __pci_setup_bridge: Prefetch window disabled successfully.<br>pci 0001:01:00.0:   bridge window [io  disabled]<br>pci 0001:01:00.0:   bridge window [mem disabled]<br>pci 0001:01:00.0:   bridge window [mem pref disabled]<br>
pci_bus 0000:00: resource 0 [io  0x0000-0xfffff]<br>pci_bus 0000:00: resource 1 [mem 0x90000000-0x9fffffff]<br>pci_bus 0000:00: resource 2 [mem 0x80000000-0x8fffffff pref]<br>pci_bus 0001:01: resource 0 [io  0xff7fe000-0xffffdfff]<br>
pci_bus 0001:01: resource 1 [mem 0xa8000000-0xb7ffffff]<br>pci_bus 0002:03: resource 0 [io  0xfeffc000-0xff7fbfff]<br>pci_bus 0002:03: resource 1 [mem 0xc8000000-0xd7ffffff]<br>Registering qe_ic with sysfs...<br>Registering ipic with sysfs...<br>
bio: create slab <bio-0> at 0<br>vgaarb: loaded<br>SCSI subsystem initialized<br>Switching to clocksource timebase<br>NET: Registered protocol family 2<br>IP route cache hash table entries: 2048 (order: 1, 8192 bytes)<br>
TCP established hash table entries: 8192 (order: 4, 65536 bytes)<br>TCP bind hash table entries: 8192 (order: 3, 32768 bytes)<br>TCP: Hash tables configured (established 8192 bind 8192)<br>TCP reno registered<br>UDP hash table entries: 256 (order: 0, 4096 bytes)<br>
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)<br>NET: Registered protocol family 1<br>pci 0000:00:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>pci 0000:00:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>pci 0001:01:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>
pci 0001:01:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>pci 0001:02:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>pci 0001:02:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>PCI: CLS 32 bytes, default 32<br>Trying to unpack rootfs image as initramfs...<br>
rootfs image is not initramfs (no cpio magic); looks like an initrd<br>Freeing initrd memory: 3345k freed<br>irq: irq 9 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 17<br>__irq_set_trigger: setting type, irq = 17, flags = 8<br>
ipic_set_irq_type function, with virq = 17, flow = 8<br>irq: irq 10 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 18<br>__irq_set_trigger: setting type, irq = 18, flags = 8<br>ipic_set_irq_type function, with virq = 18, flow = 8<br>
irq: irq 80 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 80<br>__irq_set_trigger: setting type, irq = 80, flags = 8<br>ipic_set_irq_type function, with virq = 80, flow = 8<br>audit: initializing netlink socket (disabled)<br>
type=2000 audit(0.220:1): initialized<br>JFFS2 version 2.2. (NAND) Â© 2001-2006 Red Hat, Inc.<br>SGI XFS with security attributes, large block/inode numbers, no debug enabled<br>msgmni has been set to 494<br>alg: No test for cipher_null (cipher_null-generic)<br>
alg: No test for ecb(cipher_null) (ecb-cipher_null)<br>alg: No test for digest_null (digest_null-generic)<br>alg: No test for compress_null (compress_null-generic)<br>alg: No test for stdrng (krng)<br>Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)<br>
io scheduler noop registered<br>io scheduler deadline registered<br>io scheduler cfq registered (default)<br>Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled<br>serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 17) is a 16550A<br>
console [ttyS0] enabled, bootconsole disabled<br>serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 18) is a 16550A<br>brd: module loaded<br>of_mpc8xxx_spi_probe function called.<br>irq: irq 16 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 19<br>
__irq_set_trigger: setting type, irq = 19, flags = 8<br>ipic_set_irq_type function, with virq = 19, flow = 8<br>mpc8xxx_spi_probe function called.<br>mpc8xxx_spi e0007000.spi: at 0xd1078000 (irq = 19), CPU mode<br>irq: irq 32 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 32<br>
__irq_set_trigger: setting type, irq = 32, flags = 8<br>ipic_set_irq_type function, with virq = 32, flow = 8<br>irq: irq 33 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 33<br>__irq_set_trigger: setting type, irq = 33, flags = 8<br>
ipic_set_irq_type function, with virq = 33, flow = 8<br>irq: irq 34 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 34<br>__irq_set_trigger: setting type, irq = 34, flags = 8<br>ipic_set_irq_type function, with virq = 34, flow = 8<br>
eth0: Gianfar Ethernet Controller Version 1.2, 04:00:00:00:00:0a<br>eth0: Running with NAPI enabled<br>eth0: RX BD ring size for Q[0]: 256<br>eth0: TX BD ring size for Q[0]: 256<br>irq: irq 35 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 35<br>
__irq_set_trigger: setting type, irq = 35, flags = 8<br>ipic_set_irq_type function, with virq = 35, flow = 8<br>irq: irq 36 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 36<br>__irq_set_trigger: setting type, irq = 36, flags = 8<br>
ipic_set_irq_type function, with virq = 36, flow = 8<br>irq: irq 37 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 37<br>__irq_set_trigger: setting type, irq = 37, flags = 8<br>ipic_set_irq_type function, with virq = 37, flow = 8<br>
eth1: Gianfar Ethernet Controller Version 1.2, 00:00:00:00:00:00<br>eth1: Running with NAPI enabled<br>eth1: RX BD ring size for Q[0]: 256<br>eth1: TX BD ring size for Q[0]: 256<br>ucc_geth: QE UCC Gigabit Ethernet Controller<br>
Freescale PowerQUICC MII Bus: probed<br>irq: irq 17 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 20<br>__irq_set_trigger: setting type, irq = 20, flags = 8<br>ipic_set_irq_type function, with virq = 20, flow = 8<br>
Freescale PowerQUICC MII Bus: probed<br>mice: PS/2 mouse device common for all mice<br>Skipping unavailable LED gpio -19 (pwr)<br>Skipping unavailable LED gpio -19 (hdd)<br>TCP cubic registered<br>NET: Registered protocol family 17<br>
registered taskstats version 1<br>drivers/rtc/hctosys.c: unable to open rtc device (rtc0)<br>RAMDISK: gzip image found at block 0<br>VFS: Mounted root (ext2 filesystem) on device 1:0.<br>Freeing unused kernel memory: 192k init<br>
PHY: mdio@e0024520:02 - Link is Up - 10/Half<br>================================================================<br></div></div><br>Regards,<br>Ravi<br>