SpacemiT: Add linux-7.0.y "mainline" support#9458
Conversation
Legacy, 6.6.y. Current, 6.18.y. Edge, 7.0.y. Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
BananaPi BPI-F3 SpacemiT MusePi Pro Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a "legacy" kernel target and reorganizes spacemit kernel branches (legacy/current/edge); adds many spacemit kernel configs and board DTs; introduces a SpacemiT K1 thermal driver and bindings, regulator and PCIe/PHY updates, USB2 PHY disconnect support, and board/device-tree adjustments. Changes
Sequence Diagram(s)mermaid DTS->>Driver: DT nodes + thermal-zone bindings Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch (3)
421-448: Clarify interrupt register semantics.The interrupt enable/mask logic appears inconsistent at first glance:
- Line 422: Writing
0xffffffffto "disable all interrupts"- Line 447: Setting
K1_TSENSOR_INT_EN_MASK(bit 0) to "enable thermal interrupt"- Line 467: Clearing bits in
k1_tsensor_enable_irq()to enable per-sensor interruptsThis suggests bit 0 is a global enable (active-high) while bits 1+ are per-sensor masks (active-high = masked). The register naming
INT_EN_REGis potentially misleading since it appears to function as both an enable and mask register. Consider adding a brief comment explaining this dual behavior for future maintainers.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch` around lines 421 - 448, The interrupt register K1_TSENSOR_INT_EN_REG is used as both a global enable (bit 0, K1_TSENSOR_INT_EN_MASK) and per-sensor mask bits (bits 1+, manipulated in k1_tsensor_enable_irq()), which is confusing given the name; add a short clarifying comment near the writes that first write 0xffffffff and later set K1_TSENSOR_INT_EN_MASK (and reference k1_tsensor_enable_irq()) explaining that bit 0 is a global active-high interrupt enable while the upper bits are per-sensor active-high masks, so code readers understand the dual semantics.
528-531: Minor cleanup: remove unnecessary cast and use u32 for register values.
- Line 530: The C-style cast
(struct k1_tsensor *)is unnecessary asvoid *converts implicitly.- Line 531:
maskandstatushold register values and should beu32for consistency with other register operations in the driver.♻️ Suggested cleanup
static irqreturn_t k1_tsensor_irq_thread(int irq, void *data) { - struct k1_tsensor *ts = (struct k1_tsensor *)data; - int mask, status, i; + struct k1_tsensor *ts = data; + u32 mask, status; + int i;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch` around lines 528 - 531, In k1_tsensor_irq_thread, remove the unnecessary C-style cast on the data argument by assigning data directly to ts (i.e., use "struct k1_tsensor *ts = data;") and change the types of register-related variables mask and status from int to u32 to match other register operations in the driver (keep loop/index variable i as int); update the variable declarations in the function signature/body accordingly.
581-600: Consider adding error context on probe failures.The thermal zone registration (line 582) and IRQ request (line 599-600) failures return error codes without descriptive messages, which could make debugging harder during board bring-up. Using
dev_err_probe()would provide consistent error reporting.♻️ Suggested improvement
ts->ch[i].tzd = devm_thermal_of_zone_register(dev, i, ts->ch + i, &k1_tsensor_ops); if (IS_ERR(ts->ch[i].tzd)) - return PTR_ERR(ts->ch[i].tzd); + return dev_err_probe(dev, PTR_ERR(ts->ch[i].tzd), + "Failed to register thermal zone %d\n", i); ... ret = devm_request_threaded_irq(dev, irq, NULL, k1_tsensor_irq_thread, IRQF_ONESHOT, "k1_tsensor", ts); if (ret < 0) - return ret; + return dev_err_probe(dev, ret, "Failed to request IRQ\n");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch` around lines 581 - 600, Replace raw error returns on thermal zone registration and IRQ request with dev_err_probe-style reporting: when IS_ERR(ts->ch[i].tzd) is true and when devm_thermal_add_hwmon_sysfs() or devm_request_threaded_irq() fail, call dev_err_probe(dev, err, "...") (or use dev_err_probe with the returned negative code) to log a descriptive message (e.g., "failed to register thermal zone %d" or "failed to request IRQ %d") before returning the error; update the probe path around the checks for ts->ch[i].tzd, devm_thermal_add_hwmon_sysfs(dev, ts->ch[i].tzd) and devm_request_threaded_irq(..., k1_tsensor_irq_thread, ...) to use dev_err_probe for consistent error context and then return the error code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@config/boards/orangepirv2.wip`:
- Line 6: The KERNEL_TARGET change makes the case "${BRANCH}" in edge) block and
the BCMDHD WiFi enablement dead/orphaned code; either remove that case block
entirely or comment it with a clear explanation that edge support (and
SD/SDIO/BCMDHD) was intentionally dropped for linux-7.0.y, and if retaining it
temporarily, add a TODO linking to the PR explaining why it's unreachable;
update any references to BCMDHD or edge-specific variables to avoid confusion
(search for the case "${BRANCH}" in edge) block and the BCMDHD mention to locate
and edit).
In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`:
- Around line 497-521: k1_tsensor_set_trips must handle the thermal-framework
sentinel values (INT_MIN for "no low", INT_MAX for "no high") before converting
and programming the hardware; update k1_tsensor_set_trips to check for low ==
INT_MIN and high == INT_MAX (use INT_MIN/INT_MAX) and map them to safe hardware
values instead of clamping negatives or allowing overflow: treat INT_MIN low as
"disabled" (set low to 0 or the register's minimum encodable value) and treat
INT_MAX high as the maximum encodable threshold (derive from
K1_TSENSOR_THRSH_HIGH_MASK / FIELD_GET range) before performing the /1000 +
TEMPERATURE_OFFSET conversion and FIELD_PREP into
K1_TSENSOR_THRSH_LOW_MASK/K1_TSENSOR_THRSH_HIGH_MASK; do these checks prior to
dividing or applying FIELD_PREP so no overflow/wrap occurs.
---
Nitpick comments:
In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`:
- Around line 421-448: The interrupt register K1_TSENSOR_INT_EN_REG is used as
both a global enable (bit 0, K1_TSENSOR_INT_EN_MASK) and per-sensor mask bits
(bits 1+, manipulated in k1_tsensor_enable_irq()), which is confusing given the
name; add a short clarifying comment near the writes that first write 0xffffffff
and later set K1_TSENSOR_INT_EN_MASK (and reference k1_tsensor_enable_irq())
explaining that bit 0 is a global active-high interrupt enable while the upper
bits are per-sensor active-high masks, so code readers understand the dual
semantics.
- Around line 528-531: In k1_tsensor_irq_thread, remove the unnecessary C-style
cast on the data argument by assigning data directly to ts (i.e., use "struct
k1_tsensor *ts = data;") and change the types of register-related variables mask
and status from int to u32 to match other register operations in the driver
(keep loop/index variable i as int); update the variable declarations in the
function signature/body accordingly.
- Around line 581-600: Replace raw error returns on thermal zone registration
and IRQ request with dev_err_probe-style reporting: when IS_ERR(ts->ch[i].tzd)
is true and when devm_thermal_add_hwmon_sysfs() or devm_request_threaded_irq()
fail, call dev_err_probe(dev, err, "...") (or use dev_err_probe with the
returned negative code) to log a descriptive message (e.g., "failed to register
thermal zone %d" or "failed to request IRQ %d") before returning the error;
update the probe path around the checks for ts->ch[i].tzd,
devm_thermal_add_hwmon_sysfs(dev, ts->ch[i].tzd) and
devm_request_threaded_irq(..., k1_tsensor_irq_thread, ...) to use dev_err_probe
for consistent error context and then return the error code.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (15)
config/boards/bananapif3.confconfig/boards/musepipro.confconfig/boards/orangepir2s.wipconfig/boards/orangepirv2.wipconfig/kernel/linux-spacemit-current.configconfig/kernel/linux-spacemit-edge.configconfig/kernel/linux-spacemit-legacy.configconfig/sources/families/spacemit.confpatch/kernel/archive/spacemit-7.0/001-Update-MusePi-Pro-DTS.patchpatch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patchpatch/kernel/archive/spacemit-7.0/003-PATCH-0-4-regulator-spacemit-p1-Fix-voltage-ranges-and-support-board-power-tree.patchpatch/kernel/archive/spacemit-7.0/004-PATCH-phy-move-spacemit-pcie-driver-to-its-subfolder.patchpatch/kernel/archive/spacemit-7.0/005-PATCH-riscv-dts-spacemit-adapt-regulator-node-name-to-preferred-form.patchpatch/kernel/archive/spacemit-7.0/006-PATCH-v5-2-2-mfd-simple-mfd-i2c-add-a-reboot-cell-for-the-SpacemiT-P1-chip.patchpatch/kernel/archive/spacemit-7.0/007-PATCH-v3-phy-k1-usb-add-disconnect-function-support.patch
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
igorpecovnik
left a comment
There was a problem hiding this comment.
I don't have issues with the change.
@sven-ola I assume you are good too?
|
✅ This PR has been reviewed and approved — all set for merge! |
|
As it's described by @pyavitz: no SD card support. Thus was not able to boot this kernel on my board (even not from NVME and my eMMC is also not considered). Need to investigate, probably not before thursday... |
I think there is no rush with this as linux 7 support is very basic atm. I'll merge this as is later. Here is more about change current -> legacy |
The DTS for those units need some love, much like the MusePi Pro did. That would be my guess as to why they aren't booting. Maybe something can be found here; https://lore.kernel.org/spacemit |
There is a lot here that is still not supported.
Most importantly
https://paste.armbian.com/ecugarozit.yaml
Boot tested on: BPI-F3 and MusePi Pro
Summary by CodeRabbit
New Features
Bug Fixes
Refactor