WSL2-Linux-Kernel/drivers/hid
Even Xu f715188c23 hid: intel-ish-hid: ishtp: Fix ishtp client sending disordered message
[ Upstream commit e1fa076706 ]

There is a timing issue captured during ishtp client sending stress tests.
It was observed during stress tests that ISH firmware is getting out of
ordered messages. This is a rare scenario as the current set of ISH client
drivers don't send much data to firmware. But this may not be the case
going forward.

When message size is bigger than IPC MTU, ishtp splits the message into
fragments and uses serialized async method to send message fragments.
The call stack:
ishtp_cl_send_msg_ipc->ipc_tx_callback(first fregment)->
ishtp_send_msg(with callback)->write_ipc_to_queue->
write_ipc_from_queue->callback->ipc_tx_callback(next fregment)......

When an ipc write complete interrupt is received, driver also calls
write_ipc_from_queue->ipc_tx_callback in ISR to start sending of next fragment.

Through ipc_tx_callback uses spin_lock to protect message splitting, as the
serialized sending method will call back to ipc_tx_callback again, so it doesn't
put sending under spin_lock, it causes driver cannot guarantee all fragments
be sent in order.

Considering this scenario:
ipc_tx_callback just finished a fragment splitting, and not call ishtp_send_msg
yet, there is a write complete interrupt happens, then ISR->write_ipc_from_queue
->ipc_tx_callback->ishtp_send_msg->write_ipc_to_queue......

Because ISR has higher exec priority than normal thread, this causes the new
fragment be sent out before previous fragment. This disordered message causes
invalid message to firmware.

The solution is, to send fragments synchronously:
Use ishtp_write_message writing fragments into tx queue directly one by one,
instead of ishtp_send_msg only writing one fragment with completion callback.
As no completion callback be used, so change ipc_tx_callback to ipc_tx_send.

Signed-off-by: Even Xu <even.xu@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-09-20 12:39:44 +02:00
..
amd-sfh-hid HID: AMD_SFH: Add a DMI quirk entry for Chromebooks 2022-09-05 10:30:08 +02:00
i2c-hid HID: i2c-hid: fix GET/SET_REPORT for unnumbered reports 2022-04-08 14:23:31 +02:00
intel-ish-hid hid: intel-ish-hid: ishtp: Fix ishtp client sending disordered message 2022-09-20 12:39:44 +02:00
surface-hid
usbhid
Kconfig HID: add USB_HID dependancy on some USB HID drivers 2021-12-14 10:57:05 +01:00
Makefile
hid-a4tech.c
hid-accutouch.c
hid-alps.c HID: alps: Declare U1_UNICORN_LEGACY support 2022-08-17 14:23:57 +02:00
hid-apple.c HID: apple: Do not reset quirks when the Fn key is not found 2022-01-27 11:04:27 +01:00
hid-appleir.c
hid-asus.c HID: asus: ROG NKey: Ignore portion of 0x5a report 2022-09-05 10:30:08 +02:00
hid-aureal.c
hid-axff.c
hid-belkin.c
hid-betopff.c
hid-bigbenff.c HID: bigben: fix slab-out-of-bounds Write in bigben_probe 2022-06-09 10:22:36 +02:00
hid-cherry.c
hid-chicony.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-cmedia.c
hid-core.c
hid-corsair.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-cougar.c
hid-cp2112.c HID: cp2112: prevent a buffer overflow in cp2112_xfer() 2022-08-17 14:23:40 +02:00
hid-creative-sb0540.c
hid-cypress.c
hid-debug.c HID: add mapping for KEY_ALL_APPLICATIONS 2022-03-08 19:12:53 +01:00
hid-dr.c
hid-elan.c HID: elan: Fix potential double free in elan_input_configured 2022-06-09 10:22:47 +02:00
hid-elecom.c
hid-elo.c HID: elo: Revert USB reference counting 2022-03-16 14:23:35 +01:00
hid-emsff.c
hid-ezkey.c
hid-ft260.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-gaff.c
hid-gembird.c
hid-generic.c
hid-gfrm.c
hid-glorious.c
hid-google-hammer.c HID: google: add eel USB id 2021-12-14 10:57:05 +01:00
hid-gt683r.c
hid-gyration.c
hid-holtek-kbd.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-holtek-mouse.c HID: holtek: fix mouse probing 2021-12-29 12:28:37 +01:00
hid-holtekff.c
hid-hyperv.c
hid-icade.c
hid-ids.h HID: add Lenovo Yoga C630 battery quirk 2022-09-05 10:30:08 +02:00
hid-input.c HID: add Lenovo Yoga C630 battery quirk 2022-09-05 10:30:08 +02:00
hid-ite.c
hid-jabra.c
hid-kensington.c
hid-keytouch.c
hid-kye.c
hid-lcpower.c
hid-led.c HID: hid-led: fix maximum brightness for Dream Cheeky 2022-06-09 10:22:47 +02:00
hid-lenovo.c
hid-lg-g15.c
hid-lg.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-lg.h
hid-lg2ff.c
hid-lg3ff.c
hid-lg4ff.c
hid-lg4ff.h
hid-lgff.c
hid-logitech-dj.c HID: logitech-dj: add new lightspeed receiver id 2022-04-08 14:22:46 +02:00
hid-logitech-hidpp.c
hid-macally.c
hid-magicmouse.c HID: magicmouse: Fix an error handling path in magicmouse_probe() 2022-01-27 11:05:08 +01:00
hid-maltron.c
hid-mcp2221.c HID: mcp2221: prevent a buffer overflow in mcp_smbus_write() 2022-08-17 14:23:56 +02:00
hid-mf.c
hid-microsoft.c
hid-monterey.c
hid-multitouch.c HID: multitouch: new device class fix Lenovo X12 trackpad sticky 2022-08-25 11:40:30 +02:00
hid-nti.c
hid-ntrig.c
hid-ortek.c
hid-penmount.c
hid-petalynx.c
hid-picolcd.h
hid-picolcd_backlight.c
hid-picolcd_cir.c
hid-picolcd_core.c
hid-picolcd_debugfs.c
hid-picolcd_fb.c
hid-picolcd_lcd.c
hid-picolcd_leds.c
hid-pl.c
hid-plantronics.c
hid-playstation.c
hid-primax.c
hid-prodikeys.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-quirks.c HID:Add support for UGTABLET WP5540 2022-02-23 12:03:02 +01:00
hid-redragon.c
hid-retrode.c
hid-rmi.c
hid-roccat-arvo.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-arvo.h
hid-roccat-common.c
hid-roccat-common.h
hid-roccat-isku.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-isku.h
hid-roccat-kone.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-kone.h
hid-roccat-koneplus.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-koneplus.h
hid-roccat-konepure.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-kovaplus.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-kovaplus.h
hid-roccat-lua.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-lua.h
hid-roccat-pyra.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-pyra.h
hid-roccat-ryos.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-savu.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-roccat-savu.h
hid-roccat.c
hid-saitek.c
hid-samsung.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-semitek.c
hid-sensor-custom.c
hid-sensor-hub.c
hid-sjoy.c
hid-sony.c HID: sony: fix error path in probe 2021-12-14 10:57:06 +01:00
hid-speedlink.c
hid-steam.c HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report 2022-09-05 10:30:06 +02:00
hid-steelseries.c
hid-sunplus.c
hid-thrustmaster.c HID: thrustmaster: Add sparco wheel and fix array length 2022-09-05 10:30:08 +02:00
hid-tivo.c
hid-tmff.c
hid-topseed.c
hid-twinhan.c
hid-u2fzero.c HID: add hid_is_usb() function to make it simpler for USB detection 2021-12-14 10:57:05 +01:00
hid-uclogic-core.c HID: check for valid USB device for many HID drivers 2021-12-14 10:57:06 +01:00
hid-uclogic-params.c HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad 2022-01-27 11:03:55 +01:00
hid-uclogic-params.h
hid-uclogic-rdesc.c
hid-uclogic-rdesc.h
hid-udraw-ps3.c
hid-viewsonic.c
hid-vivaldi.c HID: vivaldi: fix sysfs attributes leak 2022-03-16 14:23:35 +01:00
hid-waltop.c
hid-wiimote-core.c
hid-wiimote-debug.c
hid-wiimote-modules.c
hid-wiimote.h
hid-xinmo.c
hid-zpff.c
hid-zydacron.c
hidraw.c HID: hidraw: fix memory leak in hidraw_release() 2022-09-05 10:30:07 +02:00
uhid.c HID: uhid: Fix worker destroying device without any protection 2022-01-27 11:02:46 +01:00
wacom.h
wacom_sys.c HID: wacom: Don't register pad_input for touch switch 2022-08-17 14:22:47 +02:00
wacom_wac.c HID: wacom: Don't register pad_input for touch switch 2022-08-17 14:22:47 +02:00
wacom_wac.h HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts 2021-12-01 09:04:41 +01:00