diff mbox series

[v6,10/29] pci: Adjust dm_pci_read_bar32() to return errors correctly

Message ID 20200409102611.v6.10.I36321d5e30daf051900f01f6289dfc58439871ea@changeid
State Superseded
Headers show
Series None | expand

Commit Message

Simon Glass April 9, 2020, 4:27 p.m. UTC
At present if reading a BAR returns 0xffffffff then the value is masked
and a different value is returned. This makes it harder to detect the
problem when debugging.

Update the function to avoid masking in this case.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
---

Changes in v6:
- Rework commit message to avoid mention of missing device

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/pci/pci-uclass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Simon Glass April 9, 2020, 7:36 p.m. UTC | #1
On Thu, 9 Apr 2020 at 10:28, Simon Glass <sjg at chromium.org> wrote:
>
> At present if reading a BAR returns 0xffffffff then the value is masked
> and a different value is returned. This makes it harder to detect the
> problem when debugging.
>
> Update the function to avoid masking in this case.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
> ---
>
> Changes in v6:
> - Rework commit message to avoid mention of missing device
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/pci/pci-uclass.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Andy let me add your tag based on your email on the other v6 patch.

Reviewed-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Bin Meng April 16, 2020, 5:33 a.m. UTC | #2
On Fri, Apr 10, 2020 at 12:28 AM Simon Glass <sjg at chromium.org> wrote:
>
> At present if reading a BAR returns 0xffffffff then the value is masked
> and a different value is returned. This makes it harder to detect the
> problem when debugging.
>
> Update the function to avoid masking in this case.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
> ---
>
> Changes in v6:
> - Rework commit message to avoid mention of missing device
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/pci/pci-uclass.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 213381da6bd..7f46e901fb2 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1213,7 +1213,14 @@  u32 dm_pci_read_bar32(const struct udevice *dev, int barnum)
 
 	bar = PCI_BASE_ADDRESS_0 + barnum * 4;
 	dm_pci_read_config32(dev, bar, &addr);
-	if (addr & PCI_BASE_ADDRESS_SPACE_IO)
+
+	/*
+	 * If we get an invalid address, return this so that comparisons with
+	 * FDT_ADDR_T_NONE work correctly
+	 */
+	if (addr == 0xffffffff)
+		return addr;
+	else if (addr & PCI_BASE_ADDRESS_SPACE_IO)
 		return addr & PCI_BASE_ADDRESS_IO_MASK;
 	else
 		return addr & PCI_BASE_ADDRESS_MEM_MASK;