7.3.7-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 966/1005 iio: acpi: Accept comma separated values in ROTM strings
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu-Hsiang Tseng <[email protected]>
commit dd53f1841ecfa2da152cbc31038a5f125b2b9e57 upstream.
The ROTM method of the MXC6655 accelerometer on the Higole F9B, an Alder Lake-N handheld (AMI BIOS F9D_16G_P800217, DMI strings are all "Default string"), separates the values with a comma and a space:
Method (ROTM, 0, NotSerialized)
{
Name (SBUF, Package (0x03)
{
"-1, 0, 0",
"0, 1, 0",
"0, 0, 1"
})
Return (SBUF)
}iio_read_acpi_mount_matrix() only accepts the space separated form used in Microsoft's example ("0 1 0"). It rejects this matrix and mxc4005 falls back to the identity matrix:
mxc4005 i2c-MXC6655:00: Incorrect ACPI mount matrix string format mxc4005 i2c-MXC6655:00: mounting matrix not found: using identity...
With the X axis not inverted, iio-sensor-proxy reports left-up when the device is held right-up and vice versa, so the desktop turns the picture upside down whenever the handheld is held in landscape.
It is not the only BIOS written this way. The BOSC0200 on the AYANEO Air Plus uses commas in its ROMS method as well, with a space before one of them, and its ROMK method has "1, 0,0":
Method (ROMS, 0, NotSerialized)
{
Name (SBUF, Package (0x03)
{
"-1, 0, 0",
"0, -1 , 0",
"0, 0, -1"
})
Return (SBUF)
}The kernel's sscanf() does not support '%*[', so there is no clean way to take both separators in a single format string. That leaves either a second sscanf() call with a comma format, or normalizing the separator first. Do the latter: turn the commas into spaces before parsing, so the existing "%d %d %d" format, which already takes any amount of white space around the values, keeps working unchanged. The strings live in the buffer acpi_evaluate_object() allocated for us, so they can be modified in place.
With this change in_accel_mount_matrix on the Higole F9B reads "-1, 0, 0; 0, 1, 0; 0, 0, 1" and, with no udev hwdb override, the desktop rotates correctly in all four orientations. The AYANEO Air Plus was not tested; systemd's hwdb has an entry for it, which iio-sensor-proxy prefers over the kernel's matrix.
--- drivers/iio/industrialio-acpi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iio/industrialio-acpi.c +9 -0
@@ -6,6 +6,7 @@#include <linux/export.h> #include <linux/iio/iio.h> #include <linux/sprintf.h> +#include <linux/string.h> /** * iio_read_acpi_mount_matrix() - Read accelerometer mount matrix info from ACPI
@@ -63,6 +64,14 @@ bool iio_read_acpi_mount_matrix(struct d } str = elements[i].string.pointer; +/* +* Microsoft's example separates the values with spaces, "0 1 0". +* Some BIOSes use commas instead, with or without spaces around +* them: "0, 1, 0", "0, -1 , 0", "1, 0,0". The string lives in +* the buffer allocated for us above, so turn the commas into +* spaces in place before parsing. +*/ +strreplace (str,',' ,' ' );if (sscanf (str,"%d %d %d" , &val[0 ], &val[1 ], &val[2 ]) !=3 ) {dev_err (dev,"Incorrect ACPI mount matrix string format\n" ); goto out_free_buffer;
Greg Kroah-Hartman
maintainerPATCH 967/1005 iio: adc: aspeed: Use syscon phandle for trimming data when available
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Billy Tsai <[email protected]>
commit 4e7007317fdf83b5201f39afff5adfa0292fc707 upstream.
aspeed_adc_set_trim_data() locates the SCU holding the ADC's reference-voltage trimming data with of_find_node_by_name(NULL, "syscon"), a global search that matches the first device-tree node named "syscon" regardless of which SCU instance it actually is.
On AST2700, which splits its SCU into "syscon0" (soc0) and "syscon1" (soc1), both nodes share the same node name "syscon" and only differ by label and unit address, so the lookup always resolves to syscon0 even though the ADC's trimming data lives in syscon1.
Use the new "aspeed,trim-syscon" phandle property when present to look up the correct regmap directly, falling back to the old global by-name search when the property is absent so existing device trees keep working.
--- drivers/iio/adc/aspeed_adc.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/iio/adc/aspeed_adc.c +18 -7
@@ -201,18 +201,29 @@ static const struct iio_chan_spec aspeedstatic int aspeed_adc_set_trim_data (struct iio_dev *indio_dev) { -struct device_node *syscon; +struct device_node *np, *syscon;struct regmap *scu;u32 scu_otp, trimming_val;struct aspeed_adc_data *data =iio_priv (indio_dev); +const char *propname ="aspeed,trim-syscon" ; - syscon =of_find_node_by_name (NULL ,"syscon" ); -if (syscon ==NULL ) { -dev_warn (data->dev,"Couldn't find syscon node\n" ); -return -EOPNOTSUPP ; + np =dev_of_node (data->dev); +if (of_property_present (np, propname)) { + scu =syscon_regmap_lookup_by_phandle (np, propname); + }else { +/* +* No "aspeed,trim-syscon" phandle: either a single-SCU SoC, +* or a DTB predating the property. Fall back to the old +* global by-name lookup for backward compatibility. +*/ + syscon =of_find_node_by_name (NULL ,"syscon" ); +if (!syscon) { +dev_warn (data->dev,"Couldn't find syscon node\n" ); +return -EOPNOTSUPP ; + } + scu =syscon_node_to_regmap (syscon); +of_node_put (syscon); } - scu =syscon_node_to_regmap (syscon); -of_node_put (syscon);if (IS_ERR (scu)) {dev_warn (data->dev,"Failed to get syscon regmap\n" );return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 968/1005 iio: afe: rescale: expose offset if rescaler or source has one
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Amer <[email protected]>
commit c293f0db308fe76a0a9b0f6674cd2dea149b03aa upstream.
A rescale channel advertises IIO_CHAN_INFO_OFFSET only when its own offset is non-zero. A child rescale therefore hides a source offset, and consumers apply raw * scale and drop it, even though rescale_read_raw() folds the source offset in.
Expose the attribute when either the rescaler or the source channel provides an offset.
--- drivers/iio/afe/iio-rescale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/afe/iio-rescale.c +2 -1
@@ -303,7 +303,8 @@ static int rescale_configure_channel(str chan->info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) |BIT (IIO_CHAN_INFO_SCALE ); -if (rescale->offset) +if (rescale->offset || +iio_channel_has_info (schan,IIO_CHAN_INFO_OFFSET )) chan->info_mask_separate |=BIT (IIO_CHAN_INFO_OFFSET );/*
Greg Kroah-Hartman
maintainerPATCH 969/1005 iio: atlas-ezo: Fix humidity channel read support
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
commit 0cb3fc8987038a26ac0f581bfa26b16daf6ca6a7 upstream.
The atlas_ezo_read_raw() function rejects channels that are not of type IIO_CONCENTRATION, preventing the relative humidity channel from reading raw and scale values.
Remove the early channel type check to allow both concentration and relative humidity channels to reach the mask-specific handling.
--- drivers/iio/chemical/atlas-ezo-sensor.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/chemical/atlas-ezo-sensor.c +0 -3
@@ -116,9 +116,6 @@ static int atlas_ezo_read_raw(struct iiostruct atlas_ezo_data *data =iio_priv (indio_dev);struct i2c_client *client = data->client; -if (chan->type !=IIO_CONCENTRATION ) -return -EINVAL ; -switch (mask) {case IIO_CHAN_INFO_RAW : {int ret;
Greg Kroah-Hartman
maintainerPATCH 970/1005 iio: common: scmi_sensors: fix truncating 64-bit divisions
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit 043ececf147863fbd253687aa0b9edcac358a711 upstream.
do_div() divides a 64-bit dividend by a 32-bit divisor: the divisor is stored in a uint32_t on all architectures. The driver passes 64-bit divisors to it in several places, so they are silently truncated:
- scmi_iio_set_odr_val() divides by uHz, which exceeds 32 bits for sampling frequencies above ~4294 Hz.
- convert_ns_to_freq() divides by interval_ns, which exceeds 32 bits for update intervals of ~4.29 s and above. If its low 32 bits happen to be zero, this is a division by zero.
- scmi_iio_get_odr_val(), scmi_iio_convert_interval_to_ns(), scmi_iio_sensor_update_cb() and scmi_iio_get_raw_available() divide by int_pow(10, n), which returns u64 and exceeds 32 bits for n >= 10. The SCMI exponent fields allow values down to -16.
Truncation results in wrong sampling frequency, timestamp and raw_available values being reported to userspace.
Use div64_u64() and div64_u64_rem(), which take a 64-bit divisor.
--- drivers/iio/common/scmi_sensors/scmi_iio.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/iio/common/scmi_sensors/scmi_iio.c +13 -14
@@ -14,6 +14,7 @@#include <linux/iio/sysfs.h> #include <linux/kernel.h> #include <linux/kthread.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/scmi_protocol.h>
@@ -70,8 +71,7 @@ static int scmi_iio_sensor_update_cb(str*/ tstamp_scale = sensor->sensor_info->tstamp_scale +9 ;if (tstamp_scale <0 ) { -do_div (time,int_pow (10 ,abs (tstamp_scale))); - time_ns = time; + time_ns =div64_u64 (time,int_pow (10 ,abs (tstamp_scale))); }else { time_ns = time *int_pow (10 , tstamp_scale); }
@@ -162,7 +162,7 @@ static int scmi_iio_set_odr_val(struct i mult =scnprintf (buf,sizeof (buf),"%llu" , sf) -1 ; sec =int_pow (10 , mult) *MICROHZ_PER_HZ ; -do_div (sec, uHz); + sec =div64_u64 (sec, uHz);if (sec ==0 ) { dev_err(&iio_dev->dev, "Trying to set invalid sensor update value for sensor %s",
@@ -237,13 +237,10 @@ static int scmi_iio_read_avail(struct iistatic void convert_ns_to_freq (u64 interval_ns,u64 *hz,u64 *uhz) { -u64 rem, freq; +u64 rem; - freq =NSEC_PER_SEC ; - rem =do_div (freq, interval_ns); - *hz = freq; - *uhz = rem *1000000UL ; -do_div (*uhz, interval_ns); + *hz =div64_u64_rem (HZ_PER_GHZ , interval_ns, &rem); + *uhz =div64_u64 (rem *MICROHZ_PER_HZ , interval_ns); }static int scmi_iio_get_odr_val (struct iio_dev *iio_dev,int *val,int *val2)
@@ -269,7 +266,8 @@ static int scmi_iio_get_odr_val(struct i mult =SCMI_SENS_CFG_GET_UPDATE_EXP (sensor_config);if (mult <0 ) { sensor_interval_mult =int_pow (10 ,abs (mult)); -do_div (sensor_update_interval, sensor_interval_mult); + sensor_update_interval =div64_u64 (sensor_update_interval, + sensor_interval_mult); }else { sensor_interval_mult =int_pow (10 , mult); sensor_update_interval =
@@ -395,9 +393,9 @@ static ssize_t scmi_iio_get_raw_availabl*/ exponent = exponent - scale;if (exponent <0 ) { - rem =do_div (resolution, -int_pow (10 ,abs (exponent)) - ); + resolution =div64_u64_rem (resolution, +int_pow (10 ,abs (exponent)), + &rem); len =sysfs_emit (buf,"[%lld %llu.%llu %lld]\n" , min_range, resolution, rem, max_range);
@@ -491,7 +489,8 @@ static u64 scmi_iio_convert_interval_to_ mult =SCMI_SENS_INTVL_GET_EXP (val);if (mult <0 ) { sensor_interval_mult =int_pow (10 ,abs (mult)); -do_div (sensor_update_interval, sensor_interval_mult); + sensor_update_interval =div64_u64 (sensor_update_interval, + sensor_interval_mult); }else { sensor_interval_mult =int_pow (10 , mult); sensor_update_interval =
Greg Kroah-Hartman
maintainerPATCH 971/1005 iio: dac: mcp4725: Update the cached DAC value only on success
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baek Kyu, Kim <[email protected]>
commit 098a4c37dc8815ea941866179220394e4d182c67 upstream.
mcp4725_write_raw() updates dac_value even if mcp4725_set_value() rejects the requested value or reports an I2C transfer error. After writing 1000, a rejected write of 4096 returns -EINVAL without an I2C transfer, but out_voltage0_raw reports 4096. A later powerdown exit sends 00 00 instead of the 03 e8 frame for the last successful value. The EEPROM store path uses the same cache.
Return the setter error before updating dac_value. This keeps the last successful software value for readback, powerdown exit and EEPROM writes.
--- drivers/iio/dac/mcp4725.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/dac/mcp4725.c +2 -0
@@ -356,6 +356,8 @@ static int mcp4725_write_raw(struct iio_switch (mask) {case IIO_CHAN_INFO_RAW : ret =mcp4725_set_value (indio_dev, val); +if (ret) +return ret; data->dac_value = val;break ;default :
Greg Kroah-Hartman
maintainerPATCH 972/1005 iio: gyro: bmg160: reject duplicate event disable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
commit d0c8bd5d18a492d64d05482f4b1700e14df7ff84 upstream.
The IIO core does not filter duplicate writes to the event enable attribute. bmg160_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls bmg160_set_power_state(data, false), dropping a runtime PM reference that was not acquired for this request. This can underflow the runtime PM usage count and trigger a "Runtime PM usage count underflow" warning.
Return early when the requested state already matches ev_enable_state.
--- drivers/iio/gyro/bmg160_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/bmg160_core.c +1 -1
@@ -761,7 +761,7 @@ static int bmg160_write_event_config(strstruct bmg160_data *data =iio_priv (indio_dev);int ret; -if (state && data->ev_enable_state) +if (state == data->ev_enable_state)return 0 ;mutex_lock (&data->mutex);
Greg Kroah-Hartman
maintainerPATCH 973/1005 iio: hid-sensor: Fix scale for magnetic north heading
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maximilian Czirr <[email protected]>
commit c72dcaeaabd60e164e7324f80ccb037e879eefdd upstream.
hid_sensor_format_scale() applies the HID unit exponent only when the usage and unit match an entry in unit_conversion[].
Rotation-from-north support uses HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH, but that usage has no entry in the conversion table. As a result, the unit exponent is ignored and the heading can be exposed with a scale of 1 instead of the scale specified by the HID descriptor.
Add a unitless conversion entry so the HID unit exponent is applied to the magnetic north heading. A sensor reporting an exponent of -5 then correctly exposes a scale of 0.00001 instead of 1.
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +2 -0
@@ -38,6 +38,8 @@ static const struct { {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000}, {HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0}, + {HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH, 0, 1, 0}, + {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293}, {HID_USAGE_SENSOR_INCLINOMETER_3D, HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293},
Greg Kroah-Hartman
maintainerPATCH 974/1005 iio: hid-sensors: fix fractional part for unit exponents -7 and -8
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 79c8dffd84e9784ec05bea68dbe5e71f7ec9941a upstream.
split_micro_fraction() scales the remainder to micro units by multiplying it by 10^(6 - exp). The unit exponent of a HID field goes down to -8, so exp can be 7 or 8 here. Then the argument of int_pow() is negative, which the unsigned parameter turns into a huge power of
ten: 0 modulo 2^64. As a result, the fractional part of a value read from the hysteresis attributes is always reported as 0.
Divide by 10^(exp - 6) in these two cases. This matches the reverse conversion in convert_to_vtf_format().
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +6 -1
@@ -98,9 +98,14 @@ static void simple_div(int dividend, intstatic void split_micro_fraction (unsigned int no,int exp,int *val1,int *val2) {int divisor =int_pow (10 , exp); +unsigned int rem; *val1 = no / divisor; - *val2 = no % divisor *int_pow (10 ,6 - exp); + rem = no % divisor; +if (exp >6 ) + *val2 = rem / (unsigned int )int_pow (10 , exp -6 ); +else + *val2 = rem *int_pow (10 ,6 - exp); }/*
Greg Kroah-Hartman
maintainerPATCH 975/1005 iio: humidity: am2315: fix negative temperature decoding
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
commit 0a570feeca37d85fbfd6b4f6e3d9f33e1461c634 upstream.
The AM2315/AM2320 report temperature as a sign-magnitude value, with bit 15 as the sign and bits 14-0 as the magnitude. am2315_read_data() stores the raw value directly in an s16, causing negative temperatures to be interpreted as two's complement. Both the read_raw and the triggered buffer paths are affected.
Decode the sign bit before storing the temperature value. Positive readings are unaffected.
--- drivers/iio/humidity/am2315.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/iio/humidity/am2315.c +10 -2
@@ -113,6 +113,7 @@ static int am2315_read_data(struct am231*/ u8 rx_buf[8 ];u16 crc; +u16 temp_raw;/* First wake up the device. */ am2315_ping (data->client);
@@ -144,8 +145,15 @@ static int am2315_read_data(struct am231 sensor_data->hum_data = (rx_buf[AM2315_HUM_OFFSET ] <<8 ) | rx_buf[AM2315_HUM_OFFSET +1 ]; - sensor_data->temp_data = (rx_buf[AM2315_TEMP_OFFSET ] <<8 ) | - rx_buf[AM2315_TEMP_OFFSET +1 ]; + +/* +* Temperature is sign-magnitude, not two's complement: +* bit 15 is the sign, bits 14-0 are the magnitude (x0.1 degC). +*/ + temp_raw = (rx_buf[AM2315_TEMP_OFFSET ] <<8 ) | + rx_buf[AM2315_TEMP_OFFSET +1 ]; + sensor_data->temp_data = (temp_raw &0x8000 ) ? + -(temp_raw &0x7fff ) : temp_raw;return ret;
Greg Kroah-Hartman
maintainerPATCH 976/1005 iio: humidity: hid-sensor-humidity: Use per-instance callbacks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher Hoover <[email protected]>
commit bbe4f3f668babc9443fc1f075695e43e17ca7976 upstream.
hid-sensor-humidity keeps a single static struct hid_sensor_hub_callbacks for all instances and overwrites its pdev in every probe, so with two humidity sensors, input reports for one are delivered with the other's platform device, and a NULL dereference follows once that device is removed. The same bug was found in hid-sensor-temperature, which shares this code.
Keep the callbacks in struct hid_humidity_state, as the other HID sensor drivers (accel, gyro, als, ...) do.
--- drivers/iio/humidity/hid-sensor-humidity.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/humidity/hid-sensor-humidity.c +7 -7
@@ -15,6 +15,7 @@struct hid_humidity_state {struct hid_sensor_common common_attributes;struct hid_sensor_hub_attribute_info humidity_attr; +struct hid_sensor_hub_callbacks callbacks;struct {s32 humidity_data;aligned_s64 timestamp;
@@ -184,11 +185,6 @@ static int humidity_parse_report(structreturn ret; } -static struct hid_sensor_hub_callbacks humidity_callbacks = { - .send_event = &humidity_proc_event, - .capture_sample = &humidity_capture_sample, -}; -/* Function to initialize the processing for usage id */ static int hid_humidity_probe (struct platform_device *pdev) {
@@ -240,9 +236,13 @@ static int hid_humidity_probe(struct plaplatform_set_drvdata (pdev, indio_dev); - humidity_callbacks.pdev = pdev; + humid_st->callbacks = (struct hid_sensor_hub_callbacks ) { + .send_event = humidity_proc_event, + .capture_sample = humidity_capture_sample, + .pdev = pdev, + }; ret =sensor_hub_register_callback (hsdev,HID_USAGE_SENSOR_HUMIDITY , - &humidity_callbacks); + &humid_st->callbacks);if (ret) goto error_remove_trigger;
Greg Kroah-Hartman
maintainerPATCH 977/1005 iio: imu: inv_icm42600: fix parsing of all FIFO frames for odr change
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 4a141623442888458d147f4e61fe47411c0e4e17 upstream.
For getting all odr change events, we need to parse all FIFO frames in each iio device. Fix this correctly by sending effectively all frames to all iio devices.
Previously only batches of frames containing a matching sensor event were sent to the corresponding iio device.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 24 ++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +10 -14
@@ -550,22 +550,20 @@ int inv_icm42600_buffer_fifo_parse(struc ts = &gyro_st->ts;inv_sensors_timestamp_interrupt (ts, st->fifo.watermark.eff_gyro, st->timestamp.gyro); - ret =inv_icm42600_gyro_parse_fifo (st->indio_gyro); -if (ret) -return ret; } + ret =inv_icm42600_gyro_parse_fifo (st->indio_gyro); +if (ret) +return ret; +/* handle accelerometer timestamp and FIFO data parsing */ if (st->fifo.nb.accel >0 ) { ts = &accel_st->ts;inv_sensors_timestamp_interrupt (ts, st->fifo.watermark.eff_accel, st->timestamp.accel); - ret =inv_icm42600_accel_parse_fifo (st->indio_accel); -if (ret) -return ret; } -return 0 ; +return inv_icm42600_accel_parse_fifo (st->indio_accel); } int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
@@ -590,20 +588,18 @@ int inv_icm42600_buffer_hwfifo_flush(strif (st->fifo.nb.gyro >0 ) { ts = &gyro_st->ts;inv_sensors_timestamp_interrupt (ts, st->fifo.nb.gyro, gyro_ts); - ret =inv_icm42600_gyro_parse_fifo (st->indio_gyro); -if (ret) -return ret; } + ret =inv_icm42600_gyro_parse_fifo (st->indio_gyro); +if (ret) +return ret; +if (st->fifo.nb.accel >0 ) { ts = &accel_st->ts;inv_sensors_timestamp_interrupt (ts, st->fifo.nb.accel, accel_ts); - ret =inv_icm42600_accel_parse_fifo (st->indio_accel); -if (ret) -return ret; } -return 0 ; +return inv_icm42600_accel_parse_fifo (st->indio_accel); }int inv_icm42600_buffer_init (struct inv_icm42600_state *st)
Greg Kroah-Hartman
maintainerPATCH 978/1005 iio: imu: inv_mpu6050: fix magnetometer scale of Y and Z axes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit e5f7a6684a23d9b20184a81b4ebded3b3504ccdc upstream.
inv_mpu_magn_get_scale() returns st->magn_raw_to_gauss[chan->address], where magn_raw_to_gauss[] holds one coefficient per axis, computed in inv_magn_init() from the per-axis factory sensitivity adjustment values (ASAX, ASAY, ASAZ) of the AK8975/AK8963 magnetometer.
However INV_MPU9X50_MAGN_CHAN() never sets .address, so it is 0 for all three magnetometer channels. As a result the Y and Z channels report the scale computed from the X axis adjustment value, and userspace scales the Y and Z readings with the wrong per-axis calibration.
Set .address to the axis index (0 for X, 1 for Y, 2 for Z) in the channel macro, matching the order used to fill magn_raw_to_gauss[].
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -0
@@ -1574,6 +1574,8 @@ static const unsigned long inv_mpu_scan_ .type = IIO_MAGN, \ .modified = 1, \ .channel2 = _chan2, \ +/* index of the axis in magn_raw_to_gauss[] */ \ + .address = (_chan2) - IIO_MOD_X, \ .info_mask_separate =BIT (IIO_CHAN_INFO_SCALE ) | \ BIT(IIO_CHAN_INFO_RAW), \ .scan_index = _index, \
Greg Kroah-Hartman
maintainerPATCH 979/1005 iio: imu: inv_mpu6050: fix swapped accel and gyro startup times
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit 3a5e2ca34cadd9d5993064884aa5b9c4f6d71dff upstream.
struct inv_mpu6050_hw declares startup_time as { accel, gyro }, but every entry of hw_info[] initializes it positionally as
{ *_GYRO_STARTUP_TIME, *_ACCEL_STARTUP_TIME }, so the two values are swapped for all chips.
inv_mpu6050_switch_engine() waits for startup_time.gyro after enabling the gyroscope, so it waits for the accelerometer startup time instead, e.g. 20 ms instead of 60 ms on MPU6050 and 20 ms instead of 100 ms on ICM20602, and the first gyroscope samples can be read before the sensor has settled. Enabling only the accelerometer waits longer than needed.
Use designated initializers, so each value is assigned to the member it is named after.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 95 +++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 19 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +76 -19
@@ -149,7 +149,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6050, .fifo_size = 1024, .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE}, - .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6050_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6050_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU6500_WHOAMI_VALUE,
@@ -158,7 +161,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU6515_WHOAMI_VALUE,
@@ -167,7 +173,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU6880_WHOAMI_VALUE,
@@ -176,7 +185,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 4096, .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU6000_WHOAMI_VALUE,
@@ -185,7 +197,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6050, .fifo_size = 1024, .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE}, - .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6050_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6050_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU9150_WHOAMI_VALUE,
@@ -194,7 +209,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6050, .fifo_size = 1024, .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE}, - .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6050_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6050_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU9250_WHOAMI_VALUE,
@@ -203,7 +221,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_MPU9255_WHOAMI_VALUE,
@@ -212,7 +233,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20608_WHOAMI_VALUE,
@@ -221,7 +245,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20608D_WHOAMI_VALUE,
@@ -230,7 +257,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20609_WHOAMI_VALUE,
@@ -239,7 +269,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 4 * 1024, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20689_WHOAMI_VALUE,
@@ -248,7 +281,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 4 * 1024, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20600_WHOAMI_VALUE,
@@ -257,7 +293,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 1008, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_ICM20602_ACCEL_STARTUP_TIME , + .gyro = INV_ICM20602_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20602_WHOAMI_VALUE,
@@ -266,7 +305,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 1008, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_ICM20602_ACCEL_STARTUP_TIME , + .gyro = INV_ICM20602_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_ICM20690_WHOAMI_VALUE,
@@ -275,7 +317,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 1024, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_ICM20690_ACCEL_STARTUP_TIME , + .gyro = INV_ICM20690_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_IAM20380_WHOAMI_VALUE, .name = "IAM20380",
@@ -283,7 +328,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_IAM20680_WHOAMI_VALUE,
@@ -292,7 +340,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 512, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_IAM20680HP_WHOAMI_VALUE,
@@ -301,7 +352,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 4 * 1024, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, { .whoami = INV_IAM20680HT_WHOAMI_VALUE,
@@ -310,7 +364,10 @@ static const struct inv_mpu6050_hw hw_in .config = &chip_config_6500, .fifo_size = 4 * 1024, .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, - .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + .startup_time = { + .accel =INV_MPU6500_ACCEL_STARTUP_TIME , + .gyro = INV_MPU6500_GYRO_STARTUP_TIME, + }, }, };
Greg Kroah-Hartman
maintainerPATCH 980/1005 iio: imu: kmx61: reject duplicate event disable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
commit 9a60b35fe45801d45454e1efe90569c9cc6ea736 upstream.
The IIO core does not filter duplicate writes to the event enable attribute. kmx61_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM reference that was not acquired for this request. This can underflow the runtime PM usage count and trigger a "Runtime PM usage count underflow" warning.
Return early when the requested state already matches ev_enable_state.
--- drivers/iio/imu/kmx61.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/kmx61.c +1 -1
@@ -939,7 +939,7 @@ static int kmx61_write_event_config(strustruct kmx61_data *data =kmx61_get_data (indio_dev);int ret =0 ; -if (state && data->ev_enable_state) +if (state == data->ev_enable_state)return 0 ;guard (mutex)(&data->lock);
Greg Kroah-Hartman
maintainerPATCH 981/1005 iio: inv_sensors: do not compute period estimation when updating odr
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 0d695709ed380f1bc9303a91f57525d33766a07e upstream.
When odr is updated, the delta between the interrupts will change and it will lead to a bad period estimation.
Avoid this by preventing the period estimation in this case.
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +7 -1
@@ -142,6 +142,12 @@ void inv_sensors_timestamp_interrupt(str/* update delta timestamps and estimated period */ it = &ts->delta; ts->delta_counter += sample_nb; +/* reset in case of odr change */ +if (ts->new_mult) { + it->lo =0 ; + it->up =0 ; + ts->delta_counter =0 ; + } delta = timestamp - it->up; delta_threshold =INV_SENSORS_TIMESTAMP_MIN (INV_SENSORS_MIN_IT_DELTA , ts->chip.jitter);if (delta >= delta_threshold) {
@@ -161,7 +167,7 @@ void inv_sensors_timestamp_interrupt(str it->lo = it->up; it->up = timestamp; delta = it->up - it->lo; -if (it->lo !=0 ) { +if (it->lo !=0 && !ts->new_mult) {/* compute period and check validity */ period =div_s64 (delta, sample_nb); valid =inv_validate_period (ts, period);
Greg Kroah-Hartman
maintainerPATCH 982/1005 iio: inv_sensors: prevent timestamps going back in time in transitions
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 3785dffc7c68751a8429ae6dd75804c14a5a7c7a upstream.
Ensure when computing first timestamp and when applying odr change, that the next timestamp will not be lower than the previous one.
This way there is no risk to have a timestamp going back in time, meaning being lower than the previous one. It already can never happen without a transition because we are generating timestamps by adding the period to the last timestamp.
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 16 ++++++++++++---- include/linux/iio/common/inv_sensors_timestamp.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +12 -4
@@ -133,10 +133,15 @@ void inv_sensors_timestamp_interrupt(strreturn ;/* no previous data, compute theoretical value from interrupt */ -if (ts->timestamp ==0 ) { +if (!ts->init) {/* elapsed time: sensor period * sensor samples number */ interval = (s64 )ts->period * (s64 )sample_nb; - ts->timestamp = timestamp - interval; + delta = timestamp - interval; +/* prevent next timestamp to be lower than the last one */ +if ((delta + ts->period) > ts->timestamp) + ts->timestamp = delta; + ts->init = true; + }/* update delta timestamps and estimated period */
@@ -190,7 +195,7 @@ void inv_sensors_timestamp_apply_odr(str u32 fifo_period, size_t fifo_nb, unsigned int fifo_no) { - s64 interval; + s64 interval, timestamp;u32 fifo_mult;if (ts->new_mult ==0 )
@@ -213,7 +218,10 @@ void inv_sensors_timestamp_apply_odr(str fifo_period = fifo_mult * ts->chip_period.val;/* computes time interval between interrupt and this sample */ interval = (s64)(fifo_nb - fifo_no) * (s64 )fifo_period; - ts->timestamp = ts->it.up - interval; + timestamp = ts->it.up - interval; +/* prevent next timestamp to be lower than current one */ +if ((timestamp + ts->period) > ts->timestamp) + ts->timestamp = timestamp; } }EXPORT_SYMBOL_NS_GPL (inv_sensors_timestamp_apply_odr,"IIO_INV_SENSORS_TIMESTAMP" );
include/linux/iio/common/inv_sensors_timestamp.h +2 -1
@@ -66,6 +66,7 @@ struct inv_sensors_timestamp {u32 new_mult;u32 period;struct inv_sensors_timestamp_acc chip_period; +bool init; }; void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
@@ -94,7 +95,7 @@ static inline void inv_sensors_timestamp ts->it = interval_init; ts->delta = interval_init; ts->delta_counter =0 ; - ts->timestamp = 0; + ts->init = false; }#endif
Greg Kroah-Hartman
maintainerPATCH 983/1005 iio: light: tsl2591: dont divide by zero
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Remes <[email protected]>
commit bd63c89aac5672f40cdc123a856493b628fc1abb upstream.
The TSL2591 has two raw light channels - CH0 and CH1. The algorithm for calculating illumination from the raw channels requires division by CH0 (which can be zero) and by "counts per lux" (CPL) value which is also zero for (gain = LOW, integration time <= 400 ms).
Furthermore, the algorithm assumes CH0 > CH1, which can be violated in almost complete darkness.
As a result, reading from 'in_illuminance_input' results in division-by-zero whenever CH0 is 0 (complete darkness) or whenever the parameters result in CPL being zero. This results in kernel oops on x86_64 and in reading the value as 0 on arm64.
Fix that by:
- reporting CH0 <= CH1 as zero (catches also CH0 = 0)
- updating the lux algorithm to only do the division at the end
--- drivers/iio/light/tsl2591.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/iio/light/tsl2591.c +22 -10
@@ -16,6 +16,7 @@#include <linux/interrupt.h> #include <linux/iopoll.h> #include <linux/kernel.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/pm_runtime.h>
@@ -362,6 +363,10 @@ static int tsl2591_wait_adc_complete(str* Scale values to get more representative value of lux i.e. * lux = ((C0DATA - C1DATA) * (1000 - ((C1DATA * 1000) / C0DATA))) / CPL * +* CPL is not computed on its own: at 1x gain it is below 1 for integration +* times under 500 ms, so the division by LUX DF is folded into the final +* division instead. +* * Channel 0 = IR + Visible * Channel 1 = IR only */
@@ -373,8 +378,10 @@ static int tsl2591_read_channel_data(strstruct tsl2591_als_settings *settings = &chip->als_settings;struct i2c_client *client = chip->client;u8 als_data[TSL2591_NUM_DATA_REGISTERS ]; -int counts_per_lux, int_time_fval, gain_multi, lux; +int int_time_fval, gain_multi;u16 als_ch0, als_ch1; +u64 lux; +u32 rem;int ret; ret =tsl2591_wait_adc_complete (chip);
@@ -410,23 +417,28 @@ static int tsl2591_read_channel_data(strreturn gain_multi; } - int_time_fval =TSL2591_FVAL_TO_MSEC (settings->als_int_time); -/* Calculate counts per lux value */ - counts_per_lux = (int_time_fval * gain_multi) /TSL2591_LUX_COEFFICIENT ; +/* No visible light, this also catches C0DATA == 0 */ +if (als_ch0 <= als_ch1) { + *val =0 ; + *val2 =0 ; +break ; + } -dev_dbg (&client->dev,"Counts Per Lux: %d\n" , counts_per_lux); + int_time_fval =TSL2591_FVAL_TO_MSEC (settings->als_int_time);/* Calculate lux value */ - lux = ((als_ch0 - als_ch1) * - (1000 - ((als_ch1 *1000 ) / als_ch0))) / counts_per_lux; + lux = (u64)(als_ch0 - als_ch1) * + (1000 - ((als_ch1 *1000 ) / als_ch0)) * +TSL2591_LUX_COEFFICIENT ; + lux =div_u64 (lux, int_time_fval * gain_multi); -dev_dbg (&client->dev,"Raw lux calculation: %d\n" , lux); +dev_dbg (&client->dev,"Raw lux calculation: %llu\n" , lux);/* Divide by 1000 to get real lux value before scaling */ - *val = lux /1000 ; + *val =div_u64_rem (lux,1000 , &rem);/* Get the decimal part of lux reading */ - *val2 = (lux - (*val *1000 )) *1000 ; + *val2 = rem *1000 ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 984/1005 iio: light: vcnl4035: Fix reversed ALS mode bit
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sarmanow <[email protected]>
commit 6bcabc30b89f31e2925647d1ffa5a0e4b7919829 upstream.
According to the datasheet (table 2) the ALS_SD bit behaves the opposite way the current ALS mode defines are set, writing 0 powers the sensor and writing 1 shuts it down.
The current driver thinks the ALS is up while it's actually shut down and it's down when the systems powers it up.
--- drivers/iio/light/vcnl4035.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/light/vcnl4035.c +2 -2
@@ -44,8 +44,8 @@#define VCNL4035_DEV_ID_MASK GENMASK(7, 0)/* Default values */ -#define VCNL4035_MODE_ALS_ENABLE BIT(0) -#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define VCNL4035_MODE_ALS_ENABLE 0x00 +#define VCNL4035_MODE_ALS_DISABLE BIT(0)#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1)#define VCNL4035_MODE_ALS_INT_DISABLE 0#define VCNL4035_DEV_ID_VAL 0x80
Greg Kroah-Hartman
maintainerPATCH 985/1005 iio: magnetometer: mmc35240: leave cache-only mode before the cache sync
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shashank Mohan Jain <[email protected]>
commit 38e05cf38df705b7fa9e8ada931589fa96816f09 upstream.
mmc35240_resume() marks the register cache dirty and calls regcache_sync_region() while the regmap is still in cache-only mode. It calls regcache_cache_only(false) only after the sync. This ordering has been wrong since the resume support was added; it happened to work until regmap started rejecting a sync in cache-only mode.
Since commit afc8e3ee8307 ("regcache: Validate cache_only state in regcache_sync_region()") a sync in cache-only mode is refused with a WARN and -EINVAL. Every resume now gives
WARNING: drivers/base/regmap/regcache.c:536 at regcache_sync_region+0x1a4/0x1c0 ... mmc35240_resume+0x30/0x70 dpm_run_callback+0x7d/0x1c0 device_resume+0x175/0x270 ... mmc35240 1-0030: Failed to restore control registers
and the control registers are not written. If the chip lost its state during suspend, it runs with the reset value of CTRL1 while the cache, and with it the sampling frequency attribute, still has the configured value. Writing the same frequency again does not repair this, because regmap_update_bits() finds no difference to the cache.
Leave cache-only mode first, then mark the cache dirty and sync it.
Reproduced in qemu with the driver bound to an i2c-stub device: set in_magn_sampling_frequency to 25 (CTRL1 = 0x02), clear CTRL0 and CTRL1 of the stub behind the driver's back to emulate the power loss, and run a suspend/resume cycle with "devices" in /sys/power/pm_test. Without this change CTRL1 is still 0x00 after resume and the warning is printed. With it, and also with the regcache commit reverted, CTRL1 is 0x02 again and there is no warning. Not tested on real hardware.
--- drivers/iio/magnetometer/mmc35240.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/magnetometer/mmc35240.c +1 -2
@@ -532,14 +532,13 @@ static int mmc35240_resume(struct devicestruct mmc35240_data *data =iio_priv (indio_dev);int ret; +regcache_cache_only (data->regmap, false);regcache_mark_dirty (data->regmap); ret =regcache_sync_region (data->regmap,MMC35240_REG_CTRL0 ,MMC35240_REG_CTRL1 );if (ret <0 )dev_err (dev,"Failed to restore control registers\n" ); -regcache_cache_only (data->regmap, false); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 986/1005 iio: magnetometer: mmc5633: leave cache-only mode before the cache sync
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shashank Mohan Jain <[email protected]>
commit c794a0a82fb189d98c635c5791c67c672ad80eb8 upstream.
mmc5633_resume() marks the register cache dirty and calls regcache_sync_region() while the regmap is still in cache-only mode. It calls regcache_cache_only(false) only after the sync. This ordering has been wrong since the driver was added; it happened to work until regmap started rejecting a sync in cache-only mode.
Since commit afc8e3ee8307 ("regcache: Validate cache_only state in regcache_sync_region()") a sync in cache-only mode is refused with a WARN and -EINVAL. Every resume now gives
WARNING: drivers/base/regmap/regcache.c:536 at regcache_sync_region+0x1a4/0x1c0 ... mmc5633_resume+0x2d/0x70 dpm_run_callback+0x7d/0x1c0 device_resume+0x175/0x270 ... mmc5633_i2c 1-0030: Failed to restore control registers
and the control registers are not written. If the chip lost its state during suspend, it runs with the reset value of CTRL1 while the cache, and with it the sampling frequency attribute, still has the configured value. Writing the same frequency again does not repair this, because regmap_update_bits() finds no difference to the cache.
Leave cache-only mode first, then mark the cache dirty and sync it.
Reproduced in qemu with the I2C driver bound to an i2c-stub device: set in_magn_sampling_frequency to 3.5 (CTRL1 = 0x02), clear CTRL0 and CTRL1 of the stub behind the driver's back to emulate the power loss, and run a suspend/resume cycle with "devices" in /sys/power/pm_test. Without this change CTRL1 is still 0x00 after resume and the warning is printed. With it, and also with the regcache commit reverted, CTRL1 is 0x02 again and there is no warning. Not tested on real hardware.
--- drivers/iio/magnetometer/mmc5633.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/magnetometer/mmc5633.c +1 -2
@@ -499,13 +499,12 @@ static int mmc5633_resume(struct device *dev)struct regmap *regmap =dev_get_regmap (dev,NULL );int ret; +regcache_cache_only (regmap, false);regcache_mark_dirty (regmap); ret =regcache_sync_region (regmap,MMC5633_REG_CTRL0 ,MMC5633_REG_CTRL1 );if (ret)dev_err (dev,"Failed to restore control registers\n" ); -regcache_cache_only (regmap, false); -return 0 ; }
Signature · 1 line
2.56.1
Greg Kroah-Hartman
maintainerPATCH 987/1005 iio: magnetometer: tlv493d: fix magnetic field scale
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viral Patel <[email protected]>
commit ef5c183a863bb69bf019a2d2ae0e1bfdaebe6222 upstream.
The TLV493D-A1B6 datasheet specifies a magnetic resolution of 98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss (1 mT = 10 G), so the scale should be 0.98 G/LSB.
The driver currently reports 98/1000 = 0.098 G/LSB, which under-reports the magnetic field by a factor of 10. The comment also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
Correct the scale value and the comment.
--- drivers/iio/magnetometer/tlv493d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/magnetometer/tlv493d.c +3 -3
@@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dswitch (chan->type) {case IIO_MAGN :/* -* Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT) -* Magnetic field in Gauss: mT * 10 = 0.098. +* Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB. +* In Gauss (1 mT = 10 G): 0.98 G per LSB. */ *val =98 ; - *val2 =1000 ; + *val2 =100 ;return IIO_VAL_FRACTIONAL ;case IIO_TEMP :/*
Greg Kroah-Hartman
maintainerPATCH 988/1005 iio: proximity: hx9023s: Allocate trigger before requesting IRQ
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit bfa3b177d839bb303d0187335115b572a2644920 upstream.
An IRQ handler that already read trigger_enabled can poll data->trig after buffer disable. Detaching the virtual IRQ does not join this physical IRQ, and trigger deselection can drop the consumer reference. Devres may then free the trigger before joining the handler.
Allocate the trigger before requesting the IRQ so devres joins the handler before dropping the allocation reference.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/iio/proximity/hx9023s.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/iio/proximity/hx9023s.c +8 -8
@@ -1133,14 +1133,6 @@ static int hx9023s_probe(struct i2c_cliereturn dev_err_probe (dev, ret,"reg config failed\n" );if (client->irq) { - ret =devm_request_threaded_irq (dev, client->irq, - hx9023s_irq_handler, - hx9023s_irq_thread_handler, -IRQF_ONESHOT , -"hx9023s_event" , indio_dev); -if (ret) -return ret; - data->trig =devm_iio_trigger_alloc (dev,"%s-dev%d" , indio_dev->name,iio_device_id (indio_dev));
@@ -1150,6 +1142,14 @@ static int hx9023s_probe(struct i2c_clie data->trig->ops = &hx9023s_trigger_ops;iio_trigger_set_drvdata (data->trig, indio_dev); + ret =devm_request_threaded_irq (dev, client->irq, + hx9023s_irq_handler, + hx9023s_irq_thread_handler, +IRQF_ONESHOT , +"hx9023s_event" , indio_dev); +if (ret) +return ret; + ret =devm_iio_trigger_register (dev, data->trig);if (ret) return dev_err_probe(dev, ret,
Greg Kroah-Hartman
maintainerPATCH 989/1005 iio: proximity: sx9324: fix out-of-bounds read of scan period table
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit 7b5f54280f8e6ef07664f6705dd005feefbe87d1 upstream.
The scan period of the SX9324 is selected by the 5 bit wide SX9324_REG_GNRL_CTRL0_SCANPERIOD field, so it has 32 possible values. sx9324_scan_period_table[] however only has 16 entries, it was copied over from the SX9310 driver where the field is only 4 bits wide.
sx9324_wait_for_sample() indexes the table with the raw field value, so all the codes from 16 to 31 read past the end of the array. The default value of the register is SX9324_REG_GNRL_CTRL0_SCANPERIOD_100MS (0x16, i.e. 22), so the out-of-bounds read happens with the default configuration of the device. It is only avoided when the device has an interrupt line, as the wait is only done in the polling case.
The value read is then used as the duration of an msleep() call, so the sensor is polled with a completely random delay.
Fill the table with the scan periods of all 32 codes, which are the periods documented for the corresponding sx9324_samp_freq_table[] entries, and add a static assertion to keep both tables in sync.
--- drivers/iio/proximity/sx9324.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/iio/proximity/sx9324.c +11 -2
@@ -279,11 +279,20 @@ static const struct { { 0, 250000 }, /* 11111: 4 s */ }; +/* +* The scan period of the SX9324 is selected by the 5-bit wide +* SX9324_REG_GNRL_CTRL0_SCANPERIOD field. The values below are the scan +* periods in ms of the corresponding sx9324_samp_freq_table[] entries. +*/ static const unsigned int sx9324_scan_period_table[] = { -2 ,15 ,30 ,45 ,60 ,90 ,120 ,200 , -400 ,600 ,800 ,1000 ,2000 ,3000 ,4000 ,5000 , +1 ,2 ,4 ,6 ,8 ,10 ,14 ,18 ,/* 0x00 - 0x07 */ +22 ,26 ,30 ,34 ,38 ,42 ,46 ,50 ,/* 0x08 - 0x0f */ +56 ,62 ,68 ,74 ,80 ,90 ,100 ,200 ,/* 0x10 - 0x17 */ +300 ,400 ,600 ,800 ,1000 ,2000 ,3000 ,4000 ,/* 0x18 - 0x1f */ }; +static_assert (ARRAY_SIZE (sx9324_scan_period_table) ==ARRAY_SIZE (sx9324_samp_freq_table)); +static const struct regmap_range sx9324_writable_reg_ranges[] = {/* * To set COMPSTAT for compensation, even if datasheet says register is
Greg Kroah-Hartman
maintainerPATCH 990/1005 iio: proximity: sx9360: fix sampling frequency write and available range
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit d252425c1533bfacd5940faa3371af82196bff5b upstream.
GNRL_CTRL1/2 hold the scan period in units of 8192 / FOSC, but sx9360_set_samp_freq() computes freq * 8192 / FOSC and mis-scales val2, which is in micro units. Any integer frequency then programs a period of 0, and fractional parts above ~0.26 Hz overflow the int, writing 0x10 to GNRL_CTRL1 outside the SCANPERIOD field.
Compute FOSC / (freq * 8192), rounded to the closest value, and reject frequencies outside the 1..2047 period range.
The available range doesn't match the limits in the comments next to it
either: 4 MHz / 8192 is 488.28125 Hz, not 448.28125 Hz,
4 MHz / (8192 * 2047) is 0.238535 Hz, and (max - min) / 2047 is 0.238419 Hz. Use those values.
--- drivers/iio/proximity/sx9360.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/iio/proximity/sx9360.c +23 -6
@@ -14,10 +14,12 @@#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/log2.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/pm.h> #include <linux/property.h> #include <linux/regmap.h> +#include <linux/units.h> #include <linux/iio/iio.h>
@@ -43,6 +45,7 @@#define SX9360_REG_GNRL_CTRL1_SCANPERIOD_MASK GENMASK(2, 0)#define SX9360_REG_GNRL_CTRL2 0x12#define SX9360_REG_GNRL_CTRL2_PERIOD_102MS 0x32 +#define SX9360_REG_GNRL_SCANPERIOD_MAX GENMASK(10, 0)#define SX9360_REG_GNRL_REG_2_PERIOD_MS (_r) \ (((_r) * 8192) / (SX9360_FOSC_HZ / 1000))#define SX9360_REG_GNRL_FREQ_2_REG (_f) (((_f) * 8192) / SX9360_FOSC_HZ)
@@ -182,9 +185,9 @@ static const struct {int val;int val2; } sx9360_samp_freq_interval[] = { - { 0, 281250 }, /* 4MHz / (8192 * 2047) */ - { 0, 281250 }, - { 448, 281250 }, /* 4MHz / 8192 */ + { 0, 238535 }, /* 4MHz / (8192 * 2047) */ + { 0, 238419 }, + { 488, 281250 }, /* 4MHz / 8192 */ }; static const struct regmap_range sx9360_writable_reg_ranges[] = {
@@ -383,11 +386,25 @@ static int sx9360_read_avail(struct iio_static int sx9360_set_samp_freq (struct sx_common_data *data,int val,int val2) { -int reg; +unsigned int period_ticks; +u64 freq_uHz;__be16 buf; - reg = val *8192 /SX9360_FOSC_HZ + val2 *8192 / (SX9360_FOSC_MHZ ); - buf =cpu_to_be16 (reg); +if (val <0 || val2 <0 ) +return -EINVAL ; + + freq_uHz = (u64 )val *MICROHZ_PER_HZ + val2; +if (!freq_uHz) +return -EINVAL ; + +/* The register holds the scan period in ticks of 8192 FOSC cycles. */ + period_ticks =DIV64_U64_ROUND_CLOSEST ((u64 )SX9360_FOSC_HZ *MICROHZ_PER_HZ , + freq_uHz *8192 ); +if (!period_ticks || period_ticks >SX9360_REG_GNRL_SCANPERIOD_MAX ) +return -EINVAL ; + + buf =cpu_to_be16 (period_ticks); +guard (mutex)(&data->mutex); return regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf,
Greg Kroah-Hartman
maintainerPATCH 991/1005 iio: proximity: sx9500: ignore event config writes that dont change state
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <[email protected]>
commit b8ed9165906597b69a46fabf39ab41690721ebe8 upstream.
sx9500_write_event_config() adjusts the channel and close/far user counts on every write, even when the event is already in the requested state. Writing 0 to a disabled event and then 1 leaves the counts at 0, so the channel and its interrupts stay off while the event reads as enabled. As channel_users[] is shared with raw reads, those can then wait forever for a conversion. Writing 1 twice and then 0 has the opposite effect.
Return early when the state doesn't change, assx_common_write_event_config() does.
--- drivers/iio/proximity/sx9500.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iio/proximity/sx9500.c +6 -0
@@ -548,6 +548,12 @@ static int sx9500_write_event_config(strmutex_lock (&data->mutex); +/* The user counts must only change when the state does. */ +if (data->event_enabled[chan->channel] == state) { + ret =0 ; + goto out_unlock; + } +if (state) { ret =sx9500_inc_chan_users (data, chan->channel);if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 992/1005 iio: temperature: hid-sensor-temperature: Use per-instance callbacks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher Hoover <[email protected]>
commit 36eeb26031e90eeb81bbac3d3acad61d23fcbdf3 upstream.
hid-sensor-temperature keeps a single static struct hid_sensor_hub_callbacks for all instances and overwrites its pdev in every probe. With two temperature sensors, input reports for one are delivered with the other's platform device; once that device is removed, platform_get_drvdata() returns NULL and temperature_capture_sample() dereferences it:
BUG: kernel NULL pointer dereference, address: 00000000000003a8 RIP: 0010:temperature_capture_sample+0xd/0x50 [hid_sensor_temperature]
The oops happens in sensor_hub_raw_event() with the hub's spinlock held, so the hub's removal then hangs. It reproduces with two uhid devices that each declare a temperature sensor, one destroyed while the other still sends input reports.
Keep the callbacks in struct temperature_state, as the other HID sensor drivers (accel, gyro, als, ...) do.
--- drivers/iio/temperature/hid-sensor-temperature.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/temperature/hid-sensor-temperature.c +7 -7
@@ -15,6 +15,7 @@struct temperature_state {struct hid_sensor_common common_attributes;struct hid_sensor_hub_attribute_info temperature_attr; +struct hid_sensor_hub_callbacks callbacks;struct {s32 temperature_data;aligned_s64 timestamp;
@@ -181,11 +182,6 @@ static int temperature_parse_report(strureturn ret; } -static struct hid_sensor_hub_callbacks temperature_callbacks = { - .send_event = &temperature_proc_event, - .capture_sample = &temperature_capture_sample, -}; -/* Function to initialize the processing for usage id */ static int hid_temperature_probe (struct platform_device *pdev) {
@@ -237,9 +233,13 @@ static int hid_temperature_probe(structplatform_set_drvdata (pdev, indio_dev); - temperature_callbacks.pdev = pdev; + temp_st->callbacks = (struct hid_sensor_hub_callbacks ) { + .send_event = temperature_proc_event, + .capture_sample = temperature_capture_sample, + .pdev = pdev, + }; ret =sensor_hub_register_callback (hsdev,HID_USAGE_SENSOR_TEMPERATURE , - &temperature_callbacks); + &temp_st->callbacks);if (ret) goto error_remove_trigger;
Greg Kroah-Hartman
maintainerPATCH 993/1005 iio: temperature: mlx90614: Fix dual channel probe condition check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit 4d4e75b3074bc29525c963a81c19471528f29a45 upstream.
In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.
Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.
Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.
Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.
--- drivers/iio/temperature/mlx90614.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -1
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensorsconst struct mlx_chip_info *chip_info = data->chip_info;s32 ret; -if (chip_info->dual_channel) +if (!chip_info->dual_channel)return 0 ; ret =i2c_smbus_read_word_data (client, chip_info->op_eeprom_config1);
Greg Kroah-Hartman
maintainerPATCH 994/1005 iio: trigger: free the trigger ID after device_del()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Changyul Lee <[email protected]>
commit d32bf759801e6df23038dc834622a122ec76a4dd upstream.
iio_trigger_unregister() returns the trigger ID to iio_trigger_ida before device_del() removes the "trigger<N>" device. A trigger registered in between can get the same ID, and its device_add() fails:
sysfs: cannot create duplicate filename '/bus/iio/devices/trigger0'
For example, adding a sysfs trigger while an hrtimer trigger is being removed through configfs, or the other way around, hits this because the two paths do not share a lock.
Free the ID after device_del(), as the error path of iio_trigger_register() already does, and drop the "Possible issue in here" comment.
--- drivers/iio/industrialio-trigger.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/industrialio-trigger.c +1 -2
@@ -105,9 +105,8 @@ void iio_trigger_unregister(struct iio_t scoped_guard(mutex, &iio_trigger_list_lock)list_del (&trig_info->list); -ida_free (&iio_trigger_ida, trig_info->id); -/* Possible issue in here */ device_del (&trig_info->dev); +ida_free (&iio_trigger_ida, trig_info->id); }EXPORT_SYMBOL (iio_trigger_unregister);
Greg Kroah-Hartman
maintainerPATCH 995/1005 iio: trigger: Return an error when the trigger has no free irq
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
commit dff701806ab6252f6a0fccba880c47cd09602625 upstream.
iio_trigger_attach_poll_func() prints an error when all CONFIG_IIO_CONSUMERS_PER_TRIGGER irqs of the trigger are in use, but returns 0. The buffer of the extra consumer is enabled without a poll function.
Disabling that buffer calls clear_bit() with a negative bit number and drops a module reference for the second time. On arm and arm64 the clear_bit() goes about 512 MB past the pool bitmap. That is an oops if the address is not mapped, and a bit cleared in unrelated memory if it is.
Return the error from iio_trigger_get_irq().
--- drivers/iio/industrialio-trigger.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/industrialio-trigger.c +1 -0
@@ -292,6 +292,7 @@ int iio_trigger_attach_poll_func(structif (pf->irq <0 ) {pr_err ("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n" , trig->name,CONFIG_IIO_CONSUMERS_PER_TRIGGER ); + ret = pf->irq; goto out_put_module; }
Greg Kroah-Hartman
maintainerPATCH 996/1005 fou: reserve headroom before pushing the encap header
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodor Arsenij Larionov Trichkine <[email protected]>
commit bcb42672751a8786dce871a35bde363b041cb2f7 upstream.
ip_tunnel_xmit() and ip_md_tunnel_xmit() push the encap header before reserving headroom. A packet redirected into the tunnel (tc mirred, nft fwd/dup) keeps the headroom of its original device, so fou_build_udp() panics:
kernel BUG at net/core/skbuff.c:214!
Call Trace: skb_push+0xcc/0xf0 fou_build_udp+0x2f/0x380 gue_build_header+0xfa/0x150 ip_tunnel_xmit+0x87f/0x21c0
With a mirred mirror, the push overwrites the original packet instead. Reachable with CAP_NET_ADMIN in a user namespace.
Reserve the headroom in fou_build_header() and gue_build_header(); GUE sizes and builds the header from one copy of the encap fields. The skb head may move, so reload inner_iph after ip_tunnel_encap() and read tnl_params, which points into the head for GRE with header_ops, before the call. sit's ipip6_tunnel_xmit() holds no head pointer across it.
--- net/ipv4/fou_core.c | 19 +++++++++++++++---- net/ipv4/ip_tunnel.c | 6 ++++-- 2 files changed, 19 insertions(+), 6 deletions(-)
net/ipv4/fou_core.c +15 -4
@@ -1071,6 +1071,9 @@ static int fou_build_header(struct sk_bu__be16 sport;int err; +if (skb_cow_head (skb,fou_encap_hlen (e))) +return -ENOMEM ; + err =__fou_build_header (skb, e, protocol, &sport, type);if (err)return err;
@@ -1083,16 +1086,24 @@ static int fou_build_header(struct sk_bustatic int gue_build_header (struct sk_buff *skb,struct ip_tunnel_encap *e,u8 *protocol,struct flowi4 *fl4) { -int type = e->flags &TUNNEL_ENCAP_FLAG_CSUM ?SKB_GSO_UDP_TUNNEL_CSUM : -SKB_GSO_UDP_TUNNEL ; +struct ip_tunnel_encap encap = { + .flags =READ_ONCE (e->flags), + .sport =READ_ONCE (e->sport), + .dport =READ_ONCE (e->dport), + }; +int type = encap.flags &TUNNEL_ENCAP_FLAG_CSUM ? +SKB_GSO_UDP_TUNNEL_CSUM :SKB_GSO_UDP_TUNNEL ;__be16 sport;int err; - err =__gue_build_header (skb, e, protocol, &sport, type); +if (skb_cow_head (skb,gue_encap_hlen (&encap))) +return -ENOMEM ; + + err =__gue_build_header (skb, &encap, protocol, &sport, type);if (err)return err; -fou_build_udp (skb, e, fl4, protocol, sport); +fou_build_udp (skb, &encap, fl4, protocol, sport);return 0 ; }
net/ipv4/ip_tunnel.c +4 -2
@@ -604,6 +604,7 @@ void ip_md_tunnel_xmit(struct sk_buff *sif (ip_tunnel_encap (skb, &tun_info->encap, &proto, &fl4) <0 ) goto tx_error; + inner_iph = (const struct iphdr *)skb_inner_network_header (skb); use_cache =ip_tunnel_dst_cache_usable (skb, tun_info);if (use_cache)
@@ -747,6 +748,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, } tos = tnl_params->tos; + df = tnl_params->frag_off; + ttl = tnl_params->ttl;if (tos &0x1 ) { tos &= ~0x1 ;if (payload_protocol ==htons (ETH_P_IP )) {
@@ -765,6 +768,7 @@ void ip_tunnel_xmit(struct sk_buff *skb,if (ip_tunnel_encap (skb, &tunnel->encap, &protocol, &fl4) <0 ) goto tx_error; + inner_iph = (const struct iphdr *)skb_inner_network_header (skb);if (connected && md) { use_cache =ip_tunnel_dst_cache_usable (skb, tun_info);
@@ -797,7 +801,6 @@ void ip_tunnel_xmit(struct sk_buff *skb, goto tx_error; } - df = tnl_params->frag_off;if (payload_protocol ==htons (ETH_P_IP ) && !tunnel->ignore_df) df |= (inner_iph->frag_off &htons (IP_DF ));
@@ -819,7 +822,6 @@ void ip_tunnel_xmit(struct sk_buff *skb, } tos =ip_tunnel_ecn_encap (tos, inner_iph, skb); - ttl = tnl_params->ttl;if (ttl ==0 ) {if (payload_protocol ==htons (ETH_P_IP )) ttl = inner_iph->ttl;
Greg Kroah-Hartman
maintainerPATCH 997/1005 blk-mq: take quiesce_lock when removing a queue from the tag set
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mani Tofigh <[email protected]>
commit 495f22c5a99ac38e527294cdc4f3972718b9bee0 upstream.
Unquiescing a tag set can run the hw queues of a queue whose hctxs were already freed. blk_mq_unquiesce_tagset() walks the tag set's queues under quiesce_lock and rcu_read_lock(). Commit 71ec3c7d6db8 ("blk-mq:
quiesce a queue that joins a quiesced tag set") added quiesce_lock to the walks and to adding a queue, but blk_mq_del_queue_tag_set() still removes a queue without it. The hctxs are then freed right away since RCU only keeps the request_queue itself alive:
Task A (controller reset) Task B (namespace removal)
blk_mq_unquiesce_tagset()
/* finds q */
blk_mq_del_queue_tag_set(q)
blk_mq_release(q)
/* frees the hctxs */
blk_mq_run_hw_queues(q)
/* reads freed hctxs */The window is short. On PREEMPT_RT quiesce_lock is a sleeping lock and the walk can be preempted inside it, which is how it's hit here:
[ 399.851277] BUG: KASAN: slab-use-after-free in blk_mq_run_hw_queues+0x4bd/0x550 [ 399.851328] Read of size 8 at addr ff11000003014148 by task kworker/u9:2/116 [ 399.851352] CPU: 1 UID: 0 PID: 116 Comm: kworker/u9:2 Not tainted 7.3.0-16299-g81cb9aa43246 #1 PREEMPT_RT [ 399.851425] Workqueue: nvme-reset-wq nvme_loop_reset_ctrl_work [ 399.851441] Call Trace: [ 399.851457] <TASK> [ 399.851551] blk_mq_run_hw_queues+0x4bd/0x550 [ 399.851564] blk_mq_unquiesce_tagset+0x128/0x210 [ 399.851576] nvme_loop_reset_ctrl_work+0x78/0x4c0 [ 399.851600] process_one_work+0x92b/0x16d0 [ 399.851660] worker_thread+0x4e6/0xd60 [ 399.851707] kthread+0x300/0x3e0 [ 399.851727] ret_from_fork+0x4f0/0x6f0 [ 399.851776] ret_from_fork_asm+0x1a/0x30 [ 399.851793] </TASK> ... [ 399.851988] Freed by task 111: [ 399.852040] kfree+0x1b3/0x4b0 [ 399.852050] blk_mq_release+0x400/0x550 [ 399.852060] blk_put_queue+0x94/0x120 [ 399.852068] disk_release+0x1bd/0x3f0 [ 399.852102] nvme_free_ns+0x39/0x270 [ 399.852113] nvme_remove_nsid_range+0x2d1/0x4a0 [ 399.852123] nvme_scan_ns_list+0x2cc/0x390 [ 399.852134] nvme_scan_work+0x421/0x9f0 ...
With BLK_CGROUP the disk's root blkg holds the queue until a grace period later, which hides this for NVMe namespaces. It's still open without BLK_CGROUP, and from reading the code also for queues freed without a disk (e.g., SCSI device queues on a UFS host).
Take quiesce_lock around the list_del_rcu() as well so that the walk either finishes with a queue before it leaves the list or never sees it, and say so in the comment of quiesce_lock. With the fix, KASAN doesn't report the use-after-free anymore.
This bug was identified and confirmed with the help of a deterministic hypervisor currently under development. The C reproducer below however hits it about once every 20 minutes on a PREEMPT_RT kernel.
--- block/blk-mq.c | 3 +++ include/linux/blk-mq.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
block/blk-mq.c +3 -0
@@ -4341,7 +4341,10 @@ static void blk_mq_del_queue_tag_set(strlockdep_assert_held (&set->tag_list_lock); +/* blk_mq_unquiesce_tagset() runs the hctxs, which are not RCU freed */ +spin_lock (&set->quiesce_lock);list_del_rcu (&q->tag_set_list); +spin_unlock (&set->quiesce_lock);if (list_is_singular (&set->tag_list)) {/* just transitioned to unshared */ set->flags &= ~BLK_MQ_F_TAG_QUEUE_SHARED ;
include/linux/blk-mq.h +2 -1
@@ -524,7 +524,8 @@ enum hctx_type {* @tag_list: List of the request queues that use this tag set. See also * request_queue.tag_set_list. * @quiesce_lock: Serializes blk_mq_[un]quiesce_tagset() against each other -* and against a request queue being added to @tag_list. +* and against a request queue being added to or removed from +* @tag_list. * @quiesce_depth: How often blk_mq_quiesce_tagset() has been called without * blk_mq_unquiesce_tagset(). * @srcu: Use as lock when type of the request queue is blocking
Greg Kroah-Hartman
maintainerPATCH 998/1005 gpio: mpsse: reject bulk-in endpoints smaller than 3 bytes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunjung Ko <[email protected]>
commit f94f85f82e042c89a1e64ed3ff1d591a2bccfa7b upstream.
mpsse_read() reads min(len + 2, wMaxPacketSize) bytes and then copies len_actual - 2 bytes to the caller. A device that declares a bulk-in endpoint with wMaxPacketSize 1 completes the read with len_actual 1, so the copy length becomes -1 and memcpy() runs far past the one byte buffer on the caller's stack and past bulk_in_buf:
memcpy: detected buffer overflow: 18446744073709551615 byte write of buffer size 1
WARNING: lib/string_helpers.c:1036 at __fortify_report+0x6e/0xc0 Call Trace: __fortify_panic+0xd/0x10 gpio_mpsse_get_multiple+0x767/0x780 gpio_mpsse_gpio_get+0xa2/0xf0 gpiod_get_raw_value_commit+0xf8/0x1f0 gpiod_get_value_cansleep+0x1e/0xa0 value_show+0x42/0x90
Reproduced with dummy_hcd and raw-gadget. A read needs room for the two status bytes plus at least one data byte, so refuse to bind otherwise.
--- drivers/gpio/gpio-mpsse.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/gpio-mpsse.c +4 -0
@@ -676,6 +676,10 @@ static int gpio_mpsse_probe(struct usb_iif (err)return err; +/* Every read carries two status bytes ahead of the data */ +if (usb_endpoint_maxp (priv->bulk_in) <3 ) +return -EINVAL ; + priv->bulk_in_buf =devm_kmalloc (dev,usb_endpoint_maxp (priv->bulk_in),GFP_KERNEL );if (!priv->bulk_in_buf)
Greg Kroah-Hartman
maintainerPATCH 999/1005 accel/ivpu: Defer recovery until probe completes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karol Wachowski <[email protected]>
commit dc61b19db1f77deb4c15bb71e64f46071447837c upstream.
An error IRQ that fires after ivpu_boot() enables interrupts queues recovery_work during probe. If probe then fails, the device is torn down while the work runs, and the work faults on the unmapped BARs:
BUG: unable to handle page fault for address: ffffcfc6680200f4 Workqueue: events_unbound ivpu_pm_recovery_work [intel_vpu] RIP: 0010:ivpu_hw_ip_ipc_rx_addr_get+0xc/0xb0 [intel_vpu] Call Trace: ivpu_wait_for_ready+0x155/0x220 [intel_vpu] ivpu_boot+0x9e/0x270 [intel_vpu] ivpu_resume+0xa4/0xd0 [intel_vpu] ivpu_pm_reset_complete+0x2c/0x90 [intel_vpu] ivpu_pm_recovery_work+0xf6/0x140 [intel_vpu]
If probe succeeds, the recovery runs concurrently with the rest of probe, and its pm_runtime_disable() discards the initial autosuspend request, leaving the NPU active until first use. Any recovery that starts while the NPU is idle loses the pending autosuspend the same way.
Keep recovery_work disabled from ivpu_pm_init() until ivpu_pm_enable(). A trigger during probe still runs diagnostics and masks interrupts, and ivpu_pm_enable() runs the deferred recovery before the initial autosuspend request. A trigger racing with ivpu_pm_enable() can cause a second, harmless recovery. Request autosuspend at the end of ivpu_pm_reset_complete() so the NPU suspends again after every reset.
--- drivers/accel/ivpu/ivpu_pm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_pm.c +8 -1
@@ -151,8 +151,8 @@ static void ivpu_pm_reset_complete(strucup_write (&vdev->pm->reset_lock);atomic_set (&vdev->pm->reset_pending,0 ); -pm_runtime_mark_last_busy (vdev->drm.dev);pm_runtime_enable (vdev->drm.dev); +pm_request_autosuspend (vdev->drm.dev); }static void ivpu_pm_recovery_work (struct work_struct *work)
@@ -416,6 +416,7 @@ void ivpu_pm_init(struct ivpu_device *vdatomic_set (&pm->engine_reset_counter,0 );INIT_WORK (&pm->recovery_work, ivpu_pm_recovery_work); +disable_work (&pm->recovery_work);INIT_DELAYED_WORK (&pm->job_timeout_work, ivpu_job_timeout_work);if (ivpu_disable_recovery)
@@ -440,6 +441,12 @@ void ivpu_pm_enable(struct ivpu_device * {struct device *dev = vdev->drm.dev; +enable_work (&vdev->pm->recovery_work); +if (atomic_read (&vdev->pm->reset_pending)) { +queue_work (system_dfl_wq, &vdev->pm->recovery_work); +flush_work (&vdev->pm->recovery_work); + } +pm_runtime_allow (dev);pm_runtime_put_autosuspend (dev); }
Greg Kroah-Hartman
maintainerPATCH 1000/1005 sctp: fix skb_over_panic when adding addresses with a pending delete of another family
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
commit ce09d8c13a15fe881d0a04c91979dcdf45ed9543 upstream.
sctp_make_asconf_update_ip() accounts for a pending DEL_IP parameter by reusing the length of the address being added. The write-back side instead serializes the pending address itself, with its own address family. If the pending delete is IPv6 (20-byte parameter) while the added addresses are IPv4 (8-byte), the chunk is allocated 12 bytes short and sctp_addto_chunk() writes past the end of the skb. E.g. on mainline (05441d697f7f):
skbuff: skb_over_panic: text:ffffffff84859c77 len:392 put:20
tail:0x188 end:0x180 dev:<NULL>
kernel BUG at net/core/skbuff.c:215!
CPU: 0 UID: 1000 PID: 379 Comm: poc_sctp
Call Trace:
skb_panic
skb_put
sctp_addto_chunk
sctp_make_asconf_update_ip
sctp_send_asconf_add_ip
sctp_setsockopt_bindx
__x64_sys_setsockoptRequires addip enabled on the endpoint (net.sctp.addip_enable=1).
Account for the pending delete with its own address family, as the write-back side already does.
This issue was discovered by an LLM code scanner.
--- net/sctp/sm_make_chunk.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
net/sctp/sm_make_chunk.c +16 -12
@@ -2870,7 +2870,6 @@ struct sctp_chunk *sctp_make_asconf_updaint addr_param_len =0 ;union sctp_addr *addr;int totallen =0 , i; -int del_pickup =0 ;struct sctp_af *af;void *addr_buf;
@@ -2885,16 +2884,21 @@ struct sctp_chunk *sctp_make_asconf_upda totallen += addr_param_len; addr_buf += af->sockaddr_len; -if (asoc->asconf_addr_del_pending && !del_pickup) { -/* reuse the parameter length from the same scope one */ - totallen += paramlen; - totallen += addr_param_len; - del_pickup =1 ; - -pr_debug ("%s: picked same-scope del_pending addr, " -"totallen for all addresses is %d\n" , - __func__, totallen); - } + } + +if (asoc->asconf_addr_del_pending) { +/* The DEL_IP parameter is serialized from the pending address +* itself below; account for its own address family, which may +* differ from the added ones. +*/ + addr = asoc->asconf_addr_del_pending; + af =sctp_get_af_specific (addr->v4.sin_family); + totallen += paramlen; + totallen += af->to_addr_param (addr, &addr_param); + +pr_debug ("%s: picked del_pending addr, " +"totallen for all addresses is %d\n" , + __func__, totallen); }/* Create an asconf chunk with the required length. */
@@ -2917,7 +2921,7 @@ struct sctp_chunk *sctp_make_asconf_upda addr_buf += af->sockaddr_len; } -if (flags ==SCTP_PARAM_ADD_IP && del_pickup) { +if (flags ==SCTP_PARAM_ADD_IP && asoc->asconf_addr_del_pending) { addr = asoc->asconf_addr_del_pending; af =sctp_get_af_specific (addr->v4.sin_family); addr_param_len = af->to_addr_param (addr, &addr_param);
Greg Kroah-Hartman
maintainerPATCH 1001/1005 nvme: fix deadlock on nvme_subsystems_lock in nvme_init_subsystem()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mani Tofigh <[email protected]>
commit ba1213be15c613a1c03db69ea6480ca140a6ca00 upstream.
Connecting a controller to a new subsystem deadlocks when sysfs_create_link() fails in nvme_init_subsystem(), e.g., on an allocation failure. The error path drops the last subsystem reference with nvme_subsystems_lock held and nvme_destroy_subsystem() takes the same lock again:
nvme nvme0: failed to create sysfs link from subsystem.
============================================
WARNING: possible recursive locking detected
...
nvmesubsys/95 is trying to acquire lock:
(nvme_subsystems_lock){+.+.}-{4:4}, at: nvme_destroy_subsystem+0x1b/0x1e0
but task is already holding lock:
(nvme_subsystems_lock){+.+.}-{4:4}, at: nvme_init_identify+0x81e/0x34b0
...
Call Trace: __mutex_lock+0x1a2/0x26e0 nvme_destroy_subsystem+0x1b/0x1e0 nvme_init_identify.cold+0x3bc/0x56f nvme_init_ctrl_finish+0x1bc/0x7a0 nvme_loop_configure_admin_queue+0x205/0x2b0 nvme_loop_create_ctrl+0x480/0xd10 nvmf_dev_write+0x365/0x650 vfs_write+0x1e3/0x1250 ksys_write+0xfa/0x200 do_syscall_64+0xfb/0x590 entry_SYSCALL_64_after_hwframe+0x77/0x7f ... INFO: task nvmesubsys:95 blocked for more than 20 seconds. INFO: task nvmesubsys:95 is blocked on a mutex likely owned by task nvmesubsys:95.
Every later controller setup or removal then waits for the lock too. The nvme_validate_cntlid() error path for an existing subsystem does the same put, and deadlocks the same way if the other references go away in between.
Drop the lock before the put. For a new subsystem, take it off the list first so another controller can't find it in between. With the fix, the connect fails and the next connect works.
This bug was identified and confirmed with the help of a deterministic hypervisor currently under development. The C reproducer below however hits it within about 30s.
--- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvme/host/core.c +4 -0
@@ -3399,7 +3399,11 @@ static int nvme_init_subsystem(struct nvreturn 0 ; out_put_subsystem: +if (!found) +list_del_init (&subsys->entry); +mutex_unlock (&nvme_subsystems_lock);nvme_put_subsystem (subsys); +return ret; out_unlock:mutex_unlock (&nvme_subsystems_lock);return ret;
Greg Kroah-Hartman
maintainerPATCH 1002/1005 tcp: fix NULL pointer dereference when restarting a Fast Open listener
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
commit aa40afa831ebfe45e40a23721711059f2ac584d4 upstream.
When a valid RST is received for a Fast Open child accepted before the three-way handshake completes, reqsk_fastopen_remove() adds the request_sock to the listener's RST list if the listener is in TCP_LISTEN.
An application can call shutdown(SHUT_RD) on a listener socket. inet_csk_listen_stop() checks rskq_rst_head without holding fastopenq.lock. If rskq_rst_head is NULL, it does not acquire the lock and therefore does not synchronize with an insertion by reqsk_fastopen_remove() after that function has passed the TCP_LISTEN check.
The more likely outcome of this race, even without a subsequent listen(), is a leak. If reqsk_fastopen_remove() inserts a request_sock after inet_csk_listen_stop() observes an empty list and returns, the request_sock is stranded in rskq_rst_head and keeps a reference on the listener. The socket is already in TCP_CLOSE, so a subsequent close() does not call inet_csk_listen_stop() again.
If listen() is called again on the same socket before the delayed list insertion, the insertion can overlap the queue initialization in reqsk_queue_alloc(). If it occurs after rskq_rst_head is set to NULL but before rskq_rst_tail is set to NULL, rskq_rst_head points to the request_sock while rskq_rst_tail is NULL.
When a valid RST is later received for another accepted Fast Open child, rskq_rst_head is not NULL, so reqsk_fastopen_remove() attempts to write the request_sock pointer to rskq_rst_tail->dl_next while rskq_rst_tail is NULL. KASAN reports:
BUG: KASAN: null-ptr-deref in reqsk_fastopen_remove+0x147/0x210 Write of size 8 at addr 0000000000000088 by task swapper/3/0 ... Call Trace: <IRQ> ... reqsk_fastopen_remove+0x147/0x210 tcp_check_req+0xa70/0x1060 ... tcp_rcv_state_process+0x1cb/0x2ae0 ... tcp_v4_do_rcv+0x1fe/0x740 tcp_v4_rcv+0x1744/0x2070 ... ip_protocol_deliver_rcu+0x5c/0x280 ip_local_deliver_finish+0x171/0x330 ip_local_deliver+0x107/0x370 ... </IRQ>
To widen the race window, the issue was reproduced after adding mdelay(3000) immediately after reqsk_fastopen_remove() checks that the listener is in TCP_LISTEN and immediately after reqsk_queue_alloc() sets rskq_rst_head to NULL.
Make inet_csk_listen_stop() acquire fastopenq.lock regardless of the value of rskq_rst_head and detach the list while holding the lock. With this synchronization, reqsk_fastopen_remove() either inserts the request_sock before inet_csk_listen_stop() acquires the lock, in which case inet_csk_listen_stop() reclaims it, or sees that the listener is not in TCP_LISTEN and does not insert anything.
--- net/ipv4/inet_connection_sock.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
net/ipv4/inet_connection_sock.c +9 -11
@@ -1533,17 +1533,15 @@ skip_child_forget:if (!has_current_bpf_ctx ())cond_resched (); } -if (queue->fastopenq.rskq_rst_head) { -/* Free all the reqs queued in rskq_rst_head. */ -spin_lock_bh (&queue->fastopenq.lock); - req = queue->fastopenq.rskq_rst_head; - queue->fastopenq.rskq_rst_head =NULL ; -spin_unlock_bh (&queue->fastopenq.lock); -while (req !=NULL ) { - next = req->dl_next; -reqsk_put (req); - req = next; - } +/* Free all the reqs queued in rskq_rst_head. */ +spin_lock_bh (&queue->fastopenq.lock); + req = queue->fastopenq.rskq_rst_head; + queue->fastopenq.rskq_rst_head =NULL ; +spin_unlock_bh (&queue->fastopenq.lock); +while (req !=NULL ) { + next = req->dl_next; +reqsk_put (req); + req = next; }WARN_ON_ONCE (sk->sk_ack_backlog); }
Greg Kroah-Hartman
maintainerPATCH 1003/1005 drm/amd/display: Dont warn about links without an HPD GPIO
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Lamprecht <[email protected]>
commit fb3d0ee0f7cf41488aff58c45f1b31a8f54f3372 upstream.
Since commit def3488eb0fd ("drm/amd/display: refactor HPD to increase flexibility"), the link encoder programs the HPD filter, and dce110_program_hpd_filter() and dcn10_program_hpd_filter() hit ASSERT(0) if the encoder has no HPD GPIO. That is the case if link_get_hpd_gpio() finds no usable HPD info for the connector in the VBIOS, where program_hpd_filter() used to return early without a warning.
This logs a warning with a stack trace on every boot of some systems, for example with Ryzen 7 PRO 4750G APUs on ASRock Rack X570D4U and X470D4U2-2T boards:
WARNING: drivers/gpu/drm/amd/amdgpu/../display/dc/dio/dcn10/dcn10_link_encoder.c:1514 at dcn10_program_hpd_filter+0x39/0x90 [amdgpu], CPU#7: (udev-worker)/836 Call Trace: program_hpd_filter+0x5d/0xb0 [amdgpu] construct_phy+0x96f/0xe60 [amdgpu] link_create+0x1f0/0x240 [amdgpu] create_links+0x164/0x4f0 [amdgpu] dc_create+0x3ba/0x720 [amdgpu] amdgpu_dm_init+0x2c9/0x420 [amdgpu]
Return false without asserting if there is no HPD GPIO, as before, and keep the assertion for failing to lock the pin.
--- drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c | 5 ++++- drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +4 -1
@@ -1841,8 +1841,11 @@ bool dce110_get_hpd_state(struct link_enbool dce110_program_hpd_filter (struct link_encoder *enc,int delay_on_connect_in_ms,int delay_on_disconnect_in_ms) { +if (!enc->hpd_gpio) +return false; +/* Setup HPD filtering */ -if (enc->hpd_gpio &&dal_gpio_lock_pin (enc->hpd_gpio) ==GPIO_RESULT_OK ) { +if (dal_gpio_lock_pin (enc->hpd_gpio) ==GPIO_RESULT_OK ) {struct gpio_hpd_config config; config.delay_on_connect = delay_on_connect_in_ms;
drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c +4 -1
@@ -1502,8 +1502,11 @@ bool dcn10_get_hpd_state(struct link_encbool dcn10_program_hpd_filter (struct link_encoder *enc,int delay_on_connect_in_ms,int delay_on_disconnect_in_ms) { +if (!enc->hpd_gpio) +return false; +/* Setup HPD filtering */ -if (enc->hpd_gpio &&dal_gpio_lock_pin (enc->hpd_gpio) ==GPIO_RESULT_OK ) { +if (dal_gpio_lock_pin (enc->hpd_gpio) ==GPIO_RESULT_OK ) {struct gpio_hpd_config config; config.delay_on_connect = delay_on_connect_in_ms;
Greg Kroah-Hartman
maintainerPATCH 1004/1005 powerpc/watchdog: disable watchdog when watchdog_thresh=0
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Capitulino (Red Hat) <[email protected]>
commit d513ec3c907b067d4a32b14ec6f73c3e041cb136 upstream.
On powerpc, trying to disable the hardlockup detector with:
# echo 0 > /proc/sys/kernel/watchdog_thresh
causes an immediate and endless hardlockup detection, eventually leading to an unusable system (splat example below). This happens because watchdog_calc_timeouts() sets wd_timer_period_ms, wd_panic_timeout_tb and wd_smp_panic_timeout_tb to zero, but start_watchdog() still starts the timer (with expiry=0) in this code path:
proc_watchdog_thresh()
proc_watchdog_update()
__lockup_detector_reconfigure()
watchdog_hardlockup_start()
start_watchdog_on_cpu()
start_watchdog()
hrtimer_start() /* wd_timer_period_ms=0 */However, according to Documentation/admin-guide/sysctl/kernel.rst, setting watchdog_thresh=0 should disable both the soft and hard lockup detectors.
This condition is already checked in __lockup_detector_reconfigure() for the soft lockup detector and the arch-independent hardlockup detector, what's missing is powerpc performing the same check in start_watchdog().
[ 278.110085] watchdog: CPU 0 detected hard LOCKUP on other CPUs 1 [ 278.110086] watchdog: CPU 1 became unstuck TB:33050716089564575 [ 278.110097] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Kdump: loaded Tainted: G E 7.4.0-rc1 #1 PREEMPT(full) [ 278.110103] watchdog: CPU 0 TB:33050716089564185, last SMP heartbeat TB:33050716089563885 (0ms ago) [ 278.110109] Tainted: [E]=UNSIGNED_MODULE [ 278.110126] Hardware name: IBM,8375-42A POWER9 (architected) 0x4e0202 0xf000005 of:IBM,FW940.00 (VL940_027) hv:phyp pSeries [ 278.110136] NIP: c0000000001bd518 LR: c0000000014dedf8 CTR: 0000000000000000 [ 278.110145] REGS: c000000004b17a80 TRAP: 0900 Tainted: G E (7.4.0-rc1) [ 278.110155] MSR: 800000000280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE> CR: 22000224 XER: 20040004 [ 278.110189] CFAR: 0000000000000000 IRQMASK: 0
GPR00: 0000000000000000 c000000004b17d20 c000000001c38100 0000000000000000
GPR04: 000000000000ffff 0000000000000000 0000000000000000 0000000000000000
GPR08: 0000000000000000 0000000000000080 0000000000000080 ffffffffffffffff
GPR12: 0000000000000000 c000000017fff300 0000000000000000 000000002ef3d820
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000001
GPR24: 0000000000000001 00000040c0a6075e 0000000000000000 0000000000000001
GPR28: c0000001fdb5b140 0000000000000001 c000000002291968 c000000002291970
[ 278.110306] NIP [c0000000001bd518] plpar_hcall_norets_notrace+0x18/0x2c [ 278.110319] LR [c0000000014dedf8] check_and_cede_processor+0x48/0x60 [ 278.110333] Call Trace: [ 278.110338] [c000000004b17d20] [c000000004b17dd0] 0xc000000004b17dd0 (unreliable) [ 278.110354] [c000000004b17d80] [c0000000014df020] shared_cede_loop+0x70/0x170 [ 278.110367] [c000000004b17dc0] [c0000000014de460] cpuidle_enter_state+0x2f0/0x748 [ 278.110381] [c000000004b17e70] [c000000000fe43b8] cpuidle_enter+0x48/0x70 [ 278.110397] [c000000004b17eb0] [c0000000002cdcf8] call_cpuidle+0x48/0x90 [ 278.110409] [c000000004b17ed0] [c0000000002d6300] cpuidle_idle_call+0x160/0x2d0 [ 278.110422] [c000000004b17f20] [c0000000002d6578] do_idle+0x108/0x1f0 [ 278.110434] [c000000004b17f60] [c0000000002d6938] cpu_startup_entry+0x48/0x50 [ 278.110446] [c000000004b17f90] [c0000000000615c0] start_secondary+0x290/0x2a0 [ 278.110459] [c000000004b17fe0] [c00000000000e258] start_secondary_prolog+0x10/0x14
--- arch/powerpc/kernel/watchdog.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/watchdog.c +3 -0
@@ -487,6 +487,9 @@ static void start_watchdog(void *arg)if (!(watchdog_enabled &WATCHDOG_HARDLOCKUP_ENABLED ))return ; +if (!watchdog_thresh) +return ; +if (!cpumask_test_cpu (cpu, &watchdog_cpumask))return ;
Greg Kroah-Hartman
maintainerPATCH 1005/1005 tcp: Set unhashed_state in inet_twsk_hashdance_schedule().
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 404381b4f1053a271a85679cc76a543b10ae043e upstream.
inet_unhash() sets inet_csk(sk)->unhashed_state only when the socket is hashed because tcp_set_state(sk, TCP_CLOSE) could be called multiple times, e.g. tcp_abort() calls it directly and tcp_done_with_error().
However, inet_twsk_hashdance_schedule() also unhashes a socket when replacing it with twsk, allowing the socket to bypass checks for inet_csk(sk)->unhashed_state.
Let's update inet_csk(sk)->unhashed_state there as well.
--- net/ipv4/inet_timewait_sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/inet_timewait_sock.c +4 -2
@@ -105,10 +105,12 @@ void inet_twsk_hashdance_schedule(struct struct inet_hashinfo *hashinfo, int timeo) { -const struct inet_sock *inet =inet_sk (sk); -const struct inet_connection_sock *icsk =inet_csk (sk);spinlock_t *lock =inet_ehash_lockp (hashinfo, sk->sk_hash); +struct inet_connection_sock *icsk =inet_csk (sk);struct inet_bind_hashbucket *bhead, *bhead2; +const struct inet_sock *inet =inet_sk (sk); + + icsk->unhashed_state = sk->sk_state;/* Put TW into bind hash. Original socket stays there too. * Note, that any socket with inet->num != 0 MUST be bound in
# Librecast Test Results
044/044 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 7.3.7-rc1-g7f248ec61cf1 #1 SMP PREEMPT_DYNAMIC Wed Nov 25 15:12:41 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.3.7 release. There are 1005 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 27 Nov 2026 14:36:53 +0000. Anything received after that time might be too late.
7.3.7-rc1 compiles on x86_64 (Xeon E5-1620 v2, Slackware64-15.0), and boots & runs on x86_64 (Xeon Gold 6142, Slackware64-current). No regressions observed during boot & my custom tests.
Hallo
RC doesn't compile here and currently couldn't figure what's up.
Question as an git greenhorn:
Is it able to bisect a kernel which initial doesn't compile ? if YES: what is the bisect start then ?
Error:
In file included from kernel/sched/build_policy.c:71:kernel/sched/ext/ext.c: In function ‘__scx_disable_and_exit_task’:kernel/sched/ext/ext.c:4223:17: error: implicit declaration of function ‘scx_reset_task_fields’; did you mean ‘scx_set_task_sched’? [-Wimplicit-function-declaration]
4223 | scx_reset_task_fields(task_rq(p), p);
| ^~~~~~~~~~~~~~~~~~~~~
| scx_set_task_sched
kernel/sched/ext/ext.c: In function ‘scx_bpf_dsq_reenq_task’:
kernel/sched/ext/ext.c:10432:20: error: implicit declaration of function ‘kf_switch_rq_lock’; did you mean ‘switch_rq_lock’? [-Wimplicit-function-declaration]
10432 | entry_rq = kf_switch_rq_lock(src_rq, &flags);
| ^~~~~~~~~~~~~~~~~
| switch_rq_lockkernel/sched/ext/ext.c:10432:18: error: assignment to ‘struct rq *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
10432 | entry_rq = kf_switch_rq_lock(src_rq, &flags);
| ^kernel/sched/ext/ext.c:10450:9: error: implicit declaration of function ‘kf_restore_rq_lock’ [-Wimplicit-function-declaration]
10450 | kf_restore_rq_lock(src_rq, entry_rq, flags);
| ^~~~~~~~~~~~~~~~~~make[4]: *** [scripts/Makefile.build:290: kernel/sched/build_policy.o] Error 1