netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-net-drivers@solarflare.com>
Subject: [PATCH net-next 19/32] sfc: Remove dependence on NAPI polling in efx_test_eventq_irq()
Date: Fri, 27 Jan 2012 20:48:37 +0000	[thread overview]
Message-ID: <1327697317.2503.26.camel@bwh-desktop> (raw)
In-Reply-To: <1327696858.2503.7.camel@bwh-desktop>

We cannot safely assume that the NAPI handler will complete within the
20 ms that we allow for the event self-test.  The handler may be
deferred for longer than this, particularly on realtime kernels.

Instead, check whether either an event has been handled or (as in the
old failure path) whether an interrupt has been received and an event
has been delivered but not yet handled.  Use napi_disable() to
synchronize with the NAPI handler before checking, since it will
clear events before updating eventq_read_ptr.

Remove the test result chan.N.eventq.poll, since it is not an error
if the NAPI handler does not run during the test.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/ethernet/sfc/ethtool.c  |    4 --
 drivers/net/ethernet/sfc/selftest.c |   79 ++++++++++++++++++-----------------
 drivers/net/ethernet/sfc/selftest.h |    1 -
 3 files changed, 40 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 1a7f7ba..ba90116 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -404,10 +404,6 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 			      &tests->eventq_int[channel->channel],
 			      EFX_CHANNEL_NAME(channel),
 			      "eventq.int", NULL);
-		efx_fill_test(n++, strings, data,
-			      &tests->eventq_poll[channel->channel],
-			      EFX_CHANNEL_NAME(channel),
-			      "eventq.poll", NULL);
 	}
 
 	efx_fill_test(n++, strings, data, &tests->registers,
diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c
index 7718287..0f84789 100644
--- a/drivers/net/ethernet/sfc/selftest.c
+++ b/drivers/net/ethernet/sfc/selftest.c
@@ -161,11 +161,8 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
 			       struct efx_self_tests *tests)
 {
 	struct efx_nic *efx = channel->efx;
-	unsigned int read_ptr, count;
-
-	tests->eventq_dma[channel->channel] = -1;
-	tests->eventq_int[channel->channel] = -1;
-	tests->eventq_poll[channel->channel] = -1;
+	unsigned int read_ptr;
+	bool napi_ran, dma_seen, int_seen;
 
 	read_ptr = channel->eventq_read_ptr;
 	channel->efx->last_irq_cpu = -1;
@@ -173,44 +170,48 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
 
 	efx_nic_generate_test_event(channel);
 
-	/* Wait for arrival of interrupt */
-	count = 0;
-	do {
-		schedule_timeout_uninterruptible(HZ / 100);
-
-		if (ACCESS_ONCE(channel->eventq_read_ptr) != read_ptr)
-			goto eventq_ok;
-	} while (++count < 2);
-
-	netif_err(efx, drv, efx->net_dev,
-		  "channel %d timed out waiting for event queue\n",
-		  channel->channel);
-
-	/* See if interrupt arrived */
-	if (channel->efx->last_irq_cpu >= 0) {
-		netif_err(efx, drv, efx->net_dev,
-			  "channel %d saw interrupt on CPU%d "
-			  "during event queue test\n", channel->channel,
-			  raw_smp_processor_id());
-		tests->eventq_int[channel->channel] = 1;
+	/* Wait for arrival of interrupt.  NAPI processing may or may
+	 * not complete in time, but we can cope in any case.
+	 */
+	msleep(10);
+	napi_disable(&channel->napi_str);
+	if (channel->eventq_read_ptr != read_ptr) {
+		napi_ran = true;
+		dma_seen = true;
+		int_seen = true;
+	} else {
+		napi_ran = false;
+		dma_seen = efx_nic_event_present(channel);
+		int_seen = efx->last_irq_cpu >= 0;
 	}
+	napi_enable(&channel->napi_str);
+	efx_nic_eventq_read_ack(channel);
+
+	tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1;
+	tests->eventq_int[channel->channel] = int_seen ? 1 : -1;
 
-	/* Check to see if event was received even if interrupt wasn't */
-	if (efx_nic_event_present(channel)) {
+	if (dma_seen && int_seen) {
+		netif_dbg(efx, drv, efx->net_dev,
+			  "channel %d event queue passed (with%s NAPI)\n",
+			  channel->channel, napi_ran ? "" : "out");
+		return 0;
+	} else {
+		/* Report failure and whether either interrupt or DMA worked */
 		netif_err(efx, drv, efx->net_dev,
-			  "channel %d event was generated, but "
-			  "failed to trigger an interrupt\n", channel->channel);
-		tests->eventq_dma[channel->channel] = 1;
+			  "channel %d timed out waiting for event queue\n",
+			  channel->channel);
+		if (int_seen)
+			netif_err(efx, drv, efx->net_dev,
+				  "channel %d saw interrupt "
+				  "during event queue test\n",
+				  channel->channel);
+		if (dma_seen)
+			netif_err(efx, drv, efx->net_dev,
+				  "channel %d event was generated, but "
+				  "failed to trigger an interrupt\n",
+				  channel->channel);
+		return -ETIMEDOUT;
 	}
-
-	return -ETIMEDOUT;
- eventq_ok:
-	netif_dbg(efx, drv, efx->net_dev, "channel %d event queue passed\n",
-		  channel->channel);
-	tests->eventq_dma[channel->channel] = 1;
-	tests->eventq_int[channel->channel] = 1;
-	tests->eventq_poll[channel->channel] = 1;
-	return 0;
 }
 
 static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
diff --git a/drivers/net/ethernet/sfc/selftest.h b/drivers/net/ethernet/sfc/selftest.h
index dba5456..87abe2a 100644
--- a/drivers/net/ethernet/sfc/selftest.h
+++ b/drivers/net/ethernet/sfc/selftest.h
@@ -37,7 +37,6 @@ struct efx_self_tests {
 	int interrupt;
 	int eventq_dma[EFX_MAX_CHANNELS];
 	int eventq_int[EFX_MAX_CHANNELS];
-	int eventq_poll[EFX_MAX_CHANNELS];
 	/* offline tests */
 	int registers;
 	int phy_ext[EFX_MAX_PHY_TESTS];
-- 
1.7.7.5



-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  parent reply	other threads:[~2012-01-27 20:48 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 20:40 pull request: sfc-next 2012-01-27 Ben Hutchings
2012-01-27 20:42 ` [PATCH net-next 01/32] sfc: Fix some formatting errors reported by checkpatch Ben Hutchings
2012-01-27 20:42 ` [PATCH net-next 02/32] sfc: Avoid assignment in an if-statement, " Ben Hutchings
2012-01-27 20:42 ` [PATCH net-next 03/32] sfc: Remove parentheses around return expressions, " Ben Hutchings
2012-01-27 21:01   ` Joe Perches
2012-01-30 16:45     ` Ben Hutchings
2012-01-27 20:43 ` [PATCH net-next 04/32] sfc: Const-qualify static data as appropriate, partly prompted " Ben Hutchings
2012-01-27 20:43 ` [PATCH net-next 05/32] sfc: Remove unnecessary inclusion of <asm/io.h>, " Ben Hutchings
2012-01-27 20:43 ` [PATCH net-next 06/32] sfc: Update MCDI (firmware interface) definitions Ben Hutchings
2012-01-27 20:44 ` [PATCH net-next 07/32] sfc: Rename efx_wanted_channels() to efx_wanted_parallelism() Ben Hutchings
2012-01-27 20:44 ` [PATCH net-next 08/32] sfc: Set default parallelism to per-core by default Ben Hutchings
2012-01-27 20:44 ` [PATCH net-next 09/32] sfc: Remove fallback for invalid permanent MAC address Ben Hutchings
2012-01-27 20:45 ` [PATCH net-next 10/32] sfc: Make handling of MC reboot more reliable Ben Hutchings
2012-01-27 20:45 ` [PATCH net-next 11/32] sfc: Use new names for MC shared memory layout constants Ben Hutchings
2012-01-27 20:45 ` [PATCH net-next 12/32] sfc: Hold efx_nic::stats_lock while reading efx_nic::mac_stats Ben Hutchings
2012-01-27 20:45 ` [PATCH net-next 13/32] sfc: Merge efx_mac_operations into efx_nic_type Ben Hutchings
2012-01-27 20:46 ` [PATCH net-next 14/32] sfc: Merge efx_mcdi_mac_check_fault() and efx_mcdi_get_mac_faults() Ben Hutchings
2012-01-27 20:46 ` [PATCH net-next 15/32] sfc: Remove efx_nic_type::push_multicast_hash operation Ben Hutchings
2012-01-27 20:46 ` [PATCH net-next 16/32] sfc: Consistently test DEBUG macro, not EFX_ENABLE_DEBUG Ben Hutchings
2012-01-27 20:47 ` [PATCH net-next 17/32] sfc: Support extraction of CAPABILITIES from GET_BOARD_CFG response Ben Hutchings
2012-01-27 20:48 ` [PATCH net-next 18/32] sfc: Correct interrupt timer quantum for Siena (normal and turbo mode) Ben Hutchings
2012-01-27 20:48 ` Ben Hutchings [this message]
2012-01-27 20:48 ` [PATCH net-next 20/32] Partly revert "sfc: Handle serious errors in exactly one interrupt handler" Ben Hutchings
2012-01-27 20:49 ` [PATCH net-next 21/32] sfc: Clean up test interrupt handling Ben Hutchings
2012-01-27 20:49 ` [PATCH net-next 22/32] sfc: Add hwmon driver for boards using SFC9000-family controllers Ben Hutchings
2012-01-27 20:50 ` [PATCH net-next 23/32] sfc: Update the description of SFC_MTD Ben Hutchings
2012-01-27 20:50 ` [PATCH net-next 24/32] sfc: Remove obsolete function efx_dev_name() Ben Hutchings
2012-01-27 20:50 ` [PATCH net-next 25/32] sfc: Remove remnants of on-load self-test Ben Hutchings
2012-01-27 20:51 ` [PATCH net-next 26/32] sfc: Use existing local variables instead of repeated indirect lookups Ben Hutchings
2012-01-27 20:51 ` [PATCH net-next 27/32] sfc: Minor formatting fixes Ben Hutchings
2012-01-27 20:51 ` [PATCH net-next 28/32] sfc: Remove redundant 'rc' variable, always set to 0 Ben Hutchings
2012-01-27 20:52 ` [PATCH net-next 29/32] sfc: Rename implementation of ndo_set_rx_mode Ben Hutchings
2012-01-27 20:53 ` [PATCH net-next 30/32] sfc: Make all MAC statistics consistently 64 bits wide Ben Hutchings
2012-01-27 20:54 ` [PATCH net-next 31/32] sfc: Move the end of the non-GRO RX path into its own function Ben Hutchings
2012-01-27 20:54 ` [PATCH net-next 32/32] sfc: Replace efx_rx_buffer::is_page and other booleans with a flags field Ben Hutchings
2012-01-29 21:18 ` pull request: sfc-next 2012-01-27 David Miller
2012-01-29 21:40   ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327697317.2503.26.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).