From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26AC8EDEBF1 for ; Tue, 3 Mar 2026 21:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=u5gz69pmhzjmRZpylNGCvi1lLrKWsJozoNBksTBcXRY=; b=Iea47/NCZwX7Lu dozyB4tJ4wTiyfWgDKQMJwEtzFClawx0LfCp9/ddCFkPPe+q2e0xPAQEBM5ws2HnvM3LGS9TXylM3 e+aVfMg2WZE+IeizThr50xt4bcVNjoKzoFSqUzmZW/59XFkWw++ozmD7CtMRYQVI85FIZu7ZOuCB9 DGoId4lrkcmwT4Ni1rmY//5gK0g5KDwlE4py0lMa7jO83KNIY4MGPXuo9Z6xTiNKHSypyRc9FOYt7 psgW55GGgdoQkOWWPdqYcCbyZpeeg9pUKkgRw5AR7fcJAaUb14pTWJe9iLDZQQ2M0UzLGU4U8blgT DG0gNNRrwGnSU/bq0Jfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxXDa-0000000Fyjk-2PPM; Tue, 03 Mar 2026 21:23:50 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxXDZ-0000000FyjO-0JRN; Tue, 03 Mar 2026 21:23:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 842D760097; Tue, 3 Mar 2026 21:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 063BAC116C6; Tue, 3 Mar 2026 21:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772573027; bh=YcSocgznECK+o/we3yUad/E/8vBVLRMAT3MtSKO/W30=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fOz+tlnehFyphQ/3M8Tq4w8E8RjCKOAmlOHznFurSZzI28e4zpb+I/DjpUwHK6V/t p4es7NsaKNZLBR/kCVeLyB2qRiidgk4hQ6ULh7H4jEUY9WTvQXv8YyTdofb9hK/fwi xMxbkCaJcBNM215s0ByGjA9DI9Y9kqxOGgxcvKFOyLzaxsqSdUnkG4AYP0BplKyt1K lwDXfKxyHc1Re2XoPas1d12x8beCocMwIsV3vE7rd9HI1zmsaWO7WqZCneKIDIZNP9 jb8peg9LuPnlMH/rfiqZ+LoKXp9iZeJYix8ShkoUDlBcF1it2f4T1FwytRt/26xzdj yFQqhXNp3aR+g== Date: Tue, 3 Mar 2026 15:23:45 -0600 From: Bjorn Helgaas To: Caleb James DeLisle Cc: linux-mips@vger.kernel.org, naseefkm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, tsbogend@alpha.franken.de, ryder.lee@mediatek.com, jianjun.wang@mediatek.com, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com, vkoul@kernel.org, neil.armstrong@linaro.org, p.zabel@pengutronix.de, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, nbd@nbd.name, ansuelsmth@gmail.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 7/8] PCI: Skip bridge window reads when window is not supported Message-ID: <20260303212345.GA4074959@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260303190948.694783-8-cjd@cjdns.fr> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 03, 2026 at 07:09:47PM +0000, Caleb James DeLisle wrote: > pci_read_bridge_io() and pci_read_bridge_mmio_pref() read bridge window > registers unconditionally. If the registers are hardwired to zero > (not implemented), both base and limit will be 0. Since (0 <= 0) is > true, a bogus window [mem 0x00000000-0x000fffff] or [io 0x0000-0x0fff] > gets created. > > pci_read_bridge_windows() already detects unsupported windows by > testing register writability and sets io_window/pref_window flags > accordingly. Check these flags at the start of pci_read_bridge_io() > and pci_read_bridge_mmio_pref() to skip reading registers when the > window is not supported. > > Suggested-by: Bjorn Helgaas I think this refers to the conversation at: https://lore.kernel.org/r/20260113210259.GA715789@bhelgaas/ Can you include that URL for reference? > Signed-off-by: Ahmed Naseef > Signed-off-by: Caleb James DeLisle Acked-by: Bjorn Helgaas > --- > drivers/pci/probe.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index bccc7a4bdd79..4eacb741b4ec 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -395,6 +395,9 @@ static void pci_read_bridge_io(struct pci_dev *dev, struct resource *res, > unsigned long io_mask, io_granularity, base, limit; > struct pci_bus_region region; > > + if (!dev->io_window) > + return; > + > io_mask = PCI_IO_RANGE_MASK; > io_granularity = 0x1000; > if (dev->io_window_1k) { > @@ -465,6 +468,9 @@ static void pci_read_bridge_mmio_pref(struct pci_dev *dev, struct resource *res, > pci_bus_addr_t base, limit; > struct pci_bus_region region; > > + if (!dev->pref_window) > + return; > + > pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); > pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo); > base64 = (mem_base_lo & PCI_PREF_RANGE_MASK) << 16; > -- > 2.39.5 >