Skip to contentSkip to conversation

PCI: Increase resource array mask bit size in pcim_iomap_regions()

PATCH Applied Yinghai Lu 5 participants 5 messages Jan 4, 2012 – Jan 6, 2012

Subsystems (2)
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 PCI: Increase resource array mask bit size in pcim_iomap_regions()

DEVICE_COUNT_RESOURCE will be bigger than 16 when SRIOV supported is enabled.

Let them pass with int just like pci_enable_resources().

---
 include/linux/pci.h |    6 +++---
 lib/devres.c        |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/pci.h +3 -3
Index: linux-2.6/include/linux/pci.h
===================================================================
@@ -1433,10 +1433,10 @@ static inline void pci_fixup_device(enum
 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
 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,
+int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
 				   const char *name);
-void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
+void pcim_iounmap_regions(struct pci_dev *pdev, int mask);
 
 extern int pci_pci_problems;
 #define PCIPCI_FAIL		1	/* No PCI PCI DMA */
lib/devres.c +3 -3
Index: linux-2.6/lib/devres.c
===================================================================
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(pcim_iounmap);
  *
  * Request and iomap regions specified by @mask.
  */
-int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
+int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name)
 {
 	void __iomem * const *iomap;
 	int i, rc;
@@ -306,7 +306,7 @@ EXPORT_SYMBOL(pcim_iomap_regions);
  *
  * Request all PCI BARs and iomap regions specified by @mask.
  */
-int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
 				   const char *name)
 {
 	int request_mask = ((1 << 6) - 1) & ~mask;
@@ -330,7 +330,7 @@ EXPORT_SYMBOL(pcim_iomap_regions_request
  *
  * Unmap and release regions specified by @mask.
  */
-void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask)
+void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
 {
 	void __iomem * const *iomap;
 	int i;
#1 lore raw
Quoted 17 lines

DEVICE_COUNT_RESOURCE will be bigger than 16 when SRIOV supported is enabled.

Let them pass with int just like pci_enable_resources().

---
 include/linux/pci.h |    6 +++---
 lib/devres.c        |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/pci.h
===================================================================

include/linux/pci.h static inline void pci_fixup_device(enum · line 1439

Quoted 9 lines
include/linux/pci.h +2 -2
@@ -1433,10 +1433,10 @@ static inline void pci_fixup_device(enum
 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long
 maxlen);
 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,
+int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
 				   const char *name);

[...]

You are switching from unsigned to signed here, is this intentional? In my feeling such masks should end up in an unsigned int, no?

Eike

maintainer
#2 lore raw
Quoted 28 lines · Rolf Eike Beer
Quoted 26 lines

DEVICE_COUNT_RESOURCE will be bigger than 16 when SRIOV supported is enabled.

Let them pass with int just like pci_enable_resources().

---
 include/linux/pci.h |    6 +++---
 lib/devres.c        |    6 +++---

 2 files changed, 6 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/pci.h
===================================================================

include/linux/pci.h +0 -0
@@ -1433,10 +1433,10 @@ static inline void pci_fixup_device(enum

 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);

include/linux/pci.h +2 -2
-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,
+int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,

                                 const char *name);

[...]

Quoted 2 lines

You are switching from unsigned to signed here, is this intentional? In my feeling such masks should end up in an unsigned int, no?

I agree masks should generally be unsigned, but I think it makes sense to first follow pci_enable_resources() (which uses "int") , and maybe in the future, convert both to being unsigned.

Bjorn

#3 lore raw
In reply to Yinghai Lu
Quoted 18 lines · Yinghai Lu

DEVICE_COUNT_RESOURCE will be bigger than 16 when SRIOV supported is enabled.

Let them pass with int just like pci_enable_resources().

---
  include/linux/pci.h |    6 +++---
  lib/devres.c        |    6 +++---
  2 files changed, 6 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/pci.h
===================================================================

include/linux/pci.h +0 -0
@@ -1433,10 +1433,10 @@ static inline void pci_fixup_device(enum
  void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
  void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);

include/linux/pci.h static inline void pci_fixup_device(enum · line 1440

Quoted 10 lines
include/linux/pci.h +3 -3
  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,
+int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
  				   const char *name);
-void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
+void pcim_iounmap_regions(struct pci_dev *pdev, int mask);
 
[...]

I'd recommend u32 since it was u16 initially.