All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC PATCH v2 20/27] NTB: ntb_transport: Introduce remote eDMA backed transport mode
@ 2025-12-02 20:43 kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2025-12-02 20:43 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251129160405.2568284-21-den@valinux.co.jp>
References: <20251129160405.2568284-21-den@valinux.co.jp>
TO: Koichiro Den <den@valinux.co.jp>

Hi Koichiro,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on pci/next]
[also build test WARNING on next-20251202]
[cannot apply to jonmason-ntb/ntb-next pci/for-linus geert-renesas-devel/next linus/master v6.18]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Koichiro-Den/PCI-endpoint-pci-epf-vntb-Use-array_index_nospec-on-mws_size-access/20251130-001424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20251129160405.2568284-21-den%40valinux.co.jp
patch subject: [RFC PATCH v2 20/27] NTB: ntb_transport: Introduce remote eDMA backed transport mode
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: parisc-randconfig-r063-20251203 (https://download.01.org/0day-ci/archive/20251203/202512030438.hBGwMuy6-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.5.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202512030438.hBGwMuy6-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/ntb/ntb_edma.c:223:8-26: WARNING: dma_alloc_coherent used in info already zeroes out memory, so memset is not needed
>> drivers/ntb/ntb_edma.c:261:8-26: WARNING: dma_alloc_coherent used in intr already zeroes out memory, so memset is not needed
>> drivers/ntb/ntb_edma.c:434:3-21: WARNING: dma_alloc_coherent used in edma_ctx . intr_rc_virt already zeroes out memory, so memset is not needed

vim +223 drivers/ntb/ntb_edma.c

2c52b6a2a63cec4 Koichiro Den 2025-11-30  191  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  192  int ntb_edma_setup_mws(struct ntb_dev *ndev)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  193  {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  194  	const size_t info_bytes = PAGE_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  195  	resource_size_t size_max, offset;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  196  	dma_addr_t intr_phys, info_phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  197  	u32 wr_done = 0, rd_done = 0;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  198  	struct ntb_edma_intr *intr;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  199  	struct ntb_edma_info *info;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  200  	int peer_mw, mw_index, rc;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  201  	struct iommu_domain *dom;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  202  	bool reg_mapped = false;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  203  	size_t ll_bytes, size;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  204  	struct pci_epc *epc;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  205  	struct device *dev;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  206  	unsigned long iova;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  207  	phys_addr_t phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  208  	u64 need;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  209  	u32 i;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  210  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  211  	/* +1 is for interruption */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  212  	ll_bytes = (EDMA_WR_CH_NUM + EDMA_RD_CH_NUM + 1) * DMA_LLP_MEM_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  213  	need = EDMA_REG_SIZE + info_bytes + ll_bytes;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  214  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  215  	epc = ntb_get_pci_epc(ndev);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  216  	if (!epc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  217  		return -ENODEV;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  218  	dev = epc->dev.parent;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  219  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  220  	if (edma_ctx.initialized)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  221  		return 0;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  222  
2c52b6a2a63cec4 Koichiro Den 2025-11-30 @223  	info = dma_alloc_coherent(dev, info_bytes, &info_phys, GFP_KERNEL);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  224  	if (!info)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  225  		return -ENOMEM;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  226  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  227  	memset(info, 0, info_bytes);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  228  	info->magic = NTB_EDMA_INFO_MAGIC;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  229  	info->wr_cnt = EDMA_WR_CH_NUM;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  230  	info->rd_cnt = EDMA_RD_CH_NUM + 1; /* +1 for interruption */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  231  	info->regs_phys = edma_regs_phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  232  	info->ll_stride = DMA_LLP_MEM_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  233  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  234  	for (i = 0; i < EDMA_WR_CH_NUM; i++) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  235  		edma_ctx.ll_wr_virt[i] = dma_alloc_attrs(dev, DMA_LLP_MEM_SIZE,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  236  							 &edma_ctx.ll_wr_phys[i],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  237  							 GFP_KERNEL,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  238  							 DMA_ATTR_FORCE_CONTIGUOUS);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  239  		if (!edma_ctx.ll_wr_virt[i]) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  240  			rc = -ENOMEM;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  241  			goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  242  		}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  243  		wr_done++;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  244  		info->ll_wr_phys[i] = edma_ctx.ll_wr_phys[i];
2c52b6a2a63cec4 Koichiro Den 2025-11-30  245  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  246  	for (i = 0; i < EDMA_RD_CH_NUM + 1; i++) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  247  		edma_ctx.ll_rd_virt[i] = dma_alloc_attrs(dev, DMA_LLP_MEM_SIZE,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  248  							 &edma_ctx.ll_rd_phys[i],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  249  							 GFP_KERNEL,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  250  							 DMA_ATTR_FORCE_CONTIGUOUS);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  251  		if (!edma_ctx.ll_rd_virt[i]) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  252  			rc = -ENOMEM;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  253  			goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  254  		}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  255  		rd_done++;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  256  		info->ll_rd_phys[i] = edma_ctx.ll_rd_phys[i];
2c52b6a2a63cec4 Koichiro Den 2025-11-30  257  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  258  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  259  	/* For interruption */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  260  	edma_ctx.notify_qp_max = NTB_EDMA_NOTIFY_MAX_QP;
2c52b6a2a63cec4 Koichiro Den 2025-11-30 @261  	intr = dma_alloc_coherent(dev, sizeof(*intr), &intr_phys, GFP_KERNEL);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  262  	if (!intr) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  263  		rc = -ENOMEM;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  264  		goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  265  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  266  	memset(intr, 0, sizeof(*intr));
2c52b6a2a63cec4 Koichiro Den 2025-11-30  267  	edma_ctx.intr_ep_virt = intr;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  268  	edma_ctx.intr_ep_phys = intr_phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  269  	info->intr_dar_base = intr_phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  270  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  271  	peer_mw = ntb_peer_mw_count(ndev);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  272  	if (peer_mw <= 0) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  273  		rc = -ENODEV;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  274  		goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  275  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  276  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  277  	mw_index = peer_mw - 1; /* last MW */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  278  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  279  	rc = ntb_mw_get_align(ndev, 0, mw_index, 0, NULL, &size_max,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  280  			      &offset);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  281  	if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  282  		goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  283  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  284  	if (size_max < need) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  285  		rc = -ENOSPC;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  286  		goto err_free_ll;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  287  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  288  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  289  	/* Map register space (direct) */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  290  	dom = iommu_get_domain_for_dev(dev);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  291  	if (dom) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  292  		phys = edma_regs_phys & PAGE_MASK;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  293  		size = PAGE_ALIGN(EDMA_REG_SIZE + edma_regs_phys - phys);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  294  		iova = phys;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  295  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  296  		rc = iommu_map(dom, iova, phys, EDMA_REG_SIZE,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  297  			       IOMMU_READ | IOMMU_WRITE | IOMMU_MMIO, GFP_KERNEL);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  298  		if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  299  			dev_err(&ndev->dev, "failed to create direct mapping for eDMA reg space\n");
2c52b6a2a63cec4 Koichiro Den 2025-11-30  300  		reg_mapped = true;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  301  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  302  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  303  	rc = ntb_mw_set_trans(ndev, 0, mw_index, edma_regs_phys, EDMA_REG_SIZE, offset);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  304  	if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  305  		goto err_unmap_reg;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  306  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  307  	offset += EDMA_REG_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  308  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  309  	/* Map ntb_edma_info */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  310  	rc = ntb_mw_set_trans(ndev, 0, mw_index, info_phys, info_bytes, offset);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  311  	if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  312  		goto err_clear_trans;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  313  	offset += info_bytes;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  314  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  315  	/* Map LL location */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  316  	for (i = 0; i < EDMA_WR_CH_NUM; i++) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  317  		rc = ntb_mw_set_trans(ndev, 0, mw_index, edma_ctx.ll_wr_phys[i],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  318  				      DMA_LLP_MEM_SIZE, offset);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  319  		if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  320  			goto err_clear_trans;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  321  		offset += DMA_LLP_MEM_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  322  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  323  	for (i = 0; i < EDMA_RD_CH_NUM + 1; i++) {
2c52b6a2a63cec4 Koichiro Den 2025-11-30  324  		rc = ntb_mw_set_trans(ndev, 0, mw_index, edma_ctx.ll_rd_phys[i],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  325  				      DMA_LLP_MEM_SIZE, offset);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  326  		if (rc)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  327  			goto err_clear_trans;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  328  		offset += DMA_LLP_MEM_SIZE;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  329  	}
2c52b6a2a63cec4 Koichiro Den 2025-11-30  330  	edma_ctx.initialized = true;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  331  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  332  	return 0;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  333  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  334  err_clear_trans:
2c52b6a2a63cec4 Koichiro Den 2025-11-30  335  	/*
2c52b6a2a63cec4 Koichiro Den 2025-11-30  336  	 * Tear down the NTB translation window used for the eDMA MW.
2c52b6a2a63cec4 Koichiro Den 2025-11-30  337  	 * There is no sub-range clear API for ntb_mw_set_trans(), so we
2c52b6a2a63cec4 Koichiro Den 2025-11-30  338  	 * unconditionally drop the whole mapping on error.
2c52b6a2a63cec4 Koichiro Den 2025-11-30  339  	 */
2c52b6a2a63cec4 Koichiro Den 2025-11-30  340  	ntb_mw_clear_trans(ndev, 0, mw_index);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  341  
2c52b6a2a63cec4 Koichiro Den 2025-11-30  342  err_unmap_reg:
2c52b6a2a63cec4 Koichiro Den 2025-11-30  343  	if (reg_mapped)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  344  		iommu_unmap(dom, iova, size);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  345  err_free_ll:
2c52b6a2a63cec4 Koichiro Den 2025-11-30  346  	while (rd_done--)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  347  		dma_free_attrs(dev, DMA_LLP_MEM_SIZE,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  348  			       edma_ctx.ll_rd_virt[rd_done],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  349  			       edma_ctx.ll_rd_phys[rd_done],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  350  			       DMA_ATTR_FORCE_CONTIGUOUS);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  351  	while (wr_done--)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  352  		dma_free_attrs(dev, DMA_LLP_MEM_SIZE,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  353  			       edma_ctx.ll_wr_virt[wr_done],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  354  			       edma_ctx.ll_wr_phys[wr_done],
2c52b6a2a63cec4 Koichiro Den 2025-11-30  355  			       DMA_ATTR_FORCE_CONTIGUOUS);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  356  	if (edma_ctx.intr_ep_virt)
2c52b6a2a63cec4 Koichiro Den 2025-11-30  357  		dma_free_coherent(dev, sizeof(struct ntb_edma_intr),
2c52b6a2a63cec4 Koichiro Den 2025-11-30  358  				  edma_ctx.intr_ep_virt,
2c52b6a2a63cec4 Koichiro Den 2025-11-30  359  				  edma_ctx.intr_ep_phys);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  360  	dma_free_coherent(dev, info_bytes, info, info_phys);
2c52b6a2a63cec4 Koichiro Den 2025-11-30  361  	return rc;
2c52b6a2a63cec4 Koichiro Den 2025-11-30  362  }
2c52b6a2a63cec4 Koichiro Den 2025-11-30  363  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 19+ messages in thread
* [RFC PATCH v2 00/27] NTB transport backed by remote DW eDMA
@ 2025-11-29 16:03 Koichiro Den
  2025-11-29 16:03 ` [RFC PATCH v2 20/27] NTB: ntb_transport: Introduce remote eDMA backed transport mode Koichiro Den
  0 siblings, 1 reply; 19+ messages in thread
From: Koichiro Den @ 2025-11-29 16:03 UTC (permalink / raw)
  To: ntb, linux-pci, dmaengine, linux-kernel, Frank.Li
  Cc: mani, kwilczynski, kishon, bhelgaas, corbet, vkoul, jdmason,
	dave.jiang, allenbh, Basavaraj.Natikar, Shyam-sundar.S-k,
	kurt.schwemmer, logang, jingoohan1, lpieralisi, robh, jbrunet,
	fancer.lancer, arnd, pstanner, elfring

Hi,

This is RFC v2 of the NTB/PCI series for Renesas R-Car S4. The ultimate
goal is unchanged, i.e. to improve performance between RC and EP
(with vNTB) over ntb_transport, but the approach has changed drastically.
Based on the feedback from Frank Li in the v1 thread, in particular:
https://lore.kernel.org/all/aQEsip3TsPn4LJY9@lizhi-Precision-Tower-5810/
this RFC v2 instead builds an NTB transport backed by remote eDMA
architecture and reshapes the series around it. The RC->EP interruption
is now achieved using a dedicated eDMA read channel, so the somewhat
"hack"-ish approach in RFC v1 is no longer needed.

Compared to RFC v1, this v2 series enables NTB transport backed by
remote DW eDMA, so the current ntb_transport handling of Memory Window
is no longer needed, and direct DMA transfers between EP and RC are
used.

I realize this is quite a large series. Sorry for the volume, but for
the RFC stage I believe presenting the full picture in a single set
helps with reviewing the overall architecture. Once the direction is
agreed, I will respin it split by subsystem and topic.


The new architecture
====================

In the new architecture the endpoint exposes a small memory window that
contains the unrolled DesignWare eDMA register block plus a per-channel
control structure and linked-list rings. The endpoint allocates these in
its own memory, then maps them into a peer MW via an inbound iATU
region. The host maps the peer MW, configures a dw-edma engine to use
the remote rings. The data plane flow is depicted as below (Figure 1 and
Figure 2).

With this design, per-queue PCI memory usage is reduced to control-plane
metadata (ring descriptors and indices). Data buffers live in system
memory and are transferred by the remote eDMA, so even relatively small
BAR windows can theoritically scale to multiple ntb_transport queue
pairs, and it no longer requires the DMA_MEMCPY operation. This series
also adds ntb_netdev multiple queues support to demonstrate performance
improvement.

The shared-memory ntb_transport backend remains the default. The remote
eDMA mode is compile-time and run-time selectable via
CONFIG_NTB_TRANSPORT_EDMA and the new 'use_remote_edma' module
parameter, and existing users that do not enable it should see no
behavioural change apart from the BAR subrange support described below.


    Figure 1. RC->EP traffic via ntb_netdev+ntb_transport
                     backed by Remote eDMA

          EP                                   RC
       phys addr                            phys addr  
         space                                space 
          +-+                                  +-+
          | |                                  | |
          | |                ||                | |
          +-+-----.          ||                | |
 EDMA REG | |      \    [A]  ||                | |
          +-+----.  '---+-+  ||                | |
          | |     \     | |<---------[0-a]----------
          +-+-----------| |<----------[2]----------.
  EDMA LL | |           | |  ||                | | :
          | |           | |  ||                | | :
          +-+-----------+-+  ||  [B]           | | :
          | |                ||  ++            | | :
       ---------[0-b]----------->||----------------'
          | |            ++  ||  ||            | |
          | |            ||  ||  ++            | |
          | |            ||<----------[4]-----------
          | |            ++  ||                | |
          | |           [C]  ||                | |
       .--|#|<------------------------[3]------|#|<-.
       :  |#|                ||                |#|  :
      [5] | |                ||                | | [1]
       :  | |                ||                | |  :
       '->|#|                                  |#|--'
          |#|                                  |#|
          | |                                  | |


      0-a. configure Remote eDMA
      0-b. DMA-map and produce DAR
      1.   memcpy while building skb in ntb_netdev case
      2.   consume DAR, DMA-map SAR and kick DMA read transfer
      3.   DMA read transfer (initiated by RC remotely)
      4.   consume (commit)
      5.   memcpy to application side

      [A]: MemoryWindow that aggregates eDMA regs and LL.
           IB iATU translations (Address Match Mode).
      [B]: Control plane ring buffer (for "produce")
      [C]: Control plane ring buffer (for "consume")


    Figure 2. EP->RC traffic via ntb_netdev+ntb_transport
                     backed by Remote eDMA

          EP                                   RC
       phys addr                            phys addr  
         space                                space 
          +-+                                  +-+
          | |                                  | |
          | |                ||                | |
          +-+-----.          ||                | |
 EDMA REG | |      \    [A]  ||                | |
          +-+----.  '---+-+  ||                | |
          | |     \     | |<----------[0]-----------
          +-+-----------| |<----------[3]----------.
  EDMA LL | |           | |  ||                | | :
          | |           | |  ||                | | :
          +-+-----------+-+  ||  [B]           | | :
          | |                ||  ++            | | :
       -----------[2]----------->||----------------'
          | |            ++  ||  ||            | |
          | |            ||  ||  ++            | |
          | |            ||<----------[5]-----------
          | |            ++  ||                | |
          | |           [C]  ||                | |
       .->|#|--------[4]---------------------->|#|--.
       :  |#|                ||                |#|  :
      [1] | |                ||                | | [6]
       :  | |                ||                | |  :
       '--|#|                                  |#|<-'
          |#|                                  |#|
          | |                                  | |


      0-a. configure Remote eDMA
      1.   memcpy while building skb in ntb_netdev case
      2.   DMA-map SAR and "produce"
      3.   consume SAR, DMA-map DAR and kick DMA write transfer
      4.   DMA write transfer (initiated by RC remotely)
      5.   consume (commit)
      6.   memcpy to application side

      [A]: MemoryWindow that aggregates eDMA regs and LL.
           IB iATU translations (Address Match Mode).
      [B]: Control plane ring buffer (for "produce")
      [C]: Control plane ring buffer (for "consume")


Patch layout
============

  Patch 01-19 : preparation for Patch 20
                - 01-10: support multiple MWs in a BAR
                - 11-19: other misc preparations
  Patch 20    : main and most important patch, adds remote eDMA support
  Patch 21-22 : multi-queue use, thanks to the remote eDMA, performance
                scales
  Patch 23-27 : handle several SoC-specific issues so that remote eDMA
                mode ntb_transport works on R-Car S4


Changelog
=========

RFCv1->RFCv2 changes:
  - Architecture
    - Drop the generic interrupt backend + DW eDMA test-interrupt backend
      approach and instead adopt the remote eDMA-backed ntb_transport mode
      proposed by Frank Li. The BAR-sharing / mwN_offset / inbound
      mapping (Address Match Mode) infrastructure from RFC v1 is largely
      kept, with only minor refinements and code motion where necessary
      to fit the new transport-mode design.
  - For Patch 01
    - Rework the array_index_nospec() conversion to address review
      comments on "[RFC PATCH 01/25]".

RFCv1: https://lore.kernel.org/all/20251023071916.901355-1-den@valinux.co.jp/


Tested on
=========

* 2x Renesas R-Car S4 Spider (RC<->EP connected with OcuLink cable)
* Kernel base: next-20251128


Performance measurement
=======================

No serious measurements yet, because:
  * For "before the change", even use_dma/use_msi does not work on the
    upstream kernel unless we apply some patches for R-Car S4. With some
    unmerged patch series I had posted earlier, it was observed that we
    can achieve about 7 Gbps for the RC->EP direction. Pure upstream
    kernel can achieve around 500 Mbps though.
  * For "after the change", measurements are not mature because this
    RFC v2 patch series is not yet performance-optimized at this stage.
    Also, somewhat unstable behaviour remains around ntb_edma_isr().

Here are the rough measurements showing the achievable performance on
the R-Car S4:

- Before this change:

  * ping
    64 bytes from 10.0.0.11: icmp_seq=1 ttl=64 time=12.3 ms
    64 bytes from 10.0.0.11: icmp_seq=2 ttl=64 time=6.58 ms
    64 bytes from 10.0.0.11: icmp_seq=3 ttl=64 time=1.26 ms
    64 bytes from 10.0.0.11: icmp_seq=4 ttl=64 time=7.43 ms
    64 bytes from 10.0.0.11: icmp_seq=5 ttl=64 time=1.39 ms
    64 bytes from 10.0.0.11: icmp_seq=6 ttl=64 time=7.38 ms
    64 bytes from 10.0.0.11: icmp_seq=7 ttl=64 time=1.42 ms
    64 bytes from 10.0.0.11: icmp_seq=8 ttl=64 time=7.41 ms

  * RC->EP (`sudo iperf3 -ub0 -l 65480 -P 2`)
    [ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
    [  5]   0.00-10.01  sec   344 MBytes   288 Mbits/sec  3.483 ms  51/5555 (0.92%)  receiver
    [  6]   0.00-10.01  sec   342 MBytes   287 Mbits/sec  3.814 ms  38/5517 (0.69%)  receiver
    [SUM]   0.00-10.01  sec   686 MBytes   575 Mbits/sec  3.648 ms  89/11072 (0.8%)  receiver

  * EP->RC (`sudo iperf3 -ub0 -l 65480 -P 2`)
    [  5]   0.00-10.03  sec   334 MBytes   279 Mbits/sec  3.164 ms  390/5731 (6.8%)  receiver
    [  6]   0.00-10.03  sec   334 MBytes   279 Mbits/sec  2.416 ms  396/5741 (6.9%)  receiver
    [SUM]   0.00-10.03  sec   667 MBytes   558 Mbits/sec  2.790 ms  786/11472 (6.9%)  receiver

    Note: with `-P 2`, the best total bitrate (receiver side) was achieved.

- After this change (use_remote_edma=1) [1]:

  * ping
    64 bytes from 10.0.0.11: icmp_seq=1 ttl=64 time=1.48 ms
    64 bytes from 10.0.0.11: icmp_seq=2 ttl=64 time=1.03 ms
    64 bytes from 10.0.0.11: icmp_seq=3 ttl=64 time=0.931 ms
    64 bytes from 10.0.0.11: icmp_seq=4 ttl=64 time=0.910 ms
    64 bytes from 10.0.0.11: icmp_seq=5 ttl=64 time=1.07 ms
    64 bytes from 10.0.0.11: icmp_seq=6 ttl=64 time=0.986 ms
    64 bytes from 10.0.0.11: icmp_seq=7 ttl=64 time=0.910 ms
    64 bytes from 10.0.0.11: icmp_seq=8 ttl=64 time=0.883 ms

  * RC->EP (`sudo iperf3 -ub0 -l 65480 -P 4`)
    [  5]   0.00-10.01  sec  3.54 GBytes  3.04 Gbits/sec  0.030 ms  0/58007 (0%)  receiver
    [  6]   0.00-10.01  sec  3.71 GBytes  3.19 Gbits/sec  0.453 ms  0/60909 (0%)  receiver
    [  9]   0.00-10.01  sec  3.85 GBytes  3.30 Gbits/sec  0.027 ms  0/63072 (0%)  receiver
    [ 11]   0.00-10.01  sec  3.26 GBytes  2.80 Gbits/sec  0.070 ms  1/53512 (0.0019%)  receiver
    [SUM]   0.00-10.01  sec  14.4 GBytes  12.3 Gbits/sec  0.145 ms  1/235500 (0.00042%)  receiver

  * EP->RC (`sudo iperf3 -ub0 -l 65480 -P 4`)
    [  5]   0.00-10.03  sec  3.40 GBytes  2.91 Gbits/sec  0.104 ms  15467/71208 (22%)  receiver
    [  6]   0.00-10.03  sec  3.08 GBytes  2.64 Gbits/sec  0.176 ms  12097/62609 (19%)  receiver
    [  9]   0.00-10.03  sec  3.38 GBytes  2.90 Gbits/sec  0.270 ms  17212/72710 (24%)  receiver
    [ 11]   0.00-10.03  sec  2.56 GBytes  2.19 Gbits/sec  0.200 ms  11193/53090 (21%)  receiver
    [SUM]   0.00-10.03  sec  12.4 GBytes  10.6 Gbits/sec  0.188 ms  55969/259617 (22%)  receiver

  [1] configfs settings:
      # modprobe pci_epf_vntb dyndbg=+pmf
      # cd /sys/kernel/config/pci_ep/
      # mkdir functions/pci_epf_vntb/func1
      # echo 0x1912 >   functions/pci_epf_vntb/func1/vendorid
      # echo 0x0030 >   functions/pci_epf_vntb/func1/deviceid
      # echo 32 >       functions/pci_epf_vntb/func1/msi_interrupts
      # echo 16 >       functions/pci_epf_vntb/func1/pci_epf_vntb.0/db_count
      # echo 128 >      functions/pci_epf_vntb/func1/pci_epf_vntb.0/spad_count
      # echo 2 >        functions/pci_epf_vntb/func1/pci_epf_vntb.0/num_mws
      # echo 0xe0000 >  functions/pci_epf_vntb/func1/pci_epf_vntb.0/mw1
      # echo 0x20000 >  functions/pci_epf_vntb/func1/pci_epf_vntb.0/mw2
      # echo 0xe0000 >  functions/pci_epf_vntb/func1/pci_epf_vntb.0/mw2_offset
      # echo 0x1912 >   functions/pci_epf_vntb/func1/pci_epf_vntb.0/vntb_vid
      # echo 0x0030 >   functions/pci_epf_vntb/func1/pci_epf_vntb.0/vntb_pid
      # echo 0x10 >     functions/pci_epf_vntb/func1/pci_epf_vntb.0/vbus_number
      # echo 0 >        functions/pci_epf_vntb/func1/pci_epf_vntb.0/ctrl_bar
      # echo 4 >        functions/pci_epf_vntb/func1/pci_epf_vntb.0/db_bar
      # echo 2 >        functions/pci_epf_vntb/func1/pci_epf_vntb.0/mw1_bar
      # echo 2 >        functions/pci_epf_vntb/func1/pci_epf_vntb.0/mw2_bar
      # ln -s controllers/e65d0000.pcie-ep functions/pci_epf_vntb/func1/primary/
      # echo 1 > controllers/e65d0000.pcie-ep/start


Thanks for taking a look.


Koichiro Den (27):
  PCI: endpoint: pci-epf-vntb: Use array_index_nospec() on mws_size[]
    access
  PCI: endpoint: pci-epf-vntb: Add mwN_offset configfs attributes
  NTB: epf: Handle mwN_offset for inbound MW regions
  PCI: endpoint: Add inbound mapping ops to EPC core
  PCI: dwc: ep: Implement EPC inbound mapping support
  PCI: endpoint: pci-epf-vntb: Use pci_epc_map_inbound() for MW mapping
  NTB: Add offset parameter to MW translation APIs
  PCI: endpoint: pci-epf-vntb: Propagate MW offset from configfs when
    present
  NTB: ntb_transport: Support offsetted partial memory windows
  NTB: core: Add .get_pci_epc() to ntb_dev_ops
  NTB: epf: vntb: Implement .get_pci_epc() callback
  damengine: dw-edma: Fix MSI data values for multi-vector IMWr
    interrupts
  NTB: ntb_transport: Use seq_file for QP stats debugfs
  NTB: ntb_transport: Move TX memory window setup into setup_qp_mw()
  NTB: ntb_transport: Dynamically determine qp count
  NTB: ntb_transport: Introduce get_dma_dev() helper
  NTB: epf: Reserve a subset of MSI vectors for non-NTB users
  NTB: ntb_transport: Introduce ntb_transport_backend_ops
  PCI: dwc: ep: Cache MSI outbound iATU mapping
  NTB: ntb_transport: Introduce remote eDMA backed transport mode
  NTB: epf: Provide db_vector_count/db_vector_mask callbacks
  ntb_netdev: Multi-queue support
  NTB: epf: Add per-SoC quirk to cap MRRS for DWC eDMA (128B for R-Car)
  iommu: ipmmu-vmsa: Add PCIe ch0 to devices_allowlist
  iommu: ipmmu-vmsa: Add support for reserved regions
  arm64: dts: renesas: Add Spider RC/EP DTs for NTB with remote DW PCIe
    eDMA
  NTB: epf: Add an additional memory window (MW2) barno mapping on
    Renesas R-Car

 arch/arm64/boot/dts/renesas/Makefile          |    2 +
 .../boot/dts/renesas/r8a779f0-spider-ep.dts   |   46 +
 .../boot/dts/renesas/r8a779f0-spider-rc.dts   |   52 +
 drivers/dma/dw-edma/dw-edma-core.c            |   28 +-
 drivers/iommu/ipmmu-vmsa.c                    |    7 +-
 drivers/net/ntb_netdev.c                      |  341 ++-
 drivers/ntb/Kconfig                           |   11 +
 drivers/ntb/Makefile                          |    3 +
 drivers/ntb/hw/amd/ntb_hw_amd.c               |    6 +-
 drivers/ntb/hw/epf/ntb_hw_epf.c               |  177 +-
 drivers/ntb/hw/idt/ntb_hw_idt.c               |    3 +-
 drivers/ntb/hw/intel/ntb_hw_gen1.c            |    6 +-
 drivers/ntb/hw/intel/ntb_hw_gen1.h            |    2 +-
 drivers/ntb/hw/intel/ntb_hw_gen3.c            |    3 +-
 drivers/ntb/hw/intel/ntb_hw_gen4.c            |    6 +-
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c        |    6 +-
 drivers/ntb/msi.c                             |    6 +-
 drivers/ntb/ntb_edma.c                        |  628 ++++++
 drivers/ntb/ntb_edma.h                        |  128 ++
 .../{ntb_transport.c => ntb_transport_core.c} | 1829 ++++++++++++++---
 drivers/ntb/test/ntb_perf.c                   |    4 +-
 drivers/ntb/test/ntb_tool.c                   |    6 +-
 .../pci/controller/dwc/pcie-designware-ep.c   |  287 ++-
 drivers/pci/controller/dwc/pcie-designware.h  |    7 +
 drivers/pci/endpoint/functions/pci-epf-vntb.c |  229 ++-
 drivers/pci/endpoint/pci-epc-core.c           |   44 +
 include/linux/ntb.h                           |   39 +-
 include/linux/ntb_transport.h                 |   21 +
 include/linux/pci-epc.h                       |   11 +
 29 files changed, 3415 insertions(+), 523 deletions(-)
 create mode 100644 arch/arm64/boot/dts/renesas/r8a779f0-spider-ep.dts
 create mode 100644 arch/arm64/boot/dts/renesas/r8a779f0-spider-rc.dts
 create mode 100644 drivers/ntb/ntb_edma.c
 create mode 100644 drivers/ntb/ntb_edma.h
 rename drivers/ntb/{ntb_transport.c => ntb_transport_core.c} (59%)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-12-18  4:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 20:43 [RFC PATCH v2 20/27] NTB: ntb_transport: Introduce remote eDMA backed transport mode kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-11-29 16:03 [RFC PATCH v2 00/27] NTB transport backed by remote DW eDMA Koichiro Den
2025-11-29 16:03 ` [RFC PATCH v2 20/27] NTB: ntb_transport: Introduce remote eDMA backed transport mode Koichiro Den
2025-12-01  4:38   ` kernel test robot
2025-12-01  5:49   ` kernel test robot
2025-12-01 18:45   ` kernel test robot
2025-12-01 21:41   ` Frank Li
2025-12-02  6:43     ` Koichiro Den
2025-12-02 15:42       ` Frank Li
2025-12-03  8:53         ` Koichiro Den
2025-12-03 16:14           ` Frank Li
2025-12-04 15:42             ` Koichiro Den
2025-12-04 20:16               ` Frank Li
2025-12-05  3:04                 ` Koichiro Den
2025-12-05 15:06                   ` Frank Li
2025-12-18  4:34                     ` Koichiro Den
2025-12-01 21:46   ` Dave Jiang
2025-12-02  6:59     ` Koichiro Den
2025-12-02 14:53       ` Dave Jiang
2025-12-03 14:19         ` Koichiro Den

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.