diff mbox

[U-Boot] pci: fix checking PCI_REGION_MEM in pci_hose_phys_to_bus()

Message ID 1445636881.26450.6.camel@marvell.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Cheng Gu Oct. 23, 2015, 9:48 p.m. UTC
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)

Signed-off-by: Cheng Gu <chenggu@marvell.com>
---
 drivers/pci/pci_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Bin Meng Oct. 25, 2015, 2:36 a.m. UTC | #1
On Sat, Oct 24, 2015 at 5:48 AM, Cheng Gu <chenggu@marvell.com> wrote:
> 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)
>
> Signed-off-by: Cheng Gu <chenggu@marvell.com>
> ---
>  drivers/pci/pci_common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
> index 07f1726..a64792f 100644
> --- a/drivers/pci/pci_common.c
> +++ b/drivers/pci/pci_common.c
> @@ -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)
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tom Rini Nov. 13, 2015, 1:28 a.m. UTC | #2
On Fri, Oct 23, 2015 at 09:48:01PM +0000, Cheng Gu wrote:

> 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)
> 
> Signed-off-by: Cheng Gu <chenggu@marvell.com>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
index 07f1726..a64792f 100644
--- a/drivers/pci/pci_common.c
+++ b/drivers/pci/pci_common.c
@@ -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)