Arm-smmu 12000000.iommu: Unhandled context fault --need for help!

I’m doing DMA memcpy on AGX Orin Devkit and got the smmu fault(see log below), the L4T version is R35.2.1.
the dma memory area is reserved in the dts, and dma_addr_t is got from dma_alloc_coherent.
Could anyone help me?

the reserved memory info in my dts is:

reserved-memory {
        mempool_reserved: rsmempool-carveout {
            compatible = "shared-dma-pool";
            no-map;
            size = <0 0x800000>;
            alignment = <0 0x10000>; 
            status = "okay";
        };
    };

    my-mempool {
        compatible = "my,mempool";
        memory-region = <&mempool_reserved>;
        dma-coherent;
        dmas = <&gpcdma 30>;
        dma-names = "rx+tx";
        status = "okay";
    };

the dma alloc code in my driver probe() is:

    ....
	ret = of_reserved_mem_device_init(&pdev->dev);
	if (ret) {
		dev_err(&pdev->dev, "memory reservation intialization failed\n");
		goto __err_exit0;
	}

	pool->vaddr = dma_alloc_coherent(&pdev->dev, pool->size, &pool->dma_addr, GFP_KERNEL);
	pool->dma_end = pool->dma_addr + pool->size;
	if (!pool->vaddr) {
		dev_err(&pdev->dev, "DMA coherent memory allocation failed from pool!\n");
		ret = -ENOMEM;
		goto __err_exit1;
	}
	dev_info(&pdev->dev, "%s(): alloc_coherent success, dma_addr=0x%llX, vadd=%px, size=%ldMiB\n",
			 __func__, pool->dma_addr, pool->vaddr, pool->size / SZ_1M);

	pool->chan = dma_request_chan(&pdev->dev, "rx+tx");
	if (!pool->chan) {
		dev_err(&pdev->dev, "request dma channel failed!\n");
		goto __err_exit2;
	}
...

the pseudo code of my DMA memcpy is:

			/* get the memcpy command parameters */
			if (copy_from_user(&param, argp, sizeof(struct memcpy_args)))
				return -EFAULT;

			/* check input parameter */
                     src_offset = get_vaddr_offset((unsigned long)param.src, param.size);
                    dst_offset = get_vaddr_offset((unsigned long)param.dst, param.size);
                    if (src_offset < 0 || dst_offset < 0) {
                    dev_err(pool->dev, "invalid vaddr, src=%px, dst=%px, size=%lX!\n",
                        param.src, param.dst, param.size);
				return -EINVAL;
            }

			src = pool->dma_addr + src_offset;
			dst = pool->dma_addr + dst_offset;
			printk(KERN_INFO "MEMCPY: src_paddr=0x%llX, dst_paddr=0x%llX\n", src, dst);

			/* check memory range */
			if (src + param.size >= pool->dma_end || dst + param.size >= pool->dma_end) {
				dev_err(pool->dev, "memcpy overflow: src=0x%llX, dst=0x%llX, "
						"size=0x%lX, dma_base=0x%llX, dma_end=0x%llX\n", 
						src, dst, param.size, pool->dma_addr, pool->dma_end);
				return -EINVAL;
			}

			/* prepare for a DMA transfer */
			desc = dmaengine_prep_dma_memcpy(pool->chan, dst, src, param.size, 
											DMA_PREP_INTERRUPT | DMA_CTRL_ACK);

		reinit_completion(&pool->transfer_complete);
		desc->callback = mempool_dma_callback;
		desc->callback_param = pool;

		cookie = dmaengine_submit(desc);
		if (dma_submit_error(cookie)) {
			dev_err(pool->dev, "DMA submit failed!\n");
			ret = -EIO;
			goto __err_exit0;
		}

		/* launch and wait for DMA transfer done */
		dma_async_issue_pending(pool->chan);
		timeout = wait_for_completion_timeout(&pool->transfer_complete, msecs_to_jiffies(10000));
		if (timeout <= 0) {
			dmaengine_terminate_sync(pool->chan);
			dev_err(pool->dev, "DMA wait_for_completion_timeout!\n");
			ret = -ETIMEDOUT;
		} 

the error log in kernel message:

   9 [    0.000000] esrt: Reserving ESRT space from 0x00000008039c0f98 to 0x00000008039c0fd0.
  10 [    0.000000] Reserved memory: created DMA memory pool at 0x000000082aeb0000, size 8 MiB
  11 [    0.000000] OF: reserved mem: initialized node rsmempool-carveout, compatible id shared-dma-pool
  12 [    0.000000] Reserved memory: created CMA memory pool at 0x0000000817800000, size 256 MiB
  13 [    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool



....
[ +27.390374] my-mempool my-mempool: assigned reserved memory node rsmempool-carveout
[  +0.001037] my-mempool my-mempool: mempool_carveout_probe(): alloc_coherent success, dma_addr=0x82AEB0000, vadd=ffff800032800000, size=8MiB
[  +0.000220] my-mempool my-mempool: mempool_carveout_probe(): request DMA success, set=dma:rx+tx, name=dma0chan20, chan_id=20
[  +0.000165] my-mempool my-mempool: mempool_carveout_probe(): register miscdev success! name=rs_mempool
[ +17.734699] param.src=0000ffffbbfb3000, param.dst=0000ffffbc0b3000, param.size=0x10
[  +0.000009] MEMCPY: src_paddr=0x82AEB0000, dst_paddr=0x82AFB0000
[  +0.000027] arm-smmu 12000000.iommu: Unhandled context fault: fsr=0x402, iova=0x82afb0000, fsynr=0x220011, cbfrsynra=0x4, cb=0
[  +0.011811] arm-smmu 12000000.iommu: Unhandled context fault: fsr=0x402, iova=0x82aeb0000, fsynr=0xc0001, cbfrsynra=0xc04, cb=0
[  +0.011935] mc-err: unknown mcerr fault, int_status=0x00000000, ch_int_status=0x00000000, hubc_int_status=0x00000000 sbs_int_status=0x00000000, hub_int_status=0x00000000

does anybody have a look at it?

Sorry for the late response.
Is this still an issue to support? Any result can be shared?

And please try Jetpack 5.1.3. If the issue is still present, please share a method to replicate the issue on AGX Orin developer kit. So that we can see up and try.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.