* [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems @ 2019-08-08 10:17 Kai-Heng Feng 2019-08-09 15:39 ` Joerg Roedel 2019-08-17 6:35 ` [PATCH v2] " Kai-Heng Feng 0 siblings, 2 replies; 6+ messages in thread From: Kai-Heng Feng @ 2019-08-08 10:17 UTC (permalink / raw) To: joro; +Cc: iommu, Kai-Heng Feng, linux-kernel Raven Ridge systems may have malfunction touchpad or hang at boot if incorrect IVRS IOAPIC is provided by BIOS. Users already found correct "ivrs_ioapic=" values, let's put them inside kernel to workaround buggy BIOS. BugLink: https://bugs.launchpad.net/bugs/1795292 BugLink: https://bugs.launchpad.net/bugs/1837688 Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- drivers/iommu/amd_iommu_init.c | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 4413aa67000e..06fd008281e5 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -21,6 +21,7 @@ #include <linux/iommu.h> #include <linux/kmemleak.h> #include <linux/mem_encrypt.h> +#include <linux/dmi.h> #include <asm/pci-direct.h> #include <asm/iommu.h> #include <asm/apic.h> @@ -1109,6 +1110,78 @@ static int __init add_early_maps(void) return 0; } +struct quirk_entry { + u8 id; + u16 devid; +}; + +enum { + DELL_INSPIRON_7375 = 0, + DELL_LATITUDE_5495, + LENOVO_IDEAPAD_330S_15ARR, +}; + +static const struct quirk_entry ivrs_ioapic_quirks[][3] __initconst = { + /* ivrs_ioapic[4]=00:14.0 ivrs_ioapic[5]=00:00.2 */ + [DELL_INSPIRON_7375] = { + { .id = 4, .devid = 0xa0 }, + { .id = 5, .devid = 0x2 }, + {} + }, + /* ivrs_ioapic[4]=00:14.0 */ + [DELL_LATITUDE_5495] = { + { .id = 4, .devid = 0xa0 }, + {} + }, + /* ivrs_ioapic[32]=00:14.0 */ + [LENOVO_IDEAPAD_330S_15ARR] = { + { .id = 32, .devid = 0xa0 }, + {} + }, + {} +}; + +static int __init ivrs_ioapic_quirk_cb(const struct dmi_system_id *d) +{ + const struct quirk_entry *i; + + for (i = d->driver_data; i->id != 0 && i->devid != 0; i++) + add_special_device(IVHD_SPECIAL_IOAPIC, i->id, &i->devid, 0); + + return 0; +} + +static const struct dmi_system_id ivrs_quirks[] __initconst = { + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Dell Inspiron 7375", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7375"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[DELL_INSPIRON_7375], + }, + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Dell Latitude 5495", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 5495"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495], + }, + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Lenovo ideapad 330S-15ARR", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "81FB"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[LENOVO_IDEAPAD_330S_15ARR], + }, + {} +}; + /* * Reads the device exclusion range from ACPI and initializes the IOMMU with * it @@ -1153,6 +1226,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu, if (ret) return ret; + dmi_check_system(ivrs_quirks); + /* * First save the recommended feature enable bits from ACPI */ -- 2.17.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-08 10:17 [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems Kai-Heng Feng @ 2019-08-09 15:39 ` Joerg Roedel 2019-08-13 3:58 ` Kai-Heng Feng 2019-08-17 6:35 ` [PATCH v2] " Kai-Heng Feng 1 sibling, 1 reply; 6+ messages in thread From: Joerg Roedel @ 2019-08-09 15:39 UTC (permalink / raw) To: Kai-Heng Feng; +Cc: iommu, linux-kernel On Thu, Aug 08, 2019 at 06:17:07PM +0800, Kai-Heng Feng wrote: > Raven Ridge systems may have malfunction touchpad or hang at boot if > incorrect IVRS IOAPIC is provided by BIOS. > > Users already found correct "ivrs_ioapic=" values, let's put them inside > kernel to workaround buggy BIOS. Will that still work when a fixed BIOS for these laptops is released? Joerg _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-09 15:39 ` Joerg Roedel @ 2019-08-13 3:58 ` Kai-Heng Feng 2019-08-14 8:55 ` Joerg Roedel 0 siblings, 1 reply; 6+ messages in thread From: Kai-Heng Feng @ 2019-08-13 3:58 UTC (permalink / raw) To: Joerg Roedel; +Cc: iommu, linux-kernel at 23:39, Joerg Roedel <joro@8bytes.org> wrote: > On Thu, Aug 08, 2019 at 06:17:07PM +0800, Kai-Heng Feng wrote: >> Raven Ridge systems may have malfunction touchpad or hang at boot if >> incorrect IVRS IOAPIC is provided by BIOS. >> >> Users already found correct "ivrs_ioapic=" values, let's put them inside >> kernel to workaround buggy BIOS. > > Will that still work when a fixed BIOS for these laptops is released? Do you mean that we should stop applying these quirks once a BIOS fix is confirmed? We can modify the quirk to compare BIOS version, if there’s an unlikely BIOS update really fixes the issue. Before that happens, I think it’s OK to let the quirks stay this way. Kai-Heng > > > Joerg _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-13 3:58 ` Kai-Heng Feng @ 2019-08-14 8:55 ` Joerg Roedel 0 siblings, 0 replies; 6+ messages in thread From: Joerg Roedel @ 2019-08-14 8:55 UTC (permalink / raw) To: Kai-Heng Feng; +Cc: iommu, linux-kernel On Tue, Aug 13, 2019 at 11:58:48AM +0800, Kai-Heng Feng wrote: > at 23:39, Joerg Roedel <joro@8bytes.org> wrote: > > > On Thu, Aug 08, 2019 at 06:17:07PM +0800, Kai-Heng Feng wrote: > > > Raven Ridge systems may have malfunction touchpad or hang at boot if > > > incorrect IVRS IOAPIC is provided by BIOS. > > > > > > Users already found correct "ivrs_ioapic=" values, let's put them inside > > > kernel to workaround buggy BIOS. > > > > Will that still work when a fixed BIOS for these laptops is released? > > Do you mean that we should stop applying these quirks once a BIOS fix is > confirmed? My concern is just that these quirks break some systems that don't need them. > We can modify the quirk to compare BIOS version, if there’s an unlikely BIOS > update really fixes the issue. > Before that happens, I think it’s OK to let the quirks stay this way. A BIOS version check is not making things better here as it might lock out systems that need the quirk. I think we can leave it as it for now, but can you create a new file amd_iommu_quirks.c and move the code there. And in the struct and function names please make clear that it is about ivrs-quirks. Regards, Joerg _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-08 10:17 [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems Kai-Heng Feng 2019-08-09 15:39 ` Joerg Roedel @ 2019-08-17 6:35 ` Kai-Heng Feng 2019-08-19 6:56 ` kbuild test robot 1 sibling, 1 reply; 6+ messages in thread From: Kai-Heng Feng @ 2019-08-17 6:35 UTC (permalink / raw) To: joro; +Cc: iommu, Kai-Heng Feng, linux-kernel Raven Ridge systems may have malfunction touchpad or hang at boot if incorrect IVRS IOAPIC is provided by BIOS. Users already found correct "ivrs_ioapic=" values, let's put them inside kernel to workaround buggy BIOS. BugLink: https://bugs.launchpad.net/bugs/1795292 BugLink: https://bugs.launchpad.net/bugs/1837688 Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- v2: Split the quirk to another file. drivers/iommu/Makefile | 2 +- drivers/iommu/amd_iommu.h | 14 +++++ drivers/iommu/amd_iommu_init.c | 5 +- drivers/iommu/amd_iommu_quirks.c | 90 ++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 drivers/iommu/amd_iommu.h create mode 100644 drivers/iommu/amd_iommu_quirks.c diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index f13f36ae1af6..c6a277e69848 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o obj-$(CONFIG_IOMMU_IOVA) += iova.o obj-$(CONFIG_OF_IOMMU) += of_iommu.o obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o -obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o +obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o amd_iommu_quirks.o obj-$(CONFIG_AMD_IOMMU_DEBUGFS) += amd_iommu_debugfs.o obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o obj-$(CONFIG_ARM_SMMU) += arm-smmu.o diff --git a/drivers/iommu/amd_iommu.h b/drivers/iommu/amd_iommu.h new file mode 100644 index 000000000000..12d540d9b59b --- /dev/null +++ b/drivers/iommu/amd_iommu.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef AMD_IOMMU_H +#define AMD_IOMMU_H + +int __init add_special_device(u8 type, u8 id, u16 *devid, bool cmd_line); + +#ifdef CONFIG_DMI +void amd_iommu_apply_ivrs_quirks(void); +#else +static void amd_iommu_apply_ivrs_quirks(void) { } +#endif + +#endif diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 4413aa67000e..568c52317757 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -32,6 +32,7 @@ #include <asm/irq_remapping.h> #include <linux/crash_dump.h> +#include "amd_iommu.h" #include "amd_iommu_proto.h" #include "amd_iommu_types.h" #include "irq_remapping.h" @@ -1002,7 +1003,7 @@ static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu, set_iommu_for_device(iommu, devid); } -static int __init add_special_device(u8 type, u8 id, u16 *devid, bool cmd_line) +int __init add_special_device(u8 type, u8 id, u16 *devid, bool cmd_line) { struct devid_map *entry; struct list_head *list; @@ -1153,6 +1154,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu, if (ret) return ret; + amd_iommu_apply_ivrs_quirks(); + /* * First save the recommended feature enable bits from ACPI */ diff --git a/drivers/iommu/amd_iommu_quirks.c b/drivers/iommu/amd_iommu_quirks.c new file mode 100644 index 000000000000..14181f0f5c2a --- /dev/null +++ b/drivers/iommu/amd_iommu_quirks.c @@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * Quirks for AMD IOMMU + * + * Copyright (C) 2019 Kai-Heng Feng <kai.heng.feng@canonical.com> + */ + +#include <linux/dmi.h> + +#include "amd_iommu.h" + +#define IVHD_SPECIAL_IOAPIC 1 + +struct ivrs_quirk_entry { + u8 id; + u16 devid; +}; + +enum { + DELL_INSPIRON_7375 = 0, + DELL_LATITUDE_5495, + LENOVO_IDEAPAD_330S_15ARR, +}; + +static const struct ivrs_quirk_entry ivrs_ioapic_quirks[][3] __initconst = { + /* ivrs_ioapic[4]=00:14.0 ivrs_ioapic[5]=00:00.2 */ + [DELL_INSPIRON_7375] = { + { .id = 4, .devid = 0xa0 }, + { .id = 5, .devid = 0x2 }, + {} + }, + /* ivrs_ioapic[4]=00:14.0 */ + [DELL_LATITUDE_5495] = { + { .id = 4, .devid = 0xa0 }, + {} + }, + /* ivrs_ioapic[32]=00:14.0 */ + [LENOVO_IDEAPAD_330S_15ARR] = { + { .id = 32, .devid = 0xa0 }, + {} + }, + {} +}; + +static int __init ivrs_ioapic_quirk_cb(const struct dmi_system_id *d) +{ + const struct ivrs_quirk_entry *i; + + for (i = d->driver_data; i->id != 0 && i->devid != 0; i++) + add_special_device(IVHD_SPECIAL_IOAPIC, i->id, (u16 *)&i->devid, 0); + + return 0; +} + +static const struct dmi_system_id ivrs_quirks[] __initconst = { + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Dell Inspiron 7375", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7375"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[DELL_INSPIRON_7375], + }, + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Dell Latitude 5495", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 5495"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495], + }, + { + .callback = ivrs_ioapic_quirk_cb, + .ident = "Lenovo ideapad 330S-15ARR", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "81FB"), + }, + .driver_data = (void *)&ivrs_ioapic_quirks[LENOVO_IDEAPAD_330S_15ARR], + }, + {} +}; + +void __init amd_iommu_apply_ivrs_quirks(void) +{ + dmi_check_system(ivrs_quirks); +} -- 2.17.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-08-17 6:35 ` [PATCH v2] " Kai-Heng Feng @ 2019-08-19 6:56 ` kbuild test robot 0 siblings, 0 replies; 6+ messages in thread From: kbuild test robot @ 2019-08-19 6:56 UTC (permalink / raw) To: Kai-Heng Feng; +Cc: Kai-Heng Feng, kbuild-all, iommu, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1586 bytes --] Hi Kai-Heng, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [cannot apply to v5.3-rc5 next-20190816] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Kai-Heng-Feng/iommu-amd-Override-wrong-IVRS-IOAPIC-on-Raven-Ridge-systems/20190819-133843 config: x86_64-randconfig-f001-201933 (attached as .config) compiler: gcc-7 (Debian 7.4.0-10) 7.4.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 If you fix the issue, kindly add following tag Reported-by: kbuild test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers//iommu/amd_iommu_quirks.c:87:13: error: redefinition of 'amd_iommu_apply_ivrs_quirks' void __init amd_iommu_apply_ivrs_quirks(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers//iommu/amd_iommu_quirks.c:11:0: drivers//iommu/amd_iommu.h:11:13: note: previous definition of 'amd_iommu_apply_ivrs_quirks' was here static void amd_iommu_apply_ivrs_quirks(void) { } ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers//iommu/amd_iommu.h:11:13: warning: 'amd_iommu_apply_ivrs_quirks' defined but not used [-Wunused-function] vim +/amd_iommu_apply_ivrs_quirks +87 drivers//iommu/amd_iommu_quirks.c 86 > 87 void __init amd_iommu_apply_ivrs_quirks(void) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 31936 bytes --] [-- Attachment #3: Type: text/plain, Size: 156 bytes --] _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-19 6:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-08-08 10:17 [PATCH] iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems Kai-Heng Feng 2019-08-09 15:39 ` Joerg Roedel 2019-08-13 3:58 ` Kai-Heng Feng 2019-08-14 8:55 ` Joerg Roedel 2019-08-17 6:35 ` [PATCH v2] " Kai-Heng Feng 2019-08-19 6:56 ` kbuild test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).