Skip to content

Commit 2d71982

Browse files
lategoodbyePaolo Abeni
authored andcommitted
qca_spi: Make interrupt remembering atomic
The whole mechanism to remember occurred SPI interrupts is not atomic, which could lead to unexpected behavior. So fix this by using atomic bit operations instead. Fixes: 291ab06 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent ff960f9 commit 2d71982

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

drivers/net/ethernet/qualcomm/qca_debug.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@ qcaspi_info_show(struct seq_file *s, void *what)
9898

9999
seq_printf(s, "IRQ : %d\n",
100100
qca->spi_dev->irq);
101-
seq_printf(s, "INTR REQ : %u\n",
102-
qca->intr_req);
103-
seq_printf(s, "INTR SVC : %u\n",
104-
qca->intr_svc);
101+
seq_printf(s, "INTR : %lx\n",
102+
qca->intr);
105103

106104
seq_printf(s, "SPI max speed : %lu\n",
107105
(unsigned long)qca->spi_dev->max_speed_hz);

drivers/net/ethernet/qualcomm/qca_spi.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#define MAX_DMA_BURST_LEN 5000
3737

38+
#define SPI_INTR 0
39+
3840
/* Modules parameters */
3941
#define QCASPI_CLK_SPEED_MIN 1000000
4042
#define QCASPI_CLK_SPEED_MAX 16000000
@@ -579,14 +581,14 @@ qcaspi_spi_thread(void *data)
579581
continue;
580582
}
581583

582-
if ((qca->intr_req == qca->intr_svc) &&
584+
if (!test_bit(SPI_INTR, &qca->intr) &&
583585
!qca->txr.skb[qca->txr.head])
584586
schedule();
585587

586588
set_current_state(TASK_RUNNING);
587589

588-
netdev_dbg(qca->net_dev, "have work to do. int: %d, tx_skb: %p\n",
589-
qca->intr_req - qca->intr_svc,
590+
netdev_dbg(qca->net_dev, "have work to do. int: %lu, tx_skb: %p\n",
591+
qca->intr,
590592
qca->txr.skb[qca->txr.head]);
591593

592594
qcaspi_qca7k_sync(qca, QCASPI_EVENT_UPDATE);
@@ -600,8 +602,7 @@ qcaspi_spi_thread(void *data)
600602
msleep(QCASPI_QCA7K_REBOOT_TIME_MS);
601603
}
602604

603-
if (qca->intr_svc != qca->intr_req) {
604-
qca->intr_svc = qca->intr_req;
605+
if (test_and_clear_bit(SPI_INTR, &qca->intr)) {
605606
start_spi_intr_handling(qca, &intr_cause);
606607

607608
if (intr_cause & SPI_INT_CPU_ON) {
@@ -663,7 +664,7 @@ qcaspi_intr_handler(int irq, void *data)
663664
{
664665
struct qcaspi *qca = data;
665666

666-
qca->intr_req++;
667+
set_bit(SPI_INTR, &qca->intr);
667668
if (qca->spi_thread)
668669
wake_up_process(qca->spi_thread);
669670

@@ -679,8 +680,7 @@ qcaspi_netdev_open(struct net_device *dev)
679680
if (!qca)
680681
return -EINVAL;
681682

682-
qca->intr_req = 1;
683-
qca->intr_svc = 0;
683+
set_bit(SPI_INTR, &qca->intr);
684684
qca->sync = QCASPI_SYNC_UNKNOWN;
685685
qcafrm_fsm_init_spi(&qca->frm_handle);
686686

drivers/net/ethernet/qualcomm/qca_spi.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ struct qcaspi {
8181
struct qcafrm_handle frm_handle;
8282
struct sk_buff *rx_skb;
8383

84-
unsigned int intr_req;
85-
unsigned int intr_svc;
84+
unsigned long intr;
8685
u16 reset_count;
8786

8887
#ifdef CONFIG_DEBUG_FS

0 commit comments

Comments
 (0)