From: Stefan Assmann <sassmann@kpanic.de>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, patryk.piotrowski@intel.com, sassmann@kpanic.de
Subject: [Intel-wired-lan] [PATCH net-next] iavf: check that state transitions happen under lock
Date: Fri, 28 Oct 2022 15:45:15 +0200 [thread overview]
Message-ID: <20221028134515.253022-1-sassmann@kpanic.de> (raw)
Add a check to make sure crit_lock is being held during every state
transition and print a warning if that's not the case. For convenience
a wrapper is added that helps pointing out where the locking is missing.
Make an exception for iavf_probe() as that is too early in the init
process and generates a false positive report.
Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
drivers/net/ethernet/intel/iavf/iavf.h | 23 +++++++++++++++------
drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index 3f6187c16424..28f41bbc9c86 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -498,19 +498,30 @@ static inline const char *iavf_state_str(enum iavf_state_t state)
}
}
-static inline void iavf_change_state(struct iavf_adapter *adapter,
- enum iavf_state_t state)
+static inline void __iavf_change_state(struct iavf_adapter *adapter,
+ enum iavf_state_t state,
+ const char *func,
+ int line)
{
if (adapter->state != state) {
adapter->last_state = adapter->state;
adapter->state = state;
}
- dev_dbg(&adapter->pdev->dev,
- "state transition from:%s to:%s\n",
- iavf_state_str(adapter->last_state),
- iavf_state_str(adapter->state));
+ if (mutex_is_locked(&adapter->crit_lock))
+ dev_dbg(&adapter->pdev->dev, "%s:%d state transition %s to %s\n",
+ func, line,
+ iavf_state_str(adapter->last_state),
+ iavf_state_str(adapter->state));
+ else
+ dev_warn(&adapter->pdev->dev, "%s:%d state transition %s to %s without locking!\n",
+ func, line,
+ iavf_state_str(adapter->last_state),
+ iavf_state_str(adapter->state));
}
+#define iavf_change_state(adapter, state) \
+ __iavf_change_state(adapter, state, __func__, __LINE__)
+
int iavf_up(struct iavf_adapter *adapter);
void iavf_down(struct iavf_adapter *adapter);
int iavf_process_config(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 3fc572341781..bbc0c9f347a7 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4892,7 +4892,7 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hw->back = adapter;
adapter->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
- iavf_change_state(adapter, __IAVF_STARTUP);
+ adapter->state = __IAVF_STARTUP;
/* Call save state here because it relies on the adapter struct. */
pci_save_state(pdev);
--
2.37.3
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next reply other threads:[~2022-10-28 13:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 13:45 Stefan Assmann [this message]
2022-11-03 11:46 ` [Intel-wired-lan] [PATCH net-next] iavf: check that state transitions happen under lock Jankowski, Konrad0
2022-11-06 19:14 ` Leon Romanovsky
2022-11-07 11:57 ` Stefan Assmann
2022-11-09 13:24 ` Leon Romanovsky
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=20221028134515.253022-1-sassmann@kpanic.de \
--to=sassmann@kpanic.de \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=patryk.piotrowski@intel.com \
/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