From 6fa504cbc440f205a7dbcdf88d30c431608c655c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 6 Apr 2020 21:02:22 +0200 Subject: [PATCH] 5.4-stable patches added patches: coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch extcon-axp288-add-wakeup-support.patch mei-me-add-cedar-fork-device-ids.patch misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch misc-rtsx-set-correct-pcr_ops-for-rts522a.patch nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch pci-sysfs-revert-rescan-file-renames.patch power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch --- ...use-the-bit-macro-in-the-uapi-header.patch | 39 ++++ .../extcon-axp288-add-wakeup-support.patch | 74 ++++++++ .../mei-me-add-cedar-fork-device-ids.patch | 44 +++++ ...odule-parameter-to-determine-irqtype.patch | 109 +++++++++++ ...support-10-pci-endpoint-test-devices.patch | 38 ++++ ...rtsx-set-correct-pcr_ops-for-rts522a.patch | 32 ++++ ...d-and-reg_write-before-dereferencing.patch | 48 +++++ ...pci-sysfs-revert-rescan-file-renames.patch | 60 ++++++ ...ecial-handling-for-hp-pavilion-x2-10.patch | 178 ++++++++++++++++++ queue-5.4/series | 9 + 10 files changed, 631 insertions(+) create mode 100644 queue-5.4/coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch create mode 100644 queue-5.4/extcon-axp288-add-wakeup-support.patch create mode 100644 queue-5.4/mei-me-add-cedar-fork-device-ids.patch create mode 100644 queue-5.4/misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch create mode 100644 queue-5.4/misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch create mode 100644 queue-5.4/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch create mode 100644 queue-5.4/nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch create mode 100644 queue-5.4/pci-sysfs-revert-rescan-file-renames.patch create mode 100644 queue-5.4/power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch diff --git a/queue-5.4/coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch b/queue-5.4/coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch new file mode 100644 index 00000000000..5dc79dc9991 --- /dev/null +++ b/queue-5.4/coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch @@ -0,0 +1,39 @@ +From 9b6eaaf3db5e5888df7bca7fed7752a90f7fd871 Mon Sep 17 00:00:00 2001 +From: Eugene Syromiatnikov +Date: Tue, 24 Mar 2020 05:22:13 +0100 +Subject: coresight: do not use the BIT() macro in the UAPI header + +From: Eugene Syromiatnikov + +commit 9b6eaaf3db5e5888df7bca7fed7752a90f7fd871 upstream. + +The BIT() macro definition is not available for the UAPI headers +(moreover, it can be defined differently in the user space); replace +its usage with the _BITUL() macro that is defined in . + +Fixes: 237483aa5cf4 ("coresight: stm: adding driver for CoreSight STM component") +Signed-off-by: Eugene Syromiatnikov +Cc: stable +Reviewed-by: Mathieu Poirier +Link: https://lore.kernel.org/r/20200324042213.GA10452@asgard.redhat.com +Signed-off-by: Greg Kroah-Hartman + +--- + include/uapi/linux/coresight-stm.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/include/uapi/linux/coresight-stm.h ++++ b/include/uapi/linux/coresight-stm.h +@@ -2,8 +2,10 @@ + #ifndef __UAPI_CORESIGHT_STM_H_ + #define __UAPI_CORESIGHT_STM_H_ + +-#define STM_FLAG_TIMESTAMPED BIT(3) +-#define STM_FLAG_GUARANTEED BIT(7) ++#include ++ ++#define STM_FLAG_TIMESTAMPED _BITUL(3) ++#define STM_FLAG_GUARANTEED _BITUL(7) + + /* + * The CoreSight STM supports guaranteed and invariant timing diff --git a/queue-5.4/extcon-axp288-add-wakeup-support.patch b/queue-5.4/extcon-axp288-add-wakeup-support.patch new file mode 100644 index 00000000000..5e3a7856da7 --- /dev/null +++ b/queue-5.4/extcon-axp288-add-wakeup-support.patch @@ -0,0 +1,74 @@ +From 9c94553099efb2ba873cbdddfd416a8a09d0e5f1 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Mon, 23 Mar 2020 22:59:39 +0100 +Subject: extcon: axp288: Add wakeup support + +From: Hans de Goede + +commit 9c94553099efb2ba873cbdddfd416a8a09d0e5f1 upstream. + +On devices with an AXP288, we need to wakeup from suspend when a charger +is plugged in, so that we can do charger-type detection and so that the +axp288-charger driver, which listens for our extcon events, can configure +the input-current-limit accordingly. + +Cc: stable@vger.kernel.org +Signed-off-by: Hans de Goede +Signed-off-by: Chanwoo Choi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/extcon/extcon-axp288.c | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + +--- a/drivers/extcon/extcon-axp288.c ++++ b/drivers/extcon/extcon-axp288.c +@@ -423,9 +423,40 @@ static int axp288_extcon_probe(struct pl + /* Start charger cable type detection */ + axp288_extcon_enable(info); + ++ device_init_wakeup(dev, true); ++ platform_set_drvdata(pdev, info); ++ ++ return 0; ++} ++ ++static int __maybe_unused axp288_extcon_suspend(struct device *dev) ++{ ++ struct axp288_extcon_info *info = dev_get_drvdata(dev); ++ ++ if (device_may_wakeup(dev)) ++ enable_irq_wake(info->irq[VBUS_RISING_IRQ]); ++ + return 0; + } + ++static int __maybe_unused axp288_extcon_resume(struct device *dev) ++{ ++ struct axp288_extcon_info *info = dev_get_drvdata(dev); ++ ++ /* ++ * Wakeup when a charger is connected to do charger-type ++ * connection and generate an extcon event which makes the ++ * axp288 charger driver set the input current limit. ++ */ ++ if (device_may_wakeup(dev)) ++ disable_irq_wake(info->irq[VBUS_RISING_IRQ]); ++ ++ return 0; ++} ++ ++static SIMPLE_DEV_PM_OPS(axp288_extcon_pm_ops, axp288_extcon_suspend, ++ axp288_extcon_resume); ++ + static const struct platform_device_id axp288_extcon_table[] = { + { .name = "axp288_extcon" }, + {}, +@@ -437,6 +468,7 @@ static struct platform_driver axp288_ext + .id_table = axp288_extcon_table, + .driver = { + .name = "axp288_extcon", ++ .pm = &axp288_extcon_pm_ops, + }, + }; + diff --git a/queue-5.4/mei-me-add-cedar-fork-device-ids.patch b/queue-5.4/mei-me-add-cedar-fork-device-ids.patch new file mode 100644 index 00000000000..635cd201e10 --- /dev/null +++ b/queue-5.4/mei-me-add-cedar-fork-device-ids.patch @@ -0,0 +1,44 @@ +From 99397d33b763dc554d118aaa38cc5abc6ce985de Mon Sep 17 00:00:00 2001 +From: Alexander Usyskin +Date: Tue, 24 Mar 2020 23:07:30 +0200 +Subject: mei: me: add cedar fork device ids + +From: Alexander Usyskin + +commit 99397d33b763dc554d118aaa38cc5abc6ce985de upstream. + +Add Cedar Fork (CDF) device ids, those belongs to the cannon point family. + +Cc: +Signed-off-by: Alexander Usyskin +Signed-off-by: Tomas Winkler +Link: https://lore.kernel.org/r/20200324210730.17672-1-tomas.winkler@intel.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/misc/mei/hw-me-regs.h | 2 ++ + drivers/misc/mei/pci-me.c | 2 ++ + 2 files changed, 4 insertions(+) + +--- a/drivers/misc/mei/hw-me-regs.h ++++ b/drivers/misc/mei/hw-me-regs.h +@@ -87,6 +87,8 @@ + #define MEI_DEV_ID_CMP_H 0x06e0 /* Comet Lake H */ + #define MEI_DEV_ID_CMP_H_3 0x06e4 /* Comet Lake H 3 (iTouch) */ + ++#define MEI_DEV_ID_CDF 0x18D3 /* Cedar Fork */ ++ + #define MEI_DEV_ID_ICP_LP 0x34E0 /* Ice Lake Point LP */ + + #define MEI_DEV_ID_TGP_LP 0xA0E0 /* Tiger Lake Point LP */ +--- a/drivers/misc/mei/pci-me.c ++++ b/drivers/misc/mei/pci-me.c +@@ -109,6 +109,8 @@ static const struct pci_device_id mei_me + {MEI_PCI_DEVICE(MEI_DEV_ID_MCC, MEI_ME_PCH12_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_MCC_4, MEI_ME_PCH8_CFG)}, + ++ {MEI_PCI_DEVICE(MEI_DEV_ID_CDF, MEI_ME_PCH8_CFG)}, ++ + /* required last entry */ + {0, } + }; diff --git a/queue-5.4/misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch b/queue-5.4/misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch new file mode 100644 index 00000000000..d058f4aa681 --- /dev/null +++ b/queue-5.4/misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch @@ -0,0 +1,109 @@ +From b2ba9225e0313b1de631a44b7b48c109032bffec Mon Sep 17 00:00:00 2001 +From: Kishon Vijay Abraham I +Date: Tue, 17 Mar 2020 15:31:54 +0530 +Subject: misc: pci_endpoint_test: Avoid using module parameter to determine irqtype + +From: Kishon Vijay Abraham I + +commit b2ba9225e0313b1de631a44b7b48c109032bffec upstream. + +commit e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") +uses module parameter 'irqtype' in pci_endpoint_test_set_irq() +to check if IRQ vectors of a particular type (MSI or MSI-X or +LEGACY) is already allocated. However with multi-function devices, +'irqtype' will not correctly reflect the IRQ type of the PCI device. + +Fix it here by adding 'irqtype' for each PCI device to show the +IRQ type of a particular PCI device. + +Fixes: e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") +Signed-off-by: Kishon Vijay Abraham I +Signed-off-by: Lorenzo Pieralisi +Cc: stable@vger.kernel.org # v4.19+ +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/misc/pci_endpoint_test.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +--- a/drivers/misc/pci_endpoint_test.c ++++ b/drivers/misc/pci_endpoint_test.c +@@ -98,6 +98,7 @@ struct pci_endpoint_test { + struct completion irq_raised; + int last_irq; + int num_irqs; ++ int irq_type; + /* mutex to protect the ioctls */ + struct mutex mutex; + struct miscdevice miscdev; +@@ -157,6 +158,7 @@ static void pci_endpoint_test_free_irq_v + struct pci_dev *pdev = test->pdev; + + pci_free_irq_vectors(pdev); ++ test->irq_type = IRQ_TYPE_UNDEFINED; + } + + static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, +@@ -191,6 +193,8 @@ static bool pci_endpoint_test_alloc_irq_ + irq = 0; + res = false; + } ++ ++ test->irq_type = type; + test->num_irqs = irq; + + return res; +@@ -330,6 +334,7 @@ static bool pci_endpoint_test_copy(struc + dma_addr_t orig_dst_phys_addr; + size_t offset; + size_t alignment = test->alignment; ++ int irq_type = test->irq_type; + u32 src_crc32; + u32 dst_crc32; + +@@ -426,6 +431,7 @@ static bool pci_endpoint_test_write(stru + dma_addr_t orig_phys_addr; + size_t offset; + size_t alignment = test->alignment; ++ int irq_type = test->irq_type; + u32 crc32; + + if (size > SIZE_MAX - alignment) +@@ -494,6 +500,7 @@ static bool pci_endpoint_test_read(struc + dma_addr_t orig_phys_addr; + size_t offset; + size_t alignment = test->alignment; ++ int irq_type = test->irq_type; + u32 crc32; + + if (size > SIZE_MAX - alignment) +@@ -555,7 +562,7 @@ static bool pci_endpoint_test_set_irq(st + return false; + } + +- if (irq_type == req_irq_type) ++ if (test->irq_type == req_irq_type) + return true; + + pci_endpoint_test_release_irq(test); +@@ -567,12 +574,10 @@ static bool pci_endpoint_test_set_irq(st + if (!pci_endpoint_test_request_irq(test)) + goto err; + +- irq_type = req_irq_type; + return true; + + err: + pci_endpoint_test_free_irq_vectors(test); +- irq_type = IRQ_TYPE_UNDEFINED; + return false; + } + +@@ -652,6 +657,7 @@ static int pci_endpoint_test_probe(struc + test->test_reg_bar = 0; + test->alignment = 0; + test->pdev = pdev; ++ test->irq_type = IRQ_TYPE_UNDEFINED; + + if (no_msi) + irq_type = IRQ_TYPE_LEGACY; diff --git a/queue-5.4/misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch b/queue-5.4/misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch new file mode 100644 index 00000000000..a6547e8250a --- /dev/null +++ b/queue-5.4/misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch @@ -0,0 +1,38 @@ +From 6b443e5c80b67a7b8a85b33d052d655ef9064e90 Mon Sep 17 00:00:00 2001 +From: Kishon Vijay Abraham I +Date: Tue, 17 Mar 2020 15:31:57 +0530 +Subject: misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices + +From: Kishon Vijay Abraham I + +commit 6b443e5c80b67a7b8a85b33d052d655ef9064e90 upstream. + +Adding more than 10 pci-endpoint-test devices results in +"kobject_add_internal failed for pci-endpoint-test.1 with -EEXIST, don't +try to register things with the same name in the same directory". This +is because commit 2c156ac71c6b ("misc: Add host side PCI driver for PCI +test function device") limited the length of the "name" to 20 characters. +Change the length of the name to 24 in order to support upto 10000 +pci-endpoint-test devices. + +Fixes: 2c156ac71c6b ("misc: Add host side PCI driver for PCI test function device") +Signed-off-by: Kishon Vijay Abraham I +Signed-off-by: Lorenzo Pieralisi +Cc: stable@vger.kernel.org # v4.14+ +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/misc/pci_endpoint_test.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/misc/pci_endpoint_test.c ++++ b/drivers/misc/pci_endpoint_test.c +@@ -633,7 +633,7 @@ static int pci_endpoint_test_probe(struc + { + int err; + int id; +- char name[20]; ++ char name[24]; + enum pci_barno bar; + void __iomem *base; + struct device *dev = &pdev->dev; diff --git a/queue-5.4/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch b/queue-5.4/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch new file mode 100644 index 00000000000..f4c8353ade0 --- /dev/null +++ b/queue-5.4/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch @@ -0,0 +1,32 @@ +From 10cea23b6aae15e8324f4101d785687f2c514fe5 Mon Sep 17 00:00:00 2001 +From: YueHaibing +Date: Thu, 26 Mar 2020 11:26:18 +0800 +Subject: misc: rtsx: set correct pcr_ops for rts522A + +From: YueHaibing + +commit 10cea23b6aae15e8324f4101d785687f2c514fe5 upstream. + +rts522a should use rts522a_pcr_ops, which is +diffrent with rts5227 in phy/hw init setting. + +Fixes: ce6a5acc9387 ("mfd: rtsx: Add support for rts522A") +Signed-off-by: YueHaibing +Cc: stable +Link: https://lore.kernel.org/r/20200326032618.20472-1-yuehaibing@huawei.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/misc/cardreader/rts5227.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/misc/cardreader/rts5227.c ++++ b/drivers/misc/cardreader/rts5227.c +@@ -394,6 +394,7 @@ static const struct pcr_ops rts522a_pcr_ + void rts522a_init_params(struct rtsx_pcr *pcr) + { + rts5227_init_params(pcr); ++ pcr->ops = &rts522a_pcr_ops; + pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11); + pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3; + diff --git a/queue-5.4/nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch b/queue-5.4/nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch new file mode 100644 index 00000000000..b46f60a8cca --- /dev/null +++ b/queue-5.4/nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch @@ -0,0 +1,48 @@ +From 3c91ef69a3e94f78546b246225ed573fbf1735b4 Mon Sep 17 00:00:00 2001 +From: Nicholas Johnson +Date: Tue, 10 Mar 2020 13:22:52 +0000 +Subject: nvmem: check for NULL reg_read and reg_write before dereferencing + +From: Nicholas Johnson + +commit 3c91ef69a3e94f78546b246225ed573fbf1735b4 upstream. + +Return -EPERM if reg_read is NULL in bin_attr_nvmem_read() or if +reg_write is NULL in bin_attr_nvmem_write(). + +This prevents NULL dereferences such as the one described in +03cd45d2e219 ("thunderbolt: Prevent crash if non-active NVMem file is +read") + +Signed-off-by: Nicholas Johnson +Cc: stable +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20200310132257.23358-10-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvmem/nvmem-sysfs.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/nvmem/nvmem-sysfs.c ++++ b/drivers/nvmem/nvmem-sysfs.c +@@ -56,6 +56,9 @@ static ssize_t bin_attr_nvmem_read(struc + + count = round_down(count, nvmem->word_size); + ++ if (!nvmem->reg_read) ++ return -EPERM; ++ + rc = nvmem->reg_read(nvmem->priv, pos, buf, count); + + if (rc) +@@ -90,6 +93,9 @@ static ssize_t bin_attr_nvmem_write(stru + + count = round_down(count, nvmem->word_size); + ++ if (!nvmem->reg_write) ++ return -EPERM; ++ + rc = nvmem->reg_write(nvmem->priv, pos, buf, count); + + if (rc) diff --git a/queue-5.4/pci-sysfs-revert-rescan-file-renames.patch b/queue-5.4/pci-sysfs-revert-rescan-file-renames.patch new file mode 100644 index 00000000000..fccc1a6baf6 --- /dev/null +++ b/queue-5.4/pci-sysfs-revert-rescan-file-renames.patch @@ -0,0 +1,60 @@ +From bd641fd8303a371e789e924291086268256766b0 Mon Sep 17 00:00:00 2001 +From: Kelsey Skunberg +Date: Wed, 25 Mar 2020 09:17:08 -0600 +Subject: PCI: sysfs: Revert "rescan" file renames + +From: Kelsey Skunberg + +commit bd641fd8303a371e789e924291086268256766b0 upstream. + +We changed these sysfs filenames: + + .../pci_bus//rescan -> .../pci_bus//bus_rescan + ...//rescan -> ...//dev_rescan + +and Ruslan reported [1] that this broke a userspace application. + +Revert these name changes so both files are named "rescan" again. + +Note that we have to use __ATTR() to assign custom C symbols, i.e., +"struct device_attribute ". + +[1] https://lore.kernel.org/r/CAB=otbSYozS-ZfxB0nCiNnxcbqxwrHOSYxJJtDKa63KzXbXgpw@mail.gmail.com + +[bhelgaas: commit log, use __ATTR() both places so we don't have to rename +the attributes] +Fixes: 8bdfa145f582 ("PCI: sysfs: Define device attributes with DEVICE_ATTR*()") +Fixes: 4e2b79436e4f ("PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO()") +Link: https://lore.kernel.org/r/20200325151708.32612-1-skunberg.kelsey@gmail.com +Signed-off-by: Kelsey Skunberg +Signed-off-by: Bjorn Helgaas +Reviewed-by: Greg Kroah-Hartman +Cc: stable@vger.kernel.org # v5.4+ +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/pci/pci-sysfs.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/pci/pci-sysfs.c ++++ b/drivers/pci/pci-sysfs.c +@@ -464,7 +464,8 @@ static ssize_t dev_rescan_store(struct d + } + return count; + } +-static DEVICE_ATTR_WO(dev_rescan); ++static struct device_attribute dev_attr_dev_rescan = __ATTR(rescan, 0200, NULL, ++ dev_rescan_store); + + static ssize_t remove_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +@@ -501,7 +502,8 @@ static ssize_t bus_rescan_store(struct d + } + return count; + } +-static DEVICE_ATTR_WO(bus_rescan); ++static struct device_attribute dev_attr_bus_rescan = __ATTR(rescan, 0200, NULL, ++ bus_rescan_store); + + #if defined(CONFIG_PM) && defined(CONFIG_ACPI) + static ssize_t d3cold_allowed_store(struct device *dev, diff --git a/queue-5.4/power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch b/queue-5.4/power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch new file mode 100644 index 00000000000..25d4766da62 --- /dev/null +++ b/queue-5.4/power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch @@ -0,0 +1,178 @@ +From 9c80662a74cd2a5d1113f5c69d027face963a556 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sun, 23 Feb 2020 16:32:08 +0100 +Subject: power: supply: axp288_charger: Add special handling for HP Pavilion x2 10 + +From: Hans de Goede + +commit 9c80662a74cd2a5d1113f5c69d027face963a556 upstream. + +Some HP Pavilion x2 10 models use an AXP288 for charging and fuel-gauge. +We use a native power_supply / PMIC driver in this case, because on most +models with an AXP288 the ACPI AC / Battery code is either completely +missing or relies on custom / proprietary ACPI OpRegions which Linux +does not implement. + +The native drivers mostly work fine, but there are 2 problems: + +1. These model uses a Type-C connector for charging which the AXP288 does +not support. As long as a Type-A charger (which uses the USB data pins for +charger type detection) is used everything is fine. But if a Type-C +charger is used (such as the charger shipped with the device) then the +charger is not recognized. + +So we end up slowly discharging the device even though a charger is +connected, because we are limiting the current from the charger to 500mA. +To make things worse this happens with the device's official charger. + +Looking at the ACPI tables HP has "solved" the problem of the AXP288 not +being able to recognize Type-C chargers by simply always programming the +input-current-limit at 3000mA and relying on a Vhold setting of 4.7V +(normally 4.4V) to limit the current intake if the charger cannot handle +this. + +2. If no charger is connected when the machine boots then it boots with the +vbus-path disabled. On other devices this is done when a 5V boost converter +is active to avoid the PMIC trying to charge from the 5V boost output. +This is done when an OTG host cable is inserted and the ID pin on the +micro-B receptacle is pulled low, the ID pin has an ACPI event handler +associated with it which re-enables the vbus-path when the ID pin is pulled +high when the OTG cable is removed. The Type-C connector has no ID pin, +there is no ID pin handler and there appears to be no 5V boost converter, +so we end up not charging because the vbus-path is disabled, until we +unplug the charger which automatically clears the vbus-path disable bit and +then on the second plug-in of the adapter we start charging. + +The HP Pavilion x2 10 models with an AXP288 do have mostly working ACPI +AC / Battery code which does not rely on custom / proprietary ACPI +OpRegions. So one possible solution would be to blacklist the AXP288 +native power_supply drivers and add the HP Pavilion x2 10 with AXP288 +DMI ids to the list of devices which should use the ACPI AC / Battery +code even though they have an AXP288 PMIC. This would require changes to +4 files: drivers/acpi/ac.c, drivers/power/supply/axp288_charger.c, +drivers/acpi/battery.c and drivers/power/supply/axp288_fuel_gauge.c. + +Beside needing adding the same DMI matches to 4 different files, this +approach also triggers problem 2. from above, but then when suspended, +during suspend the machine will not wakeup because the vbus path is +disabled by the AML code when not charging, so the Vbus low-to-high +IRQ is not triggered, the CPU never wakes up and the device does not +charge even though the user likely things it is charging, esp. since +the charge status LED is directly coupled to an adapter being plugged +in and does not reflect actual charging. + +This could be worked by enabling vbus-path explicitly from say the +axp288_charger driver's suspend handler. + +So neither situation is ideal, in both cased we need to explicitly enable +the vbus-path to work around different variants of problem 2 above, this +requires a quirk in the axp288_charger code. + +If we go the route of using the ACPI AC / Battery drivers then we need +modifications to 3 other drivers; and we need to partially disable the +axp288_charger code, while at the same time keeping it around to enable +vbus-path on suspend. + +OTOH we can copy the hardcoding of 3A input-current-limit (we never touch +Vhold, so that would stay at 4.7V) to the axp288_charger code, which needs +changes regardless, then we concentrate all special handling of this +interesting device model in the axp288_charger code. That is what this +commit does. + +Cc: stable@vger.kernel.org +BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791098 +Signed-off-by: Hans de Goede +Signed-off-by: Sebastian Reichel +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/power/supply/axp288_charger.c | 57 +++++++++++++++++++++++++++++++++- + 1 file changed, 56 insertions(+), 1 deletion(-) + +--- a/drivers/power/supply/axp288_charger.c ++++ b/drivers/power/supply/axp288_charger.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #define PS_STAT_VBUS_TRIGGER BIT(0) + #define PS_STAT_BAT_CHRG_DIR BIT(2) +@@ -545,6 +546,49 @@ out: + return IRQ_HANDLED; + } + ++/* ++ * The HP Pavilion x2 10 series comes in a number of variants: ++ * Bay Trail SoC + AXP288 PMIC, DMI_BOARD_NAME: "815D" ++ * Cherry Trail SoC + AXP288 PMIC, DMI_BOARD_NAME: "813E" ++ * Cherry Trail SoC + TI PMIC, DMI_BOARD_NAME: "827C" or "82F4" ++ * ++ * The variants with the AXP288 PMIC are all kinds of special: ++ * ++ * 1. All variants use a Type-C connector which the AXP288 does not support, so ++ * when using a Type-C charger it is not recognized. Unlike most AXP288 devices, ++ * this model actually has mostly working ACPI AC / Battery code, the ACPI code ++ * "solves" this by simply setting the input_current_limit to 3A. ++ * There are still some issues with the ACPI code, so we use this native driver, ++ * and to solve the charging not working (500mA is not enough) issue we hardcode ++ * the 3A input_current_limit like the ACPI code does. ++ * ++ * 2. If no charger is connected the machine boots with the vbus-path disabled. ++ * Normally this is done when a 5V boost converter is active to avoid the PMIC ++ * trying to charge from the 5V boost converter's output. This is done when ++ * an OTG host cable is inserted and the ID pin on the micro-B receptacle is ++ * pulled low and the ID pin has an ACPI event handler associated with it ++ * which re-enables the vbus-path when the ID pin is pulled high when the ++ * OTG host cable is removed. The Type-C connector has no ID pin, there is ++ * no ID pin handler and there appears to be no 5V boost converter, so we ++ * end up not charging because the vbus-path is disabled, until we unplug ++ * the charger which automatically clears the vbus-path disable bit and then ++ * on the second plug-in of the adapter we start charging. To solve the not ++ * charging on first charger plugin we unconditionally enable the vbus-path at ++ * probe on this model, which is safe since there is no 5V boost converter. ++ */ ++static const struct dmi_system_id axp288_hp_x2_dmi_ids[] = { ++ { ++ /* ++ * Bay Trail model has "Hewlett-Packard" as sys_vendor, Cherry ++ * Trail model has "HP", so we only match on product_name. ++ */ ++ .matches = { ++ DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), ++ }, ++ }, ++ {} /* Terminating entry */ ++}; ++ + static void axp288_charger_extcon_evt_worker(struct work_struct *work) + { + struct axp288_chrg_info *info = +@@ -568,7 +612,11 @@ static void axp288_charger_extcon_evt_wo + } + + /* Determine cable/charger type */ +- if (extcon_get_state(edev, EXTCON_CHG_USB_SDP) > 0) { ++ if (dmi_check_system(axp288_hp_x2_dmi_ids)) { ++ /* See comment above axp288_hp_x2_dmi_ids declaration */ ++ dev_dbg(&info->pdev->dev, "HP X2 with Type-C, setting inlmt to 3A\n"); ++ current_limit = 3000000; ++ } else if (extcon_get_state(edev, EXTCON_CHG_USB_SDP) > 0) { + dev_dbg(&info->pdev->dev, "USB SDP charger is connected\n"); + current_limit = 500000; + } else if (extcon_get_state(edev, EXTCON_CHG_USB_CDP) > 0) { +@@ -685,6 +733,13 @@ static int charger_init_hw_regs(struct a + return ret; + } + ++ if (dmi_check_system(axp288_hp_x2_dmi_ids)) { ++ /* See comment above axp288_hp_x2_dmi_ids declaration */ ++ ret = axp288_charger_vbus_path_select(info, true); ++ if (ret < 0) ++ return ret; ++ } ++ + /* Read current charge voltage and current limit */ + ret = regmap_read(info->regmap, AXP20X_CHRG_CTRL1, &val); + if (ret < 0) { diff --git a/queue-5.4/series b/queue-5.4/series index 8f3cf52c01b..c133d17747e 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -12,3 +12,12 @@ net-mlx5e-ktls-fix-tcp-seq-off-by-1-issue-in-tx-resy.patch xarray-fix-xa_find_next-for-large-multi-index-entrie.patch padata-fix-uninitialized-return-value-in-padata_repl.patch brcmfmac-abort-and-release-host-after-error.patch +misc-rtsx-set-correct-pcr_ops-for-rts522a.patch +misc-pci_endpoint_test-fix-to-support-10-pci-endpoint-test-devices.patch +misc-pci_endpoint_test-avoid-using-module-parameter-to-determine-irqtype.patch +pci-sysfs-revert-rescan-file-renames.patch +coresight-do-not-use-the-bit-macro-in-the-uapi-header.patch +mei-me-add-cedar-fork-device-ids.patch +nvmem-check-for-null-reg_read-and-reg_write-before-dereferencing.patch +extcon-axp288-add-wakeup-support.patch +power-supply-axp288_charger-add-special-handling-for-hp-pavilion-x2-10.patch -- 2.47.3