From: Manikanta Maddireddy <mmaddireddy@nvidia.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Jingoo Han <jingoohan1@gmail.com>,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
Krzysztof Wilczynski <kwilczynski@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Rob Herring <robh@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Jon Hunter <jonathanh@nvidia.com>,
Vidya Sagar <vidyas@nvidia.com>,
Niklas Cassel <cassel@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH 1/3] PCI: dwc: Add Endpoint reinit helper
Date: Mon, 19 Oct 2026 16:45:59 +0530 [thread overview]
Message-ID: <3df397d8-5cec-448e-8dcd-59252ff240d6@nvidia.com> (raw)
In-Reply-To: <dee53d7no6nmzsaousuoqleg6dhigkejvkxmpyihc4v4piipwt@opa366n2sakq>
On 17/10/26 2:57 pm, Manivannan Sadhasivam wrote:
> On Wed, Sep 23, 2026 at 12:55:52PM +0530, Manikanta Maddireddy wrote:
>> Endpoint controllers can receive a fundamental reset while software
>> resources such as eDMA, debugfs and function state must live for the
>> controller lifetime.
>>
>> Track whether DWC Endpoint resources are initialized and add helpers
>> that perform full initialization once, then reinitialize only reset-lost
>> registers on later fundamental reset cycles.
>>
>> A fundamental reset also clears outbound iATU programming. Clear the
>> cached outbound window map, outbound address array and MSI iATU cache
>> before reinitializing registers so stale software state cannot hide a
>> window that was reset by hardware.
>>
>> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
>> ---
>> .../pci/controller/dwc/pcie-designware-ep.c | 152 +++++++++++++-----
>> drivers/pci/controller/dwc/pcie-designware.h | 13 ++
>> 2 files changed, 124 insertions(+), 41 deletions(-)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
>> index de8ee3db4360..7ba40220b821 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
>> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
>> @@ -1155,6 +1155,28 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
>> }
>> EXPORT_SYMBOL_GPL(dw_pcie_ep_raise_msix_irq);
>>
>> +static void dw_pcie_ep_clear_msi_iatu(struct dw_pcie_ep *ep)
>> +{
>> + ep->msi_iatu_mapped = false;
>> + ep->msi_iatu_mapped_offset = 0;
>> + ep->msi_msg_addr = 0;
>> + ep->msi_map_size = 0;
>> +}
>> +
>> +static void dw_pcie_ep_clear_outbound_atus(struct dw_pcie_ep *ep)
>> +{
>
> I don't think this function clears the OB iATU mappings. It is done in
> dw_pcie_ep_unmap_addr().
>
Correct, this helper only resets the software bookkeeping after a
fundamental reset has cleared the hardware iATU configuration. It does
not disable live mappings. I’ll rename it to
dw_pcie_ep_reset_outbound_state() and clarify that prerequisite in the
comment and commit message.
>> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>> +
>> + if (ep->ob_window_map)
>> + bitmap_zero(ep->ob_window_map, pci->num_ob_windows);
>> +
>> + if (ep->outbound_addr)
>> + memset(ep->outbound_addr, 0,
>> + pci->num_ob_windows * sizeof(*ep->outbound_addr));
>> +
>> + dw_pcie_ep_clear_msi_iatu(ep);
>> +}
>> +
>> /**
>> * dw_pcie_ep_cleanup - Cleanup DWC EP resources after fundamental reset
>> * @ep: DWC EP device
>> @@ -1169,11 +1191,12 @@ void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
>>
>> if (ep->msi_iatu_mapped) {
>> dw_pcie_ep_unmap_addr(ep->epc, 0, 0, ep->msi_mem_phys);
>> - ep->msi_iatu_mapped = false;
>> + dw_pcie_ep_clear_msi_iatu(ep);
>> }
>>
>> dwc_pcie_debugfs_deinit(pci);
>> dw_pcie_edma_remove(pci);
>> + ep->resources_initialized = false;
>> }
>> EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup);
>>
>> @@ -1307,6 +1330,89 @@ static void dw_pcie_ep_disable_bars(struct dw_pcie_ep *ep)
>> }
>> }
>>
>> +static void dw_pcie_ep_init_ptm(struct dw_pcie_ep *ep)
>> +{
>> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>> + u32 ptm_cap_base, reg;
>> +
>> + /*
>> + * PCIe r6.0, section 7.9.15 states that for endpoints that support
>> + * PTM, this capability structure is required in exactly one
>> + * function, which controls the PTM behavior of all PTM capable
>> + * functions. This indicates the PTM capability structure
>> + * represents controller-level registers rather than per-function
>> + * registers.
>> + *
>> + * Therefore, PTM capability registers are configured using the
>> + * standard DBI accessors, instead of func_no indexed per-function
>> + * accessors.
>> + */
>> + ptm_cap_base = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_PTM);
>> +
>> + /*
>> + * PTM responder capability can be disabled only after disabling
>> + * PTM root capability.
>> + */
>> + if (ptm_cap_base) {
>> + dw_pcie_dbi_ro_wr_en(pci);
>> + reg = dw_pcie_readl_dbi(pci, ptm_cap_base + PCI_PTM_CAP);
>> + reg &= ~PCI_PTM_CAP_ROOT;
>> + dw_pcie_writel_dbi(pci, ptm_cap_base + PCI_PTM_CAP, reg);
>> +
>> + reg = dw_pcie_readl_dbi(pci, ptm_cap_base + PCI_PTM_CAP);
>> + reg &= ~(PCI_PTM_CAP_RES | PCI_PTM_GRANULARITY_MASK);
>> + dw_pcie_writel_dbi(pci, ptm_cap_base + PCI_PTM_CAP, reg);
>> + dw_pcie_dbi_ro_wr_dis(pci);
>> + }
>> +}
>> +
>> +/**
>> + * dw_pcie_ep_reinit_registers - Reinitialize DWC EP reset-lost registers
>> + * @ep: DWC EP device
>> + *
>> + * Reinitialize the EP registers lost after a fundamental reset without
>> + * reallocating EP resources that live until dw_pcie_ep_deinit(). The
>> + * caller must only use this after hardware has reset the iATU; this
>> + * helper invalidates software iATU state but does not disable live
>> + * windows.
>> + */
>> +int dw_pcie_ep_reinit_registers(struct dw_pcie_ep *ep)
>> +{
>> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>> + int ret;
>> +
>> + dw_pcie_ep_clear_outbound_atus(ep);
>> +
>> + if (ep->ops->init) {
>> + ret = ep->ops->init(ep);
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + dw_pcie_ep_disable_bars(ep);
>> + dw_pcie_ep_init_ptm(ep);
>> + dw_pcie_ep_init_non_sticky_registers(pci);
>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(dw_pcie_ep_reinit_registers);
>> +
>> +/**
>> + * dw_pcie_ep_init_or_reinit_registers - Initialize or reinitialize DWC EP
>> + * @ep: DWC EP device
>> + *
>> + * Initialize DWC EP resources on first use. If resources are already
>> + * initialized, reinitialize only the reset-lost registers.
>> + */
>> +int dw_pcie_ep_init_or_reinit_registers(struct dw_pcie_ep *ep)
>> +{
>
> This function name looks awkward. Can you fold it inside
> dw_pcie_ep_init_registers() instead?
>
> - Mani
>
Agreed. I’ll move the selection into dw_pcie_ep_init_registers() and
keep the register restoration helper internal. Tegra can then retain its
existing initialization call and omit the full cleanup on each PERST# cycle.
- Manikanta
--
nvpublic
next prev parent reply other threads:[~2026-10-19 11:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 7:25 [PATCH 0/3] PCI: dwc: Avoid full EP cleanup on PERST# Manikanta Maddireddy
2026-09-23 7:25 ` [PATCH 1/3] PCI: dwc: Add Endpoint reinit helper Manikanta Maddireddy
2026-10-17 9:27 ` Manivannan Sadhasivam
2026-10-19 11:15 ` Manikanta Maddireddy [this message]
2026-09-23 7:25 ` [PATCH 2/3] PCI: tegra194: Avoid full Endpoint reinit on PERST# Manikanta Maddireddy
2026-10-17 9:17 ` Manivannan Sadhasivam
2026-10-19 11:17 ` Manikanta Maddireddy
2026-09-23 7:25 ` [PATCH 3/3] PCI: tegra194: Notify Endpoint functions on PERST# assert Manikanta Maddireddy
2026-10-17 9:22 ` Manivannan Sadhasivam
2026-10-19 11:19 ` Manikanta Maddireddy
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=3df397d8-5cec-448e-8dcd-59252ff240d6@nvidia.com \
--to=mmaddireddy@nvidia.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=jingoohan1@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.