linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: qca_spi: Fix receive and reset issues
@ 2019-11-20 17:29 Stefan Wahren
  2019-11-20 17:29 ` [PATCH net 1/2] net: qca_spi: fix receive buffer size check Stefan Wahren
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Wahren @ 2019-11-20 17:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Stefan Wahren

This small patch series fixes two major issues in the SPI driver for the
QCA700x.

It has been tested on a Charge Control C 300 (NXP i.MX6ULL +
2x QCA7000).

Michael Heimpold (1):
  net: qca_spi: fix receive buffer size check

Stefan Wahren (1):
  net: qca_spi: Move reset_count to struct qcaspi

 drivers/net/ethernet/qualcomm/qca_spi.c | 11 +++++------
 drivers/net/ethernet/qualcomm/qca_spi.h |  1 +
 2 files changed, 6 insertions(+), 6 deletions(-)

--
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] net: qca_spi: fix receive buffer size check
  2019-11-20 17:29 [PATCH net 0/2] net: qca_spi: Fix receive and reset issues Stefan Wahren
@ 2019-11-20 17:29 ` Stefan Wahren
  2019-11-20 17:29 ` [PATCH net 2/2] net: qca_spi: Move reset_count to struct qcaspi Stefan Wahren
  2019-11-20 20:42 ` [PATCH net 0/2] net: qca_spi: Fix receive and reset issues David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Wahren @ 2019-11-20 17:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Michael Heimpold, Stefan Wahren

From: Michael Heimpold <michael.heimpold@in-tech.com>

When receiving many or larger packets, e.g. when doing a file download,
it was observed that the read buffer size register reports up to 4 bytes
more than the current define allows in the check.
If this is the case, then no data transfer is initiated to receive the
packets (and thus to empty the buffer) which results in a stall of the
interface.

These 4 bytes are a hardware generated frame length which is prepended
to the actual frame, thus we have to respect it during our check.

Fixes: 026b907d58c4 ("net: qca_spi: Add available buffer space verification")
Signed-off-by: Michael Heimpold <michael.heimpold@in-tech.com>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 5ecf61d..351f24f 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -363,7 +363,7 @@ qcaspi_receive(struct qcaspi *qca)
 	netdev_dbg(net_dev, "qcaspi_receive: SPI_REG_RDBUF_BYTE_AVA: Value: %08x\n",
 		   available);

-	if (available > QCASPI_HW_BUF_LEN) {
+	if (available > QCASPI_HW_BUF_LEN + QCASPI_HW_PKT_LEN) {
 		/* This could only happen by interferences on the SPI line.
 		 * So retry later ...
 		 */
--
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net: qca_spi: Move reset_count to struct qcaspi
  2019-11-20 17:29 [PATCH net 0/2] net: qca_spi: Fix receive and reset issues Stefan Wahren
  2019-11-20 17:29 ` [PATCH net 1/2] net: qca_spi: fix receive buffer size check Stefan Wahren
@ 2019-11-20 17:29 ` Stefan Wahren
  2019-11-20 20:42 ` [PATCH net 0/2] net: qca_spi: Fix receive and reset issues David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Wahren @ 2019-11-20 17:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Stefan Wahren, Stefan Wahren

From: Stefan Wahren <stefan.wahren@in-tech.com>

The reset counter is specific for every QCA700x chip. So move this
into the private driver struct. Otherwise we get unpredictable reset
behavior in setups with multiple QCA700x chips.

Fixes: 291ab06ecf67 (net: qualcomm: new Ethernet over SPI driver for QCA7000)
Signed-off-by: Stefan Wahren <stefan.wahren@in-tech.com>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 9 ++++-----
 drivers/net/ethernet/qualcomm/qca_spi.h | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 351f24f..baac016 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -496,7 +496,6 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
 	u16 signature = 0;
 	u16 spi_config;
 	u16 wrbuf_space = 0;
-	static u16 reset_count;

 	if (event == QCASPI_EVENT_CPUON) {
 		/* Read signature twice, if not valid
@@ -549,13 +548,13 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)

 		qca->sync = QCASPI_SYNC_RESET;
 		qca->stats.trig_reset++;
-		reset_count = 0;
+		qca->reset_count = 0;
 		break;
 	case QCASPI_SYNC_RESET:
-		reset_count++;
+		qca->reset_count++;
 		netdev_dbg(qca->net_dev, "sync: waiting for CPU on, count %u.\n",
-			   reset_count);
-		if (reset_count >= QCASPI_RESET_TIMEOUT) {
+			   qca->reset_count);
+		if (qca->reset_count >= QCASPI_RESET_TIMEOUT) {
 			/* reset did not seem to take place, try again */
 			qca->sync = QCASPI_SYNC_UNKNOWN;
 			qca->stats.reset_timeout++;
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index eb9af45..d13a67e 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -94,6 +94,7 @@ struct qcaspi {

 	unsigned int intr_req;
 	unsigned int intr_svc;
+	u16 reset_count;

 #ifdef CONFIG_DEBUG_FS
 	struct dentry *device_root;
--
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] net: qca_spi: Fix receive and reset issues
  2019-11-20 17:29 [PATCH net 0/2] net: qca_spi: Fix receive and reset issues Stefan Wahren
  2019-11-20 17:29 ` [PATCH net 1/2] net: qca_spi: fix receive buffer size check Stefan Wahren
  2019-11-20 17:29 ` [PATCH net 2/2] net: qca_spi: Move reset_count to struct qcaspi Stefan Wahren
@ 2019-11-20 20:42 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-11-20 20:42 UTC (permalink / raw)
  To: wahrenst; +Cc: netdev, linux-kernel

From: Stefan Wahren <wahrenst@gmx.net>
Date: Wed, 20 Nov 2019 18:29:11 +0100

> This small patch series fixes two major issues in the SPI driver for the
> QCA700x.
> 
> It has been tested on a Charge Control C 300 (NXP i.MX6ULL +
> 2x QCA7000).

Series applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-20 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 17:29 [PATCH net 0/2] net: qca_spi: Fix receive and reset issues Stefan Wahren
2019-11-20 17:29 ` [PATCH net 1/2] net: qca_spi: fix receive buffer size check Stefan Wahren
2019-11-20 17:29 ` [PATCH net 2/2] net: qca_spi: Move reset_count to struct qcaspi Stefan Wahren
2019-11-20 20:42 ` [PATCH net 0/2] net: qca_spi: Fix receive and reset issues David Miller

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