Skip to content

Commit 11d9e22

Browse files
ahduyckSasha Levin
authored andcommitted
fbnic: Improve responsiveness of fbnic_mbx_poll_tx_ready
[ Upstream commit ab064f6 ] There were a couple different issues found in fbnic_mbx_poll_tx_ready. Among them were the fact that we were sleeping much longer than we actually needed to as the actual FW could respond in under 20ms. The other issue was that we would just keep polling the mailbox even if the device itself had gone away. To address the responsiveness issues we can decrease the sleeps to 20ms and use a jiffies based timeout value rather than just counting the number of times we slept and then polled. To address the hardware going away we can move the check for the firmware BAR being present from where it was and place it inside the loop after the mailbox descriptor ring is initialized and before we sleep so that we just abort and return an error if the device went away during initialization. With these two changes we see a significant improvement in boot times for the driver. Fixes: da3cde0 ("eth: fbnic: Add FW communication mechanism") Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/174654721224.499179.2698616208976624755.stgit@ahduyck-xeon-server.home.arpa Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 62fcb91 commit 11d9e22

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -772,27 +772,30 @@ void fbnic_mbx_poll(struct fbnic_dev *fbd)
772772

773773
int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
774774
{
775+
unsigned long timeout = jiffies + 10 * HZ + 1;
775776
struct fbnic_fw_mbx *tx_mbx;
776-
int attempts = 50;
777-
778-
/* Immediate fail if BAR4 isn't there */
779-
if (!fbnic_fw_present(fbd))
780-
return -ENODEV;
781777

782778
tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX];
783-
while (!tx_mbx->ready && --attempts) {
779+
while (!tx_mbx->ready) {
780+
if (!time_is_after_jiffies(timeout))
781+
return -ETIMEDOUT;
782+
784783
/* Force the firmware to trigger an interrupt response to
785784
* avoid the mailbox getting stuck closed if the interrupt
786785
* is reset.
787786
*/
788787
fbnic_mbx_reset_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX);
789788

790-
msleep(200);
789+
/* Immediate fail if BAR4 went away */
790+
if (!fbnic_fw_present(fbd))
791+
return -ENODEV;
792+
793+
msleep(20);
791794

792795
fbnic_mbx_poll(fbd);
793796
}
794797

795-
return attempts ? 0 : -ETIMEDOUT;
798+
return 0;
796799
}
797800

798801
void fbnic_mbx_flush_tx(struct fbnic_dev *fbd)

0 commit comments

Comments
 (0)