From patchwork Fri Nov 22 22:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3654 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7121E3F9F7 for ; Fri, 22 Nov 2024 23:17:07 +0100 (CET) Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53da252c2b7sf2138866e87.1 for ; Fri, 22 Nov 2024 14:17:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313827; cv=pass; d=google.com; s=arc-20240605; b=XF0ppWA67oPOuoMtBipOYfLOFHen01wbfHHxTHziF3qkPbLymC0z3Rr7INWl28ZC1Z jtiM9gcTxKCYlKO7xD1EQZzIfqJZWOv8nYTiwhEQdNTUATws3G5yv/u/1zBfoLA3FkQL cmbJHGEetS5r/U2DUVwbjDXlw3RKyOPONhUXoScZjJDzgpPrt5iCvxLfNofhRSW7L5TH HyJDuiHQZ2x3KMarCV8y/S4hbu9ZMfseivd1e2Ej8cHUEj0G4GpF3uonT9QOKwCSFfnz 0g98ctUvIqQhCcam8z3rbYFLb3TE3IjDT6gEHWDc811dJxjYvrw5JApSfR9dcUrMMgFG EPDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=OaYmgJ3WKoEB+2XGixvs4tgRkztuTXXbrJ2mh4DdRWA=; fh=t9V1IcUjtbCdTb+JQ0gXCZFduNEne6tnEnWao0IOqqc=; b=iMKKyOQ276xnKOUru6lbb5T/w2ERm4kkVS0WEFqca6mJ2y25Zl2re7r46O3f5EhKDu yf0lG8QpsjraSLqdiMkcTA/ialVE8c82lxMHnlukd2ySm2FyxWbc8tb6Pwgfa8w105d4 Ie18xTBgjvFdWhmvh/j+UjfUG32s+by2PzN9NI1XHKDCvPixnB64iEmApHr1fGqIqHSR D/CBbYk2W0qkJw+0c9nbz4CS5X7XQ9bFzsRbwLGzFJJMLgIEJI7tZrSzy+zcCh1CGIdv xk8Pzel/mnw1BQ9ZkmdskkN6IbXjqa2jVsOKV2qLORtlWoBpNSlpAViJ9yyWO2Jl4HWe qveg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MrPnHvSr; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1732313827; x=1732918627; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OaYmgJ3WKoEB+2XGixvs4tgRkztuTXXbrJ2mh4DdRWA=; b=fIJdsvllLVi+ho/pb9YUtdnROL2tlQN6YSHc/9ZFNyhetKzF+Zr5Gl4HVb2bwmYieP JsAt18yFny5PcovPWRvu3inNHXb992H7t8zSiGBr1Rus45OZ630iSN7j27V6XVl7tA2n oqFRJHHBwSzTgQYSkP4NMxmwes7Hv9zT3mmUM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313827; x=1732918627; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OaYmgJ3WKoEB+2XGixvs4tgRkztuTXXbrJ2mh4DdRWA=; b=VhRmmZYa5LwYoJmDoHaqVKyN9Jus1Dvxaxmuf4rlw4c651gY2QJ+uN094C1K26OwQT 60Mh3ErKl0c0RFt6alMQLDp+7R4zv4USY0R+xJLWOaWVU1a2rKWMZxVRIg9lAiha8pZP VTf3fR7dfvDArsI2kTATBlyO7wpGOYy5x3pWpmM5SV6KDBK2Ju+4hP+p1AnROUm/jDwY n8M8DVCJkHZtGPbBAqcM7YOpMLrRr50ERhfe5vjjI+Qe9+zEbL5mk32KdisVet2GPuRU tFG/gzR+4hwHVnaxGaxfI/2/kZp90/80zqpEVKkwIMM4xKcPFiDLpI3yU6yJQWylcbOE tQ2A== X-Forwarded-Encrypted: i=2; AJvYcCXvNXLN+DrxJC5s13iqEMcq3lXKlDr1y3yaQX7LKvgG8shRlGWDnb48cYoRTjOnVneRhWe9vFrYS+I6incQ@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyacliTfcAD6Vw0sE9s1WzgTBIkPefWUXE42wosundXHROsg1vK DTgNp2AfRtDLNRELvSpXKjZlMwR0HlBf/HZJFQxEyIITynCCBrVc7LIKrYzc3bNOSw== X-Google-Smtp-Source: AGHT+IGgQGaegLFbAhsovTrTG5wKigjhmkozvisEtElAduWbj83lOH09/pjSHYvHviBZrztyYNIFJg== X-Received: by 2002:a05:6512:554:b0:53d:d44e:fae4 with SMTP id 2adb3069b0e04-53dd44efb76mr2841754e87.28.1732313826681; Fri, 22 Nov 2024 14:17:06 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:2205:b0:53d:a45f:c0e0 with SMTP id 2adb3069b0e04-53dc629afbbls216290e87.1.-pod-prod-05-eu; Fri, 22 Nov 2024 14:17:05 -0800 (PST) X-Received: by 2002:a05:6512:b97:b0:53d:a2cb:1350 with SMTP id 2adb3069b0e04-53dd369f458mr3917878e87.17.1732313824584; Fri, 22 Nov 2024 14:17:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313824; cv=none; d=google.com; s=arc-20240605; b=HLaJDCTtNK3vXhAtKNXVQvPx2L9ftFio5e3tLxmw7LoYAcl53wdtfVGVFBqn90kmon 3OAH+LyCcjny68bI7W1fatpgzuhnPB0vOip6uFEZEYZCE6COyHYVx4TtN0rKNbPm28Ji ozHIWciAeUQfZ7hpS9ThXH4wazFqUQ3ydasdk+9uSvZDxE9ss/9TXgbx8CRTTNscvH4f d6E2zivKYnTkH0J8Thq9wlKV9QgcrBIWrTUPJQF1h5L50s47m+yrr0ZhurIwdAog4oqv CfIdCyYadxmvUtYrszzBO+lU3NANrJaM3Au62f+GlL8raPMvS03TOXgsVeahBxEhwzs0 p1jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VgKjVRJAevY3wmDGnu8dG/wFQ+or5hcDk8y0qLVlEgA=; fh=Qmq+zOVqrnRSMuDIxLDaPYdjsNS13GWP1/p3iV9tyP4=; b=JcHGbc0EVB6ySzJrHkCbI8AuxYgs+4Ym+QWbLidc7/g8VDNzBasu6WCdA/8hMwCnBY JJtt1hf+eE4wpO2hvczwdDMwLyqye57UMlwzCOSHTdjwj1kQwOu/tuYdQcp/D0wlmBfN B7hHnztHy/1aI87J/i8ztp4zpjqMrbgoqrlNcQ8DT75ts+kA8VHKxL3sLLB04A72ETPk m1TozkltpcGiGQAxbKAygNBV+2EFPPQasV2nRo0TuSfefuVGOXhkoDGGpyfDRyCY5ZFn m77r7OGIroclMuHmGdnN12aY5Z3VwQA5CAVJRAEDoqWeiqnbx15Np1Jy3cWR+roGFwOM bIKg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MrPnHvSr; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 2adb3069b0e04-53dd2446c10sor1064803e87.7.2024.11.22.14.17.04 for (Google Transport Security); Fri, 22 Nov 2024 14:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncuM5UIZR3MwPBDhOjyR/F/ZzRhscgV6Bc6XRd0FK8qx0qjxCHPO7tP0hOFVyol QouGr8qBbr2kYPv597jaNUhUU3GDkc+LTM/HP3wGLuhH1CLJDiNfHYJehCkQbHCRq/dJA8HlHuf J61aiXn/nrCeAcU8gQtRo+fZ5QkZJQ5LTvyUnJUKFyGmFSlDGiZDeSbnUIPo+FHEjuA5vVvFHpw W/R8SMkpv2wXp8GvRxx1ZG58ux14nGqivCwUWedHS1C3CBUF3dHiFu4rIfGOWbL3OIBY26a8pHb C5HHJuqQ3V1rXxuDs4JpRpt9kLUdseGwxoa0ceItHAribwcTPBCQ0TMqLG3oHEbH+K3Zs/f/KtC ldsSQYqbZ4YPxV0+m X-Received: by 2002:a05:6512:b97:b0:53d:a2cb:1350 with SMTP id 2adb3069b0e04-53dd369f458mr3917868e87.17.1732313824154; Fri, 22 Nov 2024 14:17:04 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:03 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Akshay Bhat , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org Subject: [PATCH v2 08/12] can: hi311x: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:49 +0100 Message-ID: <20241122221650.633981-9-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> References: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MrPnHvSr; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The hi3110_can_ist() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/spi/hi311x.c | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index 25d9b32f5701..09ae218315d7 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -696,27 +696,38 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) /* Check for protocol errors */ if (eflag & HI3110_ERR_PROTOCOL_MASK) { skb = alloc_can_err_skb(net, &cf); - if (!skb) - break; + if (skb) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; priv->can.can_stats.bus_error++; - priv->net->stats.rx_errors++; - if (eflag & HI3110_ERR_BITERR) - cf->data[2] |= CAN_ERR_PROT_BIT; - else if (eflag & HI3110_ERR_FRMERR) - cf->data[2] |= CAN_ERR_PROT_FORM; - else if (eflag & HI3110_ERR_STUFERR) - cf->data[2] |= CAN_ERR_PROT_STUFF; - else if (eflag & HI3110_ERR_CRCERR) - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; - else if (eflag & HI3110_ERR_ACKERR) - cf->data[3] |= CAN_ERR_PROT_LOC_ACK; - - cf->data[6] = hi3110_read(spi, HI3110_READ_TEC); - cf->data[7] = hi3110_read(spi, HI3110_READ_REC); + if (eflag & HI3110_ERR_BITERR) { + priv->net->stats.tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_BIT; + } else if (eflag & HI3110_ERR_FRMERR) { + priv->net->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_FORM; + } else if (eflag & HI3110_ERR_STUFERR) { + priv->net->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_STUFF; + } else if (eflag & HI3110_ERR_CRCERR) { + priv->net->stats.rx_errors++; + if (skb) + cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; + } else if (eflag & HI3110_ERR_ACKERR) { + priv->net->stats.tx_errors++; + if (skb) + cf->data[3] |= CAN_ERR_PROT_LOC_ACK; + } + netdev_dbg(priv->net, "Bus Error\n"); - netif_rx(skb); + if (skb) { + cf->data[6] = hi3110_read(spi, HI3110_READ_TEC); + cf->data[7] = hi3110_read(spi, HI3110_READ_REC); + netif_rx(skb); + } } }