Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1327918lqh; Mon, 6 May 2024 04:40:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3gfk5pDxfLNf3ks13xDkO3/Y0Dm8o2nzaKwDVcVF8hW2e9TxFYYXWIlTE7xOwZ3WEAnCRu2rb2LSSaBEFlGUPL9X2cWXMTPT8zJt+yw== X-Google-Smtp-Source: AGHT+IFayNs1D3wx6KYLBJUPEXiyYx4ZyrMMXjk5JaNd7Ns2oqsRKiJI79lolMIlDXSksm7sJCjG X-Received: by 2002:a05:6a20:320d:b0:1af:66e6:b1b2 with SMTP id hl13-20020a056a20320d00b001af66e6b1b2mr8059820pzc.1.1714995651208; Mon, 06 May 2024 04:40:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714995651; cv=pass; d=google.com; s=arc-20160816; b=mGPCnwzvNjeQ8VnNzWlZnTR3Qwo3xvNt2F45ZHTFxYtj2EIxcuzp/ioKhNrlKzrCOL Pg49eOGr5L+1MfkILWHLYN9C1yjdYaP+22KSAIfwtls2nj6Apu5EzMDKRGxtfA1dgi2T sxBolp4g4YdhAwgLQhIqI05aSqSj5VFmCZNEL2H/liHeyp1wJOGoivQNMCCtN6R+gmyV 4v7+z0n9eWSMgWpCmu+GxFa6tW/jttDSxNWdefWaQs0TMKcPDutL7Jw0HkSJGtEpJxcm 2gAJb/TzS+JWIJpJvp8otm85Tt/o6TVfuuvnvh+1GYB4TRsAJm2xpvUT9WK2pEodEgbZ dS2A== 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=5vvEQdonqhAK3cFmNNinstUg5N1d+o2KAqgFo4CNsT8=; fh=s/g3bJQTODSf0YLOguVZN4k/u/Uwr7PPM1PidXVqe9c=; b=fX1sRm37RudgJ7MTBH+eWW5gE9yuVjl3Y4qc/CIY68AAWWR4WZmxwpf2yz/7PzmlDg 4ZNgyToe3HEUHAYCAtOD2yXrN+sUCwYCzXu3CbwcApMwF9mn6qGI1aR1yYpq7rPfMvlR 9qHbCjWIukSr3x+VCO4+cpp9M8b7m/pPAED/26/P34TzNaYejZ3jSRPAUR+Ew6EylqwI +FRcUZvdBbXdUDcFiFONVPAVg8EibLb5KUGNvUFvqI/U2xfRxpnp1vLkbzo+gEnc5oM9 Kmy+s9szC8rYLbC0HcSRd7MsENjl9JZL4nQhsuGlcXyLCaCJMaDld3e/V0rj+I6L6RIK bRbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=iY0ptTyW; 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-169745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169745-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q6-20020a056a00084600b006f46695f7cfsi3771394pfk.374.2024.05.06.04.40.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 04:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=iY0ptTyW; 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-169745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169745-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CA0922830D7 for ; Mon, 6 May 2024 11:40:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69D66143898; 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="iY0ptTyW" 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 8C6FD143744 for ; Mon, 6 May 2024 11:40:31 +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=ZW3ttC1txeCnuBtqFqMv2GmvxRGwVxr+vtpjkN4H9G2h3yr/Z1ZIXtR2JNOD0pI+TBpR/KK5zvhMOnkqS76b6AgH9J9vrELbGQvHpKVMx3/OXiMIKRSMC4jwEtfExws7r55AFk9OeN+lBGZDwJlocAmjFhSfqgqN4Yoe/18sr60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714995635; c=relaxed/simple; bh=6Rq27B0cqBXcEXe4wotRdlbpgW3xqppwXIUuno2GF70=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AB2MpAcTac5/F6NT+65wzaikZwuLO8CzFQOAF4KaCPi8u5bPYFrSin7DwFSUPhB7WsXGXafJSRT2mCiNGjtd66wJc1roXjysWSrbC5T3PCpUMN2VNkauePeRozkDj6LkRGWUCNWreL9Gq80oT8Vc3yOXPceDXs0o07zajC42xZE= 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=iY0ptTyW; 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=5vvEQdonqhAK3cFmNNinstUg5N1d+o2KAqgFo4CNsT8=; b=iY0ptT yWieqlnTPSFtINnk8wFFdkihnqfoHOqfA8AmLedpL/47H61OJOLQOT2guswEH64X H+J9zmifOQjXY81taDQgjxsGQBHtmz/W/Bnn20O8+fmb7RWzd6M5k8wbJHfEEABX yy2YQzr0/XO5POPM13hXIYOHu7dWwWDe21ssNxE1UK0GLcZt2Z2XkESp9ahNkNgr rm4ZIZ4Hkftq15/MX38BbQUpeuqvBFLb+H4gdnyVdZiLOnxp+BZm/zHriUY9WIG1 LsqbMBYkvTaFqmNGMFCypPuryp5b03xmMb4vT2F0fqA92QI6+3NP9RWs0dDSYxVY dcFgV3u3iPx5w0fA== Received: (qmail 172779 invoked from network); 6 May 2024 13:40:29 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 May 2024 13:40:29 +0200 X-UD-Smtp-Session: l3s3148p1@tvNGiccXbrYgAwDPX0CuAO+oYiCi4tWm 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: [PATCH 1/4] serial: sh-sci: protect invalidating RXDMA on shutdown Date: Mon, 6 May 2024 13:40:17 +0200 Message-ID: <20240506114016.30498-7-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 to-be-fixed commit removed locking when invalidating the DMA RX descriptors on shutdown. It overlooked that there is still a rx_timer running which may still access the protected data. So, re-add the locking. Reported-by: Dirk Behme Closes: https://lore.kernel.org/r/ee6c9e16-9f29-450e-81da-4a8dceaa8fc7@de.bosch.com Fixes: 2c4ee23530ff ("serial: sh-sci: Postpone DMA release when falling back to PIO") Signed-off-by: Wolfram Sang --- drivers/tty/serial/sh-sci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e512eaa57ed5..a6f3517dce74 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1271,9 +1271,14 @@ static void sci_dma_rx_chan_invalidate(struct sci_port *s) static void sci_dma_rx_release(struct sci_port *s) { struct dma_chan *chan = s->chan_rx_saved; + struct uart_port *port = &s->port; + unsigned long flags; + uart_port_lock_irqsave(port, &flags); s->chan_rx_saved = NULL; sci_dma_rx_chan_invalidate(s); + uart_port_unlock_irqrestore(port, flags); + dmaengine_terminate_sync(chan); dma_free_coherent(chan->device->dev, s->buf_len_rx * 2, s->rx_buf[0], sg_dma_address(&s->sg_rx[0])); -- 2.43.0