From: Greg Kroah-Hartman Date: Mon, 22 Mar 2021 09:13:24 +0000 (+0100) Subject: 5.10-stable patches X-Git-Tag: v4.4.263~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0460a6f0de3c43ff41d9e1ff3a7333c9f39b55dc;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: counter-stm32-timer-cnt-fix-ceiling-miss-alignment-with-reload-register.patch counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch iio-adc-ab8500-gpadc-fix-off-by-10-to-3.patch iio-adc-ad7949-fix-wrong-adc-result-due-to-incorrect-bit-mask.patch iio-adc-adi-axi-adc-add-proper-kconfig-dependencies.patch iio-adc-qcom-spmi-vadc-add-default-scale-to-lr_mux2_bat_id-channel.patch iio-adc-stm32-adc-add-has_iomem-dependency.patch iio-adis16400-fix-an-error-code-in-adis16400_initial_setup.patch iio-gyro-mpu3050-fix-error-handling-in-mpu3050_trigger_handler.patch iio-hid-sensor-humidity-fix-alignment-issue-of-timestamp-channel.patch iio-hid-sensor-prox-fix-scale-not-correct-issue.patch iio-hid-sensor-temperature-fix-issues-of-timestamp-channel.patch thunderbolt-increase-runtime-pm-reference-count-on-dp-tunnel-discovery.patch thunderbolt-initialize-hopid-idas-in-tb_switch_alloc.patch --- diff --git a/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-miss-alignment-with-reload-register.patch b/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-miss-alignment-with-reload-register.patch new file mode 100644 index 00000000000..1427a8fcd99 --- /dev/null +++ b/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-miss-alignment-with-reload-register.patch @@ -0,0 +1,85 @@ +From b14d72ac731753708a7c1a6b3657b9312b6f0042 Mon Sep 17 00:00:00 2001 +From: Fabrice Gasnier +Date: Wed, 3 Mar 2021 18:49:49 +0100 +Subject: counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register + +From: Fabrice Gasnier + +commit b14d72ac731753708a7c1a6b3657b9312b6f0042 upstream. + +Ceiling value may be miss-aligned with what's actually configured into the +ARR register. This is seen after probe as currently the ARR value is zero, +whereas ceiling value is set to the maximum. So: +- reading ceiling reports zero +- in case the counter gets enabled without any prior configuration, + it won't count. +- in case the function gets set by the user 1st, (priv->ceiling) is used. + +Fix it by getting rid of the cached "priv->ceiling" variable. Rather use +the ARR register value directly by using regmap read or write when needed. +There should be no drawback on performance as priv->ceiling isn't used in +performance critical path. +There's also no point in writing ARR while setting function (sms), so +it can be safely removed. + +Fixes: ad29937e206f ("counter: Add STM32 Timer quadrature encoder") +Suggested-by: William Breathitt Gray +Signed-off-by: Fabrice Gasnier +Acked-by: William Breathitt Gray +Cc: +Link: https://lore.kernel.org/r/1614793789-10346-1-git-send-email-fabrice.gasnier@foss.st.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/counter/stm32-timer-cnt.c | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +--- a/drivers/counter/stm32-timer-cnt.c ++++ b/drivers/counter/stm32-timer-cnt.c +@@ -31,7 +31,6 @@ struct stm32_timer_cnt { + struct counter_device counter; + struct regmap *regmap; + struct clk *clk; +- u32 ceiling; + u32 max_arr; + bool enabled; + struct stm32_timer_regs bak; +@@ -75,8 +74,10 @@ static int stm32_count_write(struct coun + const unsigned long val) + { + struct stm32_timer_cnt *const priv = counter->priv; ++ u32 ceiling; + +- if (val > priv->ceiling) ++ regmap_read(priv->regmap, TIM_ARR, &ceiling); ++ if (val > ceiling) + return -EINVAL; + + return regmap_write(priv->regmap, TIM_CNT, val); +@@ -138,10 +139,6 @@ static int stm32_count_function_set(stru + + regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0); + +- /* TIMx_ARR register shouldn't be buffered (ARPE=0) */ +- regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); +- regmap_write(priv->regmap, TIM_ARR, priv->ceiling); +- + regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, sms); + + /* Make sure that registers are updated */ +@@ -199,7 +196,6 @@ static ssize_t stm32_count_ceiling_write + regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); + regmap_write(priv->regmap, TIM_ARR, ceiling); + +- priv->ceiling = ceiling; + return len; + } + +@@ -374,7 +370,6 @@ static int stm32_timer_cnt_probe(struct + + priv->regmap = ddata->regmap; + priv->clk = ddata->clk; +- priv->ceiling = ddata->max_arr; + priv->max_arr = ddata->max_arr; + + priv->counter.name = dev_name(dev); diff --git a/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch b/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch new file mode 100644 index 00000000000..0709e53b751 --- /dev/null +++ b/queue-5.10/counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch @@ -0,0 +1,55 @@ +From e4c3e133294c0a292d21073899b05ebf530169bd Mon Sep 17 00:00:00 2001 +From: Fabrice Gasnier +Date: Tue, 2 Mar 2021 15:43:55 +0100 +Subject: counter: stm32-timer-cnt: fix ceiling write max value + +From: Fabrice Gasnier + +commit e4c3e133294c0a292d21073899b05ebf530169bd upstream. + +The ceiling value isn't checked before writing it into registers. The user +could write a value higher than the counter resolution (e.g. 16 or 32 bits +indicated by max_arr). This makes most significant bits to be truncated. +Fix it by checking the max_arr to report a range error [1] to the user. + +[1] https://lkml.org/lkml/2021/2/12/358 + +Fixes: ad29937e206f ("counter: Add STM32 Timer quadrature encoder") +Signed-off-by: Fabrice Gasnier +Acked-by: William Breathitt Gray +Cc: +Link: https://lore.kernel.org/r/1614696235-24088-1-git-send-email-fabrice.gasnier@foss.st.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/counter/stm32-timer-cnt.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/counter/stm32-timer-cnt.c ++++ b/drivers/counter/stm32-timer-cnt.c +@@ -32,6 +32,7 @@ struct stm32_timer_cnt { + struct regmap *regmap; + struct clk *clk; + u32 ceiling; ++ u32 max_arr; + bool enabled; + struct stm32_timer_regs bak; + }; +@@ -191,6 +192,9 @@ static ssize_t stm32_count_ceiling_write + if (ret) + return ret; + ++ if (ceiling > priv->max_arr) ++ return -ERANGE; ++ + /* TIMx_ARR register shouldn't be buffered (ARPE=0) */ + regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); + regmap_write(priv->regmap, TIM_ARR, ceiling); +@@ -371,6 +375,7 @@ static int stm32_timer_cnt_probe(struct + priv->regmap = ddata->regmap; + priv->clk = ddata->clk; + priv->ceiling = ddata->max_arr; ++ priv->max_arr = ddata->max_arr; + + priv->counter.name = dev_name(dev); + priv->counter.parent = dev; diff --git a/queue-5.10/iio-adc-ab8500-gpadc-fix-off-by-10-to-3.patch b/queue-5.10/iio-adc-ab8500-gpadc-fix-off-by-10-to-3.patch new file mode 100644 index 00000000000..f8aed084a68 --- /dev/null +++ b/queue-5.10/iio-adc-ab8500-gpadc-fix-off-by-10-to-3.patch @@ -0,0 +1,36 @@ +From 4f5434086d9223f20b3128a7dc78b35271e76655 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Thu, 24 Dec 2020 02:17:00 +0100 +Subject: iio: adc: ab8500-gpadc: Fix off by 10 to 3 + +From: Linus Walleij + +commit 4f5434086d9223f20b3128a7dc78b35271e76655 upstream. + +Fix an off by three orders of magnitude error in the AB8500 +GPADC driver. Luckily it showed up quite quickly when trying +to make use of it. The processed reads were returning +microvolts, microamperes and microcelsius instead of millivolts, +milliamperes and millicelsius as advertised. + +Cc: stable@vger.kernel.org +Fixes: 07063bbfa98e ("iio: adc: New driver for the AB8500 GPADC") +Signed-off-by: Linus Walleij +Link: https://lore.kernel.org/r/20201224011700.1059659-1-linus.walleij@linaro.org +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/ab8500-gpadc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/iio/adc/ab8500-gpadc.c ++++ b/drivers/iio/adc/ab8500-gpadc.c +@@ -918,7 +918,7 @@ static int ab8500_gpadc_read_raw(struct + return processed; + + /* Return millivolt or milliamps or millicentigrades */ +- *val = processed * 1000; ++ *val = processed; + return IIO_VAL_INT; + } + diff --git a/queue-5.10/iio-adc-ad7949-fix-wrong-adc-result-due-to-incorrect-bit-mask.patch b/queue-5.10/iio-adc-ad7949-fix-wrong-adc-result-due-to-incorrect-bit-mask.patch new file mode 100644 index 00000000000..8f7bcfcaa48 --- /dev/null +++ b/queue-5.10/iio-adc-ad7949-fix-wrong-adc-result-due-to-incorrect-bit-mask.patch @@ -0,0 +1,38 @@ +From f890987fac8153227258121740a9609668c427f3 Mon Sep 17 00:00:00 2001 +From: Wilfried Wessner +Date: Mon, 8 Feb 2021 15:27:05 +0100 +Subject: iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask + +From: Wilfried Wessner + +commit f890987fac8153227258121740a9609668c427f3 upstream. + +Fixes a wrong bit mask used for the ADC's result, which was caused by an +improper usage of the GENMASK() macro. The bits higher than ADC's +resolution are undefined and if not masked out correctly, a wrong result +can be given. The GENMASK() macro indexing is zero based, so the mask has +to go from [resolution - 1 , 0]. + +Fixes: 7f40e0614317f ("iio:adc:ad7949: Add AD7949 ADC driver family") +Signed-off-by: Wilfried Wessner +Reviewed-by: Andy Shevchenko +Reviewed-by: Charles-Antoine Couret +Cc: +Link: https://lore.kernel.org/r/20210208142705.GA51260@ubuntu +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/ad7949.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/iio/adc/ad7949.c ++++ b/drivers/iio/adc/ad7949.c +@@ -91,7 +91,7 @@ static int ad7949_spi_read_channel(struc + int ret; + int i; + int bits_per_word = ad7949_adc->resolution; +- int mask = GENMASK(ad7949_adc->resolution, 0); ++ int mask = GENMASK(ad7949_adc->resolution - 1, 0); + struct spi_message msg; + struct spi_transfer tx[] = { + { diff --git a/queue-5.10/iio-adc-adi-axi-adc-add-proper-kconfig-dependencies.patch b/queue-5.10/iio-adc-adi-axi-adc-add-proper-kconfig-dependencies.patch new file mode 100644 index 00000000000..fdbfc4856e5 --- /dev/null +++ b/queue-5.10/iio-adc-adi-axi-adc-add-proper-kconfig-dependencies.patch @@ -0,0 +1,38 @@ +From be24c65e9fa2486bb8ec98d9f592bdcf04bedd88 Mon Sep 17 00:00:00 2001 +From: Alexandru Ardelean +Date: Wed, 10 Feb 2021 12:50:44 +0200 +Subject: iio: adc: adi-axi-adc: add proper Kconfig dependencies + +From: Alexandru Ardelean + +commit be24c65e9fa2486bb8ec98d9f592bdcf04bedd88 upstream. + +The ADI AXI ADC driver requires IO mem access and OF to work. This change +adds these dependencies to the Kconfig symbol of the driver. + +This was also found via the lkp bot, as the +devm_platform_ioremap_resource() symbol was not found at link-time on the +S390 architecture. + +Fixes: ef04070692a21 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core") +Reported-by: kernel test robot +Signed-off-by: Alexandru Ardelean +Cc: +Link: https://lore.kernel.org/r/20210210105044.48914-1-alexandru.ardelean@analog.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/Kconfig | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/iio/adc/Kconfig ++++ b/drivers/iio/adc/Kconfig +@@ -266,6 +266,8 @@ config ADI_AXI_ADC + select IIO_BUFFER + select IIO_BUFFER_HW_CONSUMER + select IIO_BUFFER_DMAENGINE ++ depends on HAS_IOMEM ++ depends on OF + help + Say yes here to build support for Analog Devices Generic + AXI ADC IP core. The IP core is used for interfacing with diff --git a/queue-5.10/iio-adc-qcom-spmi-vadc-add-default-scale-to-lr_mux2_bat_id-channel.patch b/queue-5.10/iio-adc-qcom-spmi-vadc-add-default-scale-to-lr_mux2_bat_id-channel.patch new file mode 100644 index 00000000000..dfb7e2ced5b --- /dev/null +++ b/queue-5.10/iio-adc-qcom-spmi-vadc-add-default-scale-to-lr_mux2_bat_id-channel.patch @@ -0,0 +1,48 @@ +From 7d200b283aa049fcda0d43dd6e03e9e783d2799c Mon Sep 17 00:00:00 2001 +From: Jonathan Albrieux +Date: Wed, 13 Jan 2021 16:18:07 +0100 +Subject: iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel + +From: Jonathan Albrieux + +commit 7d200b283aa049fcda0d43dd6e03e9e783d2799c upstream. + +Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream +it is indicated that "batt_id" channel has to be scaled with the default +function: + + chan@31 { + label = "batt_id"; + reg = <0x31>; + qcom,decimation = <0>; + qcom,pre-div-channel-scaling = <0>; + qcom,calibration-type = "ratiometric"; + qcom,scale-function = <0>; + qcom,hw-settle-time = <0xb>; + qcom,fast-avg-setup = <0>; + }; + +Change LR_MUX2_BAT_ID scaling accordingly. + +Signed-off-by: Jonathan Albrieux +Acked-by: Bjorn Andersson +Fixes: 7c271eea7b8a ("iio: adc: spmi-vadc: Changes to support different scaling") +Link: https://lore.kernel.org/r/20210113151808.4628-2-jonathan.albrieux@gmail.com +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/qcom-spmi-vadc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/iio/adc/qcom-spmi-vadc.c ++++ b/drivers/iio/adc/qcom-spmi-vadc.c +@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_c + VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1) + + VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0) +- VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0) ++ VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT) + VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0) + VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0) + VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0) diff --git a/queue-5.10/iio-adc-stm32-adc-add-has_iomem-dependency.patch b/queue-5.10/iio-adc-stm32-adc-add-has_iomem-dependency.patch new file mode 100644 index 00000000000..884bf8c6c04 --- /dev/null +++ b/queue-5.10/iio-adc-stm32-adc-add-has_iomem-dependency.patch @@ -0,0 +1,34 @@ +From 121875b28e3bd7519a675bf8ea2c2e793452c2bd Mon Sep 17 00:00:00 2001 +From: Jonathan Cameron +Date: Sun, 24 Jan 2021 19:50:34 +0000 +Subject: iio:adc:stm32-adc: Add HAS_IOMEM dependency + +From: Jonathan Cameron + +commit 121875b28e3bd7519a675bf8ea2c2e793452c2bd upstream. + +Seems that there are config combinations in which this driver gets enabled +and hence selects the MFD, but with out HAS_IOMEM getting pulled in +via some other route. MFD is entirely contained in an +if HAS_IOMEM block, leading to the build issue in this bugzilla. + +https://bugzilla.kernel.org/show_bug.cgi?id=209889 + +Cc: +Signed-off-by: Jonathan Cameron +Link: https://lore.kernel.org/r/20210124195034.22576-1-jic23@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/iio/adc/Kconfig ++++ b/drivers/iio/adc/Kconfig +@@ -912,6 +912,7 @@ config STM32_ADC_CORE + depends on ARCH_STM32 || COMPILE_TEST + depends on OF + depends on REGULATOR ++ depends on HAS_IOMEM + select IIO_BUFFER + select MFD_STM32_TIMERS + select IIO_STM32_TIMER_TRIGGER diff --git a/queue-5.10/iio-adis16400-fix-an-error-code-in-adis16400_initial_setup.patch b/queue-5.10/iio-adis16400-fix-an-error-code-in-adis16400_initial_setup.patch new file mode 100644 index 00000000000..beb5b3b1840 --- /dev/null +++ b/queue-5.10/iio-adis16400-fix-an-error-code-in-adis16400_initial_setup.patch @@ -0,0 +1,39 @@ +From a71266e454b5df10d019b06f5ebacd579f76be28 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Tue, 16 Feb 2021 22:42:13 +0300 +Subject: iio: adis16400: Fix an error code in adis16400_initial_setup() + +From: Dan Carpenter + +commit a71266e454b5df10d019b06f5ebacd579f76be28 upstream. + +This is to silence a new Smatch warning: + + drivers/iio/imu/adis16400.c:492 adis16400_initial_setup() + warn: sscanf doesn't return error codes + +If the condition "if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {" +is false then we return 1 instead of returning 0 and probe will fail. + +Fixes: 72a868b38bdd ("iio: imu: check sscanf return value") +Signed-off-by: Dan Carpenter +Cc: +Link: https://lore.kernel.org/r/YCwgFb3JVG6qrlQ+@mwanda +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/imu/adis16400.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/iio/imu/adis16400.c ++++ b/drivers/iio/imu/adis16400.c +@@ -462,8 +462,7 @@ static int adis16400_initial_setup(struc + if (ret) + goto err_ret; + +- ret = sscanf(indio_dev->name, "adis%u\n", &device_id); +- if (ret != 1) { ++ if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) { + ret = -EINVAL; + goto err_ret; + } diff --git a/queue-5.10/iio-gyro-mpu3050-fix-error-handling-in-mpu3050_trigger_handler.patch b/queue-5.10/iio-gyro-mpu3050-fix-error-handling-in-mpu3050_trigger_handler.patch new file mode 100644 index 00000000000..017a801647c --- /dev/null +++ b/queue-5.10/iio-gyro-mpu3050-fix-error-handling-in-mpu3050_trigger_handler.patch @@ -0,0 +1,36 @@ +From 6dbbbe4cfd398704b72b21c1d4a5d3807e909d60 Mon Sep 17 00:00:00 2001 +From: Dinghao Liu +Date: Mon, 1 Mar 2021 16:04:21 +0800 +Subject: iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler + +From: Dinghao Liu + +commit 6dbbbe4cfd398704b72b21c1d4a5d3807e909d60 upstream. + +There is one regmap_bulk_read() call in mpu3050_trigger_handler +that we have caught its return value bug lack further handling. +Check and terminate the execution flow just like the other three +regmap_bulk_read() calls in this function. + +Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope") +Signed-off-by: Dinghao Liu +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20210301080421.13436-1-dinghao.liu@zju.edu.cn +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/gyro/mpu3050-core.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/iio/gyro/mpu3050-core.c ++++ b/drivers/iio/gyro/mpu3050-core.c +@@ -550,6 +550,8 @@ static irqreturn_t mpu3050_trigger_handl + MPU3050_FIFO_R, + &fifo_values[offset], + toread); ++ if (ret) ++ goto out_trigger_unlock; + + dev_dbg(mpu3050->dev, + "%04x %04x %04x %04x %04x\n", diff --git a/queue-5.10/iio-hid-sensor-humidity-fix-alignment-issue-of-timestamp-channel.patch b/queue-5.10/iio-hid-sensor-humidity-fix-alignment-issue-of-timestamp-channel.patch new file mode 100644 index 00000000000..f6f446d82bf --- /dev/null +++ b/queue-5.10/iio-hid-sensor-humidity-fix-alignment-issue-of-timestamp-channel.patch @@ -0,0 +1,57 @@ +From 37e89e574dc238a4ebe439543c5ab4fbb2f0311b Mon Sep 17 00:00:00 2001 +From: Ye Xiang +Date: Wed, 3 Mar 2021 14:36:12 +0800 +Subject: iio: hid-sensor-humidity: Fix alignment issue of timestamp channel + +From: Ye Xiang + +commit 37e89e574dc238a4ebe439543c5ab4fbb2f0311b upstream. + +This patch ensures that, there is sufficient space and correct +alignment for the timestamp. + +Fixes: d7ed89d5aadf ("iio: hid: Add humidity sensor support") +Signed-off-by: Ye Xiang +Cc: +Link: https://lore.kernel.org/r/20210303063615.12130-2-xiang.ye@intel.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/humidity/hid-sensor-humidity.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +--- a/drivers/iio/humidity/hid-sensor-humidity.c ++++ b/drivers/iio/humidity/hid-sensor-humidity.c +@@ -15,7 +15,10 @@ + struct hid_humidity_state { + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info humidity_attr; +- s32 humidity_data; ++ struct { ++ s32 humidity_data; ++ u64 timestamp __aligned(8); ++ } scan; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; +@@ -125,9 +128,8 @@ static int humidity_proc_event(struct hi + struct hid_humidity_state *humid_st = iio_priv(indio_dev); + + if (atomic_read(&humid_st->common_attributes.data_ready)) +- iio_push_to_buffers_with_timestamp(indio_dev, +- &humid_st->humidity_data, +- iio_get_time_ns(indio_dev)); ++ iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan, ++ iio_get_time_ns(indio_dev)); + + return 0; + } +@@ -142,7 +144,7 @@ static int humidity_capture_sample(struc + + switch (usage_id) { + case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY: +- humid_st->humidity_data = *(s32 *)raw_data; ++ humid_st->scan.humidity_data = *(s32 *)raw_data; + + return 0; + default: diff --git a/queue-5.10/iio-hid-sensor-prox-fix-scale-not-correct-issue.patch b/queue-5.10/iio-hid-sensor-prox-fix-scale-not-correct-issue.patch new file mode 100644 index 00000000000..d2a367c62ef --- /dev/null +++ b/queue-5.10/iio-hid-sensor-prox-fix-scale-not-correct-issue.patch @@ -0,0 +1,60 @@ +From d68c592e02f6f49a88e705f13dfc1883432cf300 Mon Sep 17 00:00:00 2001 +From: Ye Xiang +Date: Sat, 30 Jan 2021 18:25:30 +0800 +Subject: iio: hid-sensor-prox: Fix scale not correct issue + +From: Ye Xiang + +commit d68c592e02f6f49a88e705f13dfc1883432cf300 upstream. + +Currently, the proxy sensor scale is zero because it just return the +exponent directly. To fix this issue, this patch use +hid_sensor_format_scale to process the scale first then return the +output. + +Fixes: 39a3a0138f61 ("iio: hid-sensors: Added Proximity Sensor Driver") +Signed-off-by: Ye Xiang +Link: https://lore.kernel.org/r/20210130102530.31064-1-xiang.ye@intel.com +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/light/hid-sensor-prox.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +--- a/drivers/iio/light/hid-sensor-prox.c ++++ b/drivers/iio/light/hid-sensor-prox.c +@@ -23,6 +23,9 @@ struct prox_state { + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info prox_attr; + u32 human_presence; ++ int scale_pre_decml; ++ int scale_post_decml; ++ int scale_precision; + }; + + /* Channel definitions */ +@@ -93,8 +96,9 @@ static int prox_read_raw(struct iio_dev + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SCALE: +- *val = prox_state->prox_attr.units; +- ret_type = IIO_VAL_INT; ++ *val = prox_state->scale_pre_decml; ++ *val2 = prox_state->scale_post_decml; ++ ret_type = prox_state->scale_precision; + break; + case IIO_CHAN_INFO_OFFSET: + *val = hid_sensor_convert_exponent( +@@ -234,6 +238,11 @@ static int prox_parse_report(struct plat + HID_USAGE_SENSOR_HUMAN_PRESENCE, + &st->common_attributes.sensitivity); + ++ st->scale_precision = hid_sensor_format_scale( ++ hsdev->usage, ++ &st->prox_attr, ++ &st->scale_pre_decml, &st->scale_post_decml); ++ + return ret; + } + diff --git a/queue-5.10/iio-hid-sensor-temperature-fix-issues-of-timestamp-channel.patch b/queue-5.10/iio-hid-sensor-temperature-fix-issues-of-timestamp-channel.patch new file mode 100644 index 00000000000..d27d5f18092 --- /dev/null +++ b/queue-5.10/iio-hid-sensor-temperature-fix-issues-of-timestamp-channel.patch @@ -0,0 +1,68 @@ +From 141e7633aa4d2838d1f6ad5c74cccc53547c16ac Mon Sep 17 00:00:00 2001 +From: Ye Xiang +Date: Wed, 3 Mar 2021 14:36:14 +0800 +Subject: iio: hid-sensor-temperature: Fix issues of timestamp channel + +From: Ye Xiang + +commit 141e7633aa4d2838d1f6ad5c74cccc53547c16ac upstream. + +This patch fixes 2 issues of timestamp channel: +1. This patch ensures that there is sufficient space and correct +alignment for the timestamp. +2. Correct the timestamp channel scan index. + +Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support") +Signed-off-by: Ye Xiang +Cc: +Link: https://lore.kernel.org/r/20210303063615.12130-4-xiang.ye@intel.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/temperature/hid-sensor-temperature.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +--- a/drivers/iio/temperature/hid-sensor-temperature.c ++++ b/drivers/iio/temperature/hid-sensor-temperature.c +@@ -15,7 +15,10 @@ + struct temperature_state { + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info temperature_attr; +- s32 temperature_data; ++ struct { ++ s32 temperature_data; ++ u64 timestamp __aligned(8); ++ } scan; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; +@@ -32,7 +35,7 @@ static const struct iio_chan_spec temper + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS), + }, +- IIO_CHAN_SOFT_TIMESTAMP(3), ++ IIO_CHAN_SOFT_TIMESTAMP(1), + }; + + /* Adjust channel real bits based on report descriptor */ +@@ -123,9 +126,8 @@ static int temperature_proc_event(struct + struct temperature_state *temp_st = iio_priv(indio_dev); + + if (atomic_read(&temp_st->common_attributes.data_ready)) +- iio_push_to_buffers_with_timestamp(indio_dev, +- &temp_st->temperature_data, +- iio_get_time_ns(indio_dev)); ++ iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan, ++ iio_get_time_ns(indio_dev)); + + return 0; + } +@@ -140,7 +142,7 @@ static int temperature_capture_sample(st + + switch (usage_id) { + case HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE: +- temp_st->temperature_data = *(s32 *)raw_data; ++ temp_st->scan.temperature_data = *(s32 *)raw_data; + return 0; + default: + return -EINVAL; diff --git a/queue-5.10/series b/queue-5.10/series index 7460719e925..36f115cead9 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -120,3 +120,17 @@ usb-typec-remove-vdo-part-of-tps6598x_rx_identity_reg-struct.patch usb-typec-tcpm-invoke-power_supply_changed-for-tcpm-source-psy.patch usb-dwc3-gadget-allow-runtime-suspend-if-udc-unbinded.patch usb-dwc3-gadget-prevent-ep-queuing-while-stopping-transfers.patch +thunderbolt-initialize-hopid-idas-in-tb_switch_alloc.patch +thunderbolt-increase-runtime-pm-reference-count-on-dp-tunnel-discovery.patch +iio-adc-stm32-adc-add-has_iomem-dependency.patch +iio-adc-qcom-spmi-vadc-add-default-scale-to-lr_mux2_bat_id-channel.patch +iio-adis16400-fix-an-error-code-in-adis16400_initial_setup.patch +iio-gyro-mpu3050-fix-error-handling-in-mpu3050_trigger_handler.patch +iio-adc-ab8500-gpadc-fix-off-by-10-to-3.patch +iio-adc-ad7949-fix-wrong-adc-result-due-to-incorrect-bit-mask.patch +iio-adc-adi-axi-adc-add-proper-kconfig-dependencies.patch +iio-hid-sensor-humidity-fix-alignment-issue-of-timestamp-channel.patch +iio-hid-sensor-prox-fix-scale-not-correct-issue.patch +iio-hid-sensor-temperature-fix-issues-of-timestamp-channel.patch +counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch +counter-stm32-timer-cnt-fix-ceiling-miss-alignment-with-reload-register.patch diff --git a/queue-5.10/thunderbolt-increase-runtime-pm-reference-count-on-dp-tunnel-discovery.patch b/queue-5.10/thunderbolt-increase-runtime-pm-reference-count-on-dp-tunnel-discovery.patch new file mode 100644 index 00000000000..75b77b25302 --- /dev/null +++ b/queue-5.10/thunderbolt-increase-runtime-pm-reference-count-on-dp-tunnel-discovery.patch @@ -0,0 +1,35 @@ +From c94732bda079ee66b5c3904cbb628d0cb218ab39 Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Thu, 10 Dec 2020 14:57:10 +0200 +Subject: thunderbolt: Increase runtime PM reference count on DP tunnel discovery + +From: Mika Westerberg + +commit c94732bda079ee66b5c3904cbb628d0cb218ab39 upstream. + +If the driver is unbound and then bound back it goes over the topology +and figure out the existing tunnels. However, if it finds DP tunnel it +should make sure the domain does not runtime suspend as otherwise it +will tear down the DP tunnel unexpectedly. + +Fixes: 6ac6faee5d7d ("thunderbolt: Add runtime PM for Software CM") +Cc: stable@vger.kernel.org +Signed-off-by: Mika Westerberg +Signed-off-by: Greg Kroah-Hartman +--- + drivers/thunderbolt/tb.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/thunderbolt/tb.c ++++ b/drivers/thunderbolt/tb.c +@@ -138,6 +138,10 @@ static void tb_discover_tunnels(struct t + parent->boot = true; + parent = tb_switch_parent(parent); + } ++ } else if (tb_tunnel_is_dp(tunnel)) { ++ /* Keep the domain from powering down */ ++ pm_runtime_get_sync(&tunnel->src_port->sw->dev); ++ pm_runtime_get_sync(&tunnel->dst_port->sw->dev); + } + + list_add_tail(&tunnel->list, &tcm->tunnel_list); diff --git a/queue-5.10/thunderbolt-initialize-hopid-idas-in-tb_switch_alloc.patch b/queue-5.10/thunderbolt-initialize-hopid-idas-in-tb_switch_alloc.patch new file mode 100644 index 00000000000..d2eeb737571 --- /dev/null +++ b/queue-5.10/thunderbolt-initialize-hopid-idas-in-tb_switch_alloc.patch @@ -0,0 +1,85 @@ +From 781e14eaa7d168dc07d2a2eea5c55831a5bb46f3 Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Wed, 10 Feb 2021 16:06:33 +0200 +Subject: thunderbolt: Initialize HopID IDAs in tb_switch_alloc() + +From: Mika Westerberg + +commit 781e14eaa7d168dc07d2a2eea5c55831a5bb46f3 upstream. + +If there is a failure before the tb_switch_add() is called the switch +object is released by tb_switch_release() but at that point HopID IDAs +have not yet been initialized. So we see splat like this: + +BUG: spinlock bad magic on CPU#2, kworker/u8:5/115 +... +Workqueue: thunderbolt0 tb_handle_hotplug +Call Trace: + dump_stack+0x97/0xdc + ? spin_bug+0x9a/0xa7 + do_raw_spin_lock+0x68/0x98 + _raw_spin_lock_irqsave+0x3f/0x5d + ida_destroy+0x4f/0x127 + tb_switch_release+0x6d/0xfd + device_release+0x2c/0x7d + kobject_put+0x9b/0xbc + tb_handle_hotplug+0x278/0x452 + process_one_work+0x1db/0x396 + worker_thread+0x216/0x375 + kthread+0x14d/0x155 + ? pr_cont_work+0x58/0x58 + ? kthread_blkcg+0x2e/0x2e + ret_from_fork+0x1f/0x40 + +Fix this by always initializing HopID IDAs in tb_switch_alloc(). + +Fixes: 0b2863ac3cfd ("thunderbolt: Add functions for allocating and releasing HopIDs") +Cc: stable@vger.kernel.org +Reported-by: Chiranjeevi Rapolu +Signed-off-by: Mika Westerberg +Signed-off-by: Greg Kroah-Hartman +--- + drivers/thunderbolt/switch.c | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +--- a/drivers/thunderbolt/switch.c ++++ b/drivers/thunderbolt/switch.c +@@ -761,12 +761,6 @@ static int tb_init_port(struct tb_port * + + tb_dump_port(port->sw->tb, &port->config); + +- /* Control port does not need HopID allocation */ +- if (port->port) { +- ida_init(&port->in_hopids); +- ida_init(&port->out_hopids); +- } +- + INIT_LIST_HEAD(&port->list); + return 0; + +@@ -1764,10 +1758,8 @@ static void tb_switch_release(struct dev + dma_port_free(sw->dma_port); + + tb_switch_for_each_port(sw, port) { +- if (!port->disabled) { +- ida_destroy(&port->in_hopids); +- ida_destroy(&port->out_hopids); +- } ++ ida_destroy(&port->in_hopids); ++ ida_destroy(&port->out_hopids); + } + + kfree(sw->uuid); +@@ -1947,6 +1939,12 @@ struct tb_switch *tb_switch_alloc(struct + /* minimum setup for tb_find_cap and tb_drom_read to work */ + sw->ports[i].sw = sw; + sw->ports[i].port = i; ++ ++ /* Control port does not need HopID allocation */ ++ if (i) { ++ ida_init(&sw->ports[i].in_hopids); ++ ida_init(&sw->ports[i].out_hopids); ++ } + } + + ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);