* [bug report] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code
@ 2020-12-01 8:50 Dan Carpenter
2020-12-01 15:01 ` Rob Herring
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-12-01 8:50 UTC (permalink / raw)
To: robh; +Cc: Rob Herring, linux-pci
Hello Rob Herring,
The patch a0fd361db8e5: "PCI: dwc: Move "dbi", "dbi2", and
"addr_space" resource setup into common code" from Nov 5, 2020, leads
to the following static checker warning:
drivers/pci/controller/dwc/pcie-designware-host.c:337 dw_pcie_host_init()
warn: 'pci->dbi_base' is an error pointer or valid
drivers/pci/controller/dwc/pcie-designware-host.c
304 cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
305 if (cfg_res) {
306 pp->cfg0_size = resource_size(cfg_res);
307 pp->cfg0_base = cfg_res->start;
308 } else if (!pp->va_cfg0_base) {
309 dev_err(dev, "Missing *config* reg space\n");
310 }
311
312 if (!pci->dbi_base) {
313 struct resource *dbi_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
314 pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_res);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We set pci->dbi_base here now.
315 if (IS_ERR(pci->dbi_base))
316 return PTR_ERR(pci->dbi_base);
317 }
318
319 bridge = devm_pci_alloc_host_bridge(dev, 0);
320 if (!bridge)
321 return -ENOMEM;
322
323 pp->bridge = bridge;
324
325 /* Get the I/O and memory ranges from DT */
326 resource_list_for_each_entry(win, &bridge->windows) {
327 switch (resource_type(win->res)) {
328 case IORESOURCE_IO:
329 pp->io_size = resource_size(win->res);
330 pp->io_bus_addr = win->res->start - win->offset;
331 pp->io_base = pci_pio_to_address(win->res->start);
332 break;
333 case 0:
334 dev_err(dev, "Missing *config* reg space\n");
335 pp->cfg0_size = resource_size(win->res);
336 pp->cfg0_base = win->res->start;
337 if (!pci->dbi_base) {
^^^^^^^^^^^^^^
So this is dead code because pci->dbi_base is never NULL.
338 pci->dbi_base = devm_pci_remap_cfgspace(dev,
339 pp->cfg0_base,
340 pp->cfg0_size);
341 if (!pci->dbi_base) {
342 dev_err(dev, "Error with ioremap\n");
343 return -ENOMEM;
344 }
345 }
346 break;
347 }
348 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code
2020-12-01 8:50 [bug report] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code Dan Carpenter
@ 2020-12-01 15:01 ` Rob Herring
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2020-12-01 15:01 UTC (permalink / raw)
To: Dan Carpenter; +Cc: PCI
On Tue, Dec 1, 2020 at 1:50 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Hello Rob Herring,
>
> The patch a0fd361db8e5: "PCI: dwc: Move "dbi", "dbi2", and
> "addr_space" resource setup into common code" from Nov 5, 2020, leads
> to the following static checker warning:
>
> drivers/pci/controller/dwc/pcie-designware-host.c:337 dw_pcie_host_init()
> warn: 'pci->dbi_base' is an error pointer or valid
>
> drivers/pci/controller/dwc/pcie-designware-host.c
> 304 cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
> 305 if (cfg_res) {
> 306 pp->cfg0_size = resource_size(cfg_res);
> 307 pp->cfg0_base = cfg_res->start;
> 308 } else if (!pp->va_cfg0_base) {
> 309 dev_err(dev, "Missing *config* reg space\n");
> 310 }
> 311
> 312 if (!pci->dbi_base) {
> 313 struct resource *dbi_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
> 314 pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_res);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> We set pci->dbi_base here now.
>
> 315 if (IS_ERR(pci->dbi_base))
> 316 return PTR_ERR(pci->dbi_base);
> 317 }
> 318
> 319 bridge = devm_pci_alloc_host_bridge(dev, 0);
> 320 if (!bridge)
> 321 return -ENOMEM;
> 322
> 323 pp->bridge = bridge;
> 324
> 325 /* Get the I/O and memory ranges from DT */
> 326 resource_list_for_each_entry(win, &bridge->windows) {
> 327 switch (resource_type(win->res)) {
> 328 case IORESOURCE_IO:
> 329 pp->io_size = resource_size(win->res);
> 330 pp->io_bus_addr = win->res->start - win->offset;
> 331 pp->io_base = pci_pio_to_address(win->res->start);
> 332 break;
> 333 case 0:
> 334 dev_err(dev, "Missing *config* reg space\n");
> 335 pp->cfg0_size = resource_size(win->res);
> 336 pp->cfg0_base = win->res->start;
> 337 if (!pci->dbi_base) {
> ^^^^^^^^^^^^^^
> So this is dead code because pci->dbi_base is never NULL.
I think this code should not be needed any more. It was for
compatibility with old DTs. I'll check the history.
Rob
>
> 338 pci->dbi_base = devm_pci_remap_cfgspace(dev,
> 339 pp->cfg0_base,
> 340 pp->cfg0_size);
> 341 if (!pci->dbi_base) {
> 342 dev_err(dev, "Error with ioremap\n");
> 343 return -ENOMEM;
> 344 }
> 345 }
> 346 break;
> 347 }
> 348 }
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-01 15:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 8:50 [bug report] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code Dan Carpenter
2020-12-01 15:01 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).