* [PATCH 0/3] Minor resource assignment cleanups
@ 2014-07-09 15:33 Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 1/3] PCI: Cleanup control flow Bjorn Helgaas
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2014-07-09 15:33 UTC (permalink / raw)
To: linux-pci
These are minor, mostly cosmetic changes, although they do make
a few changes to the messages printed by resource assignment. I'm
planning these for v3.17.
---
Bjorn Helgaas (3):
PCI: Cleanup control flow
PCI: Return conventional error values from pci_revert_fw_address()
PCI: Tidy resource assignment messages
drivers/pci/setup-res.c | 69 ++++++++++++++++++++---------------------------
1 file changed, 30 insertions(+), 39 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] PCI: Cleanup control flow
2014-07-09 15:33 [PATCH 0/3] Minor resource assignment cleanups Bjorn Helgaas
@ 2014-07-09 15:33 ` Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 2/3] PCI: Return conventional error values from pci_revert_fw_address() Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 3/3] PCI: Tidy resource assignment messages Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2014-07-09 15:33 UTC (permalink / raw)
To: linux-pci
Return errors immediately so the straightline path is the normal,
no-error path. No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/setup-res.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 481c4e18693a..532dc540dc5d 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -305,14 +305,16 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
if (ret < 0)
ret = pci_revert_fw_address(res, dev, resno, size);
- if (!ret) {
- res->flags &= ~IORESOURCE_UNSET;
- res->flags &= ~IORESOURCE_STARTALIGN;
- dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res);
- if (resno < PCI_BRIDGE_RESOURCES)
- pci_update_resource(dev, resno);
- }
- return ret;
+ if (ret)
+ return ret;
+
+ res->flags &= ~IORESOURCE_UNSET;
+ res->flags &= ~IORESOURCE_STARTALIGN;
+ dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res);
+ if (resno < PCI_BRIDGE_RESOURCES)
+ pci_update_resource(dev, resno);
+
+ return 0;
}
EXPORT_SYMBOL(pci_assign_resource);
@@ -335,19 +337,20 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
/* already aligned with min_align */
new_size = resource_size(res) + addsize;
ret = _pci_assign_resource(dev, resno, new_size, min_align);
- if (!ret) {
- res->flags &= ~IORESOURCE_UNSET;
- res->flags &= ~IORESOURCE_STARTALIGN;
- dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res);
- if (resno < PCI_BRIDGE_RESOURCES)
- pci_update_resource(dev, resno);
- } else {
+ if (ret) {
res->flags = flags;
dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n",
resno, res, (unsigned long long) addsize);
+ return ret;
}
- return ret;
+ res->flags &= ~IORESOURCE_UNSET;
+ res->flags &= ~IORESOURCE_STARTALIGN;
+ dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res);
+ if (resno < PCI_BRIDGE_RESOURCES)
+ pci_update_resource(dev, resno);
+
+ return 0;
}
int pci_enable_resources(struct pci_dev *dev, int mask)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] PCI: Return conventional error values from pci_revert_fw_address()
2014-07-09 15:33 [PATCH 0/3] Minor resource assignment cleanups Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 1/3] PCI: Cleanup control flow Bjorn Helgaas
@ 2014-07-09 15:33 ` Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 3/3] PCI: Tidy resource assignment messages Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2014-07-09 15:33 UTC (permalink / raw)
To: linux-pci
Previously we returned zero for success or 1 for failure. This changes
that so we return zero for success or a negative errno for failure.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/setup-res.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 532dc540dc5d..74eb6febdf87 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -166,11 +166,10 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev,
{
struct resource *root, *conflict;
resource_size_t fw_addr, start, end;
- int ret = 0;
fw_addr = pcibios_retrieve_fw_addr(dev, resno);
if (!fw_addr)
- return 1;
+ return -ENOMEM;
start = res->start;
end = res->end;
@@ -189,14 +188,13 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev,
resno, res);
conflict = request_resource_conflict(root, res);
if (conflict) {
- dev_info(&dev->dev,
- "BAR %d: %pR conflicts with %s %pR\n", resno,
- res, conflict->name, conflict);
+ dev_info(&dev->dev, "BAR %d: %pR conflicts with %s %pR\n",
+ resno, res, conflict->name, conflict);
res->start = start;
res->end = end;
- ret = 1;
+ return -EBUSY;
}
- return ret;
+ return 0;
}
static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
@@ -305,7 +303,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
if (ret < 0)
ret = pci_revert_fw_address(res, dev, resno, size);
- if (ret)
+ if (ret < 0)
return ret;
res->flags &= ~IORESOURCE_UNSET;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] PCI: Tidy resource assignment messages
2014-07-09 15:33 [PATCH 0/3] Minor resource assignment cleanups Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 1/3] PCI: Cleanup control flow Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 2/3] PCI: Return conventional error values from pci_revert_fw_address() Bjorn Helgaas
@ 2014-07-09 15:33 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2014-07-09 15:33 UTC (permalink / raw)
To: linux-pci
Print messages about failures in pci_assign_resource(). We can drop the
"by-hand" message from _pci_assign_resource() because %pR now prints the
size rather than the address if the resource hasn't been assigned.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/setup-res.c | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 74eb6febdf87..6a9e4ec37af0 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -251,7 +251,6 @@ static int _pci_assign_resource(struct pci_dev *dev, int resno,
struct resource *res = dev->resource + resno;
struct pci_bus *bus;
int ret;
- char *type;
bus = dev->bus;
while ((ret = __pci_assign_resource(bus, dev, resno, size, min_align))) {
@@ -260,21 +259,6 @@ static int _pci_assign_resource(struct pci_dev *dev, int resno,
bus = bus->parent;
}
- if (ret) {
- if (res->flags & IORESOURCE_MEM)
- if (res->flags & IORESOURCE_PREFETCH)
- type = "mem pref";
- else
- type = "mem";
- else if (res->flags & IORESOURCE_IO)
- type = "io";
- else
- type = "unknown";
- dev_info(&dev->dev,
- "BAR %d: can't assign %s (size %#llx)\n",
- resno, type, (unsigned long long) resource_size(res));
- }
-
return ret;
}
@@ -300,11 +284,16 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
* where firmware left it. That at least has a chance of
* working, which is better than just leaving it disabled.
*/
- if (ret < 0)
+ if (ret < 0) {
+ dev_info(&dev->dev, "BAR %d: no space for %pR\n", resno, res);
ret = pci_revert_fw_address(res, dev, resno, size);
+ }
- if (ret < 0)
+ if (ret < 0) {
+ dev_info(&dev->dev, "BAR %d: failed to assign %pR\n", resno,
+ res);
return ret;
+ }
res->flags &= ~IORESOURCE_UNSET;
res->flags &= ~IORESOURCE_STARTALIGN;
@@ -344,7 +333,8 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
res->flags &= ~IORESOURCE_UNSET;
res->flags &= ~IORESOURCE_STARTALIGN;
- dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res);
+ dev_info(&dev->dev, "BAR %d: reassigned %pR (expanded by %#llx)\n",
+ resno, res, (unsigned long long) addsize);
if (resno < PCI_BRIDGE_RESOURCES)
pci_update_resource(dev, resno);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-09 15:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-09 15:33 [PATCH 0/3] Minor resource assignment cleanups Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 1/3] PCI: Cleanup control flow Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 2/3] PCI: Return conventional error values from pci_revert_fw_address() Bjorn Helgaas
2014-07-09 15:33 ` [PATCH 3/3] PCI: Tidy resource assignment messages Bjorn Helgaas
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).