[PATCH] watchdog: bcm_kona_wdt: Use correct return value for bcm_kona_wdt_probe()
When call function devm_platform_ioremap_resource(), we should use IS_ERR() to check the return value and return PTR_ERR() if failed. Signed-off-by: Tiezhu Yang --- drivers/watchdog/bcm_kona_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c index eb850a8..8237c4e 100644 --- a/drivers/watchdog/bcm_kona_wdt.c +++ b/drivers/watchdog/bcm_kona_wdt.c @@ -279,7 +279,7 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) - return -ENODEV; + return PTR_ERR(wdt->base); wdt->resolution = SECWDOG_DEFAULT_RESOLUTION; ret = bcm_kona_wdt_set_resolution_reg(wdt); -- 2.1.0
Re: [PATCH 2/2] phy: Remove CONFIG_ARCH_ROCKCHIP check for subdir rockchip
On 05/25/2020 06:48 PM, Heiko Stübner wrote: Am Montag, 25. Mai 2020, 06:08:59 CEST schrieb Tiezhu Yang: If CONFIG_ARCH_ROCKCHIP is not set but COMPILE_TEST is set, the file in the subdir rockchip can not be built due to CONFIG_ARCH_ROCKCHIP check in drivers/phy/Makefile. Since the related configs in drivers/phy/rockchip/Kconfig depend on ARCH_ROCKCHIP, so remove CONFIG_ARCH_ROCKCHIP check for subdir rockchip in drivers/phy/Makefile. Signed-off-by: Tiezhu Yang wouldn't this make more sense to do for all subdirs? - allwinner: also has arch_sunxi || compile_test in its Kconfig - amlogic: same - mediatek: same - renesas: same - tega: same So I think the right way would be to drop all the obj-$(CONFIG_ARCH_...) options and group the separate directories into the generic subdir listing below them. Hi Heiko, Thanks for your suggestions. I will check it and then send v2. Thanks, Tiezhu Yang Heiko --- drivers/phy/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 310c149..e5b4f58 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_ARCH_SUNXI) += allwinner/ obj-$(CONFIG_ARCH_MESON) += amlogic/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_RENESAS)+= renesas/ -obj-$(CONFIG_ARCH_ROCKCHIP)+= rockchip/ +obj-y += rockchip/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-y += broadcom/\ cadence/ \
[PATCH v2 2/2] phy: Remove CONFIG_ARCH_* check for related subdir in Makefile
If CONFIG_ARCH_ROCKCHIP is not set but COMPILE_TEST is set, the file in the subdir rockchip can not be built due to CONFIG_ARCH_ROCKCHIP check in drivers/phy/Makefile. Since the related configs in drivers/phy/rockchip/Kconfig depend on ARCH_ROCKCHIP, so remove CONFIG_ARCH_ROCKCHIP check for subdir rockchip in drivers/phy/Makefile. The other CONFIG_ARCH_* about allwinner, amlogic, mediatek, renesas and tegra have the same situation, so remove them too. Signed-off-by: Tiezhu Yang --- v2: - Remove all the CONFIG_ARCH_* check for related subdir in Makefile - Modify the patch subject and update commit message drivers/phy/Makefile | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 310c149..16e2622 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -8,24 +8,24 @@ obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o -obj-$(CONFIG_ARCH_SUNXI) += allwinner/ -obj-$(CONFIG_ARCH_MESON) += amlogic/ -obj-$(CONFIG_ARCH_MEDIATEK)+= mediatek/ -obj-$(CONFIG_ARCH_RENESAS) += renesas/ -obj-$(CONFIG_ARCH_ROCKCHIP)+= rockchip/ -obj-$(CONFIG_ARCH_TEGRA) += tegra/ -obj-y += broadcom/\ +obj-y += allwinner/ \ + amlogic/ \ + broadcom/\ cadence/ \ freescale/ \ hisilicon/ \ intel/ \ lantiq/ \ marvell/ \ + mediatek/\ motorola/\ mscc/\ qualcomm/\ ralink/ \ + renesas/ \ + rockchip/\ samsung/ \ socionext/ \ st/ \ + tegra/ \ ti/ -- 2.1.0
[PATCH v2 1/2] phy: rockchip: Fix return value of inno_dsidphy_probe()
When call function devm_platform_ioremap_resource(), we should use IS_ERR() to check the return value and return PTR_ERR() if failed. Fixes: b7535a3bc0ba ("phy/rockchip: Add support for Innosilicon MIPI/LVDS/TTL PHY") Signed-off-by: Tiezhu Yang Reviewed-by: Heiko Stuebner --- v2: - No changes, just add Reviewed-by tag drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c index a7c6c94..8af8c6c 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c @@ -607,8 +607,8 @@ static int inno_dsidphy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, inno); inno->phy_base = devm_platform_ioremap_resource(pdev, 0); - if (!inno->phy_base) - return -ENOMEM; + if (IS_ERR(inno->phy_base)) + return PTR_ERR(inno->phy_base); inno->ref_clk = devm_clk_get(dev, "ref"); if (IS_ERR(inno->ref_clk)) { -- 2.1.0
Re: [PATCH v4 2/2] clk: Allow COMPILE_TEST for subdir hisilicon in Makefile
On 06/01/2020 05:05 AM, kbuild test robot wrote: Hi Tiezhu, Thank you for the patch! Yet something to improve: [auto build test ERROR on clk/clk-next] [also build test ERROR on v5.7-rc7 next-20200529] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Tiezhu-Yang/clk-hisilicon-Use-correct-return-value-about-hisi_reset_init/20200527-233606 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: openrisc-randconfig-r021-20200531 (attached as .config) compiler: or1k-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=openrisc If you fix the issue, kindly add following tag as appropriate Reported-by: kbuild test robot Hi, Thanks for your report, please ignore this patch. All errors (new ones prefixed by >>, old ones prefixed by <<): or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_fixed_rate': clk.c:(.text+0x158): undefined reference to `clk_register_fixed_rate' clk.c:(.text+0x158): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_fixed_rate' or1k-linux-ld: clk.c:(.text+0x220): undefined reference to `clk_unregister_fixed_rate' clk.c:(.text+0x220): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_unregister_fixed_rate' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_fixed_factor': clk.c:(.text+0x2a0): undefined reference to `clk_register_fixed_factor' clk.c:(.text+0x2a0): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_fixed_factor' or1k-linux-ld: clk.c:(.text+0x370): undefined reference to `clk_unregister_fixed_factor' clk.c:(.text+0x370): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_unregister_fixed_factor' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_mux': clk.c:(.text+0x434): undefined reference to `clk_register_mux_table' clk.c:(.text+0x434): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_mux_table' or1k-linux-ld: clk.c:(.text+0x464): undefined reference to `clk_register_clkdev' clk.c:(.text+0x464): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_clkdev' or1k-linux-ld: clk.c:(.text+0x528): undefined reference to `clk_unregister_mux' clk.c:(.text+0x528): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_unregister_mux' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_divider': clk.c:(.text+0x6e8): undefined reference to `clk_register_divider_table' clk.c:(.text+0x6e8): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_divider_table' or1k-linux-ld: clk.c:(.text+0x718): undefined reference to `clk_register_clkdev' clk.c:(.text+0x718): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_register_clkdev' or1k-linux-ld: clk.c:(.text+0x7d0): undefined reference to `clk_unregister_divider' clk.c:(.text+0x7d0): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `clk_unregister_divider' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_gate': clk.c:(.text+0x870): undefined reference to `clk_register_gate' clk.c:(.text+0x870): additional relocation overflows omitted from the output or1k-linux-ld: clk.c:(.text+0x8a0): undefined reference to `clk_register_clkdev' or1k-linux-ld: clk.c:(.text+0x960): undefined reference to `clk_unregister_gate' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_gate_sep': clk.c:(.text+0xa4c): undefined reference to `clk_register_clkdev' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_init': clk.c:(.text+0xb5c): undefined reference to `of_clk_src_onecell_get' or1k-linux-ld: clk.c:(.text+0xb6c): undefined reference to `of_clk_src_onecell_get' or1k-linux-ld: clk.c:(.text+0xb70): undefined reference to `of_clk_add_provider' or1k-linux-ld: drivers/clk/hisilicon/clk.o: in function `hi6220_clk_register_divider': clk.c:(.init.text+0xe0): undefined reference to `clk_register_clkdev' or1k-linux-ld: drivers/clk/hisilicon/clkgate-separated.o: in function `hisi_register_clkgate_sep': clkgate-separated.c:(.text+0x2b4): undefined reference to `clk_register' or1k-linux-ld: drivers/clk/hisilicon/clkdivider-hi6220.o: in function `hi6220_clkdiv_set_rate': clkdivider-hi6220.c:(.text+0x30): undefin
[PATCH 2/2] perf tools: Remove some duplicated includes
There exists some duplicated includes in tools/perf, remove them. Signed-off-by: Tiezhu Yang --- tools/perf/builtin-report.c | 1 - tools/perf/util/annotate.c | 1 - tools/perf/util/auxtrace.c | 1 - tools/perf/util/config.c| 1 - tools/perf/util/session.c | 1 - 5 files changed, 5 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ba63390..5425a2c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -47,7 +47,6 @@ #include "util/time-utils.h" #include "util/auxtrace.h" #include "util/units.h" -#include "util/branch.h" #include "util/util.h" // perf_tip() #include "ui/ui.h" #include "ui/progress.h" diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d828c2d..76bfb4a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 749487a..94a8f4f 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -55,7 +55,6 @@ #include "util/mmap.h" #include -#include #include "symbol/kallsyms.h" #include diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index ef38eba..64f14a5 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -20,7 +20,6 @@ #include "build-id.h" #include "debug.h" #include "config.h" -#include "debug.h" #include #include #include diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c11d89e..5550e26e 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -33,7 +33,6 @@ #include "../perf.h" #include "arch/common.h" #include -#include #ifdef HAVE_ZSTD_SUPPORT static int perf_session__process_compressed_event(struct perf_session *session, -- 2.1.0
[PATCH 1/2] perf tools: check libasan and libubsan in Makefile.config
When build perf with ASan or UBSan, if libasan or libubsan can not find, the feature-glibc is 0 and there exists the following error log which is wrong, because we can find gnu/libc-version.h in /usr/include, glibc-devel is also installed. [yangtiezhu@linux perf]$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address' BUILD: Doing 'make -j4' parallel build HOSTCC fixdep.o HOSTLD fixdep-in.o LINK fixdep :1:0: warning: -fsanitize=address and -fsanitize=kernel-address are not supported for this target :1:0: warning: -fsanitize=address not supported for this target Auto-detecting system features: ... dwarf: [ OFF ] ...dwarf_getlocations: [ OFF ] ... glibc: [ OFF ] ... gtk2: [ OFF ] ... libaudit: [ OFF ] ...libbfd: [ OFF ] ...libcap: [ OFF ] ...libelf: [ OFF ] ... libnuma: [ OFF ] ...numa_num_possible_cpus: [ OFF ] ... libperl: [ OFF ] ... libpython: [ OFF ] ... libcrypto: [ OFF ] ... libunwind: [ OFF ] ...libdw-dwarf-unwind: [ OFF ] ... zlib: [ OFF ] ... lzma: [ OFF ] ... get_cpuid: [ OFF ] ... bpf: [ OFF ] ...libaio: [ OFF ] ... libzstd: [ OFF ] ...disassembler-four-args: [ OFF ] Makefile.config:393: *** No gnu/libc-version.h found, please install glibc-dev[el]. Stop. Makefile.perf:224: recipe for target 'sub-make' failed make[1]: *** [sub-make] Error 2 Makefile:69: recipe for target 'all' failed make: *** [all] Error 2 [yangtiezhu@linux perf]$ ls /usr/include/gnu/libc-version.h /usr/include/gnu/libc-version.h After install libasan and libubsan, the feature-glibc is 1 and the build process is success, so the cause is related with libasan or libubsan, we should check them and print an error log to reflect the reality. Signed-off-by: Tiezhu Yang --- tools/perf/Makefile.config | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 12a8204..b699d21 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -387,6 +387,12 @@ else NO_LIBBPF := 1 NO_JVMTI := 1 else + ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) +msg := $(error No libasan found, please install libasan); + endif + ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) +msg := $(error No libubsan found, please install libubsan); + endif ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); else -- 2.1.0
[PATCH 1/2] kernel/panic.c: Make oops_may_print() return bool
The return value of oops_may_print() is true or false, so change its type to reflect that. Signed-off-by: Tiezhu Yang --- include/linux/kernel.h | 2 +- kernel/panic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9b7a8d7..69c7fa4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -322,7 +322,7 @@ void nmi_panic(struct pt_regs *regs, const char *msg); extern void oops_enter(void); extern void oops_exit(void); void print_oops_end_marker(void); -extern int oops_may_print(void); +extern bool oops_may_print(void); void do_exit(long error_code) __noreturn; void complete_and_exit(struct completion *, long) __noreturn; diff --git a/kernel/panic.c b/kernel/panic.c index b69ee9e..064d80f 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -490,7 +490,7 @@ static void do_oops_enter_exit(void) * Return true if the calling CPU is allowed to print oops-related info. * This is a bit racy.. */ -int oops_may_print(void) +bool oops_may_print(void) { return pause_on_oops_flag == 0; } -- 2.1.0
[PATCH 2/2] lib/Kconfig.debug: Fix typo in the help text of CONFIG_PANIC_TIMEOUT
There exists duplicated "the" in the help text of CONFIG_PANIC_TIMEOUT, remove it. Signed-off-by: Tiezhu Yang --- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index b3b05ad..d33627a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -824,7 +824,7 @@ config PANIC_TIMEOUT int "panic timeout" default 0 help - Set the timeout value (in seconds) until a reboot occurs when the + Set the timeout value (in seconds) until a reboot occurs when the kernel panics. If n = 0, then we wait forever. A timeout value n > 0 will wait n seconds before rebooting, while a timeout value n < 0 will reboot immediately. -- 2.1.0
Re: [PATCH 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
On 05/27/2020 07:02 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-24 20:31:55) The return value about hisi_reset_init() is not correct, fix it. Signed-off-by: Tiezhu Yang --- drivers/clk/hisilicon/clk-hi3519.c | 4 ++-- drivers/clk/hisilicon/crg-hi3516cv300.c | 4 ++-- drivers/clk/hisilicon/crg-hi3798cv200.c | 4 ++-- drivers/clk/hisilicon/reset.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hi3519.c b/drivers/clk/hisilicon/clk-hi3519.c index ad0c7f3..803fa66 100644 --- a/drivers/clk/hisilicon/clk-hi3519.c +++ b/drivers/clk/hisilicon/clk-hi3519.c @@ -149,8 +149,8 @@ static int hi3519_clk_probe(struct platform_device *pdev) return -ENOMEM; crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; + if (IS_ERR(crg->rstc)) + return PTR_ERR(crg->rstc); crg->clk_data = hi3519_clk_register(pdev); if (IS_ERR(crg->clk_data)) { The code I see is returning NULL or a valid pointer from hisi_reset_init(). Can you add a "Fixes" tag to this patch so we can figure out which patch changed the behavior and where this patch needs to be backported to? OK, I will check the git log to add a Fixes tag and then send v2. Thanks, Tiezhu Yang
Re: [PATCH 2/2] clk: Remove CONFIG_ARCH_HISI check for subdir hisilicon
On 05/27/2020 02:55 AM, kbuild test robot wrote: Hi Tiezhu, Thank you for the patch! Yet something to improve: [auto build test ERROR on clk/clk-next] [also build test ERROR on v5.7-rc7 next-20200526] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Tiezhu-Yang/clk-hisilicon-Use-correct-return-value-about-hisi_reset_init/20200525-113342 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: i386-tinyconfig (attached as .config) Hi, Thanks for your report. I find that both CONFIG_ARCH_HISI and CONFIG_COMPILE_TEST are not set in .config, if one of them is set, the build will be success. But when used with this patch and this .config, I think it is better to check CONFIG_COMMON_CLK and CONFIG_CLKDEV_LOOKUP or just check CONFIG_ARCH_HISI before build the following files "clk.o clkgate-separated.o clkdivider-hi6220.o clk-hisi-phase.o" in drivers/clk/hisilicon/Makefile to avoid the build failure. I will verify it and then send v2. Thanks, Tiezhu Yang compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce (this is a W=1 build): # save the attached .config to linux build tree make W=1 ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kbuild test robot All errors (new ones prefixed by >>, old ones prefixed by <<): ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_fixed_rate': clk.c:(.text+0x9e): undefined reference to `clk_register_fixed_rate' ld: clk.c:(.text+0xdf): undefined reference to `clk_unregister_fixed_rate' ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_fixed_factor': clk.c:(.text+0x117): undefined reference to `clk_register_fixed_factor' ld: clk.c:(.text+0x158): undefined reference to `clk_unregister_fixed_factor' ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_mux': clk.c:(.text+0x1cb): undefined reference to `clk_register_mux_table' ld: clk.c:(.text+0x1f2): undefined reference to `clk_register_clkdev' ld: clk.c:(.text+0x21a): undefined reference to `clk_unregister_mux' ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_divider': clk.c:(.text+0x2c9): undefined reference to `clk_register_divider_table' ld: clk.c:(.text+0x2e3): undefined reference to `clk_register_clkdev' ld: clk.c:(.text+0x311): undefined reference to `clk_unregister_divider' ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_gate': clk.c:(.text+0x36c): undefined reference to `clk_register_gate' ld: clk.c:(.text+0x393): undefined reference to `clk_register_clkdev' ld: clk.c:(.text+0x3bb): undefined reference to `clk_unregister_gate' ld: drivers/clk/hisilicon/clk.o: in function `hisi_clk_register_gate_sep': clk.c:(.text+0x425): undefined reference to `clk_register_clkdev' ld: drivers/clk/hisilicon/clk.o: in function `hi6220_clk_register_divider': clk.c:(.init.text+0x5d): undefined reference to `clk_register_clkdev' ld: drivers/clk/hisilicon/clkgate-separated.o: in function `hisi_register_clkgate_sep': clkgate-separated.c:(.text+0xf0): undefined reference to `clk_register' ld: drivers/clk/hisilicon/clkdivider-hi6220.o: in function `hi6220_clkdiv_set_rate': clkdivider-hi6220.c:(.text+0x16): undefined reference to `divider_get_val' ld: drivers/clk/hisilicon/clkdivider-hi6220.o: in function `hi6220_clkdiv_recalc_rate': clkdivider-hi6220.c:(.text+0x8a): undefined reference to `divider_recalc_rate' ld: drivers/clk/hisilicon/clkdivider-hi6220.o: in function `hi6220_clkdiv_round_rate': clkdivider-hi6220.c:(.text+0xa9): undefined reference to `clk_hw_get_parent' ld: clkdivider-hi6220.c:(.text+0xbd): undefined reference to `divider_round_rate_parent' ld: drivers/clk/hisilicon/clkdivider-hi6220.o: in function `hi6220_register_clkdiv': clkdivider-hi6220.c:(.text+0x1c5): undefined reference to `clk_register' ld: drivers/clk/hisilicon/clk-hisi-phase.o: in function `clk_register_hisi_phase': clk-hisi-phase.c:(.text+0x121): undefined reference to `devm_clk_register' --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
[PATCH v2 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
The return value about hisi_reset_init() is not correct, fix it. Fixes: e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference") Signed-off-by: Tiezhu Yang --- v2: - No changes, just add "Fixes:" tag drivers/clk/hisilicon/clk-hi3519.c | 4 ++-- drivers/clk/hisilicon/crg-hi3516cv300.c | 4 ++-- drivers/clk/hisilicon/crg-hi3798cv200.c | 4 ++-- drivers/clk/hisilicon/reset.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hi3519.c b/drivers/clk/hisilicon/clk-hi3519.c index ad0c7f3..803fa66 100644 --- a/drivers/clk/hisilicon/clk-hi3519.c +++ b/drivers/clk/hisilicon/clk-hi3519.c @@ -149,8 +149,8 @@ static int hi3519_clk_probe(struct platform_device *pdev) return -ENOMEM; crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; + if (IS_ERR(crg->rstc)) + return PTR_ERR(crg->rstc); crg->clk_data = hi3519_clk_register(pdev); if (IS_ERR(crg->clk_data)) { diff --git a/drivers/clk/hisilicon/crg-hi3516cv300.c b/drivers/clk/hisilicon/crg-hi3516cv300.c index 5d4e61c..c2af03d 100644 --- a/drivers/clk/hisilicon/crg-hi3516cv300.c +++ b/drivers/clk/hisilicon/crg-hi3516cv300.c @@ -271,8 +271,8 @@ static int hi3516cv300_crg_probe(struct platform_device *pdev) return -ENOENT; crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; + if (IS_ERR(crg->rstc)) + return PTR_ERR(crg->rstc); crg->clk_data = crg->funcs->register_clks(pdev); if (IS_ERR(crg->clk_data)) { diff --git a/drivers/clk/hisilicon/crg-hi3798cv200.c b/drivers/clk/hisilicon/crg-hi3798cv200.c index 08a19ba..66fd6a9 100644 --- a/drivers/clk/hisilicon/crg-hi3798cv200.c +++ b/drivers/clk/hisilicon/crg-hi3798cv200.c @@ -354,8 +354,8 @@ static int hi3798cv200_crg_probe(struct platform_device *pdev) return -ENOENT; crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; + if (IS_ERR(crg->rstc)) + return PTR_ERR(crg->rstc); crg->clk_data = crg->funcs->register_clks(pdev); if (IS_ERR(crg->clk_data)) { diff --git a/drivers/clk/hisilicon/reset.c b/drivers/clk/hisilicon/reset.c index 93cee17..f17d15f 100644 --- a/drivers/clk/hisilicon/reset.c +++ b/drivers/clk/hisilicon/reset.c @@ -93,11 +93,11 @@ struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev) rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) - return NULL; + return ERR_PTR(-ENOMEM); rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) - return NULL; + return rstc->membase; spin_lock_init(>lock); rstc->rcdev.owner = THIS_MODULE; -- 2.1.0
[PATCH v2 2/2] clk: Remove CONFIG_ARCH_HISI check for subdir hisilicon in Makefile
If CONFIG_ARCH_HISI is not set but COMPILE_TEST is set, some files in the subdir hisilicon can not be built due to CONFIG_ARCH_HISI check in drivers/clk/Makefile. Since the related configs in drivers/clk/hisilicon/Kconfig depend on ARCH_HISI, so remove CONFIG_ARCH_HISI check for subdir hisilicon in drivers/clk/Makefile. At the same time, we should add CONFIG_ARCH_HISI check for the common files in drivers/clk/hisilicon/Makefile, otherwise there exists build failure about undefined reference function when both CONFIG_ARCH_HISI and COMPILE_TEST are not set. Link: https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org/thread/AVXZQX33S7ZVVK7D5VKLTTH7MOBEEBNB/ Reported-by: kbuild test robot Signed-off-by: Tiezhu Yang --- v2: - Fix the build failure reported by kbuild test robot drivers/clk/Makefile | 2 +- drivers/clk/hisilicon/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index f4169cc..81045ec 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -79,7 +79,7 @@ obj-y += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_ARCH_DAVINCI) += davinci/ obj-$(CONFIG_H8300)+= h8300/ -obj-$(CONFIG_ARCH_HISI)+= hisilicon/ +obj-y += hisilicon/ obj-y += imgtec/ obj-y += imx/ obj-y += ingenic/ diff --git a/drivers/clk/hisilicon/Makefile b/drivers/clk/hisilicon/Makefile index b2441b9..4695d6c 100644 --- a/drivers/clk/hisilicon/Makefile +++ b/drivers/clk/hisilicon/Makefile @@ -3,7 +3,7 @@ # Hisilicon Clock specific Makefile # -obj-y += clk.o clkgate-separated.o clkdivider-hi6220.o clk-hisi-phase.o +obj-$(CONFIG_ARCH_HISI)+= clk.o clkgate-separated.o clkdivider-hi6220.o clk-hisi-phase.o obj-$(CONFIG_ARCH_HI3xxx) += clk-hi3620.o obj-$(CONFIG_ARCH_HIP04) += clk-hip04.o -- 2.1.0
Re: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
On 05/29/2020 07:15 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 19:27:42) On 05/28/2020 03:06 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 07:39:21) The return value about hisi_reset_init() is not correct, fix it. Fixes: e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference") hisi_reset_init() returns NULL on error in that commit. This patch doesn't make sense. Hi Stephen, The initial aim of this patch is to use correct return value about hisi_reset_init(), maybe NULL is OK, but the return value in this patch is more accurate. The implementation of hisi_reset_init() that I see is this: struct hisi_reset_controller *rstc; rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) return NULL; rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) return NULL; spin_lock_init(>lock); rstc->rcdev.owner = THIS_MODULE; rstc->rcdev.ops = _reset_ops; rstc->rcdev.of_node = pdev->dev.of_node; rstc->rcdev.of_reset_n_cells = 2; rstc->rcdev.of_xlate = hisi_reset_of_xlate; reset_controller_register(>rcdev); return rstc; And that returns NULL on an error and a valid pointer on success. Changing the code to check the return value of hisi_reset_init() for an error pointer is simply wrong without updating hisi_reset_init() to return an error pointer on error. Where is the patch that changes hisi_reset_init() to return an error pointer? Hi Stephen, Do you mean the following changes? diff --git a/drivers/clk/hisilicon/reset.c b/drivers/clk/hisilicon/reset.c index 93cee17..c733e2e 100644 --- a/drivers/clk/hisilicon/reset.c +++ b/drivers/clk/hisilicon/reset.c @@ -93,11 +93,11 @@ struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev) rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) - return NULL; + return ERR_PTR(-ENOMEM); rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) - return NULL; + return ERR_CAST(rstc->membase); spin_lock_init(>lock); rstc->rcdev.owner = THIS_MODULE; devm_platform_ioremap_resource() devm_ioremap_resource() __devm_ioremap_resource() By the way, we can see the comment of devm_ioremap_resource(): Usage example: res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(>dev, res); if (IS_ERR(base)) return PTR_ERR(base);
Re: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
On 05/29/2020 11:58 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-28 19:03:54) On 05/29/2020 07:15 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 19:27:42) On 05/28/2020 03:06 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 07:39:21) The return value about hisi_reset_init() is not correct, fix it. Fixes: e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference") hisi_reset_init() returns NULL on error in that commit. This patch doesn't make sense. Hi Stephen, The initial aim of this patch is to use correct return value about hisi_reset_init(), maybe NULL is OK, but the return value in this patch is more accurate. The implementation of hisi_reset_init() that I see is this: struct hisi_reset_controller *rstc; rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) return NULL; rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) return NULL; spin_lock_init(>lock); rstc->rcdev.owner = THIS_MODULE; rstc->rcdev.ops = _reset_ops; rstc->rcdev.of_node = pdev->dev.of_node; rstc->rcdev.of_reset_n_cells = 2; rstc->rcdev.of_xlate = hisi_reset_of_xlate; reset_controller_register(>rcdev); return rstc; And that returns NULL on an error and a valid pointer on success. Changing the code to check the return value of hisi_reset_init() for an error pointer is simply wrong without updating hisi_reset_init() to return an error pointer on error. Where is the patch that changes hisi_reset_init() to return an error pointer? Hi Stephen, Do you mean the following changes? Yes where is this change? ERR_PTR(-ENOMEM) and ERR_CAST(rstc->membase) rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) - return NULL; + return ERR_PTR(-ENOMEM); rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) - return NULL; + return ERR_CAST(rstc->membase);
Re: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
On 05/29/2020 12:31 PM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-28 21:02:05) On 05/29/2020 11:58 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-28 19:03:54) On 05/29/2020 07:15 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 19:27:42) On 05/28/2020 03:06 AM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-27 07:39:21) The return value about hisi_reset_init() is not correct, fix it. Fixes: e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference") hisi_reset_init() returns NULL on error in that commit. This patch doesn't make sense. Hi Stephen, The initial aim of this patch is to use correct return value about hisi_reset_init(), maybe NULL is OK, but the return value in this patch is more accurate. The implementation of hisi_reset_init() that I see is this: struct hisi_reset_controller *rstc; rstc = devm_kmalloc(>dev, sizeof(*rstc), GFP_KERNEL); if (!rstc) return NULL; rstc->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rstc->membase)) return NULL; spin_lock_init(>lock); rstc->rcdev.owner = THIS_MODULE; rstc->rcdev.ops = _reset_ops; rstc->rcdev.of_node = pdev->dev.of_node; rstc->rcdev.of_reset_n_cells = 2; rstc->rcdev.of_xlate = hisi_reset_of_xlate; reset_controller_register(>rcdev); return rstc; And that returns NULL on an error and a valid pointer on success. Changing the code to check the return value of hisi_reset_init() for an error pointer is simply wrong without updating hisi_reset_init() to return an error pointer on error. Where is the patch that changes hisi_reset_init() to return an error pointer? Hi Stephen, Do you mean the following changes? Yes where is this change? ERR_PTR(-ENOMEM) and ERR_CAST(rstc->membase) I think you didn't understand my question. I'm asking where is this patch applied to the kernel and what commit is it? I don't see it in the clk tree. Sorry for that, actually I do not quite understand what you mean. In my opinion, after the following commit, when devm_ioremap_resource() is called in hisi_reset_init(), hisi_reset_init() still returns NULL and it only returns -ENOMEM when call hisi_reset_init() failed, I think it may returns -EINVAL, -EBUSY or -ENOMEM if failed, this is what I want to fix. "reset: hisilicon: fix potential NULL pointer dereference" https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/commit/drivers/clk/hisilicon/reset.c?h=clk-next=e9a2310fb689151166df7fd9971093362d34bd79
Re: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
On 05/29/2020 05:36 PM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-28 23:44:20) On 05/29/2020 12:31 PM, Stephen Boyd wrote: Quoting Tiezhu Yang (2020-05-28 21:02:05) I think you didn't understand my question. I'm asking where is this patch applied to the kernel and what commit is it? I don't see it in the clk tree. Sorry for that, actually I do not quite understand what you mean. In my opinion, after the following commit, when devm_ioremap_resource() is called in hisi_reset_init(), hisi_reset_init() still returns NULL and it only returns -ENOMEM when call hisi_reset_init() failed, I think it may returns -EINVAL, -EBUSY or -ENOMEM if failed, this is what I want to fix. "reset: hisilicon: fix potential NULL pointer dereference" https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/commit/drivers/clk/hisilicon/reset.c?h=clk-next=e9a2310fb689151166df7fd9971093362d34bd79 This commit doesn't change the value that is returned by hisi_reset_init() on an error. It still returns NULL when an error happens. Yes, I agree, but after this commit e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference"), the return value of hisi_reset_init() is not so correct because it replaces devm_ioremap() with devm_ioremap_resource(). Do you think the code of this patch is OK but the "Fixes:" commit is not accurate? If so, can we remove the "Fixes:" tag?
[PATCH 2/3] fs: Introduce cmdline argument exceed_file_max_panic
It is important to ensure that files that are opened always get closed. Failing to close files can result in file descriptor leaks. One common answer to this problem is to just raise the limit of open file handles and then restart the server every day or every few hours, this is not a good idea for long-lived servers if there is no leaks. If there exists file descriptor leaks, when file-max limit reached, we can see that the system can not work well and at worst the user can do nothing, it is even impossible to execute reboot command due to too many open files in system. In order to reboot automatically to recover to the normal status, introduce a new cmdline argument exceed_file_max_panic for user to control whether to call panic in this case. We can reproduce this problem used with the following simple test: [yangtiezhu@linux ~]$ cat exceed_file_max_test.c #include #include #include #include int main() { int fd; while (1) { fd = open("/usr/include/stdio.h", 0444); if (fd == -1) fprintf(stderr, "%s\n", "open failed"); } return 0; } [yangtiezhu@linux ~]$ cat exceed_file_max_test.sh #!/bin/bash gcc exceed_file_max_test.c -o exceed_file_max_test.bin -Wall while true do ./exceed_file_max_test.bin >/dev/null 2>&1 & done [yangtiezhu@linux ~]$ sh exceed_file_max_test.sh & [yangtiezhu@linux ~]$ reboot bash: start pipeline: pgrp pipe: Too many open files in system bash: /usr/sbin/reboot: Too many open files in system Signed-off-by: Tiezhu Yang --- fs/file_table.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index 26516d0..6943945 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -121,6 +121,17 @@ static struct file *__alloc_file(int flags, const struct cred *cred) return f; } +static bool exceed_file_max_panic; +static int __init exceed_file_max_panic_setup(char *str) +{ + pr_info("Call panic when exceed file-max limit\n"); + exceed_file_max_panic = true; + + return 1; +} + +__setup("exceed_file_max_panic", exceed_file_max_panic_setup); + /* Find an unused file structure and return a pointer to it. * Returns an error pointer if some error happend e.g. we over file * structures limit, run out of memory or operation is not permitted. @@ -159,6 +170,9 @@ struct file *alloc_empty_file(int flags, const struct cred *cred) if (get_nr_files() > old_max) { pr_info("VFS: file-max limit %lu reached\n", get_max_files()); old_max = get_nr_files(); + + if (exceed_file_max_panic) + panic("VFS: Too many open files in system\n"); } return ERR_PTR(-ENFILE); } -- 2.1.0
[PATCH 1/3] fs: Use get_max_files() instead of files_stat.max_files in alloc_empty_file()
It is better to use get_max_files() instead of files_stat.max_files to improve readability. Signed-off-by: Tiezhu Yang --- fs/file_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index 656647f..26516d0 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -139,12 +139,12 @@ struct file *alloc_empty_file(int flags, const struct cred *cred) /* * Privileged users can go above max_files */ - if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) { + if (get_nr_files() >= get_max_files() && !capable(CAP_SYS_ADMIN)) { /* * percpu_counters are inaccurate. Do an expensive check before * we go and fail. */ - if (percpu_counter_sum_positive(_files) >= files_stat.max_files) + if (percpu_counter_sum_positive(_files) >= get_max_files()) goto over; } -- 2.1.0
[PATCH 3/3] docs: admin-guide: Explain cmdline argument exceed_file_max_panic in fs.rst
Explain the cmdline argument exceed_file_max_panic in the file Documentation/admin-guide/sysctl/fs.rst Signed-off-by: Tiezhu Yang --- Documentation/admin-guide/sysctl/fs.rst | 7 +++ 1 file changed, 7 insertions(+) diff --git a/Documentation/admin-guide/sysctl/fs.rst b/Documentation/admin-guide/sysctl/fs.rst index 2a45119..0cfc5c4 100644 --- a/Documentation/admin-guide/sysctl/fs.rst +++ b/Documentation/admin-guide/sysctl/fs.rst @@ -126,6 +126,13 @@ Attempts to allocate more file descriptors than file-max are reported with printk, look for "VFS: file-max limit reached". +If there exists file descriptor leaks, when file-max limit reached, +we can see that the system can not work well and at worst the user +can do nothing, it is even impossible to execute reboot command due +to too many open files in system. In order to reboot automatically +to recover to the normal status, we can use the cmdline argument +exceed_file_max_panic to control whether to call panic in this case. + nr_open --- -- 2.1.0
[PATCH 3/3] irqchip/ti-sci-inta: Fix typo about MODULE_AUTHOR
It should be "ti.com" instead of "ticom". Fixes: 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ti-sci-inta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c index df1f7fe..ea00d2e 100644 --- a/drivers/irqchip/irq-ti-sci-inta.c +++ b/drivers/irqchip/irq-ti-sci-inta.c @@ -610,6 +610,6 @@ static struct platform_driver ti_sci_inta_irq_domain_driver = { }; module_platform_driver(ti_sci_inta_irq_domain_driver); -MODULE_AUTHOR("Lokesh Vutla "); +MODULE_AUTHOR("Lokesh Vutla "); MODULE_DESCRIPTION("K3 Interrupt Aggregator driver over TI SCI protocol"); MODULE_LICENSE("GPL v2"); -- 2.1.0
[PATCH 1/3] irqchip/ti-sci-inta: Remove dead code in ti_sci_inta_set_type()
In the function ti_sci_inta_set_type(), the statement "return -EINVAL;" out of switch case is dead code, remove it. Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ti-sci-inta.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c index 7e3ebf6..c20c9f7 100644 --- a/drivers/irqchip/irq-ti-sci-inta.c +++ b/drivers/irqchip/irq-ti-sci-inta.c @@ -433,8 +433,6 @@ static int ti_sci_inta_set_type(struct irq_data *data, unsigned int type) default: return -EINVAL; } - - return -EINVAL; } static struct irq_chip ti_sci_inta_irq_chip = { -- 2.1.0
[PATCH 2/3] irqchip/ti-sci-inta: Fix return value about devm_ioremap_resource()
When call function devm_ioremap_resource(), we should use IS_ERR() to check the return value and return PTR_ERR() if failed. Fixes: 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ti-sci-inta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c index c20c9f7..df1f7fe 100644 --- a/drivers/irqchip/irq-ti-sci-inta.c +++ b/drivers/irqchip/irq-ti-sci-inta.c @@ -570,7 +570,7 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); inta->base = devm_ioremap_resource(dev, res); if (IS_ERR(inta->base)) - return -ENODEV; + return PTR_ERR(inta->base); domain = irq_domain_add_linear(dev_of_node(dev), ti_sci_get_num_resources(inta->vint), -- 2.1.0
[PATCH] PCI: Add Loongson vendor ID and device IDs
Add the Loongson vendor ID and device IDs to pci_ids.h to be used in the future. The Loongson IDs can be found at the following link: https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/pci.ids Co-developed-by: Lu Zeng Signed-off-by: Lu Zeng Signed-off-by: Tiezhu Yang --- include/linux/pci_ids.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 21a5724..119639d 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -3111,4 +3111,23 @@ #define PCI_VENDOR_ID_NCUBE0x10ff +#define PCI_VENDOR_ID_LOONGSON 0x0014 +#define PCI_DEVICE_ID_LOONGSON_HT 0x7a00 +#define PCI_DEVICE_ID_LOONGSON_APB 0x7a02 +#define PCI_DEVICE_ID_LOONGSON_GMAC0x7a03 +#define PCI_DEVICE_ID_LOONGSON_OTG 0x7a04 +#define PCI_DEVICE_ID_LOONGSON_GPU_2K1000 0x7a05 +#define PCI_DEVICE_ID_LOONGSON_DC 0x7a06 +#define PCI_DEVICE_ID_LOONGSON_HDA 0x7a07 +#define PCI_DEVICE_ID_LOONGSON_SATA0x7a08 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X1 0x7a09 +#define PCI_DEVICE_ID_LOONGSON_SPI 0x7a0b +#define PCI_DEVICE_ID_LOONGSON_LPC 0x7a0c +#define PCI_DEVICE_ID_LOONGSON_DMA 0x7a0f +#define PCI_DEVICE_ID_LOONGSON_EHCI0x7a14 +#define PCI_DEVICE_ID_LOONGSON_GPU_7A1000 0x7a15 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X4 0x7a19 +#define PCI_DEVICE_ID_LOONGSON_OHCI0x7a24 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X8 0x7a29 + #endif /* _LINUX_PCI_IDS_H */ -- 2.1.0
Re: [PATCH] PCI: Add Loongson vendor ID and device IDs
On 09/30/2019 10:02 PM, Andrew Murray wrote: On Mon, Sep 30, 2019 at 12:55:20PM +0800, Tiezhu Yang wrote: Add the Loongson vendor ID and device IDs to pci_ids.h to be used in the future. The Loongson IDs can be found at the following link: https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/pci.ids Co-developed-by: Lu Zeng Signed-off-by: Lu Zeng Signed-off-by: Tiezhu Yang --- include/linux/pci_ids.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 21a5724..119639d 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -3111,4 +3111,23 @@ #define PCI_VENDOR_ID_NCUBE0x10ff +#define PCI_VENDOR_ID_LOONGSON 0x0014 +#define PCI_DEVICE_ID_LOONGSON_HT 0x7a00 +#define PCI_DEVICE_ID_LOONGSON_APB 0x7a02 +#define PCI_DEVICE_ID_LOONGSON_GMAC0x7a03 +#define PCI_DEVICE_ID_LOONGSON_OTG 0x7a04 +#define PCI_DEVICE_ID_LOONGSON_GPU_2K1000 0x7a05 +#define PCI_DEVICE_ID_LOONGSON_DC 0x7a06 +#define PCI_DEVICE_ID_LOONGSON_HDA 0x7a07 +#define PCI_DEVICE_ID_LOONGSON_SATA0x7a08 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X1 0x7a09 +#define PCI_DEVICE_ID_LOONGSON_SPI 0x7a0b +#define PCI_DEVICE_ID_LOONGSON_LPC 0x7a0c +#define PCI_DEVICE_ID_LOONGSON_DMA 0x7a0f +#define PCI_DEVICE_ID_LOONGSON_EHCI0x7a14 +#define PCI_DEVICE_ID_LOONGSON_GPU_7A1000 0x7a15 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X4 0x7a19 +#define PCI_DEVICE_ID_LOONGSON_OHCI0x7a24 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X8 0x7a29 Hi Tiezhu, Thanks for the patch - however it is preferred to provide new PCI definitions along with the drivers that use them. They don't provide any useful value without drivers that use them. Hi Andrew, Thanks for your reply. This is the first step of the Loongson kernel team, we will submit other related individual driver patches step by step in the near future, these small patches make an easily understood change that can be verified by reviewers. Thanks, Tiezhu Yang Thanks, Andrew Murray + #endif /* _LINUX_PCI_IDS_H */ -- 2.1.0
Re: [PATCH] PCI: Add Loongson vendor ID and device IDs
On 10/01/2019 08:50 PM, Bjorn Helgaas wrote: On Tue, Oct 01, 2019 at 10:53:44AM +0800, Tiezhu Yang wrote: On 09/30/2019 10:02 PM, Andrew Murray wrote: On Mon, Sep 30, 2019 at 12:55:20PM +0800, Tiezhu Yang wrote: Add the Loongson vendor ID and device IDs to pci_ids.h to be used in the future. The Loongson IDs can be found at the following link: https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/pci.ids Co-developed-by: Lu Zeng Signed-off-by: Lu Zeng Signed-off-by: Tiezhu Yang --- include/linux/pci_ids.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 21a5724..119639d 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -3111,4 +3111,23 @@ #define PCI_VENDOR_ID_NCUBE0x10ff +#define PCI_VENDOR_ID_LOONGSON 0x0014 +#define PCI_DEVICE_ID_LOONGSON_HT 0x7a00 +#define PCI_DEVICE_ID_LOONGSON_APB 0x7a02 +#define PCI_DEVICE_ID_LOONGSON_GMAC0x7a03 +#define PCI_DEVICE_ID_LOONGSON_OTG 0x7a04 +#define PCI_DEVICE_ID_LOONGSON_GPU_2K1000 0x7a05 +#define PCI_DEVICE_ID_LOONGSON_DC 0x7a06 +#define PCI_DEVICE_ID_LOONGSON_HDA 0x7a07 +#define PCI_DEVICE_ID_LOONGSON_SATA0x7a08 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X1 0x7a09 +#define PCI_DEVICE_ID_LOONGSON_SPI 0x7a0b +#define PCI_DEVICE_ID_LOONGSON_LPC 0x7a0c +#define PCI_DEVICE_ID_LOONGSON_DMA 0x7a0f +#define PCI_DEVICE_ID_LOONGSON_EHCI0x7a14 +#define PCI_DEVICE_ID_LOONGSON_GPU_7A1000 0x7a15 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X4 0x7a19 +#define PCI_DEVICE_ID_LOONGSON_OHCI0x7a24 +#define PCI_DEVICE_ID_LOONGSON_PCIE_X8 0x7a29 Hi Tiezhu, Thanks for the patch - however it is preferred to provide new PCI definitions along with the drivers that use them. They don't provide any useful value without drivers that use them. Thanks for your reply. This is the first step of the Loongson kernel team, we will submit other related individual driver patches step by step in the near future, these small patches make an easily understood change that can be verified by reviewers. There are two opposing goals here: 1) The "publish early, publish often" idea that posting small things early helps get useful feedback. 2) The idea of waiting until things can be published in logical units so readers can see context and how things fit together. I think Andrew's point (which I agree with) is that an individual trivial patch like this is not enough to give meaningful feedback. I think you'll get better feedback if you wait and collect things until you can post a series that actually fixes a bug or adds a small feature. It also makes it easier for me to track patches if I can deal with a whole series at once instead of trying to figure out which individual patches are related. So I'd encourage you to think in terms of a series of 3-10 patches that are all related and together produce something useful. That's easier for readers to digest than the same patches posted incrementally over several days or weeks. Hi Bjorn, Thanks for your valuable suggestion, it is very useful. In the next work, I will submit a series of patches as soon as possible. Thanks, Tiezhu Yang Bjorn
[PATCH] MIPS: generic: Use __initconst for const init data
Fix the following checkpatch errors: $ ./scripts/checkpatch.pl --no-tree -f arch/mips/generic/init.c ERROR: Use of const init definition must use __initconst +static __initdata const void *fdt; ERROR: Use of const init definition must use __initconst +static __initdata const struct mips_machine *mach; ERROR: Use of const init definition must use __initconst +static __initdata const void *mach_match_data; Signed-off-by: Tiezhu Yang --- arch/mips/generic/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c index d5b8c47..1de215b 100644 --- a/arch/mips/generic/init.c +++ b/arch/mips/generic/init.c @@ -20,9 +20,9 @@ #include #include -static __initdata const void *fdt; -static __initdata const struct mips_machine *mach; -static __initdata const void *mach_match_data; +static __initconst const void *fdt; +static __initconst const struct mips_machine *mach; +static __initconst const void *mach_match_data; void __init prom_init(void) { -- 2.1.0
[PATCH v2] MIPS: generic: Use __initconst for const init data
Fix the following checkpatch errors: $ ./scripts/checkpatch.pl --no-tree -f arch/mips/generic/init.c ERROR: Use of const init definition must use __initconst #23: FILE: arch/mips/generic/init.c:23: +static __initdata const void *fdt; ERROR: Use of const init definition must use __initconst #24: FILE: arch/mips/generic/init.c:24: +static __initdata const struct mips_machine *mach; ERROR: Use of const init definition must use __initconst #25: FILE: arch/mips/generic/init.c:25: +static __initdata const void *mach_match_data; Fixes: eed0eabd12ef ("MIPS: generic: Introduce generic DT-based board support") Signed-off-by: Tiezhu Yang --- v2: update the commit message and use the 'Fixes:' tag arch/mips/generic/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c index d5b8c47..1de215b 100644 --- a/arch/mips/generic/init.c +++ b/arch/mips/generic/init.c @@ -20,9 +20,9 @@ #include #include -static __initdata const void *fdt; -static __initdata const struct mips_machine *mach; -static __initdata const void *mach_match_data; +static __initconst const void *fdt; +static __initconst const struct mips_machine *mach; +static __initconst const void *mach_match_data; void __init prom_init(void) { -- 2.1.0
[PATCH] net: stmmac: Remove break after a return
Since break is not useful after a return, remove it. Fixes: 3b57de958e2a ("net: stmmac: Support devicetree configs for mcast and ucast filter entries") Signed-off-by: Tiezhu Yang --- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 3d69da1..d0356fb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -130,7 +130,6 @@ static void dwmac1000_set_mchash(void __iomem *ioaddr, u32 *mcfilterbits, writel(mcfilterbits[0], ioaddr + GMAC_HASH_LOW); writel(mcfilterbits[1], ioaddr + GMAC_HASH_HIGH); return; - break; case 7: numhashregs = 4; break; @@ -140,7 +139,6 @@ static void dwmac1000_set_mchash(void __iomem *ioaddr, u32 *mcfilterbits, default: pr_debug("STMMAC: err in setting multicast filter\n"); return; - break; } for (regs = 0; regs < numhashregs; regs++) writel(mcfilterbits[regs], -- 2.1.0
Re: [PATCH] MIPS: tools: Show result for loongson3-llsc-check
On 05/01/2020 05:48 PM, Sergei Shtylyov wrote: Hello! On 30.04.2020 15:36, Tiezhu Yang wrote: It is better to show the result before loongson3-llsc-check exit, otherwise we can see nothing if the return status is EXIT_SUCCESS, it seems confusing. E.g. without this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux [loongson@localhost tools]$ With this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux loongson3-llsc-check returns success [loongson@localhost tools]$ Signed-off-by: Tiezhu Yang --- arch/mips/tools/loongson3-llsc-check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/tools/loongson3-llsc-check.c b/arch/mips/tools/loongson3-llsc-check.c index 0ebddd0..facd016 100644 --- a/arch/mips/tools/loongson3-llsc-check.c +++ b/arch/mips/tools/loongson3-llsc-check.c @@ -303,5 +303,7 @@ int main(int argc, char *argv[]) out_close: close(vmlinux_fd); out_ret: +fprintf(stdout, "loongson3-llsc-check %s\n", +status ? "returns failure" : "returns success"); Why not "loongson3-llsc-check returns %s\n"? Hi Sergei, Sorry for the late reply, thanks for your review, I will send v2. Thanks, Tiezhu Yang return status; } MBR, Sergei
[PATCH v2] MIPS: tools: Show result for loongson3-llsc-check
It is better to show the result before loongson3-llsc-check exit, otherwise we can see nothing if the return status is EXIT_SUCCESS, it seems confusing. E.g. without this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux [loongson@localhost tools]$ With this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux loongson3-llsc-check returns success [loongson@localhost tools]$ Signed-off-by: Tiezhu Yang --- v2: - move "returns" after "loongson3-llsc-check" suggested by Sergei arch/mips/tools/loongson3-llsc-check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/tools/loongson3-llsc-check.c b/arch/mips/tools/loongson3-llsc-check.c index 0ebddd0..bdbc7b4 100644 --- a/arch/mips/tools/loongson3-llsc-check.c +++ b/arch/mips/tools/loongson3-llsc-check.c @@ -303,5 +303,7 @@ int main(int argc, char *argv[]) out_close: close(vmlinux_fd); out_ret: + fprintf(stdout, "loongson3-llsc-check returns %s\n", + status ? "failure" : "success"); return status; } -- 2.1.0
[PATCH] MIPS: tools: Move "returns" after "loongson3-llsc-check"
Just move "returns" after "loongson3-llsc-check", no function changes. Signed-off-by: Tiezhu Yang --- arch/mips/tools/loongson3-llsc-check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/tools/loongson3-llsc-check.c b/arch/mips/tools/loongson3-llsc-check.c index facd016..bdbc7b4 100644 --- a/arch/mips/tools/loongson3-llsc-check.c +++ b/arch/mips/tools/loongson3-llsc-check.c @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) out_close: close(vmlinux_fd); out_ret: - fprintf(stdout, "loongson3-llsc-check %s\n", - status ? "returns failure" : "returns success"); + fprintf(stdout, "loongson3-llsc-check returns %s\n", + status ? "failure" : "success"); return status; } -- 2.1.0
[PATCH v5] MIPS: Loongson: Add DMA support for LS7A
In the current market, the most used bridge chip on the Loongson platform are RS780E and LS7A, the RS780E bridge chip is already supported by the mainline kernel. In order to use the default implementation of __phys_to_dma() and __dma_to_phys() in dma-direct.h, remove CONFIG_ARCH_HAS_PHYS_TO_DMA and then set the bus's DMA limit to 36 bit for RS780E to maintain downward compatibility. Signed-off-by: Tiezhu Yang --- Hi Christoph and Jiaxun, Thank you very much for your suggestions. v5: - use the default implementation of __phys_to_dma() and __dma_to_phys() in dma-direct.h arch/mips/Kconfig | 1 - arch/mips/include/asm/mach-loongson64/boot_param.h | 5 + arch/mips/loongson64/dma.c | 22 +++--- arch/mips/loongson64/env.c | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9f15539..12b6bdb 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1454,7 +1454,6 @@ choice config CPU_LOONGSON64 bool "Loongson 64-bit CPU" depends on SYS_HAS_CPU_LOONGSON64 - select ARCH_HAS_PHYS_TO_DMA select CPU_MIPSR2 select CPU_HAS_PREFETCH select CPU_SUPPORTS_64BIT_KERNEL diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index fc9f14b..cccf4cb 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -197,6 +197,7 @@ enum loongson_bridge_type { LS7A = 2 }; +struct pci_dev; struct loongson_system_configuration { u32 nr_cpus; u32 nr_nodes; @@ -221,9 +222,13 @@ struct loongson_system_configuration { u32 nr_sensors; struct sensor_device sensors[MAX_SENSORS]; u64 workarounds; + void (*dma_config)(struct pci_dev *pdev); }; extern struct efi_memory_map_loongson *loongson_memmap; extern struct loongson_system_configuration loongson_sysconf; +extern void rs780e_dma_config(struct pci_dev *pdev); +extern void ls7a_dma_config(struct pci_dev *pdev); + #endif diff --git a/arch/mips/loongson64/dma.c b/arch/mips/loongson64/dma.c index 5e86635..6878bcc 100644 --- a/arch/mips/loongson64/dma.c +++ b/arch/mips/loongson64/dma.c @@ -1,24 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include -dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) +void rs780e_dma_config(struct pci_dev *pdev) { - /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from -* Loongson-3's 48bit address space and embed it into 40bit */ - long nid = (paddr >> 44) & 0x3; - return ((nid << 44) ^ paddr) | (nid << 37); + pdev->dev.bus_dma_limit = DMA_BIT_MASK(36); } -phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr) +void ls7a_dma_config(struct pci_dev *pdev) { - /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from -* Loongson-3's 48bit address space and embed it into 40bit */ - long nid = (daddr >> 37) & 0x3; - return ((nid << 37) ^ daddr) | (nid << 44); } +void loongson_dma_config(struct pci_dev *pdev) +{ + loongson_sysconf.dma_config(pdev); +} + +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, loongson_dma_config); + void __init plat_swiotlb_setup(void) { swiotlb_init(1); diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 71f4aaf..496f401 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -192,8 +192,10 @@ void __init prom_init_env(void) if (vendor == PCI_VENDOR_ID_LOONGSON && device == 0x7a00) { pr_info("The bridge chip is LS7A\n"); loongson_sysconf.bridgetype = LS7A; + loongson_sysconf.dma_config = ls7a_dma_config; } else { pr_info("The bridge chip is RS780E or SR5690\n"); loongson_sysconf.bridgetype = RS780E; + loongson_sysconf.dma_config = rs780e_dma_config; } } -- 2.1.0
Re: [PATCH v5] MIPS: Loongson: Add DMA support for LS7A
Sorry, I can not receive email today due to some unknown reason, so I use the "mailto: link" in the Linux-MIPS Archive to reply. > Please use alpha-betical order here, which means put ls7a things > before rs780 things. OK, thanks. I will modify it and send v6. > Why use a hardcoded 37? LS7A's node-id bits are configurable in BIOS. Oh, the platform dependent implementation of __phys_to_dma() and __dma_to_phys() are deleted, and ls7a_dma_config() is an empty function, the hardware can translate address of node id automatically for LS7A.
[PATCH v6] MIPS: Loongson: Add DMA support for LS7A
In the current market, the most used bridge chip on the Loongson platform are RS780E and LS7A, the RS780E bridge chip is already supported by the mainline kernel. In order to use the default implementation of __phys_to_dma() and __dma_to_phys() in dma-direct.h, remove CONFIG_ARCH_HAS_PHYS_TO_DMA and then set the bus's DMA limit to 36 bit for RS780E to maintain downward compatibility. Signed-off-by: Tiezhu Yang --- Hi Christoph and Jiaxun, Thank you very much for your suggestions. v5: - use the default implementation of __phys_to_dma() and __dma_to_phys() in dma-direct.h v6: - make loongson_dma_config() static - put ls7a things before rs780 things arch/mips/Kconfig | 1 - arch/mips/include/asm/mach-loongson64/boot_param.h | 5 + arch/mips/loongson64/dma.c | 22 +++--- arch/mips/loongson64/env.c | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9f15539..12b6bdb 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1454,7 +1454,6 @@ choice config CPU_LOONGSON64 bool "Loongson 64-bit CPU" depends on SYS_HAS_CPU_LOONGSON64 - select ARCH_HAS_PHYS_TO_DMA select CPU_MIPSR2 select CPU_HAS_PREFETCH select CPU_SUPPORTS_64BIT_KERNEL diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index f082d87..0c07a96 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -197,6 +197,7 @@ enum loongson_bridge_type { RS780E = 2 }; +struct pci_dev; struct loongson_system_configuration { u32 nr_cpus; u32 nr_nodes; @@ -221,9 +222,13 @@ struct loongson_system_configuration { u32 nr_sensors; struct sensor_device sensors[MAX_SENSORS]; u64 workarounds; + void (*dma_config)(struct pci_dev *pdev); }; extern struct efi_memory_map_loongson *loongson_memmap; extern struct loongson_system_configuration loongson_sysconf; +extern void ls7a_dma_config(struct pci_dev *pdev); +extern void rs780e_dma_config(struct pci_dev *pdev); + #endif diff --git a/arch/mips/loongson64/dma.c b/arch/mips/loongson64/dma.c index 5e86635..ef40b0d 100644 --- a/arch/mips/loongson64/dma.c +++ b/arch/mips/loongson64/dma.c @@ -1,24 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include -dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) +void ls7a_dma_config(struct pci_dev *pdev) { - /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from -* Loongson-3's 48bit address space and embed it into 40bit */ - long nid = (paddr >> 44) & 0x3; - return ((nid << 44) ^ paddr) | (nid << 37); } -phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr) +void rs780e_dma_config(struct pci_dev *pdev) { - /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from -* Loongson-3's 48bit address space and embed it into 40bit */ - long nid = (daddr >> 37) & 0x3; - return ((nid << 37) ^ daddr) | (nid << 44); + pdev->dev.bus_dma_limit = DMA_BIT_MASK(36); } +static void loongson_dma_config(struct pci_dev *pdev) +{ + loongson_sysconf.dma_config(pdev); +} + +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, loongson_dma_config); + void __init plat_swiotlb_setup(void) { swiotlb_init(1); diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 71f4aaf..496f401 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -192,8 +192,10 @@ void __init prom_init_env(void) if (vendor == PCI_VENDOR_ID_LOONGSON && device == 0x7a00) { pr_info("The bridge chip is LS7A\n"); loongson_sysconf.bridgetype = LS7A; + loongson_sysconf.dma_config = ls7a_dma_config; } else { pr_info("The bridge chip is RS780E or SR5690\n"); loongson_sysconf.bridgetype = RS780E; + loongson_sysconf.dma_config = rs780e_dma_config; } } -- 2.1.0
[PATCH] MIPS: tools: Show result for loongson3-llsc-check
It is better to show the result before loongson3-llsc-check exit, otherwise we can see nothing if the return status is EXIT_SUCCESS, it seems confusing. E.g. without this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux [loongson@localhost tools]$ With this patch: [loongson@localhost tools]$ ./loongson3-llsc-check ../../../vmlinux loongson3-llsc-check returns success [loongson@localhost tools]$ Signed-off-by: Tiezhu Yang --- arch/mips/tools/loongson3-llsc-check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/tools/loongson3-llsc-check.c b/arch/mips/tools/loongson3-llsc-check.c index 0ebddd0..facd016 100644 --- a/arch/mips/tools/loongson3-llsc-check.c +++ b/arch/mips/tools/loongson3-llsc-check.c @@ -303,5 +303,7 @@ int main(int argc, char *argv[]) out_close: close(vmlinux_fd); out_ret: + fprintf(stdout, "loongson3-llsc-check %s\n", + status ? "returns failure" : "returns success"); return status; } -- 2.1.0
[PATCH] MIPS: Loongson: Make default kernel log buffer size as 128KB for Loongson3
When I update kernel with loongson3_defconfig based on the Loongson 3A3000 platform, then using dmesg command to show kernel ring buffer, the initial kernel messages have disappeared due to the log buffer is too small, it is better to change the default kernel log buffer size from 16KB to 128KB. Signed-off-by: Tiezhu Yang --- arch/mips/configs/loongson3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index 90ee008..3aa2201 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -12,7 +12,7 @@ CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y -CONFIG_LOG_BUF_SHIFT=14 +CONFIG_LOG_BUF_SHIFT=17 CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y -- 2.1.0
Re: [PATCH] MIPS: Loongson: Make default kernel log buffer size as 128KB for Loongson3
On 10/15/2019 11:36 AM, Huacai Chen wrote: On Tue, Oct 15, 2019 at 10:12 AM Tiezhu Yang wrote: When I update kernel with loongson3_defconfig based on the Loongson 3A3000 platform, then using dmesg command to show kernel ring buffer, the initial kernel messages have disappeared due to the log buffer is too small, it is better to change the default kernel log buffer size from 16KB to 128KB. Signed-off-by: Tiezhu Yang --- arch/mips/configs/loongson3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index 90ee008..3aa2201 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -12,7 +12,7 @@ CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y -CONFIG_LOG_BUF_SHIFT=14 +CONFIG_LOG_BUF_SHIFT=17 Hi, Tiezhu, Why you choose 128KB but not 64KB or 256KB? I found 64KB is enough for our cases. And if you really need more, I think 256KB could be better because there are many platforms choose 256KB. Hi Huacai, Thanks for your reply and suggestion, I will send a v2 patch. Thanks, Tiezhu Yang Huacai CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y -- 2.1.0
[PATCH v2] MIPS: Loongson: Make default kernel log buffer size as 256KB for Loongson3
When I update kernel with loongson3_defconfig based on the Loongson 3A3000 platform, then using dmesg command to show kernel ring buffer, the initial kernel messages have disappeared due to the log buffer is too small, it is better to change the default kernel log buffer size from 16KB to 256KB. Signed-off-by: Tiezhu Yang --- v2: modify the default kernel log buffer size to 256KB suggested by Huacai arch/mips/configs/loongson3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index 90ee008..4f750e6 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -12,7 +12,7 @@ CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y -CONFIG_LOG_BUF_SHIFT=14 +CONFIG_LOG_BUF_SHIFT=18 CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y -- 2.1.0
Re: [PATCH] MIPS: Loongson: Make default kernel log buffer size as 128KB for Loongson3
On 10/16/2019 02:53 AM, Paul Burton wrote: Hi Tiezhu & Huacai, On Tue, Oct 15, 2019 at 12:00:25PM +0800, Tiezhu Yang wrote: On 10/15/2019 11:36 AM, Huacai Chen wrote: On Tue, Oct 15, 2019 at 10:12 AM Tiezhu Yang wrote: When I update kernel with loongson3_defconfig based on the Loongson 3A3000 platform, then using dmesg command to show kernel ring buffer, the initial kernel messages have disappeared due to the log buffer is too small, it is better to change the default kernel log buffer size from 16KB to 128KB. Signed-off-by: Tiezhu Yang --- arch/mips/configs/loongson3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index 90ee008..3aa2201 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -12,7 +12,7 @@ CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y -CONFIG_LOG_BUF_SHIFT=14 +CONFIG_LOG_BUF_SHIFT=17 Hi, Tiezhu, Why you choose 128KB but not 64KB or 256KB? I found 64KB is enough for our cases. And if you really need more, I think 256KB could be better because there are many platforms choose 256KB. Hi Huacai, Thanks for your reply and suggestion, I will send a v2 patch. Thanks for the patches. I actually have a slight preference for 128KB if you've no specific need, since 128KB is the default. Some quick grepping says that of 405 defconfigs in tree (as of v5.4-rc3), we have: LOG_BUF_SHIFT Count 12 1 13 3 14 235 15 18 16 39 17 90 18 13 19 2 20 4 ie. 16KiB is by far the most common, then second most common is the default 128KiB. 256KiB is comparatively rare. Hi Paul, Thank you very much for your detailed explanation. I think 128KB is enough to save the boot messages because the dmesg output size is about 40KB after reboot in my system. However, I don't think your v1 patch is quite right Tiezhu - since 17 is the default it shouldn't be specified in the defconfig at all. Did you manually make the change in the loongson3_defconfig file? If so please take a look at the savedefconfig make target & try something like this: make ARCH=mips loongson3_defconfig make ARCH=mips menuconfig # Change LOG_BUF_SHIFT make ARCH=mips savedefconfig mv defconfig arch/mips/configs/loongson3_defconfig git add -i arch/mips/configs/loongson3_defconfig # Stage the relevant changes, drop the others You should end up with the CONFIG_LOG_BUF_SHIFT line just getting deleted. Yes, you are right, I will make a new patch followed with your steps and send a v3 patch: just delete the CONFIG_LOG_BUF_SHIFT line to use the default value 128KB and update the commit message. If on the other hand you really do prefer 256KiB for these systems please describe why in the commit message. It could be something as simple as "we have lots of memory so using 256KiB isn't a big deal, and gives us a better chance of preserving boot messages until they're examined". But if your log is getting this big before you look at it (or before something like systemd copies it into its journal), there's probably something fishy going on. Hi Huacai, What do you think? If you have any more suggestion, please let me know. Thanks, Tiezhu Yang Thanks, Paul
[PATCH v3] MIPS: Loongson: Make default kernel log buffer size as 128KB for Loongson3
When I update kernel with loongson3_defconfig based on the Loongson 3A3000 platform, then using dmesg command to show kernel ring buffer, the initial kernel messages have disappeared due to the log buffer is too small, it is better to change the kernel log buffer size from 16KB to 128KB which is enough to save the boot messages. Since the default LOG_BUF_SHIFT value is 17, the default kernel log buffer size is 128KB, just delete the CONFIG_LOG_BUF_SHIFT line. Signed-off-by: Tiezhu Yang --- v3: use the default LOG_BUF_SHIFT value 17 and update the commit message arch/mips/configs/loongson3_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index 90ee008..25e1179 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -12,7 +12,6 @@ CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y -CONFIG_LOG_BUF_SHIFT=14 CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y -- 2.1.0
Re: [PATCH bpf-next v2] Documentation/bpf: Use valid and new links in index.rst
On 07/30/2020 05:06 AM, Song Liu wrote: On Wed, Jul 29, 2020 at 6:17 AM Tiezhu Yang wrote: There exists an error "404 Not Found" when I click the html link of "Documentation/networking/filter.rst" in the BPF documentation [1], fix it. Additionally, use the new links about "BPF and XDP Reference Guide" and "bpf(2)" to avoid redirects. [1] https://www.kernel.org/doc/html/latest/bpf/ Fixes: d9b9170a2653 ("docs: bpf: Rename README.rst to index.rst") Fixes: cb3f0d56e153 ("docs: networking: convert filter.txt to ReST") Signed-off-by: Tiezhu Yang --- v2: - Fix a typo "clik" to "click" in the commit message, sorry for that Documentation/bpf/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/bpf/index.rst b/Documentation/bpf/index.rst index 26f4bb3..1b901b4 100644 --- a/Documentation/bpf/index.rst +++ b/Documentation/bpf/index.rst @@ -68,7 +68,7 @@ Testing and debugging BPF .. Links: -.. _Documentation/networking/filter.rst: ../networking/filter.txt +.. _Documentation/networking/filter.rst: ../networking/filter.html This should be filter.rst, no? Hi Song, Thanks for your reply. I use filter.rst first, but it still appears "404 not found" when I click this link after "make htmldocs", so I use filter.html finally. Am I missing something? Is the test method OK? Please correct me if I am wrong. Thanks, Tiezhu .. _man-pages: https://www.kernel.org/doc/man-pages/ -.. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html -.. _BPF and XDP Reference Guide: http://cilium.readthedocs.io/en/latest/bpf/ +.. _bpf(2): https://man7.org/linux/man-pages/man2/bpf.2.html +.. _BPF and XDP Reference Guide: https://docs.cilium.io/en/latest/bpf/ -- 2.1.0
[PATCH bpf-next v3] Documentation/bpf: Use valid and new links in index.rst
There exists an error "404 Not Found" when I click the html link of "Documentation/networking/filter.rst" in the BPF documentation [1], fix it. Additionally, use the new links about "BPF and XDP Reference Guide" and "bpf(2)" to avoid redirects. [1] https://www.kernel.org/doc/html/latest/bpf/ Fixes: d9b9170a2653 ("docs: bpf: Rename README.rst to index.rst") Fixes: cb3f0d56e153 ("docs: networking: convert filter.txt to ReST") Signed-off-by: Tiezhu Yang --- Documentation/bpf/index.rst | 12 ++-- Documentation/networking/filter.rst | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/bpf/index.rst b/Documentation/bpf/index.rst index 26f4bb3..44ca8ea 100644 --- a/Documentation/bpf/index.rst +++ b/Documentation/bpf/index.rst @@ -5,10 +5,10 @@ BPF Documentation This directory contains documentation for the BPF (Berkeley Packet Filter) facility, with a focus on the extended BPF version (eBPF). -This kernel side documentation is still work in progress. The main +This kernel side documentation is still work in progress. The main textual documentation is (for historical reasons) described in -`Documentation/networking/filter.rst`_, which describe both classical -and extended BPF instruction-set. +:ref:`networking-filter`, which describe both classical and extended +BPF instruction-set. The Cilium project also maintains a `BPF and XDP Reference Guide`_ that goes into great technical depth about the BPF Architecture. @@ -68,7 +68,7 @@ Testing and debugging BPF .. Links: -.. _Documentation/networking/filter.rst: ../networking/filter.txt +.. _networking-filter: ../networking/filter.rst .. _man-pages: https://www.kernel.org/doc/man-pages/ -.. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html -.. _BPF and XDP Reference Guide: http://cilium.readthedocs.io/en/latest/bpf/ +.. _bpf(2): https://man7.org/linux/man-pages/man2/bpf.2.html +.. _BPF and XDP Reference Guide: https://docs.cilium.io/en/latest/bpf/ diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index a1d3e19..debb59e 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -1,5 +1,7 @@ .. SPDX-License-Identifier: GPL-2.0 +.. _networking-filter: + === Linux Socket Filtering aka Berkeley Packet Filter (BPF) === -- 2.1.0
Re: [PATCH 1/7] irqchip: Fix potential resource leaks
On 06/23/2020 11:55 PM, Markus Elfring wrote: There exists some potential resource leaks in the error path, fix them. Will the tag “Fixes” become relevant for the commit message? Hi Markus, Thanks for your reply and suggestion. This patch contains many files in drivers/irqchip, maybe I should split it into some small patches if use the tag "Fixes"? … +++ b/drivers/irqchip/irq-nvic.c @@ -94,6 +94,7 @@ static int __init nvic_of_init(struct device_node *node, if (!nvic_irq_domain) { pr_warn("Failed to allocate irq domain\n"); + iounmap(nvic_base); return -ENOMEM; } @@ -103,6 +104,7 @@ static int __init nvic_of_init(struct device_node *node, if (ret) { pr_warn("Failed to allocate irq chips\n"); irq_domain_remove(nvic_irq_domain); + iounmap(nvic_base); return ret; } Can it helpful to add jump targets so that a bit of exception handling can be better reused at the end of this function? OK, no problem, I will do it in the v2. By the way, I have resent this patch series due to git send-email failed, https://lore.kernel.org/patchwork/cover/1261517/ Thanks, Tiezhu Regards, Markus
[PATCH v2 11/14] irqchip/omap-intc: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 8598066cddd1 ("arm: omap: irq: move irq.c to drivers/irqchip/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-omap-intc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c index d360a6e..e711530 100644 --- a/drivers/irqchip/irq-omap-intc.c +++ b/drivers/irqchip/irq-omap-intc.c @@ -254,8 +254,10 @@ static int __init omap_init_irq_of(struct device_node *node) omap_irq_soft_reset(); ret = omap_alloc_gc_of(domain, omap_irq_base); - if (ret < 0) + if (ret < 0) { irq_domain_remove(domain); + iounmap(omap_irq_base); + } return ret; } -- 2.1.0
[PATCH v2 08/14] irqchip/ls1x: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 9e543e22e204 ("irqchip: Add driver for Loongson-1 interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ls1x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-ls1x.c b/drivers/irqchip/irq-ls1x.c index 353111a..409001b 100644 --- a/drivers/irqchip/irq-ls1x.c +++ b/drivers/irqchip/irq-ls1x.c @@ -131,7 +131,7 @@ static int __init ls1x_intc_of_init(struct device_node *node, if (!priv->domain) { pr_err("ls1x-irq: cannot add IRQ domain\n"); err = -ENOMEM; - goto out_iounmap; + goto out_dispose_irq; } err = irq_alloc_domain_generic_chips(priv->domain, 32, 2, @@ -182,6 +182,8 @@ static int __init ls1x_intc_of_init(struct device_node *node, out_free_domain: irq_domain_remove(priv->domain); +out_dispose_irq: + irq_dispose_mapping(parent_irq); out_iounmap: iounmap(priv->intc_base); out_free_priv: -- 2.1.0
[PATCH v2 02/14] irqchip/csky-apb-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index 5a2ec43..11a35eb 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) _generic_chip_ops, NULL); if (!root_domain) { pr_err("C-SKY Intc irq_domain_add failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(root_domain, 32, 1, @@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0); if (ret) { pr_err("C-SKY Intc irq_alloc_gc failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_domain_remove; } return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(reg_base); + return ret; } static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq, -- 2.1.0
[PATCH v2 04/14] irqchip/davinci-aintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-aintc.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c index 810ccc4..12db502 100644 --- a/drivers/irqchip/irq-davinci-aintc.c +++ b/drivers/irqchip/irq-davinci-aintc.c @@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) resource_size(>reg)); if (!davinci_aintc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return; + goto err_release; } /* Clear all interrupt requests */ @@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return; + goto err_iounmap; } davinci_aintc_irq_domain = irq_domain_add_legacy(NULL, @@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) _domain_simple_ops, NULL); if (!davinci_aintc_irq_domain) { pr_err("%s: unable to create interrupt domain\n", __func__); - return; + goto err_free_descs; } ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1, @@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (ret) { pr_err("%s: unable to allocate generic irq chips for domain\n", __func__); - return; + goto err_domain_remove; } for (irq_off = 0, reg_off = 0; @@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) irq_base + irq_off, 32); set_handle_irq(davinci_aintc_handle_irq); + +err_domain_remove: + irq_domain_remove(davinci_aintc_irq_domain); +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_aintc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); } -- 2.1.0
[PATCH v2 07/14] irqchip/dw-apb-ictl: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c index e4550e9..bc9b750 100644 --- a/drivers/irqchip/irq-dw-apb-ictl.c +++ b/drivers/irqchip/irq-dw-apb-ictl.c @@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np, ret = of_address_to_resource(np, 0, ); if (ret) { pr_err("%pOF: unable to get resource\n", np); - return ret; + goto err_irq_dispose; } if (!request_mem_region(r.start, resource_size(), np->full_name)) { pr_err("%pOF: unable to request mem region\n", np); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } iobase = ioremap(r.start, resource_size()); @@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_err("%pOF: unable to alloc irq domain gc\n", np); - goto err_unmap; + goto err_domain_remove; } for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) { @@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np, return 0; +err_domain_remove: + irq_domain_remove(domain); err_unmap: iounmap(iobase); err_release: release_mem_region(r.start, resource_size()); +err_irq_dispose: + irq_dispose_mapping(irq); return ret; } IRQCHIP_DECLARE(dw_apb_ictl, -- 2.1.0
[PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-s3c24xx.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c index d2031fe..ef5d645 100644 --- a/drivers/irqchip/irq-s3c24xx.c +++ b/drivers/irqchip/irq-s3c24xx.c @@ -1239,7 +1239,8 @@ static int __init s3c_init_intc_of(struct device_node *np, _irq_ops_of, NULL); if (!domain) { pr_err("irq: could not create irq-domain\n"); - return -EINVAL; + ret = -EINVAL; + goto out_iounmap; } for (i = 0; i < num_ctrl; i++) { @@ -1248,15 +1249,17 @@ static int __init s3c_init_intc_of(struct device_node *np, pr_debug("irq: found controller %s\n", ctrl->name); intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL); - if (!intc) - return -ENOMEM; + if (!intc) { + ret = -ENOMEM; + goto out_domain_remove; + } intc->domain = domain; intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data), GFP_KERNEL); if (!intc->irqs) { - kfree(intc); - return -ENOMEM; + ret = -ENOMEM; + goto out_free; } if (ctrl->parent) { @@ -1285,6 +1288,13 @@ static int __init s3c_init_intc_of(struct device_node *np, set_handle_irq(s3c24xx_handle_irq); return 0; + +out_free: + kfree(intc); +out_domain_remove: + irq_domain_remove(domain); +out_iounmap: + iounmap(reg_base); } static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = { -- 2.1.0
[PATCH v2 10/14] irqchip/nvic: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-nvic.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index f747e22..cd17f5d 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node, if (!nvic_irq_domain) { pr_warn("Failed to allocate irq domain\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1, @@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node, clr, 0, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_warn("Failed to allocate irq chips\n"); - irq_domain_remove(nvic_irq_domain); - return ret; + goto err_domain_remove; } for (i = 0; i < numbanks; ++i) { @@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node, writel_relaxed(0, nvic_base + NVIC_IPR + i); return 0; + +err_domain_remove: + irq_domain_remove(nvic_irq_domain); +err_iounmap: + iounmap(nvic_base); + return ret; } IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init); -- 2.1.0
[PATCH v2 12/14] irqchip/riscv-intc: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 6b7ce8927b5a ("irqchip: RISC-V per-HART local interrupt controller driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-riscv-intc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index a6f97fa..8d6286c 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -122,6 +122,7 @@ static int __init riscv_intc_init(struct device_node *node, rc = set_handle_irq(_intc_irq); if (rc) { pr_err("failed to set irq handler\n"); + irq_domain_remove(intc_domain); return rc; } -- 2.1.0
[PATCH v2 14/14] irqchip/xilinx-intc: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 9689c99e4950 ("irqchip/xilinx: Add support for parent intc") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-xilinx-intc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c index 1d3d273..dcc51e0 100644 --- a/drivers/irqchip/irq-xilinx-intc.c +++ b/drivers/irqchip/irq-xilinx-intc.c @@ -241,7 +241,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc, } else { pr_err("irq-xilinx: interrupts property not in DT\n"); ret = -EINVAL; - goto error; + goto error_domain_remove; } } else { primary_intc = irqc; @@ -250,6 +250,8 @@ static int __init xilinx_intc_of_init(struct device_node *intc, return 0; +error_domain_remove: + irq_domain_remove(irqc->root_domain); error: iounmap(irqc->base); kfree(irqc); -- 2.1.0
[PATCH v2 09/14] irqchip/mscc-ocelot: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 19d99164480a ("irqchip: Add a driver for the Microsemi Ocelot controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-mscc-ocelot.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-mscc-ocelot.c b/drivers/irqchip/irq-mscc-ocelot.c index 88143c0..e676ae2 100644 --- a/drivers/irqchip/irq-mscc-ocelot.c +++ b/drivers/irqchip/irq-mscc-ocelot.c @@ -73,7 +73,8 @@ static int __init ocelot_irq_init(struct device_node *node, _generic_chip_ops, NULL); if (!domain) { pr_err("%pOFn: unable to add irq domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } ret = irq_alloc_domain_generic_chips(domain, OCELOT_NR_IRQ, 1, @@ -109,9 +110,10 @@ static int __init ocelot_irq_init(struct device_node *node, err_gc_free: irq_free_generic_chip(gc); - err_domain_remove: irq_domain_remove(domain); +err_irq_dispose: + irq_dispose_mapping(parent_irq); return ret; } -- 2.1.0
[PATCH v2 01/14] irqchip/ath79-misc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ath79-misc.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c index 3d641bb..53e0c50 100644 --- a/drivers/irqchip/irq-ath79-misc.c +++ b/drivers/irqchip/irq-ath79-misc.c @@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init( { struct irq_domain *domain; void __iomem *base; - int irq; + int irq, ret; irq = irq_of_parse_and_map(node, 0); if (!irq) { @@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init( base = of_iomap(node, 0); if (!base) { pr_err("Failed to get MISC IRQ registers\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT, _irq_domain_ops, base); if (!domain) { pr_err("Failed to add MISC irqdomain\n"); - return -EINVAL; + ret = -EINVAL; + goto err_iounmap; } ath79_misc_intc_domain_init(domain, irq); return 0; + +err_iounmap: + iounmap(base); +err_irq_dispose: + irq_dispose_mapping(irq); + return ret; } static int __init ar7100_misc_intc_of_init( -- 2.1.0
[PATCH v2 00/14] irqchip: Fix potential resource leaks
When I test the irqchip code of Loongson, I read the related code of other chips in drivers/irqchip and I find some potential resource leaks in the error path, I think it is better to fix them. v2: - Split the first patch into a new patch series which includes small patches and add "Fixes" tag - Use "goto" label to handle error path in some patches Tiezhu Yang (14): irqchip/ath79-misc: Fix potential resource leaks irqchip/csky-apb-intc: Fix potential resource leaks irqchip/csky-mpintc: Fix potential resource leaks irqchip/davinci-aintc: Fix potential resource leaks irqchip/davinci-cp-intc: Fix potential resource leaks irqchip/digicolor: Fix potential resource leaks irqchip/dw-apb-ictl: Fix potential resource leaks irqchip/ls1x: Fix potential resource leaks irqchip/mscc-ocelot: Fix potential resource leaks irqchip/nvic: Fix potential resource leaks irqchip/omap-intc: Fix potential resource leak irqchip/riscv-intc: Fix potential resource leak irqchip/s3c24xx: Fix potential resource leaks irqchip/xilinx-intc: Fix potential resource leak drivers/irqchip/irq-ath79-misc.c | 14 +++--- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- drivers/irqchip/irq-csky-mpintc.c | 26 -- drivers/irqchip/irq-davinci-aintc.c | 17 + drivers/irqchip/irq-davinci-cp-intc.c | 17 ++--- drivers/irqchip/irq-digicolor.c | 14 +++--- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- drivers/irqchip/irq-ls1x.c| 4 +++- drivers/irqchip/irq-mscc-ocelot.c | 6 -- drivers/irqchip/irq-nvic.c| 12 +--- drivers/irqchip/irq-omap-intc.c | 4 +++- drivers/irqchip/irq-riscv-intc.c | 1 + drivers/irqchip/irq-s3c24xx.c | 20 +++- drivers/irqchip/irq-xilinx-intc.c | 4 +++- 14 files changed, 125 insertions(+), 37 deletions(-) -- 2.1.0
[PATCH v2 2/7] irqchip/loongson-htpic: Remove unneeded select of I8259
LOONGSON_HTPIC depends on MACH_LOONGSON64 and MACH_LOONGSON64 already selects I8259 in arch/mips/Kconfig, so no need to select I8259 again when config LOONGSON_HTPIC. Signed-off-by: Tiezhu Yang --- drivers/irqchip/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 29fead2..9f57aed 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -541,7 +541,6 @@ config LOONGSON_HTPIC default y select IRQ_DOMAIN select GENERIC_IRQ_CHIP - select I8259 help Support for the Loongson-3 HyperTransport PIC Controller. -- 2.1.0
[PATCH v2 3/7] irqchip/loongson-htvec: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 818e915fbac5 ("irqchip: Add Loongson HyperTransport Vector support") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-htvec.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c index 1ece933..b36d403 100644 --- a/drivers/irqchip/irq-loongson-htvec.c +++ b/drivers/irqchip/irq-loongson-htvec.c @@ -192,7 +192,7 @@ static int htvec_of_init(struct device_node *node, if (!priv->htvec_domain) { pr_err("Failed to create IRQ domain\n"); err = -ENOMEM; - goto iounmap_base; + goto irq_dispose; } htvec_reset(priv); @@ -203,6 +203,9 @@ static int htvec_of_init(struct device_node *node, return 0; +irq_dispose: + for (; i > 0; i--) + irq_dispose_mapping(parent_irq[i - 1]); iounmap_base: iounmap(priv->base); free_priv: -- 2.1.0
[PATCH v2 0/7] irqchip: Fix some issues and do some code cleanups about Loongson
Check the return value of irq_domain_translate_onecell() and irq_domain_translate_twocell(), do some code cleanups about Loongson to make it more clean and readable. v2: - In order to avoid git send-email failed, make the related patches about Loongson into a new patch series and add "Fixes" tag Tiezhu Yang (7): irqchip/loongson-htpic: Remove redundant kfree operation irqchip/loongson-htpic: Remove unneeded select of I8259 irqchip/loongson-htvec: Fix potential resource leak irqchip/loongson-htvec: Check return value of irq_domain_translate_onecell() irqchip/loongson-pch-pic: Check return value of irq_domain_translate_twocell() irqchip/loongson-pch-msi: Remove unneeded variable dt-bindings: interrupt-controller: Fix typos in loongson,liointc.yaml .../bindings/interrupt-controller/loongson,liointc.yaml | 4 ++-- drivers/irqchip/Kconfig | 1 - drivers/irqchip/irq-loongson-htpic.c | 6 ++ drivers/irqchip/irq-loongson-htvec.c | 10 -- drivers/irqchip/irq-loongson-pch-msi.c| 7 +-- drivers/irqchip/irq-loongson-pch-pic.c| 15 +-- 6 files changed, 22 insertions(+), 21 deletions(-) -- 2.1.0
[PATCH v2 1/7] irqchip/loongson-htpic: Remove redundant kfree operation
In the function htpic_of_init(), when kzalloc htpic fails, it should return -ENOMEM directly, no need to execute "goto" to kfree. Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-htpic.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-loongson-htpic.c b/drivers/irqchip/irq-loongson-htpic.c index dd018c2..63f7280 100644 --- a/drivers/irqchip/irq-loongson-htpic.c +++ b/drivers/irqchip/irq-loongson-htpic.c @@ -93,10 +93,8 @@ int __init htpic_of_init(struct device_node *node, struct device_node *parent) } htpic = kzalloc(sizeof(*htpic), GFP_KERNEL); - if (!htpic) { - err = -ENOMEM; - goto out_free; - } + if (!htpic) + return -ENOMEM; htpic->base = of_iomap(node, 0); if (!htpic->base) { -- 2.1.0
[PATCH v2 06/14] irqchip/digicolor: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 8041dfbd31cf ("irqchip: Conexant CX92755 interrupts controller driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-digicolor.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c index fc38d2d..18c6e77 100644 --- a/drivers/irqchip/irq-digicolor.c +++ b/drivers/irqchip/irq-digicolor.c @@ -89,7 +89,8 @@ static int __init digicolor_of_init(struct device_node *node, ucregs = syscon_regmap_lookup_by_phandle(node, "syscon"); if (IS_ERR(ucregs)) { pr_err("%pOF: unable to map UC registers\n", node); - return PTR_ERR(ucregs); + ret = PTR_ERR(ucregs); + goto err_iounmap; } /* channel 1, regular IRQs */ regmap_write(ucregs, UC_IRQ_CONTROL, 1); @@ -98,7 +99,8 @@ static int __init digicolor_of_init(struct device_node *node, irq_domain_add_linear(node, 64, _generic_chip_ops, NULL); if (!digicolor_irq_domain) { pr_err("%pOF: unable to create IRQ domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(digicolor_irq_domain, 32, 1, @@ -106,7 +108,7 @@ static int __init digicolor_of_init(struct device_node *node, clr, 0, 0); if (ret) { pr_err("%pOF: unable to allocate IRQ gc\n", node); - return ret; + goto err_domain_remove; } digicolor_set_gc(reg_base, 0, IC_INT0ENABLE_LO, IC_FLAG_CLEAR_LO); @@ -115,5 +117,11 @@ static int __init digicolor_of_init(struct device_node *node, set_handle_irq(digicolor_handle_irq); return 0; + +err_domain_remove: + irq_domain_remove(digicolor_irq_domain); +err_iounmap: + iounmap(reg_base); + return ret; } IRQCHIP_DECLARE(conexant_digicolor_ic, "cnxt,cx92755-ic", digicolor_of_init); -- 2.1.0
[PATCH v2 05/14] irqchip/davinci-cp-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-cp-intc.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c index 276da277..991339f 100644 --- a/drivers/irqchip/irq-davinci-cp-intc.c +++ b/drivers/irqchip/irq-davinci-cp-intc.c @@ -175,7 +175,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, resource_size(>reg)); if (!davinci_cp_intc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_release; } davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE); @@ -210,7 +211,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return irq_base; + ret = irq_base; + goto err_iounmap; } davinci_cp_intc_irq_domain = irq_domain_add_legacy( @@ -219,7 +221,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (!davinci_cp_intc_irq_domain) { pr_err("%s: unable to create an interrupt domain\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_free_descs; } set_handle_irq(davinci_cp_intc_handle_irq); @@ -228,6 +231,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE); return 0; + +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_cp_intc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); + return ret; } int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config) -- 2.1.0
[PATCH v2 03/14] irqchip/csky-mpintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-mpintc.c | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c index a1534ed..c195e24 100644 --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) if (INTCG_base == NULL) { INTCG_base = ioremap(mfcr("cr<31, 14>"), INTCL_SIZE*nr_cpu_ids + INTCG_SIZE); - if (INTCG_base == NULL) - return -EIO; + if (INTCG_base == NULL) { + ret = -EIO; + goto err_free; + } INTCL_base = INTCG_base + INTCG_SIZE; @@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) root_domain = irq_domain_add_linear(node, nr_irq, _irqdomain_ops, NULL); - if (!root_domain) - return -ENXIO; + if (!root_domain) { + ret = -ENXIO; + goto err_iounmap; + } /* for every cpu */ for_each_present_cpu(cpu) { @@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) #ifdef CONFIG_SMP ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); - if (!ipi_irq) - return -EIO; + if (!ipi_irq) { + ret = -EIO; + goto err_domain_remove; + } set_send_ipi(_mpintc_send_ipi, ipi_irq); #endif return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(INTCG_base); +err_free: + kfree(__trigger); + return ret; } IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init); -- 2.1.0
[PATCH v2 0/7 RESEND] irqchip: Fix some issues and do some code cleanups about Loongson
[git send-email failed, so resend, sorry for that] Check the return value of irq_domain_translate_onecell() and irq_domain_translate_twocell(), do some code cleanups about Loongson to make it more clean and readable. v2: - In order to avoid git send-email failed, make the related patches about Loongson into a new patch series and add "Fixes" tag Tiezhu Yang (7): irqchip/loongson-htpic: Remove redundant kfree operation irqchip/loongson-htpic: Remove unneeded select of I8259 irqchip/loongson-htvec: Fix potential resource leak irqchip/loongson-htvec: Check return value of irq_domain_translate_onecell() irqchip/loongson-pch-pic: Check return value of irq_domain_translate_twocell() irqchip/loongson-pch-msi: Remove unneeded variable dt-bindings: interrupt-controller: Fix typos in loongson,liointc.yaml .../bindings/interrupt-controller/loongson,liointc.yaml | 4 ++-- drivers/irqchip/Kconfig | 1 - drivers/irqchip/irq-loongson-htpic.c | 6 ++ drivers/irqchip/irq-loongson-htvec.c | 10 -- drivers/irqchip/irq-loongson-pch-msi.c| 7 +-- drivers/irqchip/irq-loongson-pch-pic.c| 15 +-- 6 files changed, 22 insertions(+), 21 deletions(-) -- 2.1.0
[PATCH v2 4/7 RESEND] irqchip/loongson-htvec: Check return value of irq_domain_translate_onecell()
Check the return value of irq_domain_translate_onecell() due to it may returns -EINVAL if failed. Fixes: 818e915fbac5 ("irqchip: Add Loongson HyperTransport Vector support") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-htvec.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c index b36d403..720cf96 100644 --- a/drivers/irqchip/irq-loongson-htvec.c +++ b/drivers/irqchip/irq-loongson-htvec.c @@ -109,11 +109,14 @@ static struct irq_chip htvec_irq_chip = { static int htvec_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { + int ret; unsigned long hwirq; unsigned int type, i; struct htvec *priv = domain->host_data; - irq_domain_translate_onecell(domain, arg, , ); + ret = irq_domain_translate_onecell(domain, arg, , ); + if (ret) + return ret; for (i = 0; i < nr_irqs; i++) { irq_domain_set_info(domain, virq + i, hwirq + i, _irq_chip, -- 2.1.0
[PATCH v2 6/7 RESEND] irqchip/loongson-pch-msi: Remove unneeded variable
irq_domain_alloc_irqs_parent() returns 0 on success and non-zero value on failure, it is redudant to check its non-zero return value and then return it, so just remove the variable "ret" and return directly in the function pch_msi_parent_domain_alloc(). Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-pch-msi.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c index 50becd2..12aeeab 100644 --- a/drivers/irqchip/irq-loongson-pch-msi.c +++ b/drivers/irqchip/irq-loongson-pch-msi.c @@ -100,17 +100,12 @@ static int pch_msi_parent_domain_alloc(struct irq_domain *domain, unsigned int virq, int hwirq) { struct irq_fwspec fwspec; - int ret; fwspec.fwnode = domain->parent->fwnode; fwspec.param_count = 1; fwspec.param[0] = hwirq; - ret = irq_domain_alloc_irqs_parent(domain, virq, 1, ); - if (ret) - return ret; - - return 0; + return irq_domain_alloc_irqs_parent(domain, virq, 1, ); } static int pch_msi_middle_domain_alloc(struct irq_domain *domain, -- 2.1.0
[PATCH v2 5/7 RESEND] irqchip/loongson-pch-pic: Check return value of irq_domain_translate_twocell()
Check the return value of irq_domain_translate_twocell() due to it may returns -EINVAL if failed and use variable fwspec for it, and then use a new variable parent_fwspec which is proper for irq_domain_alloc_irqs_parent(). Fixes: ef8c01eb64ca ("irqchip: Add Loongson PCH PIC controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-pch-pic.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c index 2a05b93..016f32c 100644 --- a/drivers/irqchip/irq-loongson-pch-pic.c +++ b/drivers/irqchip/irq-loongson-pch-pic.c @@ -135,16 +135,19 @@ static int pch_pic_alloc(struct irq_domain *domain, unsigned int virq, int err; unsigned int type; unsigned long hwirq; - struct irq_fwspec fwspec; + struct irq_fwspec *fwspec = arg; + struct irq_fwspec parent_fwspec; struct pch_pic *priv = domain->host_data; - irq_domain_translate_twocell(domain, arg, , ); + err = irq_domain_translate_twocell(domain, fwspec, , ); + if (err) + return err; - fwspec.fwnode = domain->parent->fwnode; - fwspec.param_count = 1; - fwspec.param[0] = hwirq + priv->ht_vec_base; + parent_fwspec.fwnode = domain->parent->fwnode; + parent_fwspec.param_count = 1; + parent_fwspec.param[0] = hwirq + priv->ht_vec_base; - err = irq_domain_alloc_irqs_parent(domain, virq, 1, ); + err = irq_domain_alloc_irqs_parent(domain, virq, 1, _fwspec); if (err) return err; -- 2.1.0
[PATCH v2 7/7 RESEND] dt-bindings: interrupt-controller: Fix typos in loongson,liointc.yaml
Fix the following two typos in loongson,liointc.yaml: fron -> from it's -> its Fixes: b6280c8bb6f5 ("dt-bindings: interrupt-controller: Add Loongson LIOINTC") Signed-off-by: Tiezhu Yang --- .../devicetree/bindings/interrupt-controller/loongson,liointc.yaml| 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml index b1db21e..13908ca 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml @@ -51,8 +51,8 @@ properties: description: | This property points how the children interrupts will be mapped into CPU interrupt lines. Each cell refers to a parent interrupt line from 0 to 3 - and each bit in the cell refers to a children interrupt fron 0 to 31. - If a CPU interrupt line didn't connected with liointc, then keep it's + and each bit in the cell refers to a children interrupt from 0 to 31. + If a CPU interrupt line didn't connected with liointc, then keep its cell with zero. $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 4 -- 2.1.0
[PATCH v2 2/7 RESEND] irqchip/loongson-htpic: Remove unneeded select of I8259
LOONGSON_HTPIC depends on MACH_LOONGSON64 and MACH_LOONGSON64 already selects I8259 in arch/mips/Kconfig, so no need to select I8259 again when config LOONGSON_HTPIC. Signed-off-by: Tiezhu Yang --- drivers/irqchip/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 29fead2..9f57aed 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -541,7 +541,6 @@ config LOONGSON_HTPIC default y select IRQ_DOMAIN select GENERIC_IRQ_CHIP - select I8259 help Support for the Loongson-3 HyperTransport PIC Controller. -- 2.1.0
[PATCH v2 1/7 RESEND] irqchip/loongson-htpic: Remove redundant kfree operation
In the function htpic_of_init(), when kzalloc htpic fails, it should return -ENOMEM directly, no need to execute "goto" to kfree. Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-htpic.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-loongson-htpic.c b/drivers/irqchip/irq-loongson-htpic.c index dd018c2..63f7280 100644 --- a/drivers/irqchip/irq-loongson-htpic.c +++ b/drivers/irqchip/irq-loongson-htpic.c @@ -93,10 +93,8 @@ int __init htpic_of_init(struct device_node *node, struct device_node *parent) } htpic = kzalloc(sizeof(*htpic), GFP_KERNEL); - if (!htpic) { - err = -ENOMEM; - goto out_free; - } + if (!htpic) + return -ENOMEM; htpic->base = of_iomap(node, 0); if (!htpic->base) { -- 2.1.0
[PATCH v2 3/7 RESEND] irqchip/loongson-htvec: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 818e915fbac5 ("irqchip: Add Loongson HyperTransport Vector support") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-loongson-htvec.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c index 1ece933..b36d403 100644 --- a/drivers/irqchip/irq-loongson-htvec.c +++ b/drivers/irqchip/irq-loongson-htvec.c @@ -192,7 +192,7 @@ static int htvec_of_init(struct device_node *node, if (!priv->htvec_domain) { pr_err("Failed to create IRQ domain\n"); err = -ENOMEM; - goto iounmap_base; + goto irq_dispose; } htvec_reset(priv); @@ -203,6 +203,9 @@ static int htvec_of_init(struct device_node *node, return 0; +irq_dispose: + for (; i > 0; i--) + irq_dispose_mapping(parent_irq[i - 1]); iounmap_base: iounmap(priv->base); free_priv: -- 2.1.0
[PATCH v3 09/14] irqchip/mscc-ocelot: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 19d99164480a ("irqchip: Add a driver for the Microsemi Ocelot controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-mscc-ocelot.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-mscc-ocelot.c b/drivers/irqchip/irq-mscc-ocelot.c index 88143c0..e676ae2 100644 --- a/drivers/irqchip/irq-mscc-ocelot.c +++ b/drivers/irqchip/irq-mscc-ocelot.c @@ -73,7 +73,8 @@ static int __init ocelot_irq_init(struct device_node *node, _generic_chip_ops, NULL); if (!domain) { pr_err("%pOFn: unable to add irq domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } ret = irq_alloc_domain_generic_chips(domain, OCELOT_NR_IRQ, 1, @@ -109,9 +110,10 @@ static int __init ocelot_irq_init(struct device_node *node, err_gc_free: irq_free_generic_chip(gc); - err_domain_remove: irq_domain_remove(domain); +err_irq_dispose: + irq_dispose_mapping(parent_irq); return ret; } -- 2.1.0
[PATCH v3 02/14] irqchip/csky-apb-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index 5a2ec43..11a35eb 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) _generic_chip_ops, NULL); if (!root_domain) { pr_err("C-SKY Intc irq_domain_add failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(root_domain, 32, 1, @@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0); if (ret) { pr_err("C-SKY Intc irq_alloc_gc failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_domain_remove; } return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(reg_base); + return ret; } static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq, -- 2.1.0
[PATCH v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-mpintc.c | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c index a1534ed..c195e24 100644 --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) if (INTCG_base == NULL) { INTCG_base = ioremap(mfcr("cr<31, 14>"), INTCL_SIZE*nr_cpu_ids + INTCG_SIZE); - if (INTCG_base == NULL) - return -EIO; + if (INTCG_base == NULL) { + ret = -EIO; + goto err_free; + } INTCL_base = INTCG_base + INTCG_SIZE; @@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) root_domain = irq_domain_add_linear(node, nr_irq, _irqdomain_ops, NULL); - if (!root_domain) - return -ENXIO; + if (!root_domain) { + ret = -ENXIO; + goto err_iounmap; + } /* for every cpu */ for_each_present_cpu(cpu) { @@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) #ifdef CONFIG_SMP ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); - if (!ipi_irq) - return -EIO; + if (!ipi_irq) { + ret = -EIO; + goto err_domain_remove; + } set_send_ipi(_mpintc_send_ipi, ipi_irq); #endif return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(INTCG_base); +err_free: + kfree(__trigger); + return ret; } IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init); -- 2.1.0
[PATCH v3 05/14] irqchip/davinci-cp-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-cp-intc.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c index 276da277..2c2e115 100644 --- a/drivers/irqchip/irq-davinci-cp-intc.c +++ b/drivers/irqchip/irq-davinci-cp-intc.c @@ -162,6 +162,7 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, unsigned int num_regs = BITS_TO_LONGS(config->num_irqs); int offset, irq_base; void __iomem *req; + int ret; req = request_mem_region(config->reg.start, resource_size(>reg), @@ -175,7 +176,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, resource_size(>reg)); if (!davinci_cp_intc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_release; } davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE); @@ -210,7 +212,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return irq_base; + ret = irq_base; + goto err_iounmap; } davinci_cp_intc_irq_domain = irq_domain_add_legacy( @@ -219,7 +222,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (!davinci_cp_intc_irq_domain) { pr_err("%s: unable to create an interrupt domain\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_free_descs; } set_handle_irq(davinci_cp_intc_handle_irq); @@ -228,6 +232,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE); return 0; + +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_cp_intc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); + return ret; } int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config) -- 2.1.0
[PATCH v3 00/14] irqchip: Fix potential resource leaks
When I test the irqchip code of Loongson, I read the related code of other chips in drivers/irqchip and I find some potential resource leaks in the error path, I think it is better to fix them. v2: - Split the first patch into a new patch series which includes small patches and add "Fixes" tag - Use "goto" label to handle error path in some patches v3: - Add missed variable "ret" in the patch #5 and #13, sorry for that Tiezhu Yang (14): irqchip/ath79-misc: Fix potential resource leaks irqchip/csky-apb-intc: Fix potential resource leaks irqchip/csky-mpintc: Fix potential resource leaks irqchip/davinci-aintc: Fix potential resource leaks irqchip/davinci-cp-intc: Fix potential resource leaks irqchip/digicolor: Fix potential resource leaks irqchip/dw-apb-ictl: Fix potential resource leaks irqchip/ls1x: Fix potential resource leaks irqchip/mscc-ocelot: Fix potential resource leaks irqchip/nvic: Fix potential resource leaks irqchip/omap-intc: Fix potential resource leak irqchip/riscv-intc: Fix potential resource leak irqchip/s3c24xx: Fix potential resource leaks irqchip/xilinx-intc: Fix potential resource leak drivers/irqchip/irq-ath79-misc.c | 14 +++--- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- drivers/irqchip/irq-csky-mpintc.c | 26 -- drivers/irqchip/irq-davinci-aintc.c | 17 + drivers/irqchip/irq-davinci-cp-intc.c | 18 +++--- drivers/irqchip/irq-digicolor.c | 14 +++--- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- drivers/irqchip/irq-ls1x.c| 4 +++- drivers/irqchip/irq-mscc-ocelot.c | 6 -- drivers/irqchip/irq-nvic.c| 12 +--- drivers/irqchip/irq-omap-intc.c | 4 +++- drivers/irqchip/irq-riscv-intc.c | 1 + drivers/irqchip/irq-s3c24xx.c | 23 +-- drivers/irqchip/irq-xilinx-intc.c | 4 +++- 14 files changed, 128 insertions(+), 38 deletions(-) -- 2.1.0
[PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-aintc.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c index 810ccc4..12db502 100644 --- a/drivers/irqchip/irq-davinci-aintc.c +++ b/drivers/irqchip/irq-davinci-aintc.c @@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) resource_size(>reg)); if (!davinci_aintc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return; + goto err_release; } /* Clear all interrupt requests */ @@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return; + goto err_iounmap; } davinci_aintc_irq_domain = irq_domain_add_legacy(NULL, @@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) _domain_simple_ops, NULL); if (!davinci_aintc_irq_domain) { pr_err("%s: unable to create interrupt domain\n", __func__); - return; + goto err_free_descs; } ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1, @@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (ret) { pr_err("%s: unable to allocate generic irq chips for domain\n", __func__); - return; + goto err_domain_remove; } for (irq_off = 0, reg_off = 0; @@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) irq_base + irq_off, 32); set_handle_irq(davinci_aintc_handle_irq); + +err_domain_remove: + irq_domain_remove(davinci_aintc_irq_domain); +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_aintc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); } -- 2.1.0
[PATCH v3 01/14] irqchip/ath79-misc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ath79-misc.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c index 3d641bb..53e0c50 100644 --- a/drivers/irqchip/irq-ath79-misc.c +++ b/drivers/irqchip/irq-ath79-misc.c @@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init( { struct irq_domain *domain; void __iomem *base; - int irq; + int irq, ret; irq = irq_of_parse_and_map(node, 0); if (!irq) { @@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init( base = of_iomap(node, 0); if (!base) { pr_err("Failed to get MISC IRQ registers\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT, _irq_domain_ops, base); if (!domain) { pr_err("Failed to add MISC irqdomain\n"); - return -EINVAL; + ret = -EINVAL; + goto err_iounmap; } ath79_misc_intc_domain_init(domain, irq); return 0; + +err_iounmap: + iounmap(base); +err_irq_dispose: + irq_dispose_mapping(irq); + return ret; } static int __init ar7100_misc_intc_of_init( -- 2.1.0
[PATCH v3 07/14] irqchip/dw-apb-ictl: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c index e4550e9..bc9b750 100644 --- a/drivers/irqchip/irq-dw-apb-ictl.c +++ b/drivers/irqchip/irq-dw-apb-ictl.c @@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np, ret = of_address_to_resource(np, 0, ); if (ret) { pr_err("%pOF: unable to get resource\n", np); - return ret; + goto err_irq_dispose; } if (!request_mem_region(r.start, resource_size(), np->full_name)) { pr_err("%pOF: unable to request mem region\n", np); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } iobase = ioremap(r.start, resource_size()); @@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_err("%pOF: unable to alloc irq domain gc\n", np); - goto err_unmap; + goto err_domain_remove; } for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) { @@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np, return 0; +err_domain_remove: + irq_domain_remove(domain); err_unmap: iounmap(iobase); err_release: release_mem_region(r.start, resource_size()); +err_irq_dispose: + irq_dispose_mapping(irq); return ret; } IRQCHIP_DECLARE(dw_apb_ictl, -- 2.1.0
[PATCH v3 10/14] irqchip/nvic: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-nvic.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index f747e22..cd17f5d 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node, if (!nvic_irq_domain) { pr_warn("Failed to allocate irq domain\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1, @@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node, clr, 0, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_warn("Failed to allocate irq chips\n"); - irq_domain_remove(nvic_irq_domain); - return ret; + goto err_domain_remove; } for (i = 0; i < numbanks; ++i) { @@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node, writel_relaxed(0, nvic_base + NVIC_IPR + i); return 0; + +err_domain_remove: + irq_domain_remove(nvic_irq_domain); +err_iounmap: + iounmap(nvic_base); + return ret; } IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init); -- 2.1.0
[PATCH v3 08/14] irqchip/ls1x: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 9e543e22e204 ("irqchip: Add driver for Loongson-1 interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ls1x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-ls1x.c b/drivers/irqchip/irq-ls1x.c index 353111a..409001b 100644 --- a/drivers/irqchip/irq-ls1x.c +++ b/drivers/irqchip/irq-ls1x.c @@ -131,7 +131,7 @@ static int __init ls1x_intc_of_init(struct device_node *node, if (!priv->domain) { pr_err("ls1x-irq: cannot add IRQ domain\n"); err = -ENOMEM; - goto out_iounmap; + goto out_dispose_irq; } err = irq_alloc_domain_generic_chips(priv->domain, 32, 2, @@ -182,6 +182,8 @@ static int __init ls1x_intc_of_init(struct device_node *node, out_free_domain: irq_domain_remove(priv->domain); +out_dispose_irq: + irq_dispose_mapping(parent_irq); out_iounmap: iounmap(priv->intc_base); out_free_priv: -- 2.1.0
[PATCH v3 11/14] irqchip/omap-intc: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 8598066cddd1 ("arm: omap: irq: move irq.c to drivers/irqchip/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-omap-intc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c index d360a6e..e711530 100644 --- a/drivers/irqchip/irq-omap-intc.c +++ b/drivers/irqchip/irq-omap-intc.c @@ -254,8 +254,10 @@ static int __init omap_init_irq_of(struct device_node *node) omap_irq_soft_reset(); ret = omap_alloc_gc_of(domain, omap_irq_base); - if (ret < 0) + if (ret < 0) { irq_domain_remove(domain); + iounmap(omap_irq_base); + } return ret; } -- 2.1.0
[PATCH v3 06/14] irqchip/digicolor: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 8041dfbd31cf ("irqchip: Conexant CX92755 interrupts controller driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-digicolor.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c index fc38d2d..18c6e77 100644 --- a/drivers/irqchip/irq-digicolor.c +++ b/drivers/irqchip/irq-digicolor.c @@ -89,7 +89,8 @@ static int __init digicolor_of_init(struct device_node *node, ucregs = syscon_regmap_lookup_by_phandle(node, "syscon"); if (IS_ERR(ucregs)) { pr_err("%pOF: unable to map UC registers\n", node); - return PTR_ERR(ucregs); + ret = PTR_ERR(ucregs); + goto err_iounmap; } /* channel 1, regular IRQs */ regmap_write(ucregs, UC_IRQ_CONTROL, 1); @@ -98,7 +99,8 @@ static int __init digicolor_of_init(struct device_node *node, irq_domain_add_linear(node, 64, _generic_chip_ops, NULL); if (!digicolor_irq_domain) { pr_err("%pOF: unable to create IRQ domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(digicolor_irq_domain, 32, 1, @@ -106,7 +108,7 @@ static int __init digicolor_of_init(struct device_node *node, clr, 0, 0); if (ret) { pr_err("%pOF: unable to allocate IRQ gc\n", node); - return ret; + goto err_domain_remove; } digicolor_set_gc(reg_base, 0, IC_INT0ENABLE_LO, IC_FLAG_CLEAR_LO); @@ -115,5 +117,11 @@ static int __init digicolor_of_init(struct device_node *node, set_handle_irq(digicolor_handle_irq); return 0; + +err_domain_remove: + irq_domain_remove(digicolor_irq_domain); +err_iounmap: + iounmap(reg_base); + return ret; } IRQCHIP_DECLARE(conexant_digicolor_ic, "cnxt,cx92755-ic", digicolor_of_init); -- 2.1.0
[PATCH v3 02/14 RESEND] irqchip/csky-apb-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index 5a2ec43..11a35eb 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) _generic_chip_ops, NULL); if (!root_domain) { pr_err("C-SKY Intc irq_domain_add failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(root_domain, 32, 1, @@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0); if (ret) { pr_err("C-SKY Intc irq_alloc_gc failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_domain_remove; } return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(reg_base); + return ret; } static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq, -- 2.1.0
[PATCH v3 01/14 RESEND] irqchip/ath79-misc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ath79-misc.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c index 3d641bb..53e0c50 100644 --- a/drivers/irqchip/irq-ath79-misc.c +++ b/drivers/irqchip/irq-ath79-misc.c @@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init( { struct irq_domain *domain; void __iomem *base; - int irq; + int irq, ret; irq = irq_of_parse_and_map(node, 0); if (!irq) { @@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init( base = of_iomap(node, 0); if (!base) { pr_err("Failed to get MISC IRQ registers\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT, _irq_domain_ops, base); if (!domain) { pr_err("Failed to add MISC irqdomain\n"); - return -EINVAL; + ret = -EINVAL; + goto err_iounmap; } ath79_misc_intc_domain_init(domain, irq); return 0; + +err_iounmap: + iounmap(base); +err_irq_dispose: + irq_dispose_mapping(irq); + return ret; } static int __init ar7100_misc_intc_of_init( -- 2.1.0
[PATCH v3 03/14 RESEND] irqchip/csky-mpintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-mpintc.c | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c index a1534ed..c195e24 100644 --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) if (INTCG_base == NULL) { INTCG_base = ioremap(mfcr("cr<31, 14>"), INTCL_SIZE*nr_cpu_ids + INTCG_SIZE); - if (INTCG_base == NULL) - return -EIO; + if (INTCG_base == NULL) { + ret = -EIO; + goto err_free; + } INTCL_base = INTCG_base + INTCG_SIZE; @@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) root_domain = irq_domain_add_linear(node, nr_irq, _irqdomain_ops, NULL); - if (!root_domain) - return -ENXIO; + if (!root_domain) { + ret = -ENXIO; + goto err_iounmap; + } /* for every cpu */ for_each_present_cpu(cpu) { @@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) #ifdef CONFIG_SMP ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); - if (!ipi_irq) - return -EIO; + if (!ipi_irq) { + ret = -EIO; + goto err_domain_remove; + } set_send_ipi(_mpintc_send_ipi, ipi_irq); #endif return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(INTCG_base); +err_free: + kfree(__trigger); + return ret; } IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init); -- 2.1.0
[PATCH v3 09/14 RESEND] irqchip/mscc-ocelot: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 19d99164480a ("irqchip: Add a driver for the Microsemi Ocelot controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-mscc-ocelot.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-mscc-ocelot.c b/drivers/irqchip/irq-mscc-ocelot.c index 88143c0..e676ae2 100644 --- a/drivers/irqchip/irq-mscc-ocelot.c +++ b/drivers/irqchip/irq-mscc-ocelot.c @@ -73,7 +73,8 @@ static int __init ocelot_irq_init(struct device_node *node, _generic_chip_ops, NULL); if (!domain) { pr_err("%pOFn: unable to add irq domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } ret = irq_alloc_domain_generic_chips(domain, OCELOT_NR_IRQ, 1, @@ -109,9 +110,10 @@ static int __init ocelot_irq_init(struct device_node *node, err_gc_free: irq_free_generic_chip(gc); - err_domain_remove: irq_domain_remove(domain); +err_irq_dispose: + irq_dispose_mapping(parent_irq); return ret; } -- 2.1.0
[PATCH v3 00/14 RESEND] irqchip: Fix potential resource leaks
[git send-email failed due to too many commands, so only cc the major related email and resend it, sorry for that] When I test the irqchip code of Loongson, I read the related code of other chips in drivers/irqchip and I find some potential resource leaks in the error path, I think it is better to fix them. v2: - Split the first patch into a new patch series which includes small patches and add "Fixes" tag - Use "goto" label to handle error path in some patches v3: - Add missed variable "ret" in the patch #5 and #13, sorry for that Tiezhu Yang (14): irqchip/ath79-misc: Fix potential resource leaks irqchip/csky-apb-intc: Fix potential resource leaks irqchip/csky-mpintc: Fix potential resource leaks irqchip/davinci-aintc: Fix potential resource leaks irqchip/davinci-cp-intc: Fix potential resource leaks irqchip/digicolor: Fix potential resource leaks irqchip/dw-apb-ictl: Fix potential resource leaks irqchip/ls1x: Fix potential resource leaks irqchip/mscc-ocelot: Fix potential resource leaks irqchip/nvic: Fix potential resource leaks irqchip/omap-intc: Fix potential resource leak irqchip/riscv-intc: Fix potential resource leak irqchip/s3c24xx: Fix potential resource leaks irqchip/xilinx-intc: Fix potential resource leak drivers/irqchip/irq-ath79-misc.c | 14 +++--- drivers/irqchip/irq-csky-apb-intc.c | 12 ++-- drivers/irqchip/irq-csky-mpintc.c | 26 -- drivers/irqchip/irq-davinci-aintc.c | 17 + drivers/irqchip/irq-davinci-cp-intc.c | 18 +++--- drivers/irqchip/irq-digicolor.c | 14 +++--- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- drivers/irqchip/irq-ls1x.c| 4 +++- drivers/irqchip/irq-mscc-ocelot.c | 6 -- drivers/irqchip/irq-nvic.c| 12 +--- drivers/irqchip/irq-omap-intc.c | 4 +++- drivers/irqchip/irq-riscv-intc.c | 1 + drivers/irqchip/irq-s3c24xx.c | 23 +-- drivers/irqchip/irq-xilinx-intc.c | 4 +++- 14 files changed, 128 insertions(+), 38 deletions(-) -- 2.1.0
[PATCH v3 07/14 RESEND] irqchip/dw-apb-ictl: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-dw-apb-ictl.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c index e4550e9..bc9b750 100644 --- a/drivers/irqchip/irq-dw-apb-ictl.c +++ b/drivers/irqchip/irq-dw-apb-ictl.c @@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np, ret = of_address_to_resource(np, 0, ); if (ret) { pr_err("%pOF: unable to get resource\n", np); - return ret; + goto err_irq_dispose; } if (!request_mem_region(r.start, resource_size(), np->full_name)) { pr_err("%pOF: unable to request mem region\n", np); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } iobase = ioremap(r.start, resource_size()); @@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_err("%pOF: unable to alloc irq domain gc\n", np); - goto err_unmap; + goto err_domain_remove; } for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) { @@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np, return 0; +err_domain_remove: + irq_domain_remove(domain); err_unmap: iounmap(iobase); err_release: release_mem_region(r.start, resource_size()); +err_irq_dispose: + irq_dispose_mapping(irq); return ret; } IRQCHIP_DECLARE(dw_apb_ictl, -- 2.1.0
[PATCH v3 10/14 RESEND] irqchip/nvic: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-nvic.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index f747e22..cd17f5d 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node, if (!nvic_irq_domain) { pr_warn("Failed to allocate irq domain\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1, @@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node, clr, 0, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_warn("Failed to allocate irq chips\n"); - irq_domain_remove(nvic_irq_domain); - return ret; + goto err_domain_remove; } for (i = 0; i < numbanks; ++i) { @@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node, writel_relaxed(0, nvic_base + NVIC_IPR + i); return 0; + +err_domain_remove: + irq_domain_remove(nvic_irq_domain); +err_iounmap: + iounmap(nvic_base); + return ret; } IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init); -- 2.1.0
[PATCH v3 11/14 RESEND] irqchip/omap-intc: Fix potential resource leak
There exists potential resource leak in the error path, fix it. Fixes: 8598066cddd1 ("arm: omap: irq: move irq.c to drivers/irqchip/") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-omap-intc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c index d360a6e..e711530 100644 --- a/drivers/irqchip/irq-omap-intc.c +++ b/drivers/irqchip/irq-omap-intc.c @@ -254,8 +254,10 @@ static int __init omap_init_irq_of(struct device_node *node) omap_irq_soft_reset(); ret = omap_alloc_gc_of(domain, omap_irq_base); - if (ret < 0) + if (ret < 0) { irq_domain_remove(domain); + iounmap(omap_irq_base); + } return ret; } -- 2.1.0
[PATCH v3 08/14 RESEND] irqchip/ls1x: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 9e543e22e204 ("irqchip: Add driver for Loongson-1 interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ls1x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-ls1x.c b/drivers/irqchip/irq-ls1x.c index 353111a..409001b 100644 --- a/drivers/irqchip/irq-ls1x.c +++ b/drivers/irqchip/irq-ls1x.c @@ -131,7 +131,7 @@ static int __init ls1x_intc_of_init(struct device_node *node, if (!priv->domain) { pr_err("ls1x-irq: cannot add IRQ domain\n"); err = -ENOMEM; - goto out_iounmap; + goto out_dispose_irq; } err = irq_alloc_domain_generic_chips(priv->domain, 32, 2, @@ -182,6 +182,8 @@ static int __init ls1x_intc_of_init(struct device_node *node, out_free_domain: irq_domain_remove(priv->domain); +out_dispose_irq: + irq_dispose_mapping(parent_irq); out_iounmap: iounmap(priv->intc_base); out_free_priv: -- 2.1.0
[PATCH v3 05/14 RESEND] irqchip/davinci-cp-intc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-cp-intc.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c index 276da277..2c2e115 100644 --- a/drivers/irqchip/irq-davinci-cp-intc.c +++ b/drivers/irqchip/irq-davinci-cp-intc.c @@ -162,6 +162,7 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, unsigned int num_regs = BITS_TO_LONGS(config->num_irqs); int offset, irq_base; void __iomem *req; + int ret; req = request_mem_region(config->reg.start, resource_size(>reg), @@ -175,7 +176,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, resource_size(>reg)); if (!davinci_cp_intc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_release; } davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE); @@ -210,7 +212,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return irq_base; + ret = irq_base; + goto err_iounmap; } davinci_cp_intc_irq_domain = irq_domain_add_legacy( @@ -219,7 +222,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (!davinci_cp_intc_irq_domain) { pr_err("%s: unable to create an interrupt domain\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_free_descs; } set_handle_irq(davinci_cp_intc_handle_irq); @@ -228,6 +232,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE); return 0; + +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_cp_intc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); + return ret; } int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config) -- 2.1.0
[PATCH v3 06/14 RESEND] irqchip/digicolor: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 8041dfbd31cf ("irqchip: Conexant CX92755 interrupts controller driver") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-digicolor.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c index fc38d2d..18c6e77 100644 --- a/drivers/irqchip/irq-digicolor.c +++ b/drivers/irqchip/irq-digicolor.c @@ -89,7 +89,8 @@ static int __init digicolor_of_init(struct device_node *node, ucregs = syscon_regmap_lookup_by_phandle(node, "syscon"); if (IS_ERR(ucregs)) { pr_err("%pOF: unable to map UC registers\n", node); - return PTR_ERR(ucregs); + ret = PTR_ERR(ucregs); + goto err_iounmap; } /* channel 1, regular IRQs */ regmap_write(ucregs, UC_IRQ_CONTROL, 1); @@ -98,7 +99,8 @@ static int __init digicolor_of_init(struct device_node *node, irq_domain_add_linear(node, 64, _generic_chip_ops, NULL); if (!digicolor_irq_domain) { pr_err("%pOF: unable to create IRQ domain\n", node); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(digicolor_irq_domain, 32, 1, @@ -106,7 +108,7 @@ static int __init digicolor_of_init(struct device_node *node, clr, 0, 0); if (ret) { pr_err("%pOF: unable to allocate IRQ gc\n", node); - return ret; + goto err_domain_remove; } digicolor_set_gc(reg_base, 0, IC_INT0ENABLE_LO, IC_FLAG_CLEAR_LO); @@ -115,5 +117,11 @@ static int __init digicolor_of_init(struct device_node *node, set_handle_irq(digicolor_handle_irq); return 0; + +err_domain_remove: + irq_domain_remove(digicolor_irq_domain); +err_iounmap: + iounmap(reg_base); + return ret; } IRQCHIP_DECLARE(conexant_digicolor_ic, "cnxt,cx92755-ic", digicolor_of_init); -- 2.1.0
[PATCH v3 04/14 RESEND] irqchip/davinci-aintc: Fix potential resource leaks
There exists potential resource leaks in the error path, fix them. Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-aintc.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c index 810ccc4..12db502 100644 --- a/drivers/irqchip/irq-davinci-aintc.c +++ b/drivers/irqchip/irq-davinci-aintc.c @@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) resource_size(>reg)); if (!davinci_aintc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return; + goto err_release; } /* Clear all interrupt requests */ @@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return; + goto err_iounmap; } davinci_aintc_irq_domain = irq_domain_add_legacy(NULL, @@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) _domain_simple_ops, NULL); if (!davinci_aintc_irq_domain) { pr_err("%s: unable to create interrupt domain\n", __func__); - return; + goto err_free_descs; } ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1, @@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (ret) { pr_err("%s: unable to allocate generic irq chips for domain\n", __func__); - return; + goto err_domain_remove; } for (irq_off = 0, reg_off = 0; @@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) irq_base + irq_off, 32); set_handle_irq(davinci_aintc_handle_irq); + +err_domain_remove: + irq_domain_remove(davinci_aintc_irq_domain); +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_aintc_base); +err_release: + release_mem_region(config->reg.start, resource_size(>reg)); } -- 2.1.0
Re: [PATCH v3 00/14 RESEND] irqchip: Fix potential resource leaks
On 06/24/2020 04:30 PM, Marc Zyngier wrote: On 2020-06-24 08:44, Tiezhu Yang wrote: [git send-email failed due to too many commands, so only cc the major related email and resend it, sorry for that] This is becoming majorly annoying. Please fix your git setup *before* dumping 57 emails for just 14 patches. You have done the same thing yesterday, and I would hope you learned from your mistakes. Also, do not repost a series more than once per week. You have already exceeded your quota by quite a margin. I am very sorry for that. I will wait for some days to resend this patch series. M.
Re: [PATCH v2 7/7 RESEND] dt-bindings: interrupt-controller: Fix typos in loongson,liointc.yaml
On 06/24/2020 04:42 PM, Sergei Shtylyov wrote: Hello! On 24.06.2020 9:45, Tiezhu Yang wrote: Fix the following two typos in loongson,liointc.yaml: fron -> from it's -> its Fixes: b6280c8bb6f5 ("dt-bindings: interrupt-controller: Add Loongson LIOINTC") Signed-off-by: Tiezhu Yang --- .../devicetree/bindings/interrupt-controller/loongson,liointc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml index b1db21e..13908ca 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml @@ -51,8 +51,8 @@ properties: description: | This property points how the children interrupts will be mapped into CPU interrupt lines. Each cell refers to a parent interrupt line from 0 to 3 - and each bit in the cell refers to a children interrupt fron 0 to 31. - If a CPU interrupt line didn't connected with liointc, then keep it's + and each bit in the cell refers to a children interrupt from 0 to 31. + If a CPU interrupt line didn't connected with liointc, then keep its "Connect", while you're at it? OK, thank you. I will do it in the next version, maybe some days later. cell with zero. $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 4 MBR, Sergei
Re: [1/7] irqchip: Fix potential resource leaks
On 06/24/2020 04:42 PM, Markus Elfring wrote: Can it helpful to add jump targets so that a bit of exception handling can be better reused at the end of this function? OK, no problem, I will do it in the v2. It seems that the software evolution will be continued with another update suggestion like the following. [PATCH v3 10/14 RESEND] irqchip/nvic: Fix potential resource leaks https://lore.kernel.org/linux-mips/1592984711-3130-11-git-send-email-yangtie...@loongson.cn/ https://lore.kernel.org/patchwork/patch/1263191/ Can it matter to omit the word “potential” from change descriptions after you detected that specific function calls were missing in if branches? Oh, I find this issue through code review, I have no test environment to trigger the error path, but I think it is better to release the resource in the error path, so I use "potential" description. Regards, Markus
Re: [PATCH 1/7] irqchip: Fix potential resource leaks
On 06/24/2020 05:15 PM, Krzysztof Kozlowski wrote: On Tue, 23 Jun 2020 at 10:51, Tiezhu Yang wrote: There exists some potential resource leaks in the error path, fix them. This should be split per driver and per bug (although mostly in driver it's just one bug). Otherwise it is difficult to review, backport and revert. Thanks for your suggestion, I have split it into a patch series [1], I will resend it some days later due to git send-email always failed. [1] https://lore.kernel.org/patchwork/cover/1263192/ Best regards, Krzysztof Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-ath79-misc.c | 3 +++ drivers/irqchip/irq-csky-apb-intc.c | 3 +++ drivers/irqchip/irq-csky-mpintc.c | 26 -- drivers/irqchip/irq-davinci-aintc.c | 17 + drivers/irqchip/irq-davinci-cp-intc.c | 17 ++--- drivers/irqchip/irq-digicolor.c | 4 drivers/irqchip/irq-dw-apb-ictl.c | 11 --- drivers/irqchip/irq-loongson-htvec.c | 5 - drivers/irqchip/irq-ls1x.c| 4 +++- drivers/irqchip/irq-mscc-ocelot.c | 6 -- drivers/irqchip/irq-nvic.c| 2 ++ drivers/irqchip/irq-omap-intc.c | 4 +++- drivers/irqchip/irq-riscv-intc.c | 1 + drivers/irqchip/irq-s3c24xx.c | 20 +++- drivers/irqchip/irq-xilinx-intc.c | 1 + 15 files changed, 98 insertions(+), 26 deletions(-)
Re: [1/7] irqchip: Fix potential resource leaks
On 06/24/2020 05:23 PM, Markus Elfring wrote: [PATCH v3 10/14 RESEND] irqchip/nvic: Fix potential resource leaks https://lore.kernel.org/linux-mips/1592984711-3130-11-git-send-email-yangtie...@loongson.cn/ https://lore.kernel.org/patchwork/patch/1263191/ Can it matter to omit the word “potential” from change descriptions after you detected that specific function calls were missing in if branches? Oh, I find this issue through code review, I have no test environment to trigger the error path, but I think it is better to release the resource in the error path, so I use "potential" description. Did you determine that special function calls were generally missing in error cases? Yes, I read many files in drivers/irqchip, the resource is released in the error path. Were any known software analysis tools involved for the detection of questionable source code places? kmemleak can detect memory leak, but I do not know how to detect other kind of leaks. I think consciously release resource in the error path can avoid leaks. Regards, Markus