All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Kalle Valo <kvalo@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Erik Stromdahl <erik.stromdahl@gmail.com>,
	ath10k@lists.infradead.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org, Kalle Valo <kvalo@codeaurora.org>,
	Alexander Stein <alexander.stein@ew.tq-group.com>
Subject: [RFC PATCH 1/2] HACK: ath10k: add start_once support
Date: Fri,  6 Jan 2023 11:58:52 +0100	[thread overview]
Message-ID: <20230106105853.3484381-2-alexander.stein@ew.tq-group.com> (raw)
In-Reply-To: <20230106105853.3484381-1-alexander.stein@ew.tq-group.com>

From: Erik Stromdahl <erik.stromdahl@gmail.com>

Add possibility to configure the driver to only start target once.
This can reduce startup time of SDIO devices significantly since
loading the firmware can take a substantial amount of time.

The patch is also necessary for high latency devices in general
since it does not seem to be possible to rerun the BMI phase
(fw upload) without power-cycling the device.

[kvalo: this needs more discussion as it's pretty important to be able to
reset/stop the firmware. with SDIO we should (I hope) to control the target
device power. And on USB it should be possible to reset the device via a
register.]

Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
This type of patch is floating around everywhere ath10k USB support is used.
I don't have any knowledge about internals, so there is not much I can add here.

I had to add a check for start_once in ath10k_halt() as well, otherwise
interface up after shutting down will timeout.

[  410.212643] usb 1-1.1.2: Failed to submit usb control message: -110
[  410.218961] usb 1-1.1.2: unable to send the bmi data to the device: -110
[  410.225708] usb 1-1.1.2: Unable to read soc register from device: -110
[  411.236646] usb 1-1.1.2: Failed to submit usb control message: -110
[  411.242963] usb 1-1.1.2: unable to send the bmi data to the device: -110
[  411.249703] usb 1-1.1.2: unable to write to the device (-110)
[  411.255479] usb 1-1.1.2: settings HTC version failed
[  411.260476] usb 1-1.1.2: Could not init core: -22

 drivers/net/wireless/ath/ath10k/core.c | 20 ++++++++++++++++----
 drivers/net/wireless/ath/ath10k/core.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h   |  6 ++++++
 drivers/net/wireless/ath/ath10k/mac.c  |  7 +++++--
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 5eb131ab916f..f69dab55fa36 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2927,6 +2927,9 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
 	int status;
 	u32 val;
 
+	if (ar->is_started && ar->hw_params.start_once)
+		return 0;
+
 	lockdep_assert_held(&ar->conf_mutex);
 
 	clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
@@ -3231,6 +3234,8 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
 		goto err_hif_stop;
 	}
 
+	ar->is_started = true;
+
 	return 0;
 
 err_hif_stop:
@@ -3285,6 +3290,7 @@ void ath10k_core_stop(struct ath10k *ar)
 	ath10k_wmi_detach(ar);
 
 	ar->id.bmi_ids_valid = false;
+	ar->is_started = false;
 }
 EXPORT_SYMBOL(ath10k_core_stop);
 
@@ -3424,12 +3430,18 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
 		goto err_unlock;
 	}
 
-	ath10k_debug_print_boot_info(ar);
-	ath10k_core_stop(ar);
+	/* Leave target running if hw_params.start_once is set */
+	if (ar->hw_params.start_once) {
+		mutex_unlock(&ar->conf_mutex);
+	} else {
+		ath10k_debug_print_boot_info(ar);
+		ath10k_core_stop(ar);
+
+		mutex_unlock(&ar->conf_mutex);
 
-	mutex_unlock(&ar->conf_mutex);
+		ath10k_hif_power_down(ar);
+	}
 
-	ath10k_hif_power_down(ar);
 	return 0;
 
 err_unlock:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index f5de8ce8fb45..0ef21171db87 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -1054,6 +1054,8 @@ struct ath10k {
 	bool nlo_enabled;
 	bool p2p;
 
+	bool is_started;
+
 	struct {
 		enum ath10k_bus bus;
 		const struct ath10k_hif_ops *ops;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 9643031a4427..ea3b5c5c6c9b 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -639,6 +639,12 @@ struct ath10k_hw_params {
 	bool use_fw_tx_credits;
 
 	bool delay_unmap_buffer;
+
+	/* Specifies whether or not the device should be started once.
+	 * If set, the device will be started once by the early fw probe
+	 * and it will not be terminated afterwards.
+	 */
+	bool start_once;
 };
 
 struct htt_resp;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index ec8d5b29bc72..c6b84f9bb0e3 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -4790,8 +4790,11 @@ void ath10k_halt(struct ath10k *ar)
 	ath10k_scan_finish(ar);
 	ath10k_peer_cleanup_all(ar);
 	ath10k_stop_radar_confirmation(ar);
-	ath10k_core_stop(ar);
-	ath10k_hif_power_down(ar);
+	/* Leave target running if hw_params.start_once is set */
+	if (!ar->hw_params.start_once) {
+		ath10k_core_stop(ar);
+		ath10k_hif_power_down(ar);
+	}
 
 	spin_lock_bh(&ar->data_lock);
 	list_for_each_entry(arvif, &ar->arvifs, list)
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Kalle Valo <kvalo@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Erik Stromdahl <erik.stromdahl@gmail.com>,
	ath10k@lists.infradead.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org, Kalle Valo <kvalo@codeaurora.org>,
	Alexander Stein <alexander.stein@ew.tq-group.com>
Subject: [RFC PATCH 1/2] HACK: ath10k: add start_once support
Date: Fri,  6 Jan 2023 11:58:52 +0100	[thread overview]
Message-ID: <20230106105853.3484381-2-alexander.stein@ew.tq-group.com> (raw)
In-Reply-To: <20230106105853.3484381-1-alexander.stein@ew.tq-group.com>

From: Erik Stromdahl <erik.stromdahl@gmail.com>

Add possibility to configure the driver to only start target once.
This can reduce startup time of SDIO devices significantly since
loading the firmware can take a substantial amount of time.

The patch is also necessary for high latency devices in general
since it does not seem to be possible to rerun the BMI phase
(fw upload) without power-cycling the device.

[kvalo: this needs more discussion as it's pretty important to be able to
reset/stop the firmware. with SDIO we should (I hope) to control the target
device power. And on USB it should be possible to reset the device via a
register.]

Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
This type of patch is floating around everywhere ath10k USB support is used.
I don't have any knowledge about internals, so there is not much I can add here.

I had to add a check for start_once in ath10k_halt() as well, otherwise
interface up after shutting down will timeout.

[  410.212643] usb 1-1.1.2: Failed to submit usb control message: -110
[  410.218961] usb 1-1.1.2: unable to send the bmi data to the device: -110
[  410.225708] usb 1-1.1.2: Unable to read soc register from device: -110
[  411.236646] usb 1-1.1.2: Failed to submit usb control message: -110
[  411.242963] usb 1-1.1.2: unable to send the bmi data to the device: -110
[  411.249703] usb 1-1.1.2: unable to write to the device (-110)
[  411.255479] usb 1-1.1.2: settings HTC version failed
[  411.260476] usb 1-1.1.2: Could not init core: -22

 drivers/net/wireless/ath/ath10k/core.c | 20 ++++++++++++++++----
 drivers/net/wireless/ath/ath10k/core.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h   |  6 ++++++
 drivers/net/wireless/ath/ath10k/mac.c  |  7 +++++--
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 5eb131ab916f..f69dab55fa36 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2927,6 +2927,9 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
 	int status;
 	u32 val;
 
+	if (ar->is_started && ar->hw_params.start_once)
+		return 0;
+
 	lockdep_assert_held(&ar->conf_mutex);
 
 	clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
@@ -3231,6 +3234,8 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
 		goto err_hif_stop;
 	}
 
+	ar->is_started = true;
+
 	return 0;
 
 err_hif_stop:
@@ -3285,6 +3290,7 @@ void ath10k_core_stop(struct ath10k *ar)
 	ath10k_wmi_detach(ar);
 
 	ar->id.bmi_ids_valid = false;
+	ar->is_started = false;
 }
 EXPORT_SYMBOL(ath10k_core_stop);
 
@@ -3424,12 +3430,18 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
 		goto err_unlock;
 	}
 
-	ath10k_debug_print_boot_info(ar);
-	ath10k_core_stop(ar);
+	/* Leave target running if hw_params.start_once is set */
+	if (ar->hw_params.start_once) {
+		mutex_unlock(&ar->conf_mutex);
+	} else {
+		ath10k_debug_print_boot_info(ar);
+		ath10k_core_stop(ar);
+
+		mutex_unlock(&ar->conf_mutex);
 
-	mutex_unlock(&ar->conf_mutex);
+		ath10k_hif_power_down(ar);
+	}
 
-	ath10k_hif_power_down(ar);
 	return 0;
 
 err_unlock:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index f5de8ce8fb45..0ef21171db87 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -1054,6 +1054,8 @@ struct ath10k {
 	bool nlo_enabled;
 	bool p2p;
 
+	bool is_started;
+
 	struct {
 		enum ath10k_bus bus;
 		const struct ath10k_hif_ops *ops;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 9643031a4427..ea3b5c5c6c9b 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -639,6 +639,12 @@ struct ath10k_hw_params {
 	bool use_fw_tx_credits;
 
 	bool delay_unmap_buffer;
+
+	/* Specifies whether or not the device should be started once.
+	 * If set, the device will be started once by the early fw probe
+	 * and it will not be terminated afterwards.
+	 */
+	bool start_once;
 };
 
 struct htt_resp;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index ec8d5b29bc72..c6b84f9bb0e3 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -4790,8 +4790,11 @@ void ath10k_halt(struct ath10k *ar)
 	ath10k_scan_finish(ar);
 	ath10k_peer_cleanup_all(ar);
 	ath10k_stop_radar_confirmation(ar);
-	ath10k_core_stop(ar);
-	ath10k_hif_power_down(ar);
+	/* Leave target running if hw_params.start_once is set */
+	if (!ar->hw_params.start_once) {
+		ath10k_core_stop(ar);
+		ath10k_hif_power_down(ar);
+	}
 
 	spin_lock_bh(&ar->data_lock);
 	list_for_each_entry(arvif, &ar->arvifs, list)
-- 
2.34.1


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

  reply	other threads:[~2023-01-06 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 10:58 [RFC PATCH 0/2] ath10k USB support (QCA9377) Alexander Stein
2023-01-06 10:58 ` Alexander Stein
2023-01-06 10:58 ` Alexander Stein [this message]
2023-01-06 10:58   ` [RFC PATCH 1/2] HACK: ath10k: add start_once support Alexander Stein
2023-01-06 10:58 ` [RFC PATCH 2/2] ath10k: Add support for QCA9377 hw1.1 usb Alexander Stein
2023-01-06 10:58   ` Alexander Stein

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=20230106105853.3484381-2-alexander.stein@ew.tq-group.com \
    --to=alexander.stein@ew.tq-group.com \
    --cc=ath10k@lists.infradead.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=erik.stromdahl@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 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.