Re: [PATCH 4/6] riscv: dts: spacemit: add USB2.0 controller nodes for K1

[email protected]
Newsgroups org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The newly added `usb2_0` and `usb2_1` controllers are instantiated under the `storage-bus` node, which has a restrictive `dma-ranges` property that excludes system RAM, preventing DMA operations for these controllers.
--

--- Patch [4]: [PATCH 4/6] riscv: dts: spacemit: add USB2.0 controller nodes for K1 ---
commit 574278a69410138bf5c5e246489a12433bf57db8
Author: Junzhong Pan <[email protected]>

riscv: dts: spacemit: add USB2.0 controller nodes for K1

This commit adds two ChipIdea USB2.0 controllers to the SpacemiT K1
SoC device tree. One controller is configured for Dual-Role (OTG)
and the other is Host Only.

> diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
> index 08a0f28d011fe..aa35a34892503 100644
> --- a/arch/riscv/boot/dts/spacemit/k1.dtsi
> +++ b/arch/riscv/boot/dts/spacemit/k1.dtsi

[ ... ]

> @@ -1291,6 +1307,30 @@ storage-bus {
>  			#size-cells = <2>;
>  			dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>;
>  
> +			usb2_0: usb@c0900000 {
> +				compatible = "spacemit,k1-usb2";
> +				reg = <0x0 0xc0900000 0x0 0x4100>;
> +				interrupts = <105>;
> +				clocks = <&syscon_apmu CLK_USB_AXI>;
> +				resets = <&syscon_apmu RESET_USB_AXI>;
> +				phys = <&usbphy0>;
> +				phy-names = "usb-phy";
> +				dr_mode = "otg";
> +				status = "disabled";
> +			};
> +
> +			usb2_1: usb@c0980000 {

[Severity: High]
This isn't a bug introduced by this patch, but will these new USB controllers
fail to perform DMA operations because of the storage-bus node's dma-ranges
property?

The parent storage-bus node defines:
dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>;

This restricts DMA accesses to physical addresses between 0x0 and 0x7FFFFFFF.
Since the system RAM on this SoC starts at 0x100000000 (above the 4GB
boundary), will the kernel's DMA subsystem reject mappings for data buffers
or descriptors located in RAM?

Placing these new DMA-capable USB nodes under storage-bus seems to guarantee
they will fail to map memory.

> +				compatible = "spacemit,k1-usb2";
> +				reg = <0x0 0xc0980000 0x0 0x4100>;
> +				interrupts = <118>;
> +				clocks = <&syscon_apmu CLK_USB_P1>;
> +				resets = <&syscon_apmu RESET_USBP1_AXI>;
> +				phys = <&usbphy1>;
> +				phy-names = "usb-phy";
> +				dr_mode = "host";
> +				status = "disabled";
> +			};
> +
>  			usb_dwc3: usb@c0a00000 {
>  				compatible = "spacemit,k1-dwc3";
>  				reg = <0x0 0xc0a00000 0x0 0x10000>;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812-b4-spacemit-k1-usb2-v1-0-f28cf29e522b@linux.spacemit.com?part=4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.