Support for NVDEC on Tegra234
Subsystems (9)
v2 cover Support for NVDEC on Tegra234
From: Mikko Perttunen <[email protected]>
v2:
* Updated patches 1,3 based on comments
* Added Acked-by to patch 2
Original message:
Hi all,
this series adds support for the HW video decoder, NVDEC, on Tegra234 (Orin). The main change is a switch from Falcon to RISC-V for the internal microcontroller, which brings along a change in how the engine is booted. Otherwise it is backwards compatible with earlier versions.
In previous iterations, firmware was simply loaded from disk and written into engine internal memory. Now, the engine has a bootrom that loads the firmware from a carveout where it has been loaded by the system bootloader; however, we still need to tell it where that carveout is loaded and some offsets into it. For that, the first patch adds a new memory controller API to query the carveout address. The offsets are read from device tree -- the expectation is that at flashing time (when the firmware is also flashed), the flasher also delivers a device tree overlay with values corresponding to the flashed firmware.
The currently available Linux for Tegra release doesn't yet include this device tree overlay flashing, and the firmware version it contains is incompatible with this series. The plan is to fix that for the next Linux for Tegra release, but if necessary, we can postpone merging of this series to once those changes are available.
Thanks!
Mikko
Mikko Perttunen (8):
memory: tegra: Add API for retrieving carveout bounds
dt-bindings: Add headers for NVDEC on Tegra234
dt-bindings: Add bindings for Tegra234 NVDEC
arm64: tegra: Add NVDEC on Tegra234
gpu: host1x: Add stream ID register data for NVDEC on Tegra234 drm/tegra: nvdec: Support multiple clocks
drm/tegra: Add code for booting RISC-V based engines drm/tegra: Add Tegra234 support to NVDEC driver
.../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++ arch/arm64/boot/dts/nvidia/tegra234.dtsi | 27 +++ drivers/gpu/drm/tegra/Makefile | 3 +- drivers/gpu/drm/tegra/drm.c | 1 + drivers/gpu/drm/tegra/nvdec.c | 171 +++++++++++++++--- drivers/gpu/drm/tegra/riscv.c | 106 +++++++++++ drivers/gpu/drm/tegra/riscv.h | 30 +++ drivers/gpu/host1x/dev.c | 12 ++ drivers/memory/tegra/mc.c | 25 +++ drivers/memory/tegra/tegra234.c | 5 + include/dt-bindings/clock/tegra234-clock.h | 4 + include/dt-bindings/memory/tegra234-mc.h | 3 + .../dt-bindings/power/tegra234-powergate.h | 1 + include/dt-bindings/reset/tegra234-reset.h | 1 + include/soc/tegra/mc.h | 11 ++ 15 files changed, 528 insertions(+), 26 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml create mode 100644 drivers/gpu/drm/tegra/riscv.c create mode 100644 drivers/gpu/drm/tegra/riscv.h
Signature · 1 line
2.37.0
PATCH v2 1/8 memory: tegra: Add API for retrieving carveout bounds
From: Mikko Perttunen <[email protected]>
On Tegra234 NVDEC firmware is loaded from a secure carveout, where it has been loaded by a bootloader. When booting NVDEC, we need to tell it the address of this firmware, which we can determine by checking the starting address of the carveout. As such, add an MC API to query the bounds of carveouts, and add related information on Tegra234.
---
v2:
- Add check for 64-bit phys_addr_t. In practice phys_addr_t is always 64 bits where this runs, but it avoids warnings in compile test.
--- drivers/memory/tegra/mc.c | 25 +++++++++++++++++++++++++ drivers/memory/tegra/tegra234.c | 5 +++++ include/soc/tegra/mc.h | 11 +++++++++++ 3 files changed, 41 insertions(+)
drivers/memory/tegra/mc.c +25 -0
@@ -107,6 +107,31 @@ int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev) }EXPORT_SYMBOL_GPL (tegra_mc_probe_device); +int tegra_mc_get_carveout_info (struct tegra_mc *mc,unsigned int id, +phys_addr_t *base,u64 *size) +{ +u32 offset; + +if (id <1 || id >= mc->soc->num_carveouts) +return -EINVAL ; + +if (id <6 ) + offset =0xc0c +0x50 * (id -1 ); +else + offset =0x2004 +0x50 * (id -6 ); + + *base =mc_ch_readl (mc,MC_BROADCAST_CHANNEL , offset +0x0 ); +#ifdef CONFIG_PHYS_ADDR_T_64BIT + *base |= (phys_addr_t )mc_ch_readl (mc,MC_BROADCAST_CHANNEL , offset +0x4 ) <<32 ; +#endif + +if (size) + *size =mc_ch_readl (mc,MC_BROADCAST_CHANNEL , offset +0x8 ) <<17 ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tegra_mc_get_carveout_info); +static int tegra_mc_block_dma_common (struct tegra_mc *mc,const struct tegra_mc_reset *rst) {
drivers/memory/tegra/tegra234.c +5 -0
@@ -187,4 +187,9 @@ const struct tegra_mc_soc tegra234_mc_soc = { .ops = &tegra186_mc_ops, .ch_intmask = 0x0000ff00, .global_intstatus_channel_shift = 8, +/* +* Additionally, there are lite carveouts but those are not currently +* supported. +*/ + .num_carveouts = 32, };
include/soc/tegra/mc.h +11 -0
@@ -193,6 +193,8 @@ struct tegra_mc_soc {unsigned int num_address_bits;unsigned int atom_size; +unsigned int num_carveouts; +u16 client_id_mask;u8 num_channels;
@@ -244,6 +246,8 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);#ifdef CONFIG_TEGRA_MC struct tegra_mc *devm_tegra_memory_controller_get (struct device *dev);int tegra_mc_probe_device (struct tegra_mc *mc,struct device *dev); +int tegra_mc_get_carveout_info (struct tegra_mc *mc,unsigned int id, +phys_addr_t *base,u64 *size);#else static inline struct tegra_mc *devm_tegra_memory_controller_get (struct device *dev)
@@ -256,6 +260,13 @@ tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev) {return -ENODEV ; } + +static inline int +tegra_mc_get_carveout_info (struct tegra_mc *mc,unsigned int id, +phys_addr_t *base,u64 *size) +{ +return -ENODEV ; +}#endif #endif /* __SOC_TEGRA_MC_H__ */
Signature · 1 line
2.37.0
PATCH v2 2/8 dt-bindings: Add headers for NVDEC on Tegra234
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Add clock, memory controller, powergate and reset dt-binding headers necessary for NVDEC.
--- include/dt-bindings/clock/tegra234-clock.h | 4 ++++ include/dt-bindings/memory/tegra234-mc.h | 3 +++ include/dt-bindings/power/tegra234-powergate.h | 1 + include/dt-bindings/reset/tegra234-reset.h | 1 + 4 files changed, 9 insertions(+)
include/dt-bindings/clock/tegra234-clock.h +4 -0
@@ -82,6 +82,8 @@#define TEGRA234_CLK_I2S6 66U/** @brief clock recovered from I2S6 input */ #define TEGRA234_CLK_I2S6_SYNC_INPUT 67U +/** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_NVDEC */ +#define TEGRA234_CLK_NVDEC 83U/** PLL controlled by CLK_RST_CONTROLLER_PLLA_BASE for use by audio clocks */ #define TEGRA234_CLK_PLLA 93U/** @brief PLLP clk output */
@@ -130,6 +132,8 @@#define TEGRA234_CLK_SYNC_I2S5 149U/** @brief output of mux controlled by CLK_RST_CONTROLLER_AUDIO_SYNC_CLK_I2S6 */ #define TEGRA234_CLK_SYNC_I2S6 150U +/** output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_PKA */ +#define TEGRA234_CLK_TSEC_PKA 154U/** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_UARTA */ #define TEGRA234_CLK_UARTA 155U/** @brief output of gate CLK_ENB_PEX1_CORE_6 */
include/dt-bindings/memory/tegra234-mc.h +3 -0
@@ -32,6 +32,7 @@#define TEGRA234_SID_PCIE10 0x0b#define TEGRA234_SID_BPMP 0x10#define TEGRA234_SID_HOST1X 0x27 +#define TEGRA234_SID_NVDEC 0x29#define TEGRA234_SID_VIC 0x34/*
@@ -91,6 +92,8 @@#define TEGRA234_MEMORY_CLIENT_SDMMCWAB 0x67#define TEGRA234_MEMORY_CLIENT_VICSRD 0x6c#define TEGRA234_MEMORY_CLIENT_VICSWR 0x6d +#define TEGRA234_MEMORY_CLIENT_NVDECSRD 0x78 +#define TEGRA234_MEMORY_CLIENT_NVDECSWR 0x79/* BPMP read client */ #define TEGRA234_MEMORY_CLIENT_BPMPR 0x93/* BPMP write client */
include/dt-bindings/power/tegra234-powergate.h +1 -0
@@ -19,6 +19,7 @@#define TEGRA234_POWER_DOMAIN_MGBEB 18U#define TEGRA234_POWER_DOMAIN_MGBEC 19U#define TEGRA234_POWER_DOMAIN_MGBED 20U +#define TEGRA234_POWER_DOMAIN_NVDEC 23U#define TEGRA234_POWER_DOMAIN_VIC 29U#endif
include/dt-bindings/reset/tegra234-reset.h +1 -0
@@ -30,6 +30,7 @@#define TEGRA234_RESET_I2C7 33U#define TEGRA234_RESET_I2C8 34U#define TEGRA234_RESET_I2C9 35U +#define TEGRA234_RESET_NVDEC 44U#define TEGRA234_RESET_MGBE0_PCS 45U#define TEGRA234_RESET_MGBE0_MAC 46U#define TEGRA234_RESET_MGBE1_PCS 49U
Signature · 1 line
2.37.0
PATCH v2 3/8 dt-bindings: Add bindings for Tegra234 NVDEC
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Update NVDEC bindings for Tegra234. This new engine version only has two memory clients, but now requires three clocks, and as a bigger change the engine loads firmware from a secure carveout configured by the bootloader.
For the latter, we need to add a phandle to the memory controller to query the location of this carveout, and several other properties containing offsets into the firmware inside the carveout. These properties are intended to be populated through a device tree overlay configured at flashing time, so that the values correspond to the flashed NVDEC firmware.
As the binding was getting large with many conditional properties, also split the Tegra234 version out into a separate file.
---
v2:
- Split out into separate file to avoid complexity with conditionals etc.
--- .../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +154 -0
@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra234-nvdec.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Device tree binding for NVIDIA Tegra234 NVDEC + +description: | + NVDEC is the hardware video decoder present on NVIDIA Tegra210 + and newer chips. It is located on the Host1x bus and typically + programmed through Host1x channels. + +maintainers: + - Thierry Reding <[email protected]> + - Mikko Perttunen <[email protected]> + +properties: + $nodename: + pattern: "^nvdec@[0-9a-f]*$" + + compatible: + enum: + - nvidia,tegra234-nvdec + + reg: + maxItems: 1 + + clocks: + maxItems: 3 + + clock-names: + items: + - const: nvdec + - const: fuse + - const: tsec_pka + + resets: + maxItems: 1 + + reset-names: + items: + - const: nvdec + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + + interconnects: + items: + - description: DMA read memory client + - description: DMA write memory client + + interconnect-names: + items: + - const: dma-mem + - const: write + + nvidia,memory-controller: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the memory controller for determining carveout information. + + nvidia,bl-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - power-domains + - nvidia,memory-controller + - nvidia,bl-manifest-offset + - nvidia,bl-code-offset + - nvidia,bl-data-offset + - nvidia,os-manifest-offset + - nvidia,os-code-offset + - nvidia,os-data-offset + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/tegra234-clock.h> + #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/power/tegra234-powergate.h> + #include <dt-bindings/reset/tegra234-reset.h> + + nvdec@15480000 { + compatible = "nvidia,tegra234-nvdec"; + reg = <0x15480000 0x00040000>; + clocks = <&bpmp TEGRA234_CLK_NVDEC>, + <&bpmp TEGRA234_CLK_FUSE>, + <&bpmp TEGRA234_CLK_TSEC_PKA>; + clock-names = "nvdec", "fuse", "tsec_pka"; + resets = <&bpmp TEGRA234_RESET_NVDEC>; + reset-names = "nvdec"; + power-domains = <&bpmp TEGRA234_POWER_DOMAIN_NVDEC>; + interconnects = <&mc TEGRA234_MEMORY_CLIENT_NVDECSRD &emc>, + <&mc TEGRA234_MEMORY_CLIENT_NVDECSWR &emc>; + interconnect-names = "dma-mem", "write"; + iommus = <&smmu_niso1 TEGRA234_SID_NVDEC>; + dma-coherent; + + nvidia,memory-controller = <&mc>; + + /* Placeholder values, to be replaced with values from overlay */ + nvidia,bl-manifest-offset = <0>; + nvidia,bl-data-offset = <0>; + nvidia,bl-code-offset = <0>; + nvidia,os-manifest-offset = <0>; + nvidia,os-data-offset = <0>; + nvidia,os-code-offset = <0>; + };
Signature · 1 line
2.37.0
Rob Herring
maintainerRe: [PATCH v2 3/8] dt-bindings: Add bindings for Tegra234 NVDEC
Quoted 125 lines · Mikko Perttunen
From: Mikko Perttunen <[email protected]>
Update NVDEC bindings for Tegra234. This new engine version only has two memory clients, but now requires three clocks, and as a bigger change the engine loads firmware from a secure carveout configured by the bootloader.
For the latter, we need to add a phandle to the memory controller to query the location of this carveout, and several other properties containing offsets into the firmware inside the carveout. These properties are intended to be populated through a device tree overlay configured at flashing time, so that the values correspond to the flashed NVDEC firmware.
As the binding was getting large with many conditional properties, also split the Tegra234 version out into a separate file.
Signed-off-by Mikko Perttunen <[email protected]>---
v2:
- Split out into separate file to avoid complexity with conditionals etc.--- .../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yamlDocumentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +92
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra234-nvdec.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Device tree binding for NVIDIA Tegra234 NVDEC + +description: | + NVDEC is the hardware video decoder present on NVIDIA Tegra210 + and newer chips. It is located on the Host1x bus and typically + programmed through Host1x channels. + +maintainers: + - Thierry Reding <[email protected]> + - Mikko Perttunen <[email protected]> + +properties: + $nodename: + pattern: "^nvdec@[0-9a-f]*$" + + compatible: + enum: + - nvidia,tegra234-nvdec + + reg: + maxItems: 1 + + clocks: + maxItems: 3 + + clock-names: + items: + - const: nvdec + - const: fuse + - const: tsec_pka + + resets: + maxItems: 1 + + reset-names: + items: + - const: nvdec + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + + interconnects: + items: + - description: DMA read memory client + - description: DMA write memory client + + interconnect-names: + items: + - const: dma-mem + - const: write + + nvidia,memory-controller: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the memory controller for determining carveout information. + + nvidia,bl-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-code-offset:
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml line 102
Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +10
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware.
I don't think DT is the place for describing your runtime loaded firmware layout.
Rob
Re: [PATCH v2 3/8] dt-bindings: Add bindings for Tegra234 NVDEC
Quoted 140 lines · Rob Herring
Quoted 125 lines · Mikko Perttunen
From: Mikko Perttunen <[email protected]>
Update NVDEC bindings for Tegra234. This new engine version only has two memory clients, but now requires three clocks, and as a bigger change the engine loads firmware from a secure carveout configured by the bootloader.
For the latter, we need to add a phandle to the memory controller to query the location of this carveout, and several other properties containing offsets into the firmware inside the carveout. These properties are intended to be populated through a device tree overlay configured at flashing time, so that the values correspond to the flashed NVDEC firmware.
As the binding was getting large with many conditional properties, also split the Tegra234 version out into a separate file.
Signed-off-by Mikko Perttunen <[email protected]>---
v2:
- Split out into separate file to avoid complexity with conditionals etc.--- .../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+)create mode 100644
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yamlDocumentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +92
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra234-nvdec.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Device tree binding for NVIDIA Tegra234 NVDEC + +description: | + NVDEC is the hardware video decoder present on NVIDIA Tegra210 + and newer chips. It is located on the Host1x bus and typically + programmed through Host1x channels. + +maintainers: + - Thierry Reding <[email protected]> + - Mikko Perttunen <[email protected]> + +properties: + $nodename: + pattern: "^nvdec@[0-9a-f]*$" + + compatible: + enum: + - nvidia,tegra234-nvdec + + reg: + maxItems: 1 + + clocks: + maxItems: 3 + + clock-names: + items: + - const: nvdec + - const: fuse + - const: tsec_pka + + resets: + maxItems: 1 + + reset-names: + items: + - const: nvdec + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + + interconnects: + items: + - description: DMA read memory client + - description: DMA write memory client + + interconnect-names: + items: + - const: dma-mem + - const: write + + nvidia,memory-controller: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the memory controller for determining carveout information. + + nvidia,bl-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-code-offset:Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml line 102
Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +10
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware.I don't think DT is the place for describing your runtime loaded firmware layout.
Quoted 1 line
Rob
The way I see it, from the kernel's point of view it's not runtime loaded but a contract with the bootloader. Bootloader sets up hardware in a certain way the kernel doesn't otherwise know so the bootloader needs to tell the kernel how the hardware is set up.
The fact that the information is supplied through an overlay is accidental -- equivalently the bootloader that sets up the firmware could adjust the device tree like we do in other situations, but in this case an overlay is an easier implementation method.
Thanks,
Mikko
Re: [PATCH v2 3/8] dt-bindings: Add bindings for Tegra234 NVDEC
Quoted 148 lines · Mikko Perttunen
Quoted 140 lines · Rob Herring
Quoted 125 lines · Mikko Perttunen
From: Mikko Perttunen <[email protected]>
Update NVDEC bindings for Tegra234. This new engine version only has two memory clients, but now requires three clocks, and as a bigger change the engine loads firmware from a secure carveout configured by the bootloader.
For the latter, we need to add a phandle to the memory controller to query the location of this carveout, and several other properties containing offsets into the firmware inside the carveout. These properties are intended to be populated through a device tree overlay configured at flashing time, so that the values correspond to the flashed NVDEC firmware.
As the binding was getting large with many conditional properties, also split the Tegra234 version out into a separate file.
Signed-off-by Mikko Perttunen <[email protected]>---
v2:
- Split out into separate file to avoid complexity with conditionals etc.--- .../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+)create mode 100644
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yamlDocumentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +92
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra234-nvdec.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Device tree binding for NVIDIA Tegra234 NVDEC + +description: | + NVDEC is the hardware video decoder present on NVIDIA Tegra210 + and newer chips. It is located on the Host1x bus and typically + programmed through Host1x channels. + +maintainers: + - Thierry Reding <[email protected]> + - Mikko Perttunen <[email protected]> + +properties: + $nodename: + pattern: "^nvdec@[0-9a-f]*$" + + compatible: + enum: + - nvidia,tegra234-nvdec + + reg: + maxItems: 1 + + clocks: + maxItems: 3 + + clock-names: + items: + - const: nvdec + - const: fuse + - const: tsec_pka + + resets: + maxItems: 1 + + reset-names: + items: + - const: nvdec + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + + interconnects: + items: + - description: DMA read memory client + - description: DMA write memory client + + interconnect-names: + items: + - const: dma-mem + - const: write + + nvidia,memory-controller: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the memory controller for determining carveout information. + + nvidia,bl-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-code-offset:Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml line 102
Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +10
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware.I don't think DT is the place for describing your runtime loaded firmware layout.
Quoted 1 line
Rob
The way I see it, from the kernel's point of view it's not runtime loaded but a contract with the bootloader. Bootloader sets up hardware in a certain way the kernel doesn't otherwise know so the bootloader needs to tell the kernel how the hardware is set up.
Quoted 4 lines
The fact that the information is supplied through an overlay is accidental -- equivalently the bootloader that sets up the firmware could adjust the device tree like we do in other situations, but in this case an overlay is an easier implementation method.
I think the key bit of information to know here is that the kernel is not permitted to load this firmware. It's a bootloader early in the boot process that sets this up in a secure context and then needs to convey that information to the kernel.
Perhaps a slightly more idiomatic way to pass this information would be using a reserved memory node? That could span the entirety of the secure carveout (therefore removing the need to query the memory controller for that information) and be identified with a compatible string that would allow custom properties for these various offsets. Yet another way would be to have each of the bootloader and OS regions (manifest, code and data) be their own reserved memory regions. But given that this is one chunk with different regions inside makes that seem excessive.
Rob, do you have any other ideas how this information could be passed to the kernel if not via DT?
Thierry
Rob Herring
maintainerRe: [PATCH v2 3/8] dt-bindings: Add bindings for Tegra234 NVDEC
Quoted 169 lines · Thierry Reding
Quoted 148 lines · Mikko Perttunen
Quoted 140 lines · Rob Herring
Quoted 125 lines · Mikko Perttunen
From: Mikko Perttunen <[email protected]>
Update NVDEC bindings for Tegra234. This new engine version only has two memory clients, but now requires three clocks, and as a bigger change the engine loads firmware from a secure carveout configured by the bootloader.
For the latter, we need to add a phandle to the memory controller to query the location of this carveout, and several other properties containing offsets into the firmware inside the carveout. These properties are intended to be populated through a device tree overlay configured at flashing time, so that the values correspond to the flashed NVDEC firmware.
As the binding was getting large with many conditional properties, also split the Tegra234 version out into a separate file.
Signed-off-by Mikko Perttunen <[email protected]>---
v2:
- Split out into separate file to avoid complexity with conditionals etc.--- .../gpu/host1x/nvidia,tegra234-nvdec.yaml | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+)create mode 100644
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yamlDocumentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +92
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra234-nvdec.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Device tree binding for NVIDIA Tegra234 NVDEC + +description: | + NVDEC is the hardware video decoder present on NVIDIA Tegra210 + and newer chips. It is located on the Host1x bus and typically + programmed through Host1x channels. + +maintainers: + - Thierry Reding <[email protected]> + - Mikko Perttunen <[email protected]> + +properties: + $nodename: + pattern: "^nvdec@[0-9a-f]*$" + + compatible: + enum: + - nvidia,tegra234-nvdec + + reg: + maxItems: 1 + + clocks: + maxItems: 3 + + clock-names: + items: + - const: nvdec + - const: fuse + - const: tsec_pka + + resets: + maxItems: 1 + + reset-names: + items: + - const: nvdec + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + + interconnects: + items: + - description: DMA read memory client + - description: DMA write memory client + + interconnect-names: + items: + - const: dma-mem + - const: write + + nvidia,memory-controller: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the memory controller for determining carveout information. + + nvidia,bl-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-code-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,bl-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to bootloader data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-manifest-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system manifest from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-code-offset:Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml line 102
Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra234-nvdec.yaml new file +10
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system code section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware. + + nvidia,os-data-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Offset to operating system data section from beginning of firmware. Typically set as + part of a device tree overlay corresponding to flashed firmware.I don't think DT is the place for describing your runtime loaded firmware layout.
Quoted 1 line
Rob
The way I see it, from the kernel's point of view it's not runtime loaded but a contract with the bootloader. Bootloader sets up hardware in a certain way the kernel doesn't otherwise know so the bootloader needs to tell the kernel how the hardware is set up.
Quoted 4 lines
The fact that the information is supplied through an overlay is accidental -- equivalently the bootloader that sets up the firmware could adjust the device tree like we do in other situations, but in this case an overlay is an easier implementation method.
I think the key bit of information to know here is that the kernel is not permitted to load this firmware. It's a bootloader early in the boot process that sets this up in a secure context and then needs to convey that information to the kernel.
Perhaps a slightly more idiomatic way to pass this information would be using a reserved memory node? That could span the entirety of the secure carveout (therefore removing the need to query the memory controller for that information) and be identified with a compatible string that would allow custom properties for these various offsets. Yet another way would be to have each of the bootloader and OS regions (manifest, code and data) be their own reserved memory regions. But given that this is one chunk with different regions inside makes that seem excessive.
Quoted 2 lines
Rob, do you have any other ideas how this information could be passed to the kernel if not via DT?
Just update the description summarizing the above removing the overlay aspect as when they are set is more important than how.
Rob
PATCH v2 4/8 arm64: tegra: Add NVDEC on Tegra234
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Add a device tree node for NVDEC on Tegra234.
Booting the firmware requires some information regarding offsets within the firmware binary. These are passed through the device tree, but since the values vary depending on the firmware version, and the firmware itself is not available to the OS, the flasher is expected to provide a device tree overlay with values corresponding to the firmware it is flashing. The overlay then replaces the placeholder values here.
--- arch/arm64/boot/dts/nvidia/tegra234.dtsi | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +27 -0
@@ -586,6 +586,33 @@ vic@15340000 { iommus = <&smmu_niso1 TEGRA234_SID_VIC>; dma-coherent; }; + + nvdec@15480000 { + compatible = "nvidia,tegra234-nvdec"; + reg = <0x15480000 0x00040000>; + clocks = <&bpmp TEGRA234_CLK_NVDEC>, + <&bpmp TEGRA234_CLK_FUSE>, + <&bpmp TEGRA234_CLK_TSEC_PKA>; + clock-names = "nvdec", "fuse", "tsec_pka"; + resets = <&bpmp TEGRA234_RESET_NVDEC>; + reset-names = "nvdec"; + power-domains = <&bpmp TEGRA234_POWER_DOMAIN_NVDEC>; + interconnects = <&mc TEGRA234_MEMORY_CLIENT_NVDECSRD &emc>, + <&mc TEGRA234_MEMORY_CLIENT_NVDECSWR &emc>; + interconnect-names = "dma-mem", "write"; + iommus = <&smmu_niso1 TEGRA234_SID_NVDEC>; + dma-coherent; + + nvidia,memory-controller = <&mc>; + + /* Placeholder values, to be replaced with values from overlay */ + nvidia,bl-manifest-offset = <0>; + nvidia,bl-data-offset = <0>; + nvidia,bl-code-offset = <0>; + nvidia,os-manifest-offset = <0>; + nvidia,os-data-offset = <0>; + nvidia,os-code-offset = <0>; + }; }; gpio: gpio@2200000 {
Signature · 1 line
2.37.0
PATCH v2 5/8 gpu: host1x: Add stream ID register data for NVDEC on Tegra234
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Add entries for NVDEC to the Tegra234 SID table.
--- drivers/gpu/host1x/dev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/host1x/dev.c +12 -0
@@ -225,6 +225,18 @@ static const struct host1x_sid_entry tegra234_sid_table[] = { .offset = 0x34, .limit = 0x34 }, + { +/* NVDEC channel */ + .base = 0x17c8, + .offset = 0x30, + .limit = 0x30, + }, + { +/* NVDEC MMIO */ + .base = 0x1698, + .offset = 0x34, + .limit = 0x34, + }, }; static const struct host1x_info host1x08_info = {
Signature · 1 line
2.37.0
PATCH v2 6/8 drm/tegra: nvdec: Support multiple clocks
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
NVDEC on Tegra234 requires multiple clocks. Add support for that.
--- drivers/gpu/drm/tegra/nvdec.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/tegra/nvdec.c +21 -10
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2015-2021, NVIDIA Corporation. +* Copyright (c) 2015-2022, NVIDIA Corporation. */ #include <linux/clk.h>
@@ -28,6 +28,7 @@ struct nvdec_config {const char *firmware;unsigned int version;bool supports_sid; +bool has_extra_clocks; };struct nvdec {
@@ -37,7 +38,8 @@ struct nvdec {struct tegra_drm_client client;struct host1x_channel *channel;struct device *dev; -struct clk *clk; +struct clk_bulk_data clks[3 ]; +unsigned int num_clks;/* Platform configuration */ const struct nvdec_config *config;
@@ -258,7 +260,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)struct nvdec *nvdec =dev_get_drvdata (dev);int err; - err =clk_prepare_enable (nvdec->clk); + err =clk_bulk_prepare_enable (nvdec->num_clks, nvdec->clks);if (err <0 )return err;
@@ -275,7 +277,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)return 0 ; disable: -clk_disable_unprepare (nvdec->clk); +clk_bulk_disable_unprepare (nvdec->num_clks, nvdec->clks);return err; }
@@ -285,7 +287,7 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev)host1x_channel_stop (nvdec->channel); -clk_disable_unprepare (nvdec->clk); +clk_bulk_disable_unprepare (nvdec->num_clks, nvdec->clks);return 0 ; }
@@ -383,13 +385,22 @@ static int nvdec_probe(struct platform_device *pdev)if (IS_ERR (nvdec->regs))return PTR_ERR (nvdec->regs); - nvdec->clk =devm_clk_get (dev,NULL ); -if (IS_ERR (nvdec->clk)) { -dev_err (&pdev->dev,"failed to get clock\n" ); -return PTR_ERR (nvdec->clk); + nvdec->clks[0 ].id ="nvdec" ; + nvdec->num_clks =1 ; + +if (nvdec->config->has_extra_clocks) { + nvdec->num_clks =3 ; + nvdec->clks[1 ].id ="fuse" ; + nvdec->clks[2 ].id ="tsec_pka" ; + } + + err =devm_clk_bulk_get (dev, nvdec->num_clks, nvdec->clks); +if (err) { +dev_err (&pdev->dev,"failed to get clock(s)\n" ); +return err; } - err =clk_set_rate (nvdec->clk,ULONG_MAX ); + err =clk_set_rate (nvdec->clks[0 ].clk,ULONG_MAX );if (err <0 ) {dev_err (&pdev->dev,"failed to set clock rate\n" );return err;
Signature · 1 line
2.37.0
PATCH v2 7/8 drm/tegra: Add code for booting RISC-V based engines
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Add helper code for booting RISC-V based engines where firmware is located in a carveout.
--- drivers/gpu/drm/tegra/Makefile | 3 +- drivers/gpu/drm/tegra/riscv.c | 106 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/tegra/riscv.h | 30 ++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/tegra/riscv.c create mode 100644 drivers/gpu/drm/tegra/riscv.h
drivers/gpu/drm/tegra/Makefile +2 -1
@@ -24,7 +24,8 @@ tegra-drm-y := \ gr3d.o \ falcon.o \ vic.o \ - nvdec.o + nvdec.o \ + riscv.o tegra-drm-y += trace.o
drivers/gpu/drm/tegra/riscv.c new file +106 -0
106 lines not on this page · raw message
drivers/gpu/drm/tegra/riscv.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2022, NVIDIA Corporation. +*/ + +#ifndef DRM_TEGRA_RISCV_H +#define DRM_TEGRA_RISCV_H + +struct tegra_drm_riscv_descriptor { +u32 manifest_offset; +u32 code_offset; +u32 code_size; +u32 data_offset; +u32 data_size; +}; + +struct tegra_drm_riscv { +/* User initializes */ +struct device *dev; +void __iomem *regs; + +struct tegra_drm_riscv_descriptor bl_desc; +struct tegra_drm_riscv_descriptor os_desc; +}; + +int tegra_drm_riscv_read_descriptors (struct tegra_drm_riscv *riscv); +int tegra_drm_riscv_boot_bootrom (struct tegra_drm_riscv *riscv,phys_addr_t image_address, +u32 gscid,const struct tegra_drm_riscv_descriptor *desc); + +#endif
Signature · 1 line
2.37.0
PATCH v2 8/8 drm/tegra: Add Tegra234 support to NVDEC driver
In reply to Mikko PerttunenFrom: Mikko Perttunen <[email protected]>
Add support for the Tegra234 version of NVDEC to the NVDEC driver. This version sports a RISC-V controller and requires a few additional clocks. After firmware has been loaded, the behavior is, however, backwards compatible.
--- drivers/gpu/drm/tegra/drm.c | 1 + drivers/gpu/drm/tegra/nvdec.c | 140 ++++++++++++++++++++++++++++++---- 2 files changed, 126 insertions(+), 15 deletions(-)
drivers/gpu/drm/tegra/drm.c +1 -0
@@ -1382,6 +1382,7 @@ static const struct of_device_id host1x_drm_subdevs[] = { { .compatible = "nvidia,tegra194-vic", }, { .compatible = "nvidia,tegra194-nvdec", }, { .compatible = "nvidia,tegra234-vic", }, + { .compatible = "nvidia,tegra234-nvdec", }, { /* sentinel */ } };
drivers/gpu/drm/tegra/nvdec.c +125 -15
220 lines not on this page · raw message
Signature · 1 line
2.37.0