Skip to contentSkip to conversation

Fix OSPI DMA corruption via FSS_FSAS driver

PATCH Superseded Santhosh Kumar K 2 participants 5 messages Jun 29

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix OSPI DMA corruption via FSS_FSAS driver

On TI K3 SoCs, DMA transfers from OSPI produce corrupted data when the source address is only 4-byte aligned (not 4K-aligned). The root cause is XIP read prefetch in the FSS_FSAS_GENREGS wrapper (SYSCONFIG.DISXIP, bit 7), which is enabled by default.

This series adds a dedicated FSS_FSAS platform driver that disables XIP prefetch at probe, plus the respective DT binding.

Testing:
This series was tested on TI's
AM62Ax SK with OSPI NAND flash and
AM62Px SK with OSPI NOR flash:

Test log: https://gist.github.com/santhosh21/3ac2a0273065e86315a9b442327c9599
Repo: https://github.com/santhosh21/linux/commits/fsas

Santhosh Kumar K (2):
dt-bindings: memory: Add TI FSS_FSAS binding
memory: ti-k3-fsas: Add TI FSS_FSAS driver

 .../memory-controllers/ti,am62a-fsas.yaml     | 39 ++++++++++
 drivers/memory/Kconfig                        | 10 +++
 drivers/memory/Makefile                       |  1 +
 drivers/memory/ti-k3-fsas.c                   | 74 +++++++++++++++++++
 4 files changed, 124 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml
 create mode 100644 drivers/memory/ti-k3-fsas.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 dt-bindings: memory: Add TI FSS_FSAS binding

Add DT binding for the TI Flash Subsystem Application Subsystem (FSS_FSAS_GENREGS) wrapper present in TI K3 SoCs. This block controls XIP read prefetch for the OSPI controller.

---
 .../memory-controllers/ti,am62a-fsas.yaml     | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml
Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml new file +39 -0
new file mode 100644
index 000000000000..81c71ebfb7e1
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2025 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/ti/ti,am62a-fsas.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Flash SubSystem Application Subsystem (FSS_FSAS)
+
+maintainers:
+  - Santhosh Kumar K <[email protected]>
+
+description:
+  The FSS_FSAS_GENREGS block is a TI wrapper inside the Flash SubSystem (FSS).
+
+properties:
+  compatible:
+    const: ti,am62a-fsas
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        fsas@fc10000 {
+            compatible = "ti,am62a-fsas";
+            reg = <0x00 0x0fc10000 0x00 0x100>;
+        };
+    };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: memory: Add TI FSS_FSAS binding

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The `$id` field in the YAML binding schema does not match the file's location, which breaks…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The $id field in the YAML binding schema does not match the file's location, which breaks schema cross-referencing and can cause dt_binding_check to silently skip validation. --

commit 54d35a3fdeae166603662fbdb3cac4a24e6c37c1
Author: Santhosh Kumar K <[email protected]>

dt-bindings: memory: Add TI FSS_FSAS binding

This commit adds a device tree binding for the TI Flash Subsystem Application Subsystem (FSS_FSAS_GENREGS) wrapper. This wrapper block is present in TI K3 SoCs and controls XIP read prefetch for the OSPI controller.

Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml line 5

Quoted 11 lines
Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml new file +5 -0
new file mode 100644
index 0000000000000..81c71ebfb7e13
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2025 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/ti/ti,am62a-fsas.yaml#

[Severity: Medium]
Does this $id path mismatch the file's actual location?

The file is being added to the memory-controllers subdirectory, but the $id field specifies soc/ti/. When the $id field does not exactly match the file path relative to Documentation/devicetree/bindings/, it breaks schema cross-referencing and can cause dt_binding_check to silently skip validation or report misleading errors.

Quoted 3 lines
Documentation/devicetree/bindings/memory-controllers/ti,am62a-fsas.yaml new file +3 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Flash SubSystem Application Subsystem (FSS_FSAS)

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH 2/2 memory: ti-k3-fsas: Add TI FSS_FSAS driver

In reply to Santhosh Kumar K

Add a platform driver for the TI Flash SubSystem Application Subsystem (FSS_FSAS_GENREGS) in K3 SoCs. This driver takes care of disabling the OSPI XIP prefetch which causes DMA transfer data corruption.

Set SYSCONFIG.DISXIP to disable XIP read prefetch, preventing DMA data corruption when the OSPI DMA source address is not 4K-aligned.

---
 drivers/memory/Kconfig      | 10 +++++
 drivers/memory/Makefile     |  1 +
 drivers/memory/ti-k3-fsas.c | 74 +++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/memory/ti-k3-fsas.c
drivers/memory/Kconfig +10 -0
index e5527020ff33..954e47810e8d 100644
@@ -125,6 +125,16 @@ config TI_EMIF_SRAM
 	  sequence so this driver provides several relocatable PM functions
 	  for the SoC PM code to use.
 
+config TI_K3_FSS_FSAS
+	tristate "TI K3 Flash Subsystem Application Subsystem (FSAS) support"
+	depends on ARCH_K3 || COMPILE_TEST
+	help
+	  Driver for the TI K3 Flash Subsystem Application Subsystem
+	  (FSS_FSAS_GENREGS) wrapper found on K3 related SoCs.
+
+	  This driver takes care of disabling the OSPI XIP prefetch which
+	  causes DMA transfer data corruption.
+
 config FPGA_DFL_EMIF
 	tristate "FPGA DFL EMIF Driver"
 	depends on FPGA_DFL && HAS_IOMEM
drivers/memory/Makefile +1 -0
index 3ee883c8759a..8dc4860f615d 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_STM32_OMM)		+= stm32_omm.o
 obj-$(CONFIG_SAMSUNG_MC)	+= samsung/
 obj-$(CONFIG_TEGRA_MC)		+= tegra/
 obj-$(CONFIG_TI_EMIF_SRAM)	+= ti-emif-sram.o
+obj-$(CONFIG_TI_K3_FSS_FSAS)	+= ti-k3-fsas.o
 obj-$(CONFIG_FPGA_DFL_EMIF)	+= dfl-emif.o
 
 ti-emif-sram-objs		:= ti-emif-pm.o ti-emif-sram-pm.o
drivers/memory/ti-k3-fsas.c new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/2] memory: ti-k3-fsas: Add TI FSS_FSAS driver

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Incorrect wrapper macro `pm_sleep_ptr()` used for the `dev_pm_ops` structure pointer. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect wrapper macro pm_sleep_ptr() used for the dev_pm_ops structure pointer. --

commit be06c2a7e885af5ffba7e5ddc137bd7ba0758747
Author: Santhosh Kumar K <[email protected]>
memory: ti-k3-fsas: Add TI FSS_FSAS driver

This commit adds a new platform driver for the TI K3 Flash Subsystem Application Subsystem (FSS_FSAS). It configures the SYSCONFIG register to disable OSPI XIP prefetch, preventing DMA data corruption.

Quoted 5 lines
drivers/memory/ti-k3-fsas.c new file +0 -0
new file mode 100644
index 0000000000000..9ff109b8d96fd

[ ... ]

Quoted 4 lines
drivers/memory/ti-k3-fsas.c new file +4 -0
+static DEFINE_SIMPLE_DEV_PM_OPS(k3_fsas_pm_ops, NULL, k3_fsas_resume);
+
+static const struct of_device_id k3_fsas_of_match[] = {
+	{ .compatible = "ti,am62a-fsas" },

drivers/memory/ti-k3-fsas.c line 68

Quoted 10 lines
drivers/memory/ti-k3-fsas.c new file +10 -0
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, k3_fsas_of_match);
+
+static struct platform_driver k3_fsas_driver = {
+	.probe = k3_fsas_probe,
+	.driver = {
+		.name		= "k3-fsas",
+		.of_match_table	= k3_fsas_of_match,
+		.pm		= pm_sleep_ptr(&k3_fsas_pm_ops),

[Severity: Low]
Should this use pm_ptr() instead of pm_sleep_ptr() for the dev_pm_ops structure pointer?

The PM subsystem guidelines specify that pm_sleep_ptr() is intended for the individual sleep callbacks, while pm_ptr() should be used for the dev_pm_ops structure pointer itself. While this doesn't cause immediate issues since the driver currently only uses sleep callbacks, using pm_ptr() here ensures consistency with standard PM usage and prevents issues if runtime PM callbacks are added later.

Quoted 3 lines
drivers/memory/ti-k3-fsas.c new file +3 -0
+	},
+};
+module_platform_driver(k3_fsas_driver);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2