From: Bjorn Helgaas <bhelgaas@google.com>
To: linux-pci@vger.kernel.org
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] i2o: Use pci_bus_alloc_resource(), not allocate_resource() directly
Date: Wed, 26 Feb 2014 12:09:27 -0700 [thread overview]
Message-ID: <20140226190927.9616.43043.stgit@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20140226190306.9616.30567.stgit@bhelgaas-glaptop.roam.corp.google.com>
Convert i2o_res_alloc() to use pci_bus_alloc_resource() rather than
pci_find_parent_resource() and allocate_resource(). We don't have a
resource to start with, so pci_find_parent_resource() can't do anything
useful: a bus may have several memory resources available, so there might
be several possible parents. This is more likely on root buses because
host bridges may have any number of apertures.
I'm pretty sure this didn't work in the first place because it passed
size == min == max to allocate_resource(). The min and max parameters are
constraints on the *addresses* of the resource, not on its size, so I think
it was impossible for allocate_resource() to succeed.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/message/i2o/iop.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index c334ba7224a1..5e7b1b75f999 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -655,8 +655,8 @@ static int i2o_iop_activate(struct i2o_controller *c)
static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
{
i2o_status_block *sb = c->status_block.virt;
- struct resource *root, *res = &c->mem_resource;
- resource_size_t size, min, max, align;
+ struct resource *res = &c->mem_resource;
+ resource_size_t size, align;
int err;
res->name = c->pdev->bus->name;
@@ -664,21 +664,17 @@ static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
res->start = 0;
res->end = 0;
osm_info("%s: requires private memory resources.\n", c->name);
- root = pci_find_parent_resource(c->pdev, res);
- if (root == NULL) {
- osm_warn("%s: Can't find parent resource!\n", c->name);
- return;
- }
if (flags & IORESOURCE_MEM) {
- size = min = max = sb->desired_mem_size;
+ size = sb->desired_mem_size;
align = 1 << 20; /* unspecified, use 1Mb and play safe */
} else if (flags & IORESOURCE_IO) {
- size = min = max = sb->desired_io_size;
+ size = sb->desired_io_size;
align = 1 << 12; /* unspecified, use 4Kb and play safe */
}
- err = allocate_resource(root, res, size, min, max, align, NULL, NULL);
+ err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0,
+ NULL, NULL);
if (err < 0)
return;
next prev parent reply other threads:[~2014-02-26 19:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 19:08 [PATCH 0/4] i2o: Use pci_bus_alloc_resource() Bjorn Helgaas
2014-02-26 19:09 ` [PATCH 1/4] i2o: Fix I/O space allocation copy/paste error Bjorn Helgaas
2014-02-26 19:09 ` [PATCH 2/4] i2o: Fix I/O space alignment requirement Bjorn Helgaas
2014-02-26 19:09 ` [PATCH 3/4] i2o: Refactor i2o_iop_systab_set() PCI space allocation Bjorn Helgaas
2014-02-26 19:09 ` Bjorn Helgaas [this message]
2014-02-26 22:48 ` [PATCH 4/4] i2o: Use pci_bus_alloc_resource(), not allocate_resource() directly One Thousand Gnomes
2014-02-26 23:47 ` Bjorn Helgaas
2014-03-04 20:52 ` [PATCH 0/4] i2o: Use pci_bus_alloc_resource() Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140226190927.9616.43043.stgit@bhelgaas-glaptop.roam.corp.google.com \
--to=bhelgaas@google.com \
--cc=Markus.Lidel@shadowconnect.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®