Skip to content

Commit c50e324

Browse files
committed
iommu/amd: Fix devid mapping for ivrs_ioapic override
When the device id for an IOAPIC is overridden on the kernel command line, the iommu driver has to make sure it sets up a DTE for this device id. Reported-by: Su Friendy <friendy.su@sony.com.cn> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 63eaa75 commit c50e324

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎drivers/iommu/amd_iommu_init.c‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu,
712712
set_iommu_for_device(iommu, devid);
713713
}
714714

715-
static int __init add_special_device(u8 type, u8 id, u16 devid, bool cmd_line)
715+
static int __init add_special_device(u8 type, u8 id, u16 *devid, bool cmd_line)
716716
{
717717
struct devid_map *entry;
718718
struct list_head *list;
@@ -731,6 +731,8 @@ static int __init add_special_device(u8 type, u8 id, u16 devid, bool cmd_line)
731731
pr_info("AMD-Vi: Command-line override present for %s id %d - ignoring\n",
732732
type == IVHD_SPECIAL_IOAPIC ? "IOAPIC" : "HPET", id);
733733

734+
*devid = entry->devid;
735+
734736
return 0;
735737
}
736738

@@ -739,7 +741,7 @@ static int __init add_special_device(u8 type, u8 id, u16 devid, bool cmd_line)
739741
return -ENOMEM;
740742

741743
entry->id = id;
742-
entry->devid = devid;
744+
entry->devid = *devid;
743745
entry->cmd_line = cmd_line;
744746

745747
list_add_tail(&entry->list, list);
@@ -754,7 +756,7 @@ static int __init add_early_maps(void)
754756
for (i = 0; i < early_ioapic_map_size; ++i) {
755757
ret = add_special_device(IVHD_SPECIAL_IOAPIC,
756758
early_ioapic_map[i].id,
757-
early_ioapic_map[i].devid,
759+
&early_ioapic_map[i].devid,
758760
early_ioapic_map[i].cmd_line);
759761
if (ret)
760762
return ret;
@@ -763,7 +765,7 @@ static int __init add_early_maps(void)
763765
for (i = 0; i < early_hpet_map_size; ++i) {
764766
ret = add_special_device(IVHD_SPECIAL_HPET,
765767
early_hpet_map[i].id,
766-
early_hpet_map[i].devid,
768+
&early_hpet_map[i].devid,
767769
early_hpet_map[i].cmd_line);
768770
if (ret)
769771
return ret;
@@ -978,10 +980,17 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
978980
PCI_SLOT(devid),
979981
PCI_FUNC(devid));
980982

981-
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
982-
ret = add_special_device(type, handle, devid, false);
983+
ret = add_special_device(type, handle, &devid, false);
983984
if (ret)
984985
return ret;
986+
987+
/*
988+
* add_special_device might update the devid in case a
989+
* command-line override is present. So call
990+
* set_dev_entry_from_acpi after add_special_device.
991+
*/
992+
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
993+
985994
break;
986995
}
987996
default:

0 commit comments

Comments
 (0)