From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=82.195.75.108 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794835931; b=PsJVIZrtj577g0VLJCnlC/cS0sEAonpmRbG8CDEmRAGvXqmv9Hj5OBZhbp0MRJ6nfpVP Qc0DZkS4gyHc7VdCjG5MiEzd6mmrMMS4vbGVVYAzGMvzm/4glTdHwaR/Qv7+RUrzEfM9r ZQ4fLhej3FmQkB3fCWmZ051ddIhxFTFerCPv9ODpW/7Pea9Yw8uG5lHALX+7ZdS6yd5+k Uk0YHsaK1WGxFG6Ij/2kpBJLRFTpx4WyVbJrSZUVNQIEz1PXLqOy4Lq/fzrut+3bSls6Q 3GtH7xCQkes9L0S7fBOl7tq6IuoXB8epFCuDNK6XHCTbPLlziVQgnXT9/v/rJzRa90Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794835931; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Debian-User; bh=F1abZW9KdHqAJb6r2vfcjqGF17wKq2fQTvN2iS747O0=; b=4LJjmM8SWj1TknfhXNSkwoczFQA2NWYnmFMOfoRvlWtWw9vG7Gs7eBIrosxIQOewNrLd pTqumBV+x5ZMbA4DkCs0TSA6nCh0Y6CF+j23YB/fBpLr2W0SV/1jPFxlhFOzd0Q1YLl92 nOw2WnehpW9qk5rOt8f+xemWEGaiKJ6o5W+EjoVYMBzgePrp/w26mnVVDg0FWPpM8Q0Ct 4dWRux640iVC6cN58a4bXXttx/ZtPdXQA02e1lcnizYYfbVuzDsGi3SrBiq+wq6wc7e0M VPPEl/UkJCXt6/9nz24G/jie05Q6Il6dfd+tQ6DcmRHrVMgCUWm4r7G62pkLLi+zFxQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=iTyLVkSP; arc=none smtp.remote-ip=82.195.75.108 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ED8E606A31C; Mon, 16 Nov 2026 13:32:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6ED8E606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=iTyLVkSP DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-Type:Content-ID:Content-Description; bh=F1abZW9KdHqAJb6r2vfcjqGF17wKq2fQTvN2iS747O0=; b=iTyLVkSP51lpCvhuD5pEOnHKH4 nbmSNP42aAnnzr5lS/ztCvLPMGkN6MGlGt8j88OZaYTF1CBn1aPPtHtwVVnv35u5KeGYBq1P9560P lIy5hVFVbrPOlNg0TwbPyUdUeQlPSPTFumGM0MIDcQOJdmANgopEv8Qkp0RmxRj278da6ZI8yNDbQ +121n/0WeGbXUw061GWgYH6S/HCXniU/J002EQvuJ4VYqvNZoeV/NfP43XNUYHtoZtDARjQosh4Zr VGFxYUZrXm7JuQYJdICuoZRVwiMm72LvnBkBXsQBkYL0aBbrqwAKK4sP+mhz3DJlhgDUfmAeAG3gt Q7vFyMNQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1xSwoT-00HCTx-0m; Mon, 16 Nov 2026 13:32:01 +0000 From: Emfox Zhou To: Even Xu , Xinpeng Sun , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] HID: intel-thc-hid: intel-thc: keep TxDMA write errors Date: Mon, 16 Nov 2026 21:31:28 +0800 Message-ID: <20261116133132.1282020-2-emfox@debian.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261116133132.1282020-1-emfox@debian.org> References: <20261116133132.1282020-1-emfox@debian.org> X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Debian-User: emfox 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. Fixes: a688404b2e20 ("HID: intel-thc-hid: intel-thc: Add THC DMA interfaces") Signed-off-by: Emfox Zhou --- 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(-) diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c index 7feda4160..7429f851c 100644 --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c @@ -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); } diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c index c80ef8c20..c0dc44e26 100644 --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c @@ -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; }