Skip to contentSkip to conversation

devres: implement pcim_iomap_regions_request_all()

PATCH In review Tejun Heo 4 participants 7 messages Mar 11, 2008 – Mar 17, 2008

Subsystems (3)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 devres: implement pcim_iomap_regions_request_all()

Some drivers need to reserve all PCI BARs to prevent other drivers misusing unoccupied BARs. pcim_iomap_regions_request_all() requests all BARs and iomap specified BARs.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Cox <[email protected]>
Cc Jeff Garzik <[email protected]>

---
After acked, it's probably best to push this through libata-dev as that's the only user for now.

Thanks.

 lib/devres.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
lib/devres.c +25 -0
Index: work/lib/devres.c
===================================================================
@@ -298,6 +298,31 @@ int pcim_iomap_regions(struct pci_dev *p
 EXPORT_SYMBOL(pcim_iomap_regions);
 
 /**
+ * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to iomap
+ * @name: Name used when requesting regions
+ *
+ * Request all PCI BARs and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+				   const char *name)
+{
+	int request_mask = ((1 << 6) - 1) & ~mask;
+	int rc;
+
+	rc = pci_request_selected_regions(pdev, request_mask, name);
+	if (rc)
+		return rc;
+
+	rc = pcim_iomap_regions(pdev, mask, name);
+	if (rc)
+		pci_release_selected_regions(pdev, request_mask);
+	return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions_request_all);
+
+/**
  * pcim_iounmap_regions - Unmap and release PCI BARs
  * @pdev: PCI device to map IO resources for
  * @mask: Mask of BARs to unmap and release
author
#1 lore raw

PATCH 1/1 ahci: request all PCI BARs

ahci is often implemented with accompanying SFF compatible interface and legacy IDE driver may attach to the legacy IO ports when the controller is already claimed by ahci and vice-versa. This patch makes ahci use pcim_iomap_regions_request_all() so that all IO regions are claimed on attach.

---
 drivers/ata/ahci.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ata/ahci.c +4 -1
Index: work/drivers/ata/ahci.c
===================================================================
@@ -2234,7 +2234,10 @@ static int ahci_init_one(struct pci_dev 
 	if (rc)
 		return rc;
 
-	rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
+	/* AHCI controllers often implement SFF compatible interface.
+	 * Grab all PCI BARs just in case.
+	 */
+	rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
 	if (rc == -EBUSY)
 		pcim_pin_device(pdev);
 	if (rc)
#2 lore raw

Re: [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs

Quoted 16 lines · Tejun Heo

ahci is often implemented with accompanying SFF compatible interface and legacy IDE driver may attach to the legacy IO ports when the controller is already claimed by ahci and vice-versa. This patch makes ahci use pcim_iomap_regions_request_all() so that all IO regions are claimed on attach.

---
 drivers/ata/ahci.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: work/drivers/ata/ahci.c
===================================================================

drivers/ata/ahci.c static int ahci_init_one(struct pci_dev · line 2242

Quoted 10 lines
drivers/ata/ahci.c +4 -1
@@ -2234,7 +2234,10 @@ static int ahci_init_one(struct pci_dev 
 	if (rc)
 		return rc;
 
-	rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
+	/* AHCI controllers often implement SFF compatible interface.
+	 * Grab all PCI BARs just in case.
+	 */
+	rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
 	if (rc == -EBUSY)
 		pcim_pin_device(pdev);

applied this, and the devres function

Acked-by Greg Kroah-Hartman on v1 1/1
#3 lore raw
In reply to Tejun Heo
Quoted 11 lines · Tejun Heo

Some drivers need to reserve all PCI BARs to prevent other drivers misusing unoccupied BARs. pcim_iomap_regions_request_all() requests all BARs and iomap specified BARs.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Cox <[email protected]>
Cc Jeff Garzik <[email protected]>

---
After acked, it's probably best to push this through libata-dev as that's the only user for now.

Feel free to push this through the libata-dev tree.

thanks,

greg k-h

maintainer
#4 lore raw
In reply to Tejun Heo
Quoted 40 lines · On Tue, 11 Mar 2008 19:51:38 +0900 Tejun Heo <[email protected]> wrote:

Some drivers need to reserve all PCI BARs to prevent other drivers misusing unoccupied BARs. pcim_iomap_regions_request_all() requests all BARs and iomap specified BARs.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Cox <[email protected]>
Cc Jeff Garzik <[email protected]>

---
After acked, it's probably best to push this through libata-dev as that's the only user for now.

Thanks.

 lib/devres.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Index: work/lib/devres.c
===================================================================

lib/devres.c +15 -0
@@ -298,6 +298,31 @@ int pcim_iomap_regions(struct pci_dev *p
 EXPORT_SYMBOL(pcim_iomap_regions);
 
 /**
+ * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to iomap
+ * @name: Name used when requesting regions
+ *
+ * Request all PCI BARs and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+				   const char *name)
+{
+	int request_mask = ((1 << 6) - 1) & ~mask;
+	int rc;
+
+	rc = pci_request_selected_regions(pdev, request_mask, name);
+	if (rc)

lib/devres.c int pcim_iomap_regions(struct pci_dev *p · line 325

Quoted 10 lines
lib/devres.c +10 -0
+		return rc;
+
+	rc = pcim_iomap_regions(pdev, mask, name);
+	if (rc)
+		pci_release_selected_regions(pdev, request_mask);
+	return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions_request_all);
+
+/**

err, I think you lost a bit.

drivers/ata/ahci.c: In function 'ahci_init_one':
drivers/ata/ahci.c:2247: error: implicit declaration of function 'pcim_iomap_regions_request_all'

include/linux/io.h renamed from include/linux/io.h~devres-implement-pcim_iomap_regions_request_all-fix +2 -0
@@ -65,5 +65,7 @@ void __iomem * devm_ioremap_nocache(stru
 void devm_iounmap(struct device *dev, void __iomem *addr);
 int check_signature(const volatile void __iomem *io_addr,
 			const unsigned char *signature, int length);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+			const char *name)
 
 #endif /* _LINUX_IO_H */

_

author
#5 lore raw

PATCH 1/1 devres: implement pcim_iomap_regions_request_all()

Some drivers need to reserve all PCI BARs to prevent other drivers misusing unoccupied BARs. pcim_iomap_regions_request_all() requests all BARs and iomap specified BARs.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Cox <[email protected]>
Cc Jeff Garzik <[email protected]>

---
Aieee... Sorry Andrew. I forgot doing "quilt add" on the file and subsequently missed that pci.h was modified while gitting the repo.

Here's the corrected version.

 include/linux/pci.h |    2 ++
 lib/devres.c        |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
lib/devres.c +25 -0
Index: work/lib/devres.c
===================================================================
@@ -298,6 +298,31 @@ int pcim_iomap_regions(struct pci_dev *p
 EXPORT_SYMBOL(pcim_iomap_regions);
 
 /**
+ * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to iomap
+ * @name: Name used when requesting regions
+ *
+ * Request all PCI BARs and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+				   const char *name)
+{
+	int request_mask = ((1 << 6) - 1) & ~mask;
+	int rc;
+
+	rc = pci_request_selected_regions(pdev, request_mask, name);
+	if (rc)
+		return rc;
+
+	rc = pcim_iomap_regions(pdev, mask, name);
+	if (rc)
+		pci_release_selected_regions(pdev, request_mask);
+	return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions_request_all);
+
+/**
  * pcim_iounmap_regions - Unmap and release PCI BARs
  * @pdev: PCI device to map IO resources for
  * @mask: Mask of BARs to unmap and release
include/linux/pci.h +2 -0
Index: work/include/linux/pci.h
===================================================================
@@ -1044,6 +1044,8 @@ void __iomem *pcim_iomap(struct pci_dev 
 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
 int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+				   const char *name);
 void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
 
 extern int pci_pci_problems;
Applied
#6 lore raw
Quoted 12 lines · Tejun Heo

Some drivers need to reserve all PCI BARs to prevent other drivers misusing unoccupied BARs. pcim_iomap_regions_request_all() requests all BARs and iomap specified BARs.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Cox <[email protected]>
Cc Jeff Garzik <[email protected]>

---
Aieee... Sorry Andrew. I forgot doing "quilt add" on the file and subsequently missed that pci.h was modified while gitting the repo.

Quoted 5 lines

Here's the corrected version.

 include/linux/pci.h |    2 ++
 lib/devres.c        |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

applied