From nobody Tue Feb 10 00:22:03 2026 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (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 8977C12BE89 for ; Tue, 16 Apr 2024 12:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713270956; cv=none; b=lJRprB5Rormdzg5dExgUba0jjG9OKhsnZ81ECWktFuPVZwYgDHzg/+zOWbGimemTOJ81N/HnpsftD7HUj1pke2RrnFR1QnEBv6YWdEljkBR8YuUK8N0PPtREE733ghp0eRvNXye1AbxmtyIwEG6xitvF3kzbq4/bxFCHUYnJx0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713270956; c=relaxed/simple; bh=Y0tLSlgC1RFiT3mPqR8mah4c1H2bj6CTLAIREfC/r58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I9kG5n/rtvqqBj5OsuhQmcC3AYiEtZyov0xVgzUGT37I4iT5gNThZZZhWyNB3v6QT8RJcFk55t6HiV2VK/8xPiQ3GCQkRExJVTN1CaVSbLO48/7yFTkGxtSb18PyY3S5NMWXb601aMTJx2M1nrmy5wzhRPfEs1v8UN7YZ3eF1+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=FhhpJA0y; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="FhhpJA0y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=Lp5vlYVFCcetgnIn4HW8dGgnYXxUPUENhUOs0STSU6g=; b=FhhpJA 0ylNFUBo2tliReQZEop/eRBFqhFIeJRPi2jN++Eh6xStzIsu9mE6VwK7N8eR3+i6 0xPx0LwD2RwD3EgYxPCgfszwXfrkJe30YTaRWrjiaZ+wcA3K6Pwh0NwWLaE5ZGIw o3aFRT1sqMZxVbjexi593g5JwDPb2YgqREqjtELJQgIxl174jr/Z3YGZc5+oyN3I lMsj4DBQoSjcNChpF/5cTkmwTcKZK+ycWT+ETw8ka2rM94PFFLbd4GVF8ZC8AwWi mELKb+r5Y2HH5y5RIMaeA+0wsrpzKshNwFoEl8OyeIeHXyyIRZ7QruL6ehNoXjr+ A4todJ6ukmmTb1Tg== Received: (qmail 2408475 invoked from network); 16 Apr 2024 14:35:52 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Apr 2024 14:35:52 +0200 X-UD-Smtp-Session: l3s3148p1@zQCB+jUW6psgAwDPXxiyACzheF6dGXh7 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Dirk Behme , Greg Kroah-Hartman , Jiri Slaby , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH 1/2] serial: sh-sci: start hrtimer after setting up DMA Date: Tue, 16 Apr 2024 14:35:47 +0200 Message-ID: <20240416123545.7098-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416123545.7098-4-wsa+renesas@sang-engineering.com> References: <20240416123545.7098-4-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the RX DMA completion handler, the hrtimer was restarted before DMA was set up. If DMA failed, for some reason, it would clean up and the hrtimer would run into a NULL-pointer. Restart the timer after DMA was successfully set up. Reported-by: Dirk Behme Closes: https://lore.kernel.org/r/ee6c9e16-9f29-450e-81da-4a8dceaa8fc7@de.b= osch.com Fixes: 67f462b069e9 ("serial: sh-sci: Get rid of the workqueue to handle re= ceive DMA requests") Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/tty/serial/sh-sci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e512eaa57ed5..1e3c26c11c49 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1325,8 +1325,6 @@ static void sci_dma_rx_complete(void *arg) if (active >=3D 0) count =3D sci_dma_rx_push(s, s->rx_buf[active], s->buf_len_rx); =20 - start_hrtimer_us(&s->rx_timer, s->rx_timeout); - if (count) tty_flip_buffer_push(&port->state->port); =20 @@ -1346,6 +1344,8 @@ static void sci_dma_rx_complete(void *arg) =20 dma_async_issue_pending(chan); =20 + start_hrtimer_us(&s->rx_timer, s->rx_timeout); + uart_port_unlock_irqrestore(port, flags); dev_dbg(port->dev, "%s: cookie %d #%d, new active cookie %d\n", __func__, s->cookie_rx[active], active, s->active_rx); --=20 2.43.0 From nobody Tue Feb 10 00:22:03 2026 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (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 4442D101D4 for ; Tue, 16 Apr 2024 12:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713270957; cv=none; b=fqJ7B4vWT33DSUR9TOT5teacX/U9fVfvzEQmkV0xCYYE2WKHnSF82slv8+sD670DTHGlKw7wSnxyjip40baEQb/jzvY/xEKEqEt0P9vOYvEQX5bdQZIhYgoreus5smEDK8MmMqiR5mU2UA2rfXziGqq2IRuaoy7VSWaTzvvE4+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713270957; c=relaxed/simple; bh=kRk3QnAZ3qr1PcFUmSrslq3HTppGMx2/2WOyXWDOFfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rE9IZAC1lGKnW6upqdx4RCo1dX0FQkqooojSaXDUTbzi0PWMul+wFGjfJFiQvDIql8T9LVqbnXaiVo3EcUpna0ggM5sJ1cVzEnmke3dnhSQR+jPdDLJj/STMuIN3NiEh3VkNx7aSczUuU4xuoGDILlIlPk5wPyiuqO9cJpiZ268= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=ICedfnS+; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="ICedfnS+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=rK8csEqpyjcNZo4plK8L+bE/v5scXoLguzVWeStfOtQ=; b=ICedfn S+Hq8mdLli3RH2Ar+6cfnLlqR62/BKNyOQQhwLDCNXm8LgM/lMJ8e+kSrqceYg5m wHZWDf3zqOAmXTbvo4zzS9Hjr/WF/G1QxgDD5j1lff9QqSgPKdRDdnYig12OiiYM k/lbxgmWbTdMcI0W/nOoXxuMfAaG0QnIAjvkqYz6UWepdQijbbDEIcsQjXK3DoZk le7OECG5gb+gwPZ4Dm36dvVxss8kAouoM6BffztLAIhJpiA58RS50TRu6exjSbTh zZHg2CPyMfBzU/IeMCVyCjzeuU8mUbVa4oVAz67mvp6wFgjFJqmtGpOVT2UBH3s+ mk1PvTIskR0clTKA== Received: (qmail 2408539 invoked from network); 16 Apr 2024 14:35:53 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Apr 2024 14:35:53 +0200 X-UD-Smtp-Session: l3s3148p1@otaM+jUW7psgAwDPXxiyACzheF6dGXh7 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Dirk Behme , Greg Kroah-Hartman , Jiri Slaby , Geert Uytterhoeven , Aleksandar Mitev , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH 2/2] serial: sh-sci: always cancel hrtimer when DMA RX is invalidated Date: Tue, 16 Apr 2024 14:35:48 +0200 Message-ID: <20240416123545.7098-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416123545.7098-4-wsa+renesas@sang-engineering.com> References: <20240416123545.7098-4-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clear the timer whenever 'chan_rx' is cleared to avoid an OOPS. Currently, the driver only runs the timer when 'chan_rx' is set before. However, it is good defensive programming to make sure the hrtimer is always stopped before clearing the 'chan_rx' pointer. Reported-by: Dirk Behme Closes: https://lore.kernel.org/r/ee6c9e16-9f29-450e-81da-4a8dceaa8fc7@de.b= osch.com Fixes: 9ab765566086 ("serial: sh-sci: Remove timer on shutdown of port") Signed-off-by: Wolfram Sang --- Locking needs to be double-checked here. This patch is mainly calling for opinions. drivers/tty/serial/sh-sci.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 1e3c26c11c49..5ad73933c1c5 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1262,6 +1262,7 @@ static void sci_dma_rx_chan_invalidate(struct sci_por= t *s) { unsigned int i; =20 + hrtimer_cancel(&s->rx_timer); s->chan_rx =3D NULL; for (i =3D 0; i < ARRAY_SIZE(s->cookie_rx); i++) s->cookie_rx[i] =3D -EINVAL; @@ -2242,14 +2243,6 @@ static void sci_shutdown(struct uart_port *port) scr & (SCSCR_CKE1 | SCSCR_CKE0 | s->hscif_tot)); uart_port_unlock_irqrestore(port, flags); =20 -#ifdef CONFIG_SERIAL_SH_SCI_DMA - if (s->chan_rx_saved) { - dev_dbg(port->dev, "%s(%d) deleting rx_timer\n", __func__, - port->line); - hrtimer_cancel(&s->rx_timer); - } -#endif - if (s->rx_trigger > 1 && s->rx_fifo_timeout > 0) del_timer_sync(&s->rx_fifo_timer); sci_free_irq(s); --=20 2.43.0