-
Notifications
You must be signed in to change notification settings - Fork 105
[Deepin-Kernel-SIG] [linux 6.12-y] [Upstream] Merge HID/intel-thc-hid from mainline master #1389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add Documentation/hid/intel-thc-hid.rst file to provide hardware and software detail for intel THC drivers. Co-developed-by: Sun Xinpeng <[email protected]> Signed-off-by: Sun Xinpeng <[email protected]> Signed-off-by: Even Xu <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Bagas Sanjaya <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit df3a78d) Signed-off-by: Cryolitia <[email protected]>
Create intel-thc-hid folder and add Kconfig and Makefile for THC drivers. Add basic THC device context structure, definitions and related initialization APIs for THC Hardware layer driver. Also initialize regmap struct for future THC registers access. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 1b2d053) Signed-off-by: Cryolitia <[email protected]>
Add THC Hardware register definitions and descriptions. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 050427e) Signed-off-by: Cryolitia <[email protected]>
THC PIO (programmed I/O) operations are very similar with general
SPI/I2C read/write operation to access external slave device on the bus
through internal FIFO.
THC PIO operations are split into 4 steps:
1. prepare: configure hardware with correct opcode, slave address, and
fill the PIO FIFO
2. start: set start bit to issue a bus send/receive
3. wait: wait for bus sending/receiving completion
4. complete: check send/receive data in FIFO and return
Co-developed-by: Even Xu <[email protected]>
Signed-off-by: Even Xu <[email protected]>
Signed-off-by: Xinpeng Sun <[email protected]>
Tested-by: Rui Zhang <[email protected]>
Tested-by: Mark Pearson <[email protected]>
Reviewed-by: Srinivas Pandruvada <[email protected]>
Reviewed-by: Mark Pearson <[email protected]>
Tested-by: Aaron Ma <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
(cherry picked from commit e584b13)
Signed-off-by: Cryolitia <[email protected]>
Add THC interrupt operation interfaces, such as interrupt configure, global interrupt enable/disable, external touch device GPIO interrupt quiesce and unquiesce. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 86f5f4a) Signed-off-by: Cryolitia <[email protected]>
As THC PIO only has 64 bytes FIFO length, THC DMAs are introduced to send/receive large data packets. THC has three types of DMA channels: Read DMA channel (RxDMA), Write DMA channel (TxDMA) and Software DMA (SWDMA). In addition to basic DMA functions, THC RxDMA also includes an auto hardware sequence which can handle external touch device's interrupt automatically without software involved. THC RxDMA channel usually is used for handling touch input reports. THC TxDMA is very similar with general IO TxDMA, and usually is used for sending command/request to exteranl touch device. THC SWDMA can perform read, write followed by read operation according to different configurations. Unlike RxDMA triggered by bus activity, SWDMA can be triggered by SW driver at any time, for example: - Retrieving an input report without interrupt - Sending command followed by reading response THC DMA operation flow includes 4 steps: 1. Allocate DMA buffers 2. Configure opcode, fill PRD table with DMA buffers, enable DMA channel 3. Wait for completion, read out DMA buffers and update buffer pointers 4. Stop DMA and release DMA buffers THC Hardware layer driver provides APIs for all above DMA Steps. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit a688404) Signed-off-by: Cryolitia <[email protected]>
THC supports LTR configuration and runtimely mode switching. There are two LTR modes: Active LTR and Low Power LTR. THC hardware layer provides APIs for LTR configuration and mode switching. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit e86df90) Signed-off-by: Cryolitia <[email protected]>
Add common interrupt handler to clear interrupt status and return interrupt type to caller for future handling. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 4e682ea) Signed-off-by: Cryolitia <[email protected]>
Add SPI bus related APIs to configure SPI operation parameters, such as port type, bus frequency, bus IO mode, read/write OPcode, and slave register addresses. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit f02bcab) Signed-off-by: Cryolitia <[email protected]>
Add I2C bus related APIs to initialize I2C sub-system parameters, such as bus speed, slave address, address bit. As I2C sub-system hasn't auto register save and restore support, provide APIs to do it manually. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 4228966) Signed-off-by: Cryolitia <[email protected]>
Create intel-quickspi folder and add Kconfig and Makefile for THC QuickSPI driver. Add basic device structure, definitions and probe/remove functions for QuickSPI driver. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit c8f3027) Signed-off-by: Cryolitia <[email protected]>
Add HID Low level driver callbacks and hid probe function to register QucikSPI as a HID driver, and external touch device as a HID device. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 4751113) Signed-off-by: Cryolitia <[email protected]>
Add functions to query QuickSPI ACPI DSD parameters and provide APIs for DSM method accessing. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 7cb06f0) Signed-off-by: Cryolitia <[email protected]>
Intel QuickSPI driver uses THC hardware to accelerate HID over SPI (HIDSPI) protocol flow. This patch implements all data flows described in HID over SPI protocol SPEC by using THC hardware layer APIs. HID over SPI SPEC: https://www.microsoft.com/download/details.aspx?id=103325 Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 9d8d517) Signed-off-by: Cryolitia <[email protected]>
Fully implement QuickSPI driver probe/remove callbacks, interrupt handler, integrate HIDSPI protocol, enumerate HID device and register HID device. Co-developed-by: Even Xu <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 4138f21) Signed-off-by: Cryolitia <[email protected]>
Implement THC QuickSPI driver power management callbacks. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 6912aaf) Signed-off-by: Cryolitia <[email protected]>
Create intel-quicki2c folder and add Kconfig and Makefile for THC QuickI2C driver. Add basic device structure, definitions and probe/remove functions for QuickI2C driver. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 61bb271) Signed-off-by: Cryolitia <[email protected]>
Add HID Low level driver callbacks and hid probe function to register QucikI2C as a HID driver, and external touch device as a HID device. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit ba38d7f) Signed-off-by: Cryolitia <[email protected]>
Add functions to query QuickI2C ACPI DSM/DSD parameters and use these APIs to access all QuickI2C ACPI resources. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 5282e45) Signed-off-by: Cryolitia <[email protected]>
Intel QuickI2C driver uses THC hardware to accelerate HID over I2C (HIDI2C) protocol flow. This patch implements all data flows described in HID over I2C protocol SPEC by using THC hardware layer APIs. HID over I2C SPEC: https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn642101(v=vs.85) Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 6fc7613) Signed-off-by: Cryolitia <[email protected]>
Fully implement QuickI2C driver probe/remove callbacks, interrupt handler, integrate HIDI2C protocol, enumerate HID device and register HID device. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 66b59bf) Signed-off-by: Cryolitia <[email protected]>
Implement THC QuickI2C driver power management callbacks. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 5f420e8) Signed-off-by: Cryolitia <[email protected]>
Return -ENOMEM if the allocation fails. Don't return success. Fixes: 4228966 ("HID: intel-thc-hid: intel-thc: Add THC I2C config interfaces") Signed-off-by: Dan Carpenter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]> (cherry picked from commit 0b0d62f) Signed-off-by: Cryolitia <[email protected]>
Use U32 to get value from ACPI and explicitly cast to U16. Fixes: 5282e45 ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces") Signed-off-by: Even Xu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]> (cherry picked from commit d08a104) Signed-off-by: Cryolitia <[email protected]>
During S4 retore flow, quickspi device was resetted by driver and state was changed to RESETTED. It is needed to be change to ENABLED state after S4 re-initialization finished, otherwise, device will run in wrong state and HID input data will be dropped. Signed-off-by: Even Xu <[email protected]> Fixes: 6912aaf ("HID: intel-thc-hid: intel-quickspi: Add PM implementation") Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit db52926) Signed-off-by: Cryolitia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @Cryolitia, your pull request is larger than the review limit of 150000 diff characters
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: opsiff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR merges Intel Touch Host Controller (THC) HID driver support from mainline to the Deepin 6.12-y kernel. The THC hardware provides SPI and I2C interfaces for touch devices with hardware-accelerated DMA capabilities. The changes introduce:
- Core THC hardware abstraction layer with register definitions and DMA support
- QuickSPI driver implementing HID-over-SPI protocol
- QuickI2C driver implementing HID-over-I2C protocol
- Protocol definition headers for HIDSPI and HIDI2C standards
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| include/linux/hid-over-spi.h | HIDSPI protocol structures and definitions |
| include/linux/hid-over-i2c.h | HIDI2C protocol structures and definitions |
| drivers/hid/intel-thc-hid/intel-thc/intel-thc-hw.h | THC hardware register definitions and constants |
| drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.* | THC DMA engine implementation |
| drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.* | THC device initialization and operations |
| drivers/hid/intel-thc-hid/intel-quickspi/* | QuickSPI driver for HID-over-SPI devices |
| drivers/hid/intel-thc-hid/intel-quicki2c/* | QuickI2C driver for HID-over-I2C devices |
| drivers/hid/intel-thc-hid/Kconfig | Configuration options for THC drivers |
| drivers/hid/intel-thc-hid/Makefile | Build rules for THC drivers |
| drivers/hid/Kconfig | Integration of THC Kconfig |
| drivers/hid/Makefile | Integration of THC build |
| arch/x86/configs/deepin_x86_desktop_defconfig | Enable THC drivers as modules |
| MAINTAINERS | Add THC driver maintainers |
| Documentation/hid/index.rst | Add THC documentation reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
至少看到有缺失下面的补丁 需要再检查下 |
…aluate_object Delete unused argument, pass correct argument to acpi_evaluate_object. Log: intel_quicki2c 0000:00:10.0: enabling device (0000 -> 0002) ACPI: \_SB.PC00.THC0.ICRS: 1 arguments were passed to a non-method ACPI object (Buffer) (20230628/nsarguments-211) ACPI: \_SB.PC00.THC0.ISUB: 1 arguments were passed to a non-method ACPI object (Buffer) (20230628/nsarguments-211) Fixes: 5282e45 ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces") Signed-off-by: Wentao Guan <[email protected]> Signed-off-by: WangYuli <[email protected]> Reviewed-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 37d66cf) Signed-off-by: Cryolitia <[email protected]>
Align capitalization of the first characters for all code comments and refine some descriptions. Signed-off-by: Even Xu <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit bccbe21) Signed-off-by: Cryolitia <[email protected]>
Convert thc_dma_content structure comments format into kernel doc format, let it can be included into kernel doc. Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit fccef49) Signed-off-by: Cryolitia <[email protected]>
Align capitalization of the first characters for THC structure definition comments in header files. Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 13dd609) Signed-off-by: Cryolitia <[email protected]>
This patch adds support for a new feature, named "Max Input Size Control", allowing driver to set a maximum input size for RxDMA. This enhancement aims to prevent RxDMA buffer overruns caused by data corruption on the I2C bus, thereby improving overall system stability. APIs added: - thc_i2c_set_rx_max_size(): Set the maximum input size for I2C RxDMA. - thc_i2c_rx_max_size_enable(): Enable or disable the max input size control. As this max input size control feature is only applicable to RxDMA and must remain disabled during SWDMA operations, it also involves a change in SWDMA code to record the max input size control feature state before SWDMA and restore the state after SWDMA. Signed-off-by: Even Xu <[email protected]> Tested-by: Chong Han <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 45e92a0) Signed-off-by: Cryolitia <[email protected]>
This patch adds support for a new feature, named "Interrupt Delay", allowing driver to set a specific delay time for next interrupt detection. It gives driver a capability to control THC waiting time for the next interrupt, to reduce the likelihood of spurious readings. APIs added: - thc_i2c_set_rx_int_delay(): Set I2C Rx input interrupt delay value - thc_i2c_rx_int_delay_enable(): Enable or disable I2C Rx interrupt delay As this interrupt delay feature is only applicable to RxDMA and must remain disabled during SWDMA operations, it also involves a change in SWDMA code to record the max input size control feature state before SWDMA and restore the state after SWDMA. Signed-off-by: Even Xu <[email protected]> Tested-by: Chong Han <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 22da60f) Signed-off-by: Cryolitia <[email protected]>
This patch defines driver data structure and adds it into QuickI2C device structure. Changes PCI ID table to use PCI_DEVICE_DATA() to pass platform specific driver data into driver, let driver has capability to enable different hardware features according to different platform driver data. Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 48f151a) Signed-off-by: Cryolitia <[email protected]>
On Panther Lake platform (PTL), THC hardware introduces two new features for I2C subsystem: - Input max input size control - Input interrupt delay This patch adds above new advanced features into QuickI2C driver, and enables max input size control feature on PTL to improve QuickI2C driver compatibility. Signed-off-by: Even Xu <[email protected]> Tested-by: Chong Han <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 2c7c9c5) Signed-off-by: Cryolitia <[email protected]>
The QuickI2C ACPI _DSD methods return ICRS and ISUB data with a trailing byte, making the actual length is one more byte than the structs defined. It caused stack-out-of-bounds and kernel crash: kernel: BUG: KASAN: stack-out-of-bounds in quicki2c_acpi_get_dsd_property.constprop.0+0x111/0x1b0 [intel_quicki2c] kernel: Write of size 12 at addr ffff888106d1f900 by task kworker/u33:2/75 kernel: kernel: CPU: 3 UID: 0 PID: 75 Comm: kworker/u33:2 Not tainted 6.16.0+ deepin-community#3 PREEMPT(voluntary) kernel: Workqueue: async async_run_entry_fn kernel: Call Trace: kernel: <TASK> kernel: dump_stack_lvl+0x76/0xa0 kernel: print_report+0xd1/0x660 kernel: ? __pfx__raw_spin_lock_irqsave+0x10/0x10 kernel: ? __kasan_slab_free+0x5d/0x80 kernel: ? kasan_addr_to_slab+0xd/0xb0 kernel: kasan_report+0xe1/0x120 kernel: ? quicki2c_acpi_get_dsd_property.constprop.0+0x111/0x1b0 [intel_quicki2c] kernel: ? quicki2c_acpi_get_dsd_property.constprop.0+0x111/0x1b0 [intel_quicki2c] kernel: kasan_check_range+0x11c/0x200 kernel: __asan_memcpy+0x3b/0x80 kernel: quicki2c_acpi_get_dsd_property.constprop.0+0x111/0x1b0 [intel_quicki2c] kernel: ? __pfx_quicki2c_acpi_get_dsd_property.constprop.0+0x10/0x10 [intel_quicki2c] kernel: quicki2c_get_acpi_resources+0x237/0x730 [intel_quicki2c] [...] kernel: </TASK> kernel: kernel: The buggy address belongs to stack of task kworker/u33:2/75 kernel: and is located at offset 48 in frame: kernel: quicki2c_get_acpi_resources+0x0/0x730 [intel_quicki2c] kernel: kernel: This frame has 3 objects: kernel: [32, 36) 'hid_desc_addr' kernel: [48, 59) 'i2c_param' kernel: [80, 224) 'i2c_config' ACPI DSD methods return: \_SB.PC00.THC0.ICRS Buffer 000000003fdc947b 001 Len 0C = 0A 00 80 1A 06 00 00 00 00 00 00 00 \_SB.PC00.THC0.ISUB Buffer 00000000f2fcbdc4 001 Len 91 = 00 00 00 00 00 00 00 00 00 00 00 00 Adding reserved padding to quicki2c_subip_acpi_parameter/config. Fixes: 5282e45 ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces") Signed-off-by: Aaron Ma <[email protected]> Reviewed-by: Even Xu <[email protected]> Tested-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 1db9df8) Signed-off-by: Cryolitia <[email protected]>
…C regs save Improper use of secondary pointer (&dev->i2c_subip_regs) caused kernel crash and out-of-bounds error: BUG: KASAN: slab-out-of-bounds in _regmap_bulk_read+0x449/0x510 Write of size 4 at addr ffff888136005dc0 by task kworker/u33:5/5107 CPU: 3 UID: 0 PID: 5107 Comm: kworker/u33:5 Not tainted 6.16.0+ deepin-community#3 PREEMPT(voluntary) Workqueue: async async_run_entry_fn Call Trace: <TASK> dump_stack_lvl+0x76/0xa0 print_report+0xd1/0x660 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? kasan_complete_mode_report_info+0x26/0x200 kasan_report+0xe1/0x120 ? _regmap_bulk_read+0x449/0x510 ? _regmap_bulk_read+0x449/0x510 __asan_report_store4_noabort+0x17/0x30 _regmap_bulk_read+0x449/0x510 ? __pfx__regmap_bulk_read+0x10/0x10 regmap_bulk_read+0x270/0x3d0 pio_complete+0x1ee/0x2c0 [intel_thc] ? __pfx_pio_complete+0x10/0x10 [intel_thc] ? __pfx_pio_wait+0x10/0x10 [intel_thc] ? regmap_update_bits_base+0x13b/0x1f0 thc_i2c_subip_pio_read+0x117/0x270 [intel_thc] thc_i2c_subip_regs_save+0xc2/0x140 [intel_thc] ? __pfx_thc_i2c_subip_regs_save+0x10/0x10 [intel_thc] [...] The buggy address belongs to the object at ffff888136005d00 which belongs to the cache kmalloc-rnd-12-192 of size 192 The buggy address is located 0 bytes to the right of allocated 192-byte region [ffff888136005d00, ffff888136005dc0) Replaced with direct array indexing (&dev->i2c_subip_regs[i]) to ensure safe memory access. Fixes: 4228966 ("HID: intel-thc-hid: intel-thc: Add THC I2C config interfaces") Signed-off-by: Aaron Ma <[email protected]> Reviewed-by: Even Xu <[email protected]> Tested-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit a7fc15e) Signed-off-by: Cryolitia <[email protected]>
Add THC I2C WildcatLake device IDs. Signed-off-by: Xinpeng Sun <[email protected]> Reviewed-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 510f05b) Signed-off-by: Cryolitia <[email protected]>
Add THC SPI WildcatLake device IDs. Signed-off-by: Xinpeng Sun <[email protected]> Reviewed-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit cc54ed5) Signed-off-by: Cryolitia <[email protected]>
…features
There is a new BIOS enhancement that adds the capability to configure the
following two features of I2C subsystem introduced in commit 1ed0b48
("Intel-thc: Introduce max input size control") and commit 3f2a921
("Intel-thc: Introduce interrupt delay control"):
- Max input size control
- Interrupt delay control
As BIOS is used for the configuration of these two features, change driver
data usage to indicate hardware capability, and add corresponding ACPI
configuration support in QuickI2C driver.
Signed-off-by: Xinpeng Sun <[email protected]>
Tested-by: Rui Zhang <[email protected]>
Reviewed-by: Even Xu <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
(cherry picked from commit 0b1fca9)
Signed-off-by: Cryolitia <[email protected]>
The type definition of qcdev->i2c_max_frame_size is already u32, so remove the unnecessary type casting le16_to_cpu. Signed-off-by: Xinpeng Sun <[email protected]> Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 6c26c05) Signed-off-by: Cryolitia <[email protected]>
… to edge detection The original implementation used level detection for the first interrupt after device reset to avoid potential interrupt line noise and missed interrupts during the initialization phase. However, this approach introduced unintended side effects when tested with certain touch panels, including: - Delayed hardware interrupt response - Multiple spurious interrupt triggers Switching back to edge detection for the first interrupt resolves these issues while maintaining reliable interrupt handling. Extensive testing across multiple platforms with touch panels from various vendors confirms this change introduces no regressions. [[email protected]: properly capitalize shortlog] Fixes: 9d8d517 ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation") Tested-by: Rui Zhang <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 8fe2cd8) Signed-off-by: Cryolitia <[email protected]>
Add the missing PCI ID for the quickspi device used on the Lenovo Yoga Pro 9i 16IAH10. Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=220567 Signed-off-by: Abhishek Tamboli <[email protected]> Reviewed-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> (cherry picked from commit 50f1f78) Signed-off-by: Cryolitia <[email protected]>
API changes in commit ceb8bf2("module: Convert symbol namespace to string literal") Signed-off-by: Cryolitia <[email protected]>
再看看 |
deepin pr auto review我将对这个Intel THC (Touch Host Controller)驱动代码进行审查,重点关注语法逻辑、代码质量、性能和安全性等方面。
主要改进建议:
// 在thc_dma_write中增加更严格的参数检查
if (!buffer || buf_len <= 0 || buf_len > dev->dma_ctx->dma_config[THC_TXDMA].max_packet_size) {
dev_err(dev->dev, "Invalid parameters: buffer %p, len %zu, max %zu\n",
buffer, buf_len, dev->dma_ctx->dma_config[THC_TXDMA].max_packet_size);
return -EINVAL;
}
// 在thc_dma_allocate中增加资源清理
int thc_dma_allocate(struct thc_device *dev)
{
int ret, chan;
for (chan = 0; chan < MAX_THC_DMA_CHANNEL; chan++) {
ret = setup_dma_buffers(dev, &dev->dma_ctx->dma_config[chan],
dev->dma_ctx->dma_config[chan].dir);
if (ret) {
// 清理已分配的资源
while (chan--)
release_dma_buffers(dev, &dev->dma_ctx->dma_config[chan]);
return ret;
}
}
return 0;
}
// 在频繁访问的寄存器操作中使用缓存
static inline u32 thc_read_reg_cached(struct thc_device *dev, u32 offset)
{
if (dev->reg_cache[offset] != INVALID_CACHE_VALUE)
return dev->reg_cache[offset];
dev->reg_cache[offset] = ioread32(dev->mmio_addr + offset);
return dev->reg_cache[offset];
}
// 在PIO操作中增加超时和重试机制
int thc_tic_pio_read(struct thc_device *dev, const u32 address,
const u32 size, u32 *actual_size, u32 *buffer)
{
int retries = 0;
int ret;
while (retries < MAX_RETRIES) {
ret = prepare_pio(dev, opcode, address, size);
if (ret)
return ret;
ret = pio_wait(dev);
if (!ret)
break;
retries++;
if (retries == MAX_RETRIES)
return -ETIMEDOUT;
msleep(PIO_RETRY_DELAY_MS);
}
return pio_complete(dev, buffer, actual_size);
}
#ifdef CONFIG_DEBUG_FS
// 添加debugfs接口用于调试
static int thc_debug_show(struct seq_file *s, void *unused)
{
struct thc_device *dev = s->private;
seq_printf(s, "DMA Status:\n");
seq_printf(s, " RXDMA1: %s\n",
dma_is_enabled(&dev->dma_ctx->dma_config[THC_RXDMA1]) ? "enabled" : "disabled");
// ... 其他状态信息
return 0;
}
#endif
// 在空闲时降低功耗
static void thc_enter_low_power(struct thc_device *dev)
{
// 降低时钟频率
thc_set_clock_freq(dev, THC_LOW_POWER_FREQ);
// 关闭不必要的DMA通道
thc_dma_channel_disable(dev, THC_TXDMA);
// 进入低功耗LTR模式
thc_change_ltr_mode(dev, THC_LTR_MODE_LP);
}
// 使用宏简化寄存器操作
#define THC_REG_READ(dev, reg) \
ioread32((dev)->mmio_addr + (reg##_OFFSET))
#define THC_REG_WRITE(dev, reg, val) \
iowrite32((val), (dev)->mmio_addr + (reg##_OFFSET))
#define THC_REG_UPDATE(dev, reg, mask, val) \
THC_REG_WRITE(dev, reg, (THC_REG_READ(dev, reg) & ~(mask)) | (val))
#ifdef CONFIG_TEST_THC
// 添加测试模式支持
static int thc_self_test(struct thc_device *dev)
{
int ret;
// 测试DMA通道
ret = thc_dma_test(dev);
if (ret)
return ret;
// 测试PIO操作
ret = thc_pio_test(dev);
if (ret)
return ret;
// 测试中断处理
ret = thc_interrupt_test(dev);
if (ret)
return ret;
return 0;
}
#endif这些改进建议主要针对:
建议按优先级逐步实施这些改进,优先处理错误处理和安全性相关的问题。 |
No description provided.