From: Bjorn Helgaas <helgaas@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: "Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Jingoo Han" <jingoohan1@gmail.com>,
linux-pci@vger.kernel.org,
"Rick Wertenbroek" <rick.wertenbroek@gmail.com>,
"Niklas Cassel" <cassel@kernel.org>
Subject: Re: [PATCH v6 0/6] Improve PCI memory mapping API
Date: Tue, 22 Oct 2024 15:47:52 -0500 [thread overview]
Message-ID: <20241022204752.GA881656@bhelgaas> (raw)
In-Reply-To: <848f676b-afce-472e-872d-53a32af094c1@kernel.org>
On Tue, Oct 22, 2024 at 10:51:53AM +0900, Damien Le Moal wrote:
> On 10/22/24 07:19, Bjorn Helgaas wrote:
> > On Sat, Oct 12, 2024 at 08:32:40PM +0900, Damien Le Moal wrote:
> >> This series introduces the new functions pci_epc_mem_map() and
> >> pci_epc_mem_unmap() to improve handling of the PCI address mapping
> >> alignment constraints of endpoint controllers in a controller
> >> independent manner.
> >
> > Hi Damien, I know this is obvious to everybody except me, but who
> > uses this mapping? A driver running on the endpoint that does
> > MMIO? DMA (Memory Reads or Writes that target an endpoint BAR)?
> > I'm still trying to wrap my head around the whole endpoint driver
> > model.
>
> The mapping API is for mmio or DMA using endpoint controller memory
> mapped to a host PCI address range. It is not for BARs. BARs setup
> does not use the same API and has not changed with these patches.
>
> BARs can still be accessed on the endpoint (within the EPF driver)
> with regular READ_ONCE()/WRITE_ONCE() once they are set. But any
> data transfer between the PCI RC host and the EPF driver on the EP
> host that use mmio or DMA generic channel (memory copy offload
> channel) needs the new mapping API. DMA transfers that can be done
> using dedicated DMA rx/tx channels associated with the endpoint
> controller do not need to use this API as the mapping to the host
> PCI address space is automatically handled by the DMA driver.
Sorry I'm dense. I'm really not used to thinking in the endpoint
point of view. Correct me where I go off the rails:
- This code (pci_epc_mem_map()) runs on an endpoint, basically as
part of some endpoint firmware, right?
- On the endpoint's PCIe side, it receives memory read/write TLPs?
- These TLPs would be generated elsewhere in the PCIe fabric, e.g.,
by a driver on the host doing MMIO to the endpoint, or possibly
another endpoint doing peer-to-peer DMA.
- Mem read/write TLPs are routed by address, and the endpoint
accepts them if the address matches one of its BARs.
- This is a little different from a Root Complex, which would
basically treat reads/writes to anything outside the Root Port
windows as incoming DMA headed to physical memory.
- A Root Complex would use the TLP address (the PCI bus address)
directly as a CPU physical memory address unless the TLP address
is translated by an IOMMU.
- For the endpoint, you want the BAR to be an aperture to physical
memory in the address space of the SoC driving the endpoint.
- The SoC physical memory address may be different from the PCI but
address in the TLP, and pci_epc_mem_map() is the way to account
for this?
- IOMMU translations from PCI to CPU physical address space are
pretty arbitrary and needn't be contiguous on the CPU side.
- pci_epc_mem_map() sets up a conceptually similar PCI to CPU
address space translation, but it's much simpler because it
basically applies just a constant offset?
next prev parent reply other threads:[~2024-10-22 20:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 11:32 [PATCH v6 0/6] Improve PCI memory mapping API Damien Le Moal
2024-10-12 11:32 ` [PATCH v6 1/6] PCI: endpoint: Introduce pci_epc_function_is_valid() Damien Le Moal
2024-10-12 11:32 ` [PATCH v6 2/6] PCI: endpoint: Improve pci_epc_mem_alloc_addr() Damien Le Moal
2024-10-12 11:32 ` [PATCH v6 3/6] PCI: endpoint: Introduce pci_epc_mem_map()/unmap() Damien Le Moal
2024-10-12 11:47 ` Manivannan Sadhasivam
2024-10-13 9:06 ` Niklas Cassel
2024-10-14 13:09 ` Damien Le Moal
2024-10-15 6:01 ` Manivannan Sadhasivam
2024-10-12 11:32 ` [PATCH v6 4/6] PCI: endpoint: Update documentation Damien Le Moal
2024-10-12 11:48 ` Manivannan Sadhasivam
2024-10-12 11:32 ` [PATCH v6 5/6] PCI: endpoint: test: Use pci_epc_mem_map/unmap() Damien Le Moal
2024-10-12 11:32 ` [PATCH v6 6/6] PCI: dwc: endpoint: Implement the pci_epc_ops::align_addr() operation Damien Le Moal
2024-10-12 11:53 ` Manivannan Sadhasivam
2024-10-12 11:57 ` [PATCH v6 0/6] Improve PCI memory mapping API Manivannan Sadhasivam
2024-10-12 12:03 ` Damien Le Moal
2024-10-21 22:19 ` Bjorn Helgaas
2024-10-22 1:51 ` Damien Le Moal
2024-10-22 8:38 ` Niklas Cassel
2024-10-22 11:57 ` Damien Le Moal
2024-10-22 13:56 ` Manivannan Sadhasivam
2024-10-22 14:16 ` Niklas Cassel
2024-10-22 15:18 ` Frank Li
2024-10-22 15:30 ` Manivannan Sadhasivam
2024-10-22 22:12 ` Damien Le Moal
2024-10-22 20:47 ` Bjorn Helgaas [this message]
2024-10-22 22:05 ` Damien Le Moal
2024-10-22 23:49 ` Bjorn Helgaas
2024-10-23 2:51 ` Damien Le Moal
2024-10-23 9:29 ` 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=20241022204752.GA881656@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=corbet@lwn.net \
--cc=dlemoal@kernel.org \
--cc=jingoohan1@gmail.com \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=rick.wertenbroek@gmail.com \
--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 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.