All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bimmy Pujari <bimmy.pujari@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next PATCH S53-V2 5/5] i40e: lock service task correctly
Date: Mon, 14 Nov 2016 13:06:49 -0800	[thread overview]
Message-ID: <1479157609-30812-5-git-send-email-bimmy.pujari@intel.com> (raw)
In-Reply-To: <1479157609-30812-1-git-send-email-bimmy.pujari@intel.com>

From: Mitch Williams <mitch.a.williams@intel.com>

The service task lock was being set in the scheduling function, not the
actual service task. This would potentially leave the bit set for a long
time before the task actually ran. Furthermore, if the service task
takes too long, it calls the schedule function to reschedule itself -
which would fail to take the lock and do nothing.

Instead, set and clear the lock bit in the service task itself. In the
process, get rid of the i40e_service_event_complete() function, which is
really just two lines of code that can be put right in the service task
itself.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Change-ID: I83155e682b686121e2897f4429eb7d3f7c669168
---
Testing Hints : Should be no functional change, particularly around 
link up/down events. This is prep work for using this lock bit in 
the client.
 
 drivers/net/ethernet/intel/i40e/i40e_main.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 849feaa..57850fd 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -288,8 +288,7 @@ struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id)
 void i40e_service_event_schedule(struct i40e_pf *pf)
 {
 	if (!test_bit(__I40E_DOWN, &pf->state) &&
-	    !test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) &&
-	    !test_and_set_bit(__I40E_SERVICE_SCHED, &pf->state))
+	    !test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state))
 		queue_work(i40e_wq, &pf->service_task);
 }
 
@@ -5943,19 +5942,6 @@ static void i40e_handle_lan_overflow_event(struct i40e_pf *pf,
 }
 
 /**
- * i40e_service_event_complete - Finish up the service event
- * @pf: board private structure
- **/
-static void i40e_service_event_complete(struct i40e_pf *pf)
-{
-	WARN_ON(!test_bit(__I40E_SERVICE_SCHED, &pf->state));
-
-	/* flush memory to make sure state is correct before next watchog */
-	smp_mb__before_atomic();
-	clear_bit(__I40E_SERVICE_SCHED, &pf->state);
-}
-
-/**
  * i40e_get_cur_guaranteed_fd_count - Get the consumed guaranteed FD filters
  * @pf: board private structure
  **/
@@ -7264,10 +7250,12 @@ static void i40e_service_task(struct work_struct *work)
 
 	/* don't bother with service tasks if a reset is in progress */
 	if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state)) {
-		i40e_service_event_complete(pf);
 		return;
 	}
 
+	if (test_and_set_bit(__I40E_SERVICE_SCHED, &pf->state))
+		return;
+
 	i40e_detect_recover_hung(pf);
 	i40e_sync_filters_subtask(pf);
 	i40e_reset_subtask(pf);
@@ -7280,7 +7268,9 @@ static void i40e_service_task(struct work_struct *work)
 	i40e_sync_udp_filters_subtask(pf);
 	i40e_clean_adminq_subtask(pf);
 
-	i40e_service_event_complete(pf);
+	/* flush memory to make sure state is correct before next watchdog */
+	smp_mb__before_atomic();
+	clear_bit(__I40E_SERVICE_SCHED, &pf->state);
 
 	/* If the tasks have taken longer than one timer cycle or there
 	 * is more work to be done, reschedule the service task now
-- 
2.4.11


  parent reply	other threads:[~2016-11-14 21:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 21:06 [Intel-wired-lan] [next PATCH S53-V2 1/5] i40e: use unsigned printf format specifier for active_filters count Bimmy Pujari
2016-11-14 21:06 ` [Intel-wired-lan] [next PATCH S53-V2 2/5] i40e: Add support for 25G devices Bimmy Pujari
2016-11-17 21:23   ` Bowers, AndrewX
2016-11-14 21:06 ` [Intel-wired-lan] [next PATCH S53-V2 3/5] i40e: Add FEC for 25g Bimmy Pujari
2016-11-17 21:35   ` Bowers, AndrewX
2016-11-17 21:55   ` Bowers, AndrewX
2016-11-14 21:06 ` [Intel-wired-lan] [next PATCH S53-V2 4/5] i40e: Add functions which apply correct PHY access method for read and write operation Bimmy Pujari
2016-11-17 21:55   ` Bowers, AndrewX
2016-11-14 21:06 ` Bimmy Pujari [this message]
2016-11-18 17:51   ` [Intel-wired-lan] [next PATCH S53-V2 5/5] i40e: lock service task correctly Bowers, AndrewX
2016-11-17 20:41 ` [Intel-wired-lan] [next PATCH S53-V2 1/5] i40e: use unsigned printf format specifier for active_filters count Bowers, AndrewX

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=1479157609-30812-5-git-send-email-bimmy.pujari@intel.com \
    --to=bimmy.pujari@intel.com \
    --cc=intel-wired-lan@osuosl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.