* [PATCH 1/3 net-next] net: qca_spi: Avoid reading signature three times in a row
2021-05-08 12:36 [PATCH 0/3 net-next] net: qca_spi: Improve sync handling Stefan Wahren
@ 2021-05-08 12:36 ` Stefan Wahren
2021-05-08 12:36 ` [PATCH 2/3 net-next] net: qca_spi: Avoid re-sync for single signature error Stefan Wahren
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Wahren @ 2021-05-08 12:36 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linux-kernel, Stefan Wahren
There is no need to read the signature three times. So bail out
in case the second check failed.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
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,
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3 net-next] net: qca_spi: Avoid re-sync for single signature error
2021-05-08 12:36 [PATCH 0/3 net-next] net: qca_spi: Improve sync handling Stefan Wahren
2021-05-08 12:36 ` [PATCH 1/3 net-next] net: qca_spi: Avoid reading signature three times in a row Stefan Wahren
@ 2021-05-08 12:36 ` Stefan Wahren
2021-05-08 12:36 ` [PATCH 3/3 net-next] net: qca_spi: Introduce stat about bad signature Stefan Wahren
2021-05-10 21:40 ` [PATCH 0/3 net-next] net: qca_spi: Improve sync handling patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Wahren @ 2021-05-08 12:36 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linux-kernel, Stefan Wahren
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 <stefan.wahren@i2se.com>
---
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");
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3 net-next] net: qca_spi: Introduce stat about bad signature
2021-05-08 12:36 [PATCH 0/3 net-next] net: qca_spi: Improve sync handling Stefan Wahren
2021-05-08 12:36 ` [PATCH 1/3 net-next] net: qca_spi: Avoid reading signature three times in a row Stefan Wahren
2021-05-08 12:36 ` [PATCH 2/3 net-next] net: qca_spi: Avoid re-sync for single signature error Stefan Wahren
@ 2021-05-08 12:36 ` Stefan Wahren
2021-05-10 21:40 ` [PATCH 0/3 net-next] net: qca_spi: Improve sync handling patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Wahren @ 2021-05-08 12:36 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linux-kernel, Stefan Wahren
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 <stefan.wahren@i2se.com>
---
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 {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3 net-next] net: qca_spi: Improve sync handling
2021-05-08 12:36 [PATCH 0/3 net-next] net: qca_spi: Improve sync handling Stefan Wahren
` (2 preceding siblings ...)
2021-05-08 12:36 ` [PATCH 3/3 net-next] net: qca_spi: Introduce stat about bad signature Stefan Wahren
@ 2021-05-10 21:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-10 21:40 UTC (permalink / raw)
To: Stefan Wahren; +Cc: davem, kuba, netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Sat, 8 May 2021 14:36:32 +0200 you wrote:
> This small patch series contains some improvements of the sync
> handling. This was discovered while the QCA7000 was doing SLAC
> (Signal Level Attenuation Characterization).
>
> Stefan Wahren (3):
> net: qca_spi: Avoid reading signature three times in a row
> net: qca_spi: Avoid re-sync for single signature error
> net: qca_spi: Introduce stat about bad signature
>
> [...]
Here is the summary with links:
- [1/3,net-next] net: qca_spi: Avoid reading signature three times in a row
https://git.kernel.org/netdev/net-next/c/b76078df1593
- [2/3,net-next] net: qca_spi: Avoid re-sync for single signature error
https://git.kernel.org/netdev/net-next/c/6e03f3ff29c1
- [3/3,net-next] net: qca_spi: Introduce stat about bad signature
https://git.kernel.org/netdev/net-next/c/a53935674563
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] 5+ messages in thread