HID: intel-thc-hid: intel-thc: DMA lifetime fixes
Subsystems (2)
cover HID: intel-thc-hid: intel-thc: DMA lifetime fixes
This series fixes the DMA lifetime problems a protocol driver above the THC core cannot work around, plus two smaller issues next to them.
Patch 1 makes thc_dma_write() report the error it found instead of overwriting it with the result of the interrupt restore, and stops a signal from turning a committed transfer into a restartable one. The completion interrupt has to wake the queue with wake_up(), because the new wait is uninterruptible.
Patch 2 unwinds a failed allocation through thc_dma_release(), so the channel whose setup failed is freed too, and frees a scatter-gather list that was allocated but never mapped.
Patch 3 stops all four engines before thc_dma_unconfigure() clears their PRD base addresses; only the two receive engines are stopped today.
Patch 4 adds the low frequency SPI gears, down to 2.23 MHz.
Patch 5 gives the receive engines a drain budget that covers a full frame at that gear, and leaves the SWDMA path on the old one.
These apply to v7.4-rc3. They are independent of the PRD table capacity fix posted separately; the two are both needed for the recovery path to be complete, but neither depends on the other.
Emfox Zhou (5):
HID: intel-thc-hid: intel-thc: keep TxDMA write errors
HID: intel-thc-hid: intel-thc: free the failed channel
HID: intel-thc-hid: intel-thc: stop all engines first
HID: intel-thc-hid: intel-thc: add the slow SPI gears
HID: intel-thc-hid: intel-thc: budget the receive drain
.../intel-thc-hid/intel-thc/intel-thc-dev.c | 45 ++++++++--- .../intel-thc-hid/intel-thc/intel-thc-dma.c | 77 +++++++++++-------- .../intel-thc-hid/intel-thc/intel-thc-dma.h | 5 ++ 3 files changed, 86 insertions(+), 41 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
PATCH 1/5 HID: intel-thc-hid: intel-thc: keep TxDMA write errors
thc_dma_write() reports success after a timeout: the cleanup at the end overwrites the error with the result of thc_interrupt_quiesce(), so a frame that never left the device is taken as sent.
That wait also ends on a signal, and the no-completion branch folds the result into -ETIMEDOUT. There is nothing to restart here: the frame is already in the engine, so a restarted write() would hand the same report to the controller twice. Wait without interruption, the window is one second, and report a failing interrupt restore instead of dropping it.
The completion interrupt wakes the queue with wake_up_interruptible(), whose mask does not intersect TASK_UNINTERRUPTIBLE: a completion that arrives after the task sleeps is dropped, and the write waits out its timer with the bus lock held. Wake all waiters instead.
--- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 2 +- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +1 -1
@@ -990,7 +990,7 @@ int thc_interrupt_handler(struct thc_device *dev) THC_M_PRT_WRITE_INT_STS_OFFSET, write_sts); dev->write_done = true; -wake_up_interruptible (&dev->write_complete_wait); +wake_up (&dev->write_complete_wait); interrupt_type |=BIT (THC_TXDMA_INT ); }
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +5 -4
@@ -1045,8 +1045,9 @@ int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len)dma_set_start_bit (dev, &dev->dma_ctx->dma_config[THC_TXDMA ]); - ret =wait_event_interruptible_timeout (dev->write_complete_wait, dev->write_done,1 *HZ ); -if (ret <=0 || !dev->write_done) { + ret =wait_event_timeout (dev->write_complete_wait, + dev->write_done,1 *HZ ); +if (!ret || !dev->write_done) {dev_err_once (dev->dev,"timeout for waiting TxDMA completion\n" ); ret = -ETIMEDOUT ; goto end;
@@ -1059,8 +1060,8 @@ int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len) end:mutex_unlock (&dev->thc_bus_lock); -if (restore_interrupts) - ret =thc_interrupt_quiesce (dev, false); +if (restore_interrupts &&thc_interrupt_quiesce (dev, false)) +dev_err (dev->dev,"failed to restore interrupts after TxDMA write\n" );return ret; }
[email protected]
AI reviewRe: [PATCH 1/5] HID: intel-thc-hid: intel-thc: keep TxDMA write errors
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Medium] HID: intel-thc-hid: synchronous block…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Medium] HID: intel-thc-hid: synchronous block in quicki2c_hid_output_report() [1]
--
commit 7d6243e52aaa280fbfaad43053698624190f219b
Author: Emfox Zhou <[email protected]>
HID: intel-thc-hid: intel-thc: keep TxDMA write errors
This commit waits uninterruptibly for TxDMA completion in thc_dma_write(), wakes all waiters on write_complete_wait, and preserves the write error code when unquiescing interrupts during cleanup.
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len) · line 1049
Quoted 12 lines
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +2
-2@@ -1045,8 +1045,9 @@ int thc_dma_write(struct thc_device *dev, void *buffer, size_t buf_len)dma_set_start_bit (dev, &dev->dma_ctx->dma_config[THC_TXDMA ]); - ret =wait_event_interruptible_timeout (dev->write_complete_wait, dev->write_done,1 *HZ ); -if (ret <=0 || !dev->write_done) { + ret =wait_event_timeout (dev->write_complete_wait, + dev->write_done,1 *HZ );
[Severity: Medium]
This problem wasn't introduced by this patch, but does calling thc_dma_write() from quicki2c_hid_output_report() violate the HID output_report contract [1] by blocking the caller?
The HID subsystem requires the .output_report callback to be asynchronous, yet quicki2c_hid_output_report() -> quicki2c_output_report() -> thc_dma_write() acquires dev->thc_bus_lock and blocks on dev->write_complete_wait for up to a second, stalling the calling HID core workqueue or thread.
[1] https://sashiko.dev/#/bug/linux-84fcc3fd-7b0c-485b-9da1-a71ea67e4f5e
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/5 HID: intel-thc-hid: intel-thc: free the failed channel
In reply to Emfox Zhouthc_dma_allocate() unwinds with "while (chan--)". The condition is read before the decrement, so the first channel released is the one before the failure, and the failed channel keeps the PRD tables and the scatter-gather lists it did manage to allocate.
Unwind through thc_dma_release() instead, which walks every channel and skips the ones that were never set up, and free a scatter-gather list that was allocated but never mapped: sgl_alloc() leaves one behind when its entry count is too large.
That leaves release_dma_buffers() with a configuration whose prd_tbls may still be NULL, which its unconditional memset() does not survive. Clear the tables only when there are any.
--- .../hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +7 -8
@@ -297,20 +297,20 @@ static void release_dma_buffers(struct thc_device *dev,return ;for (i =0 ; i < config->prd_tbl_num; i++) { -if (!config->sgls[i] || !config->sgls_nent[i]) +if (!config->sgls[i])continue ; -dma_unmap_sg (dev->dev, config->sgls[i], - config->sgls_nent_pages[i], - config->dir); +if (config->sgls_nent[i]) +dma_unmap_sg (dev->dev, config->sgls[i], + config->sgls_nent_pages[i], + config->dir);sgl_free (config->sgls[i]); config->sgls[i] =NULL ; } -memset (config->prd_tbls,0 , prd_tbls_size); -if (config->prd_tbls) { +memset (config->prd_tbls,0 , prd_tbls_size);dma_free_coherent (dev->dev, prd_tbls_size, config->prd_tbls, config->prd_tbls_dma_handle); config->prd_tbls =NULL ;
@@ -425,8 +425,7 @@ int thc_dma_allocate(struct thc_device *dev)return 0 ; release_bufs: -while (chan--) -release_dma_buffers (dev, &dev->dma_ctx->dma_config[chan]); +thc_dma_release (dev);return ret; }
PATCH 3/5 HID: intel-thc-hid: intel-thc: stop all engines first
In reply to Emfox Zhouthc_dma_unconfigure() clears the PRD base address and the control registers of every channel, but stops only the two receive engines. The write and software DMA engines keep their start bit, so an engine that is still running is left pointing at a table base of zero.
Stop all four engines first, and clear the tables afterwards. The four start clears move to thc_clear_start_bits(), next to the per channel setter, and thc_reset_dma_settings() uses it as well, so the set of engines is written down once.
--- .../intel-thc-hid/intel-thc/intel-thc-dma.c | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +19 -14
@@ -94,6 +94,18 @@ static void dma_set_start_bit(struct thc_device *dev, } } +static void thc_clear_start_bits (struct thc_device *dev) +{ +regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_1_OFFSET , +THC_M_PRT_READ_DMA_CNTRL_START ,0 ); +regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_2_OFFSET , +THC_M_PRT_READ_DMA_CNTRL_START ,0 ); +regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_SW_OFFSET , +THC_M_PRT_READ_DMA_CNTRL_START ,0 ); +regmap_write_bits (dev->thc_regmap,THC_M_PRT_WRITE_DMA_CNTRL_OFFSET , +THC_M_PRT_WRITE_DMA_CNTRL_THC_WRDMA_START ,0 ); +} +static void dma_set_prd_control (struct thc_device *dev,u8 entry_count,u8 cb_depth,struct thc_dma_configuration *dma_config) {
@@ -267,14 +279,7 @@ static int setup_dma_buffers(struct thc_device *dev,static void thc_reset_dma_settings (struct thc_device *dev) {/* Stop all DMA channels and reset DMA read pointers */ -regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_1_OFFSET , -THC_M_PRT_READ_DMA_CNTRL_START ,0 ); -regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_2_OFFSET , -THC_M_PRT_READ_DMA_CNTRL_START ,0 ); -regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_SW_OFFSET , -THC_M_PRT_READ_DMA_CNTRL_START ,0 ); -regmap_write_bits (dev->thc_regmap,THC_M_PRT_WRITE_DMA_CNTRL_OFFSET , -THC_M_PRT_WRITE_DMA_CNTRL_THC_WRDMA_START ,0 ); +thc_clear_start_bits (dev); regmap_write_bits(dev->thc_regmap, THC_M_PRT_READ_DMA_CNTRL_1_OFFSET, THC_M_PRT_READ_DMA_CNTRL_TPCPR,
@@ -518,16 +523,16 @@ void thc_dma_unconfigure(struct thc_device *dev) {int chan; +/* +* Stop the engines first: one that is running keeps writing through +* a table whose base is already gone. +*/ +thc_clear_start_bits (dev); +for (chan =0 ; chan <MAX_THC_DMA_CHANNEL ; chan++) {dma_set_prd_base_addr (dev,0 , &dev->dma_ctx->dma_config[chan]);dma_clear_prd_control (dev, &dev->dma_ctx->dma_config[chan]); } - -regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_1_OFFSET , -THC_M_PRT_READ_DMA_CNTRL_START ,0 ); - -regmap_write_bits (dev->thc_regmap,THC_M_PRT_READ_DMA_CNTRL_2_OFFSET , -THC_M_PRT_READ_DMA_CNTRL_START ,0 ); }EXPORT_SYMBOL_NS_GPL (thc_dma_unconfigure,"INTEL_THC" );
[email protected]
AI reviewRe: [PATCH 3/5] HID: intel-thc-hid: intel-thc: stop all engines first
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Medium] HID: intel-thc-hid: intel-thc…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Medium] HID: intel-thc-hid: intel-thc: missing PRD table reinit in thc_dma_configure() [1]
--
commit 68cc7b868e9e15fc7c7b6e500ccb219382a1991c
Author: Emfox Zhou <[email protected]>
HID: intel-thc-hid: intel-thc: stop all engines first
This commit introduces a helper to clear the start bits of all four DMA engines and uses it in thc_dma_unconfigure() before clearing the PRD base address and control registers.
Quoted 4 lines
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +0
-0
[ ... ]
Quoted 4 lines
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +0
-0@@ -518,16 +523,16 @@ void thc_dma_unconfigure(struct thc_device *dev) {int chan;
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c void thc_dma_unconfigure(struct thc_device *dev) · line 535
Quoted 10 lines
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +6
-0+/* +* Stop the engines first: one that is running keeps writing through +* a table whose base is already gone. +*/ +thc_clear_start_bits (dev); +for (chan =0 ; chan <MAX_THC_DMA_CHANNEL ; chan++) {dma_set_prd_base_addr (dev,0 , &dev->dma_ctx->dma_config[chan]);dma_clear_prd_control (dev, &dev->dma_ctx->dma_config[chan]); }
[Severity: Medium]
This problem wasn't introduced by this patch, but does thc_dma_configure() leave stale PRD table entries behind after an RxDMA reset [1]?
During RxDMA reception, hardware updates len, end_of_prd, and hw_status in place inside config->prd_tbls, and thc_dma_read() normally restores each consumed table via thc_copy_one_sgl_to_prd(). When RxDMA error recovery runs try_recover() -> thc_rxdma_reset() -> thc_dma_configure(), thc_reset_dma_settings() resets the hardware ring pointers without reinitializing unread PRD tables, so subsequent transfers reuse the stale len and end_of_prd values and can truncate frames or trigger repeated DMA errors.
[1] https://sashiko.dev/#/bug/linux-0a97c61f-7f80-4aab-98a8-b9354f3b828e
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/5 HID: intel-thc-hid: intel-thc: add the slow SPI gears
In reply to Emfox ZhouThe frequency table stops at 7.8125 MHz, so a device that asks for a slower clock is rejected with -EINVAL. The divider enum already covers that range: with the low frequency bit set the divider is multiplied by eight (see intel-thc-hw.h), which brings DIV_7 down to 2.23 MHz.
Add the five missing gears. The half divider check exempts the new 5.2083 MHz gear, which is already DIV_3 with the eighth divider enabled, so the extra half divider would land on top of it. The 10.4167 MHz gear is low frequency as well but keeps the half divider; it is not part of this change.
The read and write configuration carried identical copies of that check, so move it to thc_spi_needs_half_div().
--- .../intel-thc-hid/intel-thc/intel-thc-dev.c | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +35 -8
@@ -1111,6 +1111,12 @@ int thc_port_select(struct thc_device *dev, enum thc_port_type port_type) }EXPORT_SYMBOL_NS_GPL (thc_port_select,"INTEL_THC" ); +/* 125 MHz / (8 * N), with the low frequency bit set. */ +#define THC_SPI_FREQUENCY_2M2 2232143 +#define THC_SPI_FREQUENCY_2M6 2604167 +#define THC_SPI_FREQUENCY_3M1 3125000 +#define THC_SPI_FREQUENCY_3M9 3906250 +#define THC_SPI_FREQUENCY_5M2 5208333#define THC_SPI_FREQUENCY_7M 7812500#define THC_SPI_FREQUENCY_10M 10416700#define THC_SPI_FREQUENCY_15M 15625000
@@ -1127,6 +1133,11 @@ EXPORT_SYMBOL_NS_GPL(thc_port_select, "INTEL_THC");static u8 thc_get_spi_freq_div_val (struct thc_device *dev,u32 spi_freq_val) {static const int frequency[] = { +THC_SPI_FREQUENCY_2M2 , +THC_SPI_FREQUENCY_2M6 , +THC_SPI_FREQUENCY_3M1 , +THC_SPI_FREQUENCY_3M9 , +THC_SPI_FREQUENCY_5M2 ,THC_SPI_FREQUENCY_7M ,THC_SPI_FREQUENCY_10M ,THC_SPI_FREQUENCY_15M ,
@@ -1139,6 +1150,11 @@ static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val) THC_SPI_FREQUENCY_50M, };static const u8 frequency_div[] = { +THC_SPI_FRQ_DIV_7 , +THC_SPI_FRQ_DIV_6 , +THC_SPI_FRQ_DIV_5 , +THC_SPI_FRQ_DIV_4 , +THC_SPI_FRQ_DIV_3 ,THC_SPI_FRQ_DIV_2 ,THC_SPI_FRQ_DIV_1 ,THC_SPI_FRQ_DIV_1 ,
@@ -1174,6 +1190,23 @@ static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val)return freq_div; } +/* +* 10M, 35M and 50M take the half divider; 5.2083 MHz is already DIV_3, and +* 10.4167 MHz keeps it. +*/ +static bool thc_spi_needs_half_div (u8 freq_div,u32 spi_freq_val, +bool is_low_freq) +{ +if (freq_div ==THC_SPI_FRQ_DIV_2 ) +return spi_freq_val >=THC_SPI_FREQUENCY_50M ; + +if (freq_div ==THC_SPI_FRQ_DIV_3 ) +return spi_freq_val <THC_SPI_FREQUENCY_41M && !is_low_freq; + +return freq_div ==THC_SPI_FRQ_DIV_1 && + spi_freq_val <THC_SPI_FREQUENCY_15M ; +} +/** * thc_spi_read_config - Configure SPI bus read attributes *
@@ -1199,10 +1232,7 @@ int thc_spi_read_config(struct thc_device *dev, u32 spi_freq_val,if (spi_freq_val <THC_SPI_LOW_FREQUENCY ) is_low_freq = true; -/* 10M, 35M and 50M CLK need 1.5, 3.5 and 2.5 half divider */ -if ((freq_div ==THC_SPI_FRQ_DIV_2 && spi_freq_val >=THC_SPI_FREQUENCY_50M ) || - (freq_div ==THC_SPI_FRQ_DIV_3 && spi_freq_val <THC_SPI_FREQUENCY_41M ) || - (freq_div ==THC_SPI_FRQ_DIV_1 && spi_freq_val <THC_SPI_FREQUENCY_15M )) { +if (thc_spi_needs_half_div (freq_div, spi_freq_val, is_low_freq)) {regmap_write_bits (dev->thc_regmap,THC_M_PRT_SPI_DUTYC_CFG_OFFSET ,THC_M_PRT_SPI_DUTYC_CFG_SPI_TCRF_HALF_DIV_EN ,THC_M_PRT_SPI_DUTYC_CFG_SPI_TCRF_HALF_DIV_EN );
@@ -1271,10 +1301,7 @@ int thc_spi_write_config(struct thc_device *dev, u32 spi_freq_val,if (spi_freq_val <THC_SPI_LOW_FREQUENCY ) is_low_freq = true; -/* 10M, 35M and 50M CLK need 1.5, 3.5 and 2.5 half divider */ -if ((freq_div ==THC_SPI_FRQ_DIV_2 && spi_freq_val >=THC_SPI_FREQUENCY_50M ) || - (freq_div ==THC_SPI_FRQ_DIV_3 && spi_freq_val <THC_SPI_FREQUENCY_41M ) || - (freq_div ==THC_SPI_FRQ_DIV_1 && spi_freq_val <THC_SPI_FREQUENCY_15M )) { +if (thc_spi_needs_half_div (freq_div, spi_freq_val, is_low_freq)) {regmap_write_bits (dev->thc_regmap,THC_M_PRT_SPI_DUTYC_CFG_OFFSET ,THC_M_PRT_SPI_DUTYC_CFG_SPI_TCWF_HALF_DIV_EN ,THC_M_PRT_SPI_DUTYC_CFG_SPI_TCWF_HALF_DIV_EN );
PATCH 5/5 HID: intel-thc-hid: intel-thc: budget the receive drain
In reply to Emfox Zhouthc_wait_for_dma_pause() gives every engine 10 ms to report idle, but a receive engine can be draining a whole frame. Its buffer comes from the HIDSPI device descriptor's max_input_len, rounded up to 4 KB and capped at 16 PRD entries, so up to 64 KB; at the 2.23 MHz gear that takes about 235 ms, and a timed out pause makes thc_rxdma_reset() return before the engines are reconfigured, leaving the controller quiesced with the interrupts off.
Let the callers pass the budget. thc_rxdma_reset() gets one that covers a full frame at the slowest gear. The SWDMA path keeps the old one: it pauses the receive engines with the bus lock held and the interrupts quiesced, and its frames are small.
--- .../intel-thc-hid/intel-thc/intel-thc-dma.c | 20 +++++++++++++------ .../intel-thc-hid/intel-thc/intel-thc-dma.h | 5 +++++ 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +14 -6
@@ -536,7 +536,9 @@ void thc_dma_unconfigure(struct thc_device *dev) }EXPORT_SYMBOL_NS_GPL (thc_dma_unconfigure,"INTEL_THC" ); -static int thc_wait_for_dma_pause (struct thc_device *dev,enum thc_dma_channel channel) +static int thc_wait_for_dma_pause (struct thc_device *dev, +enum thc_dma_channel channel, +u32 timeout_us) {u32 ctrl_reg, sts_reg, sts;int ret;
@@ -554,7 +556,7 @@ static int thc_wait_for_dma_pause(struct thc_device *dev, enum thc_dma_channel c ret =regmap_read_poll_timeout (dev->thc_regmap, sts_reg, sts, !(sts &THC_M_PRT_READ_DMA_INT_STS_ACTIVE ),THC_DEFAULT_RXDMA_POLLING_US_INTERVAL , -THC_DEFAULT_RXDMA_POLLING_US_TIMEOUT ); + timeout_us);if (ret) { dev_err_once(dev->dev,
@@ -588,13 +590,15 @@ int thc_rxdma_reset(struct thc_device *dev) goto end; } - ret =thc_wait_for_dma_pause (dev,THC_RXDMA1 ); + ret =thc_wait_for_dma_pause (dev,THC_RXDMA1 , +THC_RXDMA_DRAIN_US_TIMEOUT );if (ret) {dev_err (dev->dev,"Wait for RxDMA1 pause failed during RxDMA reset\n" ); goto end; } - ret =thc_wait_for_dma_pause (dev,THC_RXDMA2 ); + ret =thc_wait_for_dma_pause (dev,THC_RXDMA2 , +THC_RXDMA_DRAIN_US_TIMEOUT );if (ret) {dev_err (dev->dev,"Wait for RxDMA2 pause failed during RxDMA reset\n" ); goto end;
@@ -769,7 +773,10 @@ static int thc_swdma_read_start(struct thc_device *dev, void *write_buff,if (ret)return ret; -if (thc_wait_for_dma_pause (dev,THC_RXDMA1 ) ||thc_wait_for_dma_pause (dev,THC_RXDMA2 )) +if (thc_wait_for_dma_pause (dev,THC_RXDMA1 , +THC_DEFAULT_RXDMA_POLLING_US_TIMEOUT ) || +thc_wait_for_dma_pause (dev,THC_RXDMA2 , +THC_DEFAULT_RXDMA_POLLING_US_TIMEOUT ))return -EIO ;thc_reset_dma_settings (dev);
@@ -834,7 +841,8 @@ static int thc_swdma_read_completion(struct thc_device *dev) {int ret; - ret =thc_wait_for_dma_pause (dev,THC_SWDMA ); + ret =thc_wait_for_dma_pause (dev,THC_SWDMA , +THC_DEFAULT_RXDMA_POLLING_US_TIMEOUT );if (ret)return ret;
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.h +5 -0
@@ -19,6 +19,11 @@#define THC_DEFAULT_RXDMA_POLLING_US_INTERVAL 100#define THC_DEFAULT_RXDMA_POLLING_US_TIMEOUT (10 * USEC_PER_MSEC) +/* +* 235 ms for a 64 KB frame at the slowest gear, so this covers a whole one. +*/ +#define THC_RXDMA_DRAIN_US_TIMEOUT (500 * USEC_PER_MSEC) +/* * THC needs 1KB aligned address, dest_addr is 54 bits, not 64, * so don't need to send the lower 10-bits of address.