LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] devres: implement pcim_iomap_regions_request_all()
@ 2008-03-11 10:51 Tejun Heo
  2008-03-11 10:52 ` [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs Tejun Heo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tejun Heo @ 2008-03-11 10:51 UTC (permalink / raw)
  To: Jeff Garzik, IDE/ATA development list, linux-pci, Linux Kernel,
	Greg KH, Jeff Garzik, Alan Cox

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.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <jeff@garzik.org>
---
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
===================================================================
--- work.orig/lib/devres.c
+++ 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs
  2008-03-11 10:51 [PATCH] devres: implement pcim_iomap_regions_request_all() Tejun Heo
@ 2008-03-11 10:52 ` Tejun Heo
  2008-03-17 12:27   ` Jeff Garzik
  2008-03-11 18:18 ` [PATCH] devres: implement pcim_iomap_regions_request_all() Greg KH
  2008-03-12  6:08 ` Andrew Morton
  2 siblings, 1 reply; 7+ messages in thread
From: Tejun Heo @ 2008-03-11 10:52 UTC (permalink / raw)
  To: Jeff Garzik, IDE/ATA development list, linux-pci, Linux Kernel,
	Greg KH, Jeff Garzik, Alan Cox

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.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 drivers/ata/ahci.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: work/drivers/ata/ahci.c
===================================================================
--- work.orig/drivers/ata/ahci.c
+++ 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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] devres: implement pcim_iomap_regions_request_all()
  2008-03-11 10:51 [PATCH] devres: implement pcim_iomap_regions_request_all() Tejun Heo
  2008-03-11 10:52 ` [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs Tejun Heo
@ 2008-03-11 18:18 ` Greg KH
  2008-03-12  6:08 ` Andrew Morton
  2 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2008-03-11 18:18 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Jeff Garzik, IDE/ATA development list, linux-pci, Linux Kernel, Alan Cox

On Tue, Mar 11, 2008 at 07:51:38PM +0900, Tejun Heo 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Cc: Jeff Garzik <jeff@garzik.org>
> ---
> After acked, it's probably best to push this through libata-dev as
> that's the only user for now.

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

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

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] devres: implement pcim_iomap_regions_request_all()
  2008-03-11 10:51 [PATCH] devres: implement pcim_iomap_regions_request_all() Tejun Heo
  2008-03-11 10:52 ` [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs Tejun Heo
  2008-03-11 18:18 ` [PATCH] devres: implement pcim_iomap_regions_request_all() Greg KH
@ 2008-03-12  6:08 ` Andrew Morton
  2008-03-12  6:26   ` [PATCH UPDATED] " Tejun Heo
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2008-03-12  6:08 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Jeff Garzik, IDE/ATA development list, linux-pci, Linux Kernel,
	Greg KH, Alan Cox

On Tue, 11 Mar 2008 19:51:38 +0900 Tejun Heo <htejun@gmail.com> 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Cc: Jeff Garzik <jeff@garzik.org>
> ---
> 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
> ===================================================================
> --- work.orig/lib/devres.c
> +++ 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);
> +
> +/**

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'

--- a/include/linux/io.h~devres-implement-pcim_iomap_regions_request_all-fix
+++ a/include/linux/io.h
@@ -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 */
_


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH UPDATED] devres: implement pcim_iomap_regions_request_all()
  2008-03-12  6:08 ` Andrew Morton
@ 2008-03-12  6:26   ` Tejun Heo
  2008-03-17 12:27     ` Jeff Garzik
  0 siblings, 1 reply; 7+ messages in thread
From: Tejun Heo @ 2008-03-12  6:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jeff Garzik, IDE/ATA development list, linux-pci, Linux Kernel,
	Greg KH, Alan Cox

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.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <jeff@garzik.org>
---
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(+)

Index: work/lib/devres.c
===================================================================
--- work.orig/lib/devres.c
+++ 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
Index: work/include/linux/pci.h
===================================================================
--- work.orig/include/linux/pci.h
+++ 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;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH UPDATED] devres: implement pcim_iomap_regions_request_all()
  2008-03-12  6:26   ` [PATCH UPDATED] " Tejun Heo
@ 2008-03-17 12:27     ` Jeff Garzik
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2008-03-17 12:27 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, IDE/ATA development list, linux-pci, Linux Kernel,
	Greg KH, Alan Cox

Tejun Heo 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Cc: Jeff Garzik <jeff@garzik.org>
> ---
> 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(+)

applied



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs
  2008-03-11 10:52 ` [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs Tejun Heo
@ 2008-03-17 12:27   ` Jeff Garzik
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2008-03-17 12:27 UTC (permalink / raw)
  To: Tejun Heo
  Cc: IDE/ATA development list, linux-pci, Linux Kernel, Greg KH, Alan Cox

Tejun Heo wrote:
> 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> ---
>  drivers/ata/ahci.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> Index: work/drivers/ata/ahci.c
> ===================================================================
> --- work.orig/drivers/ata/ahci.c
> +++ 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);

applied this, and the devres function



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-17 12:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-11 10:51 [PATCH] devres: implement pcim_iomap_regions_request_all() Tejun Heo
2008-03-11 10:52 ` [PATCH libata-dev#upstream-fixes] ahci: request all PCI BARs Tejun Heo
2008-03-17 12:27   ` Jeff Garzik
2008-03-11 18:18 ` [PATCH] devres: implement pcim_iomap_regions_request_all() Greg KH
2008-03-12  6:08 ` Andrew Morton
2008-03-12  6:26   ` [PATCH UPDATED] " Tejun Heo
2008-03-17 12:27     ` Jeff Garzik

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).