Skip to content

Commit 4ff8677

Browse files
LeoBrasmpe
authored andcommitted
powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper
Creates a helper to allow allocating a new iommu_table without the need to reallocate the iommu_group. This will be helpful for replacing the iommu_table for the new DMA window, after we remove the old one with iommu_tce_table_put(). Signed-off-by: Leonardo Bras <[email protected]> Reviewed-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: Frederic Barrat <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3c33066 commit 4ff8677

File tree

1 file changed

+14
-11
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+14
-11
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,31 @@ enum {
5353
DDW_EXT_QUERY_OUT_SIZE = 2
5454
};
5555

56-
static struct iommu_table_group *iommu_pseries_alloc_group(int node)
56+
static struct iommu_table *iommu_pseries_alloc_table(int node)
5757
{
58-
struct iommu_table_group *table_group;
5958
struct iommu_table *tbl;
6059

61-
table_group = kzalloc_node(sizeof(struct iommu_table_group), GFP_KERNEL,
62-
node);
63-
if (!table_group)
64-
return NULL;
65-
6660
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, node);
6761
if (!tbl)
68-
goto free_group;
62+
return NULL;
6963

7064
INIT_LIST_HEAD_RCU(&tbl->it_group_list);
7165
kref_init(&tbl->it_kref);
66+
return tbl;
67+
}
7268

73-
table_group->tables[0] = tbl;
69+
static struct iommu_table_group *iommu_pseries_alloc_group(int node)
70+
{
71+
struct iommu_table_group *table_group;
72+
73+
table_group = kzalloc_node(sizeof(*table_group), GFP_KERNEL, node);
74+
if (!table_group)
75+
return NULL;
7476

75-
return table_group;
77+
table_group->tables[0] = iommu_pseries_alloc_table(node);
78+
if (table_group->tables[0])
79+
return table_group;
7680

77-
free_group:
7881
kfree(table_group);
7982
return NULL;
8083
}

0 commit comments

Comments
 (0)