From: Aksh Garg <a-garg7@ti.com>
To: Hans Zhang <18255117159@163.com>, <bhelgaas@google.com>,
<lpieralisi@kernel.org>, <kwilczynski@kernel.org>,
<mani@kernel.org>, <s-vadapalli@ti.com>
Cc: <robh@kernel.org>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] PCI: cadence: Add cdns_pcie_get_pcie_cap() helper and cache capability offset
Date: Mon, 11 May 2026 10:28:06 +0530 [thread overview]
Message-ID: <41c7dfa0-493a-4c85-bd71-003a4396426a@ti.com> (raw)
In-Reply-To: <20260509130716.2104103-3-18255117159@163.com>
Hi Hans,
On 09/05/26 18:37, Hans Zhang wrote:
> Add a helper cdns_pcie_get_pcie_cap() that finds and caches the
> PCIe Capability offset in struct cdns_pcie::pcie_cap. This avoids
> repeated searches and follows the pattern used in other PCIe drivers.
>
> The helper uses cdns_pcie_find_capability() to locate PCI_CAP_ID_EXP
> and stores the result for later use.
>
> This is a preparatory step for removing the hardcoded capability
> offset from host driver code.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>
> ---
> drivers/pci/controller/cadence/pcie-cadence.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
> index c057f4b393e6..bbd275193bc1 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence.h
> +++ b/drivers/pci/controller/cadence/pcie-cadence.h
> @@ -219,6 +219,7 @@ struct cdns_plat_pcie_of_data {
> * wrapper
> * @cdns_pcie_reg_offsets: Register bank offsets for different SoC
> * @debug_dir: debugfs node
> + * @pcie_cap: PCIe capability offset
> */
> struct cdns_pcie {
> void __iomem *reg_base;
> @@ -233,6 +234,7 @@ struct cdns_pcie {
> const struct cdns_pcie_ops *ops;
> const struct cdns_plat_pcie_of_data *cdns_pcie_reg_offsets;
> struct dentry *debug_dir;
> + u8 pcie_cap;
> };
>
> /**
> @@ -651,6 +653,22 @@ static inline int cdns_pcie_hpa_ep_setup(struct cdns_pcie_ep *ep)
>
> u8 cdns_pcie_find_capability(struct cdns_pcie *pcie, u8 cap);
> u16 cdns_pcie_find_ext_capability(struct cdns_pcie *pcie, u8 cap);
> +
> +/**
> + * cdns_pcie_get_pcie_cap() - Return cached PCIe Capability offset
> + * @pcie: Cadence PCIe instance
> + *
> + * Finds and caches the offset of PCI_CAP_ID_EXP on first call.
> + * Returns 0 if the capability is not present.
> + */
> +static inline u8 cdns_pcie_get_pcie_cap(struct cdns_pcie *pcie)
> +{
> + if (!pcie->pcie_cap)
> + pcie->pcie_cap = cdns_pcie_find_capability(pcie, PCI_CAP_ID_EXP);
> +
> + return pcie->pcie_cap;
> +}
> +
This function is only used to find, and cache the offset of
PCI_CAP_ID_EXP in pcie->pcie_cap. This is supposed to be called only by
the cdns_pcie_*_setup() during the initialization. After that, whoever
wants to use this cached offset can directly use pcie->pcie->offset
instead of calling this function to return the offset. Hence, this
function can be renamed as 'cdns_pcie_set_pcie_cap', and needs to return
nothing (or can return error if it is unable to find the capability offset).
Regards,
Aksh Garg
> bool cdns_pcie_linkup(struct cdns_pcie *pcie);
>
> void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie);
next prev parent reply other threads:[~2026-05-11 4:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 13:07 [PATCH v2 0/3] PCI: cadence: Fix and generalize PCIe capability offset for Root Port Hans Zhang
2026-05-09 13:07 ` [PATCH v2 1/3] PCI: cadence: Fix Root Port configuration space access for LGA IP Hans Zhang
2026-05-09 13:07 ` [PATCH v2 2/3] PCI: cadence: Add cdns_pcie_get_pcie_cap() helper and cache capability offset Hans Zhang
2026-05-11 4:58 ` Aksh Garg [this message]
2026-05-09 13:07 ` [PATCH v2 3/3] PCI: cadence: Use dynamic PCIe capability offset in host driver Hans Zhang
2026-05-11 4:47 ` Aksh Garg
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=41c7dfa0-493a-4c85-bd71-003a4396426a@ti.com \
--to=a-garg7@ti.com \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=s-vadapalli@ti.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).