Skip to contentSkip to conversation

pci: fix checking PCI_REGION_MEM in pci_hose_phys_to_bus()

PATCH In review Cheng Gu 3 participants 3 messages Oct 23, 2015 – Nov 13, 2015 PCI

lore
Share & tools
lore

Cheng Gu

author
#0 lore raw

PATCH 1/1 pci: fix checking PCI_REGION_MEM in pci_hose_phys_to_bus()

When converting between PCI bus and phys addresses, a two pass search was introduced with preference to non-PCI_REGION_SYS_MEMORY regions. See commit 2d43e873a29ca4959ba6a30fc7fb396d3fd0dccf.

However, since PCI_REGION_MEM is defined as 0, the if statement was always asserted true: ((flags & PCI_REGION_MEM) == PCI_REGION_MEM)

This patch uses PCI_REGION_TYPE bit to check if the region is
PCI_REGION_MEM: ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM)

---
 drivers/pci/pci_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci_common.c +2 -2
index 07f1726..a64792f 100644
@@ -231,7 +231,7 @@ phys_addr_t pci_hose_bus_to_phys(struct pci_controller *hose,
 	 * if PCI_REGION_MEM is set we do a two pass search with preference
 	 * on matches that don't have PCI_REGION_SYS_MEMORY set
 	 */
-	if ((flags & PCI_REGION_MEM) == PCI_REGION_MEM) {
+	if ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM) {
 		ret = __pci_hose_bus_to_phys(hose, bus_addr,
 				flags, PCI_REGION_SYS_MEMORY, &phys_addr);
 		if (!ret)
@@ -298,7 +298,7 @@ pci_addr_t pci_hose_phys_to_bus(struct pci_controller *hose,
 	 * if PCI_REGION_MEM is set we do a two pass search with preference
 	 * on matches that don't have PCI_REGION_SYS_MEMORY set
 	 */
-	if ((flags & PCI_REGION_MEM) == PCI_REGION_MEM) {
+	if ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM) {
 		ret = __pci_hose_phys_to_bus(hose, phys_addr,
 				flags, PCI_REGION_SYS_MEMORY, &bus_addr);
 		if (!ret)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 pci: fix checking PCI_REGION_MEM in pci_hose_phys_to_bus()

Quoted 29 lines · Cheng Gu

When converting between PCI bus and phys addresses, a two pass search was introduced with preference to non-PCI_REGION_SYS_MEMORY regions. See commit 2d43e873a29ca4959ba6a30fc7fb396d3fd0dccf.

However, since PCI_REGION_MEM is defined as 0, the if statement was always asserted true: ((flags & PCI_REGION_MEM) == PCI_REGION_MEM)

This patch uses PCI_REGION_TYPE bit to check if the region is
PCI_REGION_MEM: ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM)

---
 drivers/pci/pci_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci_common.c +1 -1
index 07f1726..a64792f 100644
@@ -231,7 +231,7 @@ phys_addr_t pci_hose_bus_to_phys(struct pci_controller *hose,
         * if PCI_REGION_MEM is set we do a two pass search with preference
         * on matches that don't have PCI_REGION_SYS_MEMORY set
         */
-       if ((flags & PCI_REGION_MEM) == PCI_REGION_MEM) {
+       if ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM) {
                ret = __pci_hose_bus_to_phys(hose, bus_addr,
                                flags, PCI_REGION_SYS_MEMORY, &phys_addr);
                if (!ret)

drivers/pci/pci_common.c pci_addr_t pci_hose_phys_to_bus(struct pci_controller *hose,

Quoted 9 lines
drivers/pci/pci_common.c +1 -2
@@ -298,7 +298,7 @@ pci_addr_t pci_hose_phys_to_bus(struct pci_controller *hose,
         * if PCI_REGION_MEM is set we do a two pass search with preference
         * on matches that don't have PCI_REGION_SYS_MEMORY set
         */
-       if ((flags & PCI_REGION_MEM) == PCI_REGION_MEM) {
+       if ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM) {
                ret = __pci_hose_phys_to_bus(hose, phys_addr,
                                flags, PCI_REGION_SYS_MEMORY, &bus_addr);
                if (!ret)
--
#2 lore raw
In reply to Cheng Gu
Quoted 4 lines · Cheng Gu

When converting between PCI bus and phys addresses, a two pass search was introduced with preference to non-PCI_REGION_SYS_MEMORY regions. See commit 2d43e873a29ca4959ba6a30fc7fb396d3fd0dccf.

Quoted 8 lines

However, since PCI_REGION_MEM is defined as 0, the if statement was always asserted true: ((flags & PCI_REGION_MEM) == PCI_REGION_MEM)

This patch uses PCI_REGION_TYPE bit to check if the region is
PCI_REGION_MEM: ((flags & PCI_REGION_TYPE) == PCI_REGION_MEM)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151112/f2d56f41/attachment.sig>