[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] SMMU Question for passthrough device



Hi Ian,

Thanks for you reply.
On Thu, Jan 07, 2016 at 02:00:07PM +0000, Ian Campbell wrote:
>On Thu, 2016-01-07 at 14:50 +0800, Peng Fan wrote:
>> Hi experts,
>> 
>> There are two linux os running on my ARM64 platform. Now I want to 
>> passthrough
>> a platform device(sd controller) to DomU to let DomU can directly access the
>> external SD card. The sd controller supports DMA. The sd controller driver
>> work well in Host Linux.
>> 
>> So I have a question how DomU DMA interacts with SMMU and finally access
>> memory?
>
>I'm not terribly familiar with the SMMU stuff on Xen, but I shall try.
>
>> There are 3 dma_map_ops in linux arch/arm64/mm/dma-mapping.c
>> static struct dma_map_ops iommu_dma_ops
>> static struct dma_map_ops swiotlb_dma_ops
>> struct dma_map_ops dummy_dma_ops
>> 
>> Since smmu will be assigned to XEN, linux kernel will not use
>> iommu_dma_ops. So swiotlb_dma_ops will be used for DomU. But I can not find
>> out how swiotlb_dma_ops interacts with SMMU.
>
>AFAIK it doesn't, Xen uses the SMMU and it is unavailable to guests. We
>don't currently support any of the stage 1+2 variants of the SMMU AFAIK.

Yeah. I got that XEN uses the SMMU hardware. I just want to know
how DomU let XEN build SMMU stage 2 mapping for passthrough dma-enable device
and finally do DMA. I can not find out the code path.

>
>> I checked xen/driver/passthrough/arm/smmu.c and find arm_smmu_map_page has
>> such a checking code "BUG_ON(!is_domain_direct_mapped(d));", so to my case,
>> only dom0 can use smmu, and DomU is not 1:1 mapping.
>
>Have you actually hit this BUG_ON?
>
>According to the comment this function is only called for direct mapped
>domains, and my reading of all three of the callers, via iommu_map_page, is
>that they are gated on gnttab_need_iommu_mapping(ld) which on ARM is:
>
>#define gnttab_need_iommu_mapping(d)                    \
>    (is_domain_direct_mapped(d) && need_iommu(d))

I not hit the BUG_ON. I am reading the code and try to understand the internals.
gnttab_map_grant_ref -> __gnttab_map_grant_ref -> iommu_map_page -> smmu map 
page
So If DomU want to do DMA for a passthrough platform device or PCI device,
then we should write a new PV driver to let Dom0 do the DMA to/from device?

>
>> I am confused about how DomU can DMA through SMMU.
>
>Have you seen docs/misc/arm/passthrough.txt in the Xen tree? The process is
>a bit manual but I believe that if you follow something along those lines
>then things should work.

Yeah. I have read it. And I can passthrough a simple device to DomU without
DMA and SMMU. I am just trying to understand the internals of DMA/SMMU for XEN.

Thanks,
Peng.

>
>Ian.
>

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxx
http://lists.xen.org/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.