All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iwlwifi: updates intended for v5.17 2021-12-20
@ 2021-12-20 12:33 Luca Coelho
  2021-12-20 12:33 ` [PATCH 1/2] iwlwifi: mei: clear the ownership when the driver goes down Luca Coelho
  2021-12-20 12:33 ` [PATCH 2/2] iwlwifi: mei: wait before mapping the shared area Luca Coelho
  0 siblings, 2 replies; 3+ messages in thread
From: Luca Coelho @ 2021-12-20 12:33 UTC (permalink / raw)
  To: kvalo; +Cc: luca, linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

Here's the eighth set of patches intended for v5.17.  This is a small
one with just to fixes for iwlmei that Emmanuel asked me to send out.
It turned out to be only two, not "a few" as I mentioned before.

The changes are:

* A couple of important fixes in iwlmei.

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.



Emmanuel Grumbach (2):
  iwlwifi: mei: clear the ownership when the driver goes down
  iwlwifi: mei: wait before mapping the shared area

 drivers/net/wireless/intel/iwlwifi/mei/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] iwlwifi: mei: clear the ownership when the driver goes down
  2021-12-20 12:33 [PATCH 0/2] iwlwifi: updates intended for v5.17 2021-12-20 Luca Coelho
@ 2021-12-20 12:33 ` Luca Coelho
  2021-12-20 12:33 ` [PATCH 2/2] iwlwifi: mei: wait before mapping the shared area Luca Coelho
  1 sibling, 0 replies; 3+ messages in thread
From: Luca Coelho @ 2021-12-20 12:33 UTC (permalink / raw)
  To: kvalo; +Cc: luca, linux-wireless

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

When the driver is unregistered, CSME will take ownership on the
device. Reflect this in the iwlmei object so that we will remember
to re-ask for ownership when the driver will register again.

Not doing so will cause CSME not to give the host ownership and
we will see the following error message when trying to bring up
the interface:

iwlwifi 0000:a9:00.0: iwl_pcie_prepare_card_hw iwl_trans_prepare_card_hw enter
iwlwifi 0000:a9:00.0: iwl_pcie_set_hw_ready hardware not ready
iwlwifi 0000:a9:00.0: iwl_pcie_set_hw_ready hardware not ready
iwlwifi 0000:a9:00.0: iwl_pcie_prepare_card_hw Couldn't prepare the card but SAP is connected
iwlwifi 0000:a9:00.0: Error while preparing HW: -16

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index 4453cd2571c2..787d64276f36 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -1703,6 +1703,7 @@ void iwl_mei_unregister_complete(void)
 			mei_cldev_get_drvdata(iwl_mei_global_cldev);
 
 		iwl_mei_send_sap_msg(mei->cldev, SAP_MSG_NOTIF_WIFIDR_DOWN);
+		mei->got_ownership = false;
 	}
 
 	mutex_unlock(&iwl_mei_mutex);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] iwlwifi: mei: wait before mapping the shared area
  2021-12-20 12:33 [PATCH 0/2] iwlwifi: updates intended for v5.17 2021-12-20 Luca Coelho
  2021-12-20 12:33 ` [PATCH 1/2] iwlwifi: mei: clear the ownership when the driver goes down Luca Coelho
@ 2021-12-20 12:33 ` Luca Coelho
  1 sibling, 0 replies; 3+ messages in thread
From: Luca Coelho @ 2021-12-20 12:33 UTC (permalink / raw)
  To: kvalo; +Cc: luca, linux-wireless

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

The shared area is a DMA memory allocated in the host and
mapped so that the host and the CSME firmware can
exchange data. It is mapped through a dedicated PCI device
that is driven by the mei bus driver.

The bus driver is in charge of allocating and mapping this
memory. It also needs to configure the CSME firmware with
a specific set of commands, so that the CSME firmware will
know that this memory is meant to be used by its internal
WLAN module.

For this, the CSME firmware first needs to completely
initialize its WLAN module and only then get the mapping
request.

The problem is that the mei bus enumeration completes
before the WLAN is completely ready. This means that
the WLAN module's initialization is racing with iwlmei's
allocation and mapping flow.

Testing showed a problem in resume flows where iwlmei
was too fast and the DMA mapping failed.

Add a delay to avoid this. This is still racy, but our
measurements showed that we have a good margin and we
should now be safe.

Fixes: 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME")
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index 787d64276f36..bee3415ef460 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -1810,6 +1810,12 @@ static int iwl_mei_probe(struct mei_cl_device *cldev,
 	mei_cldev_set_drvdata(cldev, mei);
 	mei->cldev = cldev;
 
+	/*
+	 * The CSME firmware needs to boot the internal WLAN client. Wait here
+	 * so that the DMA map request will succeed.
+	 */
+	msleep(20);
+
 	ret = iwl_mei_alloc_shared_mem(cldev);
 	if (ret)
 		goto free;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-20 12:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 12:33 [PATCH 0/2] iwlwifi: updates intended for v5.17 2021-12-20 Luca Coelho
2021-12-20 12:33 ` [PATCH 1/2] iwlwifi: mei: clear the ownership when the driver goes down Luca Coelho
2021-12-20 12:33 ` [PATCH 2/2] iwlwifi: mei: wait before mapping the shared area Luca Coelho

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.