Skip to content

Commit a64d600

Browse files
LuBaolutursulin
authored andcommitted
iommu: Add gfp parameter to iommu_alloc_resv_region
Add gfp parameter to iommu_alloc_resv_region() for the callers to specify the memory allocation behavior. Thus iommu_alloc_resv_region() could also be available in critical contexts. Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent a9c65b9 commit a64d600

File tree

10 files changed

+27
-18
lines changed

10 files changed

+27
-18
lines changed

drivers/acpi/arm64/iort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ static void iort_iommu_msi_get_resv_regions(struct device *dev,
11421142
struct iommu_resv_region *region;
11431143

11441144
region = iommu_alloc_resv_region(base + SZ_64K, SZ_64K,
1145-
prot, IOMMU_RESV_MSI);
1145+
prot, IOMMU_RESV_MSI,
1146+
GFP_KERNEL);
11461147
if (region)
11471148
list_add_tail(&region->list, head);
11481149
}

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,8 @@ static void amd_iommu_get_resv_regions(struct device *dev,
23062306
type = IOMMU_RESV_RESERVED;
23072307

23082308
region = iommu_alloc_resv_region(entry->address_start,
2309-
length, prot, type);
2309+
length, prot, type,
2310+
GFP_KERNEL);
23102311
if (!region) {
23112312
dev_err(dev, "Out of memory allocating dm-regions\n");
23122313
return;
@@ -2316,14 +2317,14 @@ static void amd_iommu_get_resv_regions(struct device *dev,
23162317

23172318
region = iommu_alloc_resv_region(MSI_RANGE_START,
23182319
MSI_RANGE_END - MSI_RANGE_START + 1,
2319-
0, IOMMU_RESV_MSI);
2320+
0, IOMMU_RESV_MSI, GFP_KERNEL);
23202321
if (!region)
23212322
return;
23222323
list_add_tail(&region->list, head);
23232324

23242325
region = iommu_alloc_resv_region(HT_RANGE_START,
23252326
HT_RANGE_END - HT_RANGE_START + 1,
2326-
0, IOMMU_RESV_RESERVED);
2327+
0, IOMMU_RESV_RESERVED, GFP_KERNEL);
23272328
if (!region)
23282329
return;
23292330
list_add_tail(&region->list, head);

drivers/iommu/apple-dart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
750750

751751
region = iommu_alloc_resv_region(DOORBELL_ADDR,
752752
PAGE_SIZE, prot,
753-
IOMMU_RESV_MSI);
753+
IOMMU_RESV_MSI, GFP_KERNEL);
754754
if (!region)
755755
return;
756756

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ static void arm_smmu_get_resv_regions(struct device *dev,
27562756
int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
27572757

27582758
region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
2759-
prot, IOMMU_RESV_SW_MSI);
2759+
prot, IOMMU_RESV_SW_MSI, GFP_KERNEL);
27602760
if (!region)
27612761
return;
27622762

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ static void arm_smmu_get_resv_regions(struct device *dev,
15521552
int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
15531553

15541554
region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
1555-
prot, IOMMU_RESV_SW_MSI);
1555+
prot, IOMMU_RESV_SW_MSI, GFP_KERNEL);
15561556
if (!region)
15571557
return;
15581558

drivers/iommu/intel/iommu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,8 @@ static void intel_iommu_get_resv_regions(struct device *device,
45364536
IOMMU_RESV_DIRECT_RELAXABLE : IOMMU_RESV_DIRECT;
45374537

45384538
resv = iommu_alloc_resv_region(rmrr->base_address,
4539-
length, prot, type);
4539+
length, prot, type,
4540+
GFP_KERNEL);
45404541
if (!resv)
45414542
break;
45424543

@@ -4551,7 +4552,8 @@ static void intel_iommu_get_resv_regions(struct device *device,
45514552

45524553
if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
45534554
reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
4554-
IOMMU_RESV_DIRECT_RELAXABLE);
4555+
IOMMU_RESV_DIRECT_RELAXABLE,
4556+
GFP_KERNEL);
45554557
if (reg)
45564558
list_add_tail(&reg->list, head);
45574559
}
@@ -4560,7 +4562,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
45604562

45614563
reg = iommu_alloc_resv_region(IOAPIC_RANGE_START,
45624564
IOAPIC_RANGE_END - IOAPIC_RANGE_START + 1,
4563-
0, IOMMU_RESV_MSI);
4565+
0, IOMMU_RESV_MSI, GFP_KERNEL);
45644566
if (!reg)
45654567
return;
45664568
list_add_tail(&reg->list, head);

drivers/iommu/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static int iommu_insert_resv_region(struct iommu_resv_region *new,
444444
LIST_HEAD(stack);
445445

446446
nr = iommu_alloc_resv_region(new->start, new->length,
447-
new->prot, new->type);
447+
new->prot, new->type, GFP_KERNEL);
448448
if (!nr)
449449
return -ENOMEM;
450450

@@ -2605,11 +2605,12 @@ EXPORT_SYMBOL(iommu_put_resv_regions);
26052605

26062606
struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start,
26072607
size_t length, int prot,
2608-
enum iommu_resv_type type)
2608+
enum iommu_resv_type type,
2609+
gfp_t gfp)
26092610
{
26102611
struct iommu_resv_region *region;
26112612

2612-
region = kzalloc(sizeof(*region), GFP_KERNEL);
2613+
region = kzalloc(sizeof(*region), gfp);
26132614
if (!region)
26142615
return NULL;
26152616

drivers/iommu/mtk_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
915915
continue;
916916

917917
region = iommu_alloc_resv_region(resv->iova_base, resv->size,
918-
prot, IOMMU_RESV_RESERVED);
918+
prot, IOMMU_RESV_RESERVED,
919+
GFP_KERNEL);
919920
if (!region)
920921
return;
921922

drivers/iommu/virtio-iommu.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,13 @@ static int viommu_add_resv_mem(struct viommu_endpoint *vdev,
491491
fallthrough;
492492
case VIRTIO_IOMMU_RESV_MEM_T_RESERVED:
493493
region = iommu_alloc_resv_region(start, size, 0,
494-
IOMMU_RESV_RESERVED);
494+
IOMMU_RESV_RESERVED,
495+
GFP_KERNEL);
495496
break;
496497
case VIRTIO_IOMMU_RESV_MEM_T_MSI:
497498
region = iommu_alloc_resv_region(start, size, prot,
498-
IOMMU_RESV_MSI);
499+
IOMMU_RESV_MSI,
500+
GFP_KERNEL);
499501
break;
500502
}
501503
if (!region)
@@ -910,7 +912,8 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
910912
*/
911913
if (!msi) {
912914
msi = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
913-
prot, IOMMU_RESV_SW_MSI);
915+
prot, IOMMU_RESV_SW_MSI,
916+
GFP_KERNEL);
914917
if (!msi)
915918
return;
916919

include/linux/iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ extern void iommu_set_default_translated(bool cmd_line);
457457
extern bool iommu_default_passthrough(void);
458458
extern struct iommu_resv_region *
459459
iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
460-
enum iommu_resv_type type);
460+
enum iommu_resv_type type, gfp_t gfp);
461461
extern int iommu_get_group_resv_regions(struct iommu_group *group,
462462
struct list_head *head);
463463

0 commit comments

Comments
 (0)