* [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: handle charging state change notifications
[not found] <20251009155752.773732-1-sashal@kernel.org>
@ 2025-10-09 15:54 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: add OOI chemistry Sasha Levin
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:54 UTC (permalink / raw)
To: patches, stable
Cc: Fenglin Wu, Sebastian Reichel, Sasha Levin, sre, linux-arm-msm,
linux-pm
From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
[ Upstream commit 41307ec7df057239aae3d0f089cc35a0d735cdf8 ]
The X1E80100 battery management firmware sends a notification with
code 0x83 when the battery charging state changes, such as switching
between fast charge, taper charge, end of charge, or any other error
charging states.
The same notification code is used with bit[8] set when charging stops
because the charge control end threshold is reached. Additionally,
a 2-bit value is included in bit[10:9] with the same code to indicate
the charging source capability, which is determined by the calculated
power from voltage and current readings from PDOs: 2 means a strong
charger over 60W, 1 indicates a weak charger, and 0 means there is no
charging source.
These 3-MSB [10:8] in the notification code is not much useful for now,
hence just ignore them and trigger a power supply change event whenever
0x83 notification code is received. This helps to eliminate the unknown
notification error messages.
Reported-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Closes: https://lore.kernel.org/all/r65idyc4of5obo6untebw4iqfj2zteiggnnzabrqtlcinvtddx@xc4aig5abesu/
Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes
- Unhandled firmware notifications: On X1E80100 the PMIC GLINK
firmware emits notification code 0x83 for charging state changes
(fast/taper/EOC/error). Today, the driver does not recognize 0x83
and logs “unknown notification” without notifying userspace. See
default case logging in the current tree:
`drivers/power/supply/qcom_battmgr.c:965`.
- Bit-extended notifications misparsed: Firmware also sets the 3 MSBs
[10:8] on this code for EOC (bit 8) and charging source capability
(bits [10:9]), which causes values like 0x183/0x283 to miss all
known cases and be treated as unknown. The change masks these bits
before the switch.
- Code changes and why they are correct
- New code constant: Adds `#define NOTIF_BAT_CHARGING_STATE 0x83` so
charging-state change notifications are recognized as first-class
events (`drivers/power/supply/qcom_battmgr.c:39` in upstream).
- Mask unusable MSBs: In `qcom_battmgr_notification()`, masks the
notification to the low 8 bits: `notification &= 0xff;` so
0x183/0x283 collapse to 0x83 and match the new case
(`drivers/power/supply/qcom_battmgr.c:1212` in upstream). This
matches the commit message rationale that bits [10:8] carry
auxiliary info not used by the driver today.
- Trigger userspace update: Adds a switch case for
`NOTIF_BAT_CHARGING_STATE` to call
`power_supply_changed(battmgr->bat_psy)`, same as other battery-
related notifications (`drivers/power/supply/qcom_battmgr.c:1218`).
This ensures userspace observes charging state transitions.
- Eliminates spurious errors: With masking + case, the default branch
which logs “unknown notification: %#x” (seen in current code at
`drivers/power/supply/qcom_battmgr.c:965`) is no longer hit for 0x83
variants, addressing the reported log spam.
- Scope and dependencies
- Single-file, minimal delta: Only
`drivers/power/supply/qcom_battmgr.c` is touched with 1 new define,
1 mask line, and 1 new switch case arm. No ABI or architectural
changes.
- Self-contained: No new APIs, headers, or cross-driver dependencies.
The driver already processes other notifications and calls
`power_supply_changed()` in the same function, so behavior is
consistent.
- Platform relevance: The tree already contains X1E80100 support
(e.g., compatible present in this driver), so affected systems exist
in stable lines and will benefit immediately.
- Risk assessment
- Low regression risk: Masking to 8 bits only affects notification
decoding and only for codes using upper bits as flags. All existing
known codes in this driver are within 1 byte; masking does not
collide with other codes. If a different notification someday uses
MSBs meaningfully, it will still be decoded to its base 8-bit code,
which is how the driver already categorizes notifications.
- Correct functional behavior: Treating charging state changes like
other battery property/status notifications by calling
`power_supply_changed()` is aligned with existing patterns and will
simply refresh properties from firmware.
- No behavioral change on platforms that do not emit 0x83 or do not
set the MSBs; the new case just won’t be hit.
- User impact
- Fixes stale charging state in user space that otherwise would not
update on state transitions without some other event.
- Removes persistent “unknown notification” error messages that
confuse users and integrate logs.
- Stable backport criteria
- Fixes a real user-visible bug (missing updates + log spam) on
hardware supported by stable trees.
- Change is small, contained, and non-invasive; no features or
architecture changes.
- Touches a driver in the power supply subsystem (not a core/critical
kernel subsystem), further reducing risk.
- Upstream rationale is clear; commit includes a report and a public
discussion link (“Closes:” tag), consistent with a corrective change
rather than a feature.
Conclusion: This is a textbook, low-risk bug fix that improves
correctness and logging. It should be backported to stable trees that
include `qcom_battmgr` and X1E80100/SC8280XP variants.
drivers/power/supply/qcom_battmgr.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index fdb2d1b883fc5..c9dc8b378aa1e 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -30,8 +30,9 @@ enum qcom_battmgr_variant {
#define NOTIF_BAT_PROPERTY 0x30
#define NOTIF_USB_PROPERTY 0x32
#define NOTIF_WLS_PROPERTY 0x34
-#define NOTIF_BAT_INFO 0x81
#define NOTIF_BAT_STATUS 0x80
+#define NOTIF_BAT_INFO 0x81
+#define NOTIF_BAT_CHARGING_STATE 0x83
#define BATTMGR_BAT_INFO 0x9
@@ -947,12 +948,14 @@ static void qcom_battmgr_notification(struct qcom_battmgr *battmgr,
}
notification = le32_to_cpu(msg->notification);
+ notification &= 0xff;
switch (notification) {
case NOTIF_BAT_INFO:
battmgr->info.valid = false;
fallthrough;
case NOTIF_BAT_STATUS:
case NOTIF_BAT_PROPERTY:
+ case NOTIF_BAT_CHARGING_STATE:
power_supply_changed(battmgr->bat_psy);
break;
case NOTIF_USB_PROPERTY:
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: add OOI chemistry
[not found] <20251009155752.773732-1-sashal@kernel.org>
2025-10-09 15:54 ` [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: handle charging state change notifications Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.12] firmware: qcom: tzmem: disable sc7180 platform Sasha Levin
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Christopher Ruehl, Dmitry Baryshkov, Sebastian Reichel,
Sasha Levin, sre, linux-arm-msm, linux-pm
From: Christopher Ruehl <chris.ruehl@gtsys.com.hk>
[ Upstream commit fee0904441325d83e7578ca457ec65a9d3f21264 ]
The ASUS S15 xElite model report the Li-ion battery with an OOI, hence this
update the detection and return the appropriate type.
Signed-off-by: Christopher Ruehl <chris.ruehl@gtsys.com.hk>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES – this patch is a focused bug fix that lets the Qualcomm battery
manager report the correct technology for hardware already supported by
stable kernels.
- `drivers/power/supply/qcom_battmgr.c:986` broadens the existing Li-ion
match to accept the firmware string `OOI`, which the ASUS S15 xElite
uses for its Li-ion pack; without this, the driver falls through to
the error path.
- Because the fallback logs `pr_err("Unknown battery technology '%s'")`
at `drivers/power/supply/qcom_battmgr.c:990`, affected systems
currently emit misleading kernel errors and expose
`POWER_SUPPLY_PROP_TECHNOLOGY` as `UNKNOWN`, confusing user space (see
the assignment at `drivers/power/supply/qcom_battmgr.c:1039`).
- The change mirrors the earlier `LIP` support that was already accepted
upstream for another device, touches only a single helper, and has no
dependencies, so it is safe to integrate into older stable trees that
already ship this driver.
- Risk is minimal: it simply recognizes an existing firmware identifier
and maps it to the already-supported `POWER_SUPPLY_TECHNOLOGY_LION`
value, with no architectural impact or behavioral change for other
devices.
Natural next step: 1) Queue for the stable trees that include
`drivers/power/supply/qcom_battmgr.c` so ASUS S15 xElite users stop
seeing bogus error logs and get the correct battery technology reported.
drivers/power/supply/qcom_battmgr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 99808ea9851f6..fdb2d1b883fc5 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -982,7 +982,8 @@ static void qcom_battmgr_sc8280xp_strcpy(char *dest, const char *src)
static unsigned int qcom_battmgr_sc8280xp_parse_technology(const char *chemistry)
{
- if (!strncmp(chemistry, "LIO", BATTMGR_CHEMISTRY_LEN))
+ if ((!strncmp(chemistry, "LIO", BATTMGR_CHEMISTRY_LEN)) ||
+ (!strncmp(chemistry, "OOI", BATTMGR_CHEMISTRY_LEN)))
return POWER_SUPPLY_TECHNOLOGY_LION;
if (!strncmp(chemistry, "LIP", BATTMGR_CHEMISTRY_LEN))
return POWER_SUPPLY_TECHNOLOGY_LIPO;
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-6.12] firmware: qcom: tzmem: disable sc7180 platform
[not found] <20251009155752.773732-1-sashal@kernel.org>
2025-10-09 15:54 ` [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: handle charging state change notifications Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.6] power: supply: qcom_battmgr: add OOI chemistry Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] soc: qcom: smem: Fix endian-unaware access of num_entries Sasha Levin
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Nikita Travkin, Dmitry Baryshkov, Bjorn Andersson, Sasha Levin,
bartosz.golaszewski, konradybcio, linux-arm-msm
From: Nikita Travkin <nikita@trvn.ru>
[ Upstream commit 3cc9a8cadaf66e1a53e5fee48f8bcdb0a3fd5075 ]
When SHM bridge is enabled, assigning RMTFS memory causes the calling
core to hang if the system is running in EL1.
Disable SHM bridge on sc7180 devices to avoid that hang.
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250721-sc7180-shm-hang-v1-1-99ad9ffeb5b4@trvn.ru
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES – Disabling the SHM bridge for sc7180 is a focused bug fix that
should be backported.
- `drivers/firmware/qcom/qcom_tzmem.c:79-86` keeps a blacklist of SoCs
where SHM bridge must not be activated. Adding `"qcom,sc7180"` there
makes the `for` loop in `qcom_tzmem_init()` bail out early
(`drivers/firmware/qcom/qcom_tzmem.c:93-109`), leaving
`qcom_tzmem_using_shm_bridge` false so the allocator stays in the safe
generic mode.
- Without this change, sc7180 boots with SHM bridge enabled (arm64
defconfig selects `CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE=y`, see
`arch/arm64/configs/defconfig:265`), so `qcom_scm_shm_bridge_enable()`
(`drivers/firmware/qcom/qcom_scm.c:1612-1636`) runs on every boot. On
EL1-only firmware this causes the subsequent `qcom_scm_assign_mem()`
from the RMTFS driver (`drivers/soc/qcom/rmtfs_mem.c:272-276`) to hang
the CPU when it shares the modem buffer—an unrecoverable failure
affecting common sc7180 Chromebooks and reference boards.
- The fix is consistent with earlier stable backports that blacklisted
other SoCs for the same hazard (e.g. commits `55751d3e9e96d`,
`8342009efa2a5`, `db3de3ff2611f`), underscoring that the risk is real
and the mitigation is accepted practice.
- Impact is tightly scoped: only SHM-bridge builds on sc7180 change
behaviour, falling back to the pre-existing generic allocator. No API,
ABI, or architectural changes are involved, so regression risk is
minimal while it prevents a hard hang.
- The underlying bug dates back to the SHM-bridge enablement
(`f86c61498a573`, in v6.11-rc1), so all stable lines derived from 6.11
(and newer) can be affected and benefit from the blacklist entry.
This satisfies stable-tree criteria: it fixes a severe runtime hang, the
patch is tiny and self-contained, and it simply restores the proven-safe
allocation mode on the affected hardware.
drivers/firmware/qcom/qcom_tzmem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
index ea0a353556570..12e448669b8bd 100644
--- a/drivers/firmware/qcom/qcom_tzmem.c
+++ b/drivers/firmware/qcom/qcom_tzmem.c
@@ -77,6 +77,7 @@ static bool qcom_tzmem_using_shm_bridge;
/* List of machines that are known to not support SHM bridge correctly. */
static const char *const qcom_tzmem_blacklist[] = {
+ "qcom,sc7180", /* hang in rmtfs memory assignment */
"qcom,sc8180x",
"qcom,sdm670", /* failure in GPU firmware loading */
"qcom,sdm845", /* reset in rmtfs memory assignment */
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-5.4] soc: qcom: smem: Fix endian-unaware access of num_entries
[not found] <20251009155752.773732-1-sashal@kernel.org>
` (2 preceding siblings ...)
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.12] firmware: qcom: tzmem: disable sc7180 platform Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict Sasha Levin
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Jens Reidel, Bjorn Andersson, Sasha Levin, konradybcio,
andy.gross, quic_clew, linux-arm-msm
From: Jens Reidel <adrian@mainlining.org>
[ Upstream commit 19e7aa0e9e46d0ad111a4af55b3d681b6ad945e0 ]
Add a missing le32_to_cpu when accessing num_entries, which is always a
little endian integer.
Fixes booting on Xiaomi Mi 9T (xiaomi-davinci) in big endian.
Signed-off-by: Jens Reidel <adrian@mainlining.org>
Link: https://lore.kernel.org/r/20250726235646.254730-1-adrian@mainlining.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## BACKPORT RECOMMENDATION: **YES**
### Executive Summary
This commit MUST be backported to stable kernel trees. It fixes a
critical endianness bug that causes boot failures on big-endian systems
running Qualcomm platforms with SMEM version 12
(SMEM_GLOBAL_PART_VERSION).
---
### Detailed Analysis
#### 1. **Nature of the Bug**
The bug is in `drivers/soc/qcom/smem.c` at line 901 in the
`qcom_smem_get_item_count()` function:
```c
info = (struct smem_info *)&ptable->entry[ptable->num_entries];
```
**Problem:** `ptable->num_entries` is defined as `__le32` (little-endian
32-bit integer) in the `smem_ptable` structure (line 170), but it's
being used directly as an array index without endianness conversion.
**Correct pattern (as used elsewhere in the same file):**
```c
for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) // Line 976
```
#### 2. **Code Context and Impact**
**Structure definition (line 167-172):**
```c
struct smem_ptable {
u8 magic[4];
__le32 version;
__le32 num_entries; // <-- Little-endian field
__le32 reserved[5];
struct smem_ptable_entry entry[];
};
```
**The calculation:** The code calculates the address of `smem_info`
structure, which is located immediately after the last
`smem_ptable_entry` in the array. On big-endian systems:
- Without fix: If `num_entries` is actually 5 (0x00000005 in memory),
the big-endian CPU reads it as 0x05000000 (83,886,080), pointing to
completely wrong memory
- With fix: `le32_to_cpu()` converts 0x05000000 → 0x00000005, giving the
correct index
**Impact on different systems:**
- **Little-endian (ARM/ARM64):** No conversion needed; works correctly
(most Qualcomm devices)
- **Big-endian:** Reads wrong memory address, leading to:
- Magic number mismatch → returns default SMEM_ITEM_COUNT (512)
instead of actual value
- Potential memory access violations → boot failure (as reported for
Xiaomi Mi 9T)
#### 3. **Historical Context**
**Timeline of relevant commits:**
1. **2015-09-02** - Commit `9806884d8cd55` by Stephen Boyd: "Handle big
endian CPUs"
- Comprehensive conversion of smem driver for big-endian support
- Annotated all structures with `__le32`, `__le16` types
- Added proper `le32_to_cpu()` conversions throughout
2. **2017-10-11** - Commit `5b3940676107dd` by Chris Lew: "Support
dynamic item limit"
- Introduced `qcom_smem_get_item_count()` function
- **Bug introduced here:** Forgot `le32_to_cpu()` conversion on line
901
- This was AFTER big-endian support was added, so it should have
followed the established pattern
- First appeared in v4.15-rc1 (January 2018)
3. **2025-07-27** - Commit `19e7aa0e9e46d` by Jens Reidel: "Fix endian-
unaware access of num_entries"
- The fix being analyzed (mainline)
- Already backported to at least one stable tree as `ad59a6c4b1ef1`
**Bug lifespan:** ~7 years (v4.15 to v6.17+), affecting all stable
kernels in this range
#### 4. **Consistency Analysis**
I verified ALL uses of `num_entries` in the file:
| Line | Code | Status |
|------|------|--------|
| 901 | `&ptable->entry[ptable->num_entries]` | ❌ **BUG** (missing
conversion) |
| 976 | `i < le32_to_cpu(ptable->num_entries)` | ✅ Correct |
| 1025 | `i < le32_to_cpu(ptable->num_entries)` | ✅ Correct |
Line 901 is the ONLY location with the bug. All other accesses properly
use `le32_to_cpu()`.
Additionally, the same function correctly converts other endianness-
sensitive fields:
- Line 905: `return le16_to_cpu(info->num_items);` ✅
#### 5. **Risk Assessment**
**Risk of backporting: MINIMAL**
✅ **Pros:**
- **One-line change:** Only adds `le32_to_cpu()` wrapper
- **Established pattern:** Follows existing code style (lines 976, 1025)
- **Well-tested:** Already in mainline and at least one stable tree
- **No functional change on little-endian:** `le32_to_cpu()` is a no-op
on LE systems
- **Fixes real-world bug:** User reported boot failure on Xiaomi Mi 9T
- **No side effects:** Pure correctness fix with no behavioral changes
on currently working systems
❌ **Cons:**
- None identified
**Regression risk:** Effectively zero. The fix cannot break little-
endian systems (no-op conversion) and fixes broken big-endian systems.
#### 6. **Stable Tree Criteria Compliance**
| Criterion | Assessment |
|-----------|------------|
| Fixes important bug | ✅ YES - Boot failure on big-endian |
| Small and contained | ✅ YES - One line change |
| Doesn't introduce new features | ✅ YES - Pure bug fix |
| No architectural changes | ✅ YES - Follows existing pattern |
| Minimal regression risk | ✅ YES - No-op on LE, fixes BE |
| Affects real users | ✅ YES - Xiaomi Mi 9T users reported |
| Security implications | ⚠️ Potential - Incorrect memory access could
be security-relevant |
#### 7. **Additional Evidence**
1. **Already being backported:** The presence of commit `ad59a6c4b1ef1`
(backport with "Signed-off-by: Sasha Levin") indicates stable
maintainers are actively backporting this fix
2. **Consistent with subsystem patterns:** All other endianness
conversions in the driver follow this exact pattern
3. **Affects multiple kernel versions:** Bug present since v4.15, so
kernels 4.15, 4.19, 5.4, 5.10, 5.15, 6.1, 6.6, 6.17 all need this fix
4. **No Fixes tag:** The original commit lacks a "Fixes:" tag, which is
unfortunate but shouldn't prevent backporting. The bug was introduced
in commit `5b3940676107dd`.
#### 8. **Technical Verification**
I verified the bug exists in the current 6.17 tree:
```bash
$ grep -n "info = (struct smem_info \*)&ptable->entry\["
drivers/soc/qcom/smem.c
901: info = (struct smem_info *)&ptable->entry[ptable->num_entries];
```
The fix has NOT been applied yet to this tree.
---
### Recommendation
**STRONGLY RECOMMEND BACKPORTING** this commit to all stable trees from
v4.15 onwards.
**Justification:**
1. Fixes a real, user-reported bug (boot failure)
2. Minimal change with zero regression risk
3. Follows established code patterns
4. Pure correctness fix that should have been in the original code
5. Already being backported to other stable trees
6. Affects all stable kernels since v4.15 (7+ years)
**Suggested Fixes tag (for stable backports):**
```
Fixes: 5b3940676107 ("soc: qcom: smem: Support dynamic item limit")
```
This is a textbook example of a commit that should be backported: small,
safe, fixes a real bug, and has been thoroughly validated.
drivers/soc/qcom/smem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index cf425930539e4..c4c45f15dca4f 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -898,7 +898,7 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
if (IS_ERR_OR_NULL(ptable))
return SMEM_ITEM_COUNT;
- info = (struct smem_info *)&ptable->entry[ptable->num_entries];
+ info = (struct smem_info *)&ptable->entry[le32_to_cpu(ptable->num_entries)];
if (memcmp(info->magic, SMEM_INFO_MAGIC, sizeof(info->magic)))
return SMEM_ITEM_COUNT;
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict
[not found] <20251009155752.773732-1-sashal@kernel.org>
` (3 preceding siblings ...)
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] soc: qcom: smem: Fix endian-unaware access of num_entries Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 16:08 ` Konrad Dybcio
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.16] firmware: qcom: scm: Allow QSEECOM on Dell Inspiron 7441 / Latitude 7455 Sasha Levin
` (2 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Bartosz Golaszewski, Konrad Dybcio, Neil Armstrong, Linus Walleij,
Sasha Levin, andersson, linux-arm-msm
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
[ Upstream commit cc85cb96e2e4489826e372cde645b7823c435de0 ]
The strict flag in struct pinmux_ops disallows the usage of the same pin
as a GPIO and for another function. Without it, a rouge user-space
process with enough privileges (or even a buggy driver) can request a
used pin as GPIO and drive it, potentially confusing devices or even
crashing the system. Set it globally for all pinctrl-msm users.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES – with the prerequisite series in place.
- `drivers/pinctrl/qcom/pinctrl-msm.c:219-227` now turns on `.strict`,
so once a TLMM pin is muxed to a function it cannot be re-requested as
a GPIO by a second consumer. This closes the long-standing hole where
a privileged userspace process (or a misbehaving kernel client) could
grab an in-use pin via gpiolib and drive it, confusing or crashing
attached peripherals.
- The pinmux core side already enforces the exclusivity checks: see
`drivers/pinctrl/pinmux.c:79-143`, where `ops->strict` blocks a second
claimant unless the current mux function is known to be a GPIO. With
`.strict` enabled, we finally get the same protection for Qualcomm
TLMM as many other pinctrl drivers already enjoy.
- Safe backporting absolutely requires the two earlier commits that
landed right before this one upstream:
1. `11aa02d6a9c22 ("pinctrl: allow to mark pin functions as
requestable GPIOs")` adds `PINFUNCTION_FLAG_GPIO` plus the
`function_is_gpio` hook used to keep GPIO-mode pins requestable
even under `strict`.
2. `b65803da894ca ("pinctrl: qcom: add infrastructure for marking pin
functions as GPIOs")` wires that hook up for TLMM by tagging the
`msm_mux_gpio` functions and populating `.function_is_gpio` in
`msm_pinmux_ops`.
Without these, setting `.strict` would regress every board that
applies a GPIO pinctrl state and then requests the same line through
gpiolib (the common regulator/reset pattern).
- Impact scope is large—the TLMM driver serves virtually every modern
Qualcomm SoC—but the behaviour now matches core expectations, and
legitimate GPIO users keep working because the GPIO function is
flagged appropriately. The only fallout should be catching real
conflicts (double ownership or debug “pin poking”), which is precisely
what we want to prevent.
- Change size is tiny, architectural churn is nil, and the fix has
Reviewed/Tested tags. Risk mainly comes from omitting the
dependencies; with them backported, this is a low-risk hardening fix.
Given the security and robustness benefits, and provided the two
prerequisite commits are included, this commit is a good candidate for
the stable kernels.
drivers/pinctrl/qcom/pinctrl-msm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 83eb075b6bfa1..bdce967710a31 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -293,6 +293,7 @@ static const struct pinmux_ops msm_pinmux_ops = {
.get_function_groups = msm_get_function_groups,
.gpio_request_enable = msm_pinmux_request_gpio,
.set_mux = msm_pinmux_set_mux,
+ .strict = true,
};
static int msm_config_reg(struct msm_pinctrl *pctrl,
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict Sasha Levin
@ 2025-10-09 16:08 ` Konrad Dybcio
2025-11-04 0:28 ` Sasha Levin
0 siblings, 1 reply; 10+ messages in thread
From: Konrad Dybcio @ 2025-10-09 16:08 UTC (permalink / raw)
To: Sasha Levin, patches, stable
Cc: Bartosz Golaszewski, Neil Armstrong, Linus Walleij, andersson,
linux-arm-msm
On 10/9/25 5:55 PM, Sasha Levin wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> [ Upstream commit cc85cb96e2e4489826e372cde645b7823c435de0 ]
>
> The strict flag in struct pinmux_ops disallows the usage of the same pin
> as a GPIO and for another function. Without it, a rouge user-space
> process with enough privileges (or even a buggy driver) can request a
> used pin as GPIO and drive it, potentially confusing devices or even
> crashing the system. Set it globally for all pinctrl-msm users.
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
I didn't receive more related patches, but this had quite some
dependencies (in pinctrl core and individual per-SoC drivers), which I'm
not sure are worth all digging up and resolving conflicts
Konrad
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict
2025-10-09 16:08 ` Konrad Dybcio
@ 2025-11-04 0:28 ` Sasha Levin
0 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-11-04 0:28 UTC (permalink / raw)
To: Konrad Dybcio
Cc: patches, stable, Bartosz Golaszewski, Neil Armstrong,
Linus Walleij, andersson, linux-arm-msm
On Thu, Oct 09, 2025 at 06:08:03PM +0200, Konrad Dybcio wrote:
>On 10/9/25 5:55 PM, Sasha Levin wrote:
>> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>
>> [ Upstream commit cc85cb96e2e4489826e372cde645b7823c435de0 ]
>>
>> The strict flag in struct pinmux_ops disallows the usage of the same pin
>> as a GPIO and for another function. Without it, a rouge user-space
>> process with enough privileges (or even a buggy driver) can request a
>> used pin as GPIO and drive it, potentially confusing devices or even
>> crashing the system. Set it globally for all pinctrl-msm users.
>>
>> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>> Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>
>I didn't receive more related patches, but this had quite some
>dependencies (in pinctrl core and individual per-SoC drivers), which I'm
>not sure are worth all digging up and resolving conflicts
Dropped, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH AUTOSEL 6.17-6.16] firmware: qcom: scm: Allow QSEECOM on Dell Inspiron 7441 / Latitude 7455
[not found] <20251009155752.773732-1-sashal@kernel.org>
` (4 preceding siblings ...)
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] pinctrl: qcom: make the pinmuxing strict Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.12] firmware: qcom: scm: preserve assign_mem() error return value Sasha Levin
2025-10-09 15:56 ` [PATCH AUTOSEL 6.17-5.4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card Sasha Levin
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Val Packett, Laurentiu Tudor, Bryan O'Donoghue,
Bjorn Andersson, Sasha Levin, konradybcio, linux-arm-msm
From: Val Packett <val@packett.cool>
[ Upstream commit 30ee285f1e3cdc88ec7010abeaba0cbed800bdcd ]
Allow these machines to access efivars through qseecom/uefisecapp.
Signed-off-by: Val Packett <val@packett.cool>
Reviewed-by: Laurentiu Tudor <laurentiu.tudor1@dell.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20250716003139.18543-5-val@packett.cool
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Analysis Complete
**Backport Status: YES**
### Detailed Analysis
#### 1. **Code Changes (drivers/firmware/qcom/qcom_scm.c:1994-2014)**
The commit adds exactly **2 lines** to the
`qcom_scm_qseecom_allowlist[]` static array:
```c
{ .compatible = "dell,inspiron-14-plus-7441" },
{ .compatible = "dell,latitude-7455" },
```
This is a minimal, surgical change that adds device tree compatible
strings to an allowlist that gates access to the QSEECOM interface for
UEFI variable access.
#### 2. **Stable Kernel Policy Compliance**
The Linux stable kernel rules (Documentation/process/stable-kernel-
rules.rst:24) **explicitly allow** this type of commit:
> **"New device IDs and quirks are also accepted."**
This commit adds new device identifiers to a quirk/allowlist table,
which is precisely what the stable policy permits.
#### 3. **Risk Assessment: MINIMAL**
- **Scope**: Only affects Dell Inspiron 7441 and Latitude 7455 machines
with matching device tree compatible strings
- **Regression risk**: Zero risk to existing hardware - the allowlist
check at qcom_scm.c:2063 means only machines explicitly listed can
access this functionality
- **Size**: 2 lines added, no algorithmic changes
- **Side effects**: None - confined to enabling QSEECOM on specific
machines
#### 4. **Historical Precedent: STRONG**
I identified **20+ similar commits** since 2024, all following the
identical pattern:
- `9b01fc6bb1fca` - Asus Vivobook S15 (in v6.14)
- `96ac79829ccd7` - Windows Dev Kit 2023 (in v6.14, v6.15)
- `eb47bca4cc8ab` - HP EliteBook Ultra G1q
- `304c250ba121f` - Dell XPS 13 9345 (in v6.13, v6.14, v6.15)
- `7d467c1b62d0b` - HP Omnibook X14 (in v6.14)
All of these allowlist additions have been backported to stable kernels,
establishing clear precedent.
#### 5. **User Impact: SIGNIFICANT**
The commit message states: "Allow these machines to access efivars
through qseecom/uefisecapp."
Without this commit, users of these Dell laptops cannot:
- Access UEFI variables (needed for boot configuration)
- Use efivarfs
- Modify boot settings from Linux
- Properly support firmware updates
This is a **real user-facing bug** that affects hardware functionality.
#### 6. **Testing and Review Quality**
The commit includes:
- `Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>`
- `Reviewed-by: Laurentiu Tudor <laurentiu.tudor1@dell.com>` (Dell
engineer)
Both Dell and Linaro have validated this change.
#### 7. **Already Selected for Backporting**
The commit **has already been backported** (commit `3301ae3f6d73a` by
Sasha Levin on October 3, 2025), confirming the stable maintainer's
assessment that it meets backporting criteria.
### Conclusion
**YES** - This commit is an excellent candidate for stable backporting
because:
1. ✅ Explicitly permitted by stable rules (new device IDs)
2. ✅ Fixes real user-facing issue (UEFI variable access)
3. ✅ Minimal size (2 lines)
4. ✅ Zero regression risk (only affects listed machines)
5. ✅ Well-tested and reviewed
6. ✅ Follows established pattern (20+ similar backports)
7. ✅ Enables critical hardware functionality
drivers/firmware/qcom/qcom_scm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 5243d5abbbe99..7f43f12e4e1b2 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1994,6 +1994,8 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
{ .compatible = "asus,vivobook-s15" },
{ .compatible = "asus,zenbook-a14-ux3407qa" },
{ .compatible = "asus,zenbook-a14-ux3407ra" },
+ { .compatible = "dell,inspiron-14-plus-7441" },
+ { .compatible = "dell,latitude-7455" },
{ .compatible = "dell,xps13-9345" },
{ .compatible = "hp,elitebook-ultra-g1q" },
{ .compatible = "hp,omnibook-x14" },
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-6.12] firmware: qcom: scm: preserve assign_mem() error return value
[not found] <20251009155752.773732-1-sashal@kernel.org>
` (5 preceding siblings ...)
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.16] firmware: qcom: scm: Allow QSEECOM on Dell Inspiron 7441 / Latitude 7455 Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:56 ` [PATCH AUTOSEL 6.17-5.4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card Sasha Levin
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Mukesh Ojha, Konrad Dybcio, Bjorn Andersson, Sasha Levin,
konradybcio, linux-arm-msm
From: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
[ Upstream commit 121fcf3c871181edce0708a49d2397cedd6ad21f ]
When qcom_scm_assign_mem() fails, the error value is currently being
overwritten after it is logged, resulting in the loss of the original
error code. Fix this by retaining and returning the original error value
as intended.
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250807124451.2623019-1-mukesh.ojha@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive analysis, here is my assessment:
## **Backport Status: YES**
### Summary of Analysis
This commit fixes a **7-year-old bug** in error handling for Qualcomm
Secure Channel Manager memory assignment operations. The bug was
introduced in commit d82bd359972a7f (Oct 2017) and has persisted across
all kernel versions since then.
### Bug Description
In `qcom_scm_assign_mem()` at **drivers/firmware/qcom/qcom_scm.c:1122**,
when the secure call `__qcom_scm_assign_mem()` fails:
- The actual error code is logged: `"Assign memory protection call
failed %d\n", ret`
- But then **-EINVAL is hardcoded** in the return: `return -EINVAL;`
- The fix changes this to: `return ret;`
This means callers lose critical diagnostic information about *why* the
memory assignment failed.
### Impact Assessment
**Affected Subsystems** (verified via code search):
- **drivers/misc/fastrpc.c** - FastRPC DSP communication (6 call sites)
- **drivers/net/wireless/ath/ath10k/qmi.c** - WiFi driver (2 call sites)
- **drivers/remoteproc/qcom_q6v5_mss.c** - Modem remoteproc (1 call
site)
- **drivers/remoteproc/qcom_q6v5_pas.c** - Peripheral remoteproc (2 call
sites)
- **drivers/soc/qcom/rmtfs_mem.c** - Remote filesystem memory (2 call
sites)
All these subsystems need accurate error codes to distinguish between:
- `-ENOMEM` - Memory allocation failures
- `-ETIMEDOUT` - Secure call timeout
- Firmware-specific error codes from `res.result[0]`
Currently, all failures return `-EINVAL`, making debugging Qualcomm
platform issues significantly harder.
### Stable Kernel Criteria Compliance
✅ **Fixes a real bug**: Yes - error codes are incorrectly reported,
affecting debugging
✅ **Small and contained**: Yes - single line change
✅ **Obviously correct**: Yes - preserves the actual error instead of
overwriting it
✅ **No architectural changes**: Correct - purely error handling
✅ **Minimal regression risk**: Extremely low - only changes error return
value
✅ **Already in mainline**: Yes - commit
121fcf3c871181edce0708a49d2397cedd6ad21f (Aug 2025)
✅ **Applies to all stable trees**: Verified present in v4.19, v5.10,
v5.15, v6.6, v6.17
### Code Change Analysis
**Before:**
```c
ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz,
ptr_phys, src_sz, dest_phys, dest_sz);
if (ret) {
dev_err(__scm->dev,
"Assign memory protection call failed %d\n", ret);
return -EINVAL; // ❌ Wrong - loses actual error
}
```
**After:**
```c
return ret; // ✅ Correct - preserves actual error
```
### Why This Should Be Backported
1. **Debugging improvement**: Users and developers debugging WiFi,
modem, or DSP issues on Qualcomm platforms will get accurate error
codes
2. **No behavior change for success case**: Only affects error paths
3. **No dependencies**: Applies cleanly across all kernel versions since
2017
4. **Consistent with kernel practices**: Error codes should be
propagated, not overwritten
5. **Long-standing issue**: Bug has existed since initial implementation
- affects many kernel versions in production
**Recommendation**: Backport to all active stable trees (6.12+, 6.6.x,
6.1.x, 5.15.x, 5.10.x, 5.4.x, 4.19.x).
drivers/firmware/qcom/qcom_scm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 26cd0458aacd6..5243d5abbbe99 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1119,7 +1119,7 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
if (ret) {
dev_err(__scm->dev,
"Assign memory protection call failed %d\n", ret);
- return -EINVAL;
+ return ret;
}
*srcvm = next_vm;
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 6.17-5.4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card
[not found] <20251009155752.773732-1-sashal@kernel.org>
` (6 preceding siblings ...)
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.12] firmware: qcom: scm: preserve assign_mem() error return value Sasha Levin
@ 2025-10-09 15:56 ` Sasha Levin
7 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2025-10-09 15:56 UTC (permalink / raw)
To: patches, stable
Cc: Sarthak Garg, Adrian Hunter, Ulf Hansson, Sasha Levin, linux-mmc,
linux-arm-msm
From: Sarthak Garg <quic_sartgarg@quicinc.com>
[ Upstream commit 08b68ca543ee9d5a8d2dc406165e4887dd8f170b ]
For Qualcomm SoCs which needs level shifter for SD card, extra delay is
seen on receiver data path.
To compensate this delay enable tuning for SDR50 mode for targets which
has level shifter. SDHCI_SDR50_NEEDS_TUNING caps will be set for targets
with level shifter on Qualcomm SOC's.
Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES. Enabling SDR50 tuning fixes a real bug that hits Qualcomm boards
using SD card level shifters, where the RX delay makes SDR50 unreliable
unless the DLL is tuned. Today `sdhci_msm_is_tuning_needed()` returns
false for SDR50 because of the existing `CORE_FREQ_100MHZ` check, so the
controller never tunes even when hardware advertises
`SDHCI_SDR50_NEEDS_TUNING`; this means the extra propagation delay is
never compensated. The patch adds an early SDR50+flag check
(`drivers/mmc/host/sdhci-msm.c:1119`) so tuning runs whenever firmware
sets that capability, and it programs the vendor “HC_SELECT_IN” field to
the new SDR50 selector before the tuning loop (`drivers/mmc/host/sdhci-
msm.c:1210` together with the new `CORE_HC_SELECT_IN_SDR50` definition
at `drivers/mmc/host/sdhci-msm.c:82`). That matches how HS400 is already
handled and lets the DLL pick the correct sampling point. The change is
tiny, self-contained to the Qualcomm host driver, and only engages when
hardware already flagged that SDR50 needs tuning, so it shouldn’t
regress other users. No new APIs or structural work are introduced,
making this an appropriate, low-risk stable backport that restores
reliable SDR50 operation on the affected systems.
drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 9d8e20dc8ca11..e7df864bdcaf6 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -81,6 +81,7 @@
#define CORE_IO_PAD_PWR_SWITCH_EN BIT(15)
#define CORE_IO_PAD_PWR_SWITCH BIT(16)
#define CORE_HC_SELECT_IN_EN BIT(18)
+#define CORE_HC_SELECT_IN_SDR50 (4 << 19)
#define CORE_HC_SELECT_IN_HS400 (6 << 19)
#define CORE_HC_SELECT_IN_MASK (7 << 19)
@@ -1133,6 +1134,10 @@ static bool sdhci_msm_is_tuning_needed(struct sdhci_host *host)
{
struct mmc_ios *ios = &host->mmc->ios;
+ if (ios->timing == MMC_TIMING_UHS_SDR50 &&
+ host->flags & SDHCI_SDR50_NEEDS_TUNING)
+ return true;
+
/*
* Tuning is required for SDR104, HS200 and HS400 cards and
* if clock frequency is greater than 100MHz in these modes.
@@ -1201,6 +1206,8 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
struct mmc_ios ios = host->mmc->ios;
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+ const struct sdhci_msm_offset *msm_offset = msm_host->offset;
+ u32 config;
if (!sdhci_msm_is_tuning_needed(host)) {
msm_host->use_cdr = false;
@@ -1217,6 +1224,14 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
*/
msm_host->tuning_done = 0;
+ if (ios.timing == MMC_TIMING_UHS_SDR50 &&
+ host->flags & SDHCI_SDR50_NEEDS_TUNING) {
+ config = readl_relaxed(host->ioaddr + msm_offset->core_vendor_spec);
+ config &= ~CORE_HC_SELECT_IN_MASK;
+ config |= CORE_HC_SELECT_IN_EN | CORE_HC_SELECT_IN_SDR50;
+ writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec);
+ }
+
/*
* For HS400 tuning in HS200 timing requires:
* - select MCLK/2 in VENDOR_SPEC
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread