linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wasim Khan <wasim.khan@oss.nxp.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wasim Khan <wasim.khan@nxp.com>
Subject: [PATCH] PCI : check if type 0 devices have all BARs of size zero
Date: Fri, 12 Feb 2021 11:08:56 +0100	[thread overview]
Message-ID: <20210212100856.473415-1-wasim.khan@oss.nxp.com> (raw)

From: Wasim Khan <wasim.khan@nxp.com>

Log a message if all BARs of type 0 devices are of
size zero. This can help detecting type 0 devices
not reporting BAR size correctly.

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
---
 drivers/pci/probe.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 953f15abc850..6438d6d56777 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -321,6 +321,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 {
 	unsigned int pos, reg;
+	bool found = false;
 
 	if (dev->non_compliant_bars)
 		return;
@@ -333,8 +334,12 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 		struct resource *res = &dev->resource[pos];
 		reg = PCI_BASE_ADDRESS_0 + (pos << 2);
 		pos += __pci_read_base(dev, pci_bar_unknown, res, reg);
+		found |= res->flags ? 1 : 0;
 	}
 
+	if (!dev->hdr_type && !found)
+		pci_info(dev, "BAR size is 0 for BAR[0..%d]\n", howmany - 1);
+
 	if (rom) {
 		struct resource *res = &dev->resource[PCI_ROM_RESOURCE];
 		dev->rom_base_reg = rom;
-- 
2.25.1


             reply	other threads:[~2021-02-12 10:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12 10:08 Wasim Khan [this message]
2021-02-15 21:13 ` Bjorn Helgaas
2021-02-16  7:52   ` Wasim Khan
2021-02-16 14:16     ` Bjorn Helgaas

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=20210212100856.473415-1-wasim.khan@oss.nxp.com \
    --to=wasim.khan@oss.nxp.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=wasim.khan@nxp.com \
    --subject='Re: [PATCH] PCI : check if type 0 devices have all BARs of size zero' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).