From: Frank Li <Frank.li@oss.nxp.com>
To: Manikanta Maddireddy <mmaddireddy@nvidia.com>
Cc: mani@kernel.org, kwilczynski@kernel.org,
linux-pci@vger.kernel.org, kishon@kernel.org,
Frank.Li@kernel.org, bhelgaas@google.com, cassel@kernel.org,
den@valinux.co.jp, thierry.reding@kernel.org,
jonathanh@nvidia.com, vidyas@nvidia.com,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] PCI: endpoint: Skip upper halves of 64-bit BARs during search
Date: Mon, 2 Nov 2026 10:03:14 -0600 [thread overview]
Message-ID: <aui0QhcA4iq7J5tY@SMW015318> (raw)
In-Reply-To: <20261102112306.4018464-2-mmaddireddy@nvidia.com>
On Mon, Nov 02, 2026 at 04:53:05PM +0530, Manikanta Maddireddy wrote:
> pci_epc_get_next_free_bar() skips the upper half of a 64-bit BAR only
> when it is the starting BAR. If the search subsequently passes a
> reserved or disabled 64-bit BAR, it can return its upper half as an
> independent BAR because that slot has a default programmable descriptor.
>
> For example, Tegra exposes a programmable 64-bit BAR0 and reserved
> 64-bit BAR2 and BAR4. A search starting at BAR1 skips BAR1 and BAR2,
> then incorrectly returns BAR3. The next search can similarly return
> BAR5, causing the EPF test driver to allocate and program BARs that
> belong to the reserved hardware windows.
>
> Check each candidate's preceding descriptor inside the search loop so
> upper halves are skipped throughout the search. With the Tegra layout,
> BAR0 is the only available BAR and subsequent searches return NO_BAR.
>
> Fixes: 27ce1d8ecb9b ("PCI: endpoint: Allow only_64bit on BAR_RESERVED")
> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes V1 -> V2:
> - Add Fixes: 27ce1d8ecb9b ("PCI: endpoint: Allow only_64bit on BAR_RESERVED")
> following Niklas Cassel's review.
> - Rebase onto the current PCI main-based patch stack.
> - No code changes from v1.
>
> drivers/pci/endpoint/pci-epc-core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 831b40458dcd..8d0df9fc1df9 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -98,11 +98,11 @@ enum pci_barno pci_epc_get_next_free_bar(const struct pci_epc_features
> if (!epc_features)
> return BAR_0;
>
> - /* If 'bar - 1' is a 64-bit BAR, move to the next BAR */
> - if (bar > 0 && epc_features->bar[bar - 1].only_64bit)
> - bar++;
> -
> for (i = bar; i < PCI_STD_NUM_BARS; i++) {
> + /* Skip the upper half of a 64-bit BAR. */
> + if (i > 0 && epc_features->bar[i - 1].only_64bit)
> + continue;
> +
> /* If the BAR is not reserved or disabled, return it. */
> if (epc_features->bar[i].type != BAR_RESERVED &&
> epc_features->bar[i].type != BAR_DISABLED)
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-11-02 16:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 11:23 [PATCH v2 0/2] " Manikanta Maddireddy
2026-11-02 11:23 ` [PATCH v2 1/2] " Manikanta Maddireddy
2026-11-02 15:12 ` Niklas Cassel
2026-11-02 16:03 ` Frank Li [this message]
2026-11-02 11:23 ` [PATCH v2 2/2] PCI: endpoint: Clarify only_64bit for reserved BARs Manikanta Maddireddy
2026-11-02 15:12 ` Niklas Cassel
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=aui0QhcA4iq7J5tY@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=den@valinux.co.jp \
--cc=jonathanh@nvidia.com \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mmaddireddy@nvidia.com \
--cc=thierry.reding@kernel.org \
--cc=vidyas@nvidia.com \
/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
all inboxes | Powered by JetHome®