From patchwork Tue Nov 21 16:30:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13463360 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="FVCy+rVG" Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D89198; Tue, 21 Nov 2023 08:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1700584228; x=1701189028; i=wahrenst@gmx.net; bh=gFO3xN70nhDuQ7SY9QhsM0qxlVzj4P+YuVI4yCUqFa0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=FVCy+rVGHnTnh+4TAcgF3TPHxW/oZGGXiCjNbEpbt8O/b0phxICtrrOmWNSWoGG5 lBfbsxfDeqCACkiycmECrw+Sge3o/7CqHzLdsn2vqdUR38ddlukKjBQsCwWL+Dq61 DtdyLLF+sPOmgOnsKnuH9hG4MLzAFBVs98YLuA3kQu/tWVrLo0LXH3ohE3f7KaepJ MjqEL6G8GIFCvtfea18o0Jz/jAiUAEqNaBKAfsCgtN31cTZA5P1WRwM82pySHZPlr ENY9d6fAGaLfNl5YmzttIOWHU2PsJ57HAVaAVHQEEqZlqN2QO90EYZZyN8Q4B6li1 sq/+05egqArxCmgrZg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mnpru-1rhIIY1S9a-00pKch; Tue, 21 Nov 2023 17:30:28 +0100 From: Stefan Wahren To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Lino Sanfilippo , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 1/4 net] qca_spi: Fix SPI thread creation Date: Tue, 21 Nov 2023 17:30:01 +0100 Message-Id: <20231121163004.21232-2-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121163004.21232-1-wahrenst@gmx.net> References: <20231121163004.21232-1-wahrenst@gmx.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:R5Og/3TXSv+EbNnWtBnjT7DeFeB/d8AD9ioj/3gA+uzLn+SXZ+e lagkkN/BCvhb1QAZEDH/hWfr4iBkOzpOb204fxnwFHTRixAgdTpPstG85IGTyr+T0QAYHPt 6krSePtsml1uUDA7CPyixNf+fEurH8FrJJBAGCqyM54m736UC38W4e8KjmunN7FLB3wNicc OkeyMVLM2j0ajBD+ymZIw== UI-OutboundReport: notjunk:1;M01:P0:mRSwnWXLY2I=;TWO2yF5JCazzVqnIR8NZylxkOuq VsOnTYCzNupNYYYa06HB+VsPVbJOaHcDc4vnx4+8BZH0ycNqKaJBU4kWfCzTUM6W1Kss1nLJt Bi8gUqwdAAwTs9IdMtukWLb4ZKSjihhDhpE89Yyau0nGiKfj+RSkz5Vb5E7rrwXugWxeI968z 6wX4yOabTcTAApesXCu1Wg2A6y1KCy8lFeipMGS3aW0x51G24QbLqwZqoznfWp5JiX6G6uRky g0FAGRMgDN9LSS7OfsvKuu9oLTREBlY2C6OBF943B1BJ1T29H/LhnMH/GEa16JyQRRszFOHOd BEtam9ml0sY1ulaMcpbkYAdNt726MRp12VC/u7hf4Tesdy+8IopTvgHUyu8U34Rz2Nhamv5b0 gz2GM44OeGUnR7+//ZVsdiTBNhfZKHXFj7yaJdVoYjC1Glb+qnjYS5BHdpBxHScOlNzCRdal6 mILvp9oC/0WntHpZ/wbhmg70o1t5+WWTFvdx01TeE3L6FKJjc1kce8SFPrd7twKT+xgJ1pXVK QUQteoXH8gW44WNieQmmWhBWr6CmULKEZfBi7RuAenpLhhiFnyof4P/zlI9o3EIqNiOmuCV7A Z+i7GNP9/HnA9u7V+dhlFg3orD3qd2gkKjtDDXcKtIUkC/x3fpTHJgxQqf9MP9gQM1mAkB0/9 WFLJalhQQOfMKWIsiwCoDap8XCvYYiGGfzkMCpXLAR8iNslvGlT/enDnFIfI4ndhCbb+67by5 I6rhNrS9moUyTHnoyyLH73gZG8GhyP4CccyOW1TITL3ZMlbi5ZrZUt7lD/XvC/xZLH2HXZ0Cg w+uxD6NAKaHKHAIbJOQLpYPdJByyNPJrFM3xvteGMFPN61jYIdJ6yQtLxVuuYQqUfD8Ovz27W LXvfUFlv5DTuyMM/nzK7jE71ZnffwZ5jayHjJttEcv4eo7X4VQ5Gsa/K5ZlvIThlrIVAsaJpX FOzs/A== X-Patchwork-Delegate: kuba@kernel.org The qca_spi driver create/stop the SPI kernel thread in case of netdev_open/close. This is a big issue because it allows userspace to prevent from restarting the SPI thread after ring parameter changes (e.g. signals which stop the thread). This could be done by terminating a script which changes the ring parameter in a loop. So fix this by moving create/stop of the SPI kernel into the init/uninit ops. The open/close ops could be realized just by 'park/unpark' the SPI kernel thread. Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_spi.c | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) -- 2.34.1 diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index bec723028e96..b11a998b2456 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -580,6 +580,11 @@ qcaspi_spi_thread(void *data) netdev_info(qca->net_dev, "SPI thread created\n"); while (!kthread_should_stop()) { set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_park()) { + kthread_parkme(); + continue; + } + if ((qca->intr_req == qca->intr_svc) && !qca->txr.skb[qca->txr.head]) schedule(); @@ -679,25 +684,17 @@ qcaspi_netdev_open(struct net_device *dev) qca->sync = QCASPI_SYNC_UNKNOWN; qcafrm_fsm_init_spi(&qca->frm_handle); - qca->spi_thread = kthread_run((void *)qcaspi_spi_thread, - qca, "%s", dev->name); - - if (IS_ERR(qca->spi_thread)) { - netdev_err(dev, "%s: unable to start kernel thread.\n", - QCASPI_DRV_NAME); - return PTR_ERR(qca->spi_thread); - } - ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0, dev->name, qca); if (ret) { netdev_err(dev, "%s: unable to get IRQ %d (irqval=%d).\n", QCASPI_DRV_NAME, qca->spi_dev->irq, ret); - kthread_stop(qca->spi_thread); return ret; } /* SPI thread takes care of TX queue */ + kthread_unpark(qca->spi_thread); + wake_up_process(qca->spi_thread); return 0; } @@ -712,8 +709,7 @@ qcaspi_netdev_close(struct net_device *dev) qcaspi_write_register(qca, SPI_REG_INTR_ENABLE, 0, wr_verify); free_irq(qca->spi_dev->irq, qca); - kthread_stop(qca->spi_thread); - qca->spi_thread = NULL; + kthread_park(qca->spi_thread); qcaspi_flush_tx_ring(qca); return 0; @@ -807,6 +803,7 @@ static int qcaspi_netdev_init(struct net_device *dev) { struct qcaspi *qca = netdev_priv(dev); + struct task_struct *thread; dev->mtu = QCAFRM_MAX_MTU; dev->type = ARPHRD_ETHER; @@ -830,6 +827,15 @@ qcaspi_netdev_init(struct net_device *dev) return -ENOBUFS; } + thread = kthread_create(qcaspi_spi_thread, qca, "%s", dev->name); + if (IS_ERR(thread)) { + netdev_err(dev, "%s: unable to start kernel thread.\n", + QCASPI_DRV_NAME); + return PTR_ERR(thread); + } + + qca->spi_thread = thread; + return 0; } @@ -838,6 +844,11 @@ qcaspi_netdev_uninit(struct net_device *dev) { struct qcaspi *qca = netdev_priv(dev); + if (qca->spi_thread) { + kthread_stop(qca->spi_thread); + qca->spi_thread = NULL; + } + kfree(qca->rx_buffer); qca->buffer_size = 0; dev_kfree_skb(qca->rx_skb); From patchwork Tue Nov 21 16:30:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13463358 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="fXQPRrdU" Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B74197; Tue, 21 Nov 2023 08:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1700584228; x=1701189028; i=wahrenst@gmx.net; bh=CBjZ1PW1pxUGSomTdCbNWsOlGvLT/OTWJhsIn7TxVJk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=fXQPRrdUbLmWd5SEN+Zf4z46r+L/gfzJE/8OWv+/dDdV6/5akSHNgnSBDEj5rpLn 6Sa9bT7fj/Rswrdm16vv2er+XZBuU0UEOE0OnzWOoLLSkm/WsEIomIbsB+8/KcRwE nT1SUoSGvyThL3PvwaM9JXw+za8g15e8SoXu+BI4fjt+rw7agSpW9PzE95ZDSjYM2 HkkV2I//gZSEYd881wI0n9D2fnP5SOB4L2ee6RJqoC81Ij2mKL1TQ+oYrFuny06mR jganErdUBWYeXzWODcaiHXwiz6PU1KeAgqqAC/Koi9aPk9YGL7WKM62WHbCwipqfp pKUqDqC1iuI5fUisVQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N5mGB-1rPtuB2t91-017H0w; Tue, 21 Nov 2023 17:30:28 +0100 From: Stefan Wahren To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Lino Sanfilippo , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 2/4 net] qca_spi: Fix SPI IRQ handling Date: Tue, 21 Nov 2023 17:30:02 +0100 Message-Id: <20231121163004.21232-3-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121163004.21232-1-wahrenst@gmx.net> References: <20231121163004.21232-1-wahrenst@gmx.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:hZCuJB5l+X54LokCRJHC44uNv59nEGilnW3usHMn3aChh1RMSVM QHDgmDkrPlfZ+1W9RPZX/Q8UL+bszMxxJueFHwsRfhPl208O+mLI5Q2iY1K1OjOn3HbPpDq RTXsPnkgDCdm0TNjR7Ve36+py4rNZ2W9aSq+D0btWgHGVke79g3x1EjAh0yPRgj5dlfkSUW YV+8mHaXooLdR8qZtdZJw== UI-OutboundReport: notjunk:1;M01:P0:xOcNZraKNLs=;hEXnTMiH8otvELbjWcdEa9PrCLa lpnU1yGJm5JmQiIFHjj2ARITPc2PgRomfUI1VDM4mQzGpRWdjV64kfb6f1IINPGYJV5WZ34ne BH9s3ernlljvHZXO7AC+OBGABsId6ZtrZ4SbrazBFNBjHB6VTfte6gy6DeiTBE8YLUc37bC3E yv0eMLIj17dHbNIZbbsaTw9fc+m/KOjrvXVXnw7RKAYdgt0r1Du9qSFStQ+MY+dZML4vuGMWg 1ftxYmE7bWBKOdeGE9MJCxuPb+XjCuOCq1meV+XLUCXtpzFtrRDXYbSLsanemp57ooDid3N1f cvViL3CG/aJ7uGGiDcR7d7fmUeOK9xj/VJxNxWEjXvS37I3h7fvvvKERTwdc7i2Ajy/J2WBjJ QadAGmHPdCk/qpQqOJ6v8bpN7RX7dtzY7PvkUmiTS2aNlMoOkrwZ+nvwiVWwPoN2HpFoZhm5b PIONMkGSSPh6psqaVWh1T9PhKoVSeAD9QtPU1PBC/5FPoFG1BABnFApTdYVNlwn3SA1l6OFEj 2IfvUcKFMS9IiIySIaFjUZPZ2JiRhSp6HIgVe8UFuvomMoVfW+oQbyPbCVTM5tbPLKzHxFIfE UtngETX4+okO0cTVHT6u9uDqafthFvBh9pcy7pqlM6RbjpgwqmlfNVhamct8IH0XyI0NxiKxY EJlurbuQuWtNWjAKp9u9QYt8JPWk3Rm0Le1mniWJ6JADh94Q5RIR+jMJGvad0FTYP+NdiwNOW uu3qapw6C9p49fafeBhQb3M3PhkKWf4oLf/wCX9/lEanFNSKxDV7WY6HKE0fHofocizRtSEzw dfwSrrWdhkWe/jYpafom2iEiUTzro0gfTyWfNbgREZfns57YmYLW8nh5JcVPXosHoCZHhC77D aqrZkgTeyi36BRhQc362xvJVTNEakjJPhl9gFXcHfg6F+KTBuXU5k2FAx44dvjgY7wXed9AEL 6BjLGxC2kwVjsxMlQOzhu3DNqfc= X-Patchwork-Delegate: kuba@kernel.org The functions qcaspi_netdev_open/close are responsible of request & free of the SPI interrupt, which wasn't the best choice. Currently it's possible to trigger a double free of the interrupt by calling qcaspi_netdev_close() after qcaspi_netdev_open() has failed. So let us split IRQ allocation & enabling, so we can take advantage of a device managed IRQ and also fix the issue. Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_spi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) -- 2.34.1 diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index b11a998b2456..b2573eea8a7a 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -674,7 +674,6 @@ static int qcaspi_netdev_open(struct net_device *dev) { struct qcaspi *qca = netdev_priv(dev); - int ret = 0; if (!qca) return -EINVAL; @@ -684,13 +683,7 @@ qcaspi_netdev_open(struct net_device *dev) qca->sync = QCASPI_SYNC_UNKNOWN; qcafrm_fsm_init_spi(&qca->frm_handle); - ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0, - dev->name, qca); - if (ret) { - netdev_err(dev, "%s: unable to get IRQ %d (irqval=%d).\n", - QCASPI_DRV_NAME, qca->spi_dev->irq, ret); - return ret; - } + enable_irq(qca->spi_dev->irq); /* SPI thread takes care of TX queue */ kthread_unpark(qca->spi_thread); @@ -707,7 +700,7 @@ qcaspi_netdev_close(struct net_device *dev) netif_stop_queue(dev); qcaspi_write_register(qca, SPI_REG_INTR_ENABLE, 0, wr_verify); - free_irq(qca->spi_dev->irq, qca); + disable_irq(qca->spi_dev->irq); kthread_park(qca->spi_thread); qcaspi_flush_tx_ring(qca); @@ -977,6 +970,15 @@ qca_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, qcaspi_devs); + ret = devm_request_irq(&spi->dev, spi->irq, qcaspi_intr_handler, + IRQF_NO_AUTOEN, qca->net_dev->name, qca); + if (ret) { + dev_err(&spi->dev, "Unable to get IRQ %d (irqval=%d).\n", + spi->irq, ret); + free_netdev(qcaspi_devs); + return ret; + } + ret = of_get_ethdev_address(spi->dev.of_node, qca->net_dev); if (ret) { eth_hw_addr_random(qca->net_dev); From patchwork Tue Nov 21 16:30:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13463357 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="l3e+XLIt" Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE15191; Tue, 21 Nov 2023 08:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1700584229; x=1701189029; i=wahrenst@gmx.net; bh=6XwkQvqwtcVy28fKXdFyyWyhmGSZ18nQMs5LnwizKy4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=l3e+XLItZJ0ct7Amnq0EGnKj4t+muboZX8GnWlUPolo6RRnjAeN2hi9bl6VHuAqg x7jm6cSZz3gAnH2uMypbh1P+uh5/RhXvQHWJH4O7lXALWhQpMIqpZHnvtfy7mb3SC STjSvYDvSAf1oFI5EniP/LbTyIWtgptCL9ouE8PUq9vEP6VP3yB3RQZWcEIJ1CwHr zIgTlt2tCbhUjAaRfGg7JFuj2+D+nWLKcgVae4MHYIOq/o6kcHdC++oD8imhV+TRm eojjvaY6ucxXhUcTfRiZb9ufGGxdrTT8j4IUMTEjagZYLk5bUnqGoR2AKWGaOW4/s +5vvQN4pr13bYB9pRA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MJE27-1qmQIA0CGx-00Kir0; Tue, 21 Nov 2023 17:30:29 +0100 From: Stefan Wahren To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Lino Sanfilippo , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 3/4 net] qca_spi: Fix ethtool -G iface tx behavior Date: Tue, 21 Nov 2023 17:30:03 +0100 Message-Id: <20231121163004.21232-4-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121163004.21232-1-wahrenst@gmx.net> References: <20231121163004.21232-1-wahrenst@gmx.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:WKlRcSkBLRRiKS9ZuJyqRBCwJ2sZ/WAUwE0tXUKbMppH1MFeGgN N4B0/OfKV+wEG1ZVx+x3qhALHSFoCBSgCC1tEYt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j8 1TCKSt+DgCCGCZ6MELJjhDOjHVBqInQYyP7bWnSVTi+toZD36RUlrIj0DJJ2w5PYZUhipuncV bdcx/A== X-Patchwork-Delegate: kuba@kernel.org After calling ethtool -g it was not possible to adjust the TX ring size again. The reason for this is that the readonly setting rx_pending get initialized and after that the range check in qcaspi_set_ringparam() fails regardless of the provided parameter. Since there is no adjustable RX ring at all, drop it from qcaspi_get_ringparam(). Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_debug.c | 2 -- 1 file changed, 2 deletions(-) -- 2.34.1 diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c index 6f2fa2a42770..613eb688cba2 100644 --- a/drivers/net/ethernet/qualcomm/qca_debug.c +++ b/drivers/net/ethernet/qualcomm/qca_debug.c @@ -252,9 +252,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring, { struct qcaspi *qca = netdev_priv(dev); - ring->rx_max_pending = 4; ring->tx_max_pending = TX_RING_MAX_LEN; - ring->rx_pending = 4; ring->tx_pending = qca->txr.count; } From patchwork Tue Nov 21 16:30:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13463359 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="ep89LGv1" Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D1E19A; Tue, 21 Nov 2023 08:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1700584229; x=1701189029; i=wahrenst@gmx.net; bh=JoGHBVdoQHC+Hv6Wibo5CgNTW7akgW6n35LRv1PZupQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=ep89LGv1rx9UT5YbrIdIfvDUulLILkxBdvGeCDVbWp3ydd9NZWYnG+zL3P8Au4mK 7DS+Am6nLm5CDB18U1FA6eYDc22xINzVr1/HhrhczwL1zu+wVtJJcrwxO3ZTqczji J75cVhpPuM2WIjaW2lx7EE8xwEVpEz3JNZ2cwsHn9RGCoRgdCnw226zGAazZecVgo JhJIIwxYdRWwXa+xLpFdbcViiCyLL7l3a03zTiZVN1pXM+M5GImVq48KLU4aT08kI zHHEAUmrGqq0qmRGDNO4htEVuDEskVhBZ3D2ge0qu3HB5SWk5aXCEO728YrTmZbNe kPVTatLFfYHQxQ1N+Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Ml6qC-1rk4FN1m3w-00lUrh; Tue, 21 Nov 2023 17:30:29 +0100 From: Stefan Wahren To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Lino Sanfilippo , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wahren Subject: [PATCH 4/4 net] qca_spi: Fix reset behavior Date: Tue, 21 Nov 2023 17:30:04 +0100 Message-Id: <20231121163004.21232-5-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121163004.21232-1-wahrenst@gmx.net> References: <20231121163004.21232-1-wahrenst@gmx.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:bvNYFCb4jDy2CsUdTWKcRtEIeHiKsPwaWtJYrrPMVRe7BQl3yHl mYrfz8dy7457KSPmfewTUOV+APtuGdFtt3C+7GtzUrR8B4YIubJzoddH2olZP+4tc5Cvhdx Dq7/7Cp6cdAB0C99Wr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brqT4nHN+Db gT31uZ/9DXPKHF9XIickBNMmvKI= X-Patchwork-Delegate: kuba@kernel.org In case of a reset triggered by the QCA7000 itself, the behavior of the qca_spi driver was not quite correct: - in case of a pending RX frame decoding the drop counter must be incremented and decoding state machine reseted - also the reset counter must always be incremented regardless of sync state Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren --- drivers/net/ethernet/qualcomm/qca_spi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index b2573eea8a7a..844d255f5d55 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c @@ -613,11 +613,17 @@ qcaspi_spi_thread(void *data) if (intr_cause & SPI_INT_CPU_ON) { qcaspi_qca7k_sync(qca, QCASPI_EVENT_CPUON); + /* Frame decoding in progress */ + if (qca->frm_handle.state != qca->frm_handle.init) + qca->net_dev->stats.rx_dropped++; + + qcafrm_fsm_init_spi(&qca->frm_handle); + qca->stats.device_reset++; + /* not synced. */ if (qca->sync != QCASPI_SYNC_READY) continue; - qca->stats.device_reset++; netif_wake_queue(qca->net_dev); netif_carrier_on(qca->net_dev); }