Add UFS host controller support for NVIDIA Tegra264
cover Add UFS host controller support for NVIDIA Tegra264
Add UFS host controller support for NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
This series depends on the Tegra264 M-PHY series: the binding example uses include/dt-bindings/phy/nvidia,tegra264-mphy.h, and drivers/ufs/host/Kconfig selects PHY_TEGRA_MPHY. The driver itself has no build dependency on the M-PHY driver; it consumes the generic PHY API.
---
Kartik Rajput (4):
dt-bindings: ufs: Add nvidia,tegra264-ufs
scsi: ufs: Add UIC DEBUGSAVECONFIGTIME attribute and its field masks
scsi: ufs: hisi: Use VS_DEBUGSAVECONFIGTIME instead of a literal address
scsi: ufs: tegra: Add Tegra264 UFS host controller driver
.../bindings/ufs/nvidia,tegra264-ufs.yaml | 124 ++++ drivers/ufs/host/Kconfig | 13 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-hisi.c | 6 +- drivers/ufs/host/ufs-tegra.c | 687 +++++++++++++++++++++ include/ufs/unipro.h | 6 + 6 files changed, 833 insertions(+), 4 deletions(-)
---
base-commit: a9d7ced84989ec05be09b4b8428759ef60450a0f
change-id: 20260909-tegra264-ufs-92edda57c75a
prerequisite-change-id: 20260909-tegra264-mphy-f3edf6fa4321:v1
prerequisite-patch-id: 1c46e1bce9f6106dbabf81e50cd366d3d2da01fc
prerequisite-patch-id: d367971b99f7308cef032b436c054d005b94eded
Best regards,
Signature · 1 line
Kartik Rajput <[email protected]>
PATCH 1/4 dt-bindings: ufs: Add nvidia,tegra264-ufs
Add binding for the UFS host controller on NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
--- .../bindings/ufs/nvidia,tegra264-ufs.yaml | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+)
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +124 -0
@@ -0,0 +1,124 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ufs/nvidia,tegra264-ufs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra264 UFS Host Controller + +maintainers: + - Kartik Rajput <[email protected]> + - Thierry Reding <[email protected]> + +properties: + compatible: + const: nvidia,tegra264-ufs + + reg: + items: + - description: UFS Host Controller registers + - description: UFS auxiliary registers + + reg-names: + items: + - const: ufs + - const: aux + + clocks: + items: + - description: UFS host controller functional clock + - description: UFS host controller divider clock + - description: UFS reference clock (PLLREFUFS output) + - description: UFS device-side reference clock + - description: M-PHY reference clock (UPHY0 PLL4 digital output) + + clock-names: + items: + - const: ufs + - const: div + - const: ref + - const: ref-dev + - const: phy + + resets: + items: + - description: UFS host controller reset + - description: UFS host controller AXI-master reset + - description: UFS host controller low-power sequencer reset + + reset-names: + items: + - const: ufs + - const: axi + - const: lp + + phys: + items: + - description: M-PHY lane 0 transmit + - description: M-PHY lane 0 receive + - description: M-PHY lane 1 transmit + - description: M-PHY lane 1 receive + + phy-names: + items: + - const: mphy-l0-tx + - const: mphy-l0-rx + - const: mphy-l1-tx + - const: mphy-l1-rx + + iommus: + maxItems: 1 + + dma-coherent: true + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - phys + - phy-names + - iommus + - dma-coherent + +allOf: + - $ref: ufs-common.yaml + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/nvidia,tegra264.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/phy/nvidia,tegra264-mphy.h> + #include <dt-bindings/reset/nvidia,tegra264.h> + + ufs@b8d0000 { + compatible = "nvidia,tegra264-ufs"; + reg = <0xb8d0000 0x10000>, + <0xb8e0000 0x8000>; + reg-names = "ufs", "aux"; + interrupts = <GIC_SPI 951 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bpmp TEGRA264_CLK_UFSHC_CG_SYS>, + <&bpmp TEGRA264_CLK_UFSHC_CG_SYS_DIV>, + <&bpmp TEGRA264_CLK_PLLREFUFS_CLKOUT624>, + <&bpmp TEGRA264_CLK_PLLREFUFS_UFSDEV_REFCLKOUT>, + <&bpmp TEGRA264_CLK_UPHY0_PLL4_XDIG>; + clock-names = "ufs", "div", "ref", "ref-dev", "phy"; + resets = <&bpmp TEGRA264_RESET_UFSHC>, + <&bpmp TEGRA264_RESET_UFSHC_AXI_M>, + <&bpmp TEGRA264_RESET_UFSHC_LP_SEQ>; + reset-names = "ufs", "axi", "lp"; + phys = <&mphy TEGRA_MPHY_L0_TX>, + <&mphy TEGRA_MPHY_L0_RX>, + <&mphy TEGRA_MPHY_L1_TX>, + <&mphy TEGRA_MPHY_L1_RX>; + phy-names = "mphy-l0-tx", "mphy-l0-rx", + "mphy-l1-tx", "mphy-l1-rx"; + iommus = <&smmu 0x20>; + dma-coherent; + }; +...
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Missing dependency on header file in DT binding example causes dt_binding_check to fail. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing dependency on header file in DT binding example causes dt_binding_check to fail. --
commit 3569ef54ab3548dc631c5780b8e85a8fb366de60
Author: Kartik Rajput <[email protected]>
dt-bindings: ufs: Add nvidia,tegra264-ufs
This commit adds the device tree binding for the UFS host controller on NVIDIA Tegra264 SoCs. The controller supports UFS 3.1 up to HS-G4B on two data lanes.
Quoted 5 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 96
Quoted 5 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +5
-0+examples: + - | + #include <dt-bindings/clock/nvidia,tegra264.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/phy/nvidia,tegra264-mphy.h>
[Severity: Low]
Does this missing header dependency cause a build failure?
The YAML example includes <dt-bindings/phy/nvidia,tegra264-mphy.h> here in Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml, which does not exist in the source tree and is not added by this patch series.
When running make dt_binding_check, this will cause the tool to fail with a preprocessor error due to the missing header.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs
In reply to Kartik RajputDocumentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 37
Quoted 11 lines · Kartik Rajput
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +11
-0+ clocks: + items: + - description: UFS host controller functional clock + - description: UFS host controller divider clock + - description: UFS reference clock (PLLREFUFS output) + - description: UFS device-side reference clock + - description: M-PHY reference clock (UPHY0 PLL4 digital output) + + clock-names: + items: + - const: ufs
core? Names equal to block name are not really useful
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 41
Quoted 4 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +4
-0+ - const: div + - const: ref + - const: ref-dev + - const: phy
Shouldn't the phy take its reference clock?
Quoted 45 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +45
-0+ + resets: + items: + - description: UFS host controller reset + - description: UFS host controller AXI-master reset + - description: UFS host controller low-power sequencer reset + + reset-names: + items: + - const: ufs + - const: axi + - const: lp + + phys: + items: + - description: M-PHY lane 0 transmit + - description: M-PHY lane 0 receive + - description: M-PHY lane 1 transmit + - description: M-PHY lane 1 receive + + phy-names: + items: + - const: mphy-l0-tx + - const: mphy-l0-rx + - const: mphy-l1-tx + - const: mphy-l1-rx + + iommus: + maxItems: 1 + + dma-coherent: true + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - resets + - reset-names + - phys + - phy-names + - iommus + - dma-coherent +
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 96
Quoted 10 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +10
-0+allOf: + - $ref: ufs-common.yaml + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/nvidia,tegra264.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/phy/nvidia,tegra264-mphy.h>
You need to decouple dependencies. Otherwise how is this supposed to be checked with tools? If applied, you just broke maintainer's tree.
Quoted 1 line
+ #include <
dt-bindings/reset/nvidia,tegra264.h>
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs
Hi Krzysztof,
Thanks for reviewing the patch and apologies for the delayed response.
Quoted 16 lines · Krzysztof Kozlowski
External email: Use caution opening links or attachments
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 37
Quoted 11 lines · Kartik Rajput
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +11
-0+ clocks: + items: + - description: UFS host controller functional clock + - description: UFS host controller divider clock + - description: UFS reference clock (PLLREFUFS output) + - description: UFS device-side reference clock + - description: M-PHY reference clock (UPHY0 PLL4 digital output) + + clock-names: + items: + - const: ufs
Quoted 2 lines
core? Names equal to block name are not really useful
ACK. Will rename it to "core".
Quoted 7 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 41
Quoted 4 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +4
-0+ - const: div + - const: ref + - const: ref-dev + - const: phyShouldn't the phy take its reference clock?
The name is misleading and the description is wrong, I will fix both.
The M-PHY's own reference clock and PLL are already described in the M-PHY node ("tx-ref" and "pll"), this is a different clock, UPHY0 PLL4's digital output, consumed by the host controller.
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +5
-0+allOf: + - $ref: ufs-common.yaml + +unevaluatedProperties: false +
Quoted 10 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml line 96
Quoted 5 lines
Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml new file +5
-0+examples: + - | + #include <dt-bindings/clock/nvidia,tegra264.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/phy/nvidia,tegra264-mphy.h>You need to decouple dependencies. Otherwise how is this supposed to be checked with tools? If applied, you just broke maintainer's tree.
ACK. I will drop the include and use raw cell values in the example:
phys = <&mphy 0>, <&mphy 1>, <&mphy 2>, <&mphy 3>;
Thanks,
Kartik
PATCH 2/4 scsi: ufs: Add UIC DEBUGSAVECONFIGTIME attribute and its field masks
In reply to Kartik RajputAdd the UniPro vendor-specific save-config-time attribute and masks for the two fields within it:
VS_DEBUGSAVECONFIGTIME Save-config-time attribute (0xD0A0) VS_DEBUGSAVECONFIGTIME_TREF Field masks within that attribute, for VS_DEBUGSAVECONFIGTIME_SCT use with FIELD_PREP()
ufs-hisi already writes this attribute by its literal address, so name it in the shared header rather than in the driver. Add it here in preparation for the Tegra264 UFS host controller driver, which also programs the two fields.
--- include/ufs/unipro.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/ufs/unipro.h +6 -0
@@ -6,6 +6,8 @@#ifndef _UNIPRO_H_#define _UNIPRO_H_ +#include <linux/bits.h> +/* * M-TX Configuration Attributes */
@@ -232,8 +234,12 @@#define VS_POWERSTATE 0xD083#define VS_MPHYCFGUPDT 0xD085#define VS_DEBUGOMC 0xD09E +#define VS_DEBUGSAVECONFIGTIME 0xD0A0#define VS_MPHYDISABLE 0xD0C1 +#define VS_DEBUGSAVECONFIGTIME_TREF GENMASK(4, 2) +#define VS_DEBUGSAVECONFIGTIME_SCT GENMASK(1, 0) +#define PA_GRANULARITY_MIN_VAL 1#define PA_GRANULARITY_MAX_VAL 6
Signature · 1 line
2.43.0
PATCH 3/4 scsi: ufs: hisi: Use VS_DEBUGSAVECONFIGTIME instead of a literal address
In reply to Kartik Rajputufs-hisi writes the VS_DebugSaveConfigTime UIC attribute twice by its literal address, with a comment naming it each time. The attribute now has a name in the shared UniPro header, so use it and drop the comments and the redundant (u32) cast.
No functional change.
--- drivers/ufs/host/ufs-hisi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ufs/host/ufs-hisi.c +2 -4
@@ -318,8 +318,7 @@ static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)* Boston platform need to set SaveConfigTime to 0x13, * and change sync length to maximum value */ -/* VS_DebugSaveConfigTime */ -ufshcd_dme_set (hba,UIC_ARG_MIB ((u32 )0xD0A0 ),0x13 ); +ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGSAVECONFIGTIME ),0x13 );/* g1 sync length */ ufshcd_dme_set (hba,UIC_ARG_MIB ((u32 )0x1552 ),0x4f );/* g2 sync length */
@@ -335,8 +334,7 @@ static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)if (hba->dev_quirks &UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME ) {pr_info ("ufs flash device must set VS_DebugSaveConfigTime 0x10\n" ); -/* VS_DebugSaveConfigTime */ -ufshcd_dme_set (hba,UIC_ARG_MIB (0xD0A0 ),0x10 ); +ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGSAVECONFIGTIME ),0x10 );/* sync length */ ufshcd_dme_set (hba,UIC_ARG_MIB (0x1556 ),0x48 ); }
Signature · 1 line
2.43.0
PATCH 4/4 scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Kartik RajputAdd a driver for the UFS host controller found on NVIDIA Tegra264 SoCs. The controller has Tegra-specific auxiliary registers, clocks and resets, and it drives the four M-PHY lane directions exposed by the Tegra264 M-PHY driver.
--- drivers/ufs/host/Kconfig | 13 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-tegra.c | 687 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 701 insertions(+)
drivers/ufs/host/Kconfig +13 -0
@@ -168,3 +168,16 @@ config SCSI_UFS_AMD_VERSAL2 Select this if you have UFS controller on AMD Versal Gen 2 SoC. If unsure, say N. + +config SCSI_UFS_TEGRA + tristate "NVIDIA Tegra264 UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM && (ARCH_TEGRA_264_SOC || COMPILE_TEST) + select PHY_TEGRA_MPHY + help + Enable support for the UFS host controller on NVIDIA Tegra264 + SoCs. The driver relies on the Tegra264 M-PHY driver + (PHY_TEGRA_MPHY) for the two data lanes and implements the + vendor register programming required for HS-mode transitions + and system suspend/resume. + + If unsure, say N.
drivers/ufs/host/Makefile +1 -0
@@ -14,5 +14,6 @@ obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o obj-$(CONFIG_SCSI_UFS_RENESAS) += ufs-renesas.o obj-$(CONFIG_SCSI_UFS_ROCKCHIP) += ufs-rockchip.o obj-$(CONFIG_SCSI_UFS_SPRD) += ufs-sprd.o +obj-$(CONFIG_SCSI_UFS_TEGRA) += ufs-tegra.o ufshcd-dwc.o obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o obj-$(CONFIG_SCSI_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
drivers/ufs/host/ufs-tegra.c new file +687 -0
687 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] Referencing a non-existent Kconfig symbol `PHY_TEGRA_MPHY` in `select`. - [Medium] Unmet…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Referencing a non-existent Kconfig symbol PHY_TEGRA_MPHY in select.
- [Medium] Unmet dependency risk due to unconditionally selecting a potentially architecture-specific symbol in a driver that supports COMPILE_TEST.
- [Medium] Integer truncation of the 5.84 GHz clock rate on 32-bit architectures during COMPILE_TEST.
- [Medium] Hardware PHY teardown sequence incorrectly uses forward setup order instead of reverse.
--
commit ba95657952b3e5dc9efe191a253d2fb49a5a1f66
Author: Kartik Rajput <[email protected]>
Subject: scsi: ufs: tegra: Add Tegra264 UFS host controller driver
This commit adds a new UFS host controller driver for NVIDIA Tegra264 SoCs. It implements Tegra-specific auxiliary registers, clocks, and resets, and drives four M-PHY lane directions.
Quoted 5 lines
drivers/ufs/host/Kconfig +0
-0@@ -168,3 +168,16 @@ config SCSI_UFS_AMD_VERSAL2
[ ... ]
drivers/ufs/host/Kconfig config SCSI_UFS_AMD_VERSAL2 · line 175
Quoted 4 lines
drivers/ufs/host/Kconfig +4
-0+config SCSI_UFS_TEGRA + tristate "NVIDIA Tegra264 UFS controller platform driver" + depends on SCSI_UFSHCD_PLATFORM && (ARCH_TEGRA_264_SOC || COMPILE_TEST) + select PHY_TEGRA_MPHY
[Severity: Medium]
Does the PHY_TEGRA_MPHY symbol exist in the kernel tree? If not, selecting it here will cause silent build failures or leave features disabled.
[Severity: Medium]
Additionally, since this driver supports COMPILE_TEST, does unconditionally selecting an architecture-specific PHY risk triggering unmet dependency warnings on unsupported architectures during cross-compilation?
Quoted 5 lines
drivers/ufs/host/ufs-tegra.c new file +0
-0
[ ... ]
drivers/ufs/host/ufs-tegra.c line 36
Quoted 5 lines
drivers/ufs/host/ufs-tegra.c new file +5
-0+#define UFSHC_AUX_DEV_CTRL 0x14 +#define DEV_CTRL_CLK_EN BIT(0) +#define DEV_CTRL_RESET BIT(1) + +#define UFS_TEGRA_PHY_CLK_HS_RATE_HZ 5840000000UL
[Severity: Medium]
Is this literal too large for a 32-bit unsigned long? The literal requires 33 bits, but when COMPILE_TEST is enabled on 32-bit architectures, this value will be truncated.
[ ... ]
drivers/ufs/host/ufs-tegra.c line 289
Quoted 9 lines
drivers/ufs/host/ufs-tegra.c new file +9
-0+static void ufs_tegra_mphy_exit (struct ufs_hba *hba) +{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); + +phy_exit (ufs->mphy_l0_rx); +phy_exit (ufs->mphy_l0_tx); +phy_exit (ufs->mphy_l1_rx); +phy_exit (ufs->mphy_l1_tx); +}
[Severity: Medium]
Does this exit sequence incorrectly mirror the forward initialization order? Standard resource teardown typically reverses the initialization sequence to prevent state corruption or lockups upon driver unbind or runtime suspend.
[ ... ]
drivers/ufs/host/ufs-tegra.c line 340
Quoted 9 lines
drivers/ufs/host/ufs-tegra.c new file +9
-0+static void ufs_tegra_mphy_power_off (struct ufs_hba *hba) +{ +struct ufs_tegra *ufs =ufshcd_get_variant (hba); + +phy_power_off (ufs->mphy_l0_rx); +phy_power_off (ufs->mphy_l0_tx); +phy_power_off (ufs->mphy_l1_rx); +phy_power_off (ufs->mphy_l1_tx); +}
[Severity: Medium]
Similarly, does this power off sequence execute in exact forward initialization order instead of reverse?
[ ... ]
Quoted 4 lines
drivers/ufs/host/ufs-tegra.c new file +4
-0+static int ufs_tegra_pwr_change_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status, +struct ufs_pa_layer_attr *dev_req_params) +{
[ ... ]
drivers/ufs/host/ufs-tegra.c line 615
Quoted 3 lines
drivers/ufs/host/ufs-tegra.c new file +3
-0+if (dev_req_params->hs_rate ==PA_HS_MODE_A || + dev_req_params->hs_rate ==PA_HS_MODE_B ) { + err =clk_set_rate (ufs->phy_clk,UFS_TEGRA_PHY_CLK_HS_RATE_HZ );
[Severity: Medium]
The clk_set_rate() API takes an unsigned long for the rate. Does passing the 33-bit UFS_TEGRA_PHY_CLK_HS_RATE_HZ literal cause an implicit narrowing conversion and incorrect clock rate configuration on 32-bit systems?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Kartik RajputHello,
drivers/ufs/host/ufs-tegra.c line 9
Quoted 5 lines · Kartik Rajput
drivers/ufs/host/ufs-tegra.c new file +5
-0+#include <linux/bitfield.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dma-mapping.h> +#include <linux/mod_devicetable.h>
Please don't add new instances of includes for <linux/mod_devicetable.h>. Either rely on <linux/platform_device.h> to provide of_device_id (my preferred way), or use <linux/device-id/of.h> if you want full iwyu.
drivers/ufs/host/ufs-tegra.c
Quoted 7 lines
drivers/ufs/host/ufs-tegra.c new file +6
-0+#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/reset.h> +static const struct of_device_id ufs_tegra_of_match[] = { + { .compatible ="nvidia,tegra264-ufs" , },
No trailing comma before a } please
drivers/ufs/host/ufs-tegra.c line 669
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+ {}
{ } please (i.e. a space between the braces)
Review
Quoted 2 lines
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(of, ufs_tegra_of_match);
Best regards
Uwe
Bart Van Assche
reviewerRe: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Quoted 3 lines · Uwe Kleine-König
drivers/ufs/host/ufs-tegra.c line 669
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+ {}{ } please (i.e. a space between the braces)
The preferred style for Linux kernel code is {} (no space).
Bart.
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Quoted 6 lines · Bart Van Assche
Quoted 3 lines · Uwe Kleine-König
drivers/ufs/host/ufs-tegra.c line 669
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+ {}{ } please (i.e. a space between the braces)
The preferred style for Linux kernel code is {} (no space).
Looking at the style in of_device_id arrays in next-20260909:
$ git grep -l of_device_id | xargs -n 1 perl -g -n -e 'print "$1\n" if m/of_device_id\s*[a-zA-Z_0-9]*\[\]\s*=\s*{(?:\s*{[^}]*},\s*({\s*}))/' | sort | uniq -c
1 }
1 {
3 { }
1410 { }
1098 {}and extending to *_device_id:
$ git grep -l device_id | xargs -n 1 perl -g -n -e 'print "$1\n" if m/device_id\s*[a-zA-Z_0-9]*\[\]\s*=\s*{(?:\s*{[^}]*},\s*({\s*}))/' | sort | uniq -c
2 }
2 {
7 { }
2492 { }
1304 {}So { } is slightly more usual and also better matches the spaces used in
{ .compatible = "nvidia,tegra264-ufs", },(but I agree, the latter might be subjective).
What makes you claim that {} is preferred?
Best regards
Uwe
Bart Van Assche
reviewerRe: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Quoted 1 line · Uwe Kleine-König
What makes you claim that {} is preferred?
There are many more occurrences of " = {};" (about 7000) in the Linux kernel than of " = { };" (about 1500). Additionally, clang-format changes any occurrence of " = { };" into " = {};".
Thanks,
Bart.
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Hello Bart,
Quoted 6 lines · Bart Van Assche
Quoted 1 line · Uwe Kleine-König
What makes you claim that {} is preferred?
There are many more occurrences of " = {};" (about 7000) in the Linux kernel than of " = { };" (about 1500). Additionally, clang-format changes any occurrence of " = { };" into " = {};".
clang-format does this due to
SpaceInEmptyParentheses: false
in .clang-format which I claim we have due to prefering no space between () for function calls. It seems only newer clang-format (starting with version 22) can configure that individually using SpaceInEmptyBraces.
And IMHO my statistic is more relevant because we're not talking about = {}; or = { };.
But I guess this is all subjective. Having said that I feel offended when seeing "= {};" and would ask to add a space there, too, when spotting that during a review.
Best regards
Uwe
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Hi Uwe, Bart,
Thanks for reviewing the patch.
Quoted 21 lines · Uwe Kleine-König
Hello Bart,
Quoted 6 lines · Bart Van Assche
Quoted 1 line · Uwe Kleine-König
What makes you claim that {} is preferred?
There are many more occurrences of " = {};" (about 7000) in the Linux kernel than of " = { };" (about 1500). Additionally, clang-format changes any occurrence of " = { };" into " = {};".
clang-format does this due to
SpaceInEmptyParentheses: false
in .clang-format which I claim we have due to prefering no space between () for function calls. It seems only newer clang-format (starting with version 22) can configure that individually using SpaceInEmptyBraces.
And IMHO my statistic is more relevant because we're not talking about
= {};or= { };.
Quoted 6 lines
But I guess this is all subjective. Having said that I feel offended when seeing "= {};" and would ask to add a space there, too, when spotting that during a review.
Best regards
Uwe
ACK, I will use {} instead of { }. Or if you prefer, I can use { /* sentinel */ }.
Thanks,
Kartik
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Quoted 26 lines · Kartik Rajput
Hi Uwe, Bart,
Thanks for reviewing the patch.
Quoted 21 lines · Uwe Kleine-König
Hello Bart,
Quoted 6 lines · Bart Van Assche
Quoted 1 line · Uwe Kleine-König
What makes you claim that {} is preferred?
There are many more occurrences of " = {};" (about 7000) in the Linux kernel than of " = { };" (about 1500). Additionally, clang-format changes any occurrence of " = { };" into " = {};".
clang-format does this due to
SpaceInEmptyParentheses: false
in .clang-format which I claim we have due to prefering no space between () for function calls. It seems only newer clang-format (starting with version 22) can configure that individually using SpaceInEmptyBraces.
And IMHO my statistic is more relevant because we're not talking about
= {};or= { };.
Quoted 9 lines
Quoted 6 lines
But I guess this is all subjective. Having said that I feel offended when seeing "= {};" and would ask to add a space there, too, when spotting that during a review.
Best regards
UweACK, I will use
{}instead of{ }. Or if you prefer, I can use{ /* sentinel */ }.
Apologies, { } instead of {}
Thanks,
Kartik
Re: [PATCH 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
In reply to Uwe Kleine-KönigHi Uwe,
Quoted 14 lines · Uwe Kleine-König
Hello,
drivers/ufs/host/ufs-tegra.c line 9
Quoted 5 lines · Kartik Rajput
drivers/ufs/host/ufs-tegra.c new file +5
-0+#include <linux/bitfield.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dma-mapping.h> +#include <linux/mod_devicetable.h> Please don't add new instances of includes for <
linux/mod_devicetable.h>. Either rely on <linux/platform_device.h> to provideof_device_id(my preferred way), or use <linux/device-id/of.h> if you want full iwyu.
ACK. I will use <linux/platform_device.h>.
Quoted 10 lines
drivers/ufs/host/ufs-tegra.c
Quoted 7 lines
drivers/ufs/host/ufs-tegra.c new file +6
-0+#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/reset.h> +static const struct of_device_id ufs_tegra_of_match[] = { + { .compatible ="nvidia,tegra264-ufs" , },No trailing comma before a } please
ACK.
Quoted 4 lines
drivers/ufs/host/ufs-tegra.c line 669
Quoted 1 line
drivers/ufs/host/ufs-tegra.c new file +1
-0+ {}{ } please (i.e. a space between the braces)
ACK.
Thanks,
Kartik