public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 10/29] pci: Adjust dm_pci_read_bar32() to return errors correctly
Date: Wed, 8 Apr 2020 19:58:23 +0300	[thread overview]
Message-ID: <20200408165823.GI3676135@smile.fi.intel.com> (raw)
In-Reply-To: <CAPnjgZ0dCpOY42KJgq+vB=pFX9iii=7iKOXY1UBiT2-n3oDTOA@mail.gmail.com>

On Tue, Apr 07, 2020 at 08:57:20PM -0600, Simon Glass wrote:
> Hi Andy,
> 
> On Fri, 3 Apr 2020 at 05:22, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Mon, Mar 30, 2020 at 05:12:46PM -0600, Simon Glass wrote:
> > > At present if reading a BAR returns 0xffffffff (e.g. the device is not
> > > present) then the value is masked and a different value is returned.
> > > This makes it harder to detect the problem when debugging.
> >
> > The above ('the device is not present') is actually not correct.
> > BAR is not mandatory register and detection is described in PCI spec.
> 
> What change are you suggesting here? I suggest 'not present' as an
> example of why this might happen.

I suggest to follow PCI spec.
Thus, the code below is fragile and working by luck.

> > To get device presence one may have check Vendor ID / Device ID pair rather
> > then BAR.
> >
> > > Update the function to avoid masking in this case.
> > >
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> > > Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
> > > ---
> > >
> > > Changes in v3: None
> > > Changes in v2: None
> > >
> > >  drivers/pci/pci-uclass.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> > > index ceb64517047..d2e10d6868a 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;
> > > --
> > > 2.26.0.rc2.310.g2932bb562d-goog
> > >
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
> >
> >
> 
> Regards,
> Simon

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2020-04-08 16:58 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 23:12 [PATCH v3 00/29] dm: Add programmatic generation of ACPI tables (part A) Simon Glass
2020-03-30 23:12 ` [PATCH v3 01/29] cpu: Support querying the address width Simon Glass
2020-03-30 23:12 ` [PATCH v3 02/29] spi: Add SPI mode enums Simon Glass
2020-03-30 23:12 ` [PATCH v3 03/29] tpm: cr50: Release locality on exit Simon Glass
2020-03-30 23:12 ` [PATCH v3 04/29] tpm: cr50: Add a comment for cr50_priv Simon Glass
2020-03-30 23:12 ` [PATCH v3 05/29] tpm: cr50: Use the correct GPIO binding Simon Glass
2020-03-30 23:12 ` [PATCH v3 06/29] tpm: Don't cleanup unless an error happens Simon Glass
2020-03-30 23:12 ` [PATCH v3 07/29] dm: pci: Allow disabling auto-config for a device Simon Glass
2020-03-30 23:12 ` [PATCH v3 08/29] x86: Correct wording of coreboot source code Simon Glass
2020-03-30 23:12 ` [PATCH v3 09/29] x86: apl: Move p2sb ofdata reading to the correct method Simon Glass
2020-03-30 23:12 ` [PATCH v3 10/29] pci: Adjust dm_pci_read_bar32() to return errors correctly Simon Glass
2020-04-03 11:22   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 16:58       ` Andy Shevchenko [this message]
2020-04-08 22:15         ` Simon Glass
2020-03-30 23:12 ` [PATCH v3 11/29] x86: apl: Add Global NVS table header Simon Glass
2020-03-31  8:07   ` Antwort: " Wolfgang Wallner
2020-04-03 11:25     ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 12/29] dm: core: Add basic ACPI support Simon Glass
2020-03-31  8:16   ` Antwort: " Wolfgang Wallner
2020-04-03 11:35   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 17:01       ` Andy Shevchenko
2020-04-08 22:15         ` Simon Glass
2020-03-30 23:12 ` [PATCH v3 13/29] dts: Add a binding for hid-over-i2c Simon Glass
2020-03-31 19:25   ` Antwort: " Wolfgang Wallner
2020-04-01  7:39     ` Wolfgang Wallner
2020-04-08  2:57       ` Simon Glass
2020-04-08  2:58     ` Simon Glass
2020-04-08 17:08       ` Andy Shevchenko
2020-04-08 19:39         ` Antwort: " Wolfgang Wallner
2020-04-08 20:40           ` Andy Shevchenko
2020-04-08 20:49             ` Andy Shevchenko
2020-04-15 14:00               ` Antwort: Re: " Wolfgang Wallner
2020-04-15 14:25                 ` Andy Shevchenko
2020-04-15 14:57                   ` Antwort: Re: Re: " Wolfgang Wallner
2020-04-15 15:15                     ` Andy Shevchenko
2020-04-15 15:17                       ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 14/29] acpi: Add a binding for ACPI settings in the device tree Simon Glass
2020-04-03 12:42   ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 15/29] acpi: Add a simple sandbox test Simon Glass
2020-04-03 12:51   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 16:57       ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 16/29] x86: Move acpi_s3.h to include/acpi/ Simon Glass
2020-04-03 12:53   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 17:03       ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 17/29] x86: Move acpi_table header to main include/ directory Simon Glass
2020-04-03 12:58   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 17:04       ` Andy Shevchenko
2020-04-08 22:15         ` Simon Glass
2020-03-30 23:12 ` [PATCH v3 18/29] acpi: Add an __ACPI__ preprocessor symbol Simon Glass
2020-03-30 23:12 ` [PATCH v3 19/29] acpi: Add a central location for table version numbers Simon Glass
2020-03-31 19:30   ` Antwort: " Wolfgang Wallner
2020-04-08  2:58     ` Simon Glass
2020-04-03 13:04   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-03-30 23:12 ` [PATCH v3 20/29] acpi: Add support for DMAR Simon Glass
2020-03-31 19:34   ` Antwort: " Wolfgang Wallner
2020-04-03 13:15   ` Andy Shevchenko
2020-03-30 23:12 ` [PATCH v3 21/29] test: Add hexdump.h to the unit test header Simon Glass
2020-04-06 11:53   ` Antwort: " Wolfgang Wallner
2020-03-30 23:12 ` [PATCH v3 22/29] acpi: Add a method to write tables for a device Simon Glass
2020-04-03 13:20   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-03-30 23:12 ` [PATCH v3 23/29] acpi: Convert part of acpi_table to use acpi_ctx Simon Glass
2020-04-03 13:24   ` Andy Shevchenko
2020-04-03 13:25     ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-03-30 23:13 ` [PATCH v3 24/29] x86: Allow devices to write ACPI tables Simon Glass
2020-03-30 23:13 ` [PATCH v3 25/29] acpi: Drop code for missing XSDT from acpi_write_rsdp() Simon Glass
2020-03-30 23:13 ` [PATCH v3 26/29] acpi: Move acpi_add_table() to generic code Simon Glass
2020-03-30 23:13 ` [PATCH v3 27/29] acpi: Put table-setup code in its own function Simon Glass
2020-04-03 13:32   ` Andy Shevchenko
2020-04-08  2:57     ` Simon Glass
2020-04-08 17:11       ` Andy Shevchenko
2020-04-08 19:35         ` Simon Glass
2020-03-30 23:13 ` [PATCH v3 28/29] acpi: Move the xsdt pointer to acpi_ctx Simon Glass
2020-03-30 23:13 ` [PATCH v3 29/29] acpi: Add an acpi command Simon Glass
2020-03-31 18:14   ` Leif Lindholm
2020-04-03 13:41     ` Andy Shevchenko
2020-04-03 13:39   ` Andy Shevchenko
2020-03-31  6:31 ` [PATCH v3 00/29] dm: Add programmatic generation of ACPI tables (part A) Heinrich Schuchardt
2020-04-02  2:34   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200408165823.GI3676135@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox