From 933d46447103a2767094fc01664ddffc5e0a4e5e Mon Sep 17 00:00:00 2001 From: AceLan Kao Date: Tue, 1 Oct 2019 04:57:00 +0200 Subject: [PATCH] UBUNTU: SAUCE: mfd: intel-lpss: add quirk for Dell XPS 13 7390 2-in-1 BugLink: https://bugs.launchpad.net/bugs/1845584 The memory region intel-lpss-pci uses has been declared as write-combining [ 0.001728] 5 base 4000000000 mask 6000000000 write-combining This leads to the system hangs up during booting up. Tuowen Zhao(ztuowen@gmail.com) provides a diff patch for intel-lpss driver to claim to use un-cacheable memory while calling __devm_ioremap(), and it works well. But it haven't been accepted by maintainer yet. To avoid the potential impact on other machines, I add a quirk to list the machines which has the write-combining area in MTRR which overlaps with the address that intel-lpss uses, only the machines in the list pass the DEVM_IOREMAP_UC to __devm_ioremap(). Link: https://bugzilla.kernel.org/show_bug.cgi?id=203485 Signed-off-by: AceLan Kao Acked-by: Seth Forshee Acked-by: Paolo Pisati Acked-by: Andrea Righi Signed-off-by: Kleber Sacilotto de Souza --- drivers/mfd/intel-lpss.c | 20 ++++++++++++++++++-- include/linux/io.h | 2 ++ lib/devres.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c index b5c4f8f974aa..94e6d675eac0 100644 --- a/drivers/mfd/intel-lpss.c +++ b/drivers/mfd/intel-lpss.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -130,6 +131,17 @@ static const struct mfd_cell intel_lpss_spi_cell = { static DEFINE_IDA(intel_lpss_devid_ida); static struct dentry *intel_lpss_debugfs; +static const struct dmi_system_id mtrr_large_wc_region[] = { + { + .ident = "Dell Computer Corporation", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "XPS 13 7390 2-in-1"), + }, + }, + { } +}; + static int intel_lpss_request_dma_module(const char *name) { static bool intel_lpss_dma_requested; @@ -397,8 +409,12 @@ int intel_lpss_probe(struct device *dev, if (!lpss) return -ENOMEM; - lpss->priv = devm_ioremap(dev, info->mem->start + LPSS_PRIV_OFFSET, - LPSS_PRIV_SIZE); + if (dmi_check_system(mtrr_large_wc_region)) + lpss->priv = devm_ioremap_uc(dev, info->mem->start + LPSS_PRIV_OFFSET, + LPSS_PRIV_SIZE); + else + lpss->priv = devm_ioremap(dev, info->mem->start + LPSS_PRIV_OFFSET, + LPSS_PRIV_SIZE); if (!lpss->priv) return -ENOMEM; diff --git a/include/linux/io.h b/include/linux/io.h index 32e30e8fb9db..da39ff89df65 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -75,6 +75,8 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr) void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, resource_size_t size); +void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset, + resource_size_t size); void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, resource_size_t size); void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, diff --git a/lib/devres.c b/lib/devres.c index 5f2aedd58bc5..d5286472fcbc 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -43,6 +43,35 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, } EXPORT_SYMBOL(devm_ioremap); +/** + * devm_ioremap_uc - Managed ioremap_uc() + * @dev: Generic device to remap IO address for + * @offset: Resource address to map + * @size: Size of map + * + * Managed ioremap_uc(). Map is automatically unmapped on driver detach. + */ +void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset, + resource_size_t size) +{ + void __iomem **ptr, *addr; + + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return NULL; + + addr = ioremap_uc(offset, size); + if (addr) { + *ptr = addr; + devres_add(dev, ptr); + } else + devres_free(ptr); + + return addr; +} +EXPORT_SYMBOL(devm_ioremap_uc); + + /** * devm_ioremap_nocache - Managed ioremap_nocache() * @dev: Generic device to remap IO address for -- 2.39.5