* [Intel-wired-lan] [PATCH net-next v1] iavf: Add helper to check if iavf_remove() is in progress
@ 2022-06-03 8:52 Jedrzej Jagielski
2022-06-03 18:00 ` Tony Nguyen
0 siblings, 1 reply; 2+ messages in thread
From: Jedrzej Jagielski @ 2022-06-03 8:52 UTC (permalink / raw)
To: intel-wired-lan; +Cc: Brett Creeley, Brett Creeley, Jedrzej Jagielski
From: Brett Creeley <brett@pensando.io>
Currently the driver checks if the __IAVF_IN_REMOVE_TASK bit is set in
the adapter's crit_section bitmap. This is fine, but if the
implementation were to ever change, i.e. a mutex was introduced all of
the callers of test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)
would have to change. Fix this by introducing the
iavf_is_remove_in_progress() helper function.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf.h | 1 +
drivers/net/ethernet/intel/iavf/iavf_main.c | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index fda1198d2c00..431182461462 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -505,6 +505,7 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter);
void iavf_schedule_reset(struct iavf_adapter *adapter);
void iavf_schedule_request_stats(struct iavf_adapter *adapter);
void iavf_reset(struct iavf_adapter *adapter);
+bool iavf_is_remove_in_progress(struct iavf_adapter *adapter);
void iavf_set_ethtool_ops(struct net_device *netdev);
void iavf_update_stats(struct iavf_adapter *adapter);
void iavf_reset_interrupt_capability(struct iavf_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 9f7ef52f12b9..b99d7434de44 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -268,6 +268,15 @@ int iavf_lock_timeout(struct mutex *lock, unsigned int msecs)
return -1;
}
+/**
+ * iavf_is_remove_in_progress - Check if a iavf_remove() is in progress
+ * @adapter: board private structure
+ */
+bool iavf_is_remove_in_progress(struct iavf_adapter *adapter)
+{
+ return test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section);
+}
+
/**
* iavf_schedule_reset - Set the flags and schedule a reset event
* @adapter: board private structure
@@ -2676,8 +2685,7 @@ static void iavf_watchdog_task(struct work_struct *work)
msecs_to_jiffies(1));
return;
case __IAVF_INIT_FAILED:
- if (test_bit(__IAVF_IN_REMOVE_TASK,
- &adapter->crit_section)) {
+ if (iavf_is_remove_in_progress(adapter)) {
/* Do not update the state and do not reschedule
* watchdog task, iavf_remove should handle this state
* as it can loop forever
@@ -2701,8 +2709,7 @@ static void iavf_watchdog_task(struct work_struct *work)
queue_delayed_work(iavf_wq, &adapter->watchdog_task, HZ);
return;
case __IAVF_COMM_FAILED:
- if (test_bit(__IAVF_IN_REMOVE_TASK,
- &adapter->crit_section)) {
+ if (iavf_is_remove_in_progress(adapter)) {
/* Set state to __IAVF_INIT_FAILED and perform remove
* steps. Remove IAVF_FLAG_PF_COMMS_FAILED so the task
* doesn't bring the state back to __IAVF_COMM_FAILED.
@@ -3145,7 +3152,7 @@ static void iavf_adminq_task(struct work_struct *work)
if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES)) {
if (adapter->netdev_registered ||
- !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
+ !iavf_is_remove_in_progress(adapter)) {
struct net_device *netdev = adapter->netdev;
rtnl_lock();
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Intel-wired-lan] [PATCH net-next v1] iavf: Add helper to check if iavf_remove() is in progress
2022-06-03 8:52 [Intel-wired-lan] [PATCH net-next v1] iavf: Add helper to check if iavf_remove() is in progress Jedrzej Jagielski
@ 2022-06-03 18:00 ` Tony Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Tony Nguyen @ 2022-06-03 18:00 UTC (permalink / raw)
To: Jedrzej Jagielski, intel-wired-lan; +Cc: Brett Creeley, Brett Creeley
On 6/3/2022 1:52 AM, Jedrzej Jagielski wrote:
> From: Brett Creeley <brett@pensando.io>
>
> Currently the driver checks if the __IAVF_IN_REMOVE_TASK bit is set in
> the adapter's crit_section bitmap. This is fine, but if the
> implementation were to ever change, i.e. a mutex was introduced all of
> the callers of test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)
> would have to change. Fix this by introducing the
> iavf_is_remove_in_progress() helper function.
>
> Signed-off-by: Brett Creeley <brett.creeley@intel.com>
The author and Sign-off need to match exactly:
WARNING: From:/Signed-off-by: email address mismatch: 'From: Brett
Creeley <brett@pensando.io>' != 'Signed-off-by: Brett Creeley
<brett.creeley@intel.com>'
> Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-03 18:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-03 8:52 [Intel-wired-lan] [PATCH net-next v1] iavf: Add helper to check if iavf_remove() is in progress Jedrzej Jagielski
2022-06-03 18:00 ` Tony Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox