From: Jim Quinlan <james.quinlan@broadcom.com>
To: linux-pci@vger.kernel.org,
Nicolas Saenz Julienne <nsaenz@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com,
james.quinlan@broadcom.com
Cc: "Florian Fainelli" <florian.fainelli@broadcom.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM
BCM2711/BCM2835 ARM ARCHITECTURE),
linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM
BCM2711/BCM2835 ARM ARCHITECTURE),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 12/13] PCI: brcmstb: Use order-0 indexing for inbound BAR window array
Date: Fri, 11 Sep 2026 19:35:37 -0400 [thread overview]
Message-ID: <20260911233541.1650895-13-james.quinlan@broadcom.com> (raw)
In-Reply-To: <20260911233541.1650895-1-james.quinlan@broadcom.com>
The register names for the inbound BAR registers use order-1 indexing,
e.g. the first is BAR1. The code followed this nomenclature by not using
the 0th element of the inbound array.
Undo this approach and use order-0 indexing. Also use a struct pointer
variable in two functions instead of array indexing.
Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
---
drivers/pci/controller/pcie-brcmstb.c | 49 ++++++++++++---------------
1 file changed, 21 insertions(+), 28 deletions(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 8bca98e6f5fa..53984cfa2c96 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -954,8 +954,8 @@ static void add_inbound_win(struct inbound_win *b, u8 *count, u64 size,
(*count)++;
}
-static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
- struct inbound_win inbound_wins[])
+static int brcm_pcie_get_ib_wins(struct brcm_pcie *pcie,
+ struct inbound_win *ib_win)
{
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
u64 pci_offset, cpu_addr, size = 0, tot_size = 0;
@@ -965,13 +965,6 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
int ret, i = 0;
u8 n = 0;
- /*
- * The HW registers (and PCIe) use order-1 numbering for BARs. As such,
- * we have inbound_wins[0] unused and BAR1 starts at inbound_wins[1].
- */
- struct inbound_win *b_begin = &inbound_wins[1];
- struct inbound_win *b = b_begin;
-
/*
* STB chips beside 7712 disable the first inbound window default.
* Rather being mapped to system memory it is mapped to the
@@ -980,7 +973,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
* SoCs.
*/
if (pcie->cfg->soc_base != BCM7712)
- add_inbound_win(b++, &n, 0, 0, 0);
+ add_inbound_win(ib_win++, &n, 0, 0, 0);
resource_list_for_each_entry(entry, &bridge->dma_ranges) {
u64 pcie_start = entry->res->start - entry->offset;
@@ -997,7 +990,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
* two.
*/
if (pcie->cfg->soc_base == BCM7712)
- add_inbound_win(b++, &n, size, cpu_start, pcie_start);
+ add_inbound_win(ib_win++, &n, size, cpu_start, pcie_start);
if (n > pcie->cfg->num_inbound_wins)
break;
@@ -1081,44 +1074,44 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
}
/* Enable inbound window 2, the main inbound window for STB chips */
- add_inbound_win(b++, &n, size, cpu_addr, pci_offset);
+ add_inbound_win(ib_win++, &n, size, cpu_addr, pci_offset);
/*
* Disable inbound window 3. On some chips presents the same
* window as #2 but the data appears in a settable endianness.
*/
- add_inbound_win(b++, &n, 0, 0, 0);
+ add_inbound_win(ib_win++, &n, 0, 0, 0);
return n;
}
static u32 brcm_bar_reg_offset(int bar)
{
- if (bar <= 3)
- return PCIE_MISC_RC_BAR1_CONFIG_LO + 8 * (bar - 1);
+ if (bar <= 2)
+ return PCIE_MISC_RC_BAR1_CONFIG_LO + 8 * bar;
else
- return PCIE_MISC_RC_BAR4_CONFIG_LO + 8 * (bar - 4);
+ return PCIE_MISC_RC_BAR4_CONFIG_LO + 8 * (bar - 3);
}
static u32 brcm_ubus_reg_offset(int bar)
{
- if (bar <= 3)
- return PCIE_MISC_UBUS_BAR1_CONFIG_REMAP + 8 * (bar - 1);
+ if (bar <= 2)
+ return PCIE_MISC_UBUS_BAR1_CONFIG_REMAP + 8 * bar;
else
- return PCIE_MISC_UBUS_BAR4_CONFIG_REMAP + 8 * (bar - 4);
+ return PCIE_MISC_UBUS_BAR4_CONFIG_REMAP + 8 * (bar - 3);
}
-static void set_inbound_win_registers(struct brcm_pcie *pcie,
- const struct inbound_win *inbound_wins,
- u8 num_inbound_wins)
+static void brcm_pcie_set_ib_win_registers(struct brcm_pcie *pcie,
+ const struct inbound_win *ib_win,
+ u8 num_inbound_wins)
{
void __iomem *base = pcie->base;
int i;
- for (i = 1; i <= num_inbound_wins; i++) {
- u64 pci_offset = inbound_wins[i].pci_offset;
- u64 cpu_addr = inbound_wins[i].cpu_addr;
- u64 size = inbound_wins[i].size;
+ for (i = 0; i < num_inbound_wins; i++, ib_win++) {
+ u64 pci_offset = ib_win->pci_offset;
+ u64 cpu_addr = ib_win->cpu_addr;
+ u64 size = ib_win->size;
u32 reg_offset = brcm_bar_reg_offset(i);
u32 tmp = lower_32_bits(pci_offset);
@@ -1202,11 +1195,11 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK);
writel(tmp, base + PCIE_MISC_MISC_CTRL);
- num_inbound_wins = brcm_pcie_get_inbound_wins(pcie, inbound_wins);
+ num_inbound_wins = brcm_pcie_get_ib_wins(pcie, inbound_wins);
if (num_inbound_wins < 0)
return num_inbound_wins;
- set_inbound_win_registers(pcie, inbound_wins, num_inbound_wins);
+ brcm_pcie_set_ib_win_registers(pcie, inbound_wins, num_inbound_wins);
if (!brcm_pcie_rc_mode(pcie)) {
dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n");
--
2.34.1
next prev parent reply other threads:[~2026-09-11 23:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 23:35 [PATCH 00/13] PCI: brcmstb: Stop using chip numbers for conditions Jim Quinlan
2026-09-11 23:35 ` [PATCH 01/13] PCI: brcmstb: Remove redundant const specifier for struct fields Jim Quinlan
2026-09-11 23:35 ` [PATCH 02/13] PCI: brcmstb: Use flags u32 instead of bools Jim Quinlan
2026-09-11 23:35 ` [PATCH 03/13] PCI: brcmstb: Add Broadcom quirks macro Jim Quinlan
2026-09-11 23:35 ` [PATCH 04/13] PCI: brcmstb: Declare and assign quirk OB_WIN_32BIT_ADDR Jim Quinlan
2026-09-11 23:35 ` [PATCH 05/13] PCI: brcmstb: Declare and assign quirk OB_WIN_MAXSZ_128MB Jim Quinlan
2026-09-11 23:35 ` [PATCH 06/13] PCI: brcmstb: Declare and assign flag IS_BMIPS Jim Quinlan
2026-09-11 23:35 ` [PATCH 07/13] PCI: brcmstb: Declare and assign quirk 32BIT_PCI_OPS Jim Quinlan
2026-09-11 23:35 ` [PATCH 08/13] PCI: brcmstb: Declare and assign quirk NO_RGR1_TIMER Jim Quinlan
2026-09-11 23:35 ` [PATCH 09/13] PCI: brcmstb: Declare and assign quirk EARLY_PERST_ASSERT Jim Quinlan
2026-09-11 23:35 ` [PATCH 10/13] PCI: brcmstb: Declare and assign quirk PERST_PCIE_REV_CUTOFF Jim Quinlan
2026-09-11 23:35 ` [PATCH 11/13] PCI: brcmstb: Put max_burst_size setting in cfg_data Jim Quinlan
2026-09-11 23:35 ` Jim Quinlan [this message]
2026-09-11 23:35 ` [PATCH 13/13] PCI: brcmstb: Split up complicated function into two variants Jim Quinlan
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=20260911233541.1650895-13-james.quinlan@broadcom.com \
--to=james.quinlan@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=jim2101024@gmail.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=nsaenz@kernel.org \
--cc=robh@kernel.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