public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: endpoint: Clarify pci_epc_set_bar() lifetime rules
@ 2026-01-31 13:36 Koichiro Den
  2026-01-31 13:36 ` [PATCH 1/3] PCI: dwc: ep: Return after clearing BAR-match inbound mapping Koichiro Den
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Koichiro Den @ 2026-01-31 13:36 UTC (permalink / raw)
  To: mani, cassel, kwilczynski, kishon, bhelgaas, corbet, jingoohan1,
	lpieralisi, robh, Frank.Li
  Cc: linux-pci, linux-doc, linux-kernel

Hi,

This patch series is a follow-up to a side discussion that started from
Niklas' comment at:
https://lore.kernel.org/all/aXtrW7viGZfMNZur@ryzen/

That discussion highlighted implicit ownership/lifetime assumptions in
the pci_epc_set_bar() interface: some EPC drivers keep a reference to
the struct pci_epf_bar passed in (and its optional submap array).
Mutating or freeing those objects after a successful pci_epc_set_bar()
can lead to use-after-free or other undefined or hard-to-debug behavior.

This series:
  1) Makes BAR Match vs Address Match teardown in DesignWare EP explicit
     by returning right after clearing a BAR-match inbound mapping.
  2) Fixes pci-epf-test BAR subrange mapping to use a dedicated
     pci_epf_bar instance and to free the allocated submap only after
     restoring the default BAR mapping.
  3) Documents pci_epc_set_bar() caller ownership and lifetime rules.

Base: controller/dwc branch, latest:
commit a24149881558 ("PCI: dwc: ep: Add comment explaining controller level
                      PTM access in multi PF setup")

Thanks,

Koichiro Den (3):
  PCI: dwc: ep: Return after clearing BAR-match inbound mapping
  PCI: endpoint: pci-epf-test: Use dedicated pci_epf_bar for subrange
    mapping
  PCI: endpoint: Document pci_epc_set_bar() caller ownership and
    lifetime rules

 Documentation/PCI/endpoint/pci-endpoint.rst   | 22 +++++++++++++
 .../pci/controller/dwc/pcie-designware-ep.c   |  1 +
 drivers/pci/endpoint/functions/pci-epf-test.c | 32 ++++++-------------
 3 files changed, 33 insertions(+), 22 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-02-02 15:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 13:36 [PATCH 0/3] PCI: endpoint: Clarify pci_epc_set_bar() lifetime rules Koichiro Den
2026-01-31 13:36 ` [PATCH 1/3] PCI: dwc: ep: Return after clearing BAR-match inbound mapping Koichiro Den
2026-01-31 14:25   ` Niklas Cassel
2026-01-31 13:36 ` [PATCH 2/3] PCI: endpoint: pci-epf-test: Use dedicated pci_epf_bar for subrange mapping Koichiro Den
2026-01-31 17:35   ` Niklas Cassel
2026-01-31 13:36 ` [PATCH 3/3] PCI: endpoint: Document pci_epc_set_bar() caller ownership and lifetime rules Koichiro Den
2026-01-31 16:50   ` Niklas Cassel
2026-02-01 15:45     ` Koichiro Den
2026-02-01 21:37       ` Niklas Cassel
2026-02-01 21:59         ` Niklas Cassel
2026-02-02  5:59         ` Koichiro Den
2026-02-02  9:27           ` Niklas Cassel
2026-02-02 15:04             ` Koichiro Den

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox