Re: [RFC patch] init default dma_ops to prepare intel_iommu_init failure

From: Luming Yu
Date: Thu Aug 13 2009 - 03:03:29 EST


Thanks for another workaround, we should be working on deleting wrong
assumption of"iommu_deteced == iommu working", Not just workaround. My
patch could break something.. but it is just a start towards right
goal..

On Thu, Aug 13, 2009 at 2:52 PM, FUJITA
Tomonori<fujita.tomonori@xxxxxxxxxxxxx> wrote:
> On Thu, 13 Aug 2009 13:48:45 +0800
> Luming Yu <luming.yu@xxxxxxxxx> wrote:
>
>> >>
>> >> This check can not be removed. Otherwise, swiotlb_dma_ops will always override
>> >> previous dma_ops value.
>> >
>> > Yeah.
>>
>> I think pci_swiotlb_init needs to be cleaned up for both x86_{32,64} and ia64.
>> it should be used to init default dma_ops, and the call site of it should be
>> as early as platform_dma_init in mem_init. SInce swiotlb_dma_ops is pitched as
>> default dma_ops for x86, ia64, we really don't need to let pci_swiotlb_init
>> know iommu_deteced, dmar_disabled or iommu_passthrough...and anything
>> like that..
>> Please note the major wrong assumption of the current implementation is
>> "iommu_deteced == iommu working" that I was trying to fix.
>
> How about this?
>
> You can work around that assumption, I guess.
>
>
> diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
> index f6b1ff0..48caafa 100644
> --- a/arch/ia64/kernel/pci-dma.c
> +++ b/arch/ia64/kernel/pci-dma.c
> @@ -20,6 +20,8 @@
>
> Â#include <asm/page.h>
>
> +extern int swiotlb_late_init_with_default_size (size_t size);
> +
> Âdma_addr_t bad_dma_address __read_mostly;
> ÂEXPORT_SYMBOL(bad_dma_address);
>
> @@ -44,11 +46,25 @@ struct device fallback_dev = {
> Â};
>
> Âextern struct dma_map_ops intel_dma_ops;
> +extern struct dma_map_ops swiotlb_dma_ops;
>
> Âstatic int __init pci_iommu_init(void)
> Â{
> - Â Â Â if (iommu_detected)
> - Â Â Â Â Â Â Â intel_iommu_init();
> + Â Â Â int ret;
> +
> + Â Â Â if (iommu_detected) {
> + Â Â Â Â Â Â Â ret = intel_iommu_init();
> + Â Â Â Â Â Â Â if (ret) {
> +#ifdef CONFIG_IA64_GENERIC
> + Â Â Â Â Â Â Â Â Â Â Â dma_ops = &swiotlb_dma_ops;
> + Â Â Â Â Â Â Â Â Â Â Â if (swiotlb_late_init_with_default_size(64 * (1<<20)))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â panic("failed to initialize swiotlb");
> + Â Â Â Â Â Â Â Â Â Â Â machvec_init("dig");
> +#else
> + Â Â Â Â Â Â Â Â Â Â Â panic("Unable to find Intel IOMMU");
> +#endif
> + Â Â Â Â Â Â Â }
> + Â Â Â }
>
> Â Â Â Âreturn 0;
> Â}
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/