From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F74C433F5 for ; Mon, 3 Oct 2022 07:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbiJCHMY (ORCPT ); Mon, 3 Oct 2022 03:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbiJCHMT (ORCPT ); Mon, 3 Oct 2022 03:12:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19A2938465; Mon, 3 Oct 2022 00:12:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C8140B80E67; Mon, 3 Oct 2022 07:12:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFBA4C433D7; Mon, 3 Oct 2022 07:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781131; bh=EV0UFiTw4zmp+/QrmHKwqSCnv35GQfstFaelby4prYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P08kGE+iHAvf8Tgl8u1oIPJwy5HB94nfh//XvkIWDAsg7+yIGanPL1uar51UDcg5Y +WWD2DaNrG3DTfCwUyFLiKPbcPyUwgjzAM22L8nFgKw0nFbZYahhVsD5jd2b5G2cdc fIEH2HdAkdllV7tZGlQXw43PlLE2A/XtNH26do7w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Heiko Stuebner , Guo Ren , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.19 001/101] riscv: make t-head erratas depend on MMU Date: Mon, 3 Oct 2022 09:09:57 +0200 Message-Id: <20221003070724.531191578@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Heiko Stuebner [ Upstream commit 2a2018c3ac84c2dc7cfbad117ce9339ea0914622 ] Both basic extensions of SVPBMT and ZICBOM depend on CONFIG_MMU. Make the T-Head errata implementations of the similar functionality also depend on it to prevent build errors. Fixes: a35707c3d850 ("riscv: add memory-type errata for T-Head") Fixes: d20ec7529236 ("riscv: implement cache-management errata for T-Head S= oCs") Reported-by: kernel test robot Signed-off-by: Heiko Stuebner Reviewed-by: Guo Ren Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220907154932.2858518-1-heiko@sntech.de Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/riscv/Kconfig.erratas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig.erratas b/arch/riscv/Kconfig.erratas index 457ac72c9b36..e59a770b4432 100644 --- a/arch/riscv/Kconfig.erratas +++ b/arch/riscv/Kconfig.erratas @@ -46,7 +46,7 @@ config ERRATA_THEAD =20 config ERRATA_THEAD_PBMT bool "Apply T-Head memory type errata" - depends on ERRATA_THEAD && 64BIT + depends on ERRATA_THEAD && 64BIT && MMU select RISCV_ALTERNATIVE_EARLY default y help --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47176C433FE for ; Mon, 3 Oct 2022 07:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbiJCHNu (ORCPT ); Mon, 3 Oct 2022 03:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbiJCHMz (ORCPT ); Mon, 3 Oct 2022 03:12:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B34402E7; Mon, 3 Oct 2022 00:12:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D3F2B80E67; Mon, 3 Oct 2022 07:12:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6087C433C1; Mon, 3 Oct 2022 07:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781156; bh=k7V3V4Hsxr6o2tHSNWJzPqBi2nn7WhKBYo9GdwPlTpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZoFPb/ZvrcHTFtC3FqUhy9xII1oDGLScdZA8/96h6famgMTXybywLw8XpU6u6x6/K mMbLpTGiwrQeoFCH3QaY5Rf9H0lhhwFbmTjM1L4MciIY4/jInQaS4gyTfdl372HpAx 0OlI1omhv+Vhg20X3TPu8LGGexw8fA/MhWW7Efa4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nageswara R Sastry , Athira Jajeev , Arnaldo Carvalho de Melo , Jiri Olsa , Kajol Jain , Madhavan Srinivasan , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Sasha Levin Subject: [PATCH 5.19 002/101] tools/perf: Fix out of bound access to cpu mask array Date: Mon, 3 Oct 2022 09:09:58 +0200 Message-Id: <20221003070724.557522335@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Athira Rajeev [ Upstream commit cbd7bfc7fd99acdde58ec2b0bce990158fba1654 ] The cpu mask init code in "record__mmap_cpu_mask_init" function access "bits" array part of "struct mmap_cpu_mask". The size of this array is the value from cpu__max_cpu().cpu. This array is used to contain the cpumask value for each cpu. While setting bit for each cpu, it calls "set_bit" function which access index in "bits" array. If we provide a command line option to -C which is greater than the number of CPU's present in the system, the set_bit could access an array member which is out-of the array size. This is because currently, there is no boundary check for the CPU. This will result in seg fault: <<>> ./perf record -C 12341234 ls Perf can support 2048 CPUs. Consider raising MAX_NR_CPUS Segmentation fault (core dumped) <<>> Debugging with gdb, points to function flow as below: <<>> set_bit record__mmap_cpu_mask_init record__init_thread_default_masks record__init_thread_masks cmd_record <<>> Fix this by adding boundary check for the array. After the patch: <<>> ./perf record -C 12341234 ls Perf can support 2048 CPUs. Consider raising MAX_NR_CPUS Failed to initialize parallel data streaming masks <<>> With this fix, if -C is given a non-exsiting CPU, perf record will fail with: <<>> ./perf record -C 50 ls Failed to initialize parallel data streaming masks <<>> Reported-by: Nageswara R Sastry Signed-off-by: Athira Jajeev Tested-by: Arnaldo Carvalho de Melo Tested-by: Nageswara R Sastry Cc: Jiri Olsa Cc: Kajol Jain Cc: Madhavan Srinivasan Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20220905141929.7171-2-atrajeev@linux.vnet.i= bm.com Signed-off-by: Arnaldo Carvalho de Melo Stable-dep-of: ca76d7d2812b ("perf record: Fix cpu mask bit setting for mix= ed mmaps") Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/builtin-record.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 68c878b4e5e4..708880a1c83c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -3335,16 +3335,22 @@ static struct option __record_options[] =3D { =20 struct option *record_options =3D __record_options; =20 -static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct = perf_cpu_map *cpus) +static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct p= erf_cpu_map *cpus) { struct perf_cpu cpu; int idx; =20 if (cpu_map__is_dummy(cpus)) - return; + return 0; =20 - perf_cpu_map__for_each_cpu(cpu, idx, cpus) + perf_cpu_map__for_each_cpu(cpu, idx, cpus) { + /* Return ENODEV is input cpu is greater than max cpu */ + if ((unsigned long)cpu.cpu > mask->nbits) + return -ENODEV; set_bit(cpu.cpu, mask->bits); + } + + return 0; } =20 static int record__mmap_cpu_mask_init_spec(struct mmap_cpu_mask *mask, con= st char *mask_spec) @@ -3356,7 +3362,9 @@ static int record__mmap_cpu_mask_init_spec(struct mma= p_cpu_mask *mask, const cha return -ENOMEM; =20 bitmap_zero(mask->bits, mask->nbits); - record__mmap_cpu_mask_init(mask, cpus); + if (record__mmap_cpu_mask_init(mask, cpus)) + return -ENODEV; + perf_cpu_map__put(cpus); =20 return 0; @@ -3438,7 +3446,12 @@ static int record__init_thread_masks_spec(struct rec= ord *rec, struct perf_cpu_ma pr_err("Failed to allocate CPUs mask\n"); return ret; } - record__mmap_cpu_mask_init(&cpus_mask, cpus); + + ret =3D record__mmap_cpu_mask_init(&cpus_mask, cpus); + if (ret) { + pr_err("Failed to init cpu mask\n"); + goto out_free_cpu_mask; + } =20 ret =3D record__thread_mask_alloc(&full_mask, cpu__max_cpu().cpu); if (ret) { @@ -3679,7 +3692,8 @@ static int record__init_thread_default_masks(struct r= ecord *rec, struct perf_cpu if (ret) return ret; =20 - record__mmap_cpu_mask_init(&rec->thread_masks->maps, cpus); + if (record__mmap_cpu_mask_init(&rec->thread_masks->maps, cpus)) + return -ENODEV; =20 rec->nr_threads =3D 1; =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F0FFC4332F for ; Mon, 3 Oct 2022 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiJCHN6 (ORCPT ); Mon, 3 Oct 2022 03:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiJCHM5 (ORCPT ); Mon, 3 Oct 2022 03:12:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BF53A4BC; Mon, 3 Oct 2022 00:12:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 499A6B80E6B; Mon, 3 Oct 2022 07:12:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A14EFC433C1; Mon, 3 Oct 2022 07:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781159; bh=B6Ct1dz8v8oZkert7QrNcltIhwbgLcAbbGDlHJYJWms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TgGv9ada1YFbY3te/7DGGkH+c3hOQJf+UYQ5woxWiLAjp2+E5o3WtjshyHALzJZAP derHkpX4AtmPdgyKLAAH0+xpZr1N5PJFtbevt4Zz6DUxTM2WbQF1iJYHL+lSpY5G51 GYuOw/T+GTbVelxUu5SYv+2lPxIxZKB5tLvSrjeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Namhyung Kim , Athira Rajeev , Ian Rogers , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 003/101] perf record: Fix cpu mask bit setting for mixed mmaps Date: Mon, 3 Oct 2022 09:09:59 +0200 Message-Id: <20221003070724.583961037@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Adrian Hunter [ Upstream commit ca76d7d2812b46124291f99c9b50aaf63a936f23 ] With mixed per-thread and (system-wide) per-cpu maps, the "any cpu" value -1 must be skipped when setting CPU mask bits. Prior to commit cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access to cpu mask array") the invalid setting went unnoticed, but since then it causes perf record to fail with an error. Example: Before: $ perf record -e intel_pt// --per-thread uname Failed to initialize parallel data streaming masks After: $ perf record -e intel_pt// --per-thread uname Linux [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.068 MB perf.data ] Fixes: ae4f8ae16a078964 ("libperf evlist: Allow mixing per-thread and per-c= pu mmaps") Signed-off-by: Adrian Hunter Acked-by: Namhyung Kim Cc: Athira Rajeev Cc: Ian Rogers Cc: Jiri Olsa Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220915122612.81738-2-adrian.hunter@intel.= com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/builtin-record.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 708880a1c83c..7fbc85c1da81 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -3344,6 +3344,8 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu= _mask *mask, struct perf_cp return 0; =20 perf_cpu_map__for_each_cpu(cpu, idx, cpus) { + if (cpu.cpu =3D=3D -1) + continue; /* Return ENODEV is input cpu is greater than max cpu */ if ((unsigned long)cpu.cpu > mask->nbits) return -ENODEV; --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B612C4332F for ; Mon, 3 Oct 2022 07:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbiJCHOV (ORCPT ); Mon, 3 Oct 2022 03:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbiJCHNR (ORCPT ); Mon, 3 Oct 2022 03:13:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6034333B; Mon, 3 Oct 2022 00:12:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1AC81B80E65; Mon, 3 Oct 2022 07:12:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47954C433D6; Mon, 3 Oct 2022 07:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781161; bh=EMX1hIXsoJuNfe/hfMW8cmBmiDYk7jG0rtirzCg1I54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z0y9Ne3bg5xcW2Z1uukKGj/uEq4HDNQfUj/8OwyL8iPvcuA/t1APIZ71yBewE6vul 3mYRE8zQNlths1mJbRq8lUb/d+6LgCJlo6GxHlYHRSvI5ePsKOyj6lai6YG5OhiV8E v5CMw1LjpwbxUQKidgIkGJkUvI6QeHDn7l6OfkBc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Syed Nayyar Waris , David Laight , Linus Walleij , William Breathitt Gray , Sasha Levin Subject: [PATCH 5.19 004/101] counter: 104-quad-8: Utilize iomap interface Date: Mon, 3 Oct 2022 09:10:00 +0200 Message-Id: <20221003070724.611391952@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: William Breathitt Gray [ Upstream commit b6e9cded90d46b1066a1ca260d8b5ecf67787aba ] This driver doesn't need to access I/O ports directly via inb()/outb() and friends. This patch abstracts such access by calling ioport_map() to enable the use of more typical ioread8()/iowrite8() I/O memory accessor calls. Link: https://lore.kernel.org/r/861c003318dce3d2bef4061711643bb04f5ec14f.16= 52201921.git.william.gray@linaro.org Cc: Syed Nayyar Waris Suggested-by: David Laight Reviewed-by: Linus Walleij Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/e971b897cacfac4cb2eca478f5533d2875f5cadd.16= 57813472.git.william.gray@linaro.org Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 2bc54aaa65d2 ("counter: 104-quad-8: Fix skipped IRQ lines du= ring events configuration") Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/counter/104-quad-8.c | 169 ++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 80 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index a17e51d65aca..43dde9abfdcf 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -63,7 +63,7 @@ struct quad8 { unsigned int synchronous_mode[QUAD8_NUM_COUNTERS]; unsigned int index_polarity[QUAD8_NUM_COUNTERS]; unsigned int cable_fault_enable; - unsigned int base; + void __iomem *base; }; =20 #define QUAD8_REG_INTERRUPT_STATUS 0x10 @@ -118,8 +118,8 @@ static int quad8_signal_read(struct counter_device *cou= nter, if (signal->id < 16) return -EINVAL; =20 - state =3D inb(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) - & BIT(signal->id - 16); + state =3D ioread8(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) & + BIT(signal->id - 16); =20 *level =3D (state) ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; =20 @@ -130,14 +130,14 @@ static int quad8_count_read(struct counter_device *co= unter, struct counter_count *count, u64 *val) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned int flags; unsigned int borrow; unsigned int carry; unsigned long irqflags; int i; =20 - flags =3D inb(base_offset + 1); + flags =3D ioread8(base_offset + 1); borrow =3D flags & QUAD8_FLAG_BT; carry =3D !!(flags & QUAD8_FLAG_CT); =20 @@ -147,11 +147,11 @@ static int quad8_count_read(struct counter_device *co= unter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer; transfer Counter to Output Latch */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, - base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, + base_offset + 1); =20 for (i =3D 0; i < 3; i++) - *val |=3D (unsigned long)inb(base_offset) << (8 * i); + *val |=3D (unsigned long)ioread8(base_offset) << (8 * i); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -162,7 +162,7 @@ static int quad8_count_write(struct counter_device *cou= nter, struct counter_count *count, u64 val) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned long irqflags; int i; =20 @@ -173,27 +173,27 @@ static int quad8_count_write(struct counter_device *c= ounter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Counter can only be set via Preset Register */ for (i =3D 0; i < 3; i++) - outb(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), base_offset); =20 /* Transfer Preset Register to Counter */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set Preset Register back to original value */ val =3D priv->preset[count->id]; for (i =3D 0; i < 3; i++) - outb(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), base_offset); =20 /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); /* Reset Error flag */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -246,7 +246,7 @@ static int quad8_function_write(struct counter_device *= counter, unsigned int *const quadrature_mode =3D priv->quadrature_mode + id; unsigned int *const scale =3D priv->quadrature_scale + id; unsigned int *const synchronous_mode =3D priv->synchronous_mode + id; - const int base_offset =3D priv->base + 2 * id + 1; + void __iomem *const base_offset =3D priv->base + 2 * id + 1; unsigned long irqflags; unsigned int mode_cfg; unsigned int idr_cfg; @@ -266,7 +266,7 @@ static int quad8_function_write(struct counter_device *= counter, if (*synchronous_mode) { *synchronous_mode =3D 0; /* Disable synchronous function mode */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); } } else { *quadrature_mode =3D 1; @@ -292,7 +292,7 @@ static int quad8_function_write(struct counter_device *= counter, } =20 /* Load mode configuration to Counter Mode Register */ - outb(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -305,10 +305,10 @@ static int quad8_direction_read(struct counter_device= *counter, { const struct quad8 *const priv =3D counter_priv(counter); unsigned int ud_flag; - const unsigned int flag_addr =3D priv->base + 2 * count->id + 1; + void __iomem *const flag_addr =3D priv->base + 2 * count->id + 1; =20 /* U/D flag: nonzero =3D up, zero =3D down */ - ud_flag =3D inb(flag_addr) & QUAD8_FLAG_UD; + ud_flag =3D ioread8(flag_addr) & QUAD8_FLAG_UD; =20 *direction =3D (ud_flag) ? COUNTER_COUNT_DIRECTION_FORWARD : COUNTER_COUNT_DIRECTION_BACKWARD; @@ -402,7 +402,7 @@ static int quad8_events_configure(struct counter_device= *counter) struct counter_event_node *event_node; unsigned int next_irq_trigger; unsigned long ior_cfg; - unsigned long base_offset; + void __iomem *base_offset; =20 spin_lock_irqsave(&priv->lock, irqflags); =20 @@ -438,13 +438,13 @@ static int quad8_events_configure(struct counter_devi= ce *counter) priv->preset_enable[event_node->channel] << 1 | priv->irq_trigger[event_node->channel] << 3; base_offset =3D priv->base + 2 * event_node->channel + 1; - outb(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); =20 /* Enable IRQ line */ irq_enabled |=3D BIT(event_node->channel); } =20 - outb(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -508,7 +508,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - const int base_offset =3D priv->base + 2 * channel_id + 1; + void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; unsigned long irqflags; unsigned int idr_cfg =3D index_polarity << 1; =20 @@ -519,7 +519,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, priv->index_polarity[channel_id] =3D index_polarity; =20 /* Load Index Control configuration to Index Control Register */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -549,7 +549,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - const int base_offset =3D priv->base + 2 * channel_id + 1; + void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; unsigned long irqflags; unsigned int idr_cfg =3D synchronous_mode; =20 @@ -566,7 +566,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, priv->synchronous_mode[channel_id] =3D synchronous_mode; =20 /* Load Index Control configuration to Index Control Register */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -614,7 +614,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, struct quad8 *const priv =3D counter_priv(counter); unsigned int count_mode; unsigned int mode_cfg; - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; unsigned long irqflags; =20 /* Map Generic Counter count mode to 104-QUAD-8 count mode */ @@ -648,7 +648,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, mode_cfg |=3D (priv->quadrature_scale[count->id] + 1) << 3; =20 /* Load mode configuration to Counter Mode Register */ - outb(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -669,7 +669,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, struct counter_count *count, u8 enable) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -681,7 +681,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration */ - outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -697,9 +697,9 @@ static int quad8_error_noise_get(struct counter_device = *counter, struct counter_count *count, u32 *noise_error) { const struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; =20 - *noise_error =3D !!(inb(base_offset) & QUAD8_FLAG_E); + *noise_error =3D !!(ioread8(base_offset) & QUAD8_FLAG_E); =20 return 0; } @@ -717,17 +717,17 @@ static int quad8_count_preset_read(struct counter_dev= ice *counter, static void quad8_preset_register_set(struct quad8 *const priv, const int = id, const unsigned int preset) { - const unsigned int base_offset =3D priv->base + 2 * id; + void __iomem *const base_offset =3D priv->base + 2 * id; int i; =20 priv->preset[id] =3D preset; =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set Preset Register */ for (i =3D 0; i < 3; i++) - outb(preset >> (8 * i), base_offset); + iowrite8(preset >> (8 * i), base_offset); } =20 static int quad8_count_preset_write(struct counter_device *counter, @@ -816,7 +816,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, u8 preset_enable) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -831,7 +831,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration to Input / Output Control Register */ - outb(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -858,7 +858,7 @@ static int quad8_signal_cable_fault_read(struct counter= _device *counter, } =20 /* Logic 0 =3D cable fault */ - status =3D inb(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + status =3D ioread8(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -899,7 +899,8 @@ static int quad8_signal_cable_fault_enable_write(struct= counter_device *counter, /* Enable is active low in Differential Encoder Cable Status register */ cable_fault_enable =3D ~priv->cable_fault_enable; =20 - outb(cable_fault_enable, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(cable_fault_enable, + priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -923,7 +924,7 @@ static int quad8_signal_fck_prescaler_write(struct coun= ter_device *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id / 2; - const int base_offset =3D priv->base + 2 * channel_id; + void __iomem *const base_offset =3D priv->base + 2 * channel_id; unsigned long irqflags; =20 spin_lock_irqsave(&priv->lock, irqflags); @@ -931,12 +932,12 @@ static int quad8_signal_fck_prescaler_write(struct co= unter_device *counter, priv->fck_prescaler[channel_id] =3D prescaler; =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set filter clock factor */ - outb(prescaler, base_offset); - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + iowrite8(prescaler, base_offset); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, + base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -1084,12 +1085,12 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) { struct counter_device *counter =3D private; struct quad8 *const priv =3D counter_priv(counter); - const unsigned long base =3D priv->base; + void __iomem *const base =3D priv->base; unsigned long irq_status; unsigned long channel; u8 event; =20 - irq_status =3D inb(base + QUAD8_REG_INTERRUPT_STATUS); + irq_status =3D ioread8(base + QUAD8_REG_INTERRUPT_STATUS); if (!irq_status) return IRQ_NONE; =20 @@ -1118,17 +1119,43 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) } =20 /* Clear pending interrupts on device */ - outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); =20 return IRQ_HANDLED; } =20 +static void quad8_init_counter(void __iomem *const base_offset) +{ + unsigned long i; + + /* Reset Byte Pointer */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + /* Reset filter clock factor */ + iowrite8(0, base_offset); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, + base_offset + 1); + /* Reset Byte Pointer */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + /* Reset Preset Register */ + for (i =3D 0; i < 3; i++) + iowrite8(0x00, base_offset); + /* Reset Borrow, Carry, Compare, and Sign flags */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + /* Reset Error flag */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + /* Binary encoding; Normal count; non-quadrature mode */ + iowrite8(QUAD8_CTR_CMR, base_offset + 1); + /* Disable A and B inputs; preset on index; FLG1 as Carry */ + iowrite8(QUAD8_CTR_IOR, base_offset + 1); + /* Disable index function; negative index polarity */ + iowrite8(QUAD8_CTR_IDR, base_offset + 1); +} + static int quad8_probe(struct device *dev, unsigned int id) { struct counter_device *counter; struct quad8 *priv; - int i, j; - unsigned int base_offset; + unsigned long i; int err; =20 if (!devm_request_region(dev, base[id], QUAD8_EXTENT, dev_name(dev))) { @@ -1142,6 +1169,10 @@ static int quad8_probe(struct device *dev, unsigned = int id) return -ENOMEM; priv =3D counter_priv(counter); =20 + priv->base =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); + if (!priv->base) + return -ENOMEM; + /* Initialize Counter device and driver data */ counter->name =3D dev_name(dev); counter->parent =3D dev; @@ -1150,43 +1181,21 @@ static int quad8_probe(struct device *dev, unsigned= int id) counter->num_counts =3D ARRAY_SIZE(quad8_counts); counter->signals =3D quad8_signals; counter->num_signals =3D ARRAY_SIZE(quad8_signals); - priv->base =3D base[id]; =20 spin_lock_init(&priv->lock); =20 /* Reset Index/Interrupt Register */ - outb(0x00, base[id] + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(0x00, priv->base + QUAD8_REG_INDEX_INTERRUPT); /* Reset all counters and disable interrupt function */ - outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, priv->base + QUAD8_REG_CHAN_OP); /* Set initial configuration for all counters */ - for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) { - base_offset =3D base[id] + 2 * i; - /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); - /* Reset filter clock factor */ - outb(0, base_offset); - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); - /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); - /* Reset Preset Register */ - for (j =3D 0; j < 3; j++) - outb(0x00, base_offset); - /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); - /* Reset Error flag */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); - /* Binary encoding; Normal count; non-quadrature mode */ - outb(QUAD8_CTR_CMR, base_offset + 1); - /* Disable A and B inputs; preset on index; FLG1 as Carry */ - outb(QUAD8_CTR_IOR, base_offset + 1); - /* Disable index function; negative index polarity */ - outb(QUAD8_CTR_IDR, base_offset + 1); - } + for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) + quad8_init_counter(priv->base + 2 * i); /* Disable Differential Encoder Cable Status for all channels */ - outb(0xFF, base[id] + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(0xFF, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); /* Enable all counters and enable interrupt function */ - outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base[id] + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, + priv->base + QUAD8_REG_CHAN_OP); =20 err =3D devm_request_irq(&counter->dev, irq[id], quad8_irq_handler, IRQF_SHARED, counter->name, counter); --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20978C433F5 for ; Mon, 3 Oct 2022 07:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbiJCHOR (ORCPT ); Mon, 3 Oct 2022 03:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbiJCHNR (ORCPT ); Mon, 3 Oct 2022 03:13:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A236636437; Mon, 3 Oct 2022 00:12:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D59C5B80E68; Mon, 3 Oct 2022 07:12:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32FAEC433C1; Mon, 3 Oct 2022 07:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781164; bh=b7MEc65CBx4yIJYcEfzrChpVR1Lo5PY165CiVWjE3iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spiG5EFTZGjTE2NPRJ0sCU04ey3ixlEMp9lODAsCPpCab71xU886YvPZg19oHoK7J 3cRHSwL/rU0Uf71m466v+ucpBgWxz/AXBRKCfuRUVrrmPAMGA7VwCD898agMgQLq1j LjUcTmXP4Nznw9aCRBE12ImmcW1wTC3xtcfvM3IM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Syed Nayyar Waris , Fred Eckert , Jonathan Cameron , William Breathitt Gray , Sasha Levin Subject: [PATCH 5.19 005/101] counter: 104-quad-8: Implement and utilize register structures Date: Mon, 3 Oct 2022 09:10:01 +0200 Message-Id: <20221003070724.637322460@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: William Breathitt Gray [ Upstream commit daae1ee572d1f99daddef26afe6c6fc7aeea741d ] Reduce magic numbers and improve code readability by implementing and utilizing named register data structures. Link: https://lore.kernel.org/r/20220707171709.36010-1-william.gray@linaro.= org/ Cc: Syed Nayyar Waris Tested-by: Fred Eckert Reviewed-by: Jonathan Cameron Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/285fdc7c03892251f50bdbf2c28c19998243a6a3.16= 57813472.git.william.gray@linaro.org Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 2bc54aaa65d2 ("counter: 104-quad-8: Fix skipped IRQ lines du= ring events configuration") Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/counter/104-quad-8.c | 166 ++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 73 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 43dde9abfdcf..62c2b7ac4339 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -33,6 +33,36 @@ MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line n= umbers"); =20 #define QUAD8_NUM_COUNTERS 8 =20 +/** + * struct channel_reg - channel register structure + * @data: Count data + * @control: Channel flags and control + */ +struct channel_reg { + u8 data; + u8 control; +}; + +/** + * struct quad8_reg - device register structure + * @channel: quadrature counter data and control + * @interrupt_status: channel interrupt status + * @channel_oper: enable/reset counters and interrupt functions + * @index_interrupt: enable channel interrupts + * @reserved: reserved for Factory Use + * @index_input_levels: index signal logical input level + * @cable_status: differential encoder cable status + */ +struct quad8_reg { + struct channel_reg channel[QUAD8_NUM_COUNTERS]; + u8 interrupt_status; + u8 channel_oper; + u8 index_interrupt; + u8 reserved[3]; + u8 index_input_levels; + u8 cable_status; +}; + /** * struct quad8 - device private data structure * @lock: lock to prevent clobbering device states during R/W ops @@ -48,7 +78,7 @@ MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line nu= mbers"); * @synchronous_mode: array of index function synchronous mode configurati= ons * @index_polarity: array of index function polarity configurations * @cable_fault_enable: differential encoder cable status enable configura= tions - * @base: base port address of the device + * @reg: I/O address offset for the device registers */ struct quad8 { spinlock_t lock; @@ -63,14 +93,9 @@ struct quad8 { unsigned int synchronous_mode[QUAD8_NUM_COUNTERS]; unsigned int index_polarity[QUAD8_NUM_COUNTERS]; unsigned int cable_fault_enable; - void __iomem *base; + struct quad8_reg __iomem *reg; }; =20 -#define QUAD8_REG_INTERRUPT_STATUS 0x10 -#define QUAD8_REG_CHAN_OP 0x11 -#define QUAD8_REG_INDEX_INTERRUPT 0x12 -#define QUAD8_REG_INDEX_INPUT_LEVELS 0x16 -#define QUAD8_DIFF_ENCODER_CABLE_STATUS 0x17 /* Borrow Toggle flip-flop */ #define QUAD8_FLAG_BT BIT(0) /* Carry Toggle flip-flop */ @@ -118,8 +143,7 @@ static int quad8_signal_read(struct counter_device *cou= nter, if (signal->id < 16) return -EINVAL; =20 - state =3D ioread8(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) & - BIT(signal->id - 16); + state =3D ioread8(&priv->reg->index_input_levels) & BIT(signal->id - 16); =20 *level =3D (state) ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; =20 @@ -130,14 +154,14 @@ static int quad8_count_read(struct counter_device *co= unter, struct counter_count *count, u64 *val) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + count->id; unsigned int flags; unsigned int borrow; unsigned int carry; unsigned long irqflags; int i; =20 - flags =3D ioread8(base_offset + 1); + flags =3D ioread8(&chan->control); borrow =3D flags & QUAD8_FLAG_BT; carry =3D !!(flags & QUAD8_FLAG_CT); =20 @@ -148,10 +172,10 @@ static int quad8_count_read(struct counter_device *co= unter, =20 /* Reset Byte Pointer; transfer Counter to Output Latch */ iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, - base_offset + 1); + &chan->control); =20 for (i =3D 0; i < 3; i++) - *val |=3D (unsigned long)ioread8(base_offset) << (8 * i); + *val |=3D (unsigned long)ioread8(&chan->data) << (8 * i); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -162,7 +186,7 @@ static int quad8_count_write(struct counter_device *cou= nter, struct counter_count *count, u64 val) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + count->id; unsigned long irqflags; int i; =20 @@ -173,27 +197,27 @@ static int quad8_count_write(struct counter_device *c= ounter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Counter can only be set via Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), &chan->data); =20 /* Transfer Preset Register to Counter */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, &chan->control); =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set Preset Register back to original value */ val =3D priv->preset[count->id]; for (i =3D 0; i < 3; i++) - iowrite8(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), &chan->data); =20 /* Reset Borrow, Carry, Compare, and Sign flags */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, &chan->control); /* Reset Error flag */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, &chan->control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -246,7 +270,7 @@ static int quad8_function_write(struct counter_device *= counter, unsigned int *const quadrature_mode =3D priv->quadrature_mode + id; unsigned int *const scale =3D priv->quadrature_scale + id; unsigned int *const synchronous_mode =3D priv->synchronous_mode + id; - void __iomem *const base_offset =3D priv->base + 2 * id + 1; + u8 __iomem *const control =3D &priv->reg->channel[id].control; unsigned long irqflags; unsigned int mode_cfg; unsigned int idr_cfg; @@ -266,7 +290,7 @@ static int quad8_function_write(struct counter_device *= counter, if (*synchronous_mode) { *synchronous_mode =3D 0; /* Disable synchronous function mode */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); } } else { *quadrature_mode =3D 1; @@ -292,7 +316,7 @@ static int quad8_function_write(struct counter_device *= counter, } =20 /* Load mode configuration to Counter Mode Register */ - iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -305,7 +329,7 @@ static int quad8_direction_read(struct counter_device *= counter, { const struct quad8 *const priv =3D counter_priv(counter); unsigned int ud_flag; - void __iomem *const flag_addr =3D priv->base + 2 * count->id + 1; + u8 __iomem *const flag_addr =3D &priv->reg->channel[count->id].control; =20 /* U/D flag: nonzero =3D up, zero =3D down */ ud_flag =3D ioread8(flag_addr) & QUAD8_FLAG_UD; @@ -402,7 +426,6 @@ static int quad8_events_configure(struct counter_device= *counter) struct counter_event_node *event_node; unsigned int next_irq_trigger; unsigned long ior_cfg; - void __iomem *base_offset; =20 spin_lock_irqsave(&priv->lock, irqflags); =20 @@ -437,14 +460,14 @@ static int quad8_events_configure(struct counter_devi= ce *counter) ior_cfg =3D priv->ab_enable[event_node->channel] | priv->preset_enable[event_node->channel] << 1 | priv->irq_trigger[event_node->channel] << 3; - base_offset =3D priv->base + 2 * event_node->channel + 1; - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, + &priv->reg->channel[event_node->channel].control); =20 /* Enable IRQ line */ irq_enabled |=3D BIT(event_node->channel); } =20 - iowrite8(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(irq_enabled, &priv->reg->index_interrupt); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -508,7 +531,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; + u8 __iomem *const control =3D &priv->reg->channel[channel_id].control; unsigned long irqflags; unsigned int idr_cfg =3D index_polarity << 1; =20 @@ -519,7 +542,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, priv->index_polarity[channel_id] =3D index_polarity; =20 /* Load Index Control configuration to Index Control Register */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -549,7 +572,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; + u8 __iomem *const control =3D &priv->reg->channel[channel_id].control; unsigned long irqflags; unsigned int idr_cfg =3D synchronous_mode; =20 @@ -566,7 +589,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, priv->synchronous_mode[channel_id] =3D synchronous_mode; =20 /* Load Index Control configuration to Index Control Register */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -614,7 +637,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, struct quad8 *const priv =3D counter_priv(counter); unsigned int count_mode; unsigned int mode_cfg; - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; =20 /* Map Generic Counter count mode to 104-QUAD-8 count mode */ @@ -648,7 +671,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, mode_cfg |=3D (priv->quadrature_scale[count->id] + 1) << 3; =20 /* Load mode configuration to Counter Mode Register */ - iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -669,7 +692,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, struct counter_count *count, u8 enable) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -681,7 +704,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration */ - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); + iowrite8(QUAD8_CTR_IOR | ior_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -697,9 +720,9 @@ static int quad8_error_noise_get(struct counter_device = *counter, struct counter_count *count, u32 *noise_error) { const struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const flag_addr =3D &priv->reg->channel[count->id].control; =20 - *noise_error =3D !!(ioread8(base_offset) & QUAD8_FLAG_E); + *noise_error =3D !!(ioread8(flag_addr) & QUAD8_FLAG_E); =20 return 0; } @@ -717,17 +740,17 @@ static int quad8_count_preset_read(struct counter_dev= ice *counter, static void quad8_preset_register_set(struct quad8 *const priv, const int = id, const unsigned int preset) { - void __iomem *const base_offset =3D priv->base + 2 * id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + id; int i; =20 priv->preset[id] =3D preset; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(preset >> (8 * i), base_offset); + iowrite8(preset >> (8 * i), &chan->data); } =20 static int quad8_count_preset_write(struct counter_device *counter, @@ -816,7 +839,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, u8 preset_enable) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -831,7 +854,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration to Input / Output Control Register */ - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -858,7 +881,7 @@ static int quad8_signal_cable_fault_read(struct counter= _device *counter, } =20 /* Logic 0 =3D cable fault */ - status =3D ioread8(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + status =3D ioread8(&priv->reg->cable_status); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -899,8 +922,7 @@ static int quad8_signal_cable_fault_enable_write(struct= counter_device *counter, /* Enable is active low in Differential Encoder Cable Status register */ cable_fault_enable =3D ~priv->cable_fault_enable; =20 - iowrite8(cable_fault_enable, - priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(cable_fault_enable, &priv->reg->cable_status); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -924,7 +946,7 @@ static int quad8_signal_fck_prescaler_write(struct coun= ter_device *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id / 2; - void __iomem *const base_offset =3D priv->base + 2 * channel_id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + channel_i= d; unsigned long irqflags; =20 spin_lock_irqsave(&priv->lock, irqflags); @@ -932,12 +954,12 @@ static int quad8_signal_fck_prescaler_write(struct co= unter_device *counter, priv->fck_prescaler[channel_id] =3D prescaler; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set filter clock factor */ - iowrite8(prescaler, base_offset); + iowrite8(prescaler, &chan->data); iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + &chan->control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -1085,12 +1107,11 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) { struct counter_device *counter =3D private; struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base =3D priv->base; unsigned long irq_status; unsigned long channel; u8 event; =20 - irq_status =3D ioread8(base + QUAD8_REG_INTERRUPT_STATUS); + irq_status =3D ioread8(&priv->reg->interrupt_status); if (!irq_status) return IRQ_NONE; =20 @@ -1119,36 +1140,36 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) } =20 /* Clear pending interrupts on device */ - iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, &priv->reg->channel_oper); =20 return IRQ_HANDLED; } =20 -static void quad8_init_counter(void __iomem *const base_offset) +static void quad8_init_counter(struct channel_reg __iomem *const chan) { unsigned long i; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); /* Reset filter clock factor */ - iowrite8(0, base_offset); + iowrite8(0, &chan->data); iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + &chan->control); /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); /* Reset Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(0x00, base_offset); + iowrite8(0x00, &chan->data); /* Reset Borrow, Carry, Compare, and Sign flags */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, &chan->control); /* Reset Error flag */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, &chan->control); /* Binary encoding; Normal count; non-quadrature mode */ - iowrite8(QUAD8_CTR_CMR, base_offset + 1); + iowrite8(QUAD8_CTR_CMR, &chan->control); /* Disable A and B inputs; preset on index; FLG1 as Carry */ - iowrite8(QUAD8_CTR_IOR, base_offset + 1); + iowrite8(QUAD8_CTR_IOR, &chan->control); /* Disable index function; negative index polarity */ - iowrite8(QUAD8_CTR_IDR, base_offset + 1); + iowrite8(QUAD8_CTR_IDR, &chan->control); } =20 static int quad8_probe(struct device *dev, unsigned int id) @@ -1169,8 +1190,8 @@ static int quad8_probe(struct device *dev, unsigned i= nt id) return -ENOMEM; priv =3D counter_priv(counter); =20 - priv->base =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); - if (!priv->base) + priv->reg =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); + if (!priv->reg) return -ENOMEM; =20 /* Initialize Counter device and driver data */ @@ -1185,17 +1206,16 @@ static int quad8_probe(struct device *dev, unsigned= int id) spin_lock_init(&priv->lock); =20 /* Reset Index/Interrupt Register */ - iowrite8(0x00, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(0x00, &priv->reg->index_interrupt); /* Reset all counters and disable interrupt function */ - iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, priv->base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, &priv->reg->channel_oper); /* Set initial configuration for all counters */ for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) - quad8_init_counter(priv->base + 2 * i); + quad8_init_counter(priv->reg->channel + i); /* Disable Differential Encoder Cable Status for all channels */ - iowrite8(0xFF, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(0xFF, &priv->reg->cable_status); /* Enable all counters and enable interrupt function */ - iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, - priv->base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, &priv->reg->channel_oper); =20 err =3D devm_request_irq(&counter->dev, irq[id], quad8_irq_handler, IRQF_SHARED, counter->name, counter); --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEB56C433FE for ; Mon, 3 Oct 2022 07:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbiJCHO0 (ORCPT ); Mon, 3 Oct 2022 03:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbiJCHNU (ORCPT ); Mon, 3 Oct 2022 03:13:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D833EA4F; Mon, 3 Oct 2022 00:12:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6D4B60F9A; Mon, 3 Oct 2022 07:12:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB6F6C433D6; Mon, 3 Oct 2022 07:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781167; bh=Lh2CViwMROmNg68AF88Ts0GLIYttPkhHlWpqusuk6MA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TgydtPEwImhvdxT17zVv59hmNgSK29b+q40xcZmkfvmchHcc5RboEkaqK4CRy6cMb jGTmtLlxlku7i8X1Kf6anDcz1O8aYF2TODpbbYk9Lkdz6ALmVpnEHss7+BtoWRpN47 yCPdsx51ABbuj0F8tIagPeSbbtKR/XyIII4SWLBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , William Breathitt Gray , Sasha Levin Subject: [PATCH 5.19 006/101] counter: 104-quad-8: Fix skipped IRQ lines during events configuration Date: Mon, 3 Oct 2022 09:10:02 +0200 Message-Id: <20221003070724.662230508@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: William Breathitt Gray [ Upstream commit 2bc54aaa65d2126ae629919175708a28ce7ef06e ] IRQ trigger configuration is skipped if it has already been set before; however, the IRQ line still needs to be OR'd to irq_enabled because irq_enabled is reset for every events_configure call. This patch moves the irq_enabled OR operation update to before the irq_trigger check so that IRQ line enablement is not skipped. Fixes: c95cc0d95702 ("counter: 104-quad-8: Fix persistent enabled events bu= g") Cc: stable Link: https://lore.kernel.org/r/20220815122301.2750-1-william.gray@linaro.o= rg/ Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/179eed11eaf225dbd908993b510df0c8f67b1230.16= 63844776.git.william.gray@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/counter/104-quad-8.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 62c2b7ac4339..4407203e0c9b 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -449,6 +449,9 @@ static int quad8_events_configure(struct counter_device= *counter) return -EINVAL; } =20 + /* Enable IRQ line */ + irq_enabled |=3D BIT(event_node->channel); + /* Skip configuration if it is the same as previously set */ if (priv->irq_trigger[event_node->channel] =3D=3D next_irq_trigger) continue; @@ -462,9 +465,6 @@ static int quad8_events_configure(struct counter_device= *counter) priv->irq_trigger[event_node->channel] << 3; iowrite8(QUAD8_CTR_IOR | ior_cfg, &priv->reg->channel[event_node->channel].control); - - /* Enable IRQ line */ - irq_enabled |=3D BIT(event_node->channel); } =20 iowrite8(irq_enabled, &priv->reg->index_interrupt); --=20 2.35.1 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA66EC433F5 for ; Mon, 3 Oct 2022 07:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiJCHO2 (ORCPT ); Mon, 3 Oct 2022 03:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiJCHNZ (ORCPT ); Mon, 3 Oct 2022 03:13:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 092113FEF7; Mon, 3 Oct 2022 00:12:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1E4E3B80C81; Mon, 3 Oct 2022 07:12:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8378CC433C1; Mon, 3 Oct 2022 07:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781169; bh=qA2SnoDnpquwixj7PTXMJPnHgXspquqBBBYQXotvYNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZP1rMqwyu/KJNmTaQS8JCgtwWzvP5Y7HRoRuLqe/Oi6yuDDMnp+u4Hq2rviMWAzFm BFtnXDljruGQgSms+Pqgvj6e68BolGkEKAtOvZIstMTkudBqBtvTUIqWd82qEWLmI/ +FpAzdneArkkhuGCsHsBpvE8KmHg0QVL2cZ9MBKg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , stable , Hongling Zeng Subject: [PATCH 5.19 007/101] uas: add no-uas quirk for Hiksemi usb_disk Date: Mon, 3 Oct 2022 09:10:03 +0200 Message-Id: <20221003070724.689607679@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hongling Zeng commit a625a4b8806cc1e928b7dd2cca1fee709c9de56e upstream. The UAS mode of Hiksemi is reported to fail to work on several platforms with the following error message, then after re-connecting the device will be offlined and not working at all. [ 592.518442][ 2] sd 8:0:0:0: [sda] tag#17 uas_eh_abort_handler 0 uas-tag = 18 inflight: CMD [ 592.527575][ 2] sd 8:0:0:0: [sda] tag#17 CDB: Write(10) 2a 00 03 6f 88 0= 0 00 04 00 00 [ 592.536330][ 2] sd 8:0:0:0: [sda] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD [ 592.545266][ 2] sd 8:0:0:0: [sda] tag#0 CDB: Write(10) 2a 00 07 44 1a 88= 00 00 08 00 These disks have a broken uas implementation, the tag field of the status iu-s is not set properly,so we need to fall-back to usb-storage. Acked-by: Alan Stern Cc: stable Signed-off-by: Hongling Zeng Link: https://lore.kernel.org/r/1663901173-21020-1-git-send-email-zenghongl= ing@kylinos.cn Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/usb/storage/unusual_uas.h +++ b/drivers/usb/storage/unusual_uas.h @@ -52,6 +52,13 @@ UNUSUAL_DEV(0x059f, 0x1061, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_REPORT_OPCODES | US_FL_NO_SAME), =20 +/* Reported-by: Hongling Zeng */ +UNUSUAL_DEV(0x090c, 0x2000, 0x0000, 0x9999, + "Hiksemi", + "External HDD", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_IGNORE_UAS), + /* * Apricorn USB3 dongle sometimes returns "USBSUSBSUSBS" in response to SC= SI * commands in UAS mode. Observed with the 1.28 firmware; are there other= s? From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 788B4C433FE for ; Mon, 3 Oct 2022 07:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbiJCHOh (ORCPT ); Mon, 3 Oct 2022 03:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiJCHNb (ORCPT ); Mon, 3 Oct 2022 03:13:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9895D43615; Mon, 3 Oct 2022 00:12:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B6011B80E69; Mon, 3 Oct 2022 07:12:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F20CC433C1; Mon, 3 Oct 2022 07:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781172; bh=gcoji+IwOaxVnG3o+SYR8ObBzpQCYYfcz8oCmzRPUrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwHIzQ4dQxTL+cA7NpfVT1q+sODbSDMOHmrrlPdwTzfnxvmF+Zq3VmJO3hJ+fDdSj E7PCjox+3mGIo9LSTAWc5nPyPaoNHtJ/PyuaDgkffROE76OLRTzAwOV7Lgzz/wL75n Q58jEkmcfBU/h1scLPdRu26C8hM0U3XMmz1P0zjY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , stable , Hongling Zeng Subject: [PATCH 5.19 008/101] usb-storage: Add Hiksemi USB3-FW to IGNORE_UAS Date: Mon, 3 Oct 2022 09:10:04 +0200 Message-Id: <20221003070724.714524176@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hongling Zeng commit e00b488e813f0f1ad9f778e771b7cd2fe2877023 upstream. The UAS mode of Hiksemi USB_HDD is reported to fail to work on several platforms with the following error message, then after re-connecting the device will be offlined and not working at all. [ 592.518442][ 2] sd 8:0:0:0: [sda] tag#17 uas_eh_abort_handler 0 uas-tag = 18 inflight: CMD [ 592.527575][ 2] sd 8:0:0:0: [sda] tag#17 CDB: Write(10) 2a 00 03 6f 88 0= 0 00 04 00 00 [ 592.536330][ 2] sd 8:0:0:0: [sda] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD [ 592.545266][ 2] sd 8:0:0:0: [sda] tag#0 CDB: Write(10) 2a 00 07 44 1a 88= 00 00 08 00 These disks have a broken uas implementation, the tag field of the status iu-s is not set properly,so we need to fall-back to usb-storage. Acked-by: Alan Stern Cc: stable Signed-off-by: Hongling Zeng Link: https://lore.kernel.org/r/1663901185-21067-1-git-send-email-zenghongl= ing@kylinos.cn Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/usb/storage/unusual_uas.h +++ b/drivers/usb/storage/unusual_uas.h @@ -83,6 +83,13 @@ UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_REPORT_LUNS), =20 +/* Reported-by: Hongling Zeng */ +UNUSUAL_DEV(0x0bda, 0x9210, 0x0000, 0x9999, + "Hiksemi", + "External HDD", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_IGNORE_UAS), + /* Reported-by: Benjamin Tissoires */ UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, "Initio Corporation", From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A9DFC433F5 for ; Mon, 3 Oct 2022 07:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiJCHOr (ORCPT ); Mon, 3 Oct 2022 03:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiJCHNo (ORCPT ); Mon, 3 Oct 2022 03:13:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7BEB4363D; Mon, 3 Oct 2022 00:12:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3546C60F99; Mon, 3 Oct 2022 07:12:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38F4FC433C1; Mon, 3 Oct 2022 07:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781175; bh=6pZ6UQlxPLXtJOJyXlnGRVygfTHsLZc0+Seg8suUn4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syVQUkJmwC2qfRF2/mDoAtF4Qlmis7eiKjuzzssbvM4ten1Cy0mIP+o7MF75t28+W DuXUmNvmeZhRGPB3XpJqu52DgXmQivxaQllro0ZMPEsnoW7RtsFEtS+HNz4gE1TdMM FXc42HjarAeammEDF99lAKA4QsW96bhwnawpkBbA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , stable , Hongling Zeng Subject: [PATCH 5.19 009/101] uas: ignore UAS for Thinkplus chips Date: Mon, 3 Oct 2022 09:10:05 +0200 Message-Id: <20221003070724.739004515@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hongling Zeng commit 0fb9703a3eade0bb84c635705d9c795345e55053 upstream. The UAS mode of Thinkplus(0x17ef, 0x3899) is reported to influence performance and trigger kernel panic on several platforms with the following error message: [ 39.702439] xhci_hcd 0000:0c:00.3: ERROR Transfer event for disabled endpoint or incorrect stream ring [ 39.702442] xhci_hcd 0000:0c:00.3: @000000026c61f810 00000000 00000000 1b000000 05038000 [ 720.545894][13] Workqueue: usb_hub_wq hub_event [ 720.550971][13] ffff88026c143c38 0000000000016300 ffff8802755bb900 ffff= 880 26cb80000 [ 720.559673][13] ffff88026c144000 ffff88026ca88100 0000000000000000 ffff= 880 26cb80000 [ 720.568374][13] ffff88026cb80000 ffff88026c143c50 ffffffff8186ae25 ffff= 880 26ca880f8 [ 720.577076][13] Call Trace: [ 720.580201][13] [] schedule+0x35/0x80 [ 720.586137][13] [] schedule_preempt_disabled+0xe/0x10 [ 720.593623][13] [] __mutex_lock_slowpath+0x164/0x1e0 [ 720.601012][13] [] mutex_lock+0x2f/0x40 [ 720.607141][13] [] usb_disconnect+0x59/0x290 Falling back to USB mass storage can solve this problem, so ignore UAS function of this chip. Acked-by: Alan Stern Cc: stable Signed-off-by: Hongling Zeng Link: https://lore.kernel.org/r/1663902249837086.19.seg@mailgw Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/usb/storage/unusual_uas.h +++ b/drivers/usb/storage/unusual_uas.h @@ -132,6 +132,13 @@ UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), =20 +/* Reported-by: Hongling Zeng */ +UNUSUAL_DEV(0x17ef, 0x3899, 0x0000, 0x9999, + "Thinkplus", + "External HDD", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_IGNORE_UAS), + /* Reported-by: Hans de Goede */ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999, "VIA", From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5BB7C4332F for ; Mon, 3 Oct 2022 07:12:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbiJCHM3 (ORCPT ); Mon, 3 Oct 2022 03:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiJCHMV (ORCPT ); Mon, 3 Oct 2022 03:12:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F52537193; Mon, 3 Oct 2022 00:12:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D398060F9C; Mon, 3 Oct 2022 07:12:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6290C433C1; Mon, 3 Oct 2022 07:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781134; bh=au0Hli03x+hD2RTJxEq0cDrYZzeJVBLQh548M23Y5B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q07wUe/N+lJUxTHcJo6P/UFvSuUtodDyk93BIuYsBNRYFc099NSlzoAEWSJTG8S7f wv7NM/qRgSeP/Oc0Ye9r65L27ei4typHclNlwDP2sKnBgvc/4kGUyEAS0aLDvF0q0O PD2BkaMTP4b5YuIAt2vMBqoKP2akD3gHvsup3q/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Heikki Krogerus Subject: [PATCH 5.19 010/101] usb: typec: ucsi: Remove incorrect warning Date: Mon, 3 Oct 2022 09:10:06 +0200 Message-Id: <20221003070724.762495136@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Heikki Krogerus commit 415ba26cb73f7d22a892043301b91b57ae54db02 upstream. Sink only devices do not have any source capabilities, so the driver should not warn about that. Also DRP (Dual Role Power) capable devices, such as USB Type-C docking stations, do not return any source capabilities unless they are plugged to a power supply themselves. Fixes: 1f4642b72be7 ("usb: typec: ucsi: Retrieve all the PDOs instead of ju= st the first 4") Reported-by: Paul Menzel Cc: Signed-off-by: Heikki Krogerus Link: https://lore.kernel.org/r/20220922145924.80667-1-heikki.krogerus@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/usb/typec/ucsi/ucsi.c | 2 -- 1 file changed, 2 deletions(-) --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -588,8 +588,6 @@ static int ucsi_get_pdos(struct ucsi_con num_pdos * sizeof(u32)); if (ret < 0 && ret !=3D -ETIMEDOUT) dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret); - if (ret =3D=3D 0 && offset =3D=3D 0) - dev_warn(ucsi->dev, "UCSI_GET_PDOS returned 0 bytes\n"); =20 return ret; } From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D374C433FE for ; Mon, 3 Oct 2022 07:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbiJCHMc (ORCPT ); Mon, 3 Oct 2022 03:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbiJCHMW (ORCPT ); Mon, 3 Oct 2022 03:12:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B90A33F1F4; Mon, 3 Oct 2022 00:12:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8139860F9A; Mon, 3 Oct 2022 07:12:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94015C433D6; Mon, 3 Oct 2022 07:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781137; bh=BgZzQqLPqIirT3vR3QB0OlreZGbOrUkEFdJUep8FaqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mzksTy28ayoE1usI3I3F+IoeHc5ufDI5nwp8SqvbLXKBo0D6fgSDNwBuNe/24Hoz5 3PG4dspifhaX6Se1+iKbj7Bgr9y2lWiRGnA5/LIY/KpZk98vlOGE1aeFqU8VQmgRGO 0ED27qqiQQoalG+B9VV2M9qje1MX3FGxtcv9I50I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mario Limonciello , Mika Westerberg Subject: [PATCH 5.19 011/101] thunderbolt: Explicitly reset plug events delay back to USB4 spec value Date: Mon, 3 Oct 2022 09:10:07 +0200 Message-Id: <20221003070724.785501424@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mario Limonciello commit 31f87f705b3c1635345d8e8a493697099b43e508 upstream. If any software has interacted with the USB4 registers before the Linux USB4 CM runs, it may have modified the plug events delay. It has been observed that if this value too large, it's possible that hotplugged devices will negotiate a fallback mode instead in Linux. To prevent this, explicitly align the plug events delay with the USB4 spec value of 10ms. Cc: stable@vger.kernel.org Signed-off-by: Mario Limonciello Signed-off-by: Mika Westerberg Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/thunderbolt/switch.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2413,6 +2413,7 @@ int tb_switch_configure(struct tb_switch * additional capabilities. */ sw->config.cmuv =3D USB4_VERSION_1_0; + sw->config.plug_events_delay =3D 0xa; =20 /* Enumerate the switch */ ret =3D tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH, From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49971C4332F for ; Mon, 3 Oct 2022 07:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbiJCHMt (ORCPT ); Mon, 3 Oct 2022 03:12:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiJCHMZ (ORCPT ); Mon, 3 Oct 2022 03:12:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D277C38465; Mon, 3 Oct 2022 00:12:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D662CB80E67; Mon, 3 Oct 2022 07:12:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F1ECC433D7; Mon, 3 Oct 2022 07:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781139; bh=SPWCJI6gWWdbDzhDyJnJaROymCokNv+a7LD46J4OIGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1TwU0REHmTC4amn6HCfTHKYfgWMkpupPoRr62PtI3/GDIGHOcrKA2JAeEJbwtuJn 9XQA3H5xuLQLG1UYA1UoHXZ/WCTPcL/VCG4ysfSqek35YGqH//UywcMCDPmYJE6WVn iOzpqiE/01K2HJaqhLGQ7EHiK759YE8WSgOGihpw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Wunderlich , =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Jakub Kicinski Subject: [PATCH 5.19 012/101] net: usb: qmi_wwan: Add new usb-id for Dell branded EM7455 Date: Mon, 3 Oct 2022 09:10:08 +0200 Message-Id: <20221003070724.808698923@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Wunderlich commit 797666cd5af041ffb66642fff62f7389f08566a2 upstream. Add support for Dell 5811e (EM7455) with USB-id 0x413c:0x81c2. Signed-off-by: Frank Wunderlich Cc: stable@vger.kernel.org Acked-by: Bj=C3=B8rn Mork Link: https://lore.kernel.org/r/20220926150740.6684-3-linux@fw-web.de Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -1399,6 +1399,7 @@ static const struct usb_device_id produc {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G L= TE Mobile Broadband Card (rev3) */ {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ + {QMI_FIXED_INTF(0x413c, 0x81c2, 8)}, /* Dell Wireless 5811e */ {QMI_FIXED_INTF(0x413c, 0x81cc, 8)}, /* Dell Wireless 5816e */ {QMI_FIXED_INTF(0x413c, 0x81d7, 0)}, /* Dell Wireless 5821e */ {QMI_FIXED_INTF(0x413c, 0x81d7, 1)}, /* Dell Wireless 5821e preproduction= config */ From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E666C433FE for ; Mon, 3 Oct 2022 07:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiJCHMy (ORCPT ); Mon, 3 Oct 2022 03:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiJCHMb (ORCPT ); Mon, 3 Oct 2022 03:12:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C24EE36437; Mon, 3 Oct 2022 00:12:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B4B3EB80E66; Mon, 3 Oct 2022 07:12:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E100C433D6; Mon, 3 Oct 2022 07:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781142; bh=iiHvL8xuvSgYPTGIvbygeHeLLXH/8zJ7cHYbq0fxa4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdwhYF1PIzJOM2trWac2cFOm9O8/TXJR3e3gAUHJ6l1g6zqit7ZUtyFJKge6GocZd oXqfN7q1qtPwoMYflos78sv0IKuyA/SjzRVvIt2ZNbl5SOQ56VRUMJZkHVPhm2OAp2 80rwXwMHQvlL4WEHx6RNb3N2rfm/nfRhHOFvB+0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Kepplinger , Sebastian Krzyszkowiak , Mattijs Korpershoek , Dmitry Torokhov Subject: [PATCH 5.19 013/101] Input: snvs_pwrkey - fix SNVS_HPVIDR1 register address Date: Mon, 3 Oct 2022 09:10:09 +0200 Message-Id: <20221003070724.831800295@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sebastian Krzyszkowiak commit e62563db857f81d75c5726a35bc0180bed6d1540 upstream. Both i.MX6 and i.MX8 reference manuals list 0xBF8 as SNVS_HPVIDR1 (chapters 57.9 and 6.4.5 respectively). Without this, trying to read the revision number results in 0 on all revisions, causing the i.MX6 quirk to apply on all platforms, which in turn causes the driver to synthesise power button release events instead of passing the real one as they happen even on platforms like i.MX8 where that's not wanted. Fixes: 1a26c920717a ("Input: snvs_pwrkey - send key events for i.MX6 S, DL = and Q") Tested-by: Martin Kepplinger Signed-off-by: Sebastian Krzyszkowiak Reviewed-by: Mattijs Korpershoek Cc: Link: https://lore.kernel.org/r/4599101.ElGaqSPkdT@pliszka Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/input/keyboard/snvs_pwrkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -20,7 +20,7 @@ #include #include =20 -#define SNVS_HPVIDR1_REG 0xF8 +#define SNVS_HPVIDR1_REG 0xBF8 #define SNVS_LPSR_REG 0x4C /* LP Status Register */ #define SNVS_LPCR_REG 0x38 /* LP Control Register */ #define SNVS_HPSR_REG 0x14 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC18C433FE for ; Mon, 3 Oct 2022 07:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbiJCHM7 (ORCPT ); Mon, 3 Oct 2022 03:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiJCHMc (ORCPT ); Mon, 3 Oct 2022 03:12:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FAE23ECFC; Mon, 3 Oct 2022 00:12:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9CF3960F9B; Mon, 3 Oct 2022 07:12:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B50E8C433C1; Mon, 3 Oct 2022 07:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781145; bh=Q9tUnQkxGVZdqQdRAIeF9tYNgjJi/waFbFNnzAxQM14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2BpIEcgFVCadC9p1JaaBwkY0LDc7cqN1vNcRUYr+s7+NJSokN9zXAqdruLV23GyKN xK1HJdizT4jpwhyG5FxAdaEbmr1VTKgkIsWhPgI90mHm5QQWPgMI+NO0pObPtJvCul o8YD8qR3HEDIKWdeC0xKXiLwbPJ8ESrBACArV+KM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Kroon , Marc Kleine-Budde Subject: [PATCH 5.19 014/101] can: c_can: dont cache TX messages for C_CAN cores Date: Mon, 3 Oct 2022 09:10:10 +0200 Message-Id: <20221003070724.856221977@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marc Kleine-Budde commit 81d192c2ce74157e717e1fc4b68791f82f7499d4 upstream. As Jacob noticed, the optimization introduced in 387da6bc7a82 ("can: c_can: cache frames to operate as a true FIFO") doesn't properly work on C_CAN, but on D_CAN IP cores. The exact reasons are still unknown. For now disable caching if CAN frames in the TX path for C_CAN cores. Fixes: 387da6bc7a82 ("can: c_can: cache frames to operate as a true FIFO") Link: https://lore.kernel.org/all/20220928083354.1062321-1-mkl@pengutronix.= de Link: https://lore.kernel.org/all/15a8084b-9617-2da1-6704-d7e39d60643b@gmai= l.com Reported-by: Jacob Kroon Tested-by: Jacob Kroon Cc: stable@vger.kernel.org # v5.15 Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/can/c_can/c_can.h | 17 +++++++++++++++-- drivers/net/can/c_can/c_can_main.c | 11 +++++------ 2 files changed, 20 insertions(+), 8 deletions(-) --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h @@ -235,9 +235,22 @@ static inline u8 c_can_get_tx_tail(const return ring->tail & (ring->obj_num - 1); } =20 -static inline u8 c_can_get_tx_free(const struct c_can_tx_ring *ring) +static inline u8 c_can_get_tx_free(const struct c_can_priv *priv, + const struct c_can_tx_ring *ring) { - return ring->obj_num - (ring->head - ring->tail); + u8 head =3D c_can_get_tx_head(ring); + u8 tail =3D c_can_get_tx_tail(ring); + + if (priv->type =3D=3D BOSCH_D_CAN) + return ring->obj_num - (ring->head - ring->tail); + + /* This is not a FIFO. C/D_CAN sends out the buffers + * prioritized. The lowest buffer number wins. + */ + if (head < tail) + return 0; + + return ring->obj_num - head; } =20 #endif /* C_CAN_H */ --- a/drivers/net/can/c_can/c_can_main.c +++ b/drivers/net/can/c_can/c_can_main.c @@ -429,7 +429,7 @@ static void c_can_setup_receive_object(s static bool c_can_tx_busy(const struct c_can_priv *priv, const struct c_can_tx_ring *tx_ring) { - if (c_can_get_tx_free(tx_ring) > 0) + if (c_can_get_tx_free(priv, tx_ring) > 0) return false; =20 netif_stop_queue(priv->dev); @@ -437,7 +437,7 @@ static bool c_can_tx_busy(const struct c /* Memory barrier before checking tx_free (head and tail) */ smp_mb(); =20 - if (c_can_get_tx_free(tx_ring) =3D=3D 0) { + if (c_can_get_tx_free(priv, tx_ring) =3D=3D 0) { netdev_dbg(priv->dev, "Stopping tx-queue (tx_head=3D0x%08x, tx_tail=3D0x%08x, len=3D%d).\n= ", tx_ring->head, tx_ring->tail, @@ -465,7 +465,7 @@ static netdev_tx_t c_can_start_xmit(stru =20 idx =3D c_can_get_tx_head(tx_ring); tx_ring->head++; - if (c_can_get_tx_free(tx_ring) =3D=3D 0) + if (c_can_get_tx_free(priv, tx_ring) =3D=3D 0) netif_stop_queue(dev); =20 if (idx < c_can_get_tx_tail(tx_ring)) @@ -748,7 +748,7 @@ static void c_can_do_tx(struct net_devic return; =20 tx_ring->tail +=3D pkts; - if (c_can_get_tx_free(tx_ring)) { + if (c_can_get_tx_free(priv, tx_ring)) { /* Make sure that anybody stopping the queue after * this sees the new tx_ring->tail. */ @@ -760,8 +760,7 @@ static void c_can_do_tx(struct net_devic stats->tx_packets +=3D pkts; =20 tail =3D c_can_get_tx_tail(tx_ring); - - if (tail =3D=3D 0) { + if (priv->type =3D=3D BOSCH_D_CAN && tail =3D=3D 0) { u8 head =3D c_can_get_tx_head(tx_ring); =20 /* Start transmission for all cached messages */ From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A149BC433FE for ; Mon, 3 Oct 2022 07:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiJCHNF (ORCPT ); Mon, 3 Oct 2022 03:13:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbiJCHMn (ORCPT ); Mon, 3 Oct 2022 03:12:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D8EF3ECD4; Mon, 3 Oct 2022 00:12:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 33DF2B80E6A; Mon, 3 Oct 2022 07:12:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AB8FC433D6; Mon, 3 Oct 2022 07:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781147; bh=O78QZj8Ieb5nrjcDXaWFVlxMIPOKNh/0qd969ar7LEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqDYZJCZOsBPbqsHPoJTXVpK5bvF0ZOJBDREEo0BoemBmYROuckh9+yLPNZBcuRfn nbw3/1Ba4BcwIy54hhXSypz5RiquYgJ2MJ7W2SEhEH+bNn2qwipxUwffF+sKg2aLsO gNdUulvhK9mrw0shJ+WpGH4ocUoKlb4VJNvEBWJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Cercueil , Aidan MacDonald , Stephen Boyd Subject: [PATCH 5.19 015/101] clk: ingenic-tcu: Properly enable registers before accessing timers Date: Mon, 3 Oct 2022 09:10:11 +0200 Message-Id: <20221003070724.882002128@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Aidan MacDonald commit 6726d552a6912e88cf63fe2bda87b2efa0efc7d0 upstream. Access to registers is guarded by ingenic_tcu_{enable,disable}_regs() so the stop bit can be cleared before accessing a timer channel, but those functions did not clear the stop bit on SoCs with a global TCU clock gate. Testing on the X1000 has revealed that the stop bits must be cleared _and_ the global TCU clock must be ungated to access timer registers. This appears to be the norm on Ingenic SoCs, and is specified in the documentation for the X1000 and numerous JZ47xx SoCs. If the stop bit isn't cleared, register writes don't take effect and the system can be left in a broken state, eg. the watchdog timer may not run. The bug probably went unnoticed because stop bits are zeroed when the SoC is reset, and the kernel does not set them unless a timer gets disabled at runtime. However, it is possible that a bootloader or a previous kernel (if using kexec) leaves the stop bits set and we should not rely on them being cleared. Fixing this is easy: have ingenic_tcu_{enable,disable}_regs() always clear the stop bit, regardless of the presence of a global TCU gate. Reviewed-by: Paul Cercueil Tested-by: Paul Cercueil Fixes: 4f89e4b8f121 ("clk: ingenic: Add driver for the TCU clocks") Cc: stable@vger.kernel.org Signed-off-by: Aidan MacDonald Link: https://lore.kernel.org/r/20220617122254.738900-1-aidanmacdonald.0x0@= gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/ingenic/tcu.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/drivers/clk/ingenic/tcu.c +++ b/drivers/clk/ingenic/tcu.c @@ -101,15 +101,11 @@ static bool ingenic_tcu_enable_regs(stru bool enabled =3D false; =20 /* - * If the SoC has no global TCU clock, we must ungate the channel's - * clock to be able to access its registers. - * If we have a TCU clock, it will be enabled automatically as it has - * been attached to the regmap. + * According to the programming manual, a timer channel's registers can + * only be accessed when the channel's stop bit is clear. */ - if (!tcu->clk) { - enabled =3D !!ingenic_tcu_is_enabled(hw); - regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit)); - } + enabled =3D !!ingenic_tcu_is_enabled(hw); + regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit)); =20 return enabled; } @@ -120,8 +116,7 @@ static void ingenic_tcu_disable_regs(str const struct ingenic_tcu_clk_info *info =3D tcu_clk->info; struct ingenic_tcu *tcu =3D tcu_clk->tcu; =20 - if (!tcu->clk) - regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit)); + regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit)); } =20 static u8 ingenic_tcu_get_parent(struct clk_hw *hw) From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FB8AC433F5 for ; Mon, 3 Oct 2022 07:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbiJCHNW (ORCPT ); Mon, 3 Oct 2022 03:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbiJCHMq (ORCPT ); Mon, 3 Oct 2022 03:12:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33A83ED51; Mon, 3 Oct 2022 00:12:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DD0DDB80E65; Mon, 3 Oct 2022 07:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55C2AC433D6; Mon, 3 Oct 2022 07:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781150; bh=bAsZibJ+SV/6sKdKx+eVm7gzU6Hj6eFDQbdIssBdeA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SJKXsziGOQOt2UfnzokKEuQMkSe+/h8uyj98Ix6iTzi5wyohiWEq2Y7ehByLiOAN3 pk4pMN4Pqnfy3frwIj8KK7y7hahJ5V8W7BtCLu6lbUywB65+IHrsSAdxczU+37g5cn pQy+rfMpoU7R24Iv9fpD8tIECB17ZsCv8vOsxYsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Wetzel , Felix Fietkau , Johannes Berg Subject: [PATCH 5.19 016/101] wifi: mac80211: ensure vif queues are operational after start Date: Mon, 3 Oct 2022 09:10:12 +0200 Message-Id: <20221003070724.905319582@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Wetzel commit 527008e5e87600a389feb8a57042c928ecca195d upstream. Make sure local->queue_stop_reasons and vif.txqs_stopped stay in sync. When a new vif is created the queues may end up in an inconsistent state and be inoperable: Communication not using iTXQ will work, allowing to e.g. complete the association. But the 4-way handshake will time out. The sta will not send out any skbs queued in iTXQs. All normal attempts to start the queues will fail when reaching this state. local->queue_stop_reasons will have marked all queues as operational but vif.txqs_stopped will still be set, creating an inconsistent internal state. In reality this seems to be race between the mac80211 function ieee80211_do_open() setting SDATA_STATE_RUNNING and the wake_txqs_tasklet: Depending on the driver and the timing the queues may end up to be operational or not. Cc: stable@vger.kernel.org Fixes: f856373e2f31 ("wifi: mac80211: do not wake queues on a vif that is b= eing stopped") Signed-off-by: Alexander Wetzel Acked-by: Felix Fietkau Link: https://lore.kernel.org/r/20220915130946.302803-1-alexander@wetzel-ho= me.de Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/mac80211/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 53826c663723..efcefb2dd882 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -301,14 +301,14 @@ static void __ieee80211_wake_txqs(struct ieee80211_su= b_if_data *sdata, int ac) local_bh_disable(); spin_lock(&fq->lock); =20 + sdata->vif.txqs_stopped[ac] =3D false; + if (!test_bit(SDATA_STATE_RUNNING, &sdata->state)) goto out; =20 if (sdata->vif.type =3D=3D NL80211_IFTYPE_AP) ps =3D &sdata->bss->ps; =20 - sdata->vif.txqs_stopped[ac] =3D false; - list_for_each_entry_rcu(sta, &local->sta_list, list) { if (sdata !=3D sta->sdata) continue; --=20 2.37.3 From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A157C433FE for ; Mon, 3 Oct 2022 07:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbiJCHN3 (ORCPT ); Mon, 3 Oct 2022 03:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiJCHMs (ORCPT ); Mon, 3 Oct 2022 03:12:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F373C422DE; Mon, 3 Oct 2022 00:12:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9C0DB80E66; Mon, 3 Oct 2022 07:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26661C433D7; Mon, 3 Oct 2022 07:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781153; bh=HEpb4eCnReJMMkUUurl5+sAXCcIdPcGKHFpFJgHUXuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7VHn6wJuzbHIT0fLPq5DsRK09sUehxYm9eB7yK1y8flFqm3SpQxkgBA9voukNghG Wr1I8jgv8fdp/iZ84rTKw5BDFlEOBLe2N0X4m8k30ErzRyu6rz3K5ZczMdTx/tK0sw kqsfwXFNulLLQwLpUT2bu/TGWcvqUig+3QgAYGKw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Jarkko Sakkinen , Dave Hansen , Reinette Chatre Subject: [PATCH 5.19 017/101] x86/sgx: Do not fail on incomplete sanitization on premature stop of ksgxd Date: Mon, 3 Oct 2022 09:10:13 +0200 Message-Id: <20221003070724.928405585@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jarkko Sakkinen commit 133e049a3f8c91b175029fb6a59b6039d5e79cba upstream. Unsanitized pages trigger WARN_ON() unconditionally, which can panic the whole computer, if /proc/sys/kernel/panic_on_warn is set. In sgx_init(), if misc_register() fails or misc_register() succeeds but neither sgx_drv_init() nor sgx_vepc_init() succeeds, then ksgxd will be prematurely stopped. This may leave unsanitized pages, which will result a false warning. Refine __sgx_sanitize_pages() to return: 1. Zero when the sanitization process is complete or ksgxd has been requested to stop. 2. The number of unsanitized pages otherwise. Fixes: 51ab30eb2ad4 ("x86/sgx: Replace section->init_laundry_list with sgx_= dirty_page_list") Reported-by: Paul Menzel Signed-off-by: Jarkko Sakkinen Signed-off-by: Dave Hansen Reviewed-by: Reinette Chatre Cc: stable@vger.kernel.org Link: https://lore.kernel.org/linux-sgx/20220825051827.246698-1-jarkko@kern= el.org/T/#u Link: https://lkml.kernel.org/r/20220906000221.34286-2-jarkko@kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/x86/kernel/cpu/sgx/main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -49,9 +49,13 @@ static LIST_HEAD(sgx_dirty_page_list); * Reset post-kexec EPC pages to the uninitialized state. The pages are re= moved * from the input list, and made available for the page allocator. SECS pa= ges * prepending their children in the input list are left intact. + * + * Return 0 when sanitization was successful or kthread was stopped, and t= he + * number of unsanitized pages otherwise. */ -static void __sgx_sanitize_pages(struct list_head *dirty_page_list) +static unsigned long __sgx_sanitize_pages(struct list_head *dirty_page_lis= t) { + unsigned long left_dirty =3D 0; struct sgx_epc_page *page; LIST_HEAD(dirty); int ret; @@ -59,7 +63,7 @@ static void __sgx_sanitize_pages(struct /* dirty_page_list is thread-local, no need for a lock: */ while (!list_empty(dirty_page_list)) { if (kthread_should_stop()) - return; + return 0; =20 page =3D list_first_entry(dirty_page_list, struct sgx_epc_page, list); =20 @@ -92,12 +96,14 @@ static void __sgx_sanitize_pages(struct } else { /* The page is not yet clean - move to the dirty list. */ list_move_tail(&page->list, &dirty); + left_dirty++; } =20 cond_resched(); } =20 list_splice(&dirty, dirty_page_list); + return left_dirty; } =20 static bool sgx_reclaimer_age(struct sgx_epc_page *epc_page) @@ -440,10 +446,7 @@ static int ksgxd(void *p) * required for SECS pages, whose child pages blocked EREMOVE. */ __sgx_sanitize_pages(&sgx_dirty_page_list); - __sgx_sanitize_pages(&sgx_dirty_page_list); - - /* sanity check: */ - WARN_ON(!list_empty(&sgx_dirty_page_list)); + WARN_ON(__sgx_sanitize_pages(&sgx_dirty_page_list)); =20 while (!kthread_should_stop()) { if (try_to_freeze()) From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D82F0C433FE for ; Mon, 3 Oct 2022 07:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbiJCHTK (ORCPT ); Mon, 3 Oct 2022 03:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiJCHRc (ORCPT ); Mon, 3 Oct 2022 03:17:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31EA81F2E4; Mon, 3 Oct 2022 00:14:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC0D460F9C; Mon, 3 Oct 2022 07:14:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E948AC433C1; Mon, 3 Oct 2022 07:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781259; bh=nBpY/1f++0ipZ8qC0WjHnambSVMNnvhuoHI1mrT04qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcOfjI6WZWKNsPDPUn7V7eG3/OF3G8/RBL9SYhW2tj0b0kXhO7uObnmqCAdooJYwb +MFA6yYb//MsJQaUBnrD/76rEpvjtAlRWTo7agulcUphZ5PDGb4YlZQaNHkfp+mW3c GGd9kztQFcTk4NgHHZ3GK7wewIE2x0xLgluwGYps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Christoph Hellwig , Liu Shixin , Konrad Rzeszutek Wilk , Andrew Morton Subject: [PATCH 5.19 018/101] frontswap: dont call ->init if no ops are registered Date: Mon, 3 Oct 2022 09:10:14 +0200 Message-Id: <20221003070724.951846385@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christoph Hellwig commit 37dcc673d065d9823576cd9f2484a72531e1cba6 upstream. If no frontswap module (i.e. zswap) was registered, frontswap_ops will be NULL. In such situation, swapon crashes with the following stack trace: Unable to handle kernel access to user memory outside uaccess routines at= virtual address 0000000000000000 Mem abort info: ESR =3D 0x0000000096000004 EC =3D 0x25: DABT (current EL), IL =3D 32 bits SET =3D 0, FnV =3D 0 EA =3D 0, S1PTW =3D 0 FSC =3D 0x04: level 0 translation fault Data abort info: ISV =3D 0, ISS =3D 0x00000004 CM =3D 0, WnR =3D 0 user pgtable: 4k pages, 48-bit VAs, pgdp=3D00000020a4fab000 [0000000000000000] pgd=3D0000000000000000, p4d=3D0000000000000000 Internal error: Oops: 96000004 [#1] SMP Modules linked in: zram fsl_dpaa2_eth pcs_lynx phylink ahci_qoriq crct10d= if_ce ghash_ce sbsa_gwdt fsl_mc_dpio nvme lm90 nvme_core at803x xhci_plat_h= cd rtc_fsl_ftm_alarm xgmac_mdio ahci_platform i2c_imx ip6_tables ip_tables = fuse Unloaded tainted modules: cppc_cpufreq():1 CPU: 10 PID: 761 Comm: swapon Not tainted 6.0.0-rc2-00454-g22100432cf14 #1 Hardware name: SolidRun Ltd. SolidRun CEX7 Platform, BIOS EDK II Jun 21 2= 022 pstate: 00400005 (nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=3D--) pc : frontswap_init+0x38/0x60 lr : __do_sys_swapon+0x8a8/0x9f4 sp : ffff80000969bcf0 x29: ffff80000969bcf0 x28: ffff37bee0d8fc00 x27: ffff80000a7f5000 x26: fffffcdefb971e80 x25: ffffaba797453b90 x24: 0000000000000064 x23: ffff37c1f209d1a8 x22: ffff37bee880e000 x21: ffffaba797748560 x20: ffff37bee0d8fce4 x19: ffffaba797748488 x18: 0000000000000014 x17: 0000000030ec029a x16: ffffaba795a479b0 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000030 x12: 0000000000000001 x11: ffff37c63c0aba18 x10: 0000000000000000 x9 : ffffaba7956b8c88 x8 : ffff80000969bcd0 x7 : 0000000000000000 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000000 x3 : ffffaba79730f000 x2 : ffff37bee0d8fc00 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: frontswap_init+0x38/0x60 __do_sys_swapon+0x8a8/0x9f4 __arm64_sys_swapon+0x28/0x3c invoke_syscall+0x78/0x100 el0_svc_common.constprop.0+0xd4/0xf4 do_el0_svc+0x38/0x4c el0_svc+0x34/0x10c el0t_64_sync_handler+0x11c/0x150 el0t_64_sync+0x190/0x194 Code: d000e283 910003fd f9006c41 f946d461 (f9400021) ---[ end trace 0000000000000000 ]--- Link: https://lkml.kernel.org/r/20220909130829.3262926-1-hch@lst.de Fixes: 1da0d94a3ec8 ("frontswap: remove support for multiple ops") Reported-by: Nathan Chancellor Signed-off-by: Christoph Hellwig Signed-off-by: Liu Shixin Cc: Konrad Rzeszutek Wilk Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/frontswap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/frontswap.c +++ b/mm/frontswap.c @@ -125,6 +125,9 @@ void frontswap_init(unsigned type, unsig * p->frontswap set to something valid to work properly. */ frontswap_map_set(sis, map); + + if (!frontswap_enabled()) + return; frontswap_ops->init(type); } From nobody Fri Apr 10 10:43:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 025C4C433F5 for ; Mon, 3 Oct 2022 07:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiJCHPE (ORCPT ); Mon, 3 Oct 2022 03:15:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbiJCHOL (ORCPT ); Mon, 3 Oct 2022 03:14:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FFA3FD5C; Mon, 3 Oct 2022 00:13:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AD18060F9D; Mon, 3 Oct 2022 07:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2280C433D7; Mon, 3 Oct 2022 07:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781181; bh=9EUp+cWA4O5YxOrYZhip52rjNb5qcT5Aob48PD1r0I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jl3/vsFDWSjJ3Dzqe72qZXYkAsQUEBbnV7F0azJ+12aGejuvo4iJHLuueCIBpG+fN SHZ9Dcd6aAcr4zvuyA6ZKV05qphcMqooUJWs/Owy+BsNMRxjE+XTMmimsQz2lLvLTe +VfP7QiTRWl97KJc+rUes9OToMcAwu4DFvCKpkao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , Arnd Bergmann Subject: [PATCH 5.19 019/101] ARM: dts: integrator: Tag PCI host with device_type Date: Mon, 3 Oct 2022 09:10:15 +0200 Message-Id: <20221003070724.975347464@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Linus Walleij commit 4952aa696a9f221c5e34e5961e02fca41ef67ad6 upstream. The DT parser is dependent on the PCI device being tagged as device_type =3D "pci" in order to parse memory ranges properly. Fix this up. Signed-off-by: Linus Walleij Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220919092608.813511-1-linus.walleij@linar= o.org' Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/arm/boot/dts/integratorap.dts | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm/boot/dts/integratorap.dts +++ b/arch/arm/boot/dts/integratorap.dts @@ -160,6 +160,7 @@ =20 pci: pciv3@62000000 { compatible =3D "arm,integrator-ap-pci", "v3,v360epc-pci"; + device_type =3D "pci"; #interrupt-cells =3D <1>; #size-cells =3D <2>; #address-cells =3D <3>; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D2CBC4332F for ; Mon, 3 Oct 2022 07:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbiJCHQz (ORCPT ); Mon, 3 Oct 2022 03:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbiJCHPx (ORCPT ); Mon, 3 Oct 2022 03:15:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BAC42ACF; Mon, 3 Oct 2022 00:13:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7AF6760F97; Mon, 3 Oct 2022 07:13:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BF80C433D6; Mon, 3 Oct 2022 07:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781210; bh=kXF99wYI2vw+gjdXMYA9FTirKzz+ImYzxc+lgH9a35I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x5LIU6A6DMaMZz/MzkNWRtjwMmp3CyFHB5hkMZ/pwJWxHCA6smFySrX58yXAJcEwo buF6hiemwmIZhpqY0FGJ/5h84O4V20vS9aHc9fKMUgk9g6t5nDm5VIHfqxmYMsTQKM iEwioiWgcHtzvGFbVkT75S6+4Ttxi+w3oNQ2oJEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ChenXiaoSong , Anton Altaparmakov , Andrew Morton Subject: [PATCH 5.19 020/101] ntfs: fix BUG_ON in ntfs_lookup_inode_by_name() Date: Mon, 3 Oct 2022 09:10:16 +0200 Message-Id: <20221003070724.998013226@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: ChenXiaoSong commit 1b513f613731e2afc05550e8070d79fac80c661e upstream. Syzkaller reported BUG_ON as follows: Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz ------------[ cut here ]------------ kernel BUG at fs/ntfs/dir.c:86! invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 3 PID: 758 Comm: a.out Not tainted 5.19.0-next-20220808 #5 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd= 239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:ntfs_lookup_inode_by_name+0xd11/0x2d10 Code: ff e9 b9 01 00 00 e8 1e fe d6 fe 48 8b 7d 98 49 8d 5d 07 e8 91 85 29 = ff 48 c7 45 98 00 00 00 00 e9 5a fb ff ff e8 ff fd d6 fe <0f> 0b e8 f8 fd d= 6 fe 0f 0b e8 f1 fd d6 fe 48 8b b5 50 ff ff ff 4c RSP: 0018:ffff888079607978 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000008000 RCX: 0000000000000000 RDX: ffff88807cf10000 RSI: ffffffff82a4a081 RDI: 0000000000000003 RBP: ffff888079607a70 R08: 0000000000000001 R09: ffff88807a6d01d7 R10: ffffed100f4da03a R11: 0000000000000000 R12: ffff88800f0fb110 R13: ffff88800f0ee000 R14: ffff88800f0fb000 R15: 0000000000000001 FS: 00007f33b63c7540(0000) GS:ffff888108580000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f33b635c090 CR3: 000000000f39e005 CR4: 0000000000770ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: load_system_files+0x1f7f/0x3620 ntfs_fill_super+0xa01/0x1be0 mount_bdev+0x36a/0x440 ntfs_mount+0x3a/0x50 legacy_get_tree+0xfb/0x210 vfs_get_tree+0x8f/0x2f0 do_new_mount+0x30a/0x760 path_mount+0x4de/0x1880 __x64_sys_mount+0x2b3/0x340 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f33b62ff9ea Code: 48 8b 0d a9 f4 0b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 = 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff f= f 73 01 c3 48 8b 0d 76 f4 0b 00 f7 d8 64 89 01 48 RSP: 002b:00007ffd0c471aa8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f33b62ff9ea RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffd0c471be0 RBP: 00007ffd0c471c60 R08: 00007ffd0c471ae0 R09: 00007ffd0c471c24 R10: 0000000000000000 R11: 0000000000000202 R12: 000055bac5afc160 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Modules linked in: ---[ end trace 0000000000000000 ]--- Fix this by adding sanity check on extended system files' directory inode to ensure that it is directory, just like ntfs_extend_init() when mounting ntfs3. Link: https://lkml.kernel.org/r/20220809064730.2316892-1-chenxiaosong2@huaw= ei.com Signed-off-by: ChenXiaoSong Cc: Anton Altaparmakov Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/ntfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -2092,7 +2092,8 @@ get_ctx_vol_failed: // TODO: Initialize security. /* Get the extended system files' directory inode. */ vol->extend_ino =3D ntfs_iget(sb, FILE_Extend); - if (IS_ERR(vol->extend_ino) || is_bad_inode(vol->extend_ino)) { + if (IS_ERR(vol->extend_ino) || is_bad_inode(vol->extend_ino) || + !S_ISDIR(vol->extend_ino->i_mode)) { if (!IS_ERR(vol->extend_ino)) iput(vol->extend_ino); ntfs_error(sb, "Failed to load $Extend."); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37F42C433FE for ; Mon, 3 Oct 2022 07:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbiJCHSI (ORCPT ); Mon, 3 Oct 2022 03:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbiJCHRH (ORCPT ); Mon, 3 Oct 2022 03:17:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554524686D; Mon, 3 Oct 2022 00:14:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D4AF160F9B; Mon, 3 Oct 2022 07:14:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E88CCC433C1; Mon, 3 Oct 2022 07:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781240; bh=oKI7NKRGrfksCR9P5ES2xz6H45saQiR1p4Qbpz+75vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=18KUM+xOYNNDD2kax8P2vT2JH4BteYNlNoPCyafiBbOaDf5mQ4muDMqK1OOvnZnQF eSW+E9rd8XEMQ5JfJzVO0x2FbGM6DcUssVeOHMTO/sdBvjNaNVGZfggaAdfLgelk4M +E/ZBEwpuCV9/zMoEVwx7boJbfgeP1Cz80TBfZNo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Yu Zhao , Florian Lehner , Andrew Morton , "Peter Zijlstra (Intel)" , Matthew Wilcox , Josh Poimboeuf , Dave Hansen Subject: [PATCH 5.19 021/101] x86/uaccess: avoid check_object_size() in copy_from_user_nmi() Date: Mon, 3 Oct 2022 09:10:17 +0200 Message-Id: <20221003070725.020436093@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kees Cook commit 59298997df89e19aad426d4ae0a7e5037074da5a upstream. The check_object_size() helper under CONFIG_HARDENED_USERCOPY is designed to skip any checks where the length is known at compile time as a reasonable heuristic to avoid "likely known-good" cases. However, it can only do this when the copy_*_user() helpers are, themselves, inline too. Using find_vmap_area() requires taking a spinlock. The check_object_size() helper can call find_vmap_area() when the destination is in vmap memory. If show_regs() is called in interrupt context, it will attempt a call to copy_from_user_nmi(), which may call check_object_size() and then find_vmap_area(). If something in normal context happens to be in the middle of calling find_vmap_area() (with the spinlock held), the interrupt handler will hang forever. The copy_from_user_nmi() call is actually being called with a fixed-size length, so check_object_size() should never have been called in the first place. Given the narrow constraints, just replace the __copy_from_user_inatomic() call with an open-coded version that calls only into the sanitizers and not check_object_size(), followed by a call to raw_copy_from_user(). [akpm@linux-foundation.org: no instrument_copy_from_user() in my tree...] Link: https://lkml.kernel.org/r/20220919201648.2250764-1-keescook@chromium.= org Link: https://lore.kernel.org/all/CAOUHufaPshtKrTWOz7T7QFYUNVGFm0JBjvM700Nh= f9qEL9b3EQ@mail.gmail.com Fixes: 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") Signed-off-by: Kees Cook Reported-by: Yu Zhao Reported-by: Florian Lehner Suggested-by: Andrew Morton Acked-by: Peter Zijlstra (Intel) Tested-by: Florian Lehner Cc: Matthew Wilcox Cc: Josh Poimboeuf Cc: Dave Hansen Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/x86/lib/usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c index ad0139d25401..f1bb18617156 100644 --- a/arch/x86/lib/usercopy.c +++ b/arch/x86/lib/usercopy.c @@ -44,7 +44,7 @@ copy_from_user_nmi(void *to, const void __user *from, uns= igned long n) * called from other contexts. */ pagefault_disable(); - ret =3D __copy_from_user_inatomic(to, from, n); + ret =3D raw_copy_from_user(to, from, n); pagefault_enable(); =20 return ret; --=20 2.37.3 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 038A7C433FE for ; Mon, 3 Oct 2022 07:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbiJCHSR (ORCPT ); Mon, 3 Oct 2022 03:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiJCHRJ (ORCPT ); Mon, 3 Oct 2022 03:17:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB7A546872; Mon, 3 Oct 2022 00:14:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3C3A1B80E69; Mon, 3 Oct 2022 07:14:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A945EC433D6; Mon, 3 Oct 2022 07:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781243; bh=+Rg7jiz/BdLa2YuHZAziCH9S3XwBEVJjdLlinQYrA/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lijNi25JxUHd3a1WO4yOo+JlgdiG9ZQkdbcfiybQyvs3m8eiN/CCjP5sBwGRm2UPj J1AHrbhpUAyrHg3tsO/Tyd0sS2XU01VSqFbQ2TBRCW1OBMwBPyj+RbnlmidTjWlu4s 41oOp2tm2ZR2/zexgzbawsz0ZXL0AV1027PRslwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, SeongJae Park , Andrew Morton Subject: [PATCH 5.19 022/101] mm/damon/dbgfs: fix memory leak when using debugfs_lookup() Date: Mon, 3 Oct 2022 09:10:18 +0200 Message-Id: <20221003070725.042551819@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Greg Kroah-Hartman commit 1552fd3ef7dbe07208b8ae84a0a6566adf7dfc9d upstream. When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Link: https://lkml.kernel.org/r/20220902191149.112434-1-sj@kernel.org Fixes: 75c1c2b53c78b ("mm/damon/dbgfs: support multiple contexts") Signed-off-by: Greg Kroah-Hartman Signed-off-by: SeongJae Park Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/damon/dbgfs.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -853,6 +853,7 @@ static int dbgfs_rm_context(char *name) struct dentry *root, *dir, **new_dirs; struct damon_ctx **new_ctxs; int i, j; + int ret =3D 0; =20 if (damon_nr_running_ctxs()) return -EBUSY; @@ -867,14 +868,16 @@ static int dbgfs_rm_context(char *name) =20 new_dirs =3D kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs), GFP_KERNEL); - if (!new_dirs) - return -ENOMEM; + if (!new_dirs) { + ret =3D -ENOMEM; + goto out_dput; + } =20 new_ctxs =3D kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_ctxs), GFP_KERNEL); if (!new_ctxs) { - kfree(new_dirs); - return -ENOMEM; + ret =3D -ENOMEM; + goto out_new_dirs; } =20 for (i =3D 0, j =3D 0; i < dbgfs_nr_ctxs; i++) { @@ -894,7 +897,13 @@ static int dbgfs_rm_context(char *name) dbgfs_ctxs =3D new_ctxs; dbgfs_nr_ctxs--; =20 - return 0; + goto out_dput; + +out_new_dirs: + kfree(new_dirs); +out_dput: + dput(dir); + return ret; } =20 static ssize_t dbgfs_rm_context_write(struct file *file, From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ED17C433F5 for ; Mon, 3 Oct 2022 07:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbiJCHSU (ORCPT ); Mon, 3 Oct 2022 03:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbiJCHRK (ORCPT ); Mon, 3 Oct 2022 03:17:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905AE46D83; Mon, 3 Oct 2022 00:14:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2CDBE60F97; Mon, 3 Oct 2022 07:14:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42B7BC433D6; Mon, 3 Oct 2022 07:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781245; bh=7+Jc4ZKn4Sy68ymBcsJNg4ogzEvTSBNXTpWktOodtSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHYV2Uc4Dv5u7kV5aB3ABdhFcrmR5/atO+KAJP/icJLaPXtQThLLMIhUeap9NBeEM FsjktNft25nDvqmLu0UMzoh7bwrUhDyEiVpc+YlYSjNK7Mz61Efth+uR6NyITviPB/ D0N09lARXv8OEIVCQVM4ObsgpwyfZ5CXdqYcmEMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Couzens , Jakub Kicinski Subject: [PATCH 5.19 023/101] net: mt7531: only do PLL once after the reset Date: Mon, 3 Oct 2022 09:10:19 +0200 Message-Id: <20221003070725.065678312@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Couzens commit 42bc4fafe359ed6b73602b7a2dba0dd99588f8ce upstream. Move the PLL init of the switch out of the pad configuration of the port 6 (usally cpu port). Fix a unidirectional 100 mbit limitation on 1 gbit or 2.5 gbit links for outbound traffic on port 5 or port 6. Fixes: c288575f7810 ("net: dsa: mt7530: Add the support of MT7531 switch") Cc: stable@vger.kernel.org Signed-off-by: Alexander Couzens Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/dsa/mt7530.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -506,14 +506,19 @@ static bool mt7531_dual_sgmii_supported( static int mt7531_pad_setup(struct dsa_switch *ds, phy_interface_t interface) { - struct mt7530_priv *priv =3D ds->priv; + return 0; +} + +static void +mt7531_pll_setup(struct mt7530_priv *priv) +{ u32 top_sig; u32 hwstrap; u32 xtal; u32 val; =20 if (mt7531_dual_sgmii_supported(priv)) - return 0; + return; =20 val =3D mt7530_read(priv, MT7531_CREV); top_sig =3D mt7530_read(priv, MT7531_TOP_SIG_SR); @@ -592,8 +597,6 @@ mt7531_pad_setup(struct dsa_switch *ds, val |=3D EN_COREPLL; mt7530_write(priv, MT7531_PLLGP_EN, val); usleep_range(25, 35); - - return 0; } =20 static void @@ -2310,6 +2313,8 @@ mt7531_setup(struct dsa_switch *ds) SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST | SYS_CTRL_REG_RST); =20 + mt7531_pll_setup(priv); + if (mt7531_dual_sgmii_supported(priv)) { priv->p5_intf_sel =3D P5_INTF_SEL_GMAC5_SGMII; =20 @@ -2863,8 +2868,6 @@ mt7531_cpu_port_config(struct dsa_switch case 6: interface =3D PHY_INTERFACE_MODE_2500BASEX; =20 - mt7531_pad_setup(ds, interface); - priv->p6_interface =3D interface; break; default: From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFA39C433FE for ; Mon, 3 Oct 2022 07:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbiJCHSY (ORCPT ); Mon, 3 Oct 2022 03:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbiJCHRL (ORCPT ); Mon, 3 Oct 2022 03:17:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 770C046D8E; Mon, 3 Oct 2022 00:14:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5BCF60F97; Mon, 3 Oct 2022 07:14:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04C49C433C1; Mon, 3 Oct 2022 07:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781248; bh=vV6J72lgCKZaW1qd9qddBQY27IkQVHpqMFO4vnJKAs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZIEXvpgCPLc5LPZpg2xe7oRmr6y2vQaBn8kSggNEQmRFGUNc4GYJ03ZaoJ9Bet8h Ok70n9sxX6PXAVyw9VqkmklTazC0U4EXL1jLnejsEa6ob92d9UbNopMwNQGirGybzX EMMiocSCRkfIGXuxpwp3ntS24pDwq0QO7GZsUeM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Pitre , Ulf Hansson , Peng Fan , Sudeep Holla Subject: [PATCH 5.19 024/101] Revert "firmware: arm_scmi: Add clock management to the SCMI power domain" Date: Mon, 3 Oct 2022 09:10:20 +0200 Message-Id: <20221003070725.088014050@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ulf Hansson commit 3c6656337852e9f1a4079d172f3fddfbf00868f9 upstream. This reverts commit a3b884cef873 ("firmware: arm_scmi: Add clock management to the SCMI power domain"). Using the GENPD_FLAG_PM_CLK tells genpd to gate/ungate the consumer device's clock(s) during runtime suspend/resume through the PM clock API. More precisely, in genpd_runtime_resume() the clock(s) for the consumer device would become ungated prior to the driver-level ->runtime_resume() callbacks gets invoked. This behaviour isn't a good fit for all platforms/drivers. For example, a driver may need to make some preparations of its device in its ->runtime_resume() callback, like calling clk_set_rate() before the clock(s) should be ungated. In these cases, it's easier to let the clock(s) to be managed solely by the driver, rather than at the PM domain level. For these reasons, let's drop the use GENPD_FLAG_PM_CLK for the SCMI PM domain, as to enable it to be more easily adopted across ARM platforms. Fixes: a3b884cef873 ("firmware: arm_scmi: Add clock management to the SCMI = power domain") Cc: Nicolas Pitre Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Tested-by: Peng Fan Acked-by: Sudeep Holla Link: https://lore.kernel.org/r/20220919122033.86126-1-ulf.hansson@linaro.o= rg Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/firmware/arm_scmi/scmi_pm_domain.c | 26 ------------------------= -- 1 file changed, 26 deletions(-) --- a/drivers/firmware/arm_scmi/scmi_pm_domain.c +++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include =20 @@ -53,27 +52,6 @@ static int scmi_pd_power_off(struct gene return scmi_pd_power(domain, false); } =20 -static int scmi_pd_attach_dev(struct generic_pm_domain *pd, struct device = *dev) -{ - int ret; - - ret =3D pm_clk_create(dev); - if (ret) - return ret; - - ret =3D of_pm_clk_add_clks(dev); - if (ret >=3D 0) - return 0; - - pm_clk_destroy(dev); - return ret; -} - -static void scmi_pd_detach_dev(struct generic_pm_domain *pd, struct device= *dev) -{ - pm_clk_destroy(dev); -} - static int scmi_pm_domain_probe(struct scmi_device *sdev) { int num_domains, i; @@ -124,10 +102,6 @@ static int scmi_pm_domain_probe(struct s scmi_pd->genpd.name =3D scmi_pd->name; scmi_pd->genpd.power_off =3D scmi_pd_power_off; scmi_pd->genpd.power_on =3D scmi_pd_power_on; - scmi_pd->genpd.attach_dev =3D scmi_pd_attach_dev; - scmi_pd->genpd.detach_dev =3D scmi_pd_detach_dev; - scmi_pd->genpd.flags =3D GENPD_FLAG_PM_CLK | - GENPD_FLAG_ACTIVE_WAKEUP; =20 pm_genpd_init(&scmi_pd->genpd, NULL, state =3D=3D SCMI_POWER_STATE_GENERIC_OFF); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EC67C433F5 for ; Mon, 3 Oct 2022 07:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230199AbiJCHSa (ORCPT ); Mon, 3 Oct 2022 03:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbiJCHRO (ORCPT ); Mon, 3 Oct 2022 03:17:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18CFA371A5; Mon, 3 Oct 2022 00:14:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9FFF60F97; Mon, 3 Oct 2022 07:14:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EF2FC433D6; Mon, 3 Oct 2022 07:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781251; bh=Eqr91tjBZDyNknS0i+m0ndPM69/V9VHmFj2hNSJdAbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mf0TRf+o+g2gluegAAh5vZzkSEhiqsc9RBM5n3lCi8/LcZ96oSol0e2JSH25sl1hf 4SupEgduJupAwxTuOTkNyFE+sLUaykrPSzKXh5fbxOZy6AfFzsGxwxiKKCo8XHx8Il EVFOGZWoh18FB8Rju3jhhT+aO59q5ALWGRwz9FLY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Yang Shi , David Hildenbrand , Peter Xu , Christophe Leroy , Hugh Dickins , Jason Gunthorpe , John Hubbard , "Kirill A. Shutemov" , Michael Ellerman , Nicholas Piggin , Andrew Morton Subject: [PATCH 5.19 025/101] powerpc/64s/radix: dont need to broadcast IPI for radix pmd collapse flush Date: Mon, 3 Oct 2022 09:10:21 +0200 Message-Id: <20221003070725.110421385@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yang Shi commit bedf03416913d88c796288f9dca109a53608c745 upstream. The IPI broadcast is used to serialize against fast-GUP, but fast-GUP will move to use RCU instead of disabling local interrupts in fast-GUP. Using an IPI is the old-styled way of serializing against fast-GUP although it still works as expected now. And fast-GUP now fixed the potential race with THP collapse by checking whether PMD is changed or not. So IPI broadcast in radix pmd collapse flush is not necessary anymore. But it is still needed for hash TLB. Link: https://lkml.kernel.org/r/20220907180144.555485-2-shy828301@gmail.com Suggested-by: Aneesh Kumar K.V Signed-off-by: Yang Shi Acked-by: David Hildenbrand Acked-by: Peter Xu Cc: Christophe Leroy Cc: Hugh Dickins Cc: Jason Gunthorpe Cc: John Hubbard Cc: "Kirill A. Shutemov" Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/powerpc/mm/book3s64/radix_pgtable.c | 9 --------- 1 file changed, 9 deletions(-) --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -937,15 +937,6 @@ pmd_t radix__pmdp_collapse_flush(struct pmd =3D *pmdp; pmd_clear(pmdp); =20 - /* - * pmdp collapse_flush need to ensure that there are no parallel gup - * walk after this call. This is needed so that we can have stable - * page ref count when collapsing a page. We don't allow a collapse page - * if we have gup taken on the page. We can ensure that by sending IPI - * because gup walk happens with IRQ disabled. - */ - serialize_against_pte_lookup(vma->vm_mm); - radix__flush_tlb_collapsed_pmd(vma->vm_mm, address); =20 return pmd; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 060A0C433FE for ; Mon, 3 Oct 2022 07:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbiJCHSg (ORCPT ); Mon, 3 Oct 2022 03:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbiJCHRO (ORCPT ); Mon, 3 Oct 2022 03:17:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B3793ED4E; Mon, 3 Oct 2022 00:14:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2589EB80E69; Mon, 3 Oct 2022 07:14:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FC34C433C1; Mon, 3 Oct 2022 07:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781253; bh=ToXVLTSfASxOmtqB/vBORQ1vDkn7tqrtD8k2GV/76BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QXx8iW7Ju2+Xzq/+GA1/8gzFboGgqt3tvX8BNwHtIf5Es7Oa03RIrbwBT+cWjteAM ZsavnaiWQF3ZtPVmbUfGwFmDUkeijkS+/QYA1ljAzqLlYXveNypvdrLF8sIj2AOndQ 1ESWV+GVDl2fcGtu0raHovkI7D/TOVj1VVpKE2dM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tvrtko Ursulin , Chris Wilson , Andi Shyti , Andrzej Hajda , Rodrigo Vivi Subject: [PATCH 5.19 026/101] drm/i915/gt: Restrict forced preemption to the active context Date: Mon, 3 Oct 2022 09:10:22 +0200 Message-Id: <20221003070725.132925976@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chris Wilson commit 6ef7d362123ecb5bf6d163bb9c7fd6ba2d8c968c upstream. When we submit a new pair of contexts to ELSP for execution, we start a timer by which point we expect the HW to have switched execution to the pending contexts. If the promotion to the new pair of contexts has not occurred, we declare the executing context to have hung and force the preemption to take place by resetting the engine and resubmitting the new contexts. This can lead to an unfair situation where almost all of the preemption timeout is consumed by the first context which just switches into the second context immediately prior to the timer firing and triggering the preemption reset (assuming that the timer interrupts before we process the CS events for the context switch). The second context hasn't yet had a chance to yield to the incoming ELSP (and send the ACk for the promotion) and so ends up being blamed for the reset. If we see that a context switch has occurred since setting the preemption timeout, but have not yet received the ACK for the ELSP promotion, rearm the preemption timer and check again. This is especially significant if the first context was not schedulable and so we used the shortest timer possible, greatly increasing the chance of accidentally blaming the second innocent context. Fixes: 3a7a92aba8fb ("drm/i915/execlists: Force preemption") Fixes: d12acee84ffb ("drm/i915/execlists: Cancel banned contexts on schedul= e-out") Reported-by: Tvrtko Ursulin Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Cc: Andi Shyti Reviewed-by: Andrzej Hajda Tested-by: Andrzej Hajda Cc: # v5.5+ Signed-off-by: Andi Shyti Link: https://patchwork.freedesktop.org/patch/msgid/20220921135258.1714873-= 1-andrzej.hajda@intel.com (cherry picked from commit 107ba1a2c705f4358f2602ec2f2fd821bb651f42) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/i915/gt/intel_engine_types.h | 15 +++++++++++++ drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 21 ++++++++++++++= ++++- 2 files changed, 35 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/gt/intel_engine_types.h +++ b/drivers/gpu/drm/i915/gt/intel_engine_types.h @@ -156,6 +156,21 @@ struct intel_engine_execlists { struct timer_list preempt; =20 /** + * @preempt_target: active request at the time of the preemption request + * + * We force a preemption to occur if the pending contexts have not + * been promoted to active upon receipt of the CS ack event within + * the timeout. This timeout maybe chosen based on the target, + * using a very short timeout if the context is no longer schedulable. + * That short timeout may not be applicable to other contexts, so + * if a context switch should happen within before the preemption + * timeout, we may shoot early at an innocent context. To prevent this, + * we record which context was active at the time of the preemption + * request and only reset that context upon the timeout. + */ + const struct i915_request *preempt_target; + + /** * @ccid: identifier for contexts submitted to this engine */ u32 ccid; --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c @@ -1241,6 +1241,9 @@ static unsigned long active_preempt_time if (!rq) return 0; =20 + /* Only allow ourselves to force reset the currently active context */ + engine->execlists.preempt_target =3D rq; + /* Force a fast reset for terminated contexts (ignoring sysfs!) */ if (unlikely(intel_context_is_banned(rq->context) || bad_request(rq))) return 1; @@ -2427,8 +2430,24 @@ static void execlists_submission_tasklet GEM_BUG_ON(inactive - post > ARRAY_SIZE(post)); =20 if (unlikely(preempt_timeout(engine))) { + const struct i915_request *rq =3D *engine->execlists.active; + + /* + * If after the preempt-timeout expired, we are still on the + * same active request/context as before we initiated the + * preemption, reset the engine. + * + * However, if we have processed a CS event to switch contexts, + * but not yet processed the CS event for the pending + * preemption, reset the timer allowing the new context to + * gracefully exit. + */ cancel_timer(&engine->execlists.preempt); - engine->execlists.error_interrupt |=3D ERROR_PREEMPT; + if (rq =3D=3D engine->execlists.preempt_target) + engine->execlists.error_interrupt |=3D ERROR_PREEMPT; + else + set_timer_ms(&engine->execlists.preempt, + active_preempt_timeout(engine, rq)); } =20 if (unlikely(READ_ONCE(engine->execlists.error_interrupt))) { From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D8DC4332F for ; Mon, 3 Oct 2022 07:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230073AbiJCHTH (ORCPT ); Mon, 3 Oct 2022 03:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbiJCHRS (ORCPT ); Mon, 3 Oct 2022 03:17:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD0753FA21; Mon, 3 Oct 2022 00:14:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2FE6A60F9C; Mon, 3 Oct 2022 07:14:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 405E4C433C1; Mon, 3 Oct 2022 07:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781256; bh=8Mslj1HpVI930cyTmfnLKiQ1vm20+stzMVxebWCR37s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XvCIe3VPpwEi6a5YTkWTsz3rrA5G1wKDrEsyVYj1MnUgBgJu71Y6aPDRNoLNbCz8F VQzVwoxVkkW/HlhhsWt0QAQhbDxLvPWyAZbBgzAD2r2u7HY1ofmbnVCtWWKBzMacOH hVpU1CjtHIlryI2UwRu+v3aYFDcfoNM9q/TUlsUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bokun Zhang , Alex Deucher Subject: [PATCH 5.19 027/101] drm/amdgpu: Add amdgpu suspend-resume code path under SRIOV Date: Mon, 3 Oct 2022 09:10:23 +0200 Message-Id: <20221003070725.155253949@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bokun Zhang commit 3b7329cf5a767c1be38352d43066012e220ad43c upstream. - Under SRIOV, we need to send REQ_GPU_FINI to the hypervisor during the suspend time. Furthermore, we cannot request a mode 1 reset under SRIOV as VF. Therefore, we will skip it as it is called in suspend_noirq() function. - In the resume code path, we need to send REQ_GPU_INIT to the hypervisor and also resume PSP IP block under SRIOV. Signed-off-by: Bokun Zhang Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++++= ++- 2 files changed, 30 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -1056,6 +1056,10 @@ bool amdgpu_acpi_should_gpu_reset(struct { if (adev->flags & AMD_IS_APU) return false; + + if (amdgpu_sriov_vf(adev)) + return false; + return pm_suspend_target_state !=3D PM_SUSPEND_TO_IDLE; } =20 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3178,7 +3178,8 @@ static int amdgpu_device_ip_resume_phase continue; if (adev->ip_blocks[i].version->type =3D=3D AMD_IP_BLOCK_TYPE_COMMON || adev->ip_blocks[i].version->type =3D=3D AMD_IP_BLOCK_TYPE_GMC || - adev->ip_blocks[i].version->type =3D=3D AMD_IP_BLOCK_TYPE_IH) { + adev->ip_blocks[i].version->type =3D=3D AMD_IP_BLOCK_TYPE_IH || + (adev->ip_blocks[i].version->type =3D=3D AMD_IP_BLOCK_TYPE_PSP && am= dgpu_sriov_vf(adev))) { =20 r =3D adev->ip_blocks[i].version->funcs->resume(adev); if (r) { @@ -4124,12 +4125,20 @@ static void amdgpu_device_evict_resource int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) { struct amdgpu_device *adev =3D drm_to_adev(dev); + int r =3D 0; =20 if (dev->switch_power_state =3D=3D DRM_SWITCH_POWER_OFF) return 0; =20 adev->in_suspend =3D true; =20 + if (amdgpu_sriov_vf(adev)) { + amdgpu_virt_fini_data_exchange(adev); + r =3D amdgpu_virt_request_full_gpu(adev, false); + if (r) + return r; + } + if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3)) DRM_WARN("smart shift update failed\n"); =20 @@ -4153,6 +4162,9 @@ int amdgpu_device_suspend(struct drm_dev =20 amdgpu_device_ip_suspend_phase2(adev); =20 + if (amdgpu_sriov_vf(adev)) + amdgpu_virt_release_full_gpu(adev, false); + return 0; } =20 @@ -4171,6 +4183,12 @@ int amdgpu_device_resume(struct drm_devi struct amdgpu_device *adev =3D drm_to_adev(dev); int r =3D 0; =20 + if (amdgpu_sriov_vf(adev)) { + r =3D amdgpu_virt_request_full_gpu(adev, true); + if (r) + return r; + } + if (dev->switch_power_state =3D=3D DRM_SWITCH_POWER_OFF) return 0; =20 @@ -4185,6 +4203,13 @@ int amdgpu_device_resume(struct drm_devi } =20 r =3D amdgpu_device_ip_resume(adev); + + /* no matter what r is, always need to properly release full GPU */ + if (amdgpu_sriov_vf(adev)) { + amdgpu_virt_init_data_exchange(adev); + amdgpu_virt_release_full_gpu(adev, true); + } + if (r) { dev_err(adev->dev, "amdgpu_device_ip_resume failed (%d).\n", r); return r; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9A61C433FE for ; Mon, 3 Oct 2022 07:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbiJCHPc (ORCPT ); Mon, 3 Oct 2022 03:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiJCHOU (ORCPT ); Mon, 3 Oct 2022 03:14:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4D34363E; Mon, 3 Oct 2022 00:13:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1F4C6B80E68; Mon, 3 Oct 2022 07:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81773C433C1; Mon, 3 Oct 2022 07:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781183; bh=QJyR05NM4WiVWlT8tsk60B5jcs3NG5zS1iQCf/dY5BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZ2OE98jUlV3TK87dwZEyXEC9DMWlBdSEcnyGf/1+GMnU4kVBcLyfj3/C1d+5COtz n3KfAcTyfaiHE8/UkZQxoGJK/ZMqea5W9Yoo7ghtYZJWgWLT3ho7vmCi22DUPqGk4y ezVYjJXzeiEDIehMsWn7tW94/ArIfQTwPD8PhELk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xie Yongji , Jason Wang , Maxime Coquelin , "Michael S. Tsirkin" , Chaitanya Kulkarni Subject: [PATCH 5.19 028/101] vduse: prevent uninitialized memory accesses Date: Mon, 3 Oct 2022 09:10:24 +0200 Message-Id: <20221003070725.178005883@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maxime Coquelin commit 46f8a29272e51b6df7393d58fc5cb8967397ef2b upstream. If the VDUSE application provides a smaller config space than the driver expects, the driver may use uninitialized memory from the stack. This patch prevents it by initializing the buffer passed by the driver to store the config value. This fix addresses CVE-2022-2308. Cc: stable@vger.kernel.org # v5.15+ Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace") Reviewed-by: Xie Yongji Acked-by: Jason Wang Signed-off-by: Maxime Coquelin Message-Id: <20220831154923.97809-1-maxime.coquelin@redhat.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Chaitanya Kulkarni Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -662,10 +662,15 @@ static void vduse_vdpa_get_config(struct { struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); =20 - if (offset > dev->config_size || - len > dev->config_size - offset) + /* Initialize the buffer in case of partial copy. */ + memset(buf, 0, len); + + if (offset > dev->config_size) return; =20 + if (len > dev->config_size - offset) + len =3D dev->config_size - offset; + memcpy(buf, dev->config + offset, len); } From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E011BC433FE for ; Mon, 3 Oct 2022 07:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbiJCHPo (ORCPT ); Mon, 3 Oct 2022 03:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiJCHOm (ORCPT ); Mon, 3 Oct 2022 03:14:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0274D45055; Mon, 3 Oct 2022 00:13:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9959B80C81; Mon, 3 Oct 2022 07:13:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35168C433D6; Mon, 3 Oct 2022 07:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781186; bh=Vkd72FPB/NiqU8KfEz/dei/zZaRkT5Ml31CmPobGtQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2J0FI8SSuSbB6XiW7Aue3nvMF+94VIGltkD8RrH26SEndeBbj5OPy1gXowuphSk/3 yU4BdLobTLPCBMl9ctpwEMNbDMhs1wuymR0ujTBKra/F8DjYV7pc2dQP5r+0P98A98 PBvkGoErRm6NwaadyAUx4AdLQ17mwVmPKf/+g3TQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaap Berkhout , Niklas Cassel , Mario Limonciello , Damien Le Moal Subject: [PATCH 5.19 029/101] libata: add ATA_HORKAGE_NOLPM for Pioneer BDR-207M and BDR-205 Date: Mon, 3 Oct 2022 09:10:25 +0200 Message-Id: <20221003070725.201264783@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Niklas Cassel commit ea08aec7e77bfd6599489ec430f9f859ab84575a upstream. Commit 1527f69204fe ("ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile") added an explicit entry for AMD Green Sardine AHCI controller using the board_ahci_mobile configuration (this configuration has later been renamed to board_ahci_low_power). The board_ahci_low_power configuration enables support for low power modes. This explicit entry takes precedence over the generic AHCI controller entry, which does not enable support for low power modes. Therefore, when commit 1527f69204fe ("ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile") was backported to stable kernels, it make some Pioneer optical drives, which was working perfectly fine before the commit was backported, stop working. The real problem is that the Pioneer optical drives do not handle low power modes correctly. If these optical drives would have been tested on another AHCI controller using the board_ahci_low_power configuration, this issue would have been detected earlier. Unfortunately, the board_ahci_low_power configuration is only used in less than 15% of the total AHCI controller entries, so many devices have never been tested with an AHCI controller with low power modes. Fixes: 1527f69204fe ("ata: ahci: Add Green Sardine vendor ID as board_ahci_= mobile") Cc: stable@vger.kernel.org Reported-by: Jaap Berkhout Signed-off-by: Niklas Cassel Reviewed-by: Mario Limonciello Signed-off-by: Damien Le Moal Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/ata/libata-core.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3988,6 +3988,10 @@ static const struct ata_blacklist_entry { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, =20 + /* These specific Pioneer models have LPM issues */ + { "PIONEER BD-RW BDR-207M", NULL, ATA_HORKAGE_NOLPM }, + { "PIONEER BD-RW BDR-205", NULL, ATA_HORKAGE_NOLPM }, + /* Crucial BX100 SSD 500GB has broken LPM support */ { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79175C433FE for ; Mon, 3 Oct 2022 07:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiJCHPw (ORCPT ); Mon, 3 Oct 2022 03:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbiJCHO7 (ORCPT ); Mon, 3 Oct 2022 03:14:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8203B4507C; Mon, 3 Oct 2022 00:13:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C63EB80E67; Mon, 3 Oct 2022 07:13:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAFD5C433D7; Mon, 3 Oct 2022 07:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781189; bh=XAlIbqC6rX8/P862yW6S75b1R8vBqZLNf+9k9u5oU6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U3hS1yQ9aO/i9vdLfZFbYkMAqd8DpY9B2iNvzSoQkphce90nVdIFqHcsls9+6nzwg s9y68qlzmorkS2LNrkF8/sWm7No/IUU97kAvfcAQFA+xwGxwdhWtQKTeUCL6WE1qQr veJnFcBqXgFVj0+DzOB7A4Z5IG6c4L+e/tN8pFzc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Michal Hocko , Martin Zaharinov , "Uladzislau Rezki (Sony)" , Vlastimil Babka , Andrew Morton Subject: [PATCH 5.19 030/101] mm: fix BUG splat with kvmalloc + GFP_ATOMIC Date: Mon, 3 Oct 2022 09:10:26 +0200 Message-Id: <20221003070725.223611597@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Westphal commit 30c19366636f72515679aa10dad61a4d988d4c9a upstream. Martin Zaharinov reports BUG with 5.19.10 kernel: kernel BUG at mm/vmalloc.c:2437! invalid opcode: 0000 [#1] SMP CPU: 28 PID: 0 Comm: swapper/28 Tainted: G W O 5.19.9 #1 [..] RIP: 0010:__get_vm_area_node+0x120/0x130 __vmalloc_node_range+0x96/0x1e0 kvmalloc_node+0x92/0xb0 bucket_table_alloc.isra.0+0x47/0x140 rhashtable_try_insert+0x3a4/0x440 rhashtable_insert_slow+0x1b/0x30 [..] bucket_table_alloc uses kvzalloc(GPF_ATOMIC). If kmalloc fails, this now falls through to vmalloc and hits code paths that assume GFP_KERNEL. Link: https://lkml.kernel.org/r/20220926151650.15293-1-fw@strlen.de Fixes: a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc") Signed-off-by: Florian Westphal Suggested-by: Michal Hocko Link: https://lore.kernel.org/linux-mm/Yy3MS2uhSgjF47dy@pc636/T/#t Acked-by: Michal Hocko Reported-by: Martin Zaharinov Cc: Uladzislau Rezki (Sony) Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/util.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/mm/util.c +++ b/mm/util.c @@ -619,6 +619,10 @@ void *kvmalloc_node(size_t size, gfp_t f if (ret || size <=3D PAGE_SIZE) return ret; =20 + /* non-sleeping allocations are not supported by vmalloc */ + if (!gfpflags_allow_blocking(flags)) + return NULL; + /* Don't even allow crazy sizes */ if (unlikely(size > INT_MAX)) { WARN_ON_ONCE(!(flags & __GFP_NOWARN)); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC30C433FE for ; Mon, 3 Oct 2022 07:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbiJCHP5 (ORCPT ); Mon, 3 Oct 2022 03:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiJCHPB (ORCPT ); Mon, 3 Oct 2022 03:15:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BFBE4456D; Mon, 3 Oct 2022 00:13:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84E6C60F9D; Mon, 3 Oct 2022 07:13:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95928C433C1; Mon, 3 Oct 2022 07:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781192; bh=oI7WoSRs0qWoU3rqb4Lgv2/KUIFnQrRNqyd6f56F2ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZkzG+JIWEDQliKN1FtSslAc8U7Vlal6xodrsct6PL71uLn3sQhLKeYWNkkLyaA5c EaBlTVRyL3A4wSOXk30sYX9xfdf6v2qRVWiDP1c+/UUbymqlGjXivK4E9fimA2uF1Z 50WAJItwoc353pe9X7QND3aFzsLcH2JRbNCkDkvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiang Biao , Mengen Sun , Paolo Abeni , Menglong Dong , Mat Martineau , Jakub Kicinski Subject: [PATCH 5.19 031/101] mptcp: factor out __mptcp_close() without socket lock Date: Mon, 3 Oct 2022 09:10:27 +0200 Message-Id: <20221003070725.245896745@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong commit 26d3e21ce1aab6cb19069c510fac8e7474445b18 upstream. Factor out __mptcp_close() from mptcp_close(). The caller of __mptcp_close() should hold the socket lock, and cancel mptcp work when __mptcp_close() returns true. This function will be used in the next commit. Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests") Fixes: 6aeed9045071 ("mptcp: fix race on unaccepted mptcp sockets") Cc: stable@vger.kernel.org Reviewed-by: Jiang Biao Reviewed-by: Mengen Sun Acked-by: Paolo Abeni Signed-off-by: Menglong Dong Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/mptcp/protocol.c | 14 ++++++++++++-- net/mptcp/protocol.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2832,13 +2832,12 @@ static void __mptcp_destroy_sock(struct sock_put(sk); } =20 -static void mptcp_close(struct sock *sk, long timeout) +bool __mptcp_close(struct sock *sk, long timeout) { struct mptcp_subflow_context *subflow; struct mptcp_sock *msk =3D mptcp_sk(sk); bool do_cancel_work =3D false; =20 - lock_sock(sk); sk->sk_shutdown =3D SHUTDOWN_MASK; =20 if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) { @@ -2880,6 +2879,17 @@ cleanup: } else { mptcp_reset_timeout(msk, 0); } + + return do_cancel_work; +} + +static void mptcp_close(struct sock *sk, long timeout) +{ + bool do_cancel_work; + + lock_sock(sk); + + do_cancel_work =3D __mptcp_close(sk, timeout); release_sock(sk); if (do_cancel_work) mptcp_cancel_work(sk); --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -613,6 +613,7 @@ void mptcp_subflow_reset(struct sock *ss void mptcp_subflow_queue_clean(struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); +bool __mptcp_close(struct sock *sk, long timeout); =20 bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E639C433FE for ; Mon, 3 Oct 2022 07:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbiJCHQI (ORCPT ); Mon, 3 Oct 2022 03:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiJCHPI (ORCPT ); Mon, 3 Oct 2022 03:15:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED48D40BC7; Mon, 3 Oct 2022 00:13:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 16DA6B80E69; Mon, 3 Oct 2022 07:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77ACBC433C1; Mon, 3 Oct 2022 07:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781194; bh=6HHNQMF1M7RTYBYe9ZOVC9pbUKrPoECyuXiJrc/UJlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dt/bkzG+mewYZL48yzG9q3hpAHxb+JP8WyMKHwFrG/jvaHt7Y/VJO6F8fO+SlEhZP jLQyf1BRHFr6Q5fdf9dd/wzu202ppL9K8Xy8H5hTJSZQjxId1YaVkiWTGT3RLr4jw3 1nHva7XSn+UzbhmKaVaUsEATyNiZq29iGco56Ckw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiang Biao , Mengen Sun , Paolo Abeni , Menglong Dong , Mat Martineau , Jakub Kicinski Subject: [PATCH 5.19 032/101] mptcp: fix unreleased socket in accept queue Date: Mon, 3 Oct 2022 09:10:28 +0200 Message-Id: <20221003070725.267906048@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong commit 30e51b923e436b631e8d5b77fa5e318c6b066dc7 upstream. The mptcp socket and its subflow sockets in accept queue can't be released after the process exit. While the release of a mptcp socket in listening state, the corresponding tcp socket will be released too. Meanwhile, the tcp socket in the unaccept queue will be released too. However, only init subflow is in the unaccept queue, and the joined subflow is not in the unaccept queue, which makes the joined subflow won't be released, and therefore the corresponding unaccepted mptcp socket will not be released to. This can be reproduced easily with following steps: 1. create 2 namespace and veth: $ ip netns add mptcp-client $ ip netns add mptcp-server $ sysctl -w net.ipv4.conf.all.rp_filter=3D0 $ ip netns exec mptcp-client sysctl -w net.mptcp.enabled=3D1 $ ip netns exec mptcp-server sysctl -w net.mptcp.enabled=3D1 $ ip link add red-client netns mptcp-client type veth peer red-server \ netns mptcp-server $ ip -n mptcp-server address add 10.0.0.1/24 dev red-server $ ip -n mptcp-server address add 192.168.0.1/24 dev red-server $ ip -n mptcp-client address add 10.0.0.2/24 dev red-client $ ip -n mptcp-client address add 192.168.0.2/24 dev red-client $ ip -n mptcp-server link set red-server up $ ip -n mptcp-client link set red-client up 2. configure the endpoint and limit for client and server: $ ip -n mptcp-server mptcp endpoint flush $ ip -n mptcp-server mptcp limits set subflow 2 add_addr_accepted 2 $ ip -n mptcp-client mptcp endpoint flush $ ip -n mptcp-client mptcp limits set subflow 2 add_addr_accepted 2 $ ip -n mptcp-client mptcp endpoint add 192.168.0.2 dev red-client id \ 1 subflow 3. listen and accept on a port, such as 9999. The nc command we used here is modified, which makes it use mptcp protocol by default. $ ip netns exec mptcp-server nc -l -k -p 9999 4. open another *two* terminal and use each of them to connect to the server with the following command: $ ip netns exec mptcp-client nc 10.0.0.1 9999 Input something after connect to trigger the connection of the second subflow. So that there are two established mptcp connections, with the second one still unaccepted. 5. exit all the nc command, and check the tcp socket in server namespace. And you will find that there is one tcp socket in CLOSE_WAIT state and can't release forever. Fix this by closing all of the unaccepted mptcp socket in mptcp_subflow_queue_clean() with __mptcp_close(). Now, we can ensure that all unaccepted mptcp sockets will be cleaned by __mptcp_close() before they are released, so mptcp_sock_destruct(), which is used to clean the unaccepted mptcp socket, is not needed anymore. The selftests for mptcp is ran for this commit, and no new failures. Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests") Fixes: 6aeed9045071 ("mptcp: fix race on unaccepted mptcp sockets") Cc: stable@vger.kernel.org Reviewed-by: Jiang Biao Reviewed-by: Mengen Sun Acked-by: Paolo Abeni Signed-off-by: Menglong Dong Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 33 +++++++-------------------------- 3 files changed, 9 insertions(+), 27 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2692,7 +2692,7 @@ static void __mptcp_clear_xmit(struct so dfrag_clear(sk, dfrag); } =20 -static void mptcp_cancel_work(struct sock *sk) +void mptcp_cancel_work(struct sock *sk) { struct mptcp_sock *msk =3D mptcp_sk(sk); =20 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -614,6 +614,7 @@ void mptcp_subflow_queue_clean(struct so void mptcp_sock_graft(struct sock *sk, struct socket *parent); struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); +void mptcp_cancel_work(struct sock *sk); =20 bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port); --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -602,30 +602,6 @@ static bool subflow_hmac_valid(const str return !crypto_memneq(hmac, mp_opt->hmac, MPTCPOPT_HMAC_LEN); } =20 -static void mptcp_sock_destruct(struct sock *sk) -{ - /* if new mptcp socket isn't accepted, it is free'd - * from the tcp listener sockets request queue, linked - * from req->sk. The tcp socket is released. - * This calls the ULP release function which will - * also remove the mptcp socket, via - * sock_put(ctx->conn). - * - * Problem is that the mptcp socket will be in - * ESTABLISHED state and will not have the SOCK_DEAD flag. - * Both result in warnings from inet_sock_destruct. - */ - if ((1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) { - sk->sk_state =3D TCP_CLOSE; - WARN_ON_ONCE(sk->sk_socket); - sock_orphan(sk); - } - - /* We don't need to clear msk->subflow, as it's still NULL at this point = */ - mptcp_destroy_common(mptcp_sk(sk), 0); - inet_sock_destruct(sk); -} - static void mptcp_force_close(struct sock *sk) { /* the msk is not yet exposed to user-space */ @@ -768,7 +744,6 @@ create_child: /* new mpc subflow takes ownership of the newly * created mptcp socket */ - new_msk->sk_destruct =3D mptcp_sock_destruct; mptcp_sk(new_msk)->setsockopt_seq =3D ctx->setsockopt_seq; mptcp_pm_new_connection(mptcp_sk(new_msk), child, 1); mptcp_token_accept(subflow_req, mptcp_sk(new_msk)); @@ -1763,13 +1738,19 @@ void mptcp_subflow_queue_clean(struct so =20 for (msk =3D head; msk; msk =3D next) { struct sock *sk =3D (struct sock *)msk; - bool slow; + bool slow, do_cancel_work; =20 + sock_hold(sk); slow =3D lock_sock_fast_nested(sk); next =3D msk->dl_next; msk->first =3D NULL; msk->dl_next =3D NULL; + + do_cancel_work =3D __mptcp_close(sk, 0); unlock_sock_fast(sk, slow); + if (do_cancel_work) + mptcp_cancel_work(sk); + sock_put(sk); } =20 /* we are still under the listener msk socket lock */ From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93C92C433F5 for ; Mon, 3 Oct 2022 07:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbiJCHQQ (ORCPT ); Mon, 3 Oct 2022 03:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbiJCHPI (ORCPT ); Mon, 3 Oct 2022 03:15:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C3742AF4; Mon, 3 Oct 2022 00:13:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 065FD60F9E; Mon, 3 Oct 2022 07:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17F76C433C1; Mon, 3 Oct 2022 07:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781197; bh=XlEsKmMwMZ0trT6yuKAC/k9dEZb/s+PDZV0Hw2+rCEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vK09H3mUGSIONW3HRhMo/4aqSqk/WwPXIj5zzPep5s7UZ5ZJpC2T1JU8vJ2PhVuNR qENnkW8k7+px5MG7hJ84d2t56bsqvuRFRw8ccjZevggsn3vohKfuBM/02HwnQi+LL0 ZhXVFIxxmr1hZyC5hJLLwLIf02DOpQx8eb6UQJxU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergei Antonov , Jonas Jensen , Ulf Hansson Subject: [PATCH 5.19 033/101] mmc: moxart: fix 4-bit bus width and remove 8-bit bus width Date: Mon, 3 Oct 2022 09:10:29 +0200 Message-Id: <20221003070725.292524007@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sergei Antonov commit 35ca91d1338ae158f6dcc0de5d1e86197924ffda upstream. According to the datasheet [1] at page 377, 4-bit bus width is turned on by bit 2 of the Bus Width Register. Thus the current bitmask is wrong: define BUS_WIDTH_4 BIT(1) BIT(1) does not work but BIT(2) works. This has been verified on real MOXA hardware with FTSDC010 controller revision 1_6_0. The corrected value of BUS_WIDTH_4 mask collides with: define BUS_WIDTH_8 BIT(2). Additionally, 8-bit bus width mode isn't supported according to the datasheet, so let's remove the corresponding code. [1] https://bitbucket.org/Kasreyn/mkrom-uc7112lx/src/master/documents/FIC8120_D= S_v1.2.pdf Fixes: 1b66e94e6b99 ("mmc: moxart: Add MOXA ART SD/MMC driver") Signed-off-by: Sergei Antonov Cc: Jonas Jensen Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220907205753.1577434-1-saproj@gmail.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/mmc/host/moxart-mmc.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -111,8 +111,8 @@ #define CLK_DIV_MASK 0x7f =20 /* REG_BUS_WIDTH */ -#define BUS_WIDTH_8 BIT(2) -#define BUS_WIDTH_4 BIT(1) +#define BUS_WIDTH_4_SUPPORT BIT(3) +#define BUS_WIDTH_4 BIT(2) #define BUS_WIDTH_1 BIT(0) =20 #define MMC_VDD_360 23 @@ -524,9 +524,6 @@ static void moxart_set_ios(struct mmc_ho case MMC_BUS_WIDTH_4: writel(BUS_WIDTH_4, host->base + REG_BUS_WIDTH); break; - case MMC_BUS_WIDTH_8: - writel(BUS_WIDTH_8, host->base + REG_BUS_WIDTH); - break; default: writel(BUS_WIDTH_1, host->base + REG_BUS_WIDTH); break; @@ -651,16 +648,8 @@ static int moxart_probe(struct platform_ dmaengine_slave_config(host->dma_chan_rx, &cfg); } =20 - switch ((readl(host->base + REG_BUS_WIDTH) >> 3) & 3) { - case 1: + if (readl(host->base + REG_BUS_WIDTH) & BUS_WIDTH_4_SUPPORT) mmc->caps |=3D MMC_CAP_4_BIT_DATA; - break; - case 2: - mmc->caps |=3D MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; - break; - default: - break; - } =20 writel(0, host->base + REG_INTERRUPT_MASK); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7167EC433F5 for ; Mon, 3 Oct 2022 07:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbiJCHQW (ORCPT ); Mon, 3 Oct 2022 03:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbiJCHPZ (ORCPT ); Mon, 3 Oct 2022 03:15:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB0C941D17; Mon, 3 Oct 2022 00:13:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 41F98B80C81; Mon, 3 Oct 2022 07:13:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B08B6C433C1; Mon, 3 Oct 2022 07:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781200; bh=2UHdbvEr9lqpstgtuyNn+47IaQkePd+H6y1WP7Yv+1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hahpGKJSTSg14ioBr/YrV0/JnrGgUn8c3u5Z5Ao2rEcl7Nk45VTSm1Q7dtHUljBgr YdFsoKZrmgolLrpd7l5YGlpM9hetay288pLC21R5EgN58P+6wVyCUIaTc23krjSqpm u49otTHG51bHqoVRSD2M3z4qcyt7STfrMqkLHjXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenchao Chen , Ulf Hansson Subject: [PATCH 5.19 034/101] mmc: hsq: Fix data stomping during mmc recovery Date: Mon, 3 Oct 2022 09:10:30 +0200 Message-Id: <20221003070725.318915546@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wenchao Chen commit e7afa79a3b35a27a046a2139f8b20bd6b98155c2 upstream. The block device uses multiple queues to access emmc. There will be up to 3 requests in the hsq of the host. The current code will check whether there is a request doing recovery before entering the queue, but it will not check whether there is a request when the lock is issued. The request is in recov= ery mode. If there is a request in recovery, then a read and write request is initiated at this time, and the conflict between the request and the recove= ry request will cause the data to be trampled. Signed-off-by: Wenchao Chen Fixes: 511ce378e16f ("mmc: Add MMC host software queue support") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220916090506.10662-1-wenchao.chen666@gmai= l.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/mmc/host/mmc_hsq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mmc/host/mmc_hsq.c +++ b/drivers/mmc/host/mmc_hsq.c @@ -34,7 +34,7 @@ static void mmc_hsq_pump_requests(struct spin_lock_irqsave(&hsq->lock, flags); =20 /* Make sure we are not already running a request now */ - if (hsq->mrq) { + if (hsq->mrq || hsq->recovery_halt) { spin_unlock_irqrestore(&hsq->lock, flags); return; } From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95955C433F5 for ; Mon, 3 Oct 2022 07:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbiJCHQc (ORCPT ); Mon, 3 Oct 2022 03:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiJCHPc (ORCPT ); Mon, 3 Oct 2022 03:15:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DE342AC3; Mon, 3 Oct 2022 00:13:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 17210B80E66; Mon, 3 Oct 2022 07:13:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E8ECC433C1; Mon, 3 Oct 2022 07:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781202; bh=eRALWJ3VDd4ac52FWStXVH8+xbOlHaVgaUxiJbNQ1Z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gUqPz8QrEDajQjY6iueU3PhAG5ueUL2eisSDiCE8XvlSxCIf7y2bP89GcA/Zdh3ZI itVOOC+fjH6oQKCadju3dwdzSW8uFsjYVlFpap26o6RIseNmt9WYBGBTpoUCgdu3ok DtB+X41KLlJ5Ms5iY1iAI6hfII3le/rqWYyDjAJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Peter Xu , Yang Shi , John Hubbard , "Aneesh Kumar K.V" , Hugh Dickins , Jason Gunthorpe , "Kirill A. Shutemov" , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Andrew Morton Subject: [PATCH 5.19 035/101] mm: gup: fix the fast GUP race against THP collapse Date: Mon, 3 Oct 2022 09:10:31 +0200 Message-Id: <20221003070725.345654654@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yang Shi commit 70cbc3cc78a997d8247b50389d37c4e1736019da upstream. Since general RCU GUP fast was introduced in commit 2667f50e8b81 ("mm: introduce a general RCU get_user_pages_fast()"), a TLB flush is no longer sufficient to handle concurrent GUP-fast in all cases, it only handles traditional IPI-based GUP-fast correctly. On architectures that send an IPI broadcast on TLB flush, it works as expected. But on the architectures that do not use IPI to broadcast TLB flush, it may have the below race: CPU A CPU B THP collapse fast GUP gup_pmd_range() <-- see valid= pmd gup_pte_range() <-- work = on pte pmdp_collapse_flush() <-- clear pmd and flush __collapse_huge_page_isolate() check page pinned <-- before GUP bump refcount pin the page check PTE <-- no chan= ge __collapse_huge_page_copy() copy data to huge page ptep_clear() install huge pmd for the huge page return the stale page discard the stale page The race can be fixed by checking whether PMD is changed or not after taking the page pin in fast GUP, just like what it does for PTE. If the PMD is changed it means there may be parallel THP collapse, so GUP should back off. Also update the stale comment about serializing against fast GUP in khugepaged. Link: https://lkml.kernel.org/r/20220907180144.555485-1-shy828301@gmail.com Fixes: 2667f50e8b81 ("mm: introduce a general RCU get_user_pages_fast()") Acked-by: David Hildenbrand Acked-by: Peter Xu Signed-off-by: Yang Shi Reviewed-by: John Hubbard Cc: "Aneesh Kumar K.V" Cc: Hugh Dickins Cc: Jason Gunthorpe Cc: "Kirill A. Shutemov" Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/gup.c | 34 ++++++++++++++++++++++++++++------ mm/khugepaged.c | 10 ++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) --- a/mm/gup.c +++ b/mm/gup.c @@ -2278,8 +2278,28 @@ static void __maybe_unused undo_dev_page } =20 #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL -static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, - unsigned int flags, struct page **pages, int *nr) +/* + * Fast-gup relies on pte change detection to avoid concurrent pgtable + * operations. + * + * To pin the page, fast-gup needs to do below in order: + * (1) pin the page (by prefetching pte), then (2) check pte not changed. + * + * For the rest of pgtable operations where pgtable updates can be racy + * with fast-gup, we need to do (1) clear pte, then (2) check whether page + * is pinned. + * + * Above will work for all pte-level operations, including THP split. + * + * For THP collapse, it's a bit more complicated because fast-gup may be + * walking a pgtable page that is being freed (pte is still valid but pmd + * can be cleared already). To avoid race in such condition, we need to + * also check pmd here to make sure pmd doesn't change (corresponds to + * pmdp_collapse_flush() in the THP collapse code path). + */ +static int gup_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr, + unsigned long end, unsigned int flags, + struct page **pages, int *nr) { struct dev_pagemap *pgmap =3D NULL; int nr_start =3D *nr, ret =3D 0; @@ -2325,7 +2345,8 @@ static int gup_pte_range(pmd_t pmd, unsi goto pte_unmap; } =20 - if (unlikely(pte_val(pte) !=3D pte_val(*ptep))) { + if (unlikely(pmd_val(pmd) !=3D pmd_val(*pmdp)) || + unlikely(pte_val(pte) !=3D pte_val(*ptep))) { gup_put_folio(folio, 1, flags); goto pte_unmap; } @@ -2372,8 +2393,9 @@ pte_unmap: * get_user_pages_fast_only implementation that can pin pages. Thus it's s= till * useful to have gup_huge_pmd even if we can't operate on ptes. */ -static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, - unsigned int flags, struct page **pages, int *nr) +static int gup_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr, + unsigned long end, unsigned int flags, + struct page **pages, int *nr) { return 0; } @@ -2697,7 +2719,7 @@ static int gup_pmd_range(pud_t *pudp, pu if (!gup_huge_pd(__hugepd(pmd_val(pmd)), addr, PMD_SHIFT, next, flags, pages, nr)) return 0; - } else if (!gup_pte_range(pmd, addr, next, flags, pages, nr)) + } else if (!gup_pte_range(pmd, pmdp, addr, next, flags, pages, nr)) return 0; } while (pmdp++, addr =3D next, addr !=3D end); =20 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1121,10 +1121,12 @@ static void collapse_huge_page(struct mm =20 pmd_ptl =3D pmd_lock(mm, pmd); /* probably unnecessary */ /* - * After this gup_fast can't run anymore. This also removes - * any huge TLB entry from the CPU so we won't allow - * huge and small TLB entries for the same virtual address - * to avoid the risk of CPU bugs in that area. + * This removes any huge TLB entry from the CPU so we won't allow + * huge and small TLB entries for the same virtual address to + * avoid the risk of CPU bugs in that area. + * + * Parallel fast GUP is fine since fast GUP will back off when + * it detects PMD is changed. */ _pmd =3D pmdp_collapse_flush(vma, address, pmd); spin_unlock(pmd_ptl); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21366C433FE for ; Mon, 3 Oct 2022 07:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbiJCHQu (ORCPT ); Mon, 3 Oct 2022 03:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbiJCHPq (ORCPT ); Mon, 3 Oct 2022 03:15:46 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F5F42ACB; Mon, 3 Oct 2022 00:13:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 71762CE0B17; Mon, 3 Oct 2022 07:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 337E6C433C1; Mon, 3 Oct 2022 07:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781205; bh=yQd7L1bE3vogpj8UQLY+zukKpPigSc5eoQakXOiVIcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Vzklh9tCmSKEJWjm3wgyQN9iLdfd+njppT3q6zRnhZpCY+Y43TJUPgigxysAbe0J VgZILgDyhXRwCadVz0L03e3khQzUarM/RoIORmcnudl0SAKmIx15xK/n77j8ZIL9VW yc9frZr5yDnMOUk1Wj5waNMTWa1WbJgmMin6ELM8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mel Gorman , Patrick Daly , Michal Hocko , David Hildenbrand , Andrew Morton Subject: [PATCH 5.19 036/101] mm/page_alloc: fix race condition between build_all_zonelists and page allocation Date: Mon, 3 Oct 2022 09:10:32 +0200 Message-Id: <20221003070725.371328077@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mel Gorman commit 3d36424b3b5850bd92f3e89b953a430d7cfc88ef upstream. Patrick Daly reported the following problem; NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK] - before offline operati= on [0] - ZONE_MOVABLE [1] - ZONE_NORMAL [2] - NULL For a GFP_KERNEL allocation, alloc_pages_slowpath() will save the offset of ZONE_NORMAL in ac->preferred_zoneref. If a concurrent memory_offline operation removes the last page from ZONE_MOVABLE, build_all_zonelists() & build_zonerefs_node() will update node_zonelists as shown below. Only populated zones are added. NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK] - after offline operation [0] - ZONE_NORMAL [1] - NULL [2] - NULL The race is simple -- page allocation could be in progress when a memory hot-remove operation triggers a zonelist rebuild that removes zones. The allocation request will still have a valid ac->preferred_zoneref that is now pointing to NULL and triggers an OOM kill. This problem probably always existed but may be slightly easier to trigger due to 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with pages managed by the buddy allocator") which distinguishes between zones that are completely unpopulated versus zones that have valid pages not managed by the buddy allocator (e.g. reserved, memblock, ballooning etc). Memory hotplug had multiple stages with timing considerations around managed/present page updates, the zonelist rebuild and the zone span updates. As David Hildenbrand puts it memory offlining adjusts managed+present pages of the zone essentially in one go. If after the adjustments, the zone is no longer populated (present=3D=3D0), we rebuild the zone lists. Once that's done, we try shrinking the zone (start+spanned pages) -- which results in zone_start_pfn =3D=3D 0 if there are no more pages. That happens *after* rebuilding the zonelists via remove_pfn_range_from_zone(). The only requirement to fix the race is that a page allocation request identifies when a zonelist rebuild has happened since the allocation request started and no page has yet been allocated. Use a seqlock_t to track zonelist updates with a lockless read-side of the zonelist and protecting the rebuild and update of the counter with a spinlock. [akpm@linux-foundation.org: make zonelist_update_seq static] Link: https://lkml.kernel.org/r/20220824110900.vh674ltxmzb3proq@techsingula= rity.net Fixes: 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with= pages managed by the buddy allocator") Signed-off-by: Mel Gorman Reported-by: Patrick Daly Acked-by: Michal Hocko Reviewed-by: David Hildenbrand Cc: [4.9+] Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/page_alloc.c | 53 +++++++++++++++++++++++++++++++++++++++++++--------= -- 1 file changed, 43 insertions(+), 10 deletions(-) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4623,6 +4623,30 @@ void fs_reclaim_release(gfp_t gfp_mask) EXPORT_SYMBOL_GPL(fs_reclaim_release); #endif =20 +/* + * Zonelists may change due to hotplug during allocation. Detect when zone= lists + * have been rebuilt so allocation retries. Reader side does not lock and + * retries the allocation if zonelist changes. Writer side is protected by= the + * embedded spin_lock. + */ +static DEFINE_SEQLOCK(zonelist_update_seq); + +static unsigned int zonelist_iter_begin(void) +{ + if (IS_ENABLED(CONFIG_MEMORY_HOTREMOVE)) + return read_seqbegin(&zonelist_update_seq); + + return 0; +} + +static unsigned int check_retry_zonelist(unsigned int seq) +{ + if (IS_ENABLED(CONFIG_MEMORY_HOTREMOVE)) + return read_seqretry(&zonelist_update_seq, seq); + + return seq; +} + /* Perform direct synchronous page reclaim */ static unsigned long __perform_reclaim(gfp_t gfp_mask, unsigned int order, @@ -4916,6 +4940,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u int compaction_retries; int no_progress_loops; unsigned int cpuset_mems_cookie; + unsigned int zonelist_iter_cookie; int reserve_flags; =20 /* @@ -4926,11 +4951,12 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) gfp_mask &=3D ~__GFP_ATOMIC; =20 -retry_cpuset: +restart: compaction_retries =3D 0; no_progress_loops =3D 0; compact_priority =3D DEF_COMPACT_PRIORITY; cpuset_mems_cookie =3D read_mems_allowed_begin(); + zonelist_iter_cookie =3D zonelist_iter_begin(); =20 /* * The fast path uses conservative alloc_flags to succeed only until @@ -5102,9 +5128,13 @@ retry: goto retry; =20 =20 - /* Deal with possible cpuset update races before we start OOM killing */ - if (check_retry_cpuset(cpuset_mems_cookie, ac)) - goto retry_cpuset; + /* + * Deal with possible cpuset update races or zonelist updates to avoid + * a unnecessary OOM kill. + */ + if (check_retry_cpuset(cpuset_mems_cookie, ac) || + check_retry_zonelist(zonelist_iter_cookie)) + goto restart; =20 /* Reclaim has failed us, start killing things */ page =3D __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); @@ -5124,9 +5154,13 @@ retry: } =20 nopage: - /* Deal with possible cpuset update races before we fail */ - if (check_retry_cpuset(cpuset_mems_cookie, ac)) - goto retry_cpuset; + /* + * Deal with possible cpuset update races or zonelist updates to avoid + * a unnecessary OOM kill. + */ + if (check_retry_cpuset(cpuset_mems_cookie, ac) || + check_retry_zonelist(zonelist_iter_cookie)) + goto restart; =20 /* * Make sure that __GFP_NOFAIL request doesn't leak out and make sure @@ -6421,9 +6455,8 @@ static void __build_all_zonelists(void * int nid; int __maybe_unused cpu; pg_data_t *self =3D data; - static DEFINE_SPINLOCK(lock); =20 - spin_lock(&lock); + write_seqlock(&zonelist_update_seq); =20 #ifdef CONFIG_NUMA memset(node_load, 0, sizeof(node_load)); @@ -6460,7 +6493,7 @@ static void __build_all_zonelists(void * #endif } =20 - spin_unlock(&lock); + write_sequnlock(&zonelist_update_seq); } =20 static noinline void __init From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FB11C433FE for ; Mon, 3 Oct 2022 07:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbiJCHQp (ORCPT ); Mon, 3 Oct 2022 03:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiJCHPj (ORCPT ); Mon, 3 Oct 2022 03:15:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A07E45F66; Mon, 3 Oct 2022 00:13:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C579160F9B; Mon, 3 Oct 2022 07:13:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8B42C433D7; Mon, 3 Oct 2022 07:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781208; bh=5OVQrCg82psb8xU1cdSslCWpq3FxlHwUGy06ieOXlEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mrK/hkoZmp0ZF7zJNDh+aaGFA9mAspv26z9hv+n4pW8pn8Zv6bOTFLjNTNwX1MVH4 1wqJZRqRmWVlCQ0tulJRS+w4dVzo9IQ5ePpsx2By4Y98KwES/Ynh0c79xTv9a1iKyS AAK1KafSQTsEhVjtQv6RybE6BBY0DboaJXKRj57w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maurizio Lombardi , Alexander Duyck , Chen Lin , Jakub Kicinski , Andrew Morton Subject: [PATCH 5.19 037/101] mm: prevent page_frag_alloc() from corrupting the memory Date: Mon, 3 Oct 2022 09:10:33 +0200 Message-Id: <20221003070725.395139222@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maurizio Lombardi commit dac22531bbd4af2426c4e29e05594415ccfa365d upstream. A number of drivers call page_frag_alloc() with a fragment's size > PAGE_SIZE. In low memory conditions, __page_frag_cache_refill() may fail the order 3 cache allocation and fall back to order 0; In this case, the cache will be smaller than the fragment, causing memory corruptions. Prevent this from happening by checking if the newly allocated cache is large enough for the fragment; if not, the allocation will fail and page_frag_alloc() will return NULL. Link: https://lkml.kernel.org/r/20220715125013.247085-1-mlombard@redhat.com Fixes: b63ae8ca096d ("mm/net: Rename and move page fragment handling from n= et/ to mm/") Signed-off-by: Maurizio Lombardi Reviewed-by: Alexander Duyck Cc: Chen Lin Cc: Jakub Kicinski Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/page_alloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5651,6 +5651,18 @@ refill: /* reset page count bias and offset to start of new frag */ nc->pagecnt_bias =3D PAGE_FRAG_CACHE_MAX_SIZE + 1; offset =3D size - fragsz; + if (unlikely(offset < 0)) { + /* + * The caller is trying to allocate a fragment + * with fragsz > PAGE_SIZE but the cache isn't big + * enough to satisfy the request, this may + * happen in low memory conditions. + * We don't release the cache page because + * it could make memory pressure worse + * so we simply return NULL here. + */ + return NULL; + } } =20 nc->pagecnt_bias--; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1F06C433FE for ; Mon, 3 Oct 2022 07:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbiJCHRA (ORCPT ); Mon, 3 Oct 2022 03:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiJCHQA (ORCPT ); Mon, 3 Oct 2022 03:16:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC4D46215; Mon, 3 Oct 2022 00:13:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2CC7660F9B; Mon, 3 Oct 2022 07:13:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE65C433D6; Mon, 3 Oct 2022 07:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781213; bh=CFV5xLWV3169vW5q/lnpNP60a9I5FfoMfHFZB/0Ieto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZooN/h3+SV+2Cu71ynqw97zc8Ba6JPE3DjOPfGXe6fq/eRMMQBrbUu0aVt1NSWxsT j2la+3p+zFIZfZ83VZxYWgR8phDaH0/NO8QPJv4r9B389a4p7nVZl8oPWK2xWPy1CV 8LSRa67hRxRNSi8pz6UFg/5YuBz7xqofPCI33mTg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zi Yan , Doug Berger , David Hildenbrand , Mike Kravetz , Andrew Morton Subject: [PATCH 5.19 038/101] mm/page_isolation: fix isolate_single_pageblock() isolation behavior Date: Mon, 3 Oct 2022 09:10:34 +0200 Message-Id: <20221003070725.418906323@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zi Yan commit 80e2b584f3abfc31c3fe5573007f0d1d10810fde upstream. set_migratetype_isolate() does not allow isolating MIGRATE_CMA pageblocks unless it is used for CMA allocation. isolate_single_pageblock() did not have the same behavior when it is used together with set_migratetype_isolate() in start_isolate_page_range(). This allows alloc_contig_range() with migratetype other than MIGRATE_CMA, like MIGRATE_MOVABLE (used by alloc_contig_pages()), to isolate first and last pageblock but fail the rest. The failure leads to changing migratetype of the first and last pageblock to MIGRATE_MOVABLE from MIGRATE_CMA, corrupting the CMA region. This can happen during gigantic page allocations. Like Doug said here: https://lore.kernel.org/linux-mm/a3363a52-883b-dcd1-b77f-f2bb378d6f2d@gmail= .com/T/#u, for gigantic page allocations, the user would notice no difference, since the allocation on CMA region will fail as well as it did before. But it might hurt the performance of device drivers that use CMA, since CMA region size decreases. Fix it by passing migratetype into isolate_single_pageblock(), so that set_migratetype_isolate() used by isolate_single_pageblock() will prevent the isolation happening. Link: https://lkml.kernel.org/r/20220914023913.1855924-1-zi.yan@sent.com Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granula= rity") Signed-off-by: Zi Yan Reported-by: Doug Berger Cc: David Hildenbrand Cc: Doug Berger Cc: Mike Kravetz Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/page_isolation.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -288,6 +288,7 @@ __first_valid_page(unsigned long pfn, un * @isolate_before: isolate the pageblock before the boundary_pfn * @skip_isolation: the flag to skip the pageblock isolation in second * isolate_single_pageblock() + * @migratetype: migrate type to set in error recovery. * * Free and in-use pages can be as big as MAX_ORDER-1 and contain more tha= n one * pageblock. When not all pageblocks within a page are isolated at the sa= me @@ -302,9 +303,9 @@ __first_valid_page(unsigned long pfn, un * the in-use page then splitting the free page. */ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, - gfp_t gfp_flags, bool isolate_before, bool skip_isolation) + gfp_t gfp_flags, bool isolate_before, bool skip_isolation, + int migratetype) { - unsigned char saved_mt; unsigned long start_pfn; unsigned long isolate_pageblock; unsigned long pfn; @@ -328,13 +329,13 @@ static int isolate_single_pageblock(unsi start_pfn =3D max(ALIGN_DOWN(isolate_pageblock, MAX_ORDER_NR_PAGES), zone->zone_start_pfn); =20 - saved_mt =3D get_pageblock_migratetype(pfn_to_page(isolate_pageblock)); + if (skip_isolation) { + int mt =3D get_pageblock_migratetype(pfn_to_page(isolate_pageblock)); =20 - if (skip_isolation) - VM_BUG_ON(!is_migrate_isolate(saved_mt)); - else { - ret =3D set_migratetype_isolate(pfn_to_page(isolate_pageblock), saved_mt= , flags, - isolate_pageblock, isolate_pageblock + pageblock_nr_pages); + VM_BUG_ON(!is_migrate_isolate(mt)); + } else { + ret =3D set_migratetype_isolate(pfn_to_page(isolate_pageblock), migratet= ype, + flags, isolate_pageblock, isolate_pageblock + pageblock_nr_pages); =20 if (ret) return ret; @@ -475,7 +476,7 @@ static int isolate_single_pageblock(unsi failed: /* restore the original migratetype */ if (!skip_isolation) - unset_migratetype_isolate(pfn_to_page(isolate_pageblock), saved_mt); + unset_migratetype_isolate(pfn_to_page(isolate_pageblock), migratetype); return -EBUSY; } =20 @@ -537,7 +538,8 @@ int start_isolate_page_range(unsigned lo bool skip_isolation =3D false; =20 /* isolate [isolate_start, isolate_start + pageblock_nr_pages) pageblock = */ - ret =3D isolate_single_pageblock(isolate_start, flags, gfp_flags, false, = skip_isolation); + ret =3D isolate_single_pageblock(isolate_start, flags, gfp_flags, false, + skip_isolation, migratetype); if (ret) return ret; =20 @@ -545,7 +547,8 @@ int start_isolate_page_range(unsigned lo skip_isolation =3D true; =20 /* isolate [isolate_end - pageblock_nr_pages, isolate_end) pageblock */ - ret =3D isolate_single_pageblock(isolate_end, flags, gfp_flags, true, ski= p_isolation); + ret =3D isolate_single_pageblock(isolate_end, flags, gfp_flags, true, + skip_isolation, migratetype); if (ret) { unset_migratetype_isolate(pfn_to_page(isolate_start), migratetype); return ret; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7983C4332F for ; Mon, 3 Oct 2022 07:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbiJCHRK (ORCPT ); Mon, 3 Oct 2022 03:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiJCHQJ (ORCPT ); Mon, 3 Oct 2022 03:16:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C79F45F7B; Mon, 3 Oct 2022 00:13:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D43AA60FA2; Mon, 3 Oct 2022 07:13:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E75C5C433C1; Mon, 3 Oct 2022 07:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781216; bh=lpaqM68iF2A+dnBUkjIFdA/gEKCDcJqoCeNWy5/CwWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6RsebN3HsNM4IAPUQFZY9zShBY2/P7c4Gu6ogIJQbVwbDwTvrdibQgW3lCtO3nLC svKi/oTOf1E2X6XM+/28RjP8ZmqjP0ojpEeF0v9Abfq0FOxedTHUgiSn6RdfvmpGDX sLzkecNuwgOaFd/7tV6c0bVYGzE5bhiFA0YlFqUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Binyi Han , Andrew Morton , Mike Rapoport , Ammar Faizi , Hagen Paul Pfeifer , James Bottomley , Andrew Morton Subject: [PATCH 5.19 039/101] mm: fix dereferencing possible ERR_PTR Date: Mon, 3 Oct 2022 09:10:35 +0200 Message-Id: <20221003070725.443075863@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Binyi Han commit 4eb5bbde3ccb710d3b85bfb13466612e56393369 upstream. Smatch checker complains that 'secretmem_mnt' dereferencing possible ERR_PTR(). Let the function return if 'secretmem_mnt' is ERR_PTR, to avoid deferencing it. Link: https://lkml.kernel.org/r/20220904074647.GA64291@cloud-MacBookPro Fixes: 1507f51255c9f ("mm: introduce memfd_secret system call to create "se= cret" memory areas") Signed-off-by: Binyi Han Reviewed-by: Andrew Morton Cc: Mike Rapoport Cc: Ammar Faizi Cc: Hagen Paul Pfeifer Cc: James Bottomley Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/secretmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/secretmem.c +++ b/mm/secretmem.c @@ -283,7 +283,7 @@ static int secretmem_init(void) =20 secretmem_mnt =3D kern_mount(&secretmem_fs); if (IS_ERR(secretmem_mnt)) - ret =3D PTR_ERR(secretmem_mnt); + return PTR_ERR(secretmem_mnt); =20 /* prevent secretmem mappings from ever getting PROT_EXEC */ secretmem_mnt->mnt_flags |=3D MNT_NOEXEC; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EFC7C4332F for ; Mon, 3 Oct 2022 07:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbiJCHRR (ORCPT ); Mon, 3 Oct 2022 03:17:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiJCHQY (ORCPT ); Mon, 3 Oct 2022 03:16:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B717546236; Mon, 3 Oct 2022 00:13:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C0C560F9B; Mon, 3 Oct 2022 07:13:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 688C2C433D6; Mon, 3 Oct 2022 07:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781218; bh=QBY0gO4T5Cnxvtxpzk3yL4FGs5zO0Hc1hWtnO6/Truc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNve9ThnjpsivZM5Pvp4rHFxCX4T1ciReo0/msJ33J54eatRSBHBJ9fPlJZwK0F9V R3PhtUKYLJF29i3W6oXRsrzskc6EfInrzpPJJ12dDAkAZRcQoUoesJ08ZDogcoSktA JIQ+1Zxt4TG7Erd6fC0eDRqTbQGqwFRIrZYcuwm4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Popple , Nadav Amit , "Huang, Ying" , David Hildenbrand , Peter Xu , Alex Sierra , Ben Skeggs , Felix Kuehling , huang ying , Jason Gunthorpe , John Hubbard , Karol Herbst , Logan Gunthorpe , Lyude Paul , Matthew Wilcox , Paul Mackerras , Ralph Campbell , Andrew Morton Subject: [PATCH 5.19 040/101] mm/migrate_device.c: flush TLB while holding PTL Date: Mon, 3 Oct 2022 09:10:36 +0200 Message-Id: <20221003070725.465821005@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alistair Popple commit 60bae73708963de4a17231077285bd9ff2f41c44 upstream. When clearing a PTE the TLB should be flushed whilst still holding the PTL to avoid a potential race with madvise/munmap/etc. For example consider the following sequence: CPU0 CPU1 ---- ---- migrate_vma_collect_pmd() pte_unmap_unlock() madvise(MADV_DONTNEED) -> zap_pte_range() pte_offset_map_lock() [ PTE not present, TLB not flushed ] pte_unmap_unlock() [ page is still accessible via stale TLB ] flush_tlb_range() In this case the page may still be accessed via the stale TLB entry after madvise returns. Fix this by flushing the TLB while holding the PTL. Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while c= ollecting pages") Link: https://lkml.kernel.org/r/9f801e9d8d830408f2ca27821f606e09aa856899.16= 62078528.git-series.apopple@nvidia.com Signed-off-by: Alistair Popple Reported-by: Nadav Amit Reviewed-by: "Huang, Ying" Acked-by: David Hildenbrand Acked-by: Peter Xu Cc: Alex Sierra Cc: Ben Skeggs Cc: Felix Kuehling Cc: huang ying Cc: Jason Gunthorpe Cc: John Hubbard Cc: Karol Herbst Cc: Logan Gunthorpe Cc: Lyude Paul Cc: Matthew Wilcox Cc: Paul Mackerras Cc: Ralph Campbell Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/migrate_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -248,13 +248,14 @@ next: migrate->dst[migrate->npages] =3D 0; migrate->src[migrate->npages++] =3D mpfn; } - arch_leave_lazy_mmu_mode(); - pte_unmap_unlock(ptep - 1, ptl); =20 /* Only flush the TLB if we actually modified any entries */ if (unmapped) flush_tlb_range(walk->vma, start, end); =20 + arch_leave_lazy_mmu_mode(); + pte_unmap_unlock(ptep - 1, ptl); + return 0; } From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32403C4332F for ; Mon, 3 Oct 2022 07:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbiJCHRT (ORCPT ); Mon, 3 Oct 2022 03:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbiJCHQ1 (ORCPT ); Mon, 3 Oct 2022 03:16:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527A740E25; Mon, 3 Oct 2022 00:13:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EA001B80E6A; Mon, 3 Oct 2022 07:13:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 182B3C433D6; Mon, 3 Oct 2022 07:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781221; bh=X8HBuCkoqw+yFs+sNyv9u+U5y3+61Xxi/ip1jmfXBUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=krpKYOciYJl6ZqiYcBQaUr4oCV6l2EDfc7SzukTUrtUyhtf89cUrV2mc69DU6Uzae ivhPOl28k8nyhtPJLL6a8frxeCoyu7HgRKIQz0RNU5HJYIwhRRxU9vCD5UQdcWWTRt DwGln77/vauutDiVrYloJQWkF/dRHTBcvfFKk5Ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Popple , David Hildenbrand , Peter Xu , Alex Sierra , Ben Skeggs , Felix Kuehling , huang ying , "Huang, Ying" , Jason Gunthorpe , John Hubbard , Karol Herbst , Logan Gunthorpe , Lyude Paul , Matthew Wilcox , Nadav Amit , Paul Mackerras , Ralph Campbell , Andrew Morton Subject: [PATCH 5.19 041/101] mm/migrate_device.c: add missing flush_cache_page() Date: Mon, 3 Oct 2022 09:10:37 +0200 Message-Id: <20221003070725.488962594@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alistair Popple commit a3589e1d5fe39c3d9fdd291b111524b93d08bc32 upstream. Currently we only call flush_cache_page() for the anon_exclusive case, however in both cases we clear the pte so should flush the cache. Link: https://lkml.kernel.org/r/5676f30436ab71d1a587ac73f835ed8bd2113ff5.16= 62078528.git-series.apopple@nvidia.com Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while c= ollecting pages") Signed-off-by: Alistair Popple Reviewed-by: David Hildenbrand Acked-by: Peter Xu Cc: Alex Sierra Cc: Ben Skeggs Cc: Felix Kuehling Cc: huang ying Cc: "Huang, Ying" Cc: Jason Gunthorpe Cc: John Hubbard Cc: Karol Herbst Cc: Logan Gunthorpe Cc: Lyude Paul Cc: Matthew Wilcox Cc: Nadav Amit Cc: Paul Mackerras Cc: Ralph Campbell Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/migrate_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -187,9 +187,9 @@ again: bool anon_exclusive; pte_t swp_pte; =20 + flush_cache_page(vma, addr, pte_pfn(*ptep)); anon_exclusive =3D PageAnon(page) && PageAnonExclusive(page); if (anon_exclusive) { - flush_cache_page(vma, addr, pte_pfn(*ptep)); ptep_clear_flush(vma, addr, ptep); =20 if (page_try_share_anon_rmap(page)) { From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 710E5C433F5 for ; Mon, 3 Oct 2022 07:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbiJCHRZ (ORCPT ); Mon, 3 Oct 2022 03:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbiJCHQn (ORCPT ); Mon, 3 Oct 2022 03:16:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F06743174; Mon, 3 Oct 2022 00:13:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 85E0BB80E6B; Mon, 3 Oct 2022 07:13:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6613C433D6; Mon, 3 Oct 2022 07:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781224; bh=FO6Ju2lN74Xn8cplvWUTK7Mf2MLEblUMhdcsRMe7v60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PYHioe07XpxjvPovpCo52NlXxWB7W0KQNHYuIOJHDFQKXSOs9taMgGywvgNnHWdv5 aoSr1SLShzS9IfXjXuurFehoMyN0I4QBLEzZ4vAbwq/WjzBhYK0QXpZPunK9DikxXq yNnMEYgvo1tTvgyvCU41fH3WQpYRHZGuQ9TINj0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Popple , Peter Xu , "Huang, Ying" , David Hildenbrand , Alex Sierra , Ben Skeggs , Felix Kuehling , huang ying , Jason Gunthorpe , John Hubbard , Karol Herbst , Logan Gunthorpe , Lyude Paul , Matthew Wilcox , Nadav Amit , Paul Mackerras , Ralph Campbell , Andrew Morton Subject: [PATCH 5.19 042/101] mm/migrate_device.c: copy pte dirty bit to page Date: Mon, 3 Oct 2022 09:10:38 +0200 Message-Id: <20221003070725.513231234@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alistair Popple commit fd35ca3d12cc9922d7d9a35f934e72132dbc4853 upstream. migrate_vma_setup() has a fast path in migrate_vma_collect_pmd() that installs migration entries directly if it can lock the migrating page. When removing a dirty pte the dirty bit is supposed to be carried over to the underlying page to prevent it being lost. Currently migrate_vma_*() can only be used for private anonymous mappings. That means loss of the dirty bit usually doesn't result in data loss because these pages are typically not file-backed. However pages may be backed by swap storage which can result in data loss if an attempt is made to migrate a dirty page that doesn't yet have the PageDirty flag set. In this case migration will fail due to unexpected references but the dirty pte bit will be lost. If the page is subsequently reclaimed data won't be written back to swap storage as it is considered uptodate, resulting in data loss if the page is subsequently accessed. Prevent this by copying the dirty bit to the page when removing the pte to match what try_to_migrate_one() does. Link: https://lkml.kernel.org/r/dd48e4882ce859c295c1a77612f66d198b0403f9.16= 62078528.git-series.apopple@nvidia.com Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while c= ollecting pages") Signed-off-by: Alistair Popple Acked-by: Peter Xu Reviewed-by: "Huang, Ying" Reported-by: "Huang, Ying" Acked-by: David Hildenbrand Cc: Alex Sierra Cc: Ben Skeggs Cc: Felix Kuehling Cc: huang ying Cc: Jason Gunthorpe Cc: John Hubbard Cc: Karol Herbst Cc: Logan Gunthorpe Cc: Lyude Paul Cc: Matthew Wilcox Cc: Nadav Amit Cc: Paul Mackerras Cc: Ralph Campbell Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/migrate_device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ again: flush_cache_page(vma, addr, pte_pfn(*ptep)); anon_exclusive =3D PageAnon(page) && PageAnonExclusive(page); if (anon_exclusive) { - ptep_clear_flush(vma, addr, ptep); + pte =3D ptep_clear_flush(vma, addr, ptep); =20 if (page_try_share_anon_rmap(page)) { set_pte_at(mm, addr, ptep, pte); @@ -200,11 +201,15 @@ again: goto next; } } else { - ptep_get_and_clear(mm, addr, ptep); + pte =3D ptep_get_and_clear(mm, addr, ptep); } =20 migrate->cpages++; =20 + /* Set the dirty flag on the folio now the pte is gone. */ + if (pte_dirty(pte)) + folio_mark_dirty(page_folio(page)); + /* Setup special migration page table entry */ if (mpfn & MIGRATE_PFN_WRITE) entry =3D make_writable_migration_entry( From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77DDBC433F5 for ; Mon, 3 Oct 2022 07:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbiJCHRj (ORCPT ); Mon, 3 Oct 2022 03:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbiJCHQo (ORCPT ); Mon, 3 Oct 2022 03:16:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F6543323; Mon, 3 Oct 2022 00:13:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48EE7B80E6A; Mon, 3 Oct 2022 07:13:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A07E0C433C1; Mon, 3 Oct 2022 07:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781227; bh=yYXATCN3SG+QiRAjqsQcAqt+qY8BdCFgjFsX71kkt60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2pPv1DBixm+m0D5n7/GcAmdSKMo+qO9gFzVliHmwy5Dy9u4iLI03ZTG/u6Q6TDCzW aqbEuYbMBDbjVDyE9wMOcSlM0A1Ijy791+M7aNcYgZzZ1/r1uhlVxUffwQbVy9niPt +uqb//gqjAZp7PY6qUB5aqEj3XsviLYxt1Q+wfUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minchan Kim , =?UTF-8?q?=E9=9F=A9=E5=A4=A9=C3=A7`=C2=95?= , Yang Shi , Andrew Morton Subject: [PATCH 5.19 043/101] mm: fix madivse_pageout mishandling on non-LRU page Date: Mon, 3 Oct 2022 09:10:39 +0200 Message-Id: <20221003070725.536167230@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Minchan Kim commit 58d426a7ba92870d489686dfdb9d06b66815a2ab upstream. MADV_PAGEOUT tries to isolate non-LRU pages and gets a warning from isolate_lru_page below. Fix it by checking PageLRU in advance. Acked-by: Yang Shi Reported-by: =E9=9F=A9=E5=A4=A9=C3=A7`=C2=95 Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Suggested-by: Yang Shi Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz ------------[ cut here ]------------ trying to isolate tail page WARNING: CPU: 0 PID: 6175 at mm/folio-compat.c:158 isolate_lru_page+0x130/0= x140 Modules linked in: CPU: 0 PID: 6175 Comm: syz-executor.0 Not tainted 5.18.12 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1= .1 04/01/2014 RIP: 0010:isolate_lru_page+0x130/0x140 Link: https://lore.kernel.org/linux-mm/485f8c33.2471b.182d5726afb.Coremail.= hantianshuo@iie.ac.cn/ Link: https://lkml.kernel.org/r/20220908151204.762596-1-minchan@kernel.org Fixes: 1a4e58cce84e ("mm: introduce MADV_PAGEOUT") Signed-off-by: Minchan Kim Reported-by: =E9=9F=A9=E5=A4=A9=C3=A7`=C2=95 Suggested-by: Yang Shi Acked-by: Yang Shi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/madvise.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/mm/madvise.c +++ b/mm/madvise.c @@ -451,8 +451,11 @@ regular_page: continue; } =20 - /* Do not interfere with other mappings of this page */ - if (page_mapcount(page) !=3D 1) + /* + * Do not interfere with other mappings of this page and + * non-LRU page. + */ + if (!PageLRU(page) || page_mapcount(page) !=3D 1) continue; =20 VM_BUG_ON_PAGE(PageTransCompound(page), page); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98776C43217 for ; Mon, 3 Oct 2022 07:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbiJCHRt (ORCPT ); Mon, 3 Oct 2022 03:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiJCHQp (ORCPT ); Mon, 3 Oct 2022 03:16:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36ED146602; Mon, 3 Oct 2022 00:13:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E1484B80E6B; Mon, 3 Oct 2022 07:13:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59BD9C433C1; Mon, 3 Oct 2022 07:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781229; bh=X1Hz+u9FsRDHqr1BOnIwNn2OeuPOmZB0yb2KcNknYag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uLPblokSRcXIAQUS3uyFOW5IyMUoSpYhbUk7FjSKj/A07iSPqqg+0miWdSMsVYHhn WV6UYzJiVjajSYi/0My1FobfraaWtoo+f5ZqO5WBLszZmBX/1hak/dBZ+H9KNlKPHH LjW1FKOTWymYPyIKiidKB/PReQvzUeQJ3G9fg1UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergei Antonov , "Kirill A. Shutemov" , Will Deacon , Andrew Morton Subject: [PATCH 5.19 044/101] mm: bring back update_mmu_cache() to finish_fault() Date: Mon, 3 Oct 2022 09:10:40 +0200 Message-Id: <20221003070725.558888398@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sergei Antonov commit 70427f6e9ecfc8c5f977b21dd9f846b3bda02500 upstream. Running this test program on ARMv4 a few times (sometimes just once) reproduces the bug. int main() { unsigned i; char paragon[SIZE]; void* ptr; memset(paragon, 0xAA, SIZE); ptr =3D mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); if (ptr =3D=3D MAP_FAILED) return 1; printf("ptr =3D %p\n", ptr); for (i=3D0;i<10000;i++){ memset(ptr, 0xAA, SIZE); if (memcmp(ptr, paragon, SIZE)) { printf("Unexpected bytes on iteration %u!!!\n", i); break; } } munmap(ptr, SIZE); } In the "ptr" buffer there appear runs of zero bytes which are aligned by 16 and their lengths are multiple of 16. Linux v5.11 does not have the bug, "git bisect" finds the first bad commit: f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") Before the commit update_mmu_cache() was called during a call to filemap_map_pages() as well as finish_fault(). After the commit finish_fault() lacks it. Bring back update_mmu_cache() to finish_fault() to fix the bug. Also call update_mmu_tlb() only when returning VM_FAULT_NOPAGE to more closely reproduce the code of alloc_set_pte() function that existed before the commit. On many platforms update_mmu_cache() is nop: x86, see arch/x86/include/asm/pgtable ARMv6+, see arch/arm/include/asm/tlbflush.h So, it seems, few users ran into this bug. Link: https://lkml.kernel.org/r/20220908204809.2012451-1-saproj@gmail.com Fixes: f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") Signed-off-by: Sergei Antonov Acked-by: Kirill A. Shutemov Cc: Will Deacon Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/memory.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/mm/memory.c +++ b/mm/memory.c @@ -4378,14 +4378,20 @@ vm_fault_t finish_fault(struct vm_fault =20 vmf->pte =3D pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); - ret =3D 0; + /* Re-check under ptl */ - if (likely(!vmf_pte_changed(vmf))) + if (likely(!vmf_pte_changed(vmf))) { do_set_pte(vmf, page, vmf->address); - else + + /* no need to invalidate: a not-present page won't be cached */ + update_mmu_cache(vma, vmf->address, vmf->pte); + + ret =3D 0; + } else { + update_mmu_tlb(vma, vmf->address, vmf->pte); ret =3D VM_FAULT_NOPAGE; + } =20 - update_mmu_tlb(vma, vmf->address, vmf->pte); pte_unmap_unlock(vmf->pte, vmf->ptl); return ret; } From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA532C433F5 for ; Mon, 3 Oct 2022 07:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbiJCHR5 (ORCPT ); Mon, 3 Oct 2022 03:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiJCHQq (ORCPT ); Mon, 3 Oct 2022 03:16:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCDA46604; Mon, 3 Oct 2022 00:13:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DF1F660F9C; Mon, 3 Oct 2022 07:13:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0167CC433C1; Mon, 3 Oct 2022 07:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781232; bh=WH8xXGMb++7ru7vAHuHr8eK/naEzy0QN+TcJ34WR0qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMWfcZYh23t+vT5K/IkC3vGLJkXNJscPk1GdCzW2kLFifPynFaRhe/5GP+oiS1lJl jvn+FF+MQcbIUEb/cB5kMEQQK5pPk050YnXJ0GYA6W8E8ulbUz+JJVAxqqFxkRDRoy e3QVb8cdK06Ra2gR3FtuFBnsUy8B5mB21vVl0R8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Doug Berger , Mike Kravetz , Oscar Salvador , Anshuman Khandual , Muchun Song , Andrew Morton Subject: [PATCH 5.19 045/101] mm/hugetlb: correct demote page offset logic Date: Mon, 3 Oct 2022 09:10:41 +0200 Message-Id: <20221003070725.581159438@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Doug Berger commit 317314527d173e1f139ceaf8cb87cb1746abf240 upstream. With gigantic pages it may not be true that struct page structures are contiguous across the entire gigantic page. The nth_page macro is used here in place of direct pointer arithmetic to correct for this. Mike said: : This error could cause addressing exceptions. However, this is only : possible in configurations where CONFIG_SPARSEMEM && : !CONFIG_SPARSEMEM_VMEMMAP. Such a configuration option is rare and : unknown to be the default anywhere. Link: https://lkml.kernel.org/r/20220914190917.3517663-1-opendmb@gmail.com Fixes: 8531fc6f52f5 ("hugetlb: add hugetlb demote page support") Signed-off-by: Doug Berger Reviewed-by: Mike Kravetz Reviewed-by: Oscar Salvador Reviewed-by: Anshuman Khandual Cc: Muchun Song Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/hugetlb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3418,6 +3418,7 @@ static int demote_free_huge_page(struct { int i, nid =3D page_to_nid(page); struct hstate *target_hstate; + struct page *subpage; int rc =3D 0; =20 target_hstate =3D size_to_hstate(PAGE_SIZE << h->demote_order); @@ -3451,15 +3452,16 @@ static int demote_free_huge_page(struct mutex_lock(&target_hstate->resize_lock); for (i =3D 0; i < pages_per_huge_page(h); i +=3D pages_per_huge_page(target_hstate)) { + subpage =3D nth_page(page, i); if (hstate_is_gigantic(target_hstate)) - prep_compound_gigantic_page_for_demote(page + i, + prep_compound_gigantic_page_for_demote(subpage, target_hstate->order); else - prep_compound_page(page + i, target_hstate->order); - set_page_private(page + i, 0); - set_page_refcounted(page + i); - prep_new_huge_page(target_hstate, page + i, nid); - put_page(page + i); + prep_compound_page(subpage, target_hstate->order); + set_page_private(subpage, 0); + set_page_refcounted(subpage); + prep_new_huge_page(target_hstate, subpage, nid); + put_page(subpage); } mutex_unlock(&target_hstate->resize_lock); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD259C4332F for ; Mon, 3 Oct 2022 07:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbiJCHSC (ORCPT ); Mon, 3 Oct 2022 03:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiJCHQw (ORCPT ); Mon, 3 Oct 2022 03:16:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F164646625; Mon, 3 Oct 2022 00:13:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D2DF60F9D; Mon, 3 Oct 2022 07:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F08DC433C1; Mon, 3 Oct 2022 07:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781235; bh=ICoUNowOuD5gwjloT5nuRQeI+kxe38qBkwjQbhHvGqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9kCsHIJFejxAe3v/ITTN2WJdTp6/lBFODm7ZTEW7SZZnaSLkWO7J9pFa5otaDyf2 eTBQTezHoYD/6uMycD+Xc/SRgBlm1P9/vL9u5PegrmBcHxlXSc8C19+B8vJ1c0JrCF +EdmdMZt6n7H23EqKiKKZIDi6P1ykkJiCkAwyynw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuai Xue , Miaohe Lin , Naoya Horiguchi , Huang Ying , Baolin Wang , Bixuan Cui , Andrew Morton Subject: [PATCH 5.19 046/101] mm,hwpoison: check mm when killing accessing process Date: Mon, 3 Oct 2022 09:10:42 +0200 Message-Id: <20221003070725.603747728@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Shuai Xue commit 77677cdbc2aa4b5d5d839562793d3d126201d18d upstream. The GHES code calls memory_failure_queue() from IRQ context to queue work into workqueue and schedule it on the current CPU. Then the work is processed in memory_failure_work_func() by kworker and calls memory_failure(). When a page is already poisoned, commit a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") make memory_failure() call kill_accessing_process() that: - holds mmap locking of current->mm - does pagetable walk to find the error virtual address - and sends SIGBUS to the current process with error info. However, the mm of kworker is not valid, resulting in a null-pointer dereference. So check mm when killing the accessing process. [akpm@linux-foundation.org: remove unrelated whitespace alteration] Link: https://lkml.kernel.org/r/20220914064935.7851-1-xueshuai@linux.alibab= a.com Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") Signed-off-by: Shuai Xue Reviewed-by: Miaohe Lin Acked-by: Naoya Horiguchi Cc: Huang Ying Cc: Baolin Wang Cc: Bixuan Cui Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/memory-failure.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -697,6 +697,9 @@ static int kill_accessing_process(struct }; priv.tk.tsk =3D p; =20 + if (!p->mm) + return -EFAULT; + mmap_read_lock(p->mm); ret =3D walk_page_range(p->mm, 0, TASK_SIZE, &hwp_walk_ops, (void *)&priv); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC8E3C433F5 for ; Mon, 3 Oct 2022 07:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbiJCHSM (ORCPT ); Mon, 3 Oct 2022 03:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiJCHQw (ORCPT ); Mon, 3 Oct 2022 03:16:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A236640E0F; Mon, 3 Oct 2022 00:13:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3EF3D60F9D; Mon, 3 Oct 2022 07:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BBE1C433C1; Mon, 3 Oct 2022 07:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781237; bh=RA3vT0zFO6Qmwc+snoDbLflU27xJqDl5xuyhFeeCMuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0hGiEbW9qoepAuS+CMtPMCOzgxQi8m151SfydECawsBaidXR3YqOiJTbBz+yWEjY ydHKRNs6OKjwjzMmQtqzpimJNG7OCxlY0w5vOPNpcCRpw6cjobh8Q1vCDp9/plvRa3 Z0kVfEG38+92W52O1hQ8M8reAMiRIPryn9uaJNls= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Sergey Senozhatsky , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.19 047/101] media: dvb_vb2: fix possible out of bound access Date: Mon, 3 Oct 2022 09:10:43 +0200 Message-Id: <20221003070725.627188082@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua commit 37238699073e7e93f05517e529661151173cd458 upstream. vb2_core_qbuf and vb2_core_querybuf don't check the range of b->index controlled by the user. Fix this by adding range checking code before using them. Fixes: 57868acc369a ("media: videobuf2: Add new uAPI for DVB streaming I/O") Signed-off-by: Hangyu Hua Reviewed-by: Sergey Senozhatsky Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/media/dvb-core/dvb_vb2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -354,6 +354,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx * =20 int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { + struct vb2_queue *q =3D &ctx->vb_q; + + if (b->index >=3D q->num_buffers) { + dprintk(1, "[%s] buffer index out of range\n", ctx->name); + return -EINVAL; + } vb2_core_querybuf(&ctx->vb_q, b->index, b); dprintk(3, "[%s] index=3D%d\n", ctx->name, b->index); return 0; @@ -378,8 +384,13 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *c =20 int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { + struct vb2_queue *q =3D &ctx->vb_q; int ret; =20 + if (b->index >=3D q->num_buffers) { + dprintk(1, "[%s] buffer index out of range\n", ctx->name); + return -EINVAL; + } ret =3D vb2_core_qbuf(&ctx->vb_q, b->index, b, NULL); if (ret) { dprintk(1, "[%s] index=3D%d errno=3D%d\n", ctx->name, From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C14CC433FE for ; Mon, 3 Oct 2022 07:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiJCHZq (ORCPT ); Mon, 3 Oct 2022 03:25:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231209AbiJCHYH (ORCPT ); Mon, 3 Oct 2022 03:24:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB85D4BA5D; Mon, 3 Oct 2022 00:18:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B3862B80E73; Mon, 3 Oct 2022 07:15:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B4CC433D6; Mon, 3 Oct 2022 07:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781338; bh=MNbVlkr0/6H77qDcyEnTpnuu7Iv9CKSGlNqzEqKG/6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdiK1WAhD4swfr4OqbjN5myrTPZFlQvwyhJcYh9Ir4gC9Kr+IHZ2eoP+c/IXmQlTp 57U15P6jUCeRLUEiLT/H8GcVCGH7VHcjC68/q2dIWZ2981xafd7bEPVhF6BP1JmroH NYjhr58+KatCbQdhYVQetVVerGZP7ykC7b6cENpg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Dufresne , Brian Norris , Ezequiel Garcia , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.19 048/101] media: rkvdec: Disable H.264 error detection Date: Mon, 3 Oct 2022 09:10:44 +0200 Message-Id: <20221003070725.656420899@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nicolas Dufresne commit 3a99c4474112f49a5459933d8758614002ca0ddc upstream. Quite often, the HW get stuck in error condition if a stream error was detected. As documented, the HW should stop immediately and self reset. There is likely a problem or a miss-understanding of the self reset mechanism, as unless we make a long pause, the next command will then report an error even if there is no error in it. Disabling error detection fixes the issue, and let the decoder continue after an error. This patch is safe for backport into older kernels. Fixes: cd33c830448b ("media: rkvdec: Add the rkvdec driver") Signed-off-by: Nicolas Dufresne Reviewed-by: Brian Norris Tested-by: Brian Norris Reviewed-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/staging/media/rkvdec/rkvdec-h264.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -1175,8 +1175,8 @@ static int rkvdec_h264_run(struct rkvdec =20 schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000)); =20 - writel(0xffffffff, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); - writel(0xffffffff, rkvdec->regs + RKVDEC_REG_H264_ERR_E); + writel(0, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); + writel(0, rkvdec->regs + RKVDEC_REG_H264_ERR_E); writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B903C433F5 for ; Mon, 3 Oct 2022 07:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbiJCHTW (ORCPT ); Mon, 3 Oct 2022 03:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbiJCHRm (ORCPT ); Mon, 3 Oct 2022 03:17:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F6D41509; Mon, 3 Oct 2022 00:14:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4521AB80E6A; Mon, 3 Oct 2022 07:14:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94EF1C433D7; Mon, 3 Oct 2022 07:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781262; bh=5QJ/+JSs+/bk79947/sX6z4eJz/85AcEUZ1unOH+44M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kn/dK2hB2DY5VbPYo/CXDbkCm+Z9IXc242eZQI4G484gABly02+AQSH8Q1EmTskpM Bdh2DEno20+IUcMo9oltuNI6eP9TvkUzuxfBAgDVNG0EKltPAcRDYQZ2/vUFX/Wp2a s9io7ULQgeefWKDk83Uy3GuFtVMm7CCWj2n/kN4M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "=?UTF-8?q?N=C3=ADcolas=20F . =20R . =20A . =20Prado?=" , AngeloGioacchino Del Regno , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.19 049/101] media: mediatek: vcodec: Drop platform_get_resource(IORESOURCE_IRQ) Date: Mon, 3 Oct 2022 09:10:45 +0200 Message-Id: <20221003070725.679375705@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: N=C3=ADcolas F. R. A. Prado commit a2d2e593d39bc2f29a1cd5e3779af457fd26490c upstream. Commit a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core") removed support for calling platform_get_resource(..., IORESOURCE_IRQ, ...) on DT-based drivers, but the probe() function of mtk-vcodec's encoder was still making use of it. This caused the encoder driver to fail probe. Since the platform_get_resource() call was only being used to check for the presence of the interrupt (its returned resource wasn't even used) and platform_get_irq() was already being used to get the IRQ, simply drop the use of platform_get_resource(IORESOURCE_IRQ) and handle the failure of platform_get_irq(), to get the driver probing again. [hverkuil: drop unused struct resource *res] Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from D= T core") Signed-off-by: N=C3=ADcolas F. R. A. Prado Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c | 9 +++----= -- 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c @@ -228,7 +228,6 @@ static int mtk_vcodec_probe(struct platf { struct mtk_vcodec_dev *dev; struct video_device *vfd_enc; - struct resource *res; phandle rproc_phandle; enum mtk_vcodec_fw_type fw_type; int ret; @@ -272,14 +271,12 @@ static int mtk_vcodec_probe(struct platf goto err_res; } =20 - res =3D platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (res =3D=3D NULL) { - dev_err(&pdev->dev, "failed to get irq resource"); - ret =3D -ENOENT; + dev->enc_irq =3D platform_get_irq(pdev, 0); + if (dev->enc_irq < 0) { + ret =3D dev->enc_irq; goto err_res; } =20 - dev->enc_irq =3D platform_get_irq(pdev, 0); irq_set_status_flags(dev->enc_irq, IRQ_NOAUTOEN); ret =3D devm_request_irq(&pdev->dev, dev->enc_irq, mtk_vcodec_enc_irq_handler, From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A32EC433FE for ; Mon, 3 Oct 2022 07:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbiJCHVZ (ORCPT ); Mon, 3 Oct 2022 03:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiJCHUP (ORCPT ); Mon, 3 Oct 2022 03:20:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D30474F3; Mon, 3 Oct 2022 00:15:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5DCB360FA7; Mon, 3 Oct 2022 07:14:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F137C433C1; Mon, 3 Oct 2022 07:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781291; bh=eMVD5vPmyzguqMoRJC/4QF+/CMCuXrg6Wt+trtOEB+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=akf6TT1v6/a5PaB4fJF98cfEpzVxVtdgQNpWlAtx88AKwQL/RBknePy25uk8jKyWc 7P8tFxeaR2BIIeb9tK7jrUYNV3U8Fvee3X2zkIEP8SVeH6CaIA/24CNa6P8A8cWD2M QLxUVO8MyJ2z1Ni6qyyZDR3+2ksjqqk9rVaAEixw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , syzbot+ff18193ff05f3f87f226@syzkaller.appspotmail.com, Laurent Pinchart , Mauro Carvalho Chehab Subject: [PATCH 5.19 050/101] media: v4l2-compat-ioctl32.c: zero buffer passed to v4l2_compat_get_array_args() Date: Mon, 3 Oct 2022 09:10:46 +0200 Message-Id: <20221003070725.704303593@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hans Verkuil commit 4e768c8e34e639cff66a0f175bc4aebf472e4305 upstream. The v4l2_compat_get_array_args() function can leave uninitialized memory in= the buffer it is passed. So zero it before copying array elements from userspace into the buffer. Signed-off-by: Hans Verkuil Reported-by: syzbot+ff18193ff05f3f87f226@syzkaller.appspotmail.com Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -1040,6 +1040,8 @@ int v4l2_compat_get_array_args(struct fi { int err =3D 0; =20 + memset(mbuf, 0, array_size); + switch (cmd) { case VIDIOC_G_FMT32: case VIDIOC_S_FMT32: From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69750C4332F for ; Mon, 3 Oct 2022 07:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbiJCHY2 (ORCPT ); Mon, 3 Oct 2022 03:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbiJCHXA (ORCPT ); Mon, 3 Oct 2022 03:23:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35B454B0D9; Mon, 3 Oct 2022 00:17:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFBEB60F9E; Mon, 3 Oct 2022 07:15:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6D02C433D6; Mon, 3 Oct 2022 07:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781319; bh=fTSbSxDQNbX3+B3jV7c8bVErpVLYOPAonMxTtMNcGQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K8AqVwIcbWxTaDjsmhIjURSeQSuA2iuUQfk+2Wp/oAyy07fhJgFMrlvbVMYMjkhWs eDKKZfGTiHzylaRVTcsT5HBCRsB+sbo427VSpTJc3MYgoDgoHRroYHT+f/y6Q9MFjq ubdFAwfSXPKtG3rJdszdQcyQNCpea/VXHWSQuVWI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YuTong Chang , Krzysztof Kozlowski , Tony Lindgren , Sasha Levin Subject: [PATCH 5.19 051/101] ARM: dts: am33xx: Fix MMCHS0 dma properties Date: Mon, 3 Oct 2022 09:10:47 +0200 Message-Id: <20221003070725.729378974@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: YuTong Chang [ Upstream commit 2eb502f496f7764027b7958d4e74356fed918059 ] According to technical manual(table 11-24), the DMA of MMCHS0 should be direct mapped. Fixes: b5e509066074 ("ARM: DTS: am33xx: Use the new DT bindings for the eDM= A3") Signed-off-by: YuTong Chang Message-Id: <20220620124146.5330-1-mtwget@gmail.com> Acked-by: Krzysztof Kozlowski Signed-off-by: Tony Lindgren Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/arm/boot/dts/am33xx-l4.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4= .dtsi index 7da42a5b959c..7e50fe633d8a 100644 --- a/arch/arm/boot/dts/am33xx-l4.dtsi +++ b/arch/arm/boot/dts/am33xx-l4.dtsi @@ -1502,8 +1502,7 @@ mmc1: mmc@0 { compatible =3D "ti,am335-sdhci"; ti,needs-special-reset; - dmas =3D <&edma_xbar 24 0 0 - &edma_xbar 25 0 0>; + dmas =3D <&edma 24 0>, <&edma 25 0>; dma-names =3D "tx", "rx"; interrupts =3D <64>; reg =3D <0x0 0x1000>; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E6BAC43219 for ; Mon, 3 Oct 2022 07:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230268AbiJCHYh (ORCPT ); Mon, 3 Oct 2022 03:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbiJCHXB (ORCPT ); Mon, 3 Oct 2022 03:23:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C12B44AD46; Mon, 3 Oct 2022 00:16:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7539760F97; Mon, 3 Oct 2022 07:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B8C6C433D6; Mon, 3 Oct 2022 07:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781321; bh=q4QHpmaaAtyn9aGU+5Hj6gU92GcrlTjqLaYaAGTdoRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aiGRdWREUGDqgAFTR47DcKuYwyh5xl6pASgVqHt/ExfaF+IkTzdyLTJshm5x+BuKk q2ak8EOpvWV90W2uVCOxFGfTc2Ivg2alPsCSFsSlB1yHH8K+/Yz/VWFG8VvhsNzqOz aN8RygwfZfhtpy67iVjIQcD9z4itx6eoRIvzfffc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Zhu , Philipp Zabel , Marek Vasut , Richard Leitner , Alexander Stein , Sasha Levin Subject: [PATCH 5.19 052/101] reset: imx7: Fix the iMX8MP PCIe PHY PERST support Date: Mon, 3 Oct 2022 09:10:48 +0200 Message-Id: <20221003070725.756039201@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Richard Zhu [ Upstream commit 051d9eb403887bb11852b7a4f744728a6a4b1b58 ] On i.MX7/iMX8MM/iMX8MQ, the initialized default value of PERST bit(BIT3) of SRC_PCIEPHY_RCR is 1b'1. But i.MX8MP has one inversed default value 1b'0 of PERST bit. And the PERST bit should be kept 1b'1 after power and clocks are stable. So fix the i.MX8MP PCIe PHY PERST support here. Fixes: e08672c03981 ("reset: imx7: Add support for i.MX8MP SoC") Signed-off-by: Richard Zhu Reviewed-by: Philipp Zabel Tested-by: Marek Vasut Tested-by: Richard Leitner Tested-by: Alexander Stein Signed-off-by: Philipp Zabel Link: https://lore.kernel.org/r/1661845564-11373-5-git-send-email-hongxing.= zhu@nxp.com Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/reset/reset-imx7.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c index 185a333df66c..d2408725eb2c 100644 --- a/drivers/reset/reset-imx7.c +++ b/drivers/reset/reset-imx7.c @@ -329,6 +329,7 @@ static int imx8mp_reset_set(struct reset_controller_dev= *rcdev, break; =20 case IMX8MP_RESET_PCIE_CTRL_APPS_EN: + case IMX8MP_RESET_PCIEPHY_PERST: value =3D assert ? 0 : bit; break; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D957C433F5 for ; Mon, 3 Oct 2022 07:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbiJCHYl (ORCPT ); Mon, 3 Oct 2022 03:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbiJCHXZ (ORCPT ); Mon, 3 Oct 2022 03:23:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF6A45F62; Mon, 3 Oct 2022 00:17:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CFE9BB80E6B; Mon, 3 Oct 2022 07:15:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EFE6C433C1; Mon, 3 Oct 2022 07:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781324; bh=UJ1ZSCsoX9pendbzzQIvsRKKNW92EBDO2PZe5B4PXY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pM/MaVl/lOSkKc35G+FOOwAVONJRMPn7cEZ0tYXcY+XBzOG55CONpMGdZSRWWZB3H cKqjeELhEbU3fZxkUJJflrx4UEZUO4ssnR9vQlLeC/gYwjg9H0hdmbaKjkJRNrmemB u/Z7AoWQDlDAUc2ZCeBfjgnsFtJOnb0dkoUvilxc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Romain Naour , Romain Naour , Roger Quadros , Tony Lindgren , Sasha Levin Subject: [PATCH 5.19 053/101] ARM: dts: am5748: keep usb4_tm disabled Date: Mon, 3 Oct 2022 09:10:49 +0200 Message-Id: <20221003070725.783019347@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Romain Naour [ Upstream commit 6a6d9ecff14a2a46c1deeffa3eb3825349639bdd ] Commit bcbb63b80284 ("ARM: dts: dra7: Separate AM57 dtsi files") disabled usb4_tm for am5748 devices since USB4 IP is not present in this SoC. The commit log explained the difference between AM5 and DRA7 families: AM5 and DRA7 SoC families have different set of modules in them so the SoC sepecific dtsi files need to be separated. e.g. Some of the major differences between AM576 and DRA76 DRA76x AM576x USB3 x USB4 x ATL x VCP x MLB x ISS x PRU-ICSS1 x PRU-ICSS2 x Then commit 176f26bcd41a ("ARM: dts: Add support for dra762 abz package") removed usb4_tm part from am5748.dtsi and introcuded new ti-sysc errors in dmesg: ti-sysc 48940000.target-module: clock get error for fck: -2 ti-sysc: probe of 48940000.target-module failed with error -2 Fixes: 176f26bcd41a ("ARM: dts: Add support for dra762 abz package") Signed-off-by: Romain Naour Signed-off-by: Romain Naour Message-Id: <20220823072742.351368-1-romain.naour@smile.fr> Reviewed-by: Roger Quadros Signed-off-by: Tony Lindgren Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/arm/boot/dts/am5748.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/am5748.dtsi b/arch/arm/boot/dts/am5748.dtsi index c260aa1a85bd..a1f029e9d1f3 100644 --- a/arch/arm/boot/dts/am5748.dtsi +++ b/arch/arm/boot/dts/am5748.dtsi @@ -25,6 +25,10 @@ status =3D "disabled"; }; =20 +&usb4_tm { + status =3D "disabled"; +}; + &atl_tm { status =3D "disabled"; }; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23E5DC433F5 for ; Mon, 3 Oct 2022 07:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbiJCHYp (ORCPT ); Mon, 3 Oct 2022 03:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbiJCHX1 (ORCPT ); Mon, 3 Oct 2022 03:23:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C7B14AD6E; Mon, 3 Oct 2022 00:17:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 89B54B80E71; Mon, 3 Oct 2022 07:15:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDF6EC433D6; Mon, 3 Oct 2022 07:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781327; bh=dpqP7njm08z32EsbBKqqFD21reKnRIhGSaYfiX3gJGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9j54Wi+t+BL8qU4D4uqm0kbkJNpjk2iK+EsdeHNAtO3rZNZ9dNosCCV4OTeHAeX5 oCpJC2A5ZgmWDyQN8ygvDKeTWIzKMFd6Kz7Ae22SabDJfdqbZKjGUkjbvhAgO9E6Rx veQ9EDZGOgZDSODM2YGLsoFVaALb5mf0Qb3fJpqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jernej Skrabec , Samuel Holland , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.19 054/101] soc: sunxi: sram: Actually claim SRAM regions Date: Mon, 3 Oct 2022 09:10:50 +0200 Message-Id: <20221003070725.806949417@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Samuel Holland [ Upstream commit fd362baad2e659ef0fb5652f023a606b248f1781 ] sunxi_sram_claim() checks the sram_desc->claimed flag before updating the register, with the intent that only one device can claim a region. However, this was ineffective because the flag was never set. Fixes: 4af34b572a85 ("drivers: soc: sunxi: Introduce SoC driver to map SRAM= s") Reviewed-by: Jernej Skrabec Signed-off-by: Samuel Holland Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner Signed-off-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220815041248.53268-4-samuel@sholland.org Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/soc/sunxi/sunxi_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index a8f3876963a0..f3d3f9259df9 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -254,6 +254,7 @@ int sunxi_sram_claim(struct device *dev) writel(val | ((device << sram_data->offset) & mask), base + sram_data->reg); =20 + sram_desc->claimed =3D true; spin_unlock(&sram_lock); =20 return 0; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC2ACC433F5 for ; Mon, 3 Oct 2022 07:25:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbiJCHY6 (ORCPT ); Mon, 3 Oct 2022 03:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbiJCHXc (ORCPT ); Mon, 3 Oct 2022 03:23:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E5FE4B4B9; Mon, 3 Oct 2022 00:17:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B239360F9C; Mon, 3 Oct 2022 07:15:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF31EC433C1; Mon, 3 Oct 2022 07:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781330; bh=0JjE4JfedVKsYbHauMW5vCGAELVd6/OmUJmQnFxRKQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8vdrW5TwaiEy8FYggV6wngQ4c+1KrOSc4B/Nj+gf+BVeJN7lrskiI1Osu1InPYlF ormdfNjakWeS2aFsHE8mVNoyYra0On5RaZN2/DI5udxiA9u2NYuUmL6fa3xAW34HyZ It2b+FSyrgNbkiSMpYpdXYL08xuOHezuWUTQ0lQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jernej Skrabec , Samuel Holland , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.19 055/101] soc: sunxi: sram: Prevent the driver from being unbound Date: Mon, 3 Oct 2022 09:10:51 +0200 Message-Id: <20221003070725.831395859@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Samuel Holland [ Upstream commit 90e10a1fcd9b24b4ba8c0d35136127473dcd829e ] This driver exports a regmap tied to the platform device (as opposed to a syscon, which exports a regmap tied to the OF node). Because of this, the driver can never be unbound, as that would destroy the regmap. Use builtin_platform_driver_probe() to enforce this limitation. Fixes: 5828729bebbb ("soc: sunxi: export a regmap for EMAC clock reg on A64= ") Reviewed-by: Jernej Skrabec Signed-off-by: Samuel Holland Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner Signed-off-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220815041248.53268-5-samuel@sholland.org Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/soc/sunxi/sunxi_sram.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index f3d3f9259df9..a858a37fcdd4 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -330,7 +330,7 @@ static struct regmap_config sunxi_sram_emac_clock_regma= p =3D { .writeable_reg =3D sunxi_sram_regmap_accessible_reg, }; =20 -static int sunxi_sram_probe(struct platform_device *pdev) +static int __init sunxi_sram_probe(struct platform_device *pdev) { struct dentry *d; struct regmap *emac_clock; @@ -410,9 +410,8 @@ static struct platform_driver sunxi_sram_driver =3D { .name =3D "sunxi-sram", .of_match_table =3D sunxi_sram_dt_match, }, - .probe =3D sunxi_sram_probe, }; -module_platform_driver(sunxi_sram_driver); +builtin_platform_driver_probe(sunxi_sram_driver, sunxi_sram_probe); =20 MODULE_AUTHOR("Maxime Ripard "); MODULE_DESCRIPTION("Allwinner sunXi SRAM Controller Driver"); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C17CC433FE for ; Mon, 3 Oct 2022 07:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbiJCHZj (ORCPT ); Mon, 3 Oct 2022 03:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbiJCHYH (ORCPT ); Mon, 3 Oct 2022 03:24:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B07C46630; Mon, 3 Oct 2022 00:18:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 170F5B80E68; Mon, 3 Oct 2022 07:15:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B8B0C433C1; Mon, 3 Oct 2022 07:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781332; bh=tb0bQpnUQ+TPZ2/ugxZ8lhm5RCQjTZugfa0mWmPiO8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRrPDU5nYxvY7B6DXKLxf5CKxp3W0lgLYQ4v6Xp6lhiXd0HwpymYzPbVRAdnd9Hqr vaijMxUOpEItEPFd19weaiVBzvxUFrEAeCHT/tyA1U/PIrHr485ymO8ddCns0fXSGm IdLuQ5S1n7H8ykv2PxSetXfN1FSnxAqTg+egVxPM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jernej Skrabec , Samuel Holland , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.19 056/101] soc: sunxi: sram: Fix probe function ordering issues Date: Mon, 3 Oct 2022 09:10:52 +0200 Message-Id: <20221003070725.856379254@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Samuel Holland [ Upstream commit 49fad91a7b8941979c3e9a35f9894ac45bc5d3d6 ] Errors from debugfs are intended to be non-fatal, and should not prevent the driver from probing. Since debugfs file creation is treated as infallible, move it below the parts of the probe function that can fail. This prevents an error elsewhere in the probe function from causing the file to leak. Do the same for the call to of_platform_populate(). Finally, checkpatch suggests an octal literal for the file permissions. Fixes: 4af34b572a85 ("drivers: soc: sunxi: Introduce SoC driver to map SRAM= s") Fixes: 5828729bebbb ("soc: sunxi: export a regmap for EMAC clock reg on A64= ") Reviewed-by: Jernej Skrabec Signed-off-by: Samuel Holland Tested-by: Heiko Stuebner Signed-off-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220815041248.53268-6-samuel@sholland.org Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/soc/sunxi/sunxi_sram.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index a858a37fcdd4..52d07bed7664 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -332,9 +332,9 @@ static struct regmap_config sunxi_sram_emac_clock_regma= p =3D { =20 static int __init sunxi_sram_probe(struct platform_device *pdev) { - struct dentry *d; struct regmap *emac_clock; const struct sunxi_sramc_variant *variant; + struct device *dev =3D &pdev->dev; =20 sram_dev =3D &pdev->dev; =20 @@ -346,13 +346,6 @@ static int __init sunxi_sram_probe(struct platform_dev= ice *pdev) if (IS_ERR(base)) return PTR_ERR(base); =20 - of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); - - d =3D debugfs_create_file("sram", S_IRUGO, NULL, NULL, - &sunxi_sram_fops); - if (!d) - return -ENOMEM; - if (variant->num_emac_clocks > 0) { emac_clock =3D devm_regmap_init_mmio(&pdev->dev, base, &sunxi_sram_emac_clock_regmap); @@ -361,6 +354,10 @@ static int __init sunxi_sram_probe(struct platform_dev= ice *pdev) return PTR_ERR(emac_clock); } =20 + of_platform_populate(dev->of_node, NULL, NULL, dev); + + debugfs_create_file("sram", 0444, NULL, NULL, &sunxi_sram_fops); + return 0; } =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5AD7C433FE for ; Mon, 3 Oct 2022 07:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiJCHZ2 (ORCPT ); Mon, 3 Oct 2022 03:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbiJCHXu (ORCPT ); Mon, 3 Oct 2022 03:23:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C3940BFA; Mon, 3 Oct 2022 00:17:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 47A4C60F9B; Mon, 3 Oct 2022 07:15:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 577E3C433D6; Mon, 3 Oct 2022 07:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781335; bh=rbGALLdGpMoXn3faPKL8k519MdGxpF/HHBObKz4rX/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPUtjnjqYbXg8tTpd1dDvghFGY9Z8l7QJIv5Vt6gfdpjuAWaJROewsngz2R+NtXzw 514J3QnM/XibvUpcQjpq9WcJoeJhgpl3NzB01mTRz3tL1vBIOY35ir1rA8KwBIKkYq RkBKuee6X0UTsBDupqnvIfRMTdOAGtoau7nuq3GY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jernej Skrabec , Samuel Holland , Sasha Levin Subject: [PATCH 5.19 057/101] soc: sunxi: sram: Fix debugfs info for A64 SRAM C Date: Mon, 3 Oct 2022 09:10:53 +0200 Message-Id: <20221003070725.884772653@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Samuel Holland [ Upstream commit e3c95edb1bd8b9c2cb0caa6ae382fc8080f6a0ed ] The labels were backward with respect to the register values. The SRAM is mapped to the CPU when the register value is 1. Fixes: 5e4fb6429761 ("drivers: soc: sunxi: add support for A64 and its SRAM= C") Acked-by: Jernej Skrabec Signed-off-by: Samuel Holland Signed-off-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220815041248.53268-7-samuel@sholland.org Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/soc/sunxi/sunxi_sram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index 52d07bed7664..09754cd1d57d 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -78,8 +78,8 @@ static struct sunxi_sram_desc sun4i_a10_sram_d =3D { =20 static struct sunxi_sram_desc sun50i_a64_sram_c =3D { .data =3D SUNXI_SRAM_DATA("C", 0x4, 24, 1, - SUNXI_SRAM_MAP(0, 1, "cpu"), - SUNXI_SRAM_MAP(1, 0, "de2")), + SUNXI_SRAM_MAP(1, 0, "cpu"), + SUNXI_SRAM_MAP(0, 1, "de2")), }; =20 static const struct of_device_id sunxi_sram_dt_ids[] =3D { --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2734C433FE for ; Mon, 3 Oct 2022 07:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbiJCHTS (ORCPT ); Mon, 3 Oct 2022 03:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbiJCHRd (ORCPT ); Mon, 3 Oct 2022 03:17:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7936040E1E; Mon, 3 Oct 2022 00:14:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 32A6460F9C; Mon, 3 Oct 2022 07:14:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40253C433C1; Mon, 3 Oct 2022 07:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781264; bh=2ZhtqaNWGMSJ2212K2VhLOg1LmnfgqUk2DrRZUy2uU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yDSOaC/ETNBcIvdAMGaIXPuK7sgPMv0AUHQJK7Zp3T0Z0dWXWR6Q0Oq2m/Aac/Nwy O3c8QqrhRkJbUC0EVPoQxSikv07i+/0gfPP/L4I+Ypxt3ITsBPza/cfNAi8N+bR1pC DMjsYqAAzBlOyb8Vnlq0juivZ69PiI6jiLicu7Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shengjiu Wang , Mark Brown , Sasha Levin Subject: [PATCH 5.19 058/101] ASoC: imx-card: Fix refcount issue with of_node_put Date: Mon, 3 Oct 2022 09:10:54 +0200 Message-Id: <20221003070725.910271594@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Shengjiu Wang [ Upstream commit d56ba9a04d7548d4149c46ec86a0e3cc41a70f4a ] imx_card_parse_of will search all the node with loop, if there is defer probe happen in the middle of loop, the previous released codec node will be released twice, then cause refcount issue. Here assign NULL to pointer of released nodes to fix the issue. Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver") Signed-off-by: Shengjiu Wang Link: https://lore.kernel.org/r/1663059601-29259-1-git-send-email-shengjiu.= wang@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- sound/soc/fsl/imx-card.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c index 4a8609b0d700..5153af3281d2 100644 --- a/sound/soc/fsl/imx-card.c +++ b/sound/soc/fsl/imx-card.c @@ -698,6 +698,10 @@ static int imx_card_parse_of(struct imx_card_data *dat= a) of_node_put(cpu); of_node_put(codec); of_node_put(platform); + + cpu =3D NULL; + codec =3D NULL; + platform =3D NULL; } =20 return 0; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1314C433F5 for ; Mon, 3 Oct 2022 07:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbiJCHUM (ORCPT ); Mon, 3 Oct 2022 03:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiJCHSu (ORCPT ); Mon, 3 Oct 2022 03:18:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A4A42AE7; Mon, 3 Oct 2022 00:14:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8A881B80E6D; Mon, 3 Oct 2022 07:14:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 041B3C433B5; Mon, 3 Oct 2022 07:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781267; bh=jJalopGYV6q6cOGGw0IxdJG9dao0UUZll3cdpcsRMnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8gFaW9uaar26Ap0mTTGRqwXtNno18Ekxty5jM77DChIfpa4OGjkE0xCBU+/bQR1/ gpNl1n/1W6luZrbxOknkNQhZiLZMRXF1XWSeRjo2GKtcxs3H2wRG6FiKAmu4pl1PEn g+b5chxSGCmSsNIFp7iyQy7NNnhJvVXgdsMEK+7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Conor Dooley , Claudiu Beznea , Sasha Levin Subject: [PATCH 5.19 059/101] clk: microchip: mpfs: fix clk_cfg array bounds violation Date: Mon, 3 Oct 2022 09:10:55 +0200 Message-Id: <20221003070725.935137420@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Conor Dooley [ Upstream commit 5da39ac5d648cdbfdfa8bea0e0cde279ded5c7c2 ] There is an array bounds violation present during clock registration, triggered by current code by only specific toolchains. This seems to fail gracefully in v6.0-rc1, using a toolchain build from the riscv- gnu-toolchain repo and with clang-15, and life carries on. While converting the driver to use standard clock structs/ops, kernel panics were seen during boot when built with clang-15: [ 0.581754] Unable to handle kernel NULL pointer dereference at virtual = address 00000000000000b1 [ 0.591520] Oops [#1] [ 0.594045] Modules linked in: [ 0.597435] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc1-00011-g8= e1459cf4eca #1 [ 0.606188] Hardware name: Microchip PolarFire-SoC Icicle Kit (DT) [ 0.613012] epc : __clk_register+0x4a6/0x85c [ 0.617759] ra : __clk_register+0x49e/0x85c [ 0.622489] epc : ffffffff803faf7c ra : ffffffff803faf74 sp : ffffffc804= 00b720 [ 0.630466] gp : ffffffff810e93f8 tp : ffffffe77fe60000 t0 : ffffffe77f= fb3800 [ 0.638443] t1 : 000000000000000a t2 : ffffffffffffffff s0 : ffffffc804= 00b7c0 [ 0.646420] s1 : 0000000000000001 a0 : 0000000000000001 a1 : 0000000000= 000000 [ 0.654396] a2 : 0000000000000001 a3 : 0000000000000000 a4 : 0000000000= 000000 [ 0.662373] a5 : ffffffff803a5810 a6 : 0000000200000022 a7 : 0000000000= 000006 [ 0.670350] s2 : ffffffff81099d48 s3 : ffffffff80d6e28e s4 : 0000000000= 000028 [ 0.678327] s5 : ffffffff810ed3c8 s6 : ffffffff810ed3d0 s7 : ffffffe77f= fbc100 [ 0.686304] s8 : ffffffe77ffb1540 s9 : ffffffe77ffb1540 s10: 0000000000= 000008 [ 0.694281] s11: 0000000000000000 t3 : 00000000000000c6 t4 : 0000000000= 000007 [ 0.702258] t5 : ffffffff810c78c0 t6 : ffffffe77ff88cd0 [ 0.708125] status: 0000000200000120 badaddr: 00000000000000b1 cause: 00= 0000000000000d [ 0.716869] [] devm_clk_hw_register+0x62/0xaa [ 0.723420] [] mpfs_clk_probe+0x1e0/0x244 In v6.0-rc1 and later, this issue is visible without the follow on patches doing the conversion using toolchains provided by our Yocto meta layer too. It fails on "clk_periph_timer" - which uses a different parent, that it tries to find using the macro: \#define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT].cfg.hw) If parent is RTCREF, so the macro becomes: &mpfs_cfg_clks[33].cfg.hw which is well beyond the end of the array. Amazingly, builds with GCC 11.1 see no problem here, booting correctly and hooking the parent up etc. Builds with clang-15 do not, with the above panic. Change the macro to use specific offsets depending on the parent rather than the dt-binding's clock IDs. Fixes: 1c6a7ea32b8c ("clk: microchip: mpfs: add RTCREF clock control") CC: Nathan Chancellor Signed-off-by: Conor Dooley Reviewed-by: Claudiu Beznea Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220909123123.2699583-2-conor.dooley@micro= chip.com Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/microchip/clk-mpfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/microchip/clk-mpfs.c b/drivers/clk/microchip/clk-m= pfs.c index 070c3b896559..f0f9c9a1cc48 100644 --- a/drivers/clk/microchip/clk-mpfs.c +++ b/drivers/clk/microchip/clk-mpfs.c @@ -239,6 +239,11 @@ static const struct clk_ops mpfs_clk_cfg_ops =3D { .hw.init =3D CLK_HW_INIT(_name, _parent, &mpfs_clk_cfg_ops, 0), \ } =20 +#define CLK_CPU_OFFSET 0u +#define CLK_AXI_OFFSET 1u +#define CLK_AHB_OFFSET 2u +#define CLK_RTCREF_OFFSET 3u + static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] =3D { CLK_CFG(CLK_CPU, "clk_cpu", "clk_msspll", 0, 2, mpfs_div_cpu_axi_table, 0, REG_CLOCK_CONFIG_CR), @@ -362,7 +367,7 @@ static const struct clk_ops mpfs_periph_clk_ops =3D { _flags), \ } =20 -#define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT].hw) +#define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT##_OFFSET].hw) =20 /* * Critical clocks: --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2923C433FE for ; Mon, 3 Oct 2022 07:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbiJCHTi (ORCPT ); Mon, 3 Oct 2022 03:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiJCHRs (ORCPT ); Mon, 3 Oct 2022 03:17:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C20025C49; Mon, 3 Oct 2022 00:14:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3ADF5B80E6F; Mon, 3 Oct 2022 07:14:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E45FC433C1; Mon, 3 Oct 2022 07:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781270; bh=29oDXYaJ1/GH0QpTSB639aYmU/+EHMMw4wqlP1bTBgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EE1d97Gt21JT1j/ufEczIlQSXviqhqWYyYSrMYwe5+wpwXYfGVl/M93nAmSGRQdRH JhDdk/aw60xjJffQnd3vfHL0UbWOXPX4X7inPcYrO8djqoOYzsmp35aKC78uEcHpDe SIJ9yapMV2sn2mpxAucBk+5vT/H3DYVlZR8haZr0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Conor Dooley , Claudiu Beznea , Sasha Levin Subject: [PATCH 5.19 060/101] clk: microchip: mpfs: make the rtcs ahb clock critical Date: Mon, 3 Oct 2022 09:10:56 +0200 Message-Id: <20221003070725.961091761@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Conor Dooley [ Upstream commit 05d27090b6dc88bce71a608d1271536e582b73d1 ] The onboard RTC's AHB bus clock must be kept running as the RTC will stop & lose track of time if the AHB interface clock is disabled. Fixes: 635e5e73370e ("clk: microchip: Add driver for Microchip PolarFire So= C") Signed-off-by: Conor Dooley Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220909123123.2699583-3-conor.dooley@micro= chip.com Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/microchip/clk-mpfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/microchip/clk-mpfs.c b/drivers/clk/microchip/clk-m= pfs.c index f0f9c9a1cc48..b6b89413e090 100644 --- a/drivers/clk/microchip/clk-mpfs.c +++ b/drivers/clk/microchip/clk-mpfs.c @@ -375,6 +375,8 @@ static const struct clk_ops mpfs_periph_clk_ops =3D { * trap handler * - CLK_MMUART0: reserved by the hss * - CLK_DDRC: provides clock to the ddr subsystem + * - CLK_RTC: the onboard RTC's AHB bus clock must be kept running as the = rtc will stop + * if the AHB interface clock is disabled * - CLK_FICx: these provide the processor side clocks to the "FIC" (Fabri= c InterConnect) * clock domain crossers which provide the interface to the FPGA fabric.= Disabling them * causes the FPGA fabric to go into reset. @@ -399,7 +401,7 @@ static struct mpfs_periph_hw_clock mpfs_periph_clks[] = =3D { CLK_PERIPH(CLK_CAN0, "clk_periph_can0", PARENT_CLK(AHB), 14, 0), CLK_PERIPH(CLK_CAN1, "clk_periph_can1", PARENT_CLK(AHB), 15, 0), CLK_PERIPH(CLK_USB, "clk_periph_usb", PARENT_CLK(AHB), 16, 0), - CLK_PERIPH(CLK_RTC, "clk_periph_rtc", PARENT_CLK(AHB), 18, 0), + CLK_PERIPH(CLK_RTC, "clk_periph_rtc", PARENT_CLK(AHB), 18, CLK_IS_CRITICA= L), CLK_PERIPH(CLK_QSPI, "clk_periph_qspi", PARENT_CLK(AHB), 19, 0), CLK_PERIPH(CLK_GPIO0, "clk_periph_gpio0", PARENT_CLK(AHB), 20, 0), CLK_PERIPH(CLK_GPIO1, "clk_periph_gpio1", PARENT_CLK(AHB), 21, 0), --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C13E4C433FE for ; Mon, 3 Oct 2022 07:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiJCHUS (ORCPT ); Mon, 3 Oct 2022 03:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbiJCHSv (ORCPT ); Mon, 3 Oct 2022 03:18:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F5A31F; Mon, 3 Oct 2022 00:14:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5AE6760F97; Mon, 3 Oct 2022 07:14:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4796AC433C1; Mon, 3 Oct 2022 07:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781272; bh=kVAmdmfS0VSTKTCwCJDxL7axD5eVQjvN4q8SZSjyOs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzJFzwD4LHhkxyss3Irw3gu4DQI3H9Mn7LnS6Zm6cPrdiJ+rZnbM16XhZ2Mc8uN8r Cs0PR1Gs+3Kzj1jTHWc43fYgxb6eq+ESgQ/IufHhtrtNgzVlmv2hxR+lpJEIED2qe2 S7OlpPK/Hf/CJKA9MAp5yRpNr3AnGdZVSrNBCLUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.19 061/101] arm64: dts: qcom: sm8350: fix UFS PHY serdes size Date: Mon, 3 Oct 2022 09:10:57 +0200 Message-Id: <20221003070725.985994874@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold [ Upstream commit 40e9541959100e017533e18e44d07eed44f91dc5 ] The size of the UFS PHY serdes register region is 0x1c4 and the corresponding 'reg' property should specifically not include the adjacent regions that are defined in the child node (e.g. tx and rx). Fixes: 59c7cf814783 ("arm64: dts: qcom: sm8350: Add UFS nodes") Signed-off-by: Johan Hovold Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220916093603.24263-1-johan+linaro@kernel.= org Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/arm64/boot/dts/qcom/sm8350.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sm8350.dtsi b/arch/arm64/boot/dts/qco= m/sm8350.dtsi index 3293f76478df..0e5a4fbb5eb1 100644 --- a/arch/arm64/boot/dts/qcom/sm8350.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8350.dtsi @@ -2128,7 +2128,7 @@ =20 ufs_mem_phy: phy@1d87000 { compatible =3D "qcom,sm8350-qmp-ufs-phy"; - reg =3D <0 0x01d87000 0 0xe10>; + reg =3D <0 0x01d87000 0 0x1c4>; #address-cells =3D <2>; #size-cells =3D <2>; ranges; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EB5C433FE for ; Mon, 3 Oct 2022 07:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbiJCHTq (ORCPT ); Mon, 3 Oct 2022 03:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbiJCHSN (ORCPT ); Mon, 3 Oct 2022 03:18:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EEFB48B; Mon, 3 Oct 2022 00:14:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ECE7A60F9D; Mon, 3 Oct 2022 07:14:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DBBBC433B5; Mon, 3 Oct 2022 07:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781275; bh=4qaUPYHX8vhE0GCyjuyz6U4yyj5WrBqS1igDkGjLMHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mincuyjrap6ALNDi8/qaUNuZJ/rTvMGza6YXSMpCeTYggP4p06xntIlGQAUelSSUA Duhuo6sq79xZmKvFc8vQSthHCJ1AKQqU7XcelAdg23Z9dAIiemtowN5pTIf7mj9Rjc i4FUnEkfwd2RfYBAGt2lcqoVBX/XHVeLETbzopfU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Martin=20Povi=C5=A1er?= , Mark Brown , Sasha Levin Subject: [PATCH 5.19 062/101] ASoC: tas2770: Reinit regcache on reset Date: Mon, 3 Oct 2022 09:10:58 +0200 Message-Id: <20221003070726.010352326@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Povi=C5=A1er [ Upstream commit 0a0342ede303fc420f3a388e1ae82da3ae8ff6bd ] On probe of the ASoC component, the device is reset but the regcache is retained. This means the regcache gets out of sync if the codec is rebound to a sound card for a second time. Fix it by reinitializing the regcache to defaults after the device is reset. Fixes: b0bcbe615756 ("ASoC: tas2770: Fix calling reset in probe") Signed-off-by: Martin Povi=C5=A1er Link: https://lore.kernel.org/r/20220919173453.84292-1-povik+lin@cutebit.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- sound/soc/codecs/tas2770.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index 9ea2aca65e89..e02ad765351b 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -495,6 +495,8 @@ static struct snd_soc_dai_driver tas2770_dai_driver[] = =3D { }, }; =20 +static const struct regmap_config tas2770_i2c_regmap; + static int tas2770_codec_probe(struct snd_soc_component *component) { struct tas2770_priv *tas2770 =3D @@ -508,6 +510,7 @@ static int tas2770_codec_probe(struct snd_soc_component= *component) } =20 tas2770_reset(tas2770); + regmap_reinit_cache(tas2770->regmap, &tas2770_i2c_regmap); =20 return 0; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CBC8C433FE for ; Mon, 3 Oct 2022 07:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbiJCHUY (ORCPT ); Mon, 3 Oct 2022 03:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbiJCHSw (ORCPT ); Mon, 3 Oct 2022 03:18:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6FA810548; Mon, 3 Oct 2022 00:14:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63579B80E6E; Mon, 3 Oct 2022 07:14:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0FDFC433D6; Mon, 3 Oct 2022 07:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781278; bh=bk2Tc2mP+BAlCfMSQovB6aEbXeo1uiMDHMwvfhvanAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sgu/tV0Rg54zubojGsou+inayjuc2bRxBTRBjGgcqSQWrHh6i4XBYkMRwYYk1QZiU shpp9qUCe+Gszv6g4xa1iR8GsqPzjH43uBYsLC7AMiEf3uYzN8FNOtSi3svBb8w4tc W2Rxvp2Mz/SyA87v7K4uITCDd3Tun7UNBGKuMBsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philippe Schenker , Adrien Grassein , Neil Armstrong , Sasha Levin Subject: [PATCH 5.19 063/101] drm/bridge: lt8912b: add vsync hsync Date: Mon, 3 Oct 2022 09:10:59 +0200 Message-Id: <20221003070726.035240170@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Philippe Schenker [ Upstream commit da73a94fa282f78d485bd0aab36c8ac15b6f792c ] Currently the bridge driver does not take care whether or not the display needs positive/negative vertical/horizontal syncs. Pass these two flags to the bridge from the EDID that was read out from the display. Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge") Signed-off-by: Philippe Schenker Acked-by: Adrien Grassein Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20220922124306.34729-2-= dev@pschenker.ch Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bri= dge/lontium-lt8912b.c index c642d1e02b2f..e011a2763621 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -266,7 +266,7 @@ static int lt8912_video_setup(struct lt8912 *lt) u32 hactive, h_total, hpw, hfp, hbp; u32 vactive, v_total, vpw, vfp, vbp; u8 settle =3D 0x08; - int ret; + int ret, hsync_activehigh, vsync_activehigh; =20 if (!lt) return -EINVAL; @@ -276,12 +276,14 @@ static int lt8912_video_setup(struct lt8912 *lt) hpw =3D lt->mode.hsync_len; hbp =3D lt->mode.hback_porch; h_total =3D hactive + hfp + hpw + hbp; + hsync_activehigh =3D lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH; =20 vactive =3D lt->mode.vactive; vfp =3D lt->mode.vfront_porch; vpw =3D lt->mode.vsync_len; vbp =3D lt->mode.vback_porch; v_total =3D vactive + vfp + vpw + vbp; + vsync_activehigh =3D lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH; =20 if (vactive <=3D 600) settle =3D 0x04; @@ -315,6 +317,11 @@ static int lt8912_video_setup(struct lt8912 *lt) ret |=3D regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff); ret |=3D regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8); =20 + ret |=3D regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0), + vsync_activehigh ? BIT(0) : 0); + ret |=3D regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1), + hsync_activehigh ? BIT(1) : 0); + return ret; } =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9792BC433FE for ; Mon, 3 Oct 2022 07:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbiJCHUb (ORCPT ); Mon, 3 Oct 2022 03:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiJCHS4 (ORCPT ); Mon, 3 Oct 2022 03:18:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3B114022; Mon, 3 Oct 2022 00:14:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5A9AD60FA0; Mon, 3 Oct 2022 07:14:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B05CC433D7; Mon, 3 Oct 2022 07:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781280; bh=qkArQzY5mize1vJgLOxMNgXweCLQ1qnYGCSDrPDzpmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8P85I3231OpxLBW1K0i9fgUIUHihz3t0NAmkgio/JheIRO3ua+huctoMbS0f4iix dvJMvQu02ggk08EfhnomHCjZY9nPKZ1qJvtclCE8B5XNm0GIIQdUaNepetol5Sms1K wy7fCuWncysSttxyeImCZAXSy+csLvScrKKDh8FQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philippe Schenker , Adrien Grassein , Neil Armstrong , Sasha Levin Subject: [PATCH 5.19 064/101] drm/bridge: lt8912b: set hdmi or dvi mode Date: Mon, 3 Oct 2022 09:11:00 +0200 Message-Id: <20221003070726.060986604@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Philippe Schenker [ Upstream commit 6dd1de12e1243f2013e4fabf31e99e63b1a860d0 ] The Lontium LT8912 does have a setting for DVI or HDMI. This patch reads from EDID what the display needs and sets it accordingly. Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge") Signed-off-by: Philippe Schenker Acked-by: Adrien Grassein Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20220922124306.34729-3-= dev@pschenker.ch Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bri= dge/lontium-lt8912b.c index e011a2763621..bab3772c8407 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -321,6 +321,8 @@ static int lt8912_video_setup(struct lt8912 *lt) vsync_activehigh ? BIT(0) : 0); ret |=3D regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1), hsync_activehigh ? BIT(1) : 0); + ret |=3D regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0), + lt->connector.display_info.is_hdmi ? BIT(0) : 0); =20 return ret; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9A55C433F5 for ; Mon, 3 Oct 2022 07:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230070AbiJCHVC (ORCPT ); Mon, 3 Oct 2022 03:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbiJCHTf (ORCPT ); Mon, 3 Oct 2022 03:19:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F1836085; Mon, 3 Oct 2022 00:15:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1D63460F9C; Mon, 3 Oct 2022 07:14:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29991C433D6; Mon, 3 Oct 2022 07:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781283; bh=Qe5853b8q3StE752n98hzL/qO1smAiykNgi21DIQF0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PTsCdMqqmcICrp7bGZJf4ncnjqVYWYgAaMPzJpOfrU/jnUjjULQRV7bXeuXDQrAOC +AYTlNrbDDLMqyJR3zaT/m1fu+vH8CjMFl0bVoifW4RJPhNt+C94nStMR9r2F3LfpB QSEkwO/5+0yVWz8VRNxkYfc4yjBfHZRw/zCqUthE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Francesco Dolcini , Philippe Schenker , Adrien Grassein , Neil Armstrong , Sasha Levin Subject: [PATCH 5.19 065/101] drm/bridge: lt8912b: fix corrupted image output Date: Mon, 3 Oct 2022 09:11:01 +0200 Message-Id: <20221003070726.086890033@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini [ Upstream commit 051ad2788d35ca07aec8402542e5d38429f2426a ] Correct I2C address for the register list in lt8912_write_lvds_config(), these registers are on the first I2C address (0x48), the current function is just writing garbage to the wrong registers and this creates multiple issues (artifacts and output completely corrupted) on some HDMI displays. Correct I2C address comes from Lontium documentation and it is the one used on other out-of-tree LT8912B drivers [1]. [1] https://github.com/boundarydevices/linux/blob/boundary-imx_5.10.x_2.0.0= /drivers/video/lt8912.c#L296 Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge") Signed-off-by: Francesco Dolcini Signed-off-by: Philippe Schenker Acked-by: Adrien Grassein Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20220922124306.34729-4-= dev@pschenker.ch Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bri= dge/lontium-lt8912b.c index bab3772c8407..167cd7d85dbb 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -186,7 +186,7 @@ static int lt8912_write_lvds_config(struct lt8912 *lt) {0x03, 0xff}, }; =20 - return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(se= q)); + return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq)); }; =20 static inline struct lt8912 *bridge_to_lt8912(struct drm_bridge *b) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAAF9C433F5 for ; Mon, 3 Oct 2022 07:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbiJCHUs (ORCPT ); Mon, 3 Oct 2022 03:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiJCHTF (ORCPT ); Mon, 3 Oct 2022 03:19:05 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 420E136094; Mon, 3 Oct 2022 00:15:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 26DC3CE0AF2; Mon, 3 Oct 2022 07:14:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8A56C433D6; Mon, 3 Oct 2022 07:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781286; bh=BDGFTzj7X2dKvLVLsWyErQjs+PtoFcPQrpCwZNusabE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vylEvwH18PVyXPDkZaDy1nzmlAxYVZ4P/Bli2iYBbjR0TjtRmm3HJRzV7n7xGM20t e3ee4kZ4uuMo6Taa/ab+FRpvtr23bm/SQkf1QyZeSjxqB/p2bCxq1YjTAoV8ysDam5 5ZVMgWn052qOMZm/OAjiIA+sVle7YVlNWh/ycW6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Radhey Shyam Pandey , "David S. Miller" , Sasha Levin Subject: [PATCH 5.19 066/101] net: macb: Fix ZynqMP SGMII non-wakeup source resume failure Date: Mon, 3 Oct 2022 09:11:02 +0200 Message-Id: <20221003070726.112181367@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Radhey Shyam Pandey [ Upstream commit f22bd29ba19a43e758b192429613e04aa7abb70d ] When GEM is in SGMII mode and disabled as a wakeup source, the power management controller can power down the entire full power domain(FPD) if none of the FPD devices are in use. Incase of FPD off, there are below ethernet link up issues on non-wakeup suspend/resume. To fix it add phy_exit() in suspend and phy_init() in the resume path which reinitializes PS GTR SGMII lanes. $ echo +20 > /sys/class/rtc/rtc0/wakealarm $ echo mem > /sys/power/state After resume: $ ifconfig eth0 up xilinx-psgtr fd400000.phy: lane 0 (type 10, protocol 5): PLL lock timeout phy phy-fd400000.phy.0: phy poweron failed --> -110 xilinx-psgtr fd400000.phy: lane 0 (type 10, protocol 5): PLL lock timeout SIOCSIFFLAGS: Connection timed out phy phy-fd400000.phy.0: phy poweron failed --> -110 Fixes: 8b73fa3ae02b ("net: macb: Added ZynqMP-specific initialization") Signed-off-by: Radhey Shyam Pandey Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/cadence/macb_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index d89098f4ede8..e9aa41949a4b 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -5092,6 +5092,7 @@ static int __maybe_unused macb_suspend(struct device = *dev) if (!(bp->wol & MACB_WOL_ENABLED)) { rtnl_lock(); phylink_stop(bp->phylink); + phy_exit(bp->sgmii_phy); rtnl_unlock(); spin_lock_irqsave(&bp->lock, flags); macb_reset_hw(bp); @@ -5181,6 +5182,9 @@ static int __maybe_unused macb_resume(struct device *= dev) macb_set_rx_mode(netdev); macb_restore_features(bp); rtnl_lock(); + if (!device_may_wakeup(&bp->dev->dev)) + phy_init(bp->sgmii_phy); + phylink_start(bp->phylink); rtnl_unlock(); =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71965C433FE for ; Mon, 3 Oct 2022 07:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiJCHUk (ORCPT ); Mon, 3 Oct 2022 03:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbiJCHTD (ORCPT ); Mon, 3 Oct 2022 03:19:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB7A4371BA; Mon, 3 Oct 2022 00:15:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7778E60F9F; Mon, 3 Oct 2022 07:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86A84C433C1; Mon, 3 Oct 2022 07:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781288; bh=lrsdqu+BAskSM20BQvvpxStKuyljtS3aDCsayyh4pxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1f7qxj/3i7pdNANqzhbDwRzhgRiK8iRu05HLdZSjz5x1CMpkr6EeLQtRMZ336Fgi rdGotnakxvmE3XJk5IhH7kWklyqIgR2ix71dXd44tGpMmsnnPFRGK08gOE/XkQaKUJ 6T8ON7y72Yx6VH4+G/jQOpg136zpLnvY7i33Pczc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Douglas Anderson , Sasha Levin Subject: [PATCH 5.19 067/101] Revert "drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time" Date: Mon, 3 Oct 2022 09:11:03 +0200 Message-Id: <20221003070726.139073944@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Brian Norris [ Upstream commit cc62d98bd56d45de4531844ca23913a15136c05b ] This reverts commit 211f276ed3d96e964d2d1106a198c7f4a4b3f4c0. For quite some time, core DRM helpers already ensure that any relevant connectors/CRTCs/etc. are disabled, as well as their associated components (e.g., bridges) when suspending the system. Thus, analogix_dp_bridge_{enable,disable}() already get called, which in turn call drm_panel_{prepare,unprepare}(). This makes these drm_panel_*() calls redundant. Besides redundancy, there are a few problems with this handling: (1) drm_panel_{prepare,unprepare}() are *not* reference-counted APIs and are not in general designed to be handled by multiple callers -- although some panel drivers have a coarse 'prepared' flag that mitigates some damage, at least. So at a minimum this is redundant and confusing, but in some cases, this could be actively harmful. (2) The error-handling is a bit non-standard. We ignored errors in suspend(), but handled errors in resume(). And recently, people noticed that the clk handling is unbalanced in error paths, and getting *that* right is not actually trivial, given the current way errors are mostly ignored. (3) In the particular way analogix_dp_{suspend,resume}() get used (e.g., in rockchip_dp_*(), as a late/early callback), we don't necessarily have a proper PM relationship between the DP/bridge device and the panel device. So while the DP bridge gets resumed, the panel's parent device (e.g., platform_device) may still be suspended, and so any prepare() calls may fail. So remove the superfluous, possibly-harmful suspend()/resume() handling of panel state. Fixes: 211f276ed3d9 ("drm: bridge: analogix/dp: add panel prepare/unprepare= in suspend/resume time") Link: https://lore.kernel.org/all/Yv2CPBD3Picg%2FgVe@google.com/ Signed-off-by: Brian Norris Reviewed-by: Douglas Anderson Signed-off-by: Douglas Anderson Link: https://patchwork.freedesktop.org/patch/msgid/20220822180729.1.I8ac5a= be3a4c1c6fd5c061686c6e883c22f69022c@changeid Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index 01c8b80e34ec..41431b9d55bd 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1863,12 +1863,6 @@ EXPORT_SYMBOL_GPL(analogix_dp_remove); int analogix_dp_suspend(struct analogix_dp_device *dp) { clk_disable_unprepare(dp->clock); - - if (dp->plat_data->panel) { - if (drm_panel_unprepare(dp->plat_data->panel)) - DRM_ERROR("failed to turnoff the panel\n"); - } - return 0; } EXPORT_SYMBOL_GPL(analogix_dp_suspend); @@ -1883,13 +1877,6 @@ int analogix_dp_resume(struct analogix_dp_device *dp) return ret; } =20 - if (dp->plat_data->panel) { - if (drm_panel_prepare(dp->plat_data->panel)) { - DRM_ERROR("failed to setup the panel\n"); - return -EBUSY; - } - } - return 0; } EXPORT_SYMBOL_GPL(analogix_dp_resume); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8390CC433F5 for ; Mon, 3 Oct 2022 07:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbiJCHVk (ORCPT ); Mon, 3 Oct 2022 03:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbiJCHU2 (ORCPT ); Mon, 3 Oct 2022 03:20:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6958474E6; Mon, 3 Oct 2022 00:15:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AD056B80E6A; Mon, 3 Oct 2022 07:14:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16CA8C433D7; Mon, 3 Oct 2022 07:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781294; bh=+VAuBlT2qbjuexas2uWO4klILw2NI4Bx5UICdkowzKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJSu6lozg+KhWm2tsc40obm1rvEniLt95W3vmrG0dNUebuDvbw2xzBFI8hDh0d7PF jSQ+VvSwckzROYK/KMu815PufFSvGrdlQMvYhSA4O90B4VxkkOvVVy3FWfkPMsNFAC 1xMAnvk7J+gQY+4hm3MtCmQWvIyBRyrT7UlOSXTs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.19 068/101] Input: melfas_mip4 - fix return value check in mip4_probe() Date: Mon, 3 Oct 2022 09:11:04 +0200 Message-Id: <20221003070726.165064671@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yang Yingliang [ Upstream commit a54dc27bd25f20ee3ea2009584b3166d25178243 ] devm_gpiod_get_optional() may return ERR_PTR(-EPROBE_DEFER), add a minus sign to fix it. Fixes: 6ccb1d8f78bd ("Input: add MELFAS MIP4 Touchscreen driver") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20220924030715.1653538-1-yangyingliang@huaw= ei.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/input/touchscreen/melfas_mip4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchs= creen/melfas_mip4.c index 2745bf1aee38..83f4be05e27b 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -1453,7 +1453,7 @@ static int mip4_probe(struct i2c_client *client, cons= t struct i2c_device_id *id) "ce", GPIOD_OUT_LOW); if (IS_ERR(ts->gpio_ce)) { error =3D PTR_ERR(ts->gpio_ce); - if (error !=3D EPROBE_DEFER) + if (error !=3D -EPROBE_DEFER) dev_err(&client->dev, "Failed to get gpio: %d\n", error); return error; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498C1C4332F for ; Mon, 3 Oct 2022 07:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbiJCHVR (ORCPT ); Mon, 3 Oct 2022 03:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230271AbiJCHUP (ORCPT ); Mon, 3 Oct 2022 03:20:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 736A74360F; Mon, 3 Oct 2022 00:15:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA1E960F99; Mon, 3 Oct 2022 07:14:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9B92C433D6; Mon, 3 Oct 2022 07:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781297; bh=aQkC18YX8ieVc7dyMexU5cFq2VZtUWkJcX6Z3IBJ8GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8RjS6YqZb3lBzpwe1C3bG140zS04eTzFI+lneWb3AEz7211t88bewTmdIY+oxYr+ kXA/p1Lkn9K4kGCch4LmIt1eoQzubKa5v/VozBHuGr2BdbBHAA1ERo2cFXeJ6oduIW 27YBXCXGIBFRlKAAvIhsJjdUxEh37SKoQSoQMd0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.19 069/101] gpio: mvebu: Fix check for pwm support on non-A8K platforms Date: Mon, 3 Oct 2022 09:11:05 +0200 Message-Id: <20221003070726.187680370@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Roh=C3=A1r [ Upstream commit 4335417da2b8d6d9b2d4411b5f9e248e5bb2d380 ] pwm support incompatible with Armada 80x0/70x0 API is not only in Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K platform. Fix check for pwm support appropriately. Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpio/gpio-mvebu.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 2db19cd640a4..de1e7a1a76f2 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -793,8 +793,12 @@ static int mvebu_pwm_probe(struct platform_device *pde= v, u32 offset; u32 set; =20 - if (of_device_is_compatible(mvchip->chip.of_node, - "marvell,armada-370-gpio")) { + if (mvchip->soc_variant =3D=3D MVEBU_GPIO_SOC_VARIANT_A8K) { + int ret =3D of_property_read_u32(dev->of_node, + "marvell,pwm-offset", &offset); + if (ret < 0) + return 0; + } else { /* * There are only two sets of PWM configuration registers for * all the GPIO lines on those SoCs which this driver reserves @@ -804,13 +808,6 @@ static int mvebu_pwm_probe(struct platform_device *pde= v, if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm")) return 0; offset =3D 0; - } else if (mvchip->soc_variant =3D=3D MVEBU_GPIO_SOC_VARIANT_A8K) { - int ret =3D of_property_read_u32(dev->of_node, - "marvell,pwm-offset", &offset); - if (ret < 0) - return 0; - } else { - return 0; } =20 if (IS_ERR(mvchip->clk)) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67D58C433F5 for ; Mon, 3 Oct 2022 07:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbiJCHWG (ORCPT ); Mon, 3 Oct 2022 03:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiJCHVC (ORCPT ); Mon, 3 Oct 2022 03:21:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D34E481FD; Mon, 3 Oct 2022 00:15:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CB6EC60F9D; Mon, 3 Oct 2022 07:15:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A52EC433C1; Mon, 3 Oct 2022 07:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781300; bh=u09qsr+EoB1ADRtfjiNVhEZ7kAXaXaSrn6EeiK+nI2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cy25DVe6LZ71yTRpwP0JDL3xyCRHFdn0sy8DcMD6KotxDJ4fhUWDWG5ZCa4tvJ5Vr KES0BrEQrBOr/TknEGj82eUzGKo0zax1Hy0zyevRIXkba3mixqhhjgMJLYsV5sBC/3 L2ZwsamX/FdnS2g4VwCb0cxzHntMFeprCQ8nYaOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Alexander Shishkin , Ingo Molnar , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Stephane Eranian , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 070/101] perf parse-events: Break out tracepoint and printing Date: Mon, 3 Oct 2022 09:11:06 +0200 Message-Id: <20221003070726.211212627@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ian Rogers [ Upstream commit 9b7c7728f4e4ba8dd75269fb111fa187faa018c6 ] Move print_*_events functions out of parse-events.c into a new print-events.c. Move tracepoint code into tracepoint.c or trace-event-info.c (sole user). This reduces the dependencies of parse-events.c and makes it more amenable to being a library in the future. Remove some unnecessary definitions from parse-events.h. Fix a checkpatch.pl warning on using unsigned rather than unsigned int. Fix some line length warnings too. Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: https://lore.kernel.org/r/20220729204217.250166-3-irogers@google.com [ Add include linux/stddef.h before perf_events.h for systems where __alway= s_inline isn't pulled in before used, such as older Alpine Linux ] Signed-off-by: Arnaldo Carvalho de Melo Stable-dep-of: 71c86cda750b ("perf parse-events: Remove "not supported" hyb= rid cache events") Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/util/Build | 2 + tools/perf/util/parse-events.c | 713 +---------------------------- tools/perf/util/parse-events.h | 31 -- tools/perf/util/print-events.c | 572 +++++++++++++++++++++++ tools/perf/util/print-events.h | 22 + tools/perf/util/trace-event-info.c | 96 ++++ tools/perf/util/tracepoint.c | 63 +++ tools/perf/util/tracepoint.h | 25 + 12 files changed, 791 insertions(+), 738 deletions(-) create mode 100644 tools/perf/util/print-events.c create mode 100644 tools/perf/util/print-events.h create mode 100644 tools/perf/util/tracepoint.c create mode 100644 tools/perf/util/tracepoint.h diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 468958154ed9..744dd3520584 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -10,7 +10,7 @@ */ #include "builtin.h" =20 -#include "util/parse-events.h" +#include "util/print-events.h" #include "util/pmu.h" #include "util/pmu-hybrid.h" #include "util/debug.h" diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 23a33ac15e68..dcc079a80585 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -13,6 +13,7 @@ #include #include #include "util/trace-event.h" +#include "util/tracepoint.h" =20 #include "util/debug.h" #include "util/session.h" diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index afce731cec16..e2e9ad929baf 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -36,6 +36,7 @@ #include "util/data.h" #include "util/debug.h" #include "util/string2.h" +#include "util/tracepoint.h" #include =20 #ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f075cf37a65e..1e1f10a1971d 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -53,6 +53,7 @@ #include "trace-event.h" #include "util/parse-events.h" #include "util/bpf-loader.h" +#include "util/tracepoint.h" #include "callchain.h" #include "print_binary.h" #include "string2.h" diff --git a/tools/perf/util/Build b/tools/perf/util/Build index a51267d88ca9..038e4cf8f488 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -26,6 +26,8 @@ perf-y +=3D mmap.o perf-y +=3D memswap.o perf-y +=3D parse-events.o perf-y +=3D parse-events-hybrid.o +perf-y +=3D print-events.o +perf-y +=3D tracepoint.o perf-y +=3D perf_regs.o perf-y +=3D path.o perf-y +=3D print_binary.o diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 700c95eafd62..3acf7452572c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -5,18 +5,12 @@ #include #include #include -#include -#include -#include #include #include "term.h" -#include "build-id.h" #include "evlist.h" #include "evsel.h" -#include #include #include "parse-events.h" -#include #include "string2.h" #include "strlist.h" #include "bpf-loader.h" @@ -27,20 +21,22 @@ #define YY_EXTRA_TYPE void* #include "parse-events-flex.h" #include "pmu.h" -#include "thread_map.h" -#include "probe-file.h" #include "asm/bug.h" #include "util/parse-branch-options.h" -#include "metricgroup.h" #include "util/evsel_config.h" #include "util/event.h" -#include "util/pfm.h" +#include "perf.h" #include "util/parse-events-hybrid.h" #include "util/pmu-hybrid.h" -#include "perf.h" +#include "tracepoint.h" =20 #define MAX_NAME_LEN 100 =20 +struct perf_pmu_event_symbol { + char *symbol; + enum perf_pmu_event_symbol_type type; +}; + #ifdef PARSER_DEBUG extern int parse_events_debug; #endif @@ -154,21 +150,6 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX= ] =3D { }, }; =20 -struct event_symbol event_symbols_tool[PERF_TOOL_MAX] =3D { - [PERF_TOOL_DURATION_TIME] =3D { - .symbol =3D "duration_time", - .alias =3D "", - }, - [PERF_TOOL_USER_TIME] =3D { - .symbol =3D "user_time", - .alias =3D "", - }, - [PERF_TOOL_SYSTEM_TIME] =3D { - .symbol =3D "system_time", - .alias =3D "", - }, -}; - #define __PERF_EVENT_FIELD(config, name) \ ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT) =20 @@ -177,121 +158,6 @@ struct event_symbol event_symbols_tool[PERF_TOOL_MAX]= =3D { #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) =20 -#define for_each_subsystem(sys_dir, sys_dirent) \ - while ((sys_dirent =3D readdir(sys_dir)) !=3D NULL) \ - if (sys_dirent->d_type =3D=3D DT_DIR && \ - (strcmp(sys_dirent->d_name, ".")) && \ - (strcmp(sys_dirent->d_name, ".."))) - -static int tp_event_has_id(const char *dir_path, struct dirent *evt_dir) -{ - char evt_path[MAXPATHLEN]; - int fd; - - snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, evt_dir->d_name); - fd =3D open(evt_path, O_RDONLY); - if (fd < 0) - return -EINVAL; - close(fd); - - return 0; -} - -#define for_each_event(dir_path, evt_dir, evt_dirent) \ - while ((evt_dirent =3D readdir(evt_dir)) !=3D NULL) \ - if (evt_dirent->d_type =3D=3D DT_DIR && \ - (strcmp(evt_dirent->d_name, ".")) && \ - (strcmp(evt_dirent->d_name, "..")) && \ - (!tp_event_has_id(dir_path, evt_dirent))) - -#define MAX_EVENT_LENGTH 512 - -struct tracepoint_path *tracepoint_id_to_path(u64 config) -{ - struct tracepoint_path *path =3D NULL; - DIR *sys_dir, *evt_dir; - struct dirent *sys_dirent, *evt_dirent; - char id_buf[24]; - int fd; - u64 id; - char evt_path[MAXPATHLEN]; - char *dir_path; - - sys_dir =3D tracing_events__opendir(); - if (!sys_dir) - return NULL; - - for_each_subsystem(sys_dir, sys_dirent) { - dir_path =3D get_events_file(sys_dirent->d_name); - if (!dir_path) - continue; - evt_dir =3D opendir(dir_path); - if (!evt_dir) - goto next; - - for_each_event(dir_path, evt_dir, evt_dirent) { - - scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, - evt_dirent->d_name); - fd =3D open(evt_path, O_RDONLY); - if (fd < 0) - continue; - if (read(fd, id_buf, sizeof(id_buf)) < 0) { - close(fd); - continue; - } - close(fd); - id =3D atoll(id_buf); - if (id =3D=3D config) { - put_events_file(dir_path); - closedir(evt_dir); - closedir(sys_dir); - path =3D zalloc(sizeof(*path)); - if (!path) - return NULL; - if (asprintf(&path->system, "%.*s", MAX_EVENT_LENGTH, sys_dirent->d_na= me) < 0) { - free(path); - return NULL; - } - if (asprintf(&path->name, "%.*s", MAX_EVENT_LENGTH, evt_dirent->d_name= ) < 0) { - zfree(&path->system); - free(path); - return NULL; - } - return path; - } - } - closedir(evt_dir); -next: - put_events_file(dir_path); - } - - closedir(sys_dir); - return NULL; -} - -struct tracepoint_path *tracepoint_name_to_path(const char *name) -{ - struct tracepoint_path *path =3D zalloc(sizeof(*path)); - char *str =3D strchr(name, ':'); - - if (path =3D=3D NULL || str =3D=3D NULL) { - free(path); - return NULL; - } - - path->system =3D strndup(name, str - name); - path->name =3D strdup(str+1); - - if (path->system =3D=3D NULL || path->name =3D=3D NULL) { - zfree(&path->system); - zfree(&path->name); - zfree(&path); - } - - return path; -} - const char *event_type(int type) { switch (type) { @@ -2674,571 +2540,6 @@ int exclude_perf(const struct option *opt, NULL); } =20 -static const char * const event_type_descriptors[] =3D { - "Hardware event", - "Software event", - "Tracepoint event", - "Hardware cache event", - "Raw hardware event descriptor", - "Hardware breakpoint", -}; - -static int cmp_string(const void *a, const void *b) -{ - const char * const *as =3D a; - const char * const *bs =3D b; - - return strcmp(*as, *bs); -} - -/* - * Print the events from /tracing/events - */ - -void print_tracepoint_events(const char *subsys_glob, const char *event_gl= ob, - bool name_only) -{ - DIR *sys_dir, *evt_dir; - struct dirent *sys_dirent, *evt_dirent; - char evt_path[MAXPATHLEN]; - char *dir_path; - char **evt_list =3D NULL; - unsigned int evt_i =3D 0, evt_num =3D 0; - bool evt_num_known =3D false; - -restart: - sys_dir =3D tracing_events__opendir(); - if (!sys_dir) - return; - - if (evt_num_known) { - evt_list =3D zalloc(sizeof(char *) * evt_num); - if (!evt_list) - goto out_close_sys_dir; - } - - for_each_subsystem(sys_dir, sys_dirent) { - if (subsys_glob !=3D NULL && - !strglobmatch(sys_dirent->d_name, subsys_glob)) - continue; - - dir_path =3D get_events_file(sys_dirent->d_name); - if (!dir_path) - continue; - evt_dir =3D opendir(dir_path); - if (!evt_dir) - goto next; - - for_each_event(dir_path, evt_dir, evt_dirent) { - if (event_glob !=3D NULL && - !strglobmatch(evt_dirent->d_name, event_glob)) - continue; - - if (!evt_num_known) { - evt_num++; - continue; - } - - snprintf(evt_path, MAXPATHLEN, "%s:%s", - sys_dirent->d_name, evt_dirent->d_name); - - evt_list[evt_i] =3D strdup(evt_path); - if (evt_list[evt_i] =3D=3D NULL) { - put_events_file(dir_path); - goto out_close_evt_dir; - } - evt_i++; - } - closedir(evt_dir); -next: - put_events_file(dir_path); - } - closedir(sys_dir); - - if (!evt_num_known) { - evt_num_known =3D true; - goto restart; - } - qsort(evt_list, evt_num, sizeof(char *), cmp_string); - evt_i =3D 0; - while (evt_i < evt_num) { - if (name_only) { - printf("%s ", evt_list[evt_i++]); - continue; - } - printf(" %-50s [%s]\n", evt_list[evt_i++], - event_type_descriptors[PERF_TYPE_TRACEPOINT]); - } - if (evt_num && pager_in_use()) - printf("\n"); - -out_free: - evt_num =3D evt_i; - for (evt_i =3D 0; evt_i < evt_num; evt_i++) - zfree(&evt_list[evt_i]); - zfree(&evt_list); - return; - -out_close_evt_dir: - closedir(evt_dir); -out_close_sys_dir: - closedir(sys_dir); - - printf("FATAL: not enough memory to print %s\n", - event_type_descriptors[PERF_TYPE_TRACEPOINT]); - if (evt_list) - goto out_free; -} - -/* - * Check whether event is in /tracing/events - */ - -int is_valid_tracepoint(const char *event_string) -{ - DIR *sys_dir, *evt_dir; - struct dirent *sys_dirent, *evt_dirent; - char evt_path[MAXPATHLEN]; - char *dir_path; - - sys_dir =3D tracing_events__opendir(); - if (!sys_dir) - return 0; - - for_each_subsystem(sys_dir, sys_dirent) { - dir_path =3D get_events_file(sys_dirent->d_name); - if (!dir_path) - continue; - evt_dir =3D opendir(dir_path); - if (!evt_dir) - goto next; - - for_each_event(dir_path, evt_dir, evt_dirent) { - snprintf(evt_path, MAXPATHLEN, "%s:%s", - sys_dirent->d_name, evt_dirent->d_name); - if (!strcmp(evt_path, event_string)) { - closedir(evt_dir); - closedir(sys_dir); - return 1; - } - } - closedir(evt_dir); -next: - put_events_file(dir_path); - } - closedir(sys_dir); - return 0; -} - -static bool is_event_supported(u8 type, u64 config) -{ - bool ret =3D true; - int open_return; - struct evsel *evsel; - struct perf_event_attr attr =3D { - .type =3D type, - .config =3D config, - .disabled =3D 1, - }; - struct perf_thread_map *tmap =3D thread_map__new_by_tid(0); - - if (tmap =3D=3D NULL) - return false; - - evsel =3D evsel__new(&attr); - if (evsel) { - open_return =3D evsel__open(evsel, NULL, tmap); - ret =3D open_return >=3D 0; - - if (open_return =3D=3D -EACCES) { - /* - * This happens if the paranoid value - * /proc/sys/kernel/perf_event_paranoid is set to 2 - * Re-run with exclude_kernel set; we don't do that - * by default as some ARM machines do not support it. - * - */ - evsel->core.attr.exclude_kernel =3D 1; - ret =3D evsel__open(evsel, NULL, tmap) >=3D 0; - } - evsel__delete(evsel); - } - - perf_thread_map__put(tmap); - return ret; -} - -void print_sdt_events(const char *subsys_glob, const char *event_glob, - bool name_only) -{ - struct probe_cache *pcache; - struct probe_cache_entry *ent; - struct strlist *bidlist, *sdtlist; - struct strlist_config cfg =3D {.dont_dupstr =3D true}; - struct str_node *nd, *nd2; - char *buf, *path, *ptr =3D NULL; - bool show_detail =3D false; - int ret; - - sdtlist =3D strlist__new(NULL, &cfg); - if (!sdtlist) { - pr_debug("Failed to allocate new strlist for SDT\n"); - return; - } - bidlist =3D build_id_cache__list_all(true); - if (!bidlist) { - pr_debug("Failed to get buildids: %d\n", errno); - return; - } - strlist__for_each_entry(nd, bidlist) { - pcache =3D probe_cache__new(nd->s, NULL); - if (!pcache) - continue; - list_for_each_entry(ent, &pcache->entries, node) { - if (!ent->sdt) - continue; - if (subsys_glob && - !strglobmatch(ent->pev.group, subsys_glob)) - continue; - if (event_glob && - !strglobmatch(ent->pev.event, event_glob)) - continue; - ret =3D asprintf(&buf, "%s:%s@%s", ent->pev.group, - ent->pev.event, nd->s); - if (ret > 0) - strlist__add(sdtlist, buf); - } - probe_cache__delete(pcache); - } - strlist__delete(bidlist); - - strlist__for_each_entry(nd, sdtlist) { - buf =3D strchr(nd->s, '@'); - if (buf) - *(buf++) =3D '\0'; - if (name_only) { - printf("%s ", nd->s); - continue; - } - nd2 =3D strlist__next(nd); - if (nd2) { - ptr =3D strchr(nd2->s, '@'); - if (ptr) - *ptr =3D '\0'; - if (strcmp(nd->s, nd2->s) =3D=3D 0) - show_detail =3D true; - } - if (show_detail) { - path =3D build_id_cache__origname(buf); - ret =3D asprintf(&buf, "%s@%s(%.12s)", nd->s, path, buf); - if (ret > 0) { - printf(" %-50s [%s]\n", buf, "SDT event"); - free(buf); - } - free(path); - } else - printf(" %-50s [%s]\n", nd->s, "SDT event"); - if (nd2) { - if (strcmp(nd->s, nd2->s) !=3D 0) - show_detail =3D false; - if (ptr) - *ptr =3D '@'; - } - } - strlist__delete(sdtlist); -} - -int print_hwcache_events(const char *event_glob, bool name_only) -{ - unsigned int type, op, i, evt_i =3D 0, evt_num =3D 0, npmus =3D 0; - char name[64], new_name[128]; - char **evt_list =3D NULL, **evt_pmus =3D NULL; - bool evt_num_known =3D false; - struct perf_pmu *pmu =3D NULL; - - if (perf_pmu__has_hybrid()) { - npmus =3D perf_pmu__hybrid_pmu_num(); - evt_pmus =3D zalloc(sizeof(char *) * npmus); - if (!evt_pmus) - goto out_enomem; - } - -restart: - if (evt_num_known) { - evt_list =3D zalloc(sizeof(char *) * evt_num); - if (!evt_list) - goto out_enomem; - } - - for (type =3D 0; type < PERF_COUNT_HW_CACHE_MAX; type++) { - for (op =3D 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) { - /* skip invalid cache type */ - if (!evsel__is_cache_op_valid(type, op)) - continue; - - for (i =3D 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { - unsigned int hybrid_supported =3D 0, j; - bool supported; - - __evsel__hw_cache_type_op_res_name(type, op, i, name, sizeof(name)); - if (event_glob !=3D NULL && !strglobmatch(name, event_glob)) - continue; - - if (!perf_pmu__has_hybrid()) { - if (!is_event_supported(PERF_TYPE_HW_CACHE, - type | (op << 8) | (i << 16))) { - continue; - } - } else { - perf_pmu__for_each_hybrid_pmu(pmu) { - if (!evt_num_known) { - evt_num++; - continue; - } - - supported =3D is_event_supported( - PERF_TYPE_HW_CACHE, - type | (op << 8) | (i << 16) | - ((__u64)pmu->type << PERF_PMU_TYPE_SHIFT)); - if (supported) { - snprintf(new_name, sizeof(new_name), "%s/%s/", - pmu->name, name); - evt_pmus[hybrid_supported] =3D strdup(new_name); - hybrid_supported++; - } - } - - if (hybrid_supported =3D=3D 0) - continue; - } - - if (!evt_num_known) { - evt_num++; - continue; - } - - if ((hybrid_supported =3D=3D 0) || - (hybrid_supported =3D=3D npmus)) { - evt_list[evt_i] =3D strdup(name); - if (npmus > 0) { - for (j =3D 0; j < npmus; j++) - zfree(&evt_pmus[j]); - } - } else { - for (j =3D 0; j < hybrid_supported; j++) { - evt_list[evt_i++] =3D evt_pmus[j]; - evt_pmus[j] =3D NULL; - } - continue; - } - - if (evt_list[evt_i] =3D=3D NULL) - goto out_enomem; - evt_i++; - } - } - } - - if (!evt_num_known) { - evt_num_known =3D true; - goto restart; - } - - for (evt_i =3D 0; evt_i < evt_num; evt_i++) { - if (!evt_list[evt_i]) - break; - } - - evt_num =3D evt_i; - qsort(evt_list, evt_num, sizeof(char *), cmp_string); - evt_i =3D 0; - while (evt_i < evt_num) { - if (name_only) { - printf("%s ", evt_list[evt_i++]); - continue; - } - printf(" %-50s [%s]\n", evt_list[evt_i++], - event_type_descriptors[PERF_TYPE_HW_CACHE]); - } - if (evt_num && pager_in_use()) - printf("\n"); - -out_free: - evt_num =3D evt_i; - for (evt_i =3D 0; evt_i < evt_num; evt_i++) - zfree(&evt_list[evt_i]); - zfree(&evt_list); - - for (evt_i =3D 0; evt_i < npmus; evt_i++) - zfree(&evt_pmus[evt_i]); - zfree(&evt_pmus); - return evt_num; - -out_enomem: - printf("FATAL: not enough memory to print %s\n", event_type_descriptors[P= ERF_TYPE_HW_CACHE]); - if (evt_list) - goto out_free; - return evt_num; -} - -static void print_tool_event(const struct event_symbol *syms, const char *= event_glob, - bool name_only) -{ - if (syms->symbol =3D=3D NULL) - return; - - if (event_glob && !(strglobmatch(syms->symbol, event_glob) || - (syms->alias && strglobmatch(syms->alias, event_glob)))) - return; - - if (name_only) - printf("%s ", syms->symbol); - else { - char name[MAX_NAME_LEN]; - if (syms->alias && strlen(syms->alias)) - snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); - else - strlcpy(name, syms->symbol, MAX_NAME_LEN); - printf(" %-50s [%s]\n", name, "Tool event"); - } -} - -void print_tool_events(const char *event_glob, bool name_only) -{ - // Start at 1 because the first enum entry symbols no tool event - for (int i =3D 1; i < PERF_TOOL_MAX; ++i) { - print_tool_event(event_symbols_tool + i, event_glob, name_only); - } - if (pager_in_use()) - printf("\n"); -} - -void print_symbol_events(const char *event_glob, unsigned type, - struct event_symbol *syms, unsigned max, - bool name_only) -{ - unsigned int i, evt_i =3D 0, evt_num =3D 0; - char name[MAX_NAME_LEN]; - char **evt_list =3D NULL; - bool evt_num_known =3D false; - -restart: - if (evt_num_known) { - evt_list =3D zalloc(sizeof(char *) * evt_num); - if (!evt_list) - goto out_enomem; - syms -=3D max; - } - - for (i =3D 0; i < max; i++, syms++) { - /* - * New attr.config still not supported here, the latest - * example was PERF_COUNT_SW_CGROUP_SWITCHES - */ - if (syms->symbol =3D=3D NULL) - continue; - - if (event_glob !=3D NULL && !(strglobmatch(syms->symbol, event_glob) || - (syms->alias && strglobmatch(syms->alias, event_glob)))) - continue; - - if (!is_event_supported(type, i)) - continue; - - if (!evt_num_known) { - evt_num++; - continue; - } - - if (!name_only && strlen(syms->alias)) - snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); - else - strlcpy(name, syms->symbol, MAX_NAME_LEN); - - evt_list[evt_i] =3D strdup(name); - if (evt_list[evt_i] =3D=3D NULL) - goto out_enomem; - evt_i++; - } - - if (!evt_num_known) { - evt_num_known =3D true; - goto restart; - } - qsort(evt_list, evt_num, sizeof(char *), cmp_string); - evt_i =3D 0; - while (evt_i < evt_num) { - if (name_only) { - printf("%s ", evt_list[evt_i++]); - continue; - } - printf(" %-50s [%s]\n", evt_list[evt_i++], event_type_descriptors[type]= ); - } - if (evt_num && pager_in_use()) - printf("\n"); - -out_free: - evt_num =3D evt_i; - for (evt_i =3D 0; evt_i < evt_num; evt_i++) - zfree(&evt_list[evt_i]); - zfree(&evt_list); - return; - -out_enomem: - printf("FATAL: not enough memory to print %s\n", event_type_descriptors[t= ype]); - if (evt_list) - goto out_free; -} - -/* - * Print the help text for the event symbols: - */ -void print_events(const char *event_glob, bool name_only, bool quiet_flag, - bool long_desc, bool details_flag, bool deprecated, - const char *pmu_name) -{ - print_symbol_events(event_glob, PERF_TYPE_HARDWARE, - event_symbols_hw, PERF_COUNT_HW_MAX, name_only); - - print_symbol_events(event_glob, PERF_TYPE_SOFTWARE, - event_symbols_sw, PERF_COUNT_SW_MAX, name_only); - print_tool_events(event_glob, name_only); - - print_hwcache_events(event_glob, name_only); - - print_pmu_events(event_glob, name_only, quiet_flag, long_desc, - details_flag, deprecated, pmu_name); - - if (event_glob !=3D NULL) - return; - - if (!name_only) { - printf(" %-50s [%s]\n", - "rNNN", - event_type_descriptors[PERF_TYPE_RAW]); - printf(" %-50s [%s]\n", - "cpu/t1=3Dv1[,t2=3Dv2,t3 ...]/modifier", - event_type_descriptors[PERF_TYPE_RAW]); - if (pager_in_use()) - printf(" (see 'man perf-list' on how to encode it)\n\n"); - - printf(" %-50s [%s]\n", - "mem:[/len][:access]", - event_type_descriptors[PERF_TYPE_BREAKPOINT]); - if (pager_in_use()) - printf("\n"); - } - - print_tracepoint_events(NULL, NULL, name_only); - - print_sdt_events(NULL, NULL, name_only); - - metricgroup__print(true, true, NULL, name_only, details_flag, - pmu_name); - - print_libpfm_events(name_only, long_desc); -} - int parse_events__is_hardcoded_term(struct parse_events_term *term) { return term->type_term !=3D PARSE_EVENTS__TERM_TYPE_USER; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index a38b8b160e80..ba9fa3ddaf6e 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -11,7 +11,6 @@ #include #include =20 -struct list_head; struct evsel; struct evlist; struct parse_events_error; @@ -19,14 +18,6 @@ struct parse_events_error; struct option; struct perf_pmu; =20 -struct tracepoint_path { - char *system; - char *name; - struct tracepoint_path *next; -}; - -struct tracepoint_path *tracepoint_id_to_path(u64 config); -struct tracepoint_path *tracepoint_name_to_path(const char *name); bool have_tracepoints(struct list_head *evlist); =20 const char *event_type(int type); @@ -46,8 +37,6 @@ int parse_events_terms(struct list_head *terms, const cha= r *str); int parse_filter(const struct option *opt, const char *str, int unset); int exclude_perf(const struct option *opt, const char *arg, int unset); =20 -#define EVENTS_HELP_MAX (128*1024) - enum perf_pmu_event_symbol_type { PMU_EVENT_SYMBOL_ERR, /* not a PMU EVENT */ PMU_EVENT_SYMBOL, /* normal style PMU event */ @@ -56,11 +45,6 @@ enum perf_pmu_event_symbol_type { PMU_EVENT_SYMBOL_SUFFIX2, /* suffix of pre-suf2 style event */ }; =20 -struct perf_pmu_event_symbol { - char *symbol; - enum perf_pmu_event_symbol_type type; -}; - enum { PARSE_EVENTS__TERM_TYPE_NUM, PARSE_EVENTS__TERM_TYPE_STR, @@ -219,28 +203,13 @@ void parse_events_update_lists(struct list_head *list= _event, void parse_events_evlist_error(struct parse_events_state *parse_state, int idx, const char *str); =20 -void print_events(const char *event_glob, bool name_only, bool quiet, - bool long_desc, bool details_flag, bool deprecated, - const char *pmu_name); - struct event_symbol { const char *symbol; const char *alias; }; extern struct event_symbol event_symbols_hw[]; extern struct event_symbol event_symbols_sw[]; -void print_symbol_events(const char *event_glob, unsigned type, - struct event_symbol *syms, unsigned max, - bool name_only); -void print_tool_events(const char *event_glob, bool name_only); -void print_tracepoint_events(const char *subsys_glob, const char *event_gl= ob, - bool name_only); -int print_hwcache_events(const char *event_glob, bool name_only); -void print_sdt_events(const char *subsys_glob, const char *event_glob, - bool name_only); -int is_valid_tracepoint(const char *event_string); =20 -int valid_event_mount(const char *eventfs); char *parse_events_formats_error_string(char *additional_terms); =20 void parse_events_error__init(struct parse_events_error *err); diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c new file mode 100644 index 000000000000..ba1ab5134685 --- /dev/null +++ b/tools/perf/util/print-events.c @@ -0,0 +1,572 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "build-id.h" +#include "debug.h" +#include "evsel.h" +#include "metricgroup.h" +#include "parse-events.h" +#include "pmu.h" +#include "print-events.h" +#include "probe-file.h" +#include "string2.h" +#include "strlist.h" +#include "thread_map.h" +#include "tracepoint.h" +#include "pfm.h" +#include "pmu-hybrid.h" + +#define MAX_NAME_LEN 100 + +static const char * const event_type_descriptors[] =3D { + "Hardware event", + "Software event", + "Tracepoint event", + "Hardware cache event", + "Raw hardware event descriptor", + "Hardware breakpoint", +}; + +static const struct event_symbol event_symbols_tool[PERF_TOOL_MAX] =3D { + [PERF_TOOL_DURATION_TIME] =3D { + .symbol =3D "duration_time", + .alias =3D "", + }, + [PERF_TOOL_USER_TIME] =3D { + .symbol =3D "user_time", + .alias =3D "", + }, + [PERF_TOOL_SYSTEM_TIME] =3D { + .symbol =3D "system_time", + .alias =3D "", + }, +}; + +static int cmp_string(const void *a, const void *b) +{ + const char * const *as =3D a; + const char * const *bs =3D b; + + return strcmp(*as, *bs); +} + +/* + * Print the events from /tracing/events + */ +void print_tracepoint_events(const char *subsys_glob, + const char *event_glob, bool name_only) +{ + DIR *sys_dir, *evt_dir; + struct dirent *sys_dirent, *evt_dirent; + char evt_path[MAXPATHLEN]; + char *dir_path; + char **evt_list =3D NULL; + unsigned int evt_i =3D 0, evt_num =3D 0; + bool evt_num_known =3D false; + +restart: + sys_dir =3D tracing_events__opendir(); + if (!sys_dir) + return; + + if (evt_num_known) { + evt_list =3D zalloc(sizeof(char *) * evt_num); + if (!evt_list) + goto out_close_sys_dir; + } + + for_each_subsystem(sys_dir, sys_dirent) { + if (subsys_glob !=3D NULL && + !strglobmatch(sys_dirent->d_name, subsys_glob)) + continue; + + dir_path =3D get_events_file(sys_dirent->d_name); + if (!dir_path) + continue; + evt_dir =3D opendir(dir_path); + if (!evt_dir) + goto next; + + for_each_event(dir_path, evt_dir, evt_dirent) { + if (event_glob !=3D NULL && + !strglobmatch(evt_dirent->d_name, event_glob)) + continue; + + if (!evt_num_known) { + evt_num++; + continue; + } + + snprintf(evt_path, MAXPATHLEN, "%s:%s", + sys_dirent->d_name, evt_dirent->d_name); + + evt_list[evt_i] =3D strdup(evt_path); + if (evt_list[evt_i] =3D=3D NULL) { + put_events_file(dir_path); + goto out_close_evt_dir; + } + evt_i++; + } + closedir(evt_dir); +next: + put_events_file(dir_path); + } + closedir(sys_dir); + + if (!evt_num_known) { + evt_num_known =3D true; + goto restart; + } + qsort(evt_list, evt_num, sizeof(char *), cmp_string); + evt_i =3D 0; + while (evt_i < evt_num) { + if (name_only) { + printf("%s ", evt_list[evt_i++]); + continue; + } + printf(" %-50s [%s]\n", evt_list[evt_i++], + event_type_descriptors[PERF_TYPE_TRACEPOINT]); + } + if (evt_num && pager_in_use()) + printf("\n"); + +out_free: + evt_num =3D evt_i; + for (evt_i =3D 0; evt_i < evt_num; evt_i++) + zfree(&evt_list[evt_i]); + zfree(&evt_list); + return; + +out_close_evt_dir: + closedir(evt_dir); +out_close_sys_dir: + closedir(sys_dir); + + printf("FATAL: not enough memory to print %s\n", + event_type_descriptors[PERF_TYPE_TRACEPOINT]); + if (evt_list) + goto out_free; +} + +void print_sdt_events(const char *subsys_glob, const char *event_glob, + bool name_only) +{ + struct probe_cache *pcache; + struct probe_cache_entry *ent; + struct strlist *bidlist, *sdtlist; + struct strlist_config cfg =3D {.dont_dupstr =3D true}; + struct str_node *nd, *nd2; + char *buf, *path, *ptr =3D NULL; + bool show_detail =3D false; + int ret; + + sdtlist =3D strlist__new(NULL, &cfg); + if (!sdtlist) { + pr_debug("Failed to allocate new strlist for SDT\n"); + return; + } + bidlist =3D build_id_cache__list_all(true); + if (!bidlist) { + pr_debug("Failed to get buildids: %d\n", errno); + return; + } + strlist__for_each_entry(nd, bidlist) { + pcache =3D probe_cache__new(nd->s, NULL); + if (!pcache) + continue; + list_for_each_entry(ent, &pcache->entries, node) { + if (!ent->sdt) + continue; + if (subsys_glob && + !strglobmatch(ent->pev.group, subsys_glob)) + continue; + if (event_glob && + !strglobmatch(ent->pev.event, event_glob)) + continue; + ret =3D asprintf(&buf, "%s:%s@%s", ent->pev.group, + ent->pev.event, nd->s); + if (ret > 0) + strlist__add(sdtlist, buf); + } + probe_cache__delete(pcache); + } + strlist__delete(bidlist); + + strlist__for_each_entry(nd, sdtlist) { + buf =3D strchr(nd->s, '@'); + if (buf) + *(buf++) =3D '\0'; + if (name_only) { + printf("%s ", nd->s); + continue; + } + nd2 =3D strlist__next(nd); + if (nd2) { + ptr =3D strchr(nd2->s, '@'); + if (ptr) + *ptr =3D '\0'; + if (strcmp(nd->s, nd2->s) =3D=3D 0) + show_detail =3D true; + } + if (show_detail) { + path =3D build_id_cache__origname(buf); + ret =3D asprintf(&buf, "%s@%s(%.12s)", nd->s, path, buf); + if (ret > 0) { + printf(" %-50s [%s]\n", buf, "SDT event"); + free(buf); + } + free(path); + } else + printf(" %-50s [%s]\n", nd->s, "SDT event"); + if (nd2) { + if (strcmp(nd->s, nd2->s) !=3D 0) + show_detail =3D false; + if (ptr) + *ptr =3D '@'; + } + } + strlist__delete(sdtlist); +} + +static bool is_event_supported(u8 type, unsigned int config) +{ + bool ret =3D true; + int open_return; + struct evsel *evsel; + struct perf_event_attr attr =3D { + .type =3D type, + .config =3D config, + .disabled =3D 1, + }; + struct perf_thread_map *tmap =3D thread_map__new_by_tid(0); + + if (tmap =3D=3D NULL) + return false; + + evsel =3D evsel__new(&attr); + if (evsel) { + open_return =3D evsel__open(evsel, NULL, tmap); + ret =3D open_return >=3D 0; + + if (open_return =3D=3D -EACCES) { + /* + * This happens if the paranoid value + * /proc/sys/kernel/perf_event_paranoid is set to 2 + * Re-run with exclude_kernel set; we don't do that + * by default as some ARM machines do not support it. + * + */ + evsel->core.attr.exclude_kernel =3D 1; + ret =3D evsel__open(evsel, NULL, tmap) >=3D 0; + } + evsel__delete(evsel); + } + + perf_thread_map__put(tmap); + return ret; +} + +int print_hwcache_events(const char *event_glob, bool name_only) +{ + unsigned int type, op, i, evt_i =3D 0, evt_num =3D 0, npmus =3D 0; + char name[64], new_name[128]; + char **evt_list =3D NULL, **evt_pmus =3D NULL; + bool evt_num_known =3D false; + struct perf_pmu *pmu =3D NULL; + + if (perf_pmu__has_hybrid()) { + npmus =3D perf_pmu__hybrid_pmu_num(); + evt_pmus =3D zalloc(sizeof(char *) * npmus); + if (!evt_pmus) + goto out_enomem; + } + +restart: + if (evt_num_known) { + evt_list =3D zalloc(sizeof(char *) * evt_num); + if (!evt_list) + goto out_enomem; + } + + for (type =3D 0; type < PERF_COUNT_HW_CACHE_MAX; type++) { + for (op =3D 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) { + /* skip invalid cache type */ + if (!evsel__is_cache_op_valid(type, op)) + continue; + + for (i =3D 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { + unsigned int hybrid_supported =3D 0, j; + bool supported; + + __evsel__hw_cache_type_op_res_name(type, op, i, name, sizeof(name)); + if (event_glob !=3D NULL && !strglobmatch(name, event_glob)) + continue; + + if (!perf_pmu__has_hybrid()) { + if (!is_event_supported(PERF_TYPE_HW_CACHE, + type | (op << 8) | (i << 16))) { + continue; + } + } else { + perf_pmu__for_each_hybrid_pmu(pmu) { + if (!evt_num_known) { + evt_num++; + continue; + } + + supported =3D is_event_supported( + PERF_TYPE_HW_CACHE, + type | (op << 8) | (i << 16) | + ((__u64)pmu->type << PERF_PMU_TYPE_SHIFT)); + if (supported) { + snprintf(new_name, sizeof(new_name), + "%s/%s/", pmu->name, name); + evt_pmus[hybrid_supported] =3D + strdup(new_name); + hybrid_supported++; + } + } + + if (hybrid_supported =3D=3D 0) + continue; + } + + if (!evt_num_known) { + evt_num++; + continue; + } + + if ((hybrid_supported =3D=3D 0) || + (hybrid_supported =3D=3D npmus)) { + evt_list[evt_i] =3D strdup(name); + if (npmus > 0) { + for (j =3D 0; j < npmus; j++) + zfree(&evt_pmus[j]); + } + } else { + for (j =3D 0; j < hybrid_supported; j++) { + evt_list[evt_i++] =3D evt_pmus[j]; + evt_pmus[j] =3D NULL; + } + continue; + } + + if (evt_list[evt_i] =3D=3D NULL) + goto out_enomem; + evt_i++; + } + } + } + + if (!evt_num_known) { + evt_num_known =3D true; + goto restart; + } + + for (evt_i =3D 0; evt_i < evt_num; evt_i++) { + if (!evt_list[evt_i]) + break; + } + + evt_num =3D evt_i; + qsort(evt_list, evt_num, sizeof(char *), cmp_string); + evt_i =3D 0; + while (evt_i < evt_num) { + if (name_only) { + printf("%s ", evt_list[evt_i++]); + continue; + } + printf(" %-50s [%s]\n", evt_list[evt_i++], + event_type_descriptors[PERF_TYPE_HW_CACHE]); + } + if (evt_num && pager_in_use()) + printf("\n"); + +out_free: + evt_num =3D evt_i; + for (evt_i =3D 0; evt_i < evt_num; evt_i++) + zfree(&evt_list[evt_i]); + zfree(&evt_list); + + for (evt_i =3D 0; evt_i < npmus; evt_i++) + zfree(&evt_pmus[evt_i]); + zfree(&evt_pmus); + return evt_num; + +out_enomem: + printf("FATAL: not enough memory to print %s\n", + event_type_descriptors[PERF_TYPE_HW_CACHE]); + if (evt_list) + goto out_free; + return evt_num; +} + +static void print_tool_event(const struct event_symbol *syms, const char *= event_glob, + bool name_only) +{ + if (syms->symbol =3D=3D NULL) + return; + + if (event_glob && !(strglobmatch(syms->symbol, event_glob) || + (syms->alias && strglobmatch(syms->alias, event_glob)))) + return; + + if (name_only) + printf("%s ", syms->symbol); + else { + char name[MAX_NAME_LEN]; + + if (syms->alias && strlen(syms->alias)) + snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); + else + strlcpy(name, syms->symbol, MAX_NAME_LEN); + printf(" %-50s [%s]\n", name, "Tool event"); + } +} + +void print_tool_events(const char *event_glob, bool name_only) +{ + // Start at 1 because the first enum entry means no tool event. + for (int i =3D 1; i < PERF_TOOL_MAX; ++i) + print_tool_event(event_symbols_tool + i, event_glob, name_only); + + if (pager_in_use()) + printf("\n"); +} + +void print_symbol_events(const char *event_glob, unsigned int type, + struct event_symbol *syms, unsigned int max, + bool name_only) +{ + unsigned int i, evt_i =3D 0, evt_num =3D 0; + char name[MAX_NAME_LEN]; + char **evt_list =3D NULL; + bool evt_num_known =3D false; + +restart: + if (evt_num_known) { + evt_list =3D zalloc(sizeof(char *) * evt_num); + if (!evt_list) + goto out_enomem; + syms -=3D max; + } + + for (i =3D 0; i < max; i++, syms++) { + /* + * New attr.config still not supported here, the latest + * example was PERF_COUNT_SW_CGROUP_SWITCHES + */ + if (syms->symbol =3D=3D NULL) + continue; + + if (event_glob !=3D NULL && !(strglobmatch(syms->symbol, event_glob) || + (syms->alias && strglobmatch(syms->alias, event_glob)))) + continue; + + if (!is_event_supported(type, i)) + continue; + + if (!evt_num_known) { + evt_num++; + continue; + } + + if (!name_only && strlen(syms->alias)) + snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); + else + strlcpy(name, syms->symbol, MAX_NAME_LEN); + + evt_list[evt_i] =3D strdup(name); + if (evt_list[evt_i] =3D=3D NULL) + goto out_enomem; + evt_i++; + } + + if (!evt_num_known) { + evt_num_known =3D true; + goto restart; + } + qsort(evt_list, evt_num, sizeof(char *), cmp_string); + evt_i =3D 0; + while (evt_i < evt_num) { + if (name_only) { + printf("%s ", evt_list[evt_i++]); + continue; + } + printf(" %-50s [%s]\n", evt_list[evt_i++], event_type_descriptors[type]= ); + } + if (evt_num && pager_in_use()) + printf("\n"); + +out_free: + evt_num =3D evt_i; + for (evt_i =3D 0; evt_i < evt_num; evt_i++) + zfree(&evt_list[evt_i]); + zfree(&evt_list); + return; + +out_enomem: + printf("FATAL: not enough memory to print %s\n", event_type_descriptors[t= ype]); + if (evt_list) + goto out_free; +} + +/* + * Print the help text for the event symbols: + */ +void print_events(const char *event_glob, bool name_only, bool quiet_flag, + bool long_desc, bool details_flag, bool deprecated, + const char *pmu_name) +{ + print_symbol_events(event_glob, PERF_TYPE_HARDWARE, + event_symbols_hw, PERF_COUNT_HW_MAX, name_only); + + print_symbol_events(event_glob, PERF_TYPE_SOFTWARE, + event_symbols_sw, PERF_COUNT_SW_MAX, name_only); + print_tool_events(event_glob, name_only); + + print_hwcache_events(event_glob, name_only); + + print_pmu_events(event_glob, name_only, quiet_flag, long_desc, + details_flag, deprecated, pmu_name); + + if (event_glob !=3D NULL) + return; + + if (!name_only) { + printf(" %-50s [%s]\n", + "rNNN", + event_type_descriptors[PERF_TYPE_RAW]); + printf(" %-50s [%s]\n", + "cpu/t1=3Dv1[,t2=3Dv2,t3 ...]/modifier", + event_type_descriptors[PERF_TYPE_RAW]); + if (pager_in_use()) + printf(" (see 'man perf-list' on how to encode it)\n\n"); + + printf(" %-50s [%s]\n", + "mem:[/len][:access]", + event_type_descriptors[PERF_TYPE_BREAKPOINT]); + if (pager_in_use()) + printf("\n"); + } + + print_tracepoint_events(NULL, NULL, name_only); + + print_sdt_events(NULL, NULL, name_only); + + metricgroup__print(true, true, NULL, name_only, details_flag, + pmu_name); + + print_libpfm_events(name_only, long_desc); +} diff --git a/tools/perf/util/print-events.h b/tools/perf/util/print-events.h new file mode 100644 index 000000000000..1da9910d83a6 --- /dev/null +++ b/tools/perf/util/print-events.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_PRINT_EVENTS_H +#define __PERF_PRINT_EVENTS_H + +#include + +struct event_symbol; + +void print_events(const char *event_glob, bool name_only, bool quiet_flag, + bool long_desc, bool details_flag, bool deprecated, + const char *pmu_name); +int print_hwcache_events(const char *event_glob, bool name_only); +void print_sdt_events(const char *subsys_glob, const char *event_glob, + bool name_only); +void print_symbol_events(const char *event_glob, unsigned int type, + struct event_symbol *syms, unsigned int max, + bool name_only); +void print_tool_events(const char *event_glob, bool name_only); +void print_tracepoint_events(const char *subsys_glob, const char *event_gl= ob, + bool name_only); + +#endif /* __PERF_PRINT_EVENTS_H */ diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-eve= nt-info.c index a65f65d0857e..892c323b4ac9 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -19,16 +19,24 @@ #include #include #include // page_size +#include =20 #include "trace-event.h" +#include "tracepoint.h" #include #include "evsel.h" #include "debug.h" =20 #define VERSION "0.6" +#define MAX_EVENT_LENGTH 512 =20 static int output_fd; =20 +struct tracepoint_path { + char *system; + char *name; + struct tracepoint_path *next; +}; =20 int bigendian(void) { @@ -400,6 +408,94 @@ put_tracepoints_path(struct tracepoint_path *tps) } } =20 +static struct tracepoint_path *tracepoint_id_to_path(u64 config) +{ + struct tracepoint_path *path =3D NULL; + DIR *sys_dir, *evt_dir; + struct dirent *sys_dirent, *evt_dirent; + char id_buf[24]; + int fd; + u64 id; + char evt_path[MAXPATHLEN]; + char *dir_path; + + sys_dir =3D tracing_events__opendir(); + if (!sys_dir) + return NULL; + + for_each_subsystem(sys_dir, sys_dirent) { + dir_path =3D get_events_file(sys_dirent->d_name); + if (!dir_path) + continue; + evt_dir =3D opendir(dir_path); + if (!evt_dir) + goto next; + + for_each_event(dir_path, evt_dir, evt_dirent) { + + scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, + evt_dirent->d_name); + fd =3D open(evt_path, O_RDONLY); + if (fd < 0) + continue; + if (read(fd, id_buf, sizeof(id_buf)) < 0) { + close(fd); + continue; + } + close(fd); + id =3D atoll(id_buf); + if (id =3D=3D config) { + put_events_file(dir_path); + closedir(evt_dir); + closedir(sys_dir); + path =3D zalloc(sizeof(*path)); + if (!path) + return NULL; + if (asprintf(&path->system, "%.*s", + MAX_EVENT_LENGTH, sys_dirent->d_name) < 0) { + free(path); + return NULL; + } + if (asprintf(&path->name, "%.*s", + MAX_EVENT_LENGTH, evt_dirent->d_name) < 0) { + zfree(&path->system); + free(path); + return NULL; + } + return path; + } + } + closedir(evt_dir); +next: + put_events_file(dir_path); + } + + closedir(sys_dir); + return NULL; +} + +static struct tracepoint_path *tracepoint_name_to_path(const char *name) +{ + struct tracepoint_path *path =3D zalloc(sizeof(*path)); + char *str =3D strchr(name, ':'); + + if (path =3D=3D NULL || str =3D=3D NULL) { + free(path); + return NULL; + } + + path->system =3D strndup(name, str - name); + path->name =3D strdup(str+1); + + if (path->system =3D=3D NULL || path->name =3D=3D NULL) { + zfree(&path->system); + zfree(&path->name); + zfree(&path); + } + + return path; +} + static struct tracepoint_path * get_tracepoints_path(struct list_head *pattrs) { diff --git a/tools/perf/util/tracepoint.c b/tools/perf/util/tracepoint.c new file mode 100644 index 000000000000..89ef56c43311 --- /dev/null +++ b/tools/perf/util/tracepoint.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "tracepoint.h" + +#include +#include +#include +#include +#include + +#include + +int tp_event_has_id(const char *dir_path, struct dirent *evt_dir) +{ + char evt_path[MAXPATHLEN]; + int fd; + + snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, evt_dir->d_name); + fd =3D open(evt_path, O_RDONLY); + if (fd < 0) + return -EINVAL; + close(fd); + + return 0; +} + +/* + * Check whether event is in /tracing/events + */ +int is_valid_tracepoint(const char *event_string) +{ + DIR *sys_dir, *evt_dir; + struct dirent *sys_dirent, *evt_dirent; + char evt_path[MAXPATHLEN]; + char *dir_path; + + sys_dir =3D tracing_events__opendir(); + if (!sys_dir) + return 0; + + for_each_subsystem(sys_dir, sys_dirent) { + dir_path =3D get_events_file(sys_dirent->d_name); + if (!dir_path) + continue; + evt_dir =3D opendir(dir_path); + if (!evt_dir) + goto next; + + for_each_event(dir_path, evt_dir, evt_dirent) { + snprintf(evt_path, MAXPATHLEN, "%s:%s", + sys_dirent->d_name, evt_dirent->d_name); + if (!strcmp(evt_path, event_string)) { + closedir(evt_dir); + closedir(sys_dir); + return 1; + } + } + closedir(evt_dir); +next: + put_events_file(dir_path); + } + closedir(sys_dir); + return 0; +} diff --git a/tools/perf/util/tracepoint.h b/tools/perf/util/tracepoint.h new file mode 100644 index 000000000000..c4a110fe87d7 --- /dev/null +++ b/tools/perf/util/tracepoint.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_TRACEPOINT_H +#define __PERF_TRACEPOINT_H + +#include +#include + +int tp_event_has_id(const char *dir_path, struct dirent *evt_dir); + +#define for_each_event(dir_path, evt_dir, evt_dirent) \ + while ((evt_dirent =3D readdir(evt_dir)) !=3D NULL) \ + if (evt_dirent->d_type =3D=3D DT_DIR && \ + (strcmp(evt_dirent->d_name, ".")) && \ + (strcmp(evt_dirent->d_name, "..")) && \ + (!tp_event_has_id(dir_path, evt_dirent))) + +#define for_each_subsystem(sys_dir, sys_dirent) \ + while ((sys_dirent =3D readdir(sys_dir)) !=3D NULL) \ + if (sys_dirent->d_type =3D=3D DT_DIR && \ + (strcmp(sys_dirent->d_name, ".")) && \ + (strcmp(sys_dirent->d_name, ".."))) + +int is_valid_tracepoint(const char *event_string); + +#endif /* __PERF_TRACEPOINT_H */ --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC9FEC433FE for ; Mon, 3 Oct 2022 07:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbiJCHVd (ORCPT ); Mon, 3 Oct 2022 03:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbiJCHU0 (ORCPT ); Mon, 3 Oct 2022 03:20:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6177345055; Mon, 3 Oct 2022 00:15:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2BCCAB80E6F; Mon, 3 Oct 2022 07:15:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64550C433C1; Mon, 3 Oct 2022 07:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781302; bh=H8NSv4Yp6M0l5IM5gn6zFbLZ8bwMJjfE/e6JlieoE6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDSOkY9UKW2dF7xcgWUqldVwPVhMWTzgsPfy1WZ6OSYlwnISDR9uHZP8kHXhXO8NN 3kBqEs6zwoSoIGyJWvB68TVtceJ7poI62NkBGPNDXP4TDsoBRJN5Yx3HxqM4+VBR48 NXpsyNu4APlVeNQJGvGlnglLU/SQZOxmWTd8GItk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Ammy , Kan Liang , Xing Zhengjun , Ian Rogers , Alexander Shishkin , Andi Kleen , Ingo Molnar , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 071/101] perf print-events: Fix "perf list" can not display the PMU prefix for some hybrid cache events Date: Mon, 3 Oct 2022 09:11:07 +0200 Message-Id: <20221003070726.234620614@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhengjun Xing [ Upstream commit e28c07871c3f2107e316c2590d4703496bd114f4 ] Some hybrid hardware cache events are only available on one CPU PMU. For example, 'L1-dcache-load-misses' is only available on cpu_core. We have supported in the perf list clearly reporting this info, the function works fine before but recently the argument "config" in API is_event_supported() is changed from "u64" to "unsigned int" which caused a regression, the "perf list" then can not display the PMU prefix for some hybrid cache events. For the hybrid systems, the PMU type ID is stored at config[63:32], define config to "unsigned int" will miss the PMU type ID information, then the regression happened, the config should be defined as "u64". Before: # ./perf list |grep "Hardware cache event" L1-dcache-load-misses [Hardware cache event] L1-dcache-loads [Hardware cache event] L1-dcache-stores [Hardware cache event] L1-icache-load-misses [Hardware cache event] L1-icache-loads [Hardware cache event] LLC-load-misses [Hardware cache event] LLC-loads [Hardware cache event] LLC-store-misses [Hardware cache event] LLC-stores [Hardware cache event] branch-load-misses [Hardware cache event] branch-loads [Hardware cache event] dTLB-load-misses [Hardware cache event] dTLB-loads [Hardware cache event] dTLB-store-misses [Hardware cache event] dTLB-stores [Hardware cache event] iTLB-load-misses [Hardware cache event] node-load-misses [Hardware cache event] node-loads [Hardware cache event] After: # ./perf list |grep "Hardware cache event" L1-dcache-loads [Hardware cache event] L1-dcache-stores [Hardware cache event] L1-icache-load-misses [Hardware cache event] LLC-load-misses [Hardware cache event] LLC-loads [Hardware cache event] LLC-store-misses [Hardware cache event] LLC-stores [Hardware cache event] branch-load-misses [Hardware cache event] branch-loads [Hardware cache event] cpu_atom/L1-icache-loads/ [Hardware cache event] cpu_core/L1-dcache-load-misses/ [Hardware cache event] cpu_core/node-load-misses/ [Hardware cache event] cpu_core/node-loads/ [Hardware cache event] dTLB-load-misses [Hardware cache event] dTLB-loads [Hardware cache event] dTLB-store-misses [Hardware cache event] dTLB-stores [Hardware cache event] iTLB-load-misses [Hardware cache event] Fixes: 9b7c7728f4e4ba8d ("perf parse-events: Break out tracepoint and print= ing") Reported-by: Yi Ammy Reviewed-by: Kan Liang Signed-off-by: Xing Zhengjun Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ian Rogers Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20220923030013.3726410-1-zhengjun.xing@linu= x.intel.com Signed-off-by: Arnaldo Carvalho de Melo Stable-dep-of: 71c86cda750b ("perf parse-events: Remove "not supported" hyb= rid cache events") Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/util/print-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c index ba1ab5134685..04050d4f6db8 100644 --- a/tools/perf/util/print-events.c +++ b/tools/perf/util/print-events.c @@ -239,7 +239,7 @@ void print_sdt_events(const char *subsys_glob, const ch= ar *event_glob, strlist__delete(sdtlist); } =20 -static bool is_event_supported(u8 type, unsigned int config) +static bool is_event_supported(u8 type, u64 config) { bool ret =3D true; int open_return; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68FE4C433F5 for ; Mon, 3 Oct 2022 07:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbiJCHXG (ORCPT ); Mon, 3 Oct 2022 03:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJCHWA (ORCPT ); Mon, 3 Oct 2022 03:22:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C3BD3719B; Mon, 3 Oct 2022 00:16:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4283160FA2; Mon, 3 Oct 2022 07:15:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22FEAC433C1; Mon, 3 Oct 2022 07:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781305; bh=D9GUw/I8M0RpPlgzTGnaHM/QY41l6Py1J4baPAW2qN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yh5OmXW7zijpSvYC9zy6Iee+VRhcQrnNyeVoXiDtgN1QDNLNdkPilawHAnj30GX/E 6Ctcd3OpchJNggt/vXVDP5+mXIehNh+2WPqADtAqxSx1Z9YjThTzWCA9OoJhcdfSt9 Odqp6SJ21BG1E7UxPorB5IQwK5TknGOngLXw3SyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Ammy , Kan Liang , Xing Zhengjun , Ian Rogers , Alexander Shishkin , Andi Kleen , Ingo Molnar , Jin Yao , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 072/101] perf parse-events: Remove "not supported" hybrid cache events Date: Mon, 3 Oct 2022 09:11:08 +0200 Message-Id: <20221003070726.258674812@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhengjun Xing [ Upstream commit 71c86cda750b001100e0d6dc04a88449b7381a59 ] By default, we create two hybrid cache events, one is for cpu_core, and another is for cpu_atom. But Some hybrid hardware cache events are only available on one CPU PMU. For example, the 'L1-dcache-load-misses' is only available on cpu_core, while the 'L1-icache-loads' is only available on cpu_atom. We need to remove "not supported" hybrid cache events. By extending is_event_supported() to global API and using it to check if the hybrid cache events are supported before being created, we can remove the "not supported" hybrid cache events. Before: # ./perf stat -e L1-dcache-load-misses,L1-icache-loads -a sleep 1 Performance counter stats for 'system wide': 52,570 cpu_core/L1-dcache-load-misses/ cpu_atom/L1-dcache-load-misses/ cpu_core/L1-icache-loads/ 1,471,817 cpu_atom/L1-icache-loads/ 1.004915229 seconds time elapsed After: # ./perf stat -e L1-dcache-load-misses,L1-icache-loads -a sleep 1 Performance counter stats for 'system wide': 54,510 cpu_core/L1-dcache-load-misses/ 1,441,286 cpu_atom/L1-icache-loads/ 1.005114281 seconds time elapsed Fixes: 30def61f64bac5f5 ("perf parse-events: Create two hybrid cache events= ") Reported-by: Yi Ammy Reviewed-by: Kan Liang Signed-off-by: Xing Zhengjun Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ingo Molnar Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20220923030013.3726410-2-zhengjun.xing@linu= x.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/util/parse-events-hybrid.c | 21 ++++++++++++--- tools/perf/util/parse-events.c | 39 +++++++++++++++++++++++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/print-events.c | 39 --------------------------- 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/tools/perf/util/parse-events-hybrid.c b/tools/perf/util/parse-= events-hybrid.c index 284f8eabd3b9..7c9f9150bad5 100644 --- a/tools/perf/util/parse-events-hybrid.c +++ b/tools/perf/util/parse-events-hybrid.c @@ -33,7 +33,8 @@ static void config_hybrid_attr(struct perf_event_attr *at= tr, * If the PMU type ID is 0, the PERF_TYPE_RAW will be applied. */ attr->type =3D type; - attr->config =3D attr->config | ((__u64)pmu_type << PERF_PMU_TYPE_SHIFT); + attr->config =3D (attr->config & PERF_HW_EVENT_MASK) | + ((__u64)pmu_type << PERF_PMU_TYPE_SHIFT); } =20 static int create_event_hybrid(__u32 config_type, int *idx, @@ -48,13 +49,25 @@ static int create_event_hybrid(__u32 config_type, int *= idx, __u64 config =3D attr->config; =20 config_hybrid_attr(attr, config_type, pmu->type); + + /* + * Some hybrid hardware cache events are only available on one CPU + * PMU. For example, the 'L1-dcache-load-misses' is only available + * on cpu_core, while the 'L1-icache-loads' is only available on + * cpu_atom. We need to remove "not supported" hybrid cache events. + */ + if (attr->type =3D=3D PERF_TYPE_HW_CACHE + && !is_event_supported(attr->type, attr->config)) + return 0; + evsel =3D parse_events__add_event_hybrid(list, idx, attr, name, metric_id, pmu, config_terms); - if (evsel) + if (evsel) { evsel->pmu_name =3D strdup(pmu->name); - else + if (!evsel->pmu_name) + return -ENOMEM; + } else return -ENOMEM; - attr->type =3D type; attr->config =3D config; return 0; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 3acf7452572c..b51c646c212e 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -29,6 +29,7 @@ #include "util/parse-events-hybrid.h" #include "util/pmu-hybrid.h" #include "tracepoint.h" +#include "thread_map.h" =20 #define MAX_NAME_LEN 100 =20 @@ -158,6 +159,44 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX= ] =3D { #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) =20 +bool is_event_supported(u8 type, u64 config) +{ + bool ret =3D true; + int open_return; + struct evsel *evsel; + struct perf_event_attr attr =3D { + .type =3D type, + .config =3D config, + .disabled =3D 1, + }; + struct perf_thread_map *tmap =3D thread_map__new_by_tid(0); + + if (tmap =3D=3D NULL) + return false; + + evsel =3D evsel__new(&attr); + if (evsel) { + open_return =3D evsel__open(evsel, NULL, tmap); + ret =3D open_return >=3D 0; + + if (open_return =3D=3D -EACCES) { + /* + * This happens if the paranoid value + * /proc/sys/kernel/perf_event_paranoid is set to 2 + * Re-run with exclude_kernel set; we don't do that + * by default as some ARM machines do not support it. + * + */ + evsel->core.attr.exclude_kernel =3D 1; + ret =3D evsel__open(evsel, NULL, tmap) >=3D 0; + } + evsel__delete(evsel); + } + + perf_thread_map__put(tmap); + return ret; +} + const char *event_type(int type) { switch (type) { diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index ba9fa3ddaf6e..fd97bb74559e 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -19,6 +19,7 @@ struct option; struct perf_pmu; =20 bool have_tracepoints(struct list_head *evlist); +bool is_event_supported(u8 type, u64 config); =20 const char *event_type(int type); =20 diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c index 04050d4f6db8..c4d5d87fae2f 100644 --- a/tools/perf/util/print-events.c +++ b/tools/perf/util/print-events.c @@ -22,7 +22,6 @@ #include "probe-file.h" #include "string2.h" #include "strlist.h" -#include "thread_map.h" #include "tracepoint.h" #include "pfm.h" #include "pmu-hybrid.h" @@ -239,44 +238,6 @@ void print_sdt_events(const char *subsys_glob, const c= har *event_glob, strlist__delete(sdtlist); } =20 -static bool is_event_supported(u8 type, u64 config) -{ - bool ret =3D true; - int open_return; - struct evsel *evsel; - struct perf_event_attr attr =3D { - .type =3D type, - .config =3D config, - .disabled =3D 1, - }; - struct perf_thread_map *tmap =3D thread_map__new_by_tid(0); - - if (tmap =3D=3D NULL) - return false; - - evsel =3D evsel__new(&attr); - if (evsel) { - open_return =3D evsel__open(evsel, NULL, tmap); - ret =3D open_return >=3D 0; - - if (open_return =3D=3D -EACCES) { - /* - * This happens if the paranoid value - * /proc/sys/kernel/perf_event_paranoid is set to 2 - * Re-run with exclude_kernel set; we don't do that - * by default as some ARM machines do not support it. - * - */ - evsel->core.attr.exclude_kernel =3D 1; - ret =3D evsel__open(evsel, NULL, tmap) >=3D 0; - } - evsel__delete(evsel); - } - - perf_thread_map__put(tmap); - return ret; -} - int print_hwcache_events(const char *event_glob, bool name_only) { unsigned int type, op, i, evt_i =3D 0, evt_num =3D 0, npmus =3D 0; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 564BEC433F5 for ; Mon, 3 Oct 2022 07:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbiJCHWW (ORCPT ); Mon, 3 Oct 2022 03:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbiJCHVO (ORCPT ); Mon, 3 Oct 2022 03:21:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195F33A154; Mon, 3 Oct 2022 00:16:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AFA9EB80E6E; Mon, 3 Oct 2022 07:15:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 220E5C433D6; Mon, 3 Oct 2022 07:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781308; bh=04BfXMHc19jYcL4jRRwrsqf5+yxgbjS2EabHMDMeab8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pg5Z2yvi3/aX3nvbQVcUWypZArOmLK/iF0zP8upJfGbm2BOWnr5J0akMnf7nv4LF8 +vjlWCdM4IVCPF/nm1f80aFHzfNtwQh2oUe6bkT38nnlZXJBPlUfvOvKrgsCMm0o/+ Ht+N/5Ot/PTq8Cp0bKmgbq9xjrxItM40TwfDd8MA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peilin Ye , Jakub Kicinski , Sasha Levin , syzbot+dcd3e13cf4472f2e0ba1@syzkaller.appspotmail.com Subject: [PATCH 5.19 073/101] usbnet: Fix memory leak in usbnet_disconnect() Date: Mon, 3 Oct 2022 09:11:09 +0200 Message-Id: <20221003070726.281805365@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peilin Ye [ Upstream commit a43206156263fbaf1f2b7f96257441f331e91bb7 ] Currently usbnet_disconnect() unanchors and frees all deferred URBs using usb_scuttle_anchored_urbs(), which does not free urb->context, causing a memory leak as reported by syzbot. Use a usb_get_from_anchor() while loop instead, similar to what we did in commit 19cfe912c37b ("Bluetooth: btusb: Fix memory leak in play_deferred"). Also free urb->sg. Reported-and-tested-by: syzbot+dcd3e13cf4472f2e0ba1@syzkaller.appspotmail.c= om Fixes: 69ee472f2706 ("usbnet & cdc-ether: Autosuspend for online devices") Fixes: 638c5115a794 ("USBNET: support DMA SG") Signed-off-by: Peilin Ye Link: https://lore.kernel.org/r/20220923042551.2745-1-yepeilin.cs@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/usb/usbnet.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 0ed09bb91c44..bccf63aac6cd 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1601,6 +1601,7 @@ void usbnet_disconnect (struct usb_interface *intf) struct usbnet *dev; struct usb_device *xdev; struct net_device *net; + struct urb *urb; =20 dev =3D usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); @@ -1617,7 +1618,11 @@ void usbnet_disconnect (struct usb_interface *intf) net =3D dev->net; unregister_netdev (net); =20 - usb_scuttle_anchored_urbs(&dev->deferred); + while ((urb =3D usb_get_from_anchor(&dev->deferred))) { + dev_kfree_skb(urb->context); + kfree(urb->sg); + usb_free_urb(urb); + } =20 if (dev->driver_info->unbind) dev->driver_info->unbind(dev, intf); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DF7CC433FE for ; Mon, 3 Oct 2022 07:22:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiJCHWL (ORCPT ); Mon, 3 Oct 2022 03:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiJCHVK (ORCPT ); Mon, 3 Oct 2022 03:21:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DFD45F46; Mon, 3 Oct 2022 00:16:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7AB89B80E6C; Mon, 3 Oct 2022 07:15:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E568EC433D6; Mon, 3 Oct 2022 07:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781311; bh=bKy5Cde+7OWsqG4lZVIiuQf01w1vkn4w1XQSMbK7Hrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xSS9iSUg2jCOkB2MH8rZhJ5lux15XKPzgnZKO+pzyLu/lm4Un7g9DtIj+HLx69gpk +a9JEZf0UmwEC5xpN/pEEop8fkHDpN+VvQtVHhP8jzGp6c+gJr4ff+/WhPS9dDUAaD Yh0ACm0LCcjIU3jhPAA2dJPe2f/pNvQQV0/i99Fo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 074/101] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Date: Mon, 3 Oct 2022 09:11:10 +0200 Message-Id: <20221003070726.305230889@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua [ Upstream commit 6e23ec0ba92d426c77a73a9ccab16346e5e0ef49 ] nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params to avoid possible refcount leak when tcf_ct_flow_table_get fails. Fixes: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone") Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220923020046.8021-1-hbh25y@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/sched/act_ct.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index e013253b10d1..4d44a1bf4a04 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1393,7 +1393,7 @@ static int tcf_ct_init(struct net *net, struct nlattr= *nla, =20 err =3D tcf_ct_flow_table_get(params); if (err) - goto cleanup; + goto cleanup_params; =20 spin_lock_bh(&c->tcf_lock); goto_ch =3D tcf_action_set_ctrlact(*a, parm->action, goto_ch); @@ -1408,6 +1408,9 @@ static int tcf_ct_init(struct net *net, struct nlattr= *nla, =20 return res; =20 +cleanup_params: + if (params->tmpl) + nf_ct_put(params->tmpl); cleanup: if (goto_ch) tcf_chain_put_by_act(goto_ch); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03496C433FE for ; Mon, 3 Oct 2022 07:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbiJCHWv (ORCPT ); Mon, 3 Oct 2022 03:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbiJCHVy (ORCPT ); Mon, 3 Oct 2022 03:21:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A181F635; Mon, 3 Oct 2022 00:16:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F58FB80E70; Mon, 3 Oct 2022 07:15:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94953C433D6; Mon, 3 Oct 2022 07:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781313; bh=g8ezt+zIuqYm6KOhw3hbjL5xc69Nj8LJANjkzGatBMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wN1e+CB67xIZwmePHSaFyH1EJD2rw6YVJw/r8Cjigfh/f7igxSa0ff2Og0Y23xxv8 raamNsNqo9pE7ZXpdAHrI0UG41k34IqXczsL0AVpIHLlyFjjX+yRCsGW9tRNB3CLX/ U7d7n+d1+5wwW5mJsI5mDFdWkglDMBmmvSuFehCQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rafael Mendonca , Rahul Lakkireddy , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 075/101] cxgb4: fix missing unlock on ETHOFLD desc collect fail path Date: Mon, 3 Oct 2022 09:11:11 +0200 Message-Id: <20221003070726.328982280@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Rafael Mendonca [ Upstream commit c635ebe8d911a93bd849a9419b01a58783de76f1 ] The label passed to the QDESC_GET for the ETHOFLD TXQ, RXQ, and FLQ, is the 'out' one, which skips the 'out_unlock' label, and thus doesn't unlock the 'uld_mutex' before returning. Additionally, since commit 5148e5950c67 ("cxgb4: add EOTID tracking and software context dump"), the access to these ETHOFLD hardware queues should be protected by the 'mqprio_mutex' instead. Fixes: 2d0cb84dd973 ("cxgb4: add ETHOFLD hardware queue support") Fixes: 5148e5950c67 ("cxgb4: add EOTID tracking and software context dump") Signed-off-by: Rafael Mendonca Reviewed-by: Rahul Lakkireddy Link: https://lore.kernel.org/r/20220922175109.764898-1-rafaelmendsr@gmail.= com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- .../net/ethernet/chelsio/cxgb4/cudbg_lib.c | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/e= thernet/chelsio/cxgb4/cudbg_lib.c index a7f291c89702..557c591a6ce3 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c @@ -14,6 +14,7 @@ #include "cudbg_entity.h" #include "cudbg_lib.h" #include "cudbg_zlib.h" +#include "cxgb4_tc_mqprio.h" =20 static const u32 t6_tp_pio_array[][IREG_NUM_ELEM] =3D { {0x7e40, 0x7e44, 0x020, 28}, /* t6_tp_pio_regs_20_to_3b */ @@ -3458,7 +3459,7 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init, for (i =3D 0; i < utxq->ntxq; i++) QDESC_GET_TXQ(&utxq->uldtxq[i].q, cudbg_uld_txq_to_qtype(j), - out_unlock); + out_unlock_uld); } } =20 @@ -3475,7 +3476,7 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init, for (i =3D 0; i < urxq->nrxq; i++) QDESC_GET_RXQ(&urxq->uldrxq[i].rspq, cudbg_uld_rxq_to_qtype(j), - out_unlock); + out_unlock_uld); } =20 /* ULD FLQ */ @@ -3487,7 +3488,7 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init, for (i =3D 0; i < urxq->nrxq; i++) QDESC_GET_FLQ(&urxq->uldrxq[i].fl, cudbg_uld_flq_to_qtype(j), - out_unlock); + out_unlock_uld); } =20 /* ULD CIQ */ @@ -3500,29 +3501,34 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_ini= t, for (i =3D 0; i < urxq->nciq; i++) QDESC_GET_RXQ(&urxq->uldrxq[base + i].rspq, cudbg_uld_ciq_to_qtype(j), - out_unlock); + out_unlock_uld); } } + mutex_unlock(&uld_mutex); + + if (!padap->tc_mqprio) + goto out; =20 + mutex_lock(&padap->tc_mqprio->mqprio_mutex); /* ETHOFLD TXQ */ if (s->eohw_txq) for (i =3D 0; i < s->eoqsets; i++) QDESC_GET_TXQ(&s->eohw_txq[i].q, - CUDBG_QTYPE_ETHOFLD_TXQ, out); + CUDBG_QTYPE_ETHOFLD_TXQ, out_unlock_mqprio); =20 /* ETHOFLD RXQ and FLQ */ if (s->eohw_rxq) { for (i =3D 0; i < s->eoqsets; i++) QDESC_GET_RXQ(&s->eohw_rxq[i].rspq, - CUDBG_QTYPE_ETHOFLD_RXQ, out); + CUDBG_QTYPE_ETHOFLD_RXQ, out_unlock_mqprio); =20 for (i =3D 0; i < s->eoqsets; i++) QDESC_GET_FLQ(&s->eohw_rxq[i].fl, - CUDBG_QTYPE_ETHOFLD_FLQ, out); + CUDBG_QTYPE_ETHOFLD_FLQ, out_unlock_mqprio); } =20 -out_unlock: - mutex_unlock(&uld_mutex); +out_unlock_mqprio: + mutex_unlock(&padap->tc_mqprio->mqprio_mutex); =20 out: qdesc_info->qdesc_entry_size =3D sizeof(*qdesc_entry); @@ -3559,6 +3565,10 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init, #undef QDESC_GET =20 return rc; + +out_unlock_uld: + mutex_unlock(&uld_mutex); + goto out; } =20 int cudbg_collect_flash(struct cudbg_init *pdbg_init, --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEBE7C433FE for ; Mon, 3 Oct 2022 07:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbiJCHXP (ORCPT ); Mon, 3 Oct 2022 03:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbiJCHWC (ORCPT ); Mon, 3 Oct 2022 03:22:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C965491E8; Mon, 3 Oct 2022 00:16:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E14BAB80E72; Mon, 3 Oct 2022 07:15:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 494D2C433C1; Mon, 3 Oct 2022 07:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781316; bh=jdFspMelz2PECi8IFmkcgEzHOd+qwcCZ0ciiD/c7lnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kjlHZaMSXmjtLmwKcLuK+a2IyZi7NnFEf7V5nWQBgXltFrrY46ToOFJjQS+S+28Il y9xMfK26OA2XD2Svn0BR5EK/PkoGPdBSnJd1f/JZLPFHaskoskS/cknrZ+OBZvB4cI lWsIOleWC2vh9gRnENHFZShl8wSJ0/PfWdEzWxHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Wu , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 076/101] net/mlxbf_gige: Fix an IS_ERR() vs NULL bug in mlxbf_gige_mdio_probe Date: Mon, 3 Oct 2022 09:11:12 +0200 Message-Id: <20221003070726.351598932@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peng Wu [ Upstream commit 4774db8dfc6a2e6649920ebb2fc8e2f062c2080d ] The devm_ioremap() function returns NULL on error, it doesn't return error pointers. Fixes: 3a1a274e933f ("mlxbf_gige: compute MDIO period based on i1clk") Signed-off-by: Peng Wu Link: https://lore.kernel.org/r/20220923023640.116057-1-wupeng58@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c b/d= rivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c index 4aeb927c3715..aa780b1614a3 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c @@ -246,8 +246,8 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev,= struct mlxbf_gige *priv) } =20 priv->clk_io =3D devm_ioremap(dev, res->start, resource_size(res)); - if (IS_ERR(priv->clk_io)) - return PTR_ERR(priv->clk_io); + if (!priv->clk_io) + return -ENOMEM; =20 mlxbf_gige_mdio_cfg(priv); =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAC03C433FE for ; Mon, 3 Oct 2022 07:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbiJCHtd (ORCPT ); Mon, 3 Oct 2022 03:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbiJCHsi (ORCPT ); Mon, 3 Oct 2022 03:48:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2D3FE7; Mon, 3 Oct 2022 00:27:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A6EC0B80E6C; Mon, 3 Oct 2022 07:16:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20896C43144; Mon, 3 Oct 2022 07:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781405; bh=+U+Ga5hQnijwqZqWQUookyMbcHRjXH8QxCTKWBR81FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kKfH3v6AxzETsGtdq0+LYtYoOBN76v/fqs39+Wi57/hwolqFlNUi3yKTT7DANU9/f uLD0aly9U2IWyplTd4cpCjPTYAiTB36vmNubmcfGP/yKnqo0H16tRdK3gw915CWo5C 8QUE9WGs1FVZIxR4Og5eIffguXr8RWy+1tUIMdDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.19 077/101] nvme: Fix IOC_PR_CLEAR and IOC_PR_RELEASE ioctls for nvme devices Date: Mon, 3 Oct 2022 09:11:13 +0200 Message-Id: <20221003070726.374456384@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Michael Kelley [ Upstream commit c292a337d0e45a292c301e3cd51c35aa0ae91e95 ] The IOC_PR_CLEAR and IOC_PR_RELEASE ioctls are non-functional on NVMe devices because the nvme_pr_clear() and nvme_pr_release() functions set the IEKEY field incorrectly. The IEKEY field should be set only when the key is zero (i.e, not specified). The current code does it backwards. Furthermore, the NVMe spec describes the persistent reservation "clear" function as an option on the reservation release command. The current implementation of nvme_pr_clear() erroneously uses the reservation register command. Fix these errors. Note that NVMe version 1.3 and later specify that setting the IEKEY field will return an error of Invalid Field in Command. The fix will set IEKEY when the key is zero, which is appropriate as these ioctls consider a zero key to be "unspecified", and the intention of the spec change is to require a valid key. Tested on a version 1.4 PCI NVMe device in an Azure VM. Fixes: 1673f1f08c88 ("nvme: move block_device_operations and ns/ctrl freein= g to common code") Fixes: 1d277a637a71 ("NVMe: Add persistent reservation ops") Signed-off-by: Michael Kelley Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/nvme/host/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 6d76fc608b74..326ad33537ed 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2069,14 +2069,14 @@ static int nvme_pr_preempt(struct block_device *bde= v, u64 old, u64 new, =20 static int nvme_pr_clear(struct block_device *bdev, u64 key) { - u32 cdw10 =3D 1 | (key ? 1 << 3 : 0); + u32 cdw10 =3D 1 | (key ? 0 : 1 << 3); =20 - return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register); + return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release); } =20 static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_typ= e type) { - u32 cdw10 =3D nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0); + u32 cdw10 =3D nvme_pr_type(type) << 8 | (key ? 0 : 1 << 3); =20 return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release); } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD1B3C433F5 for ; Mon, 3 Oct 2022 07:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbiJCHrj (ORCPT ); Mon, 3 Oct 2022 03:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232041AbiJCHqh (ORCPT ); Mon, 3 Oct 2022 03:46:37 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA0DD58DC4; Mon, 3 Oct 2022 00:26:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B6AC3CE0AF2; Mon, 3 Oct 2022 07:15:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABBFEC433C1; Mon, 3 Oct 2022 07:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781341; bh=QsVzm4UnJU00HSy+y4xHA6N+Zm1x/epxlo64wto3STg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d3lvvye41e3LbGZlsn2hHp2c5+QgiFPp3X87TY4iwe04if13H/8Cm8V8BKftR2Hyv Usz5bizwI9FZ5tp+JxnWfJ7qeJQvxY/uCKLgfe+QT6rJEP2FtA9X1LFMdxEQHdQaGn I5HezdTJl01+mLBAIMO5jKgtpQKo41eDFDT0P1QQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tamizh Chelvam Raja , Johannes Berg , Sasha Levin Subject: [PATCH 5.19 078/101] wifi: cfg80211: fix MCS divisor value Date: Mon, 3 Oct 2022 09:11:14 +0200 Message-Id: <20221003070726.398846620@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tamizh Chelvam Raja [ Upstream commit 64e966d1e84b29c9fa916cfeaabbf4013703942e ] The Bitrate for HE/EHT MCS6 is calculated wrongly due to the incorrect MCS divisor value for mcs6. Fix it with the proper value. previous mcs_divisor value =3D (11769/6144) =3D 1.915527 fixed mcs_divisor value =3D (11377/6144) =3D 1.851725 Fixes: 9c97c88d2f4b ("cfg80211: Add support to calculate and report 4096-QA= M HE rates") Signed-off-by: Tamizh Chelvam Raja Link: https://lore.kernel.org/r/20220908181034.9936-1-quic_tamizhr@quicinc.= com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/wireless/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/wireless/util.c b/net/wireless/util.c index b7257862e0fe..28b7f120501a 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1361,7 +1361,7 @@ static u32 cfg80211_calculate_bitrate_he(struct rate_= info *rate) 25599, /* 4.166666... */ 17067, /* 2.777777... */ 12801, /* 2.083333... */ - 11769, /* 1.851851... */ + 11377, /* 1.851725... */ 10239, /* 1.666666... */ 8532, /* 1.388888... */ 7680, /* 1.250000... */ @@ -1444,7 +1444,7 @@ static u32 cfg80211_calculate_bitrate_eht(struct rate= _info *rate) 25599, /* 4.166666... */ 17067, /* 2.777777... */ 12801, /* 2.083333... */ - 11769, /* 1.851851... */ + 11377, /* 1.851725... */ 10239, /* 1.666666... */ 8532, /* 1.388888... */ 7680, /* 1.250000... */ --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAC29C433F5 for ; Mon, 3 Oct 2022 07:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231872AbiJCHk3 (ORCPT ); Mon, 3 Oct 2022 03:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbiJCHjK (ORCPT ); Mon, 3 Oct 2022 03:39:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D9043324; Mon, 3 Oct 2022 00:24:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3134060FAD; Mon, 3 Oct 2022 07:16:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 448DBC433C1; Mon, 3 Oct 2022 07:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781370; bh=AhF3IPHzjP5s2TpdE7/z5hWjApd2lVlsJBeDIajOxyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xj88Ikd9Ho1FzbOB3neys7U4hSXejHIXpcvGK9+JsCwTSQANvI3dITBlhLPEDzFMG DNd2dKBMWDNaYIwFCbPu+4cFatBd5yoKlV+E0gEOQLBbQZQRdL18YjBlZABh5FSDx1 6f2AmiUUCWoMqlJK9pdWSiWfJY1Q5o0wjKxOwb5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Markus Theil , Stanislaw Gruszka , Hans de Goede , Johannes Berg , Sasha Levin Subject: [PATCH 5.19 079/101] wifi: mac80211: fix regression with non-QoS drivers Date: Mon, 3 Oct 2022 09:11:15 +0200 Message-Id: <20221003070726.421483359@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hans de Goede [ Upstream commit d873697ef2b7e1b6fdd8e9d449d9354bd5d29a4a ] Commit 10cb8e617560 ("mac80211: enable QoS support for nl80211 ctrl port") changed ieee80211_tx_control_port() to aways call __ieee80211_select_queue() without checking local->hw.queues. __ieee80211_select_queue() returns a queue-id between 0 and 3, which means that now ieee80211_tx_control_port() may end up setting the queue-mapping for a skb to a value higher then local->hw.queues if local->hw.queues is less then 4. Specifically this is a problem for ralink rt2500-pci cards where local->hw.queues is 2. There this causes rt2x00queue_get_tx_queue() to return NULL and the following error to be logged: "ieee80211 phy0: rt2x00mac_tx: Error - Attempt to send packet over invalid queue 2", after which association with the AP fails. Other callers of __ieee80211_select_queue() skip calling it when local->hw.queues < IEEE80211_NUM_ACS, add the same check to ieee80211_tx_control_port(). This fixes ralink rt2500-pci and similar cards when less then 4 tx-queues no longer working. Fixes: 10cb8e617560 ("mac80211: enable QoS support for nl80211 ctrl port") Cc: Markus Theil Suggested-by: Stanislaw Gruszka Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20220918192052.443529-1-hdegoede@redhat.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/mac80211/tx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 3cd24d8170d3..f6f09a3506aa 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -5761,6 +5761,9 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, st= ruct net_device *dev, skb_reset_network_header(skb); skb_reset_mac_header(skb); =20 + if (local->hw.queues < IEEE80211_NUM_ACS) + goto start_xmit; + /* update QoS header to prioritize control port frames if possible, * priorization also happens for control port frames send over * AF_PACKET @@ -5776,6 +5779,7 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, st= ruct net_device *dev, =20 rcu_read_unlock(); =20 +start_xmit: /* mutex lock is only needed for incrementing the cookie counter */ mutex_lock(&local->mtx); =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 907FAC433F5 for ; Mon, 3 Oct 2022 07:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbiJCHXJ (ORCPT ); Mon, 3 Oct 2022 03:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbiJCHWA (ORCPT ); Mon, 3 Oct 2022 03:22:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B2F540BCA; Mon, 3 Oct 2022 00:16:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 308BA60FB0; Mon, 3 Oct 2022 07:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 111ABC433C1; Mon, 3 Oct 2022 07:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781386; bh=zGDXXWjBRzum85yqymXEZW4/fwzlt0QXmVsfjdeyMFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TY5Zp14kxY4UEct7FeVwtpJKtR+NuzEWFZgN76hxAT72M5/CIloiGwpSJJOrihQ+i +ipf4Gqh8jwkWeGXM02MjKHVGxoSwS1g3fvOWUdD2mobb+cxwKgEBVzVhESubRAay7 PYKUHxJTO0GCUVSfBkNF6L/i3w9IfLO6CsHHX3hU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Pouiller?= , Johannes Berg , Peter Seiderer , Kalle Valo , =?UTF-8?q?Pawe=C5=82=20Lenkow?= , Lech Perczak , Felix Fietkau , Johannes Berg , Sasha Levin , =?UTF-8?q?Krzysztof=20Drobi=C5=84ski?= Subject: [PATCH 5.19 080/101] wifi: mac80211: fix memory corruption in minstrel_ht_update_rates() Date: Mon, 3 Oct 2022 09:11:16 +0200 Message-Id: <20221003070726.445270935@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawe=C5=82 Lenkow [ Upstream commit be92292b90bfdc31f332c962882b6d3ea0285fdf ] During our testing of WFM200 module over SDIO on i.MX6Q-based platform, we discovered a memory corruption on the system, tracing back to the wfx driver. Using kfence, it was possible to trace it back to the root cause, which is hw->max_rates set to 8 in wfx_init_common, while the maximum defined by IEEE80211_TX_TABLE_SIZE is 4. This causes array out-of-bounds writes during updates of the rate table, as seen below: BUG: KFENCE: memory corruption in kfree_rcu_work+0x320/0x36c Corrupted memory at 0xe0a4ffe0 [ 0x03 0x03 0x03 0x03 0x01 0x00 0x00 0x02 0x02 0x02 0x09 0x00 0x21 0xbb 0xbb 0xbb ] (in kfence-#81): kfree_rcu_work+0x320/0x36c process_one_work+0x3ec/0x920 worker_thread+0x60/0x7a4 kthread+0x174/0x1b4 ret_from_fork+0x14/0x2c 0x0 kfence-#81: 0xe0a4ffc0-0xe0a4ffdf, size=3D32, cache=3Dkmalloc-64 allocated by task 297 on cpu 0 at 631.039555s: minstrel_ht_update_rates+0x38/0x2b0 [mac80211] rate_control_tx_status+0xb4/0x148 [mac80211] ieee80211_tx_status_ext+0x364/0x1030 [mac80211] ieee80211_tx_status+0xe0/0x118 [mac80211] ieee80211_tasklet_handler+0xb0/0xe0 [mac80211] tasklet_action_common.constprop.0+0x11c/0x148 __do_softirq+0x1a4/0x61c irq_exit+0xcc/0x104 call_with_stack+0x18/0x20 __irq_svc+0x80/0xb0 wq_worker_sleeping+0x10/0x100 wq_worker_sleeping+0x10/0x100 schedule+0x50/0xe0 schedule_timeout+0x2e0/0x474 wait_for_completion+0xdc/0x1ec mmc_wait_for_req_done+0xc4/0xf8 mmc_io_rw_extended+0x3b4/0x4ec sdio_io_rw_ext_helper+0x290/0x384 sdio_memcpy_toio+0x30/0x38 wfx_sdio_copy_to_io+0x88/0x108 [wfx] wfx_data_write+0x88/0x1f0 [wfx] bh_work+0x1c8/0xcc0 [wfx] process_one_work+0x3ec/0x920 worker_thread+0x60/0x7a4 kthread+0x174/0x1b4 ret_from_fork+0x14/0x2c 0x0 After discussion on the wireless mailing list it was clarified that the issue has been introduced by: commit ee0e16ab756a ("mac80211: minstrel_ht: fill all requested rates") and fix shall be in minstrel_ht_update_rates in rc80211_minstrel_ht.c. Fixes: ee0e16ab756a ("mac80211: minstrel_ht: fill all requested rates") Link: https://lore.kernel.org/all/12e5adcd-8aed-f0f7-70cc-4fb7b656b829@caml= ingroup.com/ Link: https://lore.kernel.org/linux-wireless/20220915131445.30600-1-lech.pe= rczak@camlingroup.com/ Cc: J=C3=A9r=C3=B4me Pouiller Cc: Johannes Berg Cc: Peter Seiderer Cc: Kalle Valo Cc: Krzysztof Drobi=C5=84ski , Signed-off-by: Pawe=C5=82 Lenkow Signed-off-by: Lech Perczak Reviewed-by: Peter Seiderer Reviewed-by: J=C3=A9r=C3=B4me Pouiller Acked-by: Felix Fietkau Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- net/mac80211/rc80211_minstrel_ht.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_mins= trel_ht.c index 5f27e6746762..788a82f9c74d 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "rate.h" #include "sta_info.h" @@ -1550,6 +1551,7 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, st= ruct minstrel_ht_sta *mi) { struct ieee80211_sta_rates *rates; int i =3D 0; + int max_rates =3D min_t(int, mp->hw->max_rates, IEEE80211_TX_RATE_TABLE_S= IZE); =20 rates =3D kzalloc(sizeof(*rates), GFP_ATOMIC); if (!rates) @@ -1559,10 +1561,10 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, = struct minstrel_ht_sta *mi) minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]); =20 /* Fill up remaining, keep one entry for max_probe_rate */ - for (; i < (mp->hw->max_rates - 1); i++) + for (; i < (max_rates - 1); i++) minstrel_ht_set_rate(mp, mi, rates, i, mi->max_tp_rate[i]); =20 - if (i < mp->hw->max_rates) + if (i < max_rates) minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate); =20 if (i < IEEE80211_TX_RATE_TABLE_SIZE) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA879C4332F for ; Mon, 3 Oct 2022 07:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231603AbiJCHjc (ORCPT ); Mon, 3 Oct 2022 03:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbiJCHhI (ORCPT ); Mon, 3 Oct 2022 03:37:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A2C543FF; Mon, 3 Oct 2022 00:23:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id E15EFCE0B11; Mon, 3 Oct 2022 07:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4053C433C1; Mon, 3 Oct 2022 07:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781389; bh=WZC/dCR8VP/ltTJFeAkVwSkyuWMGKYRxmnWKzQ4k+jA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2fnZM+HsutuhoB2G8uekjE1yQNGVoR4pXxRmPyhnsJipaC0HmnER16DxjSqS3tbKs YSn/FtlOdvQb7fmJLMDwyHke+iJC5w5EUwLTrwxb285LSmBYYSrb2wTB3wx6ZTXrnj YDZFN2jl5sm3xQnhdNaildjXCbBQyb8aMBOkO1HY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junxiao Chang , Voon Weifeng , Jimmy JS Chen , "Looi, Hong Aun" , Paolo Abeni , Sasha Levin , Looi@vger.kernel.org Subject: [PATCH 5.19 081/101] net: stmmac: power up/down serdes in stmmac_open/release Date: Mon, 3 Oct 2022 09:11:17 +0200 Message-Id: <20221003070726.468731280@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Junxiao Chang [ Upstream commit 49725ffc15fc4e9fae68c55b691fd25168cbe5c1 ] This commit fixes DMA engine reset timeout issue in suspend/resume with ADLink I-Pi SMARC Plus board which dmesg shows: ... [ 54.678271] PM: suspend exit [ 54.754066] intel-eth-pci 0000:00:1d.2 enp0s29f2: PHY [stmmac-3:01] driv= er [Maxlinear Ethernet GPY215B] (irq=3DPOLL) [ 54.755808] intel-eth-pci 0000:00:1d.2 enp0s29f2: Register MEM_TYPE_PAGE= _POOL RxQ-0 ... [ 54.780482] intel-eth-pci 0000:00:1d.2 enp0s29f2: Register MEM_TYPE_PAGE= _POOL RxQ-7 [ 55.784098] intel-eth-pci 0000:00:1d.2: Failed to reset the dma [ 55.784111] intel-eth-pci 0000:00:1d.2 enp0s29f2: stmmac_hw_setup: DMA e= ngine initialization failed [ 55.784115] intel-eth-pci 0000:00:1d.2 enp0s29f2: stmmac_open: Hw setup = failed ... The issue is related with serdes which impacts clock. There is serdes in ADLink I-Pi SMARC board ethernet controller. Please refer to commit b9663b7ca6ff78 ("net: stmmac: Enable SERDES power up/down sequence") for detial. When issue is reproduced, DMA engine clock is not ready because serdes is not powered up. To reproduce DMA engine reset timeout issue with hardware which has serdes in GBE controller, install Ubuntu. In Ubuntu GUI, click "Power Off/Log Out" -> "Suspend" menu, it disables network interface, then goes to sleep mode. When it wakes up, it enables network interface again. Stmmac driver is called in this way: 1. stmmac_release: Stop network interface. In this function, it disables DMA engine and network interface; 2. stmmac_suspend: It is called in kernel suspend flow. But because network interface has been disabled(netif_running(ndev) is false), it does nothing and returns directly; 3. System goes into S3 or S0ix state. Some time later, system is waken up by keyboard or mouse; 4. stmmac_resume: It does nothing because network interface has been disabled; 5. stmmac_open: It is called to enable network interace again. DMA engine is initialized in this API, but serdes is not power on so there will be DMA engine reset timeout issue. Similarly, serdes powerdown should be added in stmmac_release. Network interface might be disabled by cmd "ifconfig eth0 down", DMA engine, phy and mac have been disabled in ndo_stop callback, serdes should be powered down as well. It doesn't make sense that serdes is on while other components have been turned off. If ethernet interface is in enabled state(netif_running(ndev) is true) before suspend/resume, the issue couldn't be reproduced because serdes could be powered up in stmmac_resume. Because serdes_powerup is added in stmmac_open, it doesn't need to be called in probe function. Fixes: b9663b7ca6ff78 ("net: stmmac: Enable SERDES power up/down sequence") Signed-off-by: Junxiao Chang Reviewed-by: Voon Weifeng Tested-by: Jimmy JS Chen Tested-by: Looi, Hong Aun Link: https://lore.kernel.org/r/20220923050448.1220250-1-junxiao.chang@inte= l.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 78f11dabca05..8d9272f01e31 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3704,6 +3704,15 @@ static int stmmac_open(struct net_device *dev) goto init_error; } =20 + if (priv->plat->serdes_powerup) { + ret =3D priv->plat->serdes_powerup(dev, priv->plat->bsp_priv); + if (ret < 0) { + netdev_err(priv->dev, "%s: Serdes powerup failed\n", + __func__); + goto init_error; + } + } + ret =3D stmmac_hw_setup(dev, true); if (ret < 0) { netdev_err(priv->dev, "%s: Hw setup failed\n", __func__); @@ -3793,6 +3802,10 @@ static int stmmac_release(struct net_device *dev) /* Disable the MAC Rx/Tx */ stmmac_mac_set(priv, priv->ioaddr, false); =20 + /* Powerdown Serdes if there is */ + if (priv->plat->serdes_powerdown) + priv->plat->serdes_powerdown(dev, priv->plat->bsp_priv); + netif_carrier_off(dev); =20 stmmac_release_ptp(priv); @@ -7158,14 +7171,6 @@ int stmmac_dvr_probe(struct device *device, goto error_netdev_register; } =20 - if (priv->plat->serdes_powerup) { - ret =3D priv->plat->serdes_powerup(ndev, - priv->plat->bsp_priv); - - if (ret < 0) - goto error_serdes_powerup; - } - #ifdef CONFIG_DEBUG_FS stmmac_init_fs(ndev); #endif @@ -7180,8 +7185,6 @@ int stmmac_dvr_probe(struct device *device, =20 return ret; =20 -error_serdes_powerup: - unregister_netdev(ndev); error_netdev_register: phylink_destroy(priv->phylink); error_xpcs_setup: --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D04C6C433F5 for ; Mon, 3 Oct 2022 07:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232354AbiJCHqj (ORCPT ); Mon, 3 Oct 2022 03:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231994AbiJCHok (ORCPT ); Mon, 3 Oct 2022 03:44:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8F24AD53; Mon, 3 Oct 2022 00:25:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 45CEBB80E70; Mon, 3 Oct 2022 07:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A606DC433C1; Mon, 3 Oct 2022 07:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781392; bh=9GHz39Vw2ZDGh+vvOpOkYfaybB4vERsm7/BJqAdzA8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C/+BBxVYcP8WGajMR/lBq7b/j1IVLS1dxVVRN0mnhrSLaO3HxLCrtQsujEzvQMGui Gkhny88YAq3mywsfrkORDT2Zx5MbkQsoBdDopDj7sHNbYbwX0c/SmpJQxlvJUT+X1w gYUZtxVoPcKEIf/CMysdnPCQMPj+HIGnGNvXjS3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Lukas Wunner , Florian Fainelli , Xiaolei Wang , Paolo Abeni , Sasha Levin Subject: [PATCH 5.19 082/101] net: phy: Dont WARN for PHY_UP state in mdio_bus_phy_resume() Date: Mon, 3 Oct 2022 09:11:18 +0200 Message-Id: <20221003070726.492865819@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lukas Wunner [ Upstream commit ea64cdfad124922c931633e39287c5a31a9b14a1 ] Commit 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() state") introduced a WARN() on resume from system sleep if a PHY is not in PHY_HALTED state. Commit 6dbe852c379f ("net: phy: Don't WARN for PHY_READY state in mdio_bus_phy_resume()") added an exemption for PHY_READY state from the WARN(). It turns out PHY_UP state needs to be exempted as well because the following may happen on suspend: mdio_bus_phy_suspend() phy_stop_machine() phydev->state =3D PHY_UP # if (phydev->state >=3D PHY_UP) Fixes: 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() = state") Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski Link: https://lore.kernel.org/netdev/2b1a1588-505e-dff3-301d-bfc1fb14d685@s= amsung.com/ Signed-off-by: Lukas Wunner Acked-by: Florian Fainelli Cc: Xiaolei Wang Link: https://lore.kernel.org/r/8128fdb51eeebc9efbf3776a4097363a1317aaf1.16= 63905575.git.lukas@wunner.de Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/phy/phy_device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f90a21781d8d..adc9d97cbb88 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -316,11 +316,13 @@ static __maybe_unused int mdio_bus_phy_resume(struct = device *dev) =20 phydev->suspended_by_mdio_bus =3D 0; =20 - /* If we manged to get here with the PHY state machine in a state neither - * PHY_HALTED nor PHY_READY this is an indication that something went wro= ng - * and we should most likely be using MAC managed PM and we are not. + /* If we managed to get here with the PHY state machine in a state + * neither PHY_HALTED, PHY_READY nor PHY_UP, this is an indication + * that something went wrong and we should most likely be using + * MAC managed PM, but we are not. */ - WARN_ON(phydev->state !=3D PHY_HALTED && phydev->state !=3D PHY_READY); + WARN_ON(phydev->state !=3D PHY_HALTED && phydev->state !=3D PHY_READY && + phydev->state !=3D PHY_UP); =20 ret =3D phy_init_hw(phydev); if (ret < 0) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0BF5C433F5 for ; Mon, 3 Oct 2022 07:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232315AbiJCHqQ (ORCPT ); Mon, 3 Oct 2022 03:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232369AbiJCHoS (ORCPT ); Mon, 3 Oct 2022 03:44:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530D7578BC; Mon, 3 Oct 2022 00:25:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 041D0B80E6A; Mon, 3 Oct 2022 07:16:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5912FC433D7; Mon, 3 Oct 2022 07:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781394; bh=Q2DSGgW3V97mUVZbM74pZ1v1QXO/1Mv1ZjONQCfoQp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l01XHjcZSpDhHFTkyGUnTR1s1ubNPGMPXZm47+m/vrH3iYSwkdEUe5MmAf8UJ+2ve 44WLXqlGJ1+WIel5EBSQ9oSQiQVcD8arAU3p6cSZKR4erzOZlcD8pSsSvHKIgLZXuQ nbnoXDoTqDdO8R46/fMtiYSUtP745CD5JJAVXBnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Yufen , Paolo Abeni , Sasha Levin Subject: [PATCH 5.19 083/101] selftests: Fix the if conditions of in test_extra_filter() Date: Mon, 3 Oct 2022 09:11:19 +0200 Message-Id: <20221003070726.517168159@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wang Yufen [ Upstream commit bc7a319844891746135dc1f34ab9df78d636a3ac ] The socket 2 bind the addr in use, bind should fail with EADDRINUSE. So if bind success or errno !=3D EADDRINUSE, testcase should be failed. Fixes: 3ca8e4029969 ("soreuseport: BPF selection functional test") Signed-off-by: Wang Yufen Link: https://lore.kernel.org/r/1663916557-10730-1-git-send-email-wangyufen= @huawei.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/testing/selftests/net/reuseport_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/se= lftests/net/reuseport_bpf.c index 072d709c96b4..65aea27d761c 100644 --- a/tools/testing/selftests/net/reuseport_bpf.c +++ b/tools/testing/selftests/net/reuseport_bpf.c @@ -328,7 +328,7 @@ static void test_extra_filter(const struct test_params = p) if (bind(fd1, addr, sockaddr_size())) error(1, errno, "failed to bind recv socket 1"); =20 - if (!bind(fd2, addr, sockaddr_size()) && errno !=3D EADDRINUSE) + if (!bind(fd2, addr, sockaddr_size()) || errno !=3D EADDRINUSE) error(1, errno, "bind socket 2 should fail with EADDRINUSE"); =20 free(addr); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2C89C433FE for ; Mon, 3 Oct 2022 07:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbiJCHpI (ORCPT ); Mon, 3 Oct 2022 03:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbiJCHnt (ORCPT ); Mon, 3 Oct 2022 03:43:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D107E313; Mon, 3 Oct 2022 00:25:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ADAFAB80E78; Mon, 3 Oct 2022 07:16:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12F22C43153; Mon, 3 Oct 2022 07:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781397; bh=+Eh0FR3P7JlbZLnwfRf9SovtPWzp+J1uM2l8v4qKYxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHd/e1vT9ba2X5XxXVz9v1v2L6MLv1g4WZQsGh6FEIDn7yk9Sf99Z+O/vs6+uv7sl VY6HytbZ1OYebye6/MBUD8ACbJ11pEvaSI1VpjRzhAaK03NiR9mD6bCEQ7RDy+lmxu 7vZBsjFyMiX/wY5ofpPPiMhTgL15zapCOzHkr6FE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , George Kuruvinakunnel , Tony Nguyen , Sasha Levin Subject: [PATCH 5.19 084/101] ice: xsk: change batched Tx descriptor cleaning Date: Mon, 3 Oct 2022 09:11:20 +0200 Message-Id: <20221003070726.540245054@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maciej Fijalkowski [ Upstream commit 29322791bc8b4f42fc65734840826e3ddc30921e ] AF_XDP Tx descriptor cleaning in ice driver currently works in a "lazy" way - descriptors are not cleaned immediately after send. We rather hold on with cleaning until we see that free space in ring drops below particular threshold. This was supposed to reduce the amount of unnecessary work related to cleaning and instead of keeping the ring empty, ring was rather saturated. In AF_XDP realm cleaning Tx descriptors implies producing them to CQ. This is a way of letting know user space that particular descriptor has been sent, as John points out in [0]. We tried to implement serial descriptor cleaning which would be used in conjunction with batched cleaning but it made code base more convoluted and probably harder to maintain in future. Therefore we step away from batched cleaning in a current form in favor of an approach where we set RS bit on every last descriptor from a batch and clean always at the beginning of ice_xmit_zc(). This means that we give up a bit of Tx performance, but this doesn't hurt l2fwd scenario which is way more meaningful than txonly as this can be treaten as AF_XDP based packet generator. l2fwd is not hurt due to the fact that Tx side is much faster than Rx and Rx is the one that has to catch Tx up. FWIW Tx descriptors are still produced in a batched way. [0]: https://lore.kernel.org/bpf/62b0a20232920_3573208ab@john.notmuch/ Fixes: 126cdfe1007a ("ice: xsk: Improve AF_XDP ZC Tx and use batching API") Signed-off-by: Maciej Fijalkowski Tested-by: George Kuruvinakunnel Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 143 +++++++++------------- drivers/net/ethernet/intel/ice/ice_xsk.h | 7 +- 3 files changed, 64 insertions(+), 88 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethern= et/intel/ice/ice_txrx.c index 97453d1dfafe..dd2285d4bef4 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c @@ -1467,7 +1467,7 @@ int ice_napi_poll(struct napi_struct *napi, int budge= t) bool wd; =20 if (tx_ring->xsk_pool) - wd =3D ice_xmit_zc(tx_ring, ICE_DESC_UNUSED(tx_ring), budget); + wd =3D ice_xmit_zc(tx_ring); else if (ice_ring_is_xdp(tx_ring)) wd =3D true; else diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/etherne= t/intel/ice/ice_xsk.c index 03ce85f6e6df..8833b66b4e54 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -788,69 +788,57 @@ ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, st= ruct ice_tx_buf *tx_buf) } =20 /** - * ice_clean_xdp_irq_zc - Reclaim resources after transmit completes on XD= P ring - * @xdp_ring: XDP ring to clean - * @napi_budget: amount of descriptors that NAPI allows us to clean - * - * Returns count of cleaned descriptors + * ice_clean_xdp_irq_zc - produce AF_XDP descriptors to CQ + * @xdp_ring: XDP Tx ring */ -static u16 ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring, int napi_bud= get) +static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring) { - u16 tx_thresh =3D ICE_RING_QUARTER(xdp_ring); - int budget =3D napi_budget / tx_thresh; - u16 next_dd =3D xdp_ring->next_dd; - u16 ntc, cleared_dds =3D 0; - - do { - struct ice_tx_desc *next_dd_desc; - u16 desc_cnt =3D xdp_ring->count; - struct ice_tx_buf *tx_buf; - u32 xsk_frames; - u16 i; - - next_dd_desc =3D ICE_TX_DESC(xdp_ring, next_dd); - if (!(next_dd_desc->cmd_type_offset_bsz & - cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) - break; + u16 ntc =3D xdp_ring->next_to_clean; + struct ice_tx_desc *tx_desc; + u16 cnt =3D xdp_ring->count; + struct ice_tx_buf *tx_buf; + u16 xsk_frames =3D 0; + u16 last_rs; + int i; =20 - cleared_dds++; - xsk_frames =3D 0; - if (likely(!xdp_ring->xdp_tx_active)) { - xsk_frames =3D tx_thresh; - goto skip; - } + last_rs =3D xdp_ring->next_to_use ? xdp_ring->next_to_use - 1 : cnt - 1; + tx_desc =3D ICE_TX_DESC(xdp_ring, last_rs); + if ((tx_desc->cmd_type_offset_bsz & + cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) { + if (last_rs >=3D ntc) + xsk_frames =3D last_rs - ntc + 1; + else + xsk_frames =3D last_rs + cnt - ntc + 1; + } =20 - ntc =3D xdp_ring->next_to_clean; + if (!xsk_frames) + return; =20 - for (i =3D 0; i < tx_thresh; i++) { - tx_buf =3D &xdp_ring->tx_buf[ntc]; + if (likely(!xdp_ring->xdp_tx_active)) + goto skip; =20 - if (tx_buf->raw_buf) { - ice_clean_xdp_tx_buf(xdp_ring, tx_buf); - tx_buf->raw_buf =3D NULL; - } else { - xsk_frames++; - } + ntc =3D xdp_ring->next_to_clean; + for (i =3D 0; i < xsk_frames; i++) { + tx_buf =3D &xdp_ring->tx_buf[ntc]; =20 - ntc++; - if (ntc >=3D xdp_ring->count) - ntc =3D 0; + if (tx_buf->raw_buf) { + ice_clean_xdp_tx_buf(xdp_ring, tx_buf); + tx_buf->raw_buf =3D NULL; + } else { + xsk_frames++; } + + ntc++; + if (ntc >=3D xdp_ring->count) + ntc =3D 0; + } skip: - xdp_ring->next_to_clean +=3D tx_thresh; - if (xdp_ring->next_to_clean >=3D desc_cnt) - xdp_ring->next_to_clean -=3D desc_cnt; - if (xsk_frames) - xsk_tx_completed(xdp_ring->xsk_pool, xsk_frames); - next_dd_desc->cmd_type_offset_bsz =3D 0; - next_dd =3D next_dd + tx_thresh; - if (next_dd >=3D desc_cnt) - next_dd =3D tx_thresh - 1; - } while (--budget); - - xdp_ring->next_dd =3D next_dd; - - return cleared_dds * tx_thresh; + tx_desc->cmd_type_offset_bsz =3D 0; + xdp_ring->next_to_clean +=3D xsk_frames; + if (xdp_ring->next_to_clean >=3D cnt) + xdp_ring->next_to_clean -=3D cnt; + if (xsk_frames) + xsk_tx_completed(xdp_ring->xsk_pool, xsk_frames); } =20 /** @@ -885,7 +873,6 @@ static void ice_xmit_pkt(struct ice_tx_ring *xdp_ring, = struct xdp_desc *desc, static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp_ring, struct xdp_de= sc *descs, unsigned int *total_bytes) { - u16 tx_thresh =3D ICE_RING_QUARTER(xdp_ring); u16 ntu =3D xdp_ring->next_to_use; struct ice_tx_desc *tx_desc; u32 i; @@ -905,13 +892,6 @@ static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp= _ring, struct xdp_desc *de } =20 xdp_ring->next_to_use =3D ntu; - - if (xdp_ring->next_to_use > xdp_ring->next_rs) { - tx_desc =3D ICE_TX_DESC(xdp_ring, xdp_ring->next_rs); - tx_desc->cmd_type_offset_bsz |=3D - cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S); - xdp_ring->next_rs +=3D tx_thresh; - } } =20 /** @@ -924,7 +904,6 @@ static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp_= ring, struct xdp_desc *de static void ice_fill_tx_hw_ring(struct ice_tx_ring *xdp_ring, struct xdp_d= esc *descs, u32 nb_pkts, unsigned int *total_bytes) { - u16 tx_thresh =3D ICE_RING_QUARTER(xdp_ring); u32 batched, leftover, i; =20 batched =3D ALIGN_DOWN(nb_pkts, PKTS_PER_BATCH); @@ -933,54 +912,54 @@ static void ice_fill_tx_hw_ring(struct ice_tx_ring *x= dp_ring, struct xdp_desc *d ice_xmit_pkt_batch(xdp_ring, &descs[i], total_bytes); for (; i < batched + leftover; i++) ice_xmit_pkt(xdp_ring, &descs[i], total_bytes); +} =20 - if (xdp_ring->next_to_use > xdp_ring->next_rs) { - struct ice_tx_desc *tx_desc; +/** + * ice_set_rs_bit - set RS bit on last produced descriptor (one behind cur= rent NTU) + * @xdp_ring: XDP ring to produce the HW Tx descriptors on + */ +static void ice_set_rs_bit(struct ice_tx_ring *xdp_ring) +{ + u16 ntu =3D xdp_ring->next_to_use ? xdp_ring->next_to_use - 1 : xdp_ring-= >count - 1; + struct ice_tx_desc *tx_desc; =20 - tx_desc =3D ICE_TX_DESC(xdp_ring, xdp_ring->next_rs); - tx_desc->cmd_type_offset_bsz |=3D - cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S); - xdp_ring->next_rs +=3D tx_thresh; - } + tx_desc =3D ICE_TX_DESC(xdp_ring, ntu); + tx_desc->cmd_type_offset_bsz |=3D + cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S); } =20 /** * ice_xmit_zc - take entries from XSK Tx ring and place them onto HW Tx r= ing * @xdp_ring: XDP ring to produce the HW Tx descriptors on - * @budget: number of free descriptors on HW Tx ring that can be used - * @napi_budget: amount of descriptors that NAPI allows us to clean * * Returns true if there is no more work that needs to be done, false othe= rwise */ -bool ice_xmit_zc(struct ice_tx_ring *xdp_ring, u32 budget, int napi_budget) +bool ice_xmit_zc(struct ice_tx_ring *xdp_ring) { struct xdp_desc *descs =3D xdp_ring->xsk_pool->tx_descs; - u16 tx_thresh =3D ICE_RING_QUARTER(xdp_ring); u32 nb_pkts, nb_processed =3D 0; unsigned int total_bytes =3D 0; + int budget; + + ice_clean_xdp_irq_zc(xdp_ring); =20 - if (budget < tx_thresh) - budget +=3D ice_clean_xdp_irq_zc(xdp_ring, napi_budget); + budget =3D ICE_DESC_UNUSED(xdp_ring); + budget =3D min_t(u16, budget, ICE_RING_QUARTER(xdp_ring)); =20 nb_pkts =3D xsk_tx_peek_release_desc_batch(xdp_ring->xsk_pool, budget); if (!nb_pkts) return true; =20 if (xdp_ring->next_to_use + nb_pkts >=3D xdp_ring->count) { - struct ice_tx_desc *tx_desc; - nb_processed =3D xdp_ring->count - xdp_ring->next_to_use; ice_fill_tx_hw_ring(xdp_ring, descs, nb_processed, &total_bytes); - tx_desc =3D ICE_TX_DESC(xdp_ring, xdp_ring->next_rs); - tx_desc->cmd_type_offset_bsz |=3D - cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S); - xdp_ring->next_rs =3D tx_thresh - 1; xdp_ring->next_to_use =3D 0; } =20 ice_fill_tx_hw_ring(xdp_ring, &descs[nb_processed], nb_pkts - nb_processe= d, &total_bytes); =20 + ice_set_rs_bit(xdp_ring); ice_xdp_ring_update_tail(xdp_ring); ice_update_tx_ring_stats(xdp_ring, nb_pkts, total_bytes); =20 diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.h b/drivers/net/etherne= t/intel/ice/ice_xsk.h index 4edbe81eb646..6fa181f080ef 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.h +++ b/drivers/net/ethernet/intel/ice/ice_xsk.h @@ -26,13 +26,10 @@ bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, = u16 count); bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi); void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring); void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring); -bool ice_xmit_zc(struct ice_tx_ring *xdp_ring, u32 budget, int napi_budget= ); +bool ice_xmit_zc(struct ice_tx_ring *xdp_ring); int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc); #else -static inline bool -ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_ring, - u32 __always_unused budget, - int __always_unused napi_budget) +static inline bool ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_rin= g) { return false; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A1FC433FE for ; Mon, 3 Oct 2022 07:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbiJCH1n (ORCPT ); Mon, 3 Oct 2022 03:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbiJCH1F (ORCPT ); Mon, 3 Oct 2022 03:27:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B884C422E9; Mon, 3 Oct 2022 00:18:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48FEBB80E7D; Mon, 3 Oct 2022 07:16:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF7BCC433D6; Mon, 3 Oct 2022 07:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781400; bh=Igf9UU74ITk1IWqdl+JkpDC1/G783bDledmbtt7/jcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hoLPGvJ12UFYkOTibZ8vA3VZ7uBHO+MNcv2W8xfsDqEKOZ0B5cHRLLWTX245/zbu3 De8njpQhnGGCMEiIFDMDQvf4V3704/hOfvVuhcZGOThN7P9PPvaW8O/C8SggtiX9bA qnPB/TDn3j7x/c9Vhoi+cbQjUHkP0WOKJOl8aAjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alasdair McWilliam , Maciej Fijalkowski , George Kuruvinakunnel , Tony Nguyen , Sasha Levin Subject: [PATCH 5.19 085/101] ice: xsk: drop power of 2 ring size restriction for AF_XDP Date: Mon, 3 Oct 2022 09:11:21 +0200 Message-Id: <20221003070726.563402354@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maciej Fijalkowski [ Upstream commit b3056ae2b57858b02b376b3fed6077040caf14b4 ] We had multiple customers in the past months that reported commit 296f13ff3854 ("ice: xsk: Force rings to be sized to power of 2") makes them unable to use ring size of 8160 in conjunction with AF_XDP. Remove this restriction. Fixes: 296f13ff3854 ("ice: xsk: Force rings to be sized to power of 2") CC: Alasdair McWilliam Signed-off-by: Maciej Fijalkowski Tested-by: George Kuruvinakunnel Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_xsk.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/etherne= t/intel/ice/ice_xsk.c index 8833b66b4e54..056c904b83cc 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -392,13 +392,6 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk= _buff_pool *pool, u16 qid) goto failure; } =20 - if (!is_power_of_2(vsi->rx_rings[qid]->count) || - !is_power_of_2(vsi->tx_rings[qid]->count)) { - netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n"); - pool_failure =3D -EINVAL; - goto failure; - } - if_running =3D netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi); =20 if (if_running) { @@ -534,11 +527,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring= *rx_ring, u16 count) bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count) { u16 rx_thresh =3D ICE_RING_QUARTER(rx_ring); - u16 batched, leftover, i, tail_bumps; + u16 leftover, i, tail_bumps; =20 - batched =3D ALIGN_DOWN(count, rx_thresh); - tail_bumps =3D batched / rx_thresh; - leftover =3D count & (rx_thresh - 1); + tail_bumps =3D count / rx_thresh; + leftover =3D count - (tail_bumps * rx_thresh); =20 for (i =3D 0; i < tail_bumps; i++) if (!__ice_alloc_rx_bufs_zc(rx_ring, rx_thresh)) @@ -1037,14 +1029,16 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi) */ void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring) { - u16 count_mask =3D rx_ring->count - 1; u16 ntc =3D rx_ring->next_to_clean; u16 ntu =3D rx_ring->next_to_use; =20 - for ( ; ntc !=3D ntu; ntc =3D (ntc + 1) & count_mask) { + while (ntc !=3D ntu) { struct xdp_buff *xdp =3D *ice_xdp_buf(rx_ring, ntc); =20 xsk_buff_free(xdp); + ntc++; + if (ntc >=3D rx_ring->count) + ntc =3D 0; } } =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC0B9C433F5 for ; Mon, 3 Oct 2022 07:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbiJCHXa (ORCPT ); Mon, 3 Oct 2022 03:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbiJCHWe (ORCPT ); Mon, 3 Oct 2022 03:22:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF6A42ACB; Mon, 3 Oct 2022 00:16:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1EE62B80E81; Mon, 3 Oct 2022 07:16:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CE87C43147; Mon, 3 Oct 2022 07:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781402; bh=5P0xPnBni2NMZ7vC4rX45isOsYP7Y3Sw/60Evz320Gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1yud/V1ByErvgBhwzOuaFtg5w+V75tR8hss4kyyqcN8Si40EsIuBc/8ZQNyCiL+ab XX45eX3b7r1/Xq01ehQFbIQtBYrkADHeKuWZ9nCMX/QzUPJsigifBKhlYS8jCb3Txg rCv1Wtc+YVEYJPrfPPn8ihHkTdUsaTzRGit7iieE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Angus Chen , Jason Wang , "Michael S. Tsirkin" , Zhu Lingshan , Sasha Levin Subject: [PATCH 5.19 086/101] vdpa/ifcvf: fix the calculation of queuepair Date: Mon, 3 Oct 2022 09:11:22 +0200 Message-Id: <20221003070726.587974474@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Angus Chen [ Upstream commit db5db1a00d0816207be3a0166fcb4f523eaf3b52 ] The q_pair_id to address a queue pair in the lm bar should be calculated by queue_id / 2 rather than queue_id / nr_vring. Fixes: 2ddae773c93b ("vDPA/ifcvf: detect and use the onboard number of queu= es directly") Signed-off-by: Angus Chen Reviewed-by: Jason Wang Reviewed-by: Michael S. Tsirkin Acked-by: Zhu Lingshan Message-Id: <20220923091013.191-1-angus.chen@jaguarmicro.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/vdpa/ifcvf/ifcvf_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_bas= e.c index 48c4dadb0c7c..a4c1b985f79a 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.c +++ b/drivers/vdpa/ifcvf/ifcvf_base.c @@ -315,7 +315,7 @@ u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid) u32 q_pair_id; =20 ifcvf_lm =3D (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg; - q_pair_id =3D qid / hw->nr_vring; + q_pair_id =3D qid / 2; avail_idx_addr =3D &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2]; last_avail_idx =3D vp_ioread16(avail_idx_addr); =20 @@ -329,7 +329,7 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u1= 6 num) u32 q_pair_id; =20 ifcvf_lm =3D (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg; - q_pair_id =3D qid / hw->nr_vring; + q_pair_id =3D qid / 2; avail_idx_addr =3D &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2]; hw->vring[qid].last_avail_idx =3D num; vp_iowrite16(num, avail_idx_addr); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77D76C433F5 for ; Mon, 3 Oct 2022 07:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231169AbiJCH0W (ORCPT ); Mon, 3 Oct 2022 03:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiJCHYT (ORCPT ); Mon, 3 Oct 2022 03:24:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 239AC4BD01; Mon, 3 Oct 2022 00:18:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 04A20B80E6D; Mon, 3 Oct 2022 07:15:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 594A4C433C1; Mon, 3 Oct 2022 07:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781343; bh=tZEq8krVrXdmaDCQKRFN+XMzp6hIs7PuY3GdXvm/FO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DMk4OAbEJW8sn9WusQ/Dx2DJYnHmGbdmZDdiBwZZNDkmVqD1zq4zWRaAYXy4RU79v nPCrOXYDikbifev8YCWcIyjR2V3jCslfsEvmxRU8R/vtcrfmoR8C+YST8AasMzaO6b /dKydpBoBQw++2CEwC71RS1jPfcztxAQbfhQYm4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Courbot , Suwan Kim , "Michael S. Tsirkin" , Stefan Hajnoczi , Pankaj Raghav , Sasha Levin Subject: [PATCH 5.19 087/101] virtio-blk: Fix WARN_ON_ONCE in virtio_queue_rq() Date: Mon, 3 Oct 2022 09:11:23 +0200 Message-Id: <20221003070726.611489133@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Suwan Kim [ Upstream commit 37fafe6b61e4f15d977982635bb785f4e605f7cd ] If a request fails at virtio_queue_rqs(), it is inserted to requeue_list and passed to virtio_queue_rq(). Then blk_mq_start_request() can be called again at virtio_queue_rq() and trigger WARN_ON_ONCE like below trace because request state was already set to MQ_RQ_IN_FLIGHT in virtio_queue_rqs() despite the failure. [ 1.890468] ------------[ cut here ]------------ [ 1.890776] WARNING: CPU: 2 PID: 122 at block/blk-mq.c:1143 blk_mq_start_request+0x8a/0xe0 [ 1.891045] Modules linked in: [ 1.891250] CPU: 2 PID: 122 Comm: journal-offline Not tainted 5.19.0+ #44 [ 1.891504] Hardware name: ChromiumOS crosvm, BIOS 0 [ 1.891739] RIP: 0010:blk_mq_start_request+0x8a/0xe0 [ 1.891961] Code: 12 80 74 22 48 8b 4b 10 8b 89 64 01 00 00 8b 53 20 83 fa ff 75 08 ba 00 00 00 80 0b 53 24 c1 e1 10 09 d1 89 48 34 5b 41 5e c3 <0f> 0b eb b8 65 8b 05 2b 39 b6 7e 89 c0 48 0f a3 05 39 77 5b 01 0f [ 1.892443] RSP: 0018:ffffc900002777b0 EFLAGS: 00010202 [ 1.892673] RAX: 0000000000000000 RBX: ffff888004bc0000 RCX: 00000000000= 00000 [ 1.892952] RDX: 0000000000000000 RSI: ffff888003d7c200 RDI: ffff888004b= c0000 [ 1.893228] RBP: 0000000000000000 R08: 0000000000000001 R09: ffff888004b= c0100 [ 1.893506] R10: ffffffffffffffff R11: ffffffff8185ca10 R12: ffff888004b= c0000 [ 1.893797] R13: ffffc90000277900 R14: ffff888004ab2340 R15: ffff888003d= 86e00 [ 1.894060] FS: 00007ffa143a4640(0000) GS:ffff88807dd00000(0000) knlGS:0000000000000000 [ 1.894412] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1.894682] CR2: 00005648577d9088 CR3: 00000000053da004 CR4: 00000000001= 70ee0 [ 1.894953] Call Trace: [ 1.895139] [ 1.895303] virtblk_prep_rq+0x1e5/0x280 [ 1.895509] virtio_queue_rq+0x5c/0x310 [ 1.895710] ? virtqueue_add_sgs+0x95/0xb0 [ 1.895905] ? _raw_spin_unlock_irqrestore+0x16/0x30 [ 1.896133] ? virtio_queue_rqs+0x340/0x390 [ 1.896453] ? sbitmap_get+0xfa/0x220 [ 1.896678] __blk_mq_issue_directly+0x41/0x180 [ 1.896906] blk_mq_plug_issue_direct+0xd8/0x2c0 [ 1.897115] blk_mq_flush_plug_list+0x115/0x180 [ 1.897342] blk_add_rq_to_plug+0x51/0x130 [ 1.897543] blk_mq_submit_bio+0x3a1/0x570 [ 1.897750] submit_bio_noacct_nocheck+0x418/0x520 [ 1.897985] ? submit_bio_noacct+0x1e/0x260 [ 1.897989] ext4_bio_write_page+0x222/0x420 [ 1.898000] mpage_process_page_bufs+0x178/0x1c0 [ 1.899451] mpage_prepare_extent_to_map+0x2d2/0x440 [ 1.899603] ext4_writepages+0x495/0x1020 [ 1.899733] do_writepages+0xcb/0x220 [ 1.899871] ? __seccomp_filter+0x171/0x7e0 [ 1.900006] file_write_and_wait_range+0xcd/0xf0 [ 1.900167] ext4_sync_file+0x72/0x320 [ 1.900308] __x64_sys_fsync+0x66/0xa0 [ 1.900449] do_syscall_64+0x31/0x50 [ 1.900595] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 1.900747] RIP: 0033:0x7ffa16ec96ea [ 1.900883] Code: b8 4a 00 00 00 0f 05 48 3d 00 f0 ff ff 77 41 c3 48 83 ec 18 89 7c 24 0c e8 e3 02 f8 ff 8b 7c 24 0c 89 c2 b8 4a 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 43 03 f8 ff 8b 44 24 [ 1.901302] RSP: 002b:00007ffa143a3ac0 EFLAGS: 00000293 ORIG_RAX: 000000000000004a [ 1.901499] RAX: ffffffffffffffda RBX: 0000560277ec6fe0 RCX: 00007ffa16e= c96ea [ 1.901696] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000000= 00016 [ 1.901884] RBP: 0000560277ec5910 R08: 0000000000000000 R09: 00007ffa143= a4640 [ 1.902082] R10: 00007ffa16e4d39e R11: 0000000000000293 R12: 00005602773= f59e0 [ 1.902459] R13: 0000000000000000 R14: 00007fffbfc007ff R15: 00007ffa13b= a4000 [ 1.902763] [ 1.902877] ---[ end trace 0000000000000000 ]--- To avoid calling blk_mq_start_request() twice, This patch moves the execution of blk_mq_start_request() to the end of virtblk_prep_rq(). And instead of requeuing failed request to plug list in the error path of virtblk_add_req_batch(), it uses blk_mq_requeue_request() to change failed request state to MQ_RQ_IDLE. Then virtblk can safely handle the request on the next trial. Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()") Reported-by: Alexandre Courbot Tested-by: Alexandre Courbot Signed-off-by: Suwan Kim Message-Id: <20220830150153.12627-1-suwan.kim027@gmail.com> Signed-off-by: Michael S. Tsirkin Acked-by: Stefan Hajnoczi Reviewed-by: Pankaj Raghav Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/block/virtio_blk.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 59d6d5faf739..dcd639e58ff0 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -322,14 +322,14 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_= ctx *hctx, if (unlikely(status)) return status; =20 - blk_mq_start_request(req); - vbr->sg_table.nents =3D virtblk_map_data(hctx, req, vbr); if (unlikely(vbr->sg_table.nents < 0)) { virtblk_cleanup_cmd(req); return BLK_STS_RESOURCE; } =20 + blk_mq_start_request(req); + return BLK_STS_OK; } =20 @@ -391,8 +391,7 @@ static bool virtblk_prep_rq_batch(struct request *req) } =20 static bool virtblk_add_req_batch(struct virtio_blk_vq *vq, - struct request **rqlist, - struct request **requeue_list) + struct request **rqlist) { unsigned long flags; int err; @@ -408,7 +407,7 @@ static bool virtblk_add_req_batch(struct virtio_blk_vq = *vq, if (err) { virtblk_unmap_data(req, vbr); virtblk_cleanup_cmd(req); - rq_list_add(requeue_list, req); + blk_mq_requeue_request(req, true); } } =20 @@ -436,7 +435,7 @@ static void virtio_queue_rqs(struct request **rqlist) =20 if (!next || req->mq_hctx !=3D next->mq_hctx) { req->rq_next =3D NULL; - kick =3D virtblk_add_req_batch(vq, rqlist, &requeue_list); + kick =3D virtblk_add_req_batch(vq, rqlist); if (kick) virtqueue_notify(vq->vq); =20 --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46FAC433F5 for ; Mon, 3 Oct 2022 08:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbiJCIa1 (ORCPT ); Mon, 3 Oct 2022 04:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbiJCI36 (ORCPT ); Mon, 3 Oct 2022 04:29:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB126613B; Mon, 3 Oct 2022 01:03:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA3CD60F9F; Mon, 3 Oct 2022 07:15:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B31BC433D6; Mon, 3 Oct 2022 07:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781346; bh=yRBQe6PMJ2ERLuGkK9OKR07cUYELkHgG6mBeiC+z6fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3qUD4nsLDwFokZ0BC72jEGtrklI9V8NTBqCtjhyRZAnWibOH8Eqf2cGhiLvxU1n/ paC6pGfvGk+6wADZdrVhxTcbvl4mBPasxi38rOgcbtDLrSBGFsjQ1xHVqvkyDvma/P s5Yt3PSvkgYt+QIsx5NZHLh2vpmhbIgb7fklUiKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Cohen , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 5.19 088/101] vdpa/mlx5: Fix MQ to support non power of two num queues Date: Mon, 3 Oct 2022 09:11:24 +0200 Message-Id: <20221003070726.634609733@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eli Cohen [ Upstream commit a43ae8057cc154fd26a3a23c0e8643bef104d995 ] RQT objects require that a power of two value be configured for both rqt_max_size and rqt_actual size. For create_rqt, make sure to round up to the power of two the value of given by the user who created the vdpa device and given by ndev->rqt_size. The actual size is also rounded up to the power of two using the current number of VQs given by ndev->cur_num_vqs. Same goes with modify_rqt where we need to make sure act size is power of two based on the new number of QPs. Without this patch, attempt to create a device with non power of two QPs would result in error from firmware. Fixes: 52893733f2c5 ("vdpa/mlx5: Add multiqueue support") Signed-off-by: Eli Cohen Message-Id: <20220912125019.833708-1-elic@nvidia.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index e85c1d71f4ed..f527cbeb1169 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1297,6 +1297,8 @@ static void teardown_vq(struct mlx5_vdpa_net *ndev, s= truct mlx5_vdpa_virtqueue * =20 static int create_rqt(struct mlx5_vdpa_net *ndev) { + int rqt_table_size =3D roundup_pow_of_two(ndev->rqt_size); + int act_sz =3D roundup_pow_of_two(ndev->cur_num_vqs / 2); __be32 *list; void *rqtc; int inlen; @@ -1304,7 +1306,7 @@ static int create_rqt(struct mlx5_vdpa_net *ndev) int i, j; int err; =20 - inlen =3D MLX5_ST_SZ_BYTES(create_rqt_in) + ndev->rqt_size * MLX5_ST_SZ_B= YTES(rq_num); + inlen =3D MLX5_ST_SZ_BYTES(create_rqt_in) + rqt_table_size * MLX5_ST_SZ_B= YTES(rq_num); in =3D kzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM; @@ -1313,12 +1315,12 @@ static int create_rqt(struct mlx5_vdpa_net *ndev) rqtc =3D MLX5_ADDR_OF(create_rqt_in, in, rqt_context); =20 MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q); - MLX5_SET(rqtc, rqtc, rqt_max_size, ndev->rqt_size); + MLX5_SET(rqtc, rqtc, rqt_max_size, rqt_table_size); list =3D MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]); - for (i =3D 0, j =3D 0; i < ndev->rqt_size; i++, j +=3D 2) + for (i =3D 0, j =3D 0; i < act_sz; i++, j +=3D 2) list[i] =3D cpu_to_be32(ndev->vqs[j % ndev->cur_num_vqs].virtq_id); =20 - MLX5_SET(rqtc, rqtc, rqt_actual_size, ndev->rqt_size); + MLX5_SET(rqtc, rqtc, rqt_actual_size, act_sz); err =3D mlx5_vdpa_create_rqt(&ndev->mvdev, in, inlen, &ndev->res.rqtn); kfree(in); if (err) @@ -1331,6 +1333,7 @@ static int create_rqt(struct mlx5_vdpa_net *ndev) =20 static int modify_rqt(struct mlx5_vdpa_net *ndev, int num) { + int act_sz =3D roundup_pow_of_two(num / 2); __be32 *list; void *rqtc; int inlen; @@ -1338,7 +1341,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int= num) int i, j; int err; =20 - inlen =3D MLX5_ST_SZ_BYTES(modify_rqt_in) + ndev->rqt_size * MLX5_ST_SZ_B= YTES(rq_num); + inlen =3D MLX5_ST_SZ_BYTES(modify_rqt_in) + act_sz * MLX5_ST_SZ_BYTES(rq_= num); in =3D kzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM; @@ -1349,10 +1352,10 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, i= nt num) MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q); =20 list =3D MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]); - for (i =3D 0, j =3D 0; i < ndev->rqt_size; i++, j +=3D 2) + for (i =3D 0, j =3D 0; i < act_sz; i++, j =3D j + 2) list[i] =3D cpu_to_be32(ndev->vqs[j % num].virtq_id); =20 - MLX5_SET(rqtc, rqtc, rqt_actual_size, ndev->rqt_size); + MLX5_SET(rqtc, rqtc, rqt_actual_size, act_sz); err =3D mlx5_vdpa_modify_rqt(&ndev->mvdev, in, inlen, ndev->res.rqtn); kfree(in); if (err) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1481C433F5 for ; Mon, 3 Oct 2022 07:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbiJCH0t (ORCPT ); Mon, 3 Oct 2022 03:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbiJCHYk (ORCPT ); Mon, 3 Oct 2022 03:24:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB54E3FD64; Mon, 3 Oct 2022 00:18:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4463BB80E76; Mon, 3 Oct 2022 07:15:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB8E6C433D6; Mon, 3 Oct 2022 07:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781349; bh=YoajUM20gTB4qwbFyiuAFKO4hfeAyGhn+vIsU9/vtJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OqTXHR5BCfSR4bH7RAqaeqgUaV/tUMriG9EGo+9YRC0Da0qQuGiluu4cYY1aR9pL+ YFKErMmzWr+y0KDXZ0PrpZR7/UZuWbUj9+L1Gm2F7d/wzoT2CQVaMFK4Zn0aacIpBV puwcK7qLzaSURm84vnhd8zVYT+plRUxKMnuRqjrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Sasha Levin Subject: [PATCH 5.19 089/101] dont use __kernel_write() on kmap_local_page() Date: Mon, 3 Oct 2022 09:11:25 +0200 Message-Id: <20221003070726.658463729@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Al Viro [ Upstream commit 06bbaa6dc53cb72040db952053432541acb9adc7 ] passing kmap_local_page() result to __kernel_write() is unsafe - random ->write_iter() might (and 9p one does) get unhappy when passed ITER_KVEC with pointer that came from kmap_local_page(). Fix by providing a variant of __kernel_write() that takes an iov_iter from caller (__kernel_write() becomes a trivial wrapper) and adding dump_emit_page() that parallels dump_emit(), except that instead of __kernel_write() it uses __kernel_write_iter() with ITER_BVEC source. Fixes: 3159ed57792b "fs/coredump: use kmap_local_page()" Signed-off-by: Al Viro Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- fs/coredump.c | 38 +++++++++++++++++++++++++++++++++----- fs/internal.h | 3 +++ fs/read_write.c | 22 ++++++++++++++-------- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index ebc43f960b64..f1355e52614a 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -832,6 +832,38 @@ static int __dump_skip(struct coredump_params *cprm, s= ize_t nr) } } =20 +static int dump_emit_page(struct coredump_params *cprm, struct page *page) +{ + struct bio_vec bvec =3D { + .bv_page =3D page, + .bv_offset =3D 0, + .bv_len =3D PAGE_SIZE, + }; + struct iov_iter iter; + struct file *file =3D cprm->file; + loff_t pos =3D file->f_pos; + ssize_t n; + + if (cprm->to_skip) { + if (!__dump_skip(cprm, cprm->to_skip)) + return 0; + cprm->to_skip =3D 0; + } + if (cprm->written + PAGE_SIZE > cprm->limit) + return 0; + if (dump_interrupted()) + return 0; + iov_iter_bvec(&iter, WRITE, &bvec, 1, PAGE_SIZE); + n =3D __kernel_write_iter(cprm->file, &iter, &pos); + if (n !=3D PAGE_SIZE) + return 0; + file->f_pos =3D pos; + cprm->written +=3D PAGE_SIZE; + cprm->pos +=3D PAGE_SIZE; + + return 1; +} + int dump_emit(struct coredump_params *cprm, const void *addr, int nr) { if (cprm->to_skip) { @@ -863,7 +895,6 @@ int dump_user_range(struct coredump_params *cprm, unsig= ned long start, =20 for (addr =3D start; addr < start + len; addr +=3D PAGE_SIZE) { struct page *page; - int stop; =20 /* * To avoid having to allocate page tables for virtual address @@ -874,10 +905,7 @@ int dump_user_range(struct coredump_params *cprm, unsi= gned long start, */ page =3D get_dump_page(addr); if (page) { - void *kaddr =3D kmap_local_page(page); - - stop =3D !dump_emit(cprm, kaddr, PAGE_SIZE); - kunmap_local(kaddr); + int stop =3D !dump_emit_page(cprm, page); put_page(page); if (stop) return 0; diff --git a/fs/internal.h b/fs/internal.h index 87e96b9024ce..3e206d3e317c 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -16,6 +16,7 @@ struct shrink_control; struct fs_context; struct user_namespace; struct pipe_inode_info; +struct iov_iter; =20 /* * block/bdev.c @@ -221,3 +222,5 @@ ssize_t do_getxattr(struct user_namespace *mnt_userns, int setxattr_copy(const char __user *name, struct xattr_ctx *ctx); int do_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry, struct xattr_ctx *ctx); + +ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff= _t *pos); diff --git a/fs/read_write.c b/fs/read_write.c index 397da0236607..a0a3d35e2c0f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -509,14 +509,9 @@ static ssize_t new_sync_write(struct file *filp, const= char __user *buf, size_t } =20 /* caller is responsible for file_start_write/file_end_write */ -ssize_t __kernel_write(struct file *file, const void *buf, size_t count, l= off_t *pos) +ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff= _t *pos) { - struct kvec iov =3D { - .iov_base =3D (void *)buf, - .iov_len =3D min_t(size_t, count, MAX_RW_COUNT), - }; struct kiocb kiocb; - struct iov_iter iter; ssize_t ret; =20 if (WARN_ON_ONCE(!(file->f_mode & FMODE_WRITE))) @@ -532,8 +527,7 @@ ssize_t __kernel_write(struct file *file, const void *b= uf, size_t count, loff_t =20 init_sync_kiocb(&kiocb, file); kiocb.ki_pos =3D pos ? *pos : 0; - iov_iter_kvec(&iter, WRITE, &iov, 1, iov.iov_len); - ret =3D file->f_op->write_iter(&kiocb, &iter); + ret =3D file->f_op->write_iter(&kiocb, from); if (ret > 0) { if (pos) *pos =3D kiocb.ki_pos; @@ -543,6 +537,18 @@ ssize_t __kernel_write(struct file *file, const void *= buf, size_t count, loff_t inc_syscw(current); return ret; } + +/* caller is responsible for file_start_write/file_end_write */ +ssize_t __kernel_write(struct file *file, const void *buf, size_t count, l= off_t *pos) +{ + struct kvec iov =3D { + .iov_base =3D (void *)buf, + .iov_len =3D min_t(size_t, count, MAX_RW_COUNT), + }; + struct iov_iter iter; + iov_iter_kvec(&iter, WRITE, &iov, 1, iov.iov_len); + return __kernel_write_iter(file, &iter, pos); +} /* * This "EXPORT_SYMBOL_GPL()" is more of a "EXPORT_SYMBOL_DONTUSE()", * but autofs is one of the few internal kernel users that actually --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E022C4332F for ; Mon, 3 Oct 2022 07:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbiJCHWC (ORCPT ); Mon, 3 Oct 2022 03:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbiJCHVB (ORCPT ); Mon, 3 Oct 2022 03:21:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F9C148C87; Mon, 3 Oct 2022 00:15:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 405F960FA5; Mon, 3 Oct 2022 07:15:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50E68C433C1; Mon, 3 Oct 2022 07:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781351; bh=88y6V89ZhIC2mAYvMvB8/89AVze1JwN4vvrzk+RVBGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vsoG1nYBudrUAtc3X2PGMxzMUM4siOtgyvU2QZVqGqPHQChAE5i5K3HeFASt8I6KG xg34XtRmOWhNApv0NupgkHD+gVJN+4yz7uc6iG0HQqDwb3IV23kBsgjYCNmkP50M3o aJMVaLlSmYpl+2qJSQWtnr6dTCDtFq6/d0rpRJEs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Han Xu , Fabio Estevam , Abel Vesa , Stephen Boyd , Sasha Levin Subject: [PATCH 5.19 090/101] clk: imx: imx6sx: remove the SET_RATE_PARENT flag for QSPI clocks Date: Mon, 3 Oct 2022 09:11:26 +0200 Message-Id: <20221003070726.681219152@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Han Xu [ Upstream commit b1ff1bfe81e763420afd5f3f25f0b3cbfd97055c ] There is no dedicate parent clock for QSPI so SET_RATE_PARENT flag should not be used. For instance, the default parent clock for QSPI is pll2_bus, which is also the parent clock for quite a few modules, such as MMDC, once GPMI NAND set clock rate for EDO5 mode can cause system hang due to pll2_bus rate changed. Fixes: f1541e15e38e ("clk: imx6sx: Switch to clk_hw based API") Signed-off-by: Han Xu Link: https://lore.kernel.org/r/20220915150959.3646702-1-han.xu@nxp.com Tested-by: Fabio Estevam Reviewed-by: Abel Vesa Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/imx/clk-imx6sx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c index fc1bd23d4583..598f3cf4eba4 100644 --- a/drivers/clk/imx/clk-imx6sx.c +++ b/drivers/clk/imx/clk-imx6sx.c @@ -280,13 +280,13 @@ static void __init imx6sx_clocks_init(struct device_n= ode *ccm_node) hws[IMX6SX_CLK_SSI3_SEL] =3D imx_clk_hw_mux("ssi3_sel", = base + 0x1c, 14, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); hws[IMX6SX_CLK_SSI2_SEL] =3D imx_clk_hw_mux("ssi2_sel", = base + 0x1c, 12, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); hws[IMX6SX_CLK_SSI1_SEL] =3D imx_clk_hw_mux("ssi1_sel", = base + 0x1c, 10, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); - hws[IMX6SX_CLK_QSPI1_SEL] =3D imx_clk_hw_mux_flags("qspi1_sel", = base + 0x1c, 7, 3, qspi1_sels, ARRAY_SIZE(qspi1_sels), CLK_SET_RATE_PARENT= ); + hws[IMX6SX_CLK_QSPI1_SEL] =3D imx_clk_hw_mux("qspi1_sel", = base + 0x1c, 7, 3, qspi1_sels, ARRAY_SIZE(qspi1_sels)); hws[IMX6SX_CLK_PERCLK_SEL] =3D imx_clk_hw_mux("perclk_sel", = base + 0x1c, 6, 1, perclk_sels, ARRAY_SIZE(perclk_sels)); hws[IMX6SX_CLK_VID_SEL] =3D imx_clk_hw_mux("vid_sel", = base + 0x20, 21, 3, vid_sels, ARRAY_SIZE(vid_sels)); hws[IMX6SX_CLK_ESAI_SEL] =3D imx_clk_hw_mux("esai_sel", = base + 0x20, 19, 2, audio_sels, ARRAY_SIZE(audio_sels)); hws[IMX6SX_CLK_CAN_SEL] =3D imx_clk_hw_mux("can_sel", = base + 0x20, 8, 2, can_sels, ARRAY_SIZE(can_sels)); hws[IMX6SX_CLK_UART_SEL] =3D imx_clk_hw_mux("uart_sel", = base + 0x24, 6, 1, uart_sels, ARRAY_SIZE(uart_sels)); - hws[IMX6SX_CLK_QSPI2_SEL] =3D imx_clk_hw_mux_flags("qspi2_sel", = base + 0x2c, 15, 3, qspi2_sels, ARRAY_SIZE(qspi2_sels), CLK_SET_RATE_PARENT= ); + hws[IMX6SX_CLK_QSPI2_SEL] =3D imx_clk_hw_mux("qspi2_sel", = base + 0x2c, 15, 3, qspi2_sels, ARRAY_SIZE(qspi2_sels)); hws[IMX6SX_CLK_SPDIF_SEL] =3D imx_clk_hw_mux("spdif_sel", = base + 0x30, 20, 2, audio_sels, ARRAY_SIZE(audio_sels)); hws[IMX6SX_CLK_AUDIO_SEL] =3D imx_clk_hw_mux("audio_sel", = base + 0x30, 7, 2, audio_sels, ARRAY_SIZE(audio_sels)); hws[IMX6SX_CLK_ENET_PRE_SEL] =3D imx_clk_hw_mux("enet_pre_sel", = base + 0x34, 15, 3, enet_pre_sels, ARRAY_SIZE(enet_pre_sels)= ); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E4F4C433F5 for ; Mon, 3 Oct 2022 07:22:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbiJCHWs (ORCPT ); Mon, 3 Oct 2022 03:22:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbiJCHVv (ORCPT ); Mon, 3 Oct 2022 03:21:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA33649B6D; Mon, 3 Oct 2022 00:16:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A85F6B80E6F; Mon, 3 Oct 2022 07:15:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13871C433D6; Mon, 3 Oct 2022 07:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781354; bh=DueJoZj4Ew6wuAWyr3FPZ4L4bjUI7T+MCT44ahsb0RY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mzeiXS5i2ykyUx1RsjRSBv/Aq1WpMhdLGCsfKGtO8mRaXSY00V4yZ1n0+RRXAd5U vzbFs+gVAv8W3sU1HgUg11SXJh8jgIxx20ZG5psvsVRVMl1G5dKZv/aneBMNBEoHSC hHAuJS8sKcKoydZt/vJJpeMj4NFl9ASLmPhpstZ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashutosh Dixit , Rodrigo Vivi , Sasha Levin Subject: [PATCH 5.19 091/101] drm/i915/gt: Perf_limit_reasons are only available for Gen11+ Date: Mon, 3 Oct 2022 09:11:27 +0200 Message-Id: <20221003070726.704306583@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ashutosh Dixit [ Upstream commit 7738be973fc4e2ba22154fafd3a5d7b9666f9abf ] Register GT0_PERF_LIMIT_REASONS (0x1381a8) is available only for Gen11+. Therefore ensure perf_limit_reasons sysfs files are created only for Gen11+. Otherwise on Gen < 5 accessing these files results in the following oops: <1> [88.829420] BUG: unable to handle page fault for address: ffffc90000bb8= 1a8 <1> [88.829438] #PF: supervisor read access in kernel mode <1> [88.829447] #PF: error_code(0x0000) - not-present page This patch is a backport of the drm-tip commit 0d2d201095e9 ("drm/i915: Perf_limit_reasons are only available for Gen11+") to drm-intel-fixes. The backport is not identical to the original, it only includes the sysfs portions of if. The debugfs portion is not available in drm-intel-fixes so has not been backported. Bspec: 20008 Bug: https://gitlab.freedesktop.org/drm/intel/-/issues/6863 Fixes: fa68bff7cf27 ("drm/i915/gt: Add sysfs throttle frequency interfaces") Signed-off-by: Ashutosh Dixit Reviewed-by: Rodrigo Vivi Signed-off-by: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/20220919162401.2077713-= 1-ashutosh.dixit@intel.com (backported from commit 0d2d201095e9f141d6a9fb44320afce761f8b5c2) Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/= i915/gt/intel_gt_sysfs_pm.c index f76b6cf8040e..b8cb58e2819a 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c @@ -544,8 +544,7 @@ static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_ratl, = RATL_MASK); static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMAL= ERT_MASK); static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK); =20 -static const struct attribute *freq_attrs[] =3D { - &dev_attr_punit_req_freq_mhz.attr, +static const struct attribute *throttle_reason_attrs[] =3D { &attr_throttle_reason_status.attr, &attr_throttle_reason_pl1.attr, &attr_throttle_reason_pl2.attr, @@ -594,9 +593,17 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struc= t kobject *kobj) if (!is_object_gt(kobj)) return; =20 - ret =3D sysfs_create_files(kobj, freq_attrs); + ret =3D sysfs_create_file(kobj, &dev_attr_punit_req_freq_mhz.attr); if (ret) drm_warn(>->i915->drm, - "failed to create gt%u throttle sysfs files (%pe)", + "failed to create gt%u punit_req_freq_mhz sysfs (%pe)", gt->info.id, ERR_PTR(ret)); + + if (GRAPHICS_VER(gt->i915) >=3D 11) { + ret =3D sysfs_create_files(kobj, throttle_reason_attrs); + if (ret) + drm_warn(>->i915->drm, + "failed to create gt%u throttle sysfs files (%pe)", + gt->info.id, ERR_PTR(ret)); + } } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9680DC433F5 for ; Mon, 3 Oct 2022 07:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231863AbiJCHkd (ORCPT ); Mon, 3 Oct 2022 03:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbiJCHjK (ORCPT ); Mon, 3 Oct 2022 03:39:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4365B5467C; Mon, 3 Oct 2022 00:24:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9D7360F99; Mon, 3 Oct 2022 07:15:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC8ECC433D6; Mon, 3 Oct 2022 07:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781357; bh=mx9ftnuzq9ci2eIbyQWEhEq6TrIUmYIY4z3AB7Ihuxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nFvTsEn6OCFekdbJWzxEg8EZWdjS4B82xsJ7AMybhpygHU0YkGvWK/ikX4gbIOSF3 sn8+UAHYb57VEIzxlluTVBLZOE8RCO7tiLL0PKlObb2H6O6hE8YtvAoZA3K7dnDlTP 5df6PvXIG1kNrri9rQXZ9RJiGcyiH1CDk9oNM5BU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Stephen Boyd , Sasha Levin Subject: [PATCH 5.19 092/101] clk: iproc: Do not rely on node name for correct PLL setup Date: Mon, 3 Oct 2022 09:11:28 +0200 Message-Id: <20221003070726.728825063@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ Upstream commit 1b24a132eba7a1c19475ba2510ec1c00af3ff914 ] After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block description") a warning from clk-iproc-pll.c was generated due to a duplicate PLL name as well as the console stopped working. Upon closer inspection it became clear that iproc_pll_clk_setup() used the Device Tree node unit name as an unique identifier as well as a parent name to parent all clocks under the PLL. BCM5301X was the first platform on which that got noticed because of the DT node unit name renaming but the same assumptions hold true for any user of the iproc_pll_clk_setup() function. The first 'clock-output-names' property is always guaranteed to be unique as well as providing the actual desired PLL clock name, so we utilize that to register the PLL and as a parent name of all children clock. Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support") Signed-off-by: Florian Fainelli Acked-by: Rafa=C5=82 Mi=C5=82ecki Link: https://lore.kernel.org/r/20220905161504.1526-1-f.fainelli@gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pl= l.c index 33da30f99c79..d39c44b61c52 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -736,6 +736,7 @@ void iproc_pll_clk_setup(struct device_node *node, const char *parent_name; struct iproc_clk *iclk_array; struct clk_hw_onecell_data *clk_data; + const char *clk_name; =20 if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) return; @@ -783,7 +784,12 @@ void iproc_pll_clk_setup(struct device_node *node, iclk =3D &iclk_array[0]; iclk->pll =3D pll; =20 - init.name =3D node->name; + ret =3D of_property_read_string_index(node, "clock-output-names", + 0, &clk_name); + if (WARN_ON(ret)) + goto err_pll_register; + + init.name =3D clk_name; init.ops =3D &iproc_pll_ops; init.flags =3D 0; parent_name =3D of_clk_get_parent_name(node, 0); @@ -803,13 +809,11 @@ void iproc_pll_clk_setup(struct device_node *node, goto err_pll_register; =20 clk_data->hws[0] =3D &iclk->hw; + parent_name =3D clk_name; =20 /* now initialize and register all leaf clocks */ for (i =3D 1; i < num_clks; i++) { - const char *clk_name; - memset(&init, 0, sizeof(init)); - parent_name =3D node->name; =20 ret =3D of_property_read_string_index(node, "clock-output-names", i, &clk_name); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47FF0C4332F for ; Mon, 3 Oct 2022 07:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbiJCHq3 (ORCPT ); Mon, 3 Oct 2022 03:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbiJCHo0 (ORCPT ); Mon, 3 Oct 2022 03:44:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3524F476D5; Mon, 3 Oct 2022 00:26:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0DABAB80E77; Mon, 3 Oct 2022 07:16:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D669C433D7; Mon, 3 Oct 2022 07:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781359; bh=GLpatjvPIRyVVgNUsRmGJsg+QQg8gXy0pZ8E44NzLlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7e+ydVA2ovtLBR9Ff494b8WLYPiXJitq7+tZT4TPcFszgs9VXymKoo76ZOUPemzT q/+Qq/mTmkVwNrbN4XGQ8CXq5furGmQkqp6bKIjbgyfnWscC6vtjGiGD48JikP3OND s4PcbdIh9FclzwS4uEbQgVeZh/M43Xu+OD6dB2IU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Peng Fan , Abel Vesa , Stephen Boyd , Sasha Levin Subject: [PATCH 5.19 093/101] clk: imx93: drop of_match_ptr Date: Mon, 3 Oct 2022 09:11:29 +0200 Message-Id: <20221003070726.751403109@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peng Fan [ Upstream commit daaa2fbe678efdaced53d1c635f4d326751addf8 ] There is build warning when CONFIG_OF is not selected. >> drivers/clk/imx/clk-imx93.c:324:34: warning: 'imx93_clk_of_match' >> defined but not used [-Wunused-const-variable=3D] 324 | static const struct of_device_id imx93_clk_of_match[] =3D { | ^~~~~~~~~~~~~~~~~~ The driver only support DT table, no sense to use of_match_ptr. Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk") Reported-by: kernel test robot Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/20220830033137.4149542-3-peng.fan@oss.nxp.c= om Reviewed-by: Abel Vesa Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clk/imx/clk-imx93.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c index f5c9fa40491c..dcc41d178238 100644 --- a/drivers/clk/imx/clk-imx93.c +++ b/drivers/clk/imx/clk-imx93.c @@ -332,7 +332,7 @@ static struct platform_driver imx93_clk_driver =3D { .driver =3D { .name =3D "imx93-ccm", .suppress_bind_attrs =3D true, - .of_match_table =3D of_match_ptr(imx93_clk_of_match), + .of_match_table =3D imx93_clk_of_match, }, }; module_platform_driver(imx93_clk_driver); --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43B67C433FE for ; Mon, 3 Oct 2022 07:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbiJCHZg (ORCPT ); Mon, 3 Oct 2022 03:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiJCHXx (ORCPT ); Mon, 3 Oct 2022 03:23:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13D5D4686F; Mon, 3 Oct 2022 00:17:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0431F60FA1; Mon, 3 Oct 2022 07:16:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17E00C433D6; Mon, 3 Oct 2022 07:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781362; bh=VPla568IMQ+1ZdstS01XByFNf/Tc8/20hbJ/RF7NOK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dSSnwriN1yyaOHQe2PYPgxDYwbAy2py9zSrnEqYifPp7FVWGfpMSYdc8Ww2Lad+4A y72I/GGSKYM0iI3TwAIE/9KmIL48esdobrNVQ6uJGprcV5p3EupNwwD0f/HeRo/kbd e3G3uGtkjUjhN6tcxVhGVyCMdlf10b/rl9aXiAMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 094/101] net: mscc: ocelot: fix tagged VLAN refusal while under a VLAN-unaware bridge Date: Mon, 3 Oct 2022 09:11:30 +0200 Message-Id: <20221003070726.774746245@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 276d37eb449133bc22872b8f0a6f878e120deeff ] Currently the following set of commands fails: $ ip link add br0 type bridge # vlan_filtering 0 $ ip link set swp0 master br0 $ bridge vlan port vlan-id swp0 1 PVID Egress Untagged $ bridge vlan add dev swp0 vid 10 Error: mscc_ocelot_switch_lib: Port with more than one egress-untagged VLAN= cannot have egress-tagged VLANs. Dumping ocelot->vlans, one can see that the 2 egress-untagged VLANs on swp0= are vid 1 (the bridge PVID) and vid 4094, a PVID used privately by the driver f= or VLAN-unaware bridging. So this is why bridge vid 10 is refused, despite 'bridge vlan' showing a single egress untagged VLAN. As mentioned in the comment added, having this private VLAN does not impose restrictions to the hardware configuration, yet it is a bookkeeping problem. There are 2 possible solutions. One is to make the functions that operate on VLAN-unaware pvids: - ocelot_add_vlan_unaware_pvid() - ocelot_del_vlan_unaware_pvid() - ocelot_port_setup_dsa_8021q_cpu() - ocelot_port_teardown_dsa_8021q_cpu() call something different than ocelot_vlan_member_(add|del)(), the latter be= ing the real problem, because it allocates a struct ocelot_bridge_vlan *vlan wh= ich it adds to ocelot->vlans. We don't really *need* the private VLANs in ocelot->vlans, it's just that we have the extra convenience of having the vlan->portmask cached in software (whereas without these structures, we'd h= ave to create a raw ocelot_vlant_rmw_mask() procedure which reads back the curr= ent port mask from hardware). The other solution is to filter out the private VLANs from ocelot_port_num_untagged_vlans(), since they aren't what callers care about. We only need to do this to the mentioned function and not to ocelot_port_num_tagged_vlans(), because private VLANs are never egress-tagg= ed. Nothing else seems to be broken in either solution, but the first one requi= res more rework which will conflict with the net-next change 36a0bf443585 ("ne= t: mscc: ocelot: set up tag_8021q CPU ports independent of user port affinity"= ), and I'd like to avoid that. So go with the other one. Fixes: 54c319846086 ("net: mscc: ocelot: enforce FDB isolation when VLAN-un= aware") Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220927122042.1100231-1-vladimir.oltean@nx= p.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/mscc/ocelot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc= /ocelot.c index 68991b021c56..c250ad6dc956 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -290,6 +290,13 @@ static int ocelot_port_num_untagged_vlans(struct ocelo= t *ocelot, int port) if (!(vlan->portmask & BIT(port))) continue; =20 + /* Ignore the VLAN added by ocelot_add_vlan_unaware_pvid(), + * because this is never active in hardware at the same time as + * the bridge VLANs, which only matter in VLAN-aware mode. + */ + if (vlan->vid >=3D OCELOT_RSV_VLAN_RANGE_START) + continue; + if (vlan->untagged & BIT(port)) num_untagged++; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABAFC433FE for ; Mon, 3 Oct 2022 07:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbiJCHWo (ORCPT ); Mon, 3 Oct 2022 03:22:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiJCHVu (ORCPT ); Mon, 3 Oct 2022 03:21:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208C6491F9; Mon, 3 Oct 2022 00:16:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFB9460FA6; Mon, 3 Oct 2022 07:16:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB100C433C1; Mon, 3 Oct 2022 07:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781365; bh=xRgycX1bdiD+Sa4ok5E1KEC3e5KRtZ1KznvcL7hwnVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jbb4B2TZYQDs2KQI1MeC2nfhismuh0tMRY5tDNa91g5KSrZxTGws52nfIBOYjU3TM C0XZrOOz23bueCEUSj/9iNkQRz9nxoLpVT46Yz+yGqIEHUv/Eh+FLbTM9lFo8/y3kl b8v5NN47piLe3MTVv4hswDHdGJKyUSgeSFWRt8fY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Minqiang , Lorenzo Bianconi , Daniel Golle , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 095/101] net: ethernet: mtk_eth_soc: fix mask of RX_DMA_GET_SPORT{,_V2} Date: Mon, 3 Oct 2022 09:11:31 +0200 Message-Id: <20221003070726.797595336@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Daniel Golle [ Upstream commit c9da02bfb1112461e048d3b736afb1873f6f4ccf ] The bitmasks applied in RX_DMA_GET_SPORT and RX_DMA_GET_SPORT_V2 macros were swapped. Fix that. Reported-by: Chen Minqiang Fixes: 160d3a9b192985 ("net: ethernet: mtk_eth_soc: introduce MTK_NETSYS_V2= support") Acked-by: Lorenzo Bianconi Signed-off-by: Daniel Golle Link: https://lore.kernel.org/r/YzMW+mg9UsaCdKRQ@makrotopia.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethe= rnet/mediatek/mtk_eth_soc.h index 98d6a6d047e3..c1fe1a2cb746 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -312,8 +312,8 @@ #define MTK_RXD5_PPE_CPU_REASON GENMASK(22, 18) #define MTK_RXD5_SRC_PORT GENMASK(29, 26) =20 -#define RX_DMA_GET_SPORT(x) (((x) >> 19) & 0xf) -#define RX_DMA_GET_SPORT_V2(x) (((x) >> 26) & 0x7) +#define RX_DMA_GET_SPORT(x) (((x) >> 19) & 0x7) +#define RX_DMA_GET_SPORT_V2(x) (((x) >> 26) & 0xf) =20 /* PDMA V2 descriptor rxd3 */ #define RX_DMA_VTAG_V2 BIT(0) --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77594C433FE for ; Mon, 3 Oct 2022 07:26:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbiJCH0J (ORCPT ); Mon, 3 Oct 2022 03:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiJCHYM (ORCPT ); Mon, 3 Oct 2022 03:24:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8624BD3E; Mon, 3 Oct 2022 00:18:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 92FFE60FA9; Mon, 3 Oct 2022 07:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70308C433D6; Mon, 3 Oct 2022 07:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781368; bh=dybPGXdcqcvWSfFoE1rkJVjWUx2hSoQdde7i7X3AEoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFt7xxTmE0w/hLtVRzqe6NwneYM9FPuOxNy3g2WA4jfdausv2cxyrg7NxvCp/bYdR QjvytDlHegiIPRFTdMbn1kw5ISrQVboZ6H55QlvHDq5oZI4jTgg3or/47X2/3NcJOX FlrpecMk2DidXHrfiI5EpOpfThvrAjG3U5rA/YC0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , Xing Zhengjun , Ian Rogers , Alexander Shishkin , Andi Kleen , Ingo Molnar , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 096/101] perf test: Fix test case 87 ("perf record tests") for hybrid systems Date: Mon, 3 Oct 2022 09:11:32 +0200 Message-Id: <20221003070726.820259923@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhengjun Xing [ Upstream commit 457c8b60267054869513ab1fb5513abb0a566dd0 ] The test case 87 ("perf record tests") failed on hybrid systems,the event "cpu/br_inst_retired.near_call/p" is only for non-hybrid system. Correct the test event to support both non-hybrid and hybrid systems. Before: # ./perf test 87 87: perf record tests : FAILED! After: # ./perf test 87 87: perf record tests : Ok Fixes: 24f378e66021f559 ("perf test: Add basic perf record tests") Reviewed-by: Kan Liang Signed-off-by: Xing Zhengjun Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20220927051513.3768717-1-zhengjun.xing@linu= x.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/tests/shell/record.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/reco= rd.sh index 00c7285ce1ac..301f95427159 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -61,7 +61,7 @@ test_register_capture() { echo "Register capture test [Skipped missing registers]" return fi - if ! perf record -o - --intr-regs=3Ddi,r8,dx,cx -e cpu/br_inst_retired.n= ear_call/p \ + if ! perf record -o - --intr-regs=3Ddi,r8,dx,cx -e br_inst_retired.near_= call:p \ -c 1000 --per-thread true 2> /dev/null \ | perf script -F ip,sym,iregs -i - 2> /dev/null \ | egrep -q "DI:" --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4859BC433F5 for ; Mon, 3 Oct 2022 07:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbiJCHWc (ORCPT ); Mon, 3 Oct 2022 03:22:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbiJCHVa (ORCPT ); Mon, 3 Oct 2022 03:21:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD4C7248EC; Mon, 3 Oct 2022 00:16:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 86C25B80E6C; Mon, 3 Oct 2022 07:16:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D88CCC433D6; Mon, 3 Oct 2022 07:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781373; bh=41Tuw7nhCIGbtroJKi9dP0cAM8JSkWdQwzKeupAZ33M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBhEX4IC5k1mPFwNorWM9kq+D/Afrh+nzN0gMPh2GaAWD6EZ5RMGV0PAcQHdlFpJQ jNGcqjb/d4gxvU4RnBvUU3FhfCxiCe/sS2BNWmAXzagiMnGMRtJoQkCe2Xfzo9O+5Q FcXQnERaFNPlCEgYKHjUJpQMw3Hj4sfGPDAGH1ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Adrian Hunter , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.19 097/101] perf tests record: Fail the test if the errs counter is not zero Date: Mon, 3 Oct 2022 09:11:33 +0200 Message-Id: <20221003070726.844526673@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo [ Upstream commit 25c5e67cdf744cbb93fd06647611d3036218debe ] We were just checking for the 'err' variable, when we should really see if there was some of the many checked errors that don't stop the test right away. Detected with clang 15.0.0: 44 75.23 fedora:37 : FAIL clang version 15.0.0 (Fedora 15.0.0-2.= fc37) tests/perf-record.c:68:16: error: variable 'errs' set but not used [-We= rror,-Wunused-but-set-variable] int err =3D -1, errs =3D 0, i, wakeups =3D 0; ^ 1 error generated. The patch introducing this 'perf test' entry had that check: + return (err < 0 || errs > 0) ? -1 : 0; But at some point we lost that: - return (err < 0 || errs > 0) ? -1 : 0; + if (err =3D=3D -EACCES) + return TEST_SKIP; + if (err < 0) + return TEST_FAIL; + return TEST_OK Put it back. Fixes: 2cf88f4614c996e5 ("perf test: Use skip in PERF_RECORD_*") Acked-by: Ian Rogers Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lore.kernel.org/lkml/YzR0n5QhsH9VyYB0@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- tools/perf/tests/perf-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 6a001fcfed68..4952abe716f3 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -332,7 +332,7 @@ static int test__PERF_RECORD(struct test_suite *test __= maybe_unused, int subtest out: if (err =3D=3D -EACCES) return TEST_SKIP; - if (err < 0) + if (err < 0 || errs !=3D 0) return TEST_FAIL; return TEST_OK; } --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97BA7C43219 for ; Mon, 3 Oct 2022 07:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231961AbiJCHin (ORCPT ); Mon, 3 Oct 2022 03:38:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbiJCHgx (ORCPT ); Mon, 3 Oct 2022 03:36:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21A5543D4; Mon, 3 Oct 2022 00:22:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36DD7B80E79; Mon, 3 Oct 2022 07:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8773BC433D6; Mon, 3 Oct 2022 07:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781375; bh=sdAyOR43AqkiXWVdDbIOamPiQM5FRcgzb6Smj1jPIlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yf/rXBxIyvgjqEgUoXtmJM4ZxlZAOkFV7FwBRkmYo52kX3Gvrty15k5vDD5vdCE7j kvj39Mb+aiR5souHyNLqSTsrQ4tftNF25me+tRC/QOQJk8PXMuxc93eUsdHF7bwR+l 60OnQ+D7LFHnC4V8Rw0rZqD+h0e3ZKEhfFbPF19U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.19 098/101] KVM: x86: Hide IA32_PLATFORM_DCA_CAP[31:0] from the guest Date: Mon, 3 Oct 2022 09:11:34 +0200 Message-Id: <20221003070726.867663707@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jim Mattson [ Upstream commit aae2e72229cdb21f90df2dbe4244c977e5d3265b ] The only thing reported by CPUID.9 is the value of IA32_PLATFORM_DCA_CAP[31:0] in EAX. This MSR doesn't even exist in the guest, since CPUID.1:ECX.DCA[bit 18] is clear in the guest. Clear CPUID.9 in KVM_GET_SUPPORTED_CPUID. Fixes: 24c82e576b78 ("KVM: Sanitize cpuid") Signed-off-by: Jim Mattson Message-Id: <20220922231854.249383-1-jmattson@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/x86/kvm/cpuid.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 3ab498165639..cb14441cee37 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -870,8 +870,6 @@ static inline int __do_cpuid_func(struct kvm_cpuid_arra= y *array, u32 function) entry->edx =3D 0; } break; - case 9: - break; case 0xa: { /* Architectural Performance Monitoring */ struct x86_pmu_capability cap; union cpuid10_eax eax; --=20 2.35.1 From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F3F6C433F5 for ; Mon, 3 Oct 2022 07:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiJCH0i (ORCPT ); Mon, 3 Oct 2022 03:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJCHYa (ORCPT ); Mon, 3 Oct 2022 03:24:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E438637192; Mon, 3 Oct 2022 00:18:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2AE6860F08; Mon, 3 Oct 2022 07:16:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A8D1C433D7; Mon, 3 Oct 2022 07:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781378; bh=1IZBZDt+Wlcs3Xkk1ok1GE/KHjIXbz2z7WjYvzPlrRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9JYh6eM3+IjCCe96Jo9zQzFTTS0eCEIWptItosWvde9fHbcW2KhJI3oECUrzYxwM kvGj611ZDdMZ+0XgWQAmgQShjA29WyA2wkpXth4uFYvIHfwMw0ITewyLvyZzihZ09/ w4HIaEzfG1k6TMLRzgxUECiqSCL5Ssysr6te3gp8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Saurabh Sengar , Borislav Petkov Subject: [PATCH 5.19 099/101] x86/cacheinfo: Add a cpu_llc_shared_mask() UP variant Date: Mon, 3 Oct 2022 09:11:35 +0200 Message-Id: <20221003070726.891304655@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Borislav Petkov commit df5b035b5683d6a25f077af889fb88e09827f8bc upstream. On a CONFIG_SMP=3Dn kernel, the LLC shared mask is 0, which prevents __cache_amd_cpumap_setup() from doing the L3 masks setup, and more specifically from setting up the shared_cpu_map and shared_cpu_list files in sysfs, leading to lscpu from util-linux getting confused and segfaulting. Add a cpu_llc_shared_mask() UP variant which returns a mask with a single bit set, i.e., for CPU0. Fixes: 2b83809a5e6d ("x86/cpu/amd: Derive L3 shared_cpu_map from cpu_llc_sh= ared_mask") Reported-by: Saurabh Sengar Signed-off-by: Borislav Petkov Cc: Link: https://lore.kernel.org/r/1660148115-302-1-git-send-email-ssengar@lin= ux.microsoft.com Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/x86/include/asm/smp.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -21,16 +21,6 @@ DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id); DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number); =20 -static inline struct cpumask *cpu_llc_shared_mask(int cpu) -{ - return per_cpu(cpu_llc_shared_map, cpu); -} - -static inline struct cpumask *cpu_l2c_shared_mask(int cpu) -{ - return per_cpu(cpu_l2c_shared_map, cpu); -} - DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid); DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid); DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid); @@ -172,6 +162,16 @@ extern int safe_smp_processor_id(void); # define safe_smp_processor_id() smp_processor_id() #endif =20 +static inline struct cpumask *cpu_llc_shared_mask(int cpu) +{ + return per_cpu(cpu_llc_shared_map, cpu); +} + +static inline struct cpumask *cpu_l2c_shared_mask(int cpu) +{ + return per_cpu(cpu_l2c_shared_map, cpu); +} + #else /* !CONFIG_SMP */ #define wbinvd_on_cpu(cpu) wbinvd() static inline int wbinvd_on_all_cpus(void) @@ -179,6 +179,11 @@ static inline int wbinvd_on_all_cpus(voi wbinvd(); return 0; } + +static inline struct cpumask *cpu_llc_shared_mask(int cpu) +{ + return (struct cpumask *)cpumask_of(0); +} #endif /* CONFIG_SMP */ =20 extern unsigned disabled_cpus; From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E109FC433F5 for ; Mon, 3 Oct 2022 07:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbiJCHWj (ORCPT ); Mon, 3 Oct 2022 03:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbiJCHVt (ORCPT ); Mon, 3 Oct 2022 03:21:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D6254A13F; Mon, 3 Oct 2022 00:16:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7BFCFB80E78; Mon, 3 Oct 2022 07:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9F66C433D7; Mon, 3 Oct 2022 07:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781381; bh=Ah20YAAdjRRhETddEBaRda0TzCdoJ5b74wVSxQ1iYo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipS9qI915pbQRzU0AhjycwjU/8kb2fRHgGdTB5VveH/Wxe3OiO3sdrAEFsJZQsfvT TLSYkhptt3ZegelZ10k0C1LXuCseZCUU4y6rHKIf6GrxQd2OCxyWd876YWfD1JIp3/ mnScYCrX2J9TArCvm62n871KRoxHmVKFRYK5z1FE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nadav Amit , "Peter Zijlstra (Intel)" , stable@kernel.org Subject: [PATCH 5.19 100/101] x86/alternative: Fix race in try_get_desc() Date: Mon, 3 Oct 2022 09:11:36 +0200 Message-Id: <20221003070726.915172418@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nadav Amit commit efd608fa7403ba106412b437f873929e2c862e28 upstream. I encountered some occasional crashes of poke_int3_handler() when kprobes are set, while accessing desc->vec. The text poke mechanism claims to have an RCU-like behavior, but it does not appear that there is any quiescent state to ensure that nobody holds reference to desc. As a result, the following race appears to be possible, which can lead to memory corruption. CPU0 CPU1 ---- ---- text_poke_bp_batch() -> smp_store_release(&bp_desc, &desc) [ notice that desc is on the stack ] poke_int3_handler() [ int3 might be kprobe's so sync events are do not help ] -> try_get_desc(descp=3D&bp_desc) desc =3D __READ_ONCE(bp_desc) if (!desc) [false, success] WRITE_ONCE(bp_desc, NULL); atomic_dec_and_test(&desc.refs) [ success, desc space on the stack is being reused and might have non-zero value. ] arch_atomic_inc_not_zero(&desc->refs) [ might succeed since desc points to stack memory that was freed and might be reused. ] Fix this issue with small backportable patch. Instead of trying to make RCU-like behavior for bp_desc, just eliminate the unnecessary level of indirection of bp_desc, and hold the whole descriptor as a global. Anyhow, there is only a single descriptor at any given moment. Fixes: 1f676247f36a4 ("x86/alternatives: Implement a better poke_int3_handl= er() completion scheme") Signed-off-by: Nadav Amit Signed-off-by: Peter Zijlstra (Intel) Cc: stable@kernel.org Link: https://lkml.kernel.org/r/20220920224743.3089-1-namit@vmware.com Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/x86/kernel/alternative.c | 45 +++++++++++++++++++++----------------= ----- 1 file changed, 23 insertions(+), 22 deletions(-) --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -1319,22 +1319,23 @@ struct bp_patching_desc { atomic_t refs; }; =20 -static struct bp_patching_desc *bp_desc; +static struct bp_patching_desc bp_desc; =20 static __always_inline -struct bp_patching_desc *try_get_desc(struct bp_patching_desc **descp) +struct bp_patching_desc *try_get_desc(void) { - /* rcu_dereference */ - struct bp_patching_desc *desc =3D __READ_ONCE(*descp); + struct bp_patching_desc *desc =3D &bp_desc; =20 - if (!desc || !arch_atomic_inc_not_zero(&desc->refs)) + if (!arch_atomic_inc_not_zero(&desc->refs)) return NULL; =20 return desc; } =20 -static __always_inline void put_desc(struct bp_patching_desc *desc) +static __always_inline void put_desc(void) { + struct bp_patching_desc *desc =3D &bp_desc; + smp_mb__before_atomic(); arch_atomic_dec(&desc->refs); } @@ -1367,15 +1368,15 @@ noinstr int poke_int3_handler(struct pt_ =20 /* * Having observed our INT3 instruction, we now must observe - * bp_desc: + * bp_desc with non-zero refcount: * - * bp_desc =3D desc INT3 + * bp_desc.refs =3D 1 INT3 * WMB RMB - * write INT3 if (desc) + * write INT3 if (bp_desc.refs !=3D 0) */ smp_rmb(); =20 - desc =3D try_get_desc(&bp_desc); + desc =3D try_get_desc(); if (!desc) return 0; =20 @@ -1429,7 +1430,7 @@ noinstr int poke_int3_handler(struct pt_ ret =3D 1; =20 out_put: - put_desc(desc); + put_desc(); return ret; } =20 @@ -1460,18 +1461,20 @@ static int tp_vec_nr; */ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_e= ntries) { - struct bp_patching_desc desc =3D { - .vec =3D tp, - .nr_entries =3D nr_entries, - .refs =3D ATOMIC_INIT(1), - }; unsigned char int3 =3D INT3_INSN_OPCODE; unsigned int i; int do_sync; =20 lockdep_assert_held(&text_mutex); =20 - smp_store_release(&bp_desc, &desc); /* rcu_assign_pointer */ + bp_desc.vec =3D tp; + bp_desc.nr_entries =3D nr_entries; + + /* + * Corresponds to the implicit memory barrier in try_get_desc() to + * ensure reading a non-zero refcount provides up to date bp_desc data. + */ + atomic_set_release(&bp_desc.refs, 1); =20 /* * Corresponding read barrier in int3 notifier for making sure the @@ -1559,12 +1562,10 @@ static void text_poke_bp_batch(struct te text_poke_sync(); =20 /* - * Remove and synchronize_rcu(), except we have a very primitive - * refcount based completion. + * Remove and wait for refs to be zero. */ - WRITE_ONCE(bp_desc, NULL); /* RCU_INIT_POINTER */ - if (!atomic_dec_and_test(&desc.refs)) - atomic_cond_read_acquire(&desc.refs, !VAL); + if (!atomic_dec_and_test(&bp_desc.refs)) + atomic_cond_read_acquire(&bp_desc.refs, !VAL); } =20 static void text_poke_loc_init(struct text_poke_loc *tp, void *addr, From nobody Fri Apr 10 10:43:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D2ABC433F5 for ; Mon, 3 Oct 2022 07:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbiJCH1i (ORCPT ); Mon, 3 Oct 2022 03:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbiJCH1F (ORCPT ); Mon, 3 Oct 2022 03:27:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3734CA30; Mon, 3 Oct 2022 00:19:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2C175B80E80; Mon, 3 Oct 2022 07:16:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D8CC433B5; Mon, 3 Oct 2022 07:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781383; bh=dQwt73vypob3Ud3sUD0Ot0P3DTkjbOJMneyPHL9kAww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fchG+VZNKRaOssstqfkFHj1zksLmZBHxPOOhwb4s+es6GQ7z/BSd+Z0Edu69WBeeU reX/NY9cNKVQuz6f7xCfAyN/jM85bEWhdtr5hS/76MI4b2q/oBDSenlI5dke080jnB 7a1Odr7+wjRz6jMyDzqhJJgeTXzM+H9UlMoTUcPk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Levi Yun , SeongJae Park , Andrew Morton Subject: [PATCH 5.19 101/101] damon/sysfs: fix possible memleak on damon_sysfs_add_target Date: Mon, 3 Oct 2022 09:11:37 +0200 Message-Id: <20221003070726.938515610@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070724.490989164@linuxfoundation.org> References: <20221003070724.490989164@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Levi Yun commit 1c8e2349f2d033f634d046063b704b2ca6c46972 upstream. When damon_sysfs_add_target couldn't find proper task, New allocated damon_target structure isn't registered yet, So, it's impossible to free new allocated one by damon_sysfs_destroy_targets. By calling damon_add_target as soon as allocating new target, Fix this possible memory leak. Link: https://lkml.kernel.org/r/20220926160611.48536-1-sj@kernel.org Fixes: a61ea561c871 ("mm/damon/sysfs: link DAMON for virtual address spaces= monitoring") Signed-off-by: Levi Yun Signed-off-by: SeongJae Park Reviewed-by: SeongJae Park Cc: [5.17.x] Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Waiman Long Tested-by: Bagas Sanjaya Tested-by: Fenil Jain Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- mm/damon/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2181,13 +2181,13 @@ static int damon_sysfs_add_target(struct =20 if (!t) return -ENOMEM; + damon_add_target(ctx, t); if (ctx->ops.id =3D=3D DAMON_OPS_VADDR || ctx->ops.id =3D=3D DAMON_OPS_FVADDR) { t->pid =3D find_get_pid(sys_target->pid); if (!t->pid) goto destroy_targets_out; } - damon_add_target(ctx, t); err =3D damon_sysfs_set_regions(t, sys_target->regions); if (err) goto destroy_targets_out;