From: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
To: Andrew Morton <akpm@osdl.org>, Greg KH <greg@kroah.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-pci@atrey.karlin.mff.cuni.cz
Subject: [PATCH 1/4] PCI legacy I/O port free driver (take4) - Add no_ioport flag into pci_dev
Date: Fri, 03 Mar 2006 00:14:59 +0900 [thread overview]
Message-ID: <44070BF3.3000706@jp.fujitsu.com> (raw)
In-Reply-To: <44070B62.3070608@jp.fujitsu.com>
This patch adds the no_ioport field into struct pci_dev, which is used
to tell the kernel not to touch any I/O port regions.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
drivers/pci/pci.c | 39 ++++++++++++++++++++++++++++++++-------
include/linux/pci.h | 1 +
2 files changed, 33 insertions(+), 7 deletions(-)
Index: linux-2.6.16-rc5-mm1/include/linux/pci.h
===================================================================
--- linux-2.6.16-rc5-mm1.orig/include/linux/pci.h 2006-03-01 13:56:06.000000000 +0900
+++ linux-2.6.16-rc5-mm1/include/linux/pci.h 2006-03-01 16:30:56.000000000 +0900
@@ -163,6 +163,7 @@
unsigned int is_busmaster:1; /* device is busmaster */
unsigned int no_msi:1; /* device may not use msi */
unsigned int block_ucfg_access:1; /* userspace config space access is blocked */
+ unsigned int no_ioport:1; /* device may not use ioport */
u32 saved_config_space[16]; /* config space saved at suspend time */
struct hlist_head saved_cap_space;
Index: linux-2.6.16-rc5-mm1/drivers/pci/pci.c
===================================================================
--- linux-2.6.16-rc5-mm1.orig/drivers/pci/pci.c 2006-03-01 13:56:04.000000000 +0900
+++ linux-2.6.16-rc5-mm1/drivers/pci/pci.c 2006-03-01 16:35:00.000000000 +0900
@@ -507,7 +507,14 @@
int
pci_enable_device(struct pci_dev *dev)
{
- int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
+ int i, err, bars = (1 << PCI_NUM_RESOURCES) - 1;
+
+ if (dev->no_ioport)
+ for (i = 0; i < PCI_NUM_RESOURCES; i++)
+ if (pci_resource_flags(dev, i) & IORESOURCE_IO)
+ bars &= ~(1 << i);
+
+ err = pci_enable_device_bars(dev, bars);
if (err)
return err;
pci_fixup_device(pci_fixup_enable, dev);
@@ -628,9 +635,14 @@
{
if (pci_resource_len(pdev, bar) == 0)
return;
- if (pci_resource_flags(pdev, bar) & IORESOURCE_IO)
+ if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) {
+ if (pdev->no_ioport)
+ dev_warn(&pdev->dev,
+ "Trying to release PCI I/O region #%d for "
+ "the device marked I/O resource free\n", bar);
release_region(pci_resource_start(pdev, bar),
pci_resource_len(pdev, bar));
+ }
else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM)
release_mem_region(pci_resource_start(pdev, bar),
pci_resource_len(pdev, bar));
@@ -656,6 +668,10 @@
return 0;
if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) {
+ if (pdev->no_ioport)
+ dev_warn(&pdev->dev,
+ "Trying to request PCI I/O region #%d for "
+ "the device marked I/O resource free\n", bar);
if (!request_region(pci_resource_start(pdev, bar),
pci_resource_len(pdev, bar), res_name))
goto err_out;
@@ -689,10 +705,13 @@
void pci_release_regions(struct pci_dev *pdev)
{
- int i;
+ int i, no_ioport = pdev->no_ioport;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 6; i++) {
+ if (no_ioport && (pci_resource_flags(pdev, i) & IORESOURCE_IO))
+ continue;
pci_release_region(pdev, i);
+ }
}
/**
@@ -710,16 +729,22 @@
*/
int pci_request_regions(struct pci_dev *pdev, char *res_name)
{
- int i;
+ int i, no_ioport = pdev->no_ioport;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 6; i++) {
+ if (no_ioport && (pci_resource_flags(pdev, i) & IORESOURCE_IO))
+ continue;
if(pci_request_region(pdev, i, res_name))
goto err_out;
+ }
return 0;
err_out:
- while(--i >= 0)
+ while(--i >= 0) {
+ if (no_ioport && (pci_resource_flags(pdev, i) & IORESOURCE_IO))
+ continue;
pci_release_region(pdev, i);
+ }
return -EBUSY;
}
next prev parent reply other threads:[~2006-03-02 15:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-02 15:12 [PATCH 0/4] PCI legacy I/O port free driver (take4) Kenji Kaneshige
2006-03-02 15:14 ` Kenji Kaneshige [this message]
2006-03-02 15:16 ` [PATCH 2/4] PCI legacy I/O port free driver (take4) - Update Documentation/pci.txt Kenji Kaneshige
2006-03-02 15:18 ` [PATCH 3/4] PCI legacy I/O port free driver (take4) - Make Intel e1000 driver legacy I/O port free Kenji Kaneshige
2006-03-02 15:20 ` [PATCH 4/4] PCI legacy I/O port free driver (take4) - Make Emulex lpfc " Kenji Kaneshige
2006-03-02 15:50 ` [PATCH 0/4] PCI legacy I/O port free driver (take4) Russell King
2006-03-02 16:23 ` Kenji Kaneshige
2006-03-02 16:41 ` Greg KH
2006-03-02 17:24 ` Grant Grundler
2006-03-02 18:00 ` Russell King
2006-03-02 18:12 ` Jeff Garzik
2006-03-02 19:13 ` Russell King
2006-03-02 20:01 ` Jeff Garzik
2006-03-02 19:23 ` Grant Grundler
2006-03-02 19:34 ` Russell King
2006-03-02 19:50 ` Roland Dreier
2006-03-03 3:17 ` Kenji Kaneshige
2006-03-03 6:59 ` Kenji Kaneshige
2006-03-06 1:38 ` Kenji Kaneshige
2006-03-10 2:10 ` Adam Belay
2006-03-10 4:10 ` Kenji Kaneshige
2006-03-10 7:49 ` Russell King
2006-03-10 8:33 ` Russell King
2006-03-13 5:47 ` Kenji Kaneshige
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=44070BF3.3000706@jp.fujitsu.com \
--to=kaneshige.kenji@jp.fujitsu.com \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
/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;
as well as URLs for NNTP newsgroup(s).