Subject: Re: EEH error in doing DMA with PEX 8619

From: Gavin Shan <[email-masked]>
Date: Tue, 11 Apr 2017 14:42:38 +1000

On Tue, Apr 11, 2017 at 12:15:10PM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2017-04-10 at 19:04 -0700, IanJiang wrote:
>> Thanks for your replay.
>> 
>> I fixed my test according your suggestion. The CPU physical addresses (0x
>> 1f9e400000 and 0x 1f82c00000) converted with virt_to_phys() are used ,
>> instead of DMA addresses, or BUS physical addresses (0x 60a00000 and 0x
>> 60c00000). However, EEH still reports error.
>
>That's incorrect. The system has an IOMMU, only addressed properly
>mapped/translated by the IOMMU can be used for DMA. That is addresses
>returned by things like dma_map_single/sg, dma_alloc_coherent, etc...
>
>You also need to ensure you configure a proper dma mask.
>
>Using virt_to_phys() is NEVER correct on *any* architecture.
>

Ben is correct that PCI device needs to use DMA address instead of
memory address. I was suggesting to ensure that in the driver's code
and was misunderstood. It seems the driver has used the DMA address,
which is correct. But it seems the TCE entry for the DMA address isn't
built correctly. Could you please share the kernel log with original
driver code? I am not sure if I can find somethere there, but worthy
to check.

Thanks,
Gavin