]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Jan 2019 17:44:29 +0000 (18:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Jan 2019 17:44:29 +0000 (18:44 +0100)
added patches:
acpi-pmic-xpower-fix-ts-pin-current-source-handling.patch
acpi-power-skip-duplicate-power-resource-references-in-_prx.patch
i2c-dev-prevent-adapter-retries-and-timeout-being-set-as-minus-value.patch

queue-4.14/acpi-pmic-xpower-fix-ts-pin-current-source-handling.patch [new file with mode: 0644]
queue-4.14/acpi-power-skip-duplicate-power-resource-references-in-_prx.patch [new file with mode: 0644]
queue-4.14/i2c-dev-prevent-adapter-retries-and-timeout-being-set-as-minus-value.patch [new file with mode: 0644]
queue-4.14/series

diff --git a/queue-4.14/acpi-pmic-xpower-fix-ts-pin-current-source-handling.patch b/queue-4.14/acpi-pmic-xpower-fix-ts-pin-current-source-handling.patch
new file mode 100644 (file)
index 0000000..0a390ed
--- /dev/null
@@ -0,0 +1,122 @@
+From 2b531d71595d2b5b12782a49b23c335869e2621e Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 4 Jan 2019 23:10:54 +0100
+Subject: ACPI / PMIC: xpower: Fix TS-pin current-source handling
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit 2b531d71595d2b5b12782a49b23c335869e2621e upstream.
+
+The current-source used for the battery temp-sensor (TS) is shared with the
+GPADC. For proper fuel-gauge and charger operation the TS current-source
+needs to be permanently on. But to read the GPADC we need to temporary
+switch the TS current-source to ondemand, so that the GPADC can use it,
+otherwise we will always read an all 0 value.
+
+The switching from on to on-ondemand is not necessary when the TS
+current-source is off (this happens on devices which do not have a TS).
+
+Prior to this commit there were 2 issues with our handling of the TS
+current-source switching:
+
+ 1) We were writing hardcoded values to the ADC TS pin-ctrl register,
+ overwriting various other unrelated bits. Specifically we were overwriting
+ the current-source setting for the TS and GPIO0 pins, forcing it to 80ųA
+ independent of its original setting. On a Chuwi Vi10 tablet this was
+ causing us to get a too high adc value (due to a too high current-source)
+ resulting in acpi_lpat_raw_to_temp() returning -ENOENT, resulting in:
+
+ACPI Error: AE_ERROR, Returned by Handler for [UserDefinedRegion]
+ACPI Error: Method parse/execution failed \_SB.SXP1._TMP, AE_ERROR
+
+This commit fixes this by using regmap_update_bits to change only the
+relevant bits.
+
+ 2) At the end of intel_xpower_pmic_get_raw_temp() we were unconditionally
+ enabling the TS current-source even on devices where the TS-pin is not used
+ and the current-source thus was off on entry of the function.
+
+This commit fixes this by checking if the TS current-source is off when
+entering intel_xpower_pmic_get_raw_temp() and if so it is left as is.
+
+Fixes: 58eefe2f3f53 (ACPI / PMIC: xpower: Do pinswitch ... reading GPADC)
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Cc: 4.14+ <stable@vger.kernel.org> # 4.14+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/pmic/intel_pmic_xpower.c |   41 +++++++++++++++++++++++++++-------
+ 1 file changed, 33 insertions(+), 8 deletions(-)
+
+--- a/drivers/acpi/pmic/intel_pmic_xpower.c
++++ b/drivers/acpi/pmic/intel_pmic_xpower.c
+@@ -27,8 +27,11 @@
+ #define GPI1_LDO_ON           (3 << 0)
+ #define GPI1_LDO_OFF          (4 << 0)
+-#define AXP288_ADC_TS_PIN_GPADC       0xf2
+-#define AXP288_ADC_TS_PIN_ON  0xf3
++#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK             GENMASK(1, 0)
++#define AXP288_ADC_TS_CURRENT_OFF                     (0 << 0)
++#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING                (1 << 0)
++#define AXP288_ADC_TS_CURRENT_ON_ONDEMAND             (2 << 0)
++#define AXP288_ADC_TS_CURRENT_ON                      (3 << 0)
+ static struct pmic_table power_table[] = {
+       {
+@@ -211,22 +214,44 @@ static int intel_xpower_pmic_update_powe
+  */
+ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
+ {
++      int ret, adc_ts_pin_ctrl;
+       u8 buf[2];
+-      int ret;
+-      ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL,
+-                         AXP288_ADC_TS_PIN_GPADC);
++      /*
++       * The current-source used for the battery temp-sensor (TS) is shared
++       * with the GPADC. For proper fuel-gauge and charger operation the TS
++       * current-source needs to be permanently on. But to read the GPADC we
++       * need to temporary switch the TS current-source to ondemand, so that
++       * the GPADC can use it, otherwise we will always read an all 0 value.
++       *
++       * Note that the switching from on to on-ondemand is not necessary
++       * when the TS current-source is off (this happens on devices which
++       * do not use the TS-pin).
++       */
++      ret = regmap_read(regmap, AXP288_ADC_TS_PIN_CTRL, &adc_ts_pin_ctrl);
+       if (ret)
+               return ret;
+-      /* After switching to the GPADC pin give things some time to settle */
+-      usleep_range(6000, 10000);
++      if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
++              ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
++                                       AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
++                                       AXP288_ADC_TS_CURRENT_ON_ONDEMAND);
++              if (ret)
++                      return ret;
++
++              /* Wait a bit after switching the current-source */
++              usleep_range(6000, 10000);
++      }
+       ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
+       if (ret == 0)
+               ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
+-      regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON);
++      if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
++              regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
++                                 AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
++                                 AXP288_ADC_TS_CURRENT_ON);
++      }
+       return ret;
+ }
diff --git a/queue-4.14/acpi-power-skip-duplicate-power-resource-references-in-_prx.patch b/queue-4.14/acpi-power-skip-duplicate-power-resource-references-in-_prx.patch
new file mode 100644 (file)
index 0000000..db6e6af
--- /dev/null
@@ -0,0 +1,87 @@
+From 7d7b467cb95bf29597b417d4990160d4ea6d69b9 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Sun, 30 Dec 2018 18:25:00 +0100
+Subject: ACPI: power: Skip duplicate power resource references in _PRx
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit 7d7b467cb95bf29597b417d4990160d4ea6d69b9 upstream.
+
+Some ACPI tables contain duplicate power resource references like this:
+
+        Name (_PR0, Package (0x04)  // _PR0: Power Resources for D0
+        {
+            P28P,
+            P18P,
+            P18P,
+            CLK4
+        })
+
+This causes a WARN_ON in sysfs_add_link_to_group() because we end up
+adding a link to the same acpi_device twice:
+
+sysfs: cannot create duplicate filename '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/808622C1:00/OVTI2680:00/power_resources_D0/LNXPOWER:0a'
+CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.12-301.fc29.x86_64 #1
+Hardware name: Insyde CherryTrail/Type2 - Board Product Name, BIOS jumperx.T87.KFBNEEA02 04/13/2016
+Call Trace:
+ dump_stack+0x5c/0x80
+ sysfs_warn_dup.cold.3+0x17/0x2a
+ sysfs_do_create_link_sd.isra.2+0xa9/0xb0
+ sysfs_add_link_to_group+0x30/0x50
+ acpi_power_expose_list+0x74/0xa0
+ acpi_power_add_remove_device+0x50/0xa0
+ acpi_add_single_object+0x26b/0x5f0
+ acpi_bus_check_add+0xc4/0x250
+ ...
+
+To address this issue, make acpi_extract_power_resources() check for
+duplicates and simply skip them when found.
+
+Cc: All applicable <stable@vger.kernel.org>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+[ rjw: Subject & changelog, comments ]
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/power.c |   22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+--- a/drivers/acpi/power.c
++++ b/drivers/acpi/power.c
+@@ -131,6 +131,23 @@ void acpi_power_resources_list_free(stru
+       }
+ }
++static bool acpi_power_resource_is_dup(union acpi_object *package,
++                                     unsigned int start, unsigned int i)
++{
++      acpi_handle rhandle, dup;
++      unsigned int j;
++
++      /* The caller is expected to check the package element types */
++      rhandle = package->package.elements[i].reference.handle;
++      for (j = start; j < i; j++) {
++              dup = package->package.elements[j].reference.handle;
++              if (dup == rhandle)
++                      return true;
++      }
++
++      return false;
++}
++
+ int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
+                                struct list_head *list)
+ {
+@@ -150,6 +167,11 @@ int acpi_extract_power_resources(union a
+                       err = -ENODEV;
+                       break;
+               }
++
++              /* Some ACPI tables contain duplicate power resource references */
++              if (acpi_power_resource_is_dup(package, start, i))
++                      continue;
++
+               err = acpi_add_power_resource(rhandle);
+               if (err)
+                       break;
diff --git a/queue-4.14/i2c-dev-prevent-adapter-retries-and-timeout-being-set-as-minus-value.patch b/queue-4.14/i2c-dev-prevent-adapter-retries-and-timeout-being-set-as-minus-value.patch
new file mode 100644 (file)
index 0000000..cbc6464
--- /dev/null
@@ -0,0 +1,50 @@
+From 6ebec961d59bccf65d08b13fc1ad4e6272a89338 Mon Sep 17 00:00:00 2001
+From: Yi Zeng <yizeng@asrmicro.com>
+Date: Wed, 9 Jan 2019 15:33:07 +0800
+Subject: i2c: dev: prevent adapter retries and timeout being set as minus value
+
+From: Yi Zeng <yizeng@asrmicro.com>
+
+commit 6ebec961d59bccf65d08b13fc1ad4e6272a89338 upstream.
+
+If adapter->retries is set to a minus value from user space via ioctl,
+it will make __i2c_transfer and __i2c_smbus_xfer skip the calling to
+adapter->algo->master_xfer and adapter->algo->smbus_xfer that is
+registered by the underlying bus drivers, and return value 0 to all the
+callers. The bus driver will never be accessed anymore by all users,
+besides, the users may still get successful return value without any
+error or information log print out.
+
+If adapter->timeout is set to minus value from user space via ioctl,
+it will make the retrying loop in __i2c_transfer and __i2c_smbus_xfer
+always break after the the first try, due to the time_after always
+returns true.
+
+Signed-off-by: Yi Zeng <yizeng@asrmicro.com>
+[wsa: minor grammar updates to commit message]
+Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/i2c/i2c-dev.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/i2c/i2c-dev.c
++++ b/drivers/i2c/i2c-dev.c
+@@ -461,9 +461,15 @@ static long i2cdev_ioctl(struct file *fi
+               return i2cdev_ioctl_smbus(client, arg);
+       case I2C_RETRIES:
++              if (arg > INT_MAX)
++                      return -EINVAL;
++
+               client->adapter->retries = arg;
+               break;
+       case I2C_TIMEOUT:
++              if (arg > INT_MAX)
++                      return -EINVAL;
++
+               /* For historical reasons, user-space sets the timeout
+                * value in units of 10 ms.
+                */
index 7f0f9325126f774d915311d9a7b6b635b59c5538..ddf3a0ebc13d3e367ee00c67c5486aaf036abf94 100644 (file)
@@ -13,3 +13,6 @@ usb-add-usb_quirk_delay_ctrl_msg-quirk-for-corsair-k70-rgb.patch
 slab-alien-caches-must-not-be-initialized-if-the-allocation-of-the-alien-cache-failed.patch
 mm-page_mapped-don-t-assume-compound-page-is-huge-or-thp.patch
 mm-memcg-fix-reclaim-deadlock-with-writeback.patch
+acpi-power-skip-duplicate-power-resource-references-in-_prx.patch
+acpi-pmic-xpower-fix-ts-pin-current-source-handling.patch
+i2c-dev-prevent-adapter-retries-and-timeout-being-set-as-minus-value.patch