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-kernel@vger.kernel.org
Subject: Re: [PATCH v3 09/11] PCI: endpoint: pci-epf-test: Add smoke test for EPC remote resource API
Date: Wed, 4 Feb 2026 14:37:08 -0500 [thread overview]
Message-ID: <aYOf5DXQjVEpcwCE@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260204145440.950609-10-den@valinux.co.jp>
On Wed, Feb 04, 2026 at 11:54:37PM +0900, Koichiro Den wrote:
> Add a new pci-epf-test command that exercises the newly added EPC API
> pci_epc_get_remote_resources().
>
> The test is intentionally a smoke test. It verifies that the API either
> returns -EOPNOTSUPP or a well-formed resource list (non-zero phys/size
> and known resource types). The result is reported to the host via a
> status bit and an interrupt, consistent with existing pci-epf-test
> commands.
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
> drivers/pci/endpoint/functions/pci-epf-test.c | 88 +++++++++++++++++++
> 1 file changed, 88 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 6952ee418622..6446a0a23865 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -35,6 +35,7 @@
> #define COMMAND_DISABLE_DOORBELL BIT(7)
> #define COMMAND_BAR_SUBRANGE_SETUP BIT(8)
> #define COMMAND_BAR_SUBRANGE_CLEAR BIT(9)
> +#define COMMAND_EPC_API BIT(10)
>
> #define STATUS_READ_SUCCESS BIT(0)
> #define STATUS_READ_FAIL BIT(1)
> @@ -54,6 +55,8 @@
> #define STATUS_BAR_SUBRANGE_SETUP_FAIL BIT(15)
> #define STATUS_BAR_SUBRANGE_CLEAR_SUCCESS BIT(16)
> #define STATUS_BAR_SUBRANGE_CLEAR_FAIL BIT(17)
> +#define STATUS_EPC_API_SUCCESS BIT(18)
> +#define STATUS_EPC_API_FAIL BIT(19)
>
> #define FLAG_USE_DMA BIT(0)
>
> @@ -967,6 +970,87 @@ static void pci_epf_test_bar_subrange_clear(struct pci_epf_test *epf_test,
> reg->status = cpu_to_le32(status);
> }
>
> +static void pci_epf_test_epc_api(struct pci_epf_test *epf_test,
> + struct pci_epf_test_reg *reg)
> +{
> + struct pci_epc_remote_resource *resources = NULL;
> + u32 status = le32_to_cpu(reg->status);
> + struct pci_epf *epf = epf_test->epf;
> + struct device *dev = &epf->dev;
> + struct pci_epc *epc = epf->epc;
> + int num_resources;
> + int ret, i;
> +
> + num_resources = pci_epc_get_remote_resources(epc, epf->func_no,
> + epf->vfunc_no, NULL, 0);
> + if (num_resources == -EOPNOTSUPP || num_resources == 0)
> + goto out_success;
> + if (num_resources < 0)
> + goto err;
> +
> + resources = kcalloc(num_resources, sizeof(*resources), GFP_KERNEL);
use auto cleanup
struct pci_epc_remote_resource *resources __free(kfree) =
kcalloc(num_resources, sizeof(*resources), GFP_KERNEL);
> + if (!resources)
> + goto err;
> +
> + ret = pci_epc_get_remote_resources(epc, epf->func_no, epf->vfunc_no,
> + resources, num_resources);
> + if (ret < 0) {
> + dev_err(dev, "EPC remote resource query failed: %d\n", ret);
> + goto err_free;
> + }
> + if (ret > num_resources) {
> + dev_err(dev, "EPC API returned %d resources (max %d)\n",
> + ret, num_resources);
> + goto err_free;
> + }
> +
> + for (i = 0; i < ret; i++) {
> + struct pci_epc_remote_resource *res = &resources[i];
> +
> + if (!res->phys_addr || !res->size) {
> + dev_err(dev,
> + "Invalid remote resource[%d] (type=%d phys=%pa size=%llu)\n",
> + i, res->type, &res->phys_addr, res->size);
> + goto err_free;
> + }
> +
> + /* Guard against address overflow */
> + if (res->phys_addr + res->size < res->phys_addr) {
> + dev_err(dev,
> + "Remote resource[%d] overflow (phys=%pa size=%llu)\n",
> + i, &res->phys_addr, res->size);
> + goto err_free;
> + }
> +
> + switch (res->type) {
> + case PCI_EPC_RR_DMA_CTRL_MMIO:
> + /* Generic checks above are sufficient. */
> + break;
> + case PCI_EPC_RR_DMA_CHAN_DESC:
> + /*
> + * hw_chan_id and ep2rc are informational. No extra validation
> + * beyond the generic checks above is needed.
> + */
> + break;
> + default:
> + dev_err(dev, "Unknown remote resource type %d\n", res->type);
> + goto err_free;
can you call subrange to map to one of bar?
Frank
> + }
> + }
> +
> +out_success:
> + kfree(resources);
> + status |= STATUS_EPC_API_SUCCESS;
> + reg->status = cpu_to_le32(status);
> + return;
> +
> +err_free:
> + kfree(resources);
> +err:
> + status |= STATUS_EPC_API_FAIL;
> + reg->status = cpu_to_le32(status);
> +}
> +
> static void pci_epf_test_cmd_handler(struct work_struct *work)
> {
> u32 command;
> @@ -1030,6 +1114,10 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
> pci_epf_test_bar_subrange_clear(epf_test, reg);
> pci_epf_test_raise_irq(epf_test, reg);
> break;
> + case COMMAND_EPC_API:
> + pci_epf_test_epc_api(epf_test, reg);
> + pci_epf_test_raise_irq(epf_test, reg);
> + break;
> default:
> dev_err(dev, "Invalid command 0x%x\n", command);
> break;
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-02-04 19:37 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 14:54 [PATCH v3 00/11] dmaengine, PCI: endpoint: Enable remote use of integrated DesignWare eDMA Koichiro Den
2026-02-04 14:54 ` [PATCH v3 01/11] dmaengine: Add hw_id to dma_slave_caps Koichiro Den
2026-02-04 19:39 ` Frank Li
2026-02-05 6:46 ` Koichiro Den
2026-02-05 16:04 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 02/11] dmaengine: dw-edma: Report channel hw_id in dma_slave_caps Koichiro Den
2026-02-04 14:54 ` [PATCH v3 03/11] dmaengine: dw-edma: Add per-channel interrupt routing control Koichiro Den
2026-02-04 17:42 ` Frank Li
2026-02-05 6:48 ` Koichiro Den
2026-02-05 16:05 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 04/11] dmaengine: Add selfirq callback registration API Koichiro Den
2026-02-04 17:46 ` Frank Li
2026-02-05 6:50 ` Koichiro Den
2026-02-05 16:07 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 05/11] dmaengine: dw-edma: Implement dmaengine selfirq callbacks using interrupt emulation Koichiro Den
2026-02-04 14:54 ` [PATCH v3 06/11] PCI: endpoint: Add remote resource query API Koichiro Den
2026-02-04 17:55 ` Frank Li
2026-02-05 6:53 ` Koichiro Den
2026-02-05 16:10 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 07/11] PCI: dwc: Record integrated eDMA register window Koichiro Den
2026-02-04 17:57 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 08/11] PCI: dwc: ep: Report integrated DWC eDMA remote resources Koichiro Den
2026-02-04 18:06 ` Frank Li
2026-02-05 6:58 ` Koichiro Den
2026-02-05 16:11 ` Frank Li
2026-02-04 14:54 ` [PATCH v3 09/11] PCI: endpoint: pci-epf-test: Add smoke test for EPC remote resource API Koichiro Den
2026-02-04 19:37 ` Frank Li [this message]
2026-02-05 7:01 ` Koichiro Den
2026-02-05 0:01 ` kernel test robot
2026-02-05 2:37 ` kernel test robot
2026-02-04 14:54 ` [PATCH v3 10/11] misc: pci_endpoint_test: Add EPC remote resource API test ioctl Koichiro Den
2026-02-04 14:54 ` [PATCH v3 11/11] selftests: pci_endpoint: Add EPC remote resource API test 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=aYOf5DXQjVEpcwCE@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-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