Skip to content

Commit 5ff4789

Browse files
joergroedelIngo Molnar
authored andcommitted
AMD IOMMU: set iommu for device from ACPI code too
The device<->iommu relationship has to be set from the information in the ACPI table too. This patch adds this logic to the driver. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: iommu@lists.linux-foundation.org Cc: bhavna.sarathy@amd.com Cc: robert.richter@amd.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent f1b0c8d commit 5ff4789

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

arch/x86/kernel/amd_iommu_init.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,18 @@ static void set_dev_entry_bit(u16 devid, u8 bit)
426426
amd_iommu_dev_table[devid].data[i] |= (1 << _bit);
427427
}
428428

429+
/* Writes the specific IOMMU for a device into the rlookup table */
430+
static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
431+
{
432+
amd_iommu_rlookup_table[devid] = iommu;
433+
}
434+
429435
/*
430436
* This function takes the device specific flags read from the ACPI
431437
* table and sets up the device table entry with that information
432438
*/
433-
static void __init set_dev_entry_from_acpi(u16 devid, u32 flags, u32 ext_flags)
439+
static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu,
440+
u16 devid, u32 flags, u32 ext_flags)
434441
{
435442
if (flags & ACPI_DEVFLAG_INITPASS)
436443
set_dev_entry_bit(devid, DEV_ENTRY_INIT_PASS);
@@ -446,12 +453,8 @@ static void __init set_dev_entry_from_acpi(u16 devid, u32 flags, u32 ext_flags)
446453
set_dev_entry_bit(devid, DEV_ENTRY_LINT0_PASS);
447454
if (flags & ACPI_DEVFLAG_LINT1)
448455
set_dev_entry_bit(devid, DEV_ENTRY_LINT1_PASS);
449-
}
450456

451-
/* Writes the specific IOMMU for a device into the rlookup table */
452-
static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
453-
{
454-
amd_iommu_rlookup_table[devid] = iommu;
457+
set_iommu_for_device(iommu, devid);
455458
}
456459

457460
/*
@@ -550,11 +553,12 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
550553
case IVHD_DEV_ALL:
551554
for (dev_i = iommu->first_device;
552555
dev_i <= iommu->last_device; ++dev_i)
553-
set_dev_entry_from_acpi(dev_i, e->flags, 0);
556+
set_dev_entry_from_acpi(iommu, dev_i,
557+
e->flags, 0);
554558
break;
555559
case IVHD_DEV_SELECT:
556560
devid = e->devid;
557-
set_dev_entry_from_acpi(devid, e->flags, 0);
561+
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
558562
break;
559563
case IVHD_DEV_SELECT_RANGE_START:
560564
devid_start = e->devid;
@@ -565,7 +569,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
565569
case IVHD_DEV_ALIAS:
566570
devid = e->devid;
567571
devid_to = e->ext >> 8;
568-
set_dev_entry_from_acpi(devid, e->flags, 0);
572+
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
569573
amd_iommu_alias_table[devid] = devid_to;
570574
break;
571575
case IVHD_DEV_ALIAS_RANGE:
@@ -577,7 +581,8 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
577581
break;
578582
case IVHD_DEV_EXT_SELECT:
579583
devid = e->devid;
580-
set_dev_entry_from_acpi(devid, e->flags, e->ext);
584+
set_dev_entry_from_acpi(iommu, devid, e->flags,
585+
e->ext);
581586
break;
582587
case IVHD_DEV_EXT_SELECT_RANGE:
583588
devid_start = e->devid;
@@ -590,7 +595,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
590595
for (dev_i = devid_start; dev_i <= devid; ++dev_i) {
591596
if (alias)
592597
amd_iommu_alias_table[dev_i] = devid_to;
593-
set_dev_entry_from_acpi(
598+
set_dev_entry_from_acpi(iommu,
594599
amd_iommu_alias_table[dev_i],
595600
flags, ext_flags);
596601
}

0 commit comments

Comments
 (0)