aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-08-13 05:07:25 -0400
committerJoerg Roedel <jroedel@suse.de>2015-08-13 13:49:05 -0400
commita130e69f28ba1d180242b581a15d09f06dad9227 (patch)
treecfa6e3591dfcccb5c5c3c12d474d37bdca9e1d3a /drivers/iommu
parentf7644cbfcdf03528f0f450f3940c4985b2291f49 (diff)
iommu/amd: Simplify allocation in irq_remapping_alloc()
Allocate the irq data only in the loop. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 658ee39e6569..a1585796785b 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3947,11 +3947,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
3947 if (ret < 0) 3947 if (ret < 0)
3948 return ret; 3948 return ret;
3949 3949
3950 ret = -ENOMEM;
3951 data = kzalloc(sizeof(*data), GFP_KERNEL);
3952 if (!data)
3953 goto out_free_parent;
3954
3955 if (info->type == X86_IRQ_ALLOC_TYPE_IOAPIC) { 3950 if (info->type == X86_IRQ_ALLOC_TYPE_IOAPIC) {
3956 if (get_irq_table(devid, true)) 3951 if (get_irq_table(devid, true))
3957 index = info->ioapic_pin; 3952 index = info->ioapic_pin;
@@ -3962,7 +3957,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
3962 } 3957 }
3963 if (index < 0) { 3958 if (index < 0) {
3964 pr_warn("Failed to allocate IRTE\n"); 3959 pr_warn("Failed to allocate IRTE\n");
3965 kfree(data);
3966 goto out_free_parent; 3960 goto out_free_parent;
3967 } 3961 }
3968 3962
@@ -3974,17 +3968,18 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
3974 goto out_free_data; 3968 goto out_free_data;
3975 } 3969 }
3976 3970
3977 if (i > 0) { 3971 ret = -ENOMEM;
3978 data = kzalloc(sizeof(*data), GFP_KERNEL); 3972 data = kzalloc(sizeof(*data), GFP_KERNEL);
3979 if (!data) 3973 if (!data)
3980 goto out_free_data; 3974 goto out_free_data;
3981 } 3975
3982 irq_data->hwirq = (devid << 16) + i; 3976 irq_data->hwirq = (devid << 16) + i;
3983 irq_data->chip_data = data; 3977 irq_data->chip_data = data;
3984 irq_data->chip = &amd_ir_chip; 3978 irq_data->chip = &amd_ir_chip;
3985 irq_remapping_prepare_irte(data, cfg, info, devid, index, i); 3979 irq_remapping_prepare_irte(data, cfg, info, devid, index, i);
3986 irq_set_status_flags(virq + i, IRQ_MOVE_PCNTXT); 3980 irq_set_status_flags(virq + i, IRQ_MOVE_PCNTXT);
3987 } 3981 }
3982
3988 return 0; 3983 return 0;
3989 3984
3990out_free_data: 3985out_free_data: