From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1B445176AA1; Thu, 12 Dec 2024 17:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734023047; cv=none; b=k04oO3GFY6Rswjk0a+bVJ0lBUMicvxVbKl/Sg4yBVOUenIUriStgfqrZOGrVBz68F4R4zfDkvc1d71nJs21oKc1lbUExqx+N5vJ1H9YVu2lyn7HIAKS68+7OzF2pSzDPTKdky1PyJfVE9Ms37riso6ZmWX0pJ5lkahiSUlee0LA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734023047; c=relaxed/simple; bh=Pafk+zLs7KxTMR+EVdP9NodIdw4+UkpACOPMjmBnbCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owIpEMKuDGZDJqOFp2ZndO0qtUzUSt1dfYSAPo4+jB9yLtUrD59PsPWijLFvt64jLYNmVIOhKwdMTT9sBj/0pbG+Nly5T4nFsw9w5KEQ7r9GhjMHPOrVSE3KEBsjeTwbeNaXc6oe6DvqZrsQe4D6BiSAfcaI5lNfyxbPDowZa/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AOrx/SJB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AOrx/SJB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85DB6C4CECE; Thu, 12 Dec 2024 17:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734023047; bh=Pafk+zLs7KxTMR+EVdP9NodIdw4+UkpACOPMjmBnbCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AOrx/SJBA/Edm9hgsmIvdk5JzgbG560JNOuJq9GbpI+cSvnU5QpN4iGcVz6wUmp7W ZOkIkCGHWk5InQNLu1sxfsgFnhv2ljlb+AyFL0/d8tUEEL49kzgc/R0sqgpymU03KX E5cqRiefizGcR77T5H1rSBBA6rQ1kmVBZX8GTlXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dario Binacchi , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.15 406/565] can: sun4i_can: sun4i_can_err(): fix {rx,tx}_errors statistics Date: Thu, 12 Dec 2024 16:00:01 +0100 Message-ID: <20241212144327.707856268@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144311.432886635@linuxfoundation.org> References: <20241212144311.432886635@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dario Binacchi [ Upstream commit 595a81988a6fe06eb5849e972c8b9cb21c4e0d54 ] The sun4i_can_err() function only incremented the receive error counter and never the transmit error counter, even if the STA_ERR_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the STA_ERR_DIR flag. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi Link: https://patch.msgid.link/20241122221650.633981-11-dario.binacchi@amarulasolutions.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/sun4i_can.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index aad1882a9be11..3e5aa2e0ea66e 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -563,11 +563,9 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) /* bus error interrupt */ netdev_dbg(dev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; + ecc = readl(priv->base + SUN4I_REG_STA_ADDR); if (likely(skb)) { - ecc = readl(priv->base + SUN4I_REG_STA_ADDR); - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; switch (ecc & SUN4I_STA_MASK_ERR) { @@ -585,9 +583,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) >> 16; break; } - /* error occurred during transmission? */ - if ((ecc & SUN4I_STA_ERR_DIR) == 0) + } + + /* error occurred during transmission? */ + if ((ecc & SUN4I_STA_ERR_DIR) == 0) { + if (likely(skb)) cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; } } if (isrc & SUN4I_INT_ERR_PASSIVE) { -- 2.43.0