Re: [PATCH v5 02/10] iommu/vt-d: Use per-device dma_ops

Christoph Hellwig
2019-11-14T08:14:30Z

On Thu, Nov 14, 2019 at 01:14:11PM +0800, Lu Baolu wrote:
> Could you please educate me what dma_supported() is exactly for? Will
> it always get called during boot? When will it be called?

->dma_supported is set when setting either the dma_mask or
dma_coherent_mask. These days it serves too primary purposes: reject
too small masks that can't be addressed, and provide any hooks needed
in the driver based on the mask.

> In above implementation, why do we need to check dma_direct_supported()
> at the beginning? And why

Because the existing driver called dma_direct_supported, which I added
based on x86 arch overrides doings the same a while ago. I suspect
it is related to addressing for tiny dma masks, but I'm not entirely
sure. The longer term intel-iommu maintainers or x86 maintainers might
be able to shed more light how this was supposed to work and/or how
systems with the Intel IOMMU deal with e.g. ISA devices with 24-bit
addressing.

>
> if (!info || info == DUMMY_DEVICE_DOMAIN_INFO ||
> info == DEFER_DEVICE_DOMAIN_INFO) {
> dev->dma_ops_bypass = true;

This was supposed to transform the checks from iommu_dummy and
identity_mapping. But I think it actually isn't entirely correct and
already went bad in the patch to remove identity_mapping. Pleae check
the branch I just re-pushed, which should be correct now.