From patchwork Tue Oct 1 12:50:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817962 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C35B1C244D; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=mrvlYUOFQCwbzprWUp1Zac6Hp/mp2H0xIpDP3d3vnk5VVNkcjBaKt0Mms0LltARHLtfSxETM8HS3GHr2NHZb/95U3DohsuK0oTUiTYMpBW0hyQWn5xf0dqswkgGQ34y8u9X0EQ+3h8nNrHzKAis84p2JSzmFS0c1Rdw5C+C5z0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=CIdoqbXA+YVySAKWww1LHhuYfAYue7nHwwUDVhAg8Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHIXUSpdnkn8eOZqVLGACgGVM5AFLqpE5Q8JQ0B6pscc1y73BJwYl7a8yLXOJcecqf4vQ/hfDg5XB9jAzVSuXc1Mp02Cagn8kUcmazVPO/rXGICrfkfH43eiUwj8kzXX8MjjMxBl86FeTauz8nJnIhNfzsi+d8yuWGGeQMc8QIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oV7KiK+l; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oV7KiK+l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4909C4CECE; Tue, 1 Oct 2024 12:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=CIdoqbXA+YVySAKWww1LHhuYfAYue7nHwwUDVhAg8Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oV7KiK+lj/8uPkuIW6XlNda8pIOd76lvzg+aqlHnTjAyRr8aWv0SNd/tY60FMdIT0 6jKyL0xrk0uBl+3K95+HQGJY0/DuoptAL3Dwz+5k6rBC+OStYKhbhK5dvG0PraqJ3l RTWj3enQKXGTdmnxxPEGSkZ1kXXBXwy6w03SEPEFSCzUd88bGpGKAZJp4g6Q2ik1He 5C+AQIvt1j1JfY5WG+ltzuLR1bhIGDlnl6lDx3w4JGHPNNNQWPhH7hT0C8Gwoz7rG6 k1YJaXtddlT18SISiKH8ari9LI4PAh1tNso9h3DAjwrzy/QQF8N3J91FzwRZFA5P+e RxzDSt7lby6+A== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLO-000000002mE-3uJ9; Tue, 01 Oct 2024 14:51:10 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Aniket Randive Subject: [PATCH v2 1/7] serial: qcom-geni: fix premature receiver enable Date: Tue, 1 Oct 2024 14:50:27 +0200 Message-ID: <20241001125033.10625-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The receiver should not be enabled until the port is opened so drop the bogus call to start rx from the setup code which is shared with the console implementation. This was added for some confused implementation of hibernation support, but the receiver must not be started unconditionally as the port may not have been open when hibernating the system. Fixes: 35781d8356a2 ("tty: serial: qcom-geni-serial: Add support for Hibernation feature") Cc: stable@vger.kernel.org # 6.2 Cc: Aniket Randive Signed-off-by: Johan Hovold --- drivers/tty/serial/qcom_geni_serial.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 6f0db310cf69..9ea6bd09e665 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1152,7 +1152,6 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport) false, true, true); geni_se_init(&port->se, UART_RX_WM, port->rx_fifo_depth - 2); geni_se_select_mode(&port->se, port->dev_data->mode); - qcom_geni_serial_start_rx(uport); port->setup = true; return 0; From patchwork Tue Oct 1 12:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817961 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C3FF1C245F; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=UEulrr7toOsCCsr1RZg6ymHs3Fw1iI6Q0wUMEzPkF6IGkk1P6Ejj2nHf09Xi7kzuOUEuYQuDU046evnNoaPpkN06PAiaeon/nBkuaAzuI2Ql6HZbm8DZNZduME0WSu3Ah6otnuwlThaJQ6ev/G7iS6yvdjnWw05UVY/ODkF3Qww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=hPaxSeDJ1aGZNJvz+/cNIjIukyj2Wnde/8UoejTcVrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qo6tqgik5m/3KRjSp22tm4ncdBHnbjJOlabBXInWwYqZr6srlNg6iBQ3svUmWZ6jatQM+UbyORsWRyMvEFzNQac0kRT1nHS4K/xHtjFeDRL4F45KdZ5GiMuy3v+yQCSs0A4QeqZe7OmSJDugFiYTnmhkuRy/LG0nU3OqhF1u7s8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZDJQW6zT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZDJQW6zT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF9F4C4CECD; Tue, 1 Oct 2024 12:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787070; bh=hPaxSeDJ1aGZNJvz+/cNIjIukyj2Wnde/8UoejTcVrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDJQW6zTJQc78P6uzypLd8EsVnn/frB19SXivNy4Q1Yi0dtxCVVVvnSNrdfs7bdXI ptXiMgbKysxUp/t9M+T4UviRa/sBJbBiFBHJZey9whRi6eVqwEZJt8VdkLuhWwpdMS VXWrXbSyBxYZ+kW6+g3iwbfxPe8woAemB2KNmlPgnMMl5B4cGl19Qi3N8OECno5T+j m6P9LdzdNMMKebIpumtu9lF0sIR7uGZMTKvWkCPVPGB9TNQ/LVV71t59rwCJF+bcoq kPtjPYLlDZCH28TuadXJo3Dzc7wF66BS6Zwwwg4dAO32RPa14MPOmnzn09HZW8KeNF kXOYy4HvfZhqw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mG-02ff; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 2/7] serial: qcom-geni: fix shutdown race Date: Tue, 1 Oct 2024 14:50:28 +0200 Message-ID: <20241001125033.10625-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A commit adding back the stopping of tx on port shutdown failed to add back the locking which had also been removed by commit e83766334f96 ("tty: serial: qcom_geni_serial: No need to stop tx/rx on UART shutdown"). Holding the port lock is needed to serialise against the console code, which may update the interrupt enable register and access the port state. Fixes: d8aca2f96813 ("tty: serial: qcom-geni-serial: stop operations in progress at shutdown") Fixes: 947cc4ecc06c ("serial: qcom-geni: fix soft lockup on sw flow control and suspend") Cc: stable@vger.kernel.org # 6.3 Cc: Bartosz Golaszewski Signed-off-by: Johan Hovold Reviewed-by: Bartosz Golaszewski --- drivers/tty/serial/qcom_geni_serial.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 9ea6bd09e665..b6a8729cee6d 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1096,10 +1096,12 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport) { disable_irq(uport->irq); + uart_port_lock_irq(uport); qcom_geni_serial_stop_tx(uport); qcom_geni_serial_stop_rx(uport); qcom_geni_serial_cancel_tx_cmd(uport); + uart_port_unlock_irq(uport); } static void qcom_geni_serial_flush_buffer(struct uart_port *uport) From patchwork Tue Oct 1 12:50:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817960 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C2F61A0AFB; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=MJam2Oz39iIoqPKB0N2+wltP1rvGOZnbcEARskuvNqW98Z06B5jJGC0OSlpTYkp4RNvqudhCTqTeI1dGDsQ2tu38UQ/0HwWJ774wki++8pBupiESQxsxjX5ebt916lTHcXh4aNEegQgTmH4dZzWMCKQfuj/Wj2ReKyX9hmgFmOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=1YDwGAT9d5r98sjNJsTBq19sCn2srPOrFhzzQ2PFT4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mwtFN58nKDwIBe+vamZZZh8vbWnI/YBfiTrMzLhnnmZmt6GPCWyCb2Ks8FhhL4xq586pYrcKGl6U6dacBv6A8f1hI9KJLLoqjApNekvGWrJyUNr7ZBLeY8PSEYGdOBGC1tZ12FKpcncDothuhl0mA4/h5vCXtCSmMzOjYM13f6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YOmPsqE4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YOmPsqE4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6DC3C4CED2; Tue, 1 Oct 2024 12:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=1YDwGAT9d5r98sjNJsTBq19sCn2srPOrFhzzQ2PFT4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOmPsqE4C9yMR0T+4SsdeQy8l8gyG69CDCXCf9GPGrhCEL24IU58+GD/WGfOHkRgZ mXnVzNpvCdiZ0vupH/ykosXZvXU5OSDiSaXWOzK2ggnIq0er7jG1w/i965NCPgW/Wx UfDKvfo9YVA+/xDMawhReIXJNo8p6rKwqFGkmMEf2jKDB+wiaTJqNsccIYpLTf10BZ vF+QWFipc1ZA7slXIwyKZR1GAXmsJ8wpCBPjuxjQl3gxGYMKyvEgIZEHbOQ7//a63p 7FbSIe34mRysEH5JEKIi4X9iiTHn6XyQDj/ij8bG7yK1NejlcNUFrzKXQRztqepfEH 7emdrcOEkLOog== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mI-0SiE; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 3/7] serial: qcom-geni: fix dma rx cancellation Date: Tue, 1 Oct 2024 14:50:29 +0200 Message-ID: <20241001125033.10625-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make sure to wait for the DMA transfer to complete when cancelling the rx command on stop_rx(). This specifically prevents the DMA completion interrupt from firing after rx has been restarted, something which can lead to an IOMMU fault and hosed rx when the interrupt handler unmaps the DMA buffer for the new command: qcom_geni_serial 988000.serial: serial engine reports 0 RX bytes in! arm-smmu 15000000.iommu: FSR = 00000402 [Format=2 TF], SID=0x563 arm-smmu 15000000.iommu: FSYNR0 = 00210013 [S1CBNDX=33 WNR PLVL=3] Bluetooth: hci0: command 0xfc00 tx timeout Bluetooth: hci0: Reading QCA version information failed (-110) Also add the missing state machine reset which is needed in case cancellation fails. Fixes: 2aaa43c70778 ("tty: serial: qcom-geni-serial: add support for serial engine DMA") Cc: stable@vger.kernel.org # 6.3 Cc: Bartosz Golaszewski Signed-off-by: Johan Hovold --- drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index b6a8729cee6d..dea688db0d7c 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -787,17 +787,27 @@ static void qcom_geni_serial_start_rx_fifo(struct uart_port *uport) static void qcom_geni_serial_stop_rx_dma(struct uart_port *uport) { struct qcom_geni_serial_port *port = to_dev_port(uport); + bool done; if (!qcom_geni_serial_secondary_active(uport)) return; geni_se_cancel_s_cmd(&port->se); - qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, - S_CMD_CANCEL_EN, true); - - if (qcom_geni_serial_secondary_active(uport)) + done = qcom_geni_serial_poll_bit(uport, SE_DMA_RX_IRQ_STAT, + RX_EOT, true); + if (done) { + writel(RX_EOT | RX_DMA_DONE, + uport->membase + SE_DMA_RX_IRQ_CLR); + } else { qcom_geni_serial_abort_rx(uport); + writel(1, uport->membase + SE_DMA_RX_FSM_RST); + qcom_geni_serial_poll_bit(uport, SE_DMA_RX_IRQ_STAT, + RX_RESET_DONE, true); + writel(RX_RESET_DONE | RX_DMA_DONE, + uport->membase + SE_DMA_RX_IRQ_CLR); + } + if (port->rx_dma_addr) { geni_se_rx_dma_unprep(&port->se, port->rx_dma_addr, DMA_RX_BUF_SIZE); From patchwork Tue Oct 1 12:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817963 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C4751C2DA5; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=q5v2XzSnb/EddxZVgyODXTmdi5i5fhcNEf+UXGV5QUzyaZgaw/D4bCuQsD1z8KY3f4jI4+VoFS7EgM/qVKqSX6z2rK7C97bb8Ci0qeX58kTqYYoW6gIX7Mu/GcJEMaN39pkvvTuhbS42jEzwlaJSL8ILh/+NLBeklgvbOPXE6Jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=n14DOMLu+tTkfzWSwxnagK5nwZFIdud0kYQvc+s8lB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWPlsxscsETbmbhhz36anqyOKl7WeXA4tO4buze4IVmlnpDfHk6YbBmRIMtdWd4c5JrobjtGNl5c7OpWJQFdk1rlYtrBit27v21fTczAo26s6vkpDybc+OMqzbNZXj1P7f+4tKueAwpFHplckhyRDIs6KuW5HP0AIUTDOlPzTyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PldLBLov; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PldLBLov" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9BEDC4AF09; Tue, 1 Oct 2024 12:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=n14DOMLu+tTkfzWSwxnagK5nwZFIdud0kYQvc+s8lB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PldLBLovX7GBq3jtWtaU6FGiLT2Y7EHjBoiqflV2PS7A+Slg9aWx/vLHSAsijLuVP ZN0tOvLV+90AmtaUVSy6BtK48xgm5+h9THowTpJbOGbQHSWTCnHteCPSb/n4ZXlbSS 09w+UD7dAFeEp0qWxnzBnYdvODGeEmBvOwwOdqkow0sJL5QNhr3lxSnqESGxj3wATX uhVVs96kvodNNynt8TZ/g/HxSSxgnUGtl2+6wc6ZGPtPx8FDF+39MpXR5NM7XSALEx slm0Tt4q6t/KqGroHvNOy9yk6eAI165o7fXzSMZoPd5V1TSKp+We3ualJ0xpJ2TqUv f6oTllHogg2Jg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mK-0sJo; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 4/7] serial: qcom-geni: fix receiver enable Date: Tue, 1 Oct 2024 14:50:30 +0200 Message-ID: <20241001125033.10625-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The receiver should be enabled in the startup() callback and there is no need to stop it on every termios update. Since commit 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") the calls to manipulate the secondary interrupts, which were done without holding the port lock, can lead to the receiver being left disabled when set_termios() races with the console code (e.g. when init opens the tty during boot). The calls to stop and start rx in set_termios() can similarly race with DMA completion and, for example, cause the DMA buffer to be unmapped twice or the mapping to be leaked. Fixes: 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") Fixes: 2aaa43c70778 ("tty: serial: qcom-geni-serial: add support for serial engine DMA") Fixes: c4f528795d1a ("tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP") Cc: stable@vger.kernel.org # 6.3 Cc: Bartosz Golaszewski Signed-off-by: Johan Hovold --- drivers/tty/serial/qcom_geni_serial.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index dea688db0d7c..5b6c5388efee 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1179,6 +1179,11 @@ static int qcom_geni_serial_startup(struct uart_port *uport) if (ret) return ret; } + + uart_port_lock_irq(uport); + qcom_geni_serial_start_rx(uport); + uart_port_unlock_irq(uport); + enable_irq(uport->irq); return 0; @@ -1264,7 +1269,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, unsigned int avg_bw_core; unsigned long timeout; - qcom_geni_serial_stop_rx(uport); /* baud rate */ baud = uart_get_baud_rate(uport, termios, old, 300, 4000000); @@ -1280,7 +1284,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, dev_err(port->se.dev, "Couldn't find suitable clock rate for %u\n", baud * sampling_rate); - goto out_restart_rx; + return; } dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n", @@ -1371,8 +1375,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN); writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG); writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG); -out_restart_rx: - qcom_geni_serial_start_rx(uport); } #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE From patchwork Tue Oct 1 12:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817965 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 711A91C32FF; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=lg+z58IY/Q23rItS5c9fB4UU0Of1ErjO08tRGbIKQmJrglAQGbv8z1bSk6sA3rshu17J3WbpiZ8YK1CNsaO4wi63e00ZRh6fAzos1RwlBj/vj3bUSk3KUTkkKXQrJsZh/jW9WOV+OvmM6/6AYu7ZY/OhNEf1wucLMr8esAJgJKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=Kp3teGk4rjGOq/WkTqWVcLgkD5aACFrNaTM4GdXjOIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XPWqSbvRAG98C9hH7llNZN01MML9yCKZw+pgYKVBNh/V1m83rtimD/Jxat1DBAAMWpAjQcEvxiHPmUOZpt8o5xeVv/yxhV24xcPmPm5n4bXwt+JPb3PBOCwF3Qd6ARE1Kh9i+/xlJm8In+N+xblnFAOXeRwJ4mRDbdxGCD/ExJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YVBqjVPJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YVBqjVPJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DAC6C4CEDA; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=Kp3teGk4rjGOq/WkTqWVcLgkD5aACFrNaTM4GdXjOIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YVBqjVPJhpe3uvE0x4f9BZmni1qn4VvRXm7FYMK7T0O5VylDMR1iUF9c+sjcpHsEF kMHP8Yrfa2i8ZERgBzfUzFumZYyCN8lhvNxDjQpRyGzf5sHW6IeUO611N/Wk+bQr9l UFSJCy8uES93mJlJ/5LZcLFzecqBLBHR4IsvMoYyTVC0DCOapSuiunpdvyYcDu8xrx SB5SngYQsfmmRHP3THrzU/7n2w946WV2fMxAJOV19lWiOM9/lzZJdRF3qk4/WLVl9J ZVTNhKh51Dkdg0ZXDcHjTwYftP7PlQfuZxtl/ZRLfBQ5b8CwHFV5o5J7gH5zIYhAr+ LudOLBZ7iKLHA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mN-1G3W; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold Subject: [PATCH v2 5/7] serial: qcom-geni: fix rx cancel dma status bit Date: Tue, 1 Oct 2024 14:50:31 +0200 Message-ID: <20241001125033.10625-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Cancelling an rx command is signalled using bit 14 of the rx DMA status register and not bit 11. This bit is currently unused, but this error becomes apparent, for example, when tracing the status register when closing the port. Fixes: eddac5af0654 ("soc: qcom: Add GENI based QUP Wrapper driver") Signed-off-by: Johan Hovold Reviewed-by: Douglas Anderson --- include/linux/soc/qcom/geni-se.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h index c3bca9c0bf2c..2996a3c28ef3 100644 --- a/include/linux/soc/qcom/geni-se.h +++ b/include/linux/soc/qcom/geni-se.h @@ -258,8 +258,8 @@ struct geni_se { #define RX_DMA_PARITY_ERR BIT(5) #define RX_DMA_BREAK GENMASK(8, 7) #define RX_GENI_GP_IRQ GENMASK(10, 5) -#define RX_GENI_CANCEL_IRQ BIT(11) #define RX_GENI_GP_IRQ_EXT GENMASK(13, 12) +#define RX_GENI_CANCEL_IRQ BIT(14) /* SE_HW_PARAM_0 fields */ #define TX_FIFO_WIDTH_MSK GENMASK(29, 24) From patchwork Tue Oct 1 12:50:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817966 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6866E1C32F7; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=hCO7Y1ogZ3OH/0MOz78STE/rWZFBvsSz0sAHYa4XxhjlkcvFyfBx9fwQaVP++J/EIqV4OimHdN+gEgooP3tBT/V26aXg8IG5dHjftCV3LJwJ0UKGZSxu8Dd8ZuTja7fThOJaCr9c6xOG0fHp7XQ190gx9RrwZnKafVqs3GWjjGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=/3Y1QtQb1qYiCWkwzBK4UiZggYkQeDFvwFs2e86pxBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=heax1woyLAKenvVAX2KdcP8gSzO+WY1U9UoK14FMihM4Soi6FLDD0QuF6AdQeQUiATnSCUSs+iaSTGh4T7izz2rJTUCvUgmezz7LtEJ0VPp2lk+uAFvSnxfT7mO4dLLTBirS6ovYZ9BzzYCfUqD0v+Z0uGbGrQta9UfQoUgmn2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=drdYBiEk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="drdYBiEk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DAA1C4CED7; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=/3Y1QtQb1qYiCWkwzBK4UiZggYkQeDFvwFs2e86pxBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drdYBiEkAI74sbF73h9gFzv8lqUrYS+lyoAXrmj1BU3tTZuZAYvdEXSC0MM9Zbd+7 EbrYcgE3LK9amMdajvAHxx7KYAx45yE2J3mMUhs488TSALG7HzHvtYXaeHzYChLMV/ dWdlKhObrTBgxa3A07byY9xweulQjw75ukl6n6+hVCrXiSDKJzD2gpe7XGwvEmI73B Gk6knV6ePAXmUrB0s7XGHW8lfG1jjiP71d0uwWmlOH7ZdvjAbWCgYNjzDSpmZMCOQ3 sech14LPgQiW56YRbD9kcL5+C469MUxFSAYKvUG57Ba7zesrSEr7hYqmAfuqfkd6FF dZyFJEddOynTQ== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mR-1g44; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold Subject: [PATCH v2 6/7] serial: qcom-geni: drop flip buffer WARN() Date: Tue, 1 Oct 2024 14:50:32 +0200 Message-ID: <20241001125033.10625-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop the unnecessary WARN() in case the TTY buffers are ever full in favour of a rate limited dev_err() which doesn't kill the machine when panic_on_warn is set. Signed-off-by: Johan Hovold Reviewed-by: Douglas Anderson --- drivers/tty/serial/qcom_geni_serial.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 5b6c5388efee..8bc4b240bf59 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -570,9 +570,8 @@ static void handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) ret = tty_insert_flip_string(tport, port->rx_buf, bytes); if (ret != bytes) { - dev_err(uport->dev, "%s:Unable to push data ret %d_bytes %d\n", - __func__, ret, bytes); - WARN_ON_ONCE(1); + dev_err_ratelimited(uport->dev, "failed to push data (%d < %u)\n", + ret, bytes); } uport->icount.rx += ret; tty_flip_buffer_push(tport); From patchwork Tue Oct 1 12:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13817964 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AF751C3317; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; cv=none; b=f8oF8yGgRmOX22FJHBp1T0HN9DcKl3RGeczUMntxOOv1ZSBcw7XeQbJ6wtnzN24vvZZUTWmcmsC9xTTLur/4mvEzSXYxVaaYB75OZHZfVzHp+K3pIN2XwyJjUWJDkzHHzBvRbtPyttthurH2hp3M38OU+w/l81Op83hb3udH4QY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727787071; c=relaxed/simple; bh=8cjBwVE6o2FcnHOa80+/400/+iu70ZSyEBWqXZ6ATdg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RzX5FuI9WF69UVQgtgm+JUKeI2Xx5H6dBz/CEYqK1R/O5sXn37R4JqnI9rSUrEKwre1lhx0tmTTgShrk2IIltPqqo5ivXq+zUlAX55GwrMjd5jAyZPVg0kVwW3z5vbPv/nww5Kxqap1D7Yj9S3OHdlg2BYfIrsBrOGfyW1OgwKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IiFd4R1T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IiFd4R1T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EF09C4CEDB; Tue, 1 Oct 2024 12:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727787071; bh=8cjBwVE6o2FcnHOa80+/400/+iu70ZSyEBWqXZ6ATdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiFd4R1TuTPnAN1+gACi2ZJdi7dWK4LSz+Z9pOo6XX8n8BptvPCsx1qAH3Ap20tVw WmINjEt8hNG/1lE93sC8sNDF7RRFEgKIQxkpvwLKy6DTOV6mntxCMUKw7BWDiuZKz7 fohKmBozc2mKDMpk1R1Qc9/gUXMe1HVY8/v91OenxjRJJTGt84miw6rsrYB0OdcOJo GTbvP4UgYvCzKd9SIj3tDpDhUd0wJL+zL7rGsESDIPYrb0V499LOavAf/2n9WMP6BE v48fBzQAw4Cn/yagdqAzToywuHa7Dweh5OxxAVp8I54SxvbFA9nEza4CETciOD0YZI LGQ7GQ5nyddQA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1svcLP-000000002mU-23Hc; Tue, 01 Oct 2024 14:51:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Bjorn Andersson , Konrad Dybcio , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold Subject: [PATCH v2 7/7] serial: qcom-geni: drop unused receive parameter Date: Tue, 1 Oct 2024 14:50:33 +0200 Message-ID: <20241001125033.10625-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org> References: <20241001125033.10625-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Serial drivers should not be dropping characters themselves, but at least drop the unused 'drop' parameter from the receive handler for now. Signed-off-by: Johan Hovold Reviewed-by: Douglas Anderson --- drivers/tty/serial/qcom_geni_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 8bc4b240bf59..daa852785bd9 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -562,7 +562,7 @@ static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) } #endif /* CONFIG_SERIAL_QCOM_GENI_CONSOLE */ -static void handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) +static void handle_rx_uart(struct uart_port *uport, u32 bytes) { struct qcom_geni_serial_port *port = to_dev_port(uport); struct tty_port *tport = &uport->state->port; @@ -855,7 +855,7 @@ static void qcom_geni_serial_handle_rx_dma(struct uart_port *uport, bool drop) } if (!drop) - handle_rx_uart(uport, rx_in, drop); + handle_rx_uart(uport, rx_in); ret = geni_se_rx_dma_prep(&port->se, port->rx_buf, DMA_RX_BUF_SIZE,