Skip to content

Commit cdbb2dc

Browse files
ahduyckPaolo Abeni
authored andcommitted
fbnic: Cleanup handling of completions
There was an issue in that if we were to shutdown we could be left with a completion in flight as the mailbox went away. To address that I have added an fbnic_mbx_evict_all_cmpl function that is meant to essentially create a "broken pipe" type response so that all callers will receive an error indicating that the connection has been broken as a result of us shutting down the mailbox. Fixes: 378e5cc ("eth: fbnic: hwmon: Add completion infrastructure for firmware requests") Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/174654720578.499179.380252598204530873.stgit@ahduyck-xeon-server.home.arpa Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 0f9a959 commit cdbb2dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_fw.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,20 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
928928
return attempts ? 0 : -ETIMEDOUT;
929929
}
930930

931+
static void __fbnic_fw_evict_cmpl(struct fbnic_fw_completion *cmpl_data)
932+
{
933+
cmpl_data->result = -EPIPE;
934+
complete(&cmpl_data->done);
935+
}
936+
937+
static void fbnic_mbx_evict_all_cmpl(struct fbnic_dev *fbd)
938+
{
939+
if (fbd->cmpl_data) {
940+
__fbnic_fw_evict_cmpl(fbd->cmpl_data);
941+
fbd->cmpl_data = NULL;
942+
}
943+
}
944+
931945
void fbnic_mbx_flush_tx(struct fbnic_dev *fbd)
932946
{
933947
unsigned long timeout = jiffies + 10 * HZ + 1;
@@ -945,6 +959,9 @@ void fbnic_mbx_flush_tx(struct fbnic_dev *fbd)
945959
/* Read tail to determine the last tail state for the ring */
946960
tail = tx_mbx->tail;
947961

962+
/* Flush any completions as we are no longer processing Rx */
963+
fbnic_mbx_evict_all_cmpl(fbd);
964+
948965
spin_unlock_irq(&fbd->fw_tx_lock);
949966

950967
/* Give firmware time to process packet,

0 commit comments

Comments
 (0)