Hello,
Recently I started a research on data transferring between Xavier and FPGA through DMA (engine) and PCIe. According to your TEGRA_DW_DMA_TEST code it’s possible to check the send data and its corresponding so I generated some data on “pcie->cpu_virt_addr” and did dma_write(), finally checked “dst_cpu_virt” but the data on those memories are different, could you explain why and how can I fix this issue? (also I have checked your original reference source code and other articles on this forum but failed to get intended result)
static void print_tegra_dwdma_log(struct tegra_pcie_dw *pcie, const char *prefix_str, u8 tmpbuf, u32 _size)
{
#if 1
/ DUMP_PREFIX_NONE, DUMP_PREFIX_ADDRESS or DUMP_PREFIX_OFFSET */
print_hex_dump(KERN_INFO, prefix_str, DUMP_PREFIX_ADDRESS, 8, 4, tmpbuf, _size, false);
…
static int write(struct seq_file *s, void *data)
{
struct tegra_pcie_dw *pcie = (struct tegra_pcie_dw *)(s->private);
struct dma_tx tx;
int ret = 0, size = 0, orgsize=0;
void __iomem *dst_cpu_virt;
u8 *tmpbuf1=NULL, *tmpbuf2=NULL, tmpbuf3=0;memset(&tx, 0x0, sizeof(struct dma_tx));
tx.src = pcie->src;
tx.dst = pcie->dst;
tx.size = pcie->size;
tx.channel = pcie->channel;dst_cpu_virt = ioremap_nocache(pcie->dst, (pcie->size)*SZ_1K);
tmpbuf1 = kzalloc(pcie->size, GFP_KERNEL);
if(!tmpbuf1) {
dev_err_once(pcie->dev, “tmpbuf1 alloc failed\n”);
goto err_out;
}
tmpbuf2 = kzalloc(pcie->size, GFP_KERNEL);
if(!tmpbuf2) {
dev_err_once(pcie->dev, “tmpbuf2 alloc failed\n”);
goto err_out;
}/* fill source with random data /
#if 0
get_random_bytes(pcie->cpu_virt_addr, pcie->size);
else
size = pcie->size;
orgsize = size;
while(size>=1) {
tmpbuf3 = orgsize-size;
tmpbuf1[orgsize-size]=((tmpbuf3 & 0x0f)<<4)|(tmpbuf3); / 0x00, 0x11, 0x22, 0x33, … */
size–;
}
memcpy(pcie->cpu_virt_addr, tmpbuf1, pcie->size);
endifsize = pcie->size;
print_tegra_dwdma_log(pcie, "pcie->cpu_virt_addr[B]: ", (u8 *)pcie->cpu_virt_addr, size);
print_tegra_dwdma_log(pcie, " dst_cpu_virt[B]: ", (u8 *)dst_cpu_virt, size);ret = dma_write(pcie, &tx);
if (ret < 0) {
dev_err(pcie->dev, “DMA-Write test FAILED (dma_write)\n”);
ret = -EIO;
goto err_out;
}/* compare copied data */
if (!memcmp(pcie->cpu_virt_addr, dst_cpu_virt, pcie->size))
dev_info(pcie->dev, “DMA-Write test PASSED (cmp_succ)\n”);
else {
dev_info(pcie->dev, “DMA-Write test FAILED (cmp_fail)\n”);print_tegra_dwdma_log(pcie, "pcie->cpu_virt_addr[A]: ", (u8 *)pcie->cpu_virt_addr, size); print_tegra_dwdma_log(pcie, " dst_cpu_virt[A]: ", (u8 *)dst_cpu_virt, size);
}
err_out:
if (tmpbuf1) kfree(tmpbuf1);
if (tmpbuf2) kfree(tmpbuf2);iounmap(dst_cpu_virt);
return ret;
}
I got below result;
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.707588] pcie->cpu_virt_addr[B]: ffffff8023d22000: 33221100 77665544 bbaa9988 ffeeddcc
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.716859] dst_cpu_virt[B]: ffffff800b3cc000: 33221100 fedcba98 bbaa9988 88776655
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.748646] tegra-pcie-dw 141a0000.pcie: pci->atu_base: 0xffffff8012180000
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.762236] tegra-pcie-dw 141a0000.pcie: [B]val: 0xe000e
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.769538] tegra-pcie-dw 141a0000.pcie: [A]val: 0xe000e
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.774016] tegra-pcie-dw 141a0000.pcie: [B]val(DMA_CH_CONTROL1_OFF_WRCH): 0x68
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.776554] tegra-pcie-dw 141a0000.pcie: [A]val(ll): 0x8
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.778161] tegra-pcie-dw 141a0000.pcie: !(tx->ll)
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.779115] tegra-pcie-dw 141a0000.pcie: pcie->dma_poll
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.780052] tegra-pcie-dw 141a0000.pcie: DMA write. Size: 16 bytes, Time diff: 934591 ns
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.781139] tegra-pcie-dw 141a0000.pcie: DMA-Write test FAILED (cmp_fail)
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.783539] pcie->cpu_virt_addr[A]: ffffff8023d22000: 33221100 77665544 bbaa9988 ffeeddcc
Jun 13 13:57:34 cuda1-desktop kernel: [ 5234.784642] dst_cpu_virt[A]: ffffff800b3cc000: 33221100 fedcba98 bbaa9988 88776655
You can check the kernel log and the result of lspci -vv as enclosed.
kern.log (3.2 MB)
lspci_result.txt (6.4 KB)
Thanks in advance,
Matt