[AMD Official Use Only - General] > -----Original Message----- > From: Anoob Joseph <ano...@marvell.com> > Sent: Wednesday, August 16, 2023 12:57 PM > To: Varghese, Vipin <vipin.vargh...@amd.com> > Cc: Yigit, Ferruh <ferruh.yi...@amd.com>; cheng1.ji...@intel.com; > sta...@dpdk.org; tho...@monjalon.net; dev@dpdk.org; Jerin Jacob > Kollanukkaran <jer...@marvell.com> > Subject: RE: [EXT] [PATCH] app/dma-perf: fix physical address seg-fault > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > Hi Vipin, > > Thanks for the update. Please see inline. > > Thanks, > Anoob > > > -----Original Message----- > > From: Vipin Varghese <vipin.vargh...@amd.com> > > Sent: Wednesday, August 16, 2023 12:48 PM > > To: tho...@monjalon.net; dev@dpdk.org > > Cc: ferruh.yi...@amd.com; cheng1.ji...@intel.com; sta...@dpdk.org > > Subject: [EXT] [PATCH] app/dma-perf: fix physical address seg-fault > > > > External Email > > > > ---------------------------------------------------------------------- > > do_cpu_mem_copy uses DPDK API rte_mbuf_data_iova to return the start > > of the virtual address for both src and dst. > > But in case of iova mode set as PA, this results in seg-fault. > > This is because rte_memcpy VA address and not PA. > > > > this fix checks the iova mode and invokes rte_memcpy with the right > > arguments. > > > > Bugzilla ID: 1269 > > Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test") > > Cc: cheng1.ji...@intel.com > > > > Cc: sta...@dpdk.org > > > > Signed-off-by: Vipin Varghese <vipin.vargh...@amd.com> > > --- > > > > tested for both va and pa > > > > CMD: > > PA: dpdk-test-dma-perf --iova-mode=pa -- --config test.ini > > VA: dpdk-test-dma-perf --iova-mode=va -- --config test.ini > > DC: dpdk-test-dma-perf --iova-mode=dc -- --config test.ini > > > > Log: fails for dc mode `EAL: invalid parameters for --iova-mode` > > > > test.ini: > > ``` > > [case1] > > type=CPU_MEM_COPY > > mem_size=10 > > buf_size=64,8192,2,MUL > > src_numa_node=0 > > dst_numa_node=0 > > cache_flush=0 > > test_seconds=2 > > lcore = 7 > > eal_args=--in-memory --no-pci > > ``` > > --- > > app/test-dma-perf/benchmark.c | 39 +++++++++++++++++++++++++++---- > > ---- > > 1 file changed, 30 insertions(+), 9 deletions(-) > > > > diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma- > > perf/benchmark.c index 0601e0d171..5573acc9f9 100644 > > --- a/app/test-dma-perf/benchmark.c > > +++ b/app/test-dma-perf/benchmark.c > > @@ -279,6 +279,10 @@ do_cpu_mem_copy(void *p) > > struct rte_mbuf **srcs = para->srcs; > > struct rte_mbuf **dsts = para->dsts; > > uint32_t i; > > + bool isAddrPaMode = false; > > + > > + if (rte_eal_iova_mode() == RTE_IOVA_PA) > > + isAddrPaMode = true; > > > > worker_info->stop_flag = false; > > worker_info->ready_flag = true; > > @@ -286,16 +290,33 @@ do_cpu_mem_copy(void *p) > > while (!worker_info->start_flag) > > ; > > > > - while (1) { > > - for (i = 0; i < nr_buf; i++) { > > - /* copy buffer form src to dst */ > > - rte_memcpy((void > > *)(uintptr_t)rte_mbuf_data_iova(dsts[i]), > > - (void > > *)(uintptr_t)rte_mbuf_data_iova(srcs[i]), > > - (size_t)buf_size); > > - worker_info->total_cpl++; > > + if (true == isAddrPaMode) { > > + while (1) { > > + for (i = 0; i < nr_buf; i++) { > > + void *src = rte_pktmbuf_mtod(dsts[i], > > + void > > *); > > + void *dst = rte_pktmbuf_mtod(srcs[i], > > + void > > *); > > + > > + /* copy buffer form src to dst */ > > + rte_memcpy(dst, > > + src, > > + (size_t)buf_size); > > + worker_info->total_cpl++; > > + } > > + if (worker_info->stop_flag) > > + break; > > + } > > + } else { > > + while (1) { > > + for (i = 0; i < nr_buf; i++) { > > + /* copy buffer form src to dst */ > > + rte_memcpy((void > > *)(uintptr_t)rte_mbuf_data_iova(dsts[i]), > > + (void > > *)(uintptr_t)rte_mbuf_data_iova(srcs[i]), > > + (size_t)buf_size); > > [Anoob] Even in case of VA as IOVA, rte_pktmbuf_mtod() should work, right? I > was imagining a simple replacement of ' rte_mbuf_data_iova' with > 'rte_pktmbuf_mtod' as the fix.
Ferruh and myself believe the rte_mbuf_data_iova should have been working for both PA and VA. But internally does not. I think what you are recommending is for both PA and VA just use ` rte_pktmbuf_mtod` for both. Thus we can avoid the check itself. > > > + worker_info->total_cpl++; > > + } > > + if (worker_info->stop_flag) > > + break; > > } > > - if (worker_info->stop_flag) > > - break; > > } > > > > return 0; > > -- > > 2.34.1