Commit 5ff4789d authored by Joerg Roedel's avatar Joerg Roedel Committed by Ingo Molnar

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: default avatarJoerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: robert.richter@amd.com
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f1b0c8d3
...@@ -426,11 +426,18 @@ static void set_dev_entry_bit(u16 devid, u8 bit) ...@@ -426,11 +426,18 @@ static void set_dev_entry_bit(u16 devid, u8 bit)
amd_iommu_dev_table[devid].data[i] |= (1 << _bit); amd_iommu_dev_table[devid].data[i] |= (1 << _bit);
} }
/* Writes the specific IOMMU for a device into the rlookup table */
static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
{
amd_iommu_rlookup_table[devid] = iommu;
}
/* /*
* This function takes the device specific flags read from the ACPI * This function takes the device specific flags read from the ACPI
* table and sets up the device table entry with that information * table and sets up the device table entry with that information
*/ */
static void __init set_dev_entry_from_acpi(u16 devid, u32 flags, u32 ext_flags) static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu,
u16 devid, u32 flags, u32 ext_flags)
{ {
if (flags & ACPI_DEVFLAG_INITPASS) if (flags & ACPI_DEVFLAG_INITPASS)
set_dev_entry_bit(devid, DEV_ENTRY_INIT_PASS); 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) ...@@ -446,12 +453,8 @@ static void __init set_dev_entry_from_acpi(u16 devid, u32 flags, u32 ext_flags)
set_dev_entry_bit(devid, DEV_ENTRY_LINT0_PASS); set_dev_entry_bit(devid, DEV_ENTRY_LINT0_PASS);
if (flags & ACPI_DEVFLAG_LINT1) if (flags & ACPI_DEVFLAG_LINT1)
set_dev_entry_bit(devid, DEV_ENTRY_LINT1_PASS); set_dev_entry_bit(devid, DEV_ENTRY_LINT1_PASS);
}
/* Writes the specific IOMMU for a device into the rlookup table */ set_iommu_for_device(iommu, devid);
static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
{
amd_iommu_rlookup_table[devid] = iommu;
} }
/* /*
...@@ -550,11 +553,12 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu, ...@@ -550,11 +553,12 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
case IVHD_DEV_ALL: case IVHD_DEV_ALL:
for (dev_i = iommu->first_device; for (dev_i = iommu->first_device;
dev_i <= iommu->last_device; ++dev_i) dev_i <= iommu->last_device; ++dev_i)
set_dev_entry_from_acpi(dev_i, e->flags, 0); set_dev_entry_from_acpi(iommu, dev_i,
e->flags, 0);
break; break;
case IVHD_DEV_SELECT: case IVHD_DEV_SELECT:
devid = e->devid; devid = e->devid;
set_dev_entry_from_acpi(devid, e->flags, 0); set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
break; break;
case IVHD_DEV_SELECT_RANGE_START: case IVHD_DEV_SELECT_RANGE_START:
devid_start = e->devid; devid_start = e->devid;
...@@ -565,7 +569,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu, ...@@ -565,7 +569,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
case IVHD_DEV_ALIAS: case IVHD_DEV_ALIAS:
devid = e->devid; devid = e->devid;
devid_to = e->ext >> 8; devid_to = e->ext >> 8;
set_dev_entry_from_acpi(devid, e->flags, 0); set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
amd_iommu_alias_table[devid] = devid_to; amd_iommu_alias_table[devid] = devid_to;
break; break;
case IVHD_DEV_ALIAS_RANGE: case IVHD_DEV_ALIAS_RANGE:
...@@ -577,7 +581,8 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu, ...@@ -577,7 +581,8 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
break; break;
case IVHD_DEV_EXT_SELECT: case IVHD_DEV_EXT_SELECT:
devid = e->devid; devid = e->devid;
set_dev_entry_from_acpi(devid, e->flags, e->ext); set_dev_entry_from_acpi(iommu, devid, e->flags,
e->ext);
break; break;
case IVHD_DEV_EXT_SELECT_RANGE: case IVHD_DEV_EXT_SELECT_RANGE:
devid_start = e->devid; devid_start = e->devid;
...@@ -590,7 +595,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu, ...@@ -590,7 +595,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
for (dev_i = devid_start; dev_i <= devid; ++dev_i) { for (dev_i = devid_start; dev_i <= devid; ++dev_i) {
if (alias) if (alias)
amd_iommu_alias_table[dev_i] = devid_to; amd_iommu_alias_table[dev_i] = devid_to;
set_dev_entry_from_acpi( set_dev_entry_from_acpi(iommu,
amd_iommu_alias_table[dev_i], amd_iommu_alias_table[dev_i],
flags, ext_flags); flags, ext_flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment