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);