aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qualcomm/qca_spi.c
diff options
context:
space:
mode:
authorStefan Wahren <stefan.wahren@i2se.com>2018-11-08 14:38:21 +0100
committerDavid S. Miller <davem@davemloft.net>2018-11-08 19:41:01 -0800
commit026b907d58c48b2ff2a4c04a67bb5f71ebda1f2d (patch)
tree80acab764c725b1c4141bfadb838a3ac9cc8934a /drivers/net/ethernet/qualcomm/qca_spi.c
parentsock: Reset dst when changing sk_mark via setsockopt (diff)
downloadlinux-dev-026b907d58c48b2ff2a4c04a67bb5f71ebda1f2d.tar.xz
linux-dev-026b907d58c48b2ff2a4c04a67bb5f71ebda1f2d.zip
net: qca_spi: Add available buffer space verification
Interferences on the SPI line could distort the response of available buffer space. So at least we should check that the response doesn't exceed the maximum available buffer space. In error case increase a new error counter and retry it later. This behavior avoids buffer errors in the QCA7000, which results in an unnecessary chip reset including packet loss. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qualcomm/qca_spi.c')
-rw-r--r--drivers/net/ethernet/qualcomm/qca_spi.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index d5310504f436..97f92953bdb9 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -289,6 +289,14 @@ qcaspi_transmit(struct qcaspi *qca)
qcaspi_read_register(qca, SPI_REG_WRBUF_SPC_AVA, &available);
+ if (available > QCASPI_HW_BUF_LEN) {
+ /* This could only happen by interferences on the SPI line.
+ * So retry later ...
+ */
+ qca->stats.buf_avail_err++;
+ return -1;
+ }
+
while (qca->txr.skb[qca->txr.head]) {
pkt_len = qca->txr.skb[qca->txr.head]->len + QCASPI_HW_PKT_LEN;
@@ -355,7 +363,13 @@ qcaspi_receive(struct qcaspi *qca)
netdev_dbg(net_dev, "qcaspi_receive: SPI_REG_RDBUF_BYTE_AVA: Value: %08x\n",
available);
- if (available == 0) {
+ if (available > QCASPI_HW_BUF_LEN) {
+ /* This could only happen by interferences on the SPI line.
+ * So retry later ...
+ */
+ qca->stats.buf_avail_err++;
+ return -1;
+ } else if (available == 0) {
netdev_dbg(net_dev, "qcaspi_receive called without any data being available!\n");
return -1;
}