]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
sfc: Fix two causes of flush failure
authorBen Hutchings <bhutchings@solarflare.com>
Mon, 23 May 2011 11:18:45 +0000 (12:18 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 27 Mar 2013 02:41:08 +0000 (02:41 +0000)
[ Upstream commits a606f4325dca6950996abbae452d33f2af095f39,
  d5e8cc6c946e0857826dcfbb3585068858445bfe,
  525d9e824018cd7cc8d8d44832ddcd363abfe6e1 ]

The TX DMA engine issues upstream read requests when there is room in
the TX FIFO for the completion. However, the fetches for the rest of
the packet might be delayed by any back pressure.  Since a flush must
wait for an EOP, the entire flush may be delayed by back pressure.

Mitigate this by disabling flow control before the flushes are
started.  Since PF and VF flushes run in parallel introduce
fc_disable, a reference count of the number of flushes outstanding.

The same principle could be applied to Falcon, but that
would bring with it its own testing.

We sometimes hit a "failed to flush" timeout on some TX queues, but the
flushes have completed and the flush completion events seem to go missing.
In this case, we can check the TX_DESC_PTR_TBL register and drain the
queues if the flushes had finished.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
[bwh: Backported to 3.2:
 - Call efx_nic_type::finish_flush() on both success and failure paths
 - Check the TX_DESC_PTR_TBL registers in the polling loop
 - Declare efx_mcdi_set_mac() extern]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ethernet/sfc/falcon.c
drivers/net/ethernet/sfc/mcdi.h
drivers/net/ethernet/sfc/mcdi_mac.c
drivers/net/ethernet/sfc/net_driver.h
drivers/net/ethernet/sfc/nic.c
drivers/net/ethernet/sfc/nic.h
drivers/net/ethernet/sfc/siena.c

index 97b606b92e881eb6aeda796ec7286834f3422041..26cd6c0cc2a2ea5f070dfe58a6390ef9f2e4bc71 100644 (file)
@@ -1762,6 +1762,7 @@ const struct efx_nic_type falcon_a1_nic_type = {
        .remove_port = falcon_remove_port,
        .handle_global_event = falcon_handle_global_event,
        .prepare_flush = falcon_prepare_flush,
+       .finish_flush = efx_port_dummy_op_void,
        .update_stats = falcon_update_nic_stats,
        .start_stats = falcon_start_nic_stats,
        .stop_stats = falcon_stop_nic_stats,
@@ -1804,6 +1805,7 @@ const struct efx_nic_type falcon_b0_nic_type = {
        .remove_port = falcon_remove_port,
        .handle_global_event = falcon_handle_global_event,
        .prepare_flush = falcon_prepare_flush,
+       .finish_flush = efx_port_dummy_op_void,
        .update_stats = falcon_update_nic_stats,
        .start_stats = falcon_start_nic_stats,
        .stop_stats = falcon_stop_nic_stats,
index aced2a7856fcbc60310524a86eb44745c90f791a..b61eea046160f75b96bef3ff0371595c06a4b62e 100644 (file)
@@ -126,5 +126,6 @@ extern int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx,
 extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out);
 extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id);
 extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx);
+extern int efx_mcdi_set_mac(struct efx_nic *efx);
 
 #endif /* EFX_MCDI_H */
index 50c20777a5640ffdfbe67adae3505eff68b90cff..da269d7076cecf0a751539a61859ab24764d1f60 100644 (file)
@@ -13,7 +13,7 @@
 #include "mcdi.h"
 #include "mcdi_pcol.h"
 
-static int efx_mcdi_set_mac(struct efx_nic *efx)
+int efx_mcdi_set_mac(struct efx_nic *efx)
 {
        u32 reject, fcntl;
        u8 cmdbytes[MC_CMD_SET_MAC_IN_LEN];
@@ -45,6 +45,8 @@ static int efx_mcdi_set_mac(struct efx_nic *efx)
        }
        if (efx->wanted_fc & EFX_FC_AUTO)
                fcntl = MC_CMD_FCNTL_AUTO;
+       if (efx->fc_disable)
+               fcntl = MC_CMD_FCNTL_OFF;
 
        MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
 
index b8e251a1ee48694063693698d83a25527b3c1f7c..9e2e802dc2f64f9bb597c48b2a37249a96b0665f 100644 (file)
@@ -689,6 +689,9 @@ struct efx_filter_state;
  * @promiscuous: Promiscuous flag. Protected by netif_tx_lock.
  * @multicast_hash: Multicast hash table
  * @wanted_fc: Wanted flow control flags
+ * @fc_disable: When non-zero flow control is disabled. Typically used to
+ *     ensure that network back pressure doesn't delay dma queue flushes.
+ *     Serialised by the rtnl lock.
  * @mac_work: Work item for changing MAC promiscuity and multicast hash
  * @loopback_mode: Loopback status
  * @loopback_modes: Supported loopback mode bitmask
@@ -782,6 +785,7 @@ struct efx_nic {
        bool promiscuous;
        union efx_multicast_hash multicast_hash;
        u8 wanted_fc;
+       unsigned fc_disable;
 
        atomic_t rx_reset;
        enum efx_loopback_mode loopback_mode;
@@ -835,6 +839,7 @@ static inline unsigned int efx_port_num(struct efx_nic *efx)
  * @remove_port: Free resources allocated by probe_port()
  * @handle_global_event: Handle a "global" event (may be %NULL)
  * @prepare_flush: Prepare the hardware for flushing the DMA queues
+ * @finish_flush: Clean up after flushing the DMA queues
  * @update_stats: Update statistics not provided by event handling
  * @start_stats: Start the regular fetching of statistics
  * @stop_stats: Stop the regular fetching of statistics
@@ -880,6 +885,7 @@ struct efx_nic_type {
        void (*remove_port)(struct efx_nic *efx);
        bool (*handle_global_event)(struct efx_channel *channel, efx_qword_t *);
        void (*prepare_flush)(struct efx_nic *efx);
+       void (*finish_flush)(struct efx_nic *efx);
        void (*update_stats)(struct efx_nic *efx);
        void (*start_stats)(struct efx_nic *efx);
        void (*stop_stats)(struct efx_nic *efx);
index 3edfbaf5f0229b2190e9e40ec554b4b9c6a84c86..9cca2a632fd809ae6c1198f888c7de80ad672b73 100644 (file)
@@ -1261,13 +1261,27 @@ int efx_nic_flush_queues(struct efx_nic *efx)
                        }
                        efx_for_each_possible_channel_tx_queue(tx_queue, channel) {
                                if (tx_queue->initialised &&
-                                   tx_queue->flushed != FLUSH_DONE)
-                                       ++tx_pending;
+                                   tx_queue->flushed != FLUSH_DONE) {
+                                       efx_oword_t txd_ptr_tbl;
+
+                                       efx_reado_table(efx, &txd_ptr_tbl,
+                                                       FR_BZ_TX_DESC_PTR_TBL,
+                                                       tx_queue->queue);
+                                       if (EFX_OWORD_FIELD(txd_ptr_tbl,
+                                                           FRF_AZ_TX_DESCQ_FLUSH) ||
+                                           EFX_OWORD_FIELD(txd_ptr_tbl,
+                                                           FRF_AZ_TX_DESCQ_EN))
+                                               ++tx_pending;
+                                       else
+                                               tx_queue->flushed = FLUSH_DONE;
+                               }
                        }
                }
 
-               if (rx_pending == 0 && tx_pending == 0)
+               if (rx_pending == 0 && tx_pending == 0) {
+                       efx->type->finish_flush(efx);
                        return 0;
+               }
 
                msleep(EFX_FLUSH_INTERVAL);
                efx_poll_flush_events(efx);
@@ -1293,6 +1307,7 @@ int efx_nic_flush_queues(struct efx_nic *efx)
                }
        }
 
+       efx->type->finish_flush(efx);
        return -ETIMEDOUT;
 }
 
index 66ece48003441d968071e0b4a3d09f728d6795d1..58302a26aa83db455f64ea454d7491f60320fcc9 100644 (file)
@@ -210,6 +210,8 @@ extern void falcon_irq_ack_a1(struct efx_nic *efx);
 
 /* Global Resources */
 extern int efx_nic_flush_queues(struct efx_nic *efx);
+extern void siena_prepare_flush(struct efx_nic *efx);
+extern void siena_finish_flush(struct efx_nic *efx);
 extern void falcon_start_nic_stats(struct efx_nic *efx);
 extern void falcon_stop_nic_stats(struct efx_nic *efx);
 extern void falcon_setup_xaui(struct efx_nic *efx);
index cc2549cb70765e7483a20e3f6998e7abd92d820c..c58b97346bf46873bff8563903d58378f7a18f41 100644 (file)
@@ -137,6 +137,18 @@ static void siena_remove_port(struct efx_nic *efx)
        efx_nic_free_buffer(efx, &efx->stats_buffer);
 }
 
+void siena_prepare_flush(struct efx_nic *efx)
+{
+       if (efx->fc_disable++ == 0)
+               efx_mcdi_set_mac(efx);
+}
+
+void siena_finish_flush(struct efx_nic *efx)
+{
+       if (--efx->fc_disable == 0)
+               efx_mcdi_set_mac(efx);
+}
+
 static const struct efx_nic_register_test siena_register_tests[] = {
        { FR_AZ_ADR_REGION,
          EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
@@ -624,7 +636,8 @@ const struct efx_nic_type siena_a0_nic_type = {
        .reset = siena_reset_hw,
        .probe_port = siena_probe_port,
        .remove_port = siena_remove_port,
-       .prepare_flush = efx_port_dummy_op_void,
+       .prepare_flush = siena_prepare_flush,
+       .finish_flush = siena_finish_flush,
        .update_stats = siena_update_nic_stats,
        .start_stats = siena_start_nic_stats,
        .stop_stats = siena_stop_nic_stats,