On Fri, Nov 06, 2015 at 08:10:46PM +0800, Baoquan He wrote:
> +static void copy_irq_table(u16 devid)
> +{
> +     struct irq_remap_table *table = NULL;
> +     u16 alias;
> +     u64 dte;
> +     u64 old_intr_virt;
> +
> +     alias = amd_iommu_alias_table[devid];
> +     table = irq_lookup_table[alias];
> +     if (table) {
> +             irq_lookup_table[devid] = table;
> +             return;
> +     }
> +     dte     = amd_iommu_dev_table[devid].data[2];
> +     dte &= DTE_IRQ_PHYS_ADDR_MASK;
> +     if(!dte)
> +             return;

Better check the IV bit here to see if the remapping table address is
valid.

> +
> +     table = kzalloc(sizeof(*table), GFP_ATOMIC);
> +     if (!table){
> +             pr_warn("AMD-Vi: amd irq table allocation failed\n");
> +             return;   
> +     }
> +     dte &= DTE_IRQ_PHYS_ADDR_MASK;

Applying this mask here is redundant.

> +     old_intr_virt = ioremap_cache(dte, MAX_IRQS_PER_TABLE * sizeof(u32));

The Intel code now uses the memremap interface. Please use it for this
too.

> +     table->table = old_intr_virt;
> +     //table->table = dte;
> +     irq_lookup_table[devid] = table;

Hmm, you are reusing the old tables memory, is there a reason for this?
Copying the old table into new memory is better because it keeps the old
kernels memory as it was at crash time. 


        Joerg

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to