From: Frank Li <Frank.li@nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: vkoul@kernel.org, mani@kernel.org, jingoohan1@gmail.com,
lpieralisi@kernel.org, kwilczynski@kernel.org, robh@kernel.org,
bhelgaas@google.com, dmaengine@vger.kernel.org,
linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 6/9] PCI: dwc: ep: Report integrated eDMA resources via EPC remote-resource API
Date: Fri, 6 Feb 2026 13:06:46 -0500 [thread overview]
Message-ID: <aYYttmm9alHg6LAY@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260206172646.1556847-7-den@valinux.co.jp>
On Sat, Feb 07, 2026 at 02:26:43AM +0900, Koichiro Den wrote:
> Implement pci_epc_ops.get_remote_resources() for DesignWare PCIe
> endpoint controllers with integrated eDMA.
>
> Report:
> - the eDMA controller MMIO window (physical base + size),
> - each non-empty per-channel linked-list region, along with
> per-channel metadata such as the Linux IRQ number and the
> interrupt-emulation doorbell register offset.
>
> This allows endpoint function drivers (e.g. pci-epf-test) to discover
> the eDMA resources and map a suitable doorbell target into BAR space.
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
> .../pci/controller/dwc/pcie-designware-ep.c | 85 +++++++++++++++++++
> 1 file changed, 85 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 7e7844ff0f7e..29dedac86190 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -8,6 +8,7 @@
>
> #include <linux/align.h>
> #include <linux/bitfield.h>
> +#include <linux/dma/edma.h>
> #include <linux/of.h>
> #include <linux/platform_device.h>
>
> @@ -808,6 +809,89 @@ dw_pcie_ep_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
> return ep->ops->get_features(ep);
> }
>
> +static int
> +dw_pcie_ep_get_remote_resources(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
> + struct pci_epc_remote_resource *resources,
> + int num_resources)
> +{
> + struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> + struct dw_edma_chip *edma = &pci->edma;
> + struct dw_edma_chan_info info;
> + int ll_cnt = 0, needed, idx = 0;
> + resource_size_t dma_size;
> + phys_addr_t dma_phys;
> + unsigned int i;
> + int ret;
> +
> + if (!pci->edma_reg_size)
> + return 0;
> +
> + dma_phys = pci->edma_reg_phys;
> + dma_size = pci->edma_reg_size;
> +
> + for (i = 0; i < edma->ll_wr_cnt; i++)
> + if (edma->ll_region_wr[i].sz)
> + ll_cnt++;
> +
> + for (i = 0; i < edma->ll_rd_cnt; i++)
> + if (edma->ll_region_rd[i].sz)
> + ll_cnt++;
> +
> + needed = 1 + ll_cnt;
> +
> + /* Count query mode */
> + if (!resources || !num_resources)
> + return needed;
> +
> + if (num_resources < needed)
> + return -ENOSPC;
> +
> + resources[idx++] = (struct pci_epc_remote_resource) {
> + .type = PCI_EPC_RR_DMA_CTRL_MMIO,
> + .phys_addr = dma_phys,
> + .size = dma_size,
> + };
> +
> + /* One LL region per write channel */
> + for (i = 0; i < edma->ll_wr_cnt; i++) {
> + if (!edma->ll_region_wr[i].sz)
> + continue;
> +
> + ret = dw_edma_chan_info(edma, i, &info);
> + if (ret)
> + return ret;
> +
> + resources[idx++] = (struct pci_epc_remote_resource) {
> + .type = PCI_EPC_RR_DMA_CHAN_DESC,
> + .phys_addr = edma->ll_region_wr[i].paddr,
> + .size = edma->ll_region_wr[i].sz,
> + .u.dma_chan_desc.irq = info.irq,
> + .u.dma_chan_desc.db_offset = info.db_offset,
> + };
> + }
> +
> + /* One LL region per read channel */
> + for (i = 0; i < edma->ll_rd_cnt; i++) {
> + if (!edma->ll_region_rd[i].sz)
> + continue;
> +
> + ret = dw_edma_chan_info(edma, i + edma->ll_wr_cnt, &info);
edma's information is what dw-EP pass to edma driver, supposed dw-ep know
irq and HDMI or EDMA's information, I think needn't go around to EDMA again
to fetch this information back.
Frank
> + if (ret)
> + return ret;
> +
> + resources[idx++] = (struct pci_epc_remote_resource) {
> + .type = PCI_EPC_RR_DMA_CHAN_DESC,
> + .phys_addr = edma->ll_region_rd[i].paddr,
> + .size = edma->ll_region_rd[i].sz,
> + .u.dma_chan_desc.irq = info.irq,
> + .u.dma_chan_desc.db_offset = info.db_offset,
> + };
> + }
> +
> + return idx;
> +}
> +
> static const struct pci_epc_ops epc_ops = {
> .write_header = dw_pcie_ep_write_header,
> .set_bar = dw_pcie_ep_set_bar,
> @@ -823,6 +907,7 @@ static const struct pci_epc_ops epc_ops = {
> .start = dw_pcie_ep_start,
> .stop = dw_pcie_ep_stop,
> .get_features = dw_pcie_ep_get_features,
> + .get_remote_resources = dw_pcie_ep_get_remote_resources,
> };
>
> /**
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-02-06 18:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 17:26 [PATCH v4 0/9] dmaengine, PCI: endpoint: Enable remote use of integrated DesignWare eDMA Koichiro Den
2026-02-06 17:26 ` [PATCH v4 1/9] dmaengine: dw-edma: Add per-channel interrupt routing control Koichiro Den
2026-02-06 17:43 ` Frank Li
2026-02-09 4:06 ` Koichiro Den
2026-02-06 17:26 ` [PATCH v4 2/9] dmaengine: dw-edma: Deassert emulated interrupts in the IRQ handler Koichiro Den
2026-02-06 17:26 ` [PATCH v4 3/9] dmaengine: dw-edma: Export per-channel IRQ and doorbell register offset Koichiro Den
2026-02-06 17:56 ` Frank Li
2026-02-09 4:14 ` Koichiro Den
2026-02-08 8:57 ` kernel test robot
2026-02-06 17:26 ` [PATCH v4 4/9] PCI: endpoint: Add remote resource query API Koichiro Den
2026-02-06 18:01 ` Frank Li
2026-02-07 16:39 ` Koichiro Den
2026-02-10 12:20 ` Niklas Cassel
2026-02-10 14:18 ` Koichiro Den
2026-02-06 17:26 ` [PATCH v4 5/9] PCI: dwc: Record integrated eDMA register window Koichiro Den
2026-02-06 17:26 ` [PATCH v4 6/9] PCI: dwc: ep: Report integrated eDMA resources via EPC remote-resource API Koichiro Den
2026-02-06 18:06 ` Frank Li [this message]
2026-02-07 15:59 ` Koichiro Den
2026-02-06 17:26 ` [PATCH v4 7/9] PCI: endpoint: pci-epf-test: Add embedded doorbell variant Koichiro Den
2026-02-06 19:20 ` Frank Li
2026-02-07 16:25 ` Koichiro Den
2026-02-08 12:35 ` kernel test robot
2026-02-06 17:26 ` [PATCH v4 8/9] misc: pci_endpoint_test: Allow selecting embedded doorbell Koichiro Den
2026-02-06 17:26 ` [PATCH v4 9/9] selftests: pci_endpoint: Exercise MSI and " Koichiro Den
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=aYYttmm9alHg6LAY@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=den@valinux.co.jp \
--cc=dmaengine@vger.kernel.org \
--cc=jingoohan1@gmail.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=vkoul@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 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®