From patchwork Fri Nov 22 22:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3647 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 85E0941386 for ; Fri, 22 Nov 2024 23:16:58 +0100 (CET) Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53da36a1447sf1846270e87.1 for ; Fri, 22 Nov 2024 14:16:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313818; cv=pass; d=google.com; s=arc-20240605; b=PJUukqm2jGzUyHJTe7ZqPYqlKZpuix9g/DlVqJwAEVuyJfkk06ACbSGK3SLuwLMXpw jYBw4b6OqLkkt3U4u5n+QsVe3hqX8sHVamVVNsxrFrvcQaUEwqQsSpVMWiI4NaI6Lg0A 4w6e+m8OTeNevkvUcfKWuWzOBQa4VCl92Pan3Qs2FzIh/1PKa2/+L5yLEYQfwPkzrhUC AVeEEdy6W3HRzU3JFpZEfzmyg2Y/A7R1cMGQRdoF6OQMxg8SGwdLQy1N7DZPIYI91L7P sfW/JrGnaSN8hfQnYV54H8Pb7g+yN55WLNYSPXocq93KxULv5l/F/OYyCoeddMoj29Ta /qCA== 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=BuIhDtH2J2ogmaY60Y+MZlqQh1fDcFk9fy4QE0p046g=; fh=cyAFoQCzV8uJYWeENtGtyAM8i0h5O6f/UI4CEy/xL5g=; b=Sj9toEJfoqRNeSPGbpP5CJGsQBHTljgZRBxrqLPtnp7ronRj4KLuK9YM22tKGcP2yt ezCq2SHPQcJp0SMnAfEEt5oRA3HDVmomgwtRNeTXaC19ji01e1UwEfvXk6ZVXORT0dTq F7ywP2UJc/zqFk1/GCVI2fGLsRm7yV5tX2/0NA6eM/jqpcuFsZfn+wYqz0A1qQRfKB1F 65iTl148ju8x1WDfi6YyIplp2MNR1lRlF9fkZbBGdvD0n9Mc8H3xRYxjDf/BSjiuTyTK ueJYLN2WWNBvz8yIB0P3qzFMfJi33fxYedK02qlhZsb7488MhPN8A8ZGJQFWdthbPrzF szUQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SsMKbMay; 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=1732313818; x=1732918618; 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=BuIhDtH2J2ogmaY60Y+MZlqQh1fDcFk9fy4QE0p046g=; b=myxTz0ATm8dr4rC8aTUuUPgdhHwCOS3KlhuRB1S12joPTV4SlaiplqvFW0q5cvSe+J gjKadHGKGW5sVNGbgN2p3TIYSFYQhHHgXJ24DojR8cGXkkIpWIXDZmm9rH3nIwLE8SxQ fYxgA4FKqbvNXLwHRJSf4aLh9wAOTZXR+oRL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313818; x=1732918618; 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=BuIhDtH2J2ogmaY60Y+MZlqQh1fDcFk9fy4QE0p046g=; b=G//x1BtZfjsX/3dV2kiMiESa18Q7+b3olkzG+JWwhrdEMUdfrFkot3KmeXip31vSGe uXwqHLZ83aqjbRgi7EgntjnMSRMy6wLeq9Na1j1UEs/GIMoiMsJ3ltGdfkcPeDHsYiRm HExB1bKNWmJ7xY89IFKE/2BvgwO7yUPoITDorJ0O25QT9HJEODCeIYhkyauCWMvJYv2o VippH9++Ir+Zjn9DGLTL1XQ9ig7QQf0RVHZ9IdCA8wMuilxeA8JApdy6QdWTiUhxTqcR VMzPGNFhZf1+EPHFkDQoZ6wQnRWP5jSOFJlLSNmGbwMUPZ4b9hjz0dwMNLzkEgZOM4Es AK1g== X-Forwarded-Encrypted: i=2; AJvYcCX6u9WhQU2C6j7ZLA0wmHQ5MifKx25YEgorI/E8QJErGdg46CTmuCJRhdPKIupThWr3eKm2Iif9Hgp9lkqM@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yw9lf+ahAEjRTj8oMpfdZ8zyC9z6J8L/syEn1McwEZJXBUPj3wk tZfrjzbQc16wX+Ih7rpQJTHtFEETSVX5YB7WRnL+PqBQCZP2L4nCkl0wxynQfwQBE7R0KmGHuA= = X-Google-Smtp-Source: AGHT+IH5hgdainBN++2S/kjWZRyVfJlLraJxgcMQkkgrc2OxtzGYlxGY65KsssMKfc+xRauQMmvHRA== X-Received: by 2002:a05:6512:3a8d:b0:53d:dbe8:af18 with SMTP id 2adb3069b0e04-53ddbe8af6bmr160897e87.44.1732313817915; Fri, 22 Nov 2024 14:16:57 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:3d89:b0:53a:7e:bcd3 with SMTP id 2adb3069b0e04-53dc6296ca0ls353974e87.1.-pod-prod-06-eu; Fri, 22 Nov 2024 14:16:56 -0800 (PST) X-Received: by 2002:a05:6512:3c89:b0:53d:d57a:1126 with SMTP id 2adb3069b0e04-53dd57a114emr2517536e87.7.1732313815880; Fri, 22 Nov 2024 14:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313815; cv=none; d=google.com; s=arc-20240605; b=JZFrorfwly5n2jSKfZlEadQ6U048YLgqy39onAhXIslSh3GlUlb1dQSbYLn248oFQw gUFvy2VjvrPlmjsspCD1zDPMgX9OjGwvRWCVb+XLwcMaSMnsNuSzojDWNcRwYfMsX7/N DDKcXbdpG6McXnIP/4sI5yuKd4m6Yfjd1kh9x+k9zwijc2Lvhss0jw1yS57/2Jyp4ysx hbt+WrGMdnPEpFFEFSd1b8Lr8aV10ovOGs0cvv0ECAELv9MsaGn5LcNsRiEVW202/Gfh NorfskxgBuDxrDKOKHQT9TCF70zXSXXnMAIQKEWzFTqRzHTYr0sHKqz0iQFJVu1o1Hnz 2CUQ== 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=eXl+FSVARqVcRtIxq69Tn4oF98SIhVQqmrh7i+R1ZlE=; fh=ljoFiwPup6gC9YG4NMWOEWNdgUd1CKjWIIwpUvYy39c=; b=UuvJoXTHxEiUpMrvmbaMkGrgnTHZ9gtpAl2u+j9T45/D2hnuB33MeJRuL+YtyTwwmO jJf5Kss8P3b7FJEdFCaseDRPzSvtvZizO/dhR8wQNWKIrLyefbCFprA3hkOZaGOma5vS hZqb/wwkq2LXuSUXKia3HUubLZd1fakpgStYL79sUTD/aVPoXd1ctvQpkl0ClfgjD7H1 l3v6utAJqy951rDBUdFLejSBiVdce7wOZjHds/nbkIsp5D4jNeawwCLexvOOZYPROTo+ hi8RhuiLC6rc1z3/I80Gd63Rgin8CzTMVHRc98X6Fy3HNU5YlXbyKATaCePM0tCOVyA4 adgw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SsMKbMay; 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-53dd245191bsor778123e87.11.2024.11.22.14.16.55 for (Google Transport Security); Fri, 22 Nov 2024 14:16:55 -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: ASbGnct8Vx+kBHHH47L8GI5WO8ugkneYiT3nUuIOO2nM/fY7PLrkjiOG50f5K3WaCjh lqdjy0eqh4jnWBWwm7nZHPk+erdNjdx6euuxyv1UYCZaX8Ukxu1fGJZtoO5P2UHdgWPri8CKWuI HSyziDt2EoLv1xJTWnmrZ0pgM+ArxQiGdMUmpm4W7jC8D6JQ30FcN5HJCT3erGWARD30FJSqFOs RDuWnCvmKtQ/iq0pH9JY1qxkOMXFhYhAjW+emA9QLXjsnS6yYW4xjfSTaoERVx7uitmRhG9GXRQ R70yOivFrPAhfrL8/8ZEWWqgKE8TzvqUs3IZeHXI4CeIhqHlj0KZVigolaIdOzF/s+cmIQGM2Io JR4z9yMiOtn5boJol X-Received: by 2002:a05:6512:39c3:b0:53d:d957:9f92 with SMTP id 2adb3069b0e04-53dd9579fd5mr1789697e87.9.1732313815331; Fri, 22 Nov 2024 14:16:55 -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.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:55 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 01/12] can: c_can: update statistics if skb allocation fails Date: Fri, 22 Nov 2024 23:15:42 +0100 Message-ID: <20241122221650.633981-2-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=SsMKbMay; 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: , This patch ensures that the statistics are always updated, even if the skb allocation fails. Fixes: 4d6d26537940 ("can: c_can: fix {rx,tx}_errors statistics") Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/c_can/c_can_main.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/net/can/c_can/c_can_main.c b/drivers/net/can/c_can/c_can_main.c index 511615dc3341..cc371d0c9f3c 100644 --- a/drivers/net/can/c_can/c_can_main.c +++ b/drivers/net/can/c_can/c_can_main.c @@ -1014,49 +1014,57 @@ static int c_can_handle_bus_err(struct net_device *dev, /* propagate the error condition to the CAN stack */ skb = alloc_can_err_skb(dev, &cf); - if (unlikely(!skb)) - return 0; /* check for 'last error code' which tells us the * type of the last error to occur on the CAN bus */ - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + if (likely(skb)) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; switch (lec_type) { case LEC_STUFF_ERROR: netdev_dbg(dev, "stuff error\n"); - cf->data[2] |= CAN_ERR_PROT_STUFF; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_STUFF; stats->rx_errors++; break; case LEC_FORM_ERROR: netdev_dbg(dev, "form error\n"); - cf->data[2] |= CAN_ERR_PROT_FORM; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_FORM; stats->rx_errors++; break; case LEC_ACK_ERROR: netdev_dbg(dev, "ack error\n"); - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_ACK; stats->tx_errors++; break; case LEC_BIT1_ERROR: netdev_dbg(dev, "bit1 error\n"); - cf->data[2] |= CAN_ERR_PROT_BIT1; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT1; stats->tx_errors++; break; case LEC_BIT0_ERROR: netdev_dbg(dev, "bit0 error\n"); - cf->data[2] |= CAN_ERR_PROT_BIT0; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT0; stats->tx_errors++; break; case LEC_CRC_ERROR: netdev_dbg(dev, "CRC error\n"); - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; stats->rx_errors++; break; default: break; } + if (unlikely(!skb)) + return 0; + netif_receive_skb(skb); return 1; } From patchwork Fri Nov 22 22:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3648 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3B41141586 for ; Fri, 22 Nov 2024 23:16:59 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5cfc0004fabsf2555226a12.1 for ; Fri, 22 Nov 2024 14:16:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313819; cv=pass; d=google.com; s=arc-20240605; b=Oyf9vUInWauq/Jf52aYkN8N8UAGBNjs8c4+hsL9sd6UJaGWYh5JbXPdD1hHyvWoNYW AZ7RMnQt4cruagn/o1ExxfwCR7Vy1h0oGmsT123pQpMJf4PSshfCf/6PkM3RA9VBK88R Yb+8uDVgoA0TNh9KR38sNsbzgEO6iADxf2Hjsm3yl0FXlbVsbqA32K2+h3gVIzUbraEK qKLSHdWJTY84gNshtmNXCY41EZn+c1xYK1Ab3rZwX3G1N8CSbFM4hIbPPkmeIK1+meLt 7Hholv2WiS3xOWGxxnv/oAmraRhGOgc6+JUvmAAKa/2Mst2siO+VoiGklNlgWAZZ9W5+ j2Pw== 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=rN0Yhovh49ICggWgeGtOLD0eeGg8d34HNIlbzoqKjU4=; fh=oosbCc9O4FIAMHiKRXw+FUNuOSr/rT/EH3dJRtDpD2c=; b=DJCb1HAReVc11M7CbWq5v4DxsDXE9Bo2IdvfHJJgInHH5VFnCdHflZsg1Iw1/9W8jQ LpCmvOihhGZaYaTOM7fNK8Sfu1iGTEOquFrayYqu7bdb31f0j3DJHgABvRCWcFnvnVe9 QTpuVhHwg6BhEiz9+q/B/vGgfmhN9FH6QkV/u5ofwt1I6iM6/UNLIKI8MyDcIYHqd2nH qdior8STUc8LN31KLl9OTiJmA/vouR92SbbEFEyZG0WcMe12xx7isR43wPM/FFh7uU6X 3mdjCdpJx2QhzMcFm/agOQ87/qX/f46hlPNCAsF7a817E0yiCzfnhdECrItWBlQuXIKH X+9w==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PzD7U1lg; 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=1732313819; x=1732918619; 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=rN0Yhovh49ICggWgeGtOLD0eeGg8d34HNIlbzoqKjU4=; b=dUUSbODLZg3FgQY+i6z3iIClke9DURvKk4EGzd6ez3NCp+w0lhNuS+1yYNVQi6cnkb b7n9Z69dYtGZqd8Rc99oj0i12BHZ+c+9G3Ci+G5MekLn5Vox3mFHlTHCSyUjoWRLaui6 LBN4adO1iIu2oziwKM1M3uQMTG0xv4+Fuk7SE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313819; x=1732918619; 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=rN0Yhovh49ICggWgeGtOLD0eeGg8d34HNIlbzoqKjU4=; b=OVO/la5Vj9fVS7lXlVHTKeKNbdc5dfbfZDJ5LxxdlklwRbDgtNamiFeS/8ellb5ha+ 2yHQuRrWDhW+uzI7bp4mBxDak01RM7DXtt88E9L6JUvDJKZHQXgm0Q/k6kYD68W/wgWu KSgoNip9g/Vv5Bt6hH1/GP0ZOqCsfAC5OrLUNsYf5VnaMIHNPvYtbxqMGWbmoqORNhl8 uaoqJQRupUlCNRp0dR5/Ds3fSzkP5SRLcF62g9WzeC7MKgpH1CY0zgNSwx2X4Wq46Rdu qChQc34KJoj1SsL26+QgRHw7cuO0TXN5KD6Fc4zw5cZqniX2p/Py5vwIKGwiRZW7kMRQ nXaA== X-Forwarded-Encrypted: i=2; AJvYcCWCrs64Pd1YfUWbKPcJSXLysBh1OLUNTc8639WSQq+v5wGBj6NQwx4GeRgbDFi2/WdTiPnSmzZCHxqBbV5a@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Ywx5LF7qylTUTfmbqdhYyZHcC1rqqPkDky46cvTzBqR3nz9WBrs VscKfJd02o22+rsgSaaLtTwSgcNuk/2cZWLOnQIo4viS0O3GE6MIgAXWu1GT2VrKwA== X-Google-Smtp-Source: AGHT+IHTEy+SX4C1dYclfIX8aoIbvUxdVq6w5pyWrL/9ghMEhME+M3YJIx8ujo3INnFcw4w/83aPcg== X-Received: by 2002:a05:6402:2548:b0:5cf:74c0:b4af with SMTP id 4fb4d7f45d1cf-5d007ca45fcmr9615234a12.13.1732313818871; Fri, 22 Nov 2024 14:16:58 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:d48b:0:b0:5c9:5b3:ee81 with SMTP id 4fb4d7f45d1cf-5d007e5500els582069a12.2.-pod-prod-00-eu; Fri, 22 Nov 2024 14:16:57 -0800 (PST) X-Received: by 2002:a17:906:1daa:b0:aa4:957b:25 with SMTP id a640c23a62f3a-aa509d07146mr506368266b.22.1732313817142; Fri, 22 Nov 2024 14:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313817; cv=none; d=google.com; s=arc-20240605; b=Y3lqHAE8mGP57STIXOWmmJjREzUWAsdCKdsrl2nyjEuqgoYLfY6yMF+w7BdpSdOerT cbJUCqQauG30Y//KuZ5JF5PkJtzkPCto1seBqx3mCESDw1H/zug2EYNCdqmK0vt4sUG8 18++/XTN0Q8Kj2gNiw+/SBzWs2tGqsVQOn6YmokEy5dLPR87KinkkqBTeWbJZiszOCD6 k+UEceT7R2Cs5x1MxHW77uGWW6NDeEoK5dJkB5M9yehvbsQJp337YTiNQFn4PMQ1z2/k iVT8mItl9CBNTPU+zP++cSuZp4+YuA+JcxZRC4PctZubncgzro2i/k7vGvv8xtNysqkG ZnPQ== 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=6HrdX116se3rn9QRZsQ51ceQKyywuhiVyeVP2xiWD4c=; fh=/4mtQbNQtOE6CKCtX2glb6X+KMMzJuj6HH/pLudJy9E=; b=CysW/07t6LoT9NVVVvGTiTVvHP/X6nAs5RYGtDCn6FmIBmdwXzTG3ATdQBTbK+pLZa nDWR0+UT/a4owxyT5VSe4qd5EQBxgP+aF7+rGvDni6gawMNnbkY3BfofSaJNNwjUc3Ok nz9QMP/Pd7M7JQGTm6CS57BZkG187xsQOh/h/mUtACtg5JLDEo0neTdQueXQfEuZ3SbE aLV9ngX0gwLzavAH7faLaraAexedk0jMxdx9dZhRkwKwVwqeWNDrU1ypKCkcnP6bVc+i M/aDCfSsVVyy9S6xBJ9RNNLpyca5LI9/sR+f37rsxi7M/UfoQKu+aAdOnt4sZO9qSqo3 rqRg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PzD7U1lg; 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 a640c23a62f3a-aa50a5ff889sor121410866b.1.2024.11.22.14.16.57 for (Google Transport Security); Fri, 22 Nov 2024 14:16:57 -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: ASbGncu7avTcQk3b2keIR6byX1MCrO2SXbJyfVVJisFttmIsRRB7BEM2aOCrkgx2Jkz nuyEZFc82ML/Ro8kk6FjYZ4zpeGemO0Yu+xZy+1BE0zObI009+XJHRs+QAm33cK0d78BHXfGXj8 FGT02h1rMBfMT/QSHqE7S5D+bXESEjlnPUlplwvbePZFzH6JCivia45b2Ia9GtDCv4hU5W0T7M7 I4JnaYOUHAnMwt06PgoV9NmRShJoGqmKsgD0kV1ru++JfIGMzLRgKaWemnIiscGgiEiRkr2yNMj dZHwvYgcyn7g4NFbXHxA5bmXg8mn7fqhQ21ApOCUNCEcLD28fa7gJKanrcPJcMPtRgefHdreJ2r dhwj83pKfC7WnLsbl X-Received: by 2002:a17:906:31c1:b0:aa5:24df:ca8 with SMTP id a640c23a62f3a-aa524df1311mr297959966b.18.1732313816670; Fri, 22 Nov 2024 14:16:56 -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.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:56 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Gerhard Bertelsmann , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 02/12] can: sun4i_can: call can_change_state() even if cf is NULL Date: Fri, 22 Nov 2024 23:15:43 +0100 Message-ID: <20241122221650.633981-3-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=PzD7U1lg; 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 function can_change_state() can also be called if the allocation of the skb fails, as it handles the cf parameter when it is null. Additionally, this ensures that the statistics related to state error counters (i. e. warning, passive, and bus-off) are updated. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/sun4i_can.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 360158c295d3..17f94cca93fb 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -629,10 +629,10 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) tx_state = txerr >= rxerr ? state : 0; rx_state = txerr <= rxerr ? state : 0; - if (likely(skb)) - can_change_state(dev, cf, tx_state, rx_state); - else - priv->can.state = state; + /* The skb allocation might fail, but can_change_state() + * handles cf == NULL. + */ + can_change_state(dev, cf, tx_state, rx_state); if (state == CAN_STATE_BUS_OFF) can_bus_off(dev); } From patchwork Fri Nov 22 22:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3649 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 68EBD3F9F7 for ; Fri, 22 Nov 2024 23:17:00 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5cfc022859esf1549235a12.2 for ; Fri, 22 Nov 2024 14:17:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313820; cv=pass; d=google.com; s=arc-20240605; b=U63V5czCd6tym0T05BmFfbxKZZcY5+nCyOt9n/X0//5J4yQRQsmIfuRfHnXSbzv9T9 3/AmPYO2RLqhpRIcaNAEFJvXdoUTqCXlI3+ptXVc9m+ReayqQ/pDXZb3mVvpRTG0fl1z kQy3NOBV9eAwE+c8dLhbU4vch3GpugdnZigqDJaOuHkZMXlduVhGuNSQqKKUFZwsNsel drUszIUzMPXY6DmAqD2blSKNrOk7ZpZVjkzcW51sZRNcoSYqi+XKpBVX4unUgQJoICYN uKkVqkwW1Vox/rOPQb54StQloP0MYwJeKUDjFAHhWYwmgWAccSFcDFqEwVrKTXlre3a3 glyw== 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=EkgZ4RNL7E0DOWckC9AoKsHUvuh96JQmIoZUZhhQOok=; fh=UIjzZ8l9xNEN68iOafO43LGFsXQcZWFC9/xG+/M/EPE=; b=lTnuWJYGwxpGWDqQ+elEz72Xa2GdkKH4lXmv+Xmsq7fh0V4HeMvVGRdSZXmDEBwp/4 Zs/WqzccMY1ni7z670SM4uGlqoybeadov+Sc/EircIvtzS5sz28TodxoO4RDTwoSUIf/ G2k0Br9qS9toLPajHqlGRdtIQECyECy6LoLo7SqlG3z0Gvz/To9Z9CvKYzce2d0+cTyA C5AOIDFC7jCaUEOUwD/c/X9AcBsBnuSdQ98oN6LqSNNNKPwGcakO0lse6nFNfRx7dfyE /mIHvOtLugtYr2B4sKOwthW1MR45rNyzPBxoRxOvqwxo0fgywafQlsBiA3PM0pSMNrv/ koag==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jBwkw1Wr; 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=1732313820; x=1732918620; 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=EkgZ4RNL7E0DOWckC9AoKsHUvuh96JQmIoZUZhhQOok=; b=bZqasePUZ/J2rG0eleHiz/r3Mcgi86RUh+w6gTqo3mWlp413puqe5FK/U/opEZviVc CgA27Xk9Shi/9BgT+m1GMvri6RmLsUceXODlYpqg5ty7HqOTOzhojDoQUTO0ddvUgsZ/ gEFPV3B1IIhM5v38fZRkdNCCw3ekio1qjHHAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313820; x=1732918620; 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=EkgZ4RNL7E0DOWckC9AoKsHUvuh96JQmIoZUZhhQOok=; b=Yxrrod+j6/sP2q+STM10sX/b8zoIkr/ZOC8DPBEfHDK4ua36Gr1SkF3uVxZIuISfHL CS1pNrFsWG473JFqeJbvjKuEtEbsProyVGL4uFduI25cWEhuU3b2j18S59rIVD9y+x6r bT2572Ug0/7OB6q8RclOLBR5C2gLoeqQFIU1KD79wLqkiQ63Yn9r5ZZGaMo/P82YLZ7X t4yHDRERLstImjmVlWyXMtoQqj1gOX0LRTK0GjlHshBC2MQCtJiOahsVphqZEK9EUbOD MnNG07g911VVWUp6n+798xVwXMDMD8K1tCS24WvOUYNM5alAsls0RfsrFvois67DDdGp V+tg== X-Forwarded-Encrypted: i=2; AJvYcCVeikhiFYBeuTTPmDh1tLGqWSWDEa+Uc/NRlWyc9CKZ0TrvttxDkMuG7ZpecgMTkRksC4RgHdcZir6DyQic@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yz3v5qi5nT8RU3Z/hbeh9OyUYYqSVlQVhxz+mrbX2g09/Bj4rKJ tAyR+mQ1fboqgBB9qiLfm9ru4dluBr5J1a/hlLF2iwVrFe7RoQjwCU6qdwXhIt0Fag== X-Google-Smtp-Source: AGHT+IG9EGHWg3kUWDIXXBVAJYXSU+hQVBsM4MovhHPD2eQvqznpk847xyNXXCguoUyqp1mm0VEitQ== X-Received: by 2002:a05:6402:378c:b0:5cf:cf61:25ea with SMTP id 4fb4d7f45d1cf-5d020602d48mr4095195a12.13.1732313820113; Fri, 22 Nov 2024 14:17:00 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:3185:b0:5cf:e4ec:943b with SMTP id 4fb4d7f45d1cf-5d007e1201bls1022192a12.1.-pod-prod-01-eu; Fri, 22 Nov 2024 14:16:58 -0800 (PST) X-Received: by 2002:a17:907:7757:b0:aa5:2bfb:2ec5 with SMTP id a640c23a62f3a-aa52bfb30e6mr83695666b.5.1732313818252; Fri, 22 Nov 2024 14:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313818; cv=none; d=google.com; s=arc-20240605; b=Cnm78xPFmjZ8ZkMkxhathbFpl6QPF3RC4nKxyPPwEoZn0TbPTlAdyr28r5U/hR+mdm XuShzveYUS6yBkq/3uxc3Htdzs3btbrcJR6eLFgiqq3YUe/vU6CJcK5BbSl+xX/qM3iP 9mRhliay2pTJzrUBI24SkDrZt3Oe4zS0DJmfITxwT48YEkzqg4QHtpZlNZQH63hnZWhi O7BqQone//0i8HUefMob1gzkAZYeAw+eegOUUf6dPSJbIxYnkxL1z0TejKuJFIg1c92E g6XvfsxisNf7oPaJVNCuc9LVZsb+WzMjXBGTHl4heiHXiGf/RTejdEqWrX7gYQQCnPp5 Zciw== 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=da17qF15VPZTU2YSYHqLzMcyFK3KqWPtGcD0XFwPoOY=; fh=eh5UO+EfgNW3HEsjFVBKd3JKQRz7f6lKeemiIjrTgqY=; b=PkNrsKYaafOEuSfKK/OcGDEsM7tVbVEtcLKvakErdkYb8y8tVbk/z72JaAlbWNZkoQ BAtcpz94/32zXS94wfyGC5sVMxudZbEyBVYPlmd9CioTHXlFJ3SSFHzS3HfuMeP9E5bK 37tkiaMbS4hyNG5TyIXAMk0Ui3+O7Vnzn3+zao/iKHXk1MDlwGqksYnXsZJgjCWsmuFR QIKTfK5yu3zFZ9n92ij0lSFs6tfzhpxJZDyIS53Ny2aVDA3ohn6yWjKVOMKrUZQV097Y FA/O7R9gtGnuFIQTluT6+7cA2CGeAyobb3sQUFvCZwwVMuHDI1FwO+9+d4x6SdxkMj3S 1xKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jBwkw1Wr; 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 a640c23a62f3a-aa50b345d87sor96187966b.8.2024.11.22.14.16.58 for (Google Transport Security); Fri, 22 Nov 2024 14:16:58 -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: ASbGnctQO4M6zydIZwgfqd87RCGNzm2zEhvcI7p1z+NVXi+S0CL7NqOHCnGpQrk+CGA G0mdBvcE9givEVVGQxqGFoQLVdMEiYag00l59+pvn5+4mK00I7APaiA8pwrITMN1Z1et7VtH0uu 4bq8n9U5yImK6h39iQGhwCj1dBYSpkiwiPRVxK/utjbSUjTz+/GhqhghU5YNXC3gObeW3D/zrDM PhBLq2fDqwnDftFyzYwlYqtBMMfXLS29uLbyq230FuVJ7cyvBNv+9OXsATPj5pnfjSdph5wqf3Q GoPf1y742ZkqzBkoIC46iFVPOUhLuRV4GyaHvHCGBLki8FuvT2UNI0JBb2CXzqrCNj3BDQShqQA 0d5MSx/fy+Agjk4mG X-Received: by 2002:a17:906:4c9:b0:aa5:cec:2785 with SMTP id a640c23a62f3a-aa50cec28b3mr343858766b.25.1732313817919; Fri, 22 Nov 2024 14:16:57 -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.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:57 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Jernej Skrabec , Marc Kleine-Budde , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 03/12] can: sun4i_can: continue to use likely() to check skb Date: Fri, 22 Nov 2024 23:15:44 +0100 Message-ID: <20241122221650.633981-4-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=jBwkw1Wr; 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: , Throughout the sun4i_can_err() function, the likely() macro is used to check the skb buffer, except in one instance. This patch makes the code consistent by using the macro in that case as well. Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/sun4i_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 17f94cca93fb..840b972498c1 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -570,7 +570,7 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) else state = CAN_STATE_ERROR_ACTIVE; } - if (skb && state != CAN_STATE_BUS_OFF) { + if (likely(skb) && state != CAN_STATE_BUS_OFF) { cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; From patchwork Fri Nov 22 22:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3650 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A5A2741386 for ; Fri, 22 Nov 2024 23:17:01 +0100 (CET) Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9a1828916fsf247928666b.1 for ; Fri, 22 Nov 2024 14:17:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313821; cv=pass; d=google.com; s=arc-20240605; b=Gcn1gpoARMbZ6kMptvb9BAn6PWpPermc/McI1we1gFD52TnFi+qn+n3duwoF6izJsg Y4qhW0r/olnGkzjIpqHLbhkOHH1hvKZDIo/jaOYeRnhSD80+PihKvxVmChg3k1rksGQm FNxOrqU/f6NqFsiDBknuHGfm0o6CiL23BIoNEWOps4YgxJ+hI6GZ6x3dCZDj6UeakoVy vMjvNUMZvp4IaGkbX+Xt3yRNqB5pXxju9FHhdeC19JL4KATaCmFucKul1XV8rS+9NAOp eqDLqqBKJBkdr06TGPcYzse4wqLBxNndh/CI2HlgfZOvwZh2ieiurZjtEI4AZsBoZ4Tc ysIw== 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=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=; fh=BKG6yJ5RakZz8QWcqBUY5DK/fAKdPITDXQbmZPppJKA=; b=lspAz3Bqxti6QFocrXevqu7f6yYha76llgoq2YMiXdeS1x+D0fW19BsNpx+UZ3wU33 Xq18K5KvE8A+6Fb30biKy0247zPbIVJBDcmcMxvU/cl9hxIjfaP9F8rXSTuhuut6he4i Yvgn5Ggmu54tn8PEQuSH5linGonJJX/4Pn8HTXdbRXen3YqLacfxmZbJXWZ/dneiq8Dh 7CXJiiNSMWyY1NchWGmak/QSxSuUZ2RWxHUVSfxxZMaDEMVbqBAvhLelIf73wf/J6Z1l rsxYP5499fIZw8fM52+aSd4HLgoJ5dsep528cSzeTYPgdLUvCA+j9+n7zBy/RTsoIXPI ITqw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="mgTJk7/3"; 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=1732313821; x=1732918621; 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=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=; b=OURcvr7bZd8HdprQscvtZZiptzv7dVcWrg7MDG2aTrbc/qpT4/qF+TW41RQvxzcHR5 sFaxexRUXW8XMlkshiYCZKjtageUORFlfJq1ARodLaf5bvvqJqkbxwH2cPShpim4mirR m7H3+kfIqkNhvgfp/I3DGzLlp1BsC2xoy3KCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313821; x=1732918621; 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=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=; b=CHHRdlD6l/z1L5XkDLu49wjpV7wqbVX44XcKJSagA/r0EzJ7JkBHai4vpy7jiIvi+/ ATmm3sZ4ZUDFaeVATKXD2vOABKKjSAdDKYdsMhzJYReV68k6+x/6iL8w6MxRn8wyD1LX dSkXP+zXgNSrLzzu1AyhvMw2hA/zk5Kgo+FE+qaJPFtTlIIqi6uPsBv2g2bEycXV6RoP FMdZqJEqFqxjlHohvAST2xYQ5ji4m4ybfLoUG6eN2ugjFPxT2zR77k9u613s6O4UAzKR /pvXi3eX7oThKIUEkMNyYmBTkOduvHTvSmwQ8KGSBis9T7i/2xFFn0V4gnsR1293JGom tdCg== X-Forwarded-Encrypted: i=2; AJvYcCVh97uSMKneUsGAzoRCSB+2/GkDxzpfbTw6uLKjQoBKAfN9mBrWjJ3q3jFsgPgpNwjK30ZR2VUbiRm32zab@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyDWlTaMRLqyvTXE5cNsbP2kWwVrywKatf66GCxhTvsefozrE5r rPEBE1kWbo0fioidTROua2ui5lUy8EDDApt/hbA/8wiffG7AZ2rBL37S+HK0A2Q3mQ== X-Google-Smtp-Source: AGHT+IEYju3lqe1JldjnXm9CIBTLMfUkPoE0oOMZvO6HLx7hjKhSpb6HeoRvNTkcLcG9OErd2ZwN+A== X-Received: by 2002:a17:906:4fd4:b0:aa4:cd1e:c91b with SMTP id a640c23a62f3a-aa4ef969ef9mr970272266b.7.1732313821105; Fri, 22 Nov 2024 14:17:01 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:9f2c:0:b0:5cf:e18c:1d60 with SMTP id 4fb4d7f45d1cf-5d007e33dc7ls549784a12.1.-pod-prod-00-eu; Fri, 22 Nov 2024 14:16:59 -0800 (PST) X-Received: by 2002:a05:6402:34c7:b0:5d0:292c:1fc5 with SMTP id 4fb4d7f45d1cf-5d0292c202bmr3227919a12.13.1732313819279; Fri, 22 Nov 2024 14:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313819; cv=none; d=google.com; s=arc-20240605; b=MkhMPGyS+yvFFp1RLj0Kz5GcainwTsLb+OXtMVDjAiuivK1GAsON0s3wzGgC4ceecv JQU576wP6Hbc8MSukMHWKNysc8fu/tbHzPACLN0nBbNjK5GbvEglzZQl+4jzaFh1BdO4 z6EtIC39jx4CZigwRcRnq2MBqHRMVdJnulDb2JEHA3HQhhS4GzqG+W48YklAmYuU5KkO YgmmklCCqfQ6rRy3JH9sMvZ2hmrz+FNRnVaZtCZ/cLpeTOkrts/UCP8CRiNRkmjnug6V Vwj1mNZAwArKUCX6k3mP7NRX8DhRyEXGhYNB3LTaC48qRHryxspnD0iSDfMane0lC1Sh 4KUw== 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=yJP+d2oKTX52rq2v9NzXxSt1l/2jtdXfEIdax2O5les=; fh=KPqUMTZ6D0oyaiGhwn0WF7Qj0FpxJTNWmT+VH7msReo=; b=Z1bXWq0IxZVVsPqT+uxLH6z+/XUkxTD1eC97qabRjRVnuf5dQ0P90NwlpHCD8otEMQ TtpJDrc6PUuUSrAbbYCrqxGSZlk5qBdWC7GbubTJO5YybB1UEsSgax2QcOh64SqEX79Y i8ufBDZNkF7ImU5GDH6C+HMRZ8zcxPCTMyLQ+JP1mLEwYChiBUh1iObBD98kKTwe2aAk jCvegzIahuu+XFDlVrBwR0G2qBuavl91W04zQ5dAeAX1rBJ/Pk+CLoqB38EKqhGIcUHh 3X82lj2mvH134BDJT547LfljEC0eGWkpNNMQZ0jcYgR2c/TCveTMbca0c5lU6xhPXDyQ yVQQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="mgTJk7/3"; 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 4fb4d7f45d1cf-5d01db4913bsor1652218a12.5.2024.11.22.14.16.59 for (Google Transport Security); Fri, 22 Nov 2024 14:16:59 -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: ASbGncuQ+lfoImTqKtqOwP3P22rm5NP6PkQeC8hsgGaX+7aZFR6UE5+2ybP4FP/nf+8 8HIvivWuGzUwb8ftyExvDebNN1SVmiy11UfPOhuMqfEYByrsm0FArCVqBNrlVEa8mPXTtitaT6M mnPkZ0n3QnURzzsCSl8uf8Ek1uclWjdqN9srdXx0jFwey4bhaX0jBX2JAVgFanLIPTEDX3jTVJI 4lg/tF5J+odtq80BZB+O4cJI8VBHBdn331t7v7FfK7LQmOs84Myp+1xMRiZAd+fZaG80AKzjB6E fe0sKgjh0iXuEHfQsjmnFRE8sIzhLl4ESKYZOKTtAReUqr5G6WrSBQD5O7IFRWtu/1IP8W6+2xA aNl06EmwSCa/w9oop X-Received: by 2002:a05:6402:2554:b0:5d0:ada:e44b with SMTP id 4fb4d7f45d1cf-5d01d57df0emr4922820a12.16.1732313818928; Fri, 22 Nov 2024 14:16:58 -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.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:58 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 04/12] can: hi311x: fix txerr and rxerr reporting Date: Fri, 22 Nov 2024 23:15:45 +0100 Message-ID: <20241122221650.633981-5-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="mgTJk7/3"; 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 commit a22bd630cfff ("can: hi311x: do not report txerr and rxerr during bus-off") removed the reporting of rxerr and txerr even in case of correct operation (i. e. not bus-off). The CAN frame is unnecessarily set since netif_rx() has already been called. The patch fixes the issue by postponing the netif_rx() call in case of txerr and rxerr reporting. Fixes: a22bd630cfff ("can: hi311x: do not report txerr and rxerr during bus-off") Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/spi/hi311x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index 148d974ebb21..b67464df25ff 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -671,9 +671,9 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) tx_state = txerr >= rxerr ? new_state : 0; rx_state = txerr <= rxerr ? new_state : 0; can_change_state(net, cf, tx_state, rx_state); - netif_rx(skb); if (new_state == CAN_STATE_BUS_OFF) { + netif_rx(skb); can_bus_off(net); if (priv->can.restart_ms == 0) { priv->force_quit = 1; @@ -684,6 +684,7 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; + netif_rx(skb); } } From patchwork Fri Nov 22 22:15:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3651 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AD01741586 for ; Fri, 22 Nov 2024 23:17:02 +0100 (CET) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5cfc0004fabsf2555405a12.1 for ; Fri, 22 Nov 2024 14:17:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313822; cv=pass; d=google.com; s=arc-20240605; b=P/O072SH0sIYK9QvWoCp5XXvBq89YvJdpy2ljj7Jb2LzPXwRQgLDIv626bXVCBVxHy H4Ax+SWRNzl6IVn5o3n/JkxcMaOndw6eDkIQQlFrZuSWn8irFfEaeZL7vINpZn7tSC5R GhLs2LWIDglAuXB1Zc6cbNBwo+HosZw4xYOHN3TJ43p+OYXc7RryGAjUjQscFjycgzCy QOWwdjwNIQBKVsjad8jtlBCzQYhwzbSDdR9ncllg5IDq6vgoFL2m2bj8ktcKOmBmh1id r8mTRUqk5NunpBF3UK5TRDzyTG7BrNhOmeWZqbjOLvNCaSg2icvmKUFYFjKtwtVaqt6Z Qxow== 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=15ri9dRJ2MpNK0NZi/0DqKNcr6ppNHdPG9MEKyT43QM=; fh=LOUe/rXp56c2v1RA1GEsdl7b3Qq1G5eaTWuoZY4HrGU=; b=W4BUbdNoj8E/xTGAIejLKavjDxJP84fiwDrPK4P4GQ70ZOxmascDmwlnu6x3HQC+6F oZqljcKL8DpWRK/pDZJvAIgHBJ9qGT0Mry5iczR2Yk1gLkzhc7D9Lp81xui1gL8vca6J OUpuXv7OZ2IpxRCQrGvoUOFVmv00J03k2CRZP93cg8VP/k+wmDMvjZPGftBIt6riymRF 6weZZ8zIZ7U8EAfXh/Sf/1rYxUBTkJ3UHkNLu2Ms9rPeywXnKAsOOUrGJWs9am9Aoeui s3LoI46fWFDmcwisOcEj7LU73Ota0bMhquLl0JdjB9SxeZupnbvex6kIeWm8RSvbHYgv XZoA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oRGrWnlX; 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=1732313822; x=1732918622; 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=15ri9dRJ2MpNK0NZi/0DqKNcr6ppNHdPG9MEKyT43QM=; b=ML9gG4F1cLsRhIIt5WFsMWJN3wDpsOP2rmcDT18mG6woOVx9gjPCRE+QCHAKG5yzRv HRWRQ8SUU4vhqpFZwV8M1a/JSdMGsCeBJM3Fve4r35m/tTmMgI56E0ICuJ3OlTKAD1E0 nang8oCWyiSF/TIbOC0RhJMYJucal6Rn9rQXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313822; x=1732918622; 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=15ri9dRJ2MpNK0NZi/0DqKNcr6ppNHdPG9MEKyT43QM=; b=JKLqCy1lFnzCuKYqZuzTWiPmpo/sW6JRSDsB+zydxFQKhr9pdgaPI1G0TtOyDgPRrM 1gMBwvX33h0RKfBIBcCloOhdoBUqtt918UCBzXSFQazkKhKk2871fECNkRUwAUqKHZER EDIM5gCHKIs4xHo29i5O4b8SKmv2V1HrqG7q70sA86rt0tj9UmBUlGI7K8k8JN7wZ++V 7LtP3uVXGEw3R4UPnGDntK0/RYnhG5bQKkq7Xr/HvvritU6ce3YbUxpwm5UH28fwH90H bFo4BxpUdGUhjGtcsAK2QdUkGeVI27A2M2J+sBNgFWSHgyDOqcIOv+9TKHd9JEIb7EPm PnGg== X-Forwarded-Encrypted: i=2; AJvYcCU5XbKk4XiEXvMuDtLOXMYK/qTsJ+8Cr3lEfIq5XvaBdnVUUYe8yG0vm3refMBgrGZZ5sC8ExQIsMFJk3IR@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yw//IqxJ7P58CYAGmc8hXmiXH2LQMcEkTD0ZOc0mqBO1SKWG94m VxtbmPfSyY51eEIdm0NMQHi97/ULHFoGW9zuy3DzddDbVt4s19xYxzOvpFG4Nso7Rv2kj6ZVHQ= = X-Google-Smtp-Source: AGHT+IGttACKmQVKHUS26sofm4zR58DHVPeKsx0VXprqxCoBmpCieakMpvjWqCxW1HQ0S4AEf+oqtQ== X-Received: by 2002:a05:6402:5114:b0:5cf:cec3:d53 with SMTP id 4fb4d7f45d1cf-5d007be49c4mr8995156a12.3.1732313822115; Fri, 22 Nov 2024 14:17:02 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:8a93:0:b0:5cf:e16b:7eb2 with SMTP id 4fb4d7f45d1cf-5d007cc5addls471473a12.0.-pod-prod-00-eu; Fri, 22 Nov 2024 14:17:00 -0800 (PST) X-Received: by 2002:a17:907:1c9d:b0:a9e:e1a5:755f with SMTP id a640c23a62f3a-aa4ef9433f3mr818847266b.1.1732313820337; Fri, 22 Nov 2024 14:17:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313820; cv=none; d=google.com; s=arc-20240605; b=LCpatjfejogvRdUW14v51CtlIeuF2GmBwdk9xVvu7DxdDQHAOBfkjZwtm7dtNVaQyp AcF221GihWZ6e+6Ni+85CPx1nIvvQ1SD/tEi0v9c5Wqhb7gt3WBtFcUPyWMUcZqDPPjF sDdsrzDXmTGS62H4lLOJAO+CQD4MzUHU+blM2AOn5z0ZO56qSYnwW4i36IdfEZav6UmX N7r0a2D3CvdSUMAOfhhGZAl3O9cKfr/yw60qieKcXCSFp+NjTmRp5kr3H2Y7rKyLZGkY vxeK8sGS3GTnFFgkBkicOT7w/EDXSYtrA32QJ2bbAIc7YiYbzDpN0LOJhe6SBAgrtCEg YQ4w== 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=WH36KmdYBNGOfsV00pmvqC+HZVSDrTPa9bev2FjcerA=; fh=KPqUMTZ6D0oyaiGhwn0WF7Qj0FpxJTNWmT+VH7msReo=; b=f7KlE9BP1JRiduaupuTZ7pmRMFigU8i9/ZgUrXlXAfKWqKnEigxERRJOMMgf8FGfck bRCUDTgfcNeOCd1n4FMdFc3CCKF7wFqSV4KQbTjHR7BJJPcNPMH4gLqUbFKpwkWjo1cV TGaQ6HFVyWm1CWo+J7EDapvlm6k1BScb1maN42ChOGOTRSswLgEyXIK6WTXSo/mk2VW/ 3cb1a8fZBVjYNK2hIN9MHA5hDIXzUDIJDHzLruocXc2EarKLxrdoARts/7jNSjWI1QbF 0l7yDpmnXQGQ6hpbskZv9S7UdWgNNBUus4vEHHEW9+PuQISoJ403J4SP5R54EJBU7Yjc q5DA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oRGrWnlX; 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 a640c23a62f3a-aa50a5ff5casor123394366b.2.2024.11.22.14.17.00 for (Google Transport Security); Fri, 22 Nov 2024 14:17:00 -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: ASbGncumVqhujCeXA2FLOG00r0vn5ZTusQcczz5vmRgGZmp70bOIQY9pO5Fq2UWddgV Ejjeo9nGV6PXHI6wknBj0akWQq/DSi/3XOxnzelR48a6FVv539z5BSZrTK2u1WD4H6qk1LaEz9J LMtJ0UuvCjueJXWcS6EDgka8gcnH2aqTiHhhS/Ttm4AmyJeKRPojfRV2oqd/3Cfmsu50mAaUTOy Ui7j28s19e7yNSYsK6ijtUKYaR8D33ZborzaTaQiixmT1iNvA9635vbbtvJB0/vVaHv+RylQly1 oguYRygFmMaJpuj5BZIrTl1RrUfEsqwUVbZK0vA80Js/Dhb7I/QyJLNNClHcokYS6VvmtyM+NcC D5mcv0+im++MwDJKp X-Received: by 2002:a17:907:aa8:b0:a91:1699:f8eb with SMTP id a640c23a62f3a-aa509d5aca6mr395581566b.28.1732313819950; Fri, 22 Nov 2024 14:16:59 -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.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:59 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 05/12] can: hi311x: update state error statistics if skb allocation fails Date: Fri, 22 Nov 2024 23:15:46 +0100 Message-ID: <20241122221650.633981-6-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=oRGrWnlX; 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: , This patch ensures that the statistics related to state error counters (i. e. warning, passive, and bus-off) are updated even in case the skb allocation fails. Additionally, the bus-off state is now also handled. Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/spi/hi311x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index b67464df25ff..25d9b32f5701 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -663,8 +663,6 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) u8 rxerr, txerr; skb = alloc_can_err_skb(net, &cf); - if (!skb) - break; txerr = hi3110_read(spi, HI3110_READ_TEC); rxerr = hi3110_read(spi, HI3110_READ_REC); @@ -673,14 +671,15 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) can_change_state(net, cf, tx_state, rx_state); if (new_state == CAN_STATE_BUS_OFF) { - netif_rx(skb); + if (skb) + netif_rx(skb); can_bus_off(net); if (priv->can.restart_ms == 0) { priv->force_quit = 1; hi3110_hw_sleep(spi); break; } - } else { + } else if (skb) { cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; From patchwork Fri Nov 22 22:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3652 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C6A863F9F7 for ; Fri, 22 Nov 2024 23:17:03 +0100 (CET) Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315dd8fe7fsf22507025e9.3 for ; Fri, 22 Nov 2024 14:17:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313823; cv=pass; d=google.com; s=arc-20240605; b=TdSJb2jgccAi8lj6wQTjngd4uKE6Vy7TPajk50ok94+HPqxVzztaQH36jcLdsi7cC+ kkWgHkZcMlBKePTNgHxhZNOCpwbRD3gW+IECcDkvk83qVXPl2K/3VYKfQQVrrlVP5anf 4tYOOmowi4WC2Ood09Ikr8HADBPsZJi9VkaTM7aIRsnq1S6KeAE+Gm6ZVuLs9rF1TSYh /d5D59gcePn/mjcgOlv4+0/0Pvl8X7rvi8coUGnJ/ifrKGNN17S/IoMklVsyCaRDjmk0 w2zPcC22+0fMWx57Y0f7I1V/JXS+faIYWciNF8ZKNBlqPMBJu1Xhuu+34GbsZ+uhA0m/ oYeQ== 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=kfVOR2PCdtETaGxcQMrMk4jYZfkuMRw1TgrcdTbiOBE=; fh=VJC3HnIf1Sx471o5MCmndGnDTQCQxHiuQffi6cPl+r8=; b=ACO/51sgp9Tx9oQlW8D0wUmVTC9MTxKURkGAEhEKfLIMLE0xHcdJdyne54OLiJM54Q cWEOBizdvyKtIndUFAmrTaDUC6iGzoRrMMbqh9Wwy7cragryTT9Aj06/Rio2E/r2TOUp tEoIIZ9QRnIpoVPFHsdCUX/H8XQnE8AOb4RVNBS8pm3hDdycW3dSY1/CzgV2k3nGJ7gr NzjXDeox3nDd3jy+Nwy7xa71nI4YAwr7+i0nWT3LbgBmNGk5/rnRtQA9XQD9aSIbDe7C /hBRE8ds1a/Tp5KG7QSZ8CA3nCyvthrJ1us9f60DRvfYeuAfzgi0RXdQBmgkn+0u8MVL /tJA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=DfEDuHtB; 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=1732313823; x=1732918623; 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=kfVOR2PCdtETaGxcQMrMk4jYZfkuMRw1TgrcdTbiOBE=; b=G0tYgoHgGWHRh/97oPbWOe0zdAa4NsGj5MJHq2f0pB2mO31c6BBV5Y45D7xisARm5E wYl7DUxen7xAtqXBJD5CtfnnNtjCABRHjKQDtvRFmSHcJgYaxZoweNjtBR2zFJV93sVa Ydzsg1N5d6RZx8L91ovXWCWdzmcak3D+u8968= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313823; x=1732918623; 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=kfVOR2PCdtETaGxcQMrMk4jYZfkuMRw1TgrcdTbiOBE=; b=CAamH2VYPpUdWhONErkrdQZKCou4LetB0I7kPQdHdYXRUkJ+M2qTp66Z8rR3FzXL0U V72LcWfEPJvR/F3DOMXGMUuGa/93t34wRWAfYZY4uWIgkUJ4oXt3p/xCSMmqbZfWjNFt aFz3Iae0jkw7eCLYmfBBCnAimfy60nkyV0P+ewVj3V4/2cG4NGyzuZ8fK3cXxWSbkDY9 Kp60ikmqHKHi6br54vsTzUTX+54KJC0llk4Tic3j41v/8EoKap+TXS4We4Lq8zKffTrL u4asTY0n/dWV+svjHjjcloWbTPsBFEEGqmMXmDy5gO+wW79b+IrywLIy6pMily3Nlxch i98A== X-Forwarded-Encrypted: i=2; AJvYcCXUnNZow/vfXFkHuQh+IiE5wTLXiNTHfrvjcV1lU8OGSMqwOvoSRXKLYRNQRI8xbqqtY5WOfmPCPhM5kaGt@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yz5t7A8jBD/xFyAJdbMQz+sycYOZzlhRPUtMW5MhJFOhM0HIPx7 PKJ8b2ViYJHN6+YNd/tdeieaykUbDSiFfb89MJPZG0aHZI5Q9KVHAcjbYzw4zSyOUw== X-Google-Smtp-Source: AGHT+IEgA+6O8Y//Y8o88c3FqNEaoe8XINcFl9pF5dvxspfgkGAdYy+icERBulxcq2OwZJoSREp/UQ== X-Received: by 2002:a05:600c:4704:b0:426:59fe:ac27 with SMTP id 5b1f17b1804b1-433ce48fd61mr39405075e9.26.1732313823387; Fri, 22 Nov 2024 14:17:03 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:4f44:b0:42c:af5b:fac1 with SMTP id 5b1f17b1804b1-433c5df5104ls16794965e9.1.-pod-prod-05-eu; Fri, 22 Nov 2024 14:17:02 -0800 (PST) X-Received: by 2002:a05:600c:3ac3:b0:431:4b88:d407 with SMTP id 5b1f17b1804b1-433ce410255mr42693175e9.5.1732313821602; Fri, 22 Nov 2024 14:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313821; cv=none; d=google.com; s=arc-20240605; b=eU8JvpERSONUQXUcsKeptNJN83mW817zscg+pcPHkWl++G7BTaxOtyqfJMCJ8z4Sco c/t+G6JGK12Ka3oDgqyPhmJ+GfAZju95ML15ZuemHKyq/Qz5TGu98l+f7ccdBhQ6GmaD hLEraiGNPHwJOdXOy1h3SeWfA6NVdIf4OWr4gu1XyeQ/BixNzJfwdC2BdnYxU7SZ45hr LpeFYqb8PTUt3uhLoPrcTZpsgdGBlkGvhdh56HlTKXF5NfM/iqpQxREF40gJoVVbuCRz PHETSkUbY/aWIxUx0U7glqOkGxq7rOMjtgIEeAosE7boMtzdIKDkK6y8MaqZDwLD0XVr zs+w== 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=RX04a1ntmZvpkxNuR7+A/BvpYp1w7zMI7wCHavx9c7Q=; fh=nWJlPYMhwdWw+bQDuOxuihlZNxl/SL585p0KRUhQI9Q=; b=JOUfdIewSZ379D4H/68lY5Y7ltYdMnC2K2P6AeBeqXrKyzsrjrYSsh5e7scuzfvlRS N3yBH8IJ/pP0FNDTo/CvHRDGXxw66GD6leHjEu17xQlNUyxIzEy7zuAFdZEAbJWJ6Ez4 iMh/uSOviYc1B+ClSi+DCjHJX28ogc5jy3smHZQssjDQLDs3ed94PxOSq91rIWwduc+j oSplCPCmo8P93Z0xZo9KTENB8bf53+5GmzOSFeOXbDzRCKPwtfq5T+QvSnsbX5KM3JfO tnsX2Bakv9UddN0raiYno1WSfEcBRqDhvqGND7mkj7XhoVqMTlFVnCvXHpjdkXHCgoey iwdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=DfEDuHtB; 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 5b1f17b1804b1-433cd881fdbsor15315635e9.10.2024.11.22.14.17.01 for (Google Transport Security); Fri, 22 Nov 2024 14:17:01 -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: ASbGncsxGuDd4FYnYulR4hdFuBXieeyblfjBkAH4DFfJBPOcxnt1S7KiLakbE5nILjD Fg2dsamQKQbpF5p8MtxUHUiUrE1Z3q+7+cZ77CxTMG/a5XPB9FhTHdmsDuyXQ089LQLWs9oNQXo XFoLl8vAu1cnvSBHXgjVHpG68ittKTk2B0SXzWb7JdsaUJGZoBZr0/U01C34oDWQnDiPqxFb4Ih ByN7bJtl9G+26eopT0HoY/oj2r24ugx46/840OMKhW41+kTPMUX4Tw0MOezSStgUNeakdYsugdB rJjEN8+F6Ho+bgOfdKVBOjSURi5qshWbT1foEBQriWkv+OaKkOnLgubq/mdWImaQ5tsTYZSepFH 0ZZ3aobyAPoZWFTKV X-Received: by 2002:a05:6000:1788:b0:382:51d7:a2e0 with SMTP id ffacd0b85a97d-38260b61f45mr4102854f8f.27.1732313821142; Fri, 22 Nov 2024 14:17:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:00 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chandrasekar Ramakrishnan , Dong Aisheng , Fengguang Wu , Marc Kleine-Budde , Varka Bhadram , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 06/12] can: m_can: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:47 +0100 Message-ID: <20241122221650.633981-7-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=DfEDuHtB; 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 m_can_handle_lec_err() 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: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/m_can/m_can.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 16e9e7d7527d..533bcb77c9f9 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -695,47 +695,60 @@ static int m_can_handle_lec_err(struct net_device *dev, u32 timestamp = 0; cdev->can.can_stats.bus_error++; - stats->rx_errors++; /* propagate the error condition to the CAN stack */ skb = alloc_can_err_skb(dev, &cf); - if (unlikely(!skb)) - return 0; /* check for 'last error code' which tells us the * type of the last error to occur on the CAN bus */ - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + if (likely(skb)) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; switch (lec_type) { case LEC_STUFF_ERROR: netdev_dbg(dev, "stuff error\n"); - cf->data[2] |= CAN_ERR_PROT_STUFF; + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_STUFF; break; case LEC_FORM_ERROR: netdev_dbg(dev, "form error\n"); - cf->data[2] |= CAN_ERR_PROT_FORM; + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_FORM; break; case LEC_ACK_ERROR: netdev_dbg(dev, "ack error\n"); - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_ACK; break; case LEC_BIT1_ERROR: netdev_dbg(dev, "bit1 error\n"); - cf->data[2] |= CAN_ERR_PROT_BIT1; + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT1; break; case LEC_BIT0_ERROR: netdev_dbg(dev, "bit0 error\n"); - cf->data[2] |= CAN_ERR_PROT_BIT0; + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT0; break; case LEC_CRC_ERROR: netdev_dbg(dev, "CRC error\n"); - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; break; default: break; } + if (unlikely(!skb)) + return 0; + if (cdev->is_peripheral) timestamp = m_can_get_timestamp(cdev); From patchwork Fri Nov 22 22:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3653 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D4B1D41386 for ; Fri, 22 Nov 2024 23:17:04 +0100 (CET) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-38243a4ba7csf1289150f8f.1 for ; Fri, 22 Nov 2024 14:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313824; cv=pass; d=google.com; s=arc-20240605; b=P/3wskjPDzlDXC7WPPladJs8Dn5UDKvHHEEoSvArC+xuIUNoqcUUibuwHkGHAZ4j1p nIlrRfxvdUG+mKMpGG89iyUdk8JAmnukl0rMqTqs22HFg9oD4V6pMygyU56uQhhpF2Yd tnL+I3YKylWF98JZRZDr2n5pA2AvsNBWEydu3ujQqk1W2MIiJhOnsjxbBK8wR5OotsTw ilBWNmpWld754/ZxktbqFySccSRXjTu0grytc3S3YX8BkrSd8gOKX3Mqw1SXn89eZ93q 3FDTBhD35fe6SCDLyN8GRFLGFiXiaZqG4utwD1AVvvgiwAS5B1HRJ9AmrfFp8w/1hlsL yueQ== 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; fh=LeZW/T4JeP92gHF2O+TAFtAoolpddrhJRO1+EH968xk=; b=XkXMxOr2pkN98/3VfGwnGWOcHANos1O6g9Rz86C2hZt6MD+IHuXir441vFrM+vMecQ iZEzcTLePVtgr77hZ3agXPMN4muKDYyXyyHILPlATX2jcst0zwVUIkLTgdGZURANCv/f eFHaEm7KiZa2efhBWyk2QYc3torD2i6YRE4RCUU2ys//xYlZvN0CDwRmhkRwe2ZPrQkQ ZkdW/F1XFwh/y4QVCgLeMNhZaWwoZ7a+AlVQnlPAn4JPTJoSkgivpkUUZoCdFAwiA6U9 /xyg9aTZQVYOx+6IXBaqTP882VGBIn4UJxdnt0vtfIw4eveRs9H7oBULuFCss+h6LCl5 lkzw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UN18G0Og; 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=1732313824; x=1732918624; 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; b=jw0SWhK793j9n09HC2nLrIp9S31X/skg5sIYe/idyeUcAYTz92Hn+XFAPznaI2qJVT KGoL/dI2TWUtTUnUqz+cAkaK70mdD+heOEcQ7i10URYMAKELDCns1NtqD9OTdEXLHTsR A0Mql+V9K8//yNPxMRnxbgKiIcwWgEVHaJ28U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313824; x=1732918624; 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; b=YkV9VU/gHG7/r7q0SugBWLEj6AIn7Y0WE1SNubxtY5OP4oCrh+TL29lzNyjh6oOlFI 9/0AqorHOuXAeqa/J+oBjngzkCZf2dDandZjH/46FQLcMAgLENiKfQX2NYOKnhlrQ5T5 REzrc6ENlmdvWS+DA+5GaQFzbMhL6/0lRiCKkJRAN2nKvQdvP8kv3pkZdWcPihco5aHh ppsF9cKo2LlDTLVCl6LVQ/2YnS8G+C6lqaASOkOEHIhoA/OSzhR5Iy+qTh41pPnM9/v4 t+bs3b0nA6isfPASEuING25wOkEGbIyPC00/n0kV/0uKNqvJwBl75kuM1tyeq8U3TAWF tqsQ== X-Forwarded-Encrypted: i=2; AJvYcCWWKtJeteRtsyCNa57MOCWfDSC3KgTfK4YvwYTTfJjNOv8aSbo02hsjnCjhD1E9ELl6sL9mrbTiFWOrsek0@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzQ6/xDUgM611CuaLLkoM2DEhJ5y+Ptv10F3imzJMUXL+DHCX87 uDMFSoKwOgRdlgo6GnkWfrf0RxSKRsdyOmmSIm8MNJXHlj9qVmmJR+yqz6stVAxCTQ== X-Google-Smtp-Source: AGHT+IH4Ojc/q3ZVh8QUQrWdhHU9MUYYNc1K5oqm7fXMl6AN0oV6+3CrnELZtgUty/reVsDd9CCDbg== X-Received: by 2002:a5d:59a6:0:b0:382:383e:850e with SMTP id ffacd0b85a97d-38260b58a50mr4305049f8f.13.1732313824451; Fri, 22 Nov 2024 14:17:04 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4305:b0:5d0:e0b:5536 with SMTP id 4fb4d7f45d1cf-5d00e0b5ef7ls318315a12.1.-pod-prod-09-eu; Fri, 22 Nov 2024 14:17:03 -0800 (PST) X-Received: by 2002:a17:907:7785:b0:a9a:1fd2:f668 with SMTP id a640c23a62f3a-aa5099bf60dmr377309866b.19.1732313822614; Fri, 22 Nov 2024 14:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313822; cv=none; d=google.com; s=arc-20240605; b=HjjxILK6K+GbbxDcZG9w560dH0QbnUJYucEqzZqBRGMkgaSy331zVcQB+tvqBI6BPv qiA4Ns9tMdkVKD22l/fjp0E3vD+hXjT74inK60oEn/J6+Cp/yP0gHYGS/tkfsNqTkNAq dwsjncDYwedzt3q8rlVZuGSuAPlQnZSIbo54wwKOHmSn8s6IwIXRANcKIB8R/jkrqO31 rKrD/plvNvxMBjJjW/a4AMW5o+A9dvIHGUGZhtRguC9epkeH9JN00pPNUGoYoAiYbMRs f15/WyEVHpX2MYE7DjbYS7fBLM6vKVroQ68wQoxSaZxvRdCG479jVx2wzHi6TLK/3oYm JPHQ== 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=hTITGD97t4sTBt1UReGjyzt5Hepohw9TTIeQjkSL1bk=; fh=wehOksc4GmJJCVDEZOemgknpBXE+pBAMfy2IPOPNJ0E=; b=Lz797KD9BD0QYoY3076IOZ99QTkUcDtocE5qZee/Ug1I55EDCWhhz7MtC68xKHNbcV YMQazelFtewX+7HjU1e5NgI+YycRKNVo5p5Hvfksw6EZwD8/Ff+S8rtYvAwZZcIYNrmt IR/SiUEDN2NvwN6/Ly4fWJxuK+CCDQ5AyYtaa5njXpOBH2/Pu2gJF7/c52SZ0FKRnjqS 8amxCm9REzEVxlg1cFOk15w8bN85o+ygjJpVSAb+Z4ux9PHjix1MFNIzVp2SypMqd0gu mOWwgvUUW3Zw+U+lvB3x1bWAYAJkyUWoRRVxy9z5qVgFey62Es2nROPYUOnNoF+NBs+3 C3IQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UN18G0Og; 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 a640c23a62f3a-aa50b58e803sor75423766b.16.2024.11.22.14.17.02 for (Google Transport Security); Fri, 22 Nov 2024 14:17:02 -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: ASbGncvOmdRlx19n5ULEKH5gF2tWrd4irTpk1t49fuhoibWI0RpPE4wnGFOAnlYYFD6 Nf4xA+sad/CjAutbOp4YybD97886NSNrhZBe5IpE4PCinjhXmsZiDmfEsIScut+RYwc8Yktad94 MBhhyggNrJxGJWDEEwf9Ql8SaEtZDNE7yc8LGJccS2WJVVXaijLM93OBbSgzY5gh0MTnADvEcrK CCoNfwoP5dgF8VjTVD4hYfVvou0qx3mKBVivkHsj0Vha8H1r4Nwh6K0z39s7rHspvZ98oiCD09s PAIrnJm7NsEf47NjNRJmBce+/83ezNhBZPdVO+xMyiKdbTXGZJshi02Upt2q04s1nhti+sHpp/l OyXMfPT9LKzEIrO5i X-Received: by 2002:a17:907:7809:b0:aa5:11fa:6271 with SMTP id a640c23a62f3a-aa511fa6405mr324012266b.49.1732313822235; Fri, 22 Nov 2024 14:17:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:01 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Marek Vasut , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 07/12] can: ifi_canfd: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:48 +0100 Message-ID: <20241122221650.633981-8-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=UN18G0Og; 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 ifi_canfd_handle_lec_err() 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: 5bbd655a8bd0 ("can: ifi: Add more detailed error reporting") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/ifi_canfd/ifi_canfd.c | 58 ++++++++++++++++++--------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index d32b10900d2f..c86b57d47085 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -390,36 +390,55 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) return 0; priv->can.can_stats.bus_error++; - stats->rx_errors++; /* Propagate the error condition to the CAN stack. */ skb = alloc_can_err_skb(ndev, &cf); - if (unlikely(!skb)) - return 0; /* Read the error counter register and check for new errors. */ - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + if (likely(skb)) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) - cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + } - if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_BIT0; + if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT0; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_BIT1; + if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT1; + } - if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_STUFF; + if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_STUFF; + } - if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } - if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_FORM; + if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_FORM; + } /* Reset the error counter, ack the IRQ and re-enable the counter. */ writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR); @@ -427,6 +446,9 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) priv->base + IFI_CANFD_INTERRUPT); writel(IFI_CANFD_ERROR_CTR_ER_ENABLE, priv->base + IFI_CANFD_ERROR_CTR); + if (unlikely(!skb)) + return 0; + netif_receive_skb(skb); return 1; 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); + } } } From patchwork Fri Nov 22 22:15:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3655 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E56BF3F9F7 for ; Fri, 22 Nov 2024 23:17:08 +0100 (CET) Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-539ebb5a10csf2225151e87.3 for ; Fri, 22 Nov 2024 14:17:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313828; cv=pass; d=google.com; s=arc-20240605; b=QRX4GefBWc9D46XAeyWR4W+5Rx1rrNEQMlYR41MF3euITjhEiL9ZH879t9wgdayrWD AsWmxvDzVc1r1bdaSaBzVjLv4l9GH1Kr4p/IVPXilciN4Jmy0sKcjuu0Atmp8DCS+y3y bfZrlfDn1iG1SUS1mdr7qwT5mpXqfOL8tdfEvf498jPnVaFu868tfaDOE8fuZXUXEl3b S4sBNwlRaoQBcCwOOnjFS11LVr/531yeJUQjzri1VbUSQDVfu9CNGGVkhmMR5J7xtsEq 8NFO63jYNZXkZv/GPznZy4x+h3cFZwpt+iX1jxB2KLXIhD2FIGXSJgf92Yd2jm1SXKO1 c22Q== 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=sR2WRnwgOVMBGcSPHrF4Zc8vaEiLhCWd2PYNK22GMzg=; fh=GXrkmLz+8c4TXtg418/4zvjdIHCWoOWCUDo4XPplcG8=; b=UwI48sbWC48K7LIHYtPQreAwTQlzASL1r/IKtdFRT3gCCtjzQ/OZ7YO1wuvNYEH/Vl ZwZYwPpaEpzBxDxkqNBjVWwxVn1iNBJ9GM2aOHZmOP4ksofwbKwjUahX4MXEu0a7plNF K3BJnEIduAkYAkDEGOd44At/gvp+9cuhDQDuemsLQZcH8nNxQrwYyVfEs+17KZBezNdw HtDZJp5EMrYZzuBiQAO6jyN2+XunE1NEle2ObloafKNMWGcPJy4viPLXJRWXrQtXhPzN /lWT3fJU3AiK9rL2H+GGzStUXIwTTDCA0hc8NfchPuzqS9WBe1XzincrrLgh2wsFRQRx jr8g==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cdRYU3HN; 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=1732313828; x=1732918628; 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=sR2WRnwgOVMBGcSPHrF4Zc8vaEiLhCWd2PYNK22GMzg=; b=mF1GqKdyRrjnerFGqFU4hIvM+W1CyTS2nm+TVbc+of+AUxiT8EJHFKQ9G5uKpHcA4L 4cUFmZImp9kbO+cXCx+1bmm3b2xULCutIyWSjsn3oD7zQvgWsLr1t/22/9GEiuCTYXMq Ouk+A4OE7LOpRCxHkmQWWwQfCJGCUr1BaD8fw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313828; x=1732918628; 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=sR2WRnwgOVMBGcSPHrF4Zc8vaEiLhCWd2PYNK22GMzg=; b=sEUsYVv/dxvMvVZMzCyqpemcYnB/QNGNFkNF+EX8k/wCkzBfAA1OWD7FNUFj6wDZqW fnYLWufK4w+ZScxWVXPpViWp0F9XLDE0mXYL6pzSk/76qu+KgZfYftxrWfu93IZxwVT7 eDzNLgIZwz6DrGIIc1jdbji7Pui1R1+HAZ4mDTZqCTM0TkyOIHXawme0LaWzj/3NL1vS POHpkA87EHARVUOZ+erCG9yYrvePfmYssJpycT8E3KGlw4xukoPCpxZ2rQJG8zkG9J6v zDNr7wpPwyra8zXn8dBQKnLBGsBRoCUx5QJXBfnAURLHNUMjfLFG50u23NZOvxlMV5a5 Jm6Q== X-Forwarded-Encrypted: i=2; AJvYcCWvh85eNLJXSxKjFZwK/SqRbYBV1ss+//LtiqROoXhhK26z3Ezu7QJcDpxIt1fcKHl7d5k4DFbzQFsmdpw1@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxaXF5EydZAK0Wfk55rO65cKiqTxyvqkewK2ouw32/HdDzqNpeg veUY+dha2t5fbQgB6+1hFZSGLICkpA9JoI0d+cpfzToZ+DVNWORAeZDsDrrRun0kkg== X-Google-Smtp-Source: AGHT+IGPUouRKtBN8fsi9CFOh3JzLl9zp3xSwrp2yfB5GC7VIU3SXZBQ9/2HI/SEl8ygM3T27MVFhQ== X-Received: by 2002:a05:6512:b05:b0:53d:d246:5aca with SMTP id 2adb3069b0e04-53dd369f636mr3938074e87.24.1732313827698; Fri, 22 Nov 2024 14:17:07 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a19:9118:0:b0:53d:d0a4:8845 with SMTP id 2adb3069b0e04-53dd0a48994ls245686e87.0.-pod-prod-05-eu; Fri, 22 Nov 2024 14:17:06 -0800 (PST) X-Received: by 2002:a05:6512:281c:b0:53d:d58a:cb66 with SMTP id 2adb3069b0e04-53dd58acb88mr3540935e87.51.1732313825672; Fri, 22 Nov 2024 14:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313825; cv=none; d=google.com; s=arc-20240605; b=MKCYjTj+FM8beD2Dt3ZwlnglvJZhMJw/3/k7ns8VadbaAt+UXK0uwUtjOgCGrY9iDS cRdFDdz0ydIIPcohw68M3CtkvI755I2wKmq6W0wMkRWCVc2CcM3qwPOtv85uwtKT2uTx 9jooCvpyKXu9UQI21O1VynIDQtLkEf18OvDLg6vFUtg7SHr43yMM05GjvJKb/YDq6q1+ yAB30epTvzGwuQ0eP9X2Ql/0h+ArW7h2jXMRydy5Gn7CVD3M8na3WEK53/hTcNomEM02 hjK2kU1UxNlZYAVQ6s+bPtTGA4uI/EPZu9q6J148avwDW88SZ4rJ65gtIkLADrsSSZBc rzaA== 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=RlpDyiJR/k7vKSJ97gJNXRm8erHzYQsibasSD5BWwAI=; fh=syCFqySSLxxt8gSwWXSblJI0rPP3W7ajAR6N37oixS0=; b=JMnHxf4EIHBLxEFGJFlyD1ifx+Xa1W87pWvNDSsKi3KYUR4NGnxjYznRmMkog90mji 6gIXsn9o/8w+dWJmdbFMKMeEV9jlyZxNeqGcfXraIn5lYZmBoa15TJQylOncvwBKSZk4 aafw08gjriERc7Wa07R0RTwtZtdtN7te/tWbP5SMMi2pbgNhAlCLN2eGHW2lMS6r2qLc 73Z+uGyBD38Kyvl+DwICEfFAG+kv8Sv1+PWW6UrvodCk0hpFC+zmaUaeV0cORGdLSPIQ 8JouZ/OJzPpaFBJUb5Td1+DZXC5AkZB5DvL/wCHpd/O2qkZwhJr9f9z1OgtConGqJ5Sn ur5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cdRYU3HN; 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-53dd5793b2fsor776024e87.16.2024.11.22.14.17.05 for (Google Transport Security); Fri, 22 Nov 2024 14:17:05 -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: ASbGnctkLnN1huNlY6ljICNNc8UZMhTf3boruXOTOyGMIGi66EoGOQHfl8vTHqztcGX jTmVwEmqYB3gctmg3CuyLA7oN5PteGwx7UFFRC29LR8vM0/YyPUsj4p3twbzmO3627gRu01x4Z3 O6Fb/e4lYYeXAphkkqXp5KxG+IxHf5WAQyzmm7v2JhxrjLcX29RPBymuv2x5v5g1VIYx24rFgye LDUEe2iqbiFAPJ5ILHzkBQlx0s2S1RXNcLVlckOfzcB2S3SDNQhn2x28S2a+l9ml3XtRZtcysuv GqfMecogp/gggMttD9ldxYlX68ACH72NFHfW+x7uYbUkBgx1N8NGjApg5ct5EQwbJ5HTIPSVYzo 5pWU3wnJJUdejp/jZ X-Received: by 2002:a05:6512:304c:b0:53d:da89:a491 with SMTP id 2adb3069b0e04-53dda89a8abmr1706753e87.10.1732313825233; Fri, 22 Nov 2024 14:17:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:04 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org Subject: [PATCH v2 09/12] can: sja1000: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:50 +0100 Message-ID: <20241122221650.633981-10-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=cdRYU3HN; 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 sja1000_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 429da1cc841b ("can: Driver for the SJA1000 CAN controller") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/sja1000/sja1000.c | 67 ++++++++++++++++++------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index ddb3247948ad..4d245857ef1c 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c @@ -416,8 +416,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) int ret = 0; skb = alloc_can_err_skb(dev, &cf); - if (skb == NULL) - return -ENOMEM; txerr = priv->read_reg(priv, SJA1000_TXERR); rxerr = priv->read_reg(priv, SJA1000_RXERR); @@ -425,8 +423,11 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) if (isrc & IRQ_DOI) { /* data overrun interrupt */ netdev_dbg(dev, "data overrun interrupt\n"); - cf->can_id |= CAN_ERR_CRTL; - cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + if (skb) { + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + } + stats->rx_over_errors++; stats->rx_errors++; sja1000_write_cmdreg(priv, CMD_CDO); /* clear bit */ @@ -452,7 +453,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) else state = CAN_STATE_ERROR_ACTIVE; } - if (state != CAN_STATE_BUS_OFF) { + if (state != CAN_STATE_BUS_OFF && skb) { cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; @@ -460,33 +461,38 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) if (isrc & IRQ_BEI) { /* bus error interrupt */ priv->can.can_stats.bus_error++; - stats->rx_errors++; ecc = priv->read_reg(priv, SJA1000_ECC); + if (skb) { + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - - /* set error type */ - switch (ecc & ECC_MASK) { - case ECC_BIT: - cf->data[2] |= CAN_ERR_PROT_BIT; - break; - case ECC_FORM: - cf->data[2] |= CAN_ERR_PROT_FORM; - break; - case ECC_STUFF: - cf->data[2] |= CAN_ERR_PROT_STUFF; - break; - default: - break; - } + /* set error type */ + switch (ecc & ECC_MASK) { + case ECC_BIT: + cf->data[2] |= CAN_ERR_PROT_BIT; + break; + case ECC_FORM: + cf->data[2] |= CAN_ERR_PROT_FORM; + break; + case ECC_STUFF: + cf->data[2] |= CAN_ERR_PROT_STUFF; + break; + default: + break; + } - /* set error location */ - cf->data[3] = ecc & ECC_SEG; + /* set error location */ + cf->data[3] = ecc & ECC_SEG; + } /* Error occurred during transmission? */ - if ((ecc & ECC_DIR) == 0) - cf->data[2] |= CAN_ERR_PROT_TX; + if ((ecc & ECC_DIR) == 0) { + stats->tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_TX; + } else { + stats->rx_errors++; + } } if (isrc & IRQ_EPI) { /* error passive interrupt */ @@ -502,8 +508,10 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) netdev_dbg(dev, "arbitration lost interrupt\n"); alc = priv->read_reg(priv, SJA1000_ALC); priv->can.can_stats.arbitration_lost++; - cf->can_id |= CAN_ERR_LOSTARB; - cf->data[0] = alc & 0x1f; + if (skb) { + cf->can_id |= CAN_ERR_LOSTARB; + cf->data[0] = alc & 0x1f; + } } if (state != priv->can.state) { @@ -516,6 +524,9 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) can_bus_off(dev); } + if (!skb) + return -ENOMEM; + netif_rx(skb); return ret; From patchwork Fri Nov 22 22:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3656 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2971541386 for ; Fri, 22 Nov 2024 23:17:09 +0100 (CET) Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38236ca50d5sf1243334f8f.0 for ; Fri, 22 Nov 2024 14:17:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313829; cv=pass; d=google.com; s=arc-20240605; b=V3VJX2hTtfldC2Yy9l8/TSaudZKjo6uxLVO7ZW+iy0K06gmPWxlR0Kh3HKqfnt/iM0 npnbwPGNooM76lZ8JQNqrwQnPX3i2iIa0dTP2+f9J++qxemxbx6+h/BCgyHAVKwc57ss ySyfU6ZxpHSPdt67WPjvWbhT8e89KujUgzwuepTEcjhCnkgwwpEwv7QoaD9+jK/iZU13 jKynqAfpBkAq6HKl4XX3GljefUL8Abl0nsNJBDxMHT+CSZ7qqGmI0UiDhCpj7VDexvoa HtRZtn8BOpmxRoXgR+RbhgnOtdyUdzFvSVz3ItGJ0VdYSuUb9TYexljfucPM81LUFINf MZIA== 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=Es6RimG++8dpan1LDniA2M0F2kF0f2jZyhd+8CkCQbI=; fh=xtC8pSftClC/b2D7t7bHZzcAB/KpYf/NAYiXQfTkVKY=; b=Dabobst34A4sc4xYSOnIeDWkXBfKxhYMLU9f6/zzSxY4fMeeg3cgqQJXWAicAUT04m k1/iOEoTLn+2ZyqaqoD5CBbW7imM/U6qac0M9t3+93mtWWykhVHHmVmw1Nq6/AdzV9RZ FVIRBzzA8uHYAIcrMO4H15GyJmTgEhZOD+dt4fenQHSj8DLlhI9NtT9ygKqECKAtzDaD iHaPL2AdhsYUNSamBPRc7yKi76i+2hmg3vHSo5NtbLeJsaF3k4OhAxTIwqM2z/j6g1hc e497YYl67X4MHY8CXBCjdo14FPBfHyHB/FjGjXBWPGZkcLknwPxE+kvrvTdYfTu+NF3v 8FBQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hKbk7kOt; 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=1732313829; x=1732918629; 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=Es6RimG++8dpan1LDniA2M0F2kF0f2jZyhd+8CkCQbI=; b=DNtVZhGXkeeaU/Og7qcUnoD5Fo3rjwYMd5pAEnyESPL1aax1pSRsc3geL2GcN8dHZc uoJr7NhJiJCy52gXiTqD1tetPTScb6LRCMQJAXV1JpPxFRe6IvZQZykoXlJUt0prlGd1 FT5fVk4B3tZlYyYCNMcTzMvFKcP0i7+cthiBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313829; x=1732918629; 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=Es6RimG++8dpan1LDniA2M0F2kF0f2jZyhd+8CkCQbI=; b=LkIj4aBEPww3+eQMUKXGr9T9fWdMHLBt4KrBaunQ9m1/J+tywYeU2zlsy+4KqN6m+y pKmJfeEqZj1N0AeVeh61PVfiFVmv8wDvglVVPVpuxijuZa8S5FFcdHwzGnJeTX43AKSc pbembbB4yzW06DJiH7iq6JdkdBS+/1sbkYeTUmx9yu5SVAj3yYKZiKvDhx5KrLhA9Fix HaSg6mMW/B2TWZCX92jukWs7FmTT7AgADBm1hvu3OxoH6sEbVIoRMA5+iwEl5VUuqMDl udurNiVOGJtM0Q4aWjpzH3+owaoOI3MqE2vsOjWwxDTNW5fkeZZDb4z3iD7ZLQ/zJM+I mmnQ== X-Forwarded-Encrypted: i=2; AJvYcCXrirkAMhX3i0ZNsdPK7Vw3PdLDwcZyl0BwTNVahgl4iJWxuQhhcQWASlrrORiZKwrj8/SPCucyj1VNJJzY@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzJiQhDIDIiXh7Yfsc7tinRZq2RKhmIOvnblifkplNvGwk1lsPK GXom5eEE5fxiX2PeCvXdZELLERsOVv2EHO65g6EWjimk0p39SPPy22woLki07a0PTA== X-Google-Smtp-Source: AGHT+IE5vQDjqjEZgSTcGVSoxsrysF9Od223WTQP0PIrmlOIGRNOGpSqEEV7lchH8DMZdT4eAXNSLw== X-Received: by 2002:a05:6000:1884:b0:382:6f2:df7b with SMTP id ffacd0b85a97d-38260b44d61mr3772791f8f.12.1732313828835; Fri, 22 Nov 2024 14:17:08 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:c48a:0:b0:5cf:a22:1a30 with SMTP id 4fb4d7f45d1cf-5d007cc5acdls263227a12.0.-pod-prod-02-eu; Fri, 22 Nov 2024 14:17:07 -0800 (PST) X-Received: by 2002:a17:907:7816:b0:aa4:a814:3f69 with SMTP id a640c23a62f3a-aa50990b34emr385887066b.4.1732313826835; Fri, 22 Nov 2024 14:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313826; cv=none; d=google.com; s=arc-20240605; b=l3ki6TvnMvD/5dgJsxwrPWF3yLHfOdViwU7oP3u2trifbwP0i8vT/uStTqXJbz+SQR 5gk1peNP7fm7jZXNortDKXhzxILgxrgzQ/EN+Eo9F56QKrF7f4RGE/HBYsI439ZdZ0/x FpIYt5r1/FPjNlepAceolyPP/ubdVjO7SuNtyWPWa2xo5C4A3u7vkmLzONAQM1hlxdHH ZgQV9GfdzfwvgyO+j54BcugucXvhbIq/bUiRwmjHlzu1d7fBJC2Y0eYitDeKa+aS45M5 CNAGA7BdUTBNV0cDfMKvqjWjSpFWkNoCEr1F+K6+GXyWcEFrw/oiyt4UgEit5LHGUXxs YUkg== 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=koSu2Qr3uUTmv0FA1/R7W/a8VprfWgcqXI/05k6MgFU=; fh=/4mtQbNQtOE6CKCtX2glb6X+KMMzJuj6HH/pLudJy9E=; b=NbaU26a3zCmq8NQ7DlR/ojzSKhq4Op139n58ss5VJ7PpDqMocdl8/po0U+9gCdkGai dAKRPQPCXzGi737t955rkWGWQR6MqZwQH+RQmBqqCnO1nASjMM/UvwppdX7bIHZRk7pB JZResvxm4NkfaivD87KITC4H+MG/9ASBNCnmXVXaR9CAw9F7NMdVhjWLdi8Uk3J+T7Pm zRl3EytArRmgWQIMm+Mk2XwyyM3KdZKKRQhi4BuPvL+KC/sA2qWYkhXYq+K498R8Pt8A pqDnzcHjCGq98gRvI820IhYdPgJVjqMW7y1FZH/ljNGj5EIx00/tmjjmNI1TLHFbg38C /XEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hKbk7kOt; 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 a640c23a62f3a-aa527369a43sor32841266b.14.2024.11.22.14.17.06 for (Google Transport Security); Fri, 22 Nov 2024 14:17:06 -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: ASbGncs+Sm+y5oSlDMOwKiQKfaVv/1qDY+I6CuJ7lfdws2gMl47TA5RRNDulLKEA8/1 SBa5ulQ1nzOoSak/sbXzHnXhR/q35UAKLrBK7iipGbjQjO0iqgOt8RpjRPUn0vry0FZY40BPT3o G9nRDUdg3FIbd2x6DQ6lSQkbK346TqfjgAWT8mESO4QwVsPlAF3oJsPBrUnCl20twO6dRkeIwmV kUK10HL59Q7exrySVRQiwps3k8dGIxDVIXfj9xlph6tAlJKYLnQph1XnGtExq6Errt61kxCRj7T +oHeEnvC8ulbZxM90y5ZSCtcXqtmnnvkMpc6elo8KHpRKiStFll1CBQPyyqp66Vk6BB5IKhSmDK SdXnJ7bp1dJPQK66P X-Received: by 2002:a17:906:31da:b0:aa5:30c0:384b with SMTP id a640c23a62f3a-aa530c03aecmr47395466b.24.1732313826492; Fri, 22 Nov 2024 14:17:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:06 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Gerhard Bertelsmann , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 10/12] can: sun4i_can: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:51 +0100 Message-ID: <20241122221650.633981-11-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=hKbk7kOt; 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 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 --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/sun4i_can.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 840b972498c1..5285bb0b7c69 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -579,7 +579,6 @@ 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++; if (likely(skb)) { ecc = readl(priv->base + SUN4I_REG_STA_ADDR); @@ -601,9 +600,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) { From patchwork Fri Nov 22 22:15:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3657 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 85D503F9F7 for ; Fri, 22 Nov 2024 23:17:11 +0100 (CET) Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ffb0921706sf1555641fa.1 for ; Fri, 22 Nov 2024 14:17:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313831; cv=pass; d=google.com; s=arc-20240605; b=k4lgOqPSKvu7uWFQ1UPtSu5qIh3T00iecMDP2lAyKt4raPQWI9czjDCvwXWmSX4BcF BU0K+u8KOZvNouX0XksrWnGGZPa1EU35/8N1+z8RpcbDZ1Pr00+kcT/uWs1Z1uwxb3GR b/Luqzh3dTAMQDgfM2llkyA9j0h9iLjoBcLsYPnnn50yc5mIvnWHbGQZnakGIO/by3X/ QJN7VJldEoNXA38YCMbRlS/AW5Gikw3iIhEtm0IUX4H1zFOsrLkTV9Gx+ycSMGGi8a58 Xsg+ehOJx45/qHjjH8djr+8psD5GV1SoipXuqwahTdRktFRknoht1Lj4j8s8gJeaHAdK 9QRw== 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=W/2vxF41Yk58HlLmNuXhlSPubDmdS10Klz3WpqtIflk=; fh=10pQ/r/2kOhr+c796gaF3Fz+qRReesl9U8eLwA51WnM=; b=O8tekz/gfBcuB5dVeq8+HD/63FrZNLYOPkdii3RhRXnXllNsM5glF2GQhSSXejfBi4 VyJGplcwG1iD1O37MJ5GPpu9dwcOT1R//8Aoe/veIXTMNSuYYc8Rn7mG9Y4//NR3HZSb OAoXHLrytlPntSWlrZWOYHpsxDmoHU0jEz9GeK9SJIJicyDaPAhVu6WNLs2qfJRw4IZb dSHbYcG25OO/BingtiDl+8zJ/fLRp1/F7/yuMd1tLjuQsJpOlpgLdFVgKeBfp/MrVkC2 Fmw/kUUpzcqjVNatNKf00IVkFayHqfTCIZ314rYF39z6JglAYGaCaVm0sV2fMKzfQfXq dVWw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NDdUyw0x; 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=1732313831; x=1732918631; 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=W/2vxF41Yk58HlLmNuXhlSPubDmdS10Klz3WpqtIflk=; b=ILrUI9ijELTl2bv4CPKz7ZybG3phPc6tq6SWCqErtz4PVCbYCCp7Vf7XJfA2QA7y+p k4qEz9bEj/sJsiT44wZTNXAL3Hk8glySuKynoFaTB29CjNFe86YwAyB7vWNNZv1YrPxG 3wuwg5SC3t1O+msU4s42kI6Y8+dY9YQ/rlvGw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313831; x=1732918631; 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=W/2vxF41Yk58HlLmNuXhlSPubDmdS10Klz3WpqtIflk=; b=XVkzoR5GpzhdKlIZto/tLpT9vdA343EExpuHGFM1/9fia0DURvmFbFUR7zqQCfHryA ZoIfvvxWhCsgl02dNTu1P/trUwlpw856gGzILhlySnCv6vGlrb27vqhJFyTsNrqChvbI R7k0OdJGgtsKdFX94cP7xe7KTiCYo7rglMbvP8RNUNKoPK88/b7zs39z52O3V1tFV5tk mCMB8im61mlkWr1P2xYiUWDkq2XTX+OPS6K8XfT9OoBtIfsvKrd/3c42juAg6rJYdpAd BZNUgUR4EFd2uWsL/YLP+eV8TQHiCJfflQCqkglpR6uHwgHoW2YEtFvQh2oSF6FRRAS/ t/GA== X-Forwarded-Encrypted: i=2; AJvYcCVw7A6iFI7JRfMqdhyGtIxHBux0z7CXsSWlhyh8kOQNYUSlhjUuo93f6Sxbi3IaImwlKuC9OvP8pP1n7fdq@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwB+/qXWqFG1cVS53+C+ueWoysU09MgP0GdQik7Uf/utB0cwlte ewTG5xgWIFyKrWDWpNZ6kpiOS13/1vEEdHy2INvU28P9q4i69wsYSGP4gTjeqyJ1lA== X-Google-Smtp-Source: AGHT+IE+XH5wU8spxur0xr94DAHA7fNB0DaLmabDNrBY9+UaVlkdXsAvVI2I7dCv1MbMvRsZSSjPYw== X-Received: by 2002:a05:651c:985:b0:2ff:95d7:9ed2 with SMTP id 38308e7fff4ca-2ffa716ed4fmr45453681fa.32.1732313830817; Fri, 22 Nov 2024 14:17:10 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:651c:1199:b0:2ff:a75d:603a with SMTP id 38308e7fff4ca-2ffa75d6186ls1979441fa.1.-pod-prod-05-eu; Fri, 22 Nov 2024 14:17:09 -0800 (PST) X-Received: by 2002:a05:651c:b20:b0:2ff:7d2e:f4a2 with SMTP id 38308e7fff4ca-2ffa7124e89mr40076771fa.20.1732313828855; Fri, 22 Nov 2024 14:17:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313828; cv=none; d=google.com; s=arc-20240605; b=Ww48ImpoLuxIaJnpsFLpKcmzt7r5KWtMZcdzaaMGqjmd2NfqqWxPWVs7KZaLDnpLC+ FNAJBZx6RnBHvN5CB7flW0UjyvQbEBVV4NtW3JCoaBYZG/jvOj8KzO0qvOlT12ugcFJ3 u4ZLhBrLoecgO2K+ud1Jg3by6NLdSM6c8lnu43Yl/HFy31gs080x/4j8hKvSIKvIt7JG +DOE9xcyVjwQD+InW7hyoDaec/BcfsqDldjxD6ep/L/ZoJHJYJckgFiDo3ctqYH9VL+f GEsaztBgyoeC+okmgYq5BaPh9CkI1bJJUuWV5myhiuxPDa5P+vWlkshi9R1jcp/0+nls FIyA== 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=zeHUsvNMH4naO2lNY0rPoAp0glNUJp2xtRk2ah0U1WQ=; fh=CmKGVlYv+zD+LFzklpA0QBH9fKCofsMTPpneubnHAkw=; b=dOL5xCvWNr72U967kWc3vhvRaVpFwW7aiGmiKOmhdHZv9PSP9YiNxSNzIZ3cvOClEa Wk4rYTKKv/CUuCaVc7J4Fkr/DwkBBbem6WFkxqs9LijZ/Dx9ffGBaqdW+juyWJUKXer8 ry9cDjeMNaUDFhW+NA0e6xGQE9INXJUz2ulGNNT6uRnGbq84rOnHIKTDV5e4IWegixUz vdl2gjip6VOiwVKzbCNjNcb6Io5ESCHUJKe2z0Z54cnsL7BawivqNsoyltND+53DydPE 3+i8V657VyuZfUoWAhXQ3oGO4u3L1GWJ2N/cUwi8IvFE9bF0mPLNtOmvzPSRwJ3uLUUQ 1S4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NDdUyw0x; 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 38308e7fff4ca-2ffae685ca0sor3351841fa.0.2024.11.22.14.17.08 for (Google Transport Security); Fri, 22 Nov 2024 14:17:08 -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: ASbGnct0WuyEqeteNJ9E+ZFE1h7FhtLcPXJ6/PrgDQz7H3zWYDvMTPySeASKUnXldXv Y39fUL3KMVzQCMJcBl2CdiZlQlt5vklG7RjeNsUoWc6ci0jHf4XEjkooF0ZE1NQbR42qgZeRSdE UxePNhtcW7yI1OuieeSDjKFsEoFRhGxIhn42ugCv6BwxsfRkTlFAtkm7suJPp9C/JwLvFcyMp6h siVuVkMdNfITflZ0LJS/pyYYf5fhoZ2d6KUZiwHLCMMPMBsBTHgBJrlWEdVlHEOeJm9/goJOdeH 1wHqthPHdTz+nel5IITIDupXHVoFxxe9Rh6C/UI51HiLeJTkYkH9cS3drGG6vQwHqc9Z5Ls0bgO YFcGpNZFkAsvmlaoV X-Received: by 2002:a2e:a58b:0:b0:2fb:36df:3b4 with SMTP id 38308e7fff4ca-2ffa7187eb1mr50418561fa.34.1732313828318; Fri, 22 Nov 2024 14:17:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:08 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Marc Kleine-Budde , Sebastian Haas , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org Subject: [PATCH v2 11/12] can: ems_usb: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:52 +0100 Message-ID: <20241122221650.633981-12-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=NDdUyw0x; 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 ems_usb_rx_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/usb/ems_usb.c | 58 ++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 050c0b49938a..5355bac4dccb 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -335,15 +335,14 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) struct net_device_stats *stats = &dev->netdev->stats; skb = alloc_can_err_skb(dev->netdev, &cf); - if (skb == NULL) - return; if (msg->type == CPC_MSG_TYPE_CAN_STATE) { u8 state = msg->msg.can_state; if (state & SJA1000_SR_BS) { dev->can.state = CAN_STATE_BUS_OFF; - cf->can_id |= CAN_ERR_BUSOFF; + if (skb) + cf->can_id |= CAN_ERR_BUSOFF; dev->can.can_stats.bus_off++; can_bus_off(dev->netdev); @@ -361,44 +360,53 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) /* bus error interrupt */ dev->can.can_stats.bus_error++; - stats->rx_errors++; - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + if (skb) { + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - switch (ecc & SJA1000_ECC_MASK) { - case SJA1000_ECC_BIT: - cf->data[2] |= CAN_ERR_PROT_BIT; - break; - case SJA1000_ECC_FORM: - cf->data[2] |= CAN_ERR_PROT_FORM; - break; - case SJA1000_ECC_STUFF: - cf->data[2] |= CAN_ERR_PROT_STUFF; - break; - default: - cf->data[3] = ecc & SJA1000_ECC_SEG; - break; + switch (ecc & SJA1000_ECC_MASK) { + case SJA1000_ECC_BIT: + cf->data[2] |= CAN_ERR_PROT_BIT; + break; + case SJA1000_ECC_FORM: + cf->data[2] |= CAN_ERR_PROT_FORM; + break; + case SJA1000_ECC_STUFF: + cf->data[2] |= CAN_ERR_PROT_STUFF; + break; + default: + cf->data[3] = ecc & SJA1000_ECC_SEG; + break; + } } /* Error occurred during transmission? */ - if ((ecc & SJA1000_ECC_DIR) == 0) - cf->data[2] |= CAN_ERR_PROT_TX; + if ((ecc & SJA1000_ECC_DIR) == 0) { + stats->tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_TX; + } else { + stats->rx_errors++; + } - if (dev->can.state == CAN_STATE_ERROR_WARNING || - dev->can.state == CAN_STATE_ERROR_PASSIVE) { + if (skb && (dev->can.state == CAN_STATE_ERROR_WARNING || + dev->can.state == CAN_STATE_ERROR_PASSIVE)) { cf->can_id |= CAN_ERR_CRTL; cf->data[1] = (txerr > rxerr) ? CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE; } } else if (msg->type == CPC_MSG_TYPE_OVERRUN) { - cf->can_id |= CAN_ERR_CRTL; - cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + if (skb) { + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + } stats->rx_over_errors++; stats->rx_errors++; } - netif_rx(skb); + if (skb) + netif_rx(skb); } /* From patchwork Fri Nov 22 22:15:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3658 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 68CFD3F9F7 for ; Fri, 22 Nov 2024 23:17:12 +0100 (CET) Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-53a0b48e8d4sf1948121e87.3 for ; Fri, 22 Nov 2024 14:17:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313832; cv=pass; d=google.com; s=arc-20240605; b=dNU71ukQJWhONZvIAzWQtpYbdCcJhgWn0muTG2TgvKczag0f5E0SJQu1PHY+s6NLuA oyg7qfwsHAZJuQzxIJ4oGXM7D+2ZmtLBq0C/wH6ErkVAAx+mIxElxNg/tTFVLHvruqUZ n8L1a+SMzF3Yp452JxI6yF0lIBMtm6EzXovSwz991nn2o0sx6N5H+8YC6RE++DGT3HgK 9mmEarvv2by/NErQ54kLhIfN73Ddi/SmWE9XyBUEXAeoTmS192Ty+Yl898hvX3fJcL7a udhg3+11BpYPVLeKRT1Gxu/j8wEiq3ggh2LlSVgk1t5g/upm44iELlMebwrF4eDLFKO9 Thww== 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=k+2a08jcXB6rX7sxPfd2OdXl1QT105tpiNIkq9x3C3k=; fh=vp+HoebejajfR21BeeZxRLrDwTykWLBptLq2rr5yJlc=; b=g2s9N2GyA0eSHfmMJxufjs/EdQWkI6ZuEByIoW5Odzr7xZhZMqvSZ6tOvh77hAX9s/ D+LuX2vkDM2W6Ng/c78qp80aex0jjoDyYQprJszvMXUGEAyFlYdyXrhFLts7qyXsoV2A ATCOeay8IiGUht7EHfr1cKjn/4GuWvuWj+avZylj3wqIwJV8zu+qX47dLInefhLG0UU4 hCKQ0feBH7fGwibnIwBp+l7x4c2fPBl/iJ8mf7emkO2z+R3+mVNFJxauEm42ZWwnVslv f5px0IjTWooRNvM3CersikeksHsWO5PxrZAnx2oCbewdR7Rewp9gq7NvXHCzsl/4HKho J9CA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=novn8MBa; 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=1732313832; x=1732918632; 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=k+2a08jcXB6rX7sxPfd2OdXl1QT105tpiNIkq9x3C3k=; b=BuXfNko9f9VGNC/htNl8IUF3iRQlxD8ehRRqnxBCFQJhtB5vDtWJRkG26wdT1ZCduh zEEC6llnvikgKdFX3bzvFjSS5adUYfyLC3UMlbrq0gguJ4XaYIIhQyorg9wMaZD/f7gJ gBPtSJpScfb1ty5KCPaBr+CSukv195rIV4pR8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313832; x=1732918632; 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=k+2a08jcXB6rX7sxPfd2OdXl1QT105tpiNIkq9x3C3k=; b=sU2KEwm/Cus9DifHQBbqe4QMWC2KuytoLik5ZdSu8ryV+onxleDgLS+L+sWqMY8EQh 8/qZd5ercZYxapUDrzV+wE+JOd2xlra79pllG12kqE8RJMbQt27cA6HzU6+bGfLRAkTp mfhSMg08LchCj0pMgHnXGIlFnLB7L82yOQPildjQjLnPPRUVkkMFfpGFbdcvhK75lf16 pB2NKhrgkJVpFlwVo6V9c5bR/DE4aMlI96xLMaUbxkWRmGYFciJsDMcKrB8wdBgewb0J sGLEvVXS3Hg9JcvnvdhUoh4FSi/5UGrXQy9LEDLO6Kr8uDISbDLsZs7HjGbaSesevmtP ESbQ== X-Forwarded-Encrypted: i=2; AJvYcCX7IyKlDU7mj0R2CCzXXaQTkI8zBSzO9hL8OZI//L3+FkJjMDpbBQIU1mrMyFwk0e4k784QHfmvEj+hD6mp@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxPu+zXA8M1oY9ui2oTCgDz7LXUNFxX0fXe6FTF+tlPbrzmM/io 6If3qgEqU77nQdRQomYXBEqZJq/q1kHeYr87gAW8oEhzkha5GQMrwIEmd/IWc2JPPg== X-Google-Smtp-Source: AGHT+IFeVct8Gr88fHm7xcojqnf5sJv4gOJZfzPBp0bpjc7bHwL106Iiv5v7n/JnKL9N/zbgaOZYIQ== X-Received: by 2002:a05:6512:4011:b0:53d:d665:c702 with SMTP id 2adb3069b0e04-53dd665c728mr2434611e87.18.1732313831801; Fri, 22 Nov 2024 14:17:11 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a19:ca5d:0:b0:53d:d3ec:eb4b with SMTP id 2adb3069b0e04-53dd3eceb98ls528447e87.0.-pod-prod-08-eu; Fri, 22 Nov 2024 14:17:10 -0800 (PST) X-Received: by 2002:a05:6512:2388:b0:539:e9b4:7ff6 with SMTP id 2adb3069b0e04-53dd39b0eeamr2439915e87.45.1732313829793; Fri, 22 Nov 2024 14:17:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313829; cv=none; d=google.com; s=arc-20240605; b=Rhx3yrjZ002ZOXCH8p9cfS376ZTXjb8KIUH0+lB+96wL4JhlkUWRibHd9gE50ri2Pf Bm9Y4vn/RZJMrueDzJS8/vp3OBtJgwXqbPwdh47dp6Rn2LyQt1CJoCxiQCkbWUQiw6Rj XtY+IG0uHCVli5Yo7JkAxirJHnrAkCcUpwizopbChoZNVkjyVVxuGrZcCqu/lCL+sQXk 0h0DlrSM+IfjaGwa6cx+RY5CPThy4bcsnYLTa1LCkInLc200X5SU9U+BqfBuP6che77P XtK31LNvNtI4H/eF0UxfsObQD4B5qqq9fVk2fcCRbqljxUi9+BPHI6Gi+cjCdlWfs4WJ fAzA== 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=sIjLTiSdjHPZdtn456NOY4iL8rLUfrRnErOspsYBZzw=; fh=c79H9AfaeJ3KY/StxbLxwz9s8nv7t3/PFEys9J8KSwE=; b=EOr48rqTvyaaYhsIR4Qo8cH83w/QkW/fisZZfCoq2Znq1ApQTEpjAV/S/HQOzzIlXy 9jsPcBQkeedWzfWo9Tbb6hk5LA1vRUi/S8ci0xSbLOZexcZFNa/9Mbif8zsMkFkutV8Q 53yOpdT+UNJaG5hVdkrUbCleJ4K/Ypn44knQkaLo549OFgRUQ0uCOxrwU9L5KETUx2wd OoCQ27nPTG9mj6cBh5TkN9oTyp7QR2JAx2xAtRpGyBAwBU3nFEpJ2j9PC52rFyu+fLk6 z/0CI626yt8bQdC8Sx3wuoWYdYsSoqioOVKfCN/wVUYrGwlfxb6rsQENnysEDorbDhUj 2a+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=novn8MBa; 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-53dd24ae655sor930205e87.10.2024.11.22.14.17.09 for (Google Transport Security); Fri, 22 Nov 2024 14:17:09 -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: ASbGncveDTsCSu7N8CEac8OCUSVkUq3Ze1rTLDWi2mE9OxhiZ21zSsv/iWk8/nvJLBz FUcIHt417BMc0PuESAtLW7NqW4WlSN5ib16dHFSIOVNH6vi6kjlVINNuzh/C+e4bwy33lbmOYi7 zWRYUAL22pfjoPW6RaMHw3F+h/0OfnhACb44PUKTn4opXBf0IlQ5ar2XUiiH4lWCMzwu+nN7jqa VQDevcQjo1ylTg7j2ebf/WDDcSHlxh/obW9xNAeXm2L5SYJ3gJm6w+kKQ6FtzWFVg3zQM1sEYpl Ld+PfZkTT17mRcLESPR/2HN+e5QSrMUi4B5mgl9BV//06ms2KUpTQaQTJBsOuQqIiZaXo6NFxbV 5jcN9mgUjqV7RB9cJ X-Received: by 2002:ac2:51b5:0:b0:53d:d3ff:77f6 with SMTP id 2adb3069b0e04-53dd3ff77fdmr2299001e87.46.1732313829337; Fri, 22 Nov 2024 14:17:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:09 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , "Ji-Ze Hong (Peter Hong)" , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 12/12] can: f81604: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:53 +0100 Message-ID: <20241122221650.633981-13-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=novn8MBa; 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 f81604_handle_can_bus_errors() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support") Signed-off-by: Dario Binacchi --- Changes in v2: - Fix patches 7 through 12 to ensure that statistics are updated even if the allocation of skb fails. - Add five new patches (i. e. 1-5), created during the further analysis of the code while correcting patches from the v1 series (i. e. 7-12). - Update statistics even if skb allocation fails drivers/net/can/usb/f81604.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c index bc0c8903fe77..e0cfa1460b0b 100644 --- a/drivers/net/can/usb/f81604.c +++ b/drivers/net/can/usb/f81604.c @@ -526,7 +526,6 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv, netdev_dbg(netdev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; if (skb) { cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; @@ -548,10 +547,15 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv, /* set error location */ cf->data[3] = data->ecc & F81604_SJA1000_ECC_SEG; + } - /* Error occurred during transmission? */ - if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0) + /* Error occurred during transmission? */ + if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0) { + stats->tx_errors++; + if (skb) cf->data[2] |= CAN_ERR_PROT_TX; + } else { + stats->rx_errors++; } set_bit(F81604_CLEAR_ECC, &priv->clear_flags);