From: Bjorn Helgaas <bjorn.helgaas@hp•com>
To: linux-pci@atrey•karlin.mff.cuni.cz
To: linux-arch@vger•kernel.org
Cc: Chris Zankel <chris@zankel•net>,
Grant Grundler <grundler@parisc-linux•org>,
linux-parisc@vger•kernel.org, Matthew Wilcox <matthew@wil•cx>,
Kyle McMartin <kyle@parisc-linux•org>,
linuxppc-dev@ozlabs•org, Paul Mackerras <paulus@samba•org>,
linux-arm-kernel@lists•arm.linux.org.uk,
Russell King <rmk@arm•linux.org.uk>
Subject: [patch 01/16] PCI: add generic pci_enable_resources()
Date: Tue, 04 Mar 2008 11:56:47 -0700 [thread overview]
Message-ID: <20080304185819.885549413@ldl.fc.hp.com> (raw)
In-Reply-To: 20080304185646.864917286@ldl.fc.hp.com
Each architecture has its own pcibios_enable_resources() implementation.
These differ in many minor ways that have nothing to do with actual
architectural differences. Follow-on patches will make most arches
use this generic version instead.
This version is based on powerpc, which seemed most up-to-date. The only
functional difference from the x86 version is that this uses "!r->parent"
to check for resource collisions instead of "!r->start && r->end".
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp•com>
Index: work8/drivers/pci/setup-res.c
===================================================================
--- work8.orig/drivers/pci/setup-res.c 2008-03-04 09:56:53.000000000 -0700
+++ work8/drivers/pci/setup-res.c 2008-03-04 09:56:56.000000000 -0700
@@ -263,3 +263,46 @@
}
}
}
+
+int pci_enable_resources(struct pci_dev *dev, int mask)
+{
+ u16 cmd, old_cmd;
+ int i;
+ struct resource *r;
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ old_cmd = cmd;
+
+ for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+ if (!(mask & (1 << i)))
+ continue;
+
+ r = &dev->resource[i];
+
+ if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+ continue;
+ if ((i == PCI_ROM_RESOURCE) &&
+ (!(r->flags & IORESOURCE_ROM_ENABLE)))
+ continue;
+
+ if (!r->parent) {
+ dev_err(&dev->dev, "device not available because of "
+ "BAR %d [%llx:%llx] collisions\n", i,
+ (unsigned long long) r->start,
+ (unsigned long long) r->end);
+ return -EINVAL;
+ }
+
+ if (r->flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ if (r->flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+ }
+
+ if (cmd != old_cmd) {
+ dev_info(&dev->dev, "enabling device (%04x -> %04x)\n",
+ old_cmd, cmd);
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ }
+ return 0;
+}
Index: work8/include/linux/pci.h
===================================================================
--- work8.orig/include/linux/pci.h 2008-03-04 09:56:45.000000000 -0700
+++ work8/include/linux/pci.h 2008-03-04 09:56:56.000000000 -0700
@@ -616,6 +616,7 @@
void pci_assign_unassigned_resources(void);
void pdev_enable_device(struct pci_dev *);
void pdev_sort_resources(struct pci_dev *, struct resource_list *);
+int pci_enable_resources(struct pci_dev *, int mask);
void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
int (*)(struct pci_dev *, u8, u8));
#define HAVE_PCI_REQ_REGIONS 2
--
next prev parent reply other threads:[~2008-03-04 18:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
2008-03-04 18:56 ` Bjorn Helgaas [this message]
2008-03-05 14:53 ` [patch 01/16] PCI: add generic pci_enable_resources() David Howells
2008-03-05 20:14 ` Greg KH
2008-03-04 18:56 ` [patch 02/16] alpha: use " Bjorn Helgaas
2008-03-04 18:56 ` [patch 03/16] arm: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 04/16] cris: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 05/16] frv: " Bjorn Helgaas
2008-03-05 14:52 ` David Howells
2008-03-05 20:14 ` Greg KH
2008-03-04 18:56 ` [patch 06/16] ia64: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 07/16] mips: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 08/16] mn10300: " Bjorn Helgaas
2008-03-05 15:13 ` David Howells
2008-03-05 20:15 ` Greg KH
2008-03-04 18:56 ` [patch 09/16] parisc: " Bjorn Helgaas
2008-03-05 16:17 ` Kyle McMartin
2008-03-05 20:09 ` Greg KH
2008-03-04 18:56 ` [patch 10/16] powerpc: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 11/16] ppc: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 12/16] sh: " Bjorn Helgaas
2008-03-04 18:56 ` [patch 13/16] sparc64: " Bjorn Helgaas
2008-03-04 18:57 ` [patch 14/16] v850: " Bjorn Helgaas
2008-03-04 18:57 ` [patch 15/16] x86: " Bjorn Helgaas
2008-03-04 18:57 ` [patch 16/16] xtensa: " 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=20080304185819.885549413@ldl.fc.hp.com \
--to=bjorn.helgaas@hp$(echo .)com \
--cc=chris@zankel$(echo .)net \
--cc=grundler@parisc-linux$(echo .)org \
--cc=kyle@parisc-linux$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)arm.linux.org.uk \
--cc=linux-parisc@vger$(echo .)kernel.org \
--cc=linux-pci@atrey$(echo .)karlin.mff.cuni.cz \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=matthew@wil$(echo .)cx \
--cc=paulus@samba$(echo .)org \
--cc=rmk@arm$(echo .)linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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