Skip to content

Commit c3b42b6

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/amd: Use iommu_alloc_pages_node_sz() for the IRT
Use the actual size of the irq_table allocation, limiting to 128 due to the HW alignment needs. Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5087f66 commit c3b42b6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
#define DTE_IRQ_REMAP_INTCTL (2ULL << 60)
315315
#define DTE_IRQ_REMAP_ENABLE 1ULL
316316

317+
#define DTE_INTTAB_ALIGNMENT 128
317318
#define DTE_INTTABLEN_MASK (0xfULL << 1)
318319
#define DTE_INTTABLEN_VALUE_512 9ULL
319320
#define DTE_INTTABLEN_512 (DTE_INTTABLEN_VALUE_512 << 1)

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,15 +3129,16 @@ static struct irq_remap_table *get_irq_table(struct amd_iommu *iommu, u16 devid)
31293129
return table;
31303130
}
31313131

3132-
static struct irq_remap_table *__alloc_irq_table(int nid, int order)
3132+
static struct irq_remap_table *__alloc_irq_table(int nid, size_t size)
31333133
{
31343134
struct irq_remap_table *table;
31353135

31363136
table = kzalloc(sizeof(*table), GFP_KERNEL);
31373137
if (!table)
31383138
return NULL;
31393139

3140-
table->table = iommu_alloc_pages_node(nid, GFP_KERNEL, order);
3140+
table->table = iommu_alloc_pages_node_sz(
3141+
nid, GFP_KERNEL, max(DTE_INTTAB_ALIGNMENT, size));
31413142
if (!table->table) {
31423143
kfree(table);
31433144
return NULL;
@@ -3191,7 +3192,6 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
31913192
struct irq_remap_table *new_table = NULL;
31923193
struct amd_iommu_pci_seg *pci_seg;
31933194
unsigned long flags;
3194-
int order = get_order(get_irq_table_size(max_irqs));
31953195
int nid = iommu && iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
31963196
u16 alias;
31973197

@@ -3211,7 +3211,7 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
32113211
spin_unlock_irqrestore(&iommu_table_lock, flags);
32123212

32133213
/* Nothing there yet, allocate new irq remapping table */
3214-
new_table = __alloc_irq_table(nid, order);
3214+
new_table = __alloc_irq_table(nid, get_irq_table_size(max_irqs));
32153215
if (!new_table)
32163216
return NULL;
32173217

0 commit comments

Comments
 (0)