* [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw
@ 2026-11-19 12:56 Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 1/7] PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining Krishna Chaitanya Chundru
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru, Val Packett,
Manivannan Sadhasivam, Miaoqing Pan
As per MHI spec sec 14, MHI supports bandwidth scaling to reduce power
consumption. MHI bandwidth scaling is advertised in devices that contain
the bandwidth scaling capability registers. If enabled, the device
aggregates bandwidth requirements and sends them to the host in the form
of an event. After the host performs the bandwidth switch, it sends an
acknowledgment by ringing a doorbell.
if the host supports bandwidth scaling events, then it must set
BW_CFG.ENABLED bit, set BW_CFG.DB_CHAN_ID to the channel ID to the
doorbell that will be used by the host to communicate the bandwidth
scaling status and BW_CFG.ER_INDEX to the index for the event ring
to which the device should send bandwidth scaling request in the
bandwidth scaling capability register.
As part of mmio init check if the bw scale capability is present or not,
if present advertise host supports bw scale by setting all the required
fields.
MHI layer will only forward the bw scaling request to the controller
driver, it is responsibility of the controller driver to do actual bw
scaling and then pass status to the MHI. MHI will response back to the
device based up on the status of the bw scale received.
Add a new get_misc_doorbell() to get doorbell for misc capabilities to
use the doorbell with mhi events like MHI BW scale etc.
Use workqueue & mutex for the bw scale events as the pci_set_target_speed()
which will called by the mhi controller driver can sleep.
This series depends on the PCI/ASPM patches[1] that are currently under review
and not yet merged upstream. The ASPM patches provide the infrastructure
(disable_aspm_for_retrain flag and related functionality) that this MHI bandwidth
scaling series builds upon. While the ASPM patches are still being reviewed, we
are sending this series now to enable early review and feedback on the MHI
bandwidth scaling implementation. Once the ASPM patches are merged, this series
can be applied on top without any conflicts.
This series also depends on the mhi read capability patch[2], this patch
is not merged as there is no user to use it, we can apply it along with
this series.
To: Bjorn Helgaas <bhelgaas@google.com>
To: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
To: Jingoo Han <jingoohan1@gmail.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Krzysztof Wilczyński <kw@linux.com>
To: Rob Herring <robh@kernel.org>
To: Jeff Johnson <jjohnson@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-msm@vger.kernel.org
Cc: mhi@lists.linux.dev
Cc: linux-wireless@vger.kernel.org
Cc: ath11k@lists.infradead.org
Cc: qiang.yu@oss.qualcomm.com
Link [1]: https://lore.kernel.org/all/20260708-pci-aspm-fix-v3-0-6bd72451746e@kernel.org/
Link [2]: https://lore.kernel.org/all/20260411-tsc_timesync-v2-1-6f25f72987b3@oss.qualcomm.com/#t
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
Changes in v6:
- Restore ASPM after link retraining with pci_force_enable_link_state(),
as a plain enable does not re-enable states disabled by
pci_disable_link_state() (Val)
- Include link width in the OPP lookup: key is now (per-lane rate * width,
LNKCTL2 target link speed).
- Fix pcie_set_target_speed() using a stale list cursor as the downstream
device when the bus has no function 0.
- Use the unlocked ASPM helpers, as callers do not hold pci_bus_sem.
- Move the BW scale doorbell into mhi_event_config and drop the
get_misc_doorbell() callback (Mani)
- Add MHI bandwidth scaling support for ath12k (WCN7850).
- Move the BW scale doorbell into mhi_event_config and drop the
get_misc_doorbell() callback (Mani).
- Couple of nits (Mani).
- Link to v5: https://patch.msgid.link/20260819-bwscale-v5-0-6dea79786b37@oss.qualcomm.com
Changes in v5:
- remove pre/post_link_speed_change (Bjorn)
- Use opp directly in pci directly to scale bw votes (Mani).
- Use disable aspm on link retrain field in host bridge (Mani).
- In case bw scale failure, remove workqueue etc (Mani).
- couple of nits in mhi & pci (Mani).
- Link to v4: https://lore.kernel.org/r/20250609-mhi_bw_up-v4-0-3faa8fe92b05@qti.qualcomm.com
Changes in v4:
- Remove leftover type case, change the function names to pre/post_link_speed_change(Ilpo Järvinen)
- Add check's for capability read and convert le32 to cpu (Jeffrey Hugo)
- Add macros for GENMASK & BIT() (Ilpo Järvinen)
- Link to v3: https://lore.kernel.org/r/20250519-mhi_bw_up-v3-0-3acd4a17bbb5@oss.qualcomm.com
Changes in v3:
- Move update speed logic to pwrctrl driver (Mani)
- Move pre_bus_bw & post_bus_bw to bridge as these are bridge driver specific ops,
it feels to me we need to add these in the host bridge driver similar to recently
added one reset_slot.
- Remove dwc level wrapper (Mani)
- Enable ASPM only if they are enabled already (Mani)
- Change the name of mhi_get_capability_offset to mhi_find_capability() (Bjorn)
- Fix comments in the code, subjects etc (Mani & Bjorn)
- Link to v2: https://lore.kernel.org/r/20250313-mhi_bw_up-v2-0-869ca32170bf@oss.qualcomm.com
Changes in v2:
- Update the comments.
- Split the icc bw patch as sepertate one (Bjorn)
- update the aspm disablement comment (Bjorn)
- Use FIELD_GET & FIELD_PREP instead of hard macros and couple of nits
suggested by (Ilpo Järvinen)
- Create a new function to change lnkcntrl2speed to enum pci_bus_speed (Jeff)
- Link to v1: https://lore.kernel.org/r/20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com
---
Krishna Chaitanya Chundru (6):
PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining
PCI: Export pci_set_target_speed()
PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed
bus: mhi: host: Add support for Bandwidth scale
wifi: ath12k: Add support for MHI bandwidth scaling
PCI: qcom: Enable ASPM disabling during link retraining
Miaoqing Pan (1):
wifi: ath11k: Add support for MHI bandwidth scaling
drivers/bus/mhi/common.h | 13 ++++
drivers/bus/mhi/host/init.c | 90 +++++++++++++++++++++-
drivers/bus/mhi/host/internal.h | 7 +-
drivers/bus/mhi/host/main.c | 114 +++++++++++++++++++++++++++-
drivers/bus/mhi/host/pm.c | 10 ++-
drivers/bus/mhi/host/trace.h | 7 ++
drivers/net/wireless/ath/ath11k/mhi.c | 29 +++++++
drivers/net/wireless/ath/ath12k/mhi.c | 16 ++++
drivers/net/wireless/ath/ath12k/mhi.h | 2 +
drivers/net/wireless/ath/ath12k/wifi7/mhi.c | 12 +++
drivers/pci/controller/dwc/pcie-qcom.c | 2 +
drivers/pci/pci.c | 15 ++++
drivers/pci/pcie/bwctrl.c | 66 +++++++++++++++-
include/linux/mhi.h | 11 +++
include/linux/pci.h | 2 +
15 files changed, 388 insertions(+), 8 deletions(-)
---
base-commit: 6a8f5b35d182229795bf2e75de1feff722da3dab
change-id: 20260813-bwscale-4337905a61a5
prerequisite-message-id: 20260708-pci-aspm-fix-v3-0-6bd72451746e@kernel.org
prerequisite-patch-id: 88006da4a3c4d94facb6ff3cb8e47269fb3e5636
prerequisite-patch-id: e9132f8e053568f4259ae33a5f0dfa7d14f6bb43
prerequisite-patch-id: 034cbc5c4004f7384122e454edaf10118495bb1c
prerequisite-patch-id: 3f415cab42569c0fd8d88d3de9775a57b719f82e
prerequisite-patch-id: ba94f33f11b19e08820dee482209dd1ba0d57523
prerequisite-patch-id: 060f698bfdb0e16c64735abd90e21f699f975ece
prerequisite-patch-id: 0451e6b0527b17f006d6649158abef8ae9010170
prerequisite-patch-id: c7e7e403930415790a6075778b9c4851629f54d5
prerequisite-message-id: 20260411-tsc_timesync-v2-1-6f25f72987b3@oss.qualcomm.com
prerequisite-patch-id: 898bad65110d5bb8a51ebadebc00d21b0c0eddee
prerequisite-patch-id: 927a45a5a418489c14481413149cd37840019354
prerequisite-patch-id: 927b714345dfaeecc74ab17645bd73c62a0ed51d
prerequisite-patch-id: 607cbbae4ab145955ba10db4c0eb2ec507c476c2
prerequisite-patch-id: 3eeed070306fd8e1dd9a2edc11eaa91ea3cc9115
prerequisite-patch-id: 77a89f3deee3b2a415c008fa533f3faab7e709ad
Best regards,
--
Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 1/7] PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 2/7] PCI: Export pci_set_target_speed() Krishna Chaitanya Chundru
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru, Val Packett
PCIe host bridge devices may need their operating point raised before
retraining to a higher link speed so that hardware resources (e.g., RPMh
votes on Qualcomm platforms) are available at the requested data rate.
After retraining, the operating point must be updated to reflect the
actual negotiated speed.
Add pcie_set_opp() to look up an OPP on the host bridge parent device
using a key of (total link rate in kHz, LNKCTL2 Target Link Speed
level). The total link rate is the per-lane rate multiplied by the
link width, so that OPP tables can carry separate entries per generation
and width, e.g. Gen 3 x1 and Gen 3 x2.
In pcie_set_target_speed(), call pcie_set_opp() before retraining only
when upscaling (speed_req > cur_bus_speed), since only raising the
operating point requires pre-staging hardware. After retraining, call
pcie_set_opp() unconditionally with the actual cur_bus_speed to settle
the votes. Both calls are skipped for downstream ports of PCIe switches,
as those are outside the host controller's scope.
Some controllers also require ASPM to be disabled around link retraining.
Add a disable_aspm_for_retrain flag to pci_host_bridge; when set,
pcie_set_target_speed() saves the child device's ASPM state, disables
all ASPM link states before retraining, and restores them afterward. The
child device is used because the ASPM core ignores requests made on the
Root Port itself and configures the link through its downstream device.
The states are restored with pci_force_enable_link_state(), as a
plain enable does not undo pci_disable_link_state().
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Tested-by: Val Packett <val@packett.cool> # x1e80100-dell-latitude-7455
---
drivers/pci/pcie/bwctrl.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/pci.h | 1 +
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c
index 3b1122461ffd..c1e749df5bbe 100644
--- a/drivers/pci/pcie/bwctrl.c
+++ b/drivers/pci/pcie/bwctrl.c
@@ -28,9 +28,11 @@
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/pci-bwctrl.h>
+#include <linux/pm_opp.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/units.h>
#include "../pci.h"
#include "portdrv.h"
@@ -98,6 +100,37 @@ static int pcie_bwctrl_change_speed(struct pci_dev *port, u16 target_speed, bool
return pcie_retrain_link(port, use_lt);
}
+static int pcie_set_opp(struct pci_dev *pdev, struct pci_host_bridge *host,
+ enum pci_bus_speed speed)
+{
+ struct device *dev = host->dev.parent;
+ struct dev_pm_opp_key key = {};
+ int ret, freq_mbps, width;
+ unsigned long freq_kbps;
+ struct dev_pm_opp *opp;
+ u16 lnksta;
+
+ pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
+ width = FIELD_GET(PCI_EXP_LNKSTA_NLW, lnksta);
+
+ freq_mbps = pcie_dev_speed_mbps(speed);
+ if (freq_mbps < 0)
+ return -EINVAL;
+
+ freq_kbps = freq_mbps * KILO * width;
+ key.freq = freq_kbps;
+ key.level = pci_bus_speed2lnkctl2(speed);
+ opp = dev_pm_opp_find_key_exact(dev, &key, true);
+ if (!IS_ERR(opp)) {
+ ret = dev_pm_opp_set_opp(dev, opp);
+ if (ret)
+ dev_err(dev, "Failed to set OPP for freq (%lu): %d\n",
+ freq_kbps, ret);
+ dev_pm_opp_put(opp);
+ }
+ return 0;
+}
+
/**
* pcie_set_target_speed - Set downstream Link Speed for PCIe Port
* @port: PCIe Port
@@ -118,9 +151,12 @@ static int pcie_bwctrl_change_speed(struct pci_dev *port, u16 target_speed, bool
int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req,
bool use_lt)
{
+ struct pci_host_bridge *host = pci_find_host_bridge(port->bus);
+ bool is_rootbus = pci_is_root_bus(port->bus);
struct pci_bus *bus = port->subordinate;
+ struct pci_dev *child = NULL, *dev;
+ int aspm_state = 0, ret;
u16 target_speed;
- int ret;
if (WARN_ON_ONCE(!pcie_valid_speed(speed_req)))
return -EINVAL;
@@ -130,6 +166,27 @@ int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req,
target_speed = pcie_bwctrl_select_speed(port, speed_req);
+ /*
+ * Host Bridge resources may need to be scaled for targeted speed
+ * otherwise link might not come up at requested speed.
+ */
+ if (bus && is_rootbus && host) {
+ /* Get function 0 of downstream device */
+ list_for_each_entry(dev, &bus->devices, bus_list) {
+ if (PCI_FUNC(dev->devfn) == 0) {
+ child = dev;
+ break;
+ }
+ }
+
+ if (child && host->disable_aspm_for_retrain) {
+ aspm_state = pcie_aspm_enabled(child);
+ pci_disable_link_state(child, PCIE_LINK_STATE_ALL);
+ }
+ if (speed_req > bus->cur_bus_speed)
+ pcie_set_opp(port, host, speed_req);
+ }
+
scoped_guard(rwsem_read, &pcie_bwctrl_setspeed_rwsem) {
struct pcie_bwctrl_data *data = port->link_bwctrl;
@@ -154,6 +211,12 @@ int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req,
!list_empty(&bus->devices))
ret = -EAGAIN;
+ if (bus && is_rootbus && host) {
+ if (child && host->disable_aspm_for_retrain)
+ pci_force_enable_link_state(child, aspm_state);
+ pcie_set_opp(port, host, bus->cur_bus_speed);
+ }
+
return ret;
}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9cbcadd08f3d..352079393edb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -673,6 +673,7 @@ struct pci_host_bridge {
unsigned int msi_domain:1; /* Bridge wants MSI domain */
unsigned int broken_l1ss_resume:1; /* Resuming from L1SS during
system suspend is broken */
+ unsigned int disable_aspm_for_retrain:1; /* Disable ASPM before link retain */
/* Resource alignment requirements */
resource_size_t (*align_resource)(struct pci_dev *dev,
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 2/7] PCI: Export pci_set_target_speed()
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 1/7] PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 3/7] PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed Krishna Chaitanya Chundru
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru,
Manivannan Sadhasivam
Export pci_set_target_speed() so that other kernel drivers can use it
to change the PCIe data rate.
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/pci/pcie/bwctrl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c
index c1e749df5bbe..0512ec62dd5b 100644
--- a/drivers/pci/pcie/bwctrl.c
+++ b/drivers/pci/pcie/bwctrl.c
@@ -219,6 +219,7 @@ int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req,
return ret;
}
+EXPORT_SYMBOL_GPL(pcie_set_target_speed);
static void pcie_bwnotif_enable(struct pcie_device *srv)
{
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 3/7] PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 1/7] PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 2/7] PCI: Export pci_set_target_speed() Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 4/7] bus: mhi: host: Add support for Bandwidth scale Krishna Chaitanya Chundru
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru
Add a exported function to convert lnkctl2speed to enum pci_bus_speed,
so that other kernel drivers can use it.
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/pci/pci.c | 15 +++++++++++++++
include/linux/pci.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..a89955617bec 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6056,6 +6056,21 @@ int pcie_link_bandwidth_mbps(struct pci_dev *pdev)
}
EXPORT_SYMBOL(pcie_link_bandwidth_mbps);
+/**
+ * pci_lnkctl2_bus_speed - convert Link Control 2 Target Link Speed to pci_bus_speed
+ * @speed: Target Link Speed (TLS) value from Link Control 2 register (0-4 for 2.5 GT/s - 32 GT/s)
+ *
+ * Convert the Target Link Speed (TLS) field value from the Link Control 2 register
+ * to the corresponding enum pci_bus_speed.
+ *
+ * Return: pci_bus_speed corresponding to the TLS value
+ */
+enum pci_bus_speed pci_lnkctl2_bus_speed(u32 speed)
+{
+ return pcie_link_speed[speed];
+}
+EXPORT_SYMBOL(pci_lnkctl2_bus_speed);
+
/**
* pcie_bandwidth_available - determine minimum link settings of a PCIe
* device and its bandwidth limitation
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 352079393edb..d12875c95491 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1739,6 +1739,7 @@ int pci_cfg_space_size(struct pci_dev *dev);
unsigned char pci_bus_max_busnr(struct pci_bus *bus);
resource_size_t pcibios_window_alignment(struct pci_bus *bus,
unsigned long type);
+enum pci_bus_speed pci_lnkctl2_bus_speed(u32 speed);
#define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
#define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 4/7] bus: mhi: host: Add support for Bandwidth scale
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
` (2 preceding siblings ...)
2026-11-19 12:56 ` [PATCH v6 3/7] PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 5/7] wifi: ath11k: Add support for MHI bandwidth scaling Krishna Chaitanya Chundru
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru
As per MHI spec v1.2, sec 14, MHI supports bandwidth scaling to reduce
power consumption. MHI bandwidth scaling is advertised by devices that
contain the bandwidth scaling capability registers. If enabled, the device
aggregates bandwidth requirements and sends them to the host through
dedicated mhi event ring. After the host performs the bandwidth switch,
it sends an acknowledgment by ringing a doorbell.
if the host supports bandwidth scaling events, then it must set
BW_CFG.ENABLED bit, set BW_CFG.DB_CHAN_ID to the channel ID to the
doorbell that will be used by the host to communicate the bandwidth
scaling status and BW_CFG.ER_INDEX to the index for the event ring
to which the device should send bandwidth scaling request in the
bandwidth scaling capability register.
As part of mmio init check if the bw scale capability is present or not,
if present advertise host supports bw scale by setting all the required
fields.
MHI layer will only forward the bw scaling request to the controller
driver since MHI doesn't have any idea about transport layer used by
the controller, it is responsibility of the controller driver to do actual
bw scaling and then pass status to the MHI. MHI will response back to the
device based up on the status of the bw scale received.
Add a new get_misc_doorbell() to get doorbell for misc capabilities to
use the doorbell with mhi events like MHI BW scale etc.
Use workqueue & mutex for the bw scale events as the pci_set_target_speed()
which will called by the mhi controller driver can sleep.
Co-developed-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
Signed-off-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/bus/mhi/common.h | 13 +++++
drivers/bus/mhi/host/init.c | 90 +++++++++++++++++++++++++++++--
drivers/bus/mhi/host/internal.h | 7 ++-
drivers/bus/mhi/host/main.c | 114 +++++++++++++++++++++++++++++++++++++++-
drivers/bus/mhi/host/pm.c | 10 +++-
drivers/bus/mhi/host/trace.h | 7 +++
include/linux/mhi.h | 11 ++++
7 files changed, 245 insertions(+), 7 deletions(-)
diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h
index 4c316f3d5a68..1091ba6c4dd2 100644
--- a/drivers/bus/mhi/common.h
+++ b/drivers/bus/mhi/common.h
@@ -215,6 +215,19 @@
#define MHI_CAP_ID_MAX_TRB_LEN 0x5
#define MHI_CAP_ID_MAX 0x6
+/* MHI Bandwidth scaling offsets */
+#define MHI_BW_SCALE_CFG_OFFSET 0x4
+#define MHI_BW_SCALE_CAP_ID (3)
+#define MHI_BW_SCALE_DB_CHAN_ID GENMASK(31, 25)
+#define MHI_BW_SCALE_ENABLED BIT(24)
+#define MHI_BW_SCALE_ER_INDEX GENMASK(23, 19)
+
+#define MHI_TRE_GET_EV_BW_REQ_SEQ(tre) FIELD_GET(GENMASK(15, 8), (MHI_TRE_GET_DWORD(tre, 0)))
+
+#define MHI_BW_SCALE_RESULT(status, seq) (FIELD_PREP(GENMASK(11, 8), status) | \
+ FIELD_PREP(GENMASK(7, 0), seq))
+#define MHI_BW_SCALE_NACK 0xf
+
enum mhi_pkt_type {
MHI_PKT_TYPE_INVALID = 0x0,
MHI_PKT_TYPE_NOOP_CMD = 0x1,
diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
index 7ca2fe48c9ac..3e1b61b828a7 100644
--- a/drivers/bus/mhi/host/init.c
+++ b/drivers/bus/mhi/host/init.c
@@ -497,9 +497,67 @@ static int mhi_find_capability(struct mhi_controller *mhi_cntrl, u32 capability)
return 0;
}
+static int mhi_get_er_index(struct mhi_controller *mhi_cntrl,
+ enum mhi_er_data_type type)
+{
+ struct mhi_event *mhi_event = mhi_cntrl->mhi_event;
+ int i;
+
+ /* Find event ring for requested type */
+ for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
+ if (mhi_event->data_type == type)
+ return mhi_event->er_index;
+ }
+
+ return -ENOENT;
+}
+
+static int mhi_init_bw_scale(struct mhi_controller *mhi_cntrl, u32 chdb_offset)
+{
+ struct device *dev = &mhi_cntrl->mhi_dev->dev;
+ struct mhi_event *mhi_event;
+ u32 bw_cfg_offset, val;
+ int er_index, i, bw_scale_db = 0;
+
+ if (!mhi_cntrl->bw_scale)
+ return 0;
+
+ bw_cfg_offset = mhi_find_capability(mhi_cntrl, MHI_BW_SCALE_CAP_ID);
+ if (!bw_cfg_offset)
+ return 0;
+
+ er_index = mhi_get_er_index(mhi_cntrl, MHI_ER_BW_SCALE);
+ if (er_index < 0)
+ return er_index;
+
+ mhi_event = mhi_cntrl->mhi_event;
+ for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
+ if (mhi_event->data_type == MHI_ER_BW_SCALE) {
+ bw_scale_db = mhi_event->doorbell;
+ break;
+ }
+ }
+
+ bw_cfg_offset += MHI_BW_SCALE_CFG_OFFSET;
+
+ /* Advertise host support */
+ val = FIELD_PREP(MHI_BW_SCALE_DB_CHAN_ID, bw_scale_db) |
+ FIELD_PREP(MHI_BW_SCALE_ER_INDEX, er_index) |
+ MHI_BW_SCALE_ENABLED;
+
+ mhi_write_reg(mhi_cntrl, mhi_cntrl->regs, bw_cfg_offset, val);
+
+ mhi_cntrl->bw_scale_db = mhi_cntrl->regs + chdb_offset + (8 * bw_scale_db);
+
+ dev_dbg(dev, "Bandwidth scaling setup complete with event ring: %d\n",
+ er_index);
+
+ return 0;
+}
+
int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
{
- u32 val;
+ u32 val, chdb_offset;
int i, ret;
struct mhi_chan *mhi_chan;
struct mhi_event *mhi_event;
@@ -581,6 +639,8 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
return -ERANGE;
}
+ chdb_offset = val;
+
/* Setup wake db */
mhi_cntrl->wake_db = base + val + (8 * MHI_DEV_WAKE_DB);
mhi_cntrl->wake_set = false;
@@ -634,6 +694,10 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
return ret;
}
+ ret = mhi_init_bw_scale(mhi_cntrl, chdb_offset);
+ if (ret)
+ dev_warn(dev, "Failed to setup bandwidth scaling: %d\n", ret);
+
return 0;
}
@@ -778,6 +842,10 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
case MHI_ER_CTRL:
mhi_event->process_event = mhi_process_ctrl_ev_ring;
break;
+ case MHI_ER_BW_SCALE:
+ mhi_event->doorbell = event_cfg->doorbell;
+ mhi_event->process_event = mhi_process_bw_scale_ev_ring;
+ break;
default:
dev_err(dev, "Event Ring type not supported\n");
goto error_ev_cfg;
@@ -1001,12 +1069,17 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
mhi_event->mhi_cntrl = mhi_cntrl;
spin_lock_init(&mhi_event->lock);
- if (mhi_event->data_type == MHI_ER_CTRL)
+ if (mhi_event->data_type == MHI_ER_CTRL) {
tasklet_init(&mhi_event->task, mhi_ctrl_ev_task,
(ulong)mhi_event);
- else
+ } else if (mhi_event->data_type == MHI_ER_BW_SCALE) {
+ /* Sleeps in pcie_set_target_speed(), so no tasklet */
+ INIT_WORK(&mhi_event->work, mhi_process_ev_work);
+ mutex_init(&mhi_event->mutex);
+ } else {
tasklet_init(&mhi_event->task, mhi_ev_task,
(ulong)mhi_event);
+ }
}
mhi_chan = mhi_cntrl->mhi_chan;
@@ -1094,6 +1167,7 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl)
{
struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev;
struct mhi_chan *mhi_chan = mhi_cntrl->mhi_chan;
+ struct mhi_event *mhi_event;
unsigned int i;
mhi_deinit_free_irq(mhi_cntrl);
@@ -1103,6 +1177,16 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl)
sysfs_remove_file(&mhi_dev->dev.kobj, &dev_attr_trigger_edl.attr);
destroy_workqueue(mhi_cntrl->hiprio_wq);
+
+ /* Clean up BW scale resources */
+ mhi_event = mhi_cntrl->mhi_event;
+ for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
+ if (mhi_event->data_type == MHI_ER_BW_SCALE) {
+ cancel_work_sync(&mhi_event->work);
+ mutex_destroy(&mhi_event->mutex);
+ }
+ }
+
kfree(mhi_cntrl->mhi_cmd);
kfree(mhi_cntrl->mhi_event);
diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
index 7b0ee5e3a12d..a3a9a7f69fa8 100644
--- a/drivers/bus/mhi/host/internal.h
+++ b/drivers/bus/mhi/host/internal.h
@@ -246,10 +246,13 @@ struct mhi_event {
u32 irq;
int chan; /* this event ring is dedicated to a channel (optional) */
u32 priority;
+ u32 doorbell;
enum mhi_er_data_type data_type;
struct mhi_ring ring;
struct db_cfg db_cfg;
struct tasklet_struct task;
+ struct work_struct work;
+ struct mutex mutex; /* serializes bw_scale event processing */
spinlock_t lock;
int (*process_event)(struct mhi_controller *mhi_cntrl,
struct mhi_event *mhi_event,
@@ -404,6 +407,8 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
struct mhi_event *mhi_event, u32 event_quota);
void mhi_uevent_notify(struct mhi_controller *mhi_cntrl, enum mhi_ee_type ee);
+int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
+ struct mhi_event *mhi_event, u32 event_quota);
/* ISR handlers */
irqreturn_t mhi_irq_handler(int irq_number, void *dev);
irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *dev);
@@ -419,5 +424,5 @@ void mhi_unmap_single_no_bb(struct mhi_controller *mhi_cntrl,
struct mhi_buf_info *buf_info);
void mhi_unmap_single_use_bb(struct mhi_controller *mhi_cntrl,
struct mhi_buf_info *buf_info);
-
+void mhi_process_ev_work(struct work_struct *work);
#endif /* _MHI_INT_H */
diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index 4d458396233a..d60e78a5053e 100644
--- a/drivers/bus/mhi/host/main.c
+++ b/drivers/bus/mhi/host/main.c
@@ -478,7 +478,10 @@ irqreturn_t mhi_irq_handler(int irq_number, void *dev)
if (mhi_dev)
mhi_notify(mhi_dev, MHI_CB_PENDING_DATA);
} else {
- tasklet_schedule(&mhi_event->task);
+ if (mhi_event->data_type == MHI_ER_BW_SCALE)
+ queue_work(mhi_cntrl->hiprio_wq, &mhi_event->work);
+ else
+ tasklet_schedule(&mhi_event->task);
}
return IRQ_HANDLED;
@@ -1049,6 +1052,115 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
return count;
}
+int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
+ struct mhi_event *mhi_event, u32 event_quota)
+{
+ struct mhi_event_ctxt *er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
+ struct device *dev = &mhi_cntrl->mhi_dev->dev;
+ struct mhi_ring *ev_ring = &mhi_event->ring;
+ dma_addr_t ptr = le64_to_cpu(er_ctxt->rp);
+ u32 response = MHI_BW_SCALE_NACK;
+ struct mhi_ring_element *dev_rp;
+ struct mhi_link_info link_info;
+ bool dev_wake_held = false;
+ int ret = 0;
+
+ if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state)))
+ return -EIO;
+
+ if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
+ return -EINVAL;
+
+ if (!is_valid_ring_ptr(ev_ring, ptr)) {
+ dev_err(dev,
+ "Event ring rp points outside of the event ring\n");
+ return -EIO;
+ }
+
+ dev_rp = mhi_to_virtual(ev_ring, ptr);
+ if (ev_ring->rp == dev_rp)
+ return 0;
+
+ /* If rp points to base, we need to wrap it around */
+ if (dev_rp == ev_ring->base)
+ dev_rp = ev_ring->base + ev_ring->len;
+ dev_rp--;
+
+ /* Fast forward to currently processed element and recycle er */
+ ev_ring->rp = dev_rp;
+ ev_ring->wp = dev_rp - 1;
+ if (ev_ring->wp < ev_ring->base)
+ ev_ring->wp = ev_ring->base + ev_ring->len - ev_ring->el_size;
+ mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring);
+
+ if (WARN_ON(MHI_TRE_GET_EV_TYPE(dev_rp) != MHI_PKT_TYPE_BW_REQ_EVENT)) {
+ dev_err(dev, "Unexpected event type for BW scale event ring\n");
+ return -EINVAL;
+ }
+
+ trace_mhi_bw_scale_event(mhi_cntrl, dev_rp);
+
+ link_info.target_link_speed = MHI_TRE_GET_EV_LINKSPEED(dev_rp);
+ link_info.target_link_width = MHI_TRE_GET_EV_LINKWIDTH(dev_rp);
+ link_info.sequence_num = MHI_TRE_GET_EV_BW_REQ_SEQ(dev_rp);
+
+ dev_dbg(dev, "Received BW_REQ with seq:%d link speed:0x%x width:0x%x\n",
+ link_info.sequence_num,
+ link_info.target_link_speed,
+ link_info.target_link_width);
+
+ read_lock_bh(&mhi_cntrl->pm_lock);
+ if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)))
+ mhi_ring_er_db(mhi_event);
+ read_unlock_bh(&mhi_cntrl->pm_lock);
+
+ /* Bring host and device out of suspended states */
+ ret = mhi_device_get_sync(mhi_cntrl->mhi_dev);
+ if (ret)
+ goto send_bw_scale_resp;
+
+ mhi_cntrl->runtime_get(mhi_cntrl);
+ dev_wake_held = true;
+
+ ret = mhi_cntrl->bw_scale(mhi_cntrl, &link_info);
+ if (!ret)
+ response = 0;
+
+send_bw_scale_resp:
+ response = MHI_BW_SCALE_RESULT(response, link_info.sequence_num);
+
+ if (ret)
+ dev_err(dev, "BW_REQ seq:%d speed:0x%x width:0x%x NACKed, err:%d\n",
+ link_info.sequence_num, link_info.target_link_speed,
+ link_info.target_link_width, ret);
+
+ write_lock_bh(&mhi_cntrl->pm_lock);
+ if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)))
+ mhi_write_reg(mhi_cntrl, mhi_cntrl->bw_scale_db, 0, response);
+ write_unlock_bh(&mhi_cntrl->pm_lock);
+
+ if (dev_wake_held) {
+ mhi_cntrl->runtime_put(mhi_cntrl);
+ mhi_device_put(mhi_cntrl->mhi_dev);
+ }
+
+ return ret;
+}
+
+void mhi_process_ev_work(struct work_struct *work)
+{
+ struct mhi_event *mhi_event = container_of(work, struct mhi_event,
+ work);
+
+ struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl;
+
+ if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state)))
+ return;
+
+ guard(mutex)(&mhi_event->mutex);
+ mhi_event->process_event(mhi_cntrl, mhi_event, U32_MAX);
+}
+
void mhi_ev_task(unsigned long data)
{
struct mhi_event *mhi_event = (struct mhi_event *)data;
diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c
index ced83fbb1a51..a23d33a914c9 100644
--- a/drivers/bus/mhi/host/pm.c
+++ b/drivers/bus/mhi/host/pm.c
@@ -524,7 +524,10 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl,
if (mhi_event->offload_ev)
continue;
disable_irq(mhi_cntrl->irq[mhi_event->irq]);
- tasklet_kill(&mhi_event->task);
+ if (mhi_event->data_type == MHI_ER_BW_SCALE)
+ cancel_work_sync(&mhi_event->work);
+ else
+ tasklet_kill(&mhi_event->task);
}
/* Release lock and wait for all pending threads to complete */
@@ -681,7 +684,10 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
if (mhi_event->offload_ev)
continue;
- tasklet_kill(&mhi_event->task);
+ if (mhi_event->data_type == MHI_ER_BW_SCALE)
+ cancel_work_sync(&mhi_event->work);
+ else
+ tasklet_kill(&mhi_event->task);
}
/* Release lock and wait for all pending threads to complete */
diff --git a/drivers/bus/mhi/host/trace.h b/drivers/bus/mhi/host/trace.h
index 3e0c41777429..f7cc3470bcdb 100644
--- a/drivers/bus/mhi/host/trace.h
+++ b/drivers/bus/mhi/host/trace.h
@@ -212,6 +212,13 @@ DEFINE_EVENT(mhi_process_event_ring, mhi_ctrl_event,
TP_ARGS(mhi_cntrl, rp)
);
+DEFINE_EVENT(mhi_process_event_ring, mhi_bw_scale_event,
+
+ TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp),
+
+ TP_ARGS(mhi_cntrl, rp)
+);
+
DECLARE_EVENT_CLASS(mhi_update_channel_state,
TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state,
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 65e8a397cc50..d27db66e1225 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -119,10 +119,12 @@ struct image_info {
* struct mhi_link_info - BW requirement
* @target_link_speed: Link speed as defined by TLS bits in LinkControl reg
* @target_link_width: Link width as defined by NLW bits in LinkStatus reg
+ * @sequence_num - used by device to track bw requests sent to host
*/
struct mhi_link_info {
unsigned int target_link_speed;
unsigned int target_link_width;
+ int sequence_num;
};
/**
@@ -201,10 +203,12 @@ enum mhi_ch_ee_mask {
* enum mhi_er_data_type - Event ring data types
* @MHI_ER_DATA: Only client data over this ring
* @MHI_ER_CTRL: MHI control data and client data
+ * @MHI_ER_BW_SCALE: MHI controller bandwidth scale functionality
*/
enum mhi_er_data_type {
MHI_ER_DATA,
MHI_ER_CTRL,
+ MHI_ER_BW_SCALE,
};
/**
@@ -271,6 +275,7 @@ struct mhi_event_config {
u32 irq;
u32 channel;
u32 priority;
+ u32 doorbell;
enum mhi_db_brst_mode mode;
enum mhi_er_data_type data_type;
bool hardware_event;
@@ -315,6 +320,7 @@ struct mhi_controller_config {
* @bhi: Points to base of MHI BHI register space
* @bhie: Points to base of MHI BHIe register space
* @wake_db: MHI WAKE doorbell register address
+ * @bw_scale_db: MHI BW_SCALE doorbell register address
* @iova_start: IOMMU starting address for data (required)
* @iova_stop: IOMMU stop address for data (required)
* @fw_image: Firmware image name for normal booting (optional)
@@ -373,6 +379,7 @@ struct mhi_controller_config {
* @write_reg: Write a MHI register via the physical link (required)
* @reset: Controller specific reset function (optional)
* @edl_trigger: CB function to trigger EDL mode (optional)
+ * @bw_scale: CB function for passing BW scale info (optional)
* @buffer_len: Bounce buffer length
* @index: Index of the MHI controller instance
* @bounce_buf: Use of bounce buffer
@@ -395,6 +402,7 @@ struct mhi_controller {
void __iomem *bhi;
void __iomem *bhie;
void __iomem *wake_db;
+ void __iomem *bw_scale_db;
dma_addr_t iova_start;
dma_addr_t iova_stop;
@@ -459,6 +467,9 @@ struct mhi_controller {
void (*reset)(struct mhi_controller *mhi_cntrl);
int (*edl_trigger)(struct mhi_controller *mhi_cntrl);
+ int (*bw_scale)(struct mhi_controller *mhi_cntrl,
+ struct mhi_link_info *link_info);
+
size_t buffer_len;
int index;
bool bounce_buf;
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 5/7] wifi: ath11k: Add support for MHI bandwidth scaling
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
` (3 preceding siblings ...)
2026-11-19 12:56 ` [PATCH v6 4/7] bus: mhi: host: Add support for Bandwidth scale Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 6/7] wifi: ath12k: " Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 7/7] PCI: qcom: Enable ASPM disabling during link retraining Krishna Chaitanya Chundru
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru, Miaoqing Pan
From: Miaoqing Pan <quic_miaoqing@quicinc.com>
Add support for MHI bandwidth scaling, which will reduce power consumption
if WLAN operates with lower bandwidth. This feature is only enabled for
QCA6390.
Bandwidth scaling is initiated by the endpoint firmware based upon the
bandwidth requirements, if there is high bandwidth data endpoint requests
for higher data rates or if there is less bandwidth they request for lower
data rates to reduce power. Endpoint initiates this through MHI protocol.
Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-04546-QCAHSPSWPL_V1_V2_SILICONZ_IOE-1
Signed-off-by: Miaoqing Pan <quic_miaoqing@quicinc.com>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath11k/mhi.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/mhi.c b/drivers/net/wireless/ath/ath11k/mhi.c
index a6c9ff112c68..65637fba92d1 100644
--- a/drivers/net/wireless/ath/ath11k/mhi.c
+++ b/drivers/net/wireless/ath/ath11k/mhi.c
@@ -20,6 +20,7 @@
#define MHI_TIMEOUT_DEFAULT_MS 20000
#define RDDM_DUMP_SIZE 0x420000
#define MHI_CB_INVALID 0xff
+#define MHI_BW_SCALE_CHAN_DB 126
static const struct mhi_channel_config ath11k_mhi_channels_qca6390[] = {
{
@@ -71,6 +72,18 @@ static struct mhi_event_config ath11k_mhi_events_qca6390[] = {
.client_managed = false,
.offload_channel = false,
},
+ {
+ .num_elements = 8,
+ .irq_moderation_ms = 0,
+ .irq = 1,
+ .mode = MHI_DB_BRST_DISABLE,
+ .data_type = MHI_ER_BW_SCALE,
+ .doorbell = MHI_BW_SCALE_CHAN_DB,
+ .priority = 2,
+ .hardware_event = false,
+ .client_managed = false,
+ .offload_channel = false,
+ },
};
static const struct mhi_controller_config ath11k_mhi_config_qca6390 = {
@@ -311,6 +324,21 @@ static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl,
writel(val, addr);
}
+static int ath11k_mhi_op_bw_scale(struct mhi_controller *mhi_cntrl,
+ struct mhi_link_info *link_info)
+{
+ enum pci_bus_speed speed = pci_lnkctl2_bus_speed(link_info->target_link_speed);
+ struct ath11k_base *ab = dev_get_drvdata(mhi_cntrl->cntrl_dev);
+ struct pci_dev *pci_dev = to_pci_dev(ab->dev);
+ struct pci_dev *pdev;
+
+ pdev = pci_upstream_bridge(pci_dev);
+ if (!pdev)
+ return -ENODEV;
+
+ return pcie_set_target_speed(pdev, speed, true);
+}
+
static int ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl)
{
struct device_node *np;
@@ -387,6 +415,7 @@ int ath11k_mhi_register(struct ath11k_pci *ab_pci)
mhi_ctrl->status_cb = ath11k_mhi_op_status_cb;
mhi_ctrl->read_reg = ath11k_mhi_op_read_reg;
mhi_ctrl->write_reg = ath11k_mhi_op_write_reg;
+ mhi_ctrl->bw_scale = ath11k_mhi_op_bw_scale;
switch (ab->hw_rev) {
case ATH11K_HW_QCN9074_HW10:
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 6/7] wifi: ath12k: Add support for MHI bandwidth scaling
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
` (4 preceding siblings ...)
2026-11-19 12:56 ` [PATCH v6 5/7] wifi: ath11k: Add support for MHI bandwidth scaling Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 7/7] PCI: qcom: Enable ASPM disabling during link retraining Krishna Chaitanya Chundru
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru
Add support for MHI bandwidth scaling, which reduces power consumption
if WLAN operates with lower bandwidth. This is only enabled for WCN7850.
Bandwidth scaling is initiated by the endpoint firmware based upon the
bandwidth requirements: with high bandwidth data the endpoint requests
higher data rates, and with less bandwidth it requests lower data rates
to reduce power. The endpoint initiates this through the MHI protocol.
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mhi.c | 16 ++++++++++++++++
drivers/net/wireless/ath/ath12k/mhi.h | 2 ++
drivers/net/wireless/ath/ath12k/wifi7/mhi.c | 12 ++++++++++++
3 files changed, 30 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/mhi.c b/drivers/net/wireless/ath/ath12k/mhi.c
index ee87f00bc5de..16d3f299c47b 100644
--- a/drivers/net/wireless/ath/ath12k/mhi.c
+++ b/drivers/net/wireless/ath/ath12k/mhi.c
@@ -184,6 +184,21 @@ static void ath12k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl,
writel(val, addr);
}
+static int ath12k_mhi_op_bw_scale(struct mhi_controller *mhi_cntrl,
+ struct mhi_link_info *link_info)
+{
+ enum pci_bus_speed speed = pci_lnkctl2_bus_speed(link_info->target_link_speed);
+ struct ath12k_base *ab = dev_get_drvdata(mhi_cntrl->cntrl_dev);
+ struct pci_dev *pci_dev = to_pci_dev(ab->dev);
+ struct pci_dev *pdev;
+
+ pdev = pci_upstream_bridge(pci_dev);
+ if (!pdev)
+ return -ENODEV;
+
+ return pcie_set_target_speed(pdev, speed, true);
+}
+
int ath12k_mhi_register(struct ath12k_pci *ab_pci)
{
struct ath12k_base *ab = ab_pci->ab;
@@ -261,6 +276,7 @@ int ath12k_mhi_register(struct ath12k_pci *ab_pci)
mhi_ctrl->status_cb = ath12k_mhi_op_status_cb;
mhi_ctrl->read_reg = ath12k_mhi_op_read_reg;
mhi_ctrl->write_reg = ath12k_mhi_op_write_reg;
+ mhi_ctrl->bw_scale = ath12k_mhi_op_bw_scale;
ret = mhi_register_controller(mhi_ctrl, ab->hw_params->mhi_config);
if (ret) {
diff --git a/drivers/net/wireless/ath/ath12k/mhi.h b/drivers/net/wireless/ath/ath12k/mhi.h
index 367432676385..7187394458c1 100644
--- a/drivers/net/wireless/ath/ath12k/mhi.h
+++ b/drivers/net/wireless/ath/ath12k/mhi.h
@@ -17,6 +17,8 @@
#define MHICTRL 0x38
#define MHICTRL_RESET_MASK 0x2
+#define MHI_BW_SCALE_CHAN_DB 126
+
enum ath12k_mhi_state {
ATH12K_MHI_INIT,
ATH12K_MHI_DEINIT,
diff --git a/drivers/net/wireless/ath/ath12k/wifi7/mhi.c b/drivers/net/wireless/ath/ath12k/wifi7/mhi.c
index 988affafcfd1..c482f0e04742 100644
--- a/drivers/net/wireless/ath/ath12k/wifi7/mhi.c
+++ b/drivers/net/wireless/ath/ath12k/wifi7/mhi.c
@@ -120,6 +120,18 @@ static struct mhi_event_config ath12k_wifi7_mhi_events_wcn7850[] = {
.client_managed = false,
.offload_channel = false,
},
+ {
+ .num_elements = 8,
+ .irq_moderation_ms = 0,
+ .irq = 1,
+ .mode = MHI_DB_BRST_DISABLE,
+ .data_type = MHI_ER_BW_SCALE,
+ .doorbell = MHI_BW_SCALE_CHAN_DB,
+ .priority = 2,
+ .hardware_event = false,
+ .client_managed = false,
+ .offload_channel = false,
+ },
};
const struct mhi_controller_config ath12k_wifi7_mhi_config_wcn7850 = {
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 7/7] PCI: qcom: Enable ASPM disabling during link retraining
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
` (5 preceding siblings ...)
2026-11-19 12:56 ` [PATCH v6 6/7] wifi: ath12k: " Krishna Chaitanya Chundru
@ 2026-11-19 12:56 ` Krishna Chaitanya Chundru
6 siblings, 0 replies; 8+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-11-19 12:56 UTC (permalink / raw)
To: Bjorn Helgaas, Ilpo Järvinen, Jingoo Han, Lorenzo Pieralisi,
Rob Herring, Jeff Johnson, Bartosz Golaszewski,
Manivannan Sadhasivam, Krzysztof Wilczyński
Cc: linux-pci, linux-kernel, linux-arm-msm, mhi, linux-wireless,
ath11k, qiang.yu, Krishna Chaitanya Chundru
Some Qualcomm PCIe controllers require ASPM to be disabled while the link
is being retrained, otherwise the link state transitions during bandwidth
scaling can fail. This is a controller requirement, not a device quirk.
Set the disable_aspm_for_retrain flag in qcom_pcie_host_init() so that
the PCI core disables ASPM around link retraining. Future targets fix
this in hardware and will not set the flag.
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
drivers/pci/controller/dwc/pcie-qcom.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 9b113536a82b..473f2fce258a 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -1514,6 +1514,8 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)
qcom_pcie_perst_deassert(pcie);
+ pp->bridge->disable_aspm_for_retrain = true;
+
if (pcie->cfg->ops->config_sid) {
ret = pcie->cfg->ops->config_sid(pcie);
if (ret)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-19 12:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 12:56 [PATCH v6 0/7] bus: mhi: host: Add support for mhi bus bw Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 1/7] PCI/bwctrl: Set host bridge OPP and optionally disable ASPM around link retraining Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 2/7] PCI: Export pci_set_target_speed() Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 3/7] PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 4/7] bus: mhi: host: Add support for Bandwidth scale Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 5/7] wifi: ath11k: Add support for MHI bandwidth scaling Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 6/7] wifi: ath12k: " Krishna Chaitanya Chundru
2026-11-19 12:56 ` [PATCH v6 7/7] PCI: qcom: Enable ASPM disabling during link retraining Krishna Chaitanya Chundru
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®