* [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove [not found] <20241107114712.538976-1-heiko@sntech.de> @ 2024-11-07 11:47 ` Heiko Stuebner 2024-11-07 12:59 ` Jiri Kosina 0 siblings, 1 reply; 11+ messages in thread From: Heiko Stuebner @ 2024-11-07 11:47 UTC (permalink / raw) To: lee, jikos, jic23 Cc: robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, heiko, stable The hid-sensor-hub creates the individual device structs and transfers them to the created mfd platform-devices via the platform_data in the mfd_cell. Before e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") the sensor-hub was managing access centrally, with one "completion" in the hub's data structure, which needed to be finished on removal at the latest. The mentioned commit then moved this central management to each hid sensor device, resulting on a completion in each struct hid_sensor_hub_device. The remove procedure was adapted to go through all sensor devices and finish any pending "completion". What this didn't take into account was, platform_device_add_data() that is used by mfd_add{_hotplug}_devices() does a kmemdup on the submitted platform-data. So the data the platform-device gets is a copy of the original data, meaning that the device worked on a different completion than what sensor_hub_remove() currently wants to access. To fix that, use device_for_each_child() to go through each child-device similar to how mfd_remove_devices() unregisters the devices later and with that get the live platform_data to finalize the correct completion. Fixes: e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") Cc: stable@vger.kernel.org Acked-by: Benjamin Tissoires <bentiss@kernel.org> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/hid/hid-sensor-hub.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 7bd86eef6ec7..4c94c03cb573 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -730,23 +730,30 @@ static int sensor_hub_probe(struct hid_device *hdev, return ret; } +static int sensor_hub_finalize_pending_fn(struct device *dev, void *data) +{ + struct hid_sensor_hub_device *hsdev = dev->platform_data; + + if (hsdev->pending.status) + complete(&hsdev->pending.ready); + + return 0; +} + static void sensor_hub_remove(struct hid_device *hdev) { struct sensor_hub_data *data = hid_get_drvdata(hdev); unsigned long flags; - int i; hid_dbg(hdev, " hardware removed\n"); hid_hw_close(hdev); hid_hw_stop(hdev); + spin_lock_irqsave(&data->lock, flags); - for (i = 0; i < data->hid_sensor_client_cnt; ++i) { - struct hid_sensor_hub_device *hsdev = - data->hid_sensor_hub_client_devs[i].platform_data; - if (hsdev->pending.status) - complete(&hsdev->pending.ready); - } + device_for_each_child(&hdev->dev, NULL, + sensor_hub_finalize_pending_fn); spin_unlock_irqrestore(&data->lock, flags); + mfd_remove_devices(&hdev->dev); mutex_destroy(&data->mutex); } -- 2.45.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-11-07 11:47 ` [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove Heiko Stuebner @ 2024-11-07 12:59 ` Jiri Kosina 2024-11-07 13:50 ` Heiko Stübner 0 siblings, 1 reply; 11+ messages in thread From: Jiri Kosina @ 2024-11-07 12:59 UTC (permalink / raw) To: Heiko Stuebner Cc: lee, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Thu, 7 Nov 2024, Heiko Stuebner wrote: > The hid-sensor-hub creates the individual device structs and transfers them > to the created mfd platform-devices via the platform_data in the mfd_cell. > > Before e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") > the sensor-hub was managing access centrally, with one "completion" in the > hub's data structure, which needed to be finished on removal at the latest. > > The mentioned commit then moved this central management to each hid sensor > device, resulting on a completion in each struct hid_sensor_hub_device. > The remove procedure was adapted to go through all sensor devices and > finish any pending "completion". > > What this didn't take into account was, platform_device_add_data() that is > used by mfd_add{_hotplug}_devices() does a kmemdup on the submitted > platform-data. So the data the platform-device gets is a copy of the > original data, meaning that the device worked on a different completion > than what sensor_hub_remove() currently wants to access. > > To fix that, use device_for_each_child() to go through each child-device > similar to how mfd_remove_devices() unregisters the devices later and > with that get the live platform_data to finalize the correct completion. > > Fixes: e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") > Cc: stable@vger.kernel.org > Acked-by: Benjamin Tissoires <bentiss@kernel.org> > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Jiri Kosina <jkosina@suse.com> Are you planning to merge this together with the rest of the set, or do you want me to expedite it? I'll be happy to apply it separately as a proper fix. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-11-07 12:59 ` Jiri Kosina @ 2024-11-07 13:50 ` Heiko Stübner 2024-11-07 14:34 ` Jiri Kosina 0 siblings, 1 reply; 11+ messages in thread From: Heiko Stübner @ 2024-11-07 13:50 UTC (permalink / raw) To: Jiri Kosina Cc: lee, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable Hi Jiri, Am Donnerstag, 7. November 2024, 13:59:04 CET schrieb Jiri Kosina: > On Thu, 7 Nov 2024, Heiko Stuebner wrote: > > > The hid-sensor-hub creates the individual device structs and transfers them > > to the created mfd platform-devices via the platform_data in the mfd_cell. > > > > Before e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") > > the sensor-hub was managing access centrally, with one "completion" in the > > hub's data structure, which needed to be finished on removal at the latest. > > > > The mentioned commit then moved this central management to each hid sensor > > device, resulting on a completion in each struct hid_sensor_hub_device. > > The remove procedure was adapted to go through all sensor devices and > > finish any pending "completion". > > > > What this didn't take into account was, platform_device_add_data() that is > > used by mfd_add{_hotplug}_devices() does a kmemdup on the submitted > > platform-data. So the data the platform-device gets is a copy of the > > original data, meaning that the device worked on a different completion > > than what sensor_hub_remove() currently wants to access. > > > > To fix that, use device_for_each_child() to go through each child-device > > similar to how mfd_remove_devices() unregisters the devices later and > > with that get the live platform_data to finalize the correct completion. > > > > Fixes: e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") > > Cc: stable@vger.kernel.org > > Acked-by: Benjamin Tissoires <bentiss@kernel.org> > > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > > Acked-by: Jiri Kosina <jkosina@suse.com> > > Are you planning to merge this together with the rest of the set, or do > you want me to expedite it? I'll be happy to apply it separately as a > proper fix. This change was more or less a surprise find, because I wanted to make the platform_data pointer in the mfd_cell struct const and this the hid sensor hub stood out as doing something strange ;-) . So patch 2 of this series actually depends on this change to not cause build errors. But seeing that we're after -rc6 alredy, I would assume the brunt of the mcu series might need to wait after 6.13-rc1 anyway - but I guess that depends on how Lee sees things ;-) . Heiko ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-11-07 13:50 ` Heiko Stübner @ 2024-11-07 14:34 ` Jiri Kosina 2024-11-12 14:37 ` Lee Jones 0 siblings, 1 reply; 11+ messages in thread From: Jiri Kosina @ 2024-11-07 14:34 UTC (permalink / raw) To: Heiko Stübner Cc: lee, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Thu, 7 Nov 2024, Heiko Stübner wrote: > This change was more or less a surprise find, because I wanted to make > the platform_data pointer in the mfd_cell struct const and this the hid > sensor hub stood out as doing something strange ;-) . > > So patch 2 of this series actually depends on this change to not cause > build errors. Ah, right. > But seeing that we're after -rc6 alredy, I would assume the brunt of the > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > depends on how Lee sees things ;-) . OK, I am keeping my hands off it for the time being. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-11-07 14:34 ` Jiri Kosina @ 2024-11-12 14:37 ` Lee Jones 2024-12-11 12:17 ` Lee Jones 0 siblings, 1 reply; 11+ messages in thread From: Lee Jones @ 2024-11-12 14:37 UTC (permalink / raw) To: Jiri Kosina Cc: Heiko Stübner, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Thu, 07 Nov 2024, Jiri Kosina wrote: > On Thu, 7 Nov 2024, Heiko Stübner wrote: > > > This change was more or less a surprise find, because I wanted to make > > the platform_data pointer in the mfd_cell struct const and this the hid > > sensor hub stood out as doing something strange ;-) . > > > > So patch 2 of this series actually depends on this change to not cause > > build errors. > > Ah, right. > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > depends on how Lee sees things ;-) . > > OK, I am keeping my hands off it for the time being. I can take it now with an Ack. -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-11-12 14:37 ` Lee Jones @ 2024-12-11 12:17 ` Lee Jones 2024-12-11 12:24 ` Jiri Kosina 0 siblings, 1 reply; 11+ messages in thread From: Lee Jones @ 2024-12-11 12:17 UTC (permalink / raw) To: Jiri Kosina Cc: Heiko Stübner, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Tue, 12 Nov 2024, Lee Jones wrote: > On Thu, 07 Nov 2024, Jiri Kosina wrote: > > > On Thu, 7 Nov 2024, Heiko Stübner wrote: > > > > > This change was more or less a surprise find, because I wanted to make > > > the platform_data pointer in the mfd_cell struct const and this the hid > > > sensor hub stood out as doing something strange ;-) . > > > > > > So patch 2 of this series actually depends on this change to not cause > > > build errors. > > > > Ah, right. > > > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > > depends on how Lee sees things ;-) . > > > > OK, I am keeping my hands off it for the time being. > > I can take it now with an Ack. Looking to apply this set now. Ack please. -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-12-11 12:17 ` Lee Jones @ 2024-12-11 12:24 ` Jiri Kosina 2024-12-11 13:01 ` Heiko Stübner 2024-12-11 14:23 ` srinivas pandruvada 0 siblings, 2 replies; 11+ messages in thread From: Jiri Kosina @ 2024-12-11 12:24 UTC (permalink / raw) To: Lee Jones Cc: Heiko Stübner, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Wed, 11 Dec 2024, Lee Jones wrote: > > > > This change was more or less a surprise find, because I wanted to make > > > > the platform_data pointer in the mfd_cell struct const and this the hid > > > > sensor hub stood out as doing something strange ;-) . > > > > > > > > So patch 2 of this series actually depends on this change to not cause > > > > build errors. > > > > > > Ah, right. > > > > > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > > > depends on how Lee sees things ;-) . > > > > > > OK, I am keeping my hands off it for the time being. > > > > I can take it now with an Ack. > > Looking to apply this set now. > > Ack please. I'd preferer if Srinivas could ack this as the more specific maintainer. Srinivas, please? Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-12-11 12:24 ` Jiri Kosina @ 2024-12-11 13:01 ` Heiko Stübner 2024-12-11 13:11 ` Jiri Kosina 2024-12-11 14:23 ` srinivas pandruvada 1 sibling, 1 reply; 11+ messages in thread From: Heiko Stübner @ 2024-12-11 13:01 UTC (permalink / raw) To: Lee Jones, Jiri Kosina Cc: jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable Am Mittwoch, 11. Dezember 2024, 13:24:42 CET schrieb Jiri Kosina: > On Wed, 11 Dec 2024, Lee Jones wrote: > > > > > > This change was more or less a surprise find, because I wanted to make > > > > > the platform_data pointer in the mfd_cell struct const and this the hid > > > > > sensor hub stood out as doing something strange ;-) . > > > > > > > > > > So patch 2 of this series actually depends on this change to not cause > > > > > build errors. > > > > > > > > Ah, right. > > > > > > > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > > > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > > > > depends on how Lee sees things ;-) . > > > > > > > > OK, I am keeping my hands off it for the time being. > > > > > > I can take it now with an Ack. > > > > Looking to apply this set now. > > > > Ack please. > > I'd preferer if Srinivas could ack this as the more specific maintainer. > Srinivas, please? The patch already includes the Ack from Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> from a previous version, so I guess it should be ok already? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-12-11 13:01 ` Heiko Stübner @ 2024-12-11 13:11 ` Jiri Kosina 2024-12-12 15:55 ` Lee Jones 0 siblings, 1 reply; 11+ messages in thread From: Jiri Kosina @ 2024-12-11 13:11 UTC (permalink / raw) To: Heiko Stübner Cc: Lee Jones, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Wed, 11 Dec 2024, Heiko Stübner wrote: > > > > > > This change was more or less a surprise find, because I wanted to make > > > > > > the platform_data pointer in the mfd_cell struct const and this the hid > > > > > > sensor hub stood out as doing something strange ;-) . > > > > > > > > > > > > So patch 2 of this series actually depends on this change to not cause > > > > > > build errors. > > > > > > > > > > Ah, right. > > > > > > > > > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > > > > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > > > > > depends on how Lee sees things ;-) . > > > > > > > > > > OK, I am keeping my hands off it for the time being. > > > > > > > > I can take it now with an Ack. > > > > > > Looking to apply this set now. > > > > > > Ack please. > > > > I'd preferer if Srinivas could ack this as the more specific maintainer. > > Srinivas, please? > > The patch already includes the > Ack from Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > from a previous version, so I guess it should be ok already? Ah, I missed that, indeed, sorry for the noise. With that Acked-by: Jiri Kosina <jkosina@suse.com> and Lee, please feel free to take it. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-12-11 13:11 ` Jiri Kosina @ 2024-12-12 15:55 ` Lee Jones 0 siblings, 0 replies; 11+ messages in thread From: Lee Jones @ 2024-12-12 15:55 UTC (permalink / raw) To: Jiri Kosina Cc: Heiko Stübner, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, srinivas.pandruvada, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Wed, 11 Dec 2024, Jiri Kosina wrote: > On Wed, 11 Dec 2024, Heiko Stübner wrote: > > > > > > > > This change was more or less a surprise find, because I wanted to make > > > > > > > the platform_data pointer in the mfd_cell struct const and this the hid > > > > > > > sensor hub stood out as doing something strange ;-) . > > > > > > > > > > > > > > So patch 2 of this series actually depends on this change to not cause > > > > > > > build errors. > > > > > > > > > > > > Ah, right. > > > > > > > > > > > > > But seeing that we're after -rc6 alredy, I would assume the brunt of the > > > > > > > mcu series might need to wait after 6.13-rc1 anyway - but I guess that > > > > > > > depends on how Lee sees things ;-) . > > > > > > > > > > > > OK, I am keeping my hands off it for the time being. > > > > > > > > > > I can take it now with an Ack. > > > > > > > > Looking to apply this set now. > > > > > > > > Ack please. > > > > > > I'd preferer if Srinivas could ack this as the more specific maintainer. > > > Srinivas, please? > > > > The patch already includes the > > Ack from Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > > from a previous version, so I guess it should be ok already? > > Ah, I missed that, indeed, sorry for the noise. > > With that > > Acked-by: Jiri Kosina <jkosina@suse.com> > > and Lee, please feel free to take it. Thanks, will do. -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove 2024-12-11 12:24 ` Jiri Kosina 2024-12-11 13:01 ` Heiko Stübner @ 2024-12-11 14:23 ` srinivas pandruvada 1 sibling, 0 replies; 11+ messages in thread From: srinivas pandruvada @ 2024-12-11 14:23 UTC (permalink / raw) To: Jiri Kosina, Lee Jones Cc: Heiko Stübner, jic23, robh, krzk+dt, conor+dt, jdelvare, linux, bentiss, dmitry.torokhov, pavel, ukleinek, devicetree, linux-kernel, linux-hwmon, linux-arm-kernel, linux-rockchip, linux-input, linux-iio, linux-leds, stable On Wed, 2024-12-11 at 13:24 +0100, Jiri Kosina wrote: > On Wed, 11 Dec 2024, Lee Jones wrote: > > > > > > This change was more or less a surprise find, because I > > > > > wanted to make > > > > > the platform_data pointer in the mfd_cell struct const and > > > > > this the hid > > > > > sensor hub stood out as doing something strange ;-) . > > > > > > > > > > So patch 2 of this series actually depends on this change to > > > > > not cause > > > > > build errors. > > > > > > > > Ah, right. > > > > > > > > > But seeing that we're after -rc6 alredy, I would assume the > > > > > brunt of the > > > > > mcu series might need to wait after 6.13-rc1 anyway - but I > > > > > guess that > > > > > depends on how Lee sees things ;-) . > > > > > > > > OK, I am keeping my hands off it for the time being. > > > > > > I can take it now with an Ack. > > > > Looking to apply this set now. > > > > Ack please. > > I'd preferer if Srinivas could ack this as the more specific > maintainer. > Srinivas, please? My ACK is already in the patch: Fixes: e651a1da442a ("HID: hid-sensor-hub: Allow parallel synchronous reads") Cc: stable@vger.kernel.org Acked-by: Benjamin Tissoires <bentiss@kernel.org> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de> Thanks, Srinivas > > Thanks, > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-12-12 15:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241107114712.538976-1-heiko@sntech.de>
2024-11-07 11:47 ` [PATCH v9 1/9] HID: hid-sensor-hub: don't use stale platform-data on remove Heiko Stuebner
2024-11-07 12:59 ` Jiri Kosina
2024-11-07 13:50 ` Heiko Stübner
2024-11-07 14:34 ` Jiri Kosina
2024-11-12 14:37 ` Lee Jones
2024-12-11 12:17 ` Lee Jones
2024-12-11 12:24 ` Jiri Kosina
2024-12-11 13:01 ` Heiko Stübner
2024-12-11 13:11 ` Jiri Kosina
2024-12-12 15:55 ` Lee Jones
2024-12-11 14:23 ` srinivas pandruvada
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox