Re: [PATCH v12 1/7] PCI: endpoint: Add auxiliary resource query API
From: Frank Li
Date: Fri Mar 27 2026 - 12:46:17 EST
On Fri, Mar 27, 2026 at 12:54:16PM +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_count_aux_resources() / pci_epc_get_aux_resources() and the
> corresponding pci_epc_ops callbacks. The count helper returns the number
> of available resources via an output parameter, while the get helper
> fills a caller-provided array of resources described by type, physical
> address and size, plus type-specific metadata.
>
> Suggested-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---
> Changes in v12:
> - Add pci_epc_count_aux_resources() and pci_epc_ops.count_aux_resources
> - Use pci_epc_function_is_valid() instead of open-coding
>
> drivers/pci/endpoint/pci-epc-core.c | 83 +++++++++++++++++++++++++++++
> include/linux/pci-epc.h | 53 ++++++++++++++++++
> 2 files changed, 136 insertions(+)
>
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 6c3c58185fc5..fded71a19d71 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -156,6 +156,89 @@ const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc,
> }
> EXPORT_SYMBOL_GPL(pci_epc_get_features);
>
> +/**
> + * pci_epc_count_aux_resources() - count EPC-provided auxiliary resources
> + * @epc: EPC device
> + * @func_no: function number
> + * @vfunc_no: virtual function number
> + * @num_resources: returned number of auxiliary resources
> + *
> + * 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 how many such resources the backend
> + * provides.
> + *
> + * Return: 0 on success, -EOPNOTSUPP if the backend does not support auxiliary
> + * resource queries, or another -errno on failure.
> + */
> +int pci_epc_count_aux_resources(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
> + int *num_resources)
Most like such kinds APIs return count directly,
< 0, means error.
>= 0, means how many resource.
Frank