Re: [bug report] PCI: dwc: Move "dbi", "dbi2", and "addr_space" resource setup into common code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 1, 2020 at 1:50 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> 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



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux