Messages in this thread | | | Date | Tue, 20 Oct 2015 15:16:45 -0700 | Subject | Re: [PATCH v7 03/60] sparc/PCI: Unify pci_register_region() | From | Yinghai Lu <> |
| |
On Tue, Oct 20, 2015 at 2:57 PM, Bjorn Helgaas <helgaas@kernel.org> wrote: > On Thu, Oct 08, 2015 at 02:38:22PM -0700, Yinghai Lu wrote: >> We register regions for legacy and iommu and all have open code. >> >> Unify them to pci_register_region() and call it accordingly. >> >> + if (!mem_res->flags) >> return; >> >> - p->name = "Video RAM area"; >> - p->start = mem_res->start + 0xa0000UL; >> - p->end = p->start + 0x1ffffUL; >> - p->flags = IORESOURCE_BUSY; >> - request_resource(mem_res, p); >> + mem_rstart = mem_res->start - offset; >> + mem_rend = mem_res->end - offset; > > This is essentially doing pcibios_bus_to_resource(), except in an > unnecessarily arch-dependent way. Can you rework it to use > pcibios_bus_to_resource()? I think you'll have to do > pci_register_legacy_regions() in pci_scan_one_pbm() instead of in > pci_determine_mem_io_space(), so that you have a struct pci_bus to > use, but your next patch does that anyway. > >> >> - p = kzalloc(sizeof(*p), GFP_KERNEL); >> - if (!p) >> + /* contain checking */ >> + if (!(mem_rstart <= rstart && mem_rend >= rend)) >> return;
Difference is here.
pcibios_bus_to_resource() would return resource even region is not contained.
>> + res->name = name; >> + res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; >> + res->start = rstart + offset; >> + res->end = rend + offset; >> + conflict = request_resource_conflict(mem_res, res); >> + if (conflict) { >> + printk(KERN_DEBUG "PCI: %s can't claim %s %pR: address conflict with %s %pR\n", >> + pbm->name, res->name, res, conflict->name, conflict); >> + kfree(res); >> + }
also we will need to get parent resource to use request_resource_conflict.
otherwise we need to use insert_resource(), but that will prevent driver to use the resource.
Yinghai
| |