riscv: sophgo: sg2042: Enable PCIe DMA coherence
Subsystems (6)
cover riscv: sophgo: sg2042: Enable PCIe DMA coherence
The SG2042 hardware design supports cache-coherent PCIe.
With recent firmware updates [1], it allows to use DMA coherent.
[1] https://github.com/sophgo/edk2-non-osi/commit/017a5aea26a066fd2bf501b7893937183165af36
Han Gao (2):
dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
.../devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml | 3 +++ arch/riscv/boot/dts/sophgo/sg2042.dtsi | 4 ++++ 2 files changed, 7 insertions(+)
Signature · 1 line
2.47.3
PATCH 1/2 dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
Add dma-coherent as an allowed property in the SG2042 PCIe host controller binding. SG2042's PCIe root complexes are cache-coherent with the CPU.
--- .../devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml +3 -0
@@ -30,6 +30,8 @@ properties: device-id: const: 0x2042 + dma-coherent: true + msi-parent: true allOf:
@@ -60,5 +62,6 @@ examples: vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; };
Signature · 1 line
2.47.3
Re: [PATCH 1/2] dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
Quoted 9 lines · Han Gao
Add dma-coherent as an allowed property in the SG2042 PCIe host controller binding. SG2042's PCIe root complexes are cache-coherent with the CPU.
Signed-off-by Han Gao <[email protected]>--- .../devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml | 3 +++ 1 file changed, 3 insertions(+)
PATCH 2/2 riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
In reply to Han GaoSG2042's PCIe root complexes are cache-coherent with the CPU. Mark all four PCIe controller nodes (pcie_rc0 through pcie_rc3) as dma-coherent so the kernel uses coherent DMA mappings instead of non-coherent bounce buffering.
--- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042.dtsi +4 -0
@@ -417,6 +417,7 @@ pcie_rc0: pcie@7060000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
@@ -439,6 +440,7 @@ pcie_rc1: pcie@7060800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
@@ -461,6 +463,7 @@ pcie_rc2: pcie@7062000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
@@ -483,6 +486,7 @@ pcie_rc3: pcie@7062800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
Signature · 1 line
2.47.3
Re: [PATCH 2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
Quoted 4 lines · Han Gao
SG2042's PCIe root complexes are cache-coherent with the CPU. Mark all four PCIe controller nodes (
pcie_rc0throughpcie_rc3) as dma-coherent so the kernel uses coherent DMA mappings instead of non-coherent bounce buffering.
Worth pointing out I guess that this property is needed, despite riscv being coherent by default, because the whole bus is marked dma-noncoherent.
Quoted 46 lines
Signed-off-by Han Gao <[email protected]>--- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/riscv/boot/dts/sophgo/sg2042.dtsi +4
-0@@ -417,6 +417,7 @@ pcie_rc0: pcie@7060000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -439,6 +440,7 @@ pcie_rc1: pcie@7060800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -461,6 +463,7 @@ pcie_rc2: pcie@7062000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -483,6 +486,7 @@ pcie_rc3: pcie@7062800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };Signature · 1 line
2.47.3
Re: [PATCH 2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
In reply to Han GaoQuoted 40 lines · Han Gao
SG2042's PCIe root complexes are cache-coherent with the CPU. Mark all four PCIe controller nodes (
pcie_rc0throughpcie_rc3) as dma-coherent so the kernel uses coherent DMA mappings instead of non-coherent bounce buffering.Signed-off-by Han Gao <[email protected]>--- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/riscv/boot/dts/sophgo/sg2042.dtsi +3
-0@@ -417,6 +417,7 @@ pcie_rc0: pcie@7060000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -439,6 +440,7 @@ pcie_rc1: pcie@7060800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -461,6 +463,7 @@ pcie_rc2: pcie@7062000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
arch/riscv/boot/dts/sophgo/sg2042.dtsi pcie_rc3: pcie@7062800000 { · line 492
Quoted 7 lines
arch/riscv/boot/dts/sophgo/sg2042.dtsi +1
-0@@ -483,6 +486,7 @@ pcie_rc3: pcie@7062800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };
For binding changes, LGTM. But I have a question regarding this change in dtsi.
From your patch description, I understand that enabling the dma-coherent attribute requires upgrading the firmware fip.bin. If a user only updates the kernel (which is relatively easy) but forgets or doesn't know how to upgrade the firmware, enabling coherent might cause the kernel to skip all explicit cache maintenance operations. Could this pose a subtle risk?
Wouldn't it be safer to leave the upstream unchanged in dtsi and allow users to add the dma-coherent attribute themselves after they upgrade the firmware?
I would greatly appreciate your guidance.
Thanks,
Chen
Re: [PATCH 2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
Quoted 60 lines · Chen Wang
Quoted 40 lines · Han Gao
SG2042's PCIe root complexes are cache-coherent with the CPU. Mark all four PCIe controller nodes (
pcie_rc0throughpcie_rc3) as dma-coherent so the kernel uses coherent DMA mappings instead of non-coherent bounce buffering.Signed-off-by Han Gao <[email protected]>--- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/riscv/boot/dts/sophgo/sg2042.dtsi +3
-0@@ -417,6 +417,7 @@ pcie_rc0: pcie@7060000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -439,6 +440,7 @@ pcie_rc1: pcie@7060800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };@@ -461,6 +463,7 @@ pcie_rc2: pcie@7062000000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };arch/riscv/boot/dts/sophgo/sg2042.dtsi pcie_rc3: pcie@7062800000 { · line 492
Quoted 7 lines
arch/riscv/boot/dts/sophgo/sg2042.dtsi +1
-0@@ -483,6 +486,7 @@ pcie_rc3: pcie@7062800000 { vendor-id = <0x1f1c>; device-id = <0x2042>; cdns,no-bar-match-nbits = <48>; + dma-coherent; msi-parent = <&msi>; status = "disabled"; };For binding changes, LGTM. But I have a question regarding this change in dtsi.
From your patch description, I understand that enabling the
dma-coherentattribute requires upgrading the firmwarefip.bin. If a user only updates the kernel (which is relatively easy) but forgets or doesn't know how to upgrade the firmware, enablingcoherentmight cause the kernel to skip all explicit cache maintenance operations. Could this pose a subtle risk?
Quoted 3 lines
Wouldn't it be safer to leave the upstream unchanged in dtsi and allow users to add the
dma-coherentattribute themselves after they upgrade the firmware?
In the firmware, fip.bin and devicetree are distributed together. So matching issues are unlikely.
Quoted 8 lines
I would greatly appreciate your guidance.
Thanks,
Chen
Thanks,
Han
Manivannan Sadhasivam
AppliedRe: (subset) [PATCH 0/2] riscv: sophgo: sg2042: Enable PCIe DMA coherence
In reply to Han GaoQuoted 11 lines · Han Gao
The SG2042 hardware design supports cache-coherent PCIe.
With recent firmware updates [1], it allows to use DMA coherent.
[1] https://github.com/sophgo/edk2-non-osi/commit/017a5aea26a066fd2bf501b7893937183165af36
Han Gao (2):
dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers[...]
Applied, thanks!
[1/2] dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
commit: 50c94a2351458ee6cb6e52c5678f099534366830
Best regards,
Signature · 1 line
Manivannan Sadhasivam <[email protected]>
Re: (subset) [PATCH 0/2] riscv: sophgo: sg2042: Enable PCIe DMA coherence
In reply to Han GaoQuoted 11 lines · Han Gao
The SG2042 hardware design supports cache-coherent PCIe.
With recent firmware updates [1], it allows to use DMA coherent.
[1] https://github.com/sophgo/edk2-non-osi/commit/017a5aea26a066fd2bf501b7893937183165af36
Han Gao (2):
dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers[...]
Applied to for-next, thanks!
[2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
https://github.com/sophgo/linux/commit/e728a57834d06b9bbf9bbed69e3ea16416d257d5
Thanks,
Inochi
Inochi Amaoto
maintainerRe: (subset) [PATCH 0/2] riscv: sophgo: sg2042: Enable PCIe DMA coherence
Quoted 13 lines · Inochi Amaoto
Quoted 11 lines · Han Gao
The SG2042 hardware design supports cache-coherent PCIe.
With recent firmware updates [1], it allows to use DMA coherent.
[1] https://github.com/sophgo/edk2-non-osi/commit/017a5aea26a066fd2bf501b7893937183165af36
Han Gao (2):
dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers[...]
Quoted 8 lines
Applied to for-next, thanks!
[2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
https://github.com/sophgo/linux/commit/e728a57834d06b9bbf9bbed69e3ea16416d257d5Thanks,
Inochi
Revoke this apply due to https://lore.kernel.org/sophgo/ahu57vcS0oOFmCI9@mertle/
Regards,
Inochi
Inochi Amaoto
maintainerRe: (subset) [PATCH 0/2] riscv: sophgo: sg2042: Enable PCIe DMA coherence
Quoted 16 lines · Inochi Amaoto
Quoted 15 lines · Inochi Amaoto
Quoted 11 lines · Han Gao
The SG2042 hardware design supports cache-coherent PCIe.
With recent firmware updates [1], it allows to use DMA coherent.
[1] https://github.com/sophgo/edk2-non-osi/commit/017a5aea26a066fd2bf501b7893937183165af36
Han Gao (2):
dt-bindings: pci: sophgo: Add dma-coherent property for SG2042
riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers[...]
Applied to for-next, thanks!
Quoted 9 lines
Quoted 6 lines
[2/2] riscv: dts: sophgo: Add dma-coherent to SG2042 PCIe controllers
https://github.com/sophgo/linux/commit/e728a57834d06b9bbf9bbed69e3ea16416d257d5Thanks,
InochiRevoke this apply due to https://lore.kernel.org/sophgo/ahu57vcS0oOFmCI9@mertle/
Reapply this as this error is resolved.
Regards,
Inochi