liquidio: fix race condition in instruction completion processing
Subsystems (3)
PATCH 1/1 liquidio: fix race condition in instruction completion processing
From: Rick Farrington <[email protected]>
In lio_enable_irq, the pkt_in_done count register was being cleared to zero. However, there could be some completed instructions which were not yet processed due to budget and limit constraints.
So, only write this register with the number of actual completions that were processed.
--- drivers/net/ethernet/cavium/liquidio/octeon_device.c | 5 +++-- drivers/net/ethernet/cavium/liquidio/octeon_iq.h | 2 ++ drivers/net/ethernet/cavium/liquidio/request_manager.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_device.c +3 -2
@@ -1450,8 +1450,9 @@ void lio_enable_irq(struct octeon_droq *droq, struct octeon_instr_queue *iq) }if (iq) {spin_lock_bh (&iq->lock); -writel (iq->pkt_in_done, iq->inst_cnt_reg); - iq->pkt_in_done =0 ; +writel (iq->pkts_processed, iq->inst_cnt_reg); + iq->pkt_in_done -= iq->pkts_processed; + iq->pkts_processed =0 ;/* this write needs to be flushed before we release the lock */ mmiowb ();spin_unlock_bh (&iq->lock);
drivers/net/ethernet/cavium/liquidio/octeon_iq.h +2 -0
@@ -94,6 +94,8 @@ struct octeon_instr_queue {u32 pkt_in_done; +u32 pkts_processed; +/** A spinlock to protect access to the input ring.*/ spinlock_t iq_flush_running_lock;
drivers/net/ethernet/cavium/liquidio/request_manager.c +2 -0
@@ -123,6 +123,7 @@ int octeon_init_instr_queue(struct octeon_device *oct, iq->do_auto_flush =1 ; iq->db_timeout = (u32 )conf->db_timeout;atomic_set (&iq->instr_pending,0 ); + iq->pkts_processed =0 ;/* Initialize the spinlock for this instruction queue */ spin_lock_init (&iq->lock);
@@ -495,6 +496,7 @@ static inline void __copy_cmd_into_iq(struct octeon_instr_queue *iq,lio_process_iq_request_list (oct, iq,0 );if (inst_processed) { + iq->pkts_processed += inst_processed;atomic_sub (inst_processed, &iq->instr_pending); iq->stats.instr_processed += inst_processed; }
Signature · 1 line
1.8.3.1
From: Felix Manlunas <[email protected]>
Date: Tue, 28 Aug 2018 11:32:55 -0700
Quoted 10 lines
From: Rick Farrington <[email protected]>
In
lio_enable_irq, thepkt_in_donecount register was being cleared to zero. However, there could be some completed instructions which were not yet processed due to budget and limit constraints.
So, only write this register with the number of actual completions that were processed.Signed-off-by Rick Farrington <[email protected]>Signed-off-by Felix Manlunas <[email protected]>
Applied.