* [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync
@ 2024-10-07 11:33 Stefan Wahren
2024-10-07 11:33 ` [PATCH 1/2 net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset Stefan Wahren
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefan Wahren @ 2024-10-07 11:33 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Heimpold, Christoph Fritz,
Stefan Wahren
This series contains patches which improve the QCA7000 sync behavior.
Stefan Wahren (2):
qca_spi: Count unexpected WRBUF_SPC_AVA after reset
qca_spi: Improve reset mechanism
drivers/net/ethernet/qualcomm/qca_debug.c | 4 +--
drivers/net/ethernet/qualcomm/qca_spi.c | 30 ++++++++++++++---------
drivers/net/ethernet/qualcomm/qca_spi.h | 2 +-
3 files changed, 21 insertions(+), 15 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2 net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset
2024-10-07 11:33 [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync Stefan Wahren
@ 2024-10-07 11:33 ` Stefan Wahren
2024-10-07 11:33 ` [PATCH 2/2 net-next] qca_spi: Improve reset mechanism Stefan Wahren
2024-10-10 1:10 ` [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Wahren @ 2024-10-07 11:33 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Heimpold, Christoph Fritz,
Stefan Wahren
After a reset of the QCA7000, the amount of available write buffer
space should match QCASPI_HW_BUF_LEN. If this is not the case
this error should be counted as such.
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
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 8f7ce6b51a1c..fde7197372fe 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -505,6 +505,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
if (wrbuf_space != QCASPI_HW_BUF_LEN) {
netdev_dbg(qca->net_dev, "sync: got CPU on, but wrbuf not empty. reset!\n");
qca->sync = QCASPI_SYNC_UNKNOWN;
+ qca->stats.buf_avail_err++;
} else {
netdev_dbg(qca->net_dev, "sync: got CPU on, now in sync\n");
qca->sync = QCASPI_SYNC_READY;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2 net-next] qca_spi: Improve reset mechanism
2024-10-07 11:33 [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync Stefan Wahren
2024-10-07 11:33 ` [PATCH 1/2 net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset Stefan Wahren
@ 2024-10-07 11:33 ` Stefan Wahren
2024-10-10 1:10 ` [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Wahren @ 2024-10-07 11:33 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Heimpold, Christoph Fritz,
Stefan Wahren
The commit 92717c2356cb ("net: qca_spi: Avoid high load if QCA7000 is not
available") fixed the high load in case the QCA7000 is not available
but introduced sync delays for some corner cases like buffer errors.
So add the reset requests to the atomics flags, which are polled by
the SPI thread. As a result reset requests and sync state are now
separated. This has the nice benefit to make the code easier to
understand.
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
drivers/net/ethernet/qualcomm/qca_debug.c | 4 ++--
drivers/net/ethernet/qualcomm/qca_spi.c | 29 +++++++++++++----------
drivers/net/ethernet/qualcomm/qca_spi.h | 2 +-
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index ad06da0fdaa0..13deb3da4a64 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -98,8 +98,8 @@ qcaspi_info_show(struct seq_file *s, void *what)
seq_printf(s, "IRQ : %d\n",
qca->spi_dev->irq);
- seq_printf(s, "INTR : %lx\n",
- qca->intr);
+ seq_printf(s, "FLAGS : %lx\n",
+ qca->flags);
seq_printf(s, "SPI max speed : %lu\n",
(unsigned long)qca->spi_dev->max_speed_hz);
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index fde7197372fe..b8fa6c56104e 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -35,7 +35,8 @@
#define MAX_DMA_BURST_LEN 5000
-#define SPI_INTR 0
+#define SPI_INTR 0
+#define SPI_RESET 1
/* Modules parameters */
#define QCASPI_CLK_SPEED_MIN 1000000
@@ -495,7 +496,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
if (qca->sync == QCASPI_SYNC_READY)
qca->stats.bad_signature++;
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
netdev_dbg(qca->net_dev, "sync: got CPU on, but signature was invalid, restart\n");
return;
} else {
@@ -512,6 +513,10 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
return;
}
}
+ } else {
+ /* Handle reset only on QCASPI_EVENT_UPDATE */
+ if (test_and_clear_bit(SPI_RESET, &qca->flags))
+ qca->sync = QCASPI_SYNC_UNKNOWN;
}
switch (qca->sync) {
@@ -522,7 +527,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature);
if (signature != QCASPI_GOOD_SIGNATURE) {
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
qca->stats.bad_signature++;
netdev_dbg(qca->net_dev, "sync: bad signature, restart\n");
/* don't reset right away */
@@ -553,7 +558,7 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
qca->reset_count);
if (qca->reset_count >= QCASPI_RESET_TIMEOUT) {
/* reset did not seem to take place, try again */
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
qca->stats.reset_timeout++;
netdev_dbg(qca->net_dev, "sync: reset timeout, restarting process.\n");
}
@@ -582,14 +587,14 @@ qcaspi_spi_thread(void *data)
continue;
}
- if (!test_bit(SPI_INTR, &qca->intr) &&
+ if (!qca->flags &&
!qca->txr.skb[qca->txr.head])
schedule();
set_current_state(TASK_RUNNING);
netdev_dbg(qca->net_dev, "have work to do. int: %lu, tx_skb: %p\n",
- qca->intr,
+ qca->flags,
qca->txr.skb[qca->txr.head]);
qcaspi_qca7k_sync(qca, QCASPI_EVENT_UPDATE);
@@ -603,7 +608,7 @@ qcaspi_spi_thread(void *data)
msleep(QCASPI_QCA7K_REBOOT_TIME_MS);
}
- if (test_and_clear_bit(SPI_INTR, &qca->intr)) {
+ if (test_and_clear_bit(SPI_INTR, &qca->flags)) {
start_spi_intr_handling(qca, &intr_cause);
if (intr_cause & SPI_INT_CPU_ON) {
@@ -628,7 +633,7 @@ qcaspi_spi_thread(void *data)
/* restart sync */
netdev_dbg(qca->net_dev, "===> rdbuf error!\n");
qca->stats.read_buf_err++;
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
continue;
}
@@ -636,7 +641,7 @@ qcaspi_spi_thread(void *data)
/* restart sync */
netdev_dbg(qca->net_dev, "===> wrbuf error!\n");
qca->stats.write_buf_err++;
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
continue;
}
@@ -665,7 +670,7 @@ qcaspi_intr_handler(int irq, void *data)
{
struct qcaspi *qca = data;
- set_bit(SPI_INTR, &qca->intr);
+ set_bit(SPI_INTR, &qca->flags);
if (qca->spi_thread)
wake_up_process(qca->spi_thread);
@@ -681,7 +686,7 @@ qcaspi_netdev_open(struct net_device *dev)
if (!qca)
return -EINVAL;
- set_bit(SPI_INTR, &qca->intr);
+ set_bit(SPI_INTR, &qca->flags);
qca->sync = QCASPI_SYNC_UNKNOWN;
qcafrm_fsm_init_spi(&qca->frm_handle);
@@ -800,7 +805,7 @@ qcaspi_netdev_tx_timeout(struct net_device *dev, unsigned int txqueue)
jiffies, jiffies - dev_trans_start(dev));
qca->net_dev->stats.tx_errors++;
/* Trigger tx queue flush and QCA7000 reset */
- qca->sync = QCASPI_SYNC_UNKNOWN;
+ set_bit(SPI_RESET, &qca->flags);
if (qca->spi_thread)
wake_up_process(qca->spi_thread);
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 8f4808695e82..7ba5c9e2f61c 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -81,7 +81,7 @@ struct qcaspi {
struct qcafrm_handle frm_handle;
struct sk_buff *rx_skb;
- unsigned long intr;
+ unsigned long flags;
u16 reset_count;
#ifdef CONFIG_DEBUG_FS
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync
2024-10-07 11:33 [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync Stefan Wahren
2024-10-07 11:33 ` [PATCH 1/2 net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset Stefan Wahren
2024-10-07 11:33 ` [PATCH 2/2 net-next] qca_spi: Improve reset mechanism Stefan Wahren
@ 2024-10-10 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-10 1:10 UTC (permalink / raw)
To: Stefan Wahren
Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel, mhei,
chf.fritz
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 7 Oct 2024 13:33:10 +0200 you wrote:
> This series contains patches which improve the QCA7000 sync behavior.
>
> Stefan Wahren (2):
> qca_spi: Count unexpected WRBUF_SPC_AVA after reset
> qca_spi: Improve reset mechanism
>
> drivers/net/ethernet/qualcomm/qca_debug.c | 4 +--
> drivers/net/ethernet/qualcomm/qca_spi.c | 30 ++++++++++++++---------
> drivers/net/ethernet/qualcomm/qca_spi.h | 2 +-
> 3 files changed, 21 insertions(+), 15 deletions(-)
>
> [...]
Here is the summary with links:
- [1/2,net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset
https://git.kernel.org/netdev/net-next/c/234b526896a9
- [2/2,net-next] qca_spi: Improve reset mechanism
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-10 1:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 11:33 [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync Stefan Wahren
2024-10-07 11:33 ` [PATCH 1/2 net-next] qca_spi: Count unexpected WRBUF_SPC_AVA after reset Stefan Wahren
2024-10-07 11:33 ` [PATCH 2/2 net-next] qca_spi: Improve reset mechanism Stefan Wahren
2024-10-10 1:10 ` [PATCH 0/2 net-next] qca_spi: Improvements to QCA7000 sync patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).