All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Koichiro Den" <den@valinux.co.jp>
Cc: linux-pci@vger.kernel.org, ntb@lists.linux.dev
Subject: Re: [PATCH v8 05/10] PCI: endpoint: pci-epf-vntb: Export endpoint DMA channels
Date: Thu, 22 Oct 2026 08:53:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-181210@kernel.org> (raw)
In-Reply-To: <20261022082230.3164834-6-den@valinux.co.jp>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] PCI: endpoint: pci-epf-vntb: epf_ntb_dma_set_bar() returns 0 when DMA is disabled
--

commit 2da1c2a8d12099e9d914603258e8edaefa818fbc
Author: Koichiro Den <den@valinux.co.jp>

PCI: endpoint: pci-epf-vntb: Export endpoint DMA channels

This commit adds support for exporting endpoint-local eDMA read channels to
the root complex through a configurable dma_bar configfs attribute and a
control-region extension in pci-epf-vntb.

> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index 3adbaa9d85db2..ac83af54122f7 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c

[ ... ]

> +static int epf_ntb_dma_set_bar(struct epf_ntb *ntb)
> +{
> +	struct pci_epf_bar_submap *old_submap;
> +	struct epf_ntb_dma *dma = ntb->dma;
> +	unsigned int old_num_submap;
> +	struct pci_epf_bar *bar;
> +	int restore, ret;
> +
> +	if (!dma)
> +		return 0;
> +
> +	bar = &ntb->epf->bar[ntb->epf_ntb_bar[BAR_DMA]];
> +
> +	old_submap = bar->submap;
> +	old_num_submap = bar->num_submap;
> +	bar->submap = dma->submap;
> +	bar->num_submap = dma->num_submap;
> +
> +	ret = pci_epc_set_bar(ntb->epf->epc, ntb->epf->func_no,
> +			      ntb->epf->vfunc_no, bar);
> +	if (!ret)
> +		return 0;
> +
> +	/* A failed dynamic update may have already removed the old mapping. */
> +	bar->submap = old_submap;
> +	bar->num_submap = old_num_submap;
> +	restore = pci_epc_set_bar(ntb->epf->epc, ntb->epf->func_no,
> +				  ntb->epf->vfunc_no, bar);
> +	if (restore)
> +		dev_warn(&ntb->epf->dev,
> +			 "failed to restore DMA BAR mapping: %d\n", restore);
> +
> +	return ret;
> +}
> +
>  /**
>   * epf_ntb_configure_mw() - Configure the Outbound Address Space for VHOST
>   *   to access the memory window of HOST
> @@ -342,6 +774,11 @@ static void epf_ntb_cmd_handler(struct work_struct *work)
>  		epf_ntb_teardown_mw(ntb, argument);
>  		ctrl->command_status = EPF_NTB_COMMAND_STATUS_OK;
>  		break;
> +	case EPF_NTB_COMMAND_SETUP_DMA_BAR:
> +		ret = epf_ntb_dma_set_bar(ntb);
> +		ctrl->command_status = ret ? EPF_NTB_COMMAND_STATUS_ERROR :
> +					     EPF_NTB_COMMAND_STATUS_OK;
> +		break;

[Severity: Medium]
When dma_bar is left unassigned (NO_BAR), epf_ntb_dma_collect() returns 0
without allocating ntb->dma, leaving ntb->dma as NULL.

If the peer subsequently writes EPF_NTB_COMMAND_SETUP_DMA_BAR to
ctrl->command, epf_ntb_cmd_handler() calls epf_ntb_dma_set_bar(ntb), which
checks if (!dma) and returns 0. epf_ntb_cmd_handler() then sets
ctrl->command_status to EPF_NTB_COMMAND_STATUS_OK even though DMA export is
disabled and no DMA BAR or subrange mapping was configured.

Should epf_ntb_dma_set_bar() in drivers/pci/endpoint/functions/pci-epf-vntb.c
return a negative error code (such as -EINVAL or -EOPNOTSUPP) when ntb->dma
is NULL so that ctrl->command_status is set to EPF_NTB_COMMAND_STATUS_ERROR?

>  	case EPF_NTB_COMMAND_LINK_UP:
>  		ret = epf_ntb_set_link_enabled(ntb, true);
>  		if (ret < 0)

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261022082230.3164834-1-den@valinux.co.jp?part=5

  reply	other threads:[~2026-10-22  8:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  8:22 [PATCH v8 00/10] PCI: endpoint: Remote DMA support via vNTB Koichiro Den
2026-10-22  8:22 ` [PATCH v8 01/10] PCI: endpoint: Add DMA auxiliary resource metadata Koichiro Den
2026-10-22  8:26   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 02/10] PCI: dwc: Expose endpoint DMA resources Koichiro Den
2026-10-22  8:42   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 03/10] PCI: endpoint: pci-epf-vntb: Move epf_ntb_is_bar_used() up Koichiro Den
2026-10-22  8:25   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 04/10] PCI: endpoint: Add pci-epf-ntb.h for the shared NTB control layout Koichiro Den
2026-10-22  8:26   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 05/10] PCI: endpoint: pci-epf-vntb: Export endpoint DMA channels Koichiro Den
2026-10-22  8:53   ` sashiko-bot [this message]
2026-10-22  8:22 ` [PATCH v8 06/10] PCI: endpoint: pci-epf-vntb: Allow DMA and MW to share a BAR Koichiro Den
2026-10-22  8:50   ` sashiko-bot
2026-10-22 15:41   ` Frank Li
2026-10-22  8:22 ` [PATCH v8 07/10] Documentation: PCI: endpoint: Document vNTB DMA export Koichiro Den
2026-10-22  8:27   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 08/10] NTB: ntb_hw_epf: Use the shared NTB control layout Koichiro Den
2026-10-22  8:30   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 09/10] NTB: ntb_hw_epf: Discover vNTB-embedded DMA Koichiro Den
2026-10-22  8:44   ` sashiko-bot
2026-10-22  8:22 ` [PATCH v8 10/10] NTB: ntb_hw_epf: Support DMA and MW sharing a BAR Koichiro Den
2026-10-22  8:34   ` sashiko-bot

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=sashiko-outbox-181210@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=den@valinux.co.jp \
    --cc=linux-pci@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.