From patchwork Sat May 8 12:36:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12246019 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B565BC433B4 for ; Sat, 8 May 2021 12:37:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A4BA6112F for ; Sat, 8 May 2021 12:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbhEHMif (ORCPT ); Sat, 8 May 2021 08:38:35 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:34957 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhEHMi2 (ORCPT ); Sat, 8 May 2021 08:38:28 -0400 Received: from localhost.localdomain ([37.4.249.151]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mt7st-1lQAfW44in-00tUmb; Sat, 08 May 2021 14:37:20 +0200 From: Stefan Wahren To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 1/3 net-next] net: qca_spi: Avoid reading signature three times in a row Date: Sat, 8 May 2021 14:36:33 +0200 Message-Id: <1620477395-12740-2-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> References: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:Ei53HZbPR2Of5JrXcoi6GIAT9nXpfTGZXSwI0OaBC2M0etMyT3j Wx19OQt6ZkZ2U4iWjOpmd5m59YHY6jXE31ME156q5ToRSHpdcpsaMsm3Rnkbzr5AoQoVabL 8XvJaQVPOdf0Tp4qjdjun507RBtRoPWkSqAVuBtKb8fmMXU0XvWC3gz6VAQz4P/NbuQNH1C q6EqlvI5WVW5VWrWzLHqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:95OEBbwDT6w=:jqZXOPsGiQimWZ/Pln/1mK RifMA4ePIvNoQ/GpPPEQ2Ji04D6RAwJNXNmEID0T/L1R0Z082El26xCjk11k+8tBWIgJZSLQP N7K7chPnAFFs8OTgtMHd58Aavl6/8M6yPG6uKL3Q8mGmiXMPjw6ftn0rIIFK2l/wLf+FAD5cw 9QcoOnZ7Obr2d2WTagTrVCECdcyTyUJ+Blczzpuu+e0IRVl/7ns9SHHgUfRQ8r7FmnkZ61d6v GJd+EXBv/wrPtd4Myb8+E4BmUbFKvYYcChd8ScYsq+duq/urHb+NWvnq4pgdlDq8YMaj1wxL6 +ZGaDfr5bFL06DHNkH6qZ2uaVODZOUHaRyF9dmbx/rjJUspVjcMjFYjJRPBDEfoBz6y2qCxZ5 bgmj2PAfmMp3w2AisxnGY8J8ahgdl3BSNBnZY1nqTooMW7Zj/ES83Eg92uJh/uOPwT/gFYoia f2BOiAy/gisXvl0a/6NtLgxDBSwgF9leGVk37EdNlbq7V9I2J9JpaAXUWgXmpejsahTIKdtmN eeYbAmzG+NPDsewVjZTPRc= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is no need to read the signature three times. So bail out in case the second check failed. Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index ab9b025..3e2a54c 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -506,6 +506,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) if (signature != QCASPI_GOOD_SIGNATURE) { qca->sync = QCASPI_SYNC_UNKNOWN; netdev_dbg(qca->net_dev, "sync: got CPU on, but signature was invalid, restart\n"); + return; } else { /* ensure that the WRBUF is empty */ qcaspi_read_register(qca, SPI_REG_WRBUF_SPC_AVA, From patchwork Sat May 8 12:36:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12246045 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69555C43460 for ; Sat, 8 May 2021 12:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 409B161466 for ; Sat, 8 May 2021 12:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbhEHMil (ORCPT ); Sat, 8 May 2021 08:38:41 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:59497 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230449AbhEHMia (ORCPT ); Sat, 8 May 2021 08:38:30 -0400 Received: from localhost.localdomain ([37.4.249.151]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MgNtR-1l2T5r0vyp-00hrox; Sat, 08 May 2021 14:37:20 +0200 From: Stefan Wahren To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 2/3 net-next] net: qca_spi: Avoid re-sync for single signature error Date: Sat, 8 May 2021 14:36:34 +0200 Message-Id: <1620477395-12740-3-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> References: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:JDMHD3Xez64dGDNUkMvgbFgWaO4iuZrpEx4rD20kyA+1sVWWcFc 5IvGOlETLrCuO21fxSXuUnvHYRKlig6fRX2S9/9y1ndmHxodv+0mAW6i5RdCV5vNV4Zh/3y FwqBIrP523riHRSseIS/ax6qxGHUeLVmixu9bs/ozXT6BKOOlJ59gD5fvLumGqGUuC0bGys /838T1AOOgB9/Av5C8jaA== X-UI-Out-Filterresults: notjunk:1;V03:K0:XDS+GkRFnyk=:V2Clxys2Id65tkJUZzPhPs HXt8rvLniUv6SezGrFbCWWc57I3DcHrs1VCkOkR97R9NkaOx1IkwlVouXfv5CCjYkok0taxyC 0cDaWUvNsIVm4BJhlEmR9zKCr8JRpexf93Z1IexaYLMfjksmgfHwOCtCxOE262gIwbpG5puH7 CPbnhieDQ9gnGk9UaAf9C+GsQxXMCAbkTiv8vcEd4mgRJteAAnTJvX+/AfUs3mlg0P/DaemyM 9T9lfZJ7cKt+L5EKTDIrsS15NxB8MjDEdTL0wsv3kWLMcfsCt9hRetJ61pHPa4uReUaNR58md zmB3Turx6o0fkhVfbPlu1bEPn/NE8oGOrcOm6IyGnKeBozijanBCReJe8ju8ZjOH0ZCGVvNE6 QA12uSmc6nKaNriz3TtobPMYheWVIQ+Ttg1eItkEG+u2uThu/tPp2cYSGkL6TT6S+v6kNcj4V ldIsS7rfnLcCya2iOuqR4P+WalvPZmoYAL4Adz0krmlfGcDT/WN2eCKNpx+g37PmwbHEUc45B RZCzMTSB5+hy8YZ/HJVl0g= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Setting a new network key would cause a reset of the QCA7000. Usually the driver only notice the SPI interrupt and a single signature error. So avoid the whole re-sync process (possible packet loss, transmit queue stop and no carrier for at least 1 second) in this case. Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index 3e2a54c..0937ceb 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -524,8 +524,11 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) switch (qca->sync) { case QCASPI_SYNC_READY: - /* Read signature, if not valid go to unknown state. */ + /* Check signature twice, if not valid go to unknown state. */ qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature); + if (signature != QCASPI_GOOD_SIGNATURE) + qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature); + if (signature != QCASPI_GOOD_SIGNATURE) { qca->sync = QCASPI_SYNC_UNKNOWN; netdev_dbg(qca->net_dev, "sync: bad signature, restart\n"); From patchwork Sat May 8 12:36:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12246017 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC58C433B4 for ; Sat, 8 May 2021 12:37:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF09B6112F for ; Sat, 8 May 2021 12:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbhEHMid (ORCPT ); Sat, 8 May 2021 08:38:33 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:51269 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhEHMi2 (ORCPT ); Sat, 8 May 2021 08:38:28 -0400 Received: from localhost.localdomain ([37.4.249.151]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MHWvH-1lk5JZ1wgb-00DW9t; Sat, 08 May 2021 14:37:20 +0200 From: Stefan Wahren To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 3/3 net-next] net: qca_spi: Introduce stat about bad signature Date: Sat, 8 May 2021 14:36:35 +0200 Message-Id: <1620477395-12740-4-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> References: <1620477395-12740-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:hTAdZudLB0O1qGOMwLsXCKisf+g+CQ4SWZ7xf+WmX4m1+2zAg2x 4Sne7TOergYWAb2dwZ9BhK2et90Rqq/weS1y5NaWLEKsRA2FJMxN/B3cIfbFrXjwwc7P4V7 +6jAY2/8VaA8gpYKALUlWRrVtBC67xfOwrPy+WLXF0hYpPNjaJf/7mQYg7man4E6dPhVGXW 8+lPPo8HNWBCOVZRvOV0A== X-UI-Out-Filterresults: notjunk:1;V03:K0:prqYyrZ+S5M=:wxmBbhxfwX4G3CXoZeCxkN pJ71xzZ4+Hh+TOuCRYk29A2iFfsMdyOhx5pn0m+5tx2MM8rf8AUe3f+ML56wSO2teqGVm7ShR KHlqiDf6D7I7nyeLMweQuplPJR7TZj/mBDlCNjmJB0pY332vmNxn8rHTiqXw6eObZrEJZFvPk trBP7mka1tm3jXooDP5NbuRMgSNSJqo2X3nHS7P7feVmoiwitZFJmHVnnDVCpUNDd+ZVnzIWj PJcz0giMezzR+CRQhnkm0fla7ltNyGjnQakuINOm4F8s8ljHwWNsy4WvHKe1D8CkkXudgnvWb Ls0rTt3l3o+wo0xR6bVsHPxiAn02YUFgfhzEV+GLKLmhXeJh/eQfO0zYJT+96szh5h4f4ktZW k7SiiRHh0mqpP6q8890DbBTzpOZYN0bn6MASt7wucqbUbPOSZj3P+RuJK+yCFUfWZ0fRawXiV iUrIFLF2MbLaqzX1nCTmKRBGYMso9xh9vTOX65+oLO/hJXE7+DqXWVMKG2aoKnYX+Y+QCkhsm s4pOMW3xoCdGS9q4KUn8ko= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In order to identify significant signature issues add a new stat counter, which increases on bad signature values that causes a sync loss. Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_debug.c | 1 + drivers/net/ethernet/qualcomm/qca_spi.c | 4 ++++ drivers/net/ethernet/qualcomm/qca_spi.h | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c index 702aa21..d59fff2 100644 --- a/drivers/net/ethernet/qualcomm/qca_debug.c +++ b/drivers/net/ethernet/qualcomm/qca_debug.c @@ -62,6 +62,7 @@ static const char qcaspi_gstrings_stats[][ETH_GSTRING_LEN] = { "SPI errors", "Write verify errors", "Buffer available errors", + "Bad signature", }; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index 0937ceb..79fe3ec 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -504,6 +504,9 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature); qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature); if (signature != QCASPI_GOOD_SIGNATURE) { + if (qca->sync == QCASPI_SYNC_READY) + qca->stats.bad_signature++; + qca->sync = QCASPI_SYNC_UNKNOWN; netdev_dbg(qca->net_dev, "sync: got CPU on, but signature was invalid, restart\n"); return; @@ -531,6 +534,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) if (signature != QCASPI_GOOD_SIGNATURE) { qca->sync = QCASPI_SYNC_UNKNOWN; + qca->stats.bad_signature++; netdev_dbg(qca->net_dev, "sync: bad signature, restart\n"); /* don't reset right away */ return; diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h index d13a67e..3067356 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.h +++ b/drivers/net/ethernet/qualcomm/qca_spi.h @@ -75,6 +75,7 @@ struct qcaspi_stats { u64 spi_err; u64 write_verify_failed; u64 buf_avail_err; + u64 bad_signature; }; struct qcaspi {