memory: Cleanup, improve and compile test memory drivers
Subsystems (9)
Krzysztof Kozlowski
maintainercover memory: Cleanup, improve and compile test memory drivers
Dear All,
The drivers/memory directory contains generic code (of_memory.c) and a bunch of drivers. Changes to generic code were coming usually through different trees with the driver code.
Over last days, memory drivers grew in numbers but not necessarily in quality. They lacked compile testing and code cleanup. Also lacked maintainer.
I would be happy to take care about this part.
If there are no objections, the patches could go either to Linus or to arm-soc (most of drivers are ARM specific).
Driver-specific changes in the patchset were only compile-tested. Tests are welcome. The generic code was tested on ARMv7 Exynos based boards with a exynos5422-dmc memory controller driver.
Best regards,
Krzysztof
Krzysztof Kozlowski (23):
memory: omap-gpmc: Remove unneeded asm/mach-types.h inclusion
memory: omap-gpmc: Remove unused file-scope phys_base and mem_size
memory: omap-gpmc: Include <linux/sizes.h> for SZ_16M
memory: ti-aemif: Rename SS to SSTROBE to avoid name conflicts
memory: Enable compile testing for most of the drivers
memory: of: Remove unused headers
memory: of: Remove __func__ in device related messages
memory: of: Correct indentation
memory: of: Remove unneeded extern from function declarations
memory: emif-asm-offsets: Add GPLv2 SPDX license header
memory: emif: Put constant in comparison on the right side
memory: emif: Fix whitespace coding style violations
memory: emif: Silence platform_get_irq() error in driver
memory: ti-emif-pm: Fix cast to iomem pointer
memory: renesas-rpc-if: Simplify with PTR_ERR_OR_ZERO
memory: brcmstb_dpfe: Constify the contents of string
memory: brcmstb_dpfe: Remove unneeded braces
memory: mtk-smi: Add argument to function definition
memory: omap-gpmc: Enclose macro statements in do-while
memory: omap-gpmc: Fix whitespace issue
memory: pl172: Add GPLv2 SPDX license header
memory: tegra: tegra210-emc: Fix indentation
MAINTAINERS: Add Krzysztof Kozlowski as maintainer of memory
controllers
MAINTAINERS | 7 +++++ drivers/memory/Kconfig | 31 +++++++++++-------- drivers/memory/brcmstb_dpfe.c | 5 ++- drivers/memory/emif-asm-offsets.c | 10 +----- drivers/memory/emif.c | 23 ++++++-------- drivers/memory/mtk-smi.c | 2 +- drivers/memory/of_memory.c | 28 ++++++++--------- drivers/memory/of_memory.h | 21 +++++++------ drivers/memory/omap-gpmc.c | 21 ++++++------- drivers/memory/pl172.c | 5 +-- drivers/memory/renesas-rpc-if.c | 4 +-- drivers/memory/tegra/tegra210-emc-cc-r21021.c | 2 +- drivers/memory/ti-aemif.c | 16 +++++----- drivers/memory/ti-emif-pm.c | 2 +- 14 files changed, 84 insertions(+), 93 deletions(-)
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 1/23 memory: omap-gpmc: Remove unneeded asm/mach-types.h inclusion
The driver does not use macros from asm/mach-types.h (neither MACH_TYPE nor machine_is_xxx()). Removal of this include allows compile testing on non-ARM architectures.
---
Please kindly test.
--- drivers/memory/omap-gpmc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/memory/omap-gpmc.c +0 -2
@@ -32,8 +32,6 @@#include <linux/platform_data/mtd-nand-omap2.h> -#include <asm/mach-types.h> -#define DEVICE_NAME "omap-gpmc"/* GPMC register offsets */
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 2/23 memory: omap-gpmc: Remove unused file-scope phys_base and mem_size
In reply to Krzysztof KozlowskiThe file-scope variables phys_base and mem_size are assigned in gpmc_probe() but never read.
---
Please kindly test.
--- drivers/memory/omap-gpmc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/memory/omap-gpmc.c +0 -4
@@ -242,7 +242,6 @@ static DEFINE_SPINLOCK(gpmc_mem_lock);/* Define chip-selects as reserved by default until probe completes */ static unsigned int gpmc_cs_num =GPMC_CS_NUM ;static unsigned int gpmc_nr_waitpins; -static resource_size_t phys_base, mem_size;static unsigned gpmc_capability;static void __iomem *gpmc_base;
@@ -2357,9 +2356,6 @@ static int gpmc_probe(struct platform_device *pdev)if (res ==NULL )return -ENOENT ; - phys_base = res->start; - mem_size =resource_size (res); - gpmc_base =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (gpmc_base))return PTR_ERR (gpmc_base);
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 3/23 memory: omap-gpmc: Include <linux/sizes.h> for SZ_16M
In reply to Krzysztof KozlowskiThe driver uses SZ_16M which is defined in include/linux/sizes.h. On ARM it was pulled by other headers but its inclusion is necessary for compile testing on other architectures.
--- drivers/memory/omap-gpmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/memory/omap-gpmc.c +1 -0
@@ -29,6 +29,7 @@#include <linux/of_platform.h> #include <linux/omap-gpmc.h> #include <linux/pm_runtime.h> +#include <linux/sizes.h> #include <linux/platform_data/mtd-nand-omap2.h>
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 4/23 memory: ti-aemif: Rename SS to SSTROBE to avoid name conflicts
In reply to Krzysztof KozlowskiSS conflicts with compile test build on i386:
../drivers/memory/ti-aemif.c:40:0: warning: "SS" redefined
In file included from ../arch/x86/include/uapi/asm/ptrace.h:6:0,
from ../arch/x86/include/asm/ptrace.h:7,
from ../arch/x86/include/asm/math_emu.h:5,
from ../arch/x86/include/asm/processor.h:13,
from ../include/linux/mutex.h:19,
from ../include/linux/notifier.h:14,
from ../include/linux/clk.h:14,
from ../drivers/memory/ti-aemif.c:12:
../arch/x86/include/uapi/asm/ptrace-abi.h:23:0: note: this is the location of the previous definition
#define SS 16Use more descriptive name (SSTROBE) to avoid the conflict.
---
Please kindly test.
--- drivers/memory/ti-aemif.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/memory/ti-aemif.c +8 -8
@@ -27,7 +27,7 @@#define WSTROBE_SHIFT 20#define WSETUP_SHIFT 26#define EW_SHIFT 30 -#define SS_SHIFT 31 +#define SSTROBE_SHIFT 31#define TA (x) ((x) << TA_SHIFT)#define RHOLD (x) ((x) << RHOLD_SHIFT)
@@ -37,7 +37,7 @@#define WSTROBE (x) ((x) << WSTROBE_SHIFT)#define WSETUP (x) ((x) << WSETUP_SHIFT)#define EW (x) ((x) << EW_SHIFT) -#define SS (x) ((x) << SS_SHIFT) +#define SSTROBE (x) ((x) << SSTROBE_SHIFT)#define ASIZE_MAX 0x1#define TA_MAX 0x3
@@ -48,7 +48,7 @@#define WSTROBE_MAX 0x3f#define WSETUP_MAX 0xf#define EW_MAX 0x1 -#define SS_MAX 0x1 +#define SSTROBE_MAX 0x1#define NUM_CS 4#define TA_VAL (x) (((x) & TA(TA_MAX)) >> TA_SHIFT)
@@ -59,7 +59,7 @@#define WSTROBE_VAL (x) (((x) & WSTROBE(WSTROBE_MAX)) >> WSTROBE_SHIFT)#define WSETUP_VAL (x) (((x) & WSETUP(WSETUP_MAX)) >> WSETUP_SHIFT)#define EW_VAL (x) (((x) & EW(EW_MAX)) >> EW_SHIFT) -#define SS_VAL (x) (((x) & SS(SS_MAX)) >> SS_SHIFT) +#define SSTROBE_VAL (x) (((x) & SSTROBE(SSTROBE_MAX)) >> SSTROBE_SHIFT)#define NRCSR_OFFSET 0x00#define AWCCR_OFFSET 0x04
@@ -67,7 +67,7 @@#define ACR_ASIZE_MASK 0x3#define ACR_EW_MASK BIT(30) -#define ACR_SS_MASK BIT(31) +#define ACR_SSTROBE_MASK BIT(31)#define ASIZE_16BIT 1#define CONFIG_MASK (TA(TA_MAX) | \
@@ -77,7 +77,7 @@WHOLD (WHOLD_MAX ) | \WSTROBE (WSTROBE_MAX ) | \WSETUP (WSETUP_MAX ) | \ -EW (EW_MAX ) |SS (SS_MAX ) | \ +EW (EW_MAX ) |SSTROBE (SSTROBE_MAX ) | \ ASIZE_MAX)/**
@@ -204,7 +204,7 @@ static int aemif_config_abus(struct platform_device *pdev, int csnum)if (data->enable_ew) set |=ACR_EW_MASK ;if (data->enable_ss) - set |=ACR_SS_MASK ; + set |=ACR_SSTROBE_MASK ; val =readl (aemif->base + offset); val &= ~CONFIG_MASK ;
@@ -246,7 +246,7 @@ static void aemif_get_hw_params(struct platform_device *pdev, int csnum) data->wstrobe =aemif_cycles_to_nsec (WSTROBE_VAL (val), clk_rate); data->wsetup =aemif_cycles_to_nsec (WSETUP_VAL (val), clk_rate); data->enable_ew =EW_VAL (val); - data->enable_ss =SS_VAL (val); + data->enable_ss =SSTROBE_VAL (val); data->asize = val &ASIZE_MAX ; }
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 5/23 memory: Enable compile testing for most of the drivers
In reply to Krzysztof KozlowskiMost of the memory controller drivers do not depend on architecture specific code so can be compile tested to increase build coverage.
--- drivers/memory/Kconfig | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/memory/Kconfig +18 -13
@@ -27,7 +27,8 @@ config ARM_PL172_MPMC config ATMEL_SDRAMC bool "Atmel (Multi-port DDR-)SDRAM Controller" default y - depends on ARCH_AT91 && OF + depends on ARCH_AT91 || COMPILE_TEST + depends on OF help This driver is for Atmel SDRAM Controller or Atmel Multi-port DDR-SDRAM Controller available on Atmel AT91SAM9 and SAMA5 SoCs.
@@ -37,7 +38,8 @@ config ATMEL_SDRAMC config ATMEL_EBI bool "Atmel EBI driver" default y - depends on ARCH_AT91 && OF + depends on ARCH_AT91 || COMPILE_TEST + depends on OF select MFD_SYSCON select MFD_ATMEL_SMC help
@@ -59,7 +61,8 @@ config BT1_L2_CTL config TI_AEMIF tristate "Texas Instruments AEMIF driver" - depends on (ARCH_DAVINCI || ARCH_KEYSTONE) && OF + depends on ARCH_DAVINCI || ARCH_KEYSTONE || COMPILE_TEST + depends on OF help This driver is for the AEMIF module available in Texas Instruments SoCs. AEMIF stands for Asynchronous External Memory Interface and
@@ -70,7 +73,7 @@ config TI_AEMIF config TI_EMIF tristate "Texas Instruments EMIF driver" - depends on ARCH_OMAP2PLUS + depends on ARCH_OMAP2PLUS || COMPILE_TEST select DDR help This driver is for the EMIF module available in Texas Instruments
@@ -82,7 +85,7 @@ config TI_EMIF temperature changes config OMAP_GPMC - bool + bool "Texas Instruments OMAP SoC GPMC driver" if COMPILE_TEST select GPIOLIB help This driver is for the General Purpose Memory Controller (GPMC)
@@ -106,7 +109,8 @@ config OMAP_GPMC_DEBUG config TI_EMIF_SRAM tristate "Texas Instruments EMIF SRAM driver" - depends on (SOC_AM33XX || SOC_AM43XX) && SRAM + depends on SOC_AM33XX || SOC_AM43XX || (ARM && COMPILE_TEST) + depends on SRAM help This driver is for the EMIF module available on Texas Instruments AM33XX and AM43XX SoCs and is required for PM. Certain parts of
@@ -117,7 +121,8 @@ config TI_EMIF_SRAM config MVEBU_DEVBUS bool "Marvell EBU Device Bus Controller" default y - depends on PLAT_ORION && OF + depends on PLAT_ORION || COMPILE_TEST + depends on OF help This driver is for the Device Bus controller available in some Marvell EBU SoCs such as Discovery (mv78xx0), Orion (88f5xxx) and
@@ -126,7 +131,7 @@ config MVEBU_DEVBUS config FSL_CORENET_CF tristate "Freescale CoreNet Error Reporting" - depends on FSL_SOC_BOOKE + depends on FSL_SOC_BOOKE || COMPILE_TEST help Say Y for reporting of errors from the Freescale CoreNet Coherency Fabric. Errors reported include accesses to
@@ -135,7 +140,7 @@ config FSL_CORENET_CF represents a coherency violation. config FSL_IFC - bool + bool "Freescale IFC driver" if COMPILE_TEST depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST depends on HAS_IOMEM
@@ -150,7 +155,7 @@ config JZ4780_NEMC memory devices such as NAND and SRAM. config MTK_SMI - bool + bool "Mediatek SoC Memory Controller driver" if COMPILE_TEST depends on ARCH_MEDIATEK || COMPILE_TEST help This driver is for the Memory Controller module in MediaTek SoCs,
@@ -159,7 +164,7 @@ config MTK_SMI config DA8XX_DDRCTL bool "Texas Instruments da8xx DDR2/mDDR driver" - depends on ARCH_DAVINCI_DA8XX + depends on ARCH_DAVINCI_DA8XX || COMPILE_TEST help This driver is for the DDR2/mDDR Memory Controller present on Texas Instruments da8xx SoCs. It's used to tweak various memory
@@ -169,14 +174,14 @@ config PL353_SMC tristate "ARM PL35X Static Memory Controller(SMC) driver" default y depends on ARM - depends on ARM_AMBA + depends on ARM_AMBA || COMPILE_TEST help This driver is for the ARM PL351/PL353 Static Memory Controller(SMC) module. config RENESAS_RPCIF tristate "Renesas RPC-IF driver" - depends on ARCH_RENESAS + depends on ARCH_RENESAS || COMPILE_TEST select REGMAP_MMIO help This supports Renesas R-Car Gen3 RPC-IF which provides either SPI
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 6/23 memory: of: Remove unused headers
In reply to Krzysztof KozlowskiThe of_memory.c does not use platform_device nor linked list.
--- drivers/memory/of_memory.c | 2 -- 1 file changed, 2 deletions(-)
drivers/memory/of_memory.c +0 -2
@@ -7,8 +7,6 @@*/ #include <linux/device.h> -#include <linux/platform_device.h> -#include <linux/list.h> #include <linux/of.h> #include <linux/gfp.h> #include <linux/export.h>
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 7/23 memory: of: Remove __func__ in device related messages
In reply to Krzysztof KozlowskiMessages printed by generic of_memory code will still be using device context so their location/meaning will be known. Printing __func__ is not needed.
--- drivers/memory/of_memory.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/memory/of_memory.c +8 -8
@@ -4,6 +4,7 @@* * Copyright (C) 2012 Texas Instruments, Inc. * Copyright (C) 2019 Samsung Electronics Co., Ltd. +* Copyright (C) 2020 Krzysztof Kozlowski <[email protected]> */ #include <linux/device.h>
@@ -54,7 +55,7 @@ const struct lpddr2_min_tck *of_get_min_tck(struct device_node *np,return min; default_min_tck: -dev_warn (dev,"%s: using default min-tck values\n" , __func__); +dev_warn (dev,"Using default min-tck values\n" );return &lpddr2_jedec_min_tck; }EXPORT_SYMBOL (of_get_min_tck);
@@ -114,7 +115,7 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr, tim_compat ="jedec,lpddr2-timings" ;break ;default : -dev_warn (dev,"%s: un-supported memory type\n" , __func__); +dev_warn (dev,"Unsupported memory type\n" ); }for_each_child_of_node (np_ddr, np_tim)
@@ -143,7 +144,7 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr,return timings; default_timings: -dev_warn (dev,"%s: using default timings\n" , __func__); +dev_warn (dev,"Using default memory timings\n" ); *nr_frequencies =ARRAY_SIZE (lpddr2_jedec_timings);return lpddr2_jedec_timings; }
@@ -191,8 +192,7 @@ const struct lpddr3_min_tck *of_lpddr3_get_min_tck(struct device_node *np, ret |=of_property_read_u32 (np,"tMRD-min-tck" , &min->tMRD);if (ret) { -dev_warn (dev,"%s: errors while parsing min-tck values\n" , - __func__); +dev_warn (dev,"Errors while parsing min-tck values\n" );devm_kfree (dev, min); goto default_min_tck; }
@@ -200,7 +200,7 @@ const struct lpddr3_min_tck *of_lpddr3_get_min_tck(struct device_node *np,return min; default_min_tck: -dev_warn (dev,"%s: using default min-tck values\n" , __func__); +dev_warn (dev,"Using default min-tck values\n" );return NULL ; }EXPORT_SYMBOL (of_lpddr3_get_min_tck);
@@ -262,7 +262,7 @@ const struct lpddr3_timings tim_compat ="jedec,lpddr3-timings" ;break ;default : -dev_warn (dev,"%s: un-supported memory type\n" , __func__); +dev_warn (dev,"Unsupported memory type\n" ); }for_each_child_of_node (np_ddr, np_tim)
@@ -291,7 +291,7 @@ const struct lpddr3_timingsreturn timings; default_timings: -dev_warn (dev,"%s: failed to get timings\n" , __func__); +dev_warn (dev,"Failed to get timings\n" ); *nr_frequencies =0 ;return NULL ; }
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 8/23 memory: of: Correct indentation
In reply to Krzysztof KozlowskiCorrect indentation to match open parenthesis.
--- drivers/memory/of_memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/memory/of_memory.c +6 -4
@@ -26,7 +26,7 @@* default min timings provided by JEDEC. */ const struct lpddr2_min_tck *of_get_min_tck (struct device_node *np, -struct device *dev) +struct device *dev) {int ret =0 ;struct lpddr2_min_tck *min;
@@ -61,7 +61,7 @@ const struct lpddr2_min_tck *of_get_min_tck(struct device_node *np,EXPORT_SYMBOL (of_get_min_tck);static int of_do_get_timings (struct device_node *np, -struct lpddr2_timings *tim) +struct lpddr2_timings *tim) {int ret;
@@ -83,7 +83,7 @@ static int of_do_get_timings(struct device_node *np, ret |=of_property_read_u32 (np,"tZQinit" , &tim->tZQinit); ret |=of_property_read_u32 (np,"tRAS-max-ns" , &tim->tRAS_max_ns); ret |=of_property_read_u32 (np,"tDQSCK-max-derated" , - &tim->tDQSCK_max_derated); + &tim->tDQSCK_max_derated);return ret; }
@@ -102,7 +102,9 @@ static int of_do_get_timings(struct device_node *np,* while populating, returns default timings provided by JEDEC. */ const struct lpddr2_timings *of_get_ddr_timings (struct device_node *np_ddr, -struct device *dev,u32 device_type,u32 *nr_frequencies) +struct device *dev, +u32 device_type, +u32 *nr_frequencies) {struct lpddr2_timings *timings =NULL ;u32 arr_sz =0 , i =0 ;
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 9/23 memory: of: Remove unneeded extern from function declarations
In reply to Krzysztof KozlowskiFunction declarations in headers do not need to come with extern keyword. Remove them to make the declaration slightly shorter.
--- drivers/memory/of_memory.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/memory/of_memory.h +11 -10
@@ -3,22 +3,23 @@* OpenFirmware helpers for memory drivers * * Copyright (C) 2012 Texas Instruments, Inc. +* Copyright (C) 2020 Krzysztof Kozlowski <[email protected]> */ #ifndef __LINUX_MEMORY_OF_REG_H#define __LINUX_MEMORY_OF_REG_H#if defined(CONFIG_OF ) && defined(CONFIG_DDR ) -extern const struct lpddr2_min_tck *of_get_min_tck (struct device_node *np, -struct device *dev); -extern const struct lpddr2_timings - *of_get_ddr_timings (struct device_node *np_ddr,struct device *dev, -u32 device_type,u32 *nr_frequencies); -extern const struct lpddr3_min_tck - *of_lpddr3_get_min_tck (struct device_node *np,struct device *dev); -extern const struct lpddr3_timings - *of_lpddr3_get_ddr_timings (struct device_node *np_ddr, -struct device *dev,u32 device_type,u32 *nr_frequencies); +const struct lpddr2_min_tck *of_get_min_tck (struct device_node *np, +struct device *dev); +const struct lpddr2_timings *of_get_ddr_timings (struct device_node *np_ddr, +struct device *dev, +u32 device_type,u32 *nr_frequencies); +const struct lpddr3_min_tck *of_lpddr3_get_min_tck (struct device_node *np, +struct device *dev); +const struct lpddr3_timings * +of_lpddr3_get_ddr_timings (struct device_node *np_ddr, +struct device *dev,u32 device_type,u32 *nr_frequencies);#else static inline const struct lpddr2_min_tck *of_get_min_tck (struct device_node *np,struct device *dev)
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 10/23 memory: emif-asm-offsets: Add GPLv2 SPDX license header
In reply to Krzysztof KozlowskiAdd GPLv2 license header and remove GPL boiler plate text.
--- drivers/memory/emif-asm-offsets.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/memory/emif-asm-offsets.c +1 -9
@@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * TI AM33XX EMIF PM Assembly Offsets * * Copyright (C) 2016-2017 Texas Instruments Inc. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation version 2. -* -* This program is distributed "as is" WITHOUT ANY WARRANTY of any -* kind, whether express or implied; without even the implied warranty -* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #include <linux/ti-emif-sram.h>
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 11/23 memory: emif: Put constant in comparison on the right side
In reply to Krzysztof KozlowskiFixes checkpatch warning:
WARNING: Comparisons should place the constant on the right side of the test
--- drivers/memory/emif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/emif.c +1 -1
@@ -282,7 +282,7 @@ static void set_lpmode(struct emif_data *emif, u8 lpmode)* the EMIF_PWR_MGMT_CTRL[10:8] REG_LP_MODE bit field to 0x4. */ if ((emif->plat_data->ip_rev ==EMIF_4D ) && - (EMIF_LP_MODE_PWR_DN == lpmode)) { + (lpmode ==EMIF_LP_MODE_PWR_DN )) {WARN_ONCE (1 ,"REG_LP_MODE = LP_MODE_PWR_DN(4) is prohibited by" "erratum i743 switch to LP_MODE_SELF_REFRESH(2)\n" );
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 12/23 memory: emif: Fix whitespace coding style violations
In reply to Krzysztof KozlowskiMake the code and printed messages slightly more readable. Fixes checkpatch warnings:
WARNING: quoted string split across lines
ERROR: space prohibited before that ',' (ctx:WxW)
--- drivers/memory/emif.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/memory/emif.c +7 -9
@@ -284,8 +284,7 @@ static void set_lpmode(struct emif_data *emif, u8 lpmode)if ((emif->plat_data->ip_rev ==EMIF_4D ) && (lpmode ==EMIF_LP_MODE_PWR_DN )) {WARN_ONCE (1 , -"REG_LP_MODE = LP_MODE_PWR_DN(4) is prohibited by" -"erratum i743 switch to LP_MODE_SELF_REFRESH(2)\n" ); +"REG_LP_MODE = LP_MODE_PWR_DN(4) is prohibited by erratum i743 switch to LP_MODE_SELF_REFRESH(2)\n" );/* rollback LP_MODE to Self-refresh mode */ lpmode =EMIF_LP_MODE_SELF_REFRESH ; }
@@ -714,7 +713,7 @@ static u32 get_ext_phy_ctrl_2_intelliphy_4d5(void)u32 fifo_we_slave_ratio; fifo_we_slave_ratio =DIV_ROUND_CLOSEST ( -EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck); +EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck);return fifo_we_slave_ratio | fifo_we_slave_ratio <<11 | fifo_we_slave_ratio <<22 ;
@@ -725,7 +724,7 @@ static u32 get_ext_phy_ctrl_3_intelliphy_4d5(void)u32 fifo_we_slave_ratio; fifo_we_slave_ratio =DIV_ROUND_CLOSEST ( -EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck); +EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck);return fifo_we_slave_ratio >>10 | fifo_we_slave_ratio <<1 | fifo_we_slave_ratio <<12 | fifo_we_slave_ratio <<23 ;
@@ -736,7 +735,7 @@ static u32 get_ext_phy_ctrl_4_intelliphy_4d5(void)u32 fifo_we_slave_ratio; fifo_we_slave_ratio =DIV_ROUND_CLOSEST ( -EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck); +EMIF_INTELLI_PHY_DQS_GATE_OPENING_DELAY_PS *256 , t_ck);return fifo_we_slave_ratio >>9 | fifo_we_slave_ratio <<2 | fifo_we_slave_ratio <<13 ;
@@ -975,8 +974,7 @@ static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) EMIF_CUSTOM_CONFIG_EXTENDED_TEMP_PART)) {if (emif->temperature_level >=SDRAM_TEMP_HIGH_DERATE_REFRESH ) {dev_err (emif->dev, -"%s:NOT Extended temperature capable memory." -"Converting MR4=0x%02x as shutdown event\n" , +"%s:NOT Extended temperature capable memory. Converting MR4=0x%02x as shutdown event\n" , __func__, emif->temperature_level);/* * Temperature far too high - do kernel_power_off()
@@ -1318,9 +1316,9 @@ static void __init_or_module of_get_ddr_info(struct device_node *np_emif,if (of_find_property (np_emif,"cal-resistor-per-cs" , &len)) dev_info->cal_resistors_per_cs = true; -if (of_device_is_compatible (np_ddr ,"jedec,lpddr2-s4" )) +if (of_device_is_compatible (np_ddr,"jedec,lpddr2-s4" )) dev_info->type =DDR_TYPE_LPDDR2_S4 ; -else if (of_device_is_compatible (np_ddr ,"jedec,lpddr2-s2" )) +else if (of_device_is_compatible (np_ddr,"jedec,lpddr2-s2" )) dev_info->type =DDR_TYPE_LPDDR2_S2 ;of_property_read_u32 (np_ddr,"density" , &density);
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 13/23 memory: emif: Silence platform_get_irq() error in driver
In reply to Krzysztof KozlowskiThe platform_get_irq() already prints error message so there is no need to do it again in the driver.
--- drivers/memory/emif.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/memory/emif.c +1 -4
@@ -1561,11 +1561,8 @@ static int __init_or_module emif_probe(struct platform_device *pdev) goto error; irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -dev_err (emif->dev,"%s: error getting IRQ resource - %d\n" , - __func__, irq); +if (irq <0 ) goto error; - }emif_onetime_settings (emif);emif_debugfs_init (emif);
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 14/23 memory: ti-emif-pm: Fix cast to iomem pointer
In reply to Krzysztof KozlowskiCast pointer to iomem memory properly to fix sparse warning:
drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef] __iomem *addr
drivers/memory/ti-emif-pm.c:251:38: got void *
--- drivers/memory/ti-emif-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/ti-emif-pm.c +1 -1
@@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);static int ti_emif_resume (struct device *dev) {unsigned long tmp = -__raw_readl ((void *)emif_instance->ti_emif_sram_virt); +__raw_readl ((void __iomem *)emif_instance->ti_emif_sram_virt);/* * Check to see if what we are copying is already present in the
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 14/23] memory: ti-emif-pm: Fix cast to iomem pointer
Quoted 17 lines · Krzysztof Kozlowski
Cast pointer to iomem memory properly to fix sparse warning:
drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef]__iomem*addr
drivers/memory/ti-emif-pm.c:251:38: got void *Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/memory/ti-emif-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/memory/ti-emif-pm.c +0
-0
drivers/memory/ti-emif-pm.c MODULE_DEVICE_TABLE(of, ti_emif_of_match); · line 252
Quoted 6 lines
drivers/memory/ti-emif-pm.c +1
-1@@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);static int ti_emif_resume (struct device *dev) {unsigned long tmp = -__raw_readl ((void *)emif_instance->ti_emif_sram_virt); +__raw_readl ((void __iomem *)emif_instance->ti_emif_sram_virt);
Maybe this shouldn't even be __raw_readl(), but instead READ_ONCE()?
The other accesses in this file don't use MMIO wrappers either but just treat it as a pointer. The effect would be the same though.
Arnd
Krzysztof Kozlowski
maintainerRe: [PATCH 14/23] memory: ti-emif-pm: Fix cast to iomem pointer
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Krzysztof Kozlowski
Cast pointer to iomem memory properly to fix sparse warning:
drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef]__iomem*addr
drivers/memory/ti-emif-pm.c:251:38: got void *Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/memory/ti-emif-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
drivers/memory/ti-emif-pm.c MODULE_DEVICE_TABLE(of, ti_emif_of_match); · line 252
Quoted 11 lines
drivers/memory/ti-emif-pm.c +1
-1@@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);static int ti_emif_resume (struct device *dev) {unsigned long tmp = -__raw_readl ((void *)emif_instance->ti_emif_sram_virt); +__raw_readl ((void __iomem *)emif_instance->ti_emif_sram_virt);Maybe this shouldn't even be
__raw_readl(), but insteadREAD_ONCE()?
Won't readl() be enough? Indeed it looks problematic.
Quoted 3 lines
The other accesses in this file don't use MMIO wrappers either but just treat it as a pointer. The effect would be the same though.
I think all the reads and writes are with readl() and writel().
Best regards,
Krzysztof
Re: [PATCH 14/23] memory: ti-emif-pm: Fix cast to iomem pointer
Quoted 28 lines · Krzysztof Kozlowski
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Krzysztof Kozlowski
Cast pointer to iomem memory properly to fix sparse warning:
drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef]__iomem*addr
drivers/memory/ti-emif-pm.c:251:38: got void *Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/memory/ti-emif-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
drivers/memory/ti-emif-pm.c MODULE_DEVICE_TABLE(of, ti_emif_of_match); · line 252
Quoted 11 lines
drivers/memory/ti-emif-pm.c +1
-1@@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);static int ti_emif_resume (struct device *dev) {unsigned long tmp = -__raw_readl ((void *)emif_instance->ti_emif_sram_virt); +__raw_readl ((void __iomem *)emif_instance->ti_emif_sram_virt);Maybe this shouldn't even be
__raw_readl(), but insteadREAD_ONCE()?
Quoted 1 line
Won't
readl()be enough? Indeed it looks problematic.
readl() won't work on big-endian kernels, since this is a byte comparison.
Quoted 4 lines
Quoted 2 lines
The other accesses in this file don't use MMIO wrappers either but just treat it as a pointer. The effect would be the same though.
I think all the reads and writes are with
readl()andwritel().
I actually see only one other access:
copy_addr = sram_exec_copy(emif_data->sram_pool_code,
(void *)emif_data->ti_emif_sram_virt,
&ti_emif_sram, ti_emif_sram_sz);and this one ends up in a memcpy() that does not perform any byte swapping or barriers.
Arnd
Krzysztof Kozlowski
maintainerRe: [PATCH 14/23] memory: ti-emif-pm: Fix cast to iomem pointer
Quoted 29 lines · Arnd Bergmann
Quoted 28 lines · Krzysztof Kozlowski
Quoted 26 lines · Arnd Bergmann
Quoted 17 lines · Krzysztof Kozlowski
Cast pointer to iomem memory properly to fix sparse warning:
drivers/memory/ti-emif-pm.c:251:38: warning: incorrect type in argument 1 (different address spaces)
drivers/memory/ti-emif-pm.c:251:38: expected void const volatile [noderef]__iomem*addr
drivers/memory/ti-emif-pm.c:251:38: got void *Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/memory/ti-emif-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/memory/ti-emif-pm.c +0
-0drivers/memory/ti-emif-pm.c MODULE_DEVICE_TABLE(of, ti_emif_of_match); · line 252
Quoted 6 lines
drivers/memory/ti-emif-pm.c +1
-1@@ -248,7 +248,7 @@ MODULE_DEVICE_TABLE(of, ti_emif_of_match);static int ti_emif_resume (struct device *dev) {unsigned long tmp = -__raw_readl ((void *)emif_instance->ti_emif_sram_virt); +__raw_readl ((void __iomem *)emif_instance->ti_emif_sram_virt);Maybe this shouldn't even be
__raw_readl(), but insteadREAD_ONCE()?
Quoted 3 lines
Quoted 1 line
Won't
readl()be enough? Indeed it looks problematic.
readl()won't work on big-endian kernels, since this is a byte comparison.
Ah, right.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
The other accesses in this file don't use MMIO wrappers either but just treat it as a pointer. The effect would be the same though.
I think all the reads and writes are with
readl()andwritel().
Quoted 8 lines
I actually see only one other access:
copy_addr = sram_exec_copy(emif_data->sram_pool_code, (void *)emif_data->ti_emif_sram_virt, &ti_emif_sram, ti_emif_sram_sz);and this one ends up in a
memcpy()that does not perform any byte swapping or barriers.
At least the barrier would come through mutex in sram_exec_copy() and later spin locks for page table manipulation.
Anyway, I do not have the HW to test the changes or to confirm whether this is real issue. I guess the driver author/owner should follow up on this report.
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerPATCH 15/23 memory: renesas-rpc-if: Simplify with PTR_ERR_OR_ZERO
In reply to Krzysztof KozlowskiUse PTR_ERR_OR_ZERO to make the code a little bit simpler.
--- drivers/memory/renesas-rpc-if.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/memory/renesas-rpc-if.c +1 -3
@@ -199,10 +199,8 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev) rpc->dirmap =NULL ; rpc->rstc =devm_reset_control_get_exclusive (&pdev->dev,NULL ); -if (IS_ERR (rpc->rstc)) -return PTR_ERR (rpc->rstc); -return 0 ; +return PTR_ERR_OR_ZERO (rpc->rstc); }EXPORT_SYMBOL (rpcif_sw_init);
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 16/23 memory: brcmstb_dpfe: Constify the contents of string
In reply to Krzysztof KozlowskiThe string itself can be made const for safety.
--- drivers/memory/brcmstb_dpfe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/brcmstb_dpfe.c +1 -1
@@ -188,7 +188,7 @@ struct brcmstb_dpfe_priv {struct mutex lock; }; -static const char *error_text[] = { +static const char *const error_text[] = {"Success" ,"Header code incorrect" ,"Unknown command or argument" ,"Incorrect checksum" ,"Malformed command" ,"Timed out" , };
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 16/23] memory: brcmstb_dpfe: Constify the contents of string
Quoted 3 lines · Krzysztof Kozlowski
The string itself can be made const for safety.
Signed-off-by Krzysztof Kozlowski <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 16/23] memory: brcmstb_dpfe: Constify the contents of string
Quoted 7 lines · Florian Fainelli
Quoted 3 lines · Krzysztof Kozlowski
The string itself can be made const for safety.
Signed-off-by Krzysztof Kozlowski <[email protected]>Acked-by Florian Fainelli <[email protected]>
Krzysztof Kozlowski
maintainerPATCH 17/23 memory: brcmstb_dpfe: Remove unneeded braces
In reply to Krzysztof KozlowskiSingle statement blocks don't need braces. Fixes checkpatch warning:
WARNING: braces {} are not necessary for single statement blocks
--- drivers/memory/brcmstb_dpfe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/memory/brcmstb_dpfe.c +1 -2
@@ -379,9 +379,8 @@ static void __iomem *get_msg_ptr(struct brcmstb_dpfe_priv *priv, u32 response,void __iomem *ptr =NULL ;/* There is no need to use this function for API v3 or later. */ -if (unlikely (priv->dpfe_api->version >=3 )) { +if (unlikely (priv->dpfe_api->version >=3 ))return NULL ; - } msg_type = (response >>DRAM_MSG_TYPE_OFFSET ) &DRAM_MSG_TYPE_MASK ; offset = (response >>DRAM_MSG_ADDR_OFFSET ) &DRAM_MSG_ADDR_MASK ;
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 17/23] memory: brcmstb_dpfe: Remove unneeded braces
Quoted 5 lines · Krzysztof Kozlowski
Single statement blocks don't need braces. Fixes checkpatch warning:
WARNING: braces {} are not necessary for single statement blocks
Signed-off-by Krzysztof Kozlowski <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 17/23] memory: brcmstb_dpfe: Remove unneeded braces
Quoted 9 lines · Florian Fainelli
Quoted 5 lines · Krzysztof Kozlowski
Single statement blocks don't need braces. Fixes checkpatch warning:
WARNING: braces {} are not necessary for single statement blocks
Signed-off-by Krzysztof Kozlowski <[email protected]>Acked-by Florian Fainelli <[email protected]>
Krzysztof Kozlowski
maintainerPATCH 18/23 memory: mtk-smi: Add argument to function definition
In reply to Krzysztof KozlowskiFix checkpatch warning:
WARNING: function definition argument 'struct device *' should also have an identifier name
--- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/mtk-smi.c +1 -1
@@ -60,7 +60,7 @@ struct mtk_smi_common_plat {struct mtk_smi_larb_gen {int port_in_larb[MTK_LARB_NR_MAX +1 ]; -void (*config_port)(struct device *); +void (*config_port)(struct device *dev);unsigned int larb_direct_to_common_mask;bool has_gals; };
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 18/23] memory: mtk-smi: Add argument to function definition
Quoted 5 lines · Krzysztof Kozlowski
Fix checkpatch warning:
WARNING: function definition argument 'struct device *' should also have an identifier nameSigned-off-by Krzysztof Kozlowski <[email protected]>
Is this a bug in checkpatch? I don't see why it should warn about this, as there is no function definition here.
Your change is clearly harmless, but I wonder if we should fix checkpatch instead.
Arnd
Quoted 20 lines
--- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/memory/mtk-smi.c +1
-2@@ -60,7 +60,7 @@ struct mtk_smi_common_plat {struct mtk_smi_larb_gen {int port_in_larb[MTK_LARB_NR_MAX +1 ]; -void (*config_port)(struct device *); +void (*config_port)(struct device *dev);unsigned int larb_direct_to_common_mask;bool has_gals; }; --2.17.1
Krzysztof Kozlowski
maintainerRe: [PATCH 18/23] memory: mtk-smi: Add argument to function definition
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Krzysztof Kozlowski
Fix checkpatch warning:
WARNING: function definition argument 'struct device *' should also have an identifier name
Quoted 7 lines
Quoted 1 line
Signed-off-by Krzysztof Kozlowski <[email protected]>Is this a bug in checkpatch? I don't see why it should warn about this, as there is no function definition here.
Your change is clearly harmless, but I wonder if we should fix checkpatch instead.
Good point. If this were not a warning, I would ignore it. However still the common practice is to add arguments to such type definitions as it helps to describe the type.
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerPATCH 19/23 memory: omap-gpmc: Enclose macro statements in do-while
In reply to Krzysztof Kozlowskido-while is a preferred way for complex macros because of safety reasons. This fixes checkpatch error:
ERROR: Macros starting with if should be enclosed by a do - while
loop to avoid possible if/else logic defects
--- drivers/memory/omap-gpmc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/memory/omap-gpmc.c +6 -4
@@ -635,10 +635,12 @@ static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit, int maxreturn 0 ; } -#define GPMC_SET_ONE_CD_MAX (reg, st, end, max, field, cd) \ - if (set_gpmc_timing_reg(cs, (reg), (st), (end), (max), \ - t->field, (cd), #field) < 0) \ - return -1 +#define GPMC_SET_ONE_CD_MAX (reg, st, end, max, field, cd) \ + do { \ + if (set_gpmc_timing_reg(cs, (reg), (st), (end), (max), \ + t->field, (cd), #field) < 0) \ + return -1; \ + } while (0)#define GPMC_SET_ONE (reg, st, end, field) \ GPMC_SET_ONE_CD_MAX(reg, st, end, 0, field, GPMC_CD_FCLK)
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 19/23] memory: omap-gpmc: Enclose macro statements in do-while
Quoted 8 lines · Krzysztof Kozlowski
do-while is a preferred way for complex macros because of safety reasons. This fixes checkpatch error:
ERROR: Macros starting with if should be enclosed by a do - while
loop to avoid possible if/else logic defectsSigned-off-by Krzysztof Kozlowski <[email protected]>
This is an improvement, but the macro still has other issues that are just as bad as the one you address:
- Using the # operator to avoid the "" in the invocation seems confusing
- it implicitly uses the 'cs' and 't' variables of the calling function instead of passing them as arguments.
- it calls 'return -1' in a function that otherwise uses errno-style return codes, so this gets interpreted as EPERM "Operation not permitted".
I would probably just open-code the entire thing and remove the macro like:
ret = 0;
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, GPMC_CD_FCLK, "cs_on");
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, t->cs_rd_off, GPMC_CD_FCLK, "cs_rd_off");
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, t->cs_wr_off, GPMC_CD_FCLK, "cs_wr_off);
...
if (ret)
return -ENXIO;
Of maybe leave the macro, but remove the if/return part and use the "ret |= GPMC_SET_ONE(...)" trick to avoid some of the problems.
Arnd
Krzysztof Kozlowski
maintainerRe: [PATCH 19/23] memory: omap-gpmc: Enclose macro statements in do-while
Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Krzysztof Kozlowski
do-while is a preferred way for complex macros because of safety reasons. This fixes checkpatch error:
ERROR: Macros starting with if should be enclosed by a do - while
loop to avoid possible if/else logic defects
Quoted 6 lines
Quoted 1 line
Signed-off-by Krzysztof Kozlowski <[email protected]>This is an improvement, but the macro still has other issues that are just as bad as the one you address:
- Using the # operator to avoid the "" in the invocation seems confusing
I guess it was useful for debugging.
Quoted 2 lines
- it implicitly uses the 'cs' and 't' variables of the calling function instead of passing them as arguments.
Actually another reason to convert it to just a function.
Quoted 3 lines
- it calls 'return -1' in a function that otherwise uses errno-style return codes, so this gets interpreted as EPERM "Operation not permitted".
The users of this macro also do it (gpmc_cs_set_timings()) so this wrong practice is consistent with the driver. :)
Quoted 4 lines
I would probably just open-code the entire thing and remove the macro like:
Quoted 10 lines
ret = 0;
ret |=set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, GPMC_CD_FCLK, "cs_on");
ret |=set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, t->cs_rd_off, GPMC_CD_FCLK, "cs_rd_off");
ret |=set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, t->cs_wr_off, GPMC_CD_FCLK, "cs_wr_off);
...
if (ret)
return -ENXIO;a
I like this approach because it also removes the 'return' from macro which is not desired.
Quoted 3 lines
Of maybe leave the macro, but remove the if/return part and use the "ret |=
GPMC_SET_ONE(...)" trick to avoid some of the problems.
I could probably then keep it as a function. This would be the safest and remove most of the problems here.
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerPATCH 20/23 memory: omap-gpmc: Fix whitespace issue
In reply to Krzysztof KozlowskiFix minor whitespace issues. No functional changes.
--- drivers/memory/omap-gpmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +2 -2
@@ -958,7 +958,7 @@ static int gpmc_cs_remap(int cs, u32 base)* Make sure we ignore any device offsets from the GPMC partition * allocated for the chip select and that the new base confirms * to the GPMC 16MB minimum granularity. -*/ +*/ base &= ~(SZ_16M -1 );gpmc_cs_get_memconf (cs, &old_base, &size);
@@ -1756,7 +1756,7 @@ static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t,/* TODO: remove this function once all peripherals are confirmed to * work with generic timing. Simultaneously gpmc_cs_set_timings() * has to be modified to handle timings in ps instead of ns -*/ +*/ static void gpmc_convert_ps_to_ns (struct gpmc_timings *t) { t->cs_on /=1000 ;
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 20/23] memory: omap-gpmc: Fix whitespace issue
drivers/memory/omap-gpmc.c static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t, · line 1759
Quoted 6 lines · Krzysztof Kozlowski
drivers/memory/omap-gpmc.c +1
-1@@ -1756,7 +1756,7 @@ static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t,/* TODO: remove this function once all peripherals are confirmed to * work with generic timing. Simultaneously gpmc_cs_set_timings() * has to be modified to handle timings in ps instead of ns -*/ +*/
This still doesn't follow the normal coding style for multi-line comments.
I don't think it's worth fixing, but if you think it should be changed, then make it
/*
* mult-line comment
* ...
*/
Arnd
Krzysztof Kozlowski
maintainerRe: [PATCH 20/23] memory: omap-gpmc: Fix whitespace issue
Quoted 11 lines · Arnd Bergmann
drivers/memory/omap-gpmc.c static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t, · line 1759
Quoted 6 lines · Krzysztof Kozlowski
drivers/memory/omap-gpmc.c +1
-1@@ -1756,7 +1756,7 @@ static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t,/* TODO: remove this function once all peripherals are confirmed to * work with generic timing. Simultaneously gpmc_cs_set_timings() * has to be modified to handle timings in ps instead of ns -*/ +*/ This still doesn't follow the normal coding style for multi-line comments.
Quoted 7 lines
I don't think it's worth fixing, but if you think it should be changed, then make it
/*
* mult-line comment
* ...
*/
Sure, thanks for feedback.
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerPATCH 21/23 memory: pl172: Add GPLv2 SPDX license header
In reply to Krzysztof KozlowskiAdd GPLv2 license header and remove GPL boiler plate text.
--- drivers/memory/pl172.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/memory/pl172.c +1 -4
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Memory controller driver for ARM PrimeCell PL172 * PrimeCell MultiPort Memory Controller (PL172)
@@ -6,10 +7,6 @@* * Based on: * TI AEMIF driver, Copyright (C) 2010 - 2013 Texas Instruments Inc. -* -* This file is licensed under the terms of the GNU General Public -* License version 2. This program is licensed "as is" without any -* warranty of any kind, whether express or implied. */ #include <linux/amba/bus.h>
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 22/23 memory: tegra: tegra210-emc: Fix indentation
In reply to Krzysztof KozlowskiUse tabs instead of spaces for indentation.
--- drivers/memory/tegra/tegra210-emc-cc-r21021.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/tegra/tegra210-emc-cc-r21021.c +1 -1
@@ -1044,7 +1044,7 @@ static void tegra210_emc_r21021_set_clock(struct tegra210_emc *emc, u32 clksrc) !opt_cc_short_zcal && opt_short_zcal) { value = (value & ~(EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_MASK <<EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_SHIFT )) | - ((zq_wait_long &EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_MASK ) << + ((zq_wait_long &EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_MASK ) <<EMC_MRS_WAIT_CNT_SHORT_WAIT_SHIFT ); } else if (offset == EMC_ZCAL_INTERVAL && opt_zcal_en_cc) { value =0 ;/* EMC_ZCAL_INTERVAL reset value. */
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Krzysztof Kozlowski
maintainerPATCH 23/23 MAINTAINERS: Add Krzysztof Kozlowski as maintainer of memory controllers
In reply to Krzysztof KozlowskiThe specific drivers in drivers/memory usually go via architecture (e.g. ARM SoC) maintainers but the generic parts (of_memory.[ch]) lacked any care.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -11158,6 +11158,13 @@ F: Documentation/core-api/boot-time-mm.rst F: include/linux/memblock.h F: mm/memblock.c +MEMORY CONTROLLER DRIVERS +M: Krzysztof Kozlowski <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/memory-controllers/ +F: drivers/memory/ + MEMORY FREQUENCY SCALING DRIVERS FOR NVIDIA TEGRA M: Dmitry Osipenko <[email protected]> L: [email protected]
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 23/23] MAINTAINERS: Add Krzysztof Kozlowski as maintainer of memory controllers
Quoted 5 lines · Krzysztof Kozlowski
The specific drivers in
drivers/memoryusually go via architecture (e.g. ARM SoC) maintainers but the generic parts (of_memory.[ch]) lacked any care.Signed-off-by Krzysztof Kozlowski <[email protected]>
What does this mean for specific drivers? For instance I tend to send updates to brcmstb_dpfe.c through the Broadcom ARM SoC pull requests, shall I continue to do this, or are you going to send memory controller subsystem pull requests including that file in the future?
Signature · 1 line
Florian
Krzysztof Kozlowski
maintainerRe: [PATCH 23/23] MAINTAINERS: Add Krzysztof Kozlowski as maintainer of memory controllers
Quoted 5 lines · Florian Fainelli
Quoted 4 lines · Krzysztof Kozlowski
The specific drivers in
drivers/memoryusually go via architecture (e.g. ARM SoC) maintainers but the generic parts (of_memory.[ch]) lacked any care.
Quoted 8 lines
Quoted 1 line
Signed-off-by Krzysztof Kozlowski <[email protected]>Acked-by Florian Fainelli <[email protected]>What does this mean for specific drivers? For instance I tend to send updates to
brcmstb_dpfe.cthrough the Broadcom ARM SoC pull requests, shall I continue to do this, or are you going to send memory controller subsystem pull requests including that file in the future?
If that's okay, I intend to take the drivers patches as well. I will rephrase the commit message.
Thanks for the feddback.
Best regards,
Krzysztof
Quoted 11 lines · Krzysztof Kozlowski
Dear All,
The
drivers/memorydirectory contains generic code (of_memory.c) and a bunch of drivers. Changes to generic code were coming usually through different trees with the driver code.Over last days, memory drivers grew in numbers but not necessarily in quality. They lacked compile testing and code cleanup. Also lacked maintainer.
I would be happy to take care about this part.
No objection from me, thanks for steping up to do this.
Quoted 2 lines
If there are no objections, the patches could go either to Linus or to arm-soc (most of drivers are ARM specific).
None from me!
thanks,
greg k-h
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 11 lines · Krzysztof Kozlowski
Dear All,
The
drivers/memorydirectory contains generic code (of_memory.c) and a bunch of drivers. Changes to generic code were coming usually through different trees with the driver code.Over last days, memory drivers grew in numbers but not necessarily in quality. They lacked compile testing and code cleanup. Also lacked maintainer.
Quoted 8 lines
I would be happy to take care about this part.
If there are no objections, the patches could go either to Linus or to arm-soc (most of drivers are ARM specific).
Driver-specific changes in the patchset were only compile-tested. Tests are welcome. The generic code was tested on ARMv7 Exynos based boards with a exynos5422-dmc memory controller driver.
Overall this looks great, I had a look through the patches and commented on the few things that seemed slightly odd though harmless.
Thanks for picking up the subsystem. How do you want to proceed
in the long run? I suppose you can send a pull request to [email protected] to be picked up for the coming merge window as the normal way, since
you are not yet listed as the maintained until the end of the series.
Afterwards you could either send the pull requests to Linus directly, or send them to the soc team (or to Greg) as well, the way we handle a couple of other subsystems like drivers/reset and drivers/tee that usually only have a handful of patches per release.
Arnd
Krzysztof Kozlowski
maintainerQuoted 29 lines · Arnd Bergmann
Quoted 11 lines · Krzysztof Kozlowski
Dear All,
The
drivers/memorydirectory contains generic code (of_memory.c) and a bunch of drivers. Changes to generic code were coming usually through different trees with the driver code.Over last days, memory drivers grew in numbers but not necessarily in quality. They lacked compile testing and code cleanup. Also lacked maintainer.
Quoted 8 lines
I would be happy to take care about this part.
If there are no objections, the patches could go either to Linus or to arm-soc (most of drivers are ARM specific).
Driver-specific changes in the patchset were only compile-tested. Tests are welcome. The generic code was tested on ARMv7 Exynos based boards with a exynos5422-dmc memory controller driver.
Overall this looks great, I had a look through the patches and commented on the few things that seemed slightly odd though harmless.
Thanks for picking up the subsystem. How do you want to proceed
in the long run? I suppose you can send a pull request to [email protected] to be picked up for the coming merge window as the normal way, since
you are not yet listed as the maintained until the end of the series.
Quoted 4 lines
Afterwards you could either send the pull requests to Linus directly, or send them to the soc team (or to Greg) as well, the way we handle a couple of other subsystems like
drivers/resetanddrivers/teethat usually only have a handful of patches per release.
Most of the drivers are for ARM architecture so arm-soc seems like the way to do it. However BT1_L2_CTL and JZ4780_NEMC are MIPS specific and maybe more would come in the future. Are you fine taking them as well?
Best regards,
Krzysztof
Quoted 11 lines · Krzysztof Kozlowski
Quoted 6 lines · Arnd Bergmann
On Thu, Jul 23, 2020 at 9:37 AM Krzysztof Kozlowski <[email protected]> wrote:
Afterwards you could either send the pull requests to Linus directly, or send them to the soc team (or to Greg) as well, the way we handle a couple of other subsystems like
drivers/resetanddrivers/teethat usually only have a handful of patches per release.Most of the drivers are for ARM architecture so arm-soc seems like the way to do it. However
BT1_L2_CTLandJZ4780_NEMCare MIPS specific and maybe more would come in the future. Are you fine taking them as well?
Yes, that's not a problem at all. Most other architectures are ramping down anyway, both on the maintainership side and on newly supported hardware, so we are picking those up where necessary. I also merged a couple of drivers for the MIPS based Baikal SoCs recently.
Arnd