Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1110165lqd; Thu, 25 Apr 2024 06:26:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURiPtL4N0iEpddTrARnfXXLpIW0QJI4/aD9RWSYr7DctPW7QcxxnmErj91SShLs2mfAusI1g34gJs4xUDdfMCGKAlfCi69v7QKTPMx7g== X-Google-Smtp-Source: AGHT+IEKjxBjY+6DFP2xjsRv5/mitGuqdwKlSUZCaO8KhqXG7VLyZnYCXgbwmPbPoqeoszQDJYlA X-Received: by 2002:a17:902:c402:b0:1ea:9596:91fc with SMTP id k2-20020a170902c40200b001ea959691fcmr4709707plk.0.1714051579417; Thu, 25 Apr 2024 06:26:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714051579; cv=pass; d=google.com; s=arc-20160816; b=c9qx9xiP5bPc7eyBumBdG3HKmpwetOU9yk7KGcK2GI/23zwzWJk0bpsDatIeMcLuuO 2yN9voAFn/YhjG4DF/JoIL/r3+HHbkni706BNzSN5luQvIsI8eEsudgajSEE6HhxFC5N jO1Npd1Sj+mfcDIf2q/WUHkjTen6OxUYgvzIYhYIhb2ubM6iPjggaACf7OR0mpdus3vx 72MP4OPkWN8FJCT3L0ZIcfqzz+0fHZxq3D0NdpsLkvdCZyRPHjwhptylLXYS7YX6eIM4 dG2tqdO2d5n6CAzyTLv0oFF97ORFfO4a5F+EgyOhnrbRNqBv15EUCllmuEnMQnknEQyg EFGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=mjjqNnQB3Y3PmO3eF7RCQ6exiD5LgwcG2Ut4A6E+9WE=; fh=tNGY8tnJkyz75pEsNBXaX6MMTBRLNrmb1aDpN/gE4/0=; b=Atri15GVrhyR5MFneGny1EoNUqa1KwCsDGtrmasaeY8xrK/nozqvyIaw1+Wf6Qucqi mfU6XY2dVCgTkwf8iE1samP4FRrImC6w8BJ7fKhc4q/XJ6O0zAb7GRqpLYjPr7ACrkTg t3u5h9DFB5S8Jz+6ybW/WaLAqo3T60kadh4NDFZGNS9HHyNOhjvR5HFiUgFWDQzpRQiM j2ZMbiKx0ShFTdxuFyMC/liB12J0SdBYY9Gahu3lXsE3CFr8MPGwAusszfyuwx06WZP2 LJonfxqqM5diIT/t3atOcerB9cvjOga4e4uvhwJk4JJT/QxADH06sjBOEV61oSN/n5eA wERg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@dolcini.it header.s=default header.b=0GZa0gQU; arc=pass (i=1 spf=pass spfdomain=dolcini.it dkim=pass dkdomain=dolcini.it dmarc=pass fromdomain=dolcini.it); spf=pass (google.com: domain of linux-kernel+bounces-158573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dolcini.it Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t14-20020a170902e84e00b001e77286f275si13850721plg.116.2024.04.25.06.26.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:26:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@dolcini.it header.s=default header.b=0GZa0gQU; arc=pass (i=1 spf=pass spfdomain=dolcini.it dkim=pass dkdomain=dolcini.it dmarc=pass fromdomain=dolcini.it); spf=pass (google.com: domain of linux-kernel+bounces-158573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dolcini.it 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7EDA1B24FC3 for ; Thu, 25 Apr 2024 13:12:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1272149C6D; Thu, 25 Apr 2024 13:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b="0GZa0gQU" Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A5A5139D16; Thu, 25 Apr 2024 13:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.194.8.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714050765; cv=none; b=nmqesciStK3SQKJ4Sq28OqGkqMgRMry4I8bGEliFNk/v3665k/o3veeDn5+P/+nFgMbYHGzWidL+l6X+dZuaSg3daw9w5PIJRIBYjVswWySFNPuis3xPpk5O9zUSXqx+AWPIOtI9hEhaBqkDlI1g6woEmWzREcAGwsfuMS7FzJM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714050765; c=relaxed/simple; bh=SWbsN8gb0T+55zIEnnjHmugKc2Hefu/p5fPeAaJnVvQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=pOtXfDMnazh8+9QyrCn8gLWVSxfQQ7Y2tyhD3whZP1KvwKJdNN/XRrr2sm7kHBhi8ZqEcTmqgADFGME0dYQH9hrYbvvZJJ+VvpbrPLsgf3fKF0Eq04ng3TEJWAmlZpx2JvMfjz1LLgmhiW0/LXvl/uJFbOXvaFy6l8LzMDm2WKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it; spf=pass smtp.mailfrom=dolcini.it; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b=0GZa0gQU; arc=none smtp.client-ip=217.194.8.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Received: from francesco-nb (31-10-206-125.static.upc.ch [31.10.206.125]) by mail11.truemail.it (Postfix) with ESMTPA id 569331F9E9; Thu, 25 Apr 2024 15:12:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1714050754; bh=mjjqNnQB3Y3PmO3eF7RCQ6exiD5LgwcG2Ut4A6E+9WE=; h=From:To:Subject; b=0GZa0gQUG+IjBubLquW3DLf34IruRGf2YYuTX+SKmE8vh0fYBcnrocw6OSc5Sgj1+ cTtKdsqUymXImgTdD4XxFy/ZmzGypggh0t9/bOYSqAdamNlntUSwPqvBnI2ZR/+SEc PYJsRN6kuiCiPRfkD3Sr4uTkV3/IkzkWuuqT6Yy+IGiqrqmeKsy68rjY05WvBze+a1 jX5Az0VNqfOXfHjj6AxQ+CKgxxtiU9fFRfBMjynmyI9X7WgeDT5TS+X5GaKS0PKf1q HXImYdeUeA3SKvuigNSUP6Y8ju+1ABoPe040XE75ZqFlNWYJM9MrDXSub6Uij1mJpi h9txzP/TXhung== Date: Thu, 25 Apr 2024 15:12:28 +0200 From: Francesco Dolcini To: mkl@pengutronix.de Cc: Vitor Soares , Manivannan Sadhasivam , Thomas Kopp , Wolfgang Grandegger , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vitor Soares , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] can: mcp251xfd: fix infinite loop when xmit fails Message-ID: <20240425131228.GA15857@francesco-nb> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240311121143.306403-1-ivitro@gmail.com> Hello Mark, On Mon, Mar 11, 2024 at 12:11:43PM +0000, Vitor Soares wrote: > From: Vitor Soares > > When the mcp251xfd_start_xmit() function fails, the driver stops > processing messages, and the interrupt routine does not return, > running indefinitely even after killing the running application. > > Error messages: > [ 441.298819] mcp251xfd spi2.0 can0: ERROR in mcp251xfd_start_xmit: -16 > [ 441.306498] mcp251xfd spi2.0 can0: Transmit Event FIFO buffer not empty. (seq=0x000017c7, tef_tail=0x000017cf, tef_head=0x000017d0, tx_head=0x000017d3). > ... and repeat forever. > > The issue can be triggered when multiple devices share the same > SPI interface. And there is concurrent access to the bus. > > The problem occurs because tx_ring->head increments even if > mcp251xfd_start_xmit() fails. Consequently, the driver skips one > TX package while still expecting a response in > mcp251xfd_handle_tefif_one(). > > This patch resolves the issue by decreasing tx_ring->head if > mcp251xfd_start_xmit() fails. With the fix, if we trigger the issue and > the err = -EBUSY, the driver returns NETDEV_TX_BUSY. The network stack > retries to transmit the message. > Otherwise, it prints an error and discards the message. > > Fixes: 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN") > Cc: stable@vger.kernel.org > Signed-off-by: Vitor Soares Any other feedback on this? Just reaching out to be that this does not fall through the cracks. Francesco