Skip to content

Commit a9c3d39

Browse files
committed
Merge branch 'qca_spi-improvements'
Stefan Wahren says: ==================== qca_spi: collection of improvements This series contains a wild collection of improvements for the qca_spi driver. This is a follow-up series to the recent bugfixes [1]. Patch 1, 2 & 3 in this series is the initially intended rework of netdev_open/close. Patch 4 & 10 are minor functional improvements and the rest is clean-up. Changes in V4: - keep thread handling in netdev_open, but improve this by two separate patches ( 1 & 2 ) - add missing link to bugfix series Changes in V3: - rebase on net-next-20240124 - improve commit message in Patch 8 - add Reviewed-by's from Jacob Keller - add Patch 13 for mailmap as suggested by Jacob - add Patch 14 for MAINTAINERS entry Changes in V2: - rebase on net-next-20231218 - improve cover letter [1] - https://lore.kernel.org/netdev/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e746094 + 23b8a64 commit a9c3d39

File tree

11 files changed

+58
-175
lines changed

11 files changed

+58
-175
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ Simon Kelley <[email protected]>
568568
Sricharan Ramabadhran <[email protected]> <[email protected]>
569569
570570
571+
571572
Stéphane Witzmann <[email protected]>
572573
573574

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18014,6 +18014,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
1801418014
F: Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml
1801518015
F: drivers/net/wireless/ath/ath9k/
1801618016

18017+
QUALCOMM ATHEROS QCA7K ETHERNET DRIVER
18018+
M: Stefan Wahren <[email protected]>
18019+
18020+
S: Maintained
18021+
F: Documentation/devicetree/bindings/net/qca,qca7000.txt
18022+
F: drivers/net/ethernet/qualcomm/qca*
18023+
1801718024
QUALCOMM BAM-DMUX WWAN NETWORK DRIVER
1801818025
M: Stephan Gerhold <[email protected]>
1801918026

drivers/net/ethernet/qualcomm/qca_7k.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
12
/*
2-
*
33
* Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
44
* Copyright (c) 2014, I2SE GmbH
5-
*
6-
* Permission to use, copy, modify, and/or distribute this software
7-
* for any purpose with or without fee is hereby granted, provided
8-
* that the above copyright notice and this permission notice appear
9-
* in all copies.
10-
*
11-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
14-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
15-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19-
*
205
*/
216

227
/* This module implements the Qualcomm Atheros SPI protocol for

drivers/net/ethernet/qualcomm/qca_7k.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
12
/*
23
* Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18-
*
195
*/
206

217
/* Qualcomm Atheros SPI register definition.

drivers/net/ethernet/qualcomm/qca_7k_common.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
12
/*
23
* Copyright (c) 2011, 2012, Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185
*/
196

207
/* Atheros ethernet framing. Every Ethernet frame is surrounded
@@ -162,5 +149,5 @@ EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
162149

163150
MODULE_DESCRIPTION("Qualcomm Atheros QCA7000 common");
164151
MODULE_AUTHOR("Qualcomm Atheros Communications");
165-
MODULE_AUTHOR("Stefan Wahren <[email protected]>");
152+
MODULE_AUTHOR("Stefan Wahren <[email protected]>");
166153
MODULE_LICENSE("Dual BSD/GPL");

drivers/net/ethernet/qualcomm/qca_7k_common.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
12
/*
23
* Copyright (c) 2011, 2012, Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185
*/
196

207
/* Atheros Ethernet framing. Every Ethernet frame is surrounded by an atheros
@@ -107,9 +94,6 @@ struct qcafrm_handle {
10794

10895
/* Offset in buffer (borrowed for length too) */
10996
u16 offset;
110-
111-
/* Frame length as kept by this module */
112-
u16 len;
11397
};
11498

11599
u16 qcafrm_create_header(u8 *buf, u16 len);
@@ -128,17 +112,6 @@ static inline void qcafrm_fsm_init_uart(struct qcafrm_handle *handle)
128112
handle->state = handle->init;
129113
}
130114

131-
/* Gather received bytes and try to extract a full Ethernet frame
132-
* by following a simple state machine.
133-
*
134-
* Return: QCAFRM_GATHER No Ethernet frame fully received yet.
135-
* QCAFRM_NOHEAD Header expected but not found.
136-
* QCAFRM_INVLEN QCA7K frame length is invalid
137-
* QCAFRM_NOTAIL Footer expected but not found.
138-
* > 0 Number of byte in the fully received
139-
* Ethernet frame
140-
*/
141-
142115
s32 qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte);
143116

144117
#endif /* _QCA_FRAMING_H */

drivers/net/ethernet/qualcomm/qca_debug.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
12
/*
23
* Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185
*/
196

207
/* This file contains debugging routines for use in the QCA7K driver.
@@ -255,7 +242,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
255242
struct qcaspi *qca = netdev_priv(dev);
256243

257244
ring->rx_max_pending = QCASPI_RX_MAX_FRAMES;
258-
ring->tx_max_pending = TX_RING_MAX_LEN;
245+
ring->tx_max_pending = QCASPI_TX_RING_MAX_LEN;
259246
ring->rx_pending = QCASPI_RX_MAX_FRAMES;
260247
ring->tx_pending = qca->txr.count;
261248
}
@@ -275,8 +262,8 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
275262
if (qca->spi_thread)
276263
kthread_park(qca->spi_thread);
277264

278-
qca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN);
279-
qca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN);
265+
qca->txr.count = max_t(u32, ring->tx_pending, QCASPI_TX_RING_MIN_LEN);
266+
qca->txr.count = min_t(u16, qca->txr.count, QCASPI_TX_RING_MAX_LEN);
280267

281268
if (qca->spi_thread)
282269
kthread_unpark(qca->spi_thread);

drivers/net/ethernet/qualcomm/qca_debug.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
12
/*
23
* Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185
*/
196

207
/* This file contains debugging routines for use in the QCA7K driver.

drivers/net/ethernet/qualcomm/qca_spi.c

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
12
/*
23
* Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
34
* Copyright (c) 2014, I2SE GmbH
4-
*
5-
* Permission to use, copy, modify, and/or distribute this software
6-
* for any purpose with or without fee is hereby granted, provided
7-
* that the above copyright notice and this permission notice appear
8-
* in all copies.
9-
*
10-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13-
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185
*/
196

207
/* This module implements the Qualcomm Atheros SPI protocol for
@@ -359,7 +346,7 @@ qcaspi_receive(struct qcaspi *qca)
359346
/* Read the packet size. */
360347
qcaspi_read_register(qca, SPI_REG_RDBUF_BYTE_AVA, &available);
361348

362-
netdev_dbg(net_dev, "qcaspi_receive: SPI_REG_RDBUF_BYTE_AVA: Value: %08x\n",
349+
netdev_dbg(net_dev, "qcaspi_receive: SPI_REG_RDBUF_BYTE_AVA: Value: %04x\n",
363350
available);
364351

365352
if (available > QCASPI_HW_BUF_LEN + QCASPI_HW_PKT_LEN) {
@@ -476,7 +463,7 @@ qcaspi_flush_tx_ring(struct qcaspi *qca)
476463
* has been replaced by netif_tx_lock_bh() and so on.
477464
*/
478465
netif_tx_lock_bh(qca->net_dev);
479-
for (i = 0; i < TX_RING_MAX_LEN; i++) {
466+
for (i = 0; i < QCASPI_TX_RING_MAX_LEN; i++) {
480467
if (qca->txr.skb[i]) {
481468
dev_kfree_skb(qca->txr.skb[i]);
482469
qca->txr.skb[i] = NULL;
@@ -687,7 +674,7 @@ static int
687674
qcaspi_netdev_open(struct net_device *dev)
688675
{
689676
struct qcaspi *qca = netdev_priv(dev);
690-
int ret = 0;
677+
struct task_struct *thread;
691678

692679
if (!qca)
693680
return -EINVAL;
@@ -697,23 +684,18 @@ qcaspi_netdev_open(struct net_device *dev)
697684
qca->sync = QCASPI_SYNC_UNKNOWN;
698685
qcafrm_fsm_init_spi(&qca->frm_handle);
699686

700-
qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
701-
qca, "%s", dev->name);
687+
thread = kthread_run((void *)qcaspi_spi_thread,
688+
qca, "%s", dev->name);
702689

703-
if (IS_ERR(qca->spi_thread)) {
690+
if (IS_ERR(thread)) {
704691
netdev_err(dev, "%s: unable to start kernel thread.\n",
705692
QCASPI_DRV_NAME);
706-
return PTR_ERR(qca->spi_thread);
693+
return PTR_ERR(thread);
707694
}
708695

709-
ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0,
710-
dev->name, qca);
711-
if (ret) {
712-
netdev_err(dev, "%s: unable to get IRQ %d (irqval=%d).\n",
713-
QCASPI_DRV_NAME, qca->spi_dev->irq, ret);
714-
kthread_stop(qca->spi_thread);
715-
return ret;
716-
}
696+
qca->spi_thread = thread;
697+
698+
enable_irq(qca->spi_dev->irq);
717699

718700
/* SPI thread takes care of TX queue */
719701

@@ -728,10 +710,12 @@ qcaspi_netdev_close(struct net_device *dev)
728710
netif_stop_queue(dev);
729711

730712
qcaspi_write_register(qca, SPI_REG_INTR_ENABLE, 0, wr_verify);
731-
free_irq(qca->spi_dev->irq, qca);
713+
disable_irq(qca->spi_dev->irq);
732714

733-
kthread_stop(qca->spi_thread);
734-
qca->spi_thread = NULL;
715+
if (qca->spi_thread) {
716+
kthread_stop(qca->spi_thread);
717+
qca->spi_thread = NULL;
718+
}
735719
qcaspi_flush_tx_ring(qca);
736720

737721
return 0;
@@ -831,8 +815,8 @@ qcaspi_netdev_init(struct net_device *dev)
831815
qca->clkspeed = qcaspi_clkspeed;
832816
qca->burst_len = qcaspi_burst_len;
833817
qca->spi_thread = NULL;
834-
qca->buffer_size = (dev->mtu + VLAN_ETH_HLEN + QCAFRM_HEADER_LEN +
835-
QCAFRM_FOOTER_LEN + 4) * 4;
818+
qca->buffer_size = (QCAFRM_MAX_MTU + VLAN_ETH_HLEN + QCAFRM_HEADER_LEN +
819+
QCAFRM_FOOTER_LEN + QCASPI_HW_PKT_LEN) * QCASPI_RX_MAX_FRAMES;
836820

837821
memset(&qca->stats, 0, sizeof(struct qcaspi_stats));
838822

@@ -881,6 +865,8 @@ qcaspi_netdev_setup(struct net_device *dev)
881865
qcaspi_set_ethtool_ops(dev);
882866
dev->watchdog_timeo = QCASPI_TX_TIMEOUT;
883867
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
868+
dev->needed_tailroom = ALIGN(QCAFRM_FOOTER_LEN + QCAFRM_MIN_LEN, 4);
869+
dev->needed_headroom = ALIGN(QCAFRM_HEADER_LEN, 4);
884870
dev->tx_queue_len = 100;
885871

886872
/* MTU range: 46 - 1500 */
@@ -891,7 +877,7 @@ qcaspi_netdev_setup(struct net_device *dev)
891877
memset(qca, 0, sizeof(struct qcaspi));
892878

893879
memset(&qca->txr, 0, sizeof(qca->txr));
894-
qca->txr.count = TX_RING_MAX_LEN;
880+
qca->txr.count = QCASPI_TX_RING_MAX_LEN;
895881
}
896882

897883
static const struct of_device_id qca_spi_of_match[] = {
@@ -984,6 +970,15 @@ qca_spi_probe(struct spi_device *spi)
984970

985971
spi_set_drvdata(spi, qcaspi_devs);
986972

973+
ret = devm_request_irq(&spi->dev, spi->irq, qcaspi_intr_handler,
974+
IRQF_NO_AUTOEN, qca->net_dev->name, qca);
975+
if (ret) {
976+
dev_err(&spi->dev, "Unable to get IRQ %d (irqval=%d).\n",
977+
spi->irq, ret);
978+
free_netdev(qcaspi_devs);
979+
return ret;
980+
}
981+
987982
ret = of_get_ethdev_address(spi->dev.of_node, qca->net_dev);
988983
if (ret) {
989984
eth_hw_addr_random(qca->net_dev);
@@ -998,8 +993,8 @@ qca_spi_probe(struct spi_device *spi)
998993
qcaspi_read_register(qca, SPI_REG_SIGNATURE, &signature);
999994

1000995
if (signature != QCASPI_GOOD_SIGNATURE) {
1001-
dev_err(&spi->dev, "Invalid signature (0x%04X)\n",
1002-
signature);
996+
dev_err(&spi->dev, "Invalid signature (expected 0x%04x, read 0x%04x)\n",
997+
QCASPI_GOOD_SIGNATURE, signature);
1003998
free_netdev(qcaspi_devs);
1004999
return -EFAULT;
10051000
}
@@ -1048,6 +1043,6 @@ module_spi_driver(qca_spi_driver);
10481043

10491044
MODULE_DESCRIPTION("Qualcomm Atheros QCA7000 SPI Driver");
10501045
MODULE_AUTHOR("Qualcomm Atheros Communications");
1051-
MODULE_AUTHOR("Stefan Wahren <[email protected]>");
1046+
MODULE_AUTHOR("Stefan Wahren <[email protected]>");
10521047
MODULE_LICENSE("Dual BSD/GPL");
10531048
MODULE_VERSION(QCASPI_DRV_VERSION);

0 commit comments

Comments
 (0)