Re: [PATCH v10 1/7] PCI: endpoint: Add auxiliary resource query API
Koichiro Den <[email protected]> Mon, 23 Mar 2026 10:34:27 +0900
| Newsgroups | dev.linux.lists.ntb,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <45yj3oztsa4dpy2nyc32td76umhd6dxxkmr5tsqtqvlgy6v4ju@6o4ov7nck7ca> |
On Sat, Mar 21, 2026 at 07:47:32PM +0530, Manivannan Sadhasivam wrote: > On Mon, Mar 02, 2026 at 04:14:21PM +0900, Koichiro Den wrote: > > Endpoint controller drivers may integrate auxiliary blocks (e.g. DMA > > engines) whose register windows and descriptor memories metadata need to > > be exposed to a remote peer. Endpoint function drivers need a generic > > way to discover such resources without hard-coding controller-specific > > helpers. > > > > Add pci_epc_get_aux_resources() and the corresponding pci_epc_ops > > get_aux_resources() callback. The API returns a list of resources > > described by type, physical address and size, plus type-specific > > metadata. > > > > Passing resources == NULL (or num_resources == 0) returns the required > > number of entries. > > > > Reviewed-by: Frank Li <[email protected]> > > Tested-by: Niklas Cassel <[email protected]> > > Signed-off-by: Koichiro Den <[email protected]> > > --- > > drivers/pci/endpoint/pci-epc-core.c | 41 +++++++++++++++++++++++ > > include/linux/pci-epc.h | 52 +++++++++++++++++++++++++++++ > > 2 files changed, 93 insertions(+) > > > > diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c > > index 32cf9a9bc365..d63967622505 100644 > > --- a/drivers/pci/endpoint/pci-epc-core.c > > +++ b/drivers/pci/endpoint/pci-epc-core.c > > @@ -157,6 +157,47 @@ const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, > > } > > EXPORT_SYMBOL_GPL(pci_epc_get_features); > > > > +/** > > + * pci_epc_get_aux_resources() - query EPC-provided auxiliary resources > > + * @epc: EPC device > > + * @func_no: function number > > + * @vfunc_no: virtual function number > > + * @resources: output array (may be NULL to query required count) > > + * @num_resources: size of @resources array in entries (0 when querying count) > > + * > > + * Some EPC backends integrate auxiliary blocks (e.g. DMA engines) whose control > > + * registers and/or descriptor memories can be exposed to the host by mapping > > + * them into BAR space. This helper queries the backend for such resources. > > + * > > + * Return: > > + * * >= 0: number of resources returned (or required, if @resources is NULL) > > + * * -EOPNOTSUPP: backend does not support auxiliary resource queries > > + * * other -errno on failure > > + */ > > +int pci_epc_get_aux_resources(struct pci_epc *epc, u8 func_no, u8 vfunc_no, > > + struct pci_epc_aux_resource *resources, > > + int num_resources) > > +{ > > + int ret; > > + > > + if (!epc || !epc->ops) > > + return -EINVAL; > > + > > + if (func_no >= epc->max_functions) > > + return -EINVAL; > > + > > + if (!epc->ops->get_aux_resources) > > + return -EOPNOTSUPP; > > + > > + mutex_lock(&epc->lock); > > + ret = epc->ops->get_aux_resources(epc, func_no, vfunc_no, resources, > > + num_resources); > > + mutex_unlock(&epc->lock); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(pci_epc_get_aux_resources); > > + > > /** > > * pci_epc_stop() - stop the PCI link > > * @epc: the link of the EPC device that has to be stopped > > diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h > > index 63a24ebf144c..0827650acf93 100644 > > --- a/include/linux/pci-epc.h > > +++ b/include/linux/pci-epc.h > > @@ -61,6 +61,51 @@ struct pci_epc_map { > > void __iomem *virt_addr; > > }; > > > > +/** > > + * enum pci_epc_aux_resource_type - auxiliary resource type identifiers > > + * @PCI_EPC_AUX_DMA_CTRL_MMIO: Integrated DMA controller register window (MMIO) > > + * @PCI_EPC_AUX_DMA_CHAN_DESC: Per-channel DMA descriptor > > + * @PCI_EPC_AUX_DOORBELL_MMIO: Doorbell MMIO, that might be outside the DMA > > + * controller register window > > + * > > + * EPC backends may expose auxiliary blocks (e.g. DMA engines) by mapping their > > + * register windows and descriptor memories into BAR space. This enum > > + * identifies the type of each exposable resource. > > + */ > > +enum pci_epc_aux_resource_type { > > + PCI_EPC_AUX_DMA_CTRL_MMIO, > > + PCI_EPC_AUX_DMA_CHAN_DESC, > > I see that these resources are only used in [1], which is still in early stage. > It'd help if you can just keep DOORBELL_MMIO resource related code in this > series and add these resources when required. Thanks for the suggestion. Agree. I'll drop PCI_EPC_AUX_DMA_CTRL_MMIO and PCI_EPC_AUX_DMA_CHAN_DESC from this series, and add them later when the consumer is in place. Best regards, Koichiro > > - Mani > > [1] https://lore.kernel.org/linux-pci/[email protected] > > -- > மணிவண்ணன் சதாசிவம்