Subject: Re: pci_request_regions() failure

From: "tiejun.chen" <[email-masked]>
Date: Fri, 10 Sep 2010 13:23:21 +0800

Ravi Gupta wrote:
> Hi Tiejun,
> 
> Thanks for the reply.
> 
> Omm.
>> Often we always disable this pref windows so please disable this window.
>> Try use
>> the following ways to clear PCI_PREF_MEMORY_BASE and PCI_PREF_MEMORY_LIMIT.
>> ------
>>        pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0);
>>        pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
>>
>>
> I have a little confusion about what you said. You said I should disable
> prefetched window corresponds to PCI Bridge to [bus 02-ff], the dmesgs shows
> that it is already disabled.
> 
> pci 0001:01:00.0: PCI bridge to [bus 02-ff]
> pci 0001:01:00.0:   bridge window [io  0x0000-0x0000] (disabled)
> pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff] (disabled)
> *pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
> (disabled)*

Sorry I miss this line.

> 
> Is it something that I am not getting right or you have miss read something?
> If it is problem with me, then what should be the O/P in case when I disable
> the prefetch window (by issuing pci_write_config_word(dev,
> PCI_PREF_MEMORY_BASE, 0); and pci_write_config_word(dev,
> PCI_PREF_MEMORY_LIMIT, 0); function calls)? And also, I will be really
> thankful to you if you also tell me the function in which I should place
> there function calls as I am new to linux device driver programming.

Firstly I think we'd better print the BAR0 and BAR1 on the probe function of
your device driver because you have to make sure if a8000000-a803ffff is
assigned to BAR0 and 0xa8040000-0xa807ffff for BAR1 as we expect.

u32 value;
pci_read_config_word(pdev, PCI_BASE_ADDRESS_0, &value); printk...
pci_read_config_word(pdev, PCI_BASE_ADDRESS_1, &value); printk....

And you can print this pci_resource_start(pdev, bar), pci_resource_len(pdev,
bar) from the function, __pci_request_region, on the file drivers/pci/pci.c.
Please check this as well.

And currently we have to debug this so on the function, __pci_assign_resource,
from the file drivers/pci/setup-res.c, we can force skipping temporarily
pci_bus_alloc_resource for bus 0001:01 since that will call pci_update_resource
for bus 0001:01.

static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
                                 int resno)
{
        struct resource *res = dev->resource + resno;
        resource_size_t size, min, align;
        int ret;

        size = resource_size(res);
        min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;
        align = pci_resource_alignment(dev, res);
-------
	if (bus->number == 0x01) {
		ret = -ENOMEM
		return ret;
	}
-------

I means we don't want to assign resource as the below line on the log.
------
pci 0001:01:00.0: BAR 8: assigned [mem 0xa8000000-0xa80fffff]

I expect the following output:
------
pci 0001:01:00.0: BAR 8: can't assign mem pref (size 0x100000)

Best Regards
Tiejun

> 
> Regards,
> Ravi
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Linuxppc-dev mailing list
> [email-masked]
> https://lists.ozlabs.org/listinfo/linuxppc-dev