Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1327887lqh; Mon, 6 May 2024 04:40:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIBOZvwSJyXhp6iKgyLbjLMANDXc1mVZFDgoHIeBjDn5o7nTKJoAEcA52KaO50syDXoKqOcEn4CBpDXbO5K+LPJYxC+cmYQSzsNKFaWw== X-Google-Smtp-Source: AGHT+IEb8sSluEKwNA1scCMEvnM9Vk2i8HQCkv6P6lnvxMACuqbh+cDESLFWn4KWaFDhC9doJYhN X-Received: by 2002:a50:aac6:0:b0:56e:2e10:7dad with SMTP id r6-20020a50aac6000000b0056e2e107dadmr7509126edc.35.1714995648662; Mon, 06 May 2024 04:40:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714995647; cv=pass; d=google.com; s=arc-20160816; b=q74B4c/ynEYElx+qPWApZu8uvcACRB6thyT3b9qZnTs4s2fYkRF0eTeu9ZYsSEos7D zt7eXnwLXaAJ1yTOQruDjVjUKeU0bE6jspFAr06KDx9QUBcvrrnvXZfJMtoK/Tkwlw+f QH3velBNjguXfIIMtPML5uIEzEEySr++Ob0PgVL+hPEKzEibPzk+Al2aDXMvt/l3h7GZ tGl09sTFKfTRW/FjeLy9x1NMHeGPRMadYXBKd8ZAbgjLtiC8ItQpFE9tIZySQ6SsedyX 1TM94t/sIVvLtBCd0PZYTek+cp5mAwuQ2Xba7uIY/QOiftlJMigKUJG0yMlzqwxq9+Ef F3Lg== 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=1+/fXyDcdDYBqoMNsLyvP3kBF5cFDb+XEH2MDBafQ6s=; fh=aG7hBLBmw1l015ofgK5wdSVNBW5CuCZaxxDB1+c/8fI=; b=Dufhtm/MZW9fCuXFA2JCPuG9z1rpWrwt0Ki7F0WmdBePtFEG8S9MZMjFN6UDT8PrSz gHnF9pbqVQdhxUe0d2ZjklzJ24HPvdVvSHbZfftRHWX35Pc2Y4GCncVjyVbGlXq6yuBP N9UvlyjfSD54e8bBgsW0ad26Y+yjHy5S5TFLkaaW7KDY5/8JJMbIxXM1zw+oV/slcOJZ T0E0MajgpvrWUAEIsE96lyneYUSYk5EJcP1D66igOidwa9ulsT45EjAiwV75VSiJHAek o13+cYplHyYatcS7UH8P9jY1x6IGVbqUf2vtU+Ak7nX1K4h6aQaFdsirQNSx5p0T6TMH oOhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=A0HdvaR4; 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-169744-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169744-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a10-20020a05640233ca00b005729f67af3fsi4942881edc.190.2024.05.06.04.40.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 04:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169744-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=A0HdvaR4; 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-169744-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169744-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 7BDCA1F22265 for ; Mon, 6 May 2024 11:40:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35470142E9F; Mon, 6 May 2024 11:40:36 +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="A0HdvaR4" 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 26E2114386A for ; Mon, 6 May 2024 11:40:32 +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=1714995635; cv=none; b=Z2++vu8yvubhtqUScx3VxAyHfSI2rfNPvf8mpamKsr+Zbo9gb85TF3VGYo3rIJDEcNU2klbvTTQzV8eNcZk23J3QTztGy4WNJI+iEFN7Co5Bkvc+FGHBDA4m6BSVggU7/rTBpiiAPsy7QPZ+HZnHxg/Y6RHEmRHGMHguitffNFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714995635; c=relaxed/simple; bh=vNn4nBjiHVHd0R6UykwuRVMBMzPNZgmYEEMVlqZiy8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L6Q+LnsPHWZS0alwqfDhco0QiwTj3HVPr25MceqeyKgSs3AWRMhcg61IXxj12wmVvoxa+DS8pYKKUGQmYpZvofiNbUKbHR74Jdhjs1dSbGk3GkzU62n22Z1qcwEKhPK17Kbf0cO1ABvliUnQN3sGddH69W2ZUlKFP57Xn2jRHjk= 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=A0HdvaR4; 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=1+/fXyDcdDYBqoMNsLyvP3kBF5cFDb+XEH2MDBafQ6s=; b=A0Hdva R4Xk+v0Nl+5IlgTd3GeGcGgRYHs9RVfJhjKzzMlm7hxYYsYhG+/FX9ryO3dU6M7z EKfBgP+lXcplr5BLSrmesb7C7AITCWwxe3PSqCZunflx8DhFLg/GLLY0coYuT4gt j7KvKaSTKYyNIrUxsJ9MBe29+sgFv9jD+paTkv14nD9tj5VSjAxhAKVSUkNjOmrR OhmPsUe8GAzKD0KEqzhq2HnLQhR7pUzijWpMl3X0vkTwWcUH7PRo6LCK+DkpUx5A keIlQMscFjFfnshbLNOgPMaCUNCWw2bWGceuE8CFweACgtmdk7y2tbzBR411UiAv f+3oiHXCe4lxbxdQ== Received: (qmail 172868 invoked from network); 6 May 2024 13:40:31 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 May 2024 13:40:31 +0200 X-UD-Smtp-Session: l3s3148p1@gwJgiccXhLYgAwDPX0CuAO+oYiCi4tWm From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 3/4] serial: sh-sci: let timeout timer only run when DMA is scheduled Date: Mon, 6 May 2024 13:40:19 +0200 Message-ID: <20240506114016.30498-9-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240506114016.30498-6-wsa+renesas@sang-engineering.com> References: <20240506114016.30498-6-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 The hrtimer for RXDMA timeout was unconditionally restarted in the RXDMA complete handler ignoring the fact that setting up DMA may fail and PIO is used instead. Explicitly stop the timer when DMA is completed and only restart it when setting up DMA was successful. This makes the intention of the timer much clearer, the driver easier to understand and simplifies assumptions about the timer. The latter avoids race conditions if these assumptions were not met or confused. Signed-off-by: Wolfram Sang --- drivers/tty/serial/sh-sci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 09eb0c824b10..7cc354ee6305 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1325,14 +1325,14 @@ static void sci_dma_rx_complete(void *arg) dev_dbg(port->dev, "%s(%d) active cookie %d\n", __func__, port->line, s->active_rx); + hrtimer_cancel(&s->rx_timer); + uart_port_lock_irqsave(port, &flags); active = sci_dma_rx_find_active(s); if (active >= 0) count = sci_dma_rx_push(s, s->rx_buf[active], s->buf_len_rx); - start_hrtimer_us(&s->rx_timer, s->rx_timeout); - if (count) tty_flip_buffer_push(&port->state->port); @@ -1355,6 +1355,9 @@ static void sci_dma_rx_complete(void *arg) 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); + + start_hrtimer_us(&s->rx_timer, s->rx_timeout); + return; fail: -- 2.43.0