lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230106105853.3484381-2-alexander.stein@ew.tq-group.com>
Date:   Fri,  6 Jan 2023 11:58:52 +0100
From:   Alexander Stein <alexander.stein@...tq-group.com>
To:     Kalle Valo <kvalo@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Cc:     Erik Stromdahl <erik.stromdahl@...il.com>,
        ath10k@...ts.infradead.org, linux-wireless@...r.kernel.org,
        netdev@...r.kernel.org, Kalle Valo <kvalo@...eaurora.org>,
        Alexander Stein <alexander.stein@...tq-group.com>
Subject: [RFC PATCH 1/2] HACK: ath10k: add start_once support

From: Erik Stromdahl <erik.stromdahl@...il.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@...il.com>
Signed-off-by: Kalle Valo <kvalo@...eaurora.org>
Signed-off-by: Alexander Stein <alexander.stein@...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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ