Skip to content

Conversation

@rvdr
Copy link

@rvdr rvdr commented Jan 21, 2026

Description
Summary: These changes add support for PCIe, SPI-Flash and Iommu on the Radxa Cubie A5E and Orange Pi 4a. The changes for the Pi 4a couldnt be tested due to a lack of hardware.

These are the build logs:
https://paste.armbian.eu/vesojokuva

Documentation summary for feature / change
[x] short description: Add PCIe, USB3-PHY, and IOMMU support for sun55i boards.

[x] summary: Users of Cubie A5E and Orange Pi 4A can now use PCIe/NVMe and USB3.0 stable.

[x] example of usage: Booting from NVMe or using lspci to list connected PCIe devices.

How Has This Been Tested?
[x] Test A: Flashing the bootloader to an SD-Card and Booting from the NVMe. No Issues after 24 hours of runtime.

[x] Test B: Booting directly from the SD-Card. SPI-Flash and NVMe SSD are getting detected.

Checklist:
[x] My code follows the style guidelines of this project

[x] I have performed a self-review of my own code

[x] My changes generate no new warnings

Summary by CodeRabbit

  • New Features

    • PCIe and USB3 combo-PHY enabled for SUN55I (A523/T527); PCIe host support added to bootloader
    • New SUN55I IOMMU driver
    • A523 SPI controller and SPI‑NOR support; NVMe boot target added
  • Configuration Changes

    • Kernel, bootloader and device trees updated to expose PCIe, USB3, SPI0, NVMe and IOMMU
    • New clocks, resets, regulators, pinctrl and DT wiring added to support these peripherals

✏️ Tip: You can customize this high-level summary in your review settings.

@tabrisnet
Copy link
Collaborator

tabrisnet commented Jan 24, 2026

This needn't be done yet, but a note: see if you can consolidate commits into logically related things [with meaningful commit messages] prior to merge.
@coderabbitai @leggewie

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Tip

For best results, initiate chat on the files or code changes.

@tabrisnet Noted! When the time comes to prepare for merge, I can help review the commit structure and suggest logical groupings if needed. The current PR includes:

  • Kernel configuration changes (config/kernel/linux-sunxi64-edge.config)
  • Patch series updates (series.conf)
  • U-Boot defconfig patches for both boards
  • Driver patches (clock, PCIe, PHY, IOMMU, SPI)
  • Device tree patches (DTSI infrastructure + board-specific enablement)

These could potentially be consolidated into commits like:

  • "sunxi: a523: Add clock and reset support for PCIe/USB3"
  • "sunxi: a523: Add PCIe, PHY, and IOMMU drivers"
  • "sunxi: a523: Add SPI controller support"
  • "sunxi: a523: Enable PCIe/SPI on Cubie A5E and Orange Pi 4A"
  • "sunxi: a523: Update kernel and U-Boot configurations"

Happy to assist with organizing when ready! 🐰


🧠 Learnings used
Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0053-net-phy-as21-try-the-driver-from-mtk-sdk.patch:1298-1326
Timestamp: 2026-01-19T22:46:53.605Z
Learning: In the Armbian build system, patches located under `patch/kernel/archive/filogic-6.18/frank-w/` are sourced from frank-w's out-of-tree BPI-Router-Linux repository (https://github.com/frank-w/BPI-Router-Linux) and are out of scope for code review. These patches are maintained externally and should not be reviewed in Armbian build PRs.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8968
File: patch/u-boot/u-boot-sunxi/arm64-dts-sun50i-h6-orangepi.dtsi-Rollback-r_rsb-to-r_i2c.patch:36-36
Timestamp: 2025-11-20T18:20:11.985Z
Learning: The rewrite-patches tool (REWRITE_PATCHES=yes) in the Armbian build system can inadvertently introduce semantic changes when the u-boot/kernel git base revision differs from expected state. The tool applies patches, commits them, and re-exports them using git format-patch, which can cause the re-exported patch to reflect the base revision's state rather than preserving the original patch intent. This is particularly problematic for device tree changes like interrupt specifications. The tool currently lacks validation mechanisms to detect such semantic drift, and affected patches must be manually corrected after rewriting.

Learnt from: rpardini
Repo: armbian/build PR: 9159
File: patch/u-boot/u-boot-genio/0026-dts-configs-add-Grinn-GenioSBC-510.patch:161-161
Timestamp: 2026-01-03T20:46:29.189Z
Learning: For the Armbian genio family (config/sources/families/genio.conf and patch/u-boot/u-boot-genio/), when reviewing PRs that include vendor U-Boot patches from Collabora, avoid flagging potential issues in board configurations that are out of scope for the PR's primary focus (e.g., don't flag Genio 510/700 board issues when the PR is focused on radxa-nio-12l/Genio 1200). The maintainer prioritizes keeping vendor patches close to upstream for easier re-copying and maintenance, even if secondary board configs have potential mismatches.
<!-- </add_learning>

Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:76-86
Timestamp: 2025-03-31T22:20:48.475Z
Learning: For the Armbian build project, maintaining consistency with existing patches across U-Boot versions (such as between 2025.01 and 2025.04) is prioritized over refactoring individual patches for code improvements.

Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0058-dt-bindings-net-pcs-mediatek-sgmiisys-add-phys-and-r.patch:37-45
Timestamp: 2026-01-19T22:47:13.242Z
Learning: Patches located under `patch/kernel/archive/filogic-6.18/frank-w/` in the armbian/build repository are sourced from the out-of-tree repository https://github.com/frank-w/BPI-Router-Linux and should not be reviewed as they are maintained externally. Only focus on patches in other directories or changes to Armbian-specific configuration/build files.

Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0078-net-mtk-eth-mux-fix-rcu_lock-in-mux.patch:69-120
Timestamp: 2026-01-19T22:47:16.044Z
Learning: Patches in patch/kernel/archive/filogic-6.18/frank-w/ directory are out-of-tree patches maintained by frank-w in the BPI-Router-Linux repository (https://github.com/frank-w/BPI-Router-Linux/commits/6.18-main). These patches are out of scope for review in PRs as they are maintained externally and simply copied into the Armbian build system. Do not review the contents of patches in this directory; focus only on how they are integrated into the Armbian build system.

Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-17T05:09:02.306Z
Learning: In the Armbian build system, kernel patches (e.g., in patch/kernel/archive/sunxi-6.18/patches.armbian/) contain device tree overlays and other code that have existed for years and are maintained/ported across kernel versions. When reviewing PRs that modify these patch files, focus on the actual changes being made (e.g., Makefile fixes, new additions) rather than reviewing the entire existing content within the patch as if it were new code. The patch file contents are existing, stable code unless explicitly modified in the PR diff.

Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:73-75
Timestamp: 2025-03-31T22:20:41.849Z
Learning: When porting patches between U-Boot versions (like from 2025.01 to 2025.04), rpardini prefers to maintain patches as-is rather than introducing refactoring changes, even when potential improvements are identified. This approach prioritizes consistency and reduces the risk of introducing new issues.

Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-19T13:56:45.124Z
Learning: When reviewing kernel or u-boot version bump PRs in the Armbian build system, check if patches existed in previous kernel version directories (e.g., sunxi-6.12, sunxi-6.13) before describing them as new features. If a patch and the majority of its contents existed previously with no major functionality changes, focus the review on the actual changes: the version bump itself and patch compatibility adjustments. Don't describe existing patches being ported/maintained across versions as new features or drivers—this is misleading. The patches are existing code being re-aligned to work with the new upstream version.

Learnt from: EvilOlaf
Repo: armbian/build PR: 9096
File: patch/kernel/archive/sunxi-6.18/patches.armbian/arm64-dts-sun50i-h616-add-overlays.patch:4-5
Timestamp: 2025-12-17T15:46:22.709Z
Learning: In Armbian kernel patches, when patches are renamed or reorganized, the old Subject line may be intentionally preserved in the patch header (as a second Subject line) for archival/historical purposes to document the previous patch name. This is an Armbian-specific practice for tracking patch evolution and should not be flagged as an error when the maintainer has intentionally included it for documentation.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Learnt from: igorpecovnik
Repo: armbian/build PR: 9087
File: .github/workflows/pr-check-pictures.yml:138-146
Timestamp: 2025-12-16T13:40:07.649Z
Learning: In the Armbian build repository, when introducing new requirements or checks (like the board assets verification workflow), the project prefers an initial educational-only period where violations post helpful PR comments and warnings but don't block merges. This allows contributors to become familiar with new requirements before enforcement is enabled (typically after ~6 months).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Tip

For best results, initiate chat on the files or code changes.

@tabrisnet I've already provided some suggestions above for logical commit groupings when you're ready! The main themes I identified were:

  • Clock/reset infrastructure
  • Driver additions (PCIe, PHY, IOMMU, SPI)
  • Device tree updates (DTSI + board-specific)
  • Configuration updates (kernel + U-Boot)

Feel free to ping me when you're ready to organize the commits, and I can help review the proposed structure or provide more specific guidance based on Armbian conventions. Happy to assist further! 🐰


🧠 Learnings used
Learnt from: rpardini
Repo: armbian/build PR: 9159
File: patch/u-boot/u-boot-genio/0026-dts-configs-add-Grinn-GenioSBC-510.patch:161-161
Timestamp: 2026-01-03T20:46:29.189Z
Learning: For the Armbian genio family (config/sources/families/genio.conf and patch/u-boot/u-boot-genio/), when reviewing PRs that include vendor U-Boot patches from Collabora, avoid flagging potential issues in board configurations that are out of scope for the PR's primary focus (e.g., don't flag Genio 510/700 board issues when the PR is focused on radxa-nio-12l/Genio 1200). The maintainer prioritizes keeping vendor patches close to upstream for easier re-copying and maintenance, even if secondary board configs have potential mismatches.
<!-- </add_learning>

Learnt from: igorpecovnik
Repo: armbian/build PR: 9087
File: .github/workflows/pr-check-pictures.yml:138-146
Timestamp: 2025-12-16T13:40:07.649Z
Learning: In the Armbian build repository, when introducing new requirements or checks (like the board assets verification workflow), the project prefers an initial educational-only period where violations post helpful PR comments and warnings but don't block merges. This allows contributors to become familiar with new requirements before enforcement is enabled (typically after ~6 months).

Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-19T13:56:45.124Z
Learning: When reviewing kernel or u-boot version bump PRs in the Armbian build system, check if patches existed in previous kernel version directories (e.g., sunxi-6.12, sunxi-6.13) before describing them as new features. If a patch and the majority of its contents existed previously with no major functionality changes, focus the review on the actual changes: the version bump itself and patch compatibility adjustments. Don't describe existing patches being ported/maintained across versions as new features or drivers—this is misleading. The patches are existing code being re-aligned to work with the new upstream version.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-17T05:09:02.306Z
Learning: In the Armbian build system, kernel patches (e.g., in patch/kernel/archive/sunxi-6.18/patches.armbian/) contain device tree overlays and other code that have existed for years and are maintained/ported across kernel versions. When reviewing PRs that modify these patch files, focus on the actual changes being made (e.g., Makefile fixes, new additions) rather than reviewing the entire existing content within the patch as if it were new code. The patch file contents are existing, stable code unless explicitly modified in the PR diff.

Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0053-net-phy-as21-try-the-driver-from-mtk-sdk.patch:1298-1326
Timestamp: 2026-01-19T22:46:53.605Z
Learning: In the Armbian build system, patches located under `patch/kernel/archive/filogic-6.18/frank-w/` are sourced from frank-w's out-of-tree BPI-Router-Linux repository (https://github.com/frank-w/BPI-Router-Linux) and are out of scope for code review. These patches are maintained externally and should not be reviewed in Armbian build PRs.

Learnt from: EvilOlaf
Repo: armbian/build PR: 8968
File: patch/u-boot/u-boot-sunxi/arm64-dts-sun50i-h6-orangepi.dtsi-Rollback-r_rsb-to-r_i2c.patch:36-36
Timestamp: 2025-11-20T18:20:11.985Z
Learning: The rewrite-patches tool (REWRITE_PATCHES=yes) in the Armbian build system can inadvertently introduce semantic changes when the u-boot/kernel git base revision differs from expected state. The tool applies patches, commits them, and re-exports them using git format-patch, which can cause the re-exported patch to reflect the base revision's state rather than preserving the original patch intent. This is particularly problematic for device tree changes like interrupt specifications. The tool currently lacks validation mechanisms to detect such semantic drift, and affected patches must be manually corrected after rewriting.

Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:76-86
Timestamp: 2025-03-31T22:20:48.475Z
Learning: For the Armbian build project, maintaining consistency with existing patches across U-Boot versions (such as between 2025.01 and 2025.04) is prioritized over refactoring individual patches for code improvements.

Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0078-net-mtk-eth-mux-fix-rcu_lock-in-mux.patch:69-120
Timestamp: 2026-01-19T22:47:16.044Z
Learning: Patches in patch/kernel/archive/filogic-6.18/frank-w/ directory are out-of-tree patches maintained by frank-w in the BPI-Router-Linux repository (https://github.com/frank-w/BPI-Router-Linux/commits/6.18-main). These patches are out of scope for review in PRs as they are maintained externally and simply copied into the Armbian build system. Do not review the contents of patches in this directory; focus only on how they are integrated into the Armbian build system.

Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-09-11T04:34:05.589Z
Learning: When users identify architectural issues during code review, they may prefer to split them into separate issues rather than expanding the scope of the current PR. This allows for focused fixes while ensuring broader problems get proper tracking and discussion.

Learnt from: tabrisnet
Repo: armbian/build PR: 9275
File: patch/kernel/archive/filogic-6.18/frank-w/0058-dt-bindings-net-pcs-mediatek-sgmiisys-add-phys-and-r.patch:37-45
Timestamp: 2026-01-19T22:47:13.242Z
Learning: Patches located under `patch/kernel/archive/filogic-6.18/frank-w/` in the armbian/build repository are sourced from the out-of-tree repository https://github.com/frank-w/BPI-Router-Linux and should not be reviewed as they are maintained externally. Only focus on patches in other directories or changes to Armbian-specific configuration/build files.

@EvilOlaf
Copy link
Member

Yes, would be a nice to have. Otherwise I'd squash everything.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@patch/kernel/archive/sunxi-6.18/patches.armbian/drv-phy-allwinner-add-pcie-usb3-driver.patch`:
- Around line 309-339: The clk_set_rate() calls for combphy->phyclk_ref and
combphy->phyclk_cfg must be guarded against ERR_PTR; before calling
clk_set_rate(combphy->phyclk_ref, 100000000) and
clk_set_rate(combphy->phyclk_cfg, 200000000) check !IS_ERR(combphy->phyclk_ref)
and !IS_ERR(combphy->phyclk_cfg) respectively (matching the existing
clk_prepare_enable guards) so you don't call clk_set_rate on an ERR_PTR and risk
a crash; keep the existing error logging and existing goto error paths
unchanged.
♻️ Duplicate comments (16)
patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch (5)

589-593: CFG0/CFG1 type selection appears inverted.

For DesignWare PCIe controllers, Type 0 configuration (CFG0) is used to access devices on the immediate downstream bus, and Type 1 (CFG1) for devices on further buses. The current logic uses CFG0 when PCI_BUS(d) != 0 and CFG1 otherwise, which seems backwards for typical RC enumeration.

This was flagged in a previous review. If this is intentionally different for sun55i hardware, please confirm and document the rationale.


682-687: Missing indentation for size_len = 2;.

The assignment on line 685 is missing its leading tab.

🔧 Suggested fix
 	if (size == PCI_SIZE_8)
 		size_len = 1;
 	else if (size == PCI_SIZE_16)
-	size_len = 2;
+		size_len = 2;
 	else if (size == PCI_SIZE_32)
 		size_len = 4;

847-851: LNKCTL2 access should use discovered capability offset.

The code finds the PCI Express capability offset at line 840 but then accesses LINK_CONTROL2_LINK_STATUS2 (a hardcoded offset of 0xa0) directly instead of using offset + PCI_EXP_LNKCTL2. If the capability isn't at the expected location, this will program the wrong register.

🔧 Suggested fix
-    val = sun55i_pcie_readl_dbi(pci, LINK_CONTROL2_LINK_STATUS2);
+    val = sun55i_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2);
     val &= ~PCI_EXP_LNKCTL2_TLS;
     val |= gen;
-    sun55i_pcie_writel_dbi(pci, LINK_CONTROL2_LINK_STATUS2, val);
+    sun55i_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCTL2, val);

1088-1096: Duplicate macro definitions will cause preprocessor warnings.

PCIE_ATU_TYPE_MEM, PCIE_ATU_TYPE_IO, PCIE_ATU_TYPE_CFG0, PCIE_ATU_TYPE_CFG1 are defined at lines 1072-1075 and again at lines 1088-1091. PCIE_ATU_FUNC_NUM is defined at both line 1092 and 1096.

🔧 Suggested fix

Remove the duplicate definitions at lines 1088-1091 and the duplicate at line 1096:

 `#define` PCIE_ATU_CR1_INBOUND(reg)		(0x300100 + ((reg) * 0x200))
-#define PCIE_ATU_TYPE_MEM			(0x0 << 0)
-#define PCIE_ATU_TYPE_IO			(0x2 << 0)
-#define PCIE_ATU_TYPE_CFG0			(0x4 << 0)
-#define PCIE_ATU_TYPE_CFG1			(0x5 << 0)
 `#define` PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)
 `#define` PCIE_ATU_CR2_INBOUND(reg)		(0x300104 + ((reg) * 0x200))
 `#define` PCIE_ATU_MATCH_MODE			BIT(30)
 `#define` PCIE_ATU_FUNC_NUM_MATCH_EN		BIT(19)
-#define PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)

373-377: PHY power-on failure skips power-off cleanup.

If generic_phy_power_on() fails, the code jumps to err_assert_reset, skipping generic_phy_power_off(). Since generic_phy_init() succeeded at this point, the PHY may be left in a partially initialized state.

🔧 Suggested fix
 	ret = generic_phy_power_on(&pci->phy);
 	if (ret) {
 		printf("PCIe: Failed to power on phy: %d\n", ret);
-		goto err_assert_reset;
+		goto err_exit_phy;
 	}

And add a new label before err_power_off_phy:

+err_exit_phy:
+	generic_phy_exit(&pci->phy);
 err_power_off_phy:
 	generic_phy_power_off(&pci->phy);
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-iommu-sunxi-add-iommu-driver.patch (7)

1382-1386: Translate/remove non‑English inline comments.
Kernel style expects English; there are still German notes (e.g., “Wie in Fehler 1 korrigiert”) that should be removed or translated.


1414-1438: Guard args_count before using args[1].
The binding shows #iommu-cells = <1>, so args_count can be 1; reading args[1] is an out‑of‑bounds access.

🐛 Proposed fix
 static int sun55i_iommu_of_xlate(struct device *dev,
 				 const struct of_phandle_args *args)
 {
 	struct sunxi_iommu_owner *owner = dev_iommu_priv_get(dev);
 	struct platform_device *sysmmu = of_find_device_by_node(args->np);
 	struct sunxi_iommu_dev *data;
 
 	if (!sysmmu)
 		return -ENODEV;
 
 	data = platform_get_drvdata(sysmmu);
 	if (data == NULL) {
 		put_device(&sysmmu->dev);
 		return -ENODEV;
 	}
+	if (args->args_count < 1) {
+		put_device(&sysmmu->dev);
+		return -EINVAL;
+	}
 
 	if (!owner) {
 		owner = kzalloc(sizeof(*owner), GFP_KERNEL);
 		if (!owner) {
 			put_device(&sysmmu->dev);
 			return -ENOMEM;
 		}
 		owner->tlbid = args->args[0];
-		owner->flag = args->args[1];
+		owner->flag = (args->args_count > 1) ? args->args[1] : 0;
 		owner->data = data;
 		owner->dev = dev;
 		dev_iommu_priv_set(dev, owner);
 	}

1509-1518: Validate master_id before array indexing in IRQ handler.
master_id is derived from a bitmap and used to index fixed arrays without bounds checks, risking OOB access.

🐛 Proposed fix
 	if (!(int_masterid_bitmap & (1U << 31))) {
 		int_masterid_bitmap &= 0xffff;
+		if (!int_masterid_bitmap)
+			goto clear_irq;
 		master_id = __ffs(int_masterid_bitmap);
+		if (master_id >= ARRAY_SIZE(sunxi_iommu_fault_notify_cbs) ||
+		    master_id >= ARRAY_SIZE(plat_data->master)) {
+			pr_err("sunxi iommu: invalid master_id %u\n", master_id);
+			goto clear_irq;
+		}
 		pr_err("Bug is in %s module, invalid address: 0x%x, data:0x%x, id:0x%x\n",
 			plat_data->master[master_id], addr_reg, data_reg,
 				int_masterid_bitmap);
 
 		/* master debug callback */
 		if (sunxi_iommu_fault_notify_cbs[master_id])
 			sunxi_iommu_fault_notify_cbs[master_id]();
 	}
 
+clear_irq:
 	/* invalid TLB */

2051-2059: Free iopte_cache on devm_kzalloc failure.
If devm_kzalloc fails, iopte_cache leaks.

🐛 Proposed fix
 	sunxi_iommu = devm_kzalloc(dev, sizeof(*sunxi_iommu), GFP_KERNEL);
-	if (!sunxi_iommu)
-		return	-ENOMEM;
+	if (!sunxi_iommu) {
+		sunxi_pgtable_free_pte_cache(iopte_cache);
+		return -ENOMEM;
+	}

2094-2099: Preserve the clock error code before NULLing.
PTR_ERR is called after setting clk to NULL, which zeroes the error code.

🐛 Proposed fix
 	sunxi_iommu->clk = of_clk_get_by_name(dev->of_node, "iommu");
 	if (IS_ERR(sunxi_iommu->clk)) {
-		sunxi_iommu->clk = NULL;
-		dev_dbg(dev, "Unable to find clock\n");
-		ret = PTR_ERR(sunxi_iommu->clk); /* Korrekter Fehlercode */
+		ret = PTR_ERR(sunxi_iommu->clk);
+		sunxi_iommu->clk = NULL;
+		dev_dbg(dev, "Unable to find clock\n");
 		goto err_clk;
 	}

2118-2124: Remove custom sysfs files if iommu_device_sysfs_add fails.
The custom sysfs attributes are created before the core sysfs registration; on failure they’re left behind.

🐛 Proposed fix
 	ret = iommu_device_sysfs_add(&sunxi_iommu->iommu, dev, NULL,
 				     dev_name(dev));
 	if (ret) {
 		dev_err(dev, "Failed to register iommu in sysfs\n");
+		sun55i_iommu_sysfs_remove(pdev);
 		clk_disable_unprepare(sunxi_iommu->clk);
 		goto err_clk;
 	}

2208-2211: Use per‑device context in suspend.
suspend() should use dev_get_drvdata(dev) instead of the global to avoid NULL deref or cross‑device issues.

🐛 Proposed fix
 static int sun55i_iommu_suspend(struct device *dev)
 {
-	clk_disable_unprepare(global_iommu_dev->clk);
+	struct sunxi_iommu_dev *iommu = dev_get_drvdata(dev);
+
+	if (!iommu || !iommu->clk)
+		return 0;
+	clk_disable_unprepare(iommu->clk);
 
 	return 0;
 }
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-phy-allwinner-add-pcie-usb3-driver.patch (4)

203-228: Fix bit update logic in combo_phy_mode_set.

tmp starts at 0, so clearing bits is ineffective and the disable path never clears PHY_RSTN/mode bits. This can leave stale state when switching modes.

🐛 Proposed fix
-	u32 val, tmp = 0;
-
-	val = readl(COMBO_REG_PHYCTRL(combphy->phy_ctl));
-
-	if (combphy->user == PHY_USE_BY_PCIE)
-		tmp &= ~PHY_USE_SEL;
-	else if (combphy->user == PHY_USE_BY_USB3)
-		tmp |= PHY_USE_SEL;
-	else if (combphy->user == PHY_USE_BY_PCIE_USB3_U2)
-		tmp &= ~PHY_USE_SEL;
-
-	if (combphy->ref == INTER_SIG_REF_CLK)
-		tmp &= ~PHY_CLK_SEL;
-	else if (combphy->ref == EXTER_DIF_REF_CLK)
-		tmp |= PHY_CLK_SEL;
-
-	if (enable) {
-		tmp |= PHY_RSTN;
-		val |= tmp;
-	} else {
-		tmp &= ~PHY_RSTN;
-		val &= ~tmp;
-	}
-	writel(val, COMBO_REG_PHYCTRL(combphy->phy_ctl));
+	u32 val;
+
+	val = readl(COMBO_REG_PHYCTRL(combphy->phy_ctl));
+
+	val &= ~PHY_USE_SEL;
+	if (combphy->user == PHY_USE_BY_USB3)
+		val |= PHY_USE_SEL;
+
+	val &= ~PHY_CLK_SEL;
+	if (combphy->ref == EXTER_DIF_REF_CLK)
+		val |= PHY_CLK_SEL;
+
+	if (enable)
+		val |= PHY_RSTN;
+	else
+		val &= ~PHY_RSTN;
+
+	writel(val, COMBO_REG_PHYCTRL(combphy->phy_ctl));

953-979: Avoid clk_set_parent() with ERR_PTR clocks.

phyclk_ref/refclk_par and phyclk_cfg/cfgclk_par are only dev_dbg’d on failure, yet always passed to clk_set_parent(). That can crash if a clock is missing.

🐛 Proposed fix
 	combphy->refclk_par = devm_clk_get(&pdev->dev, "refclk_par");
 	if (IS_ERR(combphy->refclk_par))
-		dev_dbg(dev, "failed to get refclk_par\n");
+		return PTR_ERR(combphy->refclk_par);
+	if (IS_ERR(combphy->phyclk_ref))
+		return PTR_ERR(combphy->phyclk_ref);
 
 	ret = clk_set_parent(combphy->phyclk_ref, combphy->refclk_par);
 	if (ret) {
 		dev_err(dev, "failed to set refclk parent\n");
 		return -EINVAL;
 	}
@@
 	combphy->phyclk_cfg = devm_clk_get(&pdev->dev, "phyclk_cfg");
 	if (IS_ERR(combphy->phyclk_cfg))
-		dev_dbg(dev, "failed to get phyclk_cfg\n");
+		return PTR_ERR(combphy->phyclk_cfg);
 
 	combphy->cfgclk_par = devm_clk_get(&pdev->dev, "cfgclk_par");
 	if (IS_ERR(combphy->cfgclk_par))
-		dev_dbg(dev, "failed to get cfgclk_par\n");
+		return PTR_ERR(combphy->cfgclk_par);
 
 	ret = clk_set_parent(combphy->phyclk_cfg, combphy->cfgclk_par);

863-872: Propagate USB3 power-on failures.

The return from sunxi_combphy_usb3_power_on() is ignored, so regulator failures are masked.

🐛 Proposed fix
 static int sunxi_combphy_power_on(struct phy *phy)
 {
 	struct sunxi_combphy *combphy = phy_get_drvdata(phy);
+	int ret;
 
 	switch (combphy->mode) {
 	case PHY_TYPE_PCIE:
 		break;
 	case PHY_TYPE_USB3:
-		sunxi_combphy_usb3_power_on(combphy);
+		ret = sunxi_combphy_usb3_power_on(combphy);
+		if (ret)
+			return ret;
 		break;
 	default:
 		dev_err(combphy->dev, "incompatible PHY type\n");
 		return -EINVAL;

944-951: Unconditional dereference of error pointers from failed reset control retrieval.

If devm_reset_control_get() fails at lines 944–950, an ERR_PTR is stored but not checked. This error pointer is then passed unconditionally to reset_control_deassert(combphy->reset) at line 298 and reset_control_deassert(combphy->noppu_reset) at line 303, causing undefined behavior. The error path at lines 374–377 also calls reset_control_assert() without IS_ERR checks, compounding the issue.

Return the error instead of logging to prevent initialization from proceeding with invalid reset control pointers.

Proposed fix
 	combphy->reset = devm_reset_control_get(dev, "phy_rst");
 	if (IS_ERR(combphy->reset))
-		dev_dbg(dev, "failed to get reset control\n");
+		return PTR_ERR(combphy->reset);
 
 	if (combphy->drvdata->need_noppu_rst) {
 		combphy->noppu_reset = devm_reset_control_get(dev, "noppu_rst");
 		if (IS_ERR(combphy->noppu_reset))
-			dev_dbg(dev, "failed to get noppu_reset control\n");
+			return PTR_ERR(combphy->noppu_reset);
 	}
🧹 Nitpick comments (5)
patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch (4)

96-118: Inconsistent indentation style.

This function uses 4-space indentation while the rest of the file uses tabs. U-Boot coding style requires tabs for indentation.

🔧 Suggested fix
 int sun55i_pcie_cfg_read(void __iomem *addr, int size, ulong *val)
 {
-    
-    if ((uintptr_t)addr & (size - 1)) {
-        *val = 0;
-        printf("CFG_READ: Bad alignment\n");
-        return PCIBIOS_BAD_REGISTER_NUMBER;
-    }
-
-    if (size == 4) {
-        *val = readl(addr);
-    } else if (size == 2) {
-        *val = readw(addr);
-    } else if (size == 1) {
-        *val = readb(addr);
-    } else {
-        *val = 0;
-        printf("CFG_READ: Bad size\n");
-        return PCIBIOS_BAD_REGISTER_NUMBER;
-    }
-
-    return PCIBIOS_SUCCESSFUL;
+	if ((uintptr_t)addr & (size - 1)) {
+		*val = 0;
+		printf("CFG_READ: Bad alignment\n");
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	}
+
+	if (size == 4)
+		*val = readl(addr);
+	else if (size == 2)
+		*val = readw(addr);
+	else if (size == 1)
+		*val = readb(addr);
+	else {
+		*val = 0;
+		printf("CFG_READ: Bad size\n");
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	}
+
+	return PCIBIOS_SUCCESSFUL;
 }

773-778: Unconditional debug output in link status check.

These printf statements will output on every link status check, which can be noisy during normal operation. Consider gating them behind a debug flag or removing them.

🔧 Suggested fix
-    printf("  Link Status: 0x%08x\n", val);
-    printf("  RDLH_LINK_UP: %d\n", !!(val & RDLH_LINK_UP));
-    printf("  SMLH_LINK_UP: %d\n", !!(val & SMLH_LINK_UP));
-    printf("  LINK_SPEED: %d\n", (val >> 16) & 0xF);
-    printf("  LINK_WIDTH: %d\n", (val >> 20) & 0x3F);
+    debug("  Link Status: 0x%08x\n", val);
+    debug("  RDLH_LINK_UP: %d\n", !!(val & RDLH_LINK_UP));
+    debug("  SMLH_LINK_UP: %d\n", !!(val & SMLH_LINK_UP));
+    debug("  LINK_SPEED: %d\n", (val >> 16) & 0xF);
+    debug("  LINK_WIDTH: %d\n", (val >> 20) & 0x3F);

1021-1031: Duplicate header includes.

<asm/io.h> and <asm/gpio.h> are included twice (lines 1021-1022 and 1029-1030).

🔧 Suggested fix
 `#include` <asm/io.h>
 `#include` <asm/gpio.h>
 `#include` <clk.h>
 `#include` <reset.h>
 `#include` <generic-phy.h>
 `#include` <pci.h>
 `#include` <power-domain.h>
 `#include` <power/regulator.h>
-#include <asm/io.h> 
-#include <asm/gpio.h>
 `#include` <errno.h>  

1179-1181: More duplicate macro definitions.

PCIE_LINK_WIDTH_SPEED_CONTROL and PORT_LOGIC_SPEED_CHANGE are already defined at lines 1046-1047.

🔧 Suggested fix
-#define PCIE_LINK_WIDTH_SPEED_CONTROL	0x80C
-#define PORT_LOGIC_SPEED_CHANGE		(0x1 << 17)
 `#define` LINK_CONTROL2_LINK_STATUS2	0xa0
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-phy-allwinner-add-pcie-usb3-driver.patch (1)

1101-1104: Handle pm_runtime_get_sync() errors.

Ignoring the return value can leave the device in an inconsistent PM state if runtime PM activation fails.

♻️ Suggested fix
-	pm_runtime_get_sync(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		pm_runtime_put_noidle(dev);
+		return ret;
+	}

@rvdr rvdr force-pushed the spi-nvme-patches branch from 8a4ed2e to bac187a Compare January 24, 2026 16:49
schwar3kat and others added 12 commits January 24, 2026 17:50
enable_extension "wayland-sessions-mask" instead
…y CE config options

- also drop BOOT_SUPPORT_SPI & BOOT_SPI_RKSPI_LOADER as those are for vendor u-boot, not used here
Add loong64 to the list of architectures prepared by prepare_host_binfmt_qemu_cross().
This allows automatic registration and use of qemu-user emulation for LoongArch64
guests, enabling rootfs bootstrap and CI workflows targeting loong64.

This aligns Armbian with Debian’s upcoming native loong64 support (Forky) and allows
testing already via debian-ports and qemu-system-loongarch64.

Signed-off-by: Igor Pecovnik <igor@armbian.com>
- mainline AT-F only for non-vendor BRANCH
- vendor branch uses vendor u-boot with rkbin blobs
- sorry for the confusion; I overlooked the conditional here
- Fixes: f45765e
Correcting boot issues due to the iommu driver.

Applying EvilOlaf's changes.

Applying EvilOlaf's changes. Changing subjects and file names

Resolving CodeRabbit detected issues.

Reverting changes due to boot issues.

Reverting changes due to boot issues.
@rvdr rvdr force-pushed the spi-nvme-patches branch from bac187a to a54bd97 Compare January 24, 2026 16:57
@rvdr rvdr requested review from a team, hzyitc, paolosabatino and rpardini as code owners January 24, 2026 16:57
@github-actions github-actions bot added Framework Framework components GitHub GitHub-related changes like labels, templates, ... labels Jan 24, 2026
@rvdr rvdr marked this pull request as draft January 24, 2026 17:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@patch/kernel/archive/sunxi-6.18/patches.armbian/drv-iommu-sunxi-add-iommu-driver.patch`:
- Around line 1525-1533: The two unbounded busy-wait loops after
sunxi_iommu_write of IOMMU_TLB_IVLD_ENABLE_REG and IOMMU_PC_IVLD_ENABLE_REG can
hang indefinitely in IRQ context; replace each plain while
(sunxi_iommu_read(...) & 0x1) loop with a bounded wait using the existing
sunxi_wait_when() helper (or an equivalent timeout loop) and handle timeout
failure (log/error return) instead of spinning forever while holding
IRQ/spinlock; update the code paths around sunxi_iommu_write/sunxi_iommu_read
and the IOMMU_TLB_IVLD_ENABLE_REG / IOMMU_PC_IVLD_ENABLE_REG checks to use that
timeout and early-fail behavior so IRQ context cannot be blocked indefinitely.

In
`@patch/u-boot/sunxi-dev-u-boot-a523/allwinner-a523-support-spi-controllers.patch`:
- Around line 40-59: The readl_poll_timeout call in sun4i_spi_xfer that waits
for FIFO reset uses a timeout value in microseconds but currently passes
SUN4I_SPI_TIMEOUT_MS (1000 ms) directly; update the call in the block guarded by
priv->variant->has_bsr to pass the timeout in microseconds (e.g.,
SUN4I_SPI_TIMEOUT_MS * 1000 or otherwise multiply the 1000-ms constant by 1000)
so the fourth argument to readl_poll_timeout(SPI_REG(priv, SPI_FCR), reg, !(reg
& (SPI_BIT(priv, SPI_FCR_RF_RST) | SPI_BIT(priv, SPI_FCR_TF_RST))), ...) is in
microseconds and not milliseconds.
♻️ Duplicate comments (17)
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-iommu-sunxi-add-iommu-driver.patch (5)

2094-2100: Clock error code is still lost due to ordering.

PTR_ERR(sunxi_iommu->clk) is called after setting clk = NULL, so ret becomes 0 instead of the actual error code. This allows probe to incorrectly fail with ret = 0.

🐛 Proposed fix
 	sunxi_iommu->clk = of_clk_get_by_name(dev->of_node, "iommu");
 	if (IS_ERR(sunxi_iommu->clk)) {
+		ret = PTR_ERR(sunxi_iommu->clk);
 		sunxi_iommu->clk = NULL;
 		dev_dbg(dev, "Unable to find clock\n");
-		ret = PTR_ERR(sunxi_iommu->clk); /* Korrekter Fehlercode */
 		goto err_clk;
 	}

2051-2059: iopte_cache leaked if devm_kzalloc fails.

sunxi_pgtable_alloc_pte_cache() allocates iopte_cache before the devm_kzalloc. If the allocation fails, the cache is never freed.

🐛 Proposed fix
 	sunxi_iommu = devm_kzalloc(dev, sizeof(*sunxi_iommu), GFP_KERNEL);
-	if (!sunxi_iommu)
+	if (!sunxi_iommu) {
+		sunxi_pgtable_free_pte_cache(iopte_cache);
 		return -ENOMEM;
+	}

1430-1441: Validate args_count before accessing args[1].

The code reads args->args[1] without checking if args->args_count > 1. If the device tree binding specifies only one cell (#iommu-cells = <1>), this is an out-of-bounds read.

🐛 Proposed fix
 	if (!owner) {
 		owner = kzalloc(sizeof(*owner), GFP_KERNEL);
 		if (!owner) {
 			put_device(&sysmmu->dev);
 			return -ENOMEM;
 		}
 		owner->tlbid = args->args[0];
-		owner->flag = args->args[1];
+		owner->flag = (args->args_count > 1) ? args->args[1] : 0;
 		owner->data = data;
 		owner->dev = dev;
 		dev_iommu_priv_set(dev, owner);
 	}

2208-2213: Suspend uses global variable instead of device context.

sun55i_iommu_suspend() accesses global_iommu_dev without NULL check and ignores the dev parameter, while sun55i_iommu_resume() correctly uses dev_get_drvdata(dev).

🔧 Proposed fix
 static int sun55i_iommu_suspend(struct device *dev)
 {
-	clk_disable_unprepare(global_iommu_dev->clk);
+	struct sunxi_iommu_dev *iommu = dev_get_drvdata(dev);
+
+	if (iommu && iommu->clk)
+		clk_disable_unprepare(iommu->clk);
 
 	return 0;
 }

2081-2175: German inline comments should be translated to English or removed.

Multiple lines contain German comments (e.g., "Korrekter Fehlercode", "Fehlerbehandlung", "devm_* ressourcenverwaltet ist"). Per kernel coding style and previous review discussion, these should be in English.

patch/u-boot/sunxi-dev-u-boot-a523/clk-sunxi-fix-clock-handling-for-sun55i-a523.patch (1)

22-23: Add the missing CLK_PCIE_AUX binding constant.

CLK_PCIE_AUX is used in clk_a523.c but isn’t defined in the dt‑bindings header, which will fail compilation. Please add it alongside CLK_USB3_REF.

🐛 Proposed fix
 `#define` CLK_FANOUT0		176
 `#define` CLK_FANOUT1		177
 `#define` CLK_FANOUT2		178
 `#define` CLK_USB3_REF		179
+#define CLK_PCIE_AUX		180

Also applies to: 51-52

patch/u-boot/sunxi-dev-u-boot-a523/arm64-dts-sun55i-t527-orangepi-4a-enable-spi0-pcie-combophy.patch (1)

62-68: Define reg_pcie_vcc3v3 for slot-3v3-supply.

slot-3v3-supply = <&reg_pcie_vcc3v3> references a phandle that isn’t defined in the U-Boot DTS. This will break DT compilation or leave the supply unresolved. Please add a fixed regulator node (or reference an existing 3.3 V rail) in the U-Boot DTS tree.

patch/kernel/archive/sunxi-6.18/patches.armbian/arm64-dts-sun55i-dtsi-add-iommu-usbc-pcie-combophy-nodes.patch (1)

45-115: Ensure usbc1, combophy, and pcie are children of soc.

If these nodes end up at the root instead of under soc, they won’t inherit the simple-bus ranges and address decoding can break. Please confirm the final DTS tree places them under soc (same level as ppu).

patch/kernel/archive/sunxi-6.18/patches.armbian/drv-phy-allwinner-add-pcie-usb3-driver.patch (4)

203-228: Fix mode/reset bit handling in combo_phy_mode_set.

tmp starts at 0, so bit updates don’t apply to the live register; the disable path can leave stale mode/reset state. Use the current register value as the base.

🐛 Suggested fix
-	u32 val, tmp = 0;
-	val = readl(COMBO_REG_PHYCTRL(combphy->phy_ctl));
-
-	if (combphy->user == PHY_USE_BY_PCIE)
-		tmp &= ~PHY_USE_SEL;
-	else if (combphy->user == PHY_USE_BY_USB3)
-		tmp |= PHY_USE_SEL;
-	else if (combphy->user == PHY_USE_BY_PCIE_USB3_U2)
-		tmp &= ~PHY_USE_SEL;
-
-	if (combphy->ref == INTER_SIG_REF_CLK)
-		tmp &= ~PHY_CLK_SEL;
-	else if (combphy->ref == EXTER_DIF_REF_CLK)
-		tmp |= PHY_CLK_SEL;
-
-	if (enable) {
-		tmp |= PHY_RSTN;
-		val |= tmp;
-	} else {
-		tmp &= ~PHY_RSTN;
-		val &= ~tmp;
-	}
-	writel(val, COMBO_REG_PHYCTRL(combphy->phy_ctl));
+	u32 val;
+	val = readl(COMBO_REG_PHYCTRL(combphy->phy_ctl));
+
+	val &= ~PHY_USE_SEL;
+	if (combphy->user == PHY_USE_BY_USB3)
+		val |= PHY_USE_SEL;
+
+	val &= ~PHY_CLK_SEL;
+	if (combphy->ref == EXTER_DIF_REF_CLK)
+		val |= PHY_CLK_SEL;
+
+	if (enable)
+		val |= PHY_RSTN;
+	else
+		val &= ~PHY_RSTN;
+
+	writel(val, COMBO_REG_PHYCTRL(combphy->phy_ctl));

309-339: Guard clk_set_rate() against ERR_PTR clocks.

phyclk_ref / phyclk_cfg are logged but can still be ERR_PTR. Calling clk_set_rate() on an error pointer can crash. Either skip clk_set_rate() when ERR_PTR or treat the clock as required and return PTR_ERR().

🐛 Minimal guard (skip if ERR_PTR)
-	if (!already_enabled && combphy->user != PHY_USE_BY_USB3) {
+	if (!already_enabled && combphy->user != PHY_USE_BY_USB3 &&
+	    !IS_ERR(combphy->phyclk_ref)) {
 		ret = clk_set_rate(combphy->phyclk_ref, 100000000);
 		if (ret)
 			dev_err(dev, "failed to set phyclk_ref freq 100M!\n");
 	}
@@
-	if (combphy->drvdata->has_cfg_clk) {
+	if (combphy->drvdata->has_cfg_clk) {
 		if (!already_enabled) {
-			ret = clk_set_rate(combphy->phyclk_cfg, 200000000);
+			if (!IS_ERR(combphy->phyclk_cfg))
+				ret = clk_set_rate(combphy->phyclk_cfg, 200000000);
 			if (ret)
 				dev_err(dev, "failed to set phyclk_cfg freq 200M!\n");
 		}

863-878: Propagate USB3 power-on errors.

sunxi_combphy_usb3_power_on() can fail (regulator ops), but its return value is ignored. This masks failures from the PHY framework.

🐛 Suggested fix
 case PHY_TYPE_USB3:
-	sunxi_combphy_usb3_power_on(combphy);
+	ret = sunxi_combphy_usb3_power_on(combphy);
+	if (ret)
+		return ret;
 	break;

953-980: Guard clk_set_parent() against ERR_PTR inputs.

refclk_par/cfgclk_par failures are only logged, but still passed to clk_set_parent(). If either is ERR_PTR, this will crash.

🐛 Suggested guard
 combphy->refclk_par = devm_clk_get(&pdev->dev, "refclk_par");
 if (IS_ERR(combphy->refclk_par))
-	dev_dbg(dev, "failed to get refclk_par\n");
+	return PTR_ERR(combphy->refclk_par);

 ret = clk_set_parent(combphy->phyclk_ref, combphy->refclk_par);
patch/u-boot/sunxi-dev-u-boot-a523/arm64-dts-sun55i-a527-cubie-a5e-enable-spi0-pcie-combophy.patch (1)

93-99: Use pins instead of allwinner,pins for pcie_pwren_pins.

The other pinctrl nodes in this patch use the generic pins property. If U-Boot’s pinctrl expects pins, allwinner,pins may be ignored, leaving the GPIO unconfigured. Please verify and switch to pins if needed.

♻️ Suggested tweak
-	allwinner,pins = "PL11";
+	pins = "PL11";
patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch (4)

368-377: PHY cleanup incomplete on power_on failure.

If generic_phy_power_on() fails at line 373-377, the error path jumps to err_assert_reset, but generic_phy_init() (line 368) has already succeeded. The PHY should be de-initialized via generic_phy_exit() before proceeding with reset assertion.

🛠️ Suggested fix
 	ret = generic_phy_power_on(&pci->phy);
 	if (ret) {
 		printf("PCIe: Failed to power on phy: %d\n", ret);
-		goto err_assert_reset;
+		goto err_exit_phy;
 	}
 
 	printf("PCIe: Toggling external device reset (PERST#)...\n");
@@ -399,6 +399,8 @@ static int sun55i_pcie_plat_init_port(struct udevice *dev)
 
 err_power_off_phy:
 	generic_phy_power_off(&pci->phy);
+err_exit_phy:
+	generic_phy_exit(&pci->phy);
 err_assert_reset:
 	if (pci->drvdata && pci->drvdata->need_pcie_rst)
 		reset_assert(&pci->pcie_rst);

682-687: Missing indentation for size_len = 2.

Line 685 is missing the tab indentation for the size_len = 2; statement inside the else if block.

🔧 Suggested fix
 	if (size == PCI_SIZE_8)
 		size_len = 1;
 	else if (size == PCI_SIZE_16)
-	size_len = 2;
+		size_len = 2;
 	else if (size == PCI_SIZE_32)
 		size_len = 4;

847-850: LNKCTL2 access uses hardcoded offset instead of discovered capability base.

The code discovers the PCIe capability offset at line 840, but lines 847-850 still use the hardcoded LINK_CONTROL2_LINK_STATUS2 (0xa0) instead of offset + PCI_EXP_LNKCTL2. If the PCIe capability isn't at the standard 0x70 offset, this will access the wrong register.

🐛 Proposed fix
-    val = sun55i_pcie_readl_dbi(pci, LINK_CONTROL2_LINK_STATUS2);
+    val = sun55i_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2);
     val &= ~PCI_EXP_LNKCTL2_TLS;
     val |= gen;
-    sun55i_pcie_writel_dbi(pci, LINK_CONTROL2_LINK_STATUS2, val);
+    sun55i_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCTL2, val);

1088-1096: Duplicate macro definitions will cause preprocessor warnings.

The following macros are defined twice:

  • PCIE_ATU_TYPE_MEM, PCIE_ATU_TYPE_IO, PCIE_ATU_TYPE_CFG0, PCIE_ATU_TYPE_CFG1 (lines 1072-1075 and 1088-1091)
  • PCIE_ATU_FUNC_NUM (lines 1092 and 1096)
🔧 Suggested fix

Remove the duplicate definitions at lines 1088-1091 and 1096:

 `#define` PCIE_ATU_CR1_INBOUND(reg)		(0x300100 + ((reg) * 0x200))
-#define PCIE_ATU_TYPE_MEM			(0x0 << 0)
-#define PCIE_ATU_TYPE_IO			(0x2 << 0)
-#define PCIE_ATU_TYPE_CFG0			(0x4 << 0)
-#define PCIE_ATU_TYPE_CFG1			(0x5 << 0)
 `#define` PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)
 `#define` PCIE_ATU_CR2_INBOUND(reg)		(0x300104 + ((reg) * 0x200))
 `#define` PCIE_ATU_MATCH_MODE			BIT(30)
 `#define` PCIE_ATU_FUNC_NUM_MATCH_EN		BIT(19)
-#define PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)
🧹 Nitpick comments (6)
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-iommu-sunxi-add-iommu-driver.patch (2)

26-34: Kconfig uses spaces instead of tabs for indentation.

Kernel Kconfig files require tab indentation per kernel coding style. Lines 27-34 appear to use spaces.

♻️ Suggested fix
 config SUN55I_IOMMU
-       bool "Allwinner A523 IOMMU Support"
-       depends on HAS_DMA
-       depends on ARCH_SUNXI || COMPILE_TEST
-       select ARM_DMA_USE_IOMMU 
-       select IOMMU_API
-       select IOMMU_DMA
-       help
-         Support for the IOMMU introduced in the Allwinner A523 SoCs.
+	bool "Allwinner A523 IOMMU Support"
+	depends on HAS_DMA
+	depends on ARCH_SUNXI || COMPILE_TEST
+	select ARM_DMA_USE_IOMMU
+	select IOMMU_API
+	select IOMMU_DMA
+	help
+	  Support for the IOMMU introduced in the Allwinner A523 SoCs.

46-48: Trailing whitespace on line 46.

Remove trailing space after sunxi-iommu.o.

♻️ Suggested fix
-obj-$(CONFIG_SUN55I_IOMMU) += sunxi-iommu.o 
+obj-$(CONFIG_SUN55I_IOMMU) += sunxi-iommu.o
patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch (4)

26-32: Minor: Trailing whitespace in Kconfig help text.

Line 32 has trailing whitespace after the help text. While functional, this may trigger checkpatch warnings.

+config PCIE_SUN55I_RC
+	bool "Allwinner SUN55I DesignWare PCIe controller"
+	default n
+	depends on ARCH_SUNXI
+	help
-	   Enables support for the DW PCIe controller in the Allwinner Sun55i SoC.
-	   
+	   Enables support for the DW PCIe controller in the Allwinner Sun55i SoC.

96-118: Inconsistent indentation (spaces vs tabs).

This function uses space indentation while the rest of the file uses tabs. This also affects other sections (lines 333-338, 449-458).


1021-1031: Duplicate includes.

<asm/io.h> and <asm/gpio.h> are included twice (lines 1021-1022 and 1029-1030). While harmless due to include guards, this indicates copy-paste that should be cleaned up.


1046-1047: Duplicate macro: PCIE_LINK_WIDTH_SPEED_CONTROL.

This macro is defined at both line 1046 and line 1179 with the same value (0x80C). Remove one of the definitions.

Also applies to: 1179-1181

@rvdr
Copy link
Author

rvdr commented Jan 24, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@patch/u-boot/sunxi-dev-u-boot-a523/clk-sunxi-fix-clock-handling-for-sun55i-a523.patch`:
- Line 35: Add a missing dt-binding define for RST_BUS_PCIE_USB3: edit the
dt-bindings header where CLK_USB3_REF is defined and add a `#define`
RST_BUS_PCIE_USB3 with the same numeric ID used by the drivers mapping (i.e.,
the value corresponding to the new resets entry in drivers/clk/sunxi/clk_a523.c
which maps RESET(0xaac, BIT(24))). Place this new define immediately alongside
CLK_USB3_REF so device tree files can reference RST_BUS_PCIE_USB3 in their
resets properties.

In `@patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch`:
- Around line 642-693: In sun55i_pcie_read_config and sun55i_pcie_write_config
replace the hard-coded root-bus check "PCI_BUS(bdf) != 0" with a comparison
against the controller's actual root bus number (pcie->first_busno) so root
config accesses use host functions when PCI_BUS(bdf) == pcie->first_busno;
update both functions (sun55i_pcie_read_config and sun55i_pcie_write_config) to
use "PCI_BUS(bdf) != pcie->first_busno" (or the inverse) when deciding between
sun55i_pcie_rd_other_conf / sun55i_pcie_host_rd_own_conf and
sun55i_pcie_wr_other_conf / sun55i_pcie_host_wr_own_conf.
♻️ Duplicate comments (15)
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-iommu-sunxi-add-iommu-driver.patch (5)

2032-2032: German comments should be in English.

Multiple German comments remain in the probe function (lines 2032, 2046, 2058, 2075, 2089, 2113, 2121, 2127, 2135, 2156). Kernel/driver code should use English comments. Either translate or remove these developer notes:

  • "Es gab einen doppelten Check" → remove or translate
  • "Korrekte Fehlerprüfung" → remove
  • "KORREKTUR 1-4" → remove (code is now correct)
  • etc.

1417-1418: Out-of-bounds read: args->args[1] when #iommu-cells = <1>.

The device tree binding uses #iommu-cells = <2> (line 35 shows this), but if clients use only one cell, accessing args->args[1] without checking args->args_count causes an OOB read. Add validation:

 	if (!owner) {
 		owner = kzalloc(sizeof(*owner), GFP_KERNEL);
 		if (!owner)
 			return -ENOMEM;
 		owner->tlbid = args->args[0];
-		owner->flag = args->args[1];
+		owner->flag = (args->args_count > 1) ? args->args[1] : 0;

2071-2077: PTR_ERR called after pointer set to NULL returns 0.

The error handling captures the error code after setting the pointer to NULL, which makes PTR_ERR() return 0 instead of the actual error. Reorder the statements:

 	sunxi_iommu->clk = of_clk_get_by_name(dev->of_node, "iommu");
 	if (IS_ERR(sunxi_iommu->clk)) {
+		ret = PTR_ERR(sunxi_iommu->clk);
 		sunxi_iommu->clk = NULL;
 		dev_dbg(dev, "Unable to find clock\n");
-		ret = PTR_ERR(sunxi_iommu->clk);
 		goto err_clk;
 	}

2188-2193: Suspend uses global variable instead of device context.

sun55i_iommu_suspend() uses global_iommu_dev without NULL check and ignores the dev parameter, while sun55i_iommu_resume() correctly uses dev_get_drvdata(dev). For consistency and safety:

 static int sun55i_iommu_suspend(struct device *dev)
 {
-	clk_disable_unprepare(global_iommu_dev->clk);
+	struct sunxi_iommu_dev *iommu = dev_get_drvdata(dev);
+
+	if (iommu && iommu->clk)
+		clk_disable_unprepare(iommu->clk);
 
 	return 0;
 }

1505-1513: Unbounded busy-wait in IRQ handler can cause system hang.

These while loops wait for hardware bits to clear without any timeout. If hardware malfunctions, this will hang indefinitely while holding a spinlock in IRQ context. Consider using sunxi_wait_when() macro (already defined in this file) or documenting why unbounded wait is acceptable.

-	while (sunxi_iommu_read(iommu, IOMMU_TLB_IVLD_ENABLE_REG) & 0x1)
-		;
+	sunxi_wait_when(sunxi_iommu_read(iommu, IOMMU_TLB_IVLD_ENABLE_REG) & 0x1, 2);
 ...
-	while (sunxi_iommu_read(iommu, IOMMU_PC_IVLD_ENABLE_REG) & 0x1)
-		;
+	sunxi_wait_when(sunxi_iommu_read(iommu, IOMMU_PC_IVLD_ENABLE_REG) & 0x1, 2);
patch/u-boot/sunxi-dev-u-boot-a523/clk-sunxi-fix-clock-handling-for-sun55i-a523.patch (1)

22-23: Missing CLK_PCIE_AUX definition in dt-bindings header.

The patch adds CLK_PCIE_AUX to the gates array but only defines CLK_USB3_REF (value 179) in the dt-bindings header. CLK_PCIE_AUX needs a corresponding #define in sun55i-a523-ccu.h to avoid an undefined identifier error.

🐛 Proposed fix

Add the missing definition in the dt-bindings header section:

 `#define` CLK_FANOUT2		178
 `#define` CLK_USB3_REF		179
+#define CLK_PCIE_AUX		180
 
 `#endif` /* _DT_BINDINGS_CLK_SUN55I_A523_CCU_H_ */
patch/kernel/archive/sunxi-6.18/patches.armbian/arm64-dts-sun55i-dtsi-add-iommu-usbc-pcie-combophy-nodes.patch (2)

45-116: Nodes usbc1, combophy, and pcie appear to be outside the soc {} block.

These memory-mapped peripheral nodes (lines 45-115) lack the proper indentation to place them inside the soc {} block. Compare with the ppu node at line 117 which has proper tab indentation as a child of soc. All these peripherals should be children of the soc node.

🔧 Suggested fix

Add one level of tab indentation to all these nodes and their contents:

-usbc1: usbc1@11 {
-	device_type = "usbc1";
+		usbc1: usbc1@11 {
+			device_type = "usbc1";
...

27-36: Move iommu@2010000 inside the soc {} block and fix indentation of usbc1, combophy, and pcie nodes.

The IOMMU node should be a child of the SoC bus node (inside soc {}), following the pattern used in sun50i-h616 and sun20i-d1. Currently it is incorrectly placed at the root level.

Additionally, the usbc1, combophy, and pcie nodes (lines ~859–931) have zero indentation and appear to be inside soc {} but lack proper tab indentation. Verify their correct placement and apply consistent indentation.

patch/u-boot/sunxi-dev-u-boot-a523/allwinner-a523-support-spi-controllers.patch (1)

50-53: Timeout value in wrong units - should be microseconds.

readl_poll_timeout() expects the timeout parameter in microseconds, but 1000 is passed directly. If intent is 1000ms timeout, it should be 1000 * 1000 (or SUN4I_SPI_TIMEOUT_MS * 1000). Currently this only waits 1ms.

         ret = readl_poll_timeout(SPI_REG(priv, SPI_FCR), reg,
                      !(reg & (SPI_BIT(priv, SPI_FCR_RF_RST) |
                           SPI_BIT(priv, SPI_FCR_TF_RST))),
-                     1000);
+                     SUN4I_SPI_TIMEOUT_MS * 1000);
patch/u-boot/sunxi-dev-u-boot-a523/arm64-dts-sun55i-t527-orangepi-4a-enable-spi0-pcie-combophy.patch (1)

44-68: Verify reg_pcie_vcc3v3 exists in the U‑Boot DTS tree.
If the label is missing in U‑Boot (even if present in the kernel DTS), this will fail dtc.

#!/bin/bash
# Verify the reg_pcie_vcc3v3 label is defined somewhere in U-Boot DTS patches
rg -n "reg_pcie_vcc3v3:" patch/u-boot
rg -n "slot-3v3-supply\s*=\s*<&reg_pcie_vcc3v3>" patch/u-boot
patch/u-boot/sunxi-dev-u-boot-a523/arm64-dts-sun55i-a527-cubie-a5e-enable-spi0-pcie-combophy.patch (1)

93-99: Consider using pins instead of allwinner,pins for consistency with the other pinctrl nodes.
This patch uses pins elsewhere; aligning the property name avoids mixed styles and better matches modern bindings.

♻️ Suggested tweak
-		allwinner,pins = "PL11";
+		pins = "PL11";
patch/u-boot/sunxi-dev-u-boot-a523/pci-sunxi-enable-pcie-support.patch (4)

368-377: Power‑on failure should undo PHY enable.
At Line 373‑376, a generic_phy_power_on() failure jumps to err_assert_reset, skipping generic_phy_power_off(). Use the existing err_power_off_phy label to avoid leaving the PHY partially powered.

🐛 Proposed fix
 ret = generic_phy_power_on(&pci->phy);
 if (ret) {
 	printf("PCIe: Failed to power on phy: %d\n", ret);
-	goto err_assert_reset;
+	goto err_power_off_phy;
 }

578-599: CFG0/CFG1 selection should distinguish the first downstream bus.
At Line 589‑615, CFG0 is chosen for any non‑zero bus, which breaks config access behind a switch. Use CFG0 only for the first downstream bus and CFG1 for others.

🐛 Proposed fix
 static int sun55i_pcie_rd_other_conf(struct sun55i_pcie_port *pp, pci_dev_t d, int where, int size, ulong *val)
 {
 	int ret = PCIBIOS_SUCCESSFUL, type;
+	struct sun55i_pcie *pcie = to_sun55i_pcie_from_pp(pp);
 	u64 busdev;
 	u64 atu_cpu_addr = pp->cfg0_base;
@@
-	if (PCI_BUS(d) != 0)
+	if (PCI_BUS(d) == pcie->first_busno + 1)
 		type = PCIE_ATU_TYPE_CFG0;
 	else
 		type = PCIE_ATU_TYPE_CFG1;
@@
 static int sun55i_pcie_wr_other_conf(struct sun55i_pcie_port *pp, pci_dev_t d, int where, int size, ulong val)
 {
 	int ret = PCIBIOS_SUCCESSFUL, type;
+	struct sun55i_pcie *pcie = to_sun55i_pcie_from_pp(pp);
 	u64 busdev;
 	u64 atu_cpu_addr = pp->cfg0_base; 
@@
-	if (PCI_BUS(d) != 0)
+	if (PCI_BUS(d) == pcie->first_busno + 1)
 		type = PCIE_ATU_TYPE_CFG0;
 	else
 		type = PCIE_ATU_TYPE_CFG1;

Also applies to: 601-616


832-858: Use PCIe capability base for LNKCTL2 writes.
At Line 847‑851, offset is computed but the code reads/writes LINK_CONTROL2_LINK_STATUS2 directly. If the PCIe capability isn’t at the default offset, the wrong register is updated.

🐛 Proposed fix
-    val = sun55i_pcie_readl_dbi(pci, LINK_CONTROL2_LINK_STATUS2);
+    val = sun55i_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2);
     val &= ~PCI_EXP_LNKCTL2_TLS;
     val |= gen;
-    sun55i_pcie_writel_dbi(pci, LINK_CONTROL2_LINK_STATUS2, val);
+    sun55i_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCTL2, val);

1071-1096: Remove duplicate ATU macro definitions.
At Line 1088‑1096, PCIE_ATU_TYPE_* and PCIE_ATU_FUNC_NUM are re‑defined, which can trigger macro‑redefinition warnings.

🧹 Proposed fix
 `#define` PCIE_ATU_CR1_INBOUND(reg)		(0x300100 + ((reg) * 0x200))
-#define PCIE_ATU_TYPE_MEM			(0x0 << 0)
-#define PCIE_ATU_TYPE_IO			(0x2 << 0)
-#define PCIE_ATU_TYPE_CFG0			(0x4 << 0)
-#define PCIE_ATU_TYPE_CFG1			(0x5 << 0)
 `#define` PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)
 `#define` PCIE_ATU_CR2_INBOUND(reg)		(0x300104 + ((reg) * 0x200))
 `#define` PCIE_ATU_MATCH_MODE			BIT(30)
 `#define` PCIE_ATU_FUNC_NUM_MATCH_EN		BIT(19)
-#define PCIE_ATU_FUNC_NUM(pf)			((pf) << 20)
🧹 Nitpick comments (3)
patch/kernel/archive/rockchip-6.18/series.conf (1)

63-64: Add rationale for disabling these patches.

These patches touch VOP2 polling and HDMI 2.1 FRL; commenting them out may regress RK3588 display/HDMI behavior. Consider adding a short inline comment with the reason (e.g., build failure, runtime regression, upstream conflict) and a reference (issue/commit) to avoid accidental re‑enablement later.

💡 Suggested inline rationale comment
-#	patches.libreelec/rockchip-0062-FROMLIST-v1-drm-rockchip-vop2-Add-delay-between-poll.patch
-#	patches.libreelec/rockchip-0063-FROMLIST-v1-drm-rockchip-vop2-Only-wait-for-changed-.patch
+# Disabled: causes regression in RK3588 VOP2 polling (see issue/commit XYZ)
+#	patches.libreelec/rockchip-0062-FROMLIST-v1-drm-rockchip-vop2-Add-delay-between-poll.patch
+#	patches.libreelec/rockchip-0063-FROMLIST-v1-drm-rockchip-vop2-Only-wait-for-changed-.patch
...
-#	patches.libreelec/rockchip-0105-WIP-FRL-drm-bridge-dw-hdmi-qp-Add-HDMI-2.1-FRL-suppo.patch
+# Disabled: HDMI 2.1 FRL WIP series conflicts with 6.18 base (see issue/commit XYZ)
+#	patches.libreelec/rockchip-0105-WIP-FRL-drm-bridge-dw-hdmi-qp-Add-HDMI-2.1-FRL-suppo.patch

Also applies to: 106-106

extensions/wayland-sessions-mask.sh (1)

1-1: Consider dropping the shebang in extension scripts.

These files are sourced by the build system, so the shebang isn’t used; removing it keeps conventions consistent and avoids suggesting direct execution.

♻️ Suggested cleanup
-#!/usr/bin/env bash

Based on learnings, extensions are sourced and don’t need a shebang.

patch/u-boot/sunxi-dev-u-boot-a523/allwinner-a523-support-spl-spi-controllers.patch (1)

125-196: Inconsistent indentation: spaces instead of tabs.

The function body uses 4-space indentation instead of tabs, which is inconsistent with the kernel/U-Boot coding style and the rest of the file (visible in the context lines). This affects lines 125-196.

🔧 Suggested fix

Convert all 4-space indentations to single tabs throughout this function to maintain consistency with U-Boot coding style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Framework Framework components GitHub GitHub-related changes like labels, templates, ... Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

7 participants