mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 2/4] pci: fix DT node matching when reg encodes a non-zero bus number
Date: Thu, 21 May 2026 10:36:56 +0200	[thread overview]
Message-ID: <20260521-pci-of-dynamic-v1-2-951f1878e378@pengutronix.de> (raw)
In-Reply-To: <20260521-pci-of-dynamic-v1-0-951f1878e378@pengutronix.de>

pci_of_match_device() compared (reg[0] >> 8) & 0xffff against devfn, but
devfn is only 8 bits. The standard PCI DT binding encodes the bus number
in bits [23:16] of reg[0], so any child node with a non-zero bus byte -
which is the common upstream convention - yielded (bus << 8) | devfn and
never matched a plain devfn. For a typical host -> root port -> endpoint
DT nesting (e.g. pci@0,0 { reg = <0x300000 ...>; ethernet@0,0 { reg =
<0x310000 ...>; }; }), the root port match failed and scanning never
reached the endpoint, so endpoint properties like local-mac-address were
never picked up.

Mask with 0xff to match only the devfn byte, like Linux's
of_pci_get_devfn().

Assisted-by: Claude Opus 4.7
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 32624fe05b..8d18889109 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -558,7 +558,7 @@ pci_of_match_device(struct device *parent, unsigned int devfn)
 			 * address, other properties are defined by the
 			 * PCI/OF node topology.
 			 */
-			reg = (reg >> 8) & 0xffff;
+			reg = (reg >> 8) & 0xff;
 			if (reg == devfn)
 				return np;
 		}

-- 
2.47.3




  parent reply	other threads:[~2026-05-21  8:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21  8:36 [PATCH 0/4] PCI: populate PCI host controller device nodes Sascha Hauer
2026-05-21  8:36 ` [PATCH 1/4] of: fall back to parent-prefixed encoding when address translation fails Sascha Hauer
2026-05-21  8:36 ` Sascha Hauer [this message]
2026-05-21  8:36 ` [PATCH 3/4] pci: add pci_is_bridge() helper Sascha Hauer
2026-05-21 16:23   ` Bjorn Helgaas
2026-05-21 19:46     ` Sascha Hauer
2026-05-21 20:53       ` Bjorn Helgaas
2026-05-21  8:36 ` [PATCH 4/4] pci: synthesize devicetree nodes for enumerated devices Sascha Hauer

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=20260521-pci-of-dynamic-v1-2-951f1878e378@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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