Skip to content

Commit

Permalink
Merge branch 'pci/enumeration' into next
Browse files Browse the repository at this point in the history
* pci/enumeration:
  PCI: tegra: Fix pci_remap_iospace() failure path
  PCI: generic: Fix pci_remap_iospace() failure path
  PCI: rcar: Fix pci_remap_iospace() failure path
  PCI: versatile: Fix pci_remap_iospace() failure path
  PCI: designware: Fix pci_remap_iospace() failure path
  PCI: aardvark: Fix pci_remap_iospace() failure path
  • Loading branch information
Bjorn Helgaas committed Oct 3, 2016
2 parents 4dc2db0 + 13f392e commit fb6b6cc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 23 deletions.
8 changes: 5 additions & 3 deletions drivers/pci/host/pci-aardvark.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
int err, res_valid = 0;
struct device *dev = &pcie->pdev->dev;
struct device_node *np = dev->of_node;
struct resource_entry *win;
struct resource_entry *win, *tmp;
resource_size_t iobase;

INIT_LIST_HEAD(&pcie->resources);
Expand All @@ -862,7 +862,7 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
if (err)
goto out_release_res;

resource_list_for_each_entry(win, &pcie->resources) {
resource_list_for_each_entry_safe(win, tmp, &pcie->resources) {
struct resource *res = win->res;

switch (resource_type(res)) {
Expand All @@ -874,9 +874,11 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
lower_32_bits(res->start),
OB_PCIE_IO);
err = pci_remap_iospace(res, iobase);
if (err)
if (err) {
dev_warn(dev, "error %d: failed to map resource %pR\n",
err, res);
resource_list_destroy_entry(win);
}
break;
case IORESOURCE_MEM:
advk_pcie_set_ob_win(pcie, 0,
Expand Down
8 changes: 5 additions & 3 deletions drivers/pci/host/pci-host-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int gen_pci_parse_request_of_pci_ranges(struct device *dev,
int err, res_valid = 0;
struct device_node *np = dev->of_node;
resource_size_t iobase;
struct resource_entry *win;
struct resource_entry *win, *tmp;

err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase);
if (err)
Expand All @@ -40,15 +40,17 @@ static int gen_pci_parse_request_of_pci_ranges(struct device *dev,
if (err)
return err;

resource_list_for_each_entry(win, resources) {
resource_list_for_each_entry_safe(win, tmp, resources) {
struct resource *res = win->res;

switch (resource_type(res)) {
case IORESOURCE_IO:
err = pci_remap_iospace(res, iobase);
if (err)
if (err) {
dev_warn(dev, "error %d: failed to map resource %pR\n",
err, res);
resource_list_destroy_entry(win);
}
break;
case IORESOURCE_MEM:
res_valid |= !(res->flags & IORESOURCE_PREFETCH);
Expand Down
7 changes: 5 additions & 2 deletions drivers/pci/host/pci-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
if (err < 0)
return err;

pci_add_resource_offset(&sys->resources, &pcie->pio, sys->io_offset);
err = pci_remap_iospace(&pcie->pio, pcie->io.start);
if (!err)
pci_add_resource_offset(&sys->resources, &pcie->pio,
sys->io_offset);

pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset);
pci_add_resource_offset(&sys->resources, &pcie->prefetch,
sys->mem_offset);
Expand All @@ -631,7 +635,6 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
if (err < 0)
return err;

pci_remap_iospace(&pcie->pio, pcie->io.start);
return 1;
}

Expand Down
8 changes: 5 additions & 3 deletions drivers/pci/host/pci-versatile.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
int err, mem = 1, res_valid = 0;
struct device_node *np = dev->of_node;
resource_size_t iobase;
struct resource_entry *win;
struct resource_entry *win, *tmp;

err = of_pci_get_host_bridge_resources(np, 0, 0xff, res, &iobase);
if (err)
Expand All @@ -84,15 +84,17 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
if (err)
goto out_release_res;

resource_list_for_each_entry(win, res) {
resource_list_for_each_entry_safe(win, tmp, res) {
struct resource *res = win->res;

switch (resource_type(res)) {
case IORESOURCE_IO:
err = pci_remap_iospace(res, iobase);
if (err)
if (err) {
dev_warn(dev, "error %d: failed to map resource %pR\n",
err, res);
resource_list_destroy_entry(win);
}
break;
case IORESOURCE_MEM:
res_valid |= !(res->flags & IORESOURCE_PREFETCH);
Expand Down
21 changes: 12 additions & 9 deletions drivers/pci/host/pcie-designware.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
struct resource *cfg_res;
int i, ret;
LIST_HEAD(res);
struct resource_entry *win;
struct resource_entry *win, *tmp;

cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
if (cfg_res) {
Expand All @@ -456,17 +456,20 @@ int dw_pcie_host_init(struct pcie_port *pp)
goto error;

/* Get the I/O and memory ranges from DT */
resource_list_for_each_entry(win, &res) {
resource_list_for_each_entry_safe(win, tmp, &res) {
switch (resource_type(win->res)) {
case IORESOURCE_IO:
pp->io = win->res;
pp->io->name = "I/O";
pp->io_size = resource_size(pp->io);
pp->io_bus_addr = pp->io->start - win->offset;
ret = pci_remap_iospace(pp->io, pp->io_base);
if (ret)
ret = pci_remap_iospace(win->res, pp->io_base);
if (ret) {
dev_warn(pp->dev, "error %d: failed to map resource %pR\n",
ret, pp->io);
ret, win->res);
resource_list_destroy_entry(win);
} else {
pp->io = win->res;
pp->io->name = "I/O";
pp->io_size = resource_size(pp->io);
pp->io_bus_addr = pp->io->start - win->offset;
}
break;
case IORESOURCE_MEM:
pp->mem = win->res;
Expand Down
9 changes: 6 additions & 3 deletions drivers/pci/host/pcie-rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
struct device *dev = pci->dev;
struct device_node *np = dev->of_node;
resource_size_t iobase;
struct resource_entry *win;
struct resource_entry *win, *tmp;

err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pci->resources, &iobase);
if (err)
Expand All @@ -955,14 +955,17 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
if (err)
goto out_release_res;

resource_list_for_each_entry(win, &pci->resources) {
resource_list_for_each_entry_safe(win, tmp, &pci->resources) {
struct resource *res = win->res;

if (resource_type(res) == IORESOURCE_IO) {
err = pci_remap_iospace(res, iobase);
if (err)
if (err) {
dev_warn(dev, "error %d: failed to map resource %pR\n",
err, res);

resource_list_destroy_entry(win);
}
}
}

Expand Down

0 comments on commit fb6b6cc

Please sign in to comment.