Skip to contentSkip to conversation

pci: Avoid assigning PCI resources that are below 0x1000

PATCH New Bin Meng 2 participants 4 messages Jun 5, 2019 PCI

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 pci: Avoid assigning PCI resources that are below 0x1000

commit b7598a43f2b4 ("[PATCH] Avoid assigning PCI resources from zero address") only moved the bus lower address to 0x1000 if the given bus start address is zero. The comment said 0x1000 is a reasonable starting value, hence we'd better apply the same adjustment when the given bus start address is below 0x1000.

---

 drivers/pci/pci_auto_common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci_auto_common.c +5 -2
index 1837873..3ff42f2 100644
@@ -21,9 +21,12 @@ void pciauto_region_init(struct pci_region *res)
 	/*
 	 * Avoid allocating PCI resources from address 0 -- this is illegal
 	 * according to PCI 2.1 and moreover, this is known to cause Linux IDE
-	 * drivers to fail. Use a reasonable starting value of 0x1000 instead.
+	 * drivers to fail. Use a reasonable starting value of 0x1000 instead
+	 * if the bus start address is below 0x1000.
 	 */
-	res->bus_lower = res->bus_start ? res->bus_start : 0x1000;
+	if (res->bus_start < 0x1000)
+		res->bus_start = 0x1000;
+	res->bus_lower = res->bus_start;
 }
 
 void pciauto_region_align(struct pci_region *res, pci_size_t size)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 pci: Avoid assigning PCI resources that are below 0x1000

Quoted 22 lines · Bin Meng

commit b7598a43f2b4 ("[PATCH] Avoid assigning PCI resources from zero address") only moved the bus lower address to 0x1000 if the given bus start address is zero. The comment said 0x1000 is a reasonable starting value, hence we'd better apply the same adjustment when the given bus start address is below 0x1000.

---

  drivers/pci/pci_auto_common.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci_auto_common.c +0 -1
index 1837873..3ff42f2 100644
@@ -21,9 +21,12 @@ void pciauto_region_init(struct pci_region *res)
  	/*
  	 * Avoid allocating PCI resources from address 0 -- this is illegal
  	 * according to PCI 2.1 and moreover, this is known to cause Linux IDE
-	 * drivers to fail. Use a reasonable starting value of 0x1000 instead.

drivers/pci/pci_auto_common.c void pciauto_region_init(struct pci_region *res) · line 32

Quoted 10 lines
drivers/pci/pci_auto_common.c +5 -1
+	 * drivers to fail. Use a reasonable starting value of 0x1000 instead
+	 * if the bus start address is below 0x1000.
  	 */
-	res->bus_lower = res->bus_start ? res->bus_start : 0x1000;
+	if (res->bus_start < 0x1000)
+		res->bus_start = 0x1000;
+	res->bus_lower = res->bus_start;
  }
 
  void pciauto_region_align(struct pci_region *res, pci_size_t size)

Thanks,
Stefan

author
#2 lore raw

PATCH 1/1 pci: Avoid assigning PCI resources that are below 0x1000

Hi Stefan,

Quoted 32 lines · Stefan Roese
Quoted 30 lines · Bin Meng

commit b7598a43f2b4 ("[PATCH] Avoid assigning PCI resources from zero address") only moved the bus lower address to 0x1000 if the given bus start address is zero. The comment said 0x1000 is a reasonable starting value, hence we'd better apply the same adjustment when the given bus start address is below 0x1000.

---

  drivers/pci/pci_auto_common.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci_auto_common.c +5 -2
index 1837873..3ff42f2 100644
@@ -21,9 +21,12 @@ void pciauto_region_init(struct pci_region *res)
      /*
       * Avoid allocating PCI resources from address 0 -- this is illegal
       * according to PCI 2.1 and moreover, this is known to cause Linux IDE
-      * drivers to fail. Use a reasonable starting value of 0x1000 instead.
+      * drivers to fail. Use a reasonable starting value of 0x1000 instead
+      * if the bus start address is below 0x1000.
       */
-     res->bus_lower = res->bus_start ? res->bus_start : 0x1000;
+     if (res->bus_start < 0x1000)
+             res->bus_start = 0x1000;
+     res->bus_lower = res->bus_start;
  }
 
Quoted 5 lines

drivers/pci/pci_auto_common.c void pciauto_region_init(struct pci_region *res) · line 32

Quoted 2 lines
drivers/pci/pci_auto_common.c +0 -0
  void pciauto_region_align(struct pci_region *res, pci_size_t size)

Thanks for the review. I just re-considered it a little bit, and thought that we should not change res->bus_start here, as the original logic did not change too. I will send a v2.

Regards,
Bin

#3 lore raw

PATCH 1/1 pci: Avoid assigning PCI resources that are below 0x1000

Hi Bin,

Quoted 41 lines · Bin Meng

Hi Stefan,

Quoted 32 lines · Stefan Roese
Quoted 30 lines · Bin Meng

commit b7598a43f2b4 ("[PATCH] Avoid assigning PCI resources from zero address") only moved the bus lower address to 0x1000 if the given bus start address is zero. The comment said 0x1000 is a reasonable starting value, hence we'd better apply the same adjustment when the given bus start address is below 0x1000.

---

   drivers/pci/pci_auto_common.c | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci_auto_common.c +5 -2
index 1837873..3ff42f2 100644
@@ -21,9 +21,12 @@ void pciauto_region_init(struct pci_region *res)
       /*
        * Avoid allocating PCI resources from address 0 -- this is illegal
        * according to PCI 2.1 and moreover, this is known to cause Linux IDE
-      * drivers to fail. Use a reasonable starting value of 0x1000 instead.
+      * drivers to fail. Use a reasonable starting value of 0x1000 instead
+      * if the bus start address is below 0x1000.
        */
-     res->bus_lower = res->bus_start ? res->bus_start : 0x1000;
+     if (res->bus_start < 0x1000)
+             res->bus_start = 0x1000;
+     res->bus_lower = res->bus_start;
   }
 
Quoted 5 lines

drivers/pci/pci_auto_common.c void pciauto_region_init(struct pci_region *res) · line 32

Quoted 2 lines
drivers/pci/pci_auto_common.c +0 -0
   void pciauto_region_align(struct pci_region *res, pci_size_t size)
Quoted 3 lines

Thanks for the review. I just re-considered it a little bit, and thought that we should not change res->bus_start here, as the original logic did not change too. I will send a v2.

Even better. I was a bit reluctant when I saw this change, but trusted you to have thought it through. ;)

BTW: Where did you spot a problem with the current implementation? What issue did hit you exactly?

Thanks,
Stefan