Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2028170lqp; Tue, 16 Apr 2024 05:36:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5OTqaSDp8bcXv4HLki16K/pZ1ynleTc00iI99j/9GzNw8WPAv3Cwp8SBstR6d5XWjf41AIKdT+TVZ/F410O7L+WL+ecQMXKKqwSn8jQ== X-Google-Smtp-Source: AGHT+IFMfbcbNG9V30iJ/QjOrpx0O5jP5vgHilDoERSBuQEQLIJ2lVKFegUHlsQfXcU4S9pOMcB6 X-Received: by 2002:a50:9e4e:0:b0:56e:2d93:3f84 with SMTP id z72-20020a509e4e000000b0056e2d933f84mr8531922ede.4.1713270997322; Tue, 16 Apr 2024 05:36:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713270997; cv=pass; d=google.com; s=arc-20160816; b=s67vlRez4pSxrhUz5kZuwa7HyPf7bIQroAJoUiwReivdbh6aZ6SsNVR5rHQeQO8qoG n9UfqK3QHbRRFT5F5khihkq8S5zibnEZVmQmSyl0ftdyFY7TcSj3rDHMgHQUKdW2mwmn 9CA2hTAn6lra00zct5dCBcrmTuAe4L/6cN9HSZEyw7WRw7gxWQ0eSgi1Y/2EP7/W/nvP qixcxhFEocpSxuoPBjwjhprLtjDiFDb9Q8ancFaeM/vQJEGoPf6C2VbU8W5hmui9rMW/ 0YS+l+wiBZC4bl6IpHK7xBTg2bWaiQ2CZ1cYA/DA8g+tN3c57D3W6EwK/BkGAvjX3ehZ JrLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rK8csEqpyjcNZo4plK8L+bE/v5scXoLguzVWeStfOtQ=; fh=/TikYQmIzGHE9y/ETkZImLKfpgqQ0toAt3VE0EM75Mk=; b=DuET8oE51NULSOI7aRYOvwo8gKblZbufQiyzjnM2F6bSG65+1VexNhIYl1S0ISBgMy hb40IsDYjh/ACu/yYn4k5mylo5g6EeFnzE29aVCLL5j+S/BQz8qnoF+YGCRTSnTqBp+O ATEcLpvsbxoUioLAIsEKho3ugdaJSy3UetoQq6Hjz7xcWcHWC08dlETa+aackUxnbLvQ mZ1O58Av9zhwkQJAeTxyTdks+O5YjkImK0Q3Ee0ZF8VpcGPt5fbciz9jIkdHJHMBZOTq a4/omR5X4tHle0yz07IA9hUpP9aBr7YVjSU5E52Tk41w/nTuHCWuoVLnKy4JspDmnR3y p3EA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=ICedfnS+; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-146800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146800-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r27-20020a50aadb000000b005701ea6f2d7si2871509edc.131.2024.04.16.05.36.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 05:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=ICedfnS+; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-146800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146800-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 10B471F20F04 for ; Tue, 16 Apr 2024 12:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B58612BE90; Tue, 16 Apr 2024 12:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="ICedfnS+" 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 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: 8bit 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.bosch.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_port *s) { unsigned int i; + hrtimer_cancel(&s->rx_timer); s->chan_rx = NULL; for (i = 0; i < ARRAY_SIZE(s->cookie_rx); i++) s->cookie_rx[i] = -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); -#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); -- 2.43.0