From nobody Sat Apr 18 21:00:48 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 9674DC433EF for ; Mon, 11 Jul 2022 09:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233190AbiGKJng (ORCPT ); Mon, 11 Jul 2022 05:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233231AbiGKJnA (ORCPT ); Mon, 11 Jul 2022 05:43:00 -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 0C0F09FE18; Mon, 11 Jul 2022 02:21: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 6D3EFB80E74; Mon, 11 Jul 2022 09:21:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7A35C34115; Mon, 11 Jul 2022 09:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531289; bh=+jjRG+CgW0KnPOvnqwFkBaHnVEYIrWfyqh7zscoWmfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSziatddSectZarKP8jiNO4eGEHALu5hOws8I09eGkev+1t5116YdAmLmS2LJWhnw WzqdDC3ZBvM8yWMG+zeyMkeWtEcnuF4Dud7h7yE5brOKOoXXehkUAeS4K5qF/d7FGV s2vpr2wWltO18zRx3ArOSGbScPgd//ZS7+nZ9pcQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Christoph Lameter , David Rientjes , Muchun Song , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Vlastimil Babka Subject: [PATCH 5.15 001/230] mm/slub: add missing TID updates on slab deactivation Date: Mon, 11 Jul 2022 11:04:17 +0200 Message-Id: <20220711090604.104215014@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jann Horn commit eeaa345e128515135ccb864c04482180c08e3259 upstream. The fastpath in slab_alloc_node() assumes that c->slab is stable as long as the TID stays the same. However, two places in __slab_alloc() currently don't update the TID when deactivating the CPU slab. If multiple operations race the right way, this could lead to an object getting lost; or, in an even more unlikely situation, it could even lead to an object being freed onto the wrong slab's freelist, messing up the `inuse` counter and eventually causing a page to be freed to the page allocator while it still contains slab objects. (I haven't actually tested these cases though, this is just based on looking at the code. Writing testcases for this stuff seems like it'd be a pain...) The race leading to state inconsistency is (all operations on the same CPU and kmem_cache): - task A: begin do_slab_free(): - read TID - read pcpu freelist (=3D=3DNULL) - check `slab =3D=3D c->slab` (true) - [PREEMPT A->B] - task B: begin slab_alloc_node(): - fastpath fails (`c->freelist` is NULL) - enter __slab_alloc() - slub_get_cpu_ptr() (disables preemption) - enter ___slab_alloc() - take local_lock_irqsave() - read c->freelist as NULL - get_freelist() returns NULL - write `c->slab =3D NULL` - drop local_unlock_irqrestore() - goto new_slab - slub_percpu_partial() is NULL - get_partial() returns NULL - slub_put_cpu_ptr() (enables preemption) - [PREEMPT B->A] - task A: finish do_slab_free(): - this_cpu_cmpxchg_double() succeeds() - [CORRUPT STATE: c->slab=3D=3DNULL, c->freelist!=3DNULL] >From there, the object on c->freelist will get lost if task B is allowed to continue from here: It will proceed to the retry_load_slab label, set c->slab, then jump to load_freelist, which clobbers c->freelist. But if we instead continue as follows, we get worse corruption: - task A: run __slab_free() on object from other struct slab: - CPU_PARTIAL_FREE case (slab was on no list, is now on pcpu partial) - task A: run slab_alloc_node() with NUMA node constraint: - fastpath fails (c->slab is NULL) - call __slab_alloc() - slub_get_cpu_ptr() (disables preemption) - enter ___slab_alloc() - c->slab is NULL: goto new_slab - slub_percpu_partial() is non-NULL - set c->slab to slub_percpu_partial(c) - [CORRUPT STATE: c->slab points to slab-1, c->freelist has objects from slab-2] - goto redo - node_match() fails - goto deactivate_slab - existing c->freelist is passed into deactivate_slab() - inuse count of slab-1 is decremented to account for object from slab-2 At this point, the inuse count of slab-1 is 1 lower than it should be. This means that if we free all allocated objects in slab-1 except for one, SLUB will think that slab-1 is completely unused, and may free its page, leading to use-after-free. Fixes: c17dda40a6a4e ("slub: Separate out kmem_cache_cpu processing from de= activate_slab") Fixes: 03e404af26dc2 ("slub: fast release on full slab") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Acked-by: Christoph Lameter Acked-by: David Rientjes Reviewed-by: Muchun Song Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Vlastimil Babka Link: https://lore.kernel.org/r/20220608182205.2945720-1-jannh@google.com Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- mm/slub.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/slub.c +++ b/mm/slub.c @@ -2935,6 +2935,7 @@ redo: =20 if (!freelist) { c->page =3D NULL; + c->tid =3D next_tid(c->tid); local_unlock_irqrestore(&s->cpu_slab->lock, flags); stat(s, DEACTIVATE_BYPASS); goto new_slab; @@ -2967,6 +2968,7 @@ deactivate_slab: freelist =3D c->freelist; c->page =3D NULL; c->freelist =3D NULL; + c->tid =3D next_tid(c->tid); local_unlock_irqrestore(&s->cpu_slab->lock, flags); deactivate_slab(s, page, freelist); From nobody Sat Apr 18 21:00:48 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 4E844C433EF for ; Mon, 11 Jul 2022 09:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbiGKJiQ (ORCPT ); Mon, 11 Jul 2022 05:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbiGKJh2 (ORCPT ); Mon, 11 Jul 2022 05:37:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE36583F01; Mon, 11 Jul 2022 02:19: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 ams.source.kernel.org (Postfix) with ESMTPS id 4E822B80E74; Mon, 11 Jul 2022 09:19:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEE7C34115; Mon, 11 Jul 2022 09:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531172; bh=iQ84uY8s4fGiSftDNeEMZ8xdGgAqkR5pl9zjUgtGbxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUqu6EdBDLjbTxIWGJgfJPCpfGMvgHhP58nTeruP9JfrMiUo8EB8xjATKOgCxQlur AbdKFQ6kTJnPlW5dhQxd68y0VBKWpp1LkoSCDxVYasf+pe+vIQj4s/5QoMwngveA/T e2qz0O3xbC9N3b1WYbwI2xoWR+l0dfPkIvfBHAyU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Shixin , "Matthew Wilcox (Oracle)" Subject: [PATCH 5.15 002/230] mm/filemap: fix UAF in find_lock_entries Date: Mon, 11 Jul 2022 11:04:18 +0200 Message-Id: <20220711090604.132579878@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Liu Shixin Release refcount after xas_set to fix UAF which may cause panic like this: page:ffffea000491fa40 refcount:1 mapcount:0 mapping:0000000000000000 index= :0x1 pfn:0x1247e9 head:ffffea000491fa00 order:3 compound_mapcount:0 compound_pincount:0 memcg:ffff888104f91091 flags: 0x2fffff80010200(slab|head|node=3D0|zone=3D2|lastcpupid=3D0x1fffff) ... page dumped because: VM_BUG_ON_PAGE(PageTail(page)) ------------[ cut here ]------------ kernel BUG at include/linux/page-flags.h:632! invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN CPU: 1 PID: 7642 Comm: sh Not tainted 5.15.51-dirty #26 ... Call Trace: __invalidate_mapping_pages+0xe7/0x540 drop_pagecache_sb+0x159/0x320 iterate_supers+0x120/0x240 drop_caches_sysctl_handler+0xaa/0xe0 proc_sys_call_handler+0x2b4/0x480 new_sync_write+0x3d6/0x5c0 vfs_write+0x446/0x7a0 ksys_write+0x105/0x210 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f52b5733130 ... This problem has been fixed on mainline by patch 6b24ca4a1a8d ("mm: Use multi-index entries in the page cache") since it deletes the related code. Fixes: 5c211ba29deb ("mm: add and use find_lock_entries") Signed-off-by: Liu Shixin Acked-by: Matthew Wilcox (Oracle) Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- mm/filemap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2090,7 +2090,11 @@ unsigned find_lock_entries(struct addres =20 rcu_read_lock(); while ((page =3D find_get_entry(&xas, end, XA_PRESENT))) { + unsigned long next_idx =3D xas.xa_index + 1; + if (!xa_is_value(page)) { + if (PageTransHuge(page)) + next_idx =3D page->index + thp_nr_pages(page); if (page->index < start) goto put; if (page->index + thp_nr_pages(page) - 1 > end) @@ -2111,13 +2115,11 @@ unlock: put: put_page(page); next: - if (!xa_is_value(page) && PageTransHuge(page)) { - unsigned int nr_pages =3D thp_nr_pages(page); - + if (next_idx !=3D xas.xa_index + 1) { /* Final THP may cross MAX_LFS_FILESIZE on 32-bit */ - xas_set(&xas, page->index + nr_pages); - if (xas.xa_index < nr_pages) + if (next_idx < xas.xa_index) break; + xas_set(&xas, next_idx); } } rcu_read_unlock(); From nobody Sat Apr 18 21:00:48 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 4EB1FC43334 for ; Mon, 11 Jul 2022 09:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233042AbiGKJjw (ORCPT ); Mon, 11 Jul 2022 05:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233133AbiGKJjJ (ORCPT ); Mon, 11 Jul 2022 05:39:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A8488CC4; Mon, 11 Jul 2022 02:20: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 42A9EB80DBA; Mon, 11 Jul 2022 09:20:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AAF8C34115; Mon, 11 Jul 2022 09:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531203; bh=YCL1pHabrAZsQ+ypy3aShkbc+c0GHfrm4urN9vWFSIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oih/6MTOxrgR3j6Q8TuvyIv0LBattG8fTDiIeRBLgw4m/m0WSa3N2J/nkrepqN7Em LK4fVYBKImVUIRxNYIiPZR3sde/AjTxwDPiAJKTZDHOMeUFP7+GFKzkMTpaKP6A5e8 1UsIouyGU4WBiv5/kRLKibeLOPyGdjqIwSQL8xsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Po-Hsu Lin Subject: [PATCH 5.15 003/230] Revert "selftests/bpf: Add test for bpf_timer overwriting crash" Date: Mon, 11 Jul 2022 11:04:19 +0200 Message-Id: <20220711090604.162280714@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Po-Hsu Lin This reverts commit b0028e1cc1faf2e5d88ad4065590aca90d650182 which is commit a7e75016a0753c24d6c995bc02501ae35368e333 upstream. It will break the bpf self-tests build with: progs/timer_crash.c:8:19: error: field has incomplete type 'struct bpf_time= r' struct bpf_timer timer; ^ /home/ubuntu/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helper= _defs.h:39:8: note: forward declaration of 'struct bpf_timer' struct bpf_timer; ^ 1 error generated. This test can only be built with 5.17 and newer kernels. Signed-off-by: Po-Hsu Lin Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- tools/testing/selftests/bpf/prog_tests/timer_crash.c | 32 ----------- tools/testing/selftests/bpf/progs/timer_crash.c | 54 --------------= ----- 2 files changed, 86 deletions(-) delete mode 100644 tools/testing/selftests/bpf/prog_tests/timer_crash.c delete mode 100644 tools/testing/selftests/bpf/progs/timer_crash.c --- a/tools/testing/selftests/bpf/prog_tests/timer_crash.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include "timer_crash.skel.h" - -enum { - MODE_ARRAY, - MODE_HASH, -}; - -static void test_timer_crash_mode(int mode) -{ - struct timer_crash *skel; - - skel =3D timer_crash__open_and_load(); - if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load")) - return; - skel->bss->pid =3D getpid(); - skel->bss->crash_map =3D mode; - if (!ASSERT_OK(timer_crash__attach(skel), "timer_crash__attach")) - goto end; - usleep(1); -end: - timer_crash__destroy(skel); -} - -void test_timer_crash(void) -{ - if (test__start_subtest("array")) - test_timer_crash_mode(MODE_ARRAY); - if (test__start_subtest("hash")) - test_timer_crash_mode(MODE_HASH); -} --- a/tools/testing/selftests/bpf/progs/timer_crash.c +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include -#include -#include - -struct map_elem { - struct bpf_timer timer; - struct bpf_spin_lock lock; -}; - -struct { - __uint(type, BPF_MAP_TYPE_ARRAY); - __uint(max_entries, 1); - __type(key, int); - __type(value, struct map_elem); -} amap SEC(".maps"); - -struct { - __uint(type, BPF_MAP_TYPE_HASH); - __uint(max_entries, 1); - __type(key, int); - __type(value, struct map_elem); -} hmap SEC(".maps"); - -int pid =3D 0; -int crash_map =3D 0; /* 0 for amap, 1 for hmap */ - -SEC("fentry/do_nanosleep") -int sys_enter(void *ctx) -{ - struct map_elem *e, value =3D {}; - void *map =3D crash_map ? (void *)&hmap : (void *)&amap; - - if (bpf_get_current_task_btf()->tgid !=3D pid) - return 0; - - *(void **)&value =3D (void *)0xdeadcaf3; - - bpf_map_update_elem(map, &(int){0}, &value, 0); - /* For array map, doing bpf_map_update_elem will do a - * check_and_free_timer_in_array, which will trigger the crash if timer - * pointer was overwritten, for hmap we need to use bpf_timer_cancel. - */ - if (crash_map =3D=3D 1) { - e =3D bpf_map_lookup_elem(map, &(int){0}); - if (!e) - return 0; - bpf_timer_cancel(&e->timer); - } - return 0; -} - -char _license[] SEC("license") =3D "GPL"; From nobody Sat Apr 18 21:00:48 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 F2632C433EF for ; Mon, 11 Jul 2022 09:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233286AbiGKJk5 (ORCPT ); Mon, 11 Jul 2022 05:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233232AbiGKJkV (ORCPT ); Mon, 11 Jul 2022 05:40:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01DBB8C760; Mon, 11 Jul 2022 02:20:35 -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 82436612A3; Mon, 11 Jul 2022 09:20:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9546EC34115; Mon, 11 Jul 2022 09:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531233; bh=gn6z5xNUSkjtagaL4BSFt6iLReVorGh4Ro3OTLFfa/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yz40VyOH3AceSZsG6Zne3a21efxkwhnuIBai4TM7KqtK8lrMM3m0sdk2NfBblZU2K 7HXSdadfu9T6jv6ImpJtBRbYWWYvq9MN8umhTbHk10t2na9c4DQmS/Vy/rSBzZ32Hb 80bZKl1/MlzsFYO+Cf8nPzzYv4Gijq3tmVOCkgZ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.15 004/230] ALSA: usb-audio: Workarounds for Behringer UMC 204/404 HD Date: Mon, 11 Jul 2022 11:04:20 +0200 Message-Id: <20220711090604.193001581@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Takashi Iwai commit ae8b1631561a3634cc09d0c62bbdd938eade05ec upstream. Both Behringer UMC 202 HD and 404 HD need explicit quirks to enable the implicit feedback mode and start the playback stream primarily. The former seems fixing the stuttering and the latter is required for a playback-only case. Note that the "clock source 41 is not valid" error message still appears even after this fix, but it should be only once at probe. The reason of the error is still unknown, but this seems to be mostly harmless as it's a one-off error and the driver retires the clock setup and it succeeds afterwards. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D215934 Cc: Link: https://lore.kernel.org/r/20220624101132.14528-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/usb/quirks.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1842,6 +1842,10 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), DEVICE_FLG(0x1395, 0x740a, /* Sennheiser DECT */ QUIRK_FLAG_GET_SAMPLE_RATE), + DEVICE_FLG(0x1397, 0x0508, /* Behringer UMC204HD */ + QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB), + DEVICE_FLG(0x1397, 0x0509, /* Behringer UMC404HD */ + QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB), DEVICE_FLG(0x13e5, 0x0001, /* Serato Phono */ QUIRK_FLAG_IGNORE_CTL_ERROR), DEVICE_FLG(0x154e, 0x1002, /* Denon DCD-1500RE */ From nobody Sat Apr 18 21:00:48 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 7BE29C433EF for ; Mon, 11 Jul 2022 09:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiGKJmh (ORCPT ); Mon, 11 Jul 2022 05:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233283AbiGKJmN (ORCPT ); Mon, 11 Jul 2022 05:42:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24DFD13F89; Mon, 11 Jul 2022 02:21:07 -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 9B2B7B80E7A; Mon, 11 Jul 2022 09:21:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E55D9C34115; Mon, 11 Jul 2022 09:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531264; bh=IaRUgGfHA+RRFpBTMZHWM764kBfEr2w8k+wgK7DdwJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXa+HQ/tOvfHf/8xYkNCxrYInzSLD4szqLRKxjgRvJxATFSpGL7WolHc8HtGypvUO zi2B/El4qZNunYaSJ0bCwyHPA/X2ikPteeAA+VRjk2yeRSU8e2mlKk1aiBy/i4vYTT 2zy+I0tD/qGB4QR05qT27hKHoovMn1uFaCP7HIbU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tim Crawford , Takashi Iwai Subject: [PATCH 5.15 005/230] ALSA: hda/realtek: Add quirk for Clevo L140PU Date: Mon, 11 Jul 2022 11:04:21 +0200 Message-Id: <20220711090604.220884239@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tim Crawford commit 11bea26929a1a3a9dd1a287b60c2f471701bf706 upstream. Fixes headset detection on Clevo L140PU. Signed-off-by: Tim Crawford Cc: Link: https://lore.kernel.org/r/20220624144109.3957-1-tcrawford@system76.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9001,6 +9001,7 @@ static const struct snd_pci_quirk alc269 SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_= NO_PRESENCE), SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MI= C_NO_PRESENCE), SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_N= O_PRESENCE), + SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_N= O_PRESENCE), SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_N= O_PRESENCE), SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MI= C_NO_PRESENCE), SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MI= C_NO_PRESENCE), From nobody Sat Apr 18 21:00:48 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 358ECC43334 for ; Mon, 11 Jul 2022 09:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233353AbiGKJm4 (ORCPT ); Mon, 11 Jul 2022 05:42:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiGKJmY (ORCPT ); Mon, 11 Jul 2022 05:42: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 04B23550A0; Mon, 11 Jul 2022 02:21: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 E39EB61227; Mon, 11 Jul 2022 09:21:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDEB8C34115; Mon, 11 Jul 2022 09:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531275; bh=4WZcDCsFE9fpCFpZDFTLUsccbZ30dyi6tyVEhn+pBDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nINfFq1ktqICL9BqTPcnjgd/qXfN4JkLJ7Nta1cub76XW85ARzg92yV9npvI1Im8/ h9uVoaN/JYkT4gR472oUEHDZ8KbSGjvRzMvy9CjJ9zOYe3BahRGh26SP7ZBHl5mrMi rBGd8v84XniKPQKj7zt2S+x1J1MHWw9zwA/N3Aoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Jan Engelhardt Subject: [PATCH 5.15 006/230] ALSA: cs46xx: Fix missing snd_card_free() call at probe error Date: Mon, 11 Jul 2022 11:04:22 +0200 Message-Id: <20220711090604.248954336@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Takashi Iwai commit c5e58c4545a69677d078b4c813b5d10d3481be9c upstream. The previous cleanup with devres may lead to the incorrect release orders at the probe error handling due to the devres's nature. Until we register the card, snd_card_free() has to be called at first for releasing the stuff properly when the driver tries to manage and release the stuff via card->private_free(). This patch fixes it by calling snd_card_free() manually on the error from the probe callback. Fixes: 5bff69b3645d ("ALSA: cs46xx: Allocate resources with device-managed = APIs") Cc: Reported-and-tested-by: Jan Engelhardt Link: https://lore.kernel.org/r/p2p1s96o-746-74p4-s95-61qo1p7782pn@vanv.qr Link: https://lore.kernel.org/r/20220705152336.350-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/pci/cs46xx/cs46xx.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -74,36 +74,36 @@ static int snd_card_cs46xx_probe(struct err =3D snd_cs46xx_create(card, pci, external_amp[dev], thinkpad[dev]); if (err < 0) - return err; + goto error; card->private_data =3D chip; chip->accept_valid =3D mmap_valid[dev]; err =3D snd_cs46xx_pcm(chip, 0); if (err < 0) - return err; + goto error; #ifdef CONFIG_SND_CS46XX_NEW_DSP err =3D snd_cs46xx_pcm_rear(chip, 1); if (err < 0) - return err; + goto error; err =3D snd_cs46xx_pcm_iec958(chip, 2); if (err < 0) - return err; + goto error; #endif err =3D snd_cs46xx_mixer(chip, 2); if (err < 0) - return err; + goto error; #ifdef CONFIG_SND_CS46XX_NEW_DSP if (chip->nr_ac97_codecs =3D=3D2) { err =3D snd_cs46xx_pcm_center_lfe(chip, 3); if (err < 0) - return err; + goto error; } #endif err =3D snd_cs46xx_midi(chip, 0); if (err < 0) - return err; + goto error; err =3D snd_cs46xx_start_dsp(chip); if (err < 0) - return err; + goto error; =20 snd_cs46xx_gameport(chip); =20 @@ -117,11 +117,15 @@ static int snd_card_cs46xx_probe(struct =20 err =3D snd_card_register(card); if (err < 0) - return err; + goto error; =20 pci_set_drvdata(pci, card); dev++; return 0; + + error: + snd_card_free(card); + return err; } =20 static struct pci_driver cs46xx_driver =3D { From nobody Sat Apr 18 21:00:48 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 27D35C43334 for ; Mon, 11 Jul 2022 09:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233315AbiGKJnL (ORCPT ); Mon, 11 Jul 2022 05:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiGKJmn (ORCPT ); Mon, 11 Jul 2022 05:42:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FE19CE2C; Mon, 11 Jul 2022 02:21: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 A4928B80E76; Mon, 11 Jul 2022 09:21:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1D5FC34115; Mon, 11 Jul 2022 09:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531278; bh=02Gr89cUsMTj9nZTGgI/higKfc2ahKfCiNE3RXAa/4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kMAwY66lAJtVWXVGI4FqiqmoLPXw+Uo+5XATgHafBlX9uwU/NDc9bDjbbbND7IqLC yNywmVasucG9i3esyukiTXnDbNWG2YuX4e1NzZcI/tZSGrn+tzVFmnia4bFHMOCISH S4hdlU88gUeG60NE+N4hpQZK9uhb7HUXO3GJTP2U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Norbert Slusarek , Thadeu Lima de Souza Cascardo , Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.15 007/230] can: bcm: use call_rcu() instead of costly synchronize_rcu() Date: Mon, 11 Jul 2022 11:04:23 +0200 Message-Id: <20220711090604.276988582@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Oliver Hartkopp commit f1b4e32aca0811aa011c76e5d6cf2fa19224b386 upstream. In commit d5f9023fa61e ("can: bcm: delay release of struct bcm_op after synchronize_rcu()") Thadeu Lima de Souza Cascardo introduced two synchronize_rcu() calls in bcm_release() (only once at socket close) and in bcm_delete_rx_op() (called on removal of each single bcm_op). Unfortunately this slow removal of the bcm_op's affects user space applications like cansniffer where the modification of a filter removes 2048 bcm_op's which blocks the cansniffer application for 40(!) seconds. In commit 181d4447905d ("can: gw: use call_rcu() instead of costly synchronize_rcu()") Eric Dumazet replaced the synchronize_rcu() calls with several call_rcu()'s to safely remove the data structures after the removal of CAN ID subscriptions with can_rx_unregister() calls. This patch adopts Erics approach for the can-bcm which should be applicable since the removal of tasklet_kill() in bcm_remove_op() and the introduction of the HRTIMER_MODE_SOFT timer handling in Linux 5.4. Fixes: d5f9023fa61e ("can: bcm: delay release of struct bcm_op after synchr= onize_rcu()") # >=3D 5.4 Link: https://lore.kernel.org/all/20220520183239.19111-1-socketcan@hartkopp= .net Cc: stable@vger.kernel.org Cc: Eric Dumazet Cc: Norbert Slusarek Cc: Thadeu Lima de Souza Cascardo Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/can/bcm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -100,6 +100,7 @@ static inline u64 get_u64(const struct c =20 struct bcm_op { struct list_head list; + struct rcu_head rcu; int ifindex; canid_t can_id; u32 flags; @@ -718,10 +719,9 @@ static struct bcm_op *bcm_find_op(struct return NULL; } =20 -static void bcm_remove_op(struct bcm_op *op) +static void bcm_free_op_rcu(struct rcu_head *rcu_head) { - hrtimer_cancel(&op->timer); - hrtimer_cancel(&op->thrtimer); + struct bcm_op *op =3D container_of(rcu_head, struct bcm_op, rcu); =20 if ((op->frames) && (op->frames !=3D &op->sframe)) kfree(op->frames); @@ -732,6 +732,14 @@ static void bcm_remove_op(struct bcm_op kfree(op); } =20 +static void bcm_remove_op(struct bcm_op *op) +{ + hrtimer_cancel(&op->timer); + hrtimer_cancel(&op->thrtimer); + + call_rcu(&op->rcu, bcm_free_op_rcu); +} + static void bcm_rx_unreg(struct net_device *dev, struct bcm_op *op) { if (op->rx_reg_dev =3D=3D dev) { @@ -757,6 +765,9 @@ static int bcm_delete_rx_op(struct list_ if ((op->can_id =3D=3D mh->can_id) && (op->ifindex =3D=3D ifindex) && (op->flags & CAN_FD_FRAME) =3D=3D (mh->flags & CAN_FD_FRAME)) { =20 + /* disable automatic timer on frame reception */ + op->flags |=3D RX_NO_AUTOTIMER; + /* * Don't care if we're bound or not (due to netdev * problems) can_rx_unregister() is always a save @@ -785,7 +796,6 @@ static int bcm_delete_rx_op(struct list_ bcm_rx_handler, op); =20 list_del(&op->list); - synchronize_rcu(); bcm_remove_op(op); return 1; /* done */ } From nobody Sat Apr 18 21:00:48 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 6385BC43334 for ; Mon, 11 Jul 2022 09:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233350AbiGKJnQ (ORCPT ); Mon, 11 Jul 2022 05:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233285AbiGKJmt (ORCPT ); Mon, 11 Jul 2022 05:42:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F5625590; Mon, 11 Jul 2022 02:21: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 ams.source.kernel.org (Postfix) with ESMTPS id 4F73BB80E7A; Mon, 11 Jul 2022 09:21:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EFFDC34115; Mon, 11 Jul 2022 09:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531281; bh=ruEx4MVS5M1wTW8qnmp6vimm1tVCSCBwM9ARVgswI6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihQ/lMVDJfMCuGzzPgQJAOL1Ow/ynkg5JLW7bkiwRza/bnyRijz37632DSPIaK4JL hkOMYbjg7d6lwIVOAdcuGDuCNsXofRjTFlUG1iYhp9AW5iNGEeePrNmzvHdAPFQ9K5 jNOIWCJ9/xK3sf/bsLF9omeSDmOpYGtz+8qtFDQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Larsson , Liang He , Marc Kleine-Budde Subject: [PATCH 5.15 008/230] can: grcan: grcan_probe(): remove extra of_node_get() Date: Mon, 11 Jul 2022 11:04:24 +0200 Message-Id: <20220711090604.304318285@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Liang He commit 562fed945ea482833667f85496eeda766d511386 upstream. In grcan_probe(), of_find_node_by_path() has already increased the refcount. There is no need to call of_node_get() again, so remove it. Link: https://lore.kernel.org/all/20220619070257.4067022-1-windhl@126.com Fixes: 1e93ed26acf0 ("can: grcan: grcan_probe(): fix broken system id check= for errata workaround needs") Cc: stable@vger.kernel.org # v5.18 Cc: Andreas Larsson Signed-off-by: Liang He Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/grcan.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1659,7 +1659,6 @@ static int grcan_probe(struct platform_d */ sysid_parent =3D of_find_node_by_path("/ambapp0"); if (sysid_parent) { - of_node_get(sysid_parent); err =3D of_property_read_u32(sysid_parent, "systemid", &sysid); if (!err && ((sysid & GRLIB_VERSION_MASK) >=3D GRCAN_TXBUG_SAFE_GRLIB_VERSION)) From nobody Sat Apr 18 21:00:48 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 5E176C433EF for ; Mon, 11 Jul 2022 09:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233200AbiGKJnV (ORCPT ); Mon, 11 Jul 2022 05:43:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230483AbiGKJmu (ORCPT ); Mon, 11 Jul 2022 05:42:50 -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 074189DEEF; Mon, 11 Jul 2022 02:21: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 ams.source.kernel.org (Postfix) with ESMTPS id 08100B80E87; Mon, 11 Jul 2022 09:21:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C89BC36AE9; Mon, 11 Jul 2022 09:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531283; bh=1qeYQQBwLgNxyjplQPoI2UqTmxio4frEoBOovOJ8Aws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAjXtbPlQLiyCaoHmvlRWQVqeG7ndzJl7uKDvQUZiG3plFkuNJiUqKzM5e2+cOtC6 TSBHuKgKlEy0/zsz7FtEKXProZzgTVhaICPhzP+KWIVtmfRGFu0iYe01q6OqwtguUS 4O7aiBpMKJrEzA4fcT7xfwuHT4Wi/l1wiH1/pw5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rhett Aultman , Marc Kleine-Budde Subject: [PATCH 5.15 009/230] can: gs_usb: gs_usb_open/close(): fix memory leak Date: Mon, 11 Jul 2022 11:04:25 +0200 Message-Id: <20220711090604.333222905@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Rhett Aultman commit 2bda24ef95c0311ab93bda00db40486acf30bd0a upstream. The gs_usb driver appears to suffer from a malady common to many USB CAN adapter drivers in that it performs usb_alloc_coherent() to allocate a number of USB request blocks (URBs) for RX, and then later relies on usb_kill_anchored_urbs() to free them, but this doesn't actually free them. As a result, this may be leaking DMA memory that's been used by the driver. This commit is an adaptation of the techniques found in the esd_usb2 driver where a similar design pattern led to a memory leak. It explicitly frees the RX URBs and their DMA memory via a call to usb_free_coherent(). Since the RX URBs were allocated in the gs_can_open(), we remove them in gs_can_close() rather than in the disconnect function as was done in esd_usb2. For more information, see the 928150fad41b ("can: esd_usb2: fix memory leak"). Link: https://lore.kernel.org/all/alpine.DEB.2.22.394.2206031547001.1630869= @thelappy Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices= ") Cc: stable@vger.kernel.org Signed-off-by: Rhett Aultman Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/usb/gs_usb.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c @@ -185,6 +185,8 @@ struct gs_can { =20 struct usb_anchor tx_submitted; atomic_t active_tx_urbs; + void *rxbuf[GS_MAX_RX_URBS]; + dma_addr_t rxbuf_dma[GS_MAX_RX_URBS]; }; =20 /* usb interface struct */ @@ -594,6 +596,7 @@ static int gs_can_open(struct net_device for (i =3D 0; i < GS_MAX_RX_URBS; i++) { struct urb *urb; u8 *buf; + dma_addr_t buf_dma; =20 /* alloc rx urb */ urb =3D usb_alloc_urb(0, GFP_KERNEL); @@ -604,7 +607,7 @@ static int gs_can_open(struct net_device buf =3D usb_alloc_coherent(dev->udev, sizeof(struct gs_host_frame), GFP_KERNEL, - &urb->transfer_dma); + &buf_dma); if (!buf) { netdev_err(netdev, "No memory left for USB buffer\n"); @@ -612,6 +615,8 @@ static int gs_can_open(struct net_device return -ENOMEM; } =20 + urb->transfer_dma =3D buf_dma; + /* fill, anchor, and submit rx urb */ usb_fill_bulk_urb(urb, dev->udev, @@ -635,10 +640,17 @@ static int gs_can_open(struct net_device rc); =20 usb_unanchor_urb(urb); + usb_free_coherent(dev->udev, + sizeof(struct gs_host_frame), + buf, + buf_dma); usb_free_urb(urb); break; } =20 + dev->rxbuf[i] =3D buf; + dev->rxbuf_dma[i] =3D buf_dma; + /* Drop reference, * USB core will take care of freeing it */ @@ -703,13 +715,20 @@ static int gs_can_close(struct net_devic int rc; struct gs_can *dev =3D netdev_priv(netdev); struct gs_usb *parent =3D dev->parent; + unsigned int i; =20 netif_stop_queue(netdev); =20 /* Stop polling */ parent->active_channels--; - if (!parent->active_channels) + if (!parent->active_channels) { usb_kill_anchored_urbs(&parent->rx_submitted); + for (i =3D 0; i < GS_MAX_RX_URBS; i++) + usb_free_coherent(dev->udev, + sizeof(struct gs_host_frame), + dev->rxbuf[i], + dev->rxbuf_dma[i]); + } =20 /* Stop sending URBs */ usb_kill_anchored_urbs(&dev->tx_submitted); From nobody Sat Apr 18 21:00:48 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 BF699C433EF for ; Mon, 11 Jul 2022 09:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233387AbiGKJnZ (ORCPT ); Mon, 11 Jul 2022 05:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbiGKJm5 (ORCPT ); Mon, 11 Jul 2022 05:42:57 -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 95E429F056; Mon, 11 Jul 2022 02:21: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 ams.source.kernel.org (Postfix) with ESMTPS id A2052B80E84; Mon, 11 Jul 2022 09:21:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C712C34115; Mon, 11 Jul 2022 09:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531286; bh=zlXhqlDzlQoxSL9b0traCeLjbAl5CQLc1Sb6lajihCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zQ4FzwbkLWhND+h1+BIVwQZTRF5NOYikk0xZPZj2e1kB4R6Eb3+agypKsRY4IliXt H9IYF2e1Nj2VdqmJCs0IUliaYA9gzRuW32Ra+lFaVWuzI+H54qm03e49NRbZF05o2V 1vVkysLA7Ih/QNBo/Jc/6+Wqjc1TLPk8ujGY1kV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Torin Cooper-Bennun , Chandrasekar Ramakrishnan , Marc Kleine-Budde Subject: [PATCH 5.15 010/230] can: m_can: m_can_chip_config(): actually enable internal timestamping Date: Mon, 11 Jul 2022 11:04:26 +0200 Message-Id: <20220711090604.362187336@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 5b12933de4e76ec164031c18ce8e0904abf530d7 upstream. In commit df06fd678260 ("can: m_can: m_can_chip_config(): enable and configure internal timestamps") the timestamping in the m_can core should be enabled. In peripheral mode, the RX'ed CAN frames, TX compete frames and error events are sorted by the timestamp. The above mentioned commit however forgot to enable the timestamping. Add the missing bits to enable the timestamp counter to the write of the Timestamp Counter Configuration register. Link: https://lore.kernel.org/all/20220612212708.4081756-1-mkl@pengutronix.= de Fixes: df06fd678260 ("can: m_can: m_can_chip_config(): enable and configure= internal timestamps") Cc: # 5.13 Cc: Torin Cooper-Bennun Reviewed-by: Chandrasekar Ramakrishnan Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/m_can/m_can.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1367,7 +1367,9 @@ static void m_can_chip_config(struct net /* enable internal timestamp generation, with a prescalar of 16. The * prescalar is applied to the nominal bit timing */ - m_can_write(cdev, M_CAN_TSCC, FIELD_PREP(TSCC_TCP_MASK, 0xf)); + m_can_write(cdev, M_CAN_TSCC, + FIELD_PREP(TSCC_TCP_MASK, 0xf) | + FIELD_PREP(TSCC_TSS_MASK, TSCC_TSS_INTERNAL)); =20 m_can_config_endisable(cdev, false); From nobody Sat Apr 18 21:00:48 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 DC68BC433EF for ; Mon, 11 Jul 2022 09:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbiGKJiW (ORCPT ); Mon, 11 Jul 2022 05:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbiGKJhg (ORCPT ); Mon, 11 Jul 2022 05:37:36 -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 6E7B684EC6; Mon, 11 Jul 2022 02:19: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 ams.source.kernel.org (Postfix) with ESMTPS id 22756B80D2C; Mon, 11 Jul 2022 09:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 800D5C34115; Mon, 11 Jul 2022 09:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531174; bh=vGd7W8KucNbrocptpdXwvh+HYLNgqBTB7aJLg508Tmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDXgk5g/1vYu3yR90FCd5EFMJsqs+VrvzP+TA+a3oU7xtGfM1s+QOtuLA2RUXVy8b U8yAhfqIkPtmVYv2RzRcAVb3ldWvMQUHEYubv78+xw18JYISjKV5JLRhnNWTAo3UTA urG6StD4ZuOj4O3abqPW2O+mXjYigXhWSXxiyZH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Torin Cooper-Bennun , Chandrasekar Ramakrishnan , Marc Kleine-Budde Subject: [PATCH 5.15 011/230] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits Date: Mon, 11 Jul 2022 11:04:27 +0200 Message-Id: <20220711090604.390790359@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 4c3333693f07313f5f0145a922f14a7d3c0f4f21 upstream. In commit 1be37d3b0414 ("can: m_can: fix periph RX path: use rx-offload to ensure skbs are sent from softirq context") the RX path for peripheral devices was switched to RX-offload. Received CAN frames are pushed to RX-offload together with a timestamp. RX-offload is designed to handle overflows of the timestamp correctly, if 32 bit timestamps are provided. The timestamps of m_can core are only 16 bits wide. So this patch shifts them to full 32 bit before passing them to RX-offload. Link: https://lore.kernel.org/all/20220612211410.4081390-1-mkl@pengutronix.= de Fixes: 1be37d3b0414 ("can: m_can: fix periph RX path: use rx-offload to ens= ure skbs are sent from softirq context") Cc: # 5.13 Cc: Torin Cooper-Bennun Reviewed-by: Chandrasekar Ramakrishnan Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/m_can/m_can.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -532,7 +532,7 @@ static int m_can_read_fifo(struct net_de stats->rx_packets++; stats->rx_bytes +=3D cf->len; =20 - timestamp =3D FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc); + timestamp =3D FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16; =20 m_can_receive_skb(cdev, skb, timestamp); =20 @@ -1043,7 +1043,7 @@ static int m_can_echo_tx_event(struct ne } =20 msg_mark =3D FIELD_GET(TX_EVENT_MM_MASK, txe); - timestamp =3D FIELD_GET(TX_EVENT_TXTS_MASK, txe); + timestamp =3D FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16; =20 /* ack txe element */ m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, From nobody Sat Apr 18 21:00:48 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 22E17C433EF for ; Mon, 11 Jul 2022 09:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbiGKJij (ORCPT ); Mon, 11 Jul 2022 05:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbiGKJhq (ORCPT ); Mon, 11 Jul 2022 05:37:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96F8F84EF1; Mon, 11 Jul 2022 02:19:40 -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 DECF4B80E6D; Mon, 11 Jul 2022 09:19:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EB5EC34115; Mon, 11 Jul 2022 09:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531177; bh=EH2MVkJDT0ydmZmxsK/QMoa0QsJj2WesG1Wewf6xwbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Skk/PXYqdoC8k7Qnx2wRwZBCyhHObTeoq6VlvbLoLNKV+SLku8QVc+eYrnJa8+aZU Sv+4bXne0IvebJ8GCxovkijwCdmIgteaUCkhoxE0T/mclBZpswFHIvB6Pa/+MWpO3j qfkesuFGTWnajjeoZqgHXOWRiaytAIUJ6+eZVZKQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Modilaynen , Thomas Kopp , Marc Kleine-Budde Subject: [PATCH 5.15 012/230] can: mcp251xfd: mcp251xfd_regmap_crc_read(): improve workaround handling for mcp2517fd Date: Mon, 11 Jul 2022 11:04:28 +0200 Message-Id: <20220711090604.419830899@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Thomas Kopp commit 406cc9cdb3e8d644b15e8028948f091b82abdbca upstream. The mcp251xfd compatible chips have an erratum ([1], [2]), where the received CRC doesn't match the calculated CRC. In commit c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") the following workaround was implementierend. - If a CRC read error on the TBC register is detected and the first byte is 0x00 or 0x80, the most significant bit of the first byte is flipped and the CRC is calculated again. - If the CRC now matches, the _original_ data is passed to the reader. For now we assume transferred data was OK. Measurements on the mcp2517fd show that the workaround is applicable not only of the lowest byte is 0x00 or 0x80, but also if 3 least significant bits are set. Update check on 1st data byte and workaround description accordingly. [1] mcp2517fd: DS80000792C: "Incorrect CRC for certain READ_CRC commands" [2] mcp2518fd: DS80000789C: "Incorrect CRC for certain READ_CRC commands" Link: https://lore.kernel.org/all/DM4PR11MB53901D49578FE265B239E55AFB7C9@DM= 4PR11MB5390.namprd11.prod.outlook.com Fixes: c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work aro= und broken CRC on TBC register") Cc: stable@vger.kernel.org Reported-by: Pavel Modilaynen Signed-off-by: Thomas Kopp [mkl: split into 2 patches, update patch description and documentation] Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c @@ -325,10 +325,12 @@ mcp251xfd_regmap_crc_read(void *context, * register. It increments once per SYS clock tick, * which is 20 or 40 MHz. * - * Observation shows that if the lowest byte (which is - * transferred first on the SPI bus) of that register - * is 0x00 or 0x80 the calculated CRC doesn't always - * match the transferred one. + * Observation on the mcp2518fd shows that if the + * lowest byte (which is transferred first on the SPI + * bus) of that register is 0x00 or 0x80 the + * calculated CRC doesn't always match the transferred + * one. On the mcp2517fd this problem is not limited + * to the first byte being 0x00 or 0x80. * * If the highest bit in the lowest byte is flipped * the transferred CRC matches the calculated one. We @@ -337,7 +339,8 @@ mcp251xfd_regmap_crc_read(void *context, * correct. */ if (reg =3D=3D MCP251XFD_REG_TBC && - (buf_rx->data[0] =3D=3D 0x0 || buf_rx->data[0] =3D=3D 0x80)) { + ((buf_rx->data[0] & 0xf8) =3D=3D 0x0 || + (buf_rx->data[0] & 0xf8) =3D=3D 0x80)) { /* Flip highest bit in lowest byte of le32 */ buf_rx->data[0] ^=3D 0x80; From nobody Sat Apr 18 21:00:48 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 2575CC433EF for ; Mon, 11 Jul 2022 09:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233152AbiGKJio (ORCPT ); Mon, 11 Jul 2022 05:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232967AbiGKJhs (ORCPT ); Mon, 11 Jul 2022 05:37:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53E4684EFF; Mon, 11 Jul 2022 02:19:41 -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 CED20612F1; Mon, 11 Jul 2022 09:19:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF97BC341C0; Mon, 11 Jul 2022 09:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531180; bh=ohZkBbfigAb/YiXoCchpRwV0Utyu12UcBZomEnYA7T0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2WiGHUtkAU46Fu5D+IRL3Q6cC1NsD1vXjMvr+/ozZXuBGZlS4gtaV+bSkSh3A+BNY 4RL3W4kGoTZi1u68pxfMnR4YOwhTQIaRyuxZRIZImBl/c39cgCwuiA0zvPI/Bd/1wl vNym0uMIn0bvMyF8kZ4GiUmClrqREopGxGXGHcSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Kopp , Marc Kleine-Budde Subject: [PATCH 5.15 013/230] can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register Date: Mon, 11 Jul 2022 11:04:29 +0200 Message-Id: <20220711090604.447608657@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Thomas Kopp commit e3d4ee7d5f7f5256dfe89219afcc7a2d553b731f upstream. The mcp251xfd compatible chips have an erratum ([1], [2]), where the received CRC doesn't match the calculated CRC. In commit c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") the following workaround was implementierend. - If a CRC read error on the TBC register is detected and the first byte is 0x00 or 0x80, the most significant bit of the first byte is flipped and the CRC is calculated again. - If the CRC now matches, the _original_ data is passed to the reader. For now we assume transferred data was OK. New investigations and simulations indicate that the CRC send by the device is calculated on correct data, and the data is incorrectly received by the SPI host controller. Use flipped instead of original data and update workaround description in mcp251xfd_regmap_crc_read(). [1] mcp2517fd: DS80000792C: "Incorrect CRC for certain READ_CRC commands" [2] mcp2518fd: DS80000789C: "Incorrect CRC for certain READ_CRC commands" Link: https://lore.kernel.org/all/DM4PR11MB53901D49578FE265B239E55AFB7C9@DM= 4PR11MB5390.namprd11.prod.outlook.com Fixes: c7eb923c3caf ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work aro= und broken CRC on TBC register") Cc: stable@vger.kernel.org Signed-off-by: Thomas Kopp [mkl: split into 2 patches, update patch description and documentation] Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c @@ -334,9 +334,8 @@ mcp251xfd_regmap_crc_read(void *context, * * If the highest bit in the lowest byte is flipped * the transferred CRC matches the calculated one. We - * assume for now the CRC calculation in the chip - * works on wrong data and the transferred data is - * correct. + * assume for now the CRC operates on the correct + * data. */ if (reg =3D=3D MCP251XFD_REG_TBC && ((buf_rx->data[0] & 0xf8) =3D=3D 0x0 || @@ -350,10 +349,8 @@ mcp251xfd_regmap_crc_read(void *context, val_len); if (!err) { /* If CRC is now correct, assume - * transferred data was OK, flip bit - * back to original value. + * flipped data is OK. */ - buf_rx->data[0] ^=3D 0x80; goto out; } } From nobody Sat Apr 18 21:00:48 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 70FB8C43334 for ; Mon, 11 Jul 2022 09:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbiGKJiy (ORCPT ); Mon, 11 Jul 2022 05:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbiGKJiC (ORCPT ); Mon, 11 Jul 2022 05:38:02 -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 9319186880; Mon, 11 Jul 2022 02:19:46 -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 8E53FCE125D; Mon, 11 Jul 2022 09:19:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2591C34115; Mon, 11 Jul 2022 09:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531183; bh=SuxZVYv0VPUMRWzbKD5w7HTqinGoGBAGbHLZ7cklbWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPg9XWlxXxBMW6JzHyUyWOohdzNXkX9Wfcvb95nMXrTiuHTrO7+/KFj324N4QvWKj 8JezDxWcsnOGAhuudq3yCat1ZuvsOrdUlVSasjJQ2FzlFoy+274sEKqbqoDmhBkNdi mqUuE2auLAimjjxZEzBWvR72EZRI5rcgVVWEMEng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuee K1r0a , Daniel Borkmann , Andrii Nakryiko , John Fastabend Subject: [PATCH 5.15 014/230] bpf: Fix incorrect verifier simulation around jmp32s jeq/jne Date: Mon, 11 Jul 2022 11:04:30 +0200 Message-Id: <20220711090604.476796935@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Borkmann commit a12ca6277eca6aeeccf66e840c23a2b520e24c8f upstream. Kuee reported a quirk in the jmp32's jeq/jne simulation, namely that the register value does not match expectations for the fall-through path. For example: Before fix: 0: R1=3Dctx(off=3D0,imm=3D0) R10=3Dfp0 0: (b7) r2 =3D 0 ; R2_w=3DP0 1: (b7) r6 =3D 563 ; R6_w=3DP563 2: (87) r2 =3D -r2 ; R2_w=3DPscalar() 3: (87) r2 =3D -r2 ; R2_w=3DPscalar() 4: (4c) w2 |=3D w6 ; R2_w=3DPscalar(umin=3D563,umax= =3D4294967295,var_off=3D(0x233; 0xfffffdcc),s32_min=3D-2147483085) R6_w=3DP= 563 5: (56) if w2 !=3D 0x8 goto pc+1 ; R2_w=3DP571 <--- [*] 6: (95) exit R0 !read_ok After fix: 0: R1=3Dctx(off=3D0,imm=3D0) R10=3Dfp0 0: (b7) r2 =3D 0 ; R2_w=3DP0 1: (b7) r6 =3D 563 ; R6_w=3DP563 2: (87) r2 =3D -r2 ; R2_w=3DPscalar() 3: (87) r2 =3D -r2 ; R2_w=3DPscalar() 4: (4c) w2 |=3D w6 ; R2_w=3DPscalar(umin=3D563,umax= =3D4294967295,var_off=3D(0x233; 0xfffffdcc),s32_min=3D-2147483085) R6_w=3DP= 563 5: (56) if w2 !=3D 0x8 goto pc+1 ; R2_w=3DP8 <--- [*] 6: (95) exit R0 !read_ok As can be seen on line 5 for the branch fall-through path in R2 [*] is that given condition w2 !=3D 0x8 is false, verifier should conclude that r2 =3D = 8 as upper 32 bit are known to be zero. However, verifier incorrectly concludes that r2 =3D 571 which is far off. The problem is it only marks false{true}_reg as known in the switch for JE/= NE case, but at the end of the function, it uses {false,true}_{64,32}off to update {false,true}_reg->var_off and they still hold the prior value of {false,true}_reg->var_off before it got marked as known. The subsequent __reg_combine_32_into_64() then propagates this old var_off and derives new bounds. The information between min/max bounds on {false,true}_reg from setting the register to known const combined with the {false,true}_reg->var= _off based on the old information then derives wrong register data. Fix it by detangling the BPF_JEQ/BPF_JNE cases and updating relevant {false,true}_{64,32}off tnums along with the register marking to known constant. Fixes: 3f50f132d840 ("bpf: Verifier, do explicit ALU32 bounds tracking") Reported-by: Kuee K1r0a Signed-off-by: Daniel Borkmann Signed-off-by: Andrii Nakryiko Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20220701124727.11153-1-daniel@iogearbox.n= et Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- kernel/bpf/verifier.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -8591,26 +8591,33 @@ static void reg_set_min_max(struct bpf_r return; =20 switch (opcode) { + /* JEQ/JNE comparison doesn't change the register equivalence. + * + * r1 =3D r2; + * if (r1 =3D=3D 42) goto label; + * ... + * label: // here both r1 and r2 are known to be 42. + * + * Hence when marking register as known preserve it's ID. + */ case BPF_JEQ: + if (is_jmp32) { + __mark_reg32_known(true_reg, val32); + true_32off =3D tnum_subreg(true_reg->var_off); + } else { + ___mark_reg_known(true_reg, val); + true_64off =3D true_reg->var_off; + } + break; case BPF_JNE: - { - struct bpf_reg_state *reg =3D - opcode =3D=3D BPF_JEQ ? true_reg : false_reg; - - /* JEQ/JNE comparison doesn't change the register equivalence. - * r1 =3D r2; - * if (r1 =3D=3D 42) goto label; - * ... - * label: // here both r1 and r2 are known to be 42. - * - * Hence when marking register as known preserve it's ID. - */ - if (is_jmp32) - __mark_reg32_known(reg, val32); - else - ___mark_reg_known(reg, val); + if (is_jmp32) { + __mark_reg32_known(false_reg, val32); + false_32off =3D tnum_subreg(false_reg->var_off); + } else { + ___mark_reg_known(false_reg, val); + false_64off =3D false_reg->var_off; + } break; - } case BPF_JSET: if (is_jmp32) { false_32off =3D tnum_and(false_32off, tnum_const(~val32)); From nobody Sat Apr 18 21:00:48 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 78923C43334 for ; Mon, 11 Jul 2022 09:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233174AbiGKJi4 (ORCPT ); Mon, 11 Jul 2022 05:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbiGKJiM (ORCPT ); Mon, 11 Jul 2022 05:38:12 -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 C5345868A6; Mon, 11 Jul 2022 02:19: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 2A6CDB80E7E; Mon, 11 Jul 2022 09:19:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BF07C34115; Mon, 11 Jul 2022 09:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531185; bh=BTdRQGUwh8mubNbXUJ+N9pwfwkRy8WzOkeXYeEula2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vMLbFqXt14RV3LzzdNC9XE5FJDk/S1/R1UPvhAFTTsLw6GHRTQWtFS0xFDF0JqrCn iYt3pUdULKCEpd8VbZDBS86hNMEuHsHToJIWo/uFZtnwqU/IhCPwVJyCjQ3hlC+q2s +EeXjf+xzdMHEyvBi1j7cVWZqlafX5Qp14GAwJFg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuee K1r0a , Daniel Borkmann , Andrii Nakryiko , John Fastabend Subject: [PATCH 5.15 015/230] bpf: Fix insufficient bounds propagation from adjust_scalar_min_max_vals Date: Mon, 11 Jul 2022 11:04:31 +0200 Message-Id: <20220711090604.505443679@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Borkmann commit 3844d153a41adea718202c10ae91dc96b37453b5 upstream. Kuee reported a corner case where the tnum becomes constant after the call to __reg_bound_offset(), but the register's bounds are not, that is, its min bounds are still not equal to the register's max bounds. This in turn allows to leak pointers through turning a pointer register as is into an unknown scalar via adjust_ptr_min_max_vals(). Before: func#0 @0 0: R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R10=3Dfp(off= =3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) 0: (b7) r0 =3D 1 ; R0_w=3Dscalar(imm=3D1,umin=3D1,= umax=3D1,var_off=3D(0x1; 0x0)) 1: (b7) r3 =3D 0 ; R3_w=3Dscalar(imm=3D0,umax=3D0,= var_off=3D(0x0; 0x0)) 2: (87) r3 =3D -r3 ; R3_w=3Dscalar() 3: (87) r3 =3D -r3 ; R3_w=3Dscalar() 4: (47) r3 |=3D 32767 ; R3_w=3Dscalar(smin=3D-922337203= 6854743041,umin=3D32767,var_off=3D(0x7fff; 0xffffffffffff8000),s32_min=3D-2= 147450881) 5: (75) if r3 s>=3D 0x0 goto pc+1 ; R3_w=3Dscalar(umin=3D9223372036= 854808575,var_off=3D(0x8000000000007fff; 0x7fffffffffff8000),s32_min=3D-214= 7450881,u32_min=3D32767) 6: (95) exit from 5 to 7: R0=3Dscalar(imm=3D1,umin=3D1,umax=3D1,var_off=3D(0x1; 0x0)) = R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R3=3Dscalar(umin=3D= 32767,umax=3D9223372036854775807,var_off=3D(0x7fff; 0x7fffffffffff8000),s32= _min=3D-2147450881) R10=3Dfp(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) 7: (d5) if r3 s<=3D 0x8000 goto pc+1 ; R3=3Dscalar(umin=3D32769,umax= =3D9223372036854775807,var_off=3D(0x7fff; 0x7fffffffffff8000),s32_min=3D-21= 47450881,u32_min=3D32767) 8: (95) exit from 7 to 9: R0=3Dscalar(imm=3D1,umin=3D1,umax=3D1,var_off=3D(0x1; 0x0)) = R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R3=3Dscalar(umin=3D= 32767,umax=3D32768,var_off=3D(0x7fff; 0x8000)) R10=3Dfp(off=3D0,imm=3D0,uma= x=3D0,var_off=3D(0x0; 0x0)) 9: (07) r3 +=3D -32767 ; R3_w=3Dscalar(imm=3D0,umax=3D1,= var_off=3D(0x0; 0x0)) <--- [*] 10: (95) exit What can be seen here is that R3=3Dscalar(umin=3D32767,umax=3D32768,var_off= =3D(0x7fff; 0x8000)) after the operation R3 +=3D -32767 results in a 'malformed' consta= nt, that is, R3_w=3Dscalar(imm=3D0,umax=3D1,var_off=3D(0x0; 0x0)). Intersecting with= var_off has not been done at that point via __update_reg_bounds(), which would have imp= roved the umax to be equal to umin. Refactor the tnum <> min/max bounds information flow into a reg_bounds_sync= () helper and use it consistently everywhere. After the fix, bounds have been corrected to R3_w=3Dscalar(imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) and thus = the register is regarded as a 'proper' constant scalar of 0. After: func#0 @0 0: R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R10=3Dfp(off= =3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) 0: (b7) r0 =3D 1 ; R0_w=3Dscalar(imm=3D1,umin=3D1,= umax=3D1,var_off=3D(0x1; 0x0)) 1: (b7) r3 =3D 0 ; R3_w=3Dscalar(imm=3D0,umax=3D0,= var_off=3D(0x0; 0x0)) 2: (87) r3 =3D -r3 ; R3_w=3Dscalar() 3: (87) r3 =3D -r3 ; R3_w=3Dscalar() 4: (47) r3 |=3D 32767 ; R3_w=3Dscalar(smin=3D-922337203= 6854743041,umin=3D32767,var_off=3D(0x7fff; 0xffffffffffff8000),s32_min=3D-2= 147450881) 5: (75) if r3 s>=3D 0x0 goto pc+1 ; R3_w=3Dscalar(umin=3D9223372036= 854808575,var_off=3D(0x8000000000007fff; 0x7fffffffffff8000),s32_min=3D-214= 7450881,u32_min=3D32767) 6: (95) exit from 5 to 7: R0=3Dscalar(imm=3D1,umin=3D1,umax=3D1,var_off=3D(0x1; 0x0)) = R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R3=3Dscalar(umin=3D= 32767,umax=3D9223372036854775807,var_off=3D(0x7fff; 0x7fffffffffff8000),s32= _min=3D-2147450881) R10=3Dfp(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) 7: (d5) if r3 s<=3D 0x8000 goto pc+1 ; R3=3Dscalar(umin=3D32769,umax= =3D9223372036854775807,var_off=3D(0x7fff; 0x7fffffffffff8000),s32_min=3D-21= 47450881,u32_min=3D32767) 8: (95) exit from 7 to 9: R0=3Dscalar(imm=3D1,umin=3D1,umax=3D1,var_off=3D(0x1; 0x0)) = R1=3Dctx(off=3D0,imm=3D0,umax=3D0,var_off=3D(0x0; 0x0)) R3=3Dscalar(umin=3D= 32767,umax=3D32768,var_off=3D(0x7fff; 0x8000)) R10=3Dfp(off=3D0,imm=3D0,uma= x=3D0,var_off=3D(0x0; 0x0)) 9: (07) r3 +=3D -32767 ; R3_w=3Dscalar(imm=3D0,umax=3D0,= var_off=3D(0x0; 0x0)) <--- [*] 10: (95) exit Fixes: b03c9f9fdc37 ("bpf/verifier: track signed and unsigned min/max value= s") Reported-by: Kuee K1r0a Signed-off-by: Daniel Borkmann Signed-off-by: Andrii Nakryiko Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20220701124727.11153-2-daniel@iogearbox.n= et Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- kernel/bpf/verifier.c | 72 +++++++++++++++------------------------------= ----- 1 file changed, 23 insertions(+), 49 deletions(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -1333,6 +1333,21 @@ static void __reg_bound_offset(struct bp reg->var_off =3D tnum_or(tnum_clear_subreg(var64_off), var32_off); } =20 +static void reg_bounds_sync(struct bpf_reg_state *reg) +{ + /* We might have learned new bounds from the var_off. */ + __update_reg_bounds(reg); + /* We might have learned something about the sign bit. */ + __reg_deduce_bounds(reg); + /* We might have learned some bits from the bounds. */ + __reg_bound_offset(reg); + /* Intersecting with the old var_off might have improved our bounds + * slightly, e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc), + * then new var_off is (0; 0x7f...fc) which improves our umax. + */ + __update_reg_bounds(reg); +} + static bool __reg32_bound_s64(s32 a) { return a >=3D 0 && a <=3D S32_MAX; @@ -1374,16 +1389,8 @@ static void __reg_combine_32_into_64(str * so they do not impact tnum bounds calculation. */ __mark_reg64_unbounded(reg); - __update_reg_bounds(reg); } - - /* Intersecting with the old var_off might have improved our bounds - * slightly. e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc), - * then new var_off is (0; 0x7f...fc) which improves our umax. - */ - __reg_deduce_bounds(reg); - __reg_bound_offset(reg); - __update_reg_bounds(reg); + reg_bounds_sync(reg); } =20 static bool __reg64_bound_s32(s64 a) @@ -1399,7 +1406,6 @@ static bool __reg64_bound_u32(u64 a) static void __reg_combine_64_into_32(struct bpf_reg_state *reg) { __mark_reg32_unbounded(reg); - if (__reg64_bound_s32(reg->smin_value) && __reg64_bound_s32(reg->smax_val= ue)) { reg->s32_min_value =3D (s32)reg->smin_value; reg->s32_max_value =3D (s32)reg->smax_value; @@ -1408,14 +1414,7 @@ static void __reg_combine_64_into_32(str reg->u32_min_value =3D (u32)reg->umin_value; reg->u32_max_value =3D (u32)reg->umax_value; } - - /* Intersecting with the old var_off might have improved our bounds - * slightly. e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc), - * then new var_off is (0; 0x7f...fc) which improves our umax. - */ - __reg_deduce_bounds(reg); - __reg_bound_offset(reg); - __update_reg_bounds(reg); + reg_bounds_sync(reg); } =20 /* Mark a register as having a completely unknown (scalar) value. */ @@ -6054,9 +6053,7 @@ static void do_refine_retval_range(struc ret_reg->s32_max_value =3D meta->msize_max_value; ret_reg->smin_value =3D -MAX_ERRNO; ret_reg->s32_min_value =3D -MAX_ERRNO; - __reg_deduce_bounds(ret_reg); - __reg_bound_offset(ret_reg); - __update_reg_bounds(ret_reg); + reg_bounds_sync(ret_reg); } =20 static int @@ -7216,11 +7213,7 @@ reject: =20 if (!check_reg_sane_offset(env, dst_reg, ptr_reg->type)) return -EINVAL; - - __update_reg_bounds(dst_reg); - __reg_deduce_bounds(dst_reg); - __reg_bound_offset(dst_reg); - + reg_bounds_sync(dst_reg); if (sanitize_check_bounds(env, insn, dst_reg) < 0) return -EACCES; if (sanitize_needed(opcode)) { @@ -7958,10 +7951,7 @@ static int adjust_scalar_min_max_vals(st /* ALU32 ops are zero extended into 64bit register */ if (alu32) zext_32_to_64(dst_reg); - - __update_reg_bounds(dst_reg); - __reg_deduce_bounds(dst_reg); - __reg_bound_offset(dst_reg); + reg_bounds_sync(dst_reg); return 0; } =20 @@ -8150,10 +8140,7 @@ static int check_alu_op(struct bpf_verif insn->dst_reg); } zext_32_to_64(dst_reg); - - __update_reg_bounds(dst_reg); - __reg_deduce_bounds(dst_reg); - __reg_bound_offset(dst_reg); + reg_bounds_sync(dst_reg); } } else { /* case: R =3D imm @@ -8756,21 +8743,8 @@ static void __reg_combine_min_max(struct dst_reg->smax_value); src_reg->var_off =3D dst_reg->var_off =3D tnum_intersect(src_reg->var_off, dst_reg->var_off); - /* We might have learned new bounds from the var_off. */ - __update_reg_bounds(src_reg); - __update_reg_bounds(dst_reg); - /* We might have learned something about the sign bit. */ - __reg_deduce_bounds(src_reg); - __reg_deduce_bounds(dst_reg); - /* We might have learned some bits from the bounds. */ - __reg_bound_offset(src_reg); - __reg_bound_offset(dst_reg); - /* Intersecting with the old var_off might have improved our bounds - * slightly. e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc), - * then new var_off is (0; 0x7f...fc) which improves our umax. - */ - __update_reg_bounds(src_reg); - __update_reg_bounds(dst_reg); + reg_bounds_sync(src_reg); + reg_bounds_sync(dst_reg); } =20 static void reg_combine_min_max(struct bpf_reg_state *true_src, From nobody Sat Apr 18 21:00:48 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 F31E8C43334 for ; Mon, 11 Jul 2022 09:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233181AbiGKJi6 (ORCPT ); Mon, 11 Jul 2022 05:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233125AbiGKJiP (ORCPT ); Mon, 11 Jul 2022 05:38:15 -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 C11E987207; Mon, 11 Jul 2022 02:19: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 ams.source.kernel.org (Postfix) with ESMTPS id 1F622B80E74; Mon, 11 Jul 2022 09:19:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C479C34115; Mon, 11 Jul 2022 09:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531188; bh=vb+0lighot6AX9XY2AUdCpU/s0sy+Et1zMwoqyMhtNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhTpuxtlivMAVQhX/+ZPfFkIDJ+YA1upEbkmcqOxriObV567ezDgy+a5Tl4gzAEDD 6YQr1soP6+2a8eU8G2utRIG/tG7YwiEyrskshPB4H37GYd1mkoSE/Qd8oBGV8kl3Uu iUBPZWAOEHanJbV+aZwXMloO/fVIOhJsQOla4jTQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Jakub Kicinski Subject: [PATCH 5.15 016/230] usbnet: fix memory leak in error case Date: Mon, 11 Jul 2022 11:04:32 +0200 Message-Id: <20220711090604.534314079@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Oliver Neukum commit b55a21b764c1e182014630fa5486d717484ac58f upstream. usbnet_write_cmd_async() mixed up which buffers need to be freed in which error case. v2: add Fixes tag v3: fix uninitialized buf pointer Fixes: 877bd862f32b8 ("usbnet: introduce usbnet 3 command helpers") Signed-off-by: Oliver Neukum Link: https://lore.kernel.org/r/20220705125351.17309-1-oneukum@suse.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/usb/usbnet.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -2135,7 +2135,7 @@ static void usbnet_async_cmd_cb(struct u int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype, u16 value, u16 index, const void *data, u16 size) { - struct usb_ctrlrequest *req =3D NULL; + struct usb_ctrlrequest *req; struct urb *urb; int err =3D -ENOMEM; void *buf =3D NULL; @@ -2153,7 +2153,7 @@ int usbnet_write_cmd_async(struct usbnet if (!buf) { netdev_err(dev->net, "Error allocating buffer" " in %s!\n", __func__); - goto fail_free; + goto fail_free_urb; } } =20 @@ -2177,14 +2177,21 @@ int usbnet_write_cmd_async(struct usbnet if (err < 0) { netdev_err(dev->net, "Error submitting the control" " message: status=3D%d\n", err); - goto fail_free; + goto fail_free_all; } return 0; =20 +fail_free_all: + kfree(req); fail_free_buf: kfree(buf); -fail_free: - kfree(req); + /* + * avoid a double free + * needed because the flag can be set only + * after filling the URB + */ + urb->transfer_flags =3D 0; +fail_free_urb: usb_free_urb(urb); fail: return err; From nobody Sat Apr 18 21:00:48 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 ABE10C43334 for ; Mon, 11 Jul 2022 09:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbiGKJjJ (ORCPT ); Mon, 11 Jul 2022 05:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233131AbiGKJia (ORCPT ); Mon, 11 Jul 2022 05:38:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D8587224; Mon, 11 Jul 2022 02:19:54 -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 13DA8B80E6D; Mon, 11 Jul 2022 09:19:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 433C1C34115; Mon, 11 Jul 2022 09:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531191; bh=lIq5QL1O+Kc+TdTym8+QkepgY8j0DpxAsVZjsV1n+AI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=um45Yrekoc4ya9V0JnX/aKeDpKtWKv/OYRyEhYG2/QkeGbg85cbLureUXF4krSMqD DAhHM5gDV+f7/+zBQTTx1PQ+HEyz+k1zmxD68DBg9SESeB0gvaRgSwd2clzaE0Xka8 XWr+rZsxiCz1z3eUiVMbS5rd2pXdeKZsC/LI+B9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Duoming Zhou , Jakub Kicinski Subject: [PATCH 5.15 017/230] net: rose: fix UAF bug caused by rose_t0timer_expiry Date: Mon, 11 Jul 2022 11:04:33 +0200 Message-Id: <20220711090604.562873193@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Duoming Zhou commit 148ca04518070910739dfc4eeda765057856403d upstream. There are UAF bugs caused by rose_t0timer_expiry(). The root cause is that del_timer() could not stop the timer handler that is running and there is no synchronization. One of the race conditions is shown below: (thread 1) | (thread 2) | rose_device_event | rose_rt_device_down | rose_remove_neigh rose_t0timer_expiry | rose_stop_t0timer(rose_neigh) ... | del_timer(&neigh->t0timer) | kfree(rose_neigh) //[1]FREE neigh->dce_mode //[2]USE | The rose_neigh is deallocated in position [1] and use in position [2]. The crash trace triggered by POC is like below: BUG: KASAN: use-after-free in expire_timers+0x144/0x320 Write of size 8 at addr ffff888009b19658 by task swapper/0/0 ... Call Trace: dump_stack_lvl+0xbf/0xee print_address_description+0x7b/0x440 print_report+0x101/0x230 ? expire_timers+0x144/0x320 kasan_report+0xed/0x120 ? expire_timers+0x144/0x320 expire_timers+0x144/0x320 __run_timers+0x3ff/0x4d0 run_timer_softirq+0x41/0x80 __do_softirq+0x233/0x544 ... This patch changes rose_stop_ftimer() and rose_stop_t0timer() in rose_remove_neigh() to del_timer_sync() in order that the timer handler could be finished before the resources such as rose_neigh and so on are deallocated. As a result, the UAF bugs could be mitigated. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Duoming Zhou Link: https://lore.kernel.org/r/20220705125610.77971-1-duoming@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/rose/rose_route.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c @@ -227,8 +227,8 @@ static void rose_remove_neigh(struct ros { struct rose_neigh *s; =20 - rose_stop_ftimer(rose_neigh); - rose_stop_t0timer(rose_neigh); + del_timer_sync(&rose_neigh->ftimer); + del_timer_sync(&rose_neigh->t0timer); =20 skb_queue_purge(&rose_neigh->queue); From nobody Sat Apr 18 21:00:48 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 61A3AC43334 for ; Mon, 11 Jul 2022 09:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbiGKJjq (ORCPT ); Mon, 11 Jul 2022 05:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbiGKJid (ORCPT ); Mon, 11 Jul 2022 05:38:33 -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 5D5C38723C; Mon, 11 Jul 2022 02:19: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 ams.source.kernel.org (Postfix) with ESMTPS id F3DB7B80833; Mon, 11 Jul 2022 09:19:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43FC4C34115; Mon, 11 Jul 2022 09:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531194; bh=IGjaSXXz+F58VMvnjySoD6f9kLwkf6beF4+9SB1lVBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eU83xhnjDc5oUtxW911ap0YpRKPhqhHxJXne8LTEVceblmF22N0grmTwDv3JPPNTH pV2/9l+Njb4o8z62/WqBNb37A0BzNjwLAzasTPSyMZiVF/RF7BLefgwMAh2dUQrZHO 9E76iqh2toJHbh5Qrw7aXaFHNcbgmOYNLUvziR8Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Brivio , Pablo Neira Ayuso Subject: [PATCH 5.15 018/230] netfilter: nft_set_pipapo: release elements in clone from abort path Date: Mon, 11 Jul 2022 11:04:34 +0200 Message-Id: <20220711090604.590837950@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pablo Neira Ayuso commit 9827a0e6e23bf43003cd3d5b7fb11baf59a35e1e upstream. New elements that reside in the clone are not released in case that the transaction is aborted. [16302.231754] ------------[ cut here ]------------ [16302.231756] WARNING: CPU: 0 PID: 100509 at net/netfilter/nf_tables_api.c= :1864 nf_tables_chain_destroy+0x26/0x127 [nf_tables] [...] [16302.231882] CPU: 0 PID: 100509 Comm: nft Tainted: G W 5.1= 9.0-rc3+ #155 [...] [16302.231887] RIP: 0010:nf_tables_chain_destroy+0x26/0x127 [nf_tables] [16302.231899] Code: f3 fe ff ff 41 55 41 54 55 53 48 8b 6f 10 48 89 fb 48 = c7 c7 82 96 d9 a0 8b 55 50 48 8b 75 58 e8 de f5 92 e0 83 7d 50 00 74 09 <0f= > 0b 5b 5d 41 5c 41 5d c3 4c 8b 65 00 48 8b 7d 08 49 39 fc 74 05 [...] [16302.231917] Call Trace: [16302.231919] [16302.231921] __nf_tables_abort.cold+0x23/0x28 [nf_tables] [16302.231934] nf_tables_abort+0x30/0x50 [nf_tables] [16302.231946] nfnetlink_rcv_batch+0x41a/0x840 [nfnetlink] [16302.231952] ? __nla_validate_parse+0x48/0x190 [16302.231959] nfnetlink_rcv+0x110/0x129 [nfnetlink] [16302.231963] netlink_unicast+0x211/0x340 [16302.231969] netlink_sendmsg+0x21e/0x460 Add nft_set_pipapo_match_destroy() helper function to release the elements in the lookup tables. Stefano Brivio says: "We additionally look for elements pointers in the cloned matching data if priv->dirty is set, because that means that cloned data might point to additional elements we did not commit to the working copy yet (such as the abort path case, but perhaps not limited to it)." Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation o= f ranges") Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/netfilter/nft_set_pipapo.c | 48 ++++++++++++++++++++++++++++--------= ----- 1 file changed, 33 insertions(+), 15 deletions(-) --- a/net/netfilter/nft_set_pipapo.c +++ b/net/netfilter/nft_set_pipapo.c @@ -2125,6 +2125,32 @@ out_scratch: } =20 /** + * nft_set_pipapo_match_destroy() - Destroy elements from key mapping array + * @set: nftables API set representation + * @m: matching data pointing to key mapping array + */ +static void nft_set_pipapo_match_destroy(const struct nft_set *set, + struct nft_pipapo_match *m) +{ + struct nft_pipapo_field *f; + int i, r; + + for (i =3D 0, f =3D m->f; i < m->field_count - 1; i++, f++) + ; + + for (r =3D 0; r < f->rules; r++) { + struct nft_pipapo_elem *e; + + if (r < f->rules - 1 && f->mt[r + 1].e =3D=3D f->mt[r].e) + continue; + + e =3D f->mt[r].e; + + nft_set_elem_destroy(set, e, true); + } +} + +/** * nft_pipapo_destroy() - Free private data for set and all committed elem= ents * @set: nftables API set representation */ @@ -2132,26 +2158,13 @@ static void nft_pipapo_destroy(const str { struct nft_pipapo *priv =3D nft_set_priv(set); struct nft_pipapo_match *m; - struct nft_pipapo_field *f; - int i, r, cpu; + int cpu; =20 m =3D rcu_dereference_protected(priv->match, true); if (m) { rcu_barrier(); =20 - for (i =3D 0, f =3D m->f; i < m->field_count - 1; i++, f++) - ; - - for (r =3D 0; r < f->rules; r++) { - struct nft_pipapo_elem *e; - - if (r < f->rules - 1 && f->mt[r + 1].e =3D=3D f->mt[r].e) - continue; - - e =3D f->mt[r].e; - - nft_set_elem_destroy(set, e, true); - } + nft_set_pipapo_match_destroy(set, m); =20 #ifdef NFT_PIPAPO_ALIGN free_percpu(m->scratch_aligned); @@ -2165,6 +2178,11 @@ static void nft_pipapo_destroy(const str } =20 if (priv->clone) { + m =3D priv->clone; + + if (priv->dirty) + nft_set_pipapo_match_destroy(set, m); + #ifdef NFT_PIPAPO_ALIGN free_percpu(priv->clone->scratch_aligned); #endif From nobody Sat Apr 18 21:00:48 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 51839C43334 for ; Mon, 11 Jul 2022 09:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbiGKJju (ORCPT ); Mon, 11 Jul 2022 05:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiGKJif (ORCPT ); Mon, 11 Jul 2022 05:38: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 99E7287352; Mon, 11 Jul 2022 02:19: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 0A5CE612A3; Mon, 11 Jul 2022 09:19:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13299C341C0; Mon, 11 Jul 2022 09:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531197; bh=+1rmFj3IQVm9APa8dq9DwcKW1nibTRw4FiU83hUaJz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Pfg6VtC6OQPiezkyOCtGvEt0Q79uMMCbzzRcHNTIgTRds1Xla1b1b9QNTydh8qRZ jq1ylpG9hS8I7V1D5uCNYi18SbzY+fV60ij00nCVEHshXFGwF39sjyAknnd48W85Oa 6R8hd5VZ0STorcbptXFKe/A2xCaPg9UodcaFI5Z8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugues ANGUELKOV , Pablo Neira Ayuso Subject: [PATCH 5.15 019/230] netfilter: nf_tables: stricter validation of element data Date: Mon, 11 Jul 2022 11:04:35 +0200 Message-Id: <20220711090604.618307892@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pablo Neira Ayuso commit 7e6bc1f6cabcd30aba0b11219d8e01b952eacbb6 upstream. Make sure element data type and length do not mismatch the one specified by the set declaration. Fixes: 7d7402642eaf ("netfilter: nf_tables: variable sized set element keys= / data") Reported-by: Hugues ANGUELKOV Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/netfilter/nf_tables_api.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5118,13 +5118,20 @@ static int nft_setelem_parse_data(struct struct nft_data *data, struct nlattr *attr) { + u32 dtype; int err; =20 err =3D nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr); if (err < 0) return err; =20 - if (desc->type !=3D NFT_DATA_VERDICT && desc->len !=3D set->dlen) { + if (set->dtype =3D=3D NFT_DATA_VERDICT) + dtype =3D NFT_DATA_VERDICT; + else + dtype =3D NFT_DATA_VALUE; + + if (dtype !=3D desc->type || + set->dlen !=3D desc->len) { nft_data_release(data, desc->type); return -EINVAL; } From nobody Sat Apr 18 21:00:48 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 4949BC43334 for ; Mon, 11 Jul 2022 09:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231431AbiGKJj5 (ORCPT ); Mon, 11 Jul 2022 05:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbiGKJjJ (ORCPT ); Mon, 11 Jul 2022 05:39:09 -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 AD0DA88776; Mon, 11 Jul 2022 02:20: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 sin.source.kernel.org (Postfix) with ESMTPS id B7424CE125D; Mon, 11 Jul 2022 09:20:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C72BEC34115; Mon, 11 Jul 2022 09:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531200; bh=iUrCCyu6FmQeyI8wW+k15UMGbAoBl7LzosdxiG9JmyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkamW7MFAnAPhP93X6vPieifCtw4j3sk8byVkmTb6KlM4qSKoTFiHsR54H/YYv9lh ekab/iQN567b9fcKkkaz1QWn3xyk0mZ5SE3fN1KWSP1h4OZn+0YhY/0iiTK7lb3OZg Svuhepw0K4VEOt+YPxkuHrEmD6bXEVtrwEu/ZqnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Anand Jain , Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 5.15 020/230] btrfs: rename btrfs_alloc_chunk to btrfs_create_chunk Date: Mon, 11 Jul 2022 11:04:36 +0200 Message-Id: <20220711090604.646648146@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Nikolay Borisov [ Upstream commit f6f39f7a0add4e7fd120a709545b57586a1d0393 ] The user facing function used to allocate new chunks is btrfs_chunk_alloc, unfortunately there is yet another similar sounding function - btrfs_alloc_chunk. This creates confusion, especially since the latter function can be considered "private" in the sense that it implements the first stage of chunk creation and as such is called by btrfs_chunk_alloc. To avoid the awkwardness that comes with having similarly named but distinctly different in their purpose function rename btrfs_alloc_chunk to btrfs_create_chunk, given that the main purpose of this function is to orchestrate the whole process of allocating a chunk - reserving space into devices, deciding on characteristics of the stripe size and creating the in-memory structures. Reviewed-by: Filipe Manana Reviewed-by: Anand Jain Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/block-group.c | 6 +++--- fs/btrfs/volumes.c | 10 +++++----- fs/btrfs/volumes.h | 2 +- fs/btrfs/zoned.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 37418b183b07..aadc1203ad88 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3400,7 +3400,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *= trans, u64 flags) */ check_system_chunk(trans, flags); =20 - bg =3D btrfs_alloc_chunk(trans, flags); + bg =3D btrfs_create_chunk(trans, flags); if (IS_ERR(bg)) { ret =3D PTR_ERR(bg); goto out; @@ -3461,7 +3461,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *= trans, u64 flags) const u64 sys_flags =3D btrfs_system_alloc_profile(trans->fs_info); struct btrfs_block_group *sys_bg; =20 - sys_bg =3D btrfs_alloc_chunk(trans, sys_flags); + sys_bg =3D btrfs_create_chunk(trans, sys_flags); if (IS_ERR(sys_bg)) { ret =3D PTR_ERR(sys_bg); btrfs_abort_transaction(trans, ret); @@ -3754,7 +3754,7 @@ void check_system_chunk(struct btrfs_trans_handle *tr= ans, u64 type) * could deadlock on an extent buffer since our caller may be * COWing an extent buffer from the chunk btree. */ - bg =3D btrfs_alloc_chunk(trans, flags); + bg =3D btrfs_create_chunk(trans, flags); if (IS_ERR(bg)) { ret =3D PTR_ERR(bg); } else if (!(type & BTRFS_BLOCK_GROUP_SYSTEM)) { diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 378e03a93e10..b75ce79a2540 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3131,7 +3131,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *tra= ns, u64 chunk_offset) const u64 sys_flags =3D btrfs_system_alloc_profile(fs_info); struct btrfs_block_group *sys_bg; =20 - sys_bg =3D btrfs_alloc_chunk(trans, sys_flags); + sys_bg =3D btrfs_create_chunk(trans, sys_flags); if (IS_ERR(sys_bg)) { ret =3D PTR_ERR(sys_bg); btrfs_abort_transaction(trans, ret); @@ -5010,7 +5010,7 @@ static void check_raid1c34_incompat_flag(struct btrfs= _fs_info *info, u64 type) } =20 /* - * Structure used internally for __btrfs_alloc_chunk() function. + * Structure used internally for btrfs_create_chunk() function. * Wraps needed parameters. */ struct alloc_chunk_ctl { @@ -5414,7 +5414,7 @@ static struct btrfs_block_group *create_chunk(struct = btrfs_trans_handle *trans, return block_group; } =20 -struct btrfs_block_group *btrfs_alloc_chunk(struct btrfs_trans_handle *tra= ns, +struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *tr= ans, u64 type) { struct btrfs_fs_info *info =3D trans->fs_info; @@ -5615,12 +5615,12 @@ static noinline int init_first_rw_device(struct btr= fs_trans_handle *trans) */ =20 alloc_profile =3D btrfs_metadata_alloc_profile(fs_info); - meta_bg =3D btrfs_alloc_chunk(trans, alloc_profile); + meta_bg =3D btrfs_create_chunk(trans, alloc_profile); if (IS_ERR(meta_bg)) return PTR_ERR(meta_bg); =20 alloc_profile =3D btrfs_system_alloc_profile(fs_info); - sys_bg =3D btrfs_alloc_chunk(trans, alloc_profile); + sys_bg =3D btrfs_create_chunk(trans, alloc_profile); if (IS_ERR(sys_bg)) return PTR_ERR(sys_bg); =20 diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 4db10d071d67..d86a6f9f166c 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -454,7 +454,7 @@ int btrfs_get_io_geometry(struct btrfs_fs_info *fs_info= , struct extent_map *map, struct btrfs_io_geometry *io_geom); int btrfs_read_sys_array(struct btrfs_fs_info *fs_info); int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info); -struct btrfs_block_group *btrfs_alloc_chunk(struct btrfs_trans_handle *tra= ns, +struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *tr= ans, u64 type); void btrfs_mapping_tree_free(struct extent_map_tree *tree); blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 596b2148807d..3bc2f92cd197 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -636,7 +636,7 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_inf= o) =20 /* * stripe_size is always aligned to BTRFS_STRIPE_LEN in - * __btrfs_alloc_chunk(). Since we want stripe_len =3D=3D zone_size, + * btrfs_create_chunk(). Since we want stripe_len =3D=3D zone_size, * check the alignment here. */ if (!IS_ALIGNED(zone_size, BTRFS_STRIPE_LEN)) { --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B6AFCC433EF for ; Mon, 11 Jul 2022 09:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbiGKJkB (ORCPT ); Mon, 11 Jul 2022 05:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbiGKJjM (ORCPT ); Mon, 11 Jul 2022 05:39:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66BA501AF; Mon, 11 Jul 2022 02:20: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 1C60FB80E6D; Mon, 11 Jul 2022 09:20:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AABDC34115; Mon, 11 Jul 2022 09:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531205; bh=mh8G2iS5VNUGeerfvoPdRHC6B3Jn8BQ3uuNu5i2Z+gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOyIT7yyLaFIveWAveD6ax1QRcXJ/samm3BAvKCMoG3oEGVT8c1TN5dnC4mqOZiyV SIefgZJa7xXGLfDAPhTWfQvESMgDWBmELcgjkhkUhs17oZn6L4PDX66aMGEPT4j65w whmBiFbOSr5c5JOJddE6H4vHzhgpIX51U1mWGvRY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 5.15 021/230] btrfs: add additional parameters to btrfs_init_tree_ref/btrfs_init_data_ref Date: Mon, 11 Jul 2022 11:04:37 +0200 Message-Id: <20220711090604.675057261@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Nikolay Borisov [ Upstream commit f42c5da6c12e990d8ec415199600b4d593c63bf5 ] In order to make 'real_root' used only in ref-verify it's required to have the necessary context to perform the same checks that this member is used for. So add 'mod_root' which will contain the root on behalf of which a delayed ref was created and a 'skip_group' parameter which will contain callsite-specific override of skip_qgroup. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/delayed-ref.h | 5 +++-- fs/btrfs/extent-tree.c | 17 +++++++++++------ fs/btrfs/file.c | 13 ++++++++----- fs/btrfs/inode.c | 3 ++- fs/btrfs/relocation.c | 21 ++++++++++++++------- fs/btrfs/tree-log.c | 2 +- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index e22fba272e4f..31266ba1d430 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -271,7 +271,7 @@ static inline void btrfs_init_generic_ref(struct btrfs_= ref *generic_ref, } =20 static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, - int level, u64 root) + int level, u64 root, u64 mod_root, bool skip_qgroup) { /* If @real_root not set, use @root as fallback */ if (!generic_ref->real_root) @@ -282,7 +282,8 @@ static inline void btrfs_init_tree_ref(struct btrfs_ref= *generic_ref, } =20 static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref, - u64 ref_root, u64 ino, u64 offset) + u64 ref_root, u64 ino, u64 offset, u64 mod_root, + bool skip_qgroup) { /* If @real_root not set, use @root as fallback */ if (!generic_ref->real_root) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 514adc83577f..e01b9344fb9c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2440,7 +2440,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle = *trans, num_bytes, parent); generic_ref.real_root =3D root->root_key.objectid; btrfs_init_data_ref(&generic_ref, ref_root, key.objectid, - key.offset); + key.offset, root->root_key.objectid, + for_reloc); generic_ref.skip_qgroup =3D for_reloc; if (inc) ret =3D btrfs_inc_extent_ref(trans, &generic_ref); @@ -2454,7 +2455,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle = *trans, btrfs_init_generic_ref(&generic_ref, action, bytenr, num_bytes, parent); generic_ref.real_root =3D root->root_key.objectid; - btrfs_init_tree_ref(&generic_ref, level - 1, ref_root); + btrfs_init_tree_ref(&generic_ref, level - 1, ref_root, + root->root_key.objectid, for_reloc); generic_ref.skip_qgroup =3D for_reloc; if (inc) ret =3D btrfs_inc_extent_ref(trans, &generic_ref); @@ -3289,7 +3291,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle = *trans, btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, buf->start, buf->len, parent); btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf), - root->root_key.objectid); + root->root_key.objectid, 0, false); =20 if (root->root_key.objectid !=3D BTRFS_TREE_LOG_OBJECTID) { btrfs_ref_tree_mod(fs_info, &generic_ref); @@ -4705,7 +4707,8 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_tra= ns_handle *trans, =20 btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT, ins->objectid, ins->offset, 0); - btrfs_init_data_ref(&generic_ref, root->root_key.objectid, owner, offset); + btrfs_init_data_ref(&generic_ref, root->root_key.objectid, owner, + offset, 0, false); btrfs_ref_tree_mod(root->fs_info, &generic_ref); =20 return btrfs_add_delayed_data_ref(trans, &generic_ref, ram_bytes); @@ -4898,7 +4901,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct b= trfs_trans_handle *trans, btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT, ins.objectid, ins.offset, parent); generic_ref.real_root =3D root->root_key.objectid; - btrfs_init_tree_ref(&generic_ref, level, root_objectid); + btrfs_init_tree_ref(&generic_ref, level, root_objectid, + root->root_key.objectid, false); btrfs_ref_tree_mod(fs_info, &generic_ref); ret =3D btrfs_add_delayed_tree_ref(trans, &generic_ref, extent_op); if (ret) @@ -5315,7 +5319,8 @@ static noinline int do_walk_down(struct btrfs_trans_h= andle *trans, =20 btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr, fs_info->nodesize, parent); - btrfs_init_tree_ref(&ref, level - 1, root->root_key.objectid); + btrfs_init_tree_ref(&ref, level - 1, root->root_key.objectid, + 0, false); ret =3D btrfs_free_extent(trans, &ref); if (ret) goto out_unlock; diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index a06c8366a8f4..1c597cd6c024 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -869,7 +869,8 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, btrfs_init_data_ref(&ref, root->root_key.objectid, new_key.objectid, - args->start - extent_offset); + args->start - extent_offset, + 0, false); ret =3D btrfs_inc_extent_ref(trans, &ref); BUG_ON(ret); /* -ENOMEM */ } @@ -955,7 +956,8 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, btrfs_init_data_ref(&ref, root->root_key.objectid, key.objectid, - key.offset - extent_offset); + key.offset - extent_offset, 0, + false); ret =3D btrfs_free_extent(trans, &ref); BUG_ON(ret); /* -ENOMEM */ args->bytes_found +=3D extent_end - key.offset; @@ -1232,7 +1234,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_hand= le *trans, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, bytenr, num_bytes, 0); btrfs_init_data_ref(&ref, root->root_key.objectid, ino, - orig_offset); + orig_offset, 0, false); ret =3D btrfs_inc_extent_ref(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); @@ -1257,7 +1259,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_hand= le *trans, other_end =3D 0; btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr, num_bytes, 0); - btrfs_init_data_ref(&ref, root->root_key.objectid, ino, orig_offset); + btrfs_init_data_ref(&ref, root->root_key.objectid, ino, orig_offset, + 0, false); if (extent_mergeable(leaf, path->slots[0] + 1, ino, bytenr, orig_offset, &other_start, &other_end)) { @@ -2715,7 +2718,7 @@ static int btrfs_insert_replace_extent(struct btrfs_t= rans_handle *trans, extent_info->disk_len, 0); ref_offset =3D extent_info->file_offset - extent_info->data_offset; btrfs_init_data_ref(&ref, root->root_key.objectid, - btrfs_ino(inode), ref_offset); + btrfs_ino(inode), ref_offset, 0, false); ret =3D btrfs_inc_extent_ref(trans, &ref); } =20 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 044d584c3467..d644dcaf3004 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4919,7 +4919,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_han= dle *trans, extent_start, extent_num_bytes, 0); ref.real_root =3D root->root_key.objectid; btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), - ino, extent_offset); + ino, extent_offset, + root->root_key.objectid, false); ret =3D btrfs_free_extent(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index a6661f2ad2c0..0300770c0a89 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1147,7 +1147,8 @@ int replace_file_extents(struct btrfs_trans_handle *t= rans, num_bytes, parent); ref.real_root =3D root->root_key.objectid; btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), - key.objectid, key.offset); + key.objectid, key.offset, + root->root_key.objectid, false); ret =3D btrfs_inc_extent_ref(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); @@ -1158,7 +1159,8 @@ int replace_file_extents(struct btrfs_trans_handle *t= rans, num_bytes, parent); ref.real_root =3D root->root_key.objectid; btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), - key.objectid, key.offset); + key.objectid, key.offset, + root->root_key.objectid, false); ret =3D btrfs_free_extent(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); @@ -1368,7 +1370,8 @@ int replace_path(struct btrfs_trans_handle *trans, st= ruct reloc_control *rc, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, old_bytenr, blocksize, path->nodes[level]->start); ref.skip_qgroup =3D true; - btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid); + btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, + 0, true); ret =3D btrfs_inc_extent_ref(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); @@ -1377,7 +1380,8 @@ int replace_path(struct btrfs_trans_handle *trans, st= ruct reloc_control *rc, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr, blocksize, 0); ref.skip_qgroup =3D true; - btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid); + btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, 0, + true); ret =3D btrfs_inc_extent_ref(trans, &ref); if (ret) { btrfs_abort_transaction(trans, ret); @@ -1386,7 +1390,8 @@ int replace_path(struct btrfs_trans_handle *trans, st= ruct reloc_control *rc, =20 btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, new_bytenr, blocksize, path->nodes[level]->start); - btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid); + btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, + 0, true); ref.skip_qgroup =3D true; ret =3D btrfs_free_extent(trans, &ref); if (ret) { @@ -1396,7 +1401,8 @@ int replace_path(struct btrfs_trans_handle *trans, st= ruct reloc_control *rc, =20 btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, old_bytenr, blocksize, 0); - btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid); + btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, + 0, true); ref.skip_qgroup =3D true; ret =3D btrfs_free_extent(trans, &ref); if (ret) { @@ -2475,7 +2481,8 @@ static int do_relocation(struct btrfs_trans_handle *t= rans, upper->eb->start); ref.real_root =3D root->root_key.objectid; btrfs_init_tree_ref(&ref, node->level, - btrfs_header_owner(upper->eb)); + btrfs_header_owner(upper->eb), + root->root_key.objectid, false); ret =3D btrfs_inc_extent_ref(trans, &ref); if (!ret) ret =3D btrfs_drop_subtree(trans, root, eb, diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 1221d8483d63..bed6811476b0 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -761,7 +761,7 @@ static noinline int replay_one_extent(struct btrfs_tran= s_handle *trans, ins.objectid, ins.offset, 0); btrfs_init_data_ref(&ref, root->root_key.objectid, - key->objectid, offset); + key->objectid, offset, 0, false); ret =3D btrfs_inc_extent_ref(trans, &ref); if (ret) goto out; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 0CCDCC433EF for ; Mon, 11 Jul 2022 09:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233224AbiGKJlK (ORCPT ); Mon, 11 Jul 2022 05:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbiGKJjN (ORCPT ); Mon, 11 Jul 2022 05:39:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9FF688CD2; Mon, 11 Jul 2022 02:20: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 387B8612A0; Mon, 11 Jul 2022 09:20:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FB11C34115; Mon, 11 Jul 2022 09:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531208; bh=mR8+1VFRbjgbOw/MaGg2JRPPf/N1EJ5dgQKd0JnY/YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6NhriXm2wr2xR78IqRMXo10Flyva3fV63jcgtWql6u6KAjwhAzZhb5HcQc1K0DRr gnA6EzMxtMQn+f1yiUYQ/U14hgLAfnhNkMJpUHojaxdI8KudSuhsupDgEP2Fce1smg EerS3R15lzY1J5zxDoybfgk5YBrC3ZUJqpe0i7mU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 5.15 022/230] btrfs: fix invalid delayed ref after subvolume creation failure Date: Mon, 11 Jul 2022 11:04:38 +0200 Message-Id: <20220711090604.703041478@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Filipe Manana [ Upstream commit 7a1636089acfee7562fe79aff7d1b4c57869896d ] When creating a subvolume, at ioctl.c:create_subvol(), if we fail to insert the new root's root item into the root tree, we are freeing the metadata extent we reserved for the new root to prevent a metadata extent leak, as we don't abort the transaction at that point (since there is nothing at that point that is irreversible). However we allocated the metadata extent for the new root which we are creating for the new subvolume, so its delayed reference refers to the ID of this new root. But when we free the metadata extent we pass the root of the subvolume where the new subvolume is located to btrfs_free_tree_block() - this is incorrect because this will generate a delayed reference that refers to the ID of the parent subvolume's root, and not to ID of the new root. This results in a failure when running delayed references that leads to a transaction abort and a trace like the following: [3868.738042] RIP: 0010:__btrfs_free_extent+0x709/0x950 [btrfs] [3868.739857] Code: 68 0f 85 e6 fb ff (...) [3868.742963] RSP: 0018:ffffb0e9045cf910 EFLAGS: 00010246 [3868.743908] RAX: 00000000fffffffe RBX: 00000000fffffffe RCX: 000000000000= 0002 [3868.745312] RDX: 00000000fffffffe RSI: 0000000000000002 RDI: ffff90b0cd79= 3b88 [3868.746643] RBP: 000000000e5d8000 R08: 0000000000000000 R09: ffff90b0cd79= 3b88 [3868.747979] R10: 0000000000000002 R11: 00014ded97944d68 R12: 000000000000= 0000 [3868.749373] R13: ffff90b09afe4a28 R14: 0000000000000000 R15: ffff90b0cd79= 3b88 [3868.750725] FS: 00007f281c4a8b80(0000) GS:ffff90b3ada00000(0000) knlGS:0= 000000000000000 [3868.752275] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [3868.753515] CR2: 00007f281c6a5000 CR3: 0000000108a42006 CR4: 000000000037= 0ee0 [3868.754869] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 000000000000= 0000 [3868.756228] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 000000000000= 0400 [3868.757803] Call Trace: [3868.758281] [3868.758655] ? btrfs_merge_delayed_refs+0x178/0x1c0 [btrfs] [3868.759827] __btrfs_run_delayed_refs+0x2b1/0x1250 [btrfs] [3868.761047] btrfs_run_delayed_refs+0x86/0x210 [btrfs] [3868.762069] ? lock_acquired+0x19f/0x420 [3868.762829] btrfs_commit_transaction+0x69/0xb20 [btrfs] [3868.763860] ? _raw_spin_unlock+0x29/0x40 [3868.764614] ? btrfs_block_rsv_release+0x1c2/0x1e0 [btrfs] [3868.765870] create_subvol+0x1d8/0x9a0 [btrfs] [3868.766766] btrfs_mksubvol+0x447/0x4c0 [btrfs] [3868.767669] ? preempt_count_add+0x49/0xa0 [3868.768444] __btrfs_ioctl_snap_create+0x123/0x190 [btrfs] [3868.769639] ? _copy_from_user+0x66/0xa0 [3868.770391] btrfs_ioctl_snap_create_v2+0xbb/0x140 [btrfs] [3868.771495] btrfs_ioctl+0xd1e/0x35c0 [btrfs] [3868.772364] ? __slab_free+0x10a/0x360 [3868.773198] ? rcu_read_lock_sched_held+0x12/0x60 [3868.774121] ? lock_release+0x223/0x4a0 [3868.774863] ? lock_acquired+0x19f/0x420 [3868.775634] ? rcu_read_lock_sched_held+0x12/0x60 [3868.776530] ? trace_hardirqs_on+0x1b/0xe0 [3868.777373] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [3868.778280] ? kmem_cache_free+0x321/0x3c0 [3868.779011] ? __x64_sys_ioctl+0x83/0xb0 [3868.779718] __x64_sys_ioctl+0x83/0xb0 [3868.780387] do_syscall_64+0x3b/0xc0 [3868.781059] entry_SYSCALL_64_after_hwframe+0x44/0xae [3868.781953] RIP: 0033:0x7f281c59e957 [3868.782585] Code: 3c 1c 48 f7 d8 4c (...) [3868.785867] RSP: 002b:00007ffe1f83e2b8 EFLAGS: 00000202 ORIG_RAX: 0000000= 000000010 [3868.787198] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f281c59= e957 [3868.788450] RDX: 00007ffe1f83e2c0 RSI: 0000000050009418 RDI: 000000000000= 0003 [3868.789748] RBP: 00007ffe1f83f300 R08: 0000000000000000 R09: 00007ffe1f83= fe36 [3868.791214] R10: 0000000000000000 R11: 0000000000000202 R12: 000000000000= 0003 [3868.792468] R13: 0000000000000003 R14: 00007ffe1f83e2c0 R15: 000000000000= 03cc [3868.793765] [3868.794037] irq event stamp: 0 [3868.794548] hardirqs last enabled at (0): [<0000000000000000>] 0x0 [3868.795670] hardirqs last disabled at (0): [] copy_proc= ess+0x934/0x2040 [3868.797086] softirqs last enabled at (0): [] copy_proc= ess+0x934/0x2040 [3868.798309] softirqs last disabled at (0): [<0000000000000000>] 0x0 [3868.799284] ---[ end trace be24c7002fe27747 ]--- [3868.799928] BTRFS info (device dm-0): leaf 241188864 gen 1268 total ptrs = 214 free space 469 owner 2 [3868.801133] BTRFS info (device dm-0): refs 2 lock_owner 225627 current 22= 5627 [3868.802056] item 0 key (237436928 169 0) itemoff 16250 itemsize 33 [3868.802863] extent refs 1 gen 1265 flags 2 [3868.803447] ref#0: tree block backref root 1610 (...) [3869.064354] item 114 key (241008640 169 0) itemoff 12488 itemsize 33 [3869.065421] extent refs 1 gen 1268 flags 2 [3869.066115] ref#0: tree block backref root 1689 (...) [3869.403834] BTRFS error (device dm-0): unable to find ref byte nr 2410086= 40 parent 0 root 1622 owner 0 offset 0 [3869.405641] BTRFS: error (device dm-0) in __btrfs_free_extent:3076: errno= =3D-2 No such entry [3869.407138] BTRFS: error (device dm-0) in btrfs_run_delayed_refs:2159: er= rno=3D-2 No such entry Fix this by passing the new subvolume's root ID to btrfs_free_tree_block(). This requires changing the root argument of btrfs_free_tree_block() from struct btrfs_root * to a u64, since at this point during the subvolume creation we have not yet created the struct btrfs_root for the new subvolume, and btrfs_free_tree_block() only needs a root ID and nothing else from a struct btrfs_root. This was triggered by test case generic/475 from fstests. Fixes: 67addf29004c5b ("btrfs: fix metadata extent leak after failure to cr= eate subvolume") CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Nikolay Borisov Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/ctree.c | 17 +++++++++-------- fs/btrfs/ctree.h | 7 ++++++- fs/btrfs/extent-tree.c | 13 +++++++------ fs/btrfs/free-space-tree.c | 4 ++-- fs/btrfs/ioctl.c | 9 +++++---- fs/btrfs/qgroup.c | 3 ++- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 899f85445925..341ce90d24b1 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -462,8 +462,8 @@ static noinline int __btrfs_cow_block(struct btrfs_tran= s_handle *trans, BUG_ON(ret < 0); rcu_assign_pointer(root->node, cow); =20 - btrfs_free_tree_block(trans, root, buf, parent_start, - last_ref); + btrfs_free_tree_block(trans, btrfs_root_id(root), buf, + parent_start, last_ref); free_extent_buffer(buf); add_root_to_dirty_list(root); } else { @@ -484,8 +484,8 @@ static noinline int __btrfs_cow_block(struct btrfs_tran= s_handle *trans, return ret; } } - btrfs_free_tree_block(trans, root, buf, parent_start, - last_ref); + btrfs_free_tree_block(trans, btrfs_root_id(root), buf, + parent_start, last_ref); } if (unlock_orig) btrfs_tree_unlock(buf); @@ -926,7 +926,7 @@ static noinline int balance_level(struct btrfs_trans_ha= ndle *trans, free_extent_buffer(mid); =20 root_sub_used(root, mid->len); - btrfs_free_tree_block(trans, root, mid, 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); /* once for the root ptr */ free_extent_buffer_stale(mid); return 0; @@ -985,7 +985,8 @@ static noinline int balance_level(struct btrfs_trans_ha= ndle *trans, btrfs_tree_unlock(right); del_ptr(root, path, level + 1, pslot + 1); root_sub_used(root, right->len); - btrfs_free_tree_block(trans, root, right, 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(root), right, + 0, 1); free_extent_buffer_stale(right); right =3D NULL; } else { @@ -1030,7 +1031,7 @@ static noinline int balance_level(struct btrfs_trans_= handle *trans, btrfs_tree_unlock(mid); del_ptr(root, path, level + 1, pslot); root_sub_used(root, mid->len); - btrfs_free_tree_block(trans, root, mid, 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); free_extent_buffer_stale(mid); mid =3D NULL; } else { @@ -4059,7 +4060,7 @@ static noinline void btrfs_del_leaf(struct btrfs_tran= s_handle *trans, root_sub_used(root, leaf->len); =20 atomic_inc(&leaf->refs); - btrfs_free_tree_block(trans, root, leaf, 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(root), leaf, 0, 1); free_extent_buffer_stale(leaf); } /* diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 21c44846b002..cc72d8981c47 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2256,6 +2256,11 @@ static inline bool btrfs_root_dead(const struct btrf= s_root *root) return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_DEAD)) !=3D= 0; } =20 +static inline u64 btrfs_root_id(const struct btrfs_root *root) +{ + return root->root_key.objectid; +} + /* struct btrfs_root_backup */ BTRFS_SETGET_STACK_FUNCS(backup_tree_root, struct btrfs_root_backup, tree_root, 64); @@ -2718,7 +2723,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct b= trfs_trans_handle *trans, u64 empty_size, enum btrfs_lock_nesting nest); void btrfs_free_tree_block(struct btrfs_trans_handle *trans, - struct btrfs_root *root, + u64 root_id, struct extent_buffer *buf, u64 parent, int last_ref); int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e01b9344fb9c..f11616f61dd6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3280,20 +3280,20 @@ static noinline int check_ref_cleanup(struct btrfs_= trans_handle *trans, } =20 void btrfs_free_tree_block(struct btrfs_trans_handle *trans, - struct btrfs_root *root, + u64 root_id, struct extent_buffer *buf, u64 parent, int last_ref) { - struct btrfs_fs_info *fs_info =3D root->fs_info; + struct btrfs_fs_info *fs_info =3D trans->fs_info; struct btrfs_ref generic_ref =3D { 0 }; int ret; =20 btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, buf->start, buf->len, parent); btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf), - root->root_key.objectid, 0, false); + root_id, 0, false); =20 - if (root->root_key.objectid !=3D BTRFS_TREE_LOG_OBJECTID) { + if (root_id !=3D BTRFS_TREE_LOG_OBJECTID) { btrfs_ref_tree_mod(fs_info, &generic_ref); ret =3D btrfs_add_delayed_tree_ref(trans, &generic_ref, NULL); BUG_ON(ret); /* -ENOMEM */ @@ -3303,7 +3303,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle = *trans, struct btrfs_block_group *cache; bool must_pin =3D false; =20 - if (root->root_key.objectid !=3D BTRFS_TREE_LOG_OBJECTID) { + if (root_id !=3D BTRFS_TREE_LOG_OBJECTID) { ret =3D check_ref_cleanup(trans, buf->start); if (!ret) { btrfs_redirty_list_add(trans->transaction, buf); @@ -5441,7 +5441,8 @@ static noinline int walk_up_proc(struct btrfs_trans_h= andle *trans, goto owner_mismatch; } =20 - btrfs_free_tree_block(trans, root, eb, parent, wc->refs[level] =3D=3D 1); + btrfs_free_tree_block(trans, btrfs_root_id(root), eb, parent, + wc->refs[level] =3D=3D 1); out: wc->refs[level] =3D 0; wc->flags[level] =3D 0; diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index a33bca94d133..3abec44c6255 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1256,8 +1256,8 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info = *fs_info) btrfs_tree_lock(free_space_root->node); btrfs_clean_tree_block(free_space_root->node); btrfs_tree_unlock(free_space_root->node); - btrfs_free_tree_block(trans, free_space_root, free_space_root->node, - 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), + free_space_root->node, 0, 1); =20 btrfs_put_root(free_space_root); =20 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index bf53af8694f8..7272d9d3fa78 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -615,11 +615,12 @@ static noinline int create_subvol(struct user_namespa= ce *mnt_userns, * Since we don't abort the transaction in this case, free the * tree block so that we don't leak space and leave the * filesystem in an inconsistent state (an extent item in the - * extent tree without backreferences). Also no need to have - * the tree block locked since it is not in any tree at this - * point, so no other task can find it and use it. + * extent tree with a backreference for a root that does not + * exists). Also no need to have the tree block locked since it + * is not in any tree at this point, so no other task can find + * it and use it. */ - btrfs_free_tree_block(trans, root, leaf, 0, 1); + btrfs_free_tree_block(trans, objectid, leaf, 0, 1); free_extent_buffer(leaf); goto fail; } diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 2c803108ea94..4ca809fa80ea 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1259,7 +1259,8 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info) btrfs_tree_lock(quota_root->node); btrfs_clean_tree_block(quota_root->node); btrfs_tree_unlock(quota_root->node); - btrfs_free_tree_block(trans, quota_root, quota_root->node, 0, 1); + btrfs_free_tree_block(trans, btrfs_root_id(quota_root), + quota_root->node, 0, 1); =20 btrfs_put_root(quota_root); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E40C6C433EF for ; Mon, 11 Jul 2022 09:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233209AbiGKJkI (ORCPT ); Mon, 11 Jul 2022 05:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233255AbiGKJjR (ORCPT ); Mon, 11 Jul 2022 05:39:17 -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 8B8EF4F1BF; Mon, 11 Jul 2022 02:20: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 0BC926124E; Mon, 11 Jul 2022 09:20:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B3EDC34115; Mon, 11 Jul 2022 09:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531211; bh=oJOs1ONI5SdQxG+Uy5dsJlVrwOLbpGr+5/00gXC7Wl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/tDwX1T0CHt2GWmbk7whdNsJYLTfIRuIm8odDWvECvNZ5eTnyUDxmgQzbHnr+K6u khNtfhT6N5fyo0zfQ8l8O0ehe69jRCsI26NdoBGgKDdOSGmRRiODxGnguEVhwHwJrj V0afzClowUWU07+BtCl32iCu/C0LGF33U8klejBw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 5.15 023/230] btrfs: fix warning when freeing leaf after subvolume creation failure Date: Mon, 11 Jul 2022 11:04:39 +0200 Message-Id: <20220711090604.732194986@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Filipe Manana [ Upstream commit 212a58fda9b9077e0efc20200a4feb76afacfd95 ] When creating a subvolume, at ioctl.c:create_subvol(), if we fail to insert the root item for the new subvolume into the root tree, we can trigger the following warning: [78961.741046] WARNING: CPU: 0 PID: 4079814 at fs/btrfs/extent-tree.c:3357 = btrfs_free_tree_block+0x2af/0x310 [btrfs] [78961.743344] Modules linked in: [78961.749440] dm_snapshot dm_thin_pool (...) [78961.773648] CPU: 0 PID: 4079814 Comm: fsstress Not tainted 5.16.0-rc4-bt= rfs-next-108 #1 [78961.775198] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS = rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [78961.777266] RIP: 0010:btrfs_free_tree_block+0x2af/0x310 [btrfs] [78961.778398] Code: 17 00 48 85 (...) [78961.781067] RSP: 0018:ffffaa4001657b28 EFLAGS: 00010202 [78961.781877] RAX: 0000000000000213 RBX: ffff897f8a796910 RCX: 00000000000= 00000 [78961.782780] RDX: 0000000000000000 RSI: 0000000011004000 RDI: 00000000fff= fffff [78961.783764] RBP: ffff8981f490e800 R08: 0000000000000001 R09: 00000000000= 00000 [78961.784740] R10: 0000000000000000 R11: 0000000000000001 R12: ffff897fc96= 3fcc8 [78961.785665] R13: 0000000000000001 R14: ffff898063548000 R15: ffff8980635= 48000 [78961.786620] FS: 00007f31283c6b80(0000) GS:ffff8982ace00000(0000) knlGS:= 0000000000000000 [78961.787717] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [78961.788598] CR2: 00007f31285c3000 CR3: 000000023fcc8003 CR4: 00000000003= 70ef0 [78961.789568] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 00000000000= 00000 [78961.790585] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 00000000000= 00400 [78961.791684] Call Trace: [78961.792082] [78961.792359] create_subvol+0x5d1/0x9a0 [btrfs] [78961.793054] btrfs_mksubvol+0x447/0x4c0 [btrfs] [78961.794009] ? preempt_count_add+0x49/0xa0 [78961.794705] __btrfs_ioctl_snap_create+0x123/0x190 [btrfs] [78961.795712] ? _copy_from_user+0x66/0xa0 [78961.796382] btrfs_ioctl_snap_create_v2+0xbb/0x140 [btrfs] [78961.797392] btrfs_ioctl+0xd1e/0x35c0 [btrfs] [78961.798172] ? __slab_free+0x10a/0x360 [78961.798820] ? rcu_read_lock_sched_held+0x12/0x60 [78961.799664] ? lock_release+0x223/0x4a0 [78961.800321] ? lock_acquired+0x19f/0x420 [78961.800992] ? rcu_read_lock_sched_held+0x12/0x60 [78961.801796] ? trace_hardirqs_on+0x1b/0xe0 [78961.802495] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [78961.803358] ? kmem_cache_free+0x321/0x3c0 [78961.804071] ? __x64_sys_ioctl+0x83/0xb0 [78961.804711] __x64_sys_ioctl+0x83/0xb0 [78961.805348] do_syscall_64+0x3b/0xc0 [78961.805969] entry_SYSCALL_64_after_hwframe+0x44/0xae [78961.806830] RIP: 0033:0x7f31284bc957 [78961.807517] Code: 3c 1c 48 f7 d8 (...) This is because we are calling btrfs_free_tree_block() on an extent buffer that is dirty. Fix that by cleaning the extent buffer, with btrfs_clean_tree_block(), before freeing it. This was triggered by test case generic/475 from fstests. Fixes: 67addf29004c5b ("btrfs: fix metadata extent leak after failure to cr= eate subvolume") CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Nikolay Borisov Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7272d9d3fa78..a37ab3e89a3b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -616,10 +616,11 @@ static noinline int create_subvol(struct user_namespa= ce *mnt_userns, * tree block so that we don't leak space and leave the * filesystem in an inconsistent state (an extent item in the * extent tree with a backreference for a root that does not - * exists). Also no need to have the tree block locked since it - * is not in any tree at this point, so no other task can find - * it and use it. + * exists). */ + btrfs_tree_lock(leaf); + btrfs_clean_tree_block(leaf); + btrfs_tree_unlock(leaf); btrfs_free_tree_block(trans, objectid, leaf, 0, 1); free_extent_buffer(leaf); goto fail; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 6800BC433EF for ; Mon, 11 Jul 2022 09:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233113AbiGKJkL (ORCPT ); Mon, 11 Jul 2022 05:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbiGKJjT (ORCPT ); Mon, 11 Jul 2022 05:39:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 966C750722; Mon, 11 Jul 2022 02:20: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 D2DB6612A0; Mon, 11 Jul 2022 09:20:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD8DFC341C8; Mon, 11 Jul 2022 09:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531214; bh=cAOsUqWfWLaLFBrgDJaoiwrjMPN8OuWXzHQEt0P8A1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zNfgI095fPOpOYMKJtqmP6VdhB2AhdLpVlyu2solQpPianVqoJb87s/J3adwVgk/0 yaOBcTbdCqVamn6KDfxk966OhbSMXbwwNrJClufj63SQrVDFKyOplpA+Xl/ifvcyav DFL2kUkg7d/D+w5qcbqgP05TsenvSHPsxcR4i/64= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tang Bin , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 024/230] Input: cpcap-pwrbutton - handle errors from platform_get_irq() Date: Mon, 11 Jul 2022 11:04:40 +0200 Message-Id: <20220711090604.761923622@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tang Bin [ Upstream commit 58ae4004b9c4bb040958cf73986b687a5ea4d85d ] The function cpcap_power_button_probe() does not perform sufficient error checking after executing platform_get_irq(), thus fix it. Signed-off-by: Tang Bin Link: https://lore.kernel.org/r/20210802121740.8700-1-tangbin@cmss.chinamob= ile.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/input/misc/cpcap-pwrbutton.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpca= p-pwrbutton.c index 0abef63217e2..372cb44d0635 100644 --- a/drivers/input/misc/cpcap-pwrbutton.c +++ b/drivers/input/misc/cpcap-pwrbutton.c @@ -54,9 +54,13 @@ static irqreturn_t powerbutton_irq(int irq, void *_butto= n) static int cpcap_power_button_probe(struct platform_device *pdev) { struct cpcap_power_button *button; - int irq =3D platform_get_irq(pdev, 0); + int irq; int err; =20 + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + button =3D devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL); if (!button) return -ENOMEM; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 60711C433EF for ; Mon, 11 Jul 2022 09:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233222AbiGKJkU (ORCPT ); Mon, 11 Jul 2022 05:40:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233391AbiGKJje (ORCPT ); Mon, 11 Jul 2022 05:39:34 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDA78AEC2; Mon, 11 Jul 2022 02:20: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 sin.source.kernel.org (Postfix) with ESMTPS id 960E3CE1260; Mon, 11 Jul 2022 09:20:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4792C34115; Mon, 11 Jul 2022 09:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531217; bh=rbumori8la7PN8tsc2VKer19837spjva39ScaQYHsfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWd2x3VQW092ubChjKEQrqdwtswPKN70ZMmVjlaM+cyM/HeBjkkwRmR0dk1YIhbI5 VCNpOdosDnXM8OrrBwXNl/x6IufuCwDNO5HpW3Wb0fDEV6dzRM5mmPjpjthhJueyMk /4NR2J9GalQ8y6zL1H8/aaTpxmAANUhBGPVSrGOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bastien Nocera , Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 025/230] Input: goodix - change goodix_i2c_write() len parameter type to int Date: Mon, 11 Jul 2022 11:04:41 +0200 Message-Id: <20220711090604.790267156@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 31ae0102a34ed863c7d32b10e768036324991679 ] Change the type of the goodix_i2c_write() len parameter to from 'unsigned' to 'int' to avoid bare use of 'unsigned', changing it to 'int' makes goodix_i2c_write()' prototype consistent with goodix_i2c_read(). Reviewed-by: Bastien Nocera Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210920150643.155872-2-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/input/touchscreen/goodix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen= /goodix.c index 5051a1766aac..1eb776abe562 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -246,7 +246,7 @@ static int goodix_i2c_read(struct i2c_client *client, * @len: length of the buffer to write */ static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *= buf, - unsigned len) + int len) { u8 *addr_buf; struct i2c_msg msg; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 7DF0DC433EF for ; Mon, 11 Jul 2022 09:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233242AbiGKJkW (ORCPT ); Mon, 11 Jul 2022 05:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233429AbiGKJji (ORCPT ); Mon, 11 Jul 2022 05:39:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3768AEF8; Mon, 11 Jul 2022 02:20: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 dfw.source.kernel.org (Postfix) with ESMTPS id 84A8A612A0; Mon, 11 Jul 2022 09:20:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6314CC34115; Mon, 11 Jul 2022 09:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531219; bh=xg0CrHl7GlZrxDRdsAtEDs9u9TY5OWj2ONOEpuzc1A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t0TzSY+zLy0gw4G+3DmQbGihMA9/SEU2dmhr0b9Y++Jc5ZqiyD8wMLPdyaGZHSRLJ AAvtVOFug2vjDYo5xnn0xitlv7rk6XAeXtCO1+oiQr8atVVVDS4dmXCiY3Dz/PI21V 9N75u7oAmxrJmS4LG2w0RwDyRIKR/fD+IkXCVMBQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bastien Nocera , Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 026/230] Input: goodix - add a goodix.h header file Date: Mon, 11 Jul 2022 11:04:42 +0200 Message-Id: <20220711090604.819190707@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 a2233cb7b65a017067e2f2703375ecc930a0ab30 ] Add a goodix.h header file, and move the register definitions, and struct declarations there and add prototypes for various helper functions. This is a preparation patch for adding support for controllers without flash, which need to have their firmware uploaded and need some other special handling too. Since MAINTAINERS needs updating because of this change anyways, also add myself as co-maintainer. Reviewed-by: Bastien Nocera Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210920150643.155872-3-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- MAINTAINERS | 3 +- drivers/input/touchscreen/goodix.c | 74 +++--------------------------- drivers/input/touchscreen/goodix.h | 73 +++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 drivers/input/touchscreen/goodix.h diff --git a/MAINTAINERS b/MAINTAINERS index a60d7e0466af..edc32575828b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7952,9 +7952,10 @@ F: drivers/media/usb/go7007/ =20 GOODIX TOUCHSCREEN M: Bastien Nocera +M: Hans de Goede L: linux-input@vger.kernel.org S: Maintained -F: drivers/input/touchscreen/goodix.c +F: drivers/input/touchscreen/goodix* =20 GOOGLE ETHERNET DRIVERS M: Jeroen de Borst diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen= /goodix.c index 1eb776abe562..5ccdd6abd868 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -14,20 +14,15 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include #include -#include #include #include #include #include +#include "goodix.h" =20 #define GOODIX_GPIO_INT_NAME "irq" #define GOODIX_GPIO_RST_NAME "reset" @@ -38,22 +33,11 @@ #define GOODIX_CONTACT_SIZE 8 #define GOODIX_MAX_CONTACT_SIZE 9 #define GOODIX_MAX_CONTACTS 10 -#define GOODIX_MAX_KEYS 7 =20 #define GOODIX_CONFIG_MIN_LENGTH 186 #define GOODIX_CONFIG_911_LENGTH 186 #define GOODIX_CONFIG_967_LENGTH 228 #define GOODIX_CONFIG_GT9X_LENGTH 240 -#define GOODIX_CONFIG_MAX_LENGTH 240 - -/* Register defines */ -#define GOODIX_REG_COMMAND 0x8040 -#define GOODIX_CMD_SCREEN_OFF 0x05 - -#define GOODIX_READ_COOR_ADDR 0x814E -#define GOODIX_GT1X_REG_CONFIG_DATA 0x8050 -#define GOODIX_GT9X_REG_CONFIG_DATA 0x8047 -#define GOODIX_REG_ID 0x8140 =20 #define GOODIX_BUFFER_STATUS_READY BIT(7) #define GOODIX_HAVE_KEY BIT(4) @@ -68,55 +52,11 @@ #define ACPI_GPIO_SUPPORT #endif =20 -struct goodix_ts_data; - -enum goodix_irq_pin_access_method { - IRQ_PIN_ACCESS_NONE, - IRQ_PIN_ACCESS_GPIO, - IRQ_PIN_ACCESS_ACPI_GPIO, - IRQ_PIN_ACCESS_ACPI_METHOD, -}; - -struct goodix_chip_data { - u16 config_addr; - int config_len; - int (*check_config)(struct goodix_ts_data *ts, const u8 *cfg, int len); - void (*calc_config_checksum)(struct goodix_ts_data *ts); -}; - struct goodix_chip_id { const char *id; const struct goodix_chip_data *data; }; =20 -#define GOODIX_ID_MAX_LEN 4 - -struct goodix_ts_data { - struct i2c_client *client; - struct input_dev *input_dev; - const struct goodix_chip_data *chip; - struct touchscreen_properties prop; - unsigned int max_touch_num; - unsigned int int_trigger_type; - struct regulator *avdd28; - struct regulator *vddio; - struct gpio_desc *gpiod_int; - struct gpio_desc *gpiod_rst; - int gpio_count; - int gpio_int_idx; - char id[GOODIX_ID_MAX_LEN + 1]; - u16 version; - const char *cfg_name; - bool reset_controller_at_probe; - bool load_cfg_from_disk; - struct completion firmware_loading_complete; - unsigned long irq_flags; - enum goodix_irq_pin_access_method irq_pin_access_method; - unsigned int contact_size; - u8 config[GOODIX_CONFIG_MAX_LENGTH]; - unsigned short keymap[GOODIX_MAX_KEYS]; -}; - static int goodix_check_cfg_8(struct goodix_ts_data *ts, const u8 *cfg, int len); static int goodix_check_cfg_16(struct goodix_ts_data *ts, @@ -216,8 +156,7 @@ static const struct dmi_system_id inverted_x_screen[] = =3D { * @buf: raw write data buffer. * @len: length of the buffer to write */ -static int goodix_i2c_read(struct i2c_client *client, - u16 reg, u8 *buf, int len) +int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len) { struct i2c_msg msgs[2]; __be16 wbuf =3D cpu_to_be16(reg); @@ -245,8 +184,7 @@ static int goodix_i2c_read(struct i2c_client *client, * @buf: raw data buffer to write. * @len: length of the buffer to write */ -static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *= buf, - int len) +int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, in= t len) { u8 *addr_buf; struct i2c_msg msg; @@ -270,7 +208,7 @@ static int goodix_i2c_write(struct i2c_client *client, = u16 reg, const u8 *buf, return ret < 0 ? ret : (ret !=3D 1 ? -EIO : 0); } =20 -static int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 valu= e) +int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value) { return goodix_i2c_write(client, reg, &value, sizeof(value)); } @@ -554,7 +492,7 @@ static int goodix_check_cfg(struct goodix_ts_data *ts, = const u8 *cfg, int len) * @cfg: config firmware to write to device * @len: config data length */ -static int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int l= en) +int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) { int error; =20 @@ -652,7 +590,7 @@ static int goodix_irq_direction_input(struct goodix_ts_= data *ts) return -EINVAL; /* Never reached */ } =20 -static int goodix_int_sync(struct goodix_ts_data *ts) +int goodix_int_sync(struct goodix_ts_data *ts) { int error; =20 diff --git a/drivers/input/touchscreen/goodix.h b/drivers/input/touchscreen= /goodix.h new file mode 100644 index 000000000000..cdaced4f2980 --- /dev/null +++ b/drivers/input/touchscreen/goodix.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __GOODIX_H__ +#define __GOODIX_H__ + +#include +#include +#include +#include +#include +#include + +/* Register defines */ +#define GOODIX_REG_COMMAND 0x8040 +#define GOODIX_CMD_SCREEN_OFF 0x05 + +#define GOODIX_GT1X_REG_CONFIG_DATA 0x8050 +#define GOODIX_GT9X_REG_CONFIG_DATA 0x8047 +#define GOODIX_REG_ID 0x8140 +#define GOODIX_READ_COOR_ADDR 0x814E + +#define GOODIX_ID_MAX_LEN 4 +#define GOODIX_CONFIG_MAX_LENGTH 240 +#define GOODIX_MAX_KEYS 7 + +enum goodix_irq_pin_access_method { + IRQ_PIN_ACCESS_NONE, + IRQ_PIN_ACCESS_GPIO, + IRQ_PIN_ACCESS_ACPI_GPIO, + IRQ_PIN_ACCESS_ACPI_METHOD, +}; + +struct goodix_ts_data; + +struct goodix_chip_data { + u16 config_addr; + int config_len; + int (*check_config)(struct goodix_ts_data *ts, const u8 *cfg, int len); + void (*calc_config_checksum)(struct goodix_ts_data *ts); +}; + +struct goodix_ts_data { + struct i2c_client *client; + struct input_dev *input_dev; + const struct goodix_chip_data *chip; + struct touchscreen_properties prop; + unsigned int max_touch_num; + unsigned int int_trigger_type; + struct regulator *avdd28; + struct regulator *vddio; + struct gpio_desc *gpiod_int; + struct gpio_desc *gpiod_rst; + int gpio_count; + int gpio_int_idx; + char id[GOODIX_ID_MAX_LEN + 1]; + u16 version; + const char *cfg_name; + bool reset_controller_at_probe; + bool load_cfg_from_disk; + struct completion firmware_loading_complete; + unsigned long irq_flags; + enum goodix_irq_pin_access_method irq_pin_access_method; + unsigned int contact_size; + u8 config[GOODIX_CONFIG_MAX_LENGTH]; + unsigned short keymap[GOODIX_MAX_KEYS]; +}; + +int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len); +int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, in= t len); +int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value); +int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len); +int goodix_int_sync(struct goodix_ts_data *ts); + +#endif --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 32A42C433EF for ; Mon, 11 Jul 2022 09:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233266AbiGKJkg (ORCPT ); Mon, 11 Jul 2022 05:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233479AbiGKJjl (ORCPT ); Mon, 11 Jul 2022 05:39:41 -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 0FE958B4BA; Mon, 11 Jul 2022 02:20: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 EDDF4B80D2C; Mon, 11 Jul 2022 09:20:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F707C34115; Mon, 11 Jul 2022 09:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531222; bh=ynAyWgoXiSjmNRHtxhcsHuqwdPZlXmQsgv73NX8sewQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2NJzizx+G15dsurdB4vBZmZm89+4CO4Vf/dTZMUQPAbPe73YZ7xhMtYa6ZrmUsx+f wmU8DRZHowIzqWwLIAtONsTVcKChP+V3eohbnnczKJjbVC07lgXwyilFUhfLf6HMYg AXpE/MBSv22f67FhW7uaPsHai07dIZtFHnlQGDeE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bastien Nocera , Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 027/230] Input: goodix - refactor reset handling Date: Mon, 11 Jul 2022 11:04:43 +0200 Message-Id: <20220711090604.847577621@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 209bda4741f68f102cf2f272227bfc938e387b51 ] Refactor reset handling a bit, change the main reset handler into a new goodix_reset_no_int_sync() helper and add a goodix_reset() wrapper which calls goodix_int_sync() separately. Also push the dev_err() call on reset failure into the goodix_reset_no_int_sync() and goodix_int_sync() functions, so that we don't need to have separate dev_err() calls in all their callers. This is a preparation patch for adding support for controllers without flash, which need to have their firmware uploaded and need some other special handling too. Reviewed-by: Bastien Nocera Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210920150643.155872-4-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/input/touchscreen/goodix.c | 48 ++++++++++++++++++++---------- drivers/input/touchscreen/goodix.h | 1 + 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen= /goodix.c index 5ccdd6abd868..2ca903a8af21 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -596,56 +596,76 @@ int goodix_int_sync(struct goodix_ts_data *ts) =20 error =3D goodix_irq_direction_output(ts, 0); if (error) - return error; + goto error; =20 msleep(50); /* T5: 50ms */ =20 error =3D goodix_irq_direction_input(ts); if (error) - return error; + goto error; =20 return 0; + +error: + dev_err(&ts->client->dev, "Controller irq sync failed.\n"); + return error; } =20 /** - * goodix_reset - Reset device during power on + * goodix_reset_no_int_sync - Reset device, leaving interrupt line in outp= ut mode * * @ts: goodix_ts_data pointer */ -static int goodix_reset(struct goodix_ts_data *ts) +int goodix_reset_no_int_sync(struct goodix_ts_data *ts) { int error; =20 /* begin select I2C slave addr */ error =3D gpiod_direction_output(ts->gpiod_rst, 0); if (error) - return error; + goto error; =20 msleep(20); /* T2: > 10ms */ =20 /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */ error =3D goodix_irq_direction_output(ts, ts->client->addr =3D=3D 0x14); if (error) - return error; + goto error; =20 usleep_range(100, 2000); /* T3: > 100us */ =20 error =3D gpiod_direction_output(ts->gpiod_rst, 1); if (error) - return error; + goto error; =20 usleep_range(6000, 10000); /* T4: > 5ms */ =20 /* end select I2C slave addr */ error =3D gpiod_direction_input(ts->gpiod_rst); if (error) - return error; + goto error; =20 - error =3D goodix_int_sync(ts); + return 0; + +error: + dev_err(&ts->client->dev, "Controller reset failed.\n"); + return error; +} + +/** + * goodix_reset - Reset device during power on + * + * @ts: goodix_ts_data pointer + */ +static int goodix_reset(struct goodix_ts_data *ts) +{ + int error; + + error =3D goodix_reset_no_int_sync(ts); if (error) return error; =20 - return 0; + return goodix_int_sync(ts); } =20 #ifdef ACPI_GPIO_SUPPORT @@ -1144,10 +1164,8 @@ static int goodix_ts_probe(struct i2c_client *client, if (ts->reset_controller_at_probe) { /* reset the controller */ error =3D goodix_reset(ts); - if (error) { - dev_err(&client->dev, "Controller reset failed.\n"); + if (error) return error; - } } =20 error =3D goodix_i2c_test(client); @@ -1289,10 +1307,8 @@ static int __maybe_unused goodix_resume(struct devic= e *dev) =20 if (error !=3D 0 || config_ver !=3D ts->config[0]) { error =3D goodix_reset(ts); - if (error) { - dev_err(dev, "Controller reset failed.\n"); + if (error) return error; - } =20 error =3D goodix_send_cfg(ts, ts->config, ts->chip->config_len); if (error) diff --git a/drivers/input/touchscreen/goodix.h b/drivers/input/touchscreen= /goodix.h index cdaced4f2980..0b88554ba2ae 100644 --- a/drivers/input/touchscreen/goodix.h +++ b/drivers/input/touchscreen/goodix.h @@ -69,5 +69,6 @@ int goodix_i2c_write(struct i2c_client *client, u16 reg, = const u8 *buf, int len) int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value); int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len); int goodix_int_sync(struct goodix_ts_data *ts); +int goodix_reset_no_int_sync(struct goodix_ts_data *ts); =20 #endif --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 C6F84C43334 for ; Mon, 11 Jul 2022 09:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232990AbiGKJki (ORCPT ); Mon, 11 Jul 2022 05:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbiGKJjo (ORCPT ); Mon, 11 Jul 2022 05:39:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E4B8BABA; Mon, 11 Jul 2022 02:20: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 A4ECFB80E7F; Mon, 11 Jul 2022 09:20:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D3C7C341C8; Mon, 11 Jul 2022 09:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531225; bh=JPi6v8SZVxEJ7mpJWPM6iNC6XWALF0V4uRUwE8A4Gzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wdJqfgcGvIkt6RowjmJk6xZwTxaqNlOa6G/HewTRT65018Lu5ScEDzP5z4sjBr8pg A1vlyzzWVsN2ekVt5ACTcyvCAg2oGXpsG+zYevm2Gq1UHwT5lzUjKFPgJQi7KwdbZ8 aFC+/4KO5EOSyQtB3PbdPD/2SqbYR/TAu8OWWLsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 028/230] Input: goodix - try not to touch the reset-pin on x86/ACPI devices Date: Mon, 11 Jul 2022 11:04:44 +0200 Message-Id: <20220711090604.876835870@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 a2fd46cd3dbb83b373ba74f4043f8dae869c65f1 ] Unless the controller is not responding at boot or after suspend/resume, the driver never resets the controller on x86/ACPI platforms. The driver still requesting the reset pin at probe() though in case it needs it. Until now the driver has always requested the reset pin with GPIOD_IN as type. The idea being to put the pin in high-impedance mode to save power until the driver actually wants to issue a reset. But this means that just requesting the pin can cause issues, since requesting it in another mode then GPIOD_ASIS may cause the pinctrl driver to touch the pin settings. We have already had issues before due to a bug in the pinctrl-cherryview.c driver which has been fixed in commit 921daeeca91b ("pinctrl: cherryview: Preserve CHV_PADCTRL1_INVRXTX_TXDATA flag on GPIOs"). And now it turns out that requesting the reset-pin as GPIOD_IN also stops the touchscreen from working on the GPD P2 max mini-laptop. The behavior of putting the pin in high-impedance mode relies on there being some external pull-up to keep it high and there seems to be no pull-up on the GPD P2 max, causing things to break. This commit fixes this by requesting the reset pin as is when using the x86/ACPI code paths to lookup the GPIOs; and by not dropping it back into input-mode in case the driver does end up issuing a reset for error-recovery. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D209061 Fixes: a7d4b171660c ("Input: goodix - add support for getting IRQ + reset G= PIOs on Cherry Trail devices") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20211206091116.44466-2-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/input/touchscreen/goodix.c | 30 +++++++++++++++++++++++++----- drivers/input/touchscreen/goodix.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen= /goodix.c index 2ca903a8af21..3667f7e51fde 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -640,10 +640,16 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *t= s) =20 usleep_range(6000, 10000); /* T4: > 5ms */ =20 - /* end select I2C slave addr */ - error =3D gpiod_direction_input(ts->gpiod_rst); - if (error) - goto error; + /* + * Put the reset pin back in to input / high-impedance mode to save + * power. Only do this in the non ACPI case since some ACPI boards + * don't have a pull-up, so there the reset pin must stay active-high. + */ + if (ts->irq_pin_access_method =3D=3D IRQ_PIN_ACCESS_GPIO) { + error =3D gpiod_direction_input(ts->gpiod_rst); + if (error) + goto error; + } =20 return 0; =20 @@ -777,6 +783,14 @@ static int goodix_add_acpi_gpio_mappings(struct goodix= _ts_data *ts) return -EINVAL; } =20 + /* + * Normally we put the reset pin in input / high-impedance mode to save + * power. But some x86/ACPI boards don't have a pull-up, so for the ACPI + * case, leave the pin as is. This results in the pin not being touched + * at all on x86/ACPI boards, except when needed for error-recover. + */ + ts->gpiod_rst_flags =3D GPIOD_ASIS; + return devm_acpi_dev_add_driver_gpios(dev, gpio_mapping); } #else @@ -802,6 +816,12 @@ static int goodix_get_gpio_config(struct goodix_ts_dat= a *ts) return -EINVAL; dev =3D &ts->client->dev; =20 + /* + * By default we request the reset pin as input, leaving it in + * high-impedance when not resetting the controller to save power. + */ + ts->gpiod_rst_flags =3D GPIOD_IN; + ts->avdd28 =3D devm_regulator_get(dev, "AVDD28"); if (IS_ERR(ts->avdd28)) { error =3D PTR_ERR(ts->avdd28); @@ -839,7 +859,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data= *ts) ts->gpiod_int =3D gpiod; =20 /* Get the reset line GPIO pin number */ - gpiod =3D devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, GPIOD_IN); + gpiod =3D devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rs= t_flags); if (IS_ERR(gpiod)) { error =3D PTR_ERR(gpiod); if (error !=3D -EPROBE_DEFER) diff --git a/drivers/input/touchscreen/goodix.h b/drivers/input/touchscreen= /goodix.h index 0b88554ba2ae..1a1571ad2cd2 100644 --- a/drivers/input/touchscreen/goodix.h +++ b/drivers/input/touchscreen/goodix.h @@ -51,6 +51,7 @@ struct goodix_ts_data { struct gpio_desc *gpiod_rst; int gpio_count; int gpio_int_idx; + enum gpiod_flags gpiod_rst_flags; char id[GOODIX_ID_MAX_LEN + 1]; u16 version; const char *cfg_name; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 C5B42CCA47B for ; Mon, 11 Jul 2022 09:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233183AbiGKJkw (ORCPT ); Mon, 11 Jul 2022 05:40:52 -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 S233160AbiGKJkA (ORCPT ); Mon, 11 Jul 2022 05:40:00 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCAE58C17C; Mon, 11 Jul 2022 02:20: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 sin.source.kernel.org (Postfix) with ESMTPS id 13E61CE125D; Mon, 11 Jul 2022 09:20:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C733DC341C0; Mon, 11 Jul 2022 09:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531228; bh=qHgKYxqgAm81b0hOmcGoke/IsgPA+fooL4yEG/AmAo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cwRbaVD8bw9bdAAP3YqGIcuE4GtYrwFS0eHdaOkq8kGxVNqdAOCVTsYXOgJU360FP 02FbxXa4hYHOVZo18ZSb7KVd27lvJWBBg5xoylkrK4EJaPl8nmQA6XABw6X+K9IXdz yWoxirsQQEOldWYqaQW6Tc2/UmKR7j2xTTqHYa5g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Michel=20D=C3=A4nzer?= , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin Subject: [PATCH 5.15 029/230] dma-buf/poll: Get a file reference for outstanding fence callbacks Date: Mon, 11 Jul 2022 11:04:45 +0200 Message-Id: <20220711090604.904789107@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Michel D=C3=A4nzer [ Upstream commit ff2d23843f7fb4f13055be5a4a9a20ddd04e6e9c ] This makes sure we don't hit the BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active); in dma_buf_release, which could be triggered by user space closing the dma-buf file description while there are outstanding fence callbacks from dma_buf_poll. Cc: stable@vger.kernel.org Signed-off-by: Michel D=C3=A4nzer Reviewed-by: Christian K=C3=B6nig Link: https://patchwork.freedesktop.org/patch/msgid/20210723075857.4065-1-m= ichel@daenzer.net Signed-off-by: Christian K=C3=B6nig Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma-buf/dma-buf.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index f9217e300eea..968c3df2810e 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -67,12 +67,9 @@ static void dma_buf_release(struct dentry *dentry) BUG_ON(dmabuf->vmapping_counter); =20 /* - * Any fences that a dma-buf poll can wait on should be signaled - * before releasing dma-buf. This is the responsibility of each - * driver that uses the reservation objects. - * - * If you hit this BUG() it means someone dropped their ref to the - * dma-buf while still having pending operation to the buffer. + * If you hit this BUG() it could mean: + * * There's a file reference imbalance in dma_buf_poll / dma_buf_poll_cb= or somewhere else + * * dmabuf->cb_in/out.active are non-0 despite no pending fence callback */ BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active); =20 @@ -200,6 +197,7 @@ static loff_t dma_buf_llseek(struct file *file, loff_t = offset, int whence) static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *= cb) { struct dma_buf_poll_cb_t *dcb =3D (struct dma_buf_poll_cb_t *)cb; + struct dma_buf *dmabuf =3D container_of(dcb->poll, struct dma_buf, poll); unsigned long flags; =20 spin_lock_irqsave(&dcb->poll->lock, flags); @@ -207,6 +205,8 @@ static void dma_buf_poll_cb(struct dma_fence *fence, st= ruct dma_fence_cb *cb) dcb->active =3D 0; spin_unlock_irqrestore(&dcb->poll->lock, flags); dma_fence_put(fence); + /* Paired with get_file in dma_buf_poll */ + fput(dmabuf->file); } =20 static bool dma_buf_poll_shared(struct dma_resv *resv, @@ -282,8 +282,12 @@ static __poll_t dma_buf_poll(struct file *file, poll_t= able *poll) spin_unlock_irq(&dmabuf->poll.lock); =20 if (events & EPOLLOUT) { + /* Paired with fput in dma_buf_poll_cb */ + get_file(dmabuf->file); + if (!dma_buf_poll_shared(resv, dcb) && !dma_buf_poll_excl(resv, dcb)) + /* No callback queued, wake up any other waiters */ dma_buf_poll_cb(NULL, &dcb->cb); else @@ -303,6 +307,9 @@ static __poll_t dma_buf_poll(struct file *file, poll_ta= ble *poll) spin_unlock_irq(&dmabuf->poll.lock); =20 if (events & EPOLLIN) { + /* Paired with fput in dma_buf_poll_cb */ + get_file(dmabuf->file); + if (!dma_buf_poll_excl(resv, dcb)) /* No callback queued, wake up any other waiters */ dma_buf_poll_cb(NULL, &dcb->cb); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 3383AC43334 for ; Mon, 11 Jul 2022 09:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233247AbiGKJkz (ORCPT ); Mon, 11 Jul 2022 05:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233188AbiGKJkB (ORCPT ); Mon, 11 Jul 2022 05:40:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACDC8C745; Mon, 11 Jul 2022 02:20: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 DDFBD612A0; Mon, 11 Jul 2022 09:20:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9D7BC341C0; Mon, 11 Jul 2022 09:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531231; bh=rmjGp32/KxPHpWOyXXiHSYLoisg8Hd5yKhINRxYoBKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zpU9FIqYcnAyJFC1gQKNE70Zj6T9N4QtRdLyxgSHT4QlV+8JR/xp7m29LGzAOzShr TwOiTwwXOT6o7a2AX1di/UlwJhiCnjqPe9LrVKAJn0ir7UhEzwBqb1MqCn9aJgxRsZ O+hIrG7H99cSJakZjOFGrWCr5GL/YEjWqmgKFGnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Sun , Josef Bacik , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 5.15 030/230] btrfs: fix deadlock between chunk allocation and chunk btree modifications Date: Mon, 11 Jul 2022 11:04:46 +0200 Message-Id: <20220711090604.932846353@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Filipe Manana [ Upstream commit 2bb2e00ed9787e52580bb651264b8d6a2b7a9dd2 ] When a task is doing some modification to the chunk btree and it is not in the context of a chunk allocation or a chunk removal, it can deadlock with another task that is currently allocating a new data or metadata chunk. These contexts are the following: * When relocating a system chunk, when we need to COW the extent buffers that belong to the chunk btree; * When adding a new device (ioctl), where we need to add a new device item to the chunk btree; * When removing a device (ioctl), where we need to remove a device item from the chunk btree; * When resizing a device (ioctl), where we need to update a device item in the chunk btree and may need to relocate a system chunk that lies beyond the new device size when shrinking a device. The problem happens due to a sequence of steps like the following: 1) Task A starts a data or metadata chunk allocation and it locks the chunk mutex; 2) Task B is relocating a system chunk, and when it needs to COW an extent buffer of the chunk btree, it has locked both that extent buffer as well as its parent extent buffer; 3) Since there is not enough available system space, either because none of the existing system block groups have enough free space or because the only one with enough free space is in RO mode due to the relocation, task B triggers a new system chunk allocation. It blocks when trying to acquire the chunk mutex, currently held by task A; 4) Task A enters btrfs_chunk_alloc_add_chunk_item(), in order to insert the new chunk item into the chunk btree and update the existing device items there. But in order to do that, it has to lock the extent buffer that task B locked at step 2, or its parent extent buffer, but task B is waiting on the chunk mutex, which is currently locked by task A, therefore resulting in a deadlock. One example report when the deadlock happens with system chunk relocation: INFO: task kworker/u9:5:546 blocked for more than 143 seconds. Not tainted 5.15.0-rc3+ #1 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:kworker/u9:5 state:D stack:25936 pid: 546 ppid: 2 flags:0x00= 004000 Workqueue: events_unbound btrfs_async_reclaim_metadata_space Call Trace: context_switch kernel/sched/core.c:4940 [inline] __schedule+0xcd9/0x2530 kernel/sched/core.c:6287 schedule+0xd3/0x270 kernel/sched/core.c:6366 rwsem_down_read_slowpath+0x4ee/0x9d0 kernel/locking/rwsem.c:993 __down_read_common kernel/locking/rwsem.c:1214 [inline] __down_read kernel/locking/rwsem.c:1223 [inline] down_read_nested+0xe6/0x440 kernel/locking/rwsem.c:1590 __btrfs_tree_read_lock+0x31/0x350 fs/btrfs/locking.c:47 btrfs_tree_read_lock fs/btrfs/locking.c:54 [inline] btrfs_read_lock_root_node+0x8a/0x320 fs/btrfs/locking.c:191 btrfs_search_slot_get_root fs/btrfs/ctree.c:1623 [inline] btrfs_search_slot+0x13b4/0x2140 fs/btrfs/ctree.c:1728 btrfs_update_device+0x11f/0x500 fs/btrfs/volumes.c:2794 btrfs_chunk_alloc_add_chunk_item+0x34d/0xea0 fs/btrfs/volumes.c:5504 do_chunk_alloc fs/btrfs/block-group.c:3408 [inline] btrfs_chunk_alloc+0x84d/0xf50 fs/btrfs/block-group.c:3653 flush_space+0x54e/0xd80 fs/btrfs/space-info.c:670 btrfs_async_reclaim_metadata_space+0x396/0xa90 fs/btrfs/space-info.c:953 process_one_work+0x9df/0x16d0 kernel/workqueue.c:2297 worker_thread+0x90/0xed0 kernel/workqueue.c:2444 kthread+0x3e5/0x4d0 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 INFO: task syz-executor:9107 blocked for more than 143 seconds. Not tainted 5.15.0-rc3+ #1 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:syz-executor state:D stack:23200 pid: 9107 ppid: 7792 flags:0x00= 004004 Call Trace: context_switch kernel/sched/core.c:4940 [inline] __schedule+0xcd9/0x2530 kernel/sched/core.c:6287 schedule+0xd3/0x270 kernel/sched/core.c:6366 schedule_preempt_disabled+0xf/0x20 kernel/sched/core.c:6425 __mutex_lock_common kernel/locking/mutex.c:669 [inline] __mutex_lock+0xc96/0x1680 kernel/locking/mutex.c:729 btrfs_chunk_alloc+0x31a/0xf50 fs/btrfs/block-group.c:3631 find_free_extent_update_loop fs/btrfs/extent-tree.c:3986 [inline] find_free_extent+0x25cb/0x3a30 fs/btrfs/extent-tree.c:4335 btrfs_reserve_extent+0x1f1/0x500 fs/btrfs/extent-tree.c:4415 btrfs_alloc_tree_block+0x203/0x1120 fs/btrfs/extent-tree.c:4813 __btrfs_cow_block+0x412/0x1620 fs/btrfs/ctree.c:415 btrfs_cow_block+0x2f6/0x8c0 fs/btrfs/ctree.c:570 btrfs_search_slot+0x1094/0x2140 fs/btrfs/ctree.c:1768 relocate_tree_block fs/btrfs/relocation.c:2694 [inline] relocate_tree_blocks+0xf73/0x1770 fs/btrfs/relocation.c:2757 relocate_block_group+0x47e/0xc70 fs/btrfs/relocation.c:3673 btrfs_relocate_block_group+0x48a/0xc60 fs/btrfs/relocation.c:4070 btrfs_relocate_chunk+0x96/0x280 fs/btrfs/volumes.c:3181 __btrfs_balance fs/btrfs/volumes.c:3911 [inline] btrfs_balance+0x1f03/0x3cd0 fs/btrfs/volumes.c:4301 btrfs_ioctl_balance+0x61e/0x800 fs/btrfs/ioctl.c:4137 btrfs_ioctl+0x39ea/0x7b70 fs/btrfs/ioctl.c:4949 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae So fix this by making sure that whenever we try to modify the chunk btree and we are neither in a chunk allocation context nor in a chunk remove context, we reserve system space before modifying the chunk btree. Reported-by: Hao Sun Link: https://lore.kernel.org/linux-btrfs/CACkBjsax51i4mu6C0C3vJqQN3NR_iVuu= coeG3U1HXjrgzn5FFQ@mail.gmail.com/ Fixes: 79bd37120b1495 ("btrfs: rework chunk allocation to avoid exhaustion = of the system chunk array") CC: stable@vger.kernel.org # 5.14+ Reviewed-by: Josef Bacik Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/block-group.c | 146 +++++++++++++++++++++++++---------------- fs/btrfs/block-group.h | 2 + fs/btrfs/relocation.c | 4 ++ fs/btrfs/volumes.c | 15 ++++- 4 files changed, 111 insertions(+), 56 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index aadc1203ad88..c6c5a22ff6e8 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3406,25 +3406,6 @@ static int do_chunk_alloc(struct btrfs_trans_handle = *trans, u64 flags) goto out; } =20 - /* - * If this is a system chunk allocation then stop right here and do not - * add the chunk item to the chunk btree. This is to prevent a deadlock - * because this system chunk allocation can be triggered while COWing - * some extent buffer of the chunk btree and while holding a lock on a - * parent extent buffer, in which case attempting to insert the chunk - * item (or update the device item) would result in a deadlock on that - * parent extent buffer. In this case defer the chunk btree updates to - * the second phase of chunk allocation and keep our reservation until - * the second phase completes. - * - * This is a rare case and can only be triggered by the very few cases - * we have where we need to touch the chunk btree outside chunk allocation - * and chunk removal. These cases are basically adding a device, removing - * a device or resizing a device. - */ - if (flags & BTRFS_BLOCK_GROUP_SYSTEM) - return 0; - ret =3D btrfs_chunk_alloc_add_chunk_item(trans, bg); /* * Normally we are not expected to fail with -ENOSPC here, since we have @@ -3557,14 +3538,14 @@ static int do_chunk_alloc(struct btrfs_trans_handle= *trans, u64 flags) * This has happened before and commit eafa4fd0ad0607 ("btrfs: fix exhaust= ion of * the system chunk array due to concurrent allocations") provides more de= tails. * - * For allocation of system chunks, we defer the updates and insertions in= to the - * chunk btree to phase 2. This is to prevent deadlocks on extent buffers = because - * if the chunk allocation is triggered while COWing an extent buffer of t= he - * chunk btree, we are holding a lock on the parent of that extent buffer = and - * doing the chunk btree updates and insertions can require locking that p= arent. - * This is for the very few and rare cases where we update the chunk btree= that - * are not chunk allocation or chunk removal: adding a device, removing a = device - * or resizing a device. + * Allocation of system chunks does not happen through this function. A ta= sk that + * needs to update the chunk btree (the only btree that uses system chunks= ), must + * preallocate chunk space by calling either check_system_chunk() or + * btrfs_reserve_chunk_metadata() - the former is used when allocating a d= ata or + * metadata chunk or when removing a chunk, while the later is used before= doing + * a modification to the chunk btree - use cases for the later are adding, + * removing and resizing a device as well as relocation of a system chunk. + * See the comment below for more details. * * The reservation of system space, done through check_system_chunk(), as = well * as all the updates and insertions into the chunk btree must be done whi= le @@ -3601,11 +3582,27 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *tr= ans, u64 flags, if (trans->allocating_chunk) return -ENOSPC; /* - * If we are removing a chunk, don't re-enter or we would deadlock. - * System space reservation and system chunk allocation is done by the - * chunk remove operation (btrfs_remove_chunk()). + * Allocation of system chunks can not happen through this path, as we + * could end up in a deadlock if we are allocating a data or metadata + * chunk and there is another task modifying the chunk btree. + * + * This is because while we are holding the chunk mutex, we will attempt + * to add the new chunk item to the chunk btree or update an existing + * device item in the chunk btree, while the other task that is modifying + * the chunk btree is attempting to COW an extent buffer while holding a + * lock on it and on its parent - if the COW operation triggers a system + * chunk allocation, then we can deadlock because we are holding the + * chunk mutex and we may need to access that extent buffer or its parent + * in order to add the chunk item or update a device item. + * + * Tasks that want to modify the chunk tree should reserve system space + * before updating the chunk btree, by calling either + * btrfs_reserve_chunk_metadata() or check_system_chunk(). + * It's possible that after a task reserves the space, it still ends up + * here - this happens in the cases described above at do_chunk_alloc(). + * The task will have to either retry or fail. */ - if (trans->removing_chunk) + if (flags & BTRFS_BLOCK_GROUP_SYSTEM) return -ENOSPC; =20 space_info =3D btrfs_find_space_info(fs_info, flags); @@ -3704,17 +3701,14 @@ static u64 get_profile_num_devs(struct btrfs_fs_inf= o *fs_info, u64 type) return num_dev; } =20 -/* - * Reserve space in the system space for allocating or removing a chunk - */ -void check_system_chunk(struct btrfs_trans_handle *trans, u64 type) +static void reserve_chunk_space(struct btrfs_trans_handle *trans, + u64 bytes, + u64 type) { struct btrfs_fs_info *fs_info =3D trans->fs_info; struct btrfs_space_info *info; u64 left; - u64 thresh; int ret =3D 0; - u64 num_devs; =20 /* * Needed because we can end up allocating a system chunk and for an @@ -3727,19 +3721,13 @@ void check_system_chunk(struct btrfs_trans_handle *= trans, u64 type) left =3D info->total_bytes - btrfs_space_info_used(info, true); spin_unlock(&info->lock); =20 - num_devs =3D get_profile_num_devs(fs_info, type); - - /* num_devs device items to update and 1 chunk item to add or remove */ - thresh =3D btrfs_calc_metadata_size(fs_info, num_devs) + - btrfs_calc_insert_metadata_size(fs_info, 1); - - if (left < thresh && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { + if (left < bytes && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { btrfs_info(fs_info, "left=3D%llu, need=3D%llu, flags=3D%llu", - left, thresh, type); + left, bytes, type); btrfs_dump_space_info(fs_info, info, 0, 0); } =20 - if (left < thresh) { + if (left < bytes) { u64 flags =3D btrfs_system_alloc_profile(fs_info); struct btrfs_block_group *bg; =20 @@ -3748,21 +3736,20 @@ void check_system_chunk(struct btrfs_trans_handle *= trans, u64 type) * needing it, as we might not need to COW all nodes/leafs from * the paths we visit in the chunk tree (they were already COWed * or created in the current transaction for example). - * - * Also, if our caller is allocating a system chunk, do not - * attempt to insert the chunk item in the chunk btree, as we - * could deadlock on an extent buffer since our caller may be - * COWing an extent buffer from the chunk btree. */ bg =3D btrfs_create_chunk(trans, flags); if (IS_ERR(bg)) { ret =3D PTR_ERR(bg); - } else if (!(type & BTRFS_BLOCK_GROUP_SYSTEM)) { + } else { /* * If we fail to add the chunk item here, we end up * trying again at phase 2 of chunk allocation, at * btrfs_create_pending_block_groups(). So ignore - * any error here. + * any error here. An ENOSPC here could happen, due to + * the cases described at do_chunk_alloc() - the system + * block group we just created was just turned into RO + * mode by a scrub for example, or a running discard + * temporarily removed its free space entries, etc. */ btrfs_chunk_alloc_add_chunk_item(trans, bg); } @@ -3771,12 +3758,61 @@ void check_system_chunk(struct btrfs_trans_handle *= trans, u64 type) if (!ret) { ret =3D btrfs_block_rsv_add(fs_info->chunk_root, &fs_info->chunk_block_rsv, - thresh, BTRFS_RESERVE_NO_FLUSH); + bytes, BTRFS_RESERVE_NO_FLUSH); if (!ret) - trans->chunk_bytes_reserved +=3D thresh; + trans->chunk_bytes_reserved +=3D bytes; } } =20 +/* + * Reserve space in the system space for allocating or removing a chunk. + * The caller must be holding fs_info->chunk_mutex. + */ +void check_system_chunk(struct btrfs_trans_handle *trans, u64 type) +{ + struct btrfs_fs_info *fs_info =3D trans->fs_info; + const u64 num_devs =3D get_profile_num_devs(fs_info, type); + u64 bytes; + + /* num_devs device items to update and 1 chunk item to add or remove. */ + bytes =3D btrfs_calc_metadata_size(fs_info, num_devs) + + btrfs_calc_insert_metadata_size(fs_info, 1); + + reserve_chunk_space(trans, bytes, type); +} + +/* + * Reserve space in the system space, if needed, for doing a modification = to the + * chunk btree. + * + * @trans: A transaction handle. + * @is_item_insertion: Indicate if the modification is for inserting a new= item + * in the chunk btree or if it's for the deletion or update + * of an existing item. + * + * This is used in a context where we need to update the chunk btree outsi= de + * block group allocation and removal, to avoid a deadlock with a concurre= nt + * task that is allocating a metadata or data block group and therefore ne= eds to + * update the chunk btree while holding the chunk mutex. After the update = to the + * chunk btree is done, btrfs_trans_release_chunk_metadata() should be cal= led. + * + */ +void btrfs_reserve_chunk_metadata(struct btrfs_trans_handle *trans, + bool is_item_insertion) +{ + struct btrfs_fs_info *fs_info =3D trans->fs_info; + u64 bytes; + + if (is_item_insertion) + bytes =3D btrfs_calc_insert_metadata_size(fs_info, 1); + else + bytes =3D btrfs_calc_metadata_size(fs_info, 1); + + mutex_lock(&fs_info->chunk_mutex); + reserve_chunk_space(trans, bytes, BTRFS_BLOCK_GROUP_SYSTEM); + mutex_unlock(&fs_info->chunk_mutex); +} + void btrfs_put_block_group_cache(struct btrfs_fs_info *info) { struct btrfs_block_group *block_group; diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index c72a71efcb18..37e55ebde735 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -289,6 +289,8 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans,= u64 flags, enum btrfs_chunk_alloc_enum force); int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, u64 type); void check_system_chunk(struct btrfs_trans_handle *trans, const u64 type); +void btrfs_reserve_chunk_metadata(struct btrfs_trans_handle *trans, + bool is_item_insertion); u64 btrfs_get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags); void btrfs_put_block_group_cache(struct btrfs_fs_info *info); int btrfs_free_block_groups(struct btrfs_fs_info *info); diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 0300770c0a89..429a198f8937 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2698,8 +2698,12 @@ static int relocate_tree_block(struct btrfs_trans_ha= ndle *trans, list_add_tail(&node->list, &rc->backref_cache.changed); } else { path->lowest_level =3D node->level; + if (root =3D=3D root->fs_info->chunk_root) + btrfs_reserve_chunk_metadata(trans, false); ret =3D btrfs_search_slot(trans, root, key, path, 0, 1); btrfs_release_path(path); + if (root =3D=3D root->fs_info->chunk_root) + btrfs_trans_release_chunk_metadata(trans); if (ret > 0) ret =3D 0; } diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b75ce79a2540..fa68efd7e610 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1879,8 +1879,10 @@ static int btrfs_add_dev_item(struct btrfs_trans_han= dle *trans, key.type =3D BTRFS_DEV_ITEM_KEY; key.offset =3D device->devid; =20 + btrfs_reserve_chunk_metadata(trans, true); ret =3D btrfs_insert_empty_item(trans, trans->fs_info->chunk_root, path, &key, sizeof(*dev_item)); + btrfs_trans_release_chunk_metadata(trans); if (ret) goto out; =20 @@ -1957,7 +1959,9 @@ static int btrfs_rm_dev_item(struct btrfs_device *dev= ice) key.type =3D BTRFS_DEV_ITEM_KEY; key.offset =3D device->devid; =20 + btrfs_reserve_chunk_metadata(trans, false); ret =3D btrfs_search_slot(trans, root, &key, path, -1, 1); + btrfs_trans_release_chunk_metadata(trans); if (ret) { if (ret > 0) ret =3D -ENOENT; @@ -2513,7 +2517,9 @@ static int btrfs_finish_sprout(struct btrfs_trans_han= dle *trans) key.type =3D BTRFS_DEV_ITEM_KEY; =20 while (1) { + btrfs_reserve_chunk_metadata(trans, false); ret =3D btrfs_search_slot(trans, root, &key, path, 0, 1); + btrfs_trans_release_chunk_metadata(trans); if (ret < 0) goto error; =20 @@ -2861,6 +2867,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *tran= s, struct btrfs_super_block *super_copy =3D fs_info->super_copy; u64 old_total; u64 diff; + int ret; =20 if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) return -EACCES; @@ -2889,7 +2896,11 @@ int btrfs_grow_device(struct btrfs_trans_handle *tra= ns, &trans->transaction->dev_update_list); mutex_unlock(&fs_info->chunk_mutex); =20 - return btrfs_update_device(trans, device); + btrfs_reserve_chunk_metadata(trans, false); + ret =3D btrfs_update_device(trans, device); + btrfs_trans_release_chunk_metadata(trans); + + return ret; } =20 static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_of= fset) @@ -4926,8 +4937,10 @@ int btrfs_shrink_device(struct btrfs_device *device,= u64 new_size) round_down(old_total - diff, fs_info->sectorsize)); mutex_unlock(&fs_info->chunk_mutex); =20 + btrfs_reserve_chunk_metadata(trans, false); /* Now btrfs_update_device() will change the on-disk size. */ ret =3D btrfs_update_device(trans, device); + btrfs_trans_release_chunk_metadata(trans); if (ret < 0) { btrfs_abort_transaction(trans, ret); btrfs_end_transaction(trans); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 33A68C43334 for ; Mon, 11 Jul 2022 09:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233232AbiGKJlC (ORCPT ); Mon, 11 Jul 2022 05:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbiGKJkf (ORCPT ); Mon, 11 Jul 2022 05:40:35 -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 657B35289A; Mon, 11 Jul 2022 02:20: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 1EA44B80E7A; Mon, 11 Jul 2022 09:20:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44F8DC34115; Mon, 11 Jul 2022 09:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531236; bh=Oc8LmOjFtOIVcOaO6TY+N7i6SkFtqCkhytIlUUqIE84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNnAc6+ejm+pORN3xmd56F4tyttPHp99UVySseM3AO/H2S0vY89Fw/jUil5qhMdoO h5kZc0/K8zJMkzorcDJg88vAqk77rB3IkIFujMai3Fo5iqYOTN/pxZ7iQpWnpk3vh3 Gx/CLunp40o70he0v11edxgViunAKpLz+4RwjvEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Brost , John Harrison , Daniel Vetter , Matt Roper , Sasha Levin Subject: [PATCH 5.15 031/230] drm/i915: Disable bonding on gen12+ platforms Date: Mon, 11 Jul 2022 11:04:47 +0200 Message-Id: <20220711090604.961757355@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Matthew Brost [ Upstream commit ce7e75c7ef1bf8ea3d947da8c674d2f40fd7d734 ] Disable bonding on gen12+ platforms aside from ones already supported by the i915 - TGL, RKL, and ADL-S. Signed-off-by: Matthew Brost Reviewed-by: John Harrison Acked-by: Daniel Vetter Signed-off-by: Matt Roper Link: https://patchwork.freedesktop.org/patch/msgid/20210728192100.132425-1= -matthew.brost@intel.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/= i915/gem/i915_gem_context.c index ee0c0b712522..ba2e037a82e4 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -442,6 +442,13 @@ set_proto_ctx_engines_bond(struct i915_user_extension = __user *base, void *data) u16 idx, num_bonds; int err, n; =20 + if (GRAPHICS_VER(i915) >=3D 12 && !IS_TIGERLAKE(i915) && + !IS_ROCKETLAKE(i915) && !IS_ALDERLAKE_S(i915)) { + drm_dbg(&i915->drm, + "Bonding on gen12+ aside from TGL, RKL, and ADL_S not supported\n"); + return -ENODEV; + } + if (get_user(idx, &ext->virtual_index)) return -EFAULT; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 3C8B5C43334 for ; Mon, 11 Jul 2022 09:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232807AbiGKJlO (ORCPT ); Mon, 11 Jul 2022 05:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbiGKJkh (ORCPT ); Mon, 11 Jul 2022 05:40:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE11528A8; Mon, 11 Jul 2022 02:20: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 D82DCB80E74; Mon, 11 Jul 2022 09:20:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AADC34115; Mon, 11 Jul 2022 09:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531239; bh=AgvTkU3k01QLw4fOSHfl7ozN/LT6Ac3EchRzAxpIE7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Dr1mH8Hu1/UYMdnwgOGjRri1u0mOTLnuCZRJzCg1e4A5NXubupoL3bXQZrCtzolb rll66tIEoU8BoBJdkg3MgxWbnyY68fp62eW9PDzXCFect2yAdbFpUBLIHn7l+colj2 Sq2XMqPKMQ+6BZbC227W5ZAyblzQgdP4g1tB4tec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tvrtko Ursulin , Matthew Auld , Maarten Lankhorst , Brost Matthew , Chris Wilson , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Sasha Levin Subject: [PATCH 5.15 032/230] drm/i915/gt: Register the migrate contexts with their engines Date: Mon, 11 Jul 2022 11:04:48 +0200 Message-Id: <20220711090604.991162181@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Thomas Hellstr=C3=B6m [ Upstream commit 3e42cc61275f95fd7f022b6380b95428efe134d3 ] Pinned contexts, like the migrate contexts need reset after resume since their context image may have been lost. Also the GuC needs to register pinned contexts. Add a list to struct intel_engine_cs where we add all pinned contexts on creation, and traverse that list at resume time to reset the pinned contexts. This fixes the kms_pipe_crc_basic@suspend-read-crc-pipe-a selftest for now, but proper LMEM backup / restore is needed for full suspend functionality. However, note that even with full LMEM backup / restore it may be desirable to keep the reset since backing up the migrate context images must happen using memcpy() after the migrate context has become inactive, and for performance- and other reasons we want to avoid memcpy() from LMEM. Also traverse the list at guc_init_lrc_mapping() calling guc_kernel_context_pin() for the pinned contexts, like is already done for the kernel context. v2: - Don't reset the contexts on each __engine_unpark() but rather at resume time (Chris Wilson). v3: - Reset contexts in the engine sanitize callback. (Chris Wilson) Cc: Tvrtko Ursulin Cc: Matthew Auld Cc: Maarten Lankhorst Cc: Brost Matthew Cc: Chris Wilson Signed-off-by: Thomas Hellstr=C3=B6m Reviewed-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20210922062527.865433-6= -thomas.hellstrom@linux.intel.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/i915/gt/intel_context_types.h | 8 +++++++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 4 ++++ drivers/gpu/drm/i915/gt/intel_engine_pm.c | 23 +++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_engine_pm.h | 2 ++ drivers/gpu/drm/i915/gt/intel_engine_types.h | 7 ++++++ .../drm/i915/gt/intel_execlists_submission.c | 2 ++ .../gpu/drm/i915/gt/intel_ring_submission.c | 3 +++ drivers/gpu/drm/i915/gt/mock_engine.c | 2 ++ .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 12 +++++++--- 9 files changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h b/drivers/gpu/dr= m/i915/gt/intel_context_types.h index e54351a170e2..a63631ea0ec4 100644 --- a/drivers/gpu/drm/i915/gt/intel_context_types.h +++ b/drivers/gpu/drm/i915/gt/intel_context_types.h @@ -152,6 +152,14 @@ struct intel_context { /** sseu: Control eu/slice partitioning */ struct intel_sseu sseu; =20 + /** + * pinned_contexts_link: List link for the engine's pinned contexts. + * This is only used if this is a perma-pinned kernel context and + * the list is assumed to only be manipulated during driver load + * or unload time so no mutex protection currently. + */ + struct list_head pinned_contexts_link; + u8 wa_bb_page; /* if set, page num reserved for context workarounds */ =20 struct { diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i9= 15/gt/intel_engine_cs.c index 0d9105a31d84..eb99441e0ada 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -320,6 +320,7 @@ static int intel_engine_setup(struct intel_gt *gt, enum= intel_engine_id id) =20 BUILD_BUG_ON(BITS_PER_TYPE(engine->mask) < I915_NUM_ENGINES); =20 + INIT_LIST_HEAD(&engine->pinned_contexts_list); engine->id =3D id; engine->legacy_idx =3D INVALID_ENGINE; engine->mask =3D BIT(id); @@ -875,6 +876,8 @@ intel_engine_create_pinned_context(struct intel_engine_= cs *engine, return ERR_PTR(err); } =20 + list_add_tail(&ce->pinned_contexts_link, &engine->pinned_contexts_list); + /* * Give our perma-pinned kernel timelines a separate lockdep class, * so that we can use them from within the normal user timelines @@ -897,6 +900,7 @@ void intel_engine_destroy_pinned_context(struct intel_c= ontext *ce) list_del(&ce->timeline->engine_link); mutex_unlock(&hwsp->vm->mutex); =20 + list_del(&ce->pinned_contexts_link); intel_context_unpin(ce); intel_context_put(ce); } diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i9= 15/gt/intel_engine_pm.c index 1f07ac4e0672..dacd62773735 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c @@ -298,6 +298,29 @@ void intel_engine_init__pm(struct intel_engine_cs *eng= ine) intel_engine_init_heartbeat(engine); } =20 +/** + * intel_engine_reset_pinned_contexts - Reset the pinned contexts of + * an engine. + * @engine: The engine whose pinned contexts we want to reset. + * + * Typically the pinned context LMEM images lose or get their content + * corrupted on suspend. This function resets their images. + */ +void intel_engine_reset_pinned_contexts(struct intel_engine_cs *engine) +{ + struct intel_context *ce; + + list_for_each_entry(ce, &engine->pinned_contexts_list, + pinned_contexts_link) { + /* kernel context gets reset at __engine_unpark() */ + if (ce =3D=3D engine->kernel_context) + continue; + + dbg_poison_ce(ce); + ce->ops->reset(ce); + } +} + #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) #include "selftest_engine_pm.c" #endif diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.h b/drivers/gpu/drm/i9= 15/gt/intel_engine_pm.h index 70ea46d6cfb0..8520c595f5e1 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.h +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.h @@ -69,4 +69,6 @@ intel_engine_create_kernel_request(struct intel_engine_cs= *engine) =20 void intel_engine_init__pm(struct intel_engine_cs *engine); =20 +void intel_engine_reset_pinned_contexts(struct intel_engine_cs *engine); + #endif /* INTEL_ENGINE_PM_H */ diff --git a/drivers/gpu/drm/i915/gt/intel_engine_types.h b/drivers/gpu/drm= /i915/gt/intel_engine_types.h index ed91bcff20eb..adc44c9fac6d 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_types.h +++ b/drivers/gpu/drm/i915/gt/intel_engine_types.h @@ -304,6 +304,13 @@ struct intel_engine_cs { =20 struct intel_context *kernel_context; /* pinned */ =20 + /** + * pinned_contexts_list: List of pinned contexts. This list is only + * assumed to be manipulated during driver load- or unload time and + * does therefore not have any additional protection. + */ + struct list_head pinned_contexts_list; + intel_engine_mask_t saturated; /* submitting semaphores too late? */ =20 struct { diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers= /gpu/drm/i915/gt/intel_execlists_submission.c index cafb0608ffb4..416f5e0657f0 100644 --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c @@ -2787,6 +2787,8 @@ static void execlists_sanitize(struct intel_engine_cs= *engine) =20 /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } =20 static void enable_error_interrupt(struct intel_engine_cs *engine) diff --git a/drivers/gpu/drm/i915/gt/intel_ring_submission.c b/drivers/gpu/= drm/i915/gt/intel_ring_submission.c index 2958e2fae380..6f2f6ba87397 100644 --- a/drivers/gpu/drm/i915/gt/intel_ring_submission.c +++ b/drivers/gpu/drm/i915/gt/intel_ring_submission.c @@ -17,6 +17,7 @@ #include "intel_ring.h" #include "shmem_utils.h" #include "intel_engine_heartbeat.h" +#include "intel_engine_pm.h" =20 /* Rough estimate of the typical request size, performing a flush, * set-context and then emitting the batch. @@ -292,6 +293,8 @@ static void xcs_sanitize(struct intel_engine_cs *engine) =20 /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } =20 static void reset_prepare(struct intel_engine_cs *engine) diff --git a/drivers/gpu/drm/i915/gt/mock_engine.c b/drivers/gpu/drm/i915/g= t/mock_engine.c index 2c1af030310c..8b89215afe46 100644 --- a/drivers/gpu/drm/i915/gt/mock_engine.c +++ b/drivers/gpu/drm/i915/gt/mock_engine.c @@ -376,6 +376,8 @@ int mock_engine_init(struct intel_engine_cs *engine) { struct intel_context *ce; =20 + INIT_LIST_HEAD(&engine->pinned_contexts_list); + engine->sched_engine =3D i915_sched_engine_create(ENGINE_MOCK); if (!engine->sched_engine) return -ENOMEM; diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gp= u/drm/i915/gt/uc/intel_guc_submission.c index 93c9de8f43e8..6e09a1cca37b 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c @@ -2347,6 +2347,8 @@ static void guc_sanitize(struct intel_engine_cs *engi= ne) =20 /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } =20 static void setup_hwsp(struct intel_engine_cs *engine) @@ -2422,9 +2424,13 @@ static inline void guc_init_lrc_mapping(struct intel= _guc *guc) * and even it did this code would be run again. */ =20 - for_each_engine(engine, gt, id) - if (engine->kernel_context) - guc_kernel_context_pin(guc, engine->kernel_context); + for_each_engine(engine, gt, id) { + struct intel_context *ce; + + list_for_each_entry(ce, &engine->pinned_contexts_list, + pinned_contexts_link) + guc_kernel_context_pin(guc, ce); + } } =20 static void guc_release(struct intel_engine_cs *engine) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 05977C433EF for ; Mon, 11 Jul 2022 09:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbiGKJl0 (ORCPT ); Mon, 11 Jul 2022 05:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232588AbiGKJks (ORCPT ); Mon, 11 Jul 2022 05:40:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344EF52FC3; Mon, 11 Jul 2022 02:20: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 BFD04B80D2C; Mon, 11 Jul 2022 09:20:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31378C341C0; Mon, 11 Jul 2022 09:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531242; bh=KK7PIPZHfYTfjyg6++h92jso97+euDiUBqTojabpj+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvdG1C/cE5ckqbNmdGP9l3UNAZi8s8dHPyctJOF1hzlTs69fs2EXKikKl6Ku/wBFu cdU7+UianTqWaaXNarv9oPUuflqnc5oz8GNYLK/ubzF97bTP4fy4R2aGGI5aNFmBql IfaSI94DXSPiwquMlIvnZhrY19YNJBq0nVgyZpuI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Mika Kuoppala , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Dave Airlie , Sasha Levin Subject: [PATCH 5.15 033/230] drm/i915: Replace the unconditional clflush with drm_clflush_virt_range() Date: Mon, 11 Jul 2022 11:04:49 +0200 Message-Id: <20220711090605.019193919@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Ville Syrj=C3=A4l=C3=A4 [ Upstream commit ef7ec41f17cbc0861891ccc0634d06a0c8dcbf09 ] Not all machines have clflush, so don't go assuming they do. Not really sure why the clflush is even here since hwsp is supposed to get snooped I thought. Although in my case we're talking about a i830 machine where render/blitter snooping is definitely busted. But it might work for the hswp perhaps. Haven't really reverse engineered that one fully. Cc: stable@vger.kernel.org Cc: Chris Wilson Cc: Mika Kuoppala Fixes: b436a5f8b6c8 ("drm/i915/gt: Track all timelines created using the HW= SP") Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20211014090941.12159-2-= ville.syrjala@linux.intel.com Reviewed-by: Dave Airlie Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/i915/gt/intel_ring_submission.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/intel_ring_submission.c b/drivers/gpu/= drm/i915/gt/intel_ring_submission.c index 6f2f6ba87397..02e18e70c78e 100644 --- a/drivers/gpu/drm/i915/gt/intel_ring_submission.c +++ b/drivers/gpu/drm/i915/gt/intel_ring_submission.c @@ -292,7 +292,7 @@ static void xcs_sanitize(struct intel_engine_cs *engine) sanitize_hwsp(engine); =20 /* And scrub the dirty cachelines for the HWSP */ - clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + drm_clflush_virt_range(engine->status_page.addr, PAGE_SIZE); =20 intel_engine_reset_pinned_contexts(engine); } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 18331C433EF for ; Mon, 11 Jul 2022 09:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233316AbiGKJlb (ORCPT ); Mon, 11 Jul 2022 05:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233166AbiGKJkv (ORCPT ); Mon, 11 Jul 2022 05:40:51 -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 E5DC752FC7; Mon, 11 Jul 2022 02:20: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 73AD9B80E7A; Mon, 11 Jul 2022 09:20:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D47FDC34115; Mon, 11 Jul 2022 09:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531245; bh=eGIB+8Gu4xZaEbCEbELdjBA9oQry6AsxRl7YUzHrQBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMHpNaC0fDuIvex4Q/nBaXUMysu9qH3hQbdetnCHXJkW2CyeVRNperg1fjf8ljBCW JTeQ17JqMvldSJxZKpsVjJrfNc6L5oXDdMT25w6TQqBxTop5K1oz0LWI8d+C2XR898 PjLMuMoWFm0TztkWe4YJxhOXEkgkJkOHQQYdIldc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.15 034/230] PCI/portdrv: Rename pm_iter() to pcie_port_device_iter() Date: Mon, 11 Jul 2022 11:04:50 +0200 Message-Id: <20220711090605.047935590@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 3134689f98f9e09004a4727370adc46e7635b4be ] Rename pm_iter() to pcie_port_device_iter() and make it visible outside CONFIG_PM and portdrv_core.c so it can be used for pciehp slot reset recovery. [bhelgaas: split into its own patch] Link: https://lore.kernel.org/linux-pci/08c046b0-c9f2-3489-eeef-7e7aca435bb= 9@gmail.com/ Link: https://lore.kernel.org/r/251f4edcc04c14f873ff1c967bc686169cd07d2d.16= 27638184.git.lukas@wunner.de Signed-off-by: Lukas Wunner Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/pci/pcie/portdrv.h | 1 + drivers/pci/pcie/portdrv_core.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 2ff5724b8f13..6126ee4676a7 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -110,6 +110,7 @@ void pcie_port_service_unregister(struct pcie_port_serv= ice_driver *new); =20 extern struct bus_type pcie_port_bus_type; int pcie_port_device_register(struct pci_dev *dev); +int pcie_port_device_iter(struct device *dev, void *data); #ifdef CONFIG_PM int pcie_port_device_suspend(struct device *dev); int pcie_port_device_resume_noirq(struct device *dev); diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_cor= e.c index 3ee63968deaa..604feeb84ee4 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -367,24 +367,24 @@ int pcie_port_device_register(struct pci_dev *dev) return status; } =20 -#ifdef CONFIG_PM -typedef int (*pcie_pm_callback_t)(struct pcie_device *); +typedef int (*pcie_callback_t)(struct pcie_device *); =20 -static int pm_iter(struct device *dev, void *data) +int pcie_port_device_iter(struct device *dev, void *data) { struct pcie_port_service_driver *service_driver; size_t offset =3D *(size_t *)data; - pcie_pm_callback_t cb; + pcie_callback_t cb; =20 if ((dev->bus =3D=3D &pcie_port_bus_type) && dev->driver) { service_driver =3D to_service_driver(dev->driver); - cb =3D *(pcie_pm_callback_t *)((void *)service_driver + offset); + cb =3D *(pcie_callback_t *)((void *)service_driver + offset); if (cb) return cb(to_pcie_device(dev)); } return 0; } =20 +#ifdef CONFIG_PM /** * pcie_port_device_suspend - suspend port services associated with a PCIe= port * @dev: PCI Express port to handle @@ -392,13 +392,13 @@ static int pm_iter(struct device *dev, void *data) int pcie_port_device_suspend(struct device *dev) { size_t off =3D offsetof(struct pcie_port_service_driver, suspend); - return device_for_each_child(dev, &off, pm_iter); + return device_for_each_child(dev, &off, pcie_port_device_iter); } =20 int pcie_port_device_resume_noirq(struct device *dev) { size_t off =3D offsetof(struct pcie_port_service_driver, resume_noirq); - return device_for_each_child(dev, &off, pm_iter); + return device_for_each_child(dev, &off, pcie_port_device_iter); } =20 /** @@ -408,7 +408,7 @@ int pcie_port_device_resume_noirq(struct device *dev) int pcie_port_device_resume(struct device *dev) { size_t off =3D offsetof(struct pcie_port_service_driver, resume); - return device_for_each_child(dev, &off, pm_iter); + return device_for_each_child(dev, &off, pcie_port_device_iter); } =20 /** @@ -418,7 +418,7 @@ int pcie_port_device_resume(struct device *dev) int pcie_port_device_runtime_suspend(struct device *dev) { size_t off =3D offsetof(struct pcie_port_service_driver, runtime_suspend); - return device_for_each_child(dev, &off, pm_iter); + return device_for_each_child(dev, &off, pcie_port_device_iter); } =20 /** @@ -428,7 +428,7 @@ int pcie_port_device_runtime_suspend(struct device *dev) int pcie_port_device_runtime_resume(struct device *dev) { size_t off =3D offsetof(struct pcie_port_service_driver, runtime_resume); - return device_for_each_child(dev, &off, pm_iter); + return device_for_each_child(dev, &off, pcie_port_device_iter); } #endif /* PM */ =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 9978AC433EF for ; Mon, 11 Jul 2022 09:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233329AbiGKJll (ORCPT ); Mon, 11 Jul 2022 05:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233094AbiGKJkx (ORCPT ); Mon, 11 Jul 2022 05:40:53 -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 36C3A237CF; Mon, 11 Jul 2022 02:20: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 sin.source.kernel.org (Postfix) with ESMTPS id 9B11ECE1261; Mon, 11 Jul 2022 09:20:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91599C34115; Mon, 11 Jul 2022 09:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531247; bh=SnrEFLDJqgO83gv4EWKET/Q/vmfdBl5tVgv09mI+I4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O9wBToZgIOB0qPU319k6Eu6dVI31JmEfCcaNxSQ5BxsLEe2YjJqWMzR5U9jp5oiaZ rzK5bKs5lHWMd4SuBtMS8Hkp8bup7BwOInYccWm74icnlkPPWCNY1JtEZva62SkcNB C7UyKwzndzZAH6Ue57gxrS7rX8kp3KiuPAPYuYBo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stuart Hayes , Lukas Wunner , Bjorn Helgaas , Keith Busch , Sasha Levin Subject: [PATCH 5.15 035/230] PCI: pciehp: Ignore Link Down/Up caused by error-induced Hot Reset Date: Mon, 11 Jul 2022 11:04:51 +0200 Message-Id: <20220711090605.076186446@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 ea401499e943c307e6d44af6c2b4e068643e7884 ] Stuart Hayes reports that an error handled by DPC at a Root Port results in pciehp gratuitously bringing down a subordinate hotplug port: RP -- UP -- DP -- UP -- DP (hotplug) -- EP pciehp brings the slot down because the Link to the Endpoint goes down. That is caused by a Hot Reset being propagated as a result of DPC. Per PCIe Base Spec 5.0, section 6.6.1 "Conventional Reset": For a Switch, the following must cause a hot reset to be sent on all Downstream Ports: [...] * The Data Link Layer of the Upstream Port reporting DL_Down status. In Switches that support Link speeds greater than 5.0 GT/s, the Upstream Port must direct the LTSSM of each Downstream Port to the Hot Reset state, but not hold the LTSSMs in that state. This permits each Downstream Port to begin Link training immediately after its hot reset completes. This behavior is recommended for all Switches. * Receiving a hot reset on the Upstream Port. Once DPC recovers, pcie_do_recovery() walks down the hierarchy and invokes pcie_portdrv_slot_reset() to restore each port's config space. At that point, a hotplug interrupt is signaled per PCIe Base Spec r5.0, section 6.7.3.4 "Software Notification of Hot-Plug Events": If the Port is enabled for edge-triggered interrupt signaling using MSI or MSI-X, an interrupt message must be sent every time the logical AND of the following conditions transitions from FALSE to TRUE: [...] * The Hot-Plug Interrupt Enable bit in the Slot Control register is set to 1b. * At least one hot-plug event status bit in the Slot Status register and its associated enable bit in the Slot Control register are both set to 1b. Prevent pciehp from gratuitously bringing down the slot by clearing the error-induced Data Link Layer State Changed event before restoring config space. Afterwards, check whether the link has unexpectedly failed to retrain and synthesize a DLLSC event if so. Allow each pcie_port_service_driver (one of them being pciehp) to define a slot_reset callback and re-use the existing pm_iter() function to iterate over the callbacks. Thereby, the Endpoint driver remains bound throughout error recovery and may restore the device to working state. Surprise removal during error recovery is detected through a Presence Detect Changed event. The hotplug port is expected to not signal that event as a result of a Hot Reset. The issue isn't DPC-specific, it also occurs when an error is handled by AER through aer_root_reset(). So while the issue was noticed only now, it's been around since 2006 when AER support was first introduced. [bhelgaas: drop PCI_ERROR_RECOVERY Kconfig, split pm_iter() rename to preparatory patch] Link: https://lore.kernel.org/linux-pci/08c046b0-c9f2-3489-eeef-7e7aca435bb= 9@gmail.com/ Fixes: 6c2b374d7485 ("PCI-Express AER implemetation: AER core and aerdriver= ") Link: https://lore.kernel.org/r/251f4edcc04c14f873ff1c967bc686169cd07d2d.16= 27638184.git.lukas@wunner.de Reported-by: Stuart Hayes Tested-by: Stuart Hayes Signed-off-by: Lukas Wunner Signed-off-by: Bjorn Helgaas Cc: stable@vger.kernel.org # v2.6.19+: ba952824e6c1: PCI/portdrv: Report re= set for frozen channel Cc: Keith Busch Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/pci/hotplug/pciehp.h | 2 ++ drivers/pci/hotplug/pciehp_core.c | 2 ++ drivers/pci/hotplug/pciehp_hpc.c | 26 ++++++++++++++++++++++++++ drivers/pci/pcie/portdrv.h | 2 ++ drivers/pci/pcie/portdrv_pci.c | 3 +++ 5 files changed, 35 insertions(+) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 10d7e7e1b553..e0a614acee05 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -192,6 +192,8 @@ int pciehp_get_attention_status(struct hotplug_slot *ho= tplug_slot, u8 *status); int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status= ); int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *statu= s); =20 +int pciehp_slot_reset(struct pcie_device *dev); + static inline const char *slot_name(struct controller *ctrl) { return hotplug_slot_name(&ctrl->hotplug_slot); diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp= _core.c index e7fe4b42f039..4042d87d539d 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -351,6 +351,8 @@ static struct pcie_port_service_driver hpdriver_portdrv= =3D { .runtime_suspend =3D pciehp_runtime_suspend, .runtime_resume =3D pciehp_runtime_resume, #endif /* PM */ + + .slot_reset =3D pciehp_slot_reset, }; =20 int __init pcie_hp_init(void) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_= hpc.c index 8bedbc77fe95..60098a701e83 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -865,6 +865,32 @@ void pcie_disable_interrupt(struct controller *ctrl) pcie_write_cmd(ctrl, 0, mask); } =20 +/** + * pciehp_slot_reset() - ignore link event caused by error-induced hot res= et + * @dev: PCI Express port service device + * + * Called from pcie_portdrv_slot_reset() after AER or DPC initiated a reset + * further up in the hierarchy to recover from an error. The reset was + * propagated down to this hotplug port. Ignore the resulting link flap. + * If the link failed to retrain successfully, synthesize the ignored even= t. + * Surprise removal during reset is detected through Presence Detect Chang= ed. + */ +int pciehp_slot_reset(struct pcie_device *dev) +{ + struct controller *ctrl =3D get_service_data(dev); + + if (ctrl->state !=3D ON_STATE) + return 0; + + pcie_capability_write_word(dev->port, PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_DLLSC); + + if (!pciehp_check_link_active(ctrl)) + pciehp_request(ctrl, PCI_EXP_SLTSTA_DLLSC); + + return 0; +} + /* * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary * bus reset of the bridge, but at the same time we want to ensure that it= is diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 6126ee4676a7..41fe1ffd5907 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -85,6 +85,8 @@ struct pcie_port_service_driver { int (*runtime_suspend)(struct pcie_device *dev); int (*runtime_resume)(struct pcie_device *dev); =20 + int (*slot_reset)(struct pcie_device *dev); + /* Device driver may resume normal operations */ void (*error_resume)(struct pci_dev *dev); =20 diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index c7ff1eea225a..1af74c3d9d5d 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -160,6 +160,9 @@ static pci_ers_result_t pcie_portdrv_error_detected(str= uct pci_dev *dev, =20 static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev) { + size_t off =3D offsetof(struct pcie_port_service_driver, slot_reset); + device_for_each_child(&dev->dev, &off, pcie_port_device_iter); + pci_restore_state(dev); pci_save_state(dev); return PCI_ERS_RESULT_RECOVERED; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 933F3C43334 for ; Mon, 11 Jul 2022 09:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbiGKJlq (ORCPT ); Mon, 11 Jul 2022 05:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233245AbiGKJkz (ORCPT ); Mon, 11 Jul 2022 05:40: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 58FC18E6FD; Mon, 11 Jul 2022 02:20: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 00094B80E7A; Mon, 11 Jul 2022 09:20:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 535D7C34115; Mon, 11 Jul 2022 09:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531250; bh=ZKjilJr1MP2/qYrlEE/6AKD8YftFdoAeZU9lHWGwhvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUtmy8km3q7iA/07CZNA+0WVK9MVO8t2keQ4rIaowJ/MpWSMQL5mVuThOulzJEvHy NbXPplAjD1dm5bCR2EMCN6kdsvJfIA3eCGxhOoE1Wj4ewWjf58x8JKg3s/ReLP1e1l G7yN46y/ECGXjCul3qTyPazuUIMRO7W3W+Tu53Sw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 036/230] media: ir_toy: prevent device from hanging during transmit Date: Mon, 11 Jul 2022 11:04:52 +0200 Message-Id: <20220711090605.104533160@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Young [ Upstream commit 4114978dcd24e72415276bba60ff4ff355970bbc ] If the IR Toy is receiving IR while a transmit is done, it may end up hanging. We can prevent this from happening by re-entering sample mode just before issuing the transmit command. Link: https://github.com/bengtmartensson/HarcHardware/discussions/25 Cc: stable@vger.kernel.org [mchehab: renamed: s/STATE_RESET/STATE_COMMAND_NO_RESP/ ] Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/media/rc/ir_toy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index 7f394277478b..53ae19fa103a 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -310,7 +310,7 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uin= t count) buf[i] =3D cpu_to_be16(v); } =20 - buf[count] =3D cpu_to_be16(0xffff); + buf[count] =3D 0xffff; =20 irtoy->tx_buf =3D buf; irtoy->tx_len =3D size; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 ECA3CC433EF for ; Mon, 11 Jul 2022 09:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233199AbiGKJls (ORCPT ); Mon, 11 Jul 2022 05:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbiGKJk5 (ORCPT ); Mon, 11 Jul 2022 05:40:57 -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 B458B904D4; Mon, 11 Jul 2022 02:20:54 -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 E861161227; Mon, 11 Jul 2022 09:20:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08352C34115; Mon, 11 Jul 2022 09:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531253; bh=Vymnmh1NdcpbekCmXewv0IKJXbg8zm4/a6uY9d1SZwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZOtD/uiR0N0Z76Kv7LNkwtJdLOBxuRcs8pYgZMOe03zbTYc2MvP2zCbPMaFMfEJ4 sniVomjjgzeA8xOuEy6AZfM9m5Q1FE2aUdt05GyoV77mvE3wd6rRaFjqGggXjjspcG hwvuvDGCn/hg5LdHXb1lnkgJxS/TbrMBAULGqL9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Gabbasov , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.15 037/230] memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash Date: Mon, 11 Jul 2022 11:04:53 +0200 Message-Id: <20220711090605.133661300@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Andrew Gabbasov [ Upstream commit 1869023e24c0de73a160a424dac4621cefd628ae ] HyperFlash devices in Renesas SoCs use 2-bytes addressing, according to HW manual paragraph 62.3.3 (which officially describes Serial Flash access, but seems to be applicable to HyperFlash too). And 1-byte bus read operations to 2-bytes unaligned addresses in external address space read mode work incorrectly (returns the other byte from the same word). Function memcpy_fromio(), used by the driver to read data from the bus, in ARM64 architecture (to which Renesas cores belong) uses 8-bytes bus accesses for appropriate aligned addresses, and 1-bytes accesses for other addresses. This results in incorrect data read from HyperFlash in unaligned cases. This issue can be reproduced using something like the following commands (where mtd1 is a parition on Hyperflash storage, defined properly in a device tree): [Correct fragment, read from Hyperflash] root@rcar-gen3:~# dd if=3D/dev/mtd1 of=3D/tmp/zz bs=3D32 count=3D1 root@rcar-gen3:~# hexdump -C /tmp/zz 00000000 f4 03 00 aa f5 03 01 aa f6 03 02 aa f7 03 03 aa |..........= ......| 00000010 00 00 80 d2 40 20 18 d5 00 06 81 d2 a0 18 a6 f2 |....@ ....= ......| 00000020 [Incorrect read of the same fragment: see the difference at offsets 8-11] root@rcar-gen3:~# dd if=3D/dev/mtd1 of=3D/tmp/zz bs=3D12 count=3D1 root@rcar-gen3:~# hexdump -C /tmp/zz 00000000 f4 03 00 aa f5 03 01 aa 03 03 aa aa |..........= ..| 0000000c Fix this issue by creating a local replacement of the copying function, that performs only properly aligned bus accesses, and is used for reading from HyperFlash. Fixes: ca7d8b980b67f ("memory: add Renesas RPC-IF driver") Cc: Signed-off-by: Andrew Gabbasov Link: https://lore.kernel.org/r/20210922184830.29147-1-andrew_gabbasov@ment= or.com Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/memory/renesas-rpc-if.c | 48 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-i= f.c index 3a416705f61c..c77b23b68a93 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -199,7 +199,6 @@ static int rpcif_reg_read(void *context, unsigned int r= eg, unsigned int *val) =20 *val =3D readl(rpc->base + reg); return 0; - } =20 static int rpcif_reg_write(void *context, unsigned int reg, unsigned int v= al) @@ -577,6 +576,48 @@ int rpcif_manual_xfer(struct rpcif *rpc) } EXPORT_SYMBOL(rpcif_manual_xfer); =20 +static void memcpy_fromio_readw(void *to, + const void __iomem *from, + size_t count) +{ + const int maxw =3D (IS_ENABLED(CONFIG_64BIT)) ? 8 : 4; + u8 buf[2]; + + if (count && ((unsigned long)from & 1)) { + *(u16 *)buf =3D __raw_readw((void __iomem *)((unsigned long)from & ~1)); + *(u8 *)to =3D buf[1]; + from++; + to++; + count--; + } + while (count >=3D 2 && !IS_ALIGNED((unsigned long)from, maxw)) { + *(u16 *)to =3D __raw_readw(from); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + while (count >=3D maxw) { +#ifdef CONFIG_64BIT + *(u64 *)to =3D __raw_readq(from); +#else + *(u32 *)to =3D __raw_readl(from); +#endif + from +=3D maxw; + to +=3D maxw; + count -=3D maxw; + } + while (count >=3D 2) { + *(u16 *)to =3D __raw_readw(from); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + if (count) { + *(u16 *)buf =3D __raw_readw(from); + *(u8 *)to =3D buf[0]; + } +} + ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *b= uf) { loff_t from =3D offs & (RPCIF_DIRMAP_SIZE - 1); @@ -598,7 +639,10 @@ ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs,= size_t len, void *buf) regmap_write(rpc->regmap, RPCIF_DRDMCR, rpc->dummy); regmap_write(rpc->regmap, RPCIF_DRDRENR, rpc->ddr); =20 - memcpy_fromio(buf, rpc->dirmap + from, len); + if (rpc->bus_size =3D=3D 2) + memcpy_fromio_readw(buf, rpc->dirmap + from, len); + else + memcpy_fromio(buf, rpc->dirmap + from, len); =20 pm_runtime_put(rpc->dev); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 540FEC433EF for ; Mon, 11 Jul 2022 09:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiGKJmA (ORCPT ); Mon, 11 Jul 2022 05:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbiGKJl1 (ORCPT ); Mon, 11 Jul 2022 05:41:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 832AF90DB3; Mon, 11 Jul 2022 02:20: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 9AABD612E8; Mon, 11 Jul 2022 09:20:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC76FC34115; Mon, 11 Jul 2022 09:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531256; bh=veREzOZlBf95QLXM5VTk9WLdU/1eFzIUtrtNp0cu6sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=umh5QyddX7m1rvIQXZUvcMa392QykRcbZexjh6tPuYE2Pu5j71yvyy8745s6NrDDS MI4ELhwoF1P9tLFeSu36DiMpbaNRflUkGsTkIBrvU0tTqhINiZKgtPaI1YdKzEmEhH a/qfKRY3bIwi5B5Tx0Wwuhkt8PoOkBw3fpyI7JtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Seevalamuthu Mariappan , Kalle Valo , Sasha Levin Subject: [PATCH 5.15 038/230] ath11k: add hw_param for wakeup_mhi Date: Mon, 11 Jul 2022 11:04:54 +0200 Message-Id: <20220711090605.164478217@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Seevalamuthu Mariappan [ Upstream commit 081e2d6476e30399433b509684d5da4d1844e430 ] Wakeup mhi is needed before pci_read/write only for QCA6390 and WCN6855. Si= nce wakeup & release mhi is enabled for all hardwares, below mhi assert is seen= in QCN9074 when doing 'rmmod ath11k_pci': Kernel panic - not syncing: dev_wake !=3D 0 CPU: 2 PID: 13535 Comm: procd Not tainted 4.4.60 #1 Hardware name: Generic DT based system [<80316dac>] (unwind_backtrace) from [<80313700>] (show_stack+0x10/0x14) [<80313700>] (show_stack) from [<805135dc>] (dump_stack+0x7c/0x9c) [<805135dc>] (dump_stack) from [<8032136c>] (panic+0x84/0x1f8) [<8032136c>] (panic) from [<80549b24>] (mhi_pm_disable_transition+0x3b8/0x= 5b8) [<80549b24>] (mhi_pm_disable_transition) from [<80549ddc>] (mhi_power_down= +0xb8/0x100) [<80549ddc>] (mhi_power_down) from [<7f5242b0>] (ath11k_mhi_op_status_cb+0= x284/0x3ac [ath11k_pci]) [E][__mhi_device_get_sync] Did not enter M0 state, cur_state:RESET pm_stat= e:SHUTDOWN Process [E][__mhi_device_get_sync] Did not enter M0 state, cur_state:RESET pm_stat= e:SHUTDOWN Process [E][__mhi_device_get_sync] Did not enter M0 state, cur_state:RESET pm_stat= e:SHUTDOWN Process [<7f5242b0>] (ath11k_mhi_op_status_cb [ath11k_pci]) from [<7f524878>] (ath= 11k_mhi_stop+0x10/0x20 [ath11k_pci]) [<7f524878>] (ath11k_mhi_stop [ath11k_pci]) from [<7f525b94>] (ath11k_pci_= power_down+0x54/0x90 [ath11k_pci]) [<7f525b94>] (ath11k_pci_power_down [ath11k_pci]) from [<8056b2a8>] (pci_d= evice_shutdown+0x30/0x44) [<8056b2a8>] (pci_device_shutdown) from [<805cfa0c>] (device_shutdown+0x12= 4/0x174) [<805cfa0c>] (device_shutdown) from [<8033aaa4>] (kernel_restart+0xc/0x50) [<8033aaa4>] (kernel_restart) from [<8033ada8>] (SyS_reboot+0x178/0x1ec) [<8033ada8>] (SyS_reboot) from [<80301b80>] (ret_fast_syscall+0x0/0x34) Hence, disable wakeup/release mhi using hw_param for other hardwares. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01060-QCAHKSWPL_SILICONZ-1 Fixes: a05bd8513335 ("ath11k: read and write registers below unwindowed add= ress") Signed-off-by: Seevalamuthu Mariappan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1636702019-26142-1-git-send-email-quic_seev= alam@quicinc.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/wireless/ath/ath11k/core.c | 5 +++++ drivers/net/wireless/ath/ath11k/hw.h | 1 + drivers/net/wireless/ath/ath11k/pci.c | 12 ++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/= ath/ath11k/core.c index 7dcf6b13f794..48b4151e13a3 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -71,6 +71,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = =3D { .supports_suspend =3D false, .hal_desc_sz =3D sizeof(struct hal_rx_desc_ipq8074), .fix_l1ss =3D true, + .wakeup_mhi =3D false, }, { .hw_rev =3D ATH11K_HW_IPQ6018_HW10, @@ -112,6 +113,7 @@ static const struct ath11k_hw_params ath11k_hw_params[]= =3D { .supports_suspend =3D false, .hal_desc_sz =3D sizeof(struct hal_rx_desc_ipq8074), .fix_l1ss =3D true, + .wakeup_mhi =3D false, }, { .name =3D "qca6390 hw2.0", @@ -152,6 +154,7 @@ static const struct ath11k_hw_params ath11k_hw_params[]= =3D { .supports_suspend =3D true, .hal_desc_sz =3D sizeof(struct hal_rx_desc_ipq8074), .fix_l1ss =3D true, + .wakeup_mhi =3D true, }, { .name =3D "qcn9074 hw1.0", @@ -190,6 +193,7 @@ static const struct ath11k_hw_params ath11k_hw_params[]= =3D { .supports_suspend =3D false, .hal_desc_sz =3D sizeof(struct hal_rx_desc_qcn9074), .fix_l1ss =3D true, + .wakeup_mhi =3D false, }, { .name =3D "wcn6855 hw2.0", @@ -230,6 +234,7 @@ static const struct ath11k_hw_params ath11k_hw_params[]= =3D { .supports_suspend =3D true, .hal_desc_sz =3D sizeof(struct hal_rx_desc_wcn6855), .fix_l1ss =3D false, + .wakeup_mhi =3D true, }, }; =20 diff --git a/drivers/net/wireless/ath/ath11k/hw.h b/drivers/net/wireless/at= h/ath11k/hw.h index 62f5978b3005..4fe051625edf 100644 --- a/drivers/net/wireless/ath/ath11k/hw.h +++ b/drivers/net/wireless/ath/ath11k/hw.h @@ -163,6 +163,7 @@ struct ath11k_hw_params { bool supports_suspend; u32 hal_desc_sz; bool fix_l1ss; + bool wakeup_mhi; }; =20 struct ath11k_hw_ops { diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/a= th/ath11k/pci.c index 353a2d669fcd..7d0be9388f89 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -182,7 +182,8 @@ void ath11k_pci_write32(struct ath11k_base *ab, u32 off= set, u32 value) /* for offset beyond BAR + 4K - 32, may * need to wakeup MHI to access. */ - if (test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && + if (ab->hw_params.wakeup_mhi && + test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && offset >=3D ACCESS_ALWAYS_OFF) mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev); =20 @@ -206,7 +207,8 @@ void ath11k_pci_write32(struct ath11k_base *ab, u32 off= set, u32 value) } } =20 - if (test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && + if (ab->hw_params.wakeup_mhi && + test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && offset >=3D ACCESS_ALWAYS_OFF) mhi_device_put(ab_pci->mhi_ctrl->mhi_dev); } @@ -219,7 +221,8 @@ u32 ath11k_pci_read32(struct ath11k_base *ab, u32 offse= t) /* for offset beyond BAR + 4K - 32, may * need to wakeup MHI to access. */ - if (test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && + if (ab->hw_params.wakeup_mhi && + test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && offset >=3D ACCESS_ALWAYS_OFF) mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev); =20 @@ -243,7 +246,8 @@ u32 ath11k_pci_read32(struct ath11k_base *ab, u32 offse= t) } } =20 - if (test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && + if (ab->hw_params.wakeup_mhi && + test_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags) && offset >=3D ACCESS_ALWAYS_OFF) mhi_device_put(ab_pci->mhi_ctrl->mhi_dev); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 ABCD1C43334 for ; Mon, 11 Jul 2022 09:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbiGKJmR (ORCPT ); Mon, 11 Jul 2022 05:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233343AbiGKJls (ORCPT ); Mon, 11 Jul 2022 05:41:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 936E997A29; Mon, 11 Jul 2022 02:21: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 sin.source.kernel.org (Postfix) with ESMTPS id 79F57CE1256; Mon, 11 Jul 2022 09:21:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65A72C34115; Mon, 11 Jul 2022 09:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531258; bh=6wpvfPx7HWP4AWB4A4y3rp0pXm8akVz7duV++56Giq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEE1L3foD8tR2ox2gg+h1kneYCBqSzjRNDgK7jtqEXbzeXSAekae6xY5wcoCfssos kxEehL8NDC+5EjHMyMAa2hncCQv8ofSQSLuWmc7UOBQkn68Kz1f0ff31vmk7qYzzH9 bc48TE2tmokEXhAiiIpHihj+a4zLdDj3tO4+1ai0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naresh Kamboju , Ariel Elior , Shai Malin , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 039/230] qed: Improve the stack space of filter_config() Date: Mon, 11 Jul 2022 11:04:55 +0200 Message-Id: <20220711090605.192560383@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Shai Malin [ Upstream commit f55e36d5ab76c3097ff36ecea60b91c6b0d80fc8 ] As it was reported and discussed in: https://lore.kernel.org/lkml/CAHk-=3Dw= hF9F89vsfH8E9TGc0tZA-yhzi2Di8wOtquNB5vRkFX5w@mail.gmail.com/ This patch improves the stack space of qede_config_rx_mode() by splitting filter_config() to 3 functions and removing the union qed_filter_type_params. Reported-by: Naresh Kamboju Signed-off-by: Ariel Elior Signed-off-by: Shai Malin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/qlogic/qed/qed_l2.c | 23 ++------- .../net/ethernet/qlogic/qede/qede_filter.c | 47 ++++++++----------- include/linux/qed/qed_eth_if.h | 21 ++++----- 3 files changed, 30 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/etherne= t/qlogic/qed/qed_l2.c index dfaf10edfabf..ba8c7a31cce1 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_l2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c @@ -2763,25 +2763,6 @@ static int qed_configure_filter_mcast(struct qed_dev= *cdev, return qed_filter_mcast_cmd(cdev, &mcast, QED_SPQ_MODE_CB, NULL); } =20 -static int qed_configure_filter(struct qed_dev *cdev, - struct qed_filter_params *params) -{ - enum qed_filter_rx_mode_type accept_flags; - - switch (params->type) { - case QED_FILTER_TYPE_UCAST: - return qed_configure_filter_ucast(cdev, ¶ms->filter.ucast); - case QED_FILTER_TYPE_MCAST: - return qed_configure_filter_mcast(cdev, ¶ms->filter.mcast); - case QED_FILTER_TYPE_RX_MODE: - accept_flags =3D params->filter.accept_flags; - return qed_configure_filter_rx_mode(cdev, accept_flags); - default: - DP_NOTICE(cdev, "Unknown filter type %d\n", (int)params->type); - return -EINVAL; - } -} - static int qed_configure_arfs_searcher(struct qed_dev *cdev, enum qed_filter_config_mode mode) { @@ -2904,7 +2885,9 @@ static const struct qed_eth_ops qed_eth_ops_pass =3D { .q_rx_stop =3D &qed_stop_rxq, .q_tx_start =3D &qed_start_txq, .q_tx_stop =3D &qed_stop_txq, - .filter_config =3D &qed_configure_filter, + .filter_config_rx_mode =3D &qed_configure_filter_rx_mode, + .filter_config_ucast =3D &qed_configure_filter_ucast, + .filter_config_mcast =3D &qed_configure_filter_mcast, .fastpath_stop =3D &qed_fastpath_stop, .eth_cqe_completion =3D &qed_fp_cqe_completion, .get_vport_stats =3D &qed_get_vport_stats, diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/e= thernet/qlogic/qede/qede_filter.c index a2e4dfb5cb44..f99b085b56a5 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -619,30 +619,28 @@ static int qede_set_ucast_rx_mac(struct qede_dev *ede= v, enum qed_filter_xcast_params_type opcode, unsigned char mac[ETH_ALEN]) { - struct qed_filter_params filter_cmd; + struct qed_filter_ucast_params ucast; =20 - memset(&filter_cmd, 0, sizeof(filter_cmd)); - filter_cmd.type =3D QED_FILTER_TYPE_UCAST; - filter_cmd.filter.ucast.type =3D opcode; - filter_cmd.filter.ucast.mac_valid =3D 1; - ether_addr_copy(filter_cmd.filter.ucast.mac, mac); + memset(&ucast, 0, sizeof(ucast)); + ucast.type =3D opcode; + ucast.mac_valid =3D 1; + ether_addr_copy(ucast.mac, mac); =20 - return edev->ops->filter_config(edev->cdev, &filter_cmd); + return edev->ops->filter_config_ucast(edev->cdev, &ucast); } =20 static int qede_set_ucast_rx_vlan(struct qede_dev *edev, enum qed_filter_xcast_params_type opcode, u16 vid) { - struct qed_filter_params filter_cmd; + struct qed_filter_ucast_params ucast; =20 - memset(&filter_cmd, 0, sizeof(filter_cmd)); - filter_cmd.type =3D QED_FILTER_TYPE_UCAST; - filter_cmd.filter.ucast.type =3D opcode; - filter_cmd.filter.ucast.vlan_valid =3D 1; - filter_cmd.filter.ucast.vlan =3D vid; + memset(&ucast, 0, sizeof(ucast)); + ucast.type =3D opcode; + ucast.vlan_valid =3D 1; + ucast.vlan =3D vid; =20 - return edev->ops->filter_config(edev->cdev, &filter_cmd); + return edev->ops->filter_config_ucast(edev->cdev, &ucast); } =20 static int qede_config_accept_any_vlan(struct qede_dev *edev, bool action) @@ -1057,18 +1055,17 @@ static int qede_set_mcast_rx_mac(struct qede_dev *e= dev, enum qed_filter_xcast_params_type opcode, unsigned char *mac, int num_macs) { - struct qed_filter_params filter_cmd; + struct qed_filter_mcast_params mcast; int i; =20 - memset(&filter_cmd, 0, sizeof(filter_cmd)); - filter_cmd.type =3D QED_FILTER_TYPE_MCAST; - filter_cmd.filter.mcast.type =3D opcode; - filter_cmd.filter.mcast.num =3D num_macs; + memset(&mcast, 0, sizeof(mcast)); + mcast.type =3D opcode; + mcast.num =3D num_macs; =20 for (i =3D 0; i < num_macs; i++, mac +=3D ETH_ALEN) - ether_addr_copy(filter_cmd.filter.mcast.mac[i], mac); + ether_addr_copy(mcast.mac[i], mac); =20 - return edev->ops->filter_config(edev->cdev, &filter_cmd); + return edev->ops->filter_config_mcast(edev->cdev, &mcast); } =20 int qede_set_mac_addr(struct net_device *ndev, void *p) @@ -1194,7 +1191,6 @@ void qede_config_rx_mode(struct net_device *ndev) { enum qed_filter_rx_mode_type accept_flags; struct qede_dev *edev =3D netdev_priv(ndev); - struct qed_filter_params rx_mode; unsigned char *uc_macs, *temp; struct netdev_hw_addr *ha; int rc, uc_count; @@ -1220,10 +1216,6 @@ void qede_config_rx_mode(struct net_device *ndev) =20 netif_addr_unlock_bh(ndev); =20 - /* Configure the struct for the Rx mode */ - memset(&rx_mode, 0, sizeof(struct qed_filter_params)); - rx_mode.type =3D QED_FILTER_TYPE_RX_MODE; - /* Remove all previous unicast secondary macs and multicast macs * (configure / leave the primary mac) */ @@ -1271,8 +1263,7 @@ void qede_config_rx_mode(struct net_device *ndev) qede_config_accept_any_vlan(edev, false); } =20 - rx_mode.filter.accept_flags =3D accept_flags; - edev->ops->filter_config(edev->cdev, &rx_mode); + edev->ops->filter_config_rx_mode(edev->cdev, accept_flags); out: kfree(uc_macs); } diff --git a/include/linux/qed/qed_eth_if.h b/include/linux/qed/qed_eth_if.h index 812a4d751163..4df0bf0a0864 100644 --- a/include/linux/qed/qed_eth_if.h +++ b/include/linux/qed/qed_eth_if.h @@ -145,12 +145,6 @@ struct qed_filter_mcast_params { unsigned char mac[64][ETH_ALEN]; }; =20 -union qed_filter_type_params { - enum qed_filter_rx_mode_type accept_flags; - struct qed_filter_ucast_params ucast; - struct qed_filter_mcast_params mcast; -}; - enum qed_filter_type { QED_FILTER_TYPE_UCAST, QED_FILTER_TYPE_MCAST, @@ -158,11 +152,6 @@ enum qed_filter_type { QED_MAX_FILTER_TYPES, }; =20 -struct qed_filter_params { - enum qed_filter_type type; - union qed_filter_type_params filter; -}; - struct qed_tunn_params { u16 vxlan_port; u8 update_vxlan_port; @@ -314,8 +303,14 @@ struct qed_eth_ops { =20 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); =20 - int (*filter_config)(struct qed_dev *cdev, - struct qed_filter_params *params); + int (*filter_config_rx_mode)(struct qed_dev *cdev, + enum qed_filter_rx_mode_type type); + + int (*filter_config_ucast)(struct qed_dev *cdev, + struct qed_filter_ucast_params *params); + + int (*filter_config_mcast)(struct qed_dev *cdev, + struct qed_filter_mcast_params *params); =20 int (*fastpath_stop)(struct qed_dev *cdev); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E6A16CCA47B for ; Mon, 11 Jul 2022 09:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233007AbiGKJmO (ORCPT ); Mon, 11 Jul 2022 05:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbiGKJls (ORCPT ); Mon, 11 Jul 2022 05:41:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92B72545D9; Mon, 11 Jul 2022 02:21: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 sin.source.kernel.org (Postfix) with ESMTPS id 3387FCE1261; Mon, 11 Jul 2022 09:21:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28A6AC34115; Mon, 11 Jul 2022 09:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531261; bh=lBs3T7xG3KVxzjM+1QQloaEKYvmThmvW7933opqJwKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QU51YLJm3m1bdgW91lMGvYT8CoFEtSZC3vLZJVmyT9he/km59diI2mOJnhdvLPMN vIuM90mY4jcVmvcgeI08HouZYF6Q/K+rXxqSf/fHKorREbijObAfr4CuUvSzcXGa+Q QXL1e4J1FU+Ce48IKtDBY4WuW60icNXkxNX25ODw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= , Hans de Goede , Sasha Levin Subject: [PATCH 5.15 040/230] platform/x86: wmi: introduce helper to convert driver to WMI driver Date: Mon, 11 Jul 2022 11:04:56 +0200 Message-Id: <20220711090605.220579381@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Barnab=C3=A1s P=C5=91cze [ Upstream commit e7b2e33449e22fdbaa0247d96f31543affe6163d ] Introduce a helper function which wraps the appropriate `container_of()` macro invocation to convert a `struct device_driver` to `struct wmi_driver`. Signed-off-by: Barnab=C3=A1s P=C5=91cze Link: https://lore.kernel.org/r/20210904175450.156801-27-pobrn@protonmail.c= om Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/platform/x86/wmi.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 1b65bb61ce88..9aeb1a009097 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -676,6 +676,11 @@ static struct wmi_device *dev_to_wdev(struct device *d= ev) return container_of(dev, struct wmi_device, dev); } =20 +static inline struct wmi_driver *drv_to_wdrv(struct device_driver *drv) +{ + return container_of(drv, struct wmi_driver, driver); +} + /* * sysfs interface */ @@ -794,8 +799,7 @@ static void wmi_dev_release(struct device *dev) =20 static int wmi_dev_match(struct device *dev, struct device_driver *driver) { - struct wmi_driver *wmi_driver =3D - container_of(driver, struct wmi_driver, driver); + struct wmi_driver *wmi_driver =3D drv_to_wdrv(driver); struct wmi_block *wblock =3D dev_to_wblock(dev); const struct wmi_device_id *id =3D wmi_driver->id_table; =20 @@ -892,8 +896,7 @@ static long wmi_ioctl(struct file *filp, unsigned int c= md, unsigned long arg) } =20 /* let the driver do any filtering and do the call */ - wdriver =3D container_of(wblock->dev.dev.driver, - struct wmi_driver, driver); + wdriver =3D drv_to_wdrv(wblock->dev.dev.driver); if (!try_module_get(wdriver->driver.owner)) { ret =3D -EBUSY; goto out_ioctl; @@ -926,8 +929,7 @@ static const struct file_operations wmi_fops =3D { static int wmi_dev_probe(struct device *dev) { struct wmi_block *wblock =3D dev_to_wblock(dev); - struct wmi_driver *wdriver =3D - container_of(dev->driver, struct wmi_driver, driver); + struct wmi_driver *wdriver =3D drv_to_wdrv(dev->driver); int ret =3D 0; char *buf; =20 @@ -990,8 +992,7 @@ static int wmi_dev_probe(struct device *dev) static void wmi_dev_remove(struct device *dev) { struct wmi_block *wblock =3D dev_to_wblock(dev); - struct wmi_driver *wdriver =3D - container_of(dev->driver, struct wmi_driver, driver); + struct wmi_driver *wdriver =3D drv_to_wdrv(dev->driver); =20 if (wdriver->filter_callback) { misc_deregister(&wblock->char_dev); @@ -1296,15 +1297,12 @@ static void acpi_wmi_notify_handler(acpi_handle han= dle, u32 event, =20 /* If a driver is bound, then notify the driver. */ if (wblock->dev.dev.driver) { - struct wmi_driver *driver; + struct wmi_driver *driver =3D drv_to_wdrv(wblock->dev.dev.driver); struct acpi_object_list input; union acpi_object params[1]; struct acpi_buffer evdata =3D { ACPI_ALLOCATE_BUFFER, NULL }; acpi_status status; =20 - driver =3D container_of(wblock->dev.dev.driver, - struct wmi_driver, driver); - input.count =3D 1; input.pointer =3D params; params[0].type =3D ACPI_TYPE_INTEGER; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 DC480C43334 for ; Mon, 11 Jul 2022 09:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233324AbiGKJmd (ORCPT ); Mon, 11 Jul 2022 05:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233273AbiGKJmL (ORCPT ); Mon, 11 Jul 2022 05:42:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00A5B9A6AE; Mon, 11 Jul 2022 02:21: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 4AE8BB80E87; Mon, 11 Jul 2022 09:21:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE360C341CB; Mon, 11 Jul 2022 09:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531267; bh=ZW4rVaNnZVyHbKOzlfPdxJiSJjl1u7LswruOjxCA1rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XCGi73Wos92Ssm9a+O2h3QbxGfxa+uFRTgj+ZeQHTkmDNc8bjO6E7GG6rj3PubiDN 1wLrI+yxF64ldCKHCbEbKLkpjmnAv8ngsziWSnyg/6CkSkVsPmKjNYVqROHlbKPbR8 H4qrzsFLqqNDeEf8KHdx1l65/VvuQFuCNEE0Y2PA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Hans de Goede , Sasha Levin Subject: [PATCH 5.15 041/230] platform/x86: wmi: Replace read_takes_no_args with a flags field Date: Mon, 11 Jul 2022 11:04:57 +0200 Message-Id: <20220711090605.249153243@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 a90b38c58667142ecff2521481ed44286d46b140 ] Replace the wmi_block.read_takes_no_args bool field with an unsigned long flags field, used together with test_bit() and friends. This is a preparation patch for fixing a driver->notify() vs ->probe() race, which requires atomic flag handling. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20211128190031.405620-1-hdegoede@redhat.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/platform/x86/wmi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 9aeb1a009097..a00b72ace6d2 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -51,6 +51,10 @@ struct guid_block { u8 flags; }; =20 +enum { /* wmi_block flags */ + WMI_READ_TAKES_NO_ARGS, +}; + struct wmi_block { struct wmi_device dev; struct list_head list; @@ -61,8 +65,7 @@ struct wmi_block { wmi_notify_handler handler; void *handler_data; u64 req_buf_size; - - bool read_takes_no_args; + unsigned long flags; }; =20 =20 @@ -325,7 +328,7 @@ static acpi_status __query_block(struct wmi_block *wblo= ck, u8 instance, wq_params[0].type =3D ACPI_TYPE_INTEGER; wq_params[0].integer.value =3D instance; =20 - if (instance =3D=3D 0 && wblock->read_takes_no_args) + if (instance =3D=3D 0 && test_bit(WMI_READ_TAKES_NO_ARGS, &wblock->flags)) input.count =3D 0; =20 /* @@ -1087,7 +1090,7 @@ static int wmi_create_device(struct device *wmi_bus_d= ev, * laptops, WQxx may not be a method at all.) */ if (info->type !=3D ACPI_TYPE_METHOD || info->param_count =3D=3D 0) - wblock->read_takes_no_args =3D true; + set_bit(WMI_READ_TAKES_NO_ARGS, &wblock->flags); =20 kfree(info); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B807DC433EF for ; Mon, 11 Jul 2022 09:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233345AbiGKJmk (ORCPT ); Mon, 11 Jul 2022 05:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233046AbiGKJmO (ORCPT ); Mon, 11 Jul 2022 05:42:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C4E89B191; Mon, 11 Jul 2022 02:21:11 -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 6315F612F3; Mon, 11 Jul 2022 09:21:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 715C4C34115; Mon, 11 Jul 2022 09:21:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531269; bh=DuRnfld3GVLwDCJgA7tVCkA/1g0bZZs/tHdu9/d1NME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gUmfpv/SncEhxw5dItkV4PH6dj1IN3xmQVcaq3NIgpcbxzOV2ICjRH1NohCOfObMy 0BUxH0oPPwYJtzuXlq2vbMrjXpOHEg4sa0uUlYMIAGBPSy3R6QuL1g0LYkX0P5x4i7 U8dhmEFaNJhLzdm1lOjGXp5zT+LrMwU+4Ej9WruI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Hans de Goede , Sasha Levin Subject: [PATCH 5.15 042/230] platform/x86: wmi: Fix driver->notify() vs ->probe() race Date: Mon, 11 Jul 2022 11:04:58 +0200 Message-Id: <20220711090605.277376059@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 9918878676a5f9e99b98679f04b9e6c0f5426b0a ] The driver core sets struct device->driver before calling out to the bus' probe() method, this leaves a window where an ACPI notify may happen on the WMI object before the driver's probe() method has completed running, causing e.g. the driver's notify() callback to get called with drvdata not yet being set leading to a NULL pointer deref. At a check for this to the WMI core, ensuring that the notify() callback is not called before the driver is ready. Fixes: 1686f5444546 ("platform/x86: wmi: Incorporate acpi_install_notify_ha= ndler") Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20211128190031.405620-2-hdegoede@redhat.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a00b72ace6d2..c4f917d45b51 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -53,6 +53,7 @@ struct guid_block { =20 enum { /* wmi_block flags */ WMI_READ_TAKES_NO_ARGS, + WMI_PROBED, }; =20 struct wmi_block { @@ -980,6 +981,7 @@ static int wmi_dev_probe(struct device *dev) } } =20 + set_bit(WMI_PROBED, &wblock->flags); return 0; =20 probe_misc_failure: @@ -997,6 +999,8 @@ static void wmi_dev_remove(struct device *dev) struct wmi_block *wblock =3D dev_to_wblock(dev); struct wmi_driver *wdriver =3D drv_to_wdrv(dev->driver); =20 + clear_bit(WMI_PROBED, &wblock->flags); + if (wdriver->filter_callback) { misc_deregister(&wblock->char_dev); kfree(wblock->char_dev.name); @@ -1299,7 +1303,7 @@ static void acpi_wmi_notify_handler(acpi_handle handl= e, u32 event, return; =20 /* If a driver is bound, then notify the driver. */ - if (wblock->dev.dev.driver) { + if (test_bit(WMI_PROBED, &wblock->flags) && wblock->dev.dev.driver) { struct wmi_driver *driver =3D drv_to_wdrv(wblock->dev.dev.driver); struct acpi_object_list input; union acpi_object params[1]; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 8812AC433EF for ; Mon, 11 Jul 2022 09:42:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232970AbiGKJmt (ORCPT ); Mon, 11 Jul 2022 05:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232557AbiGKJmR (ORCPT ); Mon, 11 Jul 2022 05:42:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF2E9B9D5; Mon, 11 Jul 2022 02:21: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 sin.source.kernel.org (Postfix) with ESMTPS id 269F1CE1256; Mon, 11 Jul 2022 09:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E27EC34115; Mon, 11 Jul 2022 09:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531272; bh=wct9TWBIQK2Q+mh6dK2ze1PHgs5Waxx3OF/u1J/ohq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LEh+7VUG6UDUhIFQZSZuML74eRbmLN3UmWT8pQ1uMF8ZM31geKPHCaB6QhR5ODEeS t7UJHo6BRd1pW5oIOmSpt5SW6W/2nhv8daia/OsJpQxaEH+WG2JucWkTOII5crEtnA Mc8Flac1nIALztNIgjkR5pE5OeXFze5UnpUbcrDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.15 043/230] mt76: mt7921: get rid of mt7921_mac_set_beacon_filter Date: Mon, 11 Jul 2022 11:04:59 +0200 Message-Id: <20220711090605.304966389@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lorenzo Bianconi [ Upstream commit b30363102a4122f6eed37927b64a2c7ac70b8859 ] Remove mt7921_mac_set_beacon_filter routine since it is no longer used. Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../net/wireless/mediatek/mt76/mt7921/mac.c | 28 ------------------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 -- 2 files changed, 31 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/= wireless/mediatek/mt76/mt7921/mac.c index bef8d4a76ed9..426e7a32bdc8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1573,34 +1573,6 @@ void mt7921_pm_power_save_work(struct work_struct *w= ork) queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); } =20 -int mt7921_mac_set_beacon_filter(struct mt7921_phy *phy, - struct ieee80211_vif *vif, - bool enable) -{ - struct mt7921_dev *dev =3D phy->dev; - bool ext_phy =3D phy !=3D &dev->phy; - int err; - - if (!dev->pm.enable) - return -EOPNOTSUPP; - - err =3D mt7921_mcu_set_bss_pm(dev, vif, enable); - if (err) - return err; - - if (enable) { - vif->driver_flags |=3D IEEE80211_VIF_BEACON_FILTER; - mt76_set(dev, MT_WF_RFCR(ext_phy), - MT_WF_RFCR_DROP_OTHER_BEACON); - } else { - vif->driver_flags &=3D ~IEEE80211_VIF_BEACON_FILTER; - mt76_clear(dev, MT_WF_RFCR(ext_phy), - MT_WF_RFCR_DROP_OTHER_BEACON); - } - - return 0; -} - void mt7921_coredump_work(struct work_struct *work) { struct mt7921_dev *dev; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/n= et/wireless/mediatek/mt76/mt7921/mt7921.h index 2d8bd6bfc820..1aafd8723b3a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -381,9 +381,6 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev); void mt7921_pm_wake_work(struct work_struct *work); void mt7921_pm_power_save_work(struct work_struct *work); bool mt7921_wait_for_mcu_init(struct mt7921_dev *dev); -int mt7921_mac_set_beacon_filter(struct mt7921_phy *phy, - struct ieee80211_vif *vif, - bool enable); void mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *v= if); void mt7921_coredump_work(struct work_struct *work); int mt7921_wfsys_reset(struct mt7921_dev *dev); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B3BE6C433EF for ; Mon, 11 Jul 2022 09:48:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbiGKJsu (ORCPT ); Mon, 11 Jul 2022 05:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233665AbiGKJsH (ORCPT ); Mon, 11 Jul 2022 05:48:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D922AAC05A; Mon, 11 Jul 2022 02:23: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 124C56134C; Mon, 11 Jul 2022 09:23:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C952C34115; Mon, 11 Jul 2022 09:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531407; bh=TfdIL7rU0ltrXpRZtd8xYeEWIr2ewaX2dINJEnxfA1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIBefv5ZQebgiD+7YMbbXcmN8zLTL+KUiztar/gpY2a60cks4+QkR5GV+eRROprb7 ceyoG96MLvbfKgwwwmqdKv68pruk7Am7PD8TiGaBengxMw0BTTH3Ui3QU1XKkvhiC9 9GjNhopk+dtyX80RgCxM8J5maUl7DTUMDwkoquNg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.15 044/230] mt76: mt7921: introduce mt7921_mcu_set_beacon_filter utility routine Date: Mon, 11 Jul 2022 11:05:00 +0200 Message-Id: <20220711090605.332748198@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lorenzo Bianconi [ Upstream commit 890809ca1986e63d29dd1591090af67b655ed89c ] Introduce mt7921_mcu_set_beacon_filter utility routine in order to remove duplicated code for hw beacon filtering. Move mt7921_pm_interface_iter in debugfs since it is just used there. Make the following routine static: - mt7921_pm_interface_iter - mt7921_mcu_uni_bss_bcnft - mt7921_mcu_set_bss_pm Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../wireless/mediatek/mt76/mt7921/debugfs.c | 20 +++++--- .../net/wireless/mediatek/mt76/mt7921/main.c | 33 +------------ .../net/wireless/mediatek/mt76/mt7921/mcu.c | 47 ++++++++++--------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 8 ++-- 4 files changed, 45 insertions(+), 63 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/= net/wireless/mediatek/mt76/mt7921/debugfs.c index 8d5e261cd10f..82fb2585f413 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -262,30 +262,38 @@ mt7921_txpwr(struct seq_file *s, void *data) return 0; } =20 +static void +mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) +{ + struct mt7921_dev *dev =3D priv; + + mt7921_mcu_set_beacon_filter(dev, vif, dev->pm.enable); +} + static int mt7921_pm_set(void *data, u64 val) { struct mt7921_dev *dev =3D data; struct mt76_connac_pm *pm =3D &dev->pm; - struct mt76_phy *mphy =3D dev->phy.mt76; - - if (val =3D=3D pm->enable) - return 0; =20 mt7921_mutex_acquire(dev); =20 + if (val =3D=3D pm->enable) + goto out; + if (!pm->enable) { pm->stats.last_wake_event =3D jiffies; pm->stats.last_doze_event =3D jiffies; } pm->enable =3D val; =20 - ieee80211_iterate_active_interfaces(mphy->hw, + ieee80211_iterate_active_interfaces(mt76_hw(dev), IEEE80211_IFACE_ITER_RESUME_ALL, - mt7921_pm_interface_iter, mphy->priv); + mt7921_pm_interface_iter, dev); =20 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); =20 +out: mt7921_mutex_release(dev); =20 return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net= /wireless/mediatek/mt76/mt7921/main.c index 30252f408ddc..13a7ae3d8351 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -528,36 +528,6 @@ static void mt7921_configure_filter(struct ieee80211_h= w *hw, mt7921_mutex_release(dev); } =20 -static int -mt7921_bss_bcnft_apply(struct mt7921_dev *dev, struct ieee80211_vif *vif, - bool assoc) -{ - int ret; - - if (!dev->pm.enable) - return 0; - - if (assoc) { - ret =3D mt7921_mcu_uni_bss_bcnft(dev, vif, true); - if (ret) - return ret; - - vif->driver_flags |=3D IEEE80211_VIF_BEACON_FILTER; - mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); - - return 0; - } - - ret =3D mt7921_mcu_set_bss_pm(dev, vif, false); - if (ret) - return ret; - - vif->driver_flags &=3D ~IEEE80211_VIF_BEACON_FILTER; - mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); - - return 0; -} - static void mt7921_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, @@ -587,7 +557,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw= *hw, if (changed & BSS_CHANGED_ASSOC) { mt7921_mcu_sta_update(dev, NULL, vif, true, MT76_STA_INFO_STATE_ASSOC); - mt7921_bss_bcnft_apply(dev, vif, info->assoc); + if (dev->pm.enable) + mt7921_mcu_set_beacon_filter(dev, vif, info->assoc); } =20 if (changed & BSS_CHANGED_ARP_FILTER) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/= wireless/mediatek/mt76/mt7921/mcu.c index 4119f8efd896..dabc0de2ec65 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1205,8 +1205,9 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, str= uct ieee80211_vif *vif) &ps_req, sizeof(ps_req), true); } =20 -int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif = *vif, - bool enable) +static int +mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable) { struct mt7921_vif *mvif =3D (struct mt7921_vif *)vif->drv_priv; struct { @@ -1240,8 +1241,9 @@ int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, = struct ieee80211_vif *vif, &bcnft_req, sizeof(bcnft_req), true); } =20 -int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vi= f, - bool enable) +static int +mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable) { struct mt7921_vif *mvif =3D (struct mt7921_vif *)vif->drv_priv; struct { @@ -1390,31 +1392,34 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev) return err; } =20 -void -mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) +int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev, + struct ieee80211_vif *vif, + bool enable) { - struct mt7921_phy *phy =3D priv; - struct mt7921_dev *dev =3D phy->dev; struct ieee80211_hw *hw =3D mt76_hw(dev); - int ret; - - if (dev->pm.enable) - ret =3D mt7921_mcu_uni_bss_bcnft(dev, vif, true); - else - ret =3D mt7921_mcu_set_bss_pm(dev, vif, false); + int err; =20 - if (ret) - return; + if (enable) { + err =3D mt7921_mcu_uni_bss_bcnft(dev, vif, true); + if (err) + return err; =20 - if (dev->pm.enable) { vif->driver_flags |=3D IEEE80211_VIF_BEACON_FILTER; ieee80211_hw_set(hw, CONNECTION_MONITOR); mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); - } else { - vif->driver_flags &=3D ~IEEE80211_VIF_BEACON_FILTER; - __clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); - mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); + + return 0; } + + err =3D mt7921_mcu_set_bss_pm(dev, vif, false); + if (err) + return err; + + vif->driver_flags &=3D ~IEEE80211_VIF_BEACON_FILTER; + __clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); + mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); + + return 0; } =20 int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txp= wr) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/n= et/wireless/mediatek/mt76/mt7921/mt7921.h index 1aafd8723b3a..32d4f2cab94e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -363,6 +363,9 @@ void mt7921_set_stream_he_caps(struct mt7921_phy *phy); void mt7921_update_channel(struct mt76_phy *mphy); int mt7921_init_debugfs(struct mt7921_dev *dev); =20 +int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev, + struct ieee80211_vif *vif, + bool enable); int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev, struct ieee80211_ampdu_params *params, bool enable); @@ -371,17 +374,12 @@ int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev, bool enable); void mt7921_scan_work(struct work_struct *work); int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vi= f); -int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif = *vif, - bool enable); -int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vi= f, - bool enable); int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev); int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev); int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev); void mt7921_pm_wake_work(struct work_struct *work); void mt7921_pm_power_save_work(struct work_struct *work); bool mt7921_wait_for_mcu_init(struct mt7921_dev *dev); -void mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *v= if); void mt7921_coredump_work(struct work_struct *work); int mt7921_wfsys_reset(struct mt7921_dev *dev); int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txp= wr); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 9CA6CC433EF for ; Mon, 11 Jul 2022 09:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233405AbiGKJno (ORCPT ); Mon, 11 Jul 2022 05:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbiGKJnH (ORCPT ); Mon, 11 Jul 2022 05:43: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 CC4C1550AA; Mon, 11 Jul 2022 02:21: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 7133161227; Mon, 11 Jul 2022 09:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81C81C34115; Mon, 11 Jul 2022 09:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531291; bh=CNgEGQnfprJQCxT+8dhucvFWX3tVxae3uRH/wYz4l+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ugG8VoqaQ+IhhRq1aHbqG9Uxsw8e+OFu5N3cdjUaOaNnKzny3vujKpECh4yKrUxF dIC8nuZfCXFFt3qgB0GlKHCcffyeZZESWLYDrXmjTz/lphQ8A7ICZMWxItfTo0/MJk 1lffCPdD6kspFIq+KIZROnEmXmBhImNQFlk94LFg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Deren Wu , Lorenzo Bianconi , Kalle Valo , Sasha Levin Subject: [PATCH 5.15 045/230] mt76: mt7921: fix a possible race enabling/disabling runtime-pm Date: Mon, 11 Jul 2022 11:05:01 +0200 Message-Id: <20220711090605.362189585@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lorenzo Bianconi [ Upstream commit d430dffbe9dd30759f3c64b65bf85b0245c8d8ab ] Fix a possible race enabling/disabling runtime-pm between mt7921_pm_set() and mt7921_poll_rx() since mt7921_pm_wake_work() always schedules rx-napi callback and it will trigger mt7921_pm_power_save_work routine putting chip to in low-power state during mt7921_pm_set processing. Suggested-by: Deren Wu Tested-by: Deren Wu Fixes: 1d8efc741df8 ("mt76: mt7921: introduce Runtime PM support") Signed-off-by: Lorenzo Bianconi Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/0f3e075a2033dc05f09dab4059e5be8cbdccc239.16= 40094847.git.lorenzo@kernel.org Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 --- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers= /net/wireless/mediatek/mt76/mt76_connac_mac.c index af43bcb54578..306e9eaea917 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c @@ -7,9 +7,6 @@ int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_c= onnac_pm *pm) { struct mt76_dev *dev =3D phy->dev; =20 - if (!pm->enable) - return 0; - if (mt76_is_usb(dev)) return 0; =20 diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/= net/wireless/mediatek/mt76/mt7921/debugfs.c index 82fb2585f413..b9f25599227d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -276,7 +276,7 @@ mt7921_pm_set(void *data, u64 val) struct mt7921_dev *dev =3D data; struct mt76_connac_pm *pm =3D &dev->pm; =20 - mt7921_mutex_acquire(dev); + mutex_lock(&dev->mt76.mutex); =20 if (val =3D=3D pm->enable) goto out; @@ -285,7 +285,11 @@ mt7921_pm_set(void *data, u64 val) pm->stats.last_wake_event =3D jiffies; pm->stats.last_doze_event =3D jiffies; } - pm->enable =3D val; + /* make sure the chip is awake here and ps_work is scheduled + * just at end of the this routine. + */ + pm->enable =3D false; + mt76_connac_pm_wake(&dev->mphy, pm); =20 ieee80211_iterate_active_interfaces(mt76_hw(dev), IEEE80211_IFACE_ITER_RESUME_ALL, @@ -293,8 +297,10 @@ mt7921_pm_set(void *data, u64 val) =20 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); =20 + pm->enable =3D val; + mt76_connac_power_save_sched(&dev->mphy, pm); out: - mt7921_mutex_release(dev); + mutex_unlock(&dev->mt76.mutex); =20 return 0; } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E9B5DC433EF for ; Mon, 11 Jul 2022 09:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233462AbiGKJpo (ORCPT ); Mon, 11 Jul 2022 05:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233606AbiGKJo2 (ORCPT ); Mon, 11 Jul 2022 05:44: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 B96043E75F; Mon, 11 Jul 2022 02:22: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 1C96BB80D2C; Mon, 11 Jul 2022 09:22:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D363C34115; Mon, 11 Jul 2022 09:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531321; bh=PyFmHW+SAkR6HsxRgSb5+k3Fe6DCWDzbWPlYeRLRIkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=incqfgm8uuDIcTAMphNhFF6cJaJ1OE4ZuX3W4fw+UlaikdI5odC0UsWmzeCN0E2Ow nDQ5pyjxaHlg5dHmus761hEMs2VYKyW8f+zbweEXnI7grBXd9bqP8z1amM6hUJFDxD ZwLJjcTDUgyaZV35dtPysI2hvJHKyNDJRqZ6PHLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Tao , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.15 046/230] bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC Date: Mon, 11 Jul 2022 11:05:02 +0200 Message-Id: <20220711090605.389897644@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Hou Tao [ Upstream commit e4a41c2c1fa916547e63440c73a51a5eb06247af ] The following error is reported when running "./test_progs -t for_each" under arm64: bpf_jit: multi-func JIT bug 58 !=3D 56 [...] JIT doesn't support bpf-to-bpf calls The root cause is the size of BPF_PSEUDO_FUNC instruction increases from 2 to 3 after the address of called bpf-function is settled and there are two bpf-to-bpf calls in test_pkt_access. The generated instructions are shown below: 0x48: 21 00 C0 D2 movz x1, #0x1, lsl #32 0x4c: 21 00 80 F2 movk x1, #0x1 0x48: E1 3F C0 92 movn x1, #0x1ff, lsl #32 0x4c: 41 FE A2 F2 movk x1, #0x17f2, lsl #16 0x50: 81 70 9F F2 movk x1, #0xfb84 Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so the size of jited image will not change. Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper") Signed-off-by: Hou Tao Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20211231151018.3781550-1-houtao1@huawei.c= om Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/net/bpf_jit_comp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 95439bbe5df8..4895b4d7e150 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -788,7 +788,10 @@ static int build_insn(const struct bpf_insn *insn, str= uct jit_ctx *ctx, u64 imm64; =20 imm64 =3D (u64)insn1.imm << 32 | (u32)imm; - emit_a64_mov_i64(dst, imm64, ctx); + if (bpf_pseudo_func(insn)) + emit_addr_mov_i64(dst, imm64, ctx); + else + emit_a64_mov_i64(dst, imm64, ctx); =20 return 1; } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 93D61C433EF for ; Mon, 11 Jul 2022 09:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233550AbiGKJqm (ORCPT ); Mon, 11 Jul 2022 05:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233894AbiGKJpI (ORCPT ); Mon, 11 Jul 2022 05:45:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A62A9E77; Mon, 11 Jul 2022 02:22:35 -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 AD868B80D2C; Mon, 11 Jul 2022 09:22:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06A82C34115; Mon, 11 Jul 2022 09:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531352; bh=8De3sl8vo6g6gUNyQnO3fBSHDA2H/6A7rO9gphhjK10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mg3QgpUqe8/SXn20R4lN4Z94mnVktvaK3nqWJMV+lG9bMHLv57XOhY4ODpgjK+kUf nml83mq29aWjfeTjBD4/bHx8o56pbCpeGW9XtC1tX9VAtiKZSudF1txk9OoNJ/VlqX QcmoFfr0enFVAZab8fv7ogcLUObqzZCkmoNMtCYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heinrich Schuchardt , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.15 047/230] riscv: defconfig: enable DRM_NOUVEAU Date: Mon, 11 Jul 2022 11:05:03 +0200 Message-Id: <20220711090605.417740083@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Heinrich Schuchardt [ Upstream commit ffa7a9141bb70702744a312f904b190ca064bdd7 ] Both RADEON and NOUVEAU graphics cards are supported on RISC-V. Enabling the one and not the other does not make sense. As typically at most one of RADEON, NOUVEAU, or VIRTIO GPU support will be needed DRM drivers should be compiled as modules. Signed-off-by: Heinrich Schuchardt Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/riscv/configs/defconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 4ebc80315f01..c252fd5706d2 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -72,9 +72,10 @@ CONFIG_GPIOLIB=3Dy CONFIG_GPIO_SIFIVE=3Dy # CONFIG_PTP_1588_CLOCK is not set CONFIG_POWER_RESET=3Dy -CONFIG_DRM=3Dy -CONFIG_DRM_RADEON=3Dy -CONFIG_DRM_VIRTIO_GPU=3Dy +CONFIG_DRM=3Dm +CONFIG_DRM_RADEON=3Dm +CONFIG_DRM_NOUVEAU=3Dm +CONFIG_DRM_VIRTIO_GPU=3Dm CONFIG_FRAMEBUFFER_CONSOLE=3Dy CONFIG_USB=3Dy CONFIG_USB_XHCI_HCD=3Dy --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B345EC43334 for ; Mon, 11 Jul 2022 09:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233561AbiGKJr6 (ORCPT ); Mon, 11 Jul 2022 05:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233604AbiGKJrU (ORCPT ); Mon, 11 Jul 2022 05:47:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784CE67170; Mon, 11 Jul 2022 02:23: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 F3D40B80E7E; Mon, 11 Jul 2022 09:23:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F016C34115; Mon, 11 Jul 2022 09:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531382; bh=0m0GkOvnLvHQiu/2/bOsz32D+no02E3Q3SY9D2E6upk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1pm+l9tgdBxWjvR9dghsnHS49H8NgHyi0x6j3l1p2okRfi3mTYqYo1+36QqXwK3YT pip+PTafWSXSAv63iwsLSllfleWSziMUTm9p8lEbbFnIINMrc1AzwfVXHWY09gaK3W 1lSUzTVvwLygXnwlAXGCkL5/HH1CI7lFX2Ae/Zxc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anup Patel , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.15 048/230] RISC-V: defconfigs: Set CONFIG_FB=y, for FB console Date: Mon, 11 Jul 2022 11:05:04 +0200 Message-Id: <20220711090605.445561661@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Palmer Dabbelt [ Upstream commit 3d12b634fe8206ea974c6061a3f3eea529ffbc48 ] We have CONFIG_FRAMEBUFFER_CONSOLE=3Dy in the defconfigs, but that depends on CONFIG_FB so it's not actually getting set. I'm assuming most users on real systems want a framebuffer console, so this enables CONFIG_FB to allow that to take effect. Fixes: 33c57c0d3c67 ("RISC-V: Add a basic defconfig") Reviewed-by: Anup Patel Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/riscv/configs/defconfig | 1 + arch/riscv/configs/rv32_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index c252fd5706d2..f2a2f9c9ed49 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -76,6 +76,7 @@ CONFIG_DRM=3Dm CONFIG_DRM_RADEON=3Dm CONFIG_DRM_NOUVEAU=3Dm CONFIG_DRM_VIRTIO_GPU=3Dm +CONFIG_FB=3Dy CONFIG_FRAMEBUFFER_CONSOLE=3Dy CONFIG_USB=3Dy CONFIG_USB_XHCI_HCD=3Dy diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_de= fconfig index 434ef5b64599..cdd113e7a291 100644 --- a/arch/riscv/configs/rv32_defconfig +++ b/arch/riscv/configs/rv32_defconfig @@ -71,6 +71,7 @@ CONFIG_POWER_RESET=3Dy CONFIG_DRM=3Dy CONFIG_DRM_RADEON=3Dy CONFIG_DRM_VIRTIO_GPU=3Dy +CONFIG_FB=3Dy CONFIG_FRAMEBUFFER_CONSOLE=3Dy CONFIG_USB=3Dy CONFIG_USB_XHCI_HCD=3Dy --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 AFED6C433EF for ; Mon, 11 Jul 2022 09:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbiGKJsS (ORCPT ); Mon, 11 Jul 2022 05:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbiGKJrg (ORCPT ); Mon, 11 Jul 2022 05:47:36 -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 CB6C7AB7D2; Mon, 11 Jul 2022 02:23: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3CD4F6134C; Mon, 11 Jul 2022 09:23:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D2AC34115; Mon, 11 Jul 2022 09:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531393; bh=WPtd9kgKbniwNf3BMQri7+fVEcYbfkFdC15EP5tNh+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZWx9vhc/a5lpeYmXK14FzqM+dU4PaF/uzL/cW3o4ciQPl9KU5wa4EZRGIYKVqPf+ V9sw0E1R9FDPBMXppvlgkSpJV6HkI9CYaC8f0hSyfledhIIxYwxDWHUSHdmsCDebHa 1QvxqjkR5WnUvu0eNKoOCuzhigwRV0G3/dmXcP5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Maor Dickman , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 049/230] net/mlx5e: Check action fwd/drop flag exists also for nic flows Date: Mon, 11 Jul 2022 11:05:05 +0200 Message-Id: <20220711090605.473699898@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Roi Dayan [ Upstream commit 6b50cf45b6a0e99f3cab848a72ecca8da56b7460 ] The driver should add offloaded rules with either a fwd or drop action. The check existed in parsing fdb flows but not when parsing nic flows. Move the test into actions_match_supported() which is called for checking nic flows and fdb flows. Signed-off-by: Roi Dayan Reviewed-by: Maor Dickman Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.c index 3aa8d0b83d10..fe52db591121 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3305,6 +3305,12 @@ static bool actions_match_supported(struct mlx5e_pri= v *priv, ct_flow =3D flow_flag_test(flow, CT) && !ct_clear; actions =3D flow->attr->action; =20 + if (!(actions & + (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP)= )) { + NL_SET_ERR_MSG_MOD(extack, "Rule must have at least one forward/drop act= ion"); + return false; + } + if (mlx5e_is_eswitch_flow(flow)) { if (flow->attr->esw_attr->split_count && ct_flow && !MLX5_CAP_GEN(flow->attr->esw_attr->in_mdev, reg_c_preserve)) { @@ -4207,13 +4213,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *p= riv, attr->action |=3D MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; } =20 - if (!(attr->action & - (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP)= )) { - NL_SET_ERR_MSG_MOD(extack, - "Rule must have at least one forward/drop action"); - return -EOPNOTSUPP; - } - if (esw_attr->split_count > 0 && !mlx5_esw_has_fwd_fdb(priv->mdev)) { NL_SET_ERR_MSG_MOD(extack, "current firmware doesn't support split rule for port mirroring"); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 A5208C433EF for ; Mon, 11 Jul 2022 09:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233684AbiGKJsZ (ORCPT ); Mon, 11 Jul 2022 05:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbiGKJrs (ORCPT ); Mon, 11 Jul 2022 05:47:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C555C120; Mon, 11 Jul 2022 02:23: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 17C6361358; Mon, 11 Jul 2022 09:23:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A373C34115; Mon, 11 Jul 2022 09:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531396; bh=KbkTQXL5JZro2qDPXqOXRQfUSjE8Y1CE+IAeO7NGlx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yqaJTmvD/yhLGadE7GxM5G5quOpr1Y5m2wLQXAwAlqaZoS4cs2qzIpBjm0K3epxRL RSr/N0l/1aD989ewtsLBZCIj+BCcWnPq3eU9zDHd7zkwwYTnCfnqCBNPsFwcFT4von wy2aAGMiMSTUkICSvrX873BeCXJR5lIlfibVwDEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Maor Dickman , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 050/230] net/mlx5e: Split actions_match_supported() into a sub function Date: Mon, 11 Jul 2022 11:05:06 +0200 Message-Id: <20220711090605.501082979@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Roi Dayan [ Upstream commit 9c1d3511a2c2fd30c991a20c670991ece4ef27c1 ] There will probably be more checks, some for nic flows, some for fdb flows and some are shared checks. Split it for fdb and nic to avoid the function getting too big. Signed-off-by: Roi Dayan Reviewed-by: Maor Dickman Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 65 +++++++++++-------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.c index fe52db591121..3c6c7801f131 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3291,19 +3291,41 @@ static bool modify_header_match_supported(struct ml= x5e_priv *priv, return true; } =20 -static bool actions_match_supported(struct mlx5e_priv *priv, - struct flow_action *flow_action, - struct mlx5e_tc_flow_parse_attr *parse_attr, - struct mlx5e_tc_flow *flow, - struct netlink_ext_ack *extack) +static bool +actions_match_supported_fdb(struct mlx5e_priv *priv, + struct mlx5e_tc_flow_parse_attr *parse_attr, + struct mlx5e_tc_flow *flow, + struct netlink_ext_ack *extack) +{ + bool ct_flow, ct_clear; + + ct_clear =3D flow->attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR; + ct_flow =3D flow_flag_test(flow, CT) && !ct_clear; + + if (flow->attr->esw_attr->split_count && ct_flow && + !MLX5_CAP_GEN(flow->attr->esw_attr->in_mdev, reg_c_preserve)) { + /* All registers used by ct are cleared when using + * split rules. + */ + NL_SET_ERR_MSG_MOD(extack, "Can't offload mirroring with action ct"); + return false; + } + + return true; +} + +static bool +actions_match_supported(struct mlx5e_priv *priv, + struct flow_action *flow_action, + struct mlx5e_tc_flow_parse_attr *parse_attr, + struct mlx5e_tc_flow *flow, + struct netlink_ext_ack *extack) { - bool ct_flow =3D false, ct_clear =3D false; - u32 actions; + u32 actions =3D flow->attr->action; + bool ct_flow, ct_clear; =20 - ct_clear =3D flow->attr->ct_attr.ct_action & - TCA_CT_ACT_CLEAR; + ct_clear =3D flow->attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR; ct_flow =3D flow_flag_test(flow, CT) && !ct_clear; - actions =3D flow->attr->action; =20 if (!(actions & (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP)= )) { @@ -3311,23 +3333,14 @@ static bool actions_match_supported(struct mlx5e_pr= iv *priv, return false; } =20 - if (mlx5e_is_eswitch_flow(flow)) { - if (flow->attr->esw_attr->split_count && ct_flow && - !MLX5_CAP_GEN(flow->attr->esw_attr->in_mdev, reg_c_preserve)) { - /* All registers used by ct are cleared when using - * split rules. - */ - NL_SET_ERR_MSG_MOD(extack, - "Can't offload mirroring with action ct"); - return false; - } - } + if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && + !modify_header_match_supported(priv, &parse_attr->spec, flow_action, + actions, ct_flow, ct_clear, extack)) + return false; =20 - if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) - return modify_header_match_supported(priv, &parse_attr->spec, - flow_action, actions, - ct_flow, ct_clear, - extack); + if (mlx5e_is_eswitch_flow(flow) && + !actions_match_supported_fdb(priv, parse_attr, flow, extack)) + return false; =20 return true; } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 266A6C433EF for ; Mon, 11 Jul 2022 09:48:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbiGKJsj (ORCPT ); Mon, 11 Jul 2022 05:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233603AbiGKJr4 (ORCPT ); Mon, 11 Jul 2022 05:47:56 -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 87704D92; Mon, 11 Jul 2022 02:23: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 DB8B96134C; Mon, 11 Jul 2022 09:23:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD72EC34115; Mon, 11 Jul 2022 09:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531399; bh=2lrhlPlKo+0MYU30iQed09QSEhys6EiO4JmaY+rUQP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejnpcTNxzhflw2xBtI2AgORMPW185gpYRGdNmbdJuAP8Q5wESqBdmhQlxbZ5rfQt8 CrA6XgtK0W4Oz9dVxoan1eRwHLEaL+GU5a8NJTOptgDzmYzC6biC0TCCqUrdbj9pai t5MqCbV0lWkNletZa/mJMI9rDy6vGWZxT/gJQ9kM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Oz Shlomo , Maor Dickman , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 051/230] net/mlx5e: TC, Reject rules with drop and modify hdr action Date: Mon, 11 Jul 2022 11:05:07 +0200 Message-Id: <20220711090605.528806429@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Roi Dayan [ Upstream commit a2446bc77a16cefd27de712d28af2396d6287593 ] This kind of action is not supported by firmware and generates a syndrome. kernel: mlx5_core 0000:08:00.0: mlx5_cmd_check:777:(pid 102063): SET_FLOW_T= ABLE_ENTRY(0x936) op_mod(0x0) failed, status bad parameter(0x3), syndrome (= 0x8708c3) Fixes: d7e75a325cb2 ("net/mlx5e: Add offloading of E-Switch TC pedit (heade= r re-write) actions") Signed-off-by: Roi Dayan Reviewed-by: Oz Shlomo Reviewed-by: Maor Dickman Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.c index 3c6c7801f131..eb0d9082ccc5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3333,6 +3333,12 @@ actions_match_supported(struct mlx5e_priv *priv, return false; } =20 + if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && + actions & MLX5_FLOW_CONTEXT_ACTION_DROP) { + NL_SET_ERR_MSG_MOD(extack, "Drop with modify header action is not suppor= ted"); + return false; + } + if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && !modify_header_match_supported(priv, &parse_attr->spec, flow_action, actions, ct_flow, ct_clear, extack)) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 45548CCA47B for ; Mon, 11 Jul 2022 09:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233708AbiGKJsq (ORCPT ); Mon, 11 Jul 2022 05:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbiGKJr6 (ORCPT ); Mon, 11 Jul 2022 05:47:58 -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 1F3EED89; Mon, 11 Jul 2022 02:23: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 dfw.source.kernel.org (Postfix) with ESMTPS id 96FB961358; Mon, 11 Jul 2022 09:23:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FBA1C34115; Mon, 11 Jul 2022 09:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531402; bh=wm02mWeYyxCV/JNLH2/EpQYrKWdNV0no7K4htriJ7bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwQ6OxnmqDD/A1kjXxwpL+SWgGPVkVhIP6l9D30SVU3YiSlKCanvnKFsIVXWpGyrm YFXMTm45zdm3V5c74N85BEaUv4jxON45fxt/1E3/BxT+oFBPwLRC6QfmtN5fJUYWXD nWYXDIEJw4K4J57Yj7rMN841wMGE5mjb6GRG47o8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Oz Shlomo , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 052/230] net/mlx5e: TC, Reject rules with forward and drop actions Date: Mon, 11 Jul 2022 11:05:08 +0200 Message-Id: <20220711090605.556990614@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Roi Dayan [ Upstream commit 5623ef8a118838aae65363750dfafcba734dc8cb ] Such rules are redundant but allowed and passed to the driver. The driver does not support offloading such rules so return an error. Fixes: 03a9d11e6eeb ("net/mlx5e: Add TC drop and mirred/redirect action par= sing for SRIOV offloads") Signed-off-by: Roi Dayan Reviewed-by: Oz Shlomo Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.c index eb0d9082ccc5..843c8435387f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3333,6 +3333,12 @@ actions_match_supported(struct mlx5e_priv *priv, return false; } =20 + if (!(~actions & + (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP)= )) { + NL_SET_ERR_MSG_MOD(extack, "Rule cannot support forward+drop action"); + return false; + } + if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && actions & MLX5_FLOW_CONTEXT_ACTION_DROP) { NL_SET_ERR_MSG_MOD(extack, "Drop with modify header action is not suppor= ted"); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 AE5A6CCA480 for ; Mon, 11 Jul 2022 09:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233662AbiGKJsn (ORCPT ); Mon, 11 Jul 2022 05:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232707AbiGKJsC (ORCPT ); Mon, 11 Jul 2022 05:48:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1824AC046; Mon, 11 Jul 2022 02:23: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 dfw.source.kernel.org (Postfix) with ESMTPS id 49415612FB; Mon, 11 Jul 2022 09:23:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5932FC34115; Mon, 11 Jul 2022 09:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531404; bh=+2dRXOeAnlD/vyR6PU7WTgRs5uidsGKSRXNCXxva60s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjfqYZsAjIeeit7w3E3VtcBeQ4H07pYufgttHj2XPV89VxORjRhykkeuwB221DTIM W1vcab7oUl74gz++ogX2P1oar9XIa45FFO5HwQvXdf6SEjLdSquvpkCPmXVr+a1Scv PMmqWqBEva3vk4EpHEcnFEVNqxpI9K2NnoobIyqY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Derek Fang , Mark Brown , Sasha Levin Subject: [PATCH 5.15 053/230] ASoC: rt5682: Avoid the unexpected IRQ event during going to suspend Date: Mon, 11 Jul 2022 11:05:09 +0200 Message-Id: <20220711090605.584904593@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Derek Fang [ Upstream commit a3774a2a6544a7a4a85186e768afc07044aa507f ] When the system suspends, the codec driver will set SAR to power saving mode if a headset is plugged in. There is a chance to generate an unexpected IRQ, and leads to issues after resuming such as noise from OMTP type headsets. Signed-off-by: Derek Fang Link: https://lore.kernel.org/r/20211109095450.12950-1-derek.fang@realtek.c= om Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt5682.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 6ad3159eceb9..949b5638db29 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -48,6 +48,7 @@ static const struct reg_sequence patch_list[] =3D { {RT5682_SAR_IL_CMD_6, 0x0110}, {RT5682_CHARGE_PUMP_1, 0x0210}, {RT5682_HP_LOGIC_CTRL_2, 0x0007}, + {RT5682_SAR_IL_CMD_2, 0xac00}, }; =20 void rt5682_apply_patch_list(struct rt5682_priv *rt5682, struct device *de= v) @@ -2969,9 +2970,6 @@ static int rt5682_suspend(struct snd_soc_component *c= omponent) cancel_delayed_work_sync(&rt5682->jack_detect_work); cancel_delayed_work_sync(&rt5682->jd_check_work); if (rt5682->hs_jack && rt5682->jack_type =3D=3D SND_JACK_HEADSET) { - snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, - RT5682_MB1_PATH_MASK | RT5682_MB2_PATH_MASK, - RT5682_CTRL_MB1_REG | RT5682_CTRL_MB2_REG); val =3D snd_soc_component_read(component, RT5682_CBJ_CTRL_2) & RT5682_JACK_TYPE_MASK; =20 @@ -2993,10 +2991,15 @@ static int rt5682_suspend(struct snd_soc_component = *component) /* enter SAR ADC power saving mode */ snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1, RT5682_SAR_BUTT_DET_MASK | RT5682_SAR_BUTDET_MODE_MASK | - RT5682_SAR_BUTDET_RST_MASK | RT5682_SAR_SEL_MB1_MB2_MASK, 0); + RT5682_SAR_SEL_MB1_MB2_MASK, 0); + usleep_range(5000, 6000); + snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, + RT5682_MB1_PATH_MASK | RT5682_MB2_PATH_MASK, + RT5682_CTRL_MB1_REG | RT5682_CTRL_MB2_REG); + usleep_range(10000, 12000); snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1, - RT5682_SAR_BUTT_DET_MASK | RT5682_SAR_BUTDET_MODE_MASK | RT5682_SAR_BUT= DET_RST_MASK, - RT5682_SAR_BUTT_DET_EN | RT5682_SAR_BUTDET_POW_SAV | RT5682_SAR_BUTDET_= RST_NORMAL); + RT5682_SAR_BUTT_DET_MASK | RT5682_SAR_BUTDET_MODE_MASK, + RT5682_SAR_BUTT_DET_EN | RT5682_SAR_BUTDET_POW_SAV); } =20 regcache_cache_only(rt5682->regmap, true); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 DE97BC43334 for ; Mon, 11 Jul 2022 09:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233417AbiGKJny (ORCPT ); Mon, 11 Jul 2022 05:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbiGKJnL (ORCPT ); Mon, 11 Jul 2022 05:43:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD6FE564DA; Mon, 11 Jul 2022 02:21: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 21080612F3; Mon, 11 Jul 2022 09:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A55AC341C0; Mon, 11 Jul 2022 09:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531294; bh=rbnbSKlh3AoMb2BtRVeYiLLfeO9YqkXAZXJhdq/+F7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DN7skezbO4gJff3jCjbswR69nmDknt/vkuiPn2LIxLbyR0wKorKhollStzKo043d1 FK8k1HK8aNSVuXJtoixdKSauTcyPzKcjGPzvungIWDgsunRL6/L+vfTCm1V8Wzu3D9 edU69JsxI/LDcVz0WaHqQgyfYnz7G/mgB8PVLNDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Derek Fang , Mark Brown , Sasha Levin Subject: [PATCH 5.15 054/230] ASoC: rt5682: Re-detect the combo jack after resuming Date: Mon, 11 Jul 2022 11:05:10 +0200 Message-Id: <20220711090605.612820760@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Derek Fang [ Upstream commit 2cd9b0ef82d936623d789bb3fbb6fcf52c500367 ] Sometimes, end-users change the jack type under suspending, so it needs to re-detect the combo jack type after resuming to avoid any unexpected behaviors. Signed-off-by: Derek Fang Link: https://lore.kernel.org/r/20211109095450.12950-2-derek.fang@realtek.c= om Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt5682-i2c.c | 1 + sound/soc/codecs/rt5682.c | 23 ++++++++++++++++++++--- sound/soc/codecs/rt5682.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index b9d5d7a0975b..b17c14b8b36e 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -196,6 +196,7 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, } =20 mutex_init(&rt5682->calibrate_mutex); + mutex_init(&rt5682->jdet_mutex); rt5682_calibrate(rt5682); =20 rt5682_apply_patch_list(rt5682, &i2c->dev); diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 949b5638db29..d470b9189768 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -49,6 +49,7 @@ static const struct reg_sequence patch_list[] =3D { {RT5682_CHARGE_PUMP_1, 0x0210}, {RT5682_HP_LOGIC_CTRL_2, 0x0007}, {RT5682_SAR_IL_CMD_2, 0xac00}, + {RT5682_CBJ_CTRL_7, 0x0104}, }; =20 void rt5682_apply_patch_list(struct rt5682_priv *rt5682, struct device *de= v) @@ -943,6 +944,10 @@ int rt5682_headset_detect(struct snd_soc_component *co= mponent, int jack_insert) snd_soc_component_update_bits(component, RT5682_HP_CHARGE_PUMP_1, RT5682_OSW_L_MASK | RT5682_OSW_R_MASK, 0); + rt5682_enable_push_button_irq(component, false); + snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, + RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW); + usleep_range(55000, 60000); snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH); =20 @@ -1099,6 +1104,7 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) return; } =20 + mutex_lock(&rt5682->jdet_mutex); mutex_lock(&rt5682->calibrate_mutex); =20 val =3D snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) @@ -1172,6 +1178,7 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) } =20 mutex_unlock(&rt5682->calibrate_mutex); + mutex_unlock(&rt5682->jdet_mutex); } EXPORT_SYMBOL_GPL(rt5682_jack_detect_handler); =20 @@ -1521,6 +1528,7 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget= *w, { struct snd_soc_component *component =3D snd_soc_dapm_to_component(w->dapm); + struct rt5682_priv *rt5682 =3D snd_soc_component_get_drvdata(component); =20 switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1532,12 +1540,17 @@ static int rt5682_hp_event(struct snd_soc_dapm_widg= et *w, RT5682_DEPOP_1, 0x60, 0x60); snd_soc_component_update_bits(component, RT5682_DAC_ADC_DIG_VOL1, 0x00c0, 0x0080); + + mutex_lock(&rt5682->jdet_mutex); + snd_soc_component_update_bits(component, RT5682_HP_CTRL_2, RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN, RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN); usleep_range(5000, 10000); snd_soc_component_update_bits(component, RT5682_CHARGE_PUMP_1, RT5682_CP_SW_SIZE_MASK, RT5682_CP_SW_SIZE_L); + + mutex_unlock(&rt5682->jdet_mutex); break; =20 case SND_SOC_DAPM_POST_PMD: @@ -2969,7 +2982,7 @@ static int rt5682_suspend(struct snd_soc_component *c= omponent) =20 cancel_delayed_work_sync(&rt5682->jack_detect_work); cancel_delayed_work_sync(&rt5682->jd_check_work); - if (rt5682->hs_jack && rt5682->jack_type =3D=3D SND_JACK_HEADSET) { + if (rt5682->hs_jack && (rt5682->jack_type & SND_JACK_HEADSET) =3D=3D SND_= JACK_HEADSET) { val =3D snd_soc_component_read(component, RT5682_CBJ_CTRL_2) & RT5682_JACK_TYPE_MASK; =20 @@ -3000,6 +3013,8 @@ static int rt5682_suspend(struct snd_soc_component *c= omponent) snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1, RT5682_SAR_BUTT_DET_MASK | RT5682_SAR_BUTDET_MODE_MASK, RT5682_SAR_BUTT_DET_EN | RT5682_SAR_BUTDET_POW_SAV); + snd_soc_component_update_bits(component, RT5682_HP_CHARGE_PUMP_1, + RT5682_OSW_L_MASK | RT5682_OSW_R_MASK, 0); } =20 regcache_cache_only(rt5682->regmap, true); @@ -3017,10 +3032,11 @@ static int rt5682_resume(struct snd_soc_component *= component) regcache_cache_only(rt5682->regmap, false); regcache_sync(rt5682->regmap); =20 - if (rt5682->hs_jack && rt5682->jack_type =3D=3D SND_JACK_HEADSET) { + if (rt5682->hs_jack && (rt5682->jack_type & SND_JACK_HEADSET) =3D=3D SND_= JACK_HEADSET) { snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1, RT5682_SAR_BUTDET_MODE_MASK | RT5682_SAR_SEL_MB1_MB2_MASK, RT5682_SAR_BUTDET_POW_NORM | RT5682_SAR_SEL_MB1_MB2_AUTO); + usleep_range(5000, 6000); snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, RT5682_MB1_PATH_MASK | RT5682_MB2_PATH_MASK, RT5682_CTRL_MB1_FSM | RT5682_CTRL_MB2_FSM); @@ -3028,8 +3044,9 @@ static int rt5682_resume(struct snd_soc_component *co= mponent) RT5682_PWR_CBJ, RT5682_PWR_CBJ); } =20 + rt5682->jack_type =3D 0; mod_delayed_work(system_power_efficient_wq, - &rt5682->jack_detect_work, msecs_to_jiffies(250)); + &rt5682->jack_detect_work, msecs_to_jiffies(0)); =20 return 0; } diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index 8e3244a62c16..f866d207d1bd 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1462,6 +1462,7 @@ struct rt5682_priv { =20 int jack_type; int irq_work_delay_time; + struct mutex jdet_mutex; }; =20 extern const char *rt5682_supply_names[RT5682_NUM_SUPPLIES]; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 3F8E2C433EF for ; Mon, 11 Jul 2022 09:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233421AbiGKJn7 (ORCPT ); Mon, 11 Jul 2022 05:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233352AbiGKJnV (ORCPT ); Mon, 11 Jul 2022 05:43:21 -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 DE854A0257; Mon, 11 Jul 2022 02:21:40 -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 02016612FA; Mon, 11 Jul 2022 09:21:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5F9BC341C8; Mon, 11 Jul 2022 09:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531297; bh=C11K35FyNvRX8cVJODSQIBAJ4Z/jrcH4PJmtKu348ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvsRYitccQkuXqUNrb/ixwg+ngg4IPHovRE17PkiLrJlETpEVVVN0nLy80n2Hg/e/ 7awKs7/MEmySODwtJVY7gl/VdtW/3lVHIIxzrpiq1OwvZgKa9G+KJcDk/gPyC6WSTl q9m0EnhbKEnfbxgKI7/YaQsxPEw7bxdHxmaJ2NPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Mark Brown , Sasha Levin Subject: [PATCH 5.15 055/230] ASoC: rt5682: Fix deadlock on resume Date: Mon, 11 Jul 2022 11:05:11 +0200 Message-Id: <20220711090605.641585241@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Peter Ujfalusi [ Upstream commit 4045daf0fa87846a27f56329fddad2deeb5ca354 ] On resume from suspend the following chain of events can happen: A rt5682_resume() -> mod_delayed_work() for jack_detect_work B DAPM sequence starts ( DAPM is locked now) A1. rt5682_jack_detect_handler() scheduled - Takes both jdet_mutex and calibrate_mutex - Calls in to rt5682_headset_detect() which tries to take DAPM lock, it starts to wait for it as B path took it already. B1. DAPM sequence reaches the "HP Amp", rt5682_hp_event() tries to take the jdet_mutex, but it is locked in A1, so it waits. Deadlock. To solve the deadlock, drop the jdet_mutex, use the jack_detect_work to do the jack removal handling, move the dapm lock up one level to protect the most of the rt5682_jack_detect_handler(), but not the jack reporting as it might trigger a DAPM sequence. The rt5682_headset_detect() can be changed to static as well. Fixes: 8deb34a90f063 ("ASoC: rt5682: fix the wrong jack type detected") Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20220126100325.16513-1-peter.ujfalusi@linux= .intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt5682-i2c.c | 15 ++++----------- sound/soc/codecs/rt5682.c | 24 ++++++++---------------- sound/soc/codecs/rt5682.h | 2 -- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index b17c14b8b36e..74a1fee071dd 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -59,18 +59,12 @@ static void rt5682_jd_check_handler(struct work_struct = *work) struct rt5682_priv *rt5682 =3D container_of(work, struct rt5682_priv, jd_check_work.work); =20 - if (snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) - & RT5682_JDH_RS_MASK) { + if (snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) & RT5682_= JDH_RS_MASK) /* jack out */ - rt5682->jack_type =3D rt5682_headset_detect(rt5682->component, 0); - - snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type, - SND_JACK_HEADSET | - SND_JACK_BTN_0 | SND_JACK_BTN_1 | - SND_JACK_BTN_2 | SND_JACK_BTN_3); - } else { + mod_delayed_work(system_power_efficient_wq, + &rt5682->jack_detect_work, 0); + else schedule_delayed_work(&rt5682->jd_check_work, 500); - } } =20 static irqreturn_t rt5682_irq(int irq, void *data) @@ -196,7 +190,6 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, } =20 mutex_init(&rt5682->calibrate_mutex); - mutex_init(&rt5682->jdet_mutex); rt5682_calibrate(rt5682); =20 rt5682_apply_patch_list(rt5682, &i2c->dev); diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index d470b9189768..1cd59e166cce 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -922,15 +922,13 @@ static void rt5682_enable_push_button_irq(struct snd_= soc_component *component, * * Returns detect status. */ -int rt5682_headset_detect(struct snd_soc_component *component, int jack_in= sert) +static int rt5682_headset_detect(struct snd_soc_component *component, int = jack_insert) { struct rt5682_priv *rt5682 =3D snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm =3D &component->dapm; unsigned int val, count; =20 if (jack_insert) { - snd_soc_dapm_mutex_lock(dapm); - snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1, RT5682_PWR_VREF2 | RT5682_PWR_MB, RT5682_PWR_VREF2 | RT5682_PWR_MB); @@ -981,8 +979,6 @@ int rt5682_headset_detect(struct snd_soc_component *com= ponent, int jack_insert) snd_soc_component_update_bits(component, RT5682_MICBIAS_2, RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK, RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU); - - snd_soc_dapm_mutex_unlock(dapm); } else { rt5682_enable_push_button_irq(component, false); snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, @@ -1011,7 +1007,6 @@ int rt5682_headset_detect(struct snd_soc_component *c= omponent, int jack_insert) dev_dbg(component->dev, "jack_type =3D %d\n", rt5682->jack_type); return rt5682->jack_type; } -EXPORT_SYMBOL_GPL(rt5682_headset_detect); =20 static int rt5682_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack, void *data) @@ -1094,6 +1089,7 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) { struct rt5682_priv *rt5682 =3D container_of(work, struct rt5682_priv, jack_detect_work.work); + struct snd_soc_dapm_context *dapm; int val, btn_type; =20 if (!rt5682->component || !rt5682->component->card || @@ -1104,7 +1100,9 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) return; } =20 - mutex_lock(&rt5682->jdet_mutex); + dapm =3D snd_soc_component_get_dapm(rt5682->component); + + snd_soc_dapm_mutex_lock(dapm); mutex_lock(&rt5682->calibrate_mutex); =20 val =3D snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) @@ -1164,6 +1162,9 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) rt5682->irq_work_delay_time =3D 50; } =20 + mutex_unlock(&rt5682->calibrate_mutex); + snd_soc_dapm_mutex_unlock(dapm); + snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type, SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | @@ -1176,9 +1177,6 @@ void rt5682_jack_detect_handler(struct work_struct *w= ork) else cancel_delayed_work_sync(&rt5682->jd_check_work); } - - mutex_unlock(&rt5682->calibrate_mutex); - mutex_unlock(&rt5682->jdet_mutex); } EXPORT_SYMBOL_GPL(rt5682_jack_detect_handler); =20 @@ -1528,7 +1526,6 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget= *w, { struct snd_soc_component *component =3D snd_soc_dapm_to_component(w->dapm); - struct rt5682_priv *rt5682 =3D snd_soc_component_get_drvdata(component); =20 switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1540,17 +1537,12 @@ static int rt5682_hp_event(struct snd_soc_dapm_widg= et *w, RT5682_DEPOP_1, 0x60, 0x60); snd_soc_component_update_bits(component, RT5682_DAC_ADC_DIG_VOL1, 0x00c0, 0x0080); - - mutex_lock(&rt5682->jdet_mutex); - snd_soc_component_update_bits(component, RT5682_HP_CTRL_2, RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN, RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN); usleep_range(5000, 10000); snd_soc_component_update_bits(component, RT5682_CHARGE_PUMP_1, RT5682_CP_SW_SIZE_MASK, RT5682_CP_SW_SIZE_L); - - mutex_unlock(&rt5682->jdet_mutex); break; =20 case SND_SOC_DAPM_POST_PMD: diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index f866d207d1bd..539a9fe26294 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1462,7 +1462,6 @@ struct rt5682_priv { =20 int jack_type; int irq_work_delay_time; - struct mutex jdet_mutex; }; =20 extern const char *rt5682_supply_names[RT5682_NUM_SUPPLIES]; @@ -1472,7 +1471,6 @@ int rt5682_sel_asrc_clk_src(struct snd_soc_component = *component, =20 void rt5682_apply_patch_list(struct rt5682_priv *rt5682, struct device *de= v); =20 -int rt5682_headset_detect(struct snd_soc_component *component, int jack_in= sert); void rt5682_jack_detect_handler(struct work_struct *work); =20 bool rt5682_volatile_register(struct device *dev, unsigned int reg); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 0E028CCA486 for ; Mon, 11 Jul 2022 09:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbiGKJpP (ORCPT ); Mon, 11 Jul 2022 05:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233094AbiGKJnf (ORCPT ); Mon, 11 Jul 2022 05:43:35 -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 EE691A0273; Mon, 11 Jul 2022 02:21: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 5199AB80E76; Mon, 11 Jul 2022 09:21:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1F0AC341C0; Mon, 11 Jul 2022 09:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531300; bh=nopZrpn6fBT1DooGZhyQykFhCFEYOp3Mr0+AMNS+aJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zprQ8bsrkug6oVcivmu1vpqTn19ZqdHZ6asdZObNwr10bQvNM/jZoFJJ/aqAQ/kkE kvCYJ8/uW873GO6+rzWvF+5lRcFS+xreAdWLyjzsKzbCawUOfIfNmlIxBSOwTrNuzB DX2KYcUjF6J+knQYS0TrE0SPRmXlWrkwgCPFwqa8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 056/230] netfilter: nf_tables: convert pktinfo->tprot_set to flags field Date: Mon, 11 Jul 2022 11:05:12 +0200 Message-Id: <20220711090605.669242621@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pablo Neira Ayuso [ Upstream commit b5bdc6f9c24db9a0adf8bd00c0e935b184654f00 ] Generalize boolean field to store more flags on the pktinfo structure. Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/net/netfilter/nf_tables.h | 8 ++++++-- include/net/netfilter/nf_tables_ipv4.h | 7 ++++--- include/net/netfilter/nf_tables_ipv6.h | 6 +++--- net/netfilter/nf_tables_core.c | 2 +- net/netfilter/nf_tables_trace.c | 4 ++-- net/netfilter/nft_meta.c | 2 +- net/netfilter/nft_payload.c | 4 ++-- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_t= ables.h index 2af1c2c64128..d005f87691da 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -21,10 +21,14 @@ struct module; =20 #define NFT_JUMP_STACK_SIZE 16 =20 +enum { + NFT_PKTINFO_L4PROTO =3D (1 << 0), +}; + struct nft_pktinfo { struct sk_buff *skb; const struct nf_hook_state *state; - bool tprot_set; + u8 flags; u8 tprot; u16 fragoff; unsigned int thoff; @@ -75,7 +79,7 @@ static inline void nft_set_pktinfo(struct nft_pktinfo *pk= t, =20 static inline void nft_set_pktinfo_unspec(struct nft_pktinfo *pkt) { - pkt->tprot_set =3D false; + pkt->flags =3D 0; pkt->tprot =3D 0; pkt->thoff =3D 0; pkt->fragoff =3D 0; diff --git a/include/net/netfilter/nf_tables_ipv4.h b/include/net/netfilter= /nf_tables_ipv4.h index eb4c094cd54d..c4a6147b0ef8 100644 --- a/include/net/netfilter/nf_tables_ipv4.h +++ b/include/net/netfilter/nf_tables_ipv4.h @@ -10,7 +10,7 @@ static inline void nft_set_pktinfo_ipv4(struct nft_pktinf= o *pkt) struct iphdr *ip; =20 ip =3D ip_hdr(pkt->skb); - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D ip->protocol; pkt->thoff =3D ip_hdrlen(pkt->skb); pkt->fragoff =3D ntohs(ip->frag_off) & IP_OFFSET; @@ -36,7 +36,7 @@ static inline int __nft_set_pktinfo_ipv4_validate(struct = nft_pktinfo *pkt) else if (len < thoff) return -1; =20 - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D iph->protocol; pkt->thoff =3D thoff; pkt->fragoff =3D ntohs(iph->frag_off) & IP_OFFSET; @@ -71,7 +71,7 @@ static inline int nft_set_pktinfo_ipv4_ingress(struct nft= _pktinfo *pkt) goto inhdr_error; } =20 - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D iph->protocol; pkt->thoff =3D thoff; pkt->fragoff =3D ntohs(iph->frag_off) & IP_OFFSET; @@ -82,4 +82,5 @@ static inline int nft_set_pktinfo_ipv4_ingress(struct nft= _pktinfo *pkt) __IP_INC_STATS(nft_net(pkt), IPSTATS_MIB_INHDRERRORS); return -1; } + #endif diff --git a/include/net/netfilter/nf_tables_ipv6.h b/include/net/netfilter= /nf_tables_ipv6.h index 7595e02b00ba..ec7eaeaf4f04 100644 --- a/include/net/netfilter/nf_tables_ipv6.h +++ b/include/net/netfilter/nf_tables_ipv6.h @@ -18,7 +18,7 @@ static inline void nft_set_pktinfo_ipv6(struct nft_pktinf= o *pkt) return; } =20 - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D protohdr; pkt->thoff =3D thoff; pkt->fragoff =3D frag_off; @@ -50,7 +50,7 @@ static inline int __nft_set_pktinfo_ipv6_validate(struct = nft_pktinfo *pkt) if (protohdr < 0) return -1; =20 - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D protohdr; pkt->thoff =3D thoff; pkt->fragoff =3D frag_off; @@ -96,7 +96,7 @@ static inline int nft_set_pktinfo_ipv6_ingress(struct nft= _pktinfo *pkt) if (protohdr < 0) goto inhdr_error; =20 - pkt->tprot_set =3D true; + pkt->flags =3D NFT_PKTINFO_L4PROTO; pkt->tprot =3D protohdr; pkt->thoff =3D thoff; pkt->fragoff =3D frag_off; diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c index 907e848dbc17..d4d8f613af51 100644 --- a/net/netfilter/nf_tables_core.c +++ b/net/netfilter/nf_tables_core.c @@ -79,7 +79,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *= expr, if (priv->base =3D=3D NFT_PAYLOAD_NETWORK_HEADER) ptr =3D skb_network_header(skb); else { - if (!pkt->tprot_set) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) return false; ptr =3D skb_network_header(skb) + nft_thoff(pkt); } diff --git a/net/netfilter/nf_tables_trace.c b/net/netfilter/nf_tables_trac= e.c index e4fe2f0780eb..84a7dea46efa 100644 --- a/net/netfilter/nf_tables_trace.c +++ b/net/netfilter/nf_tables_trace.c @@ -113,13 +113,13 @@ static int nf_trace_fill_pkt_info(struct sk_buff *nls= kb, int off =3D skb_network_offset(skb); unsigned int len, nh_end; =20 - nh_end =3D pkt->tprot_set ? nft_thoff(pkt) : skb->len; + nh_end =3D pkt->flags & NFT_PKTINFO_L4PROTO ? nft_thoff(pkt) : skb->len; len =3D min_t(unsigned int, nh_end - skb_network_offset(skb), NFT_TRACETYPE_NETWORK_HSIZE); if (trace_fill_header(nlskb, NFTA_TRACE_NETWORK_HEADER, skb, off, len)) return -1; =20 - if (pkt->tprot_set) { + if (pkt->flags & NFT_PKTINFO_L4PROTO) { len =3D min_t(unsigned int, skb->len - nft_thoff(pkt), NFT_TRACETYPE_TRANSPORT_HSIZE); if (trace_fill_header(nlskb, NFTA_TRACE_TRANSPORT_HEADER, skb, diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c index 44d9b38e5f90..14412f69a34e 100644 --- a/net/netfilter/nft_meta.c +++ b/net/netfilter/nft_meta.c @@ -321,7 +321,7 @@ void nft_meta_get_eval(const struct nft_expr *expr, nft_reg_store8(dest, nft_pf(pkt)); break; case NFT_META_L4PROTO: - if (!pkt->tprot_set) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) goto err; nft_reg_store8(dest, pkt->tprot); break; diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 132875cd7fff..c3ccfff54a35 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -108,7 +108,7 @@ void nft_payload_eval(const struct nft_expr *expr, offset =3D skb_network_offset(skb); break; case NFT_PAYLOAD_TRANSPORT_HEADER: - if (!pkt->tprot_set) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) goto err; offset =3D nft_thoff(pkt); break; @@ -613,7 +613,7 @@ static void nft_payload_set_eval(const struct nft_expr = *expr, offset =3D skb_network_offset(skb); break; case NFT_PAYLOAD_TRANSPORT_HEADER: - if (!pkt->tprot_set) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) goto err; offset =3D nft_thoff(pkt); break; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B34A3CCA47B for ; Mon, 11 Jul 2022 09:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233279AbiGKJpQ (ORCPT ); Mon, 11 Jul 2022 05:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbiGKJnq (ORCPT ); Mon, 11 Jul 2022 05:43: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 DEE482B607; Mon, 11 Jul 2022 02:21: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 F1B12B80E84; Mon, 11 Jul 2022 09:21:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AD8BC34115; Mon, 11 Jul 2022 09:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531302; bh=G57iwikh67ZN2F5OTV1+Pbp4DNDewuULz6lsg3DI4ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wyfvyELlsOyrVljmZz4jIkuQNWoPxz1cgzkO6wGgO34c9ZVtE4g4e3Pz7mIF/U7Z/ 2mTQfO2m+XpcTY31/lKQrJFFQ1jy2itnTXC3J0wOb17DaQ34Sjk2QwQ3Vy74VGvBI8 psuQHUGzA2yXL6R23HTOJRBnNlVsekeLGFsJ9O+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 057/230] netfilter: nft_payload: support for inner header matching / mangling Date: Mon, 11 Jul 2022 11:05:13 +0200 Message-Id: <20220711090605.696713102@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pablo Neira Ayuso [ Upstream commit c46b38dc8743535e686b911d253a844f0bd50ead ] Allow to match and mangle on inner headers / payload data after the transport header. There is a new field in the pktinfo structure that stores the inner header offset which is calculated only when requested. Only TCP and UDP supported at this stage. Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/net/netfilter/nf_tables.h | 2 + include/uapi/linux/netfilter/nf_tables.h | 2 + net/netfilter/nft_payload.c | 56 +++++++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_t= ables.h index d005f87691da..bcfee89012a1 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -23,6 +23,7 @@ struct module; =20 enum { NFT_PKTINFO_L4PROTO =3D (1 << 0), + NFT_PKTINFO_INNER =3D (1 << 1), }; =20 struct nft_pktinfo { @@ -32,6 +33,7 @@ struct nft_pktinfo { u8 tprot; u16 fragoff; unsigned int thoff; + unsigned int inneroff; }; =20 static inline struct sock *nft_sk(const struct nft_pktinfo *pkt) diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/= netfilter/nf_tables.h index e94d1fa554cb..07871c8a0601 100644 --- a/include/uapi/linux/netfilter/nf_tables.h +++ b/include/uapi/linux/netfilter/nf_tables.h @@ -753,11 +753,13 @@ enum nft_dynset_attributes { * @NFT_PAYLOAD_LL_HEADER: link layer header * @NFT_PAYLOAD_NETWORK_HEADER: network header * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header + * @NFT_PAYLOAD_INNER_HEADER: inner header / payload */ enum nft_payload_bases { NFT_PAYLOAD_LL_HEADER, NFT_PAYLOAD_NETWORK_HEADER, NFT_PAYLOAD_TRANSPORT_HEADER, + NFT_PAYLOAD_INNER_HEADER, }; =20 /** diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index c3ccfff54a35..ee359a4a60f5 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -22,6 +22,7 @@ #include #include #include +#include #include =20 static bool nft_payload_rebuild_vlan_hdr(const struct sk_buff *skb, int ma= c_off, @@ -79,6 +80,45 @@ nft_payload_copy_vlan(u32 *d, const struct sk_buff *skb,= u8 offset, u8 len) return skb_copy_bits(skb, offset + mac_off, dst_u8, len) =3D=3D 0; } =20 +static int __nft_payload_inner_offset(struct nft_pktinfo *pkt) +{ + unsigned int thoff =3D nft_thoff(pkt); + + if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) + return -1; + + switch (pkt->tprot) { + case IPPROTO_UDP: + pkt->inneroff =3D thoff + sizeof(struct udphdr); + break; + case IPPROTO_TCP: { + struct tcphdr *th, _tcph; + + th =3D skb_header_pointer(pkt->skb, thoff, sizeof(_tcph), &_tcph); + if (!th) + return -1; + + pkt->inneroff =3D thoff + __tcp_hdrlen(th); + } + break; + default: + return -1; + } + + pkt->flags |=3D NFT_PKTINFO_INNER; + + return 0; +} + +static int nft_payload_inner_offset(const struct nft_pktinfo *pkt) +{ + if (!(pkt->flags & NFT_PKTINFO_INNER) && + __nft_payload_inner_offset((struct nft_pktinfo *)pkt) < 0) + return -1; + + return pkt->inneroff; +} + void nft_payload_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt) @@ -112,6 +152,11 @@ void nft_payload_eval(const struct nft_expr *expr, goto err; offset =3D nft_thoff(pkt); break; + case NFT_PAYLOAD_INNER_HEADER: + offset =3D nft_payload_inner_offset(pkt); + if (offset < 0) + goto err; + break; default: BUG(); } @@ -617,6 +662,11 @@ static void nft_payload_set_eval(const struct nft_expr= *expr, goto err; offset =3D nft_thoff(pkt); break; + case NFT_PAYLOAD_INNER_HEADER: + offset =3D nft_payload_inner_offset(pkt); + if (offset < 0) + goto err; + break; default: BUG(); } @@ -625,7 +675,8 @@ static void nft_payload_set_eval(const struct nft_expr = *expr, offset +=3D priv->offset; =20 if ((priv->csum_type =3D=3D NFT_PAYLOAD_CSUM_INET || priv->csum_flags) && - (priv->base !=3D NFT_PAYLOAD_TRANSPORT_HEADER || + ((priv->base !=3D NFT_PAYLOAD_TRANSPORT_HEADER && + priv->base !=3D NFT_PAYLOAD_INNER_HEADER) || skb->ip_summed !=3D CHECKSUM_PARTIAL)) { fsum =3D skb_checksum(skb, offset, priv->len, 0); tsum =3D csum_partial(src, priv->len, 0); @@ -744,6 +795,7 @@ nft_payload_select_ops(const struct nft_ctx *ctx, case NFT_PAYLOAD_LL_HEADER: case NFT_PAYLOAD_NETWORK_HEADER: case NFT_PAYLOAD_TRANSPORT_HEADER: + case NFT_PAYLOAD_INNER_HEADER: break; default: return ERR_PTR(-EOPNOTSUPP); @@ -762,7 +814,7 @@ nft_payload_select_ops(const struct nft_ctx *ctx, len =3D ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN])); =20 if (len <=3D 4 && is_power_of_2(len) && IS_ALIGNED(offset, len) && - base !=3D NFT_PAYLOAD_LL_HEADER) + base !=3D NFT_PAYLOAD_LL_HEADER && base !=3D NFT_PAYLOAD_INNER_HEADER) return &nft_payload_fast_ops; else return &nft_payload_ops; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 A0866CCA47B for ; Mon, 11 Jul 2022 09:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233338AbiGKJpX (ORCPT ); Mon, 11 Jul 2022 05:45:23 -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 S233413AbiGKJnx (ORCPT ); Mon, 11 Jul 2022 05:43:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 019FAA23BE; Mon, 11 Jul 2022 02:21: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 B4D00B80E7A; Mon, 11 Jul 2022 09:21:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C822C34115; Mon, 11 Jul 2022 09:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531305; bh=6OGDwIFv/5XaLp9/EoSSAjeNh5wIQiQh6P3Zams+wAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wIBu4DpOJSiDWI998am5HYpqYjlA4XDk0VMU4KjjDupcI8D4x4CFc+5ZDsKWQTnN5 AhnH7TI5JdTOWPYKU/ZChxMyxjXtrJJOYigFKCSb2gOW3oIPK+ko27PG2fpQXpc+sr xzMdV/965qT7HWJjCt2bMwUH+EBan4i1tFXnBxy0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 058/230] netfilter: nft_payload: dont allow th access for fragments Date: Mon, 11 Jul 2022 11:05:14 +0200 Message-Id: <20220711090605.724516881@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit a9e8503def0fd4ed89ade1f61c315f904581d439 ] Loads relative to ->thoff naturally expect that this points to the transport header, but this is only true if pkt->fragoff =3D=3D 0. This has little effect for rulesets with connection tracking/nat because these enable ip defra. For other rulesets this prevents false matches. Fixes: 96518518cc41 ("netfilter: add nftables") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/netfilter/nft_exthdr.c | 2 +- net/netfilter/nft_payload.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c index dbe1f2e7dd9e..9e927ab4df15 100644 --- a/net/netfilter/nft_exthdr.c +++ b/net/netfilter/nft_exthdr.c @@ -167,7 +167,7 @@ nft_tcp_header_pointer(const struct nft_pktinfo *pkt, { struct tcphdr *tcph; =20 - if (pkt->tprot !=3D IPPROTO_TCP) + if (pkt->tprot !=3D IPPROTO_TCP || pkt->fragoff) return NULL; =20 tcph =3D skb_header_pointer(pkt->skb, nft_thoff(pkt), sizeof(*tcph), buff= er); diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index ee359a4a60f5..b46e01365bd9 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -84,7 +84,7 @@ static int __nft_payload_inner_offset(struct nft_pktinfo = *pkt) { unsigned int thoff =3D nft_thoff(pkt); =20 - if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO) || pkt->fragoff) return -1; =20 switch (pkt->tprot) { @@ -148,7 +148,7 @@ void nft_payload_eval(const struct nft_expr *expr, offset =3D skb_network_offset(skb); break; case NFT_PAYLOAD_TRANSPORT_HEADER: - if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO) || pkt->fragoff) goto err; offset =3D nft_thoff(pkt); break; @@ -658,7 +658,7 @@ static void nft_payload_set_eval(const struct nft_expr = *expr, offset =3D skb_network_offset(skb); break; case NFT_PAYLOAD_TRANSPORT_HEADER: - if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) + if (!(pkt->flags & NFT_PKTINFO_L4PROTO) || pkt->fragoff) goto err; offset =3D nft_thoff(pkt); break; @@ -697,7 +697,8 @@ static void nft_payload_set_eval(const struct nft_expr = *expr, if (priv->csum_type =3D=3D NFT_PAYLOAD_CSUM_SCTP && pkt->tprot =3D=3D IPPROTO_SCTP && skb->ip_summed !=3D CHECKSUM_PARTIAL) { - if (nft_payload_csum_sctp(skb, nft_thoff(pkt))) + if (pkt->fragoff =3D=3D 0 && + nft_payload_csum_sctp(skb, nft_thoff(pkt))) goto err; } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 CE058C433EF for ; Mon, 11 Jul 2022 09:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbiGKJp1 (ORCPT ); Mon, 11 Jul 2022 05:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233374AbiGKJn4 (ORCPT ); Mon, 11 Jul 2022 05:43:56 -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 CC395564D0; Mon, 11 Jul 2022 02:21: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 B9DC9612E8; Mon, 11 Jul 2022 09:21:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9470C34115; Mon, 11 Jul 2022 09:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531308; bh=cbIngTbkadnuBXg1TrRSSn/ja57fLg6KwjtLYx6GfUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pci1YgtbKNxkJ/8mZJxzXtfWKWUzNV4w+xnP6k52C1fRH8+5uVt9bOr0WSK/ttvxn zNhv4mLHwNiFO+Z6pEtHbhoksY4h4j2XypmPv8wY5JuKRZNgRwljzhEXq/oUgHOt5C 0LGW+nb3yX9aN7mLF1LCm5Mj8Iuc8H9NrA5gFTlE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Alexander Gordeev , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.15 059/230] s390/boot: allocate amode31 section in decompressor Date: Mon, 11 Jul 2022 11:05:15 +0200 Message-Id: <20220711090605.752583647@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Gordeev [ Upstream commit e3ec8e0f5711d73f7e5d5c3cffdf4fad4f1487b9 ] The memory for amode31 section is allocated from the decompressed kernel. Instead, allocate that memory from the decompressor. This is a prerequisite to allow initialization of the virtual memory before the decompressed kernel takes over. Reviewed-by: Heiko Carstens Signed-off-by: Alexander Gordeev Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/s390/boot/compressed/decompressor.h | 1 + arch/s390/boot/startup.c | 8 ++++++++ arch/s390/kernel/entry.h | 1 + arch/s390/kernel/setup.c | 22 +++++++++------------- arch/s390/kernel/vmlinux.lds.S | 1 + 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/arch/s390/boot/compressed/decompressor.h b/arch/s390/boot/comp= ressed/decompressor.h index a59f75c5b049..f75cc31a77dd 100644 --- a/arch/s390/boot/compressed/decompressor.h +++ b/arch/s390/boot/compressed/decompressor.h @@ -24,6 +24,7 @@ struct vmlinux_info { unsigned long dynsym_start; unsigned long rela_dyn_start; unsigned long rela_dyn_end; + unsigned long amode31_size; }; =20 /* Symbols defined by linker scripts */ diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c index b13352dd1e1c..1aa11a8f57dd 100644 --- a/arch/s390/boot/startup.c +++ b/arch/s390/boot/startup.c @@ -15,6 +15,7 @@ #include "uv.h" =20 unsigned long __bootdata_preserved(__kaslr_offset); +unsigned long __bootdata(__amode31_base); unsigned long __bootdata_preserved(VMALLOC_START); unsigned long __bootdata_preserved(VMALLOC_END); struct page *__bootdata_preserved(vmemmap); @@ -233,6 +234,12 @@ static void offset_vmlinux_info(unsigned long offset) vmlinux.dynsym_start +=3D offset; } =20 +static unsigned long reserve_amode31(unsigned long safe_addr) +{ + __amode31_base =3D PAGE_ALIGN(safe_addr); + return safe_addr + vmlinux.amode31_size; +} + void startup_kernel(void) { unsigned long random_lma; @@ -247,6 +254,7 @@ void startup_kernel(void) setup_lpp(); store_ipl_parmblock(); safe_addr =3D mem_safe_offset(); + safe_addr =3D reserve_amode31(safe_addr); safe_addr =3D read_ipl_report(safe_addr); uv_query_info(); rescue_initrd(safe_addr); diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h index 7f2696e8d511..6083090be1f4 100644 --- a/arch/s390/kernel/entry.h +++ b/arch/s390/kernel/entry.h @@ -70,5 +70,6 @@ extern struct exception_table_entry _stop_amode31_ex_tabl= e[]; #define __amode31_data __section(".amode31.data") #define __amode31_ref __section(".amode31.refs") extern long _start_amode31_refs[], _end_amode31_refs[]; +extern unsigned long __amode31_base; =20 #endif /* _ENTRY_H */ diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 8ede12c4ba6b..e38de9e8ee13 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -95,10 +95,10 @@ EXPORT_SYMBOL(console_irq); * relocated above 2 GB, because it has to use 31 bit addresses. * Such code and data is part of the .amode31 section. */ -unsigned long __amode31_ref __samode31 =3D __pa(&_samode31); -unsigned long __amode31_ref __eamode31 =3D __pa(&_eamode31); -unsigned long __amode31_ref __stext_amode31 =3D __pa(&_stext_amode31); -unsigned long __amode31_ref __etext_amode31 =3D __pa(&_etext_amode31); +unsigned long __amode31_ref __samode31 =3D (unsigned long)&_samode31; +unsigned long __amode31_ref __eamode31 =3D (unsigned long)&_eamode31; +unsigned long __amode31_ref __stext_amode31 =3D (unsigned long)&_stext_amo= de31; +unsigned long __amode31_ref __etext_amode31 =3D (unsigned long)&_etext_amo= de31; struct exception_table_entry __amode31_ref *__start_amode31_ex_table =3D _= start_amode31_ex_table; struct exception_table_entry __amode31_ref *__stop_amode31_ex_table =3D _s= top_amode31_ex_table; =20 @@ -149,6 +149,7 @@ struct mem_detect_info __bootdata(mem_detect); struct initrd_data __bootdata(initrd_data); =20 unsigned long __bootdata_preserved(__kaslr_offset); +unsigned long __bootdata(__amode31_base); unsigned int __bootdata_preserved(zlib_dfltcc_support); EXPORT_SYMBOL(zlib_dfltcc_support); u64 __bootdata_preserved(stfle_fac_list[16]); @@ -800,6 +801,7 @@ static void __init reserve_kernel(void) =20 memblock_reserve(0, STARTUP_NORMAL_OFFSET); memblock_reserve((unsigned long)sclp_early_sccb, EXT_SCCB_READ_SCP); + memblock_reserve(__amode31_base, __eamode31 - __samode31); memblock_reserve((unsigned long)_stext, PFN_PHYS(start_pfn) - (unsigned long)_stext); } @@ -820,20 +822,14 @@ static void __init setup_memory(void) =20 static void __init relocate_amode31_section(void) { - unsigned long amode31_addr, amode31_size; - long amode31_offset; + unsigned long amode31_size =3D __eamode31 - __samode31; + long amode31_offset =3D __amode31_base - __samode31; long *ptr; =20 - /* Allocate a new AMODE31 capable memory region */ - amode31_size =3D __eamode31 - __samode31; pr_info("Relocating AMODE31 section of size 0x%08lx\n", amode31_size); - amode31_addr =3D (unsigned long)memblock_alloc_low(amode31_size, PAGE_SIZ= E); - if (!amode31_addr) - panic("Failed to allocate memory for AMODE31 section\n"); - amode31_offset =3D amode31_addr - __samode31; =20 /* Move original AMODE31 section to the new one */ - memmove((void *)amode31_addr, (void *)__samode31, amode31_size); + memmove((void *)__amode31_base, (void *)__samode31, amode31_size); /* Zero out the old AMODE31 section to catch invalid accesses within it */ memset((void *)__samode31, 0, amode31_size); =20 diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 63bdb9e1bfc1..42c43521878f 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -212,6 +212,7 @@ SECTIONS QUAD(__dynsym_start) /* dynsym_start */ QUAD(__rela_dyn_start) /* rela_dyn_start */ QUAD(__rela_dyn_end) /* rela_dyn_end */ + QUAD(_eamode31 - _samode31) /* amode31_size */ } :NONE =20 /* Debugging sections. */ --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 7D83AC43334 for ; Mon, 11 Jul 2022 09:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233400AbiGKJp3 (ORCPT ); Mon, 11 Jul 2022 05:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbiGKJoH (ORCPT ); Mon, 11 Jul 2022 05:44:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67FB357235; Mon, 11 Jul 2022 02:21: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 944F8612F3; Mon, 11 Jul 2022 09:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 788EFC34115; Mon, 11 Jul 2022 09:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531311; bh=csSJNhzYcJsSPAsuW+YFrLOiXri0TwGOGs5YubKA7kU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/WJ1ClGFocTusqlbql0II1u/yVkAX7eF1Xf+Aza+rWYroqRoJNcwG9PtYnDI4Y/U DjFjZjMlf0GO8djgaIc61Syv6wOE0g6B2Z4Ky6rf4/yLmXQzW1OUcQnOHMkrspvz/p +c5qWyJbXN9ArwvTpoLZdkiVotPbZsoWUPVqPjHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Alexander Gordeev , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.15 060/230] s390/setup: use physical pointers for memblock_reserve() Date: Mon, 11 Jul 2022 11:05:16 +0200 Message-Id: <20220711090605.780037799@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Gordeev [ Upstream commit 04f11ed7d8e018e1f01ebda5814ddfeb3a1e6ae1 ] memblock_reserve() function accepts physcal address of a memory block to be reserved, but provided with virtual memory pointers. Reviewed-by: Heiko Carstens Signed-off-by: Alexander Gordeev Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/s390/kernel/setup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index e38de9e8ee13..2ebde341d057 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -797,13 +797,10 @@ static void __init check_initrd(void) */ static void __init reserve_kernel(void) { - unsigned long start_pfn =3D PFN_UP(__pa(_end)); - memblock_reserve(0, STARTUP_NORMAL_OFFSET); - memblock_reserve((unsigned long)sclp_early_sccb, EXT_SCCB_READ_SCP); memblock_reserve(__amode31_base, __eamode31 - __samode31); - memblock_reserve((unsigned long)_stext, PFN_PHYS(start_pfn) - - (unsigned long)_stext); + memblock_reserve(__pa(sclp_early_sccb), EXT_SCCB_READ_SCP); + memblock_reserve(__pa(_stext), _end - _stext); } =20 static void __init setup_memory(void) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B9742C433EF for ; Mon, 11 Jul 2022 09:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233414AbiGKJpg (ORCPT ); Mon, 11 Jul 2022 05:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233467AbiGKJoM (ORCPT ); Mon, 11 Jul 2022 05:44:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68580A4CB5; Mon, 11 Jul 2022 02:21: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 E27BFB80E6D; Mon, 11 Jul 2022 09:21:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58ADBC34115; Mon, 11 Jul 2022 09:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531313; bh=aHY4s6ThFh4WFR8QECkXyGEc/WgAC0zJmGhEJyrM++M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xvIl3+JXjmSfhiOnAqwimouaA75M/Jh7bU59y4fwQchgsA0FRV6ocypOq1tCKAjEW gvD2c+PliGxfV/ZCbjQ9rgtpiAeIuNbx/REGSszZr+ur/STunPmO6qNMOb6+GZnw5J B3KDwKUAs6BgUBuOofFv1UymaM0/obZ48d1lWsmI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Egorenkov , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.15 061/230] s390/setup: preserve memory at OLDMEM_BASE and OLDMEM_SIZE Date: Mon, 11 Jul 2022 11:05:17 +0200 Message-Id: <20220711090605.807742798@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Egorenkov [ Upstream commit 6b4b54c7ca347bcb4aa7a3cc01aa16e84ac7fbe4 ] We need to preserve the values at OLDMEM_BASE and OLDMEM_SIZE which are used by zgetdump in case when kdump crashes. In that case zgetdump will attempt to read OLDMEM_BASE and OLDMEM_SIZE in order to find out where the memory range [0 - OLDMEM_SIZE] belonging to the production kernel is. Fixes: f1a546947431 ("s390/setup: don't reserve memory that occupied decomp= ressor's head") Cc: stable@vger.kernel.org # 5.15+ Signed-off-by: Alexander Egorenkov Acked-by: Vasily Gorbik Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/s390/kernel/setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 2ebde341d057..36c1f31dfd66 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -798,6 +798,8 @@ static void __init check_initrd(void) static void __init reserve_kernel(void) { memblock_reserve(0, STARTUP_NORMAL_OFFSET); + memblock_reserve(OLDMEM_BASE, sizeof(unsigned long)); + memblock_reserve(OLDMEM_SIZE, sizeof(unsigned long)); memblock_reserve(__amode31_base, __eamode31 - __samode31); memblock_reserve(__pa(sclp_early_sccb), EXT_SCCB_READ_SCP); memblock_reserve(__pa(_stext), _end - _stext); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 B41F7C43334 for ; Mon, 11 Jul 2022 09:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233507AbiGKJq1 (ORCPT ); Mon, 11 Jul 2022 05:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbiGKJoQ (ORCPT ); Mon, 11 Jul 2022 05:44:16 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C890AA7D65; Mon, 11 Jul 2022 02:21:59 -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 1320ACE1261; Mon, 11 Jul 2022 09:21:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06F31C34115; Mon, 11 Jul 2022 09:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531316; bh=Qp/4vTTjsjQl1T0Fo2W+iWdD6MYDxyl9nKH1aVGXKmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQFprLtRYm8Gpll4M4eBN6lvDxkZMiihbCAQf4tB4MHgr9KOB0o43aMHNcgNEVf/v TjjD609WyVJm2lffWZ+f6yXkHGfwixTZ5O39OqQhTU1pANJZPelG+fADCysZFuYGYZ 8Ya1SNF+joIBd3QNYc1LxaybI+YhLa7Qy75jN4YE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sukadev Bhattiprolu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 062/230] ibmvnic: init init_done_rc earlier Date: Mon, 11 Jul 2022 11:05:18 +0200 Message-Id: <20220711090605.836475160@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sukadev Bhattiprolu [ Upstream commit ae16bf15374d8b055e040ac6f3f1147ab1c9bb7d ] We currently initialize the ->init_done completion/return code fields before issuing a CRQ_INIT command. But if we get a transport event soon after registering the CRQ the taskslet may already have recorded the completion and error code. If we initialize here, we might overwrite/ lose that and end up issuing the CRQ_INIT only to timeout later. If that timeout happens during probe, we will leave the adapter in the DOWN state rather than retrying to register/init the CRQ. Initialize the completion before registering the CRQ so we don't lose the notification. Fixes: 032c5e82847a ("Driver for IBM System i/p VNIC protocol") Signed-off-by: Sukadev Bhattiprolu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/ibm/ibmvnic.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index b262aa84b6a2..70267bd73429 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -2063,6 +2063,19 @@ static const char *reset_reason_to_string(enum ibmvn= ic_reset_reason reason) return "UNKNOWN"; } =20 +/* + * Initialize the init_done completion and return code values. We + * can get a transport event just after registering the CRQ and the + * tasklet will use this to communicate the transport event. To ensure + * we don't miss the notification/error, initialize these _before_ + * regisering the CRQ. + */ +static inline void reinit_init_done(struct ibmvnic_adapter *adapter) +{ + reinit_completion(&adapter->init_done); + adapter->init_done_rc =3D 0; +} + /* * do_reset returns zero if we are able to keep processing reset events, or * non-zero if we hit a fatal error and must halt. @@ -2169,6 +2182,8 @@ static int do_reset(struct ibmvnic_adapter *adapter, */ adapter->state =3D VNIC_PROBED; =20 + reinit_init_done(adapter); + if (adapter->reset_reason =3D=3D VNIC_RESET_CHANGE_PARAM) { rc =3D init_crq_queue(adapter); } else if (adapter->reset_reason =3D=3D VNIC_RESET_MOBILITY) { @@ -2314,7 +2329,8 @@ static int do_hard_reset(struct ibmvnic_adapter *adap= ter, */ adapter->state =3D VNIC_PROBED; =20 - reinit_completion(&adapter->init_done); + reinit_init_done(adapter); + rc =3D init_crq_queue(adapter); if (rc) { netdev_err(adapter->netdev, @@ -5485,10 +5501,6 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter= *adapter, bool reset) =20 adapter->from_passive_init =3D false; =20 - if (reset) - reinit_completion(&adapter->init_done); - - adapter->init_done_rc =3D 0; rc =3D ibmvnic_send_crq_init(adapter); if (rc) { dev_err(dev, "Send crq init failed with error %d\n", rc); @@ -5502,12 +5514,14 @@ static int ibmvnic_reset_init(struct ibmvnic_adapte= r *adapter, bool reset) =20 if (adapter->init_done_rc) { release_crq_queue(adapter); + dev_err(dev, "CRQ-init failed, %d\n", adapter->init_done_rc); return adapter->init_done_rc; } =20 if (adapter->from_passive_init) { adapter->state =3D VNIC_OPEN; adapter->from_passive_init =3D false; + dev_err(dev, "CRQ-init failed, passive-init\n"); return -1; } =20 @@ -5596,6 +5610,8 @@ static int ibmvnic_probe(struct vio_dev *dev, const s= truct vio_device_id *id) =20 init_success =3D false; do { + reinit_init_done(adapter); + rc =3D init_crq_queue(adapter); if (rc) { dev_err(&dev->dev, "Couldn't initialize crq. rc=3D%d\n", --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 39EAAC43334 for ; Mon, 11 Jul 2022 09:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233472AbiGKJpy (ORCPT ); Mon, 11 Jul 2022 05:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233499AbiGKJoP (ORCPT ); Mon, 11 Jul 2022 05:44: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 4372EA2E6E; Mon, 11 Jul 2022 02:22:00 -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 A92BD612E8; Mon, 11 Jul 2022 09:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4CC0C34115; Mon, 11 Jul 2022 09:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531319; bh=nQtP9y8c4IgLOcZn+HDIIgDf2vPne8ZLgK4tRrshfMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uj5fX9Jw+LPDYv5xsbPsSX3KYJJsl5DhQoDl36pObENxhAVmahAl1i2QkguQ0Bhhd +c3ki2VFkSugbaDdIVn8eEEHOkmuQvwHcCzyCMXBcBXCVTJPaHe6OUB7CWppCV494P ywiVF7h49+t7VV64t5R4x7rgYWZeiY/2XzOHcC0M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sukadev Bhattiprolu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 063/230] ibmvnic: clear fop when retrying probe Date: Mon, 11 Jul 2022 11:05:19 +0200 Message-Id: <20220711090605.864445518@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sukadev Bhattiprolu [ Upstream commit f628ad531b4f34fdba0984255b4a2850dd369513 ] Clear ->failover_pending flag that may have been set in the previous pass of registering CRQ. If we don't clear, a subsequent ibmvnic_open() call would be misled into thinking a failover is pending and assuming that the reset worker thread would open the adapter. If this pass of registering the CRQ succeeds (i.e there is no transport event), there wouldn't be a reset worker thread. This would leave the adapter unconfigured and require manual intervention to bring it up during boot. Fixes: 5a18e1e0c193 ("ibmvnic: Fix failover case for non-redundant configur= ation") Signed-off-by: Sukadev Bhattiprolu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/ibm/ibmvnic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index 70267bd73429..9f4f40564d74 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5612,6 +5612,11 @@ static int ibmvnic_probe(struct vio_dev *dev, const = struct vio_device_id *id) do { reinit_init_done(adapter); =20 + /* clear any failovers we got in the previous pass + * since we are reinitializing the CRQ + */ + adapter->failover_pending =3D false; + rc =3D init_crq_queue(adapter); if (rc) { dev_err(&dev->dev, "Couldn't initialize crq. rc=3D%d\n", --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 56D87C433EF for ; Mon, 11 Jul 2022 09:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233465AbiGKJqH (ORCPT ); Mon, 11 Jul 2022 05:46:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233690AbiGKJok (ORCPT ); Mon, 11 Jul 2022 05:44:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF0D3E77A; Mon, 11 Jul 2022 02:22:07 -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 C0EF8B80E76; Mon, 11 Jul 2022 09:22:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FD18C34115; Mon, 11 Jul 2022 09:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531324; bh=74WhtXZKqSp2DqO0Sv6x8JdAsyTQOWekwa4KA0f0Xr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b6X9irx8k+qUgTsTeqD4ZJbqd1MuVYaTToLLS1lyf0sYztsAwsVxeHql1HLgzJ+/X Qmq/SsBtoDwuUu6XDUCZIa90RDGkSKVCsLccE77b5qmRIPuyGfipKzYuMPiFyk+NZO KfUKoMUfC6GAsa8eFSljSST2Yc9F+l+biAONPZwc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sukadev Bhattiprolu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 064/230] ibmvnic: Allow queueing resets during probe Date: Mon, 11 Jul 2022 11:05:20 +0200 Message-Id: <20220711090605.892421664@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sukadev Bhattiprolu [ Upstream commit fd98693cb0721317f27341951593712c580c36a1 ] We currently don't allow queuing resets when adapter is in VNIC_PROBING state - instead we throw away the reset and return EBUSY. The reasoning is probably that during ibmvnic_probe() the ibmvnic_adapter itself is being initialized so performing a reset during this time can lead us to accessing fields in the ibmvnic_adapter that are not fully initialized. A review of the code shows that all the adapter state neede to process a reset is initialized before registering the CRQ so that should no longer be a concern. Further the expectation is that if we do get a reset (transport event) during probe, the do..while() loop in ibmvnic_probe() will handle this by reinitializing the CRQ. While that is true to some extent, it is possible that the reset might occur _after_ the CRQ is registered and CRQ_INIT message was exchanged but _before_ the adapter state is set to VNIC_PROBED. As mentioned above, such a reset will be thrown away. While the client assumes that the adapter is functional, the vnic server will wait for the client to reinit the adapter. This disconnect between the two leaves the adapter down needing manual intervention. Because ibmvnic_probe() has other work to do after initializing the CRQ (such as registering the netdev at a minimum) and because the reset event can occur at any instant after the CRQ is initialized, there will always be a window between initializing the CRQ and considering the adapter ready for resets (ie state =3D=3D PROBED). So rather than discarding resets during this window, allow queueing them - but only process them after the adapter is fully initialized. To do this, introduce a new completion state ->probe_done and have the reset worker thread wait on this before processing resets. This change brings up two new situations in or just after ibmvnic_probe(). First after one or more resets were queued, we encounter an error and decide to retry the initialization. At that point the queued resets are no longer relevant since we could be talking to a new vnic server. So we must purge/flush the queued resets before restarting the initialization. As a side note, since we are still in the probing stage and we have not registered the netdev, it will not be CHANGE_PARAM reset. Second this change opens up a potential race between the worker thread in __ibmvnic_reset(), the tasklet and the ibmvnic_open() due to the following sequence of events: 1. Register CRQ 2. Get transport event before CRQ_INIT completes. 3. Tasklet schedules reset: a) add rwi to list b) schedule_work() to start worker thread which runs and waits for ->probe_done. 4. ibmvnic_probe() decides to retry, purges rwi_list 5. Re-register crq and this time rest of probe succeeds - register netdev and complete(->probe_done). 6. Worker thread resumes in __ibmvnic_reset() from 3b. 7. Worker thread sets ->resetting bit 8. ibmvnic_open() comes in, notices ->resetting bit, sets state to IBMVNIC_OPEN and returns early expecting worker thread to finish the open. 9. Worker thread finds rwi_list empty and returns without opening the interface. If this happens, the ->ndo_open() call is effectively lost and the interface remains down. To address this, ensure that ->rwi_list is not empty before setting the ->resetting bit. See also comments in __ibmvnic_reset(). Fixes: 6a2fb0e99f9c ("ibmvnic: driver initialization for kdump/kexec") Signed-off-by: Sukadev Bhattiprolu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/ibm/ibmvnic.c | 107 ++++++++++++++++++++++++++--- drivers/net/ethernet/ibm/ibmvnic.h | 1 + 2 files changed, 98 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index 9f4f40564d74..28344c3dfea1 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -2471,23 +2471,82 @@ static int do_passive_init(struct ibmvnic_adapter *= adapter) static void __ibmvnic_reset(struct work_struct *work) { struct ibmvnic_adapter *adapter; - bool saved_state =3D false; + unsigned int timeout =3D 5000; struct ibmvnic_rwi *tmprwi; + bool saved_state =3D false; struct ibmvnic_rwi *rwi; unsigned long flags; - u32 reset_state; + struct device *dev; + bool need_reset; int num_fails =3D 0; + u32 reset_state; int rc =3D 0; =20 adapter =3D container_of(work, struct ibmvnic_adapter, ibmvnic_reset); + dev =3D &adapter->vdev->dev; =20 - if (test_and_set_bit_lock(0, &adapter->resetting)) { + /* Wait for ibmvnic_probe() to complete. If probe is taking too long + * or if another reset is in progress, defer work for now. If probe + * eventually fails it will flush and terminate our work. + * + * Three possibilities here: + * 1. Adpater being removed - just return + * 2. Timed out on probe or another reset in progress - delay the work + * 3. Completed probe - perform any resets in queue + */ + if (adapter->state =3D=3D VNIC_PROBING && + !wait_for_completion_timeout(&adapter->probe_done, timeout)) { + dev_err(dev, "Reset thread timed out on probe"); queue_delayed_work(system_long_wq, &adapter->ibmvnic_delayed_reset, IBMVNIC_RESET_DELAY); return; } =20 + /* adapter is done with probe (i.e state is never VNIC_PROBING now) */ + if (adapter->state =3D=3D VNIC_REMOVING) + return; + + /* ->rwi_list is stable now (no one else is removing entries) */ + + /* ibmvnic_probe() may have purged the reset queue after we were + * scheduled to process a reset so there maybe no resets to process. + * Before setting the ->resetting bit though, we have to make sure + * that there is infact a reset to process. Otherwise we may race + * with ibmvnic_open() and end up leaving the vnic down: + * + * __ibmvnic_reset() ibmvnic_open() + * ----------------- -------------- + * + * set ->resetting bit + * find ->resetting bit is set + * set ->state to IBMVNIC_OPEN (i.e + * assume reset will open device) + * return + * find reset queue empty + * return + * + * Neither performed vnic login/open and vnic stays down + * + * If we hold the lock and conditionally set the bit, either we + * or ibmvnic_open() will complete the open. + */ + need_reset =3D false; + spin_lock(&adapter->rwi_lock); + if (!list_empty(&adapter->rwi_list)) { + if (test_and_set_bit_lock(0, &adapter->resetting)) { + queue_delayed_work(system_long_wq, + &adapter->ibmvnic_delayed_reset, + IBMVNIC_RESET_DELAY); + } else { + need_reset =3D true; + } + } + spin_unlock(&adapter->rwi_lock); + + if (!need_reset) + return; + rwi =3D get_next_rwi(adapter); while (rwi) { spin_lock_irqsave(&adapter->state_lock, flags); @@ -2639,13 +2698,6 @@ static int ibmvnic_reset(struct ibmvnic_adapter *ada= pter, goto err; } =20 - if (adapter->state =3D=3D VNIC_PROBING) { - netdev_warn(netdev, "Adapter reset during probe\n"); - adapter->init_done_rc =3D -EAGAIN; - ret =3D EAGAIN; - goto err; - } - list_for_each_entry(tmp, &adapter->rwi_list, list) { if (tmp->reset_reason =3D=3D reason) { netdev_dbg(netdev, "Skipping matching reset, reason=3D%s\n", @@ -5561,6 +5613,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const s= truct vio_device_id *id) struct ibmvnic_adapter *adapter; struct net_device *netdev; unsigned char *mac_addr_p; + unsigned long flags; bool init_success; int rc; =20 @@ -5602,6 +5655,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const s= truct vio_device_id *id) spin_lock_init(&adapter->rwi_lock); spin_lock_init(&adapter->state_lock); mutex_init(&adapter->fw_lock); + init_completion(&adapter->probe_done); init_completion(&adapter->init_done); init_completion(&adapter->fw_done); init_completion(&adapter->reset_done); @@ -5617,6 +5671,26 @@ static int ibmvnic_probe(struct vio_dev *dev, const = struct vio_device_id *id) */ adapter->failover_pending =3D false; =20 + /* If we had already initialized CRQ, we may have one or + * more resets queued already. Discard those and release + * the CRQ before initializing the CRQ again. + */ + release_crq_queue(adapter); + + /* Since we are still in PROBING state, __ibmvnic_reset() + * will not access the ->rwi_list and since we released CRQ, + * we won't get _new_ transport events. But there maybe an + * ongoing ibmvnic_reset() call. So serialize access to + * rwi_list. If we win the race, ibvmnic_reset() could add + * a reset after we purged but thats ok - we just may end + * up with an extra reset (i.e similar to having two or more + * resets in the queue at once). + * CHECK. + */ + spin_lock_irqsave(&adapter->rwi_lock, flags); + flush_reset_queue(adapter); + spin_unlock_irqrestore(&adapter->rwi_lock, flags); + rc =3D init_crq_queue(adapter); if (rc) { dev_err(&dev->dev, "Couldn't initialize crq. rc=3D%d\n", @@ -5668,6 +5742,8 @@ static int ibmvnic_probe(struct vio_dev *dev, const s= truct vio_device_id *id) } dev_info(&dev->dev, "ibmvnic registered\n"); =20 + complete(&adapter->probe_done); + return 0; =20 ibmvnic_register_fail: @@ -5682,6 +5758,17 @@ static int ibmvnic_probe(struct vio_dev *dev, const = struct vio_device_id *id) ibmvnic_init_fail: release_sub_crqs(adapter, 1); release_crq_queue(adapter); + + /* cleanup worker thread after releasing CRQ so we don't get + * transport events (i.e new work items for the worker thread). + */ + adapter->state =3D VNIC_REMOVING; + complete(&adapter->probe_done); + flush_work(&adapter->ibmvnic_reset); + flush_delayed_work(&adapter->ibmvnic_delayed_reset); + + flush_reset_queue(adapter); + mutex_destroy(&adapter->fw_lock); free_netdev(netdev); =20 diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/= ibmvnic.h index 1a9ed9202654..b01c439965ff 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.h +++ b/drivers/net/ethernet/ibm/ibmvnic.h @@ -927,6 +927,7 @@ struct ibmvnic_adapter { =20 struct ibmvnic_tx_pool *tx_pool; struct ibmvnic_tx_pool *tso_pool; + struct completion probe_done; struct completion init_done; int init_done_rc; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 8A164C433EF for ; Mon, 11 Jul 2022 09:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233399AbiGKJpv (ORCPT ); Mon, 11 Jul 2022 05:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233675AbiGKJoj (ORCPT ); Mon, 11 Jul 2022 05:44: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 E6895A79E5; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id D50FD612B7; Mon, 11 Jul 2022 09:22:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC69C341C0; Mon, 11 Jul 2022 09:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531327; bh=wzKm2vevtd6ICYsl21LmVAkfMbeqROkn+UFyIa7wBMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MA/UVr91pSg3trMZTOLihXqGNMTMq8epe8qh6Ms9tBqs8e8om0PwdIwLhkZfsVCwa N7VgqABmYSOX6X9f67nqwJiOGQ01rYW7QkQ58RXRjF/yKf2K6LPQfa9bGjSXQj8YwK VfWfsOvqCOs0l6pcs7tFKeiPaTdZozOPTgVv4RAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Gurtovoy , Israel Rukshin , Feng Li , Stefan Hajnoczi , Christoph Hellwig , "Michael S. Tsirkin" , Sasha Levin , Arnd Bergmann Subject: [PATCH 5.15 065/230] virtio-blk: avoid preallocating big SGL for data Date: Mon, 11 Jul 2022 11:05:21 +0200 Message-Id: <20220711090605.921067778@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Max Gurtovoy [ Upstream commit 02746e26c39ee473b975e0f68d1295abc92672ed ] No need to pre-allocate a big buffer for the IO SGL anymore. If a device has lots of deep queues, preallocation for the sg list can consume substantial amounts of memory. For HW virtio-blk device, nr_hw_queues can be 64 or 128 and each queue's depth might be 128. This means the resulting preallocation for the data SGLs is big. Switch to runtime allocation for SGL for lists longer than 2 entries. This is the approach used by NVMe drivers so it should be reasonable for virtio block as well. Runtime SGL allocation has always been the case for the legacy I/O path so this is nothing new. The preallocated small SGL depends on SG_CHAIN so if the ARCH doesn't support SG_CHAIN, use only runtime allocation for the SGL. Re-organize the setup of the IO request to fit the new sg chain mechanism. No performance degradation was seen (fio libaio engine with 16 jobs and 128 iodepth): IO size IOPs Rand Read (before/after) IOPs Rand Write (before/= after) Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Reviewed-by: Christoph Hellwig Reviewed-by: Feng Li Reviewed-by: Israel Rukshin Reviewed-by: Stefan Hajnoczi Tested-by: Bagas Sanjaya Tested-by: Stefan Hajnoczi -------- --------------------------------- -------------------------= --------- 512B 318K/316K 329K/325K 4KB 323K/321K 353K/349K 16KB 199K/208K 250K/275K 128KB 36K/36.1K 39.2K/41.7K Signed-off-by: Max Gurtovoy Reviewed-by: Israel Rukshin Link: https://lore.kernel.org/r/20210901131434.31158-1-mgurtovoy@nvidia.com Reviewed-by: Feng Li Reviewed-by: Stefan Hajnoczi Tested-by: Stefan Hajnoczi Reviewed-by: Christoph Hellwig Signed-off-by: Arnd Bergmann # kconfig fixups Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/block/Kconfig | 1 + drivers/block/virtio_blk.c | 156 ++++++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 56 deletions(-) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index f93cb989241c..28ed157b1203 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -410,6 +410,7 @@ config XEN_BLKDEV_BACKEND config VIRTIO_BLK tristate "Virtio block driver" depends on VIRTIO + select SG_POOL help This is the virtual block driver for virtio. It can be used with QEMU based VMMs (like KVM or Xen). Say Y or M. diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index c05138a28475..ccc5770d7654 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -24,6 +24,12 @@ /* The maximum number of sg elements that fit into a virtqueue */ #define VIRTIO_BLK_MAX_SG_ELEMS 32768 =20 +#ifdef CONFIG_ARCH_NO_SG_CHAIN +#define VIRTIO_BLK_INLINE_SG_CNT 0 +#else +#define VIRTIO_BLK_INLINE_SG_CNT 2 +#endif + static int major; static DEFINE_IDA(vd_index_ida); =20 @@ -77,6 +83,7 @@ struct virtio_blk { struct virtblk_req { struct virtio_blk_outhdr out_hdr; u8 status; + struct sg_table sg_table; struct scatterlist sg[]; }; =20 @@ -162,12 +169,92 @@ static int virtblk_setup_discard_write_zeroes(struct = request *req, bool unmap) return 0; } =20 -static inline void virtblk_request_done(struct request *req) +static void virtblk_unmap_data(struct request *req, struct virtblk_req *vb= r) { - struct virtblk_req *vbr =3D blk_mq_rq_to_pdu(req); + if (blk_rq_nr_phys_segments(req)) + sg_free_table_chained(&vbr->sg_table, + VIRTIO_BLK_INLINE_SG_CNT); +} + +static int virtblk_map_data(struct blk_mq_hw_ctx *hctx, struct request *re= q, + struct virtblk_req *vbr) +{ + int err; + + if (!blk_rq_nr_phys_segments(req)) + return 0; + + vbr->sg_table.sgl =3D vbr->sg; + err =3D sg_alloc_table_chained(&vbr->sg_table, + blk_rq_nr_phys_segments(req), + vbr->sg_table.sgl, + VIRTIO_BLK_INLINE_SG_CNT); + if (unlikely(err)) + return -ENOMEM; =20 + return blk_rq_map_sg(hctx->queue, req, vbr->sg_table.sgl); +} + +static void virtblk_cleanup_cmd(struct request *req) +{ if (req->rq_flags & RQF_SPECIAL_PAYLOAD) kfree(bvec_virt(&req->special_vec)); +} + +static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *r= eq, + struct virtblk_req *vbr) +{ + bool unmap =3D false; + u32 type; + + vbr->out_hdr.sector =3D 0; + + switch (req_op(req)) { + case REQ_OP_READ: + type =3D VIRTIO_BLK_T_IN; + vbr->out_hdr.sector =3D cpu_to_virtio64(vdev, + blk_rq_pos(req)); + break; + case REQ_OP_WRITE: + type =3D VIRTIO_BLK_T_OUT; + vbr->out_hdr.sector =3D cpu_to_virtio64(vdev, + blk_rq_pos(req)); + break; + case REQ_OP_FLUSH: + type =3D VIRTIO_BLK_T_FLUSH; + break; + case REQ_OP_DISCARD: + type =3D VIRTIO_BLK_T_DISCARD; + break; + case REQ_OP_WRITE_ZEROES: + type =3D VIRTIO_BLK_T_WRITE_ZEROES; + unmap =3D !(req->cmd_flags & REQ_NOUNMAP); + break; + case REQ_OP_DRV_IN: + type =3D VIRTIO_BLK_T_GET_ID; + break; + default: + WARN_ON_ONCE(1); + return BLK_STS_IOERR; + } + + vbr->out_hdr.type =3D cpu_to_virtio32(vdev, type); + vbr->out_hdr.ioprio =3D cpu_to_virtio32(vdev, req_get_ioprio(req)); + + if (type =3D=3D VIRTIO_BLK_T_DISCARD || type =3D=3D VIRTIO_BLK_T_WRITE_ZE= ROES) { + if (virtblk_setup_discard_write_zeroes(req, unmap)) + return BLK_STS_RESOURCE; + } + + return 0; +} + +static inline void virtblk_request_done(struct request *req) +{ + struct virtblk_req *vbr =3D blk_mq_rq_to_pdu(req); + + virtblk_unmap_data(req, vbr); + virtblk_cleanup_cmd(req); blk_mq_end_request(req, virtblk_result(vbr)); } =20 @@ -225,57 +312,23 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_= ctx *hctx, int qid =3D hctx->queue_num; int err; bool notify =3D false; - bool unmap =3D false; - u32 type; =20 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems); =20 - switch (req_op(req)) { - case REQ_OP_READ: - case REQ_OP_WRITE: - type =3D 0; - break; - case REQ_OP_FLUSH: - type =3D VIRTIO_BLK_T_FLUSH; - break; - case REQ_OP_DISCARD: - type =3D VIRTIO_BLK_T_DISCARD; - break; - case REQ_OP_WRITE_ZEROES: - type =3D VIRTIO_BLK_T_WRITE_ZEROES; - unmap =3D !(req->cmd_flags & REQ_NOUNMAP); - break; - case REQ_OP_DRV_IN: - type =3D VIRTIO_BLK_T_GET_ID; - break; - default: - WARN_ON_ONCE(1); - return BLK_STS_IOERR; - } - - vbr->out_hdr.type =3D cpu_to_virtio32(vblk->vdev, type); - vbr->out_hdr.sector =3D type ? - 0 : cpu_to_virtio64(vblk->vdev, blk_rq_pos(req)); - vbr->out_hdr.ioprio =3D cpu_to_virtio32(vblk->vdev, req_get_ioprio(req)); + err =3D virtblk_setup_cmd(vblk->vdev, req, vbr); + if (unlikely(err)) + return err; =20 blk_mq_start_request(req); =20 - if (type =3D=3D VIRTIO_BLK_T_DISCARD || type =3D=3D VIRTIO_BLK_T_WRITE_ZE= ROES) { - err =3D virtblk_setup_discard_write_zeroes(req, unmap); - if (err) - return BLK_STS_RESOURCE; - } - - num =3D blk_rq_map_sg(hctx->queue, req, vbr->sg); - if (num) { - if (rq_data_dir(req) =3D=3D WRITE) - vbr->out_hdr.type |=3D cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_OUT); - else - vbr->out_hdr.type |=3D cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_IN); + num =3D virtblk_map_data(hctx, req, vbr); + if (unlikely(num < 0)) { + virtblk_cleanup_cmd(req); + return BLK_STS_RESOURCE; } =20 spin_lock_irqsave(&vblk->vqs[qid].lock, flags); - err =3D virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num); + err =3D virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg_table.sgl, num); if (err) { virtqueue_kick(vblk->vqs[qid].vq); /* Don't stop the queue if -ENOMEM: we may have failed to @@ -284,6 +337,8 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ct= x *hctx, if (err =3D=3D -ENOSPC) blk_mq_stop_hw_queue(hctx); spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags); + virtblk_unmap_data(req, vbr); + virtblk_cleanup_cmd(req); switch (err) { case -ENOSPC: return BLK_STS_DEV_RESOURCE; @@ -660,16 +715,6 @@ static const struct attribute_group *virtblk_attr_grou= ps[] =3D { NULL, }; =20 -static int virtblk_init_request(struct blk_mq_tag_set *set, struct request= *rq, - unsigned int hctx_idx, unsigned int numa_node) -{ - struct virtio_blk *vblk =3D set->driver_data; - struct virtblk_req *vbr =3D blk_mq_rq_to_pdu(rq); - - sg_init_table(vbr->sg, vblk->sg_elems); - return 0; -} - static int virtblk_map_queues(struct blk_mq_tag_set *set) { struct virtio_blk *vblk =3D set->driver_data; @@ -682,7 +727,6 @@ static const struct blk_mq_ops virtio_mq_ops =3D { .queue_rq =3D virtio_queue_rq, .commit_rqs =3D virtio_commit_rqs, .complete =3D virtblk_request_done, - .init_request =3D virtblk_init_request, .map_queues =3D virtblk_map_queues, }; =20 @@ -762,7 +806,7 @@ static int virtblk_probe(struct virtio_device *vdev) vblk->tag_set.flags =3D BLK_MQ_F_SHOULD_MERGE; vblk->tag_set.cmd_size =3D sizeof(struct virtblk_req) + - sizeof(struct scatterlist) * sg_elems; + sizeof(struct scatterlist) * VIRTIO_BLK_INLINE_SG_CNT; vblk->tag_set.driver_data =3D vblk; vblk->tag_set.nr_hw_queues =3D vblk->num_vqs; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 7D78EC433EF for ; Mon, 11 Jul 2022 09:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233482AbiGKJqA (ORCPT ); Mon, 11 Jul 2022 05:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbiGKJoj (ORCPT ); Mon, 11 Jul 2022 05:44:39 -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 0663965550; Mon, 11 Jul 2022 02:22: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 65FF2B80D2C; Mon, 11 Jul 2022 09:22:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0011C34115; Mon, 11 Jul 2022 09:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531330; bh=0gSaiwLMGnnaQodJeKaLiO2p8CWmE/nCdtGe/1xzvJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AxzRWLJFNLAjtNvpIqk/Xha4ylfop8LbDM+f+3+mWD5Rbh3USpFMJhGVtkYkixCwn O2ezwjyob/+DJOWe60QRWVbn2ZeHoiNscudQWF97WvxrAApPa3AfXMbDqaFGz3YDaG y3XZbwbxleBgX6JAKlO/wSlUuAQWiFin1Jew2rM8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe , Sasha Levin Subject: [PATCH 5.15 066/230] io_uring: ensure that fsnotify is always called Date: Mon, 11 Jul 2022 11:05:22 +0200 Message-Id: <20220711090605.950070957@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jens Axboe [ Upstream commit f63cf5192fe3418ad5ae1a4412eba5694b145f79 ] Ensure that we call fsnotify_modify() if we write a file, and that we do fsnotify_access() if we read it. This enables anyone using inotify on the file to get notified. Ditto for fallocate, ensure that fsnotify_modify() is called. Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/io_uring.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 189323740324..0c5dcda0b622 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2686,8 +2686,12 @@ static bool io_rw_should_reissue(struct io_kiocb *re= q) =20 static bool __io_complete_rw_common(struct io_kiocb *req, long res) { - if (req->rw.kiocb.ki_flags & IOCB_WRITE) + if (req->rw.kiocb.ki_flags & IOCB_WRITE) { kiocb_end_write(req); + fsnotify_modify(req->file); + } else { + fsnotify_access(req->file); + } if (res !=3D req->result) { if ((res =3D=3D -EAGAIN || res =3D=3D -EOPNOTSUPP) && io_rw_should_reissue(req)) { @@ -4183,6 +4187,8 @@ static int io_fallocate(struct io_kiocb *req, unsigne= d int issue_flags) req->sync.len); if (ret < 0) req_set_fail(req); + else + fsnotify_modify(req->file); io_req_complete(req, ret); return 0; } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 C108DCCA47B for ; Mon, 11 Jul 2022 09:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233492AbiGKJqL (ORCPT ); Mon, 11 Jul 2022 05:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233705AbiGKJoo (ORCPT ); Mon, 11 Jul 2022 05:44:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4EF22B637; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id 99FA661227; Mon, 11 Jul 2022 09:22:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A034BC34115; Mon, 11 Jul 2022 09:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531333; bh=G9+MC9Bm/hCR6EhwkzzQkRijdDIMmmHji1Qt/+0XSs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ahqFBapuz8l0XFZWnoRnxjBfflH67YenBfoSqV7U0WRpNp8P0xqFTpbEdfT8pMj6 pPBjOs3rq0XexWX2uw8p1arA/61vlb5AFfMF6Y4bk+xRh/opYoNZYjgqao1aUasZ6f rYivH3TyLX2+NHn2IvXcxh2006tweIf7upJe7Wk4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 067/230] block: use bdev_get_queue() in bio.c Date: Mon, 11 Jul 2022 11:05:23 +0200 Message-Id: <20220711090605.978080465@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pavel Begunkov [ Upstream commit 3caee4634be68e755d2fb130962f1623661dbd5b ] Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached queue pointer and so is faster. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/85c36ea784d285a5075baa10049e6b59e15fb484.16= 34219547.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- block/bio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index 8381c6690dd6..365bb6362669 100644 --- a/block/bio.c +++ b/block/bio.c @@ -910,7 +910,7 @@ EXPORT_SYMBOL(bio_add_pc_page); int bio_add_zone_append_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { - struct request_queue *q =3D bio->bi_bdev->bd_disk->queue; + struct request_queue *q =3D bdev_get_queue(bio->bi_bdev); bool same_page =3D false; =20 if (WARN_ON_ONCE(bio_op(bio) !=3D REQ_OP_ZONE_APPEND)) @@ -1054,7 +1054,7 @@ static int bio_iov_bvec_set(struct bio *bio, struct i= ov_iter *iter) =20 static int bio_iov_bvec_set_append(struct bio *bio, struct iov_iter *iter) { - struct request_queue *q =3D bio->bi_bdev->bd_disk->queue; + struct request_queue *q =3D bdev_get_queue(bio->bi_bdev); struct iov_iter i =3D *iter; =20 iov_iter_truncate(&i, queue_max_zone_append_sectors(q) << 9); @@ -1132,7 +1132,7 @@ static int __bio_iov_append_get_pages(struct bio *bio= , struct iov_iter *iter) { unsigned short nr_pages =3D bio->bi_max_vecs - bio->bi_vcnt; unsigned short entries_left =3D bio->bi_max_vecs - bio->bi_vcnt; - struct request_queue *q =3D bio->bi_bdev->bd_disk->queue; + struct request_queue *q =3D bdev_get_queue(bio->bi_bdev); unsigned int max_append_sectors =3D queue_max_zone_append_sectors(q); struct bio_vec *bv =3D bio->bi_io_vec + bio->bi_vcnt; struct page **pages =3D (struct page **)bv; @@ -1471,10 +1471,10 @@ void bio_endio(struct bio *bio) return; =20 if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED)) - rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio); + rq_qos_done_bio(bdev_get_queue(bio->bi_bdev), bio); =20 if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { - trace_block_bio_complete(bio->bi_bdev->bd_disk->queue, bio); + trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), bio); bio_clear_flag(bio, BIO_TRACE_COMPLETION); } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 52081C43334 for ; Mon, 11 Jul 2022 09:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233512AbiGKJqa (ORCPT ); Mon, 11 Jul 2022 05:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233708AbiGKJoo (ORCPT ); Mon, 11 Jul 2022 05:44:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9245D2BB0E; Mon, 11 Jul 2022 02:22: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 7115061283; Mon, 11 Jul 2022 09:22:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F51FC34115; Mon, 11 Jul 2022 09:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531335; bh=WvrECEWfwpgZ3U7b0mnKDdps2mWNuLBNzbWv509ML6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zqAmbPl1fgeFtiy/uzdkEZL0qCvb/wjGlunZ/wyuS3z4QM0R+iMgt5pHYgSWX8slV 6Krd940nqNc7Dmk6fiSigTRxrJ162t7asTrMcLvmDCUM7o5SdoQjDidliL2oAwOzrY NbhMgA1eJPj0HFdwV5S4wwZZ+CdzxkASrJ9UrHfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 068/230] block: only mark bio as tracked if it really is tracked Date: Mon, 11 Jul 2022 11:05:24 +0200 Message-Id: <20220711090606.006275650@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jens Axboe [ Upstream commit 90b8faa0e8de1b02b619fb33f6c6e1e13e7d1d70 ] We set BIO_TRACKED unconditionally when rq_qos_throttle() is called, even though we may not even have an rq_qos handler. Only mark it as TRACKED if it really is potentially tracked. This saves considerable time for the case where the bio isn't tracked: 2.64% -1.65% [kernel.vmlinux] [k] bio_endio Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- block/blk-rq-qos.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index f000f83e0621..3cfbc8668cba 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -189,9 +189,10 @@ static inline void rq_qos_throttle(struct request_queu= e *q, struct bio *bio) * BIO_TRACKED lets controllers know that a bio went through the * normal rq_qos path. */ - bio_set_flag(bio, BIO_TRACKED); - if (q->rq_qos) + if (q->rq_qos) { + bio_set_flag(bio, BIO_TRACKED); __rq_qos_throttle(q->rq_qos, bio); + } } =20 static inline void rq_qos_track(struct request_queue *q, struct request *r= q, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 514C7C43334 for ; Mon, 11 Jul 2022 09:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233497AbiGKJqQ (ORCPT ); Mon, 11 Jul 2022 05:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233745AbiGKJox (ORCPT ); Mon, 11 Jul 2022 05:44:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F0865564; Mon, 11 Jul 2022 02:22: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 EA7D8B80E6D; Mon, 11 Jul 2022 09:22:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 316A5C341C8; Mon, 11 Jul 2022 09:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531338; bh=a0WyAbxVFMqNHfDvGyHJPsBeIcAafRbFW85cd1hCW0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rR9/V+S2IzVkbGMM2Ys/TzswOID8pYw1WCE4PYOwGAxrybAQr1tSgcd/MWRplxbfh xeIVqwKzzaPccwobDaIfgUHAk1kUUl1tKbL3kF4Cc0EdXFvrr+bQuoxoaNX490ynPY vT8401qfHt+jfxE/1u8+2nQzXqF1gdB5QciNLFW4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , Ming Lei , Yu Kuai , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 069/230] block: fix rq-qos breakage from skipping rq_qos_done_bio() Date: Mon, 11 Jul 2022 11:05:25 +0200 Message-Id: <20220711090606.034512477@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tejun Heo [ Upstream commit aa1b46dcdc7baaf5fec0be25782ef24b26aa209e ] a647a524a467 ("block: don't call rq_qos_ops->done_bio if the bio isn't tracked") made bio_endio() skip rq_qos_done_bio() if BIO_TRACKED is not set. While this fixed a potential oops, it also broke blk-iocost by skipping the done_bio callback for merged bios. Before, whether a bio goes through rq_qos_throttle() or rq_qos_merge(), rq_qos_done_bio() would be called on the bio on completion with BIO_TRACKED distinguishing the former from the latter. rq_qos_done_bio() is not called for bios which wenth through rq_qos_merge(). This royally confuses blk-iocost as the merged bios never finish and are considered perpetually in-flight. One reliably reproducible failure mode is an intermediate cgroup geting stuck active preventing its children from being activated due to the leaf-only rule, leading to loss of control. The following is from resctl-bench protection scenario which emulates isolating a web server like workload from a memory bomb run on an iocost configuration which should yield a reasonable level of protection. # cat /sys/block/nvme2n1/device/model Samsung SSD 970 PRO 512GB # cat /sys/fs/cgroup/io.cost.model 259:0 ctrl=3Duser model=3Dlinear rbps=3D834913556 rseqiops=3D93622 rrandi= ops=3D102913 wbps=3D618985353 wseqiops=3D72325 wrandiops=3D71025 # cat /sys/fs/cgroup/io.cost.qos 259:0 enable=3D1 ctrl=3Duser rpct=3D95.00 rlat=3D18776 wpct=3D95.00 wlat= =3D8897 min=3D60.00 max=3D100.00 # resctl-bench -m 29.6G -r out.json run protection::scenario=3Dmem-hog,lo= ops=3D1 ... Memory Hog Summary =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D IO Latency: R p50=3D242u:336u/2.5m p90=3D794u:1.4m/7.5m p99=3D2.7m:8.0m/6= 2.5m max=3D8.0m:36.4m/350m W p50=3D221u:323u/1.5m p90=3D709u:1.2m/5.5m p99=3D1.5m:2.5m/9= .5m max=3D6.9m:35.9m/350m Isolation and Request Latency Impact Distributions: min p01 p05 p10 p25 p50 p75 p90 p95 p99 = max mean stdev isol% 15.90 15.90 15.90 40.05 57.24 59.07 60.01 74.63 74.63 90.35 9= 0.35 58.12 15.82 lat-imp% 0 0 0 0 0 4.55 14.68 15.54 233.5 548.1 5= 48.1 53.88 143.6 Result: isol=3D58.12:15.82% lat_imp=3D53.88%:143.6 work_csv=3D100.0% miss= ing=3D3.96% The isolation result of 58.12% is close to what this device would show without any IO control. Fix it by introducing a new flag BIO_QOS_MERGED to mark merged bios and calling rq_qos_done_bio() on them too. For consistency and clarity, rename BIO_TRACKED to BIO_QOS_THROTTLED. The flag checks are moved into rq_qos_done_bio() so that it's next to the code paths that set the flags. With the patch applied, the above same benchmark shows: # resctl-bench -m 29.6G -r out.json run protection::scenario=3Dmem-hog,lo= ops=3D1 ... Memory Hog Summary =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D IO Latency: R p50=3D123u:84.4u/985u p90=3D322u:256u/2.5m p99=3D1.6m:1.4m/= 9.5m max=3D11.1m:36.0m/350m W p50=3D429u:274u/995u p90=3D1.7m:1.3m/4.5m p99=3D3.4m:2.7m/1= 1.5m max=3D7.9m:5.9m/26.5m Isolation and Request Latency Impact Distributions: min p01 p05 p10 p25 p50 p75 p90 p95 p99 = max mean stdev isol% 84.91 84.91 89.51 90.73 92.31 94.49 96.36 98.04 98.71 100.0 1= 00.0 94.42 2.81 lat-imp% 0 0 0 0 0 2.81 5.73 11.11 13.92 17.53 2= 2.61 4.10 4.68 Result: isol=3D94.42:2.81% lat_imp=3D4.10%:4.68 work_csv=3D58.34% missing= =3D0% Signed-off-by: Tejun Heo Fixes: a647a524a467 ("block: don't call rq_qos_ops->done_bio if the bio isn= 't tracked") Cc: stable@vger.kernel.org # v5.15+ Cc: Ming Lei Cc: Yu Kuai Reviewed-by: Ming Lei Link: https://lore.kernel.org/r/Yi7rdrzQEHjJLGKB@slm.duckdns.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- block/bio.c | 3 +-- block/blk-iolatency.c | 2 +- block/blk-rq-qos.h | 20 +++++++++++--------- include/linux/blk_types.h | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/block/bio.c b/block/bio.c index 365bb6362669..b8a8bfba714f 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1470,8 +1470,7 @@ void bio_endio(struct bio *bio) if (!bio_integrity_endio(bio)) return; =20 - if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED)) - rq_qos_done_bio(bdev_get_queue(bio->bi_bdev), bio); + rq_qos_done_bio(bio); =20 if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), bio); diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index ce3847499d85..d85f30a85ee7 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -601,7 +601,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqo= s, struct bio *bio) int inflight =3D 0; =20 blkg =3D bio->bi_blkg; - if (!blkg || !bio_flagged(bio, BIO_TRACKED)) + if (!blkg || !bio_flagged(bio, BIO_QOS_THROTTLED)) return; =20 iolat =3D blkg_to_lat(bio->bi_blkg); diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 3cfbc8668cba..68267007da1c 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -177,20 +177,20 @@ static inline void rq_qos_requeue(struct request_queu= e *q, struct request *rq) __rq_qos_requeue(q->rq_qos, rq); } =20 -static inline void rq_qos_done_bio(struct request_queue *q, struct bio *bi= o) +static inline void rq_qos_done_bio(struct bio *bio) { - if (q->rq_qos) - __rq_qos_done_bio(q->rq_qos, bio); + if (bio->bi_bdev && (bio_flagged(bio, BIO_QOS_THROTTLED) || + bio_flagged(bio, BIO_QOS_MERGED))) { + struct request_queue *q =3D bdev_get_queue(bio->bi_bdev); + if (q->rq_qos) + __rq_qos_done_bio(q->rq_qos, bio); + } } =20 static inline void rq_qos_throttle(struct request_queue *q, struct bio *bi= o) { - /* - * BIO_TRACKED lets controllers know that a bio went through the - * normal rq_qos path. - */ if (q->rq_qos) { - bio_set_flag(bio, BIO_TRACKED); + bio_set_flag(bio, BIO_QOS_THROTTLED); __rq_qos_throttle(q->rq_qos, bio); } } @@ -205,8 +205,10 @@ static inline void rq_qos_track(struct request_queue *= q, struct request *rq, static inline void rq_qos_merge(struct request_queue *q, struct request *r= q, struct bio *bio) { - if (q->rq_qos) + if (q->rq_qos) { + bio_set_flag(bio, BIO_QOS_MERGED); __rq_qos_merge(q->rq_qos, rq, bio); + } } =20 static inline void rq_qos_queue_depth_changed(struct request_queue *q) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 17c92c0f15b2..36ce3d0fb9f3 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -294,7 +294,8 @@ enum { BIO_TRACE_COMPLETION, /* bio_endio() should trace the final completion * of this bio. */ BIO_CGROUP_ACCT, /* has been accounted to a cgroup */ - BIO_TRACKED, /* set if bio goes through the rq_qos path */ + BIO_QOS_THROTTLED, /* bio went through rq_qos throttle path */ + BIO_QOS_MERGED, /* but went through rq_qos merge path */ BIO_REMAPPED, BIO_ZONE_WRITE_LOCKED, /* Owns a zoned device zone write lock */ BIO_PERCPU_CACHE, /* can participate in per-cpu alloc cache */ --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 2CF2EC43334 for ; Mon, 11 Jul 2022 09:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbiGKJqS (ORCPT ); Mon, 11 Jul 2022 05:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbiGKJox (ORCPT ); Mon, 11 Jul 2022 05:44: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 E21766556D; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id 25A22612FE; Mon, 11 Jul 2022 09:22:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D070C34115; Mon, 11 Jul 2022 09:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531341; bh=Rq9vb6WikgfKYlDfhi0TMEnx25Zy4QErCJtOFjm+XEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1fnesUghuM2UqkpoJHjlB0mX2Zac/sKoe7RouXEG+fCmhCzz7CSUJHkcAwOK82XjW p3NBT7l/AlMciQAT6/31KV687LQ/8anOrIZAykaTVCrjCqbJjhCnSAMwqsRkEsF1V5 yiw1EvZ+mpzn6RudJOwjSucK4uVkq650sMctVM4c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keith Packard , "Gustavo A. R. Silva" , Dan Williams , Kees Cook , Sasha Levin , Rasmus Villemoes , Daniel Vetter Subject: [PATCH 5.15 070/230] stddef: Introduce struct_group() helper macro Date: Mon, 11 Jul 2022 11:05:26 +0200 Message-Id: <20220711090606.063060909@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 50d7bd38c3aafc4749e05e8d7fcb616979143602 ] Kernel code has a regular need to describe groups of members within a structure usually when they need to be copied or initialized separately from the rest of the surrounding structure. The generally accepted design pattern in C is to use a named sub-struct: struct foo { int one; struct { int two; int three, four; } thing; int five; }; This would allow for traditional references and sizing: memcpy(&dst.thing, &src.thing, sizeof(dst.thing)); However, doing this would mean that referencing struct members enclosed by such named structs would always require including the sub-struct name in identifiers: do_something(dst.thing.three); This has tended to be quite inflexible, especially when such groupings need to be added to established code which causes huge naming churn. Three workarounds exist in the kernel for this problem, and each have other negative properties. To avoid the naming churn, there is a design pattern of adding macro aliases for the named struct: #define f_three thing.three This ends up polluting the global namespace, and makes it difficult to search for identifiers. Another common work-around in kernel code avoids the pollution by avoiding the named struct entirely, instead identifying the group's boundaries using either a pair of empty anonymous structs of a pair of zero-element arrays: struct foo { int one; struct { } start; int two; int three, four; struct { } finish; int five; }; struct foo { int one; int start[0]; int two; int three, four; int finish[0]; int five; }; This allows code to avoid needing to use a sub-struct named for member references within the surrounding structure, but loses the benefits of being able to actually use such a struct, making it rather fragile. Using these requires open-coded calculation of sizes and offsets. The efforts made to avoid common mistakes include lots of comments, or adding various BUILD_BUG_ON()s. Such code is left with no way for the compiler to reason about the boundaries (e.g. the "start" object looks like it's 0 bytes in length), making bounds checking depend on open-coded calculations: if (length > offsetof(struct foo, finish) - offsetof(struct foo, start)) return -EINVAL; memcpy(&dst.start, &src.start, offsetof(struct foo, finish) - offsetof(struct foo, start)); However, the vast majority of places in the kernel that operate on groups of members do so without any identification of the grouping, relying either on comments or implicit knowledge of the struct contents, which is even harder for the compiler to reason about, and results in even more fragile manual sizing, usually depending on member locations outside of the region (e.g. to copy "two" and "three", use the start of "four" to find the size): BUILD_BUG_ON((offsetof(struct foo, four) < offsetof(struct foo, two)) || (offsetof(struct foo, four) < offsetof(struct foo, three)); if (length > offsetof(struct foo, four) - offsetof(struct foo, two)) return -EINVAL; memcpy(&dst.two, &src.two, length); In order to have a regular programmatic way to describe a struct region that can be used for references and sizing, can be examined for bounds checking, avoids forcing the use of intermediate identifiers, and avoids polluting the global namespace, introduce the struct_group() macro. This macro wraps the member declarations to create an anonymous union of an anonymous struct (no intermediate name) and a named struct (for references and sizing): struct foo { int one; struct_group(thing, int two; int three, four; ); int five; }; if (length > sizeof(src.thing)) return -EINVAL; memcpy(&dst.thing, &src.thing, length); do_something(dst.three); There are some rare cases where the resulting struct_group() needs attributes added, so struct_group_attr() is also introduced to allow for specifying struct attributes (e.g. __align(x) or __packed). Additionally, there are places where such declarations would like to have the struct be tagged, so struct_group_tagged() is added. Given there is a need for a handful of UAPI uses too, the underlying __struct_group() macro has been defined in UAPI so it can be used there too. To avoid confusing scripts/kernel-doc, hide the macro from its struct parsing. Co-developed-by: Keith Packard Signed-off-by: Keith Packard Acked-by: Gustavo A. R. Silva Link: https://lore.kernel.org/lkml/20210728023217.GC35706@embeddedor Enhanced-by: Rasmus Villemoes Link: https://lore.kernel.org/lkml/41183a98-bdb9-4ad6-7eab-5a7292a6df84@ras= musvillemoes.dk Enhanced-by: Dan Williams Link: https://lore.kernel.org/lkml/1d9a2e6df2a9a35b2cdd50a9a68cac5991e7e5f0= .camel@intel.com Enhanced-by: Daniel Vetter Link: https://lore.kernel.org/lkml/YQKa76A6XuFqgM03@phenom.ffwll.local Acked-by: Dan Williams Signed-off-by: Kees Cook Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/stddef.h | 48 +++++++++++++++++++++++++++++++++++++ include/uapi/linux/stddef.h | 21 ++++++++++++++++ scripts/kernel-doc | 7 ++++++ 3 files changed, 76 insertions(+) diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 998a4ba28eba..938216f8ab7e 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -36,4 +36,52 @@ enum { #define offsetofend(TYPE, MEMBER) \ (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) =20 +/** + * struct_group() - Wrap a set of declarations in a mirrored struct + * + * @NAME: The identifier name of the mirrored sub-struct + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. + */ +#define struct_group(NAME, MEMBERS...) \ + __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS) + +/** + * struct_group_attr() - Create a struct_group() with trailing attributes + * + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes to apply + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. Includes structure attributes argument. + */ +#define struct_group_attr(NAME, ATTRS, MEMBERS...) \ + __struct_group(/* no tag */, NAME, ATTRS, MEMBERS) + +/** + * struct_group_tagged() - Create a struct_group with a reusable tag + * + * @TAG: The tag name for the named sub-struct + * @NAME: The identifier name of the mirrored sub-struct + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. Includes struct tag argument for the named copy, + * so the specified layout can be reused later. + */ +#define struct_group_tagged(TAG, NAME, MEMBERS...) \ + __struct_group(TAG, NAME, /* no attrs */, MEMBERS) + #endif diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index ee8220f8dcf5..610204f7c275 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -4,3 +4,24 @@ #ifndef __always_inline #define __always_inline inline #endif + +/** + * __struct_group() - Create a mirrored named and anonyomous struct + * + * @TAG: The tag name for the named sub-struct (usually empty) + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes (usually empty) + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical layout + * and size: one anonymous and one named. The former's members can be used + * normally without sub-struct naming, and the latter can be used to + * reason about the start, end, and size of the group of struct members. + * The named struct can also be explicitly tagged for layer reuse, as well + * as both having struct attributes appended. + */ +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ + union { \ + struct { MEMBERS } ATTRS; \ + struct TAG { MEMBERS } ATTRS NAME; \ + } diff --git a/scripts/kernel-doc b/scripts/kernel-doc index cfcb60737957..38aa799a776c 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1245,6 +1245,13 @@ sub dump_struct($$) { $members =3D~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos; $members =3D~ s/\s*____cacheline_aligned_in_smp/ /gos; $members =3D~ s/\s*____cacheline_aligned/ /gos; + # unwrap struct_group(): + # - first eat non-declaration parameters and rewrite for final match + # - then remove macro, outer parens, and trailing semicolon + $members =3D~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos; + $members =3D~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP= (/gos; + $members =3D~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos; + $members =3D~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos; =20 my $args =3D qr{([^,)]+)}; # replace DECLARE_BITMAP --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 869CFC433EF for ; Mon, 11 Jul 2022 09:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233518AbiGKJqf (ORCPT ); Mon, 11 Jul 2022 05:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbiGKJo4 (ORCPT ); Mon, 11 Jul 2022 05:44:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE3165579; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id DAD3E612F1; Mon, 11 Jul 2022 09:22:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5B49C34115; Mon, 11 Jul 2022 09:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531344; bh=AUh9IYr5aMUKXPDT6lbV8vkYuEZJ42X0dasAyZ14M6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6HoQLGCOxD9EHCpZL4zdpQJnAX6KF5dFr+gCs/oWHXhWV4vaZU3EeriL/ZbO38mD 99o3zb215yJa2QIJamXT/WMnZJ0lx3j08eH7UIXIj2gg9QxyVxWdeRvnObbLbzapGb 7TOaT4ypVhOo/QyI0KH6jTtH2mu7yHrndGFNqyoo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "Gustavo A. R. Silva" , Kees Cook , Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 071/230] media: omap3isp: Use struct_group() for memcpy() region Date: Mon, 11 Jul 2022 11:05:27 +0200 Message-Id: <20220711090606.090894937@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit d4568fc8525897e683983806f813be1ae9eedaed ] In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Wrap the target region in struct_group(). This additionally fixes a theoretical misalignment of the copy (since the size of "buf" changes between 64-bit and 32-bit, but this is likely never built for 64-bit). FWIW, I think this code is totally broken on 64-bit (which appears to not be a "real" build configuration): it would either always fail (with an uninitialized data->buf_size) or would cause corruption in userspace due to the copy_to_user() in the call path against an uninitialized data->buf value: omap3isp_stat_request_statistics_time32(...) struct omap3isp_stat_data data64; ... omap3isp_stat_request_statistics(stat, &data64); int omap3isp_stat_request_statistics(struct ispstat *stat, struct omap3isp_stat_data *data) ... buf =3D isp_stat_buf_get(stat, data); static struct ispstat_buffer *isp_stat_buf_get(struct ispstat *stat, struct omap3isp_stat_data *d= ata) ... if (buf->buf_size > data->buf_size) { ... return ERR_PTR(-EINVAL); } ... rval =3D copy_to_user(data->buf, buf->virt_addr, buf->buf_size); Regardless, additionally initialize data64 to be zero-filled to avoid undefined behavior. Link: https://lore.kernel.org/lkml/20211215220505.GB21862@embeddedor Cc: Arnd Bergmann Fixes: 378e3f81cb56 ("media: omap3isp: support 64-bit version of omap3isp_s= tat_data") Cc: stable@vger.kernel.org Reviewed-by: Gustavo A. R. Silva Signed-off-by: Kees Cook Reviewed-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/media/platform/omap3isp/ispstat.c | 5 +++-- include/uapi/linux/omap3isp.h | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/plat= form/omap3isp/ispstat.c index 5b9b57f4d9bf..68cf68dbcace 100644 --- a/drivers/media/platform/omap3isp/ispstat.c +++ b/drivers/media/platform/omap3isp/ispstat.c @@ -512,7 +512,7 @@ int omap3isp_stat_request_statistics(struct ispstat *st= at, int omap3isp_stat_request_statistics_time32(struct ispstat *stat, struct omap3isp_stat_data_time32 *data) { - struct omap3isp_stat_data data64; + struct omap3isp_stat_data data64 =3D { }; int ret; =20 ret =3D omap3isp_stat_request_statistics(stat, &data64); @@ -521,7 +521,8 @@ int omap3isp_stat_request_statistics_time32(struct isps= tat *stat, =20 data->ts.tv_sec =3D data64.ts.tv_sec; data->ts.tv_usec =3D data64.ts.tv_usec; - memcpy(&data->buf, &data64.buf, sizeof(*data) - sizeof(data->ts)); + data->buf =3D (uintptr_t)data64.buf; + memcpy(&data->frame, &data64.frame, sizeof(data->frame)); =20 return 0; } diff --git a/include/uapi/linux/omap3isp.h b/include/uapi/linux/omap3isp.h index 87b55755f4ff..d9db7ad43890 100644 --- a/include/uapi/linux/omap3isp.h +++ b/include/uapi/linux/omap3isp.h @@ -162,6 +162,7 @@ struct omap3isp_h3a_aewb_config { * struct omap3isp_stat_data - Statistic data sent to or received from user * @ts: Timestamp of returned framestats. * @buf: Pointer to pass to user. + * @buf_size: Size of buffer. * @frame_number: Frame number of requested stats. * @cur_frame: Current frame number being processed. * @config_counter: Number of the configuration associated with the data. @@ -176,10 +177,12 @@ struct omap3isp_stat_data { struct timeval ts; #endif void __user *buf; - __u32 buf_size; - __u16 frame_number; - __u16 cur_frame; - __u16 config_counter; + __struct_group(/* no tag */, frame, /* no attrs */, + __u32 buf_size; + __u16 frame_number; + __u16 cur_frame; + __u16 config_counter; + ); }; =20 #ifdef __KERNEL__ @@ -189,10 +192,12 @@ struct omap3isp_stat_data_time32 { __s32 tv_usec; } ts; __u32 buf; - __u32 buf_size; - __u16 frame_number; - __u16 cur_frame; - __u16 config_counter; + __struct_group(/* no tag */, frame, /* no attrs */, + __u32 buf_size; + __u16 frame_number; + __u16 cur_frame; + __u16 config_counter; + ); }; #endif =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 D78D0C433EF for ; Mon, 11 Jul 2022 09:46:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbiGKJqV (ORCPT ); Mon, 11 Jul 2022 05:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233794AbiGKJo7 (ORCPT ); Mon, 11 Jul 2022 05:44:59 -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 A1FF0A9E44; Mon, 11 Jul 2022 02:22: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 91613612F1; Mon, 11 Jul 2022 09:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D057C34115; Mon, 11 Jul 2022 09:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531347; bh=pTxtoLbMkPQmSeDvjO5YStqyjNXGzgQQA4ofL0zE1wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7zgrKe9KT+w9DERtLdY+B2NiNm+SOnY+WG6qcPFhxuVycRqlVtjUYgaF1w5yfa7s oYD5MEkXc4tQIFFtowMckeZ12ZcvT63Eeqg31O7I2Iq9Hm38CLVrHEPAA4Np656qzY mYX+bXK7hQkTTLaqWLqs6ZHSU74nG0dSkA3O+vsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Hilman , Johan Hovold , Lad Prabhakar , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 072/230] media: davinci: vpif: fix use-after-free on driver unbind Date: Mon, 11 Jul 2022 11:05:28 +0200 Message-Id: <20220711090606.118956055@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 43acb728bbc40169d2e2425e84a80068270974be ] The driver allocates and registers two platform device structures during probe, but the devices were never deregistered on driver unbind. This results in a use-after-free on driver unbind as the device structures were allocated using devres and would be freed by driver core when remove() returns. Fix this by adding the missing deregistration calls to the remove() callback and failing probe on registration errors. Note that the platform device structures must be freed using a proper release callback to avoid leaking associated resources like device names. Fixes: 479f7a118105 ("[media] davinci: vpif: adaptions for DT support") Cc: stable@vger.kernel.org # 4.12 Cc: Kevin Hilman Signed-off-by: Johan Hovold Reviewed-by: Lad Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/media/platform/davinci/vpif.c | 97 ++++++++++++++++++++------- 1 file changed, 71 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform= /davinci/vpif.c index 5658c7f148d7..8ffc01c606d0 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -41,6 +41,11 @@ MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); #define VPIF_CH2_MAX_MODES 15 #define VPIF_CH3_MAX_MODES 2 =20 +struct vpif_data { + struct platform_device *capture; + struct platform_device *display; +}; + DEFINE_SPINLOCK(vpif_lock); EXPORT_SYMBOL_GPL(vpif_lock); =20 @@ -423,11 +428,19 @@ int vpif_channel_getfid(u8 channel_id) } EXPORT_SYMBOL(vpif_channel_getfid); =20 +static void vpif_pdev_release(struct device *dev) +{ + struct platform_device *pdev =3D to_platform_device(dev); + + kfree(pdev); +} + static int vpif_probe(struct platform_device *pdev) { static struct resource *res, *res_irq; struct platform_device *pdev_capture, *pdev_display; struct device_node *endpoint =3D NULL; + struct vpif_data *data; int ret; =20 res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -435,6 +448,12 @@ static int vpif_probe(struct platform_device *pdev) if (IS_ERR(vpif_base)) return PTR_ERR(vpif_base); =20 + data =3D kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + platform_set_drvdata(pdev, data); + pm_runtime_enable(&pdev->dev); pm_runtime_get(&pdev->dev); =20 @@ -462,49 +481,75 @@ static int vpif_probe(struct platform_device *pdev) goto err_put_rpm; } =20 - pdev_capture =3D devm_kzalloc(&pdev->dev, sizeof(*pdev_capture), - GFP_KERNEL); - if (pdev_capture) { - pdev_capture->name =3D "vpif_capture"; - pdev_capture->id =3D -1; - pdev_capture->resource =3D res_irq; - pdev_capture->num_resources =3D 1; - pdev_capture->dev.dma_mask =3D pdev->dev.dma_mask; - pdev_capture->dev.coherent_dma_mask =3D pdev->dev.coherent_dma_mask; - pdev_capture->dev.parent =3D &pdev->dev; - platform_device_register(pdev_capture); - } else { - dev_warn(&pdev->dev, "Unable to allocate memory for pdev_capture.\n"); + pdev_capture =3D kzalloc(sizeof(*pdev_capture), GFP_KERNEL); + if (!pdev_capture) { + ret =3D -ENOMEM; + goto err_put_rpm; } =20 - pdev_display =3D devm_kzalloc(&pdev->dev, sizeof(*pdev_display), - GFP_KERNEL); - if (pdev_display) { - pdev_display->name =3D "vpif_display"; - pdev_display->id =3D -1; - pdev_display->resource =3D res_irq; - pdev_display->num_resources =3D 1; - pdev_display->dev.dma_mask =3D pdev->dev.dma_mask; - pdev_display->dev.coherent_dma_mask =3D pdev->dev.coherent_dma_mask; - pdev_display->dev.parent =3D &pdev->dev; - platform_device_register(pdev_display); - } else { - dev_warn(&pdev->dev, "Unable to allocate memory for pdev_display.\n"); + pdev_capture->name =3D "vpif_capture"; + pdev_capture->id =3D -1; + pdev_capture->resource =3D res_irq; + pdev_capture->num_resources =3D 1; + pdev_capture->dev.dma_mask =3D pdev->dev.dma_mask; + pdev_capture->dev.coherent_dma_mask =3D pdev->dev.coherent_dma_mask; + pdev_capture->dev.parent =3D &pdev->dev; + pdev_capture->dev.release =3D vpif_pdev_release; + + ret =3D platform_device_register(pdev_capture); + if (ret) + goto err_put_pdev_capture; + + pdev_display =3D kzalloc(sizeof(*pdev_display), GFP_KERNEL); + if (!pdev_display) { + ret =3D -ENOMEM; + goto err_put_pdev_capture; } =20 + pdev_display->name =3D "vpif_display"; + pdev_display->id =3D -1; + pdev_display->resource =3D res_irq; + pdev_display->num_resources =3D 1; + pdev_display->dev.dma_mask =3D pdev->dev.dma_mask; + pdev_display->dev.coherent_dma_mask =3D pdev->dev.coherent_dma_mask; + pdev_display->dev.parent =3D &pdev->dev; + pdev_display->dev.release =3D vpif_pdev_release; + + ret =3D platform_device_register(pdev_display); + if (ret) + goto err_put_pdev_display; + + data->capture =3D pdev_capture; + data->display =3D pdev_display; + return 0; =20 +err_put_pdev_display: + platform_device_put(pdev_display); +err_put_pdev_capture: + platform_device_put(pdev_capture); err_put_rpm: pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); + kfree(data); =20 return ret; } =20 static int vpif_remove(struct platform_device *pdev) { + struct vpif_data *data =3D platform_get_drvdata(pdev); + + if (data->capture) + platform_device_unregister(data->capture); + if (data->display) + platform_device_unregister(data->display); + pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); + + kfree(data); + return 0; } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 C2B67C43334 for ; Mon, 11 Jul 2022 09:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233525AbiGKJqi (ORCPT ); Mon, 11 Jul 2022 05:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233867AbiGKJpF (ORCPT ); Mon, 11 Jul 2022 05:45: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 EBB1FA9E6C; Mon, 11 Jul 2022 02:22: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 E7D70B80E7F; Mon, 11 Jul 2022 09:22:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43DD2C34115; Mon, 11 Jul 2022 09:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531349; bh=0gd7H/PDn7gfPt/8kA00oAnxY4DvAvEYKewAvbpW1YY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZETOW1JJ0uC+hc+2IriwVYeB09jHCZKoPPhJSZeVrQKL04c2RNoHimIObTEfzZrF maarvdc/yzOhPfaY1cRorPZQ9tmt6BaT9TPmtHP8r3xAj3oD1tK/lto5ZT0YIBU4OQ 7KMWZ+S9g1APlSbjFUdafcOmOIT5ehLe7CUoCg3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Wang , Felix Fietkau , Sasha Levin Subject: [PATCH 5.15 073/230] mt76: mt76_connac: fix MCU_CE_CMD_SET_ROC definition error Date: Mon, 11 Jul 2022 11:05:29 +0200 Message-Id: <20220711090606.147920434@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Wang [ Upstream commit bf9727a27442a50c75b7d99a5088330c578b2a42 ] Fixed an MCU_CE_CMD_SET_ROC definition error that occurred from a previous refactor work. Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library") Signed-off-by: Sean Wang Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers= /net/wireless/mediatek/mt76/mt76_connac_mcu.h index 77d4435e4581..72a70a7046fb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -556,7 +556,7 @@ enum { MCU_CMD_SET_BSS_CONNECTED =3D MCU_CE_PREFIX | 0x16, MCU_CMD_SET_BSS_ABORT =3D MCU_CE_PREFIX | 0x17, MCU_CMD_CANCEL_HW_SCAN =3D MCU_CE_PREFIX | 0x1b, - MCU_CMD_SET_ROC =3D MCU_CE_PREFIX | 0x1d, + MCU_CMD_SET_ROC =3D MCU_CE_PREFIX | 0x1c, MCU_CMD_SET_P2P_OPPPS =3D MCU_CE_PREFIX | 0x33, MCU_CMD_SET_RATE_TX_POWER =3D MCU_CE_PREFIX | 0x5d, MCU_CMD_SCHED_SCAN_ENABLE =3D MCU_CE_PREFIX | 0x61, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 4CB71C433EF for ; Mon, 11 Jul 2022 09:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbiGKJqq (ORCPT ); Mon, 11 Jul 2022 05:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233903AbiGKJpI (ORCPT ); Mon, 11 Jul 2022 05:45:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D193599C6; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id A1334612B7; Mon, 11 Jul 2022 09:22:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE153C34115; Mon, 11 Jul 2022 09:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531355; bh=ibPMo5ETyDCzk+1MyI+Rq7SjNwIpy1QqCC3YTqmPCyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A6TsF78SRTRePvCtn0nteNW/SmwmfCK1flXwwcCOwMRpZoUcOAdwfePY+a5kciGGi nnAxvrcBdiH34rjE3X21fftE/LJfZrEPSI2z19yeIvipizJOqjD+NOSEZTYSS5aKWY xafLFz0ebtTBRjvx8TpSsdbunqBJ/YEqc3P+CwAI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.15 074/230] mt76: mt7921: do not always disable fw runtime-pm Date: Mon, 11 Jul 2022 11:05:30 +0200 Message-Id: <20220711090606.175784253@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lorenzo Bianconi [ Upstream commit b44eeb8cbdf2b88f2844f11e4f263b0abed5b5b0 ] After commit 'd430dffbe9dd ("mt76: mt7921: fix a possible race enabling/disabling runtime-pm")', runtime-pm is always disabled in the fw even if the user requests to enable it toggling debugfs node since mt7921_pm_interface_iter routine will use pm->enable to configure the fw. Fix the issue moving enable variable configuration before running mt7921_pm_interface_iter routine. Fixes: d430dffbe9dd ("mt76: mt7921: fix a possible race enabling/disabling = runtime-pm") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/= net/wireless/mediatek/mt76/mt7921/debugfs.c index b9f25599227d..cfcf7964c688 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -291,13 +291,12 @@ mt7921_pm_set(void *data, u64 val) pm->enable =3D false; mt76_connac_pm_wake(&dev->mphy, pm); =20 + pm->enable =3D val; ieee80211_iterate_active_interfaces(mt76_hw(dev), IEEE80211_IFACE_ITER_RESUME_ALL, mt7921_pm_interface_iter, dev); =20 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); - - pm->enable =3D val; mt76_connac_power_save_sched(&dev->mphy, pm); out: mutex_unlock(&dev->mt76.mutex); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 2AF1FC433EF for ; Mon, 11 Jul 2022 09:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233094AbiGKJqz (ORCPT ); Mon, 11 Jul 2022 05:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiGKJpO (ORCPT ); Mon, 11 Jul 2022 05:45:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 538B5AA80B; Mon, 11 Jul 2022 02:22:40 -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 15C43B80E7A; Mon, 11 Jul 2022 09:22:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 686B0C341C0; Mon, 11 Jul 2022 09:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531357; bh=5GKi10fYzc4JmM1MLGEA0EUW50eoSbUpV1U2MXuatIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ogOJopdY1x63jsWQByNVJAqaw8HaijlInPOhWsP7a4Hc48NzMCED3301W/bqDAp5H VWXP5dxtNC21ZSLuyfz+vfi5aya2c9D91ZsElWaPdPc7EkvbDUIREbw2WuOCObchz9 WqqBCvHibqkU46kNuqA2EYbPdie6blIMaf9uuJQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Widawsky , Dan Williams , Sasha Levin Subject: [PATCH 5.15 075/230] cxl/port: Hold port reference until decoder release Date: Mon, 11 Jul 2022 11:05:31 +0200 Message-Id: <20220711090606.203801610@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dan Williams [ Upstream commit 74be98774dfbc5b8b795db726bd772e735d2edd4 ] KASAN + DEBUG_KOBJECT_RELEASE reports a potential use-after-free in cxl_decoder_release() where it goes to reference its parent, a cxl_port, to free its id back to port->decoder_ida. BUG: KASAN: use-after-free in to_cxl_port+0x18/0x90 [cxl_core] Read of size 8 at addr ffff888119270908 by task kworker/35:2/379 CPU: 35 PID: 379 Comm: kworker/35:2 Tainted: G OE 5.17.0-rc2= + #198 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 Workqueue: events kobject_delayed_cleanup Call Trace: dump_stack_lvl+0x59/0x73 print_address_description.constprop.0+0x1f/0x150 ? to_cxl_port+0x18/0x90 [cxl_core] kasan_report.cold+0x83/0xdf ? to_cxl_port+0x18/0x90 [cxl_core] to_cxl_port+0x18/0x90 [cxl_core] cxl_decoder_release+0x2a/0x60 [cxl_core] device_release+0x5f/0x100 kobject_cleanup+0x80/0x1c0 The device core only guarantees parent lifetime until all children are unregistered. If a child needs a parent to complete its ->release() callback that child needs to hold a reference to extend the lifetime of the parent. Fixes: 40ba17afdfab ("cxl/acpi: Introduce cxl_decoder objects") Reported-by: Ben Widawsky Tested-by: Ben Widawsky Reviewed-by: Ben Widawsky Link: https://lore.kernel.org/r/164505751190.4175768.13324905271463416712.s= tgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/cxl/core/bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/cxl/core/bus.c b/drivers/cxl/core/bus.c index 267d8042bec2..0987a6423ee0 100644 --- a/drivers/cxl/core/bus.c +++ b/drivers/cxl/core/bus.c @@ -182,6 +182,7 @@ static void cxl_decoder_release(struct device *dev) =20 ida_free(&port->decoder_ida, cxld->id); kfree(cxld); + put_device(&port->dev); } =20 static const struct device_type cxl_decoder_switch_type =3D { @@ -481,6 +482,9 @@ cxl_decoder_alloc(struct cxl_port *port, int nr_targets= , resource_size_t base, if (rc < 0) goto err; =20 + /* need parent to stick around to release the id */ + get_device(&port->dev); + *cxld =3D (struct cxl_decoder) { .id =3D rc, .range =3D { --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 7355FC43334 for ; Mon, 11 Jul 2022 09:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233425AbiGKJq6 (ORCPT ); Mon, 11 Jul 2022 05:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbiGKJpQ (ORCPT ); Mon, 11 Jul 2022 05:45:16 -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 2876A5A459; Mon, 11 Jul 2022 02:22:43 -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 DA6F6B80D2C; Mon, 11 Jul 2022 09:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42C03C341C0; Mon, 11 Jul 2022 09:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531360; bh=ZRKOWlgp3/1UmGe8prm69u5KOFkQi/fYa9/rSwmn2Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJWP9/ECfT7CYL9yPwAzA5xj6i+u66CeNXd92EzVfcii4/SoLUtvMDRctLNUnWhDH EaiT/KD23P2ZuuwhjP65O08iTZIg9PivdStlY0q+9frxt5Do+zR6abFpTTBbvdpw73 AkmRTiwAwfi2yS9roXiE2+czf6N8qDbe9EwtMJmk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Biju Das , Lad Prabhakar , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 5.15 076/230] clk: renesas: r9a07g044: Update multiplier and divider values for PLL2/3 Date: Mon, 11 Jul 2022 11:05:32 +0200 Message-Id: <20220711090606.232816891@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lad Prabhakar [ Upstream commit b289cdecc7c3e25e001cde260c882e4d9a8b0772 ] As per the HW manual (Rev.1.00 Sep, 2021) PLL2 and PLL3 should be 1600 MHz, but with current multiplier and divider values this resulted to 1596 MHz. This patch updates the multiplier and divider values for PLL2 and PLL3 so that we get the exact (1600 MHz) values. Fixes: 17f0ff3d49ff1 ("clk: renesas: Add support for R9A07G044 SoC") Suggested-by: Biju Das Signed-off-by: Lad Prabhakar Link: https://lore.kernel.org/r/20211223093223.4725-1-prabhakar.mahadev-lad= .rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/clk/renesas/r9a07g044-cpg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/renesas/r9a07g044-cpg.c b/drivers/clk/renesas/r9a0= 7g044-cpg.c index 1490446985e2..61609eddf7d0 100644 --- a/drivers/clk/renesas/r9a07g044-cpg.c +++ b/drivers/clk/renesas/r9a07g044-cpg.c @@ -61,8 +61,8 @@ static const struct cpg_core_clk r9a07g044_core_clks[] __= initconst =3D { DEF_FIXED(".osc", R9A07G044_OSCCLK, CLK_EXTAL, 1, 1), DEF_FIXED(".osc_div1000", CLK_OSC_DIV1000, CLK_EXTAL, 1, 1000), DEF_SAMPLL(".pll1", CLK_PLL1, CLK_EXTAL, PLL146_CONF(0)), - DEF_FIXED(".pll2", CLK_PLL2, CLK_EXTAL, 133, 2), - DEF_FIXED(".pll3", CLK_PLL3, CLK_EXTAL, 133, 2), + DEF_FIXED(".pll2", CLK_PLL2, CLK_EXTAL, 200, 3), + DEF_FIXED(".pll3", CLK_PLL3, CLK_EXTAL, 200, 3), =20 DEF_FIXED(".pll2_div2", CLK_PLL2_DIV2, CLK_PLL2, 1, 2), DEF_FIXED(".pll2_div16", CLK_PLL2_DIV16, CLK_PLL2, 1, 16), --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 DD07ACCA480 for ; Mon, 11 Jul 2022 09:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233592AbiGKJrG (ORCPT ); Mon, 11 Jul 2022 05:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbiGKJpm (ORCPT ); Mon, 11 Jul 2022 05:45:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC305A465; Mon, 11 Jul 2022 02:22:46 -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 A6C87B80E6D; Mon, 11 Jul 2022 09:22:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 081A6C34115; Mon, 11 Jul 2022 09:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531363; bh=8uvwMb3IGS1bUx9nzsZ+AkD+tb8VskWdxw5l4vTVUAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imq7p3Ez4lSzNn8NqcyyC6UKXCR+1tShUXUrUxNNgJtLuNPf43Fph3yxbakXYe25W B3oAyEhwEsV+mybFT89dnrF1g4kgJjjY5iD/pjCDDt7TS5oU5fBd0g+W7ffEpAqWsa Fkbx0rBKhF/L9IqU+0vzUaVuzt7Cze5Ysb4rkdx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 077/230] KVM: x86/mmu: Use yield-safe TDP MMU root iter in MMU notifier unmapping Date: Mon, 11 Jul 2022 11:05:33 +0200 Message-Id: <20220711090606.260747828@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Christopherson [ Upstream commit 7533377215b6ee432c06c5855f6be5d66e694e46 ] Use the yield-safe variant of the TDP MMU iterator when handling an unmapping event from the MMU notifier, as most occurences of the event allow yielding. Fixes: e1eed5847b09 ("KVM: x86/mmu: Allow yielding during MMU notifier unma= p/zap, if possible") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20211120015008.3780032-1-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/x86/kvm/mmu/tdp_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 853780eb033b..6195f0d219ae 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1100,7 +1100,7 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, str= uct kvm_gfn_range *range, { struct kvm_mmu_page *root; =20 - for_each_tdp_mmu_root(kvm, root, range->slot->as_id) + for_each_tdp_mmu_root_yield_safe(kvm, root, range->slot->as_id, false) flush =3D zap_gfn_range(kvm, root, range->start, range->end, range->may_block, flush, false); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E6B2CC43334 for ; Mon, 11 Jul 2022 09:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233477AbiGKJrI (ORCPT ); Mon, 11 Jul 2022 05:47:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233450AbiGKJpn (ORCPT ); Mon, 11 Jul 2022 05:45:43 -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 2A99F5B066; Mon, 11 Jul 2022 02:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id B5794612B7; Mon, 11 Jul 2022 09:22:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0A43C341C0; Mon, 11 Jul 2022 09:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531366; bh=nfsbR7Y7htdB02SDzWP5iMuEXlgHu7ikm6QeoB55DHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDV6j08/UV01a848EjvFf2ZklchGIyOhecrQafH8Uy4lCnHOk3+OM4p04BnpgwHTe BZaX3SRI0RLGunOeoaRX3xWaiy5GA96MyZgT/F8BvGhJrf8oHbaXGOES4xHspU/22b ZuyvaQLByQI1kOISWAjyIwPScYIh+BfATF5/5DU4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 078/230] KVM: x86/mmu: Use common TDP MMU zap helper for MMU notifier unmap hook Date: Mon, 11 Jul 2022 11:05:34 +0200 Message-Id: <20220711090606.288998183@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Christopherson [ Upstream commit 83b83a02073ec8d18c77a9bbe0881d710f7a9d32 ] Use the common TDP MMU zap helper when handling an MMU notifier unmap event, the two flows are semantically identical. Consolidate the code in preparation for a future bug fix, as both kvm_tdp_mmu_unmap_gfn_range() and __kvm_tdp_mmu_zap_gfn_range() are guilty of not zapping SPTEs in invalid roots. No functional change intended. Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20211215011557.399940-2-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/x86/kvm/mmu/tdp_mmu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 6195f0d219ae..6c2bb60ccd88 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1098,13 +1098,8 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa= , u32 error_code, bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *ra= nge, bool flush) { - struct kvm_mmu_page *root; - - for_each_tdp_mmu_root_yield_safe(kvm, root, range->slot->as_id, false) - flush =3D zap_gfn_range(kvm, root, range->start, range->end, - range->may_block, flush, false); - - return flush; + return __kvm_tdp_mmu_zap_gfn_range(kvm, range->slot->as_id, range->start, + range->end, range->may_block, flush); } =20 typedef bool (*tdp_handler_t)(struct kvm *kvm, struct tdp_iter *iter, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E1ADCCCA47B for ; Mon, 11 Jul 2022 09:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233606AbiGKJrU (ORCPT ); Mon, 11 Jul 2022 05:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbiGKJql (ORCPT ); Mon, 11 Jul 2022 05:46:41 -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 EF5ADAA835; Mon, 11 Jul 2022 02:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 31A78B80E6D; Mon, 11 Jul 2022 09:22:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DC1CC34115; Mon, 11 Jul 2022 09:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531368; bh=98xabKMvFokdJSYWZLW9SiiH3AuKJZ1xJ1jKU4viRX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yCiKSR7LSM4dvh6LQRGOsMRnLxYNp1kGbULlH+sxFqpF85bHAP2+tGEv6D5VGAU4x i3Ya/fG8cUKE2jSMH+F+FvQe+PWhnQSaQVabjHMtsZjMVoM1T55ZQzi/JYU4koq4rk kRtpQA8PSWSTg8nNeHA+rmU+KR2t0Zk022XRORaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Manish Rangankar , Nilesh Javali , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 079/230] scsi: qla2xxx: Move heartbeat handling from DPC thread to workqueue Date: Mon, 11 Jul 2022 11:05:35 +0200 Message-Id: <20220711090606.317951304@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Manish Rangankar [ Upstream commit 3a4e1f3b3a3c733de3b82b9b522e54803e1165ae ] DPC thread gets restricted due to a no-op mailbox, which is a blocking call and has a high execution frequency. To free up the DPC thread we move no-op handling to the workqueue. Also, modified qla_do_heartbeat() to send no-op MBC if we don=E2=80=99t have any active interrupts, but there are still I/Os outstanding with firmware. Link: https://lore.kernel.org/r/20210908164622.19240-9-njavali@marvell.com Fixes: d94d8158e184 ("scsi: qla2xxx: Add heartbeat check") Reviewed-by: Himanshu Madhani Signed-off-by: Manish Rangankar Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/scsi/qla2xxx/qla_def.h | 4 +- drivers/scsi/qla2xxx/qla_init.c | 2 + drivers/scsi/qla2xxx/qla_os.c | 78 +++++++++++++++------------------ 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 2ea35e47ea44..0589ab8e6467 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3759,6 +3759,7 @@ struct qla_qpair { struct qla_fw_resources fwres ____cacheline_aligned; u32 cmd_cnt; u32 cmd_completion_cnt; + u32 prev_completion_cnt; }; =20 /* Place holder for FW buffer parameters */ @@ -4618,6 +4619,7 @@ struct qla_hw_data { struct qla_chip_state_84xx *cs84xx; struct isp_operations *isp_ops; struct workqueue_struct *wq; + struct work_struct heartbeat_work; struct qlfc_fw fw_buf; =20 /* FCP_CMND priority support */ @@ -4719,7 +4721,6 @@ struct qla_hw_data { =20 struct qla_hw_data_stat stat; pci_error_state_t pci_error_state; - u64 prev_cmd_cnt; struct dma_pool *purex_dma_pool; struct btree_head32 host_map; =20 @@ -4865,7 +4866,6 @@ typedef struct scsi_qla_host { #define SET_ZIO_THRESHOLD_NEEDED 32 #define ISP_ABORT_TO_ROM 33 #define VPORT_DELETE 34 -#define HEARTBEAT_CHK 38 =20 #define PROCESS_PUREX_IOCB 63 =20 diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_ini= t.c index af8df5a800c6..c3ba2995209b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -7096,12 +7096,14 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) ha->chip_reset++; ha->base_qpair->chip_reset =3D ha->chip_reset; ha->base_qpair->cmd_cnt =3D ha->base_qpair->cmd_completion_cnt =3D 0; + ha->base_qpair->prev_completion_cnt =3D 0; for (i =3D 0; i < ha->max_qpairs; i++) { if (ha->queue_pair_map[i]) { ha->queue_pair_map[i]->chip_reset =3D ha->base_qpair->chip_reset; ha->queue_pair_map[i]->cmd_cnt =3D ha->queue_pair_map[i]->cmd_completion_cnt =3D 0; + ha->base_qpair->prev_completion_cnt =3D 0; } } =20 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 77c0bf06f162..b224326bacee 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2779,6 +2779,16 @@ qla2xxx_scan_finished(struct Scsi_Host *shost, unsig= ned long time) return atomic_read(&vha->loop_state) =3D=3D LOOP_READY; } =20 +static void qla_heartbeat_work_fn(struct work_struct *work) +{ + struct qla_hw_data *ha =3D container_of(work, + struct qla_hw_data, heartbeat_work); + struct scsi_qla_host *base_vha =3D pci_get_drvdata(ha->pdev); + + if (!ha->flags.mbox_busy && base_vha->flags.init_done) + qla_no_op_mb(base_vha); +} + static void qla2x00_iocb_work_fn(struct work_struct *work) { struct scsi_qla_host *vha =3D container_of(work, @@ -3217,6 +3227,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct = pci_device_id *id) host->transportt, sht->vendor_id); =20 INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); + INIT_WORK(&ha->heartbeat_work, qla_heartbeat_work_fn); =20 /* Set up the irqs */ ret =3D qla2x00_request_irqs(ha, rsp); @@ -7103,17 +7114,6 @@ qla2x00_do_dpc(void *data) qla2x00_lip_reset(base_vha); } =20 - if (test_bit(HEARTBEAT_CHK, &base_vha->dpc_flags)) { - /* - * if there is a mb in progress then that's - * enough of a check to see if fw is still ticking. - */ - if (!ha->flags.mbox_busy && base_vha->flags.init_done) - qla_no_op_mb(base_vha); - - clear_bit(HEARTBEAT_CHK, &base_vha->dpc_flags); - } - ha->dpc_active =3D 0; end_loop: set_current_state(TASK_INTERRUPTIBLE); @@ -7172,57 +7172,51 @@ qla2x00_rst_aen(scsi_qla_host_t *vha) =20 static bool qla_do_heartbeat(struct scsi_qla_host *vha) { - u64 cmd_cnt, prev_cmd_cnt; - bool do_hb =3D false; struct qla_hw_data *ha =3D vha->hw; - int i; + u32 cmpl_cnt; + u16 i; + bool do_heartbeat =3D false; =20 - /* if cmds are still pending down in fw, then do hb */ - if (ha->base_qpair->cmd_cnt !=3D ha->base_qpair->cmd_completion_cnt) { - do_hb =3D true; + /* + * Allow do_heartbeat only if we don=E2=80=99t have any active interrupts, + * but there are still IOs outstanding with firmware. + */ + cmpl_cnt =3D ha->base_qpair->cmd_completion_cnt; + if (cmpl_cnt =3D=3D ha->base_qpair->prev_completion_cnt && + cmpl_cnt !=3D ha->base_qpair->cmd_cnt) { + do_heartbeat =3D true; goto skip; } + ha->base_qpair->prev_completion_cnt =3D cmpl_cnt; =20 for (i =3D 0; i < ha->max_qpairs; i++) { - if (ha->queue_pair_map[i] && - ha->queue_pair_map[i]->cmd_cnt !=3D - ha->queue_pair_map[i]->cmd_completion_cnt) { - do_hb =3D true; - break; + if (ha->queue_pair_map[i]) { + cmpl_cnt =3D ha->queue_pair_map[i]->cmd_completion_cnt; + if (cmpl_cnt =3D=3D ha->queue_pair_map[i]->prev_completion_cnt && + cmpl_cnt !=3D ha->queue_pair_map[i]->cmd_cnt) { + do_heartbeat =3D true; + break; + } + ha->queue_pair_map[i]->prev_completion_cnt =3D cmpl_cnt; } } =20 skip: - prev_cmd_cnt =3D ha->prev_cmd_cnt; - cmd_cnt =3D ha->base_qpair->cmd_cnt; - for (i =3D 0; i < ha->max_qpairs; i++) { - if (ha->queue_pair_map[i]) - cmd_cnt +=3D ha->queue_pair_map[i]->cmd_cnt; - } - ha->prev_cmd_cnt =3D cmd_cnt; - - if (!do_hb && ((cmd_cnt - prev_cmd_cnt) > 50)) - /* - * IOs are completing before periodic hb check. - * IOs seems to be running, do hb for sanity check. - */ - do_hb =3D true; - - return do_hb; + return do_heartbeat; } =20 static void qla_heart_beat(struct scsi_qla_host *vha) { + struct qla_hw_data *ha =3D vha->hw; + if (vha->vp_idx) return; =20 if (vha->hw->flags.eeh_busy || qla2x00_chip_is_down(vha)) return; =20 - if (qla_do_heartbeat(vha)) { - set_bit(HEARTBEAT_CHK, &vha->dpc_flags); - qla2xxx_wake_dpc(vha); - } + if (qla_do_heartbeat(vha)) + queue_work(ha->wq, &ha->heartbeat_work); } =20 /************************************************************************** --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 4976BC433EF for ; Mon, 11 Jul 2022 09:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233568AbiGKJrY (ORCPT ); Mon, 11 Jul 2022 05:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233561AbiGKJqr (ORCPT ); Mon, 11 Jul 2022 05:46:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEEE7AA839; Mon, 11 Jul 2022 02:22: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 3246861363; Mon, 11 Jul 2022 09:22:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44279C341CE; Mon, 11 Jul 2022 09:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531371; bh=472lZAJbgmvRdN1CwPSC6F/zqCZdJ5jdrQ+tHuhEiMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tzLYhUYapY6/408rqQ6FsTwwg9ebSUwJdPtfFuatoS1/oHe1X8X1kIBTSnucN0ZXH qxWSJCGsLkeza5sOoKoPovFVRRi46Hg/fG7deCV5Pni9gR9B5CNakaeBTU9NQPIUOo tEnu4N2zhaBaYcWtFA7gckqqV0zurpT6xOZhP/w0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Quinn Tran , Nilesh Javali , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 080/230] scsi: qla2xxx: Fix laggy FC remote port session recovery Date: Mon, 11 Jul 2022 11:05:36 +0200 Message-Id: <20220711090606.345572573@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Quinn Tran [ Upstream commit 713b415726f100f6644971e75ebfe1edbef1a390 ] For session recovery, driver relies on the dpc thread to initiate certain operations. The dpc thread runs exclusively without the Mailbox interface being occupied. A recent code change for heartbeat check via mailbox cmd 0 is preventing the dpc thread from carrying out its operation. This patch allows the higher priority error recovery to run first before running the lower priority heartbeat check. Link: https://lore.kernel.org/r/20220310092604.22950-9-njavali@marvell.com Fixes: d94d8158e184 ("scsi: qla2xxx: Add heartbeat check") Cc: stable@vger.kernel.org Reviewed-by: Himanshu Madhani Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_os.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 0589ab8e6467..303ad60d1d49 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -4621,6 +4621,7 @@ struct qla_hw_data { struct workqueue_struct *wq; struct work_struct heartbeat_work; struct qlfc_fw fw_buf; + unsigned long last_heartbeat_run_jiffies; =20 /* FCP_CMND priority support */ struct qla_fcp_prio_cfg *fcp_prio_cfg; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b224326bacee..12958aea893f 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -7205,7 +7205,7 @@ static bool qla_do_heartbeat(struct scsi_qla_host *vh= a) return do_heartbeat; } =20 -static void qla_heart_beat(struct scsi_qla_host *vha) +static void qla_heart_beat(struct scsi_qla_host *vha, u16 dpc_started) { struct qla_hw_data *ha =3D vha->hw; =20 @@ -7215,8 +7215,19 @@ static void qla_heart_beat(struct scsi_qla_host *vha) if (vha->hw->flags.eeh_busy || qla2x00_chip_is_down(vha)) return; =20 - if (qla_do_heartbeat(vha)) + /* + * dpc thread cannot run if heartbeat is running at the same time. + * We also do not want to starve heartbeat task. Therefore, do + * heartbeat task at least once every 5 seconds. + */ + if (dpc_started && + time_before(jiffies, ha->last_heartbeat_run_jiffies + 5 * HZ)) + return; + + if (qla_do_heartbeat(vha)) { + ha->last_heartbeat_run_jiffies =3D jiffies; queue_work(ha->wq, &ha->heartbeat_work); + } } =20 /************************************************************************** @@ -7407,6 +7418,8 @@ qla2x00_timer(struct timer_list *t) start_dpc++; } =20 + /* borrowing w to signify dpc will run */ + w =3D 0; /* Schedule the DPC routine if needed */ if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || @@ -7439,9 +7452,10 @@ qla2x00_timer(struct timer_list *t) test_bit(RELOGIN_NEEDED, &vha->dpc_flags), test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags)); qla2xxx_wake_dpc(vha); + w =3D 1; } =20 - qla_heart_beat(vha); + qla_heart_beat(vha, w); =20 qla2x00_restart_timer(vha, WATCH_INTERVAL); } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 9AD76CCA47B for ; Mon, 11 Jul 2022 09:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233587AbiGKJrg (ORCPT ); Mon, 11 Jul 2022 05:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233585AbiGKJq5 (ORCPT ); Mon, 11 Jul 2022 05:46:57 -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 4D6C85B78C; Mon, 11 Jul 2022 02:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 9E77FB80D2C; Mon, 11 Jul 2022 09:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ACFAC34115; Mon, 11 Jul 2022 09:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531374; bh=1TdSlce/DgVKTiZFs1xju2C/eht7mNg9T9nlCWRVF2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tscylTCJeHN199kxL4zLEiZ9ZnfoVfd2U0q8zHFpKAjAOzMxEvszO4EmQxxEVEZCL 4TSBKvXsvzXyNzZSzS6I8Y48sU45Kqog/6c8Jw4INyt9SoayfRqKZJuQNtBWQ4Ui9u lchFF2siYuFcUFe1G3vLNkYZH/o2tXfDiCfQXng8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Himanshu Madhani , Quinn Tran , Nilesh Javali , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 081/230] scsi: qla2xxx: edif: Replace list_for_each_safe with list_for_each_entry_safe Date: Mon, 11 Jul 2022 11:05:37 +0200 Message-Id: <20220711090606.373547731@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Quinn Tran [ Upstream commit 8062b742d3bd336ca10ab5a1db1629d33700f9c6 ] This patch is per review comment by Hannes Reinecke from previous submission to replace list_for_each_safe with list_for_each_entry_safe. Link: https://lore.kernel.org/r/20211026115412.27691-8-njavali@marvell.com Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/scsi/qla2xxx/qla_edif.c | 39 ++++++++------------------------- drivers/scsi/qla2xxx/qla_edif.h | 1 - drivers/scsi/qla2xxx/qla_os.c | 8 +++---- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edi= f.c index a00fe88c6021..e40b9cc38214 100644 --- a/drivers/scsi/qla2xxx/qla_edif.c +++ b/drivers/scsi/qla2xxx/qla_edif.c @@ -1684,41 +1684,25 @@ static struct enode * qla_enode_find(scsi_qla_host_t *vha, uint32_t ntype, uint32_t p1, uint32_t= p2) { struct enode *node_rtn =3D NULL; - struct enode *list_node =3D NULL; + struct enode *list_node, *q; unsigned long flags; - struct list_head *pos, *q; uint32_t sid; - uint32_t rw_flag; struct purexevent *purex; =20 /* secure the list from moving under us */ spin_lock_irqsave(&vha->pur_cinfo.pur_lock, flags); =20 - list_for_each_safe(pos, q, &vha->pur_cinfo.head) { - list_node =3D list_entry(pos, struct enode, list); + list_for_each_entry_safe(list_node, q, &vha->pur_cinfo.head, list) { =20 /* node type determines what p1 and p2 are */ purex =3D &list_node->u.purexinfo; sid =3D p1; - rw_flag =3D p2; =20 if (purex->pur_info.pur_sid.b24 =3D=3D sid) { - if (purex->pur_info.pur_pend =3D=3D 1 && - rw_flag =3D=3D PUR_GET) { - /* - * if the receive is in progress - * and its a read/get then can't - * transfer yet - */ - ql_dbg(ql_dbg_edif, vha, 0x9106, - "%s purex xfer in progress for sid=3D%x\n", - __func__, sid); - } else { - /* found it and its complete */ - node_rtn =3D list_node; - list_del(pos); - break; - } + /* found it and its complete */ + node_rtn =3D list_node; + list_del(&list_node->list); + break; } } =20 @@ -2428,7 +2412,6 @@ void qla24xx_auth_els(scsi_qla_host_t *vha, void **pk= t, struct rsp_que **rsp) =20 purex =3D &ptr->u.purexinfo; purex->pur_info.pur_sid =3D a.did; - purex->pur_info.pur_pend =3D 0; purex->pur_info.pur_bytes_rcvd =3D totlen; purex->pur_info.pur_rx_xchg_address =3D le32_to_cpu(p->rx_xchg_addr); purex->pur_info.pur_nphdl =3D le16_to_cpu(p->nport_handle); @@ -3180,18 +3163,14 @@ static uint16_t qla_edif_sadb_get_sa_index(fc_port_= t *fcport, /* release any sadb entries -- only done at teardown */ void qla_edif_sadb_release(struct qla_hw_data *ha) { - struct list_head *pos; - struct list_head *tmp; - struct edif_sa_index_entry *entry; + struct edif_sa_index_entry *entry, *tmp; =20 - list_for_each_safe(pos, tmp, &ha->sadb_rx_index_list) { - entry =3D list_entry(pos, struct edif_sa_index_entry, next); + list_for_each_entry_safe(entry, tmp, &ha->sadb_rx_index_list, next) { list_del(&entry->next); kfree(entry); } =20 - list_for_each_safe(pos, tmp, &ha->sadb_tx_index_list) { - entry =3D list_entry(pos, struct edif_sa_index_entry, next); + list_for_each_entry_safe(entry, tmp, &ha->sadb_tx_index_list, next) { list_del(&entry->next); kfree(entry); } diff --git a/drivers/scsi/qla2xxx/qla_edif.h b/drivers/scsi/qla2xxx/qla_edi= f.h index 45cf87e33778..32800bfb32a3 100644 --- a/drivers/scsi/qla2xxx/qla_edif.h +++ b/drivers/scsi/qla2xxx/qla_edif.h @@ -101,7 +101,6 @@ struct dinfo { }; =20 struct pur_ninfo { - unsigned int pur_pend:1; port_id_t pur_sid; port_id_t pur_did; uint8_t vp_idx; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 12958aea893f..c7ab8a8be24c 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3886,13 +3886,13 @@ qla2x00_remove_one(struct pci_dev *pdev) static inline void qla24xx_free_purex_list(struct purex_list *list) { - struct list_head *item, *next; + struct purex_item *item, *next; ulong flags; =20 spin_lock_irqsave(&list->lock, flags); - list_for_each_safe(item, next, &list->head) { - list_del(item); - kfree(list_entry(item, struct purex_item, list)); + list_for_each_entry_safe(item, next, &list->head, list) { + list_del(&item->list); + kfree(item); } spin_unlock_irqrestore(&list->lock, flags); } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 111E2C433EF for ; Mon, 11 Jul 2022 09:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233630AbiGKJrj (ORCPT ); Mon, 11 Jul 2022 05:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiGKJrH (ORCPT ); Mon, 11 Jul 2022 05:47:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4E55C350; Mon, 11 Jul 2022 02:22:59 -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 5CDDFB80E6D; Mon, 11 Jul 2022 09:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3DD5C341C0; Mon, 11 Jul 2022 09:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531377; bh=vKDipy7cGgRrRs2S/HoIY0V0cYNgIWXkWEb8VzIflQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUGCKluYr0Mo6ON//6LWm2ogJmmShmePi91QXjrToI6OinHz3XmYr7S48oc4ovT0a 7Dr846TVH13FjA021OUh2DlY8MczIgDAjB3D+ZJbBhv17GGDqoc5dssEIJnrXxwOJs DPDBYlQJYno1BuSS6KqRxQ/ZrbYRjUixTczj4gfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Patalano , Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 082/230] scsi: qla2xxx: Fix crash during module load unload test Date: Mon, 11 Jul 2022 11:05:38 +0200 Message-Id: <20220711090606.401106281@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Arun Easi [ Upstream commit 0972252450f90db56dd5415a20e2aec21a08d036 ] During purex packet handling the driver was incorrectly freeing a pre-allocated structure. Fix this by skipping that entry. System crashed with the following stack during a module unload test. Call Trace: sbitmap_init_node+0x7f/0x1e0 sbitmap_queue_init_node+0x24/0x150 blk_mq_init_bitmaps+0x3d/0xa0 blk_mq_init_tags+0x68/0x90 blk_mq_alloc_map_and_rqs+0x44/0x120 blk_mq_alloc_set_map_and_rqs+0x63/0x150 blk_mq_alloc_tag_set+0x11b/0x230 scsi_add_host_with_dma.cold+0x3f/0x245 qla2x00_probe_one+0xd5a/0x1b80 [qla2xxx] Call Trace with slub_debug and debug kernel: kasan_report_invalid_free+0x50/0x80 __kasan_slab_free+0x137/0x150 slab_free_freelist_hook+0xc6/0x190 kfree+0xe8/0x2e0 qla2x00_free_device+0x3bb/0x5d0 [qla2xxx] qla2x00_remove_one+0x668/0xcf0 [qla2xxx] Link: https://lore.kernel.org/r/20220310092604.22950-6-njavali@marvell.com Fixes: 62e9dd177732 ("scsi: qla2xxx: Change in PUREX to handle FPIN ELS req= uests") Cc: stable@vger.kernel.org Reported-by: Marco Patalano Tested-by: Marco Patalano Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index c7ab8a8be24c..e683b1c01c9f 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3892,6 +3892,8 @@ qla24xx_free_purex_list(struct purex_list *list) spin_lock_irqsave(&list->lock, flags); list_for_each_entry_safe(item, next, &list->head, list) { list_del(&item->list); + if (item =3D=3D &item->vha->default_item) + continue; kfree(item); } spin_unlock_irqrestore(&list->lock, flags); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 4E3B3C43334 for ; Mon, 11 Jul 2022 09:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbiGKJrm (ORCPT ); Mon, 11 Jul 2022 05:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbiGKJrI (ORCPT ); Mon, 11 Jul 2022 05:47:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8235B040; Mon, 11 Jul 2022 02:23: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 76D3C612FE; Mon, 11 Jul 2022 09:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D97C34115; Mon, 11 Jul 2022 09:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531379; bh=qA3BFqcQaxF/A7x7eR1efEtNeDX0omYnIc7NJ9zzW8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f77AsYbBAgys2v7v4dKZmzAEH28Dc7G8cIGPiex/2XzbT6j8TXVVIYF9xJRVAcTB9 1bfCNXTuPA6EWGSh0k0AZoTwVi2GXrwvQnrzdQmO9i1IWNLRV5Ybh8yQ088Yk+U8zU QyTIH9bPiKC8F3WerjYIdH5dEixmmEPzP5HJvDuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , Sasha Levin Subject: [PATCH 5.15 083/230] gfs2: Fix gfs2_file_buffered_write endless loop workaround Date: Mon, 11 Jul 2022 11:05:39 +0200 Message-Id: <20220711090606.428962510@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Andreas Gruenbacher [ Upstream commit 46f3e0421ccb5474b5c006b0089b9dfd42534bb6 ] Since commit 554c577cee95b, gfs2_file_buffered_write() can accidentally return a truncated iov_iter, which might confuse callers. Fix that. Fixes: 554c577cee95b ("gfs2: Prevent endless loops in gfs2_file_buffered_wr= ite") Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/gfs2/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 60390f9dc31f..e93185d804e0 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1086,6 +1086,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb = *iocb, gfs2_holder_uninit(gh); if (statfs_gh) kfree(statfs_gh); + from->count =3D orig_count - read; return read ? read : ret; } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 80159C43334 for ; Mon, 11 Jul 2022 09:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbiGKJsC (ORCPT ); Mon, 11 Jul 2022 05:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbiGKJrc (ORCPT ); Mon, 11 Jul 2022 05:47:32 -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 35CC65C955; Mon, 11 Jul 2022 02:23: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 B04ADB80E6D; Mon, 11 Jul 2022 09:23:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CE56C34115; Mon, 11 Jul 2022 09:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531385; bh=3cja/hQNCOn4PAFMjDouotW5Db/OIZC/dXKK3WM6m0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Tfmm++Cn493USQc/yHmaPTzwLwLxI35ewBJ2B3zhj44htUMC5ktAEMJGYvyFoGiI +WF/gqOw6uaNP6dHqKhK3hvg3T5ZwQpt0UTkJ1gPHh0lQxCt/WKRLpKIKr1LDQkUJ4 lgX5O5L7I1Rl4zLA+cYjPpflR0Jejh2kr9e9aih0= 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.15 084/230] vdpa/mlx5: Avoid processing works if workqueue was destroyed Date: Mon, 11 Jul 2022 11:05:40 +0200 Message-Id: <20220711090606.456720798@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 ad6dc1daaf29f97f23cc810d60ee01c0e83f4c6b ] If mlx5_vdpa gets unloaded while a VM is running, the workqueue will be destroyed. However, vhost might still have reference to the kick function and might attempt to push new works. This could lead to null pointer dereference. To fix this, set mvdev->wq to NULL just before destroying and verify that the workqueue is not NULL in mlx5_vdpa_kick_vq before attempting to push a new work. Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting= ") Signed-off-by: Eli Cohen Link: https://lore.kernel.org/r/20220321141303.9586-1-elic@nvidia.com Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index 174895372e7f..467a349dc26c 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1641,7 +1641,7 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vde= v, u16 idx) return; =20 if (unlikely(is_ctrl_vq_idx(mvdev, idx))) { - if (!mvdev->cvq.ready) + if (!mvdev->wq || !mvdev->cvq.ready) return; =20 queue_work(mvdev->wq, &ndev->cvq_ent.work); @@ -2626,9 +2626,12 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *= v_mdev, struct vdpa_device * struct mlx5_vdpa_mgmtdev *mgtdev =3D container_of(v_mdev, struct mlx5_vdp= a_mgmtdev, mgtdev); struct mlx5_vdpa_dev *mvdev =3D to_mvdev(dev); struct mlx5_vdpa_net *ndev =3D to_mlx5_vdpa_ndev(mvdev); + struct workqueue_struct *wq; =20 mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); - destroy_workqueue(mvdev->wq); + wq =3D mvdev->wq; + mvdev->wq =3D NULL; + destroy_workqueue(wq); _vdpa_unregister_device(dev); mgtdev->ndev =3D NULL; } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 AF165C433EF for ; Mon, 11 Jul 2022 09:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233460AbiGKJsI (ORCPT ); Mon, 11 Jul 2022 05:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233577AbiGKJre (ORCPT ); Mon, 11 Jul 2022 05:47:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9751AB7C0; Mon, 11 Jul 2022 02: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 ams.source.kernel.org (Postfix) with ESMTPS id 596C2B80E7E; Mon, 11 Jul 2022 09:23:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B69D7C34115; Mon, 11 Jul 2022 09:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531388; bh=IAb8LwL92r24iHKH65l8qzlPUc2Zxl8VJi1CLmbM2AM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O/4MroZBROhBsYbxhOjgSJGMr6zcjetx7dehqr1LzdiOyNKxYBgSwMARfnaalzNCX r9IqT2+i8iqpNcyjsBck9VK8+q1prAveACXuT1EcbjnbfLFiV4z1sK+HpwMkyPTC0n TzE8celL9f3651LQuT8dOBcHyfZKdUqaqCNbOLxs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 5.15 085/230] btrfs: handle device lookup with btrfs_dev_lookup_args Date: Mon, 11 Jul 2022 11:05:41 +0200 Message-Id: <20220711090606.484420518@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Josef Bacik [ Upstream commit 562d7b1512f7369a19bca2883e2e8672d78f0481 ] We have a lot of device lookup functions that all do something slightly different. Clean this up by adding a struct to hold the different lookup criteria, and then pass this around to btrfs_find_device() so it can do the proper matching based on the lookup criteria. Reviewed-by: Anand Jain Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/dev-replace.c | 16 +++--- fs/btrfs/ioctl.c | 13 +++-- fs/btrfs/scrub.c | 6 +- fs/btrfs/volumes.c | 122 +++++++++++++++++++++++++---------------- fs/btrfs/volumes.h | 20 ++++++- 5 files changed, 112 insertions(+), 65 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index bdbc310a8f8c..781556e2a37f 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -70,6 +70,7 @@ static int btrfs_dev_replace_kthread(void *data); =20 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info) { + struct btrfs_dev_lookup_args args =3D { .devid =3D BTRFS_DEV_REPLACE_DEVI= D }; struct btrfs_key key; struct btrfs_root *dev_root =3D fs_info->dev_root; struct btrfs_dev_replace *dev_replace =3D &fs_info->dev_replace; @@ -100,8 +101,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_inf= o) * We don't have a replace item or it's corrupted. If there is * a replace target, fail the mount. */ - if (btrfs_find_device(fs_info->fs_devices, - BTRFS_DEV_REPLACE_DEVID, NULL, NULL)) { + if (btrfs_find_device(fs_info->fs_devices, &args)) { btrfs_err(fs_info, "found replace target device without a valid replace item"); ret =3D -EUCLEAN; @@ -163,8 +163,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_inf= o) * We don't have an active replace item but if there is a * replace target, fail the mount. */ - if (btrfs_find_device(fs_info->fs_devices, - BTRFS_DEV_REPLACE_DEVID, NULL, NULL)) { + if (btrfs_find_device(fs_info->fs_devices, &args)) { btrfs_err(fs_info, "replace devid present without an active replace item"); ret =3D -EUCLEAN; @@ -175,11 +174,10 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_i= nfo) break; case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED: - dev_replace->srcdev =3D btrfs_find_device(fs_info->fs_devices, - src_devid, NULL, NULL); - dev_replace->tgtdev =3D btrfs_find_device(fs_info->fs_devices, - BTRFS_DEV_REPLACE_DEVID, - NULL, NULL); + dev_replace->tgtdev =3D btrfs_find_device(fs_info->fs_devices, &args); + args.devid =3D src_devid; + dev_replace->srcdev =3D btrfs_find_device(fs_info->fs_devices, &args); + /* * allow 'btrfs dev replace_cancel' if src/tgt device is * missing diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a37ab3e89a3b..4951a2ab88dd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1657,6 +1657,7 @@ static int exclop_start_or_cancel_reloc(struct btrfs_= fs_info *fs_info, static noinline int btrfs_ioctl_resize(struct file *file, void __user *arg) { + BTRFS_DEV_LOOKUP_ARGS(args); struct inode *inode =3D file_inode(file); struct btrfs_fs_info *fs_info =3D btrfs_sb(inode->i_sb); u64 new_size; @@ -1712,7 +1713,8 @@ static noinline int btrfs_ioctl_resize(struct file *f= ile, btrfs_info(fs_info, "resizing devid %llu", devid); } =20 - device =3D btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL); + args.devid =3D devid; + device =3D btrfs_find_device(fs_info->fs_devices, &args); if (!device) { btrfs_info(fs_info, "resizer unable to find device %llu", devid); @@ -3375,22 +3377,21 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_inf= o *fs_info, static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info, void __user *arg) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_ioctl_dev_info_args *di_args; struct btrfs_device *dev; int ret =3D 0; - char *s_uuid =3D NULL; =20 di_args =3D memdup_user(arg, sizeof(*di_args)); if (IS_ERR(di_args)) return PTR_ERR(di_args); =20 + args.devid =3D di_args->devid; if (!btrfs_is_empty_uuid(di_args->uuid)) - s_uuid =3D di_args->uuid; + args.uuid =3D di_args->uuid; =20 rcu_read_lock(); - dev =3D btrfs_find_device(fs_info->fs_devices, di_args->devid, s_uuid, - NULL); - + dev =3D btrfs_find_device(fs_info->fs_devices, &args); if (!dev) { ret =3D -ENODEV; goto out; diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 62f4bafbe54b..6f2787b21530 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -4068,6 +4068,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u6= 4 devid, u64 start, u64 end, struct btrfs_scrub_progress *progress, int readonly, int is_dev_replace) { + struct btrfs_dev_lookup_args args =3D { .devid =3D devid }; struct scrub_ctx *sctx; int ret; struct btrfs_device *dev; @@ -4115,7 +4116,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u6= 4 devid, u64 start, goto out_free_ctx; =20 mutex_lock(&fs_info->fs_devices->device_list_mutex); - dev =3D btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL); + dev =3D btrfs_find_device(fs_info->fs_devices, &args); if (!dev || (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) && !is_dev_replace)) { mutex_unlock(&fs_info->fs_devices->device_list_mutex); @@ -4288,11 +4289,12 @@ int btrfs_scrub_cancel_dev(struct btrfs_device *dev) int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid, struct btrfs_scrub_progress *progress) { + struct btrfs_dev_lookup_args args =3D { .devid =3D devid }; struct btrfs_device *dev; struct scrub_ctx *sctx =3D NULL; =20 mutex_lock(&fs_info->fs_devices->device_list_mutex); - dev =3D btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL); + dev =3D btrfs_find_device(fs_info->fs_devices, &args); if (dev) sctx =3D dev->scrub_ctx; if (sctx) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fa68efd7e610..53417a1c5402 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -844,9 +844,13 @@ static noinline struct btrfs_device *device_list_add(c= onst char *path, =20 device =3D NULL; } else { + struct btrfs_dev_lookup_args args =3D { + .devid =3D devid, + .uuid =3D disk_super->dev_item.uuid, + }; + mutex_lock(&fs_devices->device_list_mutex); - device =3D btrfs_find_device(fs_devices, devid, - disk_super->dev_item.uuid, NULL); + device =3D btrfs_find_device(fs_devices, &args); =20 /* * If this disk has been pulled into an fs devices created by @@ -2360,10 +2364,9 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_d= evice *tgtdev) static struct btrfs_device *btrfs_find_device_by_path( struct btrfs_fs_info *fs_info, const char *device_path) { + BTRFS_DEV_LOOKUP_ARGS(args); int ret =3D 0; struct btrfs_super_block *disk_super; - u64 devid; - u8 *dev_uuid; struct block_device *bdev; struct btrfs_device *device; =20 @@ -2372,14 +2375,14 @@ static struct btrfs_device *btrfs_find_device_by_pa= th( if (ret) return ERR_PTR(ret); =20 - devid =3D btrfs_stack_device_id(&disk_super->dev_item); - dev_uuid =3D disk_super->dev_item.uuid; + args.devid =3D btrfs_stack_device_id(&disk_super->dev_item); + args.uuid =3D disk_super->dev_item.uuid; if (btrfs_fs_incompat(fs_info, METADATA_UUID)) - device =3D btrfs_find_device(fs_info->fs_devices, devid, dev_uuid, - disk_super->metadata_uuid); + args.fsid =3D disk_super->metadata_uuid; else - device =3D btrfs_find_device(fs_info->fs_devices, devid, dev_uuid, - disk_super->fsid); + args.fsid =3D disk_super->fsid; + + device =3D btrfs_find_device(fs_info->fs_devices, &args); =20 btrfs_release_disk_super(disk_super); if (!device) @@ -2395,11 +2398,12 @@ struct btrfs_device *btrfs_find_device_by_devspec( struct btrfs_fs_info *fs_info, u64 devid, const char *device_path) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_device *device; =20 if (devid) { - device =3D btrfs_find_device(fs_info->fs_devices, devid, NULL, - NULL); + args.devid =3D devid; + device =3D btrfs_find_device(fs_info->fs_devices, &args); if (!device) return ERR_PTR(-ENOENT); return device; @@ -2409,14 +2413,11 @@ struct btrfs_device *btrfs_find_device_by_devspec( return ERR_PTR(-EINVAL); =20 if (strcmp(device_path, "missing") =3D=3D 0) { - /* Find first missing device */ - list_for_each_entry(device, &fs_info->fs_devices->devices, - dev_list) { - if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, - &device->dev_state) && !device->bdev) - return device; - } - return ERR_PTR(-ENOENT); + args.missing =3D true; + device =3D btrfs_find_device(fs_info->fs_devices, &args); + if (!device) + return ERR_PTR(-ENOENT); + return device; } =20 return btrfs_find_device_by_path(fs_info, device_path); @@ -2496,6 +2497,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info = *fs_info) */ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_fs_info *fs_info =3D trans->fs_info; struct btrfs_root *root =3D fs_info->chunk_root; struct btrfs_path *path; @@ -2505,7 +2507,6 @@ static int btrfs_finish_sprout(struct btrfs_trans_han= dle *trans) struct btrfs_key key; u8 fs_uuid[BTRFS_FSID_SIZE]; u8 dev_uuid[BTRFS_UUID_SIZE]; - u64 devid; int ret; =20 path =3D btrfs_alloc_path(); @@ -2544,13 +2545,14 @@ static int btrfs_finish_sprout(struct btrfs_trans_h= andle *trans) =20 dev_item =3D btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_item); - devid =3D btrfs_device_id(leaf, dev_item); + args.devid =3D btrfs_device_id(leaf, dev_item); read_extent_buffer(leaf, dev_uuid, btrfs_device_uuid(dev_item), BTRFS_UUID_SIZE); read_extent_buffer(leaf, fs_uuid, btrfs_device_fsid(dev_item), BTRFS_FSID_SIZE); - device =3D btrfs_find_device(fs_info->fs_devices, devid, dev_uuid, - fs_uuid); + args.uuid =3D dev_uuid; + args.fsid =3D fs_uuid; + device =3D btrfs_find_device(fs_info->fs_devices, &args); BUG_ON(!device); /* Logic error */ =20 if (device->fs_devices->seeding) { @@ -6805,6 +6807,33 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_= info, struct bio *bio, return BLK_STS_OK; } =20 +static bool dev_args_match_fs_devices(const struct btrfs_dev_lookup_args *= args, + const struct btrfs_fs_devices *fs_devices) +{ + if (args->fsid =3D=3D NULL) + return true; + if (memcmp(fs_devices->metadata_uuid, args->fsid, BTRFS_FSID_SIZE) =3D=3D= 0) + return true; + return false; +} + +static bool dev_args_match_device(const struct btrfs_dev_lookup_args *args, + const struct btrfs_device *device) +{ + ASSERT((args->devid !=3D (u64)-1) || args->missing); + + if ((args->devid !=3D (u64)-1) && device->devid !=3D args->devid) + return false; + if (args->uuid && memcmp(device->uuid, args->uuid, BTRFS_UUID_SIZE) !=3D = 0) + return false; + if (!args->missing) + return true; + if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state) && + !device->bdev) + return true; + return false; +} + /* * Find a device specified by @devid or @uuid in the list of @fs_devices, = or * return NULL. @@ -6812,31 +6841,25 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs= _info, struct bio *bio, * If devid and uuid are both specified, the match must be exact, otherwise * only devid is used. */ -struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices, - u64 devid, u8 *uuid, u8 *fsid) +struct btrfs_device *btrfs_find_device(const struct btrfs_fs_devices *fs_d= evices, + const struct btrfs_dev_lookup_args *args) { struct btrfs_device *device; struct btrfs_fs_devices *seed_devs; =20 - if (!fsid || !memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE)) { + if (dev_args_match_fs_devices(args, fs_devices)) { list_for_each_entry(device, &fs_devices->devices, dev_list) { - if (device->devid =3D=3D devid && - (!uuid || memcmp(device->uuid, uuid, - BTRFS_UUID_SIZE) =3D=3D 0)) + if (dev_args_match_device(args, device)) return device; } } =20 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { - if (!fsid || - !memcmp(seed_devs->metadata_uuid, fsid, BTRFS_FSID_SIZE)) { - list_for_each_entry(device, &seed_devs->devices, - dev_list) { - if (device->devid =3D=3D devid && - (!uuid || memcmp(device->uuid, uuid, - BTRFS_UUID_SIZE) =3D=3D 0)) - return device; - } + if (!dev_args_match_fs_devices(args, seed_devs)) + continue; + list_for_each_entry(device, &seed_devs->devices, dev_list) { + if (dev_args_match_device(args, device)) + return device; } } =20 @@ -7002,6 +7025,7 @@ static void warn_32bit_meta_chunk(struct btrfs_fs_inf= o *fs_info, static int read_one_chunk(struct btrfs_key *key, struct extent_buffer *lea= f, struct btrfs_chunk *chunk) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_fs_info *fs_info =3D leaf->fs_info; struct extent_map_tree *map_tree =3D &fs_info->mapping_tree; struct map_lookup *map; @@ -7079,11 +7103,12 @@ static int read_one_chunk(struct btrfs_key *key, st= ruct extent_buffer *leaf, map->stripes[i].physical =3D btrfs_stripe_offset_nr(leaf, chunk, i); devid =3D btrfs_stripe_devid_nr(leaf, chunk, i); + args.devid =3D devid; read_extent_buffer(leaf, uuid, (unsigned long) btrfs_stripe_dev_uuid_nr(chunk, i), BTRFS_UUID_SIZE); - map->stripes[i].dev =3D btrfs_find_device(fs_info->fs_devices, - devid, uuid, NULL); + args.uuid =3D uuid; + map->stripes[i].dev =3D btrfs_find_device(fs_info->fs_devices, &args); if (!map->stripes[i].dev && !btrfs_test_opt(fs_info, DEGRADED)) { free_extent_map(em); @@ -7201,6 +7226,7 @@ static struct btrfs_fs_devices *open_seed_devices(str= uct btrfs_fs_info *fs_info, static int read_one_dev(struct extent_buffer *leaf, struct btrfs_dev_item *dev_item) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_fs_info *fs_info =3D leaf->fs_info; struct btrfs_fs_devices *fs_devices =3D fs_info->fs_devices; struct btrfs_device *device; @@ -7209,11 +7235,13 @@ static int read_one_dev(struct extent_buffer *leaf, u8 fs_uuid[BTRFS_FSID_SIZE]; u8 dev_uuid[BTRFS_UUID_SIZE]; =20 - devid =3D btrfs_device_id(leaf, dev_item); + devid =3D args.devid =3D btrfs_device_id(leaf, dev_item); read_extent_buffer(leaf, dev_uuid, btrfs_device_uuid(dev_item), BTRFS_UUID_SIZE); read_extent_buffer(leaf, fs_uuid, btrfs_device_fsid(dev_item), BTRFS_FSID_SIZE); + args.uuid =3D dev_uuid; + args.fsid =3D fs_uuid; =20 if (memcmp(fs_uuid, fs_devices->metadata_uuid, BTRFS_FSID_SIZE)) { fs_devices =3D open_seed_devices(fs_info, fs_uuid); @@ -7221,8 +7249,7 @@ static int read_one_dev(struct extent_buffer *leaf, return PTR_ERR(fs_devices); } =20 - device =3D btrfs_find_device(fs_info->fs_devices, devid, dev_uuid, - fs_uuid); + device =3D btrfs_find_device(fs_info->fs_devices, &args); if (!device) { if (!btrfs_test_opt(fs_info, DEGRADED)) { btrfs_report_missing_device(fs_info, devid, @@ -7899,12 +7926,14 @@ static void btrfs_dev_stat_print_on_load(struct btr= fs_device *dev) int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info, struct btrfs_ioctl_get_dev_stats *stats) { + BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_device *dev; struct btrfs_fs_devices *fs_devices =3D fs_info->fs_devices; int i; =20 mutex_lock(&fs_devices->device_list_mutex); - dev =3D btrfs_find_device(fs_info->fs_devices, stats->devid, NULL, NULL); + args.devid =3D stats->devid; + dev =3D btrfs_find_device(fs_info->fs_devices, &args); mutex_unlock(&fs_devices->device_list_mutex); =20 if (!dev) { @@ -7980,6 +8009,7 @@ static int verify_one_dev_extent(struct btrfs_fs_info= *fs_info, u64 chunk_offset, u64 devid, u64 physical_offset, u64 physical_len) { + struct btrfs_dev_lookup_args args =3D { .devid =3D devid }; struct extent_map_tree *em_tree =3D &fs_info->mapping_tree; struct extent_map *em; struct map_lookup *map; @@ -8035,7 +8065,7 @@ static int verify_one_dev_extent(struct btrfs_fs_info= *fs_info, } =20 /* Make sure no dev extent is beyond device boundary */ - dev =3D btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL); + dev =3D btrfs_find_device(fs_info->fs_devices, &args); if (!dev) { btrfs_err(fs_info, "failed to find devid %llu", devid); ret =3D -EUCLEAN; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index d86a6f9f166c..f3b1380f45ad 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -418,6 +418,22 @@ struct btrfs_balance_control { struct btrfs_balance_progress stat; }; =20 +/* + * Search for a given device by the set parameters + */ +struct btrfs_dev_lookup_args { + u64 devid; + u8 *uuid; + u8 *fsid; + bool missing; +}; + +/* We have to initialize to -1 because BTRFS_DEV_REPLACE_DEVID is 0 */ +#define BTRFS_DEV_LOOKUP_ARGS_INIT { .devid =3D (u64)-1 } + +#define BTRFS_DEV_LOOKUP_ARGS(name) \ + struct btrfs_dev_lookup_args name =3D BTRFS_DEV_LOOKUP_ARGS_INIT + enum btrfs_map_op { BTRFS_MAP_READ, BTRFS_MAP_WRITE, @@ -482,8 +498,8 @@ void __exit btrfs_cleanup_fs_uuids(void); int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len); int btrfs_grow_device(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 new_size); -struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices, - u64 devid, u8 *uuid, u8 *fsid); +struct btrfs_device *btrfs_find_device(const struct btrfs_fs_devices *fs_d= evices, + const struct btrfs_dev_lookup_args *args); int btrfs_shrink_device(struct btrfs_device *device, u64 new_size); int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *path); int btrfs_balance(struct btrfs_fs_info *fs_info, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 E47BAC433EF for ; Mon, 11 Jul 2022 09:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbiGKJsQ (ORCPT ); Mon, 11 Jul 2022 05:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbiGKJre (ORCPT ); Mon, 11 Jul 2022 05:47:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32173AB7C7; Mon, 11 Jul 2022 02:23: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 72C9F61361; Mon, 11 Jul 2022 09:23:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82633C341C0; Mon, 11 Jul 2022 09:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531390; bh=4g8ckDjMfPAgYHdj3FDaYCIvYJD0IeClaQPl02qoew0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNR7l1tbj9larK66B+M7vfbCXFW8sBhho82T0uBREsLWLbi6HjsgsHmjJ+NzOKg9h /izC0q6tN/rNNqg4pW0tsigY9KhTkr5/Tb/N39TVKzN7tlwIXxL1b428mAaWJIaapZ pqRs53dm4odnpt3LejoawITx1FZaAarSvYwjy4RE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Anand Jain , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 5.15 086/230] btrfs: add a btrfs_get_dev_args_from_path helper Date: Mon, 11 Jul 2022 11:05:42 +0200 Message-Id: <20220711090606.512344336@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Josef Bacik [ Upstream commit faa775c41d655a4786e9d53cb075a77bb5a75f66 ] We are going to want to populate our device lookup args outside of any locks and then do the actual device lookup later, so add a helper to do this work and make btrfs_find_device_by_devspec() use this helper for now. Reviewed-by: Nikolay Borisov Reviewed-by: Anand Jain Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/volumes.c | 96 ++++++++++++++++++++++++++++++---------------- fs/btrfs/volumes.h | 4 ++ 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 53417a1c5402..8d09e6d442b2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2361,45 +2361,81 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_= device *tgtdev) btrfs_free_device(tgtdev); } =20 -static struct btrfs_device *btrfs_find_device_by_path( - struct btrfs_fs_info *fs_info, const char *device_path) +/** + * Populate args from device at path + * + * @fs_info: the filesystem + * @args: the args to populate + * @path: the path to the device + * + * This will read the super block of the device at @path and populate @arg= s with + * the devid, fsid, and uuid. This is meant to be used for ioctls that ne= ed to + * lookup a device to operate on, but need to do it before we take any loc= ks. + * This properly handles the special case of "missing" that a user may pas= s in, + * and does some basic sanity checks. The caller must make sure that @pat= h is + * properly NUL terminated before calling in, and must call + * btrfs_put_dev_args_from_path() in order to free up the temporary fsid a= nd + * uuid buffers. + * + * Return: 0 for success, -errno for failure + */ +int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info, + struct btrfs_dev_lookup_args *args, + const char *path) { - BTRFS_DEV_LOOKUP_ARGS(args); - int ret =3D 0; struct btrfs_super_block *disk_super; struct block_device *bdev; - struct btrfs_device *device; + int ret; =20 - ret =3D btrfs_get_bdev_and_sb(device_path, FMODE_READ, - fs_info->bdev_holder, 0, &bdev, &disk_super); - if (ret) - return ERR_PTR(ret); + if (!path || !path[0]) + return -EINVAL; + if (!strcmp(path, "missing")) { + args->missing =3D true; + return 0; + } + + args->uuid =3D kzalloc(BTRFS_UUID_SIZE, GFP_KERNEL); + args->fsid =3D kzalloc(BTRFS_FSID_SIZE, GFP_KERNEL); + if (!args->uuid || !args->fsid) { + btrfs_put_dev_args_from_path(args); + return -ENOMEM; + } =20 - args.devid =3D btrfs_stack_device_id(&disk_super->dev_item); - args.uuid =3D disk_super->dev_item.uuid; + ret =3D btrfs_get_bdev_and_sb(path, FMODE_READ, fs_info->bdev_holder, 0, + &bdev, &disk_super); + if (ret) + return ret; + args->devid =3D btrfs_stack_device_id(&disk_super->dev_item); + memcpy(args->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE); if (btrfs_fs_incompat(fs_info, METADATA_UUID)) - args.fsid =3D disk_super->metadata_uuid; + memcpy(args->fsid, disk_super->metadata_uuid, BTRFS_FSID_SIZE); else - args.fsid =3D disk_super->fsid; - - device =3D btrfs_find_device(fs_info->fs_devices, &args); - + memcpy(args->fsid, disk_super->fsid, BTRFS_FSID_SIZE); btrfs_release_disk_super(disk_super); - if (!device) - device =3D ERR_PTR(-ENOENT); blkdev_put(bdev, FMODE_READ); - return device; + return 0; } =20 /* - * Lookup a device given by device id, or the path if the id is 0. + * Only use this jointly with btrfs_get_dev_args_from_path() because we wi= ll + * allocate our ->uuid and ->fsid pointers, everybody else uses local vari= ables + * that don't need to be freed. */ +void btrfs_put_dev_args_from_path(struct btrfs_dev_lookup_args *args) +{ + kfree(args->uuid); + kfree(args->fsid); + args->uuid =3D NULL; + args->fsid =3D NULL; +} + struct btrfs_device *btrfs_find_device_by_devspec( struct btrfs_fs_info *fs_info, u64 devid, const char *device_path) { BTRFS_DEV_LOOKUP_ARGS(args); struct btrfs_device *device; + int ret; =20 if (devid) { args.devid =3D devid; @@ -2409,18 +2445,14 @@ struct btrfs_device *btrfs_find_device_by_devspec( return device; } =20 - if (!device_path || !device_path[0]) - return ERR_PTR(-EINVAL); - - if (strcmp(device_path, "missing") =3D=3D 0) { - args.missing =3D true; - device =3D btrfs_find_device(fs_info->fs_devices, &args); - if (!device) - return ERR_PTR(-ENOENT); - return device; - } - - return btrfs_find_device_by_path(fs_info, device_path); + ret =3D btrfs_get_dev_args_from_path(fs_info, &args, device_path); + if (ret) + return ERR_PTR(ret); + device =3D btrfs_find_device(fs_info->fs_devices, &args); + btrfs_put_dev_args_from_path(&args); + if (!device) + return ERR_PTR(-ENOENT); + return device; } =20 /* diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index f3b1380f45ad..d1df03f77e29 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -487,9 +487,13 @@ void btrfs_assign_next_active_device(struct btrfs_devi= ce *device, struct btrfs_device *btrfs_find_device_by_devspec(struct btrfs_fs_info *fs= _info, u64 devid, const char *devpath); +int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info, + struct btrfs_dev_lookup_args *args, + const char *path); struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info, const u64 *devid, const u8 *uuid); +void btrfs_put_dev_args_from_path(struct btrfs_dev_lookup_args *args); void btrfs_free_device(struct btrfs_device *device); int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, u64 devid, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 03264C433EF for ; Mon, 11 Jul 2022 09:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234021AbiGKJxf (ORCPT ); Mon, 11 Jul 2022 05:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbiGKJxH (ORCPT ); Mon, 11 Jul 2022 05:53:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA8AADD5D; Mon, 11 Jul 2022 02:25: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 6E3126112E; Mon, 11 Jul 2022 09:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 777FDC341C8; Mon, 11 Jul 2022 09:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531526; bh=8XFo7GCgPNsNnNLp9Xa7cTmBxczINSncb4/aW5uUbyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZCjY4qpgFVrFTqevA1703Br37zKx1iS+0JVYtHNjo084NGnRJcAcFZjcyC5Bq3Jbi oT09tOtBypjEf6bLuVXvuJS0g79lvSf53jnPsDRaA5kwpq6pa69te48UG5y7nA3V5m jA/CQKbabAOeNiXYJuqWGsaq+MFQhExLNZLx7AN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 5.15 087/230] btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls Date: Mon, 11 Jul 2022 11:05:43 +0200 Message-Id: <20220711090606.540516311@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Josef Bacik [ Upstream commit 1a15eb724aaef8656f8cc01d9355797cfe7c618e ] For device removal and replace we call btrfs_find_device_by_devspec, which if we give it a device path and nothing else will call btrfs_get_dev_args_from_path, which opens the block device and reads the super block and then looks up our device based on that. However at this point we're holding the sb write "lock", so reading the block device pulls in the dependency of ->open_mutex, which produces the following lockdep splat =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D WARNING: possible circular locking dependency detected 5.14.0-rc2+ #405 Not tainted Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Reviewed-by: Anand Jain Suggested-by: Anand Jain Tested-by: Bagas Sanjaya ------------------------------------------------------ losetup/11576 is trying to acquire lock: ffff9bbe8cded938 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0x= 67/0x5e0 but task is already holding lock: ffff9bbe88e4fc68 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x660 = [loop] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&lo->lo_mutex){+.+.}-{3:3}: __mutex_lock+0x7d/0x750 lo_open+0x28/0x60 [loop] blkdev_get_whole+0x25/0xf0 blkdev_get_by_dev.part.0+0x168/0x3c0 blkdev_open+0xd2/0xe0 do_dentry_open+0x161/0x390 path_openat+0x3cc/0xa20 do_filp_open+0x96/0x120 do_sys_openat2+0x7b/0x130 __x64_sys_openat+0x46/0x70 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #3 (&disk->open_mutex){+.+.}-{3:3}: __mutex_lock+0x7d/0x750 blkdev_get_by_dev.part.0+0x56/0x3c0 blkdev_get_by_path+0x98/0xa0 btrfs_get_bdev_and_sb+0x1b/0xb0 btrfs_find_device_by_devspec+0x12b/0x1c0 btrfs_rm_device+0x127/0x610 btrfs_ioctl+0x2a31/0x2e70 __x64_sys_ioctl+0x80/0xb0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #2 (sb_writers#12){.+.+}-{0:0}: lo_write_bvec+0xc2/0x240 [loop] loop_process_work+0x238/0xd00 [loop] process_one_work+0x26b/0x560 worker_thread+0x55/0x3c0 kthread+0x140/0x160 ret_from_fork+0x1f/0x30 -> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}: process_one_work+0x245/0x560 worker_thread+0x55/0x3c0 kthread+0x140/0x160 ret_from_fork+0x1f/0x30 -> #0 ((wq_completion)loop0){+.+.}-{0:0}: __lock_acquire+0x10ea/0x1d90 lock_acquire+0xb5/0x2b0 flush_workqueue+0x91/0x5e0 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x660 [loop] block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x80/0xb0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae other info that might help us debug this: Chain exists of: (wq_completion)loop0 --> &disk->open_mutex --> &lo->lo_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&lo->lo_mutex); lock(&disk->open_mutex); lock(&lo->lo_mutex); lock((wq_completion)loop0); *** DEADLOCK *** 1 lock held by losetup/11576: #0: ffff9bbe88e4fc68 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0= x660 [loop] stack backtrace: CPU: 0 PID: 11576 Comm: losetup Not tainted 5.14.0-rc2+ #405 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/0= 1/2014 Call Trace: dump_stack_lvl+0x57/0x72 check_noncircular+0xcf/0xf0 ? stack_trace_save+0x3b/0x50 __lock_acquire+0x10ea/0x1d90 lock_acquire+0xb5/0x2b0 ? flush_workqueue+0x67/0x5e0 ? lockdep_init_map_type+0x47/0x220 flush_workqueue+0x91/0x5e0 ? flush_workqueue+0x67/0x5e0 ? verify_cpu+0xf0/0x100 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x660 [loop] ? blkdev_ioctl+0x8d/0x2a0 block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x80/0xb0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f31b02404cb Instead what we want to do is populate our device lookup args before we grab any locks, and then pass these args into btrfs_rm_device(). From there we can find the device and do the appropriate removal. Suggested-by: Anand Jain Reviewed-by: Anand Jain Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/ioctl.c | 67 +++++++++++++++++++++++++++------------------- fs/btrfs/volumes.c | 15 +++++------ fs/btrfs/volumes.h | 2 +- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 4951a2ab88dd..4317720a29e8 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3218,6 +3218,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info = *fs_info, void __user *arg) =20 static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg) { + BTRFS_DEV_LOOKUP_ARGS(args); struct inode *inode =3D file_inode(file); struct btrfs_fs_info *fs_info =3D btrfs_sb(inode->i_sb); struct btrfs_ioctl_vol_args_v2 *vol_args; @@ -3229,35 +3230,39 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file= , void __user *arg) if (!capable(CAP_SYS_ADMIN)) return -EPERM; =20 - ret =3D mnt_want_write_file(file); - if (ret) - return ret; - vol_args =3D memdup_user(arg, sizeof(*vol_args)); if (IS_ERR(vol_args)) { ret =3D PTR_ERR(vol_args); - goto err_drop; + goto out; } =20 if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) { ret =3D -EOPNOTSUPP; goto out; } + vol_args->name[BTRFS_SUBVOL_NAME_MAX] =3D '\0'; - if (!(vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) && - strcmp("cancel", vol_args->name) =3D=3D 0) + if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) { + args.devid =3D vol_args->devid; + } else if (!strcmp("cancel", vol_args->name)) { cancel =3D true; + } else { + ret =3D btrfs_get_dev_args_from_path(fs_info, &args, vol_args->name); + if (ret) + goto out; + } + + ret =3D mnt_want_write_file(file); + if (ret) + goto out; =20 ret =3D exclop_start_or_cancel_reloc(fs_info, BTRFS_EXCLOP_DEV_REMOVE, cancel); if (ret) - goto out; - /* Exclusive operation is now claimed */ + goto err_drop; =20 - if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) - ret =3D btrfs_rm_device(fs_info, NULL, vol_args->devid, &bdev, &mode); - else - ret =3D btrfs_rm_device(fs_info, vol_args->name, 0, &bdev, &mode); + /* Exclusive operation is now claimed */ + ret =3D btrfs_rm_device(fs_info, &args, &bdev, &mode); =20 btrfs_exclop_finish(fs_info); =20 @@ -3269,17 +3274,19 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file= , void __user *arg) btrfs_info(fs_info, "device deleted: %s", vol_args->name); } -out: - kfree(vol_args); err_drop: mnt_drop_write_file(file); if (bdev) blkdev_put(bdev, mode); +out: + btrfs_put_dev_args_from_path(&args); + kfree(vol_args); return ret; } =20 static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) { + BTRFS_DEV_LOOKUP_ARGS(args); struct inode *inode =3D file_inode(file); struct btrfs_fs_info *fs_info =3D btrfs_sb(inode->i_sb); struct btrfs_ioctl_vol_args *vol_args; @@ -3291,32 +3298,38 @@ static long btrfs_ioctl_rm_dev(struct file *file, v= oid __user *arg) if (!capable(CAP_SYS_ADMIN)) return -EPERM; =20 - ret =3D mnt_want_write_file(file); - if (ret) - return ret; - vol_args =3D memdup_user(arg, sizeof(*vol_args)); - if (IS_ERR(vol_args)) { - ret =3D PTR_ERR(vol_args); - goto out_drop_write; - } + if (IS_ERR(vol_args)) + return PTR_ERR(vol_args); + vol_args->name[BTRFS_PATH_NAME_MAX] =3D '\0'; - cancel =3D (strcmp("cancel", vol_args->name) =3D=3D 0); + if (!strcmp("cancel", vol_args->name)) { + cancel =3D true; + } else { + ret =3D btrfs_get_dev_args_from_path(fs_info, &args, vol_args->name); + if (ret) + goto out; + } + + ret =3D mnt_want_write_file(file); + if (ret) + goto out; =20 ret =3D exclop_start_or_cancel_reloc(fs_info, BTRFS_EXCLOP_DEV_REMOVE, cancel); if (ret =3D=3D 0) { - ret =3D btrfs_rm_device(fs_info, vol_args->name, 0, &bdev, &mode); + ret =3D btrfs_rm_device(fs_info, &args, &bdev, &mode); if (!ret) btrfs_info(fs_info, "disk deleted %s", vol_args->name); btrfs_exclop_finish(fs_info); } =20 - kfree(vol_args); -out_drop_write: mnt_drop_write_file(file); if (bdev) blkdev_put(bdev, mode); +out: + btrfs_put_dev_args_from_path(&args); + kfree(vol_args); return ret; } =20 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8d09e6d442b2..3bd68f1b79e6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2120,8 +2120,9 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *= fs_info, update_dev_time(device_path); } =20 -int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, - u64 devid, struct block_device **bdev, fmode_t *mode) +int btrfs_rm_device(struct btrfs_fs_info *fs_info, + struct btrfs_dev_lookup_args *args, + struct block_device **bdev, fmode_t *mode) { struct btrfs_device *device; struct btrfs_fs_devices *cur_devices; @@ -2140,14 +2141,12 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, = const char *device_path, if (ret) goto out; =20 - device =3D btrfs_find_device_by_devspec(fs_info, devid, device_path); - - if (IS_ERR(device)) { - if (PTR_ERR(device) =3D=3D -ENOENT && - device_path && strcmp(device_path, "missing") =3D=3D 0) + device =3D btrfs_find_device(fs_info->fs_devices, args); + if (!device) { + if (args->missing) ret =3D BTRFS_ERROR_DEV_MISSING_NOT_FOUND; else - ret =3D PTR_ERR(device); + ret =3D -ENOENT; goto out; } =20 diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index d1df03f77e29..30288b728bbb 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -496,7 +496,7 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs= _info *fs_info, void btrfs_put_dev_args_from_path(struct btrfs_dev_lookup_args *args); void btrfs_free_device(struct btrfs_device *device); int btrfs_rm_device(struct btrfs_fs_info *fs_info, - const char *device_path, u64 devid, + struct btrfs_dev_lookup_args *args, struct block_device **bdev, fmode_t *mode); void __exit btrfs_cleanup_fs_uuids(void); int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 18E23CCA47B for ; Mon, 11 Jul 2022 09:49:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbiGKJtg (ORCPT ); Mon, 11 Jul 2022 05:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233694AbiGKJsh (ORCPT ); Mon, 11 Jul 2022 05:48:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70283EAD; Mon, 11 Jul 2022 02:23: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 86964B80CEF; Mon, 11 Jul 2022 09:23:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8051C34115; Mon, 11 Jul 2022 09:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531410; bh=DviDe3YdOiK48VV2ouMZ/mwRhFKQstraiLFaIzZug6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rKio/0v65gs/cZQyZOVHGIwowt2KPVGWajRpdajdIwBEkpPKFeTbPqe/FRSnK8ypb iyQyjbG7HspjmzRoiMISqUXIRHjm3ClmhKNSsjXswFBNlIZ3h/di9EkB0VHb8zsifW NQq8fWrcne1d7aIVJp+aXyfcVhYg5OodlROUgztk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Luca=20B=C3=A9la=20Palkovics?= , Anand Jain , Qu Wenruo , David Sterba , Sasha Levin Subject: [PATCH 5.15 088/230] btrfs: remove device item and update super block in the same transaction Date: Mon, 11 Jul 2022 11:05:44 +0200 Message-Id: <20220711090606.568460790@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Qu Wenruo [ Upstream commit bbac58698a55cc0a6f0c0d69a6dcd3f9f3134c11 ] [BUG] There is a report that a btrfs has a bad super block num devices. This makes btrfs to reject the fs completely. BTRFS error (device sdd3): super_num_devices 3 mismatch with num_devices = 2 found here BTRFS error (device sdd3): failed to read chunk tree: -22 BTRFS error (device sdd3): open_ctree failed [CAUSE] During btrfs device removal, chunk tree and super block num devs are updated in two different transactions: btrfs_rm_device() |- btrfs_rm_dev_item(device) | |- trans =3D btrfs_start_transaction() | | Now we got transaction X | | | |- btrfs_del_item() | | Now device item is removed from chunk tree | | | |- btrfs_commit_transaction() | Transaction X got committed, super num devs untouched, | but device item removed from chunk tree. | (AKA, super num devs is already incorrect) | |- cur_devices->num_devices--; |- cur_devices->total_devices--; |- btrfs_set_super_num_devices() All those operations are not in transaction X, thus it will only be written back to disk in next transaction. So after the transaction X in btrfs_rm_dev_item() committed, but before transaction X+1 (which can be minutes away), a power loss happen, then we got the super num mismatch. [FIX] Instead of starting and committing a transaction inside btrfs_rm_dev_item(), start a transaction in side btrfs_rm_device() and pass it to btrfs_rm_dev_item(). And only commit the transaction after everything is done. Reported-by: Luca B=C3=A9la Palkovics Link: https://lore.kernel.org/linux-btrfs/CA+8xDSpvdm_U0QLBAnrH=3DzqDq_cWCO= H5TiV46CKmp3igr44okQ@mail.gmail.com/ CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Anand Jain Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/volumes.c | 65 ++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3bd68f1b79e6..cec54c6e1cdd 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1942,23 +1942,18 @@ static void update_dev_time(const char *device_path) path_put(&path); } =20 -static int btrfs_rm_dev_item(struct btrfs_device *device) +static int btrfs_rm_dev_item(struct btrfs_trans_handle *trans, + struct btrfs_device *device) { struct btrfs_root *root =3D device->fs_info->chunk_root; int ret; struct btrfs_path *path; struct btrfs_key key; - struct btrfs_trans_handle *trans; =20 path =3D btrfs_alloc_path(); if (!path) return -ENOMEM; =20 - trans =3D btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) { - btrfs_free_path(path); - return PTR_ERR(trans); - } key.objectid =3D BTRFS_DEV_ITEMS_OBJECTID; key.type =3D BTRFS_DEV_ITEM_KEY; key.offset =3D device->devid; @@ -1969,21 +1964,12 @@ static int btrfs_rm_dev_item(struct btrfs_device *d= evice) if (ret) { if (ret > 0) ret =3D -ENOENT; - btrfs_abort_transaction(trans, ret); - btrfs_end_transaction(trans); goto out; } =20 ret =3D btrfs_del_item(trans, root, path); - if (ret) { - btrfs_abort_transaction(trans, ret); - btrfs_end_transaction(trans); - } - out: btrfs_free_path(path); - if (!ret) - ret =3D btrfs_commit_transaction(trans); return ret; } =20 @@ -2124,6 +2110,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, struct btrfs_dev_lookup_args *args, struct block_device **bdev, fmode_t *mode) { + struct btrfs_trans_handle *trans; struct btrfs_device *device; struct btrfs_fs_devices *cur_devices; struct btrfs_fs_devices *fs_devices =3D fs_info->fs_devices; @@ -2139,7 +2126,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, =20 ret =3D btrfs_check_raid_min_devices(fs_info, num_devices - 1); if (ret) - goto out; + return ret; =20 device =3D btrfs_find_device(fs_info->fs_devices, args); if (!device) { @@ -2147,27 +2134,22 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, ret =3D BTRFS_ERROR_DEV_MISSING_NOT_FOUND; else ret =3D -ENOENT; - goto out; + return ret; } =20 if (btrfs_pinned_by_swapfile(fs_info, device)) { btrfs_warn_in_rcu(fs_info, "cannot remove device %s (devid %llu) due to active swapfile", rcu_str_deref(device->name), device->devid); - ret =3D -ETXTBSY; - goto out; + return -ETXTBSY; } =20 - if (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) { - ret =3D BTRFS_ERROR_DEV_TGT_REPLACE; - goto out; - } + if (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) + return BTRFS_ERROR_DEV_TGT_REPLACE; =20 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && - fs_info->fs_devices->rw_devices =3D=3D 1) { - ret =3D BTRFS_ERROR_DEV_ONLY_WRITABLE; - goto out; - } + fs_info->fs_devices->rw_devices =3D=3D 1) + return BTRFS_ERROR_DEV_ONLY_WRITABLE; =20 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { mutex_lock(&fs_info->chunk_mutex); @@ -2182,14 +2164,22 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, if (ret) goto error_undo; =20 - /* - * TODO: the superblock still includes this device in its num_devices - * counter although write_all_supers() is not locked out. This - * could give a filesystem state which requires a degraded mount. - */ - ret =3D btrfs_rm_dev_item(device); - if (ret) + trans =3D btrfs_start_transaction(fs_info->chunk_root, 0); + if (IS_ERR(trans)) { + ret =3D PTR_ERR(trans); goto error_undo; + } + + ret =3D btrfs_rm_dev_item(trans, device); + if (ret) { + /* Any error in dev item removal is critical */ + btrfs_crit(fs_info, + "failed to remove device item for devid %llu: %d", + device->devid, ret); + btrfs_abort_transaction(trans, ret); + btrfs_end_transaction(trans); + return ret; + } =20 clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state); btrfs_scrub_cancel_dev(device); @@ -2264,7 +2254,8 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, free_fs_devices(cur_devices); } =20 -out: + ret =3D btrfs_commit_transaction(trans); + return ret; =20 error_undo: @@ -2276,7 +2267,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, device->fs_devices->rw_devices++; mutex_unlock(&fs_info->chunk_mutex); } - goto out; + return ret; } =20 void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_device *srcdev) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 2E8C6C43334 for ; Mon, 11 Jul 2022 09:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233747AbiGKJuL (ORCPT ); Mon, 11 Jul 2022 05:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233808AbiGKJtR (ORCPT ); Mon, 11 Jul 2022 05:49:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB14ACED0; Mon, 11 Jul 2022 02:24: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 A26AD6134F; Mon, 11 Jul 2022 09:24:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3A71C34115; Mon, 11 Jul 2022 09:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531441; bh=UB2l8rglaiJ+3138F+SK8mciJZH6/QYMdfUlOV/2Wbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mp+CnlDos+fgcOWzaINBSewS0AmA3TBHtChkTUf29+LIMrdei8V7tnMnJrir9Lh/5 ccAYi2tXOupR8r92s3WqWIcovd97wAwAANE3a5no1qJgwe9IfadYNPtc6K2ymZn5/1 QkgJSnawe2feSZ0lSK71RetTveKcEG7UWH3Pvh3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luis Chamberlain , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 089/230] drbd: add error handling support for add_disk() Date: Mon, 11 Jul 2022 11:05:45 +0200 Message-Id: <20220711090606.597054422@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Luis Chamberlain [ Upstream commit e92ab4eda516a5bfd96c087282ebe9521deba4f4 ] We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/block/drbd/drbd_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 8ba2fe356f01..ae6a136d278e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2798,7 +2798,9 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig goto out_idr_remove_vol; } =20 - add_disk(disk); + err =3D add_disk(disk); + if (err) + goto out_cleanup_disk; =20 /* inherit the connection state */ device->state.conn =3D first_connection(resource)->cstate; @@ -2812,6 +2814,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig drbd_debugfs_device_add(device); return NO_ERROR; =20 +out_cleanup_disk: + blk_cleanup_disk(disk); out_idr_remove_vol: idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 116D1CCA480 for ; Mon, 11 Jul 2022 09:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbiGKJvR (ORCPT ); Mon, 11 Jul 2022 05:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233193AbiGKJuc (ORCPT ); Mon, 11 Jul 2022 05:50:32 -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 32DAE313A7; Mon, 11 Jul 2022 02:24: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 ams.source.kernel.org (Postfix) with ESMTPS id D5E8DB80D2C; Mon, 11 Jul 2022 09:24:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32138C341C0; Mon, 11 Jul 2022 09:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531471; bh=xZz0qpVyBij1ECB9UEqppt9fb3xkzJWlXqnbQzD241E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tlrz2eXoukHe8KHEapEYFtFIey496FM8RJFKkH1IzRz60rhGHN25rJ4QmzlCx7BOR aIK4Ry8ZEnNfeALjorOBFKx60k2yxiCmvFfXax6PjKgSCr9r7jEWds67W5JQNcNuHQ 0mcGfb4zkmKsViIgEdv/gRiJhV+HJ3hw8YX/ayI4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wu Bo , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 090/230] drbd: Fix double free problem in drbd_create_device Date: Mon, 11 Jul 2022 11:05:46 +0200 Message-Id: <20220711090606.625323058@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Wu Bo [ Upstream commit 27548088ac628109f70eb0b1eb521d035844dba8 ] In drbd_create_device(), the 'out_no_io_page' lable has called blk_cleanup_disk() when return failed. So remove the 'out_cleanup_disk' lable to avoid double free the disk pointer. Fixes: e92ab4eda516 ("drbd: add error handling support for add_disk()") Signed-off-by: Wu Bo Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/1636013229-26309-1-git-send-email-wubo40@hu= awei.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/block/drbd/drbd_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index ae6a136d278e..b91d2a9dc238 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2800,7 +2800,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig =20 err =3D add_disk(disk); if (err) - goto out_cleanup_disk; + goto out_idr_remove_vol; =20 /* inherit the connection state */ device->state.conn =3D first_connection(resource)->cstate; @@ -2814,8 +2814,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig drbd_debugfs_device_add(device); return NO_ERROR; =20 -out_cleanup_disk: - blk_cleanup_disk(disk); out_idr_remove_vol: idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 1C9A2C43334 for ; Mon, 11 Jul 2022 09:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233879AbiGKJwK (ORCPT ); Mon, 11 Jul 2022 05:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233860AbiGKJu5 (ORCPT ); Mon, 11 Jul 2022 05:50:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8925D3192F; Mon, 11 Jul 2022 02:25: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 sin.source.kernel.org (Postfix) with ESMTPS id EC000CE1264; Mon, 11 Jul 2022 09:25:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2E98C34115; Mon, 11 Jul 2022 09:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531502; bh=OkeWu99N5SrmLfN4AN0wIMMRc1pHUKJug/+bJwKRD4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2kLZwdlk6XQ5JbJruAOiQBofLpHPvhwbdBxeLhuvRqHF54EaEZ60q6xHjH9oBbc1B i+OEP0Rq9mfDdhkTXRL0vgJILIAFlmaRVGVCy4ZwUg4M6gjQh27faJ2LgxLcH1VgTY fIg5t7qjOQu3vUl6S9XcftcHZlSIcCYTr/9VkhVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Lars Ellenberg , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 091/230] drbd: fix an invalid memory access caused by incorrect use of list iterator Date: Mon, 11 Jul 2022 11:05:47 +0200 Message-Id: <20220711090606.654369927@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Xiaomeng Tong [ Upstream commit ae4d37b5df749926891583d42a6801b5da11e3c1 ] The bug is here: idr_remove(&connection->peer_devices, vnr); If the previous for_each_connection() don't exit early (no goto hit inside the loop), the iterator 'connection' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&resource->connections). As a result, the use of 'connection' above will lead to a invalid memory access (including a possible invalid free as idr_remove could call free_layer). The original intention should have been to remove all peer_devices, but the following lines have already done the work. So just remove this line and the unneeded label, to fix this bug. Cc: stable@vger.kernel.org Fixes: c06ece6ba6f1b ("drbd: Turn connection->volumes into connection->peer= _devices") Signed-off-by: Xiaomeng Tong Reviewed-by: Christoph B=C3=B6hmwalder Reviewed-by: Lars Ellenberg Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/block/drbd/drbd_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index b91d2a9dc238..d59af26d7703 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2795,12 +2795,12 @@ enum drbd_ret_code drbd_create_device(struct drbd_c= onfig_context *adm_ctx, unsig =20 if (init_submitter(device)) { err =3D ERR_NOMEM; - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; } =20 err =3D add_disk(disk); if (err) - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; =20 /* inherit the connection state */ device->state.conn =3D first_connection(resource)->cstate; @@ -2814,8 +2814,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig drbd_debugfs_device_add(device); return NO_ERROR; =20 -out_idr_remove_vol: - idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: for_each_connection(connection, resource) { peer_device =3D idr_remove(&connection->peer_devices, vnr); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 2CE76C43334 for ; Mon, 11 Jul 2022 09:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbiGKJwu (ORCPT ); Mon, 11 Jul 2022 05:52:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233828AbiGKJwC (ORCPT ); Mon, 11 Jul 2022 05:52:02 -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 71455ACEFD; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id A88D761137; Mon, 11 Jul 2022 09:25:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B22F2C341CB; Mon, 11 Jul 2022 09:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531513; bh=V8hUALuVDDRIHZZs372a4TXfodfvKv8TCg8jcpNNJ58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5KgUxLh9WgcuTf/zEdGWVhO3hAe82Q/mAT88Knz7RrgzePwqeVY0pNJIOI4S7xTQ QM/Qr+eb2aF2wcLTLDEGXikO8Ju64K8YZ2NhgnJQScan59WlH5ut0MnfkLzKSQ96Ke dmH2cZaeaR+9pX4CbTTMoTf3LUD+niqDq34Re4J4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Yang , Qingqing Zhuo , Michael Strauss , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 092/230] drm/amd/display: Set min dcfclk if pipe count is 0 Date: Mon, 11 Jul 2022 11:05:48 +0200 Message-Id: <20220711090606.682264786@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Strauss [ Upstream commit bc204778b4032b336cb3bde85bea852d79e7e389 ] [WHY] Clocks don't get recalculated in 0 stream/0 pipe configs, blocking S0i3 if dcfclk gets high enough [HOW] Create DCN31 copy of DCN30 bandwidth validation func which doesn't entirely skip validation in 0 pipe scenarios Override dcfclk to vlevel 0/min value during validation if pipe count is 0 Reviewed-by: Eric Yang Acked-by: Qingqing Zhuo Signed-off-by: Michael Strauss Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../drm/amd/display/dc/dcn30/dcn30_resource.c | 2 +- .../drm/amd/display/dc/dcn30/dcn30_resource.h | 7 +++ .../drm/amd/display/dc/dcn31/dcn31_resource.c | 63 ++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c index 0294d0cc4759..735c92a5aa36 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c @@ -1856,7 +1856,7 @@ static struct pipe_ctx *dcn30_find_split_pipe( return pipe; } =20 -static noinline bool dcn30_internal_validate_bw( +noinline bool dcn30_internal_validate_bw( struct dc *dc, struct dc_state *context, display_e2e_pipe_params_st *pipes, diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.h b/driver= s/gpu/drm/amd/display/dc/dcn30/dcn30_resource.h index b754b89beadf..b92e4cc0232f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.h +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.h @@ -55,6 +55,13 @@ unsigned int dcn30_calc_max_scaled_time( =20 bool dcn30_validate_bandwidth(struct dc *dc, struct dc_state *context, bool fast_validate); +bool dcn30_internal_validate_bw( + struct dc *dc, + struct dc_state *context, + display_e2e_pipe_params_st *pipes, + int *pipe_cnt_out, + int *vlevel_out, + bool fast_validate); void dcn30_calculate_wm_and_dlg( struct dc *dc, struct dc_state *context, display_e2e_pipe_params_st *pipes, diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c index b60ab3cc0f11..7aadb35a3079 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c @@ -1664,6 +1664,15 @@ static void dcn31_calculate_wm_and_dlg_fp( if (context->bw_ctx.dml.soc.min_dcfclk > dcfclk) dcfclk =3D context->bw_ctx.dml.soc.min_dcfclk; =20 + /* We don't recalculate clocks for 0 pipe configs, which can block + * S0i3 as high clocks will block low power states + * Override any clocks that can block S0i3 to min here + */ + if (pipe_cnt =3D=3D 0) { + context->bw_ctx.bw.dcn.clk.dcfclk_khz =3D dcfclk; // always should be vl= evel 0 + return; + } + pipes[0].clks_cfg.voltage =3D vlevel; pipes[0].clks_cfg.dcfclk_mhz =3D dcfclk; pipes[0].clks_cfg.socclk_mhz =3D context->bw_ctx.dml.soc.clock_limits[vle= vel].socclk_mhz; @@ -1789,6 +1798,58 @@ static void dcn31_calculate_wm_and_dlg( DC_FP_END(); } =20 +bool dcn31_validate_bandwidth(struct dc *dc, + struct dc_state *context, + bool fast_validate) +{ + bool out =3D false; + + BW_VAL_TRACE_SETUP(); + + int vlevel =3D 0; + int pipe_cnt =3D 0; + display_e2e_pipe_params_st *pipes =3D kzalloc(dc->res_pool->pipe_count * = sizeof(display_e2e_pipe_params_st), GFP_KERNEL); + DC_LOGGER_INIT(dc->ctx->logger); + + BW_VAL_TRACE_COUNT(); + + out =3D dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel= , fast_validate); + + // Disable fast_validate to set min dcfclk in alculate_wm_and_dlg + if (pipe_cnt =3D=3D 0) + fast_validate =3D false; + + if (!out) + goto validate_fail; + + BW_VAL_TRACE_END_VOLTAGE_LEVEL(); + + if (fast_validate) { + BW_VAL_TRACE_SKIP(fast); + goto validate_out; + } + + dc->res_pool->funcs->calculate_wm_and_dlg(dc, context, pipes, pipe_cnt, v= level); + + BW_VAL_TRACE_END_WATERMARKS(); + + goto validate_out; + +validate_fail: + DC_LOG_WARNING("Mode Validation Warning: %s failed alidation.\n", + dml_get_status_message(context->bw_ctx.dml.vba.ValidationStatus[context-= >bw_ctx.dml.vba.soc.num_states])); + + BW_VAL_TRACE_SKIP(fail); + out =3D false; + +validate_out: + kfree(pipes); + + BW_VAL_TRACE_FINISH(); + + return out; +} + static struct dc_cap_funcs cap_funcs =3D { .get_dcc_compression_cap =3D dcn20_get_dcc_compression_cap }; @@ -1871,7 +1932,7 @@ static struct resource_funcs dcn31_res_pool_funcs =3D= { .link_encs_assign =3D link_enc_cfg_link_encs_assign, .link_enc_unassign =3D link_enc_cfg_link_enc_unassign, .panel_cntl_create =3D dcn31_panel_cntl_create, - .validate_bandwidth =3D dcn30_validate_bandwidth, + .validate_bandwidth =3D dcn31_validate_bandwidth, .calculate_wm_and_dlg =3D dcn31_calculate_wm_and_dlg, .update_soc_for_wm_a =3D dcn31_update_soc_for_wm_a, .populate_dml_pipes =3D dcn31_populate_dml_pipes_from_context, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 2B08AC433EF for ; Mon, 11 Jul 2022 09:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbiGKJxR (ORCPT ); Mon, 11 Jul 2022 05:53:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233810AbiGKJwg (ORCPT ); Mon, 11 Jul 2022 05:52:36 -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 43CB33AB24; Mon, 11 Jul 2022 02:25: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 59EBF6136E; Mon, 11 Jul 2022 09:25:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D7A1C341C0; Mon, 11 Jul 2022 09:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531515; bh=Fm4+o5WNjgZg0zdFVCwzmvKNgf8GosL0bKZIpZHmpNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OClA9yAP2M1XdxvdQdkbaXoRVipPx0qXQ0e/w5b5RNtx0Ft3NLAkTVUUmKaMsE8yN WzydLMnlWU3VmEf0t05gugFxEV/ZpCCawh5muqXAay+sfS0Un9SnSP30YuyeZLj9NQ tJqdITPQbglGlNmjqnKNHezQWhFJSjMNAbcowMKA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, CHANDAN VURDIGERE NATARAJ , Rodrigo Siqueira , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 093/230] drm/amd/display: Fix by adding FPU protection for dcn30_internal_validate_bw Date: Mon, 11 Jul 2022 11:05:49 +0200 Message-Id: <20220711090606.710805739@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: CHANDAN VURDIGERE NATARAJ [ Upstream commit 50e6cb3fd2cde554db646282ea10df7236e6493c ] [Why] Below general protection fault observed when WebGL Aquarium is run for longer duration. If drm debug logs are enabled and set to 0x1f then the issue is observed within 10 minutes of run. [ 100.717056] general protection fault, probably for non-canonical address= 0x2d33302d32323032: 0000 [#1] PREEMPT SMP NOPTI [ 100.727921] CPU: 3 PID: 1906 Comm: DrmThread Tainted: G W = 5.15.30 #12 d726c6a2d6ebe5cf9223931cbca6892f916fe18b [ 100.754419] RIP: 0010:CalculateSwathWidth+0x1f7/0x44f [ 100.767109] Code: 00 00 00 f2 42 0f 11 04 f0 48 8b 85 88 00 00 00 f2 42 = 0f 10 04 f0 48 8b 85 98 00 00 00 f2 42 0f 11 04 f0 48 8b 45 10 0f 57 c0 42 0f 2a 04 b0 0f 57 c9 f3 43 0f 2a 0c b4 e8 8c e2 f3 ff 48 8b [ 100.781269] RSP: 0018:ffffa9230079eeb0 EFLAGS: 00010246 [ 100.812528] RAX: 2d33302d32323032 RBX: 0000000000000500 RCX: 00000000000= 00000 [ 100.819656] RDX: 0000000000000001 RSI: ffff99deb712c49c RDI: 00000000000= 00000 [ 100.826781] RBP: ffffa9230079ef50 R08: ffff99deb712460c R09: ffff99deb71= 2462c [ 100.833907] R10: ffff99deb7124940 R11: ffff99deb7124d70 R12: ffff99deb71= 2ae44 [ 100.841033] R13: 0000000000000001 R14: 0000000000000000 R15: ffffa923007= 9f0a0 [ 100.848159] FS: 00007af121212640(0000) GS:ffff99deba780000(0000) knlGS:= 0000000000000000 [ 100.856240] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 100.861980] CR2: 0000209000fe1000 CR3: 000000011b18c000 CR4: 00000000003= 50ee0 [ 100.869106] Call Trace: [ 100.871555] [ 100.873655] ? asm_sysvec_reschedule_ipi+0x12/0x20 [ 100.878449] CalculateSwathAndDETConfiguration+0x1a3/0x6dd [ 100.883937] dml31_ModeSupportAndSystemConfigurationFull+0x2ce4/0x76da [ 100.890467] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.895173] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.899874] ? __sprint_symbol+0x80/0x135 [ 100.903883] ? dm_update_plane_state+0x3f9/0x4d2 [ 100.908500] ? symbol_string+0xb7/0xde [ 100.912250] ? number+0x145/0x29b [ 100.915566] ? vsnprintf+0x341/0x5ff [ 100.919141] ? desc_read_finalized_seq+0x39/0x87 [ 100.923755] ? update_load_avg+0x1b9/0x607 [ 100.927849] ? compute_mst_dsc_configs_for_state+0x7d/0xd5b [ 100.933416] ? fetch_pipe_params+0xa4d/0xd0c [ 100.937686] ? dc_fpu_end+0x3d/0xa8 [ 100.941175] dml_get_voltage_level+0x16b/0x180 [ 100.945619] dcn30_internal_validate_bw+0x10e/0x89b [ 100.950495] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.955285] ? resource_build_scaling_params+0x98b/0xb8c [ 100.960595] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.965384] dcn31_validate_bandwidth+0x9a/0x1fc [ 100.970001] dc_validate_global_state+0x238/0x295 [ 100.974703] amdgpu_dm_atomic_check+0x9c1/0xbce [ 100.979235] ? _printk+0x59/0x73 [ 100.982467] drm_atomic_check_only+0x403/0x78b [ 100.986912] drm_mode_atomic_ioctl+0x49b/0x546 [ 100.991358] ? drm_ioctl+0x1c1/0x3b3 [ 100.994936] ? drm_atomic_set_property+0x92a/0x92a [ 100.999725] drm_ioctl_kernel+0xdc/0x149 [ 101.003648] drm_ioctl+0x27f/0x3b3 [ 101.007051] ? drm_atomic_set_property+0x92a/0x92a [ 101.011842] amdgpu_drm_ioctl+0x49/0x7d [ 101.015679] __se_sys_ioctl+0x7c/0xb8 [ 101.015685] do_syscall_64+0x5f/0xb8 [ 101.015690] ? __irq_exit_rcu+0x34/0x96 [How] It calles populate_dml_pipes which uses doubles to initialize. Adding FPU protection avoids context switch and probable loss of vba context as there is potential contention while drm debug logs are enabled. Signed-off-by: CHANDAN VURDIGERE NATARAJ Reviewed-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c index 7aadb35a3079..e224c5213258 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c @@ -1813,7 +1813,9 @@ bool dcn31_validate_bandwidth(struct dc *dc, =20 BW_VAL_TRACE_COUNT(); =20 + DC_FP_START(); out =3D dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel= , fast_validate); + DC_FP_END(); =20 // Disable fast_validate to set min dcfclk in alculate_wm_and_dlg if (pipe_cnt =3D=3D 0) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 EEF73C433EF for ; Mon, 11 Jul 2022 09:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233981AbiGKJxP (ORCPT ); Mon, 11 Jul 2022 05:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233499AbiGKJwd (ORCPT ); Mon, 11 Jul 2022 05:52:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B553AB39; Mon, 11 Jul 2022 02:25: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 C3C11B80D2C; Mon, 11 Jul 2022 09:25:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29723C34115; Mon, 11 Jul 2022 09:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531518; bh=6yGShLJBClWDowMoevtSmpngGA0EyC9sGK0/MTq4gsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXE6WviASoN1Luj5MaXvtIv6N5f0uZWcrkLi7yv9iCsvoWso0d/j9axgTgSK93gVJ Eb/ePLgETUpeIvYnN9FXi1Phw0QZYFT9ZRm82GFZiYrJYwoXiq4KsKOGq5tq7cWzQV u4hl2Th8V7g8Xek8UPbUVAjKAMNNjLOisDX9VgP8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Sasha Levin Subject: [PATCH 5.15 094/230] NFSD: De-duplicate net_generic(nf->nf_net, nfsd_net_id) Date: Mon, 11 Jul 2022 11:05:50 +0200 Message-Id: <20220711090606.738860895@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chuck Lever [ Upstream commit 2c445a0e72cb1fbfbdb7f9473c53556ee27c1d90 ] Since this pointer is used repeatedly, move it to a stack variable. Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/nfsd/vfs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 5f62fa0963ce..c8e3f81d110e 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1121,6 +1121,7 @@ __be32 nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, unsigned long count, __be32 *verf) { + struct nfsd_net *nn; struct nfsd_file *nf; loff_t end =3D LLONG_MAX; __be32 err =3D nfserr_inval; @@ -1137,6 +1138,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fh= p, NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &nf); if (err) goto out; + nn =3D net_generic(nf->nf_net, nfsd_net_id); if (EX_ISSYNC(fhp->fh_export)) { errseq_t since =3D READ_ONCE(nf->nf_file->f_wb_err); int err2; @@ -1144,8 +1146,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fh= p, err2 =3D vfs_fsync_range(nf->nf_file, offset, end, 0); switch (err2) { case 0: - nfsd_copy_boot_verifier(verf, net_generic(nf->nf_net, - nfsd_net_id)); + nfsd_copy_boot_verifier(verf, nn); err2 =3D filemap_check_wb_err(nf->nf_file->f_mapping, since); err =3D nfserrno(err2); @@ -1154,13 +1155,11 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *= fhp, err =3D nfserr_notsupp; break; default: - nfsd_reset_boot_verifier(net_generic(nf->nf_net, - nfsd_net_id)); + nfsd_reset_boot_verifier(nn); err =3D nfserrno(err2); } } else - nfsd_copy_boot_verifier(verf, net_generic(nf->nf_net, - nfsd_net_id)); + nfsd_copy_boot_verifier(verf, nn); =20 nfsd_file_put(nf); out: --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 5A684CCA47B for ; Mon, 11 Jul 2022 09:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233615AbiGKJx0 (ORCPT ); Mon, 11 Jul 2022 05:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbiGKJwq (ORCPT ); Mon, 11 Jul 2022 05:52:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA3505E30B; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id DC99961137; Mon, 11 Jul 2022 09:25:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5425C341C0; Mon, 11 Jul 2022 09:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531521; bh=VPsDOJ5dVlCQhyEy1xLFYwObJL/ZKpKKHYGGLbdfY4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2zrxcpRn/gEXk2kz9RiXkX7hYm++qmEQrbtMeSkDLuZ+hxCy3C0Kc9mGeFAhVVnB 2wnK8ZG4OYK4tWo00Vk/s+lAGm+AOUEp5HBTND8Fyq04ppyYZitBQxAakr04pP415o n+n+uZaSG3HPo+LKT/W6SlBAL5KXSiXxDBS/JzZ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Aloni , Chuck Lever , Bruce Fields , Sasha Levin Subject: [PATCH 5.15 095/230] NFSD: COMMIT operations must not return NFS?ERR_INVAL Date: Mon, 11 Jul 2022 11:05:51 +0200 Message-Id: <20220711090606.766372026@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chuck Lever [ Upstream commit 3f965021c8bc38965ecb1924f570c4842b33d408 ] Since, well, forever, the Linux NFS server's nfsd_commit() function has returned nfserr_inval when the passed-in byte range arguments were non-sensical. However, according to RFC 1813 section 3.3.21, NFSv3 COMMIT requests are permitted to return only the following non-zero status codes: NFS3ERR_IO NFS3ERR_STALE NFS3ERR_BADHANDLE NFS3ERR_SERVERFAULT NFS3ERR_INVAL is not included in that list. Likewise, NFS4ERR_INVAL is not listed in the COMMIT row of Table 6 in RFC 8881. RFC 7530 does permit COMMIT to return NFS4ERR_INVAL, but does not specify when it can or should be used. Instead of dropping or failing a COMMIT request in a byte range that is not supported, turn it into a valid request by treating one or both arguments as zero. Offset zero means start-of-file, count zero means until-end-of-file, so we only ever extend the commit range. NFS servers are always allowed to commit more and sooner than requested. The range check is no longer bounded by NFS_OFFSET_MAX, but rather by the value that is returned in the maxfilesize field of the NFSv3 FSINFO procedure or the NFSv4 maxfilesize file attribute. Note that this change results in a new pynfs failure: CMT4 st_commit.testCommitOverflow : RUNNING CMT4 st_commit.testCommitOverflow : FAILURE COMMIT with offset + count overflow should return NFS4ERR_INVAL, instead got NFS4_OK IMO the test is not correct as written: RFC 8881 does not allow the COMMIT operation to return NFS4ERR_INVAL. Reported-by: Dan Aloni Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Reviewed-by: Bruce Fields Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/nfsd/nfs3proc.c | 6 ------ fs/nfsd/vfs.c | 53 +++++++++++++++++++++++++++++++--------------- fs/nfsd/vfs.h | 4 ++-- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index b540489ea240..936eebd4c56d 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -660,15 +660,9 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) argp->count, (unsigned long long) argp->offset); =20 - if (argp->offset > NFS_OFFSET_MAX) { - resp->status =3D nfserr_inval; - goto out; - } - fh_copy(&resp->fh, &argp->fh); resp->status =3D nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count, resp->verf); -out: return rpc_success; } =20 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index c8e3f81d110e..abfbb6953e89 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1108,42 +1108,61 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *f= hp, loff_t offset, } =20 #ifdef CONFIG_NFSD_V3 -/* - * Commit all pending writes to stable storage. +/** + * nfsd_commit - Commit pending writes to stable storage + * @rqstp: RPC request being processed + * @fhp: NFS filehandle + * @offset: raw offset from beginning of file + * @count: raw count of bytes to sync + * @verf: filled in with the server's current write verifier * - * Note: we only guarantee that data that lies within the range specified - * by the 'offset' and 'count' parameters will be synced. + * Note: we guarantee that data that lies within the range specified + * by the 'offset' and 'count' parameters will be synced. The server + * is permitted to sync data that lies outside this range at the + * same time. * * Unfortunately we cannot lock the file to make sure we return full WCC * data to the client, as locking happens lower down in the filesystem. + * + * Return values: + * An nfsstat value in network byte order. */ __be32 -nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, - loff_t offset, unsigned long count, __be32 *verf) +nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, u64 offset, + u32 count, __be32 *verf) { + u64 maxbytes; + loff_t start, end; struct nfsd_net *nn; struct nfsd_file *nf; - loff_t end =3D LLONG_MAX; - __be32 err =3D nfserr_inval; - - if (offset < 0) - goto out; - if (count !=3D 0) { - end =3D offset + (loff_t)count - 1; - if (end < offset) - goto out; - } + __be32 err; =20 err =3D nfsd_file_acquire(rqstp, fhp, NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &nf); if (err) goto out; + + /* + * Convert the client-provided (offset, count) range to a + * (start, end) range. If the client-provided range falls + * outside the maximum file size of the underlying FS, + * clamp the sync range appropriately. + */ + start =3D 0; + end =3D LLONG_MAX; + maxbytes =3D (u64)fhp->fh_dentry->d_sb->s_maxbytes; + if (offset < maxbytes) { + start =3D offset; + if (count && (offset + count - 1 < maxbytes)) + end =3D offset + count - 1; + } + nn =3D net_generic(nf->nf_net, nfsd_net_id); if (EX_ISSYNC(fhp->fh_export)) { errseq_t since =3D READ_ONCE(nf->nf_file->f_wb_err); int err2; =20 - err2 =3D vfs_fsync_range(nf->nf_file, offset, end, 0); + err2 =3D vfs_fsync_range(nf->nf_file, start, end, 0); switch (err2) { case 0: nfsd_copy_boot_verifier(verf, nn); diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index b21b76e6b9a8..3cf5a8a13da5 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -73,8 +73,8 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *, char *name, int len, struct iattr *attrs, struct svc_fh *res, int createmode, u32 *verifier, bool *truncp, bool *created); -__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, - loff_t, unsigned long, __be32 *verf); +__be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp, + u64 offset, u32 count, __be32 *verf); #endif /* CONFIG_NFSD_V3 */ #ifdef CONFIG_NFSD_V4 __be32 nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 3E94AC43334 for ; Mon, 11 Jul 2022 09:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234012AbiGKJx3 (ORCPT ); Mon, 11 Jul 2022 05:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233813AbiGKJxF (ORCPT ); Mon, 11 Jul 2022 05:53: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 75F52ADD58; Mon, 11 Jul 2022 02:25: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 ams.source.kernel.org (Postfix) with ESMTPS id 53C35B80E89; Mon, 11 Jul 2022 09:25:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA916C34115; Mon, 11 Jul 2022 09:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531524; bh=WMMimb6oH2aQKjY001SDEoyVxYdl3PN4VWbitUA/0lU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FT0DUt0Yv7LmDfgA3IsstQqQJBOUeeNsGm/q7Nay9zxUNILv0nbDc/4mpHMYmMZ64 0kX5tcd70dVw9WbDcAEfQAnRTOuCw9znNg8ovzc3d3HSB1GLU+0JRdRIAb5fDwDILP fjNOVombmeQHgO6swYST0lzZqEsmjOOf9ci3dNOM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Myrtle Shah , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.15 096/230] riscv/mm: Add XIP_FIXUP for riscv_pfn_base Date: Mon, 11 Jul 2022 11:05:52 +0200 Message-Id: <20220711090606.793876247@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Palmer Dabbelt [ Upstream commit ca0cb9a60f6d86d4b2139c6f393a78f39edcd7cb ] This manifests as a crash early in boot on VexRiscv. Signed-off-by: Myrtle Shah [Palmer: split commit] Fixes: 44c922572952 ("RISC-V: enable XIP") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/riscv/mm/init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 7f130ac3b9f9..c58a7c77989b 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -265,6 +265,7 @@ pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(P= AGE_SIZE); static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __align= ed(PAGE_SIZE); =20 #ifdef CONFIG_XIP_KERNEL +#define riscv_pfn_base (*(unsigned long *)XIP_FIXUP(&riscv_pfn_ba= se)) #define trampoline_pg_dir ((pgd_t *)XIP_FIXUP(trampoline_pg_dir)) #define fixmap_pte ((pte_t *)XIP_FIXUP(fixmap_pte)) #define early_pg_dir ((pgd_t *)XIP_FIXUP(early_pg_dir)) --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 26F22C433EF for ; Mon, 11 Jul 2022 09:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233687AbiGKJtC (ORCPT ); Mon, 11 Jul 2022 05:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233535AbiGKJsd (ORCPT ); Mon, 11 Jul 2022 05:48:33 -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 3E5A621AA; Mon, 11 Jul 2022 02:23: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 CDEB6612FE; Mon, 11 Jul 2022 09:23:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABD77C34115; Mon, 11 Jul 2022 09:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531413; bh=8Hp75SX0vLGmD71SdPF4zbXYt3vUEF4vh8eSbNgZBBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ocf4FM+1n1yXaOvkZnePe6GUa+G5Tsiyz9t1FOXAsdVwWMvLmzrasUXmyHwpwHOdg u4SV5Sr/gzAmfJNyd2P8HRrWYZNnoUsAlLWBpNk5viK6Va8HuLQVcVZpNEJqydYnAY QW0zJ1ByArjkn3xZA9sgH58irw5V9k43vEf0ky/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Martin Kepplinger , Stable@vger.kernel.org, Jonathan Cameron , Sasha Levin Subject: [PATCH 5.15 097/230] iio: accel: mma8452: use the correct logic to get mma8452_data Date: Mon, 11 Jul 2022 11:05:53 +0200 Message-Id: <20220711090606.821624396@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Haibo Chen [ Upstream commit c87b7b12f48db86ac9909894f4dc0107d7df6375 ] The original logic to get mma8452_data is wrong, the *dev point to the device belong to iio_dev. we can't use this dev to find the correct i2c_client. The original logic happen to work because it finally use dev->driver_data to get iio_dev. Here use the API to_i2c_client() is wrong and make reader confuse. To correct the logic, it should be like this struct mma8452_data *data =3D iio_priv(dev_get_drvdata(dev)); But after commit 8b7651f25962 ("iio: iio_device_alloc(): Remove unnecessary self drvdata"), the upper logic also can't work. When try to show the avialable scale in userspace, will meet kernel dump, kernel handle NULL pointer dereference. So use dev_to_iio_dev() to correct the logic. Dual fixes tags as the second reflects when the bug was exposed, whilst the first reflects when the original bug was introduced. Fixes: c3cdd6e48e35 ("iio: mma8452: refactor for seperating chip specific d= ata") Fixes: 8b7651f25962 ("iio: iio_device_alloc(): Remove unnecessary self drvd= ata") Signed-off-by: Haibo Chen Reviewed-by: Martin Kepplinger Cc: Link: https://lore.kernel.org/r/1645497741-5402-1-git-send-email-haibo.chen= @nxp.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/iio/accel/mma8452.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 373b59557afe..1f46a73aafea 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -380,8 +380,8 @@ static ssize_t mma8452_show_scale_avail(struct device *= dev, struct device_attribute *attr, char *buf) { - struct mma8452_data *data =3D iio_priv(i2c_get_clientdata( - to_i2c_client(dev))); + struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); + struct mma8452_data *data =3D iio_priv(indio_dev); =20 return mma8452_show_int_plus_micros(buf, data->chip_info->mma_scales, ARRAY_SIZE(data->chip_info->mma_scales)); --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 CE938C433EF for ; Mon, 11 Jul 2022 09:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233726AbiGKJtG (ORCPT ); Mon, 11 Jul 2022 05:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233614AbiGKJsg (ORCPT ); Mon, 11 Jul 2022 05:48:36 -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 6939ED4F; Mon, 11 Jul 2022 02:23: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 8B74961356; Mon, 11 Jul 2022 09:23:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9849AC34115; Mon, 11 Jul 2022 09:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531416; bh=n3LKFrUOulNQYs64hrFzzY10neeo4Ui1IPzl+7axOZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uxeqcNxMF9LFyUhnab60zEBprl1WD3RNedjZq9CS5bOD8TfGXdk0I8ijeDbE1hmbb tPyxV7OqAaz+G5e/r4Rbl1vRj7Jwx2j6L5uulCLBo/pFwpsQE4T00UEKb4a2qCbk7h PO5cv3c83TpzJH2gwWAXDLh0VxtdoKPQ1f1QKe8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antonio Quartulli , Marek Lindner , Simon Wunderlich , Sven Eckelmann , b.a.t.m.a.n@lists.open-mesh.org, Sebastian Andrzej Siewior , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 098/230] batman-adv: Use netif_rx(). Date: Mon, 11 Jul 2022 11:05:54 +0200 Message-Id: <20220711090606.849955061@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Andrzej Siewior [ Upstream commit 94da81e2fc4285db373fe9a1eb012c2ee205b110 ] Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any co= ntext.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Antonio Quartulli Cc: Marek Lindner Cc: Simon Wunderlich Cc: Sven Eckelmann Cc: b.a.t.m.a.n@lists.open-mesh.org Signed-off-by: Sebastian Andrzej Siewior Acked-by: Sven Eckelmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/batman-adv/bridge_loop_avoidance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge= _loop_avoidance.c index 17687848daec..11f6ef657d82 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -443,7 +443,7 @@ static void batadv_bla_send_claim(struct batadv_priv *b= at_priv, u8 *mac, batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, skb->len + ETH_HLEN); =20 - netif_rx_any_context(skb); + netif_rx(skb); out: batadv_hardif_put(primary_if); } --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 519B1C43334 for ; Mon, 11 Jul 2022 09:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233524AbiGKJtk (ORCPT ); Mon, 11 Jul 2022 05:49:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233650AbiGKJsk (ORCPT ); Mon, 11 Jul 2022 05:48: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 751E42BD9; Mon, 11 Jul 2022 02:23:41 -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 09F1CB80E7F; Mon, 11 Jul 2022 09:23:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E097C34115; Mon, 11 Jul 2022 09:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531418; bh=nF3W83uGiPxnuF4oBfW8Fn1L0YBcmi8QxYzK9yQiV8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeU/QpC4eamZ/TJs8RPtxNRzLkcHEgMQYwUpA9SxYeCS5Kd4FIAlEJ4nDQ/ypJN+j vs0R+vxVhJRK1lHNjWH/RgTdewJjja+s5IxHopd/b1U/Bzbp8tq0Z5u+H+dd2hnRRp XhB1tO6NyCBTM8XWji3pmKnVKxOS6Ta7Ik0pAzFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Michael Walle , Sasha Levin Subject: [PATCH 5.15 099/230] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set Date: Mon, 11 Jul 2022 11:05:55 +0200 Message-Id: <20220711090606.878475325@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tudor Ambarus [ Upstream commit 151c6b49d679872d6fc0b50e0ad96303091694a2 ] Even if SPI_NOR_NO_ERASE was set, one could still send erase opcodes to the flash. It is not recommended to send unsupported opcodes to flashes. Fix the logic and do not set mtd->_erase when SPI_NOR_NO_ERASE is specified. With this users will not be able to issue erase opcodes to flashes and instead they will recive an -ENOTSUPP error. Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR") Signed-off-by: Tudor Ambarus Reviewed-by: Michael Walle Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220228163334.277730-1-tudor.ambarus@micro= chip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/mtd/spi-nor/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 90f39aabc1ff..d97cdbc2b9de 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3148,7 +3148,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *nam= e, mtd->writesize =3D nor->params->writesize; mtd->flags =3D MTD_CAP_NORFLASH; mtd->size =3D nor->params->size; - mtd->_erase =3D spi_nor_erase; mtd->_read =3D spi_nor_read; mtd->_suspend =3D spi_nor_suspend; mtd->_resume =3D spi_nor_resume; @@ -3178,6 +3177,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *nam= e, =20 if (info->flags & SPI_NOR_NO_ERASE) mtd->flags |=3D MTD_NO_ERASE; + else + mtd->_erase =3D spi_nor_erase; =20 mtd->dev.parent =3D dev; nor->page_size =3D nor->params->page_size; --=20 2.35.1 From nobody Sat Apr 18 21:00:48 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 CA276C43334 for ; Mon, 11 Jul 2022 09:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbiGKJto (ORCPT ); Mon, 11 Jul 2022 05:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233715AbiGKJsv (ORCPT ); Mon, 11 Jul 2022 05:48:51 -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 C51A65F95; Mon, 11 Jul 2022 02:23:43 -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 1BED861356; Mon, 11 Jul 2022 09:23:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F014CC34115; Mon, 11 Jul 2022 09:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531421; bh=da8zybw2cPdBWw+YaxzPCfdsoxLA+sIg0E0z/yJMA1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v7ZeEz6zarO+jmz47stuUrPT9HFXUDmSvFPth+NHPSMx9sLHpBse0HuIMIW/fXGqn aB/p/cicfLX3Wwa8a8qo/cGrZGn7kltu4cXzR9SXzWm8PhowRYuOx842cEY0YMftKP H3pe2QF6vIVJjT0DixmFSd0+3n1ccylwMy3W8N7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Randy Dunlap , Andy Whitcroft , Christoph Lameter , Daniel Micay , David Rientjes , Dennis Zhou , Dwaipayan Ray , Joe Perches , Joonsoo Kim , Lukas Bulwahn , Pekka Enberg , Tejun Heo , Vlastimil Babka , Alexandre Bounine , "Gustavo A. R. Silva" , Ira Weiny , Jing Xiangfeng , John Hubbard , kernel test robot , Matt Porter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Souptick Joarder , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 100/230] Compiler Attributes: add __alloc_size() for better bounds checking Date: Mon, 11 Jul 2022 11:05:56 +0200 Message-Id: <20220711090606.906431052@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 86cffecdeaa278444870c8745ab166a65865dbf0 ] GCC and Clang can use the "alloc_size" attribute to better inform the results of __builtin_object_size() (for compile-time constant values). Clang can additionally use alloc_size to inform the results of __builtin_dynamic_object_size() (for run-time values). Because GCC sees the frequent use of struct_size() as an allocator size argument, and notices it can return SIZE_MAX (the overflow indication), it complains about these call sites overflowing (since SIZE_MAX is greater than the default -Walloc-size-larger-than=3DPTRDIFF_MAX). This isn't helpful since we already know a SIZE_MAX will be caught at run-time (this was an intentional design). To deal with this, we must disable this check as it is both a false positive and redundant. (Clang does not have this warning option.) Unfortunately, just checking the -Wno-alloc-size-larger-than is not sufficient to make the __alloc_size attribute behave correctly under older GCC versions. The attribute itself must be disabled in those situations too, as there appears to be no way to reliably silence the SIZE_MAX constant expression cases for GCC versions less than 9.1: In file included from ./include/linux/resource_ext.h:11, from ./include/linux/pci.h:40, from drivers/net/ethernet/intel/ixgbe/ixgbe.h:9, from drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c:4: In function 'kmalloc_node', inlined from 'ixgbe_alloc_q_vector' at ./include/linux/slab.h:743:9: ./include/linux/slab.h:618:9: error: argument 1 value '18446744073709551= 615' exceeds maximum object size 9223372036854775807 [-Werror=3Dalloc-size-= larger-than=3D] return __kmalloc_node(size, flags, node); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/slab.h: In function 'ixgbe_alloc_q_vector': ./include/linux/slab.h:455:7: note: in a call to allocation function '__= kmalloc_node' declared here void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_slab_= alignment __malloc; ^~~~~~~~~~~~~~ Specifically: '-Wno-alloc-size-larger-than' is not correctly handled by GCC < 9.1 https://godbolt.org/z/hqsfG7q84 (doesn't disable) https://godbolt.org/z/P9jdrPTYh (doesn't admit to not knowing about opt= ion) https://godbolt.org/z/465TPMWKb (only warns when other warnings appear) '-Walloc-size-larger-than=3D18446744073709551615' is not handled by GCC < = 8.2 https://godbolt.org/z/73hh1EPxz (ignores numeric value) Since anything marked with __alloc_size would also qualify for marking with __malloc, just include __malloc along with it to avoid redundant markings. (Suggested by Linus Torvalds.) Finally, make sure checkpatch.pl doesn't get confused about finding the __alloc_size attribute on functions. (Thanks to Joe Perches.) Link: https://lkml.kernel.org/r/20210930222704.2631604-3-keescook@chromium.= org Signed-off-by: Kees Cook Tested-by: Randy Dunlap Cc: Andy Whitcroft Cc: Christoph Lameter Cc: Daniel Micay Cc: David Rientjes Cc: Dennis Zhou Cc: Dwaipayan Ray Cc: Joe Perches Cc: Joonsoo Kim Cc: Lukas Bulwahn Cc: Pekka Enberg Cc: Tejun Heo Cc: Vlastimil Babka Cc: Alexandre Bounine Cc: Gustavo A. R. Silva Cc: Ira Weiny Cc: Jing Xiangfeng Cc: John Hubbard Cc: kernel test robot Cc: Matt Porter Cc: Miguel Ojeda Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Souptick Joarder Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- Makefile | 15 +++++++++++++++ include/linux/compiler-gcc.h | 8 ++++++++ include/linux/compiler_attributes.h | 10 ++++++++++ include/linux/compiler_types.h | 12 ++++++++++++ scripts/checkpatch.pl | 3 ++- 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c7750d260a55..397fb08d17f2 100644 --- a/Makefile +++ b/Makefile @@ -1011,6 +1011,21 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS +=3D -Wno-maybe-uninitialized endif =20 +ifdef CONFIG_CC_IS_GCC +# The allocators already balk at large sizes, so silence the compiler +# warnings for bounds checks involving those possible values. While +# -Wno-alloc-size-larger-than would normally be used here, earlier versions +# of gcc (<9.1) weirdly don't handle the option correctly when _other_ +# warnings are produced (?!). Using -Walloc-size-larger-than=3DSIZE_MAX +# doesn't work (as it is documented to), silently resolving to "0" prior to +# version 9.1 (and producing an error more recently). Numeric values larger +# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently +# ignored, continuing to default to PTRDIFF_MAX. So, left with no other +# choice, we must perform a versioned check to disable this warning. +# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au +KBUILD_CFLAGS +=3D $(call cc-ifversion, -ge, 0901, -Wno-alloc-size-larger-= than) +endif + # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS +=3D -fno-strict-overflow =20 diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index bd2b881c6b63..b9d5f9c373a0 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -144,3 +144,11 @@ #else #define __diag_GCC_8(s) #endif + +/* + * Prior to 9.1, -Wno-alloc-size-larger-than (and therefore the "alloc_siz= e" + * attribute) do not work, and must be disabled. + */ +#if GCC_VERSION < 90100 +#undef __alloc_size__ +#endif diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_a= ttributes.h index e6ec63403965..3de06a8fae73 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -33,6 +33,15 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __aligned_largest __attribute__((__aligned__)) =20 +/* + * Note: do not use this directly. Instead, use __alloc_size() since it is= conditionally + * available and includes other attributes. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.ht= ml#index-alloc_005fsize-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#alloc-size + */ +#define __alloc_size__(x, ...) __attribute__((__alloc_size__(x, ## __VA_A= RGS__))) + /* * Note: users of __always_inline currently do not write "inline" themselv= es, * which seems to be required by gcc to apply the attribute according @@ -153,6 +162,7 @@ =20 /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.ht= ml#index-malloc-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#malloc */ #define __malloc __attribute__((__malloc__)) =20 diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index b6ff83a714ca..4f2203c4a257 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -250,6 +250,18 @@ struct ftrace_likely_data { # define __cficanonical #endif =20 +/* + * Any place that could be marked with the "alloc_size" attribute is also + * a place to be marked with the "malloc" attribute. Do this as part of the + * __alloc_size macro to avoid redundant attributes and to avoid missing a + * __malloc marking. + */ +#ifdef __alloc_size__ +# define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc +#else +# define __alloc_size(x, ...) __malloc +#endif + #ifndef asm_volatile_goto #define asm_volatile_goto(x...) asm goto(x) #endif diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c27d2312cfc3..88cb294dc447 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -489,7 +489,8 @@ our $Attribute =3D qr{ ____cacheline_aligned| ____cacheline_aligned_in_smp| ____cacheline_internodealigned_in_smp| - __weak + __weak| + __alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) }x; our $Modifier; our $Inline =3D qr{inline|__always_inline|noinline|__inline|__inline__}; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 B7719C43334 for ; Mon, 11 Jul 2022 09:49:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233612AbiGKJts (ORCPT ); Mon, 11 Jul 2022 05:49:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiGKJs5 (ORCPT ); Mon, 11 Jul 2022 05:48:57 -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 25362BC37; Mon, 11 Jul 2022 02:23: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 DF6C8612FE; Mon, 11 Jul 2022 09:23:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E74F9C34115; Mon, 11 Jul 2022 09:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531424; bh=hSlfljaxN0870y3L7U2AvEFp1w8AZEKDtfWQyHcJPd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkCkUJxjQYHxFrSfVGtMiWowapSxEBUED7e6wdrbMLmijhWWdBQlzYTCmgMGKUK5H 67oho4Qq5fAxLe+eGGX0jSQGDN92nL/RqUV1rTNaUu91N1b0mdObF0bzJaw0ZSpxBX 3zLxIrfqYZLpIhzQgWd9qt5pNHCGJcepQ8YFOtwQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Hocko , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 101/230] mm: vmalloc: introduce array allocation functions Date: Mon, 11 Jul 2022 11:05:57 +0200 Message-Id: <20220711090606.934875485@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Paolo Bonzini [ Upstream commit a8749a35c39903120ec421ef2525acc8e0daa55c ] Linux has dozens of occurrences of vmalloc(array_size()) and vzalloc(array_size()). Allow to simplify the code by providing vmalloc_array and vcalloc, as well as the underscored variants that let the caller specify the GFP flags. Acked-by: Michal Hocko Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/vmalloc.h | 5 +++++ mm/util.c | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 4fe9e885bbfa..5535be1012a2 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -159,6 +159,11 @@ void *__vmalloc_node(unsigned long size, unsigned long= align, gfp_t gfp_mask, int node, const void *caller); void *vmalloc_no_huge(unsigned long size); =20 +extern void *__vmalloc_array(size_t n, size_t size, gfp_t flags) __alloc_s= ize(1, 2); +extern void *vmalloc_array(size_t n, size_t size) __alloc_size(1, 2); +extern void *__vcalloc(size_t n, size_t size, gfp_t flags) __alloc_size(1,= 2); +extern void *vcalloc(size_t n, size_t size) __alloc_size(1, 2); + extern void vfree(const void *addr); extern void vfree_atomic(const void *addr); =20 diff --git a/mm/util.c b/mm/util.c index 3073de05c2bd..ea04979f131e 100644 --- a/mm/util.c +++ b/mm/util.c @@ -698,6 +698,56 @@ static inline void *__page_rmapping(struct page *page) return (void *)mapping; } =20 +/** + * __vmalloc_array - allocate memory for a virtually contiguous array. + * @n: number of elements. + * @size: element size. + * @flags: the type of memory to allocate (see kmalloc). + */ +void *__vmalloc_array(size_t n, size_t size, gfp_t flags) +{ + size_t bytes; + + if (unlikely(check_mul_overflow(n, size, &bytes))) + return NULL; + return __vmalloc(bytes, flags); +} +EXPORT_SYMBOL(__vmalloc_array); + +/** + * vmalloc_array - allocate memory for a virtually contiguous array. + * @n: number of elements. + * @size: element size. + */ +void *vmalloc_array(size_t n, size_t size) +{ + return __vmalloc_array(n, size, GFP_KERNEL); +} +EXPORT_SYMBOL(vmalloc_array); + +/** + * __vcalloc - allocate and zero memory for a virtually contiguous array. + * @n: number of elements. + * @size: element size. + * @flags: the type of memory to allocate (see kmalloc). + */ +void *__vcalloc(size_t n, size_t size, gfp_t flags) +{ + return __vmalloc_array(n, size, flags | __GFP_ZERO); +} +EXPORT_SYMBOL(__vcalloc); + +/** + * vcalloc - allocate and zero memory for a virtually contiguous array. + * @n: number of elements. + * @size: element size. + */ +void *vcalloc(size_t n, size_t size) +{ + return __vmalloc_array(n, size, GFP_KERNEL | __GFP_ZERO); +} +EXPORT_SYMBOL(vcalloc); + /* Neutral page->mapping pointer to address_space or anon_vma or other */ void *page_rmapping(struct page *page) { --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 74419C433EF for ; Mon, 11 Jul 2022 09:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233655AbiGKJtw (ORCPT ); Mon, 11 Jul 2022 05:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233626AbiGKJs7 (ORCPT ); Mon, 11 Jul 2022 05:48:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA3B13F10; Mon, 11 Jul 2022 02:23: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 41DE4B80E87; Mon, 11 Jul 2022 09:23:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1FC2C34115; Mon, 11 Jul 2022 09:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531427; bh=KGhYVJ8pp4XsDqQk/KlU1Vc0YUpVtWV2RCuc9vjGtOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8kbMUem4l4zX96jnz6m8cXYPUJIpNq06579ZPRG/iPOJNQhNTuY6PJ3ejEhHQZLA 5bUwxwl97tH04PyPm4d2aqXA1grcKXlRKTaesj9STxcEuBOYSE+MufWEnZ5yeTfPaj RY7ybW0GNGZXFdc4/OjbA4A4pBeneTK0YvEaavQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 102/230] KVM: use __vcalloc for very large allocations Date: Mon, 11 Jul 2022 11:05:58 +0200 Message-Id: <20220711090606.962822924@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Paolo Bonzini [ Upstream commit 37b2a6510a48ca361ced679f92682b7b7d7d0330 ] Allocations whose size is related to the memslot size can be arbitrarily large. Do not use kvzalloc/kvcalloc, as those are limited to "not crazy" sizes that fit in 32 bits. Cc: stable@vger.kernel.org Fixes: 7661809d493b ("mm: don't allow oversized kvmalloc() calls") Reviewed-by: David Hildenbrand Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/kvm/book3s_hv_uvmem.c | 2 +- arch/x86/kvm/mmu/page_track.c | 4 ++-- arch/x86/kvm/x86.c | 4 ++-- virt/kvm/kvm_main.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_h= v_uvmem.c index 3fbe710ff839..3d4ee75b0fb7 100644 --- a/arch/powerpc/kvm/book3s_hv_uvmem.c +++ b/arch/powerpc/kvm/book3s_hv_uvmem.c @@ -251,7 +251,7 @@ int kvmppc_uvmem_slot_init(struct kvm *kvm, const struc= t kvm_memory_slot *slot) p =3D kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM; - p->pfns =3D vzalloc(array_size(slot->npages, sizeof(*p->pfns))); + p->pfns =3D vcalloc(slot->npages, sizeof(*p->pfns)); if (!p->pfns) { kfree(p); return -ENOMEM; diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c index 21427e84a82e..630ae70bb6bd 100644 --- a/arch/x86/kvm/mmu/page_track.c +++ b/arch/x86/kvm/mmu/page_track.c @@ -36,8 +36,8 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot = *slot, =20 for (i =3D 0; i < KVM_PAGE_TRACK_MAX; i++) { slot->arch.gfn_track[i] =3D - kvcalloc(npages, sizeof(*slot->arch.gfn_track[i]), - GFP_KERNEL_ACCOUNT); + __vcalloc(npages, sizeof(*slot->arch.gfn_track[i]), + GFP_KERNEL_ACCOUNT); if (!slot->arch.gfn_track[i]) goto track_free; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 39aaa21e28f7..8974884ef2ad 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11552,7 +11552,7 @@ static int memslot_rmap_alloc(struct kvm_memory_slo= t *slot, if (slot->arch.rmap[i]) continue; =20 - slot->arch.rmap[i] =3D kvcalloc(lpages, sz, GFP_KERNEL_ACCOUNT); + slot->arch.rmap[i] =3D __vcalloc(lpages, sz, GFP_KERNEL_ACCOUNT); if (!slot->arch.rmap[i]) { memslot_rmap_free(slot); return -ENOMEM; @@ -11633,7 +11633,7 @@ static int kvm_alloc_memslot_metadata(struct kvm *k= vm, =20 lpages =3D __kvm_mmu_slot_lpages(slot, npages, level); =20 - linfo =3D kvcalloc(lpages, sizeof(*linfo), GFP_KERNEL_ACCOUNT); + linfo =3D __vcalloc(lpages, sizeof(*linfo), GFP_KERNEL_ACCOUNT); if (!linfo) goto out_free; =20 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fefdf3a6dae3..99c591569815 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1255,9 +1255,9 @@ static int kvm_vm_release(struct inode *inode, struct= file *filp) */ static int kvm_alloc_dirty_bitmap(struct kvm_memory_slot *memslot) { - unsigned long dirty_bytes =3D 2 * kvm_dirty_bitmap_bytes(memslot); + unsigned long dirty_bytes =3D kvm_dirty_bitmap_bytes(memslot); =20 - memslot->dirty_bitmap =3D kvzalloc(dirty_bytes, GFP_KERNEL_ACCOUNT); + memslot->dirty_bitmap =3D __vcalloc(2, dirty_bytes, GFP_KERNEL_ACCOUNT); if (!memslot->dirty_bitmap) return -ENOMEM; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 9DF99C433EF for ; Mon, 11 Jul 2022 09:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233669AbiGKJt6 (ORCPT ); Mon, 11 Jul 2022 05:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233758AbiGKJtL (ORCPT ); Mon, 11 Jul 2022 05:49:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18EA06068E; Mon, 11 Jul 2022 02:23: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 03F8EB80E7A; Mon, 11 Jul 2022 09:23:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F656C34115; Mon, 11 Jul 2022 09:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531429; bh=Oc3uZAn2SjytfeW43gNwv+Wr/ecIVvXA2iXT/tRe3yw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMNHPouqxk1ctAFunqzgbrbgKD7BjeRIoLc8i0JckvEfBnBmv7dPJLPeeKHVpmL84 YWbizMxfQ1nw3dhYCZER+7z4cnuqT6u3bjRgZ9Yjvba9SZKkBmZz1kh55MrxnHRqxt uU6zF98nC58Eq1LHTfZ2yO2oMrGiZc9tNXhIsKNE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dongliang Mu , David Sterba , Sasha Levin , syzbot+82650a4e0ed38f218363@syzkaller.appspotmail.com Subject: [PATCH 5.15 103/230] btrfs: dont access possibly stale fs_info data in device_list_add Date: Mon, 11 Jul 2022 11:05:59 +0200 Message-Id: <20220711090606.990492753@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dongliang Mu [ Upstream commit 79c9234ba596e903907de20573fd4bcc85315b06 ] Syzbot reported a possible use-after-free in printing information in device_list_add. Very similar with the bug fixed by commit 0697d9a61099 ("btrfs: don't access possibly stale fs_info data for printing duplicate device"), but this time the use occurs in btrfs_info_in_rcu. Call Trace: kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 btrfs_printk+0x395/0x425 fs/btrfs/super.c:244 device_list_add.cold+0xd7/0x2ed fs/btrfs/volumes.c:957 btrfs_scan_one_device+0x4c7/0x5c0 fs/btrfs/volumes.c:1387 btrfs_control_ioctl+0x12a/0x2d0 fs/btrfs/super.c:2409 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Fix this by modifying device->fs_info to NULL too. Reported-and-tested-by: syzbot+82650a4e0ed38f218363@syzkaller.appspotmail.c= om CC: stable@vger.kernel.org # 4.19+ Signed-off-by: Dongliang Mu Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/volumes.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index cec54c6e1cdd..89ce0b449c22 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -955,6 +955,11 @@ static noinline struct btrfs_device *device_list_add(c= onst char *path, /* * We are going to replace the device path for a given devid, * make sure it's the same device if the device is mounted + * + * NOTE: the device->fs_info may not be reliable here so pass + * in a NULL to message helpers instead. This avoids a possible + * use-after-free when the fs_info and fs_info->sb are already + * torn down. */ if (device->bdev) { int error; @@ -968,12 +973,6 @@ static noinline struct btrfs_device *device_list_add(c= onst char *path, =20 if (device->bdev->bd_dev !=3D path_dev) { mutex_unlock(&fs_devices->device_list_mutex); - /* - * device->fs_info may not be reliable here, so - * pass in a NULL instead. This avoids a - * possible use-after-free when the fs_info and - * fs_info->sb are already torn down. - */ btrfs_warn_in_rcu(NULL, "duplicate device %s devid %llu generation %llu scanned by %s (%d)", path, devid, found_transid, @@ -981,7 +980,7 @@ static noinline struct btrfs_device *device_list_add(co= nst char *path, task_pid_nr(current)); return ERR_PTR(-EEXIST); } - btrfs_info_in_rcu(device->fs_info, + btrfs_info_in_rcu(NULL, "devid %llu device path %s changed to %s scanned by %s (%d)", devid, rcu_str_deref(device->name), path, current->comm, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 29B13C433EF for ; Mon, 11 Jul 2022 09:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233537AbiGKJuB (ORCPT ); Mon, 11 Jul 2022 05:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbiGKJtM (ORCPT ); Mon, 11 Jul 2022 05:49:12 -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 45D3174353; Mon, 11 Jul 2022 02:23: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 37568612B7; Mon, 11 Jul 2022 09:23:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FF84C34115; Mon, 11 Jul 2022 09:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531432; bh=zigCpVn/B3vzOaksBD336+TQT3rmGIw/ZQWAKwCVs9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZH2WKAKy1p27LcfOOTP4EiPA7UwaLAgpCPywtQdyT5OhYSmJN6UX9e/4UZcFaf9+S JKjqHxXUiJeDDdGNIWxJqjpAfMtAoLakjbT3vPfbQN2EQ+nC/OXE3LcloAOoo/3NDf Pqpy+/lmCZuqvDhHHvsFJXV1R35Kdskbcr1IghsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudio Imbrenda , Christian Borntraeger , Janis Schoetterl-Glausch , Sasha Levin Subject: [PATCH 5.15 104/230] KVM: s390x: fix SCK locking Date: Mon, 11 Jul 2022 11:06:00 +0200 Message-Id: <20220711090607.019176476@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Claudio Imbrenda [ Upstream commit c0573ba5c5a2244dc02060b1f374d4593c1d20b7 ] When handling the SCK instruction, the kvm lock is taken, even though the vcpu lock is already being held. The normal locking order is kvm lock first and then vcpu lock. This is can (and in some circumstances does) lead to deadlocks. The function kvm_s390_set_tod_clock is called both by the SCK handler and by some IOCTLs to set the clock. The IOCTLs will not hold the vcpu lock, so they can safely take the kvm lock. The SCK handler holds the vcpu lock, but will also somehow need to acquire the kvm lock without relinquishing the vcpu lock. The solution is to factor out the code to set the clock, and provide two wrappers. One is called like the original function and does the locking, the other is called kvm_s390_try_set_tod_clock and uses trylock to try to acquire the kvm lock. This new wrapper is then used in the SCK handler. If locking fails, -EAGAIN is returned, which is eventually propagated to userspace, thus also freeing the vcpu lock and allowing for forward progress. This is not the most efficient or elegant way to solve this issue, but the SCK instruction is deprecated and its performance is not critical. The goal of this patch is just to provide a simple but correct way to fix the bug. Fixes: 6a3f95a6b04c ("KVM: s390: Intercept SCK instruction") Signed-off-by: Claudio Imbrenda Reviewed-by: Christian Borntraeger Reviewed-by: Janis Schoetterl-Glausch Link: https://lore.kernel.org/r/20220301143340.111129-1-imbrenda@linux.ibm.= com Cc: stable@vger.kernel.org Signed-off-by: Christian Borntraeger Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/s390/kvm/kvm-s390.c | 19 ++++++++++++++++--- arch/s390/kvm/kvm-s390.h | 4 ++-- arch/s390/kvm/priv.c | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 402597f9d050..b456aa196c04 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3913,14 +3913,12 @@ static int kvm_s390_handle_requests(struct kvm_vcpu= *vcpu) return 0; } =20 -void kvm_s390_set_tod_clock(struct kvm *kvm, - const struct kvm_s390_vm_tod_clock *gtod) +static void __kvm_s390_set_tod_clock(struct kvm *kvm, const struct kvm_s39= 0_vm_tod_clock *gtod) { struct kvm_vcpu *vcpu; union tod_clock clk; int i; =20 - mutex_lock(&kvm->lock); preempt_disable(); =20 store_tod_clock_ext(&clk); @@ -3941,7 +3939,22 @@ void kvm_s390_set_tod_clock(struct kvm *kvm, =20 kvm_s390_vcpu_unblock_all(kvm); preempt_enable(); +} + +void kvm_s390_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_= clock *gtod) +{ + mutex_lock(&kvm->lock); + __kvm_s390_set_tod_clock(kvm, gtod); + mutex_unlock(&kvm->lock); +} + +int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_t= od_clock *gtod) +{ + if (!mutex_trylock(&kvm->lock)) + return 0; + __kvm_s390_set_tod_clock(kvm, gtod); mutex_unlock(&kvm->lock); + return 1; } =20 /** diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 1539dd981104..f8803bf0ff17 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -326,8 +326,8 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu); int kvm_s390_handle_sigp_pei(struct kvm_vcpu *vcpu); =20 /* implemented in kvm-s390.c */ -void kvm_s390_set_tod_clock(struct kvm *kvm, - const struct kvm_s390_vm_tod_clock *gtod); +void kvm_s390_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_= clock *gtod); +int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_t= od_clock *gtod); long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable= ); int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long ad= dr); int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr); diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index 417154b314a6..6a765fe22eaf 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c @@ -102,7 +102,20 @@ static int handle_set_clock(struct kvm_vcpu *vcpu) return kvm_s390_inject_prog_cond(vcpu, rc); =20 VCPU_EVENT(vcpu, 3, "SCK: setting guest TOD to 0x%llx", gtod.tod); - kvm_s390_set_tod_clock(vcpu->kvm, >od); + /* + * To set the TOD clock the kvm lock must be taken, but the vcpu lock + * is already held in handle_set_clock. The usual lock order is the + * opposite. As SCK is deprecated and should not be used in several + * cases, for example when the multiple epoch facility or TOD clock + * steering facility is installed (see Principles of Operation), a + * slow path can be used. If the lock can not be taken via try_lock, + * the instruction will be retried via -EAGAIN at a later point in + * time. + */ + if (!kvm_s390_try_set_tod_clock(vcpu->kvm, >od)) { + kvm_s390_retry_instr(vcpu); + return -EAGAIN; + } =20 kvm_s390_set_psw_cc(vcpu, 0); return 0; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 03898C433EF for ; Mon, 11 Jul 2022 09:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233721AbiGKJuF (ORCPT ); Mon, 11 Jul 2022 05:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233791AbiGKJtP (ORCPT ); Mon, 11 Jul 2022 05:49:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FFFC7AB23; Mon, 11 Jul 2022 02:23: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 dfw.source.kernel.org (Postfix) with ESMTPS id 129FD6134C; Mon, 11 Jul 2022 09:23:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11106C34115; Mon, 11 Jul 2022 09:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531435; bh=3I3gg384dMTs0wQ0ZdufSMp00jh+Tq4Oo6AjInUC+LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vMnf0XQbh2ccrstp3v/SOgVnSvcgCtfjqcQh3PcTcx4cROfOC9IwseNA4n+LzctAz I8vLdWhxrSfsrnP6jiuNLQYOgqO4OPWaQoWLggLfwKganiNi3pOjU5Xg0Y4RIiXHmq Ywzl7B7yMljvRybram6pMWYHRa927HVQiZwb+PO0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Patalano , Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 105/230] scsi: qla2xxx: Fix loss of NVMe namespaces after driver reload test Date: Mon, 11 Jul 2022 11:06:01 +0200 Message-Id: <20220711090607.046745625@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Arun Easi [ Upstream commit db212f2eb3fb7f546366777e93c8f54614d39269 ] Driver registration of localport can race when it happens at the remote port discovery time. Fix this by calling the registration under a mutex. Link: https://lore.kernel.org/r/20220310092604.22950-4-njavali@marvell.com Fixes: e84067d74301 ("scsi: qla2xxx: Add FC-NVMe F/W initialization and tra= nsport registration") Cc: stable@vger.kernel.org Reported-by: Marco Patalano Tested-by: Marco Patalano Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/scsi/qla2xxx/qla_nvme.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvm= e.c index 42b29f4fd937..1bf3ab10846a 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -775,7 +775,6 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha) ha =3D vha->hw; tmpl =3D &qla_nvme_fc_transport; =20 - WARN_ON(vha->nvme_local_port); =20 qla_nvme_fc_transport.max_hw_queues =3D min((uint8_t)(qla_nvme_fc_transport.max_hw_queues), @@ -786,13 +785,25 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha) pinfo.port_role =3D FC_PORT_ROLE_NVME_INITIATOR; pinfo.port_id =3D vha->d_id.b24; =20 - ql_log(ql_log_info, vha, 0xffff, - "register_localport: host-traddr=3Dnn-0x%llx:pn-0x%llx on portID:%x\n= ", - pinfo.node_name, pinfo.port_name, pinfo.port_id); - qla_nvme_fc_transport.dma_boundary =3D vha->host->dma_boundary; - - ret =3D nvme_fc_register_localport(&pinfo, tmpl, - get_device(&ha->pdev->dev), &vha->nvme_local_port); + mutex_lock(&ha->vport_lock); + /* + * Check again for nvme_local_port to see if any other thread raced + * with this one and finished registration. + */ + if (!vha->nvme_local_port) { + ql_log(ql_log_info, vha, 0xffff, + "register_localport: host-traddr=3Dnn-0x%llx:pn-0x%llx on portID:%x\= n", + pinfo.node_name, pinfo.port_name, pinfo.port_id); + qla_nvme_fc_transport.dma_boundary =3D vha->host->dma_boundary; + + ret =3D nvme_fc_register_localport(&pinfo, tmpl, + get_device(&ha->pdev->dev), + &vha->nvme_local_port); + mutex_unlock(&ha->vport_lock); + } else { + mutex_unlock(&ha->vport_lock); + return 0; + } if (ret) { ql_log(ql_log_warn, vha, 0xffff, "register_localport failed: ret=3D%x\n", ret); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 671A3CCA47B for ; Mon, 11 Jul 2022 09:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233738AbiGKJuI (ORCPT ); Mon, 11 Jul 2022 05:50:08 -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 S233795AbiGKJtQ (ORCPT ); Mon, 11 Jul 2022 05:49:16 -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 7B99FACEC5; Mon, 11 Jul 2022 02:23:59 -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 E63F261356; Mon, 11 Jul 2022 09:23:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC88CC34115; Mon, 11 Jul 2022 09:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531438; bh=tOrTmnkvypOInQwBGOplI6UmHax23uF7QhIN1+eDHZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkrkpNa3Wm9rpwDRuqOHZRfUgVAI00rvMT2ZTzmVhewUDTQAK/5+VhOAaj+mksWnU q70nvGMnO0sWeT9t6frL5VPh2p7PgHfO66QSvaRxFD6tPFBVDyO923rPnjHiPA1wy1 /N3YyFyzhhS+hujb37vTvoX8qV3tf1lfN/zCkeQI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.15 106/230] powerpc/32: Dont use lmw/stmw for saving/restoring non volatile regs Date: Mon, 11 Jul 2022 11:06:02 +0200 Message-Id: <20220711090607.074732684@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Christophe Leroy [ Upstream commit a85c728cb5e12216c19ae5878980c2cbbbf8616d ] Instructions lmw/stmw are interesting for functions that are rarely used and not in the cache, because only one instruction is to be copied into the instruction cache instead of 19. However those instruction are less performant than 19x raw lwz/stw as they require synchronisation plus one additional cycle. SAVE_NVGPRS / REST_NVGPRS are used in only a few places which are mostly in interrupts entries/exits and in task switch so they are likely already in the cache. Using standard lwz improves null_syscall selftest by: - 10 cycles on mpc832x. - 2 cycles on mpc8xx. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/316c543b8906712c108985c8463eec09c8db577b.16= 29732542.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/include/asm/ppc_asm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/= ppc_asm.h index 1c538a9a11e0..7be24048b8d1 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h @@ -28,8 +28,8 @@ #else #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) -#define SAVE_NVGPRS(base) stmw 13, GPR0+4*13(base) -#define REST_NVGPRS(base) lmw 13, GPR0+4*13(base) +#define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); SAVE_1= 0GPRS(22, base) +#define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); REST_1= 0GPRS(22, base) #endif =20 #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 86E86C433EF for ; Mon, 11 Jul 2022 09:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233766AbiGKJuR (ORCPT ); Mon, 11 Jul 2022 05:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbiGKJtV (ORCPT ); Mon, 11 Jul 2022 05:49:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D373C248FA; Mon, 11 Jul 2022 02:24: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 4BB28B80E7E; Mon, 11 Jul 2022 09:24:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84599C34115; Mon, 11 Jul 2022 09:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531443; bh=o7GX/JBWNVpVdHKDfQXCW02YKTtRL9r0qkWI7tB9csQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KVtZ85MkkosGEhVXWXxY6oj3Obj0pYMzZsymIyP73lgQs4Y3WZeMA69U/bM/zkrf7 +lXaxcwU5+KOBL/rLJ7NkvyxuVuJj9loX/8FecqKyV3ksUOAGda5N20udSBaKBINXk C+KTP9m4++loqvLAMzyADlAEqw8J4ep7694E69YM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Segher Boessenkool , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.15 107/230] powerpc: flexible GPR range save/restore macros Date: Mon, 11 Jul 2022 11:06:03 +0200 Message-Id: <20220711090607.103010388@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Nicholas Piggin [ Upstream commit aebd1fb45c622e9a2b06fb70665d084d3a8d6c78 ] Introduce macros that operate on a (start, end) range of GPRs, which reduces lines of code and need to do mental arithmetic while reading the code. Signed-off-by: Nicholas Piggin Reviewed-by: Segher Boessenkool Reviewed-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20211022061322.2671178-1-npiggin@gmail.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/boot/crt0.S | 31 +++++++------ arch/powerpc/crypto/md5-asm.S | 10 ++--- arch/powerpc/crypto/sha1-powerpc-asm.S | 6 +-- arch/powerpc/include/asm/ppc_asm.h | 43 ++++++++++++------- arch/powerpc/kernel/entry_32.S | 23 ++++------ arch/powerpc/kernel/exceptions-64e.S | 14 ++---- arch/powerpc/kernel/exceptions-64s.S | 6 +-- arch/powerpc/kernel/head_32.h | 3 +- arch/powerpc/kernel/head_booke.h | 3 +- arch/powerpc/kernel/interrupt_64.S | 34 ++++++--------- arch/powerpc/kernel/optprobes_head.S | 4 +- arch/powerpc/kernel/tm.S | 15 ++----- .../powerpc/kernel/trace/ftrace_64_mprofile.S | 15 +++---- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 5 +-- .../lib/test_emulate_step_exec_instr.S | 8 ++-- 15 files changed, 94 insertions(+), 126 deletions(-) diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S index 1d83966f5ef6..e8f10a599659 100644 --- a/arch/powerpc/boot/crt0.S +++ b/arch/powerpc/boot/crt0.S @@ -226,16 +226,19 @@ p_base: mflr r10 /* r10 now points to runtime addr o= f p_base */ #ifdef __powerpc64__ =20 #define PROM_FRAME_SIZE 512 -#define SAVE_GPR(n, base) std n,8*(n)(base) -#define REST_GPR(n, base) ld n,8*(n)(base) -#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) -#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) -#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) -#define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) -#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) -#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) -#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) -#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) + +.macro OP_REGS op, width, start, end, base, offset + .Lreg=3D\start + .rept (\end - \start + 1) + \op .Lreg,\offset+\width*.Lreg(\base) + .Lreg=3D.Lreg+1 + .endr +.endm + +#define SAVE_GPRS(start, end, base) OP_REGS std, 8, start, end, base, 0 +#define REST_GPRS(start, end, base) OP_REGS ld, 8, start, end, base, 0 +#define SAVE_GPR(n, base) SAVE_GPRS(n, n, base) +#define REST_GPR(n, base) REST_GPRS(n, n, base) =20 /* prom handles the jump into and return from firmware. The prom args poi= nter is loaded in r3. */ @@ -246,9 +249,7 @@ prom: stdu r1,-PROM_FRAME_SIZE(r1) /* Save SP and create stack space */ =20 SAVE_GPR(2, r1) - SAVE_GPR(13, r1) - SAVE_8GPRS(14, r1) - SAVE_10GPRS(22, r1) + SAVE_GPRS(13, 31, r1) mfcr r10 std r10,8*32(r1) mfmsr r10 @@ -283,9 +284,7 @@ prom: =20 /* Restore other registers */ REST_GPR(2, r1) - REST_GPR(13, r1) - REST_8GPRS(14, r1) - REST_10GPRS(22, r1) + REST_GPRS(13, 31, r1) ld r10,8*32(r1) mtcr r10 =20 diff --git a/arch/powerpc/crypto/md5-asm.S b/arch/powerpc/crypto/md5-asm.S index 948d100a2934..fa6bc440cf4a 100644 --- a/arch/powerpc/crypto/md5-asm.S +++ b/arch/powerpc/crypto/md5-asm.S @@ -38,15 +38,11 @@ =20 #define INITIALIZE \ PPC_STLU r1,-INT_FRAME_SIZE(r1); \ - SAVE_8GPRS(14, r1); /* push registers onto stack */ \ - SAVE_4GPRS(22, r1); \ - SAVE_GPR(26, r1) + SAVE_GPRS(14, 26, r1) /* push registers onto stack */ =20 #define FINALIZE \ - REST_8GPRS(14, r1); /* pop registers from stack */ \ - REST_4GPRS(22, r1); \ - REST_GPR(26, r1); \ - addi r1,r1,INT_FRAME_SIZE; + REST_GPRS(14, 26, r1); /* pop registers from stack */ \ + addi r1,r1,INT_FRAME_SIZE =20 #ifdef __BIG_ENDIAN__ #define LOAD_DATA(reg, off) \ diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/s= ha1-powerpc-asm.S index 23e248beff71..f0d5ed557ab1 100644 --- a/arch/powerpc/crypto/sha1-powerpc-asm.S +++ b/arch/powerpc/crypto/sha1-powerpc-asm.S @@ -125,8 +125,7 @@ =20 _GLOBAL(powerpc_sha_transform) PPC_STLU r1,-INT_FRAME_SIZE(r1) - SAVE_8GPRS(14, r1) - SAVE_10GPRS(22, r1) + SAVE_GPRS(14, 31, r1) =20 /* Load up A - E */ lwz RA(0),0(r3) /* A */ @@ -184,7 +183,6 @@ _GLOBAL(powerpc_sha_transform) stw RD(0),12(r3) stw RE(0),16(r3) =20 - REST_8GPRS(14, r1) - REST_10GPRS(22, r1) + REST_GPRS(14, 31, r1) addi r1,r1,INT_FRAME_SIZE blr diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/= ppc_asm.h index 7be24048b8d1..f21e6bde17a1 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h @@ -16,30 +16,41 @@ =20 #define SZL (BITS_PER_LONG/8) =20 +/* + * This expands to a sequence of operations with reg incrementing from + * start to end inclusive, of this form: + * + * op reg, (offset + (width * reg))(base) + * + * Note that offset is not the offset of the first operation unless start + * is zero (or width is zero). + */ +.macro OP_REGS op, width, start, end, base, offset + .Lreg=3D\start + .rept (\end - \start + 1) + \op .Lreg, \offset + \width * .Lreg(\base) + .Lreg=3D.Lreg+1 + .endr +.endm + /* * Macros for storing registers into and loading registers from * exception frames. */ #ifdef __powerpc64__ -#define SAVE_GPR(n, base) std n,GPR0+8*(n)(base) -#define REST_GPR(n, base) ld n,GPR0+8*(n)(base) -#define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) -#define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base) +#define SAVE_GPRS(start, end, base) OP_REGS std, 8, start, end, base, GPR0 +#define REST_GPRS(start, end, base) OP_REGS ld, 8, start, end, base, GPR0 +#define SAVE_NVGPRS(base) SAVE_GPRS(14, 31, base) +#define REST_NVGPRS(base) REST_GPRS(14, 31, base) #else -#define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) -#define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) -#define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); SAVE_1= 0GPRS(22, base) -#define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); REST_1= 0GPRS(22, base) +#define SAVE_GPRS(start, end, base) OP_REGS stw, 4, start, end, base, GPR0 +#define REST_GPRS(start, end, base) OP_REGS lwz, 4, start, end, base, GPR0 +#define SAVE_NVGPRS(base) SAVE_GPRS(13, 31, base) +#define REST_NVGPRS(base) REST_GPRS(13, 31, base) #endif =20 -#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) -#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) -#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) -#define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) -#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) -#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) -#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) -#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) +#define SAVE_GPR(n, base) SAVE_GPRS(n, n, base) +#define REST_GPR(n, base) REST_GPRS(n, n, base) =20 #define SAVE_FPR(n, base) stfd n,8*TS_FPRWIDTH*(n)(base) #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 61fdd53cdd9a..c62dd9815965 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -90,8 +90,7 @@ transfer_to_syscall: stw r12,8(r1) stw r2,_TRAP(r1) SAVE_GPR(0, r1) - SAVE_4GPRS(3, r1) - SAVE_2GPRS(7, r1) + SAVE_GPRS(3, 8, r1) addi r2,r10,-THREAD SAVE_NVGPRS(r1) =20 @@ -139,7 +138,7 @@ syscall_exit_finish: mtxer r5 lwz r0,GPR0(r1) lwz r3,GPR3(r1) - REST_8GPRS(4,r1) + REST_GPRS(4, 11, r1) lwz r12,GPR12(r1) b 1b =20 @@ -232,9 +231,9 @@ fast_exception_return: beq 3f /* if not, we've got problems */ #endif =20 -2: REST_4GPRS(3, r11) +2: REST_GPRS(3, 6, r11) lwz r10,_CCR(r11) - REST_2GPRS(1, r11) + REST_GPRS(1, 2, r11) mtcr r10 lwz r10,_LINK(r11) mtlr r10 @@ -298,16 +297,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) * the reliable stack unwinder later on. Clear it. */ stw r0,8(r1) - REST_4GPRS(7, r1) - REST_2GPRS(11, r1) + REST_GPRS(7, 12, r1) =20 mtcr r3 mtlr r4 mtctr r5 mtspr SPRN_XER,r6 =20 - REST_4GPRS(2, r1) - REST_GPR(6, r1) + REST_GPRS(2, 6, r1) REST_GPR(0, r1) REST_GPR(1, r1) rfi @@ -341,8 +338,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) lwz r6,_CCR(r1) li r0,0 =20 - REST_4GPRS(7, r1) - REST_2GPRS(11, r1) + REST_GPRS(7, 12, r1) =20 mtlr r3 mtctr r4 @@ -354,7 +350,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) */ stw r0,8(r1) =20 - REST_4GPRS(2, r1) + REST_GPRS(2, 5, r1) =20 bne- cr1,1f /* emulate stack store */ mtcr r6 @@ -430,8 +426,7 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return) bne interrupt_return; \ lwz r0,GPR0(r1); \ lwz r2,GPR2(r1); \ - REST_4GPRS(3, r1); \ - REST_2GPRS(7, r1); \ + REST_GPRS(3, 8, r1); \ lwz r10,_XER(r1); \ lwz r11,_CTR(r1); \ mtspr SPRN_XER,r10; \ diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exc= eptions-64e.S index 711c66b76df1..67dc4e3179a0 100644 --- a/arch/powerpc/kernel/exceptions-64e.S +++ b/arch/powerpc/kernel/exceptions-64e.S @@ -198,8 +198,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) =20 stdcx. r0,0,r1 /* to clear the reservation */ =20 - REST_4GPRS(2, r1) - REST_4GPRS(6, r1) + REST_GPRS(2, 9, r1) =20 ld r10,_CTR(r1) ld r11,_XER(r1) @@ -375,9 +374,7 @@ ret_from_mc_except: exc_##n##_common: \ std r0,GPR0(r1); /* save r0 in stackframe */ \ std r2,GPR2(r1); /* save r2 in stackframe */ \ - SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ - SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ - std r9,GPR9(r1); /* save r9 in stackframe */ \ + SAVE_GPRS(3, 9, r1); /* save r3 - r9 in stackframe */ \ std r10,_NIP(r1); /* save SRR0 to stackframe */ \ std r11,_MSR(r1); /* save SRR1 to stackframe */ \ beq 2f; /* if from kernel mode */ \ @@ -1061,9 +1058,7 @@ bad_stack_book3e: std r11,_ESR(r1) std r0,GPR0(r1); /* save r0 in stackframe */ \ std r2,GPR2(r1); /* save r2 in stackframe */ \ - SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ - SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ - std r9,GPR9(r1); /* save r9 in stackframe */ \ + SAVE_GPRS(3, 9, r1); /* save r3 - r9 in stackframe */ \ ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \ ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \ mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \ @@ -1077,8 +1072,7 @@ bad_stack_book3e: std r10,_LINK(r1) std r11,_CTR(r1) std r12,_XER(r1) - SAVE_10GPRS(14,r1) - SAVE_8GPRS(24,r1) + SAVE_GPRS(14, 31, r1) lhz r12,PACA_TRAP_SAVE(r13) std r12,_TRAP(r1) addi r11,r1,INT_FRAME_SIZE diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exc= eptions-64s.S index eaf1f72131a1..277eccf0f086 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -574,8 +574,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) ld r10,IAREA+EX_CTR(r13) std r10,_CTR(r1) std r2,GPR2(r1) /* save r2 in stackframe */ - SAVE_4GPRS(3, r1) /* save r3 - r6 in stackframe */ - SAVE_2GPRS(7, r1) /* save r7, r8 in stackframe */ + SAVE_GPRS(3, 8, r1) /* save r3 - r8 in stackframe */ mflr r9 /* Get LR, later save to stack */ ld r2,PACATOC(r13) /* get kernel TOC into r2 */ std r9,_LINK(r1) @@ -693,8 +692,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) mtlr r9 ld r9,_CCR(r1) mtcr r9 - REST_8GPRS(2, r1) - REST_4GPRS(10, r1) + REST_GPRS(2, 13, r1) REST_GPR(0, r1) /* restore original r1. */ ld r1,GPR1(r1) diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h index 349c4a820231..261c79bdbe53 100644 --- a/arch/powerpc/kernel/head_32.h +++ b/arch/powerpc/kernel/head_32.h @@ -115,8 +115,7 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt) stw r10,8(r1) li r10, \trapno stw r10,_TRAP(r1) - SAVE_4GPRS(3, r1) - SAVE_2GPRS(7, r1) + SAVE_GPRS(3, 8, r1) SAVE_NVGPRS(r1) stw r2,GPR2(r1) stw r12,_NIP(r1) diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_bo= oke.h index ef8d1b1c234e..bb6d5d0fc4ac 100644 --- a/arch/powerpc/kernel/head_booke.h +++ b/arch/powerpc/kernel/head_booke.h @@ -87,8 +87,7 @@ END_BTB_FLUSH_SECTION stw r10, 8(r1) li r10, \trapno stw r10,_TRAP(r1) - SAVE_4GPRS(3, r1) - SAVE_2GPRS(7, r1) + SAVE_GPRS(3, 8, r1) SAVE_NVGPRS(r1) stw r2,GPR2(r1) stw r12,_NIP(r1) diff --git a/arch/powerpc/kernel/interrupt_64.S b/arch/powerpc/kernel/inter= rupt_64.S index 4c6d1a8dcefe..ff8c8c03f41a 100644 --- a/arch/powerpc/kernel/interrupt_64.S +++ b/arch/powerpc/kernel/interrupt_64.S @@ -166,10 +166,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) * The value of AMR only matters while we're in the kernel. */ mtcr r2 - ld r2,GPR2(r1) - ld r3,GPR3(r1) - ld r13,GPR13(r1) - ld r1,GPR1(r1) + REST_GPRS(2, 3, r1) + REST_GPR(13, r1) + REST_GPR(1, r1) RFSCV_TO_USER b . /* prevent speculative execution */ =20 @@ -187,9 +186,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) mtctr r3 mtlr r4 mtspr SPRN_XER,r5 - REST_10GPRS(2, r1) - REST_2GPRS(12, r1) - ld r1,GPR1(r1) + REST_GPRS(2, 13, r1) + REST_GPR(1, r1) RFI_TO_USER .Lsyscall_vectored_\name\()_rst_end: =20 @@ -378,10 +376,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) * The value of AMR only matters while we're in the kernel. */ mtcr r2 - ld r2,GPR2(r1) - ld r3,GPR3(r1) - ld r13,GPR13(r1) - ld r1,GPR1(r1) + REST_GPRS(2, 3, r1) + REST_GPR(13, r1) + REST_GPR(1, r1) RFI_TO_USER b . /* prevent speculative execution */ =20 @@ -392,8 +389,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) mtctr r3 mtspr SPRN_XER,r4 ld r0,GPR0(r1) - REST_8GPRS(4, r1) - ld r12,GPR12(r1) + REST_GPRS(4, 12, r1) b .Lsyscall_restore_regs_cont .Lsyscall_rst_end: =20 @@ -522,17 +518,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ld r6,_XER(r1) li r0,0 =20 - REST_4GPRS(7, r1) - REST_2GPRS(11, r1) - REST_GPR(13, r1) + REST_GPRS(7, 13, r1) =20 mtcr r3 mtlr r4 mtctr r5 mtspr SPRN_XER,r6 =20 - REST_4GPRS(2, r1) - REST_GPR(6, r1) + REST_GPRS(2, 6, r1) REST_GPR(0, r1) REST_GPR(1, r1) .ifc \srr,srr @@ -629,8 +622,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ld r6,_CCR(r1) li r0,0 =20 - REST_4GPRS(7, r1) - REST_2GPRS(11, r1) + REST_GPRS(7, 12, r1) =20 mtlr r3 mtctr r4 @@ -642,7 +634,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) */ std r0,STACK_FRAME_OVERHEAD-16(r1) =20 - REST_4GPRS(2, r1) + REST_GPRS(2, 5, r1) =20 bne- cr1,1f /* emulate stack store */ mtcr r6 diff --git a/arch/powerpc/kernel/optprobes_head.S b/arch/powerpc/kernel/opt= probes_head.S index 19ea3312403c..5c7f0b4b784b 100644 --- a/arch/powerpc/kernel/optprobes_head.S +++ b/arch/powerpc/kernel/optprobes_head.S @@ -10,8 +10,8 @@ #include =20 #ifdef CONFIG_PPC64 -#define SAVE_30GPRS(base) SAVE_10GPRS(2,base); SAVE_10GPRS(12,base); SAVE_= 10GPRS(22,base) -#define REST_30GPRS(base) REST_10GPRS(2,base); REST_10GPRS(12,base); REST_= 10GPRS(22,base) +#define SAVE_30GPRS(base) SAVE_GPRS(2, 31, base) +#define REST_30GPRS(base) REST_GPRS(2, 31, base) #define TEMPLATE_FOR_IMM_LOAD_INSNS nop; nop; nop; nop; nop #else #define SAVE_30GPRS(base) stmw r2, GPR2(base) diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index 2b91f233b05d..3beecc32940b 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S @@ -226,11 +226,8 @@ _GLOBAL(tm_reclaim) =20 /* Sync the userland GPRs 2-12, 14-31 to thread->regs: */ SAVE_GPR(0, r7) /* user r0 */ - SAVE_GPR(2, r7) /* user r2 */ - SAVE_4GPRS(3, r7) /* user r3-r6 */ - SAVE_GPR(8, r7) /* user r8 */ - SAVE_GPR(9, r7) /* user r9 */ - SAVE_GPR(10, r7) /* user r10 */ + SAVE_GPRS(2, 6, r7) /* user r2-r6 */ + SAVE_GPRS(8, 10, r7) /* user r8-r10 */ ld r3, GPR1(r1) /* user r1 */ ld r4, GPR7(r1) /* user r7 */ ld r5, GPR11(r1) /* user r11 */ @@ -445,12 +442,8 @@ restore_gprs: ld r6, THREAD_TM_PPR(r3) =20 REST_GPR(0, r7) /* GPR0 */ - REST_2GPRS(2, r7) /* GPR2-3 */ - REST_GPR(4, r7) /* GPR4 */ - REST_4GPRS(8, r7) /* GPR8-11 */ - REST_2GPRS(12, r7) /* GPR12-13 */ - - REST_NVGPRS(r7) /* GPR14-31 */ + REST_GPRS(2, 4, r7) /* GPR2-4 */ + REST_GPRS(8, 31, r7) /* GPR8-31 */ =20 /* Load up PPR and DSCR here so we don't run with user values for long */ mtspr SPRN_DSCR, r5 diff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerpc/= kernel/trace/ftrace_64_mprofile.S index f9fd5f743eba..d636fc755f60 100644 --- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S +++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S @@ -41,15 +41,14 @@ _GLOBAL(ftrace_regs_caller) =20 /* Save all gprs to pt_regs */ SAVE_GPR(0, r1) - SAVE_10GPRS(2, r1) + SAVE_GPRS(2, 11, r1) =20 /* Ok to continue? */ lbz r3, PACA_FTRACE_ENABLED(r13) cmpdi r3, 0 beq ftrace_no_trace =20 - SAVE_10GPRS(12, r1) - SAVE_10GPRS(22, r1) + SAVE_GPRS(12, 31, r1) =20 /* Save previous stack pointer (r1) */ addi r8, r1, SWITCH_FRAME_SIZE @@ -108,10 +107,8 @@ ftrace_regs_call: #endif =20 /* Restore gprs */ - REST_GPR(0,r1) - REST_10GPRS(2,r1) - REST_10GPRS(12,r1) - REST_10GPRS(22,r1) + REST_GPR(0, r1) + REST_GPRS(2, 31, r1) =20 /* Restore possibly modified LR */ ld r0, _LINK(r1) @@ -157,7 +154,7 @@ _GLOBAL(ftrace_caller) stdu r1, -SWITCH_FRAME_SIZE(r1) =20 /* Save all gprs to pt_regs */ - SAVE_8GPRS(3, r1) + SAVE_GPRS(3, 10, r1) =20 lbz r3, PACA_FTRACE_ENABLED(r13) cmpdi r3, 0 @@ -194,7 +191,7 @@ ftrace_call: mtctr r3 =20 /* Restore gprs */ - REST_8GPRS(3,r1) + REST_GPRS(3, 10, r1) =20 /* Restore callee's TOC */ ld r2, 24(r1) diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/boo= k3s_hv_rmhandlers.S index 32a4b4d412b9..81fc1e0ebe9a 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -2711,8 +2711,7 @@ kvmppc_bad_host_intr: std r0, GPR0(r1) std r9, GPR1(r1) std r2, GPR2(r1) - SAVE_4GPRS(3, r1) - SAVE_2GPRS(7, r1) + SAVE_GPRS(3, 8, r1) srdi r0, r12, 32 clrldi r12, r12, 32 std r0, _CCR(r1) @@ -2735,7 +2734,7 @@ kvmppc_bad_host_intr: ld r9, HSTATE_SCRATCH2(r13) ld r12, HSTATE_SCRATCH0(r13) GET_SCRATCH0(r0) - SAVE_4GPRS(9, r1) + SAVE_GPRS(9, 12, r1) std r0, GPR13(r1) SAVE_NVGPRS(r1) ld r5, HSTATE_CFAR(r13) diff --git a/arch/powerpc/lib/test_emulate_step_exec_instr.S b/arch/powerpc= /lib/test_emulate_step_exec_instr.S index 9ef941d958d8..5473f9d03df3 100644 --- a/arch/powerpc/lib/test_emulate_step_exec_instr.S +++ b/arch/powerpc/lib/test_emulate_step_exec_instr.S @@ -37,7 +37,7 @@ _GLOBAL(exec_instr) * The stack pointer (GPR1) and the thread pointer (GPR13) are not * saved as these should not be modified anyway. */ - SAVE_2GPRS(2, r1) + SAVE_GPRS(2, 3, r1) SAVE_NVGPRS(r1) =20 /* @@ -75,8 +75,7 @@ _GLOBAL(exec_instr) =20 /* Load GPRs from pt_regs */ REST_GPR(0, r31) - REST_10GPRS(2, r31) - REST_GPR(12, r31) + REST_GPRS(2, 12, r31) REST_NVGPRS(r31) =20 /* Placeholder for the test instruction */ @@ -99,8 +98,7 @@ _GLOBAL(exec_instr) subi r3, r3, GPR0 SAVE_GPR(0, r3) SAVE_GPR(2, r3) - SAVE_8GPRS(4, r3) - SAVE_GPR(12, r3) + SAVE_GPRS(4, 12, r3) SAVE_NVGPRS(r3) =20 /* Save resulting LR to pt_regs */ --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 EC4D6C43334 for ; Mon, 11 Jul 2022 09:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233774AbiGKJuV (ORCPT ); Mon, 11 Jul 2022 05:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbiGKJtV (ORCPT ); Mon, 11 Jul 2022 05:49:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4088223BC3; Mon, 11 Jul 2022 02:24: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 EBBE8B80E8B; Mon, 11 Jul 2022 09:24:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40E44C34115; Mon, 11 Jul 2022 09:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531446; bh=cHPd56qosha3JEpRvPuMYx+vO1CJT2wmAfE0skjLUpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jf0MF/yOdV/4ElmbLPSCkLINZd/wXuJuucFSzJfqoAp2Jl4ws0XRHw/k3XRlPtYZD DEMWVAXe2qqhlttSmtvv8AVLzvYm33o1A3nQjko/rYxZlF4tnzNZomMwhjh+jmn46/ cRlFDZ1LWxgXcBr23XIYR8VkEDxd1TggMbE2pLtM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Michael Neuling , Michael Ellerman , Sasha Levin Subject: [PATCH 5.15 108/230] powerpc/tm: Fix more userspace r13 corruption Date: Mon, 11 Jul 2022 11:06:04 +0200 Message-Id: <20220711090607.131735800@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Nicholas Piggin [ Upstream commit 9d71165d3934e607070c4e48458c0cf161b1baea ] Commit cf13435b730a ("powerpc/tm: Fix userspace r13 corruption") fixes a problem in treclaim where a SLB miss can occur on the thread_struct->ckpt_regs while SCRATCH0 is live with the saved user r13 value, clobbering it with the kernel r13 and ultimately resulting in kernel r13 being stored in ckpt_regs. There is an equivalent problem in trechkpt where the user r13 value is loaded into r13 from chkpt_regs to be recheckpointed, but a SLB miss could occur on ckpt_regs accesses after that, which will result in r13 being clobbered with a kernel value and that will get recheckpointed and then restored to user registers. The same memory page is accessed right before this critical window where a SLB miss could cause corruption, so hitting the bug requires the SLB entry be removed within a small window of instructions, which is possible if a SLB related MCE hits there. PAPR also permits the hypervisor to discard this SLB entry (because slb_shadow->persistent is only set to SLB_NUM_BOLTED) although it's not known whether any implementations would do this (KVM does not). So this is an extremely unlikely bug, only found by inspection. Fix this by also storing user r13 in a temporary location on the kernel stack and don't change the r13 register from kernel r13 until the RI=3D0 critical section that does not fault. The SCRATCH0 change is not strictly part of the fix, it's only used in the RI=3D0 section so it does not have the same problem as the previous SCRATCH0 bug. Fixes: 98ae22e15b43 ("powerpc: Add helper functions for transactional memor= y context switching") Cc: stable@vger.kernel.org # v3.9+ Signed-off-by: Nicholas Piggin Acked-by: Michael Neuling Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220311024733.48926-1-npiggin@gmail.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/kernel/tm.S | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index 3beecc32940b..5a0f023a26e9 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S @@ -443,7 +443,8 @@ restore_gprs: =20 REST_GPR(0, r7) /* GPR0 */ REST_GPRS(2, 4, r7) /* GPR2-4 */ - REST_GPRS(8, 31, r7) /* GPR8-31 */ + REST_GPRS(8, 12, r7) /* GPR8-12 */ + REST_GPRS(14, 31, r7) /* GPR14-31 */ =20 /* Load up PPR and DSCR here so we don't run with user values for long */ mtspr SPRN_DSCR, r5 @@ -479,18 +480,24 @@ restore_gprs: REST_GPR(6, r7) =20 /* - * Store r1 and r5 on the stack so that we can access them after we - * clear MSR RI. + * Store user r1 and r5 and r13 on the stack (in the unused save + * areas / compiler reserved areas), so that we can access them after + * we clear MSR RI. */ =20 REST_GPR(5, r7) std r5, -8(r1) - ld r5, GPR1(r7) + ld r5, GPR13(r7) std r5, -16(r1) + ld r5, GPR1(r7) + std r5, -24(r1) =20 REST_GPR(7, r7) =20 - /* Clear MSR RI since we are about to use SCRATCH0. EE is already off */ + /* Stash the stack pointer away for use after recheckpoint */ + std r1, PACAR1(r13) + + /* Clear MSR RI since we are about to clobber r13. EE is already off */ li r5, 0 mtmsrd r5, 1 =20 @@ -501,9 +508,9 @@ restore_gprs: * until we turn MSR RI back on. */ =20 - SET_SCRATCH0(r1) ld r5, -8(r1) - ld r1, -16(r1) + ld r13, -16(r1) + ld r1, -24(r1) =20 /* Commit register state as checkpointed state: */ TRECHKPT @@ -519,9 +526,9 @@ restore_gprs: */ =20 GET_PACA(r13) - GET_SCRATCH0(r1) + ld r1, PACAR1(r13) =20 - /* R1 is restored, so we are recoverable again. EE is still off */ + /* R13, R1 is restored, so we are recoverable again. EE is still off */ li r4, MSR_RI mtmsrd r4, 1 =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 2C1C2C433EF for ; Mon, 11 Jul 2022 09:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233772AbiGKJu1 (ORCPT ); Mon, 11 Jul 2022 05:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233858AbiGKJtW (ORCPT ); Mon, 11 Jul 2022 05:49:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F43124940; Mon, 11 Jul 2022 02:24: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 dfw.source.kernel.org (Postfix) with ESMTPS id 17CA06124E; Mon, 11 Jul 2022 09:24:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23856C341C8; Mon, 11 Jul 2022 09:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531449; bh=lRISEmsP/F7+HXwJ+1ZXXTgip6J9+k9Li3ei1iTB2z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZdOgsDN1Lft8HUd6fSo/jg/eVZnl8T/dWG9Bu+1TGLIPJrxMhJsBkKrAF6tI1t/0 p/Wxh19+lB6mQkGgUJmPqrlejZPTXcCutjlcnWkvwnBK5/d0A2h19v6iCbhofrzeM/ SaIL2rmrjS4J+/6sKLkmq6lXKKeBTMJue2yruKl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Wang , Sasha Levin Subject: [PATCH 5.15 109/230] serial: sc16is7xx: Clear RS485 bits in the shutdown Date: Mon, 11 Jul 2022 11:06:05 +0200 Message-Id: <20220711090607.160112615@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Hui Wang [ Upstream commit 927728a34f11b5a27f4610bdb7068317d6fdc72a ] We tested RS485 function on an EVB which has SC16IS752, after finishing the test, we started the RS232 function test, but found the RTS is still working in the RS485 mode. That is because both startup and shutdown call port_update() to set the EFCR_REG, this will not clear the RS485 bits once the bits are set in the reconf_rs485(). To fix it, clear the RS485 bits in shutdown. Cc: Signed-off-by: Hui Wang Link: https://lore.kernel.org/r/20220308110042.108451-1-hui.wang@canonical.= com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/serial/sc16is7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 0ab788058fa2..e98aa7b97cc5 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1055,10 +1055,12 @@ static void sc16is7xx_shutdown(struct uart_port *po= rt) =20 /* Disable all interrupts */ sc16is7xx_port_write(port, SC16IS7XX_IER_REG, 0); - /* Disable TX/RX */ + /* Disable TX/RX, clear auto RS485 and RTS invert */ sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, SC16IS7XX_EFCR_RXDISABLE_BIT | - SC16IS7XX_EFCR_TXDISABLE_BIT, + SC16IS7XX_EFCR_TXDISABLE_BIT | + SC16IS7XX_EFCR_AUTO_RS485_BIT | + SC16IS7XX_EFCR_RTS_INVERT_BIT, SC16IS7XX_EFCR_RXDISABLE_BIT | SC16IS7XX_EFCR_TXDISABLE_BIT); =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 63F40C433EF for ; Mon, 11 Jul 2022 09:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233799AbiGKJug (ORCPT ); Mon, 11 Jul 2022 05:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233870AbiGKJtX (ORCPT ); Mon, 11 Jul 2022 05:49:23 -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 611D623BD6; Mon, 11 Jul 2022 02:24: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 C73AB612FE; Mon, 11 Jul 2022 09:24:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1233C34115; Mon, 11 Jul 2022 09:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531452; bh=BhTQ1+OzpOMgF/TPBqjizHXL4xPWjSslKZNPIH5xw8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djda2JJbyu9+W0PFokRJbzAMmFQaBJjoFI6PLErUK4vaMvgbwX6MQVD+M1c+t+8ib pvsVou0n3sh5mXguoWk5v4E18wO6CtQQDNKmY9tn3DwanY5M3WP1uKUjcHMjT9m7qX DS0DbX66Np3/wNJhFvOiv4jopMQnwwRf8aCWWw6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manivannan Sadhasivam , Kees Cook , Manivannan Sadhasivam , Sasha Levin Subject: [PATCH 5.15 110/230] bus: mhi: core: Use correctly sized arguments for bit field Date: Mon, 11 Jul 2022 11:06:06 +0200 Message-Id: <20220711090607.187942873@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 5a717e93239fc373a314e03e45c43b62ebea1b26 ] The find.h APIs are designed to be used only on unsigned long arguments. This can technically result in a over-read, but it is harmless in this case. Regardless, fix it to avoid the warning seen under -Warray-bounds, which we'd like to enable globally: In file included from ./include/linux/bitmap.h:9, from ./include/linux/cpumask.h:12, from ./arch/x86/include/asm/cpumask.h:5, from ./arch/x86/include/asm/msr.h:11, from ./arch/x86/include/asm/processor.h:22, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:60, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:55, from ./include/linux/wait.h:9, from ./include/linux/wait_bit.h:8, from ./include/linux/fs.h:6, from ./include/linux/debugfs.h:15, from drivers/bus/mhi/core/init.c:7: drivers/bus/mhi/core/init.c: In function 'to_mhi_pm_state_str': ./include/linux/find.h:187:37: warning: array subscript 'long unsigned int[= 0]' is partly outside array bounds of 'enum mhi_pm_state[1]' [-Warray-bound= s] 187 | unsigned long val =3D *addr & GENMASK(size - 1, 0); | ^~~~~ drivers/bus/mhi/core/init.c:80:51: note: while referencing 'state' 80 | const char *to_mhi_pm_state_str(enum mhi_pm_state state) | ~~~~~~~~~~~~~~~~~~^~~~~ Link: https://lore.kernel.org/r/20211215232446.2069794-1-keescook@chromium.= org [mani: changed the variable name "bits" to "pm_state"] Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kees Cook Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20211216081227.237749-10-manivannan.sadhasi= vam@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/bus/mhi/core/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 4183945fc2c4..c0187367ae75 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -79,7 +79,8 @@ static const char * const mhi_pm_state_str[] =3D { =20 const char *to_mhi_pm_state_str(enum mhi_pm_state state) { - int index =3D find_last_bit((unsigned long *)&state, 32); + unsigned long pm_state =3D state; + int index =3D find_last_bit(&pm_state, 32); =20 if (index >=3D ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 DA871C43334 for ; Mon, 11 Jul 2022 09:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233822AbiGKJun (ORCPT ); Mon, 11 Jul 2022 05:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233901AbiGKJt1 (ORCPT ); Mon, 11 Jul 2022 05:49:27 -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 733A330F45; Mon, 11 Jul 2022 02:24: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 ams.source.kernel.org (Postfix) with ESMTPS id 21E32B80E7E; Mon, 11 Jul 2022 09:24:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81B98C34115; Mon, 11 Jul 2022 09:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531454; bh=sVckVqzBuaFdEfw03NQFhajl30hVv6q9ySlGu3DcHQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v2ssL892MUqOLY3UBgcUdW1bQQcepcSb3e5AFsB8XLtO9Zw1UifrSrLQecFWmL4SU uVMwPoH2lfG2IvtpUVorkCiNSmuyUw6Y/wXsDx8zJTBMNknkvyeBa19UocvpOes8Pm 9Lx+T61U3tJtgQGvc+Soaq32JJWPgebxhOAJE1CQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manivannan Sadhasivam , Hemant Kumar , Alex Elder , Paul Davey , Manivannan Sadhasivam , Sasha Levin Subject: [PATCH 5.15 111/230] bus: mhi: Fix pm_state conversion to string Date: Mon, 11 Jul 2022 11:06:07 +0200 Message-Id: <20220711090607.215407115@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Paul Davey [ Upstream commit 64f93a9a27c1970fa8ee5ffc5a6ae2bda477ec5b ] On big endian architectures the mhi debugfs files which report pm state give "Invalid State" for all states. This is caused by using find_last_bit which takes an unsigned long* while the state is passed in as an enum mhi_pm_state which will be of int size. Fix by using __fls to pass the value of state instead of find_last_bit. Also the current API expects "mhi_pm_state" enumerator as the function argument but the function only works with bitmasks. So as Alex suggested, let's change the argument to u32 to avoid confusion. Fixes: a6e2e3522f29 ("bus: mhi: core: Add support for PM state transitions") Cc: stable@vger.kernel.org [mani: changed the function argument to u32] Reviewed-by: Manivannan Sadhasivam Reviewed-by: Hemant Kumar Reviewed-by: Alex Elder Signed-off-by: Paul Davey Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20220301160308.107452-3-manivannan.sadhasiv= am@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/bus/mhi/core/init.c | 10 ++++++---- drivers/bus/mhi/core/internal.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index c0187367ae75..d8787aaa176b 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -77,12 +77,14 @@ static const char * const mhi_pm_state_str[] =3D { [MHI_PM_STATE_LD_ERR_FATAL_DETECT] =3D "Linkdown or Error Fatal Detect", }; =20 -const char *to_mhi_pm_state_str(enum mhi_pm_state state) +const char *to_mhi_pm_state_str(u32 state) { - unsigned long pm_state =3D state; - int index =3D find_last_bit(&pm_state, 32); + int index; =20 - if (index >=3D ARRAY_SIZE(mhi_pm_state_str)) + if (state) + index =3D __fls(state); + + if (!state || index >=3D ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; =20 return mhi_pm_state_str[index]; diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/interna= l.h index c02c4d48b744..71f181402be9 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -622,7 +622,7 @@ void mhi_free_bhie_table(struct mhi_controller *mhi_cnt= rl, enum mhi_pm_state __must_check mhi_tryset_pm_state( struct mhi_controller *mhi_cntrl, enum mhi_pm_state state); -const char *to_mhi_pm_state_str(enum mhi_pm_state state); +const char *to_mhi_pm_state_str(u32 state); int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, enum dev_st_transition state); void mhi_pm_st_worker(struct work_struct *work); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 CB085C43334 for ; Mon, 11 Jul 2022 09:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233617AbiGKJur (ORCPT ); Mon, 11 Jul 2022 05:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbiGKJtf (ORCPT ); Mon, 11 Jul 2022 05:49:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2738E4B0CB; Mon, 11 Jul 2022 02:24: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 2C710612B7; Mon, 11 Jul 2022 09:24:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B718C34115; Mon, 11 Jul 2022 09:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531457; bh=SHtzspCuhbnM1/YWBdJUS3Fsa20mVhf+ATOcOxMdMA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPnwAFAchAtVt85Lu6VC32sb9xPwnzia/rg/u5uYNw0XSlTCjtrdKXKJcVrutsHLC ULihrM6CENp0zex0h2siDkuDqGFSMv5F2OM6xGGTmZux09J7xtgTq3FTjUDYDJQ1q/ 44C7zkpEwnsDxMAdTbsW4XdsrkDqYM/Fi4t6XsMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "Gustavo A. R. Silva" , Kees Cook , Sasha Levin Subject: [PATCH 5.15 112/230] stddef: Introduce DECLARE_FLEX_ARRAY() helper Date: Mon, 11 Jul 2022 11:06:08 +0200 Message-Id: <20220711090607.243974627@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 3080ea5553cc909b000d1f1d964a9041962f2c5b ] There are many places where kernel code wants to have several different typed trailing flexible arrays. This would normally be done with multiple flexible arrays in a union, but since GCC and Clang don't (on the surface) allow this, there have been many open-coded workarounds, usually involving neighboring 0-element arrays at the end of a structure. For example, instead of something like this: struct thing { ... union { struct type1 foo[]; struct type2 bar[]; }; }; code works around the compiler with: struct thing { ... struct type1 foo[0]; struct type2 bar[]; }; Another case is when a flexible array is wanted as the single member within a struct (which itself is usually in a union). For example, this would be worked around as: union many { ... struct { struct type3 baz[0]; }; }; These kinds of work-arounds cause problems with size checks against such zero-element arrays (for example when building with -Warray-bounds and -Wzero-length-bounds, and with the coming FORTIFY_SOURCE improvements), so they must all be converted to "real" flexible arrays, avoiding warnings like this: fs/hpfs/anode.c: In function 'hpfs_add_sector_to_btree': fs/hpfs/anode.c:209:27: warning: array subscript 0 is outside the bounds of= an interior zero-length array 'struct bplus_internal_node[0]' [-Wzero-leng= th-bounds] 209 | anode->btree.u.internal[0].down =3D cpu_to_le32(a); | ~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from fs/hpfs/hpfs_fn.h:26, from fs/hpfs/anode.c:10: fs/hpfs/hpfs.h:412:32: note: while referencing 'internal' 412 | struct bplus_internal_node internal[0]; /* (internal) 2-word en= tries giving | ^~~~~~~~ drivers/net/can/usb/etas_es58x/es58x_fd.c: In function 'es58x_fd_tx_can_msg= ': drivers/net/can/usb/etas_es58x/es58x_fd.c:360:35: warning: array subscript = 65535 is outside the bounds of an interior zero-length array 'u8[0]' {aka '= unsigned char[]'} [-Wzero-length-bounds] 360 | tx_can_msg =3D (typeof(tx_can_msg))&es58x_fd_urb_cmd->raw_msg[msg_= len]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~ In file included from drivers/net/can/usb/etas_es58x/es58x_core.h:22, from drivers/net/can/usb/etas_es58x/es58x_fd.c:17: drivers/net/can/usb/etas_es58x/es58x_fd.h:231:6: note: while referencing 'r= aw_msg' 231 | u8 raw_msg[0]; | ^~~~~~~ However, it _is_ entirely possible to have one or more flexible arrays in a struct or union: it just has to be in another struct. And since it cannot be alone in a struct, such a struct must have at least 1 other named member -- but that member can be zero sized. Wrap all this nonsense into the new DECLARE_FLEX_ARRAY() in support of having flexible arrays in unions (or alone in a struct). As with struct_group(), since this is needed in UAPI headers as well, implement the core there, with a non-UAPI wrapper. Additionally update kernel-doc to understand its existence. https://github.com/KSPP/linux/issues/137 Cc: Arnd Bergmann Cc: "Gustavo A. R. Silva" Signed-off-by: Kees Cook Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/stddef.h | 13 +++++++++++++ include/uapi/linux/stddef.h | 16 ++++++++++++++++ scripts/kernel-doc | 2 ++ 3 files changed, 31 insertions(+) diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 938216f8ab7e..31fdbb784c24 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -84,4 +84,17 @@ enum { #define struct_group_tagged(TAG, NAME, MEMBERS...) \ __struct_group(TAG, NAME, /* no attrs */, MEMBERS) =20 +/** + * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define DECLARE_FLEX_ARRAY(TYPE, NAME) \ + __DECLARE_FLEX_ARRAY(TYPE, NAME) + #endif diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index 610204f7c275..3021ea25a284 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -25,3 +25,19 @@ struct { MEMBERS } ATTRS; \ struct TAG { MEMBERS } ATTRS NAME; \ } + +/** + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ + struct { \ + struct { } __empty_ ## NAME; \ + TYPE NAME[]; \ + } diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 38aa799a776c..5d54b57ff90c 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1263,6 +1263,8 @@ sub dump_struct($$) { $members =3D~ s/DECLARE_KFIFO\s*\($args,\s*$args,\s*$args\)/$2 \*$1/gos; # replace DECLARE_KFIFO_PTR $members =3D~ s/DECLARE_KFIFO_PTR\s*\($args,\s*$args\)/$2 \*$1/gos; + # replace DECLARE_FLEX_ARRAY + $members =3D~ s/(?:__)?DECLARE_FLEX_ARRAY\s*\($args,\s*$args\)/$1 $2\[\]/= gos; my $declaration =3D $members; =20 # Split nested struct/union elements as newer ones --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 862C8C43334 for ; Mon, 11 Jul 2022 09:51:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233779AbiGKJu7 (ORCPT ); Mon, 11 Jul 2022 05:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233672AbiGKJt7 (ORCPT ); Mon, 11 Jul 2022 05:49:59 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE27022BDD; Mon, 11 Jul 2022 02:24: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 sin.source.kernel.org (Postfix) with ESMTPS id 56508CE1264; Mon, 11 Jul 2022 09:24:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E788C341C8; Mon, 11 Jul 2022 09:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531460; bh=V+WDw0l5UMQAs734NnB/Vod18HHkXveYEPQ8H8oYbvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWNbtq3QcTvnFeTkN0WH+5GNWu79Y5aTpk4pzAFnOifrvHuuX9DulPT0yYe9+ek5h aVkGW2G85j8RvyGKEJ/D+XqbH/Re7APJ2Xr3T8U5CtTAaiqS9a1YsvS3/u3U4G3toF q5TDjOUwcdan5B3NlZdaP2/jbBMm7jMBFIDGspDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tadeusz Struk , Kees Cook , Sasha Levin Subject: [PATCH 5.15 113/230] uapi/linux/stddef.h: Add include guards Date: Mon, 11 Jul 2022 11:06:09 +0200 Message-Id: <20220711090607.272184014@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tadeusz Struk [ Upstream commit 55037ed7bdc62151a726f5685f88afa6a82959b1 ] Add include guard wrapper define to uapi/linux/stddef.h to prevent macro redefinition errors when stddef.h is included more than once. This was not needed before since the only contents already used a redefinition test. Signed-off-by: Tadeusz Struk Link: https://lore.kernel.org/r/20220329171252.57279-1-tadeusz.struk@linaro= .org Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/uapi/linux/stddef.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index 3021ea25a284..7837ba4fe728 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_STDDEF_H +#define _UAPI_LINUX_STDDEF_H + #include =20 #ifndef __always_inline @@ -41,3 +44,4 @@ struct { } __empty_ ## NAME; \ TYPE NAME[]; \ } +#endif --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 60F46C433EF for ; Mon, 11 Jul 2022 09:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233699AbiGKJu4 (ORCPT ); Mon, 11 Jul 2022 05:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233653AbiGKJtv (ORCPT ); Mon, 11 Jul 2022 05:49:51 -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 7923B23BE1; Mon, 11 Jul 2022 02:24: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 dfw.source.kernel.org (Postfix) with ESMTPS id 071F161137; Mon, 11 Jul 2022 09:24:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FD7CC34115; Mon, 11 Jul 2022 09:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531463; bh=VaAKUmeoSHCUKx+/wcTdAV8VPn+5DYvP1BM4UbaOHhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckKnu7wl2jTD/+Lgwh5I4uMWfFaCkYikyvORxl4GoVZ1h4RxmCn4zw0X8QDAfM79e Btx4q4t8zhtAHWYNDK3dATGAX3TfA4TDAIBvNxCn10LqBItcgoaVFF7p38UnnSaV9h b1ImNiaKWDUh5Wj8CIV1DBHbxymQC6qbZgtlCzZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Yu , Mark Brown , Sasha Levin Subject: [PATCH 5.15 114/230] ASoC: rt5682: move clk related code to rt5682_i2c_probe Date: Mon, 11 Jul 2022 11:06:10 +0200 Message-Id: <20220711090607.300417959@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jack Yu [ Upstream commit 57589f82762e40bdaa975d840fa2bc5157b5be95 ] The DAI clock is only used in I2S mode, to make it clear and to fix clock resource release issue, we move CCF clock related code to rt5682_i2c_probe to fix clock register/unregister issue. Signed-off-by: Jack Yu Link: https://lore.kernel.org/r/20210929054344.12112-1-jack.yu@realtek.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt5682-i2c.c | 22 +++++++++++ sound/soc/codecs/rt5682.c | 70 +++++++++++++---------------------- sound/soc/codecs/rt5682.h | 3 ++ 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index 74a1fee071dd..3d2d7c9ce66d 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -133,6 +133,8 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, =20 i2c_set_clientdata(i2c, rt5682); =20 + rt5682->i2c_dev =3D &i2c->dev; + rt5682->pdata =3D i2s_default_platform_data; =20 if (pdata) @@ -270,6 +272,26 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); } =20 +#ifdef CONFIG_COMMON_CLK + /* Check if MCLK provided */ + rt5682->mclk =3D devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(rt5682->mclk)) { + if (PTR_ERR(rt5682->mclk) !=3D -ENOENT) { + ret =3D PTR_ERR(rt5682->mclk); + return ret; + } + rt5682->mclk =3D NULL; + } + + /* Register CCF DAI clock control */ + ret =3D rt5682_register_dai_clks(rt5682); + if (ret) + return ret; + + /* Initial setup for CCF */ + rt5682->lrck[RT5682_AIF1] =3D 48000; +#endif + return devm_snd_soc_register_component(&i2c->dev, &rt5682_soc_component_dev, rt5682_dai, ARRAY_SIZE(rt5682_dai)); diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 1cd59e166cce..80d199843b8c 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -2562,7 +2562,7 @@ static int rt5682_set_bias_level(struct snd_soc_compo= nent *component, static bool rt5682_clk_check(struct rt5682_priv *rt5682) { if (!rt5682->master[RT5682_AIF1]) { - dev_dbg(rt5682->component->dev, "sysclk/dai not set correctly\n"); + dev_dbg(rt5682->i2c_dev, "sysclk/dai not set correctly\n"); return false; } return true; @@ -2573,13 +2573,15 @@ static int rt5682_wclk_prepare(struct clk_hw *hw) struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_WCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; - struct snd_soc_dapm_context *dapm =3D - snd_soc_component_get_dapm(component); + struct snd_soc_component *component; + struct snd_soc_dapm_context *dapm; =20 if (!rt5682_clk_check(rt5682)) return -EINVAL; =20 + component =3D rt5682->component; + dapm =3D snd_soc_component_get_dapm(component); + snd_soc_dapm_mutex_lock(dapm); =20 snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS"); @@ -2609,13 +2611,15 @@ static void rt5682_wclk_unprepare(struct clk_hw *hw) struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_WCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; - struct snd_soc_dapm_context *dapm =3D - snd_soc_component_get_dapm(component); + struct snd_soc_component *component; + struct snd_soc_dapm_context *dapm; =20 if (!rt5682_clk_check(rt5682)) return; =20 + component =3D rt5682->component; + dapm =3D snd_soc_component_get_dapm(component); + snd_soc_dapm_mutex_lock(dapm); =20 snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS"); @@ -2639,7 +2643,6 @@ static unsigned long rt5682_wclk_recalc_rate(struct c= lk_hw *hw, struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_WCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; const char * const clk_name =3D clk_hw_get_name(hw); =20 if (!rt5682_clk_check(rt5682)) @@ -2649,7 +2652,7 @@ static unsigned long rt5682_wclk_recalc_rate(struct c= lk_hw *hw, */ if (rt5682->lrck[RT5682_AIF1] !=3D CLK_48 && rt5682->lrck[RT5682_AIF1] !=3D CLK_44) { - dev_warn(component->dev, "%s: clk %s only support %d or %d Hz output\n", + dev_warn(rt5682->i2c_dev, "%s: clk %s only support %d or %d Hz output\n", __func__, clk_name, CLK_44, CLK_48); return 0; } @@ -2663,7 +2666,6 @@ static long rt5682_wclk_round_rate(struct clk_hw *hw,= unsigned long rate, struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_WCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; const char * const clk_name =3D clk_hw_get_name(hw); =20 if (!rt5682_clk_check(rt5682)) @@ -2673,7 +2675,7 @@ static long rt5682_wclk_round_rate(struct clk_hw *hw,= unsigned long rate, * It will force to 48kHz if not both. */ if (rate !=3D CLK_48 && rate !=3D CLK_44) { - dev_warn(component->dev, "%s: clk %s only support %d or %d Hz output\n", + dev_warn(rt5682->i2c_dev, "%s: clk %s only support %d or %d Hz output\n", __func__, clk_name, CLK_44, CLK_48); rate =3D CLK_48; } @@ -2687,7 +2689,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, un= signed long rate, struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_WCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; + struct snd_soc_component *component; struct clk_hw *parent_hw; const char * const clk_name =3D clk_hw_get_name(hw); int pre_div; @@ -2696,6 +2698,8 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, un= signed long rate, if (!rt5682_clk_check(rt5682)) return -EINVAL; =20 + component =3D rt5682->component; + /* * Whether the wclk's parent clk (mclk) exists or not, please ensure * it is fixed or set to 48MHz before setting wclk rate. It's a @@ -2705,12 +2709,12 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, = unsigned long rate, */ parent_hw =3D clk_hw_get_parent(hw); if (!parent_hw) - dev_warn(component->dev, + dev_warn(rt5682->i2c_dev, "Parent mclk of wclk not acquired in driver. Please ensure mclk was pro= vided as %d Hz.\n", CLK_PLL2_FIN); =20 if (parent_rate !=3D CLK_PLL2_FIN) - dev_warn(component->dev, "clk %s only support %d Hz input\n", + dev_warn(rt5682->i2c_dev, "clk %s only support %d Hz input\n", clk_name, CLK_PLL2_FIN); =20 /* @@ -2742,10 +2746,9 @@ static unsigned long rt5682_bclk_recalc_rate(struct = clk_hw *hw, struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_BCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; unsigned int bclks_per_wclk; =20 - bclks_per_wclk =3D snd_soc_component_read(component, RT5682_TDM_TCON_CTRL= ); + regmap_read(rt5682->regmap, RT5682_TDM_TCON_CTRL, &bclks_per_wclk); =20 switch (bclks_per_wclk & RT5682_TDM_BCLK_MS1_MASK) { case RT5682_TDM_BCLK_MS1_256: @@ -2806,20 +2809,22 @@ static int rt5682_bclk_set_rate(struct clk_hw *hw, = unsigned long rate, struct rt5682_priv *rt5682 =3D container_of(hw, struct rt5682_priv, dai_clks_hw[RT5682_DAI_BCLK_IDX]); - struct snd_soc_component *component =3D rt5682->component; + struct snd_soc_component *component; struct snd_soc_dai *dai; unsigned long factor; =20 if (!rt5682_clk_check(rt5682)) return -EINVAL; =20 + component =3D rt5682->component; + factor =3D rt5682_bclk_get_factor(rate, parent_rate); =20 for_each_component_dais(component, dai) if (dai->id =3D=3D RT5682_AIF1) break; if (!dai) { - dev_err(component->dev, "dai %d not found in component\n", + dev_err(rt5682->i2c_dev, "dai %d not found in component\n", RT5682_AIF1); return -ENODEV; } @@ -2842,10 +2847,9 @@ static const struct clk_ops rt5682_dai_clk_ops[RT568= 2_DAI_NUM_CLKS] =3D { }, }; =20 -static int rt5682_register_dai_clks(struct snd_soc_component *component) +int rt5682_register_dai_clks(struct rt5682_priv *rt5682) { - struct device *dev =3D component->dev; - struct rt5682_priv *rt5682 =3D snd_soc_component_get_drvdata(component); + struct device *dev =3D rt5682->i2c_dev; struct rt5682_platform_data *pdata =3D &rt5682->pdata; struct clk_hw *dai_clk_hw; int i, ret; @@ -2905,6 +2909,7 @@ static int rt5682_register_dai_clks(struct snd_soc_co= mponent *component) =20 return 0; } +EXPORT_SYMBOL_GPL(rt5682_register_dai_clks); #endif /* CONFIG_COMMON_CLK */ =20 static int rt5682_probe(struct snd_soc_component *component) @@ -2914,9 +2919,6 @@ static int rt5682_probe(struct snd_soc_component *com= ponent) unsigned long time; struct snd_soc_dapm_context *dapm =3D &component->dapm; =20 -#ifdef CONFIG_COMMON_CLK - int ret; -#endif rt5682->component =3D component; =20 if (rt5682->is_sdw) { @@ -2928,26 +2930,6 @@ static int rt5682_probe(struct snd_soc_component *co= mponent) dev_err(&slave->dev, "Initialization not complete, timed out\n"); return -ETIMEDOUT; } - } else { -#ifdef CONFIG_COMMON_CLK - /* Check if MCLK provided */ - rt5682->mclk =3D devm_clk_get(component->dev, "mclk"); - if (IS_ERR(rt5682->mclk)) { - if (PTR_ERR(rt5682->mclk) !=3D -ENOENT) { - ret =3D PTR_ERR(rt5682->mclk); - return ret; - } - rt5682->mclk =3D NULL; - } - - /* Register CCF DAI clock control */ - ret =3D rt5682_register_dai_clks(component); - if (ret) - return ret; - - /* Initial setup for CCF */ - rt5682->lrck[RT5682_AIF1] =3D CLK_48; -#endif } =20 snd_soc_dapm_disable_pin(dapm, "MICBIAS"); diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index 539a9fe26294..52ff0d9c36c5 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1428,6 +1428,7 @@ enum { =20 struct rt5682_priv { struct snd_soc_component *component; + struct device *i2c_dev; struct rt5682_platform_data pdata; struct regmap *regmap; struct regmap *sdw_regmap; @@ -1481,6 +1482,8 @@ void rt5682_calibrate(struct rt5682_priv *rt5682); void rt5682_reset(struct rt5682_priv *rt5682); int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev); =20 +int rt5682_register_dai_clks(struct rt5682_priv *rt5682); + #define RT5682_REG_NUM 318 extern const struct reg_default rt5682_reg[RT5682_REG_NUM]; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 56395C43334 for ; Mon, 11 Jul 2022 09:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233875AbiGKJvH (ORCPT ); Mon, 11 Jul 2022 05:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233716AbiGKJuC (ORCPT ); Mon, 11 Jul 2022 05:50:02 -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 198BD27FD0; Mon, 11 Jul 2022 02:24: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 A8A5A61137; Mon, 11 Jul 2022 09:24:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAD97C34115; Mon, 11 Jul 2022 09:24:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531466; bh=07WT9RtlxwLOxY71BOZkHyVY+aRKwX1I6w6eyvoueyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NSV4X/EPBggYQ7XgdZrPg+Ux1iUuFlLAdKlULj8ceCeMrrfrJk/qMT283/zMbumAr 0XZM3ZADC9Dgdq8IAbW0FLdIxATdYcGxiW8pjanKO7VPo3TpuBsqWBUTuyZJpC/yxh JnSk7oxrojUjwC5IF2R1yUgkQPTURVyu6VGDKnDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Mark Brown , Sasha Levin Subject: [PATCH 5.15 115/230] ASoC: rt5682: fix an incorrect NULL check on list iterator Date: Mon, 11 Jul 2022 11:06:11 +0200 Message-Id: <20220711090607.329020791@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Xiaomeng Tong [ Upstream commit c8618d65007ba68d7891130642d73e89372101e8 ] The bug is here: if (!dai) { The list iterator value 'dai' will *always* be set and non-NULL by for_each_component_dais(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found (In fact, it will be a bogus pointer to an invalid struct object containing the HEAD). Otherwise it will bypass the check 'if (!dai) {' (never call dev_err() and never return -ENODEV;) and lead to invalid memory access lately when calling 'rt5682_set_bclk1_ratio(dai, factor);'. To fix the bug, just return rt5682_set_bclk1_ratio(dai, factor); when found the 'dai', otherwise dev_err() and return -ENODEV; Cc: stable@vger.kernel.org Fixes: ebbfabc16d23d ("ASoC: rt5682: Add CCF usage for providing I2S clks") Signed-off-by: Xiaomeng Tong Link: https://lore.kernel.org/r/20220327081002.12684-1-xiam0nd.tong@gmail.c= om Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt5682.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 80d199843b8c..8a9e1a4fa03e 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -2822,14 +2822,11 @@ static int rt5682_bclk_set_rate(struct clk_hw *hw, = unsigned long rate, =20 for_each_component_dais(component, dai) if (dai->id =3D=3D RT5682_AIF1) - break; - if (!dai) { - dev_err(rt5682->i2c_dev, "dai %d not found in component\n", - RT5682_AIF1); - return -ENODEV; - } + return rt5682_set_bclk1_ratio(dai, factor); =20 - return rt5682_set_bclk1_ratio(dai, factor); + dev_err(rt5682->i2c_dev, "dai %d not found in component\n", + RT5682_AIF1); + return -ENODEV; } =20 static const struct clk_ops rt5682_dai_clk_ops[RT5682_DAI_NUM_CLKS] =3D { --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 3359DCCA47B for ; Mon, 11 Jul 2022 09:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233790AbiGKJvP (ORCPT ); Mon, 11 Jul 2022 05:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233761AbiGKJuQ (ORCPT ); Mon, 11 Jul 2022 05:50:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1ACA31224; Mon, 11 Jul 2022 02:24: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 699E16112E; Mon, 11 Jul 2022 09:24:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79C8DC34115; Mon, 11 Jul 2022 09:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531468; bh=U0t7320AYDbcwwyLOZh9lTpswuXbCQhm6S7HxSJKKR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FO4CnZ996AG2Sv7sveLFVeXtG86KHWUtMu4GotvLd5f3rdl8Rcdo1nfl1c8SnOhac qMkvtsv4gdmqRXbA4rE9NBxWFlyfPVdbtmLqUAS4qTrgXxq4DWoU+MnVagWPvyHpnp J1g14BXcvXWJQ8T94VeIuEakLjrbQZc6NcpY37zg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Zhu , tiancyin , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 116/230] drm/amd/vcn: fix an error msg on vcn 3.0 Date: Mon, 11 Jul 2022 11:06:12 +0200 Message-Id: <20220711090607.357523545@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: tiancyin [ Upstream commit 425d7a87e54ee358f580eaf10cf28dc95f7121c1 ] Some video card has more than one vcn instance, passing 0 to vcn_v3_0_pause_dpg_mode is incorrect. Error msg: Register(1) [mmUVD_POWER_STATUS] failed to reach value 0x00000001 !=3D 0x00000002 Reviewed-by: James Zhu Signed-off-by: tiancyin Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/am= dgpu/vcn_v3_0.c index 6e56bef4fdf8..1310617f030f 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c @@ -1511,7 +1511,7 @@ static int vcn_v3_0_stop_dpg_mode(struct amdgpu_devic= e *adev, int inst_idx) struct dpg_pause_state state =3D {.fw_based =3D VCN_DPG_STATE__UNPAUSE}; uint32_t tmp; =20 - vcn_v3_0_pause_dpg_mode(adev, 0, &state); + vcn_v3_0_pause_dpg_mode(adev, inst_idx, &state); =20 /* Wait for power status to be 1 */ SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 066BFC43334 for ; Mon, 11 Jul 2022 09:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233901AbiGKJvU (ORCPT ); Mon, 11 Jul 2022 05:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233629AbiGKJuc (ORCPT ); Mon, 11 Jul 2022 05:50:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81EB8313A8; Mon, 11 Jul 2022 02:24:35 -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 1450A61363; Mon, 11 Jul 2022 09:24:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1870BC34115; Mon, 11 Jul 2022 09:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531474; bh=T+y81cV5cT0q5eTK5Na8tcQR7hBNFKwry7g91mXTPIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dXqo6La95fcm2p+nxLgBf4SPgxq+GizeP4v1GTSwNbt++90mxv9rkjkWhqE5VKrqA UzPGcv6C8CTbeH7uAeASwxcEGfUd96mFRMrdEuzCrLYibMMOGmse3dDh/B0lzkuEVl QhovAVMp99/JSATf5fmvostrVwhabMLVoClusF8g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Oliver Upton , Marc Zyngier , Sasha Levin Subject: [PATCH 5.15 117/230] KVM: Dont create VM debugfs files outside of the VM directory Date: Mon, 11 Jul 2022 11:06:13 +0200 Message-Id: <20220711090607.384854767@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Oliver Upton [ Upstream commit a44a4cc1c969afec97dbb2aedaf6f38eaa6253bb ] Unfortunately, there is no guarantee that KVM was able to instantiate a debugfs directory for a particular VM. To that end, KVM shouldn't even attempt to create new debugfs files in this case. If the specified parent dentry is NULL, debugfs_create_file() will instantiate files at the root of debugfs. For arm64, it is possible to create the vgic-state file outside of a VM directory, the file is not cleaned up when a VM is destroyed. Nonetheless, the corresponding struct kvm is freed when the VM is destroyed. Nip the problem in the bud for all possible errant debugfs file creations by initializing kvm->debugfs_dentry to -ENOENT. In so doing, debugfs_create_file() will fail instead of creating the file in the root directory. Cc: stable@kernel.org Fixes: 929f45e32499 ("kvm: no need to check return value of debugfs_create = functions") Signed-off-by: Oliver Upton Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220406235615.1447180-2-oupton@google.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- virt/kvm/kvm_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 99c591569815..9134ae252d7c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -911,7 +911,7 @@ static void kvm_destroy_vm_debugfs(struct kvm *kvm) int kvm_debugfs_num_entries =3D kvm_vm_stats_header.num_desc + kvm_vcpu_stats_header.num_desc; =20 - if (!kvm->debugfs_dentry) + if (IS_ERR(kvm->debugfs_dentry)) return; =20 debugfs_remove_recursive(kvm->debugfs_dentry); @@ -934,6 +934,12 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int = fd) int kvm_debugfs_num_entries =3D kvm_vm_stats_header.num_desc + kvm_vcpu_stats_header.num_desc; =20 + /* + * Force subsequent debugfs file creations to fail if the VM directory + * is not created. + */ + kvm->debugfs_dentry =3D ERR_PTR(-ENOENT); + if (!debugfs_initialized()) return 0; =20 @@ -5373,7 +5379,7 @@ static void kvm_uevent_notify_change(unsigned int typ= e, struct kvm *kvm) } add_uevent_var(env, "PID=3D%d", kvm->userspace_pid); =20 - if (kvm->debugfs_dentry) { + if (!IS_ERR(kvm->debugfs_dentry)) { char *tmp, *p =3D kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT); =20 if (p) { --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 38BBDC433EF for ; Mon, 11 Jul 2022 09:51:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbiGKJvX (ORCPT ); Mon, 11 Jul 2022 05:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233788AbiGKJuf (ORCPT ); Mon, 11 Jul 2022 05:50:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB73823BEF; Mon, 11 Jul 2022 02:24: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 9FF45B80E7E; Mon, 11 Jul 2022 09:24:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4040C34115; Mon, 11 Jul 2022 09:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531477; bh=RWogilwkxJcP15SAbJz7VzfvXOwDkcVEDfMpxC6e0J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0oatoPEn5pqNo8sFlsAOQ7sprBjGuW9Zss7KvK1YypjNj4jXOQ7gpB1IlltdGyOly rS1yq4ZoFEj+DE4yJrtuM2E+Uss3KnvRc+nA3Kq9B0OZ1FmQwWUNpFO5hi3k4Y7Cfh us3ZZMYfue+HHmyxx8rH+8xEYsdaSnEp0eGx3DjE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhenguo Zhao , Sasha Levin Subject: [PATCH 5.15 118/230] tty: n_gsm: Modify CR,PF bit when config requester Date: Mon, 11 Jul 2022 11:06:14 +0200 Message-Id: <20220711090607.412980854@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Zhenguo Zhao [ Upstream commit cc0f42122a7e7a5ede9c5f2a41199128b8449eda ] When n_gsm config "initiator=3D0",as requester,gsmld receives dlci SABM/DISC control command frame,but send UA frame is error. Example: Gsmld receive dlc0 SABM frame "f9 03 3f 01 1c f9",now it sends UA frame "f9 01 63 01 a3 f9",CR and PF bit are 0,but it should be set 1 from requster to initiator. Kernel test log as follows: Before modify [ 271.732031] c1 gsmld_receive: 00000000: f9 03 3f 01 1c f9 [ 271.741719] c1 <-- 0) C: SABM(P) [ 271.749483] c1 gsmld_output: 00000000: f9 01 63 01 a3 f9 [ 271.758337] c1 --> 0) R: UA(F) After modify [ 261.233188] c0 gsmld_receive: 00000000: f9 03 3f 01 1c f9 [ 261.242767] c0 <-- 0) C: SABM(P) [ 261.250497] c0 gsmld_output: 00000000: f9 03 73 01 d7 f9 [ 261.259759] c0 --> 0) C: UA(P) Signed-off-by: Zhenguo Zhao Link: https://lore.kernel.org/r/1629461872-26965-3-git-send-email-zhenguo68= 58@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 6734ef22c304..91ce8e6e889a 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -625,7 +625,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int= cr, int control) =20 static inline void gsm_response(struct gsm_mux *gsm, int addr, int control) { - gsm_send(gsm, addr, 0, control); + gsm_send(gsm, addr, 1, control); } =20 /** @@ -1818,9 +1818,9 @@ static void gsm_queue(struct gsm_mux *gsm) if (dlci =3D=3D NULL) return; if (dlci->dead) - gsm_response(gsm, address, DM); + gsm_response(gsm, address, DM|PF); else { - gsm_response(gsm, address, UA); + gsm_response(gsm, address, UA|PF); gsm_dlci_open(dlci); } break; @@ -1828,11 +1828,11 @@ static void gsm_queue(struct gsm_mux *gsm) if (cr =3D=3D 0) goto invalid; if (dlci =3D=3D NULL || dlci->state =3D=3D DLCI_CLOSED) { - gsm_response(gsm, address, DM); + gsm_response(gsm, address, DM|PF); return; } /* Real close complete */ - gsm_response(gsm, address, UA); + gsm_response(gsm, address, UA|PF); gsm_dlci_close(dlci); break; case UA|PF: --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 9BCB9C43334 for ; Mon, 11 Jul 2022 09:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233918AbiGKJv0 (ORCPT ); Mon, 11 Jul 2022 05:51:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233791AbiGKJuf (ORCPT ); Mon, 11 Jul 2022 05:50:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9584323BF8; Mon, 11 Jul 2022 02:24: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 58619B80E7A; Mon, 11 Jul 2022 09:24:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5DECC34115; Mon, 11 Jul 2022 09:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531480; bh=U0whqmfMtKkmTNWHFkRmR4u61sCo8ezj3001BZTs4fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zhdnLMmPkGIRd93HCPSlKIWPnUiqVg54w5NH1smcHz+5Oa6oRnYJ5NA+gCwG7qYWe vgg7SlWjpCZwKqkM8CFofTYsXRspAUt9qVn1gX0LUIP/b3nJPPRV7Fcpb6imvkbxsy pRiLOan2xRki0UPAdt6vE3tkHw/mZI7PiZ1HQAIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhenguo Zhao , Sasha Levin Subject: [PATCH 5.15 119/230] tty: n_gsm: Save dlci address open status when config requester Date: Mon, 11 Jul 2022 11:06:15 +0200 Message-Id: <20220711090607.441445257@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Zhenguo Zhao [ Upstream commit 0b91b5332368f2fb0c3e5cfebc6aff9e167acd8b ] When n_gsm config "initiator=3D0",as requester ,receive SABM frame,n_gsm register gsmtty dev,and save dlci open address status,if receive DLC0 DISC or CLD frame,it can unregister the gsmtty dev by saving dlci address. Signed-off-by: Zhenguo Zhao Link: https://lore.kernel.org/r/1629461872-26965-8-git-send-email-zhenguo68= 58@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 57 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 91ce8e6e889a..3038e5631be5 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -274,6 +274,10 @@ static DEFINE_SPINLOCK(gsm_mux_lock); =20 static struct tty_driver *gsm_tty_driver; =20 +/* Save dlci open address */ +static int addr_open[256] =3D { 0 }; +/* Save dlci open count */ +static int addr_cnt; /* * This section of the driver logic implements the GSM encodings * both the basic and the 'advanced'. Reliable transport is not @@ -1191,6 +1195,7 @@ static void gsm_control_rls(struct gsm_mux *gsm, cons= t u8 *data, int clen) } =20 static void gsm_dlci_begin_close(struct gsm_dlci *dlci); +static void gsm_dlci_close(struct gsm_dlci *dlci); =20 /** * gsm_control_message - DLCI 0 control processing @@ -1209,15 +1214,28 @@ static void gsm_control_message(struct gsm_mux *gsm= , unsigned int command, { u8 buf[1]; unsigned long flags; + struct gsm_dlci *dlci; + int i; + int address; =20 switch (command) { case CMD_CLD: { - struct gsm_dlci *dlci =3D gsm->dlci[0]; + if (addr_cnt > 0) { + for (i =3D 0; i < addr_cnt; i++) { + address =3D addr_open[i]; + dlci =3D gsm->dlci[address]; + gsm_dlci_close(dlci); + addr_open[i] =3D 0; + } + } /* Modem wishes to close down */ + dlci =3D gsm->dlci[0]; if (dlci) { dlci->dead =3D true; gsm->dead =3D true; - gsm_dlci_begin_close(dlci); + gsm_dlci_close(dlci); + addr_cnt =3D 0; + gsm_response(gsm, 0, UA|PF); } } break; @@ -1780,6 +1798,7 @@ static void gsm_queue(struct gsm_mux *gsm) struct gsm_dlci *dlci; u8 cr; int address; + int i, j, k, address_tmp; /* We have to sneak a look at the packet body to do the FCS. A somewhat layering violation in the spec */ =20 @@ -1822,6 +1841,11 @@ static void gsm_queue(struct gsm_mux *gsm) else { gsm_response(gsm, address, UA|PF); gsm_dlci_open(dlci); + /* Save dlci open address */ + if (address) { + addr_open[addr_cnt] =3D address; + addr_cnt++; + } } break; case DISC|PF: @@ -1832,8 +1856,33 @@ static void gsm_queue(struct gsm_mux *gsm) return; } /* Real close complete */ - gsm_response(gsm, address, UA|PF); - gsm_dlci_close(dlci); + if (!address) { + if (addr_cnt > 0) { + for (i =3D 0; i < addr_cnt; i++) { + address =3D addr_open[i]; + dlci =3D gsm->dlci[address]; + gsm_dlci_close(dlci); + addr_open[i] =3D 0; + } + } + dlci =3D gsm->dlci[0]; + gsm_dlci_close(dlci); + addr_cnt =3D 0; + gsm_response(gsm, 0, UA|PF); + } else { + gsm_response(gsm, address, UA|PF); + gsm_dlci_close(dlci); + /* clear dlci address */ + for (j =3D 0; j < addr_cnt; j++) { + address_tmp =3D addr_open[j]; + if (address_tmp =3D=3D address) { + for (k =3D j; k < addr_cnt; k++) + addr_open[k] =3D addr_open[k+1]; + addr_cnt--; + break; + } + } + } break; case UA|PF: if (cr =3D=3D 0 || dlci =3D=3D NULL) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 101FFC43334 for ; Mon, 11 Jul 2022 09:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbiGKJv2 (ORCPT ); Mon, 11 Jul 2022 05:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233793AbiGKJuf (ORCPT ); Mon, 11 Jul 2022 05:50:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE63423BFD; Mon, 11 Jul 2022 02:24:43 -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 6B23F6112E; Mon, 11 Jul 2022 09:24:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7661FC34115; Mon, 11 Jul 2022 09:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531482; bh=OztkhgOXTnGq6TpN1feISMFPe9y925sbiii4GoroiN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bruuMauYrlI7CP4o5Sz25QlCBjCFbUjsTcGhBhyVTl6Be+2PltVFVy1zO5LxUEQ9u IUen1phosbVbxsczuSG3ulKD+H9lgCAhUm8HOgE27R39XXE/+FPX992CdPeC41AvfO Jwez6+xAglluReppj821EEC61LufqAj24kKfW7WM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 5.15 120/230] tty: n_gsm: fix frame reception handling Date: Mon, 11 Jul 2022 11:06:16 +0200 Message-Id: <20220711090607.469409675@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Starke [ Upstream commit 7a0e4b1733b635026a87c023f6d703faf0095e39 ] The frame checksum (FCS) is currently handled in gsm_queue() after reception of a frame. However, this breaks layering. A workaround with 'received_fcs' was implemented so far. Furthermore, frames are handled as such even if no end flag was received. Move FCS calculation from gsm_queue() to gsm0_receive() and gsm1_receive(). Also delay gsm_queue() call there until a full frame was received to fix both points. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220414094225.4527-6-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 3038e5631be5..d3d5308daf35 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -221,7 +221,6 @@ struct gsm_mux { int encoding; u8 control; u8 fcs; - u8 received_fcs; u8 *txframe; /* TX framing buffer */ =20 /* Method for the receiver side */ @@ -1799,18 +1798,7 @@ static void gsm_queue(struct gsm_mux *gsm) u8 cr; int address; int i, j, k, address_tmp; - /* We have to sneak a look at the packet body to do the FCS. - A somewhat layering violation in the spec */ =20 - if ((gsm->control & ~PF) =3D=3D UI) - gsm->fcs =3D gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len); - if (gsm->encoding =3D=3D 0) { - /* WARNING: gsm->received_fcs is used for - gsm->encoding =3D 0 only. - In this case it contain the last piece of data - required to generate final CRC */ - gsm->fcs =3D gsm_fcs_add(gsm->fcs, gsm->received_fcs); - } if (gsm->fcs !=3D GOOD_FCS) { gsm->bad_fcs++; if (debug & 4) @@ -1997,19 +1985,25 @@ static void gsm0_receive(struct gsm_mux *gsm, unsig= ned char c) break; case GSM_DATA: /* Data */ gsm->buf[gsm->count++] =3D c; - if (gsm->count =3D=3D gsm->len) + if (gsm->count =3D=3D gsm->len) { + /* Calculate final FCS for UI frames over all data */ + if ((gsm->control & ~PF) !=3D UIH) { + gsm->fcs =3D gsm_fcs_add_block(gsm->fcs, gsm->buf, + gsm->count); + } gsm->state =3D GSM_FCS; + } break; case GSM_FCS: /* FCS follows the packet */ - gsm->received_fcs =3D c; - gsm_queue(gsm); + gsm->fcs =3D gsm_fcs_add(gsm->fcs, c); gsm->state =3D GSM_SSOF; break; case GSM_SSOF: - if (c =3D=3D GSM0_SOF) { - gsm->state =3D GSM_SEARCH; - break; - } + gsm->state =3D GSM_SEARCH; + if (c =3D=3D GSM0_SOF) + gsm_queue(gsm); + else + gsm->bad_size++; break; default: pr_debug("%s: unhandled state: %d\n", __func__, gsm->state); @@ -2038,11 +2032,24 @@ static void gsm1_receive(struct gsm_mux *gsm, unsig= ned char c) return; } if (c =3D=3D GSM1_SOF) { - /* EOF is only valid in frame if we have got to the data state - and received at least one byte (the FCS) */ - if (gsm->state =3D=3D GSM_DATA && gsm->count) { - /* Extract the FCS */ + /* EOF is only valid in frame if we have got to the data state */ + if (gsm->state =3D=3D GSM_DATA) { + if (gsm->count < 1) { + /* Missing FSC */ + gsm->malformed++; + gsm->state =3D GSM_START; + return; + } + /* Remove the FCS from data */ gsm->count--; + if ((gsm->control & ~PF) !=3D UIH) { + /* Calculate final FCS for UI frames over all + * data but FCS + */ + gsm->fcs =3D gsm_fcs_add_block(gsm->fcs, gsm->buf, + gsm->count); + } + /* Add the FCS itself to test against GOOD_FCS */ gsm->fcs =3D gsm_fcs_add(gsm->fcs, gsm->buf[gsm->count]); gsm->len =3D gsm->count; gsm_queue(gsm); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 47B93C43334 for ; Mon, 11 Jul 2022 09:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233930AbiGKJvb (ORCPT ); Mon, 11 Jul 2022 05:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbiGKJuh (ORCPT ); Mon, 11 Jul 2022 05:50:37 -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 A99BC27FF6; Mon, 11 Jul 2022 02:24:46 -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 491A16112E; Mon, 11 Jul 2022 09:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59B57C341C0; Mon, 11 Jul 2022 09:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531485; bh=utpFc4eprk1ZOCb4ywBMrgGC5I9nTAOGmMQyCLDsbcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PweaJCB26qzp9Dy5I1pLT3o49QkIMxRzSaPaZg7G2cpWhg3mw6GW6vwJBaVAwIfbR 5lN2kO4Y5qgTn7tY/XYJvkr8sQyJ2b6OYAgLLw530xSLJ6VA9cY2g3Kcgz8W0krqGI fq1wpHzpS4Zxxo6misfZCTEkFCgMx81nkQ2nk6wU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Schickel , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 121/230] ALSA: usb-audio: add mapping for MSI MPG X570S Carbon Max Wifi. Date: Mon, 11 Jul 2022 11:06:17 +0200 Message-Id: <20220711090607.497626700@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Johannes Schickel [ Upstream commit 5762f980ca10dcfe5eead7c40d1c34cae61f409b ] The USB audio device 0db0:419c based on the Realtek ALC4080 chip exposes all playback volume controls as "PCM". This is makes distinguishing the individual functions hard. The added mapping distinguishes all playback volume controls as their respective function: - Speaker - for back panel output - Frontpanel Headphone - for front panel output - IEC958 - for digital output on the back panel This clarifies the individual volume control functions for users. Signed-off-by: Johannes Schickel Link: https://lore.kernel.org/r/20220115140257.8751-1-lordhoto@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/usb/mixer_maps.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index 6ffd23f2ee65..64fdca76b40e 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -423,6 +423,14 @@ static const struct usbmix_name_map aorus_master_alc12= 20vb_map[] =3D { {} }; =20 +/* MSI MPG X570S Carbon Max Wifi with ALC4080 */ +static const struct usbmix_name_map msi_mpg_x570s_carbon_max_wifi_alc4080_= map[] =3D { + { 29, "Speaker Playback" }, + { 30, "Front Headphone Playback" }, + { 32, "IEC958 Playback" }, + {} +}; + /* * Control map entries */ @@ -574,6 +582,10 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = =3D { .map =3D trx40_mobo_map, .connector_map =3D trx40_mobo_connector_map, }, + { /* MSI MPG X570S Carbon Max Wifi */ + .id =3D USB_ID(0x0db0, 0x419c), + .map =3D msi_mpg_x570s_carbon_max_wifi_alc4080_map, + }, { /* MSI TRX40 */ .id =3D USB_ID(0x0db0, 0x543d), .map =3D trx40_mobo_map, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 AB527C433EF for ; Mon, 11 Jul 2022 09:51:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233938AbiGKJve (ORCPT ); Mon, 11 Jul 2022 05:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbiGKJuh (ORCPT ); Mon, 11 Jul 2022 05:50:37 -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 665E723150; Mon, 11 Jul 2022 02:24: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 01C2961363; Mon, 11 Jul 2022 09:24:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12865C34115; Mon, 11 Jul 2022 09:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531488; bh=sU8MHd1BAT9pPPmpxJARHgNTc6LMa/2QtgH3sVlDSB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJqGIbYlHnyo2Dn3Us2xjj2cjycwcaCndA+8VpJbngON6fGdT9lLtv8m4Ui8Esd0W BM8tGTG2u6OqIZY1DRojTqupiBDws75g1u6IbcZrZ3dzyeGFeNxd6IjPHD5MNLS7ma NIV8rQ0YnjnLcovf6w6EV9hZ0iHEqTQb3p6Nj+zM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maurizio Avogadro , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 122/230] ALSA: usb-audio: add mapping for MSI MAG X570S Torpedo MAX. Date: Mon, 11 Jul 2022 11:06:18 +0200 Message-Id: <20220711090607.526500681@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Avogadro [ Upstream commit 4ddef9c4d70aae0c9029bdec7c3f7f1c1c51ff8c ] The USB audio device 0db0:a073 based on the Realtek ALC4080 chipset exposes all playback volume controls as "PCM". This makes distinguishing the individual functions hard. The mapping already adopted for device 0db0:419c based on the same chipset fixes the issue, apply it for this device too. Signed-off-by: Maurizio Avogadro Cc: Link: https://lore.kernel.org/r/Yl1ykPaGgsFf3SnW@ryzen Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/usb/mixer_maps.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index 64fdca76b40e..997425ef0a29 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -586,6 +586,10 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = =3D { .id =3D USB_ID(0x0db0, 0x419c), .map =3D msi_mpg_x570s_carbon_max_wifi_alc4080_map, }, + { /* MSI MAG X570S Torpedo Max */ + .id =3D USB_ID(0x0db0, 0xa073), + .map =3D msi_mpg_x570s_carbon_max_wifi_alc4080_map, + }, { /* MSI TRX40 */ .id =3D USB_ID(0x0db0, 0x543d), .map =3D trx40_mobo_map, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 6B00BC43334 for ; Mon, 11 Jul 2022 09:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233946AbiGKJvh (ORCPT ); Mon, 11 Jul 2022 05:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233806AbiGKJuh (ORCPT ); Mon, 11 Jul 2022 05:50: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 9C61F23BDE; Mon, 11 Jul 2022 02:24: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 sin.source.kernel.org (Postfix) with ESMTPS id DC23ECE1257; Mon, 11 Jul 2022 09:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7BF7C34115; Mon, 11 Jul 2022 09:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531491; bh=Ogtk9ds9PUoZv1yHNlKP+Gp/qGJsLeUWAZAHVWnzl1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSeXE8Mbi03DbJG58PrIk3rl6YxsVxa1JTXvzTCrpR3Vw7VpCInx416xpw0FM+Dn1 LJA0yFf/NC+bnqJld3XN8i++G4nA7jmMOLrdq3nPDWi+9i4+sHdZ2i0Ng1MIGa8Vge ZteJFMHKy8fg2IqK4nJagkKuvtdt1u5fEyzM/DM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 5.15 123/230] tty: n_gsm: fix missing update of modem controls after DLCI open Date: Mon, 11 Jul 2022 11:06:19 +0200 Message-Id: <20220711090607.554714477@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Starke [ Upstream commit 48473802506d2d6151f59e0e764932b33b53cb3b ] Currently the peer is not informed about the initial state of the modem control lines after a new DLCI has been opened. Fix this by sending the initial modem control line states after DLCI open. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220420101346.3315-1-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index d3d5308daf35..c52d5e0d5c6f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -371,6 +371,7 @@ static const u8 gsm_fcs8[256] =3D { #define GOOD_FCS 0xCF =20 static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len); +static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk); =20 /** * gsm_fcs_add - update FCS @@ -1489,6 +1490,9 @@ static void gsm_dlci_open(struct gsm_dlci *dlci) dlci->state =3D DLCI_OPEN; if (debug & 8) pr_debug("DLCI %d goes open.\n", dlci->addr); + /* Send current modem state */ + if (dlci->addr) + gsmtty_modem_update(dlci, 0); wake_up(&dlci->gsm->event); } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 440F0C433EF for ; Mon, 11 Jul 2022 09:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbiGKJvo (ORCPT ); Mon, 11 Jul 2022 05:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbiGKJuh (ORCPT ); Mon, 11 Jul 2022 05:50:37 -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 AABE3248D4; Mon, 11 Jul 2022 02:24: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 49F87B80D2C; Mon, 11 Jul 2022 09:24:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E95C34115; Mon, 11 Jul 2022 09:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531494; bh=Z0FI6AxhInGWtJD1LczNEjiGeOd7WuiQcvBy+zjdl9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIQ5t1pGMBbpx/YLAiWMKTn+cag93ru9wVxZIPYBdcjoti/0n2G4NpYbulbsac1AX hybHJJWzu6agpr/NcoAkSanb9X3LOrKxu6CZIiZBhgG4VeWeaqUiQK8jD4GVK72Ux2 UiPg+IyhYNtzteS68XXqvWaUmfSseRVHUZBrNhPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Johannes Thumshirn , David Sterba , Sasha Levin Subject: [PATCH 5.15 124/230] btrfs: zoned: encapsulate inode locking for zoned relocation Date: Mon, 11 Jul 2022 11:06:20 +0200 Message-Id: <20220711090607.582974972@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Johannes Thumshirn [ Upstream commit 869f4cdc73f9378986755030c684c011f0b71517 ] Encapsulate the inode lock needed for serializing the data relocation writes on a zoned filesystem into a helper. This streamlines the code reading flow and hides special casing for zoned filesystems. Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/extent_io.c | 8 ++------ fs/btrfs/zoned.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 6dd375ed6e3d..059bd0753e27 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5139,8 +5139,6 @@ int extent_writepages(struct address_space *mapping, struct writeback_control *wbc) { struct inode *inode =3D mapping->host; - const bool data_reloc =3D btrfs_is_data_reloc_root(BTRFS_I(inode)->root); - const bool zoned =3D btrfs_is_zoned(BTRFS_I(inode)->root->fs_info); int ret =3D 0; struct extent_page_data epd =3D { .bio_ctrl =3D { 0 }, @@ -5152,11 +5150,9 @@ int extent_writepages(struct address_space *mapping, * Allow only a single thread to do the reloc work in zoned mode to * protect the write pointer updates. */ - if (data_reloc && zoned) - btrfs_inode_lock(inode, 0); + btrfs_zoned_data_reloc_lock(BTRFS_I(inode)); ret =3D extent_write_cache_pages(mapping, wbc, &epd); - if (data_reloc && zoned) - btrfs_inode_unlock(inode, 0); + btrfs_zoned_data_reloc_unlock(BTRFS_I(inode)); ASSERT(ret <=3D 0); if (ret < 0) { end_write_bio(&epd, ret); diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 813aa3cddc11..d680c3ee918a 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -8,6 +8,7 @@ #include "volumes.h" #include "disk-io.h" #include "block-group.h" +#include "btrfs_inode.h" =20 /* * Block groups with more than this value (percents) of unusable space wil= l be @@ -324,4 +325,20 @@ static inline void btrfs_clear_treelog_bg(struct btrfs= _block_group *bg) spin_unlock(&fs_info->treelog_bg_lock); } =20 +static inline void btrfs_zoned_data_reloc_lock(struct btrfs_inode *inode) +{ + struct btrfs_root *root =3D inode->root; + + if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) + btrfs_inode_lock(&inode->vfs_inode, 0); +} + +static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode) +{ + struct btrfs_root *root =3D inode->root; + + if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) + btrfs_inode_unlock(&inode->vfs_inode, 0); +} + #endif --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 094C2C43334 for ; Mon, 11 Jul 2022 09:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbiGKJvu (ORCPT ); Mon, 11 Jul 2022 05:51:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbiGKJui (ORCPT ); Mon, 11 Jul 2022 05:50:38 -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 D7C50248FF; Mon, 11 Jul 2022 02:24: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 4E6B66112E; Mon, 11 Jul 2022 09:24:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 633D7C341C0; Mon, 11 Jul 2022 09:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531496; bh=yZtrHS6oc+q1zJ4xFjTvui4hoYjxxt2NUH81KemFZrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYT2OHsaeYfS9NUWDXqu8O/qxAN7rXGPM7/ujrxr+waDRqnpkUrosrtoJVvuhocn+ 7W38AwrD/95Bb0R/aMj7KakiOzyV+3VdZjJ6W8pYB3NYg6ouG1ZokZRQ7wHZ1eXT++ Pe4DmHSFRpBdTKfJrvSk59tmh/faQbBjSImgwyQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Naohiro Aota , David Sterba , Sasha Levin Subject: [PATCH 5.15 125/230] btrfs: zoned: use dedicated lock for data relocation Date: Mon, 11 Jul 2022 11:06:21 +0200 Message-Id: <20220711090607.610632602@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Naohiro Aota [ Upstream commit 5f0addf7b89085f8e0a2593faa419d6111612b9b ] Currently, we use btrfs_inode_{lock,unlock}() to grant an exclusive writeback of the relocation data inode in btrfs_zoned_data_reloc_{lock,unlock}(). However, that can cause a deadlock in the following path. Thread A takes btrfs_inode_lock() and waits for metadata reservation by e.g, waiting for writeback: prealloc_file_extent_cluster() - btrfs_inode_lock(&inode->vfs_inode, 0); - btrfs_prealloc_file_range() ... - btrfs_replace_file_extents() - btrfs_start_transaction ... - btrfs_reserve_metadata_bytes() Thread B (e.g, doing a writeback work) needs to wait for the inode lock to continue writeback process: do_writepages - btrfs_writepages - extent_writpages - btrfs_zoned_data_reloc_lock(BTRFS_I(inode)); - btrfs_inode_lock() The deadlock is caused by relying on the vfs_inode's lock. By using it, we introduced unnecessary exclusion of writeback and btrfs_prealloc_file_range(). Also, the lock at this point is useless as we don't have any dirty pages in the inode yet. Introduce fs_info->zoned_data_reloc_io_lock and use it for the exclusive writeback. Fixes: 35156d852762 ("btrfs: zoned: only allow one process to add pages to = a relocation inode") CC: stable@vger.kernel.org # 5.16.x: 869f4cdc73f9: btrfs: zoned: encapsulat= e inode locking for zoned relocation CC: stable@vger.kernel.org # 5.16.x CC: stable@vger.kernel.org # 5.17 Cc: Johannes Thumshirn Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/ctree.h | 1 + fs/btrfs/disk-io.c | 1 + fs/btrfs/zoned.h | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index cc72d8981c47..d1838de0b39c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1027,6 +1027,7 @@ struct btrfs_fs_info { */ spinlock_t relocation_bg_lock; u64 data_reloc_bg; + struct mutex zoned_data_reloc_io_lock; =20 #ifdef CONFIG_BTRFS_FS_REF_VERIFY spinlock_t ref_verify_lock; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 233d894f6feb..909d19656316 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2914,6 +2914,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) mutex_init(&fs_info->reloc_mutex); mutex_init(&fs_info->delalloc_root_mutex); mutex_init(&fs_info->zoned_meta_io_lock); + mutex_init(&fs_info->zoned_data_reloc_io_lock); seqlock_init(&fs_info->profiles_lock); =20 INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots); diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index d680c3ee918a..3a826f7c2040 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -330,7 +330,7 @@ static inline void btrfs_zoned_data_reloc_lock(struct b= trfs_inode *inode) struct btrfs_root *root =3D inode->root; =20 if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) - btrfs_inode_lock(&inode->vfs_inode, 0); + mutex_lock(&root->fs_info->zoned_data_reloc_io_lock); } =20 static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode) @@ -338,7 +338,7 @@ static inline void btrfs_zoned_data_reloc_unlock(struct= btrfs_inode *inode) struct btrfs_root *root =3D inode->root; =20 if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) - btrfs_inode_unlock(&inode->vfs_inode, 0); + mutex_unlock(&root->fs_info->zoned_data_reloc_io_lock); } =20 #endif --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 E5F09C433EF for ; Mon, 11 Jul 2022 09:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233842AbiGKJwE (ORCPT ); Mon, 11 Jul 2022 05:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233843AbiGKJup (ORCPT ); Mon, 11 Jul 2022 05:50: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 0CCAB29830; Mon, 11 Jul 2022 02:25: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 9EE38B80E7A; Mon, 11 Jul 2022 09:25:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F1DAC34115; Mon, 11 Jul 2022 09:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531499; bh=jLg70Q9nZHijQ04V8fPVGvO1b75QYGWIzu9gmbZ9Xr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OGg2gj4XzgitG/GO3LyXj39N1tFw364Ok67w5cnx+p4enDl45qvTIafk41NITHF8f 3ody7LDM1/vXk3XYW86x61aIRRp6ZoqhMvv3lSwSvLaivMOGIV9Wdb06a/MgeauAS1 6tpWhfXs+XcD/b90+UUsvul32ConanwhcRcycNDQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Oliver Upton , syzbot+df6fbbd2ee39f21289ef@syzkaller.appspotmail.com, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 126/230] KVM: Initialize debugfs_dentry when a VM is created to avoid NULL deref Date: Mon, 11 Jul 2022 11:06:22 +0200 Message-Id: <20220711090607.639773751@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Christopherson [ Upstream commit 5c697c367a66307a5d943c3449421aff2aa3ca4a ] Initialize debugfs_entry to its semi-magical -ENOENT value when the VM is created. KVM's teardown when VM creation fails is kludgy and calls kvm_uevent_notify_change() and kvm_destroy_vm_debugfs() even if KVM never attempted kvm_create_vm_debugfs(). Because debugfs_entry is zero initialized, the IS_ERR() checks pass and KVM derefs a NULL pointer. BUG: kernel NULL pointer dereference, address: 0000000000000018 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 1068b1067 P4D 1068b1067 PUD 1068b0067 PMD 0 Oops: 0000 [#1] SMP CPU: 0 PID: 871 Comm: repro Not tainted 5.18.0-rc1+ #825 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:__dentry_path+0x7b/0x130 Call Trace: dentry_path_raw+0x42/0x70 kvm_uevent_notify_change.part.0+0x10c/0x200 [kvm] kvm_put_kvm+0x63/0x2b0 [kvm] kvm_dev_ioctl+0x43a/0x920 [kvm] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x31/0x50 entry_SYSCALL_64_after_hwframe+0x44/0xae Modules linked in: kvm_intel kvm irqbypass Fixes: a44a4cc1c969 ("KVM: Don't create VM debugfs files outside of the VM = directory") Cc: stable@vger.kernel.org Cc: Marc Zyngier Cc: Oliver Upton Reported-by: syzbot+df6fbbd2ee39f21289ef@syzkaller.appspotmail.com Signed-off-by: Sean Christopherson Reviewed-by: Oliver Upton Message-Id: <20220415004622.2207751-1-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- virt/kvm/kvm_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9134ae252d7c..9eac68ae291e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -934,12 +934,6 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int = fd) int kvm_debugfs_num_entries =3D kvm_vm_stats_header.num_desc + kvm_vcpu_stats_header.num_desc; =20 - /* - * Force subsequent debugfs file creations to fail if the VM directory - * is not created. - */ - kvm->debugfs_dentry =3D ERR_PTR(-ENOENT); - if (!debugfs_initialized()) return 0; =20 @@ -1055,6 +1049,12 @@ static struct kvm *kvm_create_vm(unsigned long type) =20 BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); =20 + /* + * Force subsequent debugfs file creations to fail if the VM directory + * is not created (by kvm_create_vm_debugfs()). + */ + kvm->debugfs_dentry =3D ERR_PTR(-ENOENT); + if (init_srcu_struct(&kvm->srcu)) goto out_err_no_srcu; if (init_srcu_struct(&kvm->irq_srcu)) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 48C9CC43334 for ; Mon, 11 Jul 2022 09:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233870AbiGKJwP (ORCPT ); Mon, 11 Jul 2022 05:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233865AbiGKJu6 (ORCPT ); Mon, 11 Jul 2022 05:50:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8D631DE1; Mon, 11 Jul 2022 02:25: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 97A726112E; Mon, 11 Jul 2022 09:25:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B370C34115; Mon, 11 Jul 2022 09:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531505; bh=GIfK8Byv40Doke3jciY44/Uks9FgkwxfoZqJmMCfspU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cI2eFNrPH3CA4sUoiUMUW61Q+zvoj7YK4UCO3XbZ+gXo6egVOQfaIfgjucDoiJ6hk +z1UJ+cF9ZtvKDhKRRhcpXj6q8vmF35/vbJu5miAHJ2Snn3XXQC/+eeC4Bloqe8sEu WxQhDf309dO7q854jXxDYgDzCDO6wWiGpoSX9e8c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naoya Horiguchi , Yang Shi , "Aneesh Kumar K.V" , David Hildenbrand , Ding Hui , Miaohe Lin , Michal Hocko , Oscar Salvador , Peter Xu , Tony Luck , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 127/230] mm/hwpoison: mf_mutex for soft offline and unpoison Date: Mon, 11 Jul 2022 11:06:23 +0200 Message-Id: <20220711090607.668206816@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Naoya Horiguchi [ Upstream commit 91d005479e06392617bacc114509d611b705eaac ] Patch series "mm/hwpoison: fix unpoison_memory()", v4. The main purpose of this series is to sync unpoison code to recent changes around how hwpoison code takes page refcount. Unpoison should work or simply fail (without crash) if impossible. The recent works of keeping hwpoison pages in shmem pagecache introduce a new state of hwpoisoned pages, but unpoison for such pages is not supported yet with this series. It seems that soft-offline and unpoison can be used as general purpose page offline/online mechanism (not in the context of memory error). I think that we need some additional works to realize it because currently soft-offline and unpoison are assumed not to happen so frequently (print out too many messages for aggressive usecases). But anyway this could be another interesting next topic. v1: https://lore.kernel.org/linux-mm/20210614021212.223326-1-nao.horiguchi@= gmail.com/ v2: https://lore.kernel.org/linux-mm/20211025230503.2650970-1-naoya.horiguc= hi@linux.dev/ v3: https://lore.kernel.org/linux-mm/20211105055058.3152564-1-naoya.horiguc= hi@linux.dev/ This patch (of 3): Originally mf_mutex is introduced to serialize multiple MCE events, but it is not that useful to allow unpoison to run in parallel with memory_failure() and soft offline. So apply mf_mutex to soft offline and unpoison. The memory failure handler and soft offline handler get simpler with this. Link: https://lkml.kernel.org/r/20211115084006.3728254-1-naoya.horiguchi@li= nux.dev Link: https://lkml.kernel.org/r/20211115084006.3728254-2-naoya.horiguchi@li= nux.dev Signed-off-by: Naoya Horiguchi Reviewed-by: Yang Shi Cc: "Aneesh Kumar K.V" Cc: David Hildenbrand Cc: Ding Hui Cc: Miaohe Lin Cc: Michal Hocko Cc: Oscar Salvador Cc: Peter Xu Cc: Tony Luck Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- mm/memory-failure.c | 62 +++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c3ceb7436933..e6425d959fa9 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1463,14 +1463,6 @@ static int memory_failure_hugetlb(unsigned long pfn,= int flags) lock_page(head); page_flags =3D head->flags; =20 - if (!PageHWPoison(head)) { - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); - num_poisoned_pages_dec(); - unlock_page(head); - put_page(head); - return 0; - } - /* * TODO: hwpoison for pud-sized hugetlb doesn't work right now, so * simply disable it. In order to make it work properly, we need @@ -1584,6 +1576,8 @@ static int memory_failure_dev_pagemap(unsigned long p= fn, int flags, return rc; } =20 +static DEFINE_MUTEX(mf_mutex); + /** * memory_failure - Handle memory failure of a page. * @pfn: Page Number of the corrupted page @@ -1610,7 +1604,6 @@ int memory_failure(unsigned long pfn, int flags) int res =3D 0; unsigned long page_flags; bool retry =3D true; - static DEFINE_MUTEX(mf_mutex); =20 if (!sysctl_memory_failure_recovery) panic("Memory failure on page %lx", pfn); @@ -1744,16 +1737,6 @@ int memory_failure(unsigned long pfn, int flags) */ page_flags =3D p->flags; =20 - /* - * unpoison always clear PG_hwpoison inside page lock - */ - if (!PageHWPoison(p)) { - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); - num_poisoned_pages_dec(); - unlock_page(p); - put_page(p); - goto unlock_mutex; - } if (hwpoison_filter(p)) { if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); @@ -1934,6 +1917,7 @@ int unpoison_memory(unsigned long pfn) struct page *page; struct page *p; int freeit =3D 0; + int ret =3D 0; unsigned long flags =3D 0; static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); @@ -1944,39 +1928,30 @@ int unpoison_memory(unsigned long pfn) p =3D pfn_to_page(pfn); page =3D compound_head(p); =20 + mutex_lock(&mf_mutex); + if (!PageHWPoison(p)) { unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } =20 if (page_count(page) > 1) { unpoison_pr_info("Unpoison: Someone grabs the hwpoison page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } =20 if (page_mapped(page)) { unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } =20 if (page_mapping(page)) { unpoison_pr_info("Unpoison: the hwpoison page has non-NULL mapping %#lx\= n", pfn, &unpoison_rs); - return 0; - } - - /* - * unpoison_memory() can encounter thp only when the thp is being - * worked by memory_failure() and the page lock is not held yet. - * In such case, we yield to memory_failure() and make unpoison fail. - */ - if (!PageHuge(page) && PageTransHuge(page)) { - unpoison_pr_info("Unpoison: Memory failure is now running on %#lx\n", - pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } =20 if (!get_hwpoison_page(p, flags)) { @@ -1984,29 +1959,23 @@ int unpoison_memory(unsigned long pfn) num_poisoned_pages_dec(); unpoison_pr_info("Unpoison: Software-unpoisoned free page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } =20 - lock_page(page); - /* - * This test is racy because PG_hwpoison is set outside of page lock. - * That's acceptable because that won't trigger kernel panic. Instead, - * the PG_hwpoison page will be caught and isolated on the entrance to - * the free buddy page pool. - */ if (TestClearPageHWPoison(page)) { unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n", pfn, &unpoison_rs); num_poisoned_pages_dec(); freeit =3D 1; } - unlock_page(page); =20 put_page(page); if (freeit && !(pfn =3D=3D my_zero_pfn(0) && page_count(p) =3D=3D 1)) put_page(page); =20 - return 0; +unlock_mutex: + mutex_unlock(&mf_mutex); + return ret; } EXPORT_SYMBOL(unpoison_memory); =20 @@ -2187,9 +2156,12 @@ int soft_offline_page(unsigned long pfn, int flags) return -EIO; } =20 + mutex_lock(&mf_mutex); + if (PageHWPoison(page)) { pr_info("%s: %#lx page already poisoned\n", __func__, pfn); put_ref_page(ref_page); + mutex_unlock(&mf_mutex); return 0; } =20 @@ -2208,5 +2180,7 @@ int soft_offline_page(unsigned long pfn, int flags) } } =20 + mutex_unlock(&mf_mutex); + return ret; } --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 4EADFC433EF for ; Mon, 11 Jul 2022 09:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233910AbiGKJwc (ORCPT ); Mon, 11 Jul 2022 05:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233889AbiGKJvR (ORCPT ); Mon, 11 Jul 2022 05:51:17 -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 01B605D0E4; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4FCFC61137; Mon, 11 Jul 2022 09:25:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39DD1C34115; Mon, 11 Jul 2022 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531507; bh=Hrn73FUsc2y0i6Zvxmud28An4gKYs2EWMshHcsib3q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQ8dCdjeZEzhmWBWn/gYY9Bk9o3GukbzEe0apHGeOwUUV2NTDg0Z9bFfm+byUMslE 1GXgeKSd0ECVetJIy1om5KTWICh1xmGAhb62TacuIzzxLYzqItnpdO8N7N9To4E2Rm mdX0tNIOIGD0DY64w+5FNdW2Rdc+nzyfORXsPhIA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, luofei , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Miaohe Lin , Naoya Horiguchi , Thomas Gleixner , Tony Luck , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 128/230] mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler Date: Mon, 11 Jul 2022 11:06:24 +0200 Message-Id: <20220711090607.696575480@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: luofei [ Upstream commit d1fe111fb62a1cf0446a2919f5effbb33ad0702c ] When the hwpoison page meets the filter conditions, it should not be regarded as successful memory_failure() processing for mce handler, but should return a distinct value, otherwise mce handler regards the error page has been identified and isolated, which may lead to calling set_mce_nospec() to change page attribute, etc. Here memory_failure() return -EOPNOTSUPP to indicate that the error event is filtered, mce handler should not take any action for this situation and hwpoison injector should treat as correct. Link: https://lkml.kernel.org/r/20220223082135.2769649-1-luofei@unicloud.com Signed-off-by: luofei Acked-by: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Thomas Gleixner Cc: Tony Luck Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/x86/kernel/cpu/mce/core.c | 8 +++++--- drivers/base/memory.c | 2 ++ mm/hwpoison-inject.c | 3 ++- mm/madvise.c | 2 ++ mm/memory-failure.c | 9 +++++++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index e23e74e2f928..848cfb013f58 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1297,10 +1297,12 @@ static void kill_me_maybe(struct callback_head *cb) =20 /* * -EHWPOISON from memory_failure() means that it already sent SIGBUS - * to the current process with the proper error info, so no need to - * send SIGBUS here again. + * to the current process with the proper error info, + * -EOPNOTSUPP means hwpoison_filter() filtered the error event, + * + * In both cases, no further processing is required. */ - if (ret =3D=3D -EHWPOISON) + if (ret =3D=3D -EHWPOISON || ret =3D=3D -EOPNOTSUPP) return; =20 if (p->mce_vaddr !=3D (void __user *)-1l) { diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c0d501a3a714..c778d1df7455 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -555,6 +555,8 @@ static ssize_t hard_offline_page_store(struct device *d= ev, return -EINVAL; pfn >>=3D PAGE_SHIFT; ret =3D memory_failure(pfn, 0); + if (ret =3D=3D -EOPNOTSUPP) + ret =3D 0; return ret ? ret : count; } =20 diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index aff4d27ec235..a1d6fc3c78b9 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c @@ -48,7 +48,8 @@ static int hwpoison_inject(void *data, u64 val) =20 inject: pr_info("Injecting memory failure at pfn %#lx\n", pfn); - return memory_failure(pfn, 0); + err =3D memory_failure(pfn, 0); + return (err =3D=3D -EOPNOTSUPP) ? 0 : err; } =20 static int hwpoison_unpoison(void *data, u64 val) diff --git a/mm/madvise.c b/mm/madvise.c index 8e5ca01a6cc0..882767d58c27 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -968,6 +968,8 @@ static int madvise_inject_error(int behavior, pr_info("Injecting memory failure for pfn %#lx at process virtual addre= ss %#lx\n", pfn, start); ret =3D memory_failure(pfn, MF_COUNT_INCREASED); + if (ret =3D=3D -EOPNOTSUPP) + ret =3D 0; } =20 if (ret) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e6425d959fa9..5664bafd5e77 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1444,7 +1444,7 @@ static int memory_failure_hugetlb(unsigned long pfn, = int flags) if (TestClearPageHWPoison(head)) num_poisoned_pages_dec(); unlock_page(head); - return 0; + return -EOPNOTSUPP; } unlock_page(head); res =3D MF_FAILED; @@ -1525,7 +1525,7 @@ static int memory_failure_dev_pagemap(unsigned long p= fn, int flags, goto out; =20 if (hwpoison_filter(page)) { - rc =3D 0; + rc =3D -EOPNOTSUPP; goto unlock; } =20 @@ -1594,6 +1594,10 @@ static DEFINE_MUTEX(mf_mutex); * * Must run in process context (e.g. a work queue) with interrupts * enabled and no spinlocks hold. + * + * Return: 0 for successfully handled the memory error, + * -EOPNOTSUPP for memory_filter() filtered the error event, + * < 0(except -EOPNOTSUPP) on failure. */ int memory_failure(unsigned long pfn, int flags) { @@ -1742,6 +1746,7 @@ int memory_failure(unsigned long pfn, int flags) num_poisoned_pages_dec(); unlock_page(p); put_page(p); + res =3D -EOPNOTSUPP; goto unlock_mutex; } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 2D05AC433EF for ; Mon, 11 Jul 2022 09:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233972AbiGKJws (ORCPT ); Mon, 11 Jul 2022 05:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbiGKJwB (ORCPT ); Mon, 11 Jul 2022 05:52: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 4CF32ACEE5; Mon, 11 Jul 2022 02:25: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 F04706124E; Mon, 11 Jul 2022 09:25:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9261C34115; Mon, 11 Jul 2022 09:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531510; bh=9K04RVcc5+Of6dPmUZUF7MfhV/bdoktf5T5hjkB0ntw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eXC9+49lgVNTgEhlxEohSlTfn5cog2wd29rOWzRTLSYtks6fzG3xWY98eg5xbQ9/J E//BuVMT5nsJpvW7jJALjtX+i1CRJza+R9FJgXFqpFsaCuuWmcxNf83jeydohP4RU7 H+8dSmjwEam0cLaLUyYAp9ffsuz1LI85Jr9xt8oE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Naoya Horiguchi , Tony Luck , Borislav Petkov , Mike Kravetz , Yang Shi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 129/230] mm/memory-failure.c: fix race with changing page compound again Date: Mon, 11 Jul 2022 11:06:25 +0200 Message-Id: <20220711090607.725243061@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Miaohe Lin [ Upstream commit 888af2701db79b9b27c7e37f9ede528a5ca53b76 ] Patch series "A few fixup patches for memory failure", v2. This series contains a few patches to fix the race with changing page compound page, make non-LRU movable pages unhandlable and so on. More details can be found in the respective changelogs. There is a race window where we got the compound_head, the hugetlb page could be freed to buddy, or even changed to another compound page just before we try to get hwpoison page. Think about the below race window: CPU 1 CPU 2 memory_failure_hugetlb struct page *head =3D compound_head(p); hugetlb page might be freed to buddy, or even changed to another compound page. get_hwpoison_page -- page is not what we want now... If this race happens, just bail out. Also MF_MSG_DIFFERENT_PAGE_SIZE is introduced to record this event. [akpm@linux-foundation.org: s@/**@/*@, per Naoya Horiguchi] Link: https://lkml.kernel.org/r/20220312074613.4798-1-linmiaohe@huawei.com Link: https://lkml.kernel.org/r/20220312074613.4798-2-linmiaohe@huawei.com Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi Cc: Tony Luck Cc: Borislav Petkov Cc: Mike Kravetz Cc: Yang Shi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/mm.h | 1 + include/ras/ras_event.h | 1 + mm/memory-failure.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 85205adcdd0d..7a80a08eec84 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3167,6 +3167,7 @@ enum mf_action_page_type { MF_MSG_BUDDY_2ND, MF_MSG_DAX, MF_MSG_UNSPLIT_THP, + MF_MSG_DIFFERENT_PAGE_SIZE, MF_MSG_UNKNOWN, }; =20 diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h index 0bdbc0d17d2f..cac13ff1d6eb 100644 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -376,6 +376,7 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \ EM ( MF_MSG_DAX, "dax page" ) \ EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ + EM ( MF_MSG_DIFFERENT_PAGE_SIZE, "different page size" ) \ EMe ( MF_MSG_UNKNOWN, "unknown page" ) =20 /* diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5664bafd5e77..a4d70c21c146 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -741,6 +741,7 @@ static const char * const action_page_types[] =3D { [MF_MSG_BUDDY_2ND] =3D "free buddy page (2nd try)", [MF_MSG_DAX] =3D "dax page", [MF_MSG_UNSPLIT_THP] =3D "unsplit thp", + [MF_MSG_DIFFERENT_PAGE_SIZE] =3D "different page size", [MF_MSG_UNKNOWN] =3D "unknown page", }; =20 @@ -1461,6 +1462,17 @@ static int memory_failure_hugetlb(unsigned long pfn,= int flags) } =20 lock_page(head); + + /* + * The page could have changed compound pages due to race window. + * If this happens just bail out. + */ + if (!PageHuge(p) || compound_head(p) !=3D head) { + action_result(pfn, MF_MSG_DIFFERENT_PAGE_SIZE, MF_IGNORED); + res =3D -EBUSY; + goto out; + } + page_flags =3D head->flags; =20 /* --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 9BEC1C433EF for ; Mon, 11 Jul 2022 09:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234180AbiGKJ7I (ORCPT ); Mon, 11 Jul 2022 05:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234241AbiGKJ6a (ORCPT ); Mon, 11 Jul 2022 05:58:30 -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 9F5A4B5D0E; Mon, 11 Jul 2022 02:27: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 B494AB80DB7; Mon, 11 Jul 2022 09:27:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6A80C34115; Mon, 11 Jul 2022 09:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531645; bh=MTKGH5nnA43tfFzzTSuct0DNfY1kNSKYvBdt0p6/CzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=146ST5OpboCN3WT14YDFTrJ57o6o+qkbscaDkGr/ks1u0LY1qe5fB43j14HNr+7iQ oEZDeQikw+smtQRRStnqQYfVeEGSLb6VvHNHrxcLErwooV6CCVjSfMsy41I7A3fzDc WmAlDUclIp6FRAOEX1wyyFy7bbzj7XycdWROGdYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naoya Horiguchi , Mike Kravetz , Miaohe Lin , Yang Shi , Dan Carpenter , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 130/230] mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb() Date: Mon, 11 Jul 2022 11:06:26 +0200 Message-Id: <20220711090607.753081711@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Naoya Horiguchi [ Upstream commit 405ce051236cc65b30bbfe490b28ce60ae6aed85 ] There is a race condition between memory_failure_hugetlb() and hugetlb free/demotion, which causes setting PageHWPoison flag on the wrong page. The one simple result is that wrong processes can be killed, but another (more serious) one is that the actual error is left unhandled, so no one prevents later access to it, and that might lead to more serious results like consuming corrupted data. Think about the below race window: CPU 1 CPU 2 memory_failure_hugetlb struct page *head =3D compound_head(p); hugetlb page might be freed to buddy, or even changed to another compound page. get_hwpoison_page -- page is not what we want now... The current code first does prechecks roughly and then reconfirms after taking refcount, but it's found that it makes code overly complicated, so move the prechecks in a single hugetlb_lock range. A newly introduced function, try_memory_failure_hugetlb(), always takes hugetlb_lock (even for non-hugetlb pages). That can be improved, but memory_failure() is rare in principle, so should not be a big problem. Link: https://lkml.kernel.org/r/20220408135323.1559401-2-naoya.horiguchi@li= nux.dev Fixes: 761ad8d7c7b5 ("mm: hwpoison: introduce memory_failure_hugetlb()") Signed-off-by: Naoya Horiguchi Reported-by: Mike Kravetz Reviewed-by: Miaohe Lin Reviewed-by: Mike Kravetz Cc: Yang Shi Cc: Dan Carpenter Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/hugetlb.h | 6 ++ include/linux/mm.h | 8 +++ mm/hugetlb.c | 10 +++ mm/memory-failure.c | 137 ++++++++++++++++++++++++++++++---------- 4 files changed, 127 insertions(+), 34 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 1faebe1cd0ed..22c1d935e22d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -167,6 +167,7 @@ long hugetlb_unreserve_pages(struct inode *inode, long = start, long end, long freed); bool isolate_huge_page(struct page *page, struct list_head *list); int get_hwpoison_huge_page(struct page *page, bool *hugetlb); +int get_huge_page_for_hwpoison(unsigned long pfn, int flags); void putback_active_hugepage(struct page *page); void move_hugetlb_state(struct page *oldpage, struct page *newpage, int re= ason); void free_huge_page(struct page *page); @@ -362,6 +363,11 @@ static inline int get_hwpoison_huge_page(struct page *= page, bool *hugetlb) return 0; } =20 +static inline int get_huge_page_for_hwpoison(unsigned long pfn, int flags) +{ + return 0; +} + static inline void putback_active_hugepage(struct page *page) { } diff --git a/include/linux/mm.h b/include/linux/mm.h index 7a80a08eec84..c5fa46e9c0ca 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3132,6 +3132,14 @@ extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p); extern atomic_long_t num_poisoned_pages __read_mostly; extern int soft_offline_page(unsigned long pfn, int flags); +#ifdef CONFIG_MEMORY_FAILURE +extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags); +#else +static inline int __get_huge_page_for_hwpoison(unsigned long pfn, int flag= s) +{ + return 0; +} +#endif =20 =20 /* diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e4c717b08cfe..eed96302897a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6290,6 +6290,16 @@ int get_hwpoison_huge_page(struct page *page, bool *= hugetlb) return ret; } =20 +int get_huge_page_for_hwpoison(unsigned long pfn, int flags) +{ + int ret; + + spin_lock_irq(&hugetlb_lock); + ret =3D __get_huge_page_for_hwpoison(pfn, flags); + spin_unlock_irq(&hugetlb_lock); + return ret; +} + void putback_active_hugepage(struct page *page) { spin_lock_irq(&hugetlb_lock); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index a4d70c21c146..ecd64b203272 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1419,50 +1419,113 @@ static int try_to_split_thp_page(struct page *page= , const char *msg) return 0; } =20 -static int memory_failure_hugetlb(unsigned long pfn, int flags) +/* + * Called from hugetlb code with hugetlb_lock held. + * + * Return values: + * 0 - free hugepage + * 1 - in-use hugepage + * 2 - not a hugepage + * -EBUSY - the hugepage is busy (try to retry) + * -EHWPOISON - the hugepage is already hwpoisoned + */ +int __get_huge_page_for_hwpoison(unsigned long pfn, int flags) +{ + struct page *page =3D pfn_to_page(pfn); + struct page *head =3D compound_head(page); + int ret =3D 2; /* fallback to normal page handling */ + bool count_increased =3D false; + + if (!PageHeadHuge(head)) + goto out; + + if (flags & MF_COUNT_INCREASED) { + ret =3D 1; + count_increased =3D true; + } else if (HPageFreed(head) || HPageMigratable(head)) { + ret =3D get_page_unless_zero(head); + if (ret) + count_increased =3D true; + } else { + ret =3D -EBUSY; + goto out; + } + + if (TestSetPageHWPoison(head)) { + ret =3D -EHWPOISON; + goto out; + } + + return ret; +out: + if (count_increased) + put_page(head); + return ret; +} + +#ifdef CONFIG_HUGETLB_PAGE +/* + * Taking refcount of hugetlb pages needs extra care about race conditions + * with basic operations like hugepage allocation/free/demotion. + * So some of prechecks for hwpoison (pinning, and testing/setting + * PageHWPoison) should be done in single hugetlb_lock range. + */ +static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *h= ugetlb) { - struct page *p =3D pfn_to_page(pfn); - struct page *head =3D compound_head(p); int res; + struct page *p =3D pfn_to_page(pfn); + struct page *head; unsigned long page_flags; + bool retry =3D true; =20 - if (TestSetPageHWPoison(head)) { - pr_err("Memory failure: %#lx: already hardware poisoned\n", - pfn); - res =3D -EHWPOISON; - if (flags & MF_ACTION_REQUIRED) + *hugetlb =3D 1; +retry: + res =3D get_huge_page_for_hwpoison(pfn, flags); + if (res =3D=3D 2) { /* fallback to normal page handling */ + *hugetlb =3D 0; + return 0; + } else if (res =3D=3D -EHWPOISON) { + pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn); + if (flags & MF_ACTION_REQUIRED) { + head =3D compound_head(p); res =3D kill_accessing_process(current, page_to_pfn(head), flags); + } + return res; + } else if (res =3D=3D -EBUSY) { + if (retry) { + retry =3D false; + goto retry; + } + action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); return res; } =20 + head =3D compound_head(p); + lock_page(head); + + if (hwpoison_filter(p)) { + ClearPageHWPoison(head); + res =3D -EOPNOTSUPP; + goto out; + } + num_poisoned_pages_inc(); =20 - if (!(flags & MF_COUNT_INCREASED)) { - res =3D get_hwpoison_page(p, flags); - if (!res) { - lock_page(head); - if (hwpoison_filter(p)) { - if (TestClearPageHWPoison(head)) - num_poisoned_pages_dec(); - unlock_page(head); - return -EOPNOTSUPP; - } - unlock_page(head); - res =3D MF_FAILED; - if (__page_handle_poison(p)) { - page_ref_inc(p); - res =3D MF_RECOVERED; - } - action_result(pfn, MF_MSG_FREE_HUGE, res); - return res =3D=3D MF_RECOVERED ? 0 : -EBUSY; - } else if (res < 0) { - action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); - return -EBUSY; + /* + * Handling free hugepage. The possible race with hugepage allocation + * or demotion can be prevented by PageHWPoison flag. + */ + if (res =3D=3D 0) { + unlock_page(head); + res =3D MF_FAILED; + if (__page_handle_poison(p)) { + page_ref_inc(p); + res =3D MF_RECOVERED; } + action_result(pfn, MF_MSG_FREE_HUGE, res); + return res =3D=3D MF_RECOVERED ? 0 : -EBUSY; } =20 - lock_page(head); - /* * The page could have changed compound pages due to race window. * If this happens just bail out. @@ -1501,6 +1564,12 @@ static int memory_failure_hugetlb(unsigned long pfn,= int flags) unlock_page(head); return res; } +#else +static inline int try_memory_failure_hugetlb(unsigned long pfn, int flags,= int *hugetlb) +{ + return 0; +} +#endif =20 static int memory_failure_dev_pagemap(unsigned long pfn, int flags, struct dev_pagemap *pgmap) @@ -1620,6 +1689,7 @@ int memory_failure(unsigned long pfn, int flags) int res =3D 0; unsigned long page_flags; bool retry =3D true; + int hugetlb =3D 0; =20 if (!sysctl_memory_failure_recovery) panic("Memory failure on page %lx", pfn); @@ -1640,10 +1710,9 @@ int memory_failure(unsigned long pfn, int flags) mutex_lock(&mf_mutex); =20 try_again: - if (PageHuge(p)) { - res =3D memory_failure_hugetlb(pfn, flags); + res =3D try_memory_failure_hugetlb(pfn, flags, &hugetlb); + if (hugetlb) goto unlock_mutex; - } =20 if (TestSetPageHWPoison(p)) { pr_err("Memory failure: %#lx: already hardware poisoned\n", --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 86B65C43334 for ; Mon, 11 Jul 2022 09:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233963AbiGKJx5 (ORCPT ); Mon, 11 Jul 2022 05:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233957AbiGKJxL (ORCPT ); Mon, 11 Jul 2022 05:53: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 66333ADD6F; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id A63A161370; Mon, 11 Jul 2022 09:25:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D370C34115; Mon, 11 Jul 2022 09:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531530; bh=n1ERvqJYN6N8alN0J6PYp2laun7OTpOR51vvmkEW9No=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zexDBKbcy94ydQn4i5TZxX5+GwLPacYnTjnVqxMhK0qjGxN18CzP2pMZ7EUJA1Fzq 8QlV0pVBGmgU8X9ku/0BsyiA9WtbT9dcW3eez3LhzKZWMYErXP9YhVamXM0LCX2CcW 8kOwYrM84EjqcfHTDfwgaFemrKejiRlCsTh9lywc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 5.15 131/230] tty: n_gsm: fix invalid use of MSC in advanced option Date: Mon, 11 Jul 2022 11:06:27 +0200 Message-Id: <20220711090607.781750032@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Starke [ Upstream commit c19ffe00fed6bb423d81406d2a7e5793074c7d83 ] n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDeta= ils.aspx?specificationId=3D1516 The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to the newer 27.010 here. Chapter 5.4.6.3.7 states that the Modem Status Command (MSC) shall only be used if the basic option was chosen. The current implementation uses MSC frames even if advanced option was chosen to inform the peer about modem line state updates. A standard conform peer may choose to discard these frames in advanced option mode. Furthermore, gsmtty_modem_update() is not part of the 'tty_operations' functions despite its name. Rename gsmtty_modem_update() to gsm_modem_update() to clarify this. Split its function into gsm_modem_upd_via_data() and gsm_modem_upd_via_msc() depending on the encoding and adaption. Introduce gsm_dlci_modem_output() as adaption of gsm_dlci_data_output() to encode and queue empty frames in advanced option mode. Use it in gsm_modem_upd_via_data(). gsm_modem_upd_via_msc() is based on the initial gsmtty_modem_update() function which used only MSC frames to update modem states. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220422071025.5490-2-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 125 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 8 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index c52d5e0d5c6f..c8ca00fad8e4 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -371,7 +371,7 @@ static const u8 gsm_fcs8[256] =3D { #define GOOD_FCS 0xCF =20 static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len); -static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk); +static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk); =20 /** * gsm_fcs_add - update FCS @@ -928,6 +928,63 @@ static int gsm_dlci_data_output_framed(struct gsm_mux = *gsm, return size; } =20 +/** + * gsm_dlci_modem_output - try and push modem status out of a DLCI + * @gsm: mux + * @dlci: the DLCI to pull modem status from + * @brk: break signal + * + * Push an empty frame in to the transmit queue to update the modem status + * bits and to transmit an optional break. + * + * Caller must hold the tx_lock of the mux. + */ + +static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlc= i, + u8 brk) +{ + u8 *dp =3D NULL; + struct gsm_msg *msg; + int size; + + /* for modem bits without break data */ + if (dlci->adaption =3D=3D 1) { + size =3D 0; + } else if (dlci->adaption =3D=3D 2) { + size =3D 1; + if (brk > 0) + size++; + } else { + pr_err("%s: unsupported adaption %d\n", __func__, + dlci->adaption); + } + + msg =3D gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype); + if (!msg) { + pr_err("%s: gsm_data_alloc error", __func__); + return -ENOMEM; + } + dp =3D msg->data; + switch (dlci->adaption) { + case 1: /* Unstructured */ + break; + case 2: /* Unstructured with modem bits. */ + if (brk =3D=3D 0) { + *dp++ =3D (gsm_encode_modem(dlci) << 1) | EA; + } else { + *dp++ =3D gsm_encode_modem(dlci) << 1; + *dp++ =3D (brk << 4) | 2 | EA; /* Length, Break, EA */ + } + break; + default: + /* Handled above */ + break; + } + + __gsm_data_queue(dlci, msg); + return size; +} + /** * gsm_dlci_data_sweep - look for data to send * @gsm: the GSM mux @@ -1492,7 +1549,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci) pr_debug("DLCI %d goes open.\n", dlci->addr); /* Send current modem state */ if (dlci->addr) - gsmtty_modem_update(dlci, 0); + gsm_modem_update(dlci, 0); wake_up(&dlci->gsm->event); } =20 @@ -2977,12 +3034,43 @@ static struct tty_ldisc_ops tty_ldisc_packet =3D { =20 #define TX_SIZE 512 =20 -static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk) +/** + * gsm_modem_upd_via_data - send modem bits via convergence layer + * @dlci: channel + * @brk: break signal + * + * Send an empty frame to signal mobile state changes and to transmit the + * break signal for adaption 2. + */ + +static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk) +{ + struct gsm_mux *gsm =3D dlci->gsm; + unsigned long flags; + + if (dlci->state !=3D DLCI_OPEN || dlci->adaption !=3D 2) + return; + + spin_lock_irqsave(&gsm->tx_lock, flags); + gsm_dlci_modem_output(gsm, dlci, brk); + spin_unlock_irqrestore(&gsm->tx_lock, flags); +} + +/** + * gsm_modem_upd_via_msc - send modem bits via control frame + * @dlci: channel + * @brk: break signal + */ + +static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) { u8 modembits[3]; struct gsm_control *ctrl; int len =3D 2; =20 + if (dlci->gsm->encoding !=3D 0) + return 0; + modembits[0] =3D (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */ if (!brk) { modembits[1] =3D (gsm_encode_modem(dlci) << 1) | EA; @@ -2997,6 +3085,27 @@ static int gsmtty_modem_update(struct gsm_dlci *dlci= , u8 brk) return gsm_control_wait(dlci->gsm, ctrl); } =20 +/** + * gsm_modem_update - send modem status line state + * @dlci: channel + * @brk: break signal + */ + +static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) +{ + if (dlci->adaption =3D=3D 2) { + /* Send convergence layer type 2 empty data frame. */ + gsm_modem_upd_via_data(dlci, brk); + return 0; + } else if (dlci->gsm->encoding =3D=3D 0) { + /* Send as MSC control message. */ + return gsm_modem_upd_via_msc(dlci, brk); + } + + /* Modem status lines are not supported. */ + return -EPROTONOSUPPORT; +} + static int gsm_carrier_raised(struct tty_port *port) { struct gsm_dlci *dlci =3D container_of(port, struct gsm_dlci, port); @@ -3029,7 +3138,7 @@ static void gsm_dtr_rts(struct tty_port *port, int on= off) modem_tx &=3D ~(TIOCM_DTR | TIOCM_RTS); if (modem_tx !=3D dlci->modem_tx) { dlci->modem_tx =3D modem_tx; - gsmtty_modem_update(dlci, 0); + gsm_modem_update(dlci, 0); } } =20 @@ -3218,7 +3327,7 @@ static int gsmtty_tiocmset(struct tty_struct *tty, =20 if (modem_tx !=3D dlci->modem_tx) { dlci->modem_tx =3D modem_tx; - return gsmtty_modem_update(dlci, 0); + return gsm_modem_update(dlci, 0); } return 0; } @@ -3279,7 +3388,7 @@ static void gsmtty_throttle(struct tty_struct *tty) dlci->modem_tx &=3D ~TIOCM_RTS; dlci->throttled =3D true; /* Send an MSC with RTS cleared */ - gsmtty_modem_update(dlci, 0); + gsm_modem_update(dlci, 0); } =20 static void gsmtty_unthrottle(struct tty_struct *tty) @@ -3291,7 +3400,7 @@ static void gsmtty_unthrottle(struct tty_struct *tty) dlci->modem_tx |=3D TIOCM_RTS; dlci->throttled =3D false; /* Send an MSC with RTS set */ - gsmtty_modem_update(dlci, 0); + gsm_modem_update(dlci, 0); } =20 static int gsmtty_break_ctl(struct tty_struct *tty, int state) @@ -3309,7 +3418,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, i= nt state) if (encode > 0x0F) encode =3D 0x0F; /* Best effort */ } - return gsmtty_modem_update(dlci, encode); + return gsm_modem_update(dlci, encode); } =20 static void gsmtty_cleanup(struct tty_struct *tty) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 F0E0FC43334 for ; Mon, 11 Jul 2022 09:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233761AbiGKJzU (ORCPT ); Mon, 11 Jul 2022 05:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbiGKJyc (ORCPT ); Mon, 11 Jul 2022 05:54:32 -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 E499D33A0A; Mon, 11 Jul 2022 02: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 98F17B80D2C; Mon, 11 Jul 2022 09:26:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E59BFC34115; Mon, 11 Jul 2022 09:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531560; bh=Alp2MHh6Ac99EuP+tf9BV2sOZk7KseWriY8CNcxWR9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xeXiaqnWGU7HRviybDx/K9KYNLSUEJ+BvS9wbRnqnqfjSZ5qlEKxziHTRRUGTl4dn AadkNNtRZmFQlnuX9G874UVbw3E9jsPHDD+Vvk4wNiSazA0qbdL7lr6m3VpNIAjyLa qerzacx39ohhVCoa9DnsAZZvLAMgQfOVdI63eG7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Daniel Starke , Sasha Levin Subject: [PATCH 5.15 132/230] tty: n_gsm: fix sometimes uninitialized warning in gsm_dlci_modem_output() Date: Mon, 11 Jul 2022 11:06:28 +0200 Message-Id: <20220711090607.809091125@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Starke [ Upstream commit 19317433057dc1f2ca9a975e4e6b547282c2a5ef ] 'size' may be used uninitialized in gsm_dlci_modem_output() if called with an adaption that is neither 1 nor 2. The function is currently only called by gsm_modem_upd_via_data() and only for adaption 2. Properly handle every invalid case by returning -EINVAL to silence the compiler warning and avoid future regressions. Fixes: c19ffe00fed6 ("tty: n_gsm: fix invalid use of MSC in advanced option= ") Cc: stable@vger.kernel.org Reported-by: kernel test robot Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220425104726.7986-1-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index c8ca00fad8e4..fd4a86111a6e 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -945,18 +945,21 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm,= struct gsm_dlci *dlci, { u8 *dp =3D NULL; struct gsm_msg *msg; - int size; + int size =3D 0; =20 /* for modem bits without break data */ - if (dlci->adaption =3D=3D 1) { - size =3D 0; - } else if (dlci->adaption =3D=3D 2) { - size =3D 1; + switch (dlci->adaption) { + case 1: /* Unstructured */ + break; + case 2: /* Unstructured with modem bits. */ + size++; if (brk > 0) size++; - } else { + break; + default: pr_err("%s: unsupported adaption %d\n", __func__, dlci->adaption); + return -EINVAL; } =20 msg =3D gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 42D44C43334 for ; Mon, 11 Jul 2022 09:56:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234046AbiGKJ40 (ORCPT ); Mon, 11 Jul 2022 05:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbiGKJzp (ORCPT ); Mon, 11 Jul 2022 05:55:45 -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 4D39CB23E2; Mon, 11 Jul 2022 02:26: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 dfw.source.kernel.org (Postfix) with ESMTPS id E175461370; Mon, 11 Jul 2022 09:26:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA600C34115; Mon, 11 Jul 2022 09:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531590; bh=3cODyiIArg5qEo2VckCG8XY4zG4teTgxZicxoXR9kYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HZR0fA5ZEFcSxAdKtdcIDj/712wnutLrupwlaF8+utqVc5AP3+GlkrHrOBM9DmGxc 0zoCEYUcqeWU2ruYmViVM3p54pXuNJfUAbKcyj4MXfUwO7e6PHha7O3LDtf87wFvit XYVxekuobYFy3GpO5ECtSuINVmE+jA58rNLMjSdo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.15 133/230] powerpc/vdso: Remove cvdso_call_time macro Date: Mon, 11 Jul 2022 11:06:29 +0200 Message-Id: <20220711090607.837197961@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Christophe Leroy [ Upstream commit 9b97bea90072a075363a200dd7b54ad4a24e9491 ] cvdso_call_time macro is very similar to cvdso_call macro. Add a call_time argument to cvdso_call which is 0 by default and set to 1 when using cvdso_call to call __c_kernel_time(). Return returned value as is with CR[SO] cleared when it is used for time(). Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/837a260ad86fc1ce297a562c2117fd69be5f7b5c.16= 42782130.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/include/asm/vdso/gettimeofday.h | 37 ++++++-------------- arch/powerpc/kernel/vdso32/gettimeofday.S | 2 +- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/in= clude/asm/vdso/gettimeofday.h index 1faff0be1111..df00e91c9a90 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -9,12 +9,12 @@ #include =20 /* - * The macros sets two stack frames, one for the caller and one for the ca= llee + * The macro sets two stack frames, one for the caller and one for the cal= lee * because there are no requirement for the caller to set a stack frame wh= en * calling VDSO so it may have omitted to set one, especially on PPC64 */ =20 -.macro cvdso_call funct +.macro cvdso_call funct call_time=3D0 .cfi_startproc PPC_STLU r1, -PPC_MIN_STKFRM(r1) mflr r0 @@ -25,45 +25,28 @@ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif get_datapage r5 + .ifeq \call_time addi r5, r5, VDSO_DATA_OFFSET + .else + addi r4, r5, VDSO_DATA_OFFSET + .endif bl DOTSYM(\funct) PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) #ifdef __powerpc64__ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif + .ifeq \call_time cmpwi r3, 0 + .endif mtlr r0 .cfi_restore lr addi r1, r1, 2 * PPC_MIN_STKFRM crclr so + .ifeq \call_time beqlr+ crset so neg r3, r3 - blr - .cfi_endproc -.endm - -.macro cvdso_call_time funct - .cfi_startproc - PPC_STLU r1, -PPC_MIN_STKFRM(r1) - mflr r0 - .cfi_register lr, r0 - PPC_STLU r1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapage r4 - addi r4, r4, VDSO_DATA_OFFSET - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - crclr so - mtlr r0 - .cfi_restore lr - addi r1, r1, 2 * PPC_MIN_STKFRM + .endif blr .cfi_endproc .endm diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kerne= l/vdso32/gettimeofday.S index d21d08140a5e..9b3ac09423c8 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -63,7 +63,7 @@ V_FUNCTION_END(__kernel_clock_getres) * */ V_FUNCTION_BEGIN(__kernel_time) - cvdso_call_time __c_kernel_time + cvdso_call __c_kernel_time call_time=3D1 V_FUNCTION_END(__kernel_time) =20 /* Routines for restoring integer registers, called by the compiler. */ --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 19BD2C433EF for ; Mon, 11 Jul 2022 09:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234055AbiGKJ6t (ORCPT ); Mon, 11 Jul 2022 05:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231280AbiGKJ6U (ORCPT ); Mon, 11 Jul 2022 05:58:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA8B13C148; Mon, 11 Jul 2022 02:27: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 0191BB80D2C; Mon, 11 Jul 2022 09:27:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FC5C34115; Mon, 11 Jul 2022 09:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531620; bh=W3FkDVsaLvy6NEH/0/OxivKco67wNMOeiRL3HtMFaUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sBB6Xs4idaGIfu3TQK/PAwZH/8r+Geh6uG9IG8z31IqeXLjp7ycy4MCT7hhg7u30F 4VL1iSgpYO8caBf8mzGFMbBCr6VIFcC/NC5FqsyD0UYKzzA+ZDhG+IjgL2BfabMu09 R+weYhwGChflVWwMjAYKq0Pg3pKCAZCzKJ/CIJ0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.15 134/230] powerpc/vdso: Move cvdso_call macro into gettimeofday.S Date: Mon, 11 Jul 2022 11:06:30 +0200 Message-Id: <20220711090607.865563405@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Christophe Leroy [ Upstream commit 692b21d78046851e75dc25bba773189c670b49c2 ] Now that gettimeofday.S is unique, move cvdso_call macro into that file which is the only user. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/72720359d4c58e3a3b96dd74952741225faac3de.16= 42782130.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/include/asm/vdso/gettimeofday.h | 52 +------------------- arch/powerpc/kernel/vdso32/gettimeofday.S | 44 ++++++++++++++++- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/in= clude/asm/vdso/gettimeofday.h index df00e91c9a90..f0a4cf01e85c 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -2,57 +2,9 @@ #ifndef _ASM_POWERPC_VDSO_GETTIMEOFDAY_H #define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H =20 -#include - -#ifdef __ASSEMBLY__ - -#include - -/* - * The macro sets two stack frames, one for the caller and one for the cal= lee - * because there are no requirement for the caller to set a stack frame wh= en - * calling VDSO so it may have omitted to set one, especially on PPC64 - */ - -.macro cvdso_call funct call_time=3D0 - .cfi_startproc - PPC_STLU r1, -PPC_MIN_STKFRM(r1) - mflr r0 - .cfi_register lr, r0 - PPC_STLU r1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapage r5 - .ifeq \call_time - addi r5, r5, VDSO_DATA_OFFSET - .else - addi r4, r5, VDSO_DATA_OFFSET - .endif - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - .ifeq \call_time - cmpwi r3, 0 - .endif - mtlr r0 - .cfi_restore lr - addi r1, r1, 2 * PPC_MIN_STKFRM - crclr so - .ifeq \call_time - beqlr+ - crset so - neg r3, r3 - .endif - blr - .cfi_endproc -.endm - -#else +#ifndef __ASSEMBLY__ =20 +#include #include #include #include diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kerne= l/vdso32/gettimeofday.S index 9b3ac09423c8..dd2099128b8f 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -12,7 +12,49 @@ #include #include #include -#include + +/* + * The macro sets two stack frames, one for the caller and one for the cal= lee + * because there are no requirement for the caller to set a stack frame wh= en + * calling VDSO so it may have omitted to set one, especially on PPC64 + */ + +.macro cvdso_call funct call_time=3D0 + .cfi_startproc + PPC_STLU r1, -PPC_MIN_STKFRM(r1) + mflr r0 + .cfi_register lr, r0 + PPC_STLU r1, -PPC_MIN_STKFRM(r1) + PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + get_datapage r5 + .ifeq \call_time + addi r5, r5, VDSO_DATA_OFFSET + .else + addi r4, r5, VDSO_DATA_OFFSET + .endif + bl DOTSYM(\funct) + PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + .ifeq \call_time + cmpwi r3, 0 + .endif + mtlr r0 + .cfi_restore lr + addi r1, r1, 2 * PPC_MIN_STKFRM + crclr so + .ifeq \call_time + beqlr+ + crset so + neg r3, r3 + .endif + blr + .cfi_endproc +.endm =20 .text /* --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 6D40ECCA480 for ; Mon, 11 Jul 2022 09:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234247AbiGKJ6i (ORCPT ); Mon, 11 Jul 2022 05:58:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234160AbiGKJ6I (ORCPT ); Mon, 11 Jul 2022 05:58:08 -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 D858AB4BD9; Mon, 11 Jul 2022 02:27: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 sin.source.kernel.org (Postfix) with ESMTPS id 03BD6CE126E; Mon, 11 Jul 2022 09:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16CA3C34115; Mon, 11 Jul 2022 09:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531631; bh=G3XdD4ZflwNdqfaY4yjkjFso/enpN8n0LYdk3KU1qK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQb3oxKDlGk3BXmyKcfFkk406Dqvl202qd6JJSNFMKndRGIlv3nlMClJhAash5i16 b3L8YbTrVL2DaBINa6syD0pY3YL2JJ6JG0sUgHhG8GkkNLSd2o8CxkcxSM4O2eDDf1 HKhnW6eOup39kHwvtsh8xJpS2BCnHsTpRn8NyRi8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Modra , Michael Ellerman , Segher Boessenkool , Sasha Levin Subject: [PATCH 5.15 135/230] powerpc/vdso: Fix incorrect CFI in gettimeofday.S Date: Mon, 11 Jul 2022 11:06:31 +0200 Message-Id: <20220711090607.893284695@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Ellerman [ Upstream commit 6d65028eb67dbb7627651adfc460d64196d38bd8 ] As reported by Alan, the CFI (Call Frame Information) in the VDSO time routines is incorrect since commit ce7d8056e38b ("powerpc/vdso: Prepare for switching VDSO to generic C implementation."). DWARF has a concept called the CFA (Canonical Frame Address), which on powerpc is calculated as an offset from the stack pointer (r1). That means when the stack pointer is changed there must be a corresponding CFI directive to update the calculation of the CFA. The current code is missing those directives for the changes to r1, which prevents gdb from being able to generate a backtrace from inside VDSO functions, eg: Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime () (gdb) bt #0 0x00007ffff7f804dc in __kernel_clock_gettime () #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.s= o.6 #2 0x00007fffffffd960 in ?? () #3 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.s= o.6 Backtrace stopped: frame did not save the PC Alan helpfully describes some rules for correctly maintaining the CFI infor= mation: 1) Every adjustment to the current frame address reg (ie. r1) must be described, and exactly at the instruction where r1 changes. Why? Because stack unwinding might want to access previous frames. 2) If a function changes LR or any non-volatile register, the save location for those regs must be given. The CFI can be at any instruction after the saves up to the point that the reg is changed. (Exception: LR save should be described before a bl. not after) 3) If asychronous unwind info is needed then restores of LR and non-volatile regs must also be described. The CFI can be at any instruction after the reg is restored up to the point where the save location is (potentially) trashed. Fix the inability to backtrace by adding CFI directives describing the changes to r1, ie. satisfying rule 1. Also change the information for LR to point to the copy saved on the stack, not the value in r0 that will be overwritten by the function call. Finally, add CFI directives describing the save/restore of r2. With the fix gdb can correctly back trace and navigate up and down the stac= k: Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime () (gdb) bt #0 0x00007ffff7f804dc in __kernel_clock_gettime () #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.s= o.6 #2 0x0000000100015b60 in gettime () #3 0x000000010000c8bc in print_long_format () #4 0x000000010000d180 in print_current_files () #5 0x00000001000054ac in main () (gdb) up #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.s= o.6 (gdb) #2 0x0000000100015b60 in gettime () (gdb) #3 0x000000010000c8bc in print_long_format () (gdb) #4 0x000000010000d180 in print_current_files () (gdb) #5 0x00000001000054ac in main () (gdb) Initial frame selected; you cannot go up. (gdb) down #4 0x000000010000d180 in print_current_files () (gdb) #3 0x000000010000c8bc in print_long_format () (gdb) #2 0x0000000100015b60 in gettime () (gdb) #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.s= o.6 (gdb) #0 0x00007ffff7f804dc in __kernel_clock_gettime () (gdb) Fixes: ce7d8056e38b ("powerpc/vdso: Prepare for switching VDSO to generic C= implementation.") Cc: stable@vger.kernel.org # v5.11+ Reported-by: Alan Modra Signed-off-by: Michael Ellerman Reviewed-by: Segher Boessenkool Link: https://lore.kernel.org/r/20220502125010.1319370-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/kernel/vdso32/gettimeofday.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kerne= l/vdso32/gettimeofday.S index dd2099128b8f..42d40f895c1f 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -22,12 +22,15 @@ .macro cvdso_call funct call_time=3D0 .cfi_startproc PPC_STLU r1, -PPC_MIN_STKFRM(r1) + .cfi_adjust_cfa_offset PPC_MIN_STKFRM mflr r0 - .cfi_register lr, r0 PPC_STLU r1, -PPC_MIN_STKFRM(r1) + .cfi_adjust_cfa_offset PPC_MIN_STKFRM PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) + .cfi_rel_offset lr, PPC_MIN_STKFRM + PPC_LR_STKOFF #ifdef __powerpc64__ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) + .cfi_rel_offset r2, PPC_MIN_STKFRM + STK_GOT #endif get_datapage r5 .ifeq \call_time @@ -39,13 +42,15 @@ PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) #ifdef __powerpc64__ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) + .cfi_restore r2 #endif .ifeq \call_time cmpwi r3, 0 .endif mtlr r0 - .cfi_restore lr addi r1, r1, 2 * PPC_MIN_STKFRM + .cfi_restore lr + .cfi_def_cfa_offset 0 crclr so .ifeq \call_time beqlr+ --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 E4CC6C43334 for ; Mon, 11 Jul 2022 09:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbiGKJ7N (ORCPT ); Mon, 11 Jul 2022 05:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbiGKJ6g (ORCPT ); Mon, 11 Jul 2022 05:58:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E8DB5D15; Mon, 11 Jul 2022 02:27: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 D376A61366; Mon, 11 Jul 2022 09:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC9CDC34115; Mon, 11 Jul 2022 09:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531634; bh=72C4Cq7hWJ3xQ8q5umw7jp4XTDXmIZeMx894K7C2sR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAon/scjWfPjDlstymWMlbqgoQ+EipU9/rtfFRkOjkW/DWESSNqq+e2N03xIOD5vU 8p5gJUMFL0mC8jzxxEeJPAhAhVUtxRO1Pu6moZKIsdlbagcxBuuEZWG+XM35RM6I0K ncyh5XXKPh6PyDtCv4Xavwgx+ntBpQpavbTYpbSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, AngeloGioacchino Del Regno , Sasha Levin Subject: [PATCH 5.15 136/230] serial: 8250_mtk: Make sure to select the right FEATURE_SEL Date: Mon, 11 Jul 2022 11:06:32 +0200 Message-Id: <20220711090607.922087626@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: AngeloGioacchino Del Regno [ Upstream commit 6f81fdded0d024c7d4084d434764f30bca1cd6b1 ] Set the FEATURE_SEL at probe time to make sure that BIT(0) is enabled: this guarantees that when the port is configured as AP UART, the right register layout is interpreted by the UART IP. Signed-off-by: AngeloGioacchino Del Regno Cc: stable Link: https://lore.kernel.org/r/20220427132328.228297-3-angelogioacchino.de= lregno@collabora.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/serial/8250/8250_mtk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8= 250_mtk.c index de48a58460f4..de57f47635cd 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -57,6 +57,9 @@ #define MTK_UART_XON1 40 /* I/O: Xon character 1 */ #define MTK_UART_XOFF1 42 /* I/O: Xoff character 1 */ =20 +#define MTK_UART_FEATURE_SEL 39 /* Feature Selection register */ +#define MTK_UART_FEAT_NEWRMAP BIT(0) /* Use new register map */ + #ifdef CONFIG_SERIAL_8250_DMA enum dma_rx_status { DMA_RX_START =3D 0, @@ -572,6 +575,10 @@ static int mtk8250_probe(struct platform_device *pdev) uart.dma =3D data->dma; #endif =20 + /* Set AP UART new register map */ + writel(MTK_UART_FEAT_NEWRMAP, uart.port.membase + + (MTK_UART_FEATURE_SEL << uart.port.regshift)); + /* Disable Rate Fix function */ writel(0x0, uart.port.membase + (MTK_UART_RATE_FIX << uart.port.regshift)); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 95546CCA47B for ; Mon, 11 Jul 2022 09:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234307AbiGKJ7R (ORCPT ); Mon, 11 Jul 2022 05:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234228AbiGKJ6j (ORCPT ); Mon, 11 Jul 2022 05:58:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0815BB5D29; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id A17E161383; Mon, 11 Jul 2022 09:27:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAE1BC34115; Mon, 11 Jul 2022 09:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531637; bh=yukl6GV3BRbGGtmdnfo95ezX+H3GVr/qNTWjY1Phkmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CczWVxuyhWIh4CL3FxPASBHzJclnkjJUr48pLliffnahP1cz++FSQLAuhz8WQO9/n +IO6MNS1roQ02vx7e1fj0YN5YSHcJlrUvhOl4obRYKa+rsDKfvulAlYIHR0Z/PMcOy dsZ1Oh7IOaZyFgKpXkBRQ4PI8RwhEcRCXIojaLGg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 5.15 137/230] tty: n_gsm: fix invalid gsmtty_write_room() result Date: Mon, 11 Jul 2022 11:06:33 +0200 Message-Id: <20220711090607.950458131@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Starke [ Upstream commit 9361ebfbb79fd1bc8594a487c01ad52cdaa391ea ] gsmtty_write() does not prevent the user to use the full fifo size of 4096 bytes as allocated in gsm_dlci_alloc(). However, gsmtty_write_room() tries to limit the return value by 'TX_SIZE' and returns a negative value if the fifo has more than 'TX_SIZE' bytes stored. This is obviously wrong as 'TX_SIZE' is defined as 512. Define 'TX_SIZE' to the fifo size and use it accordingly for allocation to keep the current behavior. Return the correct remaining size of the fifo in gsmtty_write_room() via kfifo_avail(). Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220504081733.3494-3-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index fd4a86111a6e..4a430f6ca170 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -137,6 +137,7 @@ struct gsm_dlci { int retries; /* Uplink tty if active */ struct tty_port port; /* The tty bound to this DLCI if there is one */ +#define TX_SIZE 4096 /* Must be power of 2. */ struct kfifo fifo; /* Queue fifo for the DLCI */ int adaption; /* Adaption layer in use */ int prev_adaption; @@ -1758,7 +1759,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux= *gsm, int addr) return NULL; spin_lock_init(&dlci->lock); mutex_init(&dlci->mutex); - if (kfifo_alloc(&dlci->fifo, 4096, GFP_KERNEL) < 0) { + if (kfifo_alloc(&dlci->fifo, TX_SIZE, GFP_KERNEL) < 0) { kfree(dlci); return NULL; } @@ -3035,8 +3036,6 @@ static struct tty_ldisc_ops tty_ldisc_packet =3D { * Virtual tty side */ =20 -#define TX_SIZE 512 - /** * gsm_modem_upd_via_data - send modem bits via convergence layer * @dlci: channel @@ -3274,7 +3273,7 @@ static unsigned int gsmtty_write_room(struct tty_stru= ct *tty) struct gsm_dlci *dlci =3D tty->driver_data; if (dlci->state =3D=3D DLCI_CLOSED) return 0; - return TX_SIZE - kfifo_len(&dlci->fifo); + return kfifo_avail(&dlci->fifo); } =20 static unsigned int gsmtty_chars_in_buffer(struct tty_struct *tty) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 16493C433EF for ; Mon, 11 Jul 2022 10:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234231AbiGKKAE (ORCPT ); Mon, 11 Jul 2022 06:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231986AbiGKJ7G (ORCPT ); Mon, 11 Jul 2022 05:59:06 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A882BB62A2; Mon, 11 Jul 2022 02:27:38 -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 62F63CE126A; Mon, 11 Jul 2022 09:27:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75798C34115; Mon, 11 Jul 2022 09:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531639; bh=m/KGAc9SXJsoFefchDyBa6ZxTDVjstgXbewAd/5Yeqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gkL5FJescV9DPqarMa0vQTQu4x/CC0fkcNntjh7xxqsXfuUuJilCm1+ssBJZHHPT Ua86/5j4V2JrNkfmkkkGNa0pdLm+URX4xjulv8eLwUQ6r4rjcMTTVbvHfDJaP05JnQ x43vS01rzgK/eDTqtZv+frw32P7djUKcSgY7ns9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 138/230] drm/amdgpu: bind to any 0x1002 PCI diplay class device Date: Mon, 11 Jul 2022 11:06:34 +0200 Message-Id: <20220711090607.978575207@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Alex Deucher [ Upstream commit eb4fd29afd4aa1c98d882800ceeee7d1f5262803 ] Bind to all 0x1002 GPU devices. For now we explicitly return -ENODEV for generic bindings. Remove this check once IP discovery based checking is in place. v2: rebase (Alex) Reviewed-by: Christian K=C3=B6nig Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index f65b4b233ffb..c294081022bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1952,6 +1952,16 @@ static const struct pci_device_id pciidlist[] =3D { {0x1002, 0x7424, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BEIGE_GOBY}, {0x1002, 0x743F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BEIGE_GOBY}, =20 + { PCI_DEVICE(0x1002, PCI_ANY_ID), + .class =3D PCI_CLASS_DISPLAY_VGA << 8, + .class_mask =3D 0xffffff, + .driver_data =3D 0 }, + + { PCI_DEVICE(0x1002, PCI_ANY_ID), + .class =3D PCI_CLASS_DISPLAY_OTHER << 8, + .class_mask =3D 0xffffff, + .driver_data =3D 0 }, + {0, 0, 0} }; =20 @@ -1999,6 +2009,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return -ENODEV; } =20 + if (flags =3D=3D 0) { + DRM_INFO("Unsupported asic. Remove me when IP discovery init is in plac= e.\n"); + return -ENODEV; + } + if (amdgpu_virtual_display || amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK)) supports_atomic =3D true; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 B6618C433EF for ; Mon, 11 Jul 2022 09:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbiGKJ7E (ORCPT ); Mon, 11 Jul 2022 05:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbiGKJ63 (ORCPT ); Mon, 11 Jul 2022 05:58:29 -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 13E8360536; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2370A61370; Mon, 11 Jul 2022 09:27:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29B06C34115; Mon, 11 Jul 2022 09:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531642; bh=QV3wDxkxr74z3UkBITYTHGpxhZq8sdSdwFhGqaxO/UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNPWStETgrcR/E25nSh3n52DhzKVQiNsDzEwYXEgnZC0VKlDWVhh0xjPL2NFVI2ku JU+wfxRJKfhPhqOiuBaYpfL3uiY/SfSDZdSURK7X+0Rg10m2CCuJswcUc66ziv6bNv e7ZOejkkCl9a0EStUaLwqHyVmJa1PlxhljUXdhDg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Fink , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 139/230] drm/amdgpu: Fix rejecting Tahiti GPUs Date: Mon, 11 Jul 2022 11:06:35 +0200 Message-Id: <20220711090608.007049812@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Fink [ Upstream commit 3993a799fc971bc9b918bd969aa55864447b5dde ] [ Upstream commit 5f0754ab2751d1935818459e8e71a8fe26f6403c ] eb4fd29afd4a ("drm/amdgpu: bind to any 0x1002 PCI diplay class device") add= ed generic bindings to amdgpu so that that it binds to all display class devic= es with VID 0x1002 and then rejects those in amdgpu_pci_probe. Unfortunately it reuses a driver_data value of 0 to detect those new bindin= gs, which is already used to denote CHIP_TAHITI ASICs. The driver_data value given to those new bindings was changed in dd0761fd24ea1 ("drm/amdgpu: set CHIP_IP_DISCOVERY as the asic type by defau= lt") to CHIP_IP_DISCOVERY (=3D36), but it seems that the check in amdgpu_pci_pro= be was forgotten to be changed. Therefore, it still rejects Tahiti GPUs. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1860 Fixes: eb4fd29afd4a ("drm/amdgpu: bind to any 0x1002 PCI diplay class devic= e") Cc: stable@vger.kernel.org Signed-off-by: Lukas Fink Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2009,7 +2009,7 @@ static int amdgpu_pci_probe(struct pci_d return -ENODEV; } =20 - if (flags =3D=3D 0) { + if (flags =3D=3D CHIP_IP_DISCOVERY) { DRM_INFO("Unsupported asic. Remove me when IP discovery init is in plac= e.\n"); return -ENODEV; } From nobody Sat Apr 18 21:00:49 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 B0DE7C433EF for ; Mon, 11 Jul 2022 09:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234242AbiGKJyb (ORCPT ); Mon, 11 Jul 2022 05:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233276AbiGKJx0 (ORCPT ); Mon, 11 Jul 2022 05:53:26 -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 2C9C4AE554; Mon, 11 Jul 2022 02:25: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 56FA46135F; Mon, 11 Jul 2022 09:25:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68446C341C8; Mon, 11 Jul 2022 09:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531532; bh=QlBAKrIYnrUzq35r1sV7UTU7z78mc0/i7wzKFGjNtb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fEnyzci8d3U3hQWfTmj5Po21FYUIVSEA/FdO6ZoSeXz7o/X7mNGd5nV7i0hVfqQFK qG97vFLZxoMbc29FeuYo9jUiY9GGiIgakSlD7gNQZ8a7cXrkEJb+GKxsX9BC2AgV0n /iuziwxrLlfg+o7w0Y4OTHVt1+IiZ7vI1BditnPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hawking Zhang , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 140/230] drm/amdgpu: drop flags check for CHIP_IP_DISCOVERY Date: Mon, 11 Jul 2022 11:06:36 +0200 Message-Id: <20220711090608.035066118@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Alex Deucher [ Upstream commit d82ce3cd30aa28db3e94ffc36ebf0af2ff12801d ] Support for IP based discovery is in place now so this check is no longer required. Reviewed-by: Hawking Zhang Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index cb0b5972e7fd..a0dd4b41ba4a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2009,11 +2009,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return -ENODEV; } =20 - if (flags =3D=3D CHIP_IP_DISCOVERY) { - DRM_INFO("Unsupported asic. Remove me when IP discovery init is in plac= e.\n"); - return -ENODEV; - } - if (amdgpu_virtual_display || amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK)) supports_atomic =3D true; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 E1652CCA47B for ; Mon, 11 Jul 2022 09:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233804AbiGKJyg (ORCPT ); Mon, 11 Jul 2022 05:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbiGKJx3 (ORCPT ); Mon, 11 Jul 2022 05:53:29 -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 0E22D32ECF; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1A63F6112E; Mon, 11 Jul 2022 09:25:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27106C34115; Mon, 11 Jul 2022 09:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531535; bh=XjUZrUHL7LcdbDE6IVjFy/5ilO4yxwYXYvobmuNbkv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gqQqdBSyF+77WS1C6PunlTI4A5YlPyiI3ymCYcFikWSrvoPIov4rmoyRDyG7kDSI/ L66H4xHUlXRbpDbBPC/Xq2MEnM6940zK1pEmCqCxxqBuxmLO02v24y8NPmSH/Cd/VY /0xsa+4uNhoWPbAQsi3EWpS4Z9GTk27dbj7TPwhw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lijo Lazar , Mario Limonciello , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 141/230] drm/amd: Refactor `amdgpu_aspm` to be evaluated per device Date: Mon, 11 Jul 2022 11:06:37 +0200 Message-Id: <20220711090608.062900976@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 0ab5d711ec74d9e60673900974806b7688857947 ] Evaluating `pcie_aspm_enabled` as part of driver probe has the implication that if one PCIe bridge with an AMD GPU connected doesn't support ASPM then none of them do. This is an invalid assumption as the PCIe core will configure ASPM for individual PCIe bridges. Create a new helper function that can be called by individual dGPUs to react to the `amdgpu_aspm` module parameter without having negative results for other dGPUs on the PCIe bus. Suggested-by: Lijo Lazar Reviewed-by: Lijo Lazar Signed-off-by: Mario Limonciello Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 25 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/cik.c | 2 +- drivers/gpu/drm/amd/amdgpu/nv.c | 2 +- drivers/gpu/drm/amd/amdgpu/si.c | 2 +- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +- drivers/gpu/drm/amd/amdgpu/vi.c | 2 +- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 2 +- 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdg= pu/amdgpu.h index 2eebefd26fa8..5f95d03fd46a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1285,6 +1285,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *a= dev, void amdgpu_device_pci_config_reset(struct amdgpu_device *adev); int amdgpu_device_pci_reset(struct amdgpu_device *adev); bool amdgpu_device_need_post(struct amdgpu_device *adev); +bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev); =20 void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_byte= s, u64 num_vis_bytes); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c index a926b5ebbfdf..d1af709cc7dc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1309,6 +1309,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *a= dev) return true; } =20 +/** + * amdgpu_device_should_use_aspm - check if the device should program ASPM + * + * @adev: amdgpu_device pointer + * + * Confirm whether the module parameter and pcie bridge agree that ASPM sh= ould + * be set for this device. + * + * Returns true if it should be used or false if not. + */ +bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev) +{ + switch (amdgpu_aspm) { + case -1: + break; + case 0: + return false; + case 1: + return true; + default: + return false; + } + return pcie_aspm_enabled(adev->pdev); +} + /* if we get transitioned to only one device, take VGA back */ /** * amdgpu_device_vga_set_decode - enable/disable vga decode diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/= cik.c index f10ce740a29c..de6d10390ab2 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c @@ -1719,7 +1719,7 @@ static void cik_program_aspm(struct amdgpu_device *ad= ev) bool disable_l0s =3D false, disable_l1 =3D false, disable_plloff_in_l1 = =3D false; bool disable_clkreq =3D false; =20 - if (amdgpu_aspm =3D=3D 0) + if (!amdgpu_device_should_use_aspm(adev)) return; =20 if (pci_is_root_bus(adev->pdev->bus)) diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/n= v.c index 9cbed9a8f1c0..6e277236b44f 100644 --- a/drivers/gpu/drm/amd/amdgpu/nv.c +++ b/drivers/gpu/drm/amd/amdgpu/nv.c @@ -584,7 +584,7 @@ static void nv_pcie_gen3_enable(struct amdgpu_device *a= dev) =20 static void nv_program_aspm(struct amdgpu_device *adev) { - if (!amdgpu_aspm) + if (!amdgpu_device_should_use_aspm(adev)) return; =20 if (!(adev->flags & AMD_IS_APU) && diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/s= i.c index e6d2f74a7976..7f99e130acd0 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c @@ -2453,7 +2453,7 @@ static void si_program_aspm(struct amdgpu_device *ade= v) bool disable_l0s =3D false, disable_l1 =3D false, disable_plloff_in_l1 = =3D false; bool disable_clkreq =3D false; =20 - if (amdgpu_aspm =3D=3D 0) + if (!amdgpu_device_should_use_aspm(adev)) return; =20 if (adev->flags & AMD_IS_APU) diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgp= u/soc15.c index 6439d5c3d8d8..bdb47ae96ce6 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -689,7 +689,7 @@ static void soc15_pcie_gen3_enable(struct amdgpu_device= *adev) =20 static void soc15_program_aspm(struct amdgpu_device *adev) { - if (!amdgpu_aspm) + if (!amdgpu_device_should_use_aspm(adev)) return; =20 if (!(adev->flags & AMD_IS_APU) && diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/v= i.c index 6645ebbd2696..039b90cdc3bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c @@ -1140,7 +1140,7 @@ static void vi_program_aspm(struct amdgpu_device *ade= v) bool bL1SS =3D false; bool bClkReqSupport =3D true; =20 - if (!amdgpu_aspm) + if (!amdgpu_device_should_use_aspm(adev)) return; =20 if (adev->flags & AMD_IS_APU || diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/driv= ers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c index 574a9d7f7a5e..918d5c7c2328 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -338,7 +338,7 @@ sienna_cichlid_get_allowed_feature_mask(struct smu_cont= ext *smu, if (smu->dc_controlled_by_gpio) *(uint64_t *)feature_mask |=3D FEATURE_MASK(FEATURE_ACDC_BIT); =20 - if (amdgpu_aspm) + if (amdgpu_device_should_use_aspm(adev)) *(uint64_t *)feature_mask |=3D FEATURE_MASK(FEATURE_DS_LCLK_BIT); =20 return 0; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 DAE14C43334 for ; Mon, 11 Jul 2022 09:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbiGKJyk (ORCPT ); Mon, 11 Jul 2022 05:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234029AbiGKJx4 (ORCPT ); Mon, 11 Jul 2022 05:53:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A54AEF49; Mon, 11 Jul 2022 02:25:40 -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 74AF0B80E8C; Mon, 11 Jul 2022 09:25:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D73FDC34115; Mon, 11 Jul 2022 09:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531538; bh=NFoeWV8XCLFB34kMOAY52aZI2Cc0cS6OCzNu6IoLMZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFP1Unq6OGm7o8v0qe8wLC52X02pH9H+hR8cSip4eM4KYEF0zGaYh2vv4GauTWlJc 4bF9FGMspkdVtfOqzYNT6XraJ8LoBvkBRdfoqK505S7E+A8lJ7OCx5Kh9g96mqQOL9 dwoQCF1UE3ZPonfzXcmHA46shDwwCjA5c7YxfjqY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Gong , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 142/230] drm/amdgpu: vi: disable ASPM on Intel Alder Lake based systems Date: Mon, 11 Jul 2022 11:06:38 +0200 Message-Id: <20220711090608.091098872@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Gong [ Upstream commit aa482ddca85a3485be0e7b83a0789dc4d987670b ] Active State Power Management (ASPM) feature is enabled since kernel 5.14. There are some AMD Volcanic Islands (VI) GFX cards, such as the WX3200 and RX640, that do not work with ASPM-enabled Intel Alder Lake based systems. Using these GFX cards as video/display output, Intel Alder Lake based systems will freeze after suspend/resume. The issue was originally reported on one system (Dell Precision 3660 with BIOS version 0.14.81), but was later confirmed to affect at least 4 pre-production Alder Lake based systems. Add an extra check to disable ASPM on Intel Alder Lake based systems with the problematic AMD Volcanic Islands GFX cards. Fixes: 0064b0ce85bb ("drm/amd/pm: enable ASPM by default") Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1885 Signed-off-by: Richard Gong Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/amd/amdgpu/vi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/v= i.c index 039b90cdc3bc..45f0188c4273 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c @@ -81,6 +81,10 @@ #include "mxgpu_vi.h" #include "amdgpu_dm.h" =20 +#if IS_ENABLED(CONFIG_X86) +#include +#endif + #define ixPCIE_LC_L1_PM_SUBSTATE 0x100100C6 #define PCIE_LC_L1_PM_SUBSTATE__LC_L1_SUBSTATES_OVERRIDE_EN_MASK 0x0000000= 1L #define PCIE_LC_L1_PM_SUBSTATE__LC_PCI_PM_L1_2_OVERRIDE_MASK 0x00000002L @@ -1134,13 +1138,24 @@ static void vi_enable_aspm(struct amdgpu_device *ad= ev) WREG32_PCIE(ixPCIE_LC_CNTL, data); } =20 +static bool aspm_support_quirk_check(void) +{ +#if IS_ENABLED(CONFIG_X86) + struct cpuinfo_x86 *c =3D &cpu_data(0); + + return !(c->x86 =3D=3D 6 && c->x86_model =3D=3D INTEL_FAM6_ALDERLAKE); +#else + return true; +#endif +} + static void vi_program_aspm(struct amdgpu_device *adev) { u32 data, data1, orig; bool bL1SS =3D false; bool bClkReqSupport =3D true; =20 - if (!amdgpu_device_should_use_aspm(adev)) + if (!amdgpu_device_should_use_aspm(adev) || !aspm_support_quirk_check()) return; =20 if (adev->flags & AMD_IS_APU || --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 EECABC43334 for ; Mon, 11 Jul 2022 09:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233973AbiGKJyo (ORCPT ); Mon, 11 Jul 2022 05:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbiGKJx5 (ORCPT ); Mon, 11 Jul 2022 05:53:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4294AEF53; Mon, 11 Jul 2022 02: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9487D6136F; Mon, 11 Jul 2022 09:25:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F6C1C36AED; Mon, 11 Jul 2022 09:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531541; bh=nY92Q6t9HQ1EGT2GXplwzbOzFAiJHfULIB3VSs63zjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wgko3kNsBIzDMdOsWkE0CyVbcojpPg6XqkMicw5x20s1dVk9X0lk0HXhILEHYJY2P p4DL36uH8ZvW2d5XAd1TYIM52MpvHXd/gJxf5c6j6sXdA9XhRqEiKzdyK8jq1ZFWPH KdxOZ3lbO7su0vO1T4OmlONJXfGTKagbqcTxjK1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Maarten Lankhorst , Sasha Levin Subject: [PATCH 5.15 143/230] drm/i915: Fix a race between vma / object destruction and unbinding Date: Mon, 11 Jul 2022 11:06:39 +0200 Message-Id: <20220711090608.119577076@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Thomas Hellstr=C3=B6m [ Upstream commit bc1922e5d349db4be14c55513102c024c2ae8a50 ] The vma destruction code was using an unlocked advisory check for drm_mm_node_allocated() to avoid racing with eviction code unbinding the vma. This is very fragile and prohibits the dereference of non-refcounted pointers of dying vmas after a call to __i915_vma_unbind(). It also prohibits the dereference of vma->obj of refcounted pointers of dying vmas after a call to __i915_vma_unbind(), since even if a refcount is held on the vma, that won't guarantee that its backing object doesn't get destroyed. So introduce an unbind under the vm mutex at object destroy time, removing all weak references of the vma and its object from the object vma list and from the vm bound list. Signed-off-by: Thomas Hellstr=C3=B6m Reviewed-by: Maarten Lankhorst Link: https://patchwork.freedesktop.org/patch/msgid/20220127115622.302970-1= -thomas.hellstrom@linux.intel.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/i915/gem/i915_gem_object.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i= 915/gem/i915_gem_object.c index 6fb9afb65034..5f48d5ea5c15 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -224,6 +224,12 @@ void __i915_gem_free_object(struct drm_i915_gem_object= *obj) GEM_BUG_ON(vma->obj !=3D obj); spin_unlock(&obj->vma.lock); =20 + /* Verify that the vma is unbound under the vm mutex. */ + mutex_lock(&vma->vm->mutex); + atomic_and(~I915_VMA_PIN_MASK, &vma->flags); + __i915_vma_unbind(vma); + mutex_unlock(&vma->vm->mutex); + __i915_vma_put(vma); =20 spin_lock(&obj->vma.lock); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 7CF67C433EF for ; Mon, 11 Jul 2022 09:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233956AbiGKJzQ (ORCPT ); Mon, 11 Jul 2022 05:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234000AbiGKJyG (ORCPT ); Mon, 11 Jul 2022 05:54:06 -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 DE5B1AEF73; Mon, 11 Jul 2022 02:25:46 -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 1D0E5B80E7E; Mon, 11 Jul 2022 09:25:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E226C34115; Mon, 11 Jul 2022 09:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531543; bh=0OYdaRbdLWNZ8z/6ur+Zqcb5Wq5UHeldQUWNjF/45oE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgxpaJq9rYp2SDJr9BErdngy26ItLhQwe1AqayuhAefL5CnT3qNU4bpM7tSUEs0tE M6DY44lR9aFNaODwPHcoo8GQazMpKXmsGjWLhgsUOak+KvRFZBR9FHIwtdOVfR5YtU ea6hqlpPXcqBGhsJSXPNt/Nr/RPKWndDeOUdPIjg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chun-Kuang Hu , "jason-jh.lin" , Sasha Levin Subject: [PATCH 5.15 144/230] drm/mediatek: Use mailbox rx_callback instead of cmdq_task_cb Date: Mon, 11 Jul 2022 11:06:40 +0200 Message-Id: <20220711090608.147755342@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chun-Kuang Hu [ Upstream commit 1ee07a683b7e4e6ad9ad4f77fce4751741bc8ceb ] rx_callback is a standard mailbox callback mechanism and could cover the function of proprietary cmdq_task_cb, so use the standard one instead of the proprietary one. Signed-off-by: Chun-Kuang Hu Signed-off-by: jason-jh.lin Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/medi= atek/mtk_drm_crtc.c index a4e80e499674..369d3e68c0b6 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -4,6 +4,8 @@ */ =20 #include +#include +#include #include #include #include @@ -222,9 +224,11 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct= drm_crtc *crtc, } =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) -static void ddp_cmdq_cb(struct cmdq_cb_data data) +static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) { - cmdq_pkt_destroy(data.data); + struct cmdq_cb_data *data =3D mssg; + + cmdq_pkt_destroy(data->pkt); } #endif =20 @@ -475,7 +479,12 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_= crtc *mtk_crtc, cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); mtk_crtc_ddp_config(crtc, cmdq_handle); cmdq_pkt_finalize(cmdq_handle); - cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle); + dma_sync_single_for_device(mtk_crtc->cmdq_client->chan->mbox->dev, + cmdq_handle->pa_base, + cmdq_handle->cmd_buf_size, + DMA_TO_DEVICE); + mbox_send_message(mtk_crtc->cmdq_client->chan, cmdq_handle); + mbox_client_txdone(mtk_crtc->cmdq_client->chan, 0); } #endif mtk_crtc->config_updating =3D false; @@ -839,6 +848,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, } =20 if (mtk_crtc->cmdq_client) { + mtk_crtc->cmdq_client->client.rx_callback =3D ddp_cmdq_cb; ret =3D of_property_read_u32_index(priv->mutex_node, "mediatek,gce-events", drm_crtc_index(&mtk_crtc->base), --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 8DAD5C433EF for ; Mon, 11 Jul 2022 09:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233992AbiGKJys (ORCPT ); Mon, 11 Jul 2022 05:54:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234051AbiGKJyI (ORCPT ); Mon, 11 Jul 2022 05:54:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D9ADAF743; Mon, 11 Jul 2022 02:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1EF3061366; Mon, 11 Jul 2022 09:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CB2BC34115; Mon, 11 Jul 2022 09:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531546; bh=y6KWV1l7vFa0AvPblk5Xk5IqSRITdwavbUj/jVWrbMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IttRf0t12GDfEPitC9FLR2iXKOngwGS0p8NIqZCDHnCdz2EVAKQfBCWqbXWQS9WHj wmrdQWrJrzWbW3KOinKn6SwzDOMZEp/VWJlSZWo3d2woXLERIuvTpNycBpTeU2u2ij m92XUT3S35y/XPXX9YkeDMUgw70ZTQMXquzkNFXw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chun-Kuang Hu , "jason-jh.lin" , Sasha Levin Subject: [PATCH 5.15 145/230] drm/mediatek: Remove the pointer of struct cmdq_client Date: Mon, 11 Jul 2022 11:06:41 +0200 Message-Id: <20220711090608.175503461@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chun-Kuang Hu [ Upstream commit 563c9d4a5b117552150efbecbaf0877947e98a32 ] In mailbox rx_callback, it pass struct mbox_client to callback function, but it could not map back to mtk_drm_crtc instance because struct cmdq_client use a pointer to struct mbox_client: struct cmdq_client { struct mbox_client client; struct mbox_chan *chan; }; struct mtk_drm_crtc { /* client instance data */ struct cmdq_client *cmdq_client; }; so remove the pointer of struct cmdq_client and let mtk_drm_crtc instance define cmdq_client as: struct mtk_drm_crtc { /* client instance data */ struct cmdq_client cmdq_client; }; and in rx_callback function, use struct mbox_client to get struct mtk_drm_crtc. Signed-off-by: Chun-Kuang Hu Signed-off-by: jason-jh.lin Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/medi= atek/mtk_drm_crtc.c index 369d3e68c0b6..e23e3224ac67 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -52,7 +52,7 @@ struct mtk_drm_crtc { bool pending_async_planes; =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) - struct cmdq_client *cmdq_client; + struct cmdq_client cmdq_client; u32 cmdq_event; #endif =20 @@ -472,19 +472,19 @@ static void mtk_drm_crtc_update_config(struct mtk_drm= _crtc *mtk_crtc, mtk_mutex_release(mtk_crtc->mutex); } #if IS_REACHABLE(CONFIG_MTK_CMDQ) - if (mtk_crtc->cmdq_client) { - mbox_flush(mtk_crtc->cmdq_client->chan, 2000); - cmdq_handle =3D cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE); + if (mtk_crtc->cmdq_client.chan) { + mbox_flush(mtk_crtc->cmdq_client.chan, 2000); + cmdq_handle =3D cmdq_pkt_create(&mtk_crtc->cmdq_client, PAGE_SIZE); cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); mtk_crtc_ddp_config(crtc, cmdq_handle); cmdq_pkt_finalize(cmdq_handle); - dma_sync_single_for_device(mtk_crtc->cmdq_client->chan->mbox->dev, + dma_sync_single_for_device(mtk_crtc->cmdq_client.chan->mbox->dev, cmdq_handle->pa_base, cmdq_handle->cmd_buf_size, DMA_TO_DEVICE); - mbox_send_message(mtk_crtc->cmdq_client->chan, cmdq_handle); - mbox_client_txdone(mtk_crtc->cmdq_client->chan, 0); + mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle); + mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0); } #endif mtk_crtc->config_updating =3D false; @@ -498,7 +498,7 @@ static void mtk_crtc_ddp_irq(void *data) struct mtk_drm_private *priv =3D crtc->dev->dev_private; =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) - if (!priv->data->shadow_register && !mtk_crtc->cmdq_client) + if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan) #else if (!priv->data->shadow_register) #endif @@ -838,17 +838,20 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mutex_init(&mtk_crtc->hw_lock); =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) - mtk_crtc->cmdq_client =3D - cmdq_mbox_create(mtk_crtc->mmsys_dev, - drm_crtc_index(&mtk_crtc->base)); - if (IS_ERR(mtk_crtc->cmdq_client)) { + mtk_crtc->cmdq_client.client.dev =3D mtk_crtc->mmsys_dev; + mtk_crtc->cmdq_client.client.tx_block =3D false; + mtk_crtc->cmdq_client.client.knows_txdone =3D true; + mtk_crtc->cmdq_client.client.rx_callback =3D ddp_cmdq_cb; + mtk_crtc->cmdq_client.chan =3D + mbox_request_channel(&mtk_crtc->cmdq_client.client, + drm_crtc_index(&mtk_crtc->base)); + if (IS_ERR(mtk_crtc->cmdq_client.chan)) { dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing regis= ter by CPU now\n", drm_crtc_index(&mtk_crtc->base)); - mtk_crtc->cmdq_client =3D NULL; + mtk_crtc->cmdq_client.chan =3D NULL; } =20 - if (mtk_crtc->cmdq_client) { - mtk_crtc->cmdq_client->client.rx_callback =3D ddp_cmdq_cb; + if (mtk_crtc->cmdq_client.chan) { ret =3D of_property_read_u32_index(priv->mutex_node, "mediatek,gce-events", drm_crtc_index(&mtk_crtc->base), @@ -856,8 +859,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, if (ret) { dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n", drm_crtc_index(&mtk_crtc->base)); - cmdq_mbox_destroy(mtk_crtc->cmdq_client); - mtk_crtc->cmdq_client =3D NULL; + mbox_free_channel(mtk_crtc->cmdq_client.chan); + mtk_crtc->cmdq_client.chan =3D NULL; } } #endif --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 4AC32C433EF for ; Mon, 11 Jul 2022 09:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234002AbiGKJyx (ORCPT ); Mon, 11 Jul 2022 05:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234147AbiGKJyT (ORCPT ); Mon, 11 Jul 2022 05:54: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 C079BAF770; Mon, 11 Jul 2022 02:25: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 8026BB80E6D; Mon, 11 Jul 2022 09:25:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D00FFC34115; Mon, 11 Jul 2022 09:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531549; bh=AqEjWHgcoYJmR2Y2hTNYTlTBsAIkaFux81Wk/JVj7WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPokVt8jbM30eZNU3ugskrg/lFMRodmAoMMcevn+oQxd5ENIIbb6sc5jWv23vT1PY 8W3n+uQcYG9SCfEsANp6imIKH3y+uoehpg5F0kgVMldVa+M628xnm+RHk8N0kWJO1/ fe+xGjnpJQZGt1DhyM8/9xGXRobPHsi5UyQHw6FQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chun-Kuang Hu , "jason-jh.lin" , Sasha Levin Subject: [PATCH 5.15 146/230] drm/mediatek: Detect CMDQ execution timeout Date: Mon, 11 Jul 2022 11:06:42 +0200 Message-Id: <20220711090608.203578148@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chun-Kuang Hu [ Upstream commit eaf80126aba6fd1754837eec91e4c8bbd58ae52e ] CMDQ is used to update display register in vblank period, so it should be execute in next 2 vblank. One vblank interrupt before send message (occasionally) and one vblank interrupt after cmdq done. If it fail to execute in next 3 vblank, tiemout happen. Signed-off-by: Chun-Kuang Hu Signed-off-by: jason-jh.lin Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/medi= atek/mtk_drm_crtc.c index e23e3224ac67..dad1f85ee315 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -54,6 +54,7 @@ struct mtk_drm_crtc { #if IS_REACHABLE(CONFIG_MTK_CMDQ) struct cmdq_client cmdq_client; u32 cmdq_event; + u32 cmdq_vblank_cnt; #endif =20 struct device *mmsys_dev; @@ -227,7 +228,10 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct= drm_crtc *crtc, static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) { struct cmdq_cb_data *data =3D mssg; + struct cmdq_client *cmdq_cl =3D container_of(cl, struct cmdq_client, clie= nt); + struct mtk_drm_crtc *mtk_crtc =3D container_of(cmdq_cl, struct mtk_drm_cr= tc, cmdq_client); =20 + mtk_crtc->cmdq_vblank_cnt =3D 0; cmdq_pkt_destroy(data->pkt); } #endif @@ -483,6 +487,15 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_= crtc *mtk_crtc, cmdq_handle->pa_base, cmdq_handle->cmd_buf_size, DMA_TO_DEVICE); + /* + * CMDQ command should execute in next 3 vblank. + * One vblank interrupt before send message (occasionally) + * and one vblank interrupt after cmdq done, + * so it's timeout after 3 vblank interrupt. + * If it fail to execute in next 3 vblank, timeout happen. + */ + mtk_crtc->cmdq_vblank_cnt =3D 3; + mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle); mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0); } @@ -499,11 +512,14 @@ static void mtk_crtc_ddp_irq(void *data) =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan) + mtk_crtc_ddp_config(crtc, NULL); + else if (mtk_crtc->cmdq_vblank_cnt > 0 && --mtk_crtc->cmdq_vblank_cnt =3D= =3D 0) + DRM_ERROR("mtk_crtc %d CMDQ execute command timeout!\n", + drm_crtc_index(&mtk_crtc->base)); #else if (!priv->data->shadow_register) -#endif mtk_crtc_ddp_config(crtc, NULL); - +#endif mtk_drm_finish_page_flip(mtk_crtc); } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 ED00EC43334 for ; Mon, 11 Jul 2022 09:54:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233989AbiGKJy4 (ORCPT ); Mon, 11 Jul 2022 05:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234178AbiGKJyX (ORCPT ); Mon, 11 Jul 2022 05:54:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41EBFB024E; Mon, 11 Jul 2022 02: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 22DD8B80E7E; Mon, 11 Jul 2022 09:25:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83D50C34115; Mon, 11 Jul 2022 09:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531551; bh=Ru0FlTXSFrP7c1l1IHpyvE9E4uTeRkhrDqGAdgkUydQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F0juPWiErB7ZkHU/xiJ4vclQmLJG4pDfxEDlcBOwEHrrYudbv25OaTl53mejOz8nv CRXLUOEErsuUcHJIM0L3QPKbfqAMY2fVCS3S/inp309Icbu53QuL/+sGQgct2s2ubX rvMJSHnIjDJBRdo3z2kyU2n+KUtPUNtdTuw/r3HA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chun-Kuang Hu , "jason-jh.lin" , Sasha Levin Subject: [PATCH 5.15 147/230] drm/mediatek: Add cmdq_handle in mtk_crtc Date: Mon, 11 Jul 2022 11:06:43 +0200 Message-Id: <20220711090608.231843173@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Chun-Kuang Hu [ Upstream commit 7627122fd1c06800a1fe624e9fb3c269796115e8 ] One mtk_crtc need just one cmdq_handle, so add one cmdq_handle in mtk_crtc to prevent frequently allocation and free of cmdq_handle. Signed-off-by: Chun-Kuang Hu Signed-off-by: jason-jh.lin Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 62 +++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/medi= atek/mtk_drm_crtc.c index dad1f85ee315..ffa54b416ca7 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -53,6 +53,7 @@ struct mtk_drm_crtc { =20 #if IS_REACHABLE(CONFIG_MTK_CMDQ) struct cmdq_client cmdq_client; + struct cmdq_pkt cmdq_handle; u32 cmdq_event; u32 cmdq_vblank_cnt; #endif @@ -107,12 +108,55 @@ static void mtk_drm_finish_page_flip(struct mtk_drm_c= rtc *mtk_crtc) } } =20 +#if IS_REACHABLE(CONFIG_MTK_CMDQ) +static int mtk_drm_cmdq_pkt_create(struct cmdq_client *client, struct cmdq= _pkt *pkt, + size_t size) +{ + struct device *dev; + dma_addr_t dma_addr; + + pkt->va_base =3D kzalloc(size, GFP_KERNEL); + if (!pkt->va_base) { + kfree(pkt); + return -ENOMEM; + } + pkt->buf_size =3D size; + pkt->cl =3D (void *)client; + + dev =3D client->chan->mbox->dev; + dma_addr =3D dma_map_single(dev, pkt->va_base, pkt->buf_size, + DMA_TO_DEVICE); + if (dma_mapping_error(dev, dma_addr)) { + dev_err(dev, "dma map failed, size=3D%u\n", (u32)(u64)size); + kfree(pkt->va_base); + kfree(pkt); + return -ENOMEM; + } + + pkt->pa_base =3D dma_addr; + + return 0; +} + +static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt) +{ + struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; + + dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_size, + DMA_TO_DEVICE); + kfree(pkt->va_base); + kfree(pkt); +} +#endif + static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) { struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); =20 mtk_mutex_put(mtk_crtc->mutex); - +#if IS_REACHABLE(CONFIG_MTK_CMDQ) + mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle); +#endif drm_crtc_cleanup(crtc); } =20 @@ -227,12 +271,10 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struc= t drm_crtc *crtc, #if IS_REACHABLE(CONFIG_MTK_CMDQ) static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) { - struct cmdq_cb_data *data =3D mssg; struct cmdq_client *cmdq_cl =3D container_of(cl, struct cmdq_client, clie= nt); struct mtk_drm_crtc *mtk_crtc =3D container_of(cmdq_cl, struct mtk_drm_cr= tc, cmdq_client); =20 mtk_crtc->cmdq_vblank_cnt =3D 0; - cmdq_pkt_destroy(data->pkt); } #endif =20 @@ -438,7 +480,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_c= rtc *mtk_crtc, bool needs_vblank) { #if IS_REACHABLE(CONFIG_MTK_CMDQ) - struct cmdq_pkt *cmdq_handle; + struct cmdq_pkt *cmdq_handle =3D &mtk_crtc->cmdq_handle; #endif struct drm_crtc *crtc =3D &mtk_crtc->base; struct mtk_drm_private *priv =3D crtc->dev->dev_private; @@ -478,7 +520,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_c= rtc *mtk_crtc, #if IS_REACHABLE(CONFIG_MTK_CMDQ) if (mtk_crtc->cmdq_client.chan) { mbox_flush(mtk_crtc->cmdq_client.chan, 2000); - cmdq_handle =3D cmdq_pkt_create(&mtk_crtc->cmdq_client, PAGE_SIZE); + cmdq_handle->cmd_buf_size =3D 0; cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); mtk_crtc_ddp_config(crtc, cmdq_handle); @@ -877,6 +919,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, drm_crtc_index(&mtk_crtc->base)); mbox_free_channel(mtk_crtc->cmdq_client.chan); mtk_crtc->cmdq_client.chan =3D NULL; + } else { + ret =3D mtk_drm_cmdq_pkt_create(&mtk_crtc->cmdq_client, + &mtk_crtc->cmdq_handle, + PAGE_SIZE); + if (ret) { + dev_dbg(dev, "mtk_crtc %d failed to create cmdq packet\n", + drm_crtc_index(&mtk_crtc->base)); + mbox_free_channel(mtk_crtc->cmdq_client.chan); + mtk_crtc->cmdq_client.chan =3D NULL; + } } } #endif --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 24E27C433EF for ; Mon, 11 Jul 2022 09:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234059AbiGKJzG (ORCPT ); Mon, 11 Jul 2022 05:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234210AbiGKJy1 (ORCPT ); Mon, 11 Jul 2022 05:54:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F7E3B025F; Mon, 11 Jul 2022 02:25:59 -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 EF1EFB80E8F; Mon, 11 Jul 2022 09:25:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F434C34115; Mon, 11 Jul 2022 09:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531554; bh=pRDLEiqXGckzWAfPGHUwsgjSluhofxx3Sa3x9GF5Juk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmgb8ILIa2OQkCSU8aaER1EWf+pmnvbuAt48a0N8t30KkBByrFjY5rR04ei5fnKMP +aGTHeg5xq04ArPrek+DpunpZcAgR4m8yWa7+HmIxZLKrHCKZmAA7aRbrx0FJAFkLx voF1G8pIZYJ2z2x+nsiXqmv01ZJvaCRhAFpzerSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rex-BC Chen , "jason-jh.lin" , Chun-Kuang Hu , Sasha Levin Subject: [PATCH 5.15 148/230] drm/mediatek: Add vblank register/unregister callback functions Date: Mon, 11 Jul 2022 11:06:44 +0200 Message-Id: <20220711090608.259613541@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Rex-BC Chen [ Upstream commit b74d921b900b6ce38c6247c0a1c86be9f3746493 ] We encountered a kernel panic issue that callback data will be NULL when it's using in ovl irq handler. There is a timing issue between mtk_disp_ovl_irq_handler() and mtk_ovl_disable_vblank(). To resolve this issue, we use the flow to register/unregister vblank cb: - Register callback function and callback data when crtc creates. - Unregister callback function and callback data when crtc destroies. With this solution, we can assure callback data will not be NULL when vblank is disable. Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20220321072= 320.15019-1-rex-bc.chen@mediatek.com/ Fixes: 9b0704988b15 ("drm/mediatek: Register vblank callback function") Signed-off-by: Rex-BC Chen Reviewed-by: jason-jh.lin Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 16 +++++++----- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 22 ++++++++++++---- drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 20 +++++++++----- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 14 +++++++++- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 4 +++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 29 ++++++++++++++++----- 6 files changed, 80 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/medi= atek/mtk_disp_drv.h index 86c3068894b1..974462831133 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -76,9 +76,11 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int = idx, void mtk_ovl_start(struct device *dev); void mtk_ovl_stop(struct device *dev); unsigned int mtk_ovl_supported_rotations(struct device *dev); -void mtk_ovl_enable_vblank(struct device *dev, - void (*vblank_cb)(void *), - void *vblank_cb_data); +void mtk_ovl_register_vblank_cb(struct device *dev, + void (*vblank_cb)(void *), + void *vblank_cb_data); +void mtk_ovl_unregister_vblank_cb(struct device *dev); +void mtk_ovl_enable_vblank(struct device *dev); void mtk_ovl_disable_vblank(struct device *dev); =20 void mtk_rdma_bypass_shadow(struct device *dev); @@ -93,9 +95,11 @@ void mtk_rdma_layer_config(struct device *dev, unsigned = int idx, struct cmdq_pkt *cmdq_pkt); void mtk_rdma_start(struct device *dev); void mtk_rdma_stop(struct device *dev); -void mtk_rdma_enable_vblank(struct device *dev, - void (*vblank_cb)(void *), - void *vblank_cb_data); +void mtk_rdma_register_vblank_cb(struct device *dev, + void (*vblank_cb)(void *), + void *vblank_cb_data); +void mtk_rdma_unregister_vblank_cb(struct device *dev); +void mtk_rdma_enable_vblank(struct device *dev); void mtk_rdma_disable_vblank(struct device *dev); =20 #endif diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/medi= atek/mtk_disp_ovl.c index 5326989d5206..411cf0f21661 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -96,14 +96,28 @@ static irqreturn_t mtk_disp_ovl_irq_handler(int irq, vo= id *dev_id) return IRQ_HANDLED; } =20 -void mtk_ovl_enable_vblank(struct device *dev, - void (*vblank_cb)(void *), - void *vblank_cb_data) +void mtk_ovl_register_vblank_cb(struct device *dev, + void (*vblank_cb)(void *), + void *vblank_cb_data) { struct mtk_disp_ovl *ovl =3D dev_get_drvdata(dev); =20 ovl->vblank_cb =3D vblank_cb; ovl->vblank_cb_data =3D vblank_cb_data; +} + +void mtk_ovl_unregister_vblank_cb(struct device *dev) +{ + struct mtk_disp_ovl *ovl =3D dev_get_drvdata(dev); + + ovl->vblank_cb =3D NULL; + ovl->vblank_cb_data =3D NULL; +} + +void mtk_ovl_enable_vblank(struct device *dev) +{ + struct mtk_disp_ovl *ovl =3D dev_get_drvdata(dev); + writel(0x0, ovl->regs + DISP_REG_OVL_INTSTA); writel_relaxed(OVL_FME_CPL_INT, ovl->regs + DISP_REG_OVL_INTEN); } @@ -112,8 +126,6 @@ void mtk_ovl_disable_vblank(struct device *dev) { struct mtk_disp_ovl *ovl =3D dev_get_drvdata(dev); =20 - ovl->vblank_cb =3D NULL; - ovl->vblank_cb_data =3D NULL; writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_INTEN); } =20 diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/med= iatek/mtk_disp_rdma.c index 75d7f45579e2..a6a6cb5f75af 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c @@ -94,24 +94,32 @@ static void rdma_update_bits(struct device *dev, unsign= ed int reg, writel(tmp, rdma->regs + reg); } =20 -void mtk_rdma_enable_vblank(struct device *dev, - void (*vblank_cb)(void *), - void *vblank_cb_data) +void mtk_rdma_register_vblank_cb(struct device *dev, + void (*vblank_cb)(void *), + void *vblank_cb_data) { struct mtk_disp_rdma *rdma =3D dev_get_drvdata(dev); =20 rdma->vblank_cb =3D vblank_cb; rdma->vblank_cb_data =3D vblank_cb_data; - rdma_update_bits(dev, DISP_REG_RDMA_INT_ENABLE, RDMA_FRAME_END_INT, - RDMA_FRAME_END_INT); } =20 -void mtk_rdma_disable_vblank(struct device *dev) +void mtk_rdma_unregister_vblank_cb(struct device *dev) { struct mtk_disp_rdma *rdma =3D dev_get_drvdata(dev); =20 rdma->vblank_cb =3D NULL; rdma->vblank_cb_data =3D NULL; +} + +void mtk_rdma_enable_vblank(struct device *dev) +{ + rdma_update_bits(dev, DISP_REG_RDMA_INT_ENABLE, RDMA_FRAME_END_INT, + RDMA_FRAME_END_INT); +} + +void mtk_rdma_disable_vblank(struct device *dev) +{ rdma_update_bits(dev, DISP_REG_RDMA_INT_ENABLE, RDMA_FRAME_END_INT, 0); } =20 diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/medi= atek/mtk_drm_crtc.c index ffa54b416ca7..34bb6c713a90 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -152,11 +152,20 @@ static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt = *pkt) static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) { struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); + int i; =20 mtk_mutex_put(mtk_crtc->mutex); #if IS_REACHABLE(CONFIG_MTK_CMDQ) mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle); #endif + + for (i =3D 0; i < mtk_crtc->ddp_comp_nr; i++) { + struct mtk_ddp_comp *comp; + + comp =3D mtk_crtc->ddp_comp[i]; + mtk_ddp_comp_unregister_vblank_cb(comp); + } + drm_crtc_cleanup(crtc); } =20 @@ -570,7 +579,7 @@ static int mtk_drm_crtc_enable_vblank(struct drm_crtc *= crtc) struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); struct mtk_ddp_comp *comp =3D mtk_crtc->ddp_comp[0]; =20 - mtk_ddp_comp_enable_vblank(comp, mtk_crtc_ddp_irq, &mtk_crtc->base); + mtk_ddp_comp_enable_vblank(comp); =20 return 0; } @@ -870,6 +879,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, if (comp->funcs->ctm_set) has_ctm =3D true; } + + mtk_ddp_comp_register_vblank_cb(comp, mtk_crtc_ddp_irq, + &mtk_crtc->base); } =20 for (i =3D 0; i < mtk_crtc->ddp_comp_nr; i++) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/= mediatek/mtk_drm_ddp_comp.c index 99cbf44463e4..22d23668b484 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -276,6 +276,8 @@ static const struct mtk_ddp_comp_funcs ddp_ovl =3D { .config =3D mtk_ovl_config, .start =3D mtk_ovl_start, .stop =3D mtk_ovl_stop, + .register_vblank_cb =3D mtk_ovl_register_vblank_cb, + .unregister_vblank_cb =3D mtk_ovl_unregister_vblank_cb, .enable_vblank =3D mtk_ovl_enable_vblank, .disable_vblank =3D mtk_ovl_disable_vblank, .supported_rotations =3D mtk_ovl_supported_rotations, @@ -292,6 +294,8 @@ static const struct mtk_ddp_comp_funcs ddp_rdma =3D { .config =3D mtk_rdma_config, .start =3D mtk_rdma_start, .stop =3D mtk_rdma_stop, + .register_vblank_cb =3D mtk_rdma_register_vblank_cb, + .unregister_vblank_cb =3D mtk_rdma_unregister_vblank_cb, .enable_vblank =3D mtk_rdma_enable_vblank, .disable_vblank =3D mtk_rdma_disable_vblank, .layer_nr =3D mtk_rdma_layer_nr, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/= mediatek/mtk_drm_ddp_comp.h index bb914d976cf5..25cb50f2391f 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -47,9 +47,11 @@ struct mtk_ddp_comp_funcs { unsigned int bpc, struct cmdq_pkt *cmdq_pkt); void (*start)(struct device *dev); void (*stop)(struct device *dev); - void (*enable_vblank)(struct device *dev, - void (*vblank_cb)(void *), - void *vblank_cb_data); + void (*register_vblank_cb)(struct device *dev, + void (*vblank_cb)(void *), + void *vblank_cb_data); + void (*unregister_vblank_cb)(struct device *dev); + void (*enable_vblank)(struct device *dev); void (*disable_vblank)(struct device *dev); unsigned int (*supported_rotations)(struct device *dev); unsigned int (*layer_nr)(struct device *dev); @@ -110,12 +112,25 @@ static inline void mtk_ddp_comp_stop(struct mtk_ddp_c= omp *comp) comp->funcs->stop(comp->dev); } =20 -static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp, - void (*vblank_cb)(void *), - void *vblank_cb_data) +static inline void mtk_ddp_comp_register_vblank_cb(struct mtk_ddp_comp *co= mp, + void (*vblank_cb)(void *), + void *vblank_cb_data) +{ + if (comp->funcs && comp->funcs->register_vblank_cb) + comp->funcs->register_vblank_cb(comp->dev, vblank_cb, + vblank_cb_data); +} + +static inline void mtk_ddp_comp_unregister_vblank_cb(struct mtk_ddp_comp *= comp) +{ + if (comp->funcs && comp->funcs->unregister_vblank_cb) + comp->funcs->unregister_vblank_cb(comp->dev); +} + +static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp) { if (comp->funcs && comp->funcs->enable_vblank) - comp->funcs->enable_vblank(comp->dev, vblank_cb, vblank_cb_data); + comp->funcs->enable_vblank(comp->dev); } =20 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp) --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 D69BACCA47B for ; Mon, 11 Jul 2022 09:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbiGKJzM (ORCPT ); Mon, 11 Jul 2022 05:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234225AbiGKJy3 (ORCPT ); Mon, 11 Jul 2022 05:54:29 -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 818F9B0269; Mon, 11 Jul 2022 02:26:00 -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 C7A42B80E84; Mon, 11 Jul 2022 09:25:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 179C8C34115; Mon, 11 Jul 2022 09:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531557; bh=cklb2sVuuc/uXDDNwPufVaIA5HGokBkhDzSFJjd6AJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyZ4Ixu2yoKE8c3LtIKYLA7YglwAOgc/QS8ywGJy8J/dPQaYWVaSb9kJE716qT9J5 ALK19IxynYZPnf4WyxeWukLlQue8olCpTGf6KBHgKejQh7P9BKWduoHkvZX6tgLbv1 NEQTIc2C7vHRqk2GGYKRKx5h/VNjdP5inSLab5iA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.15 149/230] Bluetooth: protect le accept and resolv lists with hdev->lock Date: Mon, 11 Jul 2022 11:06:45 +0200 Message-Id: <20220711090608.287671349@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Niels Dossche [ Upstream commit 5e2b6064cbc5fd582396768c5f9583f65085e368 ] Concurrent operations from events on le_{accept,resolv}_list are currently unprotected by hdev->lock. Most existing code do already protect the lists with that lock. This can be observed in hci_debugfs and hci_sync. Add the protection for these events too. Fixes: b950aa88638c ("Bluetooth: Add definitions and track LE resolve list = modification") Fixes: 0f36b589e4ee ("Bluetooth: Track LE white list modification via HCI c= ommands") Signed-off-by: Niels Dossche Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/bluetooth/hci_event.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5ac3aca6deeb..2337e9275863 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1559,7 +1559,9 @@ static void hci_cc_le_clear_accept_list(struct hci_de= v *hdev, if (status) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_clear(&hdev->le_accept_list); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_add_to_accept_list(struct hci_dev *hdev, @@ -1577,8 +1579,10 @@ static void hci_cc_le_add_to_accept_list(struct hci_= dev *hdev, if (!sent) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_del_from_accept_list(struct hci_dev *hdev, @@ -1596,8 +1600,10 @@ static void hci_cc_le_del_from_accept_list(struct hc= i_dev *hdev, if (!sent) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_read_supported_states(struct hci_dev *hdev, @@ -1661,9 +1667,11 @@ static void hci_cc_le_add_to_resolv_list(struct hci_= dev *hdev, if (!sent) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type, sent->peer_irk, sent->local_irk); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, @@ -1681,8 +1689,10 @@ static void hci_cc_le_del_from_resolv_list(struct hc= i_dev *hdev, if (!sent) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_clear_resolv_list(struct hci_dev *hdev, @@ -1695,7 +1705,9 @@ static void hci_cc_le_clear_resolv_list(struct hci_de= v *hdev, if (status) return; =20 + hci_dev_lock(hdev); hci_bdaddr_list_clear(&hdev->le_resolv_list); + hci_dev_unlock(hdev); } =20 static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 95770C433EF for ; Mon, 11 Jul 2022 09:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234086AbiGKJz2 (ORCPT ); Mon, 11 Jul 2022 05:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233499AbiGKJye (ORCPT ); Mon, 11 Jul 2022 05:54:34 -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 AA1D137F80; Mon, 11 Jul 2022 02:26: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 9D0FE61372; Mon, 11 Jul 2022 09:26:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABFC6C34115; Mon, 11 Jul 2022 09:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531563; bh=FhHAONEXImklSYVmbBubQLpn3WHQX79deib2O31UJn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjiOPkPg04hIsCh0rzajmLo8z8/ehrHIRkCE7lYCVxYXv5neNntPbafmqZ+T+CcxV a7y45xS1NcrzCZUmIJb56phrh0A8N7AWCv1mWQQoOc9kKI2UNIHeiiN4sVv6lgX/zx jEK48rqYAzsSQJk578WctVC9T+ukvpmmBaDyRADM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yake Yang , Sean Wang , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.15 150/230] Bluetooth: btmtksdio: fix use-after-free at btmtksdio_recv_event Date: Mon, 11 Jul 2022 11:06:46 +0200 Message-Id: <20220711090608.316052083@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sean Wang [ Upstream commit 0fab6361c4ba17d1b43a991bef4238a3c1754d35 ] We should not access skb buffer data anymore after hci_recv_frame was called. [ 39.634809] BUG: KASAN: use-after-free in btmtksdio_recv_event+0x1b0 [ 39.634855] Read of size 1 at addr ffffff80cf28a60d by task kworker [ 39.634962] Call trace: [ 39.634974] dump_backtrace+0x0/0x3b8 [ 39.634999] show_stack+0x20/0x2c [ 39.635016] dump_stack_lvl+0x60/0x78 [ 39.635040] print_address_description+0x70/0x2f0 [ 39.635062] kasan_report+0x154/0x194 [ 39.635079] __asan_report_load1_noabort+0x44/0x50 [ 39.635099] btmtksdio_recv_event+0x1b0/0x1c4 [ 39.635129] btmtksdio_txrx_work+0x6cc/0xac4 [ 39.635157] process_one_work+0x560/0xc5c [ 39.635177] worker_thread+0x7ec/0xcc0 [ 39.635195] kthread+0x2d0/0x3d0 [ 39.635215] ret_from_fork+0x10/0x20 [ 39.635247] Allocated by task 0: [ 39.635260] (stack is not available) [ 39.635281] Freed by task 2392: [ 39.635295] kasan_save_stack+0x38/0x68 [ 39.635319] kasan_set_track+0x28/0x3c [ 39.635338] kasan_set_free_info+0x28/0x4c [ 39.635357] ____kasan_slab_free+0x104/0x150 [ 39.635374] __kasan_slab_free+0x18/0x28 [ 39.635391] slab_free_freelist_hook+0x114/0x248 [ 39.635410] kfree+0xf8/0x2b4 [ 39.635427] skb_free_head+0x58/0x98 [ 39.635447] skb_release_data+0x2f4/0x410 [ 39.635464] skb_release_all+0x50/0x60 [ 39.635481] kfree_skb+0xc8/0x25c [ 39.635498] hci_event_packet+0x894/0xca4 [bluetooth] [ 39.635721] hci_rx_work+0x1c8/0x68c [bluetooth] [ 39.635925] process_one_work+0x560/0xc5c [ 39.635951] worker_thread+0x7ec/0xcc0 [ 39.635970] kthread+0x2d0/0x3d0 [ 39.635990] ret_from_fork+0x10/0x20 [ 39.636021] The buggy address belongs to the object at ffffff80cf28a600 which belongs to the cache kmalloc-512 of size 512 [ 39.636039] The buggy address is located 13 bytes inside of 512-byte region [ffffff80cf28a600, ffffff80cf28a800) Fixes: 9aebfd4a2200 ("Bluetooth: mediatek: add support for MediaTek MT7663S= and MT7668S SDIO devices") Co-developed-by: Yake Yang Signed-off-by: Yake Yang Signed-off-by: Sean Wang Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/bluetooth/btmtksdio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index ff1f5dfbb6db..d66e4df171d2 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -331,6 +331,7 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, s= truct sk_buff *skb) { struct btmtksdio_dev *bdev =3D hci_get_drvdata(hdev); struct hci_event_hdr *hdr =3D (void *)skb->data; + u8 evt =3D hdr->evt; int err; =20 /* Fix up the vendor event id with 0xff for vendor specific instead @@ -355,7 +356,7 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, s= truct sk_buff *skb) if (err < 0) goto err_free_skb; =20 - if (hdr->evt =3D=3D HCI_EV_VENDOR) { + if (evt =3D=3D HCI_EV_VENDOR) { if (test_and_clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state)) { /* Barrier to sync with other CPUs */ --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 215B9C43334 for ; Mon, 11 Jul 2022 09:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234095AbiGKJzh (ORCPT ); Mon, 11 Jul 2022 05:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233725AbiGKJyr (ORCPT ); Mon, 11 Jul 2022 05:54:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7387337F98; Mon, 11 Jul 2022 02:26: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 dfw.source.kernel.org (Postfix) with ESMTPS id 6944461366; Mon, 11 Jul 2022 09:26:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7646EC34115; Mon, 11 Jul 2022 09:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531565; bh=CN63vJ3BRAvBG+MdV3XQIgUNjYaxqwnfOtQObgAkbis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zFgZPSVxnX6OoyJQIlDlkLR6FAbGDUKGRQOLbTQSdx4IYdOtdGa8O3lxKLbVXbdDG iWimSKBKUJWUEIdv1Kg2WnRq/i5n3FzxnNKA0/qdRV7eSe38QZDlDdzeiv9dRqlcoZ En4v7fhkdCoBYV7bQSjCusG3h4o8Yg7YVjMQe78M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 151/230] io_uring: avoid io-wq -EAGAIN looping for !IOPOLL Date: Mon, 11 Jul 2022 11:06:47 +0200 Message-Id: <20220711090608.343538274@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pavel Begunkov [ Upstream commit e0deb6a025ae8c850dc8685be39fb27b06c88736 ] If an opcode handler semi-reliably returns -EAGAIN, io_wq_submit_work() might continue busily hammer the same handler over and over again, which is not ideal. The -EAGAIN handling in question was put there only for IOPOLL, so restrict it to IOPOLL mode only where there is no other recourse than to retry as we cannot wait. Fixes: def596e9557c9 ("io_uring: support for IO polling") Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/f168b4f24181942f3614dd8ff648221736f572e6.16= 52433740.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 0c5dcda0b622..9bff14c5e2b2 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6866,7 +6866,7 @@ static void io_wq_submit_work(struct io_wq_work *work) * forcing a sync submission from here, since we can't * wait for request slots on the block side. */ - if (ret !=3D -EAGAIN) + if (ret !=3D -EAGAIN || !(req->ctx->flags & IORING_SETUP_IOPOLL)) break; cond_resched(); } while (1); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 D4ADBC433EF for ; Mon, 11 Jul 2022 09:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbiGKJzp (ORCPT ); Mon, 11 Jul 2022 05:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234036AbiGKJy6 (ORCPT ); Mon, 11 Jul 2022 05:54:58 -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 6F25537FAB; Mon, 11 Jul 2022 02:26: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3913E61363; Mon, 11 Jul 2022 09:26:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4758CC341C8; Mon, 11 Jul 2022 09:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531568; bh=0ZU9bBInoWO4Pr+JFp/0wb2t3sXUPYu60GbCWbRRfjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qboiURjxQnxnG82HHCyQmn6+4VxD03iFkbrnKG0dlLKCUZwxYkM0W8+skQO4wH66j uWr8g/+4/fzetSQ/DzEmJR+b93f0U0iTY2jWzENwKNtdquxVntOzIrJcuRNaXpIEaO oCbi/PTuygzN3UFhddupqOq4Wfvzsht8pxkhqmuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Marc Zyngier , Thomas Gleixner , Will Deacon , Sasha Levin Subject: [PATCH 5.15 152/230] irqchip/gic-v3: Ensure pseudo-NMIs have an ISB between ack and handling Date: Mon, 11 Jul 2022 11:06:48 +0200 Message-Id: <20220711090608.371572311@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Mark Rutland [ Upstream commit adf14453d2c037ab529040c1186ea32e277e783a ] There are cases where a context synchronization event is necessary between an IRQ being raised and being handled, and there are races such that we cannot rely upon the exception entry being subsequent to the interrupt being raised. We identified and fixes this for regular IRQs in commit: 39a06b67c2c1256b ("irqchip/gic: Ensure we have an ISB between ack and ->h= andle_irq") Unfortunately, we forgot to do the same for psuedo-NMIs when support for those was added in commit: f32c926651dcd168 ("irqchip/gic-v3: Handle pseudo-NMIs") Which means that when pseudo-NMIs are used for PMU support, we'll hit the same problem. Apply the same fix as for regular IRQs. Note that when EOI mode 1 is in use, the call to gic_write_eoir() will provide an ISB. Fixes: f32c926651dcd168 ("irqchip/gic-v3: Handle pseudo-NMIs") Signed-off-by: Mark Rutland Cc: Marc Zyngier Cc: Thomas Gleixner Cc: Will Deacon Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220513133038.226182-2-mark.rutland@arm.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/irqchip/irq-gic-v3.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index fd4fb1b35787..d8ea330454f4 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -654,6 +654,9 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_= regs *regs) =20 if (static_branch_likely(&supports_deactivate_key)) gic_write_eoir(irqnr); + else + isb() + /* * Leave the PSR.I bit set to prevent other NMIs to be * received while handling this one. --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 07092C43334 for ; Mon, 11 Jul 2022 09:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232583AbiGKJzz (ORCPT ); Mon, 11 Jul 2022 05:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234069AbiGKJzI (ORCPT ); Mon, 11 Jul 2022 05:55:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AFDB1945; Mon, 11 Jul 2022 02:26: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 dfw.source.kernel.org (Postfix) with ESMTPS id E39046112E; Mon, 11 Jul 2022 09:26:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF017C34115; Mon, 11 Jul 2022 09:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531571; bh=s9qJw2urS+Yhp6Cits5M/AupqYxACgwsDJBxw1SWSS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YuyIYcHHDTzuRfe9kBhXit5pxs1VB1KbVdiRzuGFSrof5B5DcFsF0VHCAiPfluRiM wx+vBWxKflmBGcIB7J7ryzxsDgpBIrKsrHdcz040e24CkbNAk9IwXOG43fbOkBtABJ +D0I+t1bRbkued9Kqlgi8xzUWnY+hoZb/uTrtH8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Marc Dionne , linux-afs@lists.infradead.org, "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 153/230] rxrpc: Fix locking issue Date: Mon, 11 Jul 2022 11:06:49 +0200 Message-Id: <20220711090608.399787157@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: David Howells [ Upstream commit ad25f5cb39872ca14bcbe00816ae65c22fe04b89 ] There's a locking issue with the per-netns list of calls in rxrpc. The pieces of code that add and remove a call from the list use write_lock() and the calls procfile uses read_lock() to access it. However, the timer callback function may trigger a removal by trying to queue a call for processing and finding that it's already queued - at which point it has a spare refcount that it has to do something with. Unfortunately, if it puts the call and this reduces the refcount to 0, the call will be removed from the list. Unfortunately, since the _bh variants of the locking functions aren't used, this can deadlock. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D WARNING: inconsistent lock state 5.18.0-rc3-build4+ #10 Not tainted Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya -------------------------------- inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. ksoftirqd/2/25 [HC0[0]:SC1[1]:HE1:SE0] takes: ffff888107ac4038 (&rxnet->call_lock){+.?.}-{2:2}, at: rxrpc_put_call+0x103/= 0x14b {SOFTIRQ-ON-W} state was registered at: ... Possible unsafe locking scenario: CPU0 ---- lock(&rxnet->call_lock); lock(&rxnet->call_lock); *** DEADLOCK *** 1 lock held by ksoftirqd/2/25: #0: ffff8881008ffdb0 ((&call->timer)){+.-.}-{0:0}, at: call_timer_fn+0x5/0= x23d Changes =3D=3D=3D=3D=3D=3D=3D ver #2) - Changed to using list_next_rcu() rather than rcu_dereference() directly. Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by u= serspace and kernel both") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- fs/seq_file.c | 32 ++++++++++++++++++++++++++++++++ include/linux/list.h | 10 ++++++++++ include/linux/seq_file.h | 4 ++++ net/rxrpc/ar-internal.h | 2 +- net/rxrpc/call_accept.c | 6 +++--- net/rxrpc/call_object.c | 18 +++++++++--------- net/rxrpc/net_ns.c | 2 +- net/rxrpc/proc.c | 10 ++-------- 8 files changed, 62 insertions(+), 22 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index 4a2cda04d3e2..b17ee4c4f618 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -947,6 +947,38 @@ struct list_head *seq_list_next(void *v, struct list_h= ead *head, loff_t *ppos) } EXPORT_SYMBOL(seq_list_next); =20 +struct list_head *seq_list_start_rcu(struct list_head *head, loff_t pos) +{ + struct list_head *lh; + + list_for_each_rcu(lh, head) + if (pos-- =3D=3D 0) + return lh; + + return NULL; +} +EXPORT_SYMBOL(seq_list_start_rcu); + +struct list_head *seq_list_start_head_rcu(struct list_head *head, loff_t p= os) +{ + if (!pos) + return head; + + return seq_list_start_rcu(head, pos - 1); +} +EXPORT_SYMBOL(seq_list_start_head_rcu); + +struct list_head *seq_list_next_rcu(void *v, struct list_head *head, + loff_t *ppos) +{ + struct list_head *lh; + + lh =3D list_next_rcu((struct list_head *)v); + ++*ppos; + return lh =3D=3D head ? NULL : lh; +} +EXPORT_SYMBOL(seq_list_next_rcu); + /** * seq_hlist_start - start an iteration of a hlist * @head: the head of the hlist diff --git a/include/linux/list.h b/include/linux/list.h index a119dd1990d4..d206ae93c06d 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -577,6 +577,16 @@ static inline void list_splice_tail_init(struct list_h= ead *list, #define list_for_each(pos, head) \ for (pos =3D (head)->next; !list_is_head(pos, (head)); pos =3D pos->next) =20 +/** + * list_for_each_rcu - Iterate over a list in an RCU-safe fashion + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each_rcu(pos, head) \ + for (pos =3D rcu_dereference((head)->next); \ + !list_is_head(pos, (head)); \ + pos =3D rcu_dereference(pos->next)) + /** * list_for_each_continue - continue iteration over a list * @pos: the &struct list_head to use as a loop cursor. diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 5733890df64f..0b429111f85e 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -261,6 +261,10 @@ extern struct list_head *seq_list_start_head(struct li= st_head *head, extern struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos); =20 +extern struct list_head *seq_list_start_rcu(struct list_head *head, loff_t= pos); +extern struct list_head *seq_list_start_head_rcu(struct list_head *head, l= off_t pos); +extern struct list_head *seq_list_next_rcu(void *v, struct list_head *head= , loff_t *ppos); + /* * Helpers for iteration over hlist_head-s in seq_files */ diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index dce056adb78c..f2d593e27b64 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -68,7 +68,7 @@ struct rxrpc_net { struct proc_dir_entry *proc_net; /* Subdir in /proc/net */ u32 epoch; /* Local epoch for detecting local-end reset */ struct list_head calls; /* List of calls active in this namespace */ - rwlock_t call_lock; /* Lock for ->calls */ + spinlock_t call_lock; /* Lock for ->calls */ atomic_t nr_calls; /* Count of allocated calls */ =20 atomic_t nr_conns; diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c index 1ae90fb97936..8b24ffbc72ef 100644 --- a/net/rxrpc/call_accept.c +++ b/net/rxrpc/call_accept.c @@ -140,9 +140,9 @@ static int rxrpc_service_prealloc_one(struct rxrpc_sock= *rx, write_unlock(&rx->call_lock); =20 rxnet =3D call->rxnet; - write_lock(&rxnet->call_lock); - list_add_tail(&call->link, &rxnet->calls); - write_unlock(&rxnet->call_lock); + spin_lock_bh(&rxnet->call_lock); + list_add_tail_rcu(&call->link, &rxnet->calls); + spin_unlock_bh(&rxnet->call_lock); =20 b->call_backlog[call_head] =3D call; smp_store_release(&b->call_backlog_head, (call_head + 1) & (size - 1)); diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c index 043508fd8d8a..25c9a2cbf048 100644 --- a/net/rxrpc/call_object.c +++ b/net/rxrpc/call_object.c @@ -337,9 +337,9 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_s= ock *rx, write_unlock(&rx->call_lock); =20 rxnet =3D call->rxnet; - write_lock(&rxnet->call_lock); - list_add_tail(&call->link, &rxnet->calls); - write_unlock(&rxnet->call_lock); + spin_lock_bh(&rxnet->call_lock); + list_add_tail_rcu(&call->link, &rxnet->calls); + spin_unlock_bh(&rxnet->call_lock); =20 /* From this point on, the call is protected by its own lock. */ release_sock(&rx->sk); @@ -631,9 +631,9 @@ void rxrpc_put_call(struct rxrpc_call *call, enum rxrpc= _call_trace op) ASSERTCMP(call->state, =3D=3D, RXRPC_CALL_COMPLETE); =20 if (!list_empty(&call->link)) { - write_lock(&rxnet->call_lock); + spin_lock_bh(&rxnet->call_lock); list_del_init(&call->link); - write_unlock(&rxnet->call_lock); + spin_unlock_bh(&rxnet->call_lock); } =20 rxrpc_cleanup_call(call); @@ -705,7 +705,7 @@ void rxrpc_destroy_all_calls(struct rxrpc_net *rxnet) _enter(""); =20 if (!list_empty(&rxnet->calls)) { - write_lock(&rxnet->call_lock); + spin_lock_bh(&rxnet->call_lock); =20 while (!list_empty(&rxnet->calls)) { call =3D list_entry(rxnet->calls.next, @@ -720,12 +720,12 @@ void rxrpc_destroy_all_calls(struct rxrpc_net *rxnet) rxrpc_call_states[call->state], call->flags, call->events); =20 - write_unlock(&rxnet->call_lock); + spin_unlock_bh(&rxnet->call_lock); cond_resched(); - write_lock(&rxnet->call_lock); + spin_lock_bh(&rxnet->call_lock); } =20 - write_unlock(&rxnet->call_lock); + spin_unlock_bh(&rxnet->call_lock); } =20 atomic_dec(&rxnet->nr_calls); diff --git a/net/rxrpc/net_ns.c b/net/rxrpc/net_ns.c index cc7e30733feb..e4d6d432515b 100644 --- a/net/rxrpc/net_ns.c +++ b/net/rxrpc/net_ns.c @@ -50,7 +50,7 @@ static __net_init int rxrpc_init_net(struct net *net) rxnet->epoch |=3D RXRPC_RANDOM_EPOCH; =20 INIT_LIST_HEAD(&rxnet->calls); - rwlock_init(&rxnet->call_lock); + spin_lock_init(&rxnet->call_lock); atomic_set(&rxnet->nr_calls, 1); =20 atomic_set(&rxnet->nr_conns, 1); diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c index e2f990754f88..5a67955cc00f 100644 --- a/net/rxrpc/proc.c +++ b/net/rxrpc/proc.c @@ -26,29 +26,23 @@ static const char *const rxrpc_conn_states[RXRPC_CONN__= NR_STATES] =3D { */ static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos) __acquires(rcu) - __acquires(rxnet->call_lock) { struct rxrpc_net *rxnet =3D rxrpc_net(seq_file_net(seq)); =20 rcu_read_lock(); - read_lock(&rxnet->call_lock); - return seq_list_start_head(&rxnet->calls, *_pos); + return seq_list_start_head_rcu(&rxnet->calls, *_pos); } =20 static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *po= s) { struct rxrpc_net *rxnet =3D rxrpc_net(seq_file_net(seq)); =20 - return seq_list_next(v, &rxnet->calls, pos); + return seq_list_next_rcu(v, &rxnet->calls, pos); } =20 static void rxrpc_call_seq_stop(struct seq_file *seq, void *v) - __releases(rxnet->call_lock) __releases(rcu) { - struct rxrpc_net *rxnet =3D rxrpc_net(seq_file_net(seq)); - - read_unlock(&rxnet->call_lock); rcu_read_unlock(); } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 47F2BC43334 for ; Mon, 11 Jul 2022 09:56:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234098AbiGKJ4M (ORCPT ); Mon, 11 Jul 2022 05:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbiGKJza (ORCPT ); Mon, 11 Jul 2022 05:55:30 -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 39FB833A27; Mon, 11 Jul 2022 02:26: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 sin.source.kernel.org (Postfix) with ESMTPS id AFA62CE1268; Mon, 11 Jul 2022 09:26:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A330EC34115; Mon, 11 Jul 2022 09:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531574; bh=zwrZQNaTn0ZHycoDdEB+Kr7r7722XnecbnkQ7TC4xjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=shat7RjuUYsb9M+wyDKV25WkBmzxtJt06iTEqKIOccky24QH+4PhJF8xJsPLEosF1 7QoBOpONcJPgJLT5TVwjYPycti/J6s3/4OTtiB7ORJtk0fyijaQF0mtbq1ZXUv2PCV 6mZ8KuAKFEAfGtOvZ6crHbwmTrXn+B1GgNOQWaOc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Lypak , Adam Skladowski , Sireesh Kodali , Rob Herring , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 154/230] dt-bindings: soc: qcom: smd-rpm: Add compatible for MSM8953 SoC Date: Mon, 11 Jul 2022 11:06:50 +0200 Message-Id: <20220711090608.429338303@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Lypak [ Upstream commit 96c42812f798c5e48d55cd6fc2101ce99af19608 ] Document compatible for MSM8953 SoC. Signed-off-by: Vladimir Lypak Signed-off-by: Adam Skladowski Signed-off-by: Sireesh Kodali Acked-by: Rob Herring Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20210825165943.19415-1-sireeshkodali1@gmail= .com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml b= /Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml index cc3fe5ed7421..77963b86b714 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml @@ -34,6 +34,7 @@ properties: - qcom,rpm-ipq6018 - qcom,rpm-msm8226 - qcom,rpm-msm8916 + - qcom,rpm-msm8953 - qcom,rpm-msm8974 - qcom,rpm-msm8976 - qcom,rpm-msm8996 @@ -57,6 +58,7 @@ if: - qcom,rpm-apq8084 - qcom,rpm-msm8916 - qcom,rpm-msm8974 + - qcom,rpm-msm8953 then: required: - qcom,smd-channels --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 0ED87C43334 for ; Mon, 11 Jul 2022 09:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234122AbiGKJ4F (ORCPT ); Mon, 11 Jul 2022 05:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbiGKJza (ORCPT ); Mon, 11 Jul 2022 05:55:30 -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 2438C37F8D; Mon, 11 Jul 2022 02:26: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 ams.source.kernel.org (Postfix) with ESMTPS id 03BC3B80D2C; Mon, 11 Jul 2022 09:26:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55BFCC341C0; Mon, 11 Jul 2022 09:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531576; bh=iavFSzIg6J15DD6EpN1kRCljEYmVOhPE1G5qPmcCNms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwREpGyifiokTqzuBKuc89quLBBdo/IfmlMtZDJ6wOPiNCUkw7PY5AX7tSKkg1GGj 6d6SCxnOltuiM8YH2LO0XkdlCF6Y9RIb9v7Mh8p4QINlu85CMUgAzHak9VJvIB6NRD ZCIOT41NcEfOevNrctc/lORMzGwZpLU1J7c9xGe4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bryan ODonoghue , Krzysztof Kozlowski , Rob Herring , Sasha Levin Subject: [PATCH 5.15 155/230] dt-bindings: soc: qcom: smd-rpm: Fix missing MSM8936 compatible Date: Mon, 11 Jul 2022 11:06:51 +0200 Message-Id: <20220711090608.458292462@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Bryan O'Donoghue [ Upstream commit e930244918092d44b60a7b538cf60d737010ceef ] Add compatible msm8936. msm8936 covers both msm8936 and msm8939. The relevant driver already has the compat string but, we haven't documented it. Fixes: d6e52482f5ab ("drivers: soc: Add MSM8936 SMD RPM compatible") Signed-off-by: Bryan O'Donoghue Acked-by: Krzysztof Kozlowski Signed-off-by: Rob Herring Link: https://lore.kernel.org/r/20220418231857.3061053-1-bryan.odonoghue@li= naro.org Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml b= /Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml index 77963b86b714..1b0062e3c1a4 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml @@ -34,6 +34,7 @@ properties: - qcom,rpm-ipq6018 - qcom,rpm-msm8226 - qcom,rpm-msm8916 + - qcom,rpm-msm8936 - qcom,rpm-msm8953 - qcom,rpm-msm8974 - qcom,rpm-msm8976 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 0B326C433EF for ; Mon, 11 Jul 2022 09:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233499AbiGKJz7 (ORCPT ); Mon, 11 Jul 2022 05:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233668AbiGKJzS (ORCPT ); Mon, 11 Jul 2022 05:55: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 AC8AC33341; Mon, 11 Jul 2022 02:26: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 0506C61376; Mon, 11 Jul 2022 09:26:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BC29C34115; Mon, 11 Jul 2022 09:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531579; bh=w7ayt6OeqqIe/QS+tSiV48KClRgPaOXmOyVXYHm6Q08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EF1tLtFB9O1+ezCuxJOFcK9ZVJNaYK5qURPFeWWD3PGXsKzJH6ftSdIwkzY9volwi SScOqzepS8Q1NhilkxaRZDva2y2SHbPWA5B4qg3ri/wdk+W8TF07UL4xjAFgTS48Kw Wwfb1aAUwaO9BHOkdldueRmmYZ2l2rkqU9tIAdw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Shuah Khan , Luis Chamberlain , Sasha Levin Subject: [PATCH 5.15 156/230] module: change to print useful messages from elf_validity_check() Date: Mon, 11 Jul 2022 11:06:52 +0200 Message-Id: <20220711090608.486184291@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Shuah Khan [ Upstream commit 7fd982f394c42f25a73fe9dfbf1e6b11fa26b40a ] elf_validity_check() checks ELF headers for errors and ELF Spec. compliance and if any of them fail it returns -ENOEXEC from all of these error paths. Almost all of them don't print any messages. When elf_validity_check() returns an error, load_module() prints an error message without error code. It is hard to determine why the module ELF structure is invalid, even if load_module() prints the error code which is -ENOEXEC in all of these cases. Change to print useful error messages from elf_validity_check() to clearly say what went wrong and why the ELF validity checks failed. Remove the load_module() error message which is no longer needed. This patch includes changes to fix build warns on 32-bit platforms: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'} Reported-by: kernel test robot Signed-off-by: Shuah Khan Signed-off-by: Luis Chamberlain Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- kernel/module.c | 75 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 83991c2d5af9..256b3c80a771 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2967,14 +2967,29 @@ static int elf_validity_check(struct load_info *inf= o) Elf_Shdr *shdr, *strhdr; int err; =20 - if (info->len < sizeof(*(info->hdr))) - return -ENOEXEC; + if (info->len < sizeof(*(info->hdr))) { + pr_err("Invalid ELF header len %lu\n", info->len); + goto no_exec; + } =20 - if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) !=3D 0 - || info->hdr->e_type !=3D ET_REL - || !elf_check_arch(info->hdr) - || info->hdr->e_shentsize !=3D sizeof(Elf_Shdr)) - return -ENOEXEC; + if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) !=3D 0) { + pr_err("Invalid ELF header magic: !=3D %s\n", ELFMAG); + goto no_exec; + } + if (info->hdr->e_type !=3D ET_REL) { + pr_err("Invalid ELF header type: %u !=3D %u\n", + info->hdr->e_type, ET_REL); + goto no_exec; + } + if (!elf_check_arch(info->hdr)) { + pr_err("Invalid architecture in ELF header: %u\n", + info->hdr->e_machine); + goto no_exec; + } + if (info->hdr->e_shentsize !=3D sizeof(Elf_Shdr)) { + pr_err("Invalid ELF section header size\n"); + goto no_exec; + } =20 /* * e_shnum is 16 bits, and sizeof(Elf_Shdr) is @@ -2983,8 +2998,10 @@ static int elf_validity_check(struct load_info *info) */ if (info->hdr->e_shoff >=3D info->len || (info->hdr->e_shnum * sizeof(Elf_Shdr) > - info->len - info->hdr->e_shoff)) - return -ENOEXEC; + info->len - info->hdr->e_shoff)) { + pr_err("Invalid ELF section header overflow\n"); + goto no_exec; + } =20 info->sechdrs =3D (void *)info->hdr + info->hdr->e_shoff; =20 @@ -2992,13 +3009,19 @@ static int elf_validity_check(struct load_info *inf= o) * Verify if the section name table index is valid. */ if (info->hdr->e_shstrndx =3D=3D SHN_UNDEF - || info->hdr->e_shstrndx >=3D info->hdr->e_shnum) - return -ENOEXEC; + || info->hdr->e_shstrndx >=3D info->hdr->e_shnum) { + pr_err("Invalid ELF section name index: %d || e_shstrndx (%d) >=3D e_shn= um (%d)\n", + info->hdr->e_shstrndx, info->hdr->e_shstrndx, + info->hdr->e_shnum); + goto no_exec; + } =20 strhdr =3D &info->sechdrs[info->hdr->e_shstrndx]; err =3D validate_section_offset(info, strhdr); - if (err < 0) + if (err < 0) { + pr_err("Invalid ELF section hdr(type %u)\n", strhdr->sh_type); return err; + } =20 /* * The section name table must be NUL-terminated, as required @@ -3006,8 +3029,10 @@ static int elf_validity_check(struct load_info *info) * strings in the section safe. */ info->secstrings =3D (void *)info->hdr + strhdr->sh_offset; - if (info->secstrings[strhdr->sh_size - 1] !=3D '\0') - return -ENOEXEC; + if (info->secstrings[strhdr->sh_size - 1] !=3D '\0') { + pr_err("ELF Spec violation: section name table isn't null terminated\n"); + goto no_exec; + } =20 /* * The code assumes that section 0 has a length of zero and @@ -3015,8 +3040,11 @@ static int elf_validity_check(struct load_info *info) */ if (info->sechdrs[0].sh_type !=3D SHT_NULL || info->sechdrs[0].sh_size !=3D 0 - || info->sechdrs[0].sh_addr !=3D 0) - return -ENOEXEC; + || info->sechdrs[0].sh_addr !=3D 0) { + pr_err("ELF Spec violation: section 0 type(%d)!=3DSH_NULL or non-zero le= n or addr\n", + info->sechdrs[0].sh_type); + goto no_exec; + } =20 for (i =3D 1; i < info->hdr->e_shnum; i++) { shdr =3D &info->sechdrs[i]; @@ -3026,8 +3054,12 @@ static int elf_validity_check(struct load_info *info) continue; case SHT_SYMTAB: if (shdr->sh_link =3D=3D SHN_UNDEF - || shdr->sh_link >=3D info->hdr->e_shnum) - return -ENOEXEC; + || shdr->sh_link >=3D info->hdr->e_shnum) { + pr_err("Invalid ELF sh_link!=3DSHN_UNDEF(%d) or (sh_link(%d) >=3D hdr-= >e_shnum(%d)\n", + shdr->sh_link, shdr->sh_link, + info->hdr->e_shnum); + goto no_exec; + } fallthrough; default: err =3D validate_section_offset(info, shdr); @@ -3049,6 +3081,9 @@ static int elf_validity_check(struct load_info *info) } =20 return 0; + +no_exec: + return -ENOEXEC; } =20 #define COPY_CHUNK_SIZE (16*PAGE_SIZE) @@ -3925,10 +3960,8 @@ static int load_module(struct load_info *info, const= char __user *uargs, * sections. */ err =3D elf_validity_check(info); - if (err) { - pr_err("Module has invalid ELF structures\n"); + if (err) goto free_copy; - } =20 /* * Everything checks out, so set up the section info --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 C1249C433EF for ; Mon, 11 Jul 2022 09:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234139AbiGKJ4N (ORCPT ); Mon, 11 Jul 2022 05:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234024AbiGKJzj (ORCPT ); Mon, 11 Jul 2022 05:55: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 9F236B196F; Mon, 11 Jul 2022 02:26: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9EAF361366; Mon, 11 Jul 2022 09:26:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1233C34115; Mon, 11 Jul 2022 09:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531582; bh=jnOphOWqpgoZV4dWNukkzUVmQEoSgCbpw4TlAg2/yL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXQEODg9HeXN3v+3RAmA+MFIt1hw1C7E3vud1LJW66htzynH6ZmY/pWWqoedOOYVY KFBpuxMlUqigaP+/Xzv0KbgUyJmfuBHzofQ/eMyWAAc+cp6M1NuGjy6uPv8fOItz8q FJILZKirxYatbUHxqSlrl4cQj83R+2hJ7LuEDFZg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Dobriyan , Luis Chamberlain , Sasha Levin Subject: [PATCH 5.15 157/230] module: fix [e_shstrndx].sh_size=0 OOB access Date: Mon, 11 Jul 2022 11:06:53 +0200 Message-Id: <20220711090608.514645585@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Alexey Dobriyan [ Upstream commit 391e982bfa632b8315235d8be9c0a81374c6a19c ] It is trivial to craft a module to trigger OOB access in this line: if (info->secstrings[strhdr->sh_size - 1] !=3D '\0') { BUG: unable to handle page fault for address: ffffc90000aa0fff PGD 100000067 P4D 100000067 PUD 100066067 PMD 10436f067 PTE 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 7 PID: 1215 Comm: insmod Not tainted 5.18.0-rc5-00007-g9bf578647087-di= rty #10 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-4.fc34 0= 4/01/2014 RIP: 0010:load_module+0x19b/0x2391 Fixes: ec2a29593c83 ("module: harden ELF info handling") Signed-off-by: Alexey Dobriyan [rebased patch onto modules-next] Signed-off-by: Luis Chamberlain Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- kernel/module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/module.c b/kernel/module.c index 256b3c80a771..ef79f4dbda87 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3029,6 +3029,10 @@ static int elf_validity_check(struct load_info *info) * strings in the section safe. */ info->secstrings =3D (void *)info->hdr + strhdr->sh_offset; + if (strhdr->sh_size =3D=3D 0) { + pr_err("empty section name table\n"); + goto no_exec; + } if (info->secstrings[strhdr->sh_size - 1] !=3D '\0') { pr_err("ELF Spec violation: section name table isn't null terminated\n"); goto no_exec; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 59957C43334 for ; Mon, 11 Jul 2022 09:56:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbiGKJ4e (ORCPT ); Mon, 11 Jul 2022 05:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbiGKJzw (ORCPT ); Mon, 11 Jul 2022 05:55:52 -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 B9BE8B23CC; Mon, 11 Jul 2022 02:26: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 5FA4B6136F; Mon, 11 Jul 2022 09:26:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D31FC34115; Mon, 11 Jul 2022 09:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531584; bh=ruQ50WIOI0+7m3siYikWENO+ppOpQi5iT7iajfkpbn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ws6RvgQuBlknIRaCWIdfqIiXAIfSqyKtDo3mM4d+m2FVMWiZKIJu9K1jHvq3sVTAX 9PC3ZmrtxVmUINeYB/8t4GOlPluocbFS5ZrIkm+6EZKnOIqixPOBxrX/Ozc9x54oY7 zJe+89yT07t8MUHTQYE1DuFTHxh+DwnJ3Mn8mN8M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Zhang, Bernice" , Jacob Pan , Yian Chen , Joerg Roedel , Zhang@vger.kernel.org Subject: [PATCH 5.15 158/230] iommu/vt-d: Fix PCI bus rescan device hot add Date: Mon, 11 Jul 2022 11:06:54 +0200 Message-Id: <20220711090608.542361994@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Yian Chen commit 316f92a705a4c2bf4712135180d56f3cca09243a upstream. Notifier calling chain uses priority to determine the execution order of the notifiers or listeners registered to the chain. PCI bus device hot add utilizes the notification mechanism. The current code sets low priority (INT_MIN) to Intel dmar_pci_bus_notifier and postpones DMAR decoding after adding new device into IOMMU. The result is that struct device pointer cannot be found in DRHD search for the new device's DMAR/IOMMU. Subsequently, the device is put under the "catch-all" IOMMU instead of the correct one. This could cause system hang when device TLB invalidation is sent to the wrong IOMMU. Invalidation timeout error and hard lockup have been observed and data inconsistency/crush may occur as well. This patch fixes the issue by setting a positive priority(1) for dmar_pci_bus_notifier while the priority of IOMMU bus notifier uses the default value(0), therefore DMAR decoding will be in advance of DRHD search for a new device to find the correct IOMMU. Following is a 2-step example that triggers the bug by simulating PCI device hot add behavior in Intel Sapphire Rapids server. echo 1 > /sys/bus/pci/devices/0000:6a:01.0/remove echo 1 > /sys/bus/pci/rescan Fixes: 59ce0515cdaf ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope") Cc: stable@vger.kernel.org # v3.15+ Reported-by: Zhang, Bernice Signed-off-by: Jacob Pan Signed-off-by: Yian Chen Link: https://lore.kernel.org/r/20220521002115.1624069-1-yian.chen@intel.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/iommu/intel/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -385,7 +385,7 @@ static int dmar_pci_bus_notifier(struct =20 static struct notifier_block dmar_pci_bus_nb =3D { .notifier_call =3D dmar_pci_bus_notifier, - .priority =3D INT_MIN, + .priority =3D 1, }; =20 static struct dmar_drhd_unit * From nobody Sat Apr 18 21:00:49 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 93B35C433EF for ; Mon, 11 Jul 2022 09:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234049AbiGKJ4u (ORCPT ); Mon, 11 Jul 2022 05:56:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234034AbiGKJ4N (ORCPT ); Mon, 11 Jul 2022 05:56:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F997B31D9; Mon, 11 Jul 2022 02:26: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 1E140612E8; Mon, 11 Jul 2022 09:26:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29020C34115; Mon, 11 Jul 2022 09:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531587; bh=FEfMHg6hOiOU9NuBqymi/4Nkwi5QgLNr/8rryIS5iF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UdZo5tNev8AoZKuPpoxcwH9G1yj34OkDVn07hFuAnYoAcuvzJ4nH3i9ZVj64jzIGT /KVpXZ32sYG2Ndjyw9wP8RE6UUlibo0AnzpCYzFapDGeJbpIpZqGhEruwg16wPbV06 HM4dXMZuegBlS0hvGoFKRG6TCmsk3BLDIWH7dyGQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guiling Deng , Helge Deller Subject: [PATCH 5.15 159/230] fbdev: fbmem: Fix logo center image dx issue Date: Mon, 11 Jul 2022 11:06:55 +0200 Message-Id: <20220711090608.570810128@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Guiling Deng commit 955f04766d4e6eb94bf3baa539e096808c74ebfb upstream. Image.dx gets wrong value because of missing '()'. If xres =3D=3D logo->width and n =3D=3D 1, image.dx =3D -16. Signed-off-by: Guiling Deng Fixes: 3d8b1933eb1c ("fbdev: fbmem: add config option to center the bootup = logo") Cc: stable@vger.kernel.org # v5.0+ Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/video/fbdev/core/fbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -514,7 +514,7 @@ static int fb_show_logo_line(struct fb_i =20 while (n && (n * (logo->width + 8) - 8 > xres)) --n; - image.dx =3D (xres - n * (logo->width + 8) - 8) / 2; + image.dx =3D (xres - (n * (logo->width + 8) - 8)) / 2; image.dy =3D y ?: (yres - logo->height) / 2; } else { image.dx =3D 0; From nobody Sat Apr 18 21:00:49 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 D2F79CCA480 for ; Mon, 11 Jul 2022 09:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234170AbiGKJ4s (ORCPT ); Mon, 11 Jul 2022 05:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234133AbiGKJ4M (ORCPT ); Mon, 11 Jul 2022 05:56:12 -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 4E5BEB31C8; Mon, 11 Jul 2022 02:26:35 -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 C0B2D61383; Mon, 11 Jul 2022 09:26:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4618C34115; Mon, 11 Jul 2022 09:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531593; bh=kIuWGbz5DEODWD0dV/0NoRWJI6rMTuCyhXGaKzuwQ3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ze9IgzQHF7HmQIp5pZzA7TPZd40t08pIsQPzUPoHMwUUiXLd/lCo+StSD8E5iKXwj TfSfePebUQ4SfIduEqF8ziPZqNzGBzfhYM0dkZfAitLfhhMLUlIEhquHUU1JTQHNS1 kDRSAUmGjPl33I2bM/AZyZ0GIbveHdUwG/52BoL8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Geert Uytterhoeven Subject: [PATCH 5.15 160/230] fbmem: Check virtual screen sizes in fb_set_var() Date: Mon, 11 Jul 2022 11:06:56 +0200 Message-Id: <20220711090608.599372121@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Helge Deller commit 6c11df58fd1ac0aefcb3b227f72769272b939e56 upstream. Verify that the fbdev or drm driver correctly adjusted the virtual screen sizes. On failure report the failing driver and reject the screen size change. Signed-off-by: Helge Deller Reviewed-by: Geert Uytterhoeven Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/video/fbdev/core/fbmem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1020,6 +1020,16 @@ fb_set_var(struct fb_info *info, struct if (ret) return ret; =20 + /* verify that virtual resolution >=3D physical resolution */ + if (var->xres_virtual < var->xres || + var->yres_virtual < var->yres) { + pr_warn("WARNING: fbcon: Driver '%s' missed to adjust virtual screen siz= e (%ux%u vs. %ux%u)\n", + info->fix.id, + var->xres_virtual, var->yres_virtual, + var->xres, var->yres); + return -EINVAL; + } + if ((var->activate & FB_ACTIVATE_MASK) !=3D FB_ACTIVATE_NOW) return 0; From nobody Sat Apr 18 21:00:49 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 680E8C433EF for ; Mon, 11 Jul 2022 09:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234198AbiGKJ5S (ORCPT ); Mon, 11 Jul 2022 05:57:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234041AbiGKJ4t (ORCPT ); Mon, 11 Jul 2022 05:56:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E8FB4189; Mon, 11 Jul 2022 02:26:50 -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 30F2AB80E92; Mon, 11 Jul 2022 09:26:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86B7AC34115; Mon, 11 Jul 2022 09:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531595; bh=S9mbCzU3aDaS30PbSuhcVdHDJcVEx5OvHyDJ8pSdBd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIvELIldhA0oAz3LghBU2dP/0GiSSkz2/CS/t4Yjqq/5lHReDLU/8Wu1vS1LHeQI6 uEi91IB8vu0vUT9lQYEs4Uhm8OhkHvnUGmLLbtTWWw0d1VZPH7P/W+uZKQ5MRA5eQG Jnf/Edpo0LyvtURQK2YbHTSrKQYc5ihEHkNg+/nM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Daniel Vetter , Geert Uytterhoeven Subject: [PATCH 5.15 161/230] fbcon: Disallow setting font bigger than screen size Date: Mon, 11 Jul 2022 11:06:57 +0200 Message-Id: <20220711090608.628351902@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Helge Deller commit 65a01e601dbba8b7a51a2677811f70f783766682 upstream. Prevent that users set a font size which is bigger than the physical screen. It's unlikely this may happen (because screens are usually much larger than= the fonts and each font char is limited to 32x32 pixels), but it may happen on smaller screens/LCD displays. Signed-off-by: Helge Deller Reviewed-by: Daniel Vetter Reviewed-by: Geert Uytterhoeven Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2480,6 +2480,11 @@ static int fbcon_set_font(struct vc_data if (charcount !=3D 256 && charcount !=3D 512) return -EINVAL; =20 + /* font bigger than screen resolution ? */ + if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || + h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) + return -EINVAL; + /* Make sure drawing engine can handle the font */ if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || !(info->pixmap.blit_y & (1 << (font->height - 1)))) From nobody Sat Apr 18 21:00:49 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 D04B1C43334 for ; Mon, 11 Jul 2022 09:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234178AbiGKJ4x (ORCPT ); Mon, 11 Jul 2022 05:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234045AbiGKJ4Y (ORCPT ); Mon, 11 Jul 2022 05:56:24 -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 A6846B38CA; Mon, 11 Jul 2022 02:26: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 1F31BB80E8B; Mon, 11 Jul 2022 09:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C0F2C34115; Mon, 11 Jul 2022 09:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531598; bh=/arBt1W/MCDb9c/f3TGb/Hvy8ldRKHztfHDnFIYTmpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tjcVDC/JllWSPGxYf0TejLWT7qTCt1LS3YgCdNxxaFne4cKFaXVrLdZFEMGyRCjKZ gdjDYiZV8cJsNw+OvDzQqOueoEzKFMXj7OEJLRYqQ2d9OAGhmY2tb2At9HhMrtRTvX WeRh/Ds7ZG8ndsCxlZfBrATsUrVK66YPLBE8eX30= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Geert Uytterhoeven Subject: [PATCH 5.15 162/230] fbcon: Prevent that screen size is smaller than font size Date: Mon, 11 Jul 2022 11:06:58 +0200 Message-Id: <20220711090608.656936314@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Helge Deller commit e64242caef18b4a5840b0e7a9bff37abd4f4f933 upstream. We need to prevent that users configure a screen size which is smaller than= the currently selected font size. Otherwise rendering chars on the screen will access memory outside the graphics memory region. This patch adds a new function fbcon_modechange_possible() which implements this check and which later may be extended with other checks if necessary. The new function is called from the FBIOPUT_VSCREENINFO ioctl handler in fbmem.c, which will return -EINVAL if userspace asked for a too small screen size. Signed-off-by: Helge Deller Reviewed-by: Geert Uytterhoeven Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/video/fbdev/core/fbcon.c | 28 ++++++++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 4 +++- include/linux/fbcon.h | 4 ++++ 3 files changed, 35 insertions(+), 1 deletion(-) --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2747,6 +2747,34 @@ void fbcon_update_vcs(struct fb_info *in } EXPORT_SYMBOL(fbcon_update_vcs); =20 +/* let fbcon check if it supports a new screen resolution */ +int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screenin= fo *var) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct vc_data *vc; + unsigned int i; + + WARN_CONSOLE_UNLOCKED(); + + if (!ops) + return 0; + + /* prevent setting a screen size which is smaller than font size */ + for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { + vc =3D vc_cons[i].d; + if (!vc || vc->vc_mode !=3D KD_TEXT || + registered_fb[con2fb_map[i]] !=3D info) + continue; + + if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) || + vc->vc_font.height > FBCON_SWAP(var->rotate, var->yres, var->xres)) + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(fbcon_modechange_possible); + int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1120,7 +1120,9 @@ static long do_fb_ioctl(struct fb_info * return -EFAULT; console_lock(); lock_fb_info(info); - ret =3D fb_set_var(info, &var); + ret =3D fbcon_modechange_possible(info, &var); + if (!ret) + ret =3D fb_set_var(info, &var); if (!ret) fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL); unlock_fb_info(info); --- a/include/linux/fbcon.h +++ b/include/linux/fbcon.h @@ -15,6 +15,8 @@ void fbcon_new_modelist(struct fb_info * void fbcon_get_requirement(struct fb_info *info, struct fb_blit_caps *caps); void fbcon_fb_blanked(struct fb_info *info, int blank); +int fbcon_modechange_possible(struct fb_info *info, + struct fb_var_screeninfo *var); void fbcon_update_vcs(struct fb_info *info, bool all); void fbcon_remap_all(struct fb_info *info); int fbcon_set_con2fb_map_ioctl(void __user *argp); @@ -33,6 +35,8 @@ static inline void fbcon_new_modelist(st static inline void fbcon_get_requirement(struct fb_info *info, struct fb_blit_caps *caps) {} static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {} +static inline int fbcon_modechange_possible(struct fb_info *info, + struct fb_var_screeninfo *var) { return 0; } static inline void fbcon_update_vcs(struct fb_info *info, bool all) {} static inline void fbcon_remap_all(struct fb_info *info) {} static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0= ; } From nobody Sat Apr 18 21:00:49 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 ABD49C433EF for ; Mon, 11 Jul 2022 09:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbiGKJ47 (ORCPT ); Mon, 11 Jul 2022 05:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233720AbiGKJ4k (ORCPT ); Mon, 11 Jul 2022 05:56: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 41FE0B38E7; Mon, 11 Jul 2022 02:26:46 -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 E83EBB80E91; Mon, 11 Jul 2022 09:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BBA6C34115; Mon, 11 Jul 2022 09:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531601; bh=NL2ogyRTiRWJHJiqmYU+cNarar9DcAoC2rgdkm966C0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z84AN8+/+SN57c3muZAe4S8srGHnl+93FwGxNj64YvY5h+r8U9nyKvnhJyjJAPajm ZiEhBSP5yfQsQuXhfPpG/2hrAK8oyR5lazXdQ+ix2S/nOsorwaAyeIlD/lqe3/o4lf 5AABo+suCPdQE0W4sgaRWu9VrFSXetn2X6PkHuPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" Subject: [PATCH 5.15 163/230] PM: runtime: Redefine pm_runtime_release_supplier() Date: Mon, 11 Jul 2022 11:06:59 +0200 Message-Id: <20220711090608.686442021@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 J. Wysocki commit 07358194badf73e267289b40b761f5dc56928eab upstream. Instead of passing an extra bool argument to pm_runtime_release_supplier(), make its callers take care of triggering a runtime-suspend of the supplier device as needed. No expected functional impact. Suggested-by: Greg Kroah-Hartman Signed-off-by: Rafael J. Wysocki Reviewed-by: Greg Kroah-Hartman Cc: 5.1+ # 5.1+ Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/base/core.c | 3 ++- drivers/base/power/runtime.c | 20 +++++++++----------- include/linux/pm_runtime.h | 5 ++--- 3 files changed, 13 insertions(+), 15 deletions(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -485,7 +485,8 @@ static void device_link_release_fn(struc /* Ensure that all references to the link object have been dropped. */ device_link_synchronize_removal(); =20 - pm_runtime_release_supplier(link, true); + pm_runtime_release_supplier(link); + pm_request_idle(link->supplier); =20 put_device(link->consumer); put_device(link->supplier); --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -308,13 +308,10 @@ static int rpm_get_suppliers(struct devi /** * pm_runtime_release_supplier - Drop references to device link's supplier. * @link: Target device link. - * @check_idle: Whether or not to check if the supplier device is idle. * - * Drop all runtime PM references associated with @link to its supplier de= vice - * and if @check_idle is set, check if that device is idle (and so it can = be - * suspended). + * Drop all runtime PM references associated with @link to its supplier de= vice. */ -void pm_runtime_release_supplier(struct device_link *link, bool check_idle) +void pm_runtime_release_supplier(struct device_link *link) { struct device *supplier =3D link->supplier; =20 @@ -327,9 +324,6 @@ void pm_runtime_release_supplier(struct while (refcount_dec_not_one(&link->rpm_active) && atomic_read(&supplier->power.usage_count) > 0) pm_runtime_put_noidle(supplier); - - if (check_idle) - pm_request_idle(supplier); } =20 static void __rpm_put_suppliers(struct device *dev, bool try_to_suspend) @@ -337,8 +331,11 @@ static void __rpm_put_suppliers(struct d struct device_link *link; =20 list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, - device_links_read_lock_held()) - pm_runtime_release_supplier(link, try_to_suspend); + device_links_read_lock_held()) { + pm_runtime_release_supplier(link); + if (try_to_suspend) + pm_request_idle(link->supplier); + } } =20 static void rpm_put_suppliers(struct device *dev) @@ -1791,7 +1788,8 @@ void pm_runtime_drop_link(struct device_ return; =20 pm_runtime_drop_link_count(link->consumer); - pm_runtime_release_supplier(link, true); + pm_runtime_release_supplier(link); + pm_request_idle(link->supplier); } =20 static bool pm_runtime_need_not_resume(struct device *dev) --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -58,7 +58,7 @@ extern void pm_runtime_get_suppliers(str extern void pm_runtime_put_suppliers(struct device *dev); extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device_link *link); -extern void pm_runtime_release_supplier(struct device_link *link, bool che= ck_idle); +extern void pm_runtime_release_supplier(struct device_link *link); =20 extern int devm_pm_runtime_enable(struct device *dev); =20 @@ -284,8 +284,7 @@ static inline void pm_runtime_get_suppli static inline void pm_runtime_put_suppliers(struct device *dev) {} static inline void pm_runtime_new_link(struct device *dev) {} static inline void pm_runtime_drop_link(struct device_link *link) {} -static inline void pm_runtime_release_supplier(struct device_link *link, - bool check_idle) {} +static inline void pm_runtime_release_supplier(struct device_link *link) {} =20 #endif /* !CONFIG_PM */ From nobody Sat Apr 18 21:00:49 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 DD123C433EF for ; Mon, 11 Jul 2022 09:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbiGKJ5P (ORCPT ); Mon, 11 Jul 2022 05:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbiGKJ4s (ORCPT ); Mon, 11 Jul 2022 05:56: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 3D049B38F6; Mon, 11 Jul 2022 02:26: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 91BDBB80D2C; Mon, 11 Jul 2022 09:26:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3976C341C0; Mon, 11 Jul 2022 09:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531604; bh=SKoJobLuXWL5FRX92QKZJyelch0U0Zzj/8c/a3u1sTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kvfk5uaphfn/OXlr9MtbulzvnW3yZO8mRHHyIG4UziL8UIBGcTe4HXEZGTBqd25rm JBvVg0IBjTy7p8Hna/kiqI4kSHK62kKVELsg25kHgDI+JHDrdFPAl+5TCrCgMowEWU sQW5S2lXCi1C5wlMA2exPiTulGJgSjVsHYAAophY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Alison Schofield , Dan Williams Subject: [PATCH 5.15 164/230] memregion: Fix memregion_free() fallback definition Date: Mon, 11 Jul 2022 11:07:00 +0200 Message-Id: <20220711090608.714649746@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dan Williams commit f50974eee5c4a5de1e4f1a3d873099f170df25f8 upstream. In the CONFIG_MEMREGION=3Dn case, memregion_free() is meant to be a static inline. 0day reports: In file included from drivers/cxl/core/port.c:4: include/linux/memregion.h:19:6: warning: no previous prototype for function 'memregion_free' [-Wmissing-prototypes] Mark memregion_free() static. Fixes: 33dd70752cd7 ("lib: Uplevel the pmem "region" ida to a global alloca= tor") Reported-by: kernel test robot Reviewed-by: Alison Schofield Link: https://lore.kernel.org/r/165601455171.4042645.3350844271068713515.st= git@dwillia2-xfh Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/memregion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/memregion.h +++ b/include/linux/memregion.h @@ -16,7 +16,7 @@ static inline int memregion_alloc(gfp_t { return -ENOMEM; } -void memregion_free(int id) +static inline void memregion_free(int id) { } #endif From nobody Sat Apr 18 21:00:49 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 DD9A5C43334 for ; Mon, 11 Jul 2022 09:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234214AbiGKJ5i (ORCPT ); Mon, 11 Jul 2022 05:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234158AbiGKJ5K (ORCPT ); Mon, 11 Jul 2022 05:57:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28EF9B4BE5; Mon, 11 Jul 2022 02:26:59 -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 3C50EB80E8F; Mon, 11 Jul 2022 09:26:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C4BC341C8; Mon, 11 Jul 2022 09:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531606; bh=7glkkp0LLer/1vOu19Ra/fd2zYttlhPNl2QaoAA/NUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CRJoLC+swP99YiWqrFNCE/D/y8b2XNi25A0YHYGUzBxEhytBy1JMy+EN/kKo9rruj Fn8IlTO0wSkCQCVw+ykwICMceMfKkmg6qvg8moBsvPN5chEh2Ag0qm4T9+U9jGEEQ9 DpQuB1TJva5fAMRXdqx+bBebUILqy3hPN4y6qsaM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Hsin-Yi Wang , Helge Deller Subject: [PATCH 5.15 165/230] video: of_display_timing.h: include errno.h Date: Mon, 11 Jul 2022 11:07:01 +0200 Message-Id: <20220711090608.742508474@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Hsin-Yi Wang commit 3663a2fb325b8782524f3edb0ae32d6faa615109 upstream. If CONFIG_OF is not enabled, default of_get_display_timing() returns an errno, so include the header. Fixes: 422b67e0b31a ("videomode: provide dummy inline functions for !CONFIG= _OF") Suggested-by: Stephen Boyd Signed-off-by: Hsin-Yi Wang Reviewed-by: Stephen Boyd Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/video/of_display_timing.h | 2 ++ 1 file changed, 2 insertions(+) --- a/include/video/of_display_timing.h +++ b/include/video/of_display_timing.h @@ -8,6 +8,8 @@ #ifndef __LINUX_OF_DISPLAY_TIMING_H #define __LINUX_OF_DISPLAY_TIMING_H =20 +#include + struct device_node; struct display_timing; struct display_timings; From nobody Sat Apr 18 21:00:49 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 ED520C43334 for ; Mon, 11 Jul 2022 09:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234190AbiGKJ5k (ORCPT ); Mon, 11 Jul 2022 05:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbiGKJ5M (ORCPT ); Mon, 11 Jul 2022 05:57:12 -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 A618AB418F; Mon, 11 Jul 2022 02:26: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 327A06112E; Mon, 11 Jul 2022 09:26:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41C78C341C0; Mon, 11 Jul 2022 09:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531609; bh=K6jNGp2dUuNiWhAggovJ4j01QWBZArB13C35cE1qd8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ITfnJHzMeBvGuDvRVmUq3jRukw7SF7bjaxLUwHPgM84djZO0vonrSASIMGsvQDJ3H lQp8f4p1jqhzmpyZgBFvTj7YkQfnmvVwcBoz79XyxXuvneov/0MS0MwyNuEIP4MjOs +RB7B29lNhewzdG1ZXj2Br5Ih2yIFhIXOVspel/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sachin Sant , "Jason A. Donenfeld" , Michael Ellerman Subject: [PATCH 5.15 166/230] powerpc/powernv: delay rng platform device creation until later in boot Date: Mon, 11 Jul 2022 11:07:02 +0200 Message-Id: <20220711090608.769497319@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jason A. Donenfeld commit 887502826549caa7e4215fd9e628f48f14c0825a upstream. The platform device for the rng must be created much later in boot. Otherwise it tries to connect to a parent that doesn't yet exist, resulting in this splat: [ 0.000478] kobject: '(null)' ((____ptrval____)): is not initialized, = yet kobject_get() is being called. [ 0.002925] [c000000002a0fb30] [c00000000073b0bc] kobject_get+0x8c/0x1= 00 (unreliable) [ 0.003071] [c000000002a0fba0] [c00000000087e464] device_add+0xf4/0xb00 [ 0.003194] [c000000002a0fc80] [c000000000a7f6e4] of_device_add+0x64/0= x80 [ 0.003321] [c000000002a0fcb0] [c000000000a800d0] of_platform_device_c= reate_pdata+0xd0/0x1b0 [ 0.003476] [c000000002a0fd00] [c00000000201fa44] pnv_get_random_long_= early+0x240/0x2e4 [ 0.003623] [c000000002a0fe20] [c000000002060c38] random_init+0xc0/0x2= 14 This patch fixes the issue by doing the platform device creation inside of machine_subsys_initcall. Fixes: f3eac426657d ("powerpc/powernv: wire up rng during setup_arch") Cc: stable@vger.kernel.org Reported-by: Sachin Sant Signed-off-by: Jason A. Donenfeld Tested-by: Sachin Sant [mpe: Change "of node" to "platform device" in change log] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220630121654.1939181-1-Jason@zx2c4.com Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/powerpc/platforms/powernv/rng.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/arch/powerpc/platforms/powernv/rng.c +++ b/arch/powerpc/platforms/powernv/rng.c @@ -176,12 +176,8 @@ static int __init pnv_get_random_long_ea NULL) !=3D pnv_get_random_long_early) return 0; =20 - for_each_compatible_node(dn, NULL, "ibm,power-rng") { - if (rng_create(dn)) - continue; - /* Create devices for hwrng driver */ - of_platform_device_create(dn, NULL, NULL); - } + for_each_compatible_node(dn, NULL, "ibm,power-rng") + rng_create(dn); =20 if (!ppc_md.get_random_seed) return 0; @@ -205,10 +201,18 @@ void __init pnv_rng_init(void) =20 static int __init pnv_rng_late_init(void) { + struct device_node *dn; unsigned long v; + /* In case it wasn't called during init for some other reason. */ if (ppc_md.get_random_seed =3D=3D pnv_get_random_long_early) pnv_get_random_long_early(&v); + + if (ppc_md.get_random_seed =3D=3D powernv_get_random_long) { + for_each_compatible_node(dn, NULL, "ibm,power-rng") + of_platform_device_create(dn, NULL, NULL); + } + return 0; } machine_subsys_initcall(powernv, pnv_rng_late_init); From nobody Sat Apr 18 21:00:49 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 F116BC433EF for ; Mon, 11 Jul 2022 09:58:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234182AbiGKJ6G (ORCPT ); Mon, 11 Jul 2022 05:58:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234179AbiGKJ50 (ORCPT ); Mon, 11 Jul 2022 05:57:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5467FB4BF8; Mon, 11 Jul 2022 02:27: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 98159B80E93; Mon, 11 Jul 2022 09:26:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1D78C341C0; Mon, 11 Jul 2022 09:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531612; bh=YqtQP35jXWYBrQLN/cToll7pQXBag6WgH9ZCEqVLZqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sDcPASoI4017RjWKxApzpGY3hszY4O4+P8FioF3BeXNI0FhfYbUkMxXDI3ZUACiHM UwUegjZly1P9Hat7yhFFu/AzrfxWez9JLC+hwpTWSYedgRCf+oI8RDIOCPWVH6vMN2 l097QVscXcCwDwN3s/SVfoxtBSoDsf8ZcuzE/+Ig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Marangi , Jakub Kicinski Subject: [PATCH 5.15 167/230] net: dsa: qca8k: reset cpu port on MTU change Date: Mon, 11 Jul 2022 11:07:03 +0200 Message-Id: <20220711090608.797548765@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Christian Marangi commit 386228c694bf1e7a7688e44412cb33500b0ac585 upstream. It was discovered that the Documentation lacks of a fundamental detail on how to correctly change the MAX_FRAME_SIZE of the switch. In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the switch panics and cease to send any packet. This cause the mgmt ethernet system to not receive any packet (the slow fallback still works) and makes the device not reachable. To recover from this a switch reset is required. To correctly handle this, turn off the cpu ports before changing the MAX_FRAME_SIZE and turn on again after the value is applied. Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks") Cc: stable@vger.kernel.org Signed-off-by: Christian Marangi Link: https://lore.kernel.org/r/20220621151122.10220-1-ansuelsmth@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/dsa/qca8k.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1599,7 +1599,7 @@ static int qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct qca8k_priv *priv =3D ds->priv; - int i, mtu =3D 0; + int ret, i, mtu =3D 0; =20 priv->port_mtu[port] =3D new_mtu; =20 @@ -1607,8 +1607,27 @@ qca8k_port_change_mtu(struct dsa_switch if (priv->port_mtu[i] > mtu) mtu =3D priv->port_mtu[i]; =20 + /* To change the MAX_FRAME_SIZE the cpu ports must be off or + * the switch panics. + * Turn off both cpu ports before applying the new value to prevent + * this. + */ + if (priv->port_sts[0].enabled) + qca8k_port_set_status(priv, 0, 0); + + if (priv->port_sts[6].enabled) + qca8k_port_set_status(priv, 6, 0); + /* Include L2 header / FCS length */ - return qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_L= EN); + ret =3D qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_= LEN); + + if (priv->port_sts[0].enabled) + qca8k_port_set_status(priv, 0, 1); + + if (priv->port_sts[6].enabled) + qca8k_port_set_status(priv, 6, 1); + + return ret; } =20 static int From nobody Sat Apr 18 21:00:49 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 F0AFCC433EF for ; Mon, 11 Jul 2022 09:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234112AbiGKJ5a (ORCPT ); Mon, 11 Jul 2022 05:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234070AbiGKJ5C (ORCPT ); Mon, 11 Jul 2022 05:57:02 -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 BE613B4BCD; Mon, 11 Jul 2022 02:26: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 DEDC461377; Mon, 11 Jul 2022 09:26:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF3B8C341C0; Mon, 11 Jul 2022 09:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531615; bh=DI1WLhMFLliuiUtby0ptR0kS8Q9qsjCmG1Srm0YwIlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eTesO6SV8wsb0O1eeplG6B0GpXffejT/V+4tcHpY4K//yVeCp8DBKK/euWcpnbNxl 7Ml3lQVMMDEgkG01RZDUd/eD92H4lkzMyhfItowqIWahlWvdLi3mUpF/hYvwT46ohO /dCJTD6lir5RrtxOkEgnB7SwYLHjIqq6pgYbV/Vk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "stable@vger.kernel.org, linux-can@vger.kernel.org, Marc Kleine-Budde" Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jimmy Assarsson Subject: [PATCH 5.15 168/230] can: kvaser_usb: replace run-time checks with struct kvaser_usb_driver_info Date: Mon, 11 Jul 2022 11:07:04 +0200 Message-Id: <20220711090608.825628533@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jimmy Assarsson commit 49f274c72357d2d74cba70b172cf369768909707 upstream. Unify and move compile-time known information into new struct kvaser_usb_driver_info, in favor of run-time checks. All Kvaser USBcanII supports listen-only mode and error counter reporting. Link: https://lore.kernel.org/all/20220603083820.800246-2-extja@kvaser.com Suggested-by: Marc Kleine-Budde Cc: stable@vger.kernel.org Signed-off-by: Jimmy Assarsson [mkl: move struct kvaser_usb_driver_info into kvaser_usb_core.c] Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 22 + drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 275 ++++++++++++------= ----- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 24 +- 3 files changed, 173 insertions(+), 148 deletions(-) --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h @@ -35,9 +35,9 @@ #define KVASER_USB_RX_BUFFER_SIZE 3072 #define KVASER_USB_MAX_NET_DEVICES 5 =20 -/* USB devices features */ -#define KVASER_USB_HAS_SILENT_MODE BIT(0) -#define KVASER_USB_HAS_TXRX_ERRORS BIT(1) +/* Kvaser USB device quirks */ +#define KVASER_USB_QUIRK_HAS_SILENT_MODE BIT(0) +#define KVASER_USB_QUIRK_HAS_TXRX_ERRORS BIT(1) =20 /* Device capabilities */ #define KVASER_USB_CAP_BERR_CAP 0x01 @@ -65,12 +65,7 @@ struct kvaser_usb_dev_card_data_hydra { struct kvaser_usb_dev_card_data { u32 ctrlmode_supported; u32 capabilities; - union { - struct { - enum kvaser_usb_leaf_family family; - } leaf; - struct kvaser_usb_dev_card_data_hydra hydra; - }; + struct kvaser_usb_dev_card_data_hydra hydra; }; =20 /* Context for an outstanding, not yet ACKed, transmission */ @@ -84,7 +79,7 @@ struct kvaser_usb { struct usb_device *udev; struct usb_interface *intf; struct kvaser_usb_net_priv *nets[KVASER_USB_MAX_NET_DEVICES]; - const struct kvaser_usb_dev_ops *ops; + const struct kvaser_usb_driver_info *driver_info; const struct kvaser_usb_dev_cfg *cfg; =20 struct usb_endpoint_descriptor *bulk_in, *bulk_out; @@ -166,6 +161,12 @@ struct kvaser_usb_dev_ops { int *cmd_len, u16 transid); }; =20 +struct kvaser_usb_driver_info { + u32 quirks; + enum kvaser_usb_leaf_family family; + const struct kvaser_usb_dev_ops *ops; +}; + struct kvaser_usb_dev_cfg { const struct can_clock clock; const unsigned int timestamp_freq; @@ -185,4 +186,5 @@ int kvaser_usb_send_cmd_async(struct kva int len); =20 int kvaser_usb_can_rx_over_error(struct net_device *netdev); + #endif /* KVASER_USB_H */ --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c @@ -61,8 +61,6 @@ #define USB_USBCAN_R_V2_PRODUCT_ID 294 #define USB_LEAF_LIGHT_R_V2_PRODUCT_ID 295 #define USB_LEAF_LIGHT_HS_V2_OEM2_PRODUCT_ID 296 -#define USB_LEAF_PRODUCT_ID_END \ - USB_LEAF_LIGHT_HS_V2_OEM2_PRODUCT_ID =20 /* Kvaser USBCan-II devices product ids */ #define USB_USBCAN_REVB_PRODUCT_ID 2 @@ -89,116 +87,144 @@ #define USB_USBCAN_PRO_4HS_PRODUCT_ID 276 #define USB_HYBRID_CANLIN_PRODUCT_ID 277 #define USB_HYBRID_PRO_CANLIN_PRODUCT_ID 278 -#define USB_HYDRA_PRODUCT_ID_END \ - USB_HYBRID_PRO_CANLIN_PRODUCT_ID =20 -static inline bool kvaser_is_leaf(const struct usb_device_id *id) -{ - return (id->idProduct >=3D USB_LEAF_DEVEL_PRODUCT_ID && - id->idProduct <=3D USB_CAN_R_PRODUCT_ID) || - (id->idProduct >=3D USB_LEAF_LITE_V2_PRODUCT_ID && - id->idProduct <=3D USB_LEAF_PRODUCT_ID_END); -} +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_hydra = =3D { + .quirks =3D 0, + .ops =3D &kvaser_usb_hydra_dev_ops, +}; =20 -static inline bool kvaser_is_usbcan(const struct usb_device_id *id) -{ - return id->idProduct >=3D USB_USBCAN_REVB_PRODUCT_ID && - id->idProduct <=3D USB_MEMORATOR_PRODUCT_ID; -} +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_usbcan = =3D { + .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS | + KVASER_USB_QUIRK_HAS_SILENT_MODE, + .family =3D KVASER_USBCAN, + .ops =3D &kvaser_usb_leaf_dev_ops, +}; =20 -static inline bool kvaser_is_hydra(const struct usb_device_id *id) -{ - return id->idProduct >=3D USB_BLACKBIRD_V2_PRODUCT_ID && - id->idProduct <=3D USB_HYDRA_PRODUCT_ID_END; -} +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf =3D= { + .quirks =3D 0, + .family =3D KVASER_LEAF, + .ops =3D &kvaser_usb_leaf_dev_ops, +}; + +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err= =3D { + .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS, + .family =3D KVASER_LEAF, + .ops =3D &kvaser_usb_leaf_dev_ops, +}; + +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err= _listen =3D { + .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS | + KVASER_USB_QUIRK_HAS_SILENT_MODE, + .family =3D KVASER_LEAF, + .ops =3D &kvaser_usb_leaf_dev_ops, +}; =20 static const struct usb_device_id kvaser_usb_table[] =3D { /* Leaf USB product IDs */ - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_DEVEL_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_PRODUCT_ID) }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_DEVEL_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_SPRO_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_LS_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_SWC_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_LIN_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_SPRO_LS_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_SPRO_SWC_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO2_DEVEL_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO2_HSHS_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_UPRO_HSHS_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_GI_PRODUCT_ID) }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_GI_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_OBDII_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS | - KVASER_USB_HAS_SILENT_MODE }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err_listen= }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO2_HSLS_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_CH_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_BLACKBIRD_SPRO_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_OEM_MERCURY_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_OEM_LEAF_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_CAN_R_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_2HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_2HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_R_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_R_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM2_PRODUCT_ID) }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_2HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_2HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_R_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_R_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, =20 /* USBCANII USB product IDs */ { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN2_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_usbcan }, { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_REVB_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_usbcan }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMORATOR_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_usbcan }, { USB_DEVICE(KVASER_VENDOR_ID, USB_VCI2_PRODUCT_ID), - .driver_info =3D KVASER_USB_HAS_TXRX_ERRORS }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_usbcan }, =20 /* Minihydra USB product IDs */ - { USB_DEVICE(KVASER_VENDOR_ID, USB_BLACKBIRD_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_PRO_5HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_5HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_4HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_HS_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_2HS_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_2HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_PRO_2HS_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_2CANLIN_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_ATI_USBCAN_PRO_2HS_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_ATI_MEMO_PRO_2HS_V2_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_PRO_2CANLIN_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_U100_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_U100P_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_U100S_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_4HS_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_CANLIN_PRODUCT_ID) }, - { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_PRO_CANLIN_PRODUCT_ID) }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_BLACKBIRD_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_PRO_5HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_5HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_4HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_HS_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_2HS_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_2HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_MEMO_PRO_2HS_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_2CANLIN_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_ATI_USBCAN_PRO_2HS_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_ATI_MEMO_PRO_2HS_V2_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_PRO_2CANLIN_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_U100_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_U100P_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_U100S_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_PRO_4HS_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_CANLIN_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, + { USB_DEVICE(KVASER_VENDOR_ID, USB_HYBRID_PRO_CANLIN_PRODUCT_ID), + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_hydra }, { } }; MODULE_DEVICE_TABLE(usb, kvaser_usb_table); @@ -289,6 +315,7 @@ int kvaser_usb_can_rx_over_error(struct static void kvaser_usb_read_bulk_callback(struct urb *urb) { struct kvaser_usb *dev =3D urb->context; + const struct kvaser_usb_dev_ops *ops =3D dev->driver_info->ops; int err; unsigned int i; =20 @@ -305,8 +332,8 @@ static void kvaser_usb_read_bulk_callbac goto resubmit_urb; } =20 - dev->ops->dev_read_bulk_callback(dev, urb->transfer_buffer, - urb->actual_length); + ops->dev_read_bulk_callback(dev, urb->transfer_buffer, + urb->actual_length); =20 resubmit_urb: usb_fill_bulk_urb(urb, dev->udev, @@ -400,6 +427,7 @@ static int kvaser_usb_open(struct net_de { struct kvaser_usb_net_priv *priv =3D netdev_priv(netdev); struct kvaser_usb *dev =3D priv->dev; + const struct kvaser_usb_dev_ops *ops =3D dev->driver_info->ops; int err; =20 err =3D open_candev(netdev); @@ -410,11 +438,11 @@ static int kvaser_usb_open(struct net_de if (err) goto error; =20 - err =3D dev->ops->dev_set_opt_mode(priv); + err =3D ops->dev_set_opt_mode(priv); if (err) goto error; =20 - err =3D dev->ops->dev_start_chip(priv); + err =3D ops->dev_start_chip(priv); if (err) { netdev_warn(netdev, "Cannot start device, error %d\n", err); goto error; @@ -471,22 +499,23 @@ static int kvaser_usb_close(struct net_d { struct kvaser_usb_net_priv *priv =3D netdev_priv(netdev); struct kvaser_usb *dev =3D priv->dev; + const struct kvaser_usb_dev_ops *ops =3D dev->driver_info->ops; int err; =20 netif_stop_queue(netdev); =20 - err =3D dev->ops->dev_flush_queue(priv); + err =3D ops->dev_flush_queue(priv); if (err) netdev_warn(netdev, "Cannot flush queue, error %d\n", err); =20 - if (dev->ops->dev_reset_chip) { - err =3D dev->ops->dev_reset_chip(dev, priv->channel); + if (ops->dev_reset_chip) { + err =3D ops->dev_reset_chip(dev, priv->channel); if (err) netdev_warn(netdev, "Cannot reset card, error %d\n", err); } =20 - err =3D dev->ops->dev_stop_chip(priv); + err =3D ops->dev_stop_chip(priv); if (err) netdev_warn(netdev, "Cannot stop device, error %d\n", err); =20 @@ -525,6 +554,7 @@ static netdev_tx_t kvaser_usb_start_xmit { struct kvaser_usb_net_priv *priv =3D netdev_priv(netdev); struct kvaser_usb *dev =3D priv->dev; + const struct kvaser_usb_dev_ops *ops =3D dev->driver_info->ops; struct net_device_stats *stats =3D &netdev->stats; struct kvaser_usb_tx_urb_context *context =3D NULL; struct urb *urb; @@ -567,8 +597,8 @@ static netdev_tx_t kvaser_usb_start_xmit goto freeurb; } =20 - buf =3D dev->ops->dev_frame_to_cmd(priv, skb, &context->dlc, &cmd_len, - context->echo_index); + buf =3D ops->dev_frame_to_cmd(priv, skb, &context->dlc, &cmd_len, + context->echo_index); if (!buf) { stats->tx_dropped++; dev_kfree_skb(skb); @@ -652,15 +682,16 @@ static void kvaser_usb_remove_interfaces } } =20 -static int kvaser_usb_init_one(struct kvaser_usb *dev, - const struct usb_device_id *id, int channel) +static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel) { struct net_device *netdev; struct kvaser_usb_net_priv *priv; + const struct kvaser_usb_driver_info *driver_info =3D dev->driver_info; + const struct kvaser_usb_dev_ops *ops =3D driver_info->ops; int err; =20 - if (dev->ops->dev_reset_chip) { - err =3D dev->ops->dev_reset_chip(dev, channel); + if (ops->dev_reset_chip) { + err =3D ops->dev_reset_chip(dev, channel); if (err) return err; } @@ -689,20 +720,19 @@ static int kvaser_usb_init_one(struct kv priv->can.state =3D CAN_STATE_STOPPED; priv->can.clock.freq =3D dev->cfg->clock.freq; priv->can.bittiming_const =3D dev->cfg->bittiming_const; - priv->can.do_set_bittiming =3D dev->ops->dev_set_bittiming; - priv->can.do_set_mode =3D dev->ops->dev_set_mode; - if ((id->driver_info & KVASER_USB_HAS_TXRX_ERRORS) || + priv->can.do_set_bittiming =3D ops->dev_set_bittiming; + priv->can.do_set_mode =3D ops->dev_set_mode; + if ((driver_info->quirks & KVASER_USB_QUIRK_HAS_TXRX_ERRORS) || (priv->dev->card_data.capabilities & KVASER_USB_CAP_BERR_CAP)) - priv->can.do_get_berr_counter =3D dev->ops->dev_get_berr_counter; - if (id->driver_info & KVASER_USB_HAS_SILENT_MODE) + priv->can.do_get_berr_counter =3D ops->dev_get_berr_counter; + if (driver_info->quirks & KVASER_USB_QUIRK_HAS_SILENT_MODE) priv->can.ctrlmode_supported |=3D CAN_CTRLMODE_LISTENONLY; =20 priv->can.ctrlmode_supported |=3D dev->card_data.ctrlmode_supported; =20 if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) { priv->can.data_bittiming_const =3D dev->cfg->data_bittiming_const; - priv->can.do_set_data_bittiming =3D - dev->ops->dev_set_data_bittiming; + priv->can.do_set_data_bittiming =3D ops->dev_set_data_bittiming; } =20 netdev->flags |=3D IFF_ECHO; @@ -733,29 +763,22 @@ static int kvaser_usb_probe(struct usb_i struct kvaser_usb *dev; int err; int i; + const struct kvaser_usb_driver_info *driver_info; + const struct kvaser_usb_dev_ops *ops; + + driver_info =3D (const struct kvaser_usb_driver_info *)id->driver_info; + if (!driver_info) + return -ENODEV; =20 dev =3D devm_kzalloc(&intf->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; =20 - if (kvaser_is_leaf(id)) { - dev->card_data.leaf.family =3D KVASER_LEAF; - dev->ops =3D &kvaser_usb_leaf_dev_ops; - } else if (kvaser_is_usbcan(id)) { - dev->card_data.leaf.family =3D KVASER_USBCAN; - dev->ops =3D &kvaser_usb_leaf_dev_ops; - } else if (kvaser_is_hydra(id)) { - dev->ops =3D &kvaser_usb_hydra_dev_ops; - } else { - dev_err(&intf->dev, - "Product ID (%d) is not a supported Kvaser USB device\n", - id->idProduct); - return -ENODEV; - } - dev->intf =3D intf; + dev->driver_info =3D driver_info; + ops =3D driver_info->ops; =20 - err =3D dev->ops->dev_setup_endpoints(dev); + err =3D ops->dev_setup_endpoints(dev); if (err) { dev_err(&intf->dev, "Cannot get usb endpoint(s)"); return err; @@ -769,22 +792,22 @@ static int kvaser_usb_probe(struct usb_i =20 dev->card_data.ctrlmode_supported =3D 0; dev->card_data.capabilities =3D 0; - err =3D dev->ops->dev_init_card(dev); + err =3D ops->dev_init_card(dev); if (err) { dev_err(&intf->dev, "Failed to initialize card, error %d\n", err); return err; } =20 - err =3D dev->ops->dev_get_software_info(dev); + err =3D ops->dev_get_software_info(dev); if (err) { dev_err(&intf->dev, "Cannot get software info, error %d\n", err); return err; } =20 - if (dev->ops->dev_get_software_details) { - err =3D dev->ops->dev_get_software_details(dev); + if (ops->dev_get_software_details) { + err =3D ops->dev_get_software_details(dev); if (err) { dev_err(&intf->dev, "Cannot get software details, error %d\n", err); @@ -802,14 +825,14 @@ static int kvaser_usb_probe(struct usb_i =20 dev_dbg(&intf->dev, "Max outstanding tx =3D %d URBs\n", dev->max_tx_urbs); =20 - err =3D dev->ops->dev_get_card_info(dev); + err =3D ops->dev_get_card_info(dev); if (err) { dev_err(&intf->dev, "Cannot get card info, error %d\n", err); return err; } =20 - if (dev->ops->dev_get_capabilities) { - err =3D dev->ops->dev_get_capabilities(dev); + if (ops->dev_get_capabilities) { + err =3D ops->dev_get_capabilities(dev); if (err) { dev_err(&intf->dev, "Cannot get capabilities, error %d\n", err); @@ -819,7 +842,7 @@ static int kvaser_usb_probe(struct usb_i } =20 for (i =3D 0; i < dev->nchannels; i++) { - err =3D kvaser_usb_init_one(dev, id, i); + err =3D kvaser_usb_init_one(dev, i); if (err) { kvaser_usb_remove_interfaces(dev); return err; --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c @@ -405,7 +405,7 @@ kvaser_usb_leaf_frame_to_cmd(const struc sizeof(struct kvaser_cmd_tx_can); cmd->u.tx_can.channel =3D priv->channel; =20 - switch (dev->card_data.leaf.family) { + switch (dev->driver_info->family) { case KVASER_LEAF: cmd_tx_can_flags =3D &cmd->u.tx_can.leaf.flags; break; @@ -551,7 +551,7 @@ static int kvaser_usb_leaf_get_software_ if (err) return err; =20 - switch (dev->card_data.leaf.family) { + switch (dev->driver_info->family) { case KVASER_LEAF: kvaser_usb_leaf_get_software_info_leaf(dev, &cmd.u.leaf.softinfo); break; @@ -598,7 +598,7 @@ static int kvaser_usb_leaf_get_card_info =20 dev->nchannels =3D cmd.u.cardinfo.nchannels; if (dev->nchannels > KVASER_USB_MAX_NET_DEVICES || - (dev->card_data.leaf.family =3D=3D KVASER_USBCAN && + (dev->driver_info->family =3D=3D KVASER_USBCAN && dev->nchannels > MAX_USBCAN_NET_DEVICES)) return -EINVAL; =20 @@ -734,7 +734,7 @@ kvaser_usb_leaf_rx_error_update_can_stat new_state < CAN_STATE_BUS_OFF) priv->can.can_stats.restarts++; =20 - switch (dev->card_data.leaf.family) { + switch (dev->driver_info->family) { case KVASER_LEAF: if (es->leaf.error_factor) { priv->can.can_stats.bus_error++; @@ -813,7 +813,7 @@ static void kvaser_usb_leaf_rx_error(con } } =20 - switch (dev->card_data.leaf.family) { + switch (dev->driver_info->family) { case KVASER_LEAF: if (es->leaf.error_factor) { cf->can_id |=3D CAN_ERR_BUSERROR | CAN_ERR_PROT; @@ -1005,7 +1005,7 @@ static void kvaser_usb_leaf_rx_can_msg(c stats =3D &priv->netdev->stats; =20 if ((cmd->u.rx_can_header.flag & MSG_FLAG_ERROR_FRAME) && - (dev->card_data.leaf.family =3D=3D KVASER_LEAF && + (dev->driver_info->family =3D=3D KVASER_LEAF && cmd->id =3D=3D CMD_LEAF_LOG_MESSAGE)) { kvaser_usb_leaf_leaf_rx_error(dev, cmd); return; @@ -1021,7 +1021,7 @@ static void kvaser_usb_leaf_rx_can_msg(c return; } =20 - switch (dev->card_data.leaf.family) { + switch (dev->driver_info->family) { case KVASER_LEAF: rx_data =3D cmd->u.leaf.rx_can.data; break; @@ -1036,7 +1036,7 @@ static void kvaser_usb_leaf_rx_can_msg(c return; } =20 - if (dev->card_data.leaf.family =3D=3D KVASER_LEAF && cmd->id =3D=3D + if (dev->driver_info->family =3D=3D KVASER_LEAF && cmd->id =3D=3D CMD_LEAF_LOG_MESSAGE) { cf->can_id =3D le32_to_cpu(cmd->u.leaf.log_message.id); if (cf->can_id & KVASER_EXTENDED_FRAME) @@ -1133,14 +1133,14 @@ static void kvaser_usb_leaf_handle_comma break; =20 case CMD_LEAF_LOG_MESSAGE: - if (dev->card_data.leaf.family !=3D KVASER_LEAF) + if (dev->driver_info->family !=3D KVASER_LEAF) goto warn; kvaser_usb_leaf_rx_can_msg(dev, cmd); break; =20 case CMD_CHIP_STATE_EVENT: case CMD_CAN_ERROR_EVENT: - if (dev->card_data.leaf.family =3D=3D KVASER_LEAF) + if (dev->driver_info->family =3D=3D KVASER_LEAF) kvaser_usb_leaf_leaf_rx_error(dev, cmd); else kvaser_usb_leaf_usbcan_rx_error(dev, cmd); @@ -1152,12 +1152,12 @@ static void kvaser_usb_leaf_handle_comma =20 /* Ignored commands */ case CMD_USBCAN_CLOCK_OVERFLOW_EVENT: - if (dev->card_data.leaf.family !=3D KVASER_USBCAN) + if (dev->driver_info->family !=3D KVASER_USBCAN) goto warn; break; =20 case CMD_FLUSH_QUEUE_REPLY: - if (dev->card_data.leaf.family !=3D KVASER_LEAF) + if (dev->driver_info->family !=3D KVASER_LEAF) goto warn; break; From nobody Sat Apr 18 21:00:49 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 6323BCCA47B for ; Mon, 11 Jul 2022 09:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234132AbiGKJ6R (ORCPT ); Mon, 11 Jul 2022 05:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbiGKJ5t (ORCPT ); Mon, 11 Jul 2022 05:57:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0B213C8FA; Mon, 11 Jul 2022 02:27: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 ams.source.kernel.org (Postfix) with ESMTPS id 56DCAB80E91; Mon, 11 Jul 2022 09:26:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5C8AC34115; Mon, 11 Jul 2022 09:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531618; bh=uKKAqgqXf3T0j+MdqN2lR9VI38gLlZEfScmFSyQ+XsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hu/YYuroTh5ozr4N+m9Czo6n4aUGRK4bACW28Ol3rOO39bkHJTQ0P04DYQxcOSTjm nkEqYByryb+SZ7R8WlUzA+CpTMsTqUxB4h5sV10Oy0HsXMi9yendGfHXrcOuXu8acH 6TxJsCo53q0YHoWSfptXY52IE27/pSFQ1xPWVvvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "stable@vger.kernel.org, linux-can@vger.kernel.org, Marc Kleine-Budde" Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jimmy Assarsson Subject: [PATCH 5.15 169/230] can: kvaser_usb: kvaser_usb_leaf: fix CAN clock frequency regression Date: Mon, 11 Jul 2022 11:07:05 +0200 Message-Id: <20220711090608.854222675@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jimmy Assarsson commit e6c80e601053ffdac5709f11ff3ec1e19ed05f7b upstream. The firmware of M32C based Leaf devices expects bittiming parameters calculated for 16MHz clock. Since we use the actual clock frequency of the device, the device may end up with wrong bittiming parameters, depending on user requested parameters. This regression affects M32C based Leaf devices with non-16MHz clock. Fixes: a8b513b824e4 ("can: kvaser_usb: get CAN clock frequency from device") Link: https://lore.kernel.org/all/20220603083820.800246-3-extja@kvaser.com Cc: stable@vger.kernel.org Signed-off-by: Jimmy Assarsson Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 1=20 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 33 ++++++++++++++----= ----- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 25 +++++++++++------ 3 files changed, 38 insertions(+), 21 deletions(-) --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h @@ -38,6 +38,7 @@ /* Kvaser USB device quirks */ #define KVASER_USB_QUIRK_HAS_SILENT_MODE BIT(0) #define KVASER_USB_QUIRK_HAS_TXRX_ERRORS BIT(1) +#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ BIT(2) =20 /* Device capabilities */ #define KVASER_USB_CAP_BERR_CAP 0x01 --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c @@ -101,26 +101,33 @@ static const struct kvaser_usb_driver_in }; =20 static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf =3D= { - .quirks =3D 0, + .quirks =3D KVASER_USB_QUIRK_IGNORE_CLK_FREQ, .family =3D KVASER_LEAF, .ops =3D &kvaser_usb_leaf_dev_ops, }; =20 static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err= =3D { - .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS, + .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS | + KVASER_USB_QUIRK_IGNORE_CLK_FREQ, .family =3D KVASER_LEAF, .ops =3D &kvaser_usb_leaf_dev_ops, }; =20 static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err= _listen =3D { .quirks =3D KVASER_USB_QUIRK_HAS_TXRX_ERRORS | - KVASER_USB_QUIRK_HAS_SILENT_MODE, + KVASER_USB_QUIRK_HAS_SILENT_MODE | + KVASER_USB_QUIRK_IGNORE_CLK_FREQ, .family =3D KVASER_LEAF, .ops =3D &kvaser_usb_leaf_dev_ops, }; =20 +static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leafimx = =3D { + .quirks =3D 0, + .ops =3D &kvaser_usb_leaf_dev_ops, +}; + static const struct usb_device_id kvaser_usb_table[] =3D { - /* Leaf USB product IDs */ + /* Leaf M32C USB product IDs */ { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_DEVEL_PRODUCT_ID), .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_PRODUCT_ID), @@ -161,22 +168,24 @@ static const struct usb_device_id kvaser .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, { USB_DEVICE(KVASER_VENDOR_ID, USB_CAN_R_PRODUCT_ID), .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf_err }, + + /* Leaf i.MX28 USB product IDs */ { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_2HS_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_2HS_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_R_V2_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_R_V2_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM2_PRODUCT_ID), - .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leaf }, + .driver_info =3D (kernel_ulong_t)&kvaser_usb_driver_info_leafimx }, =20 /* USBCANII USB product IDs */ { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN2_PRODUCT_ID), --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c @@ -525,16 +525,23 @@ static void kvaser_usb_leaf_get_software dev->fw_version =3D le32_to_cpu(softinfo->fw_version); dev->max_tx_urbs =3D le16_to_cpu(softinfo->max_outstanding_tx); =20 - switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) { - case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK: + if (dev->driver_info->quirks & KVASER_USB_QUIRK_IGNORE_CLK_FREQ) { + /* Firmware expects bittiming parameters calculated for 16MHz + * clock, regardless of the actual clock + */ dev->cfg =3D &kvaser_usb_leaf_dev_cfg_16mhz; - break; - case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK: - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_24mhz; - break; - case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK: - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_32mhz; - break; + } else { + switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) { + case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK: + dev->cfg =3D &kvaser_usb_leaf_dev_cfg_16mhz; + break; + case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK: + dev->cfg =3D &kvaser_usb_leaf_dev_cfg_24mhz; + break; + case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK: + dev->cfg =3D &kvaser_usb_leaf_dev_cfg_32mhz; + break; + } } } From nobody Sat Apr 18 21:00:49 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 1C464C433EF for ; Mon, 11 Jul 2022 09:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234033AbiGKJ6q (ORCPT ); Mon, 11 Jul 2022 05:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234220AbiGKJ6O (ORCPT ); Mon, 11 Jul 2022 05:58:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C830045F6D; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id EF6E161137; Mon, 11 Jul 2022 09:27:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 066BDC34115; Mon, 11 Jul 2022 09:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531623; bh=VbEduvmmM1AuODkVN1ppk9QzuyHdgUEgBWpZMa+qDm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EAO4dvMf+q/4UiG+bkZ498Qqh8RPnubN8Z5BX710z6uZlAx9vhP16w0sa63TNtoXZ DkZ14nczwWnII0MTi0SyAxHcqt3913ud+l/1MkfIM+bUmcDTDc2/Zdpvday2QZXFW+ js40SBZ1u2zCWKDXBlXl45Yx66RkVqTlWsE3wQS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "stable@vger.kernel.org, linux-can@vger.kernel.org, Marc Kleine-Budde" Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jimmy Assarsson Subject: [PATCH 5.15 170/230] can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits Date: Mon, 11 Jul 2022 11:07:06 +0200 Message-Id: <20220711090608.882514911@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jimmy Assarsson commit b3b6df2c56d80b8c6740433cff5f016668b8de70 upstream. Use correct bittiming limits depending on device. For devices based on USBcanII, Leaf M32C or Leaf i.MX28. Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devic= es") Fixes: b4f20130af23 ("can: kvaser_usb: add support for Kvaser Leaf v2 and u= sb mini PCIe") Fixes: f5d4abea3ce0 ("can: kvaser_usb: Add support for the USBcan-II family= ") Link: https://lore.kernel.org/all/20220603083820.800246-4-extja@kvaser.com Cc: stable@vger.kernel.org Signed-off-by: Jimmy Assarsson [mkl: remove stray netlink.h include] [mkl: keep struct can_bittiming_const kvaser_usb_flexc_bittiming_const in k= vaser_usb_hydra.c] Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 2=20 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 4 - drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 76 ++++++++++++-----= ----- 3 files changed, 47 insertions(+), 35 deletions(-) --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h @@ -188,4 +188,6 @@ int kvaser_usb_send_cmd_async(struct kva =20 int kvaser_usb_can_rx_over_error(struct net_device *netdev); =20 +extern const struct can_bittiming_const kvaser_usb_flexc_bittiming_const; + #endif /* KVASER_USB_H */ --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c @@ -373,7 +373,7 @@ static const struct can_bittiming_const .brp_inc =3D 1, }; =20 -static const struct can_bittiming_const kvaser_usb_hydra_flexc_bittiming_c= =3D { +const struct can_bittiming_const kvaser_usb_flexc_bittiming_const =3D { .name =3D "kvaser_usb_flex", .tseg1_min =3D 4, .tseg1_max =3D 16, @@ -2052,7 +2052,7 @@ static const struct kvaser_usb_dev_cfg k .freq =3D 24000000, }, .timestamp_freq =3D 1, - .bittiming_const =3D &kvaser_usb_hydra_flexc_bittiming_c, + .bittiming_const =3D &kvaser_usb_flexc_bittiming_const, }; =20 static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_rt =3D { --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c @@ -100,16 +100,6 @@ #define USBCAN_ERROR_STATE_RX_ERROR BIT(1) #define USBCAN_ERROR_STATE_BUSERROR BIT(2) =20 -/* bittiming parameters */ -#define KVASER_USB_TSEG1_MIN 1 -#define KVASER_USB_TSEG1_MAX 16 -#define KVASER_USB_TSEG2_MIN 1 -#define KVASER_USB_TSEG2_MAX 8 -#define KVASER_USB_SJW_MAX 4 -#define KVASER_USB_BRP_MIN 1 -#define KVASER_USB_BRP_MAX 64 -#define KVASER_USB_BRP_INC 1 - /* ctrl modes */ #define KVASER_CTRL_MODE_NORMAL 1 #define KVASER_CTRL_MODE_SILENT 2 @@ -342,48 +332,68 @@ struct kvaser_usb_err_summary { }; }; =20 -static const struct can_bittiming_const kvaser_usb_leaf_bittiming_const = =3D { - .name =3D "kvaser_usb", - .tseg1_min =3D KVASER_USB_TSEG1_MIN, - .tseg1_max =3D KVASER_USB_TSEG1_MAX, - .tseg2_min =3D KVASER_USB_TSEG2_MIN, - .tseg2_max =3D KVASER_USB_TSEG2_MAX, - .sjw_max =3D KVASER_USB_SJW_MAX, - .brp_min =3D KVASER_USB_BRP_MIN, - .brp_max =3D KVASER_USB_BRP_MAX, - .brp_inc =3D KVASER_USB_BRP_INC, +static const struct can_bittiming_const kvaser_usb_leaf_m16c_bittiming_con= st =3D { + .name =3D "kvaser_usb_ucii", + .tseg1_min =3D 4, + .tseg1_max =3D 16, + .tseg2_min =3D 2, + .tseg2_max =3D 8, + .sjw_max =3D 4, + .brp_min =3D 1, + .brp_max =3D 16, + .brp_inc =3D 1, +}; + +static const struct can_bittiming_const kvaser_usb_leaf_m32c_bittiming_con= st =3D { + .name =3D "kvaser_usb_leaf", + .tseg1_min =3D 3, + .tseg1_max =3D 16, + .tseg2_min =3D 2, + .tseg2_max =3D 8, + .sjw_max =3D 4, + .brp_min =3D 2, + .brp_max =3D 128, + .brp_inc =3D 2, }; =20 -static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_8mhz =3D { +static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_usbcan_dev_cfg =3D { .clock =3D { .freq =3D 8000000, }, .timestamp_freq =3D 1, - .bittiming_const =3D &kvaser_usb_leaf_bittiming_const, + .bittiming_const =3D &kvaser_usb_leaf_m16c_bittiming_const, +}; + +static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg =3D { + .clock =3D { + .freq =3D 16000000, + }, + .timestamp_freq =3D 1, + .bittiming_const =3D &kvaser_usb_leaf_m32c_bittiming_const, }; =20 -static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_16mhz =3D { +static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_16mhz = =3D { .clock =3D { .freq =3D 16000000, }, .timestamp_freq =3D 1, - .bittiming_const =3D &kvaser_usb_leaf_bittiming_const, + .bittiming_const =3D &kvaser_usb_flexc_bittiming_const, }; =20 -static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_24mhz =3D { +static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_24mhz = =3D { .clock =3D { .freq =3D 24000000, }, .timestamp_freq =3D 1, - .bittiming_const =3D &kvaser_usb_leaf_bittiming_const, + .bittiming_const =3D &kvaser_usb_flexc_bittiming_const, }; =20 -static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_32mhz =3D { +static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_32mhz = =3D { .clock =3D { .freq =3D 32000000, }, .timestamp_freq =3D 1, - .bittiming_const =3D &kvaser_usb_leaf_bittiming_const, + .bittiming_const =3D &kvaser_usb_flexc_bittiming_const, }; =20 static void * @@ -529,17 +539,17 @@ static void kvaser_usb_leaf_get_software /* Firmware expects bittiming parameters calculated for 16MHz * clock, regardless of the actual clock */ - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_16mhz; + dev->cfg =3D &kvaser_usb_leaf_m32c_dev_cfg; } else { switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) { case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK: - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_16mhz; + dev->cfg =3D &kvaser_usb_leaf_imx_dev_cfg_16mhz; break; case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK: - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_24mhz; + dev->cfg =3D &kvaser_usb_leaf_imx_dev_cfg_24mhz; break; case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK: - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_32mhz; + dev->cfg =3D &kvaser_usb_leaf_imx_dev_cfg_32mhz; break; } } @@ -566,7 +576,7 @@ static int kvaser_usb_leaf_get_software_ dev->fw_version =3D le32_to_cpu(cmd.u.usbcan.softinfo.fw_version); dev->max_tx_urbs =3D le16_to_cpu(cmd.u.usbcan.softinfo.max_outstanding_tx); - dev->cfg =3D &kvaser_usb_leaf_dev_cfg_8mhz; + dev->cfg =3D &kvaser_usb_leaf_usbcan_dev_cfg; break; } From nobody Sat Apr 18 21:00:49 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 D8FD7C43334 for ; Mon, 11 Jul 2022 09:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231961AbiGKJ6a (ORCPT ); Mon, 11 Jul 2022 05:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234226AbiGKJ6H (ORCPT ); Mon, 11 Jul 2022 05:58: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 AA8BB3C8D1; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9A0A861363; Mon, 11 Jul 2022 09:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB9FCC34115; Mon, 11 Jul 2022 09:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531626; bh=sdJokJh/mT6NTEEZR+84538Xzs9PvYlTM6kDBhenlis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTWcjakxlatJtJ7KXYTSGOakj5TiV44VinyNGzYArj2mwEsz5KR2x2HEW08IDRJBv iYXqX0yjwKb/yPRqICKVtwwWRvL1EDrE/7ifMeJ0Y9LH0vCNU+oyldAuxuCOFgR2AP qKHWKzrjA56rAZc84YRfD/x6HM5gogAgvSy/9pgU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Eric Sandeen , "Darrick J. Wong" , Ayushman Dutta , Kuniyuki Iwashima Subject: [PATCH 5.15 171/230] xfs: remove incorrect ASSERT in xfs_rename Date: Mon, 11 Jul 2022 11:07:07 +0200 Message-Id: <20220711090608.911844588@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Eric Sandeen commit e445976537ad139162980bee015b7364e5b64fff upstream. This ASSERT in xfs_rename is a) incorrect, because (RENAME_WHITEOUT|RENAME_NOREPLACE) is a valid combination, and b) unnecessary, because actual invalid flag combinations are already handled at the vfs level in do_renameat2() before we get called. So, remove it. Reported-by: Paolo Bonzini Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Fixes: 7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") Reported-by: Ayushman Dutta Signed-off-by: Kuniyuki Iwashima Acked-by: Darrick J. Wong Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/xfs/xfs_inode.c | 1 - 1 file changed, 1 deletion(-) --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3128,7 +3128,6 @@ xfs_rename( * appropriately. */ if (flags & RENAME_WHITEOUT) { - ASSERT(!(flags & (RENAME_NOREPLACE | RENAME_EXCHANGE))); error =3D xfs_rename_alloc_whiteout(mnt_userns, target_dp, &wip); if (error) return error; From nobody Sat Apr 18 21:00:49 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 CD1D9C43334 for ; Mon, 11 Jul 2022 09:58:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234176AbiGKJ62 (ORCPT ); Mon, 11 Jul 2022 05:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234180AbiGKJ6B (ORCPT ); Mon, 11 Jul 2022 05:58: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 B01433C8DF; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3EC306135F; Mon, 11 Jul 2022 09:27:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DDE0C341C8; Mon, 11 Jul 2022 09:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531628; bh=cQt35amAe1aytsNuFRRAiFO5nBqm46vCBpFexZL0QAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kaq5PNiGVEk40YqDPlbWJvhTKFh9sNOm8yPyTPTxsPspjKRTjywjvg1ypXkcLPhHi BpAOYiPcBVdviIXilDlOsyBke68yqasCeHazX9uiUZu8YOqCDORhWeqRuooaQXQoKe SbashjVr8HxXlZrU8cw9iG4kRcSi3MRBOGghq3OQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Wang Subject: [PATCH 5.15 172/230] Revert "serial: sc16is7xx: Clear RS485 bits in the shutdown" Date: Mon, 11 Jul 2022 11:07:08 +0200 Message-Id: <20220711090608.941499183@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Hui Wang commit 41c606879f89623dd5269eaffea640b915e9e17c upstream. This reverts commit 927728a34f11b5a27f4610bdb7068317d6fdc72a. Once the uart_port->rs485->flag is set to SER_RS485_ENABLED, the port should always work in RS485 mode. If users want the port to leave RS485 mode, they need to call ioctl() to clear SER_RS485_ENABLED. So here we shouldn't clear the RS485 bits in the shutdown(). Fixes: 927728a34f11 ("serial: sc16is7xx: Clear RS485 bits in the shutdown") Signed-off-by: Hui Wang Link: https://lore.kernel.org/r/20220418094339.678144-1-hui.wang@canonical.= com Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/serial/sc16is7xx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1055,12 +1055,10 @@ static void sc16is7xx_shutdown(struct ua =20 /* Disable all interrupts */ sc16is7xx_port_write(port, SC16IS7XX_IER_REG, 0); - /* Disable TX/RX, clear auto RS485 and RTS invert */ + /* Disable TX/RX */ sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, SC16IS7XX_EFCR_RXDISABLE_BIT | - SC16IS7XX_EFCR_TXDISABLE_BIT | - SC16IS7XX_EFCR_AUTO_RS485_BIT | - SC16IS7XX_EFCR_RTS_INVERT_BIT, + SC16IS7XX_EFCR_TXDISABLE_BIT, SC16IS7XX_EFCR_RXDISABLE_BIT | SC16IS7XX_EFCR_TXDISABLE_BIT); From nobody Sat Apr 18 21:00:49 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 2CE24CCA482 for ; Mon, 11 Jul 2022 10:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234436AbiGKKEw (ORCPT ); Mon, 11 Jul 2022 06:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234513AbiGKKDa (ORCPT ); Mon, 11 Jul 2022 06:03: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 0501B48E8F; Mon, 11 Jul 2022 02:29: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 96B8961414; Mon, 11 Jul 2022 09:29:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E03AC34115; Mon, 11 Jul 2022 09:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531768; bh=dXCyeXMzsanEOjnWTi9p5QfZZN2jI9uPP4wKsJmHxbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlnXxTNFq43952O+l3WRpGCDBm8Iu7DnF9GSwDIzEdoT3zZw49N99fY+hMEgn2ZqD 8BT+u5MUE+ynUBzKP2WJ5JPFHmpbXYuWGnVYyHEOTVSFIDMnLDBj1YvRDG6rdTBcK7 7bUC/zbZSs/nM4atY9XnPWMkkDcueFAtZkKrhB1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Dan Carpenter , David Sterba Subject: [PATCH 5.15 173/230] btrfs: fix error pointer dereference in btrfs_ioctl_rm_dev_v2() Date: Mon, 11 Jul 2022 11:07:09 +0200 Message-Id: <20220711090608.969302812@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dan Carpenter commit d815b3f2f273537cb8afaf5ab11a46851f6c03e5 upstream. If memdup_user() fails the error handing will crash when it tries to kfree() an error pointer. Just return directly because there is no cleanup required. Fixes: 1a15eb724aae ("btrfs: use btrfs_get_dev_args_from_path in dev remova= l ioctls") Reviewed-by: Josef Bacik Signed-off-by: Dan Carpenter Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3231,10 +3231,8 @@ static long btrfs_ioctl_rm_dev_v2(struct return -EPERM; =20 vol_args =3D memdup_user(arg, sizeof(*vol_args)); - if (IS_ERR(vol_args)) { - ret =3D PTR_ERR(vol_args); - goto out; - } + if (IS_ERR(vol_args)) + return PTR_ERR(vol_args); =20 if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) { ret =3D -EOPNOTSUPP; From nobody Sat Apr 18 21:00:49 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 2DE75C43334 for ; Mon, 11 Jul 2022 09:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231584AbiGKJ7w (ORCPT ); Mon, 11 Jul 2022 05:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234217AbiGKJ6o (ORCPT ); Mon, 11 Jul 2022 05:58:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD4BB5D16; Mon, 11 Jul 2022 02:27: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 ams.source.kernel.org (Postfix) with ESMTPS id 6A819B80D2C; Mon, 11 Jul 2022 09:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2F7AC34115; Mon, 11 Jul 2022 09:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531648; bh=n0hYW14P2MKpZwo1i5aFk7orNBSieQ8KYy2b4+bCFyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jm281VnOWQIOe18JArJwlJQZO0F/RsYuHa4UXtC2N0g9U6DjkNAC0V3qnBWwGb4n9 9zKXrLVEhSLOuxaxXy6p+cUqvszFeapNXLhGuonlXnh5ECnYQERoFr5qbEjI+wEa8P xk5IJ/9H6yYycjjRfqXdCCAMq5VeS2eDkKabk7N0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Ye Guojin , "Michael S. Tsirkin" , Stefano Garzarella , Max Gurtovoy , Stefan Hajnoczi Subject: [PATCH 5.15 174/230] virtio-blk: modify the value type of num in virtio_queue_rq() Date: Mon, 11 Jul 2022 11:07:10 +0200 Message-Id: <20220711090608.997252359@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Ye Guojin commit 0466a39bd0b6c462338f10d18076703d14a552de upstream. This was found by coccicheck: ./drivers/block/virtio_blk.c, 334, 14-17, WARNING Unsigned expression compared with zero num < 0 Reported-by: Zeal Robot Signed-off-by: Ye Guojin Link: https://lore.kernel.org/r/20211117063955.160777-1-ye.guojin@zte.com.cn Signed-off-by: Michael S. Tsirkin Fixes: 02746e26c39e ("virtio-blk: avoid preallocating big SGL for data") Reviewed-by: Stefano Garzarella Reviewed-by: Max Gurtovoy Reviewed-by: Stefan Hajnoczi Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/block/virtio_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -308,7 +308,7 @@ static blk_status_t virtio_queue_rq(stru struct request *req =3D bd->rq; struct virtblk_req *vbr =3D blk_mq_rq_to_pdu(req); unsigned long flags; - unsigned int num; + int num; int qid =3D hctx->queue_num; int err; bool notify =3D false; From nobody Sat Apr 18 21:00:49 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 4B643C433EF for ; Mon, 11 Jul 2022 10:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234287AbiGKKAy (ORCPT ); Mon, 11 Jul 2022 06:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234514AbiGKJ7n (ORCPT ); Mon, 11 Jul 2022 05:59:43 -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 16FE5B7D49; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id 3A029B80D2C; Mon, 11 Jul 2022 09:28:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C3C3C34115; Mon, 11 Jul 2022 09:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531679; bh=qXisc+E/ALompKboJG36VZK8MAarwbjXLP9t9pP4C+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wWqQemC2DusARXLkvp2AiTqJCfuX0TMfIES6+V1ImDaEfIj4yZtaichRJ/UdnfNye vtTUwtLV8tYt3ydanwvtcDZajltl6rDd4DBlht8yyU9JSBKGVXEyxljuTuz2VZmjh1 Jz31rjFBW26LPONmXd5OdkcZblR7KC5GYTmI+b1A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Anand Jain , Tom Rix , David Sterba Subject: [PATCH 5.15 175/230] btrfs: fix use of uninitialized variable at rm device ioctl Date: Mon, 11 Jul 2022 11:07:11 +0200 Message-Id: <20220711090609.025325347@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Tom Rix commit 37b4599547e324589e011c20f74b021d6d25cb7f upstream. Clang static analysis reports this problem ioctl.c:3333:8: warning: 3rd function call argument is an uninitialized value ret =3D exclop_start_or_cancel_reloc(fs_info, cancel is only set in one branch of an if-check and is always used. So initialize to false. Fixes: 1a15eb724aae ("btrfs: use btrfs_get_dev_args_from_path in dev remova= l ioctls") Reviewed-by: Filipe Manana Reviewed-by: Anand Jain Signed-off-by: Tom Rix Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3291,7 +3291,7 @@ static long btrfs_ioctl_rm_dev(struct fi struct block_device *bdev =3D NULL; fmode_t mode; int ret; - bool cancel; + bool cancel =3D false; =20 if (!capable(CAP_SYS_ADMIN)) return -EPERM; From nobody Sat Apr 18 21:00:49 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 1D875C43334 for ; Mon, 11 Jul 2022 10:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234429AbiGKKCd (ORCPT ); Mon, 11 Jul 2022 06:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234225AbiGKKBy (ORCPT ); Mon, 11 Jul 2022 06:01:54 -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 E0F1965585; Mon, 11 Jul 2022 02:28: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 2B0B6B80DB7; Mon, 11 Jul 2022 09:28:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64872C34115; Mon, 11 Jul 2022 09:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531709; bh=xGYQNJJI17CuW0Ug1SdLR/e3i/hXLSrdy6sgfvRKxyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvilalJwYys9h/pVMPELRY2FsYUnCM9flXWguExRGIOhYuYH/kOcOYj3KSiR7Q5Oi 04S/P+ISOMLTP/xiLCOEDS1snY5nQnhlcwYPMLkFLvn/Xo82pqsb8YguidhT3TyWpM J9KuKaPySvagG3A06DT11QuOM5WifF+5xenxgQdU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.15 176/230] tty: n_gsm: fix encoding of command/response bit Date: Mon, 11 Jul 2022 11:07:12 +0200 Message-Id: <20220711090609.052703588@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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.starke@siemens.com commit 57435c42400ec147a527b2313188b649e81e449e upstream. n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDeta= ils.aspx?specificationId=3D1516 The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to the newer 27.010 here. Chapter 5.2.1.2 describes the encoding of the C/R (command/response) bit. Table 1 shows that the actual encoding of the C/R bit is inverted if the associated frame is sent by the responder. The referenced commit fixed here further broke the internal meaning of this bit in the outgoing path by always setting the C/R bit regardless of the frame type. This patch fixes both by setting the C/R bit always consistently for command (1) and response (0) frames and inverting it later for the responder where necessary. The meaning of this bit in the debug output is being preserved and shows the bit as if it was encoded by the initiator. This reflects only the frame type rather than the encoded combination of communication side and frame type. Fixes: cc0f42122a7e ("tty: n_gsm: Modify CR,PF bit when config requester") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220218073123.2121-2-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/n_gsm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -471,7 +471,7 @@ static void gsm_hex_dump_bytes(const cha * gsm_print_packet - display a frame for debug * @hdr: header to print before decode * @addr: address EA from the frame - * @cr: C/R bit from the frame + * @cr: C/R bit seen as initiator * @control: control including PF bit * @data: following data bytes * @dlen: length of data @@ -571,7 +571,7 @@ static int gsm_stuff_frame(const u8 *inp * gsm_send - send a control frame * @gsm: our GSM mux * @addr: address for control frame - * @cr: command/response bit + * @cr: command/response bit seen as initiator * @control: control byte including PF bit * * Format up and transmit a control frame. These do not go via the @@ -586,11 +586,15 @@ static void gsm_send(struct gsm_mux *gsm int len; u8 cbuf[10]; u8 ibuf[3]; + int ocr; + + /* toggle C/R coding if not initiator */ + ocr =3D cr ^ (gsm->initiator ? 0 : 1); =20 switch (gsm->encoding) { case 0: cbuf[0] =3D GSM0_SOF; - cbuf[1] =3D (addr << 2) | (cr << 1) | EA; + cbuf[1] =3D (addr << 2) | (ocr << 1) | EA; cbuf[2] =3D control; cbuf[3] =3D EA; /* Length of data =3D 0 */ cbuf[4] =3D 0xFF - gsm_fcs_add_block(INIT_FCS, cbuf + 1, 3); @@ -600,7 +604,7 @@ static void gsm_send(struct gsm_mux *gsm case 1: case 2: /* Control frame + packing (but not frame stuffing) in mode 1 */ - ibuf[0] =3D (addr << 2) | (cr << 1) | EA; + ibuf[0] =3D (addr << 2) | (ocr << 1) | EA; ibuf[1] =3D control; ibuf[2] =3D 0xFF - gsm_fcs_add_block(INIT_FCS, ibuf, 2); /* Stuffing may double the size worst case */ @@ -630,7 +634,7 @@ static void gsm_send(struct gsm_mux *gsm =20 static inline void gsm_response(struct gsm_mux *gsm, int addr, int control) { - gsm_send(gsm, addr, 1, control); + gsm_send(gsm, addr, 0, control); } =20 /** @@ -1875,10 +1879,10 @@ static void gsm_queue(struct gsm_mux *gs goto invalid; =20 cr =3D gsm->address & 1; /* C/R bit */ + cr ^=3D gsm->initiator ? 0 : 1; /* Flip so 1 always means command */ =20 gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len); =20 - cr ^=3D 1 - gsm->initiator; /* Flip so 1 always means command */ dlci =3D gsm->dlci[address]; =20 switch (gsm->control) { From nobody Sat Apr 18 21:00:49 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 F3A7ECCA480 for ; Mon, 11 Jul 2022 10:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234505AbiGKKDn (ORCPT ); Mon, 11 Jul 2022 06:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234480AbiGKKC5 (ORCPT ); Mon, 11 Jul 2022 06:02:57 -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 065AF65D50; Mon, 11 Jul 2022 02:29:00 -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 7A7B461360; Mon, 11 Jul 2022 09:29:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82034C34115; Mon, 11 Jul 2022 09:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531739; bh=8xduzV9XPwv+MRJJNBuvjbGKAF/YIl6fxiUCeWx2Z4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2T/QQqn2JMftqnj47FCpOccdiTVDzmEoKQWrjBD3giGki3mBi5+KgW3hyDwfIaSiP 7VTdNBJlEs1tzU9F3EB+xTn15v9RXHkhi48wwwVg/xsZvAjGswUarmYPJRuYQ2wp5g EgPow6TmEIzTOVzTxl0TSM14ngDTKWVhHxrsdLTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Martin Blumenstingl , Neil Armstrong , Sasha Levin Subject: [PATCH 5.15 177/230] ARM: meson: Fix refcount leak in meson_smp_prepare_cpus Date: Mon, 11 Jul 2022 11:07:13 +0200 Message-Id: <20220711090609.134134578@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Miaoqian Lin [ Upstream commit 34d2cd3fccced12b958b8848e3eff0ee4296764c ] of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: d850f3e5d296 ("ARM: meson: Add SMP bringup code for Meson8 and Meson= 8b") Signed-off-by: Miaoqian Lin Reviewed-by: Martin Blumenstingl Signed-off-by: Neil Armstrong Link: https://lore.kernel.org/r/20220512021611.47921-1-linmq006@gmail.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/mach-meson/platsmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-meson/platsmp.c b/arch/arm/mach-meson/platsmp.c index 4b8ad728bb42..32ac60b89fdc 100644 --- a/arch/arm/mach-meson/platsmp.c +++ b/arch/arm/mach-meson/platsmp.c @@ -71,6 +71,7 @@ static void __init meson_smp_prepare_cpus(const char *scu= _compatible, } =20 sram_base =3D of_iomap(node, 0); + of_node_put(node); if (!sram_base) { pr_err("Couldn't map SRAM registers\n"); return; @@ -91,6 +92,7 @@ static void __init meson_smp_prepare_cpus(const char *scu= _compatible, } =20 scu_base =3D of_iomap(node, 0); + of_node_put(node); if (!scu_base) { pr_err("Couldn't map SCU registers\n"); return; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 273C0CCA47B for ; Mon, 11 Jul 2022 10:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234562AbiGKKEE (ORCPT ); Mon, 11 Jul 2022 06:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbiGKKDZ (ORCPT ); Mon, 11 Jul 2022 06:03:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398D4675A4; Mon, 11 Jul 2022 02:29: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 C9B526136E; Mon, 11 Jul 2022 09:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9878C34115; Mon, 11 Jul 2022 09:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531754; bh=JnbQUXFmoCPU/Ryxi5nJ3JILasfWjNYUzM7FYb5s3Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSoqOXVoLmhNduXs12P0FYDE6lYqLn5C2GcDaDkLJaO4ayyKvEIa/k6v1LAgdkvJh x5p247y91UDWlM01cmoek0y+7jbway/T1D9xavVg0lpAvYmu9AcPn53plX+SF1bFQu 2itE3Rfqwf9diSdZ8M93AzynK/BDo5+vRx/L+gCw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Holland , Jernej Skrabec , Linus Walleij , Sasha Levin Subject: [PATCH 5.15 178/230] pinctrl: sunxi: a83t: Fix NAND function name for some pins Date: Mon, 11 Jul 2022 11:07:14 +0200 Message-Id: <20220711090609.162283165@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 aaefa29270d9551b604165a08406543efa9d16f5 ] The other NAND pins on Port C use the "nand0" function name. "nand0" also matches all of the other Allwinner SoCs. Fixes: 4730f33f0d82 ("pinctrl: sunxi: add allwinner A83T PIO controller sup= port") Signed-off-by: Samuel Holland Acked-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220526024956.49500-1-samuel@sholland.org Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c b/drivers/pinctrl/s= unxi/pinctrl-sun8i-a83t.c index 4ada80317a3b..b5c1a8f363f3 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c @@ -158,26 +158,26 @@ static const struct sunxi_desc_pin sun8i_a83t_pins[] = =3D { SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 14), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x2, "nand"), /* DQ6 */ + SUNXI_FUNCTION(0x2, "nand0"), /* DQ6 */ SUNXI_FUNCTION(0x3, "mmc2")), /* D6 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 15), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x2, "nand"), /* DQ7 */ + SUNXI_FUNCTION(0x2, "nand0"), /* DQ7 */ SUNXI_FUNCTION(0x3, "mmc2")), /* D7 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 16), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x2, "nand"), /* DQS */ + SUNXI_FUNCTION(0x2, "nand0"), /* DQS */ SUNXI_FUNCTION(0x3, "mmc2")), /* RST */ SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 17), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x2, "nand")), /* CE2 */ + SUNXI_FUNCTION(0x2, "nand0")), /* CE2 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 18), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x2, "nand")), /* CE3 */ + SUNXI_FUNCTION(0x2, "nand0")), /* CE3 */ /* Hole */ SUNXI_PIN(SUNXI_PINCTRL_PIN(D, 2), SUNXI_FUNCTION(0x0, "gpio_in"), --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 66978C433EF for ; Mon, 11 Jul 2022 10:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234574AbiGKKEG (ORCPT ); Mon, 11 Jul 2022 06:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234336AbiGKKD1 (ORCPT ); Mon, 11 Jul 2022 06:03:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5E2AB7FE; Mon, 11 Jul 2022 02:29: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 2DA2EB80D2C; Mon, 11 Jul 2022 09:29:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84111C34115; Mon, 11 Jul 2022 09:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531756; bh=u6uVBS3Wdb5rawdD2BPm9jKCU9OiNfMRMgbErBXsGM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p00QI4gpTObjuY34jKGrNjMVHnw5sKSsX0tp5wTbCIGa5xiT4siH0M3k18+67qXqW 2XPQMIPpVhWqpSyHWfyBqC8tX5v1nJZum6TVDzy9mDK84ZjDEQdGfih3sP42pn03hJ EaBdZjqnDc9b+lWGLI+mfDmC6ECxOeFhg77NSzSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.15 179/230] ASoC: rt711: Add endianness flag in snd_soc_component_driver Date: Mon, 11 Jul 2022 11:07:15 +0200 Message-Id: <20220711090609.189791935@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Charles Keepax [ Upstream commit 33f06beac3ade10834a82ad4105dcd91d4b00d61 ] The endianness flag is used on the CODEC side to specify an ambivalence to endian, typically because it is lost over the hardware link. This device receives audio over a SoundWire DAI and as such should have endianness applied. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20220504170905.332415-31-ckeepax@opensource= .cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt711.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index a7c5608a0ef8..9cc7283a19c2 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -943,6 +943,7 @@ static const struct snd_soc_component_driver soc_codec_= dev_rt711 =3D { .num_dapm_routes =3D ARRAY_SIZE(rt711_audio_map), .set_jack =3D rt711_set_jack_detect, .remove =3D rt711_remove, + .endianness =3D 1, }; =20 static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 87603C433EF for ; Mon, 11 Jul 2022 10:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234577AbiGKKEK (ORCPT ); Mon, 11 Jul 2022 06:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234438AbiGKKD2 (ORCPT ); Mon, 11 Jul 2022 06:03:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A93CC67CAF; Mon, 11 Jul 2022 02:29: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 44F1961414; Mon, 11 Jul 2022 09:29:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48DC5C34115; Mon, 11 Jul 2022 09:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531759; bh=8zI3HCloRYHVOHZCHLLz52FB/eHr8XOjH38oxYCQtKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xe9Kfi9xL9yoqmoc+RWy/GS5Vm47N54tbD8U8NSbN3sCwIGAr5+mdqlmohgu4MfbA eivow276HTmV/mewaTZYWx5igO09xXVqHJhRVi7v2sGPS/JVo+efQDpIH2cx9EUVoZ essztqWuFFaJ4nVTx6k/ytCr19jmj4/VWSUdRLG4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.15 180/230] ASoC: rt711-sdca: Add endianness flag in snd_soc_component_driver Date: Mon, 11 Jul 2022 11:07:16 +0200 Message-Id: <20220711090609.218222690@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Charles Keepax [ Upstream commit 3e50a5001055d79c04ea1c79fe4b4ff937a3339c ] The endianness flag is used on the CODEC side to specify an ambivalence to endian, typically because it is lost over the hardware link. This device receives audio over a SoundWire DAI and as such should have endianness applied. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20220504170905.332415-32-ckeepax@opensource= .cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt711-sdca.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c index 2e992589f1e4..b168e9303ea9 100644 --- a/sound/soc/codecs/rt711-sdca.c +++ b/sound/soc/codecs/rt711-sdca.c @@ -1208,6 +1208,7 @@ static const struct snd_soc_component_driver soc_sdca= _dev_rt711 =3D { .num_dapm_routes =3D ARRAY_SIZE(rt711_sdca_audio_map), .set_jack =3D rt711_sdca_set_jack_detect, .remove =3D rt711_sdca_remove, + .endianness =3D 1, }; =20 static int rt711_sdca_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_st= ream, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 2D111C43334 for ; Mon, 11 Jul 2022 10:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234509AbiGKKE5 (ORCPT ); Mon, 11 Jul 2022 06:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234473AbiGKKDa (ORCPT ); Mon, 11 Jul 2022 06:03:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED8F64E1E; Mon, 11 Jul 2022 02:29: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 C854AB80E88; Mon, 11 Jul 2022 09:29:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00603C34115; Mon, 11 Jul 2022 09:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531762; bh=/CQDIX6MgHw6BSW5F+R2dK1axL90w7kDbL15plXrA1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhuEcKL0HrCMXGc0LDdSr212Nygoo1pi1TQmrSB+QHz/jvDqSmcsdGknmz6r0mLMK +xf2XaMcNBUX2mDJIusiFky2kT6B8z8pkZ613xW5pFc+GgMWdaYwiees/OUz0pOA0o W5nUCIYanTWPYjJ9J4FzcKfBQqdYvu0n4iPt8lv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Rander Wang , Bard Liao , Mark Brown , Sasha Levin Subject: [PATCH 5.15 181/230] ASoC: codecs: rt700/rt711/rt711-sdca: resume bus/codec in .set_jack_detect Date: Mon, 11 Jul 2022 11:07:17 +0200 Message-Id: <20220711090609.246360825@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Pierre-Louis Bossart [ Upstream commit 40737057b48f1b4db67b0d766b95c87ba8fc5e03 ] The .set_jack_detect() codec component callback is invoked during card registration, which happens when the machine driver is probed. The issue is that this callback can race with the bus suspend/resume, and IO timeouts can happen. This can be reproduced very easily if the machine driver is 'blacklisted' and manually probed after the bus suspends. The bus and codec need to be re-initialized using pm_runtime helpers. Previous contributions tried to make sure accesses to the bus during the .set_jack_detect() component callback only happen when the bus is active. This was done by changing the regcache status on a component remove. This is however a layering violation, the regcache status should only be modified on device probe, suspend and resume. The component probe/remove should not modify how the device regcache is handled. This solution also didn't handle all the possible race conditions, and the RT700 headset codec was not handled. This patch tries to resume the codec device before handling the jack initializations. In case the codec has not yet been initialized, pm_runtime may not be enabled yet, so we don't squelch the -EACCES error code and only stop the jack information. When the codec reports as attached, the jack initialization will proceed as usual. BugLink: https://github.com/thesofproject/linux/issues/3643 Fixes: 7ad4d237e7c4a ('ASoC: rt711-sdca: Add RT711 SDCA vendor-specific dri= ver') Fixes: 899b12542b089 ('ASoC: rt711: add snd_soc_component remove callback') Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20220606203752.144159-8-pierre-louis.bossar= t@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- sound/soc/codecs/rt700.c | 16 +++++++++++++--- sound/soc/codecs/rt711-sdca.c | 26 ++++++++++++++------------ sound/soc/codecs/rt711.c | 24 +++++++++++++----------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c index 921382724f9c..614a40247679 100644 --- a/sound/soc/codecs/rt700.c +++ b/sound/soc/codecs/rt700.c @@ -315,17 +315,27 @@ static int rt700_set_jack_detect(struct snd_soc_compo= nent *component, struct snd_soc_jack *hs_jack, void *data) { struct rt700_priv *rt700 =3D snd_soc_component_get_drvdata(component); + int ret; =20 rt700->hs_jack =3D hs_jack; =20 - if (!rt700->hw_init) { - dev_dbg(&rt700->slave->dev, - "%s hw_init not ready yet\n", __func__); + ret =3D pm_runtime_resume_and_get(component->dev); + if (ret < 0) { + if (ret !=3D -EACCES) { + dev_err(component->dev, "%s: failed to resume %d\n", __func__, ret); + return ret; + } + + /* pm_runtime not enabled yet */ + dev_dbg(component->dev, "%s: skipping jack init for now\n", __func__); return 0; } =20 rt700_jack_init(rt700); =20 + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + return 0; } =20 diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c index b168e9303ea9..c15fb98eac86 100644 --- a/sound/soc/codecs/rt711-sdca.c +++ b/sound/soc/codecs/rt711-sdca.c @@ -487,16 +487,27 @@ static int rt711_sdca_set_jack_detect(struct snd_soc_= component *component, struct snd_soc_jack *hs_jack, void *data) { struct rt711_sdca_priv *rt711 =3D snd_soc_component_get_drvdata(component= ); + int ret; =20 rt711->hs_jack =3D hs_jack; =20 - if (!rt711->hw_init) { - dev_dbg(&rt711->slave->dev, - "%s hw_init not ready yet\n", __func__); + ret =3D pm_runtime_resume_and_get(component->dev); + if (ret < 0) { + if (ret !=3D -EACCES) { + dev_err(component->dev, "%s: failed to resume %d\n", __func__, ret); + return ret; + } + + /* pm_runtime not enabled yet */ + dev_dbg(component->dev, "%s: skipping jack init for now\n", __func__); return 0; } =20 rt711_sdca_jack_init(rt711); + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + return 0; } =20 @@ -1190,14 +1201,6 @@ static int rt711_sdca_probe(struct snd_soc_component= *component) return 0; } =20 -static void rt711_sdca_remove(struct snd_soc_component *component) -{ - struct rt711_sdca_priv *rt711 =3D snd_soc_component_get_drvdata(component= ); - - regcache_cache_only(rt711->regmap, true); - regcache_cache_only(rt711->mbq_regmap, true); -} - static const struct snd_soc_component_driver soc_sdca_dev_rt711 =3D { .probe =3D rt711_sdca_probe, .controls =3D rt711_sdca_snd_controls, @@ -1207,7 +1210,6 @@ static const struct snd_soc_component_driver soc_sdca= _dev_rt711 =3D { .dapm_routes =3D rt711_sdca_audio_map, .num_dapm_routes =3D ARRAY_SIZE(rt711_sdca_audio_map), .set_jack =3D rt711_sdca_set_jack_detect, - .remove =3D rt711_sdca_remove, .endianness =3D 1, }; =20 diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index 9cc7283a19c2..fafb0ba8349f 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -450,17 +450,27 @@ static int rt711_set_jack_detect(struct snd_soc_compo= nent *component, struct snd_soc_jack *hs_jack, void *data) { struct rt711_priv *rt711 =3D snd_soc_component_get_drvdata(component); + int ret; =20 rt711->hs_jack =3D hs_jack; =20 - if (!rt711->hw_init) { - dev_dbg(&rt711->slave->dev, - "%s hw_init not ready yet\n", __func__); + ret =3D pm_runtime_resume_and_get(component->dev); + if (ret < 0) { + if (ret !=3D -EACCES) { + dev_err(component->dev, "%s: failed to resume %d\n", __func__, ret); + return ret; + } + + /* pm_runtime not enabled yet */ + dev_dbg(component->dev, "%s: skipping jack init for now\n", __func__); return 0; } =20 rt711_jack_init(rt711); =20 + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + return 0; } =20 @@ -925,13 +935,6 @@ static int rt711_probe(struct snd_soc_component *compo= nent) return 0; } =20 -static void rt711_remove(struct snd_soc_component *component) -{ - struct rt711_priv *rt711 =3D snd_soc_component_get_drvdata(component); - - regcache_cache_only(rt711->regmap, true); -} - static const struct snd_soc_component_driver soc_codec_dev_rt711 =3D { .probe =3D rt711_probe, .set_bias_level =3D rt711_set_bias_level, @@ -942,7 +945,6 @@ static const struct snd_soc_component_driver soc_codec_= dev_rt711 =3D { .dapm_routes =3D rt711_audio_map, .num_dapm_routes =3D ARRAY_SIZE(rt711_audio_map), .set_jack =3D rt711_set_jack_detect, - .remove =3D rt711_remove, .endianness =3D 1, }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 B7BE6C433EF for ; Mon, 11 Jul 2022 10:04:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234481AbiGKKEz (ORCPT ); Mon, 11 Jul 2022 06:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234511AbiGKKDa (ORCPT ); Mon, 11 Jul 2022 06:03:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC10C48E8C; Mon, 11 Jul 2022 02:29: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 ams.source.kernel.org (Postfix) with ESMTPS id 786DDB80E6D; Mon, 11 Jul 2022 09:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D92FAC34115; Mon, 11 Jul 2022 09:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531765; bh=s1ijYzDz9YDw93VsXIoGWIkfJnpWGJMooOl/cYJ8gQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAnH1cQHTbEdMEfC8SrxWZSkgE/DOXJ4edKEMqprom7VX2s2bv34OTHg9Koc5O0df zClOdlZ9pVo7rp39Sx8JOsY4RpMvVka7sUkC9ts0GAqOfiMnIr2a7AZXro4tZc1IR2 UGlH/m+5rJMXzExjDTq01QvmhDV83G8VRgNZ5J/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Dybcio , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 182/230] arm64: dts: qcom: msm8994: Fix CPU6/7 reg values Date: Mon, 11 Jul 2022 11:07:18 +0200 Message-Id: <20220711090609.274114574@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Konrad Dybcio [ Upstream commit 47bf59c4755930f616dd90c8c6a85f40a6d347ea ] CPU6 and CPU7 were mistakengly pointing to CPU5 reg. Fix it. Fixes: 02d8091bbca0 ("arm64: dts: qcom: msm8994: Add a proper CPU map") Signed-off-by: Konrad Dybcio Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220501184016.64138-1-konrad.dybcio@somain= line.org Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/qcom/msm8994.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8994.dtsi b/arch/arm64/boot/dts/qc= om/msm8994.dtsi index 3c27671c8b5c..a8dc8163ee82 100644 --- a/arch/arm64/boot/dts/qcom/msm8994.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8994.dtsi @@ -93,7 +93,7 @@ CPU6: cpu@102 { device_type =3D "cpu"; compatible =3D "arm,cortex-a57"; - reg =3D <0x0 0x101>; + reg =3D <0x0 0x102>; enable-method =3D "psci"; next-level-cache =3D <&L2_1>; }; @@ -101,7 +101,7 @@ CPU7: cpu@103 { device_type =3D "cpu"; compatible =3D "arm,cortex-a57"; - reg =3D <0x0 0x101>; + reg =3D <0x0 0x103>; enable-method =3D "psci"; next-level-cache =3D <&L2_1>; }; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 4D445C433EF for ; Mon, 11 Jul 2022 10:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbiGKKAA (ORCPT ); Mon, 11 Jul 2022 06:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiGKJ7E (ORCPT ); Mon, 11 Jul 2022 05:59:04 -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 5EAA7B6290; Mon, 11 Jul 2022 02:27: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 B477ECE1268; Mon, 11 Jul 2022 09:27:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E774C34115; Mon, 11 Jul 2022 09:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531650; bh=73Uh7vu2OsPbWICEJYHjM7Eli153prRiBAG3rtQxm8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r8svoC5bvpKyqWRQ47p0LXKJKTdNaA3PEnsjKhDpg7rdD+syy0T08eixgbRdBbE7v Be9m8oIwukF5Y2jBQfvZT0l6076zy6oCzfDAkQAbLMWq77o269ras3bgBWEWvsGEqu yBv5Z4c8oWXO6ITuP+Wtii4kjqqhC6CdYtwW9YY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Baryshkov , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 183/230] arm64: dts: qcom: sdm845: use dispcc AHB clock for mdss node Date: Mon, 11 Jul 2022 11:07:19 +0200 Message-Id: <20220711090609.301392757@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dmitry Baryshkov [ Upstream commit 3ba500dee327e0261e728edec8a4f2f563d2760c ] It was noticed that on sdm845 after an MDSS suspend/resume cycle the driver can not read HW_REV registers properly (they will return 0 instead). Chaning the "iface" clock from <&gcc GCC_DISP_AHB_CLK> to <&dispcc DISP_CC_MDSS_AHB_CLK> fixes the issue. Fixes: 08c2a076d18f ("arm64: dts: qcom: sdm845: Add dpu to sdm845 dts file") Signed-off-by: Dmitry Baryshkov Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220531124735.1165582-1-dmitry.baryshkov@l= inaro.org Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qco= m/sdm845.dtsi index d20eacfc1017..ea7a272d267a 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -4147,7 +4147,7 @@ =20 power-domains =3D <&dispcc MDSS_GDSC>; =20 - clocks =3D <&gcc GCC_DISP_AHB_CLK>, + clocks =3D <&dispcc DISP_CC_MDSS_AHB_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names =3D "iface", "core"; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 9ED81C433EF for ; Mon, 11 Jul 2022 10:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234273AbiGKKAQ (ORCPT ); Mon, 11 Jul 2022 06:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234277AbiGKJ7L (ORCPT ); Mon, 11 Jul 2022 05:59:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15FD624A7; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id 69D4B613F8; Mon, 11 Jul 2022 09:27:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BD29C34115; Mon, 11 Jul 2022 09:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531653; bh=wpauSRjKkxczRqOFAKR0G9QBSNrt+x6DlEL/bNnxU/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/rL3QdQpqogNpHlkVkeJr9A22NpOL9+wytUBTQGbFNWi+j3x96wcYLQWrLGp8AeP bgTeRwbFxUxX63XmE2CQL67Vy13NY6e0HRAe7pevomPemKwtP5bpHY5NOVY2f5snUx qfYs4GvXIkYs6FetiSLFZNuw4Fpb2auRtBZ2BxHQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 184/230] ARM: mxs_defconfig: Enable the framebuffer Date: Mon, 11 Jul 2022 11:07:20 +0200 Message-Id: <20220711090609.329087746@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Fabio Estevam [ Upstream commit b10ef5f2ddb3a5a22ac0936c8d91a50ac5e55e77 ] Currently, when booting Linux on a imx28-evk board there is no display activity. Enable CONFIG_FB which is nowadays required for CONFIG_DRM_PANEL_LVDS, CONFIG_DRM_PANEL_SIMPLE, CONFIG_DRM_PANEL_SEIKO_43WVF1G, CONFIG_FB_MODE_HELPERS, CONFIG_BACKLIGHT_PWM, CONFIG_BACKLIGHT_GPIO, CONFIG_FRAMEBUFFER_CONSOLE, CONFIG_LOGO, CONFIG_FONTS, CONFIG_FONT_8x8 and CONFIG_FONT_8x16. Based on commit c54467482ffd ("ARM: imx_v6_v7_defconfig: enable fb"). Fixes: f611b1e7624c ("drm: Avoid circular dependencies for CONFIG_FB") Signed-off-by: Fabio Estevam Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/configs/mxs_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig index ca32446b187f..f53086ddc48b 100644 --- a/arch/arm/configs/mxs_defconfig +++ b/arch/arm/configs/mxs_defconfig @@ -93,6 +93,7 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=3Dy CONFIG_DRM=3Dy CONFIG_DRM_PANEL_SEIKO_43WVF1G=3Dy CONFIG_DRM_MXSFB=3Dy +CONFIG_FB=3Dy CONFIG_FB_MODE_HELPERS=3Dy CONFIG_LCD_CLASS_DEVICE=3Dy CONFIG_BACKLIGHT_CLASS_DEVICE=3Dy --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 42747C43334 for ; Mon, 11 Jul 2022 10:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbiGKKAK (ORCPT ); Mon, 11 Jul 2022 06:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbiGKJ7G (ORCPT ); Mon, 11 Jul 2022 05:59:06 -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 D6FE5B62A3; Mon, 11 Jul 2022 02:27:38 -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 1AB5A61363; Mon, 11 Jul 2022 09:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A302C34115; Mon, 11 Jul 2022 09:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531656; bh=XRosj7ZKB+v8fTnHvicj/hK4NALpuTjgSwVKyt/CFDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDMJLN63ns+NP4Nz4avN0HG12Wyt9UH21kPlqXGGQvek/hGvguG84AwOiYZIbu76a 9ausZiifjCkuwXKfxTvSFP8XFGYmyIH0asUXsQmditQYw+0yCdzqvz+UOVYxyBF/mY He9tXQMgqpM8a4/Rlvx7B9eqJg8Mv9vVybwG+dw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 185/230] arm64: dts: imx8mp-evk: correct mmc pad settings Date: Mon, 11 Jul 2022 11:07:21 +0200 Message-Id: <20220711090609.357414901@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 01785f1f156511c4f285786b4192245d4f476bf1 ] According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Not set reserved bit. Fixes: 9e847693c6f3 ("arm64: dts: freescale: Add i.MX8MP EVK board support") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index 7b99fad6e4d6..3c4369d6468c 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -377,7 +377,7 @@ =20 pinctrl_reg_usdhc2_vmmc: regusdhc2vmmcgrp { fsl,pins =3D < - MX8MP_IOMUXC_SD2_RESET_B__GPIO2_IO19 0x41 + MX8MP_IOMUXC_SD2_RESET_B__GPIO2_IO19 0x40 >; }; =20 @@ -402,7 +402,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d0 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d0 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d0 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; =20 @@ -414,7 +414,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d4 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d4 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d4 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; =20 @@ -426,7 +426,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d6 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d6 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d6 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 D3D51C43334 for ; Mon, 11 Jul 2022 10:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234346AbiGKKAe (ORCPT ); Mon, 11 Jul 2022 06:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234386AbiGKJ72 (ORCPT ); Mon, 11 Jul 2022 05:59:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243F5643E2; Mon, 11 Jul 2022 02:27: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 sin.source.kernel.org (Postfix) with ESMTPS id 1C9F7CE1267; Mon, 11 Jul 2022 09:27:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05B50C34115; Mon, 11 Jul 2022 09:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531659; bh=pvAUyeDuhA9Doy3U65eCiwgeQOavBWcDdXsmnMt2JGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lN5uGUmdiKxegNotZ2X8eaJHxX6fPRvXF0IHN0h+6OUukshbqU+zRhRKy3bdnTVha wL/zktvsE8fUe9aZC41KkfZBWYjiRoLdmudZV608nC4pquA2/YyMjzZHabDCa+HKa5 O9KCHJpXJgaJ3ATkn5NR6mgfJPMA6dvTukX1wfzM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Sherry Sun , Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 186/230] arm64: dts: imx8mp-evk: correct the uart2 pinctl value Date: Mon, 11 Jul 2022 11:07:22 +0200 Message-Id: <20220711090609.384953911@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Sherry Sun [ Upstream commit 2d4fb72b681205eed4553d8802632bd3270be3ba ] According to the IOMUXC_SW_PAD_CTL_PAD_UART2_RXD/TXD register define in imx8mp RM, bit0 and bit3 are reserved, and the uart2 rx/tx pin should enable the pull up, so need to set bit8 to 1. The original pinctl value 0x49 is incorrect and needs to be changed to 0x140, same as uart1 and uart3. Fixes: 9e847693c6f3 ("arm64: dts: freescale: Add i.MX8MP EVK board support") Reviewed-by: Haibo Chen Signed-off-by: Sherry Sun Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index 3c4369d6468c..3f424a8937f1 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -383,8 +383,8 @@ =20 pinctrl_uart2: uart2grp { fsl,pins =3D < - MX8MP_IOMUXC_UART2_RXD__UART2_DCE_RX 0x49 - MX8MP_IOMUXC_UART2_TXD__UART2_DCE_TX 0x49 + MX8MP_IOMUXC_UART2_RXD__UART2_DCE_RX 0x140 + MX8MP_IOMUXC_UART2_TXD__UART2_DCE_TX 0x140 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 BBC3FC43334 for ; Mon, 11 Jul 2022 10:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234319AbiGKKAT (ORCPT ); Mon, 11 Jul 2022 06:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbiGKJ7R (ORCPT ); Mon, 11 Jul 2022 05:59:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1035063911; Mon, 11 Jul 2022 02:27: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 dfw.source.kernel.org (Postfix) with ESMTPS id C8F1761372; Mon, 11 Jul 2022 09:27:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6390C34115; Mon, 11 Jul 2022 09:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531662; bh=XUoSAv6TxAwN+8OKNJOnZbAN/7rSjDyG73oAYspuHQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1jupjsNGqxTm2ziXn1JfImzpQkdvDVRlnaUDzrbJ9YyojDUSOjIr+9dX5jH+QYq0X W0BvLtzYO/2jC7RjP33x7i20VmI23LIX5ijUJW2eQzvv7cgCD1wdSTLWDIKd8iKlTr hUxIfuED/H2LgiZr1JNGTBeb/36LaCBAFzrZNpbQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 187/230] arm64: dts: imx8mp-evk: correct gpio-led pad settings Date: Mon, 11 Jul 2022 11:07:23 +0200 Message-Id: <20220711090609.412872318@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 b838582ab8d5fb11b2c0275056a9f34e1d94fece ] 0x19 is not a valid setting. According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Correct setting with PE PUE set, DSE set to 0. Fixes: 50d336b12f34 ("arm64: dts: imx8mp-evk: Add GPIO LED support") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index 3f424a8937f1..be3b01b5e159 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -351,7 +351,7 @@ =20 pinctrl_gpio_led: gpioledgrp { fsl,pins =3D < - MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO16 0x19 + MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO16 0x140 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 49B26C433EF for ; Mon, 11 Jul 2022 10:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234329AbiGKKAW (ORCPT ); Mon, 11 Jul 2022 06:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234362AbiGKJ7Z (ORCPT ); Mon, 11 Jul 2022 05:59:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B1FB6D9F; Mon, 11 Jul 2022 02:27: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 930FB61383; Mon, 11 Jul 2022 09:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B695C34115; Mon, 11 Jul 2022 09:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531665; bh=VSToU5cyn+2gNJ8tszJBMX7+ceNI777SKqz86CXfqlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcv9hozm4YPm4snn/lOXJzpHtMWPjgVaGnMVIQqUUgp0WNk+fbMPQ89XQCXqldi3g 0e5vUf2INuSfyWhFGF1c1VJ+wobvhZKl/swziztehWBLF7/5JddSl3+3tYowbKEtIY H5zS4Lma1Y/DE1Sxk6ZC+4S4VgPazSWHTRo6icXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 188/230] arm64: dts: imx8mp-evk: correct vbus pad settings Date: Mon, 11 Jul 2022 11:07:24 +0200 Message-Id: <20220711090609.440710078@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 e2c00820a99c55c9bb40642d5818a904a1e0d664 ] 0x19 is not a valid setting. According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Not set reserved bit. Fixes: 43da4f92a611 ("arm64: dts: imx8mp-evk: enable usb1 as host mode") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index be3b01b5e159..c794e8662da8 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -390,7 +390,7 @@ =20 pinctrl_usb1_vbus: usb1grp { fsl,pins =3D < - MX8MP_IOMUXC_GPIO1_IO14__USB2_OTG_PWR 0x19 + MX8MP_IOMUXC_GPIO1_IO14__USB2_OTG_PWR 0x10 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 AD317C43334 for ; Mon, 11 Jul 2022 10:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234341AbiGKKA3 (ORCPT ); Mon, 11 Jul 2022 06:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234363AbiGKJ7Z (ORCPT ); Mon, 11 Jul 2022 05:59: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 E85DEB6DB1; Mon, 11 Jul 2022 02:27:50 -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 28645B80E89; Mon, 11 Jul 2022 09:27:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74585C34115; Mon, 11 Jul 2022 09:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531667; bh=5s+Fgfq5iq8N3/TnZxgcKJQcxO0NV51qn95ZG79XstU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ikk76yIHffizv0pe3wNn/MW2TF671S1OBxc6hKfBrbBc+yCcP6GWWhSK0cYgF8pVd iTG540nchs3S8uHaJ3HO2/6Hkmo1Wr0eKUDrUp65jEUX72vFDqbvp54D58+9InGScI irIk5q3ASspDVuCeIbiXQRKcEc5ENUOQjwGSnk+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 189/230] arm64: dts: imx8mp-evk: correct eqos pad settings Date: Mon, 11 Jul 2022 11:07:25 +0200 Message-Id: <20220711090609.469016842@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 e6e1bc0ec9e8ad212fa46d8878a6e17cd31fdf7b ] According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Although function is not broken, we should not set reserved bit. Fixes: dc6d5dc89bad ("arm64: dts: imx8mp-evk: enable EQOS ethernet") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index c794e8662da8..33664c217673 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -285,21 +285,21 @@ &iomuxc { pinctrl_eqos: eqosgrp { fsl,pins =3D < - MX8MP_IOMUXC_ENET_MDC__ENET_QOS_MDC 0x3 - MX8MP_IOMUXC_ENET_MDIO__ENET_QOS_MDIO 0x3 - MX8MP_IOMUXC_ENET_RD0__ENET_QOS_RGMII_RD0 0x91 - MX8MP_IOMUXC_ENET_RD1__ENET_QOS_RGMII_RD1 0x91 - MX8MP_IOMUXC_ENET_RD2__ENET_QOS_RGMII_RD2 0x91 - MX8MP_IOMUXC_ENET_RD3__ENET_QOS_RGMII_RD3 0x91 - MX8MP_IOMUXC_ENET_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK 0x91 - MX8MP_IOMUXC_ENET_RX_CTL__ENET_QOS_RGMII_RX_CTL 0x91 - MX8MP_IOMUXC_ENET_TD0__ENET_QOS_RGMII_TD0 0x1f - MX8MP_IOMUXC_ENET_TD1__ENET_QOS_RGMII_TD1 0x1f - MX8MP_IOMUXC_ENET_TD2__ENET_QOS_RGMII_TD2 0x1f - MX8MP_IOMUXC_ENET_TD3__ENET_QOS_RGMII_TD3 0x1f - MX8MP_IOMUXC_ENET_TX_CTL__ENET_QOS_RGMII_TX_CTL 0x1f - MX8MP_IOMUXC_ENET_TXC__CCM_ENET_QOS_CLOCK_GENERATE_TX_CLK 0x1f - MX8MP_IOMUXC_SAI2_RXC__GPIO4_IO22 0x19 + MX8MP_IOMUXC_ENET_MDC__ENET_QOS_MDC 0x2 + MX8MP_IOMUXC_ENET_MDIO__ENET_QOS_MDIO 0x2 + MX8MP_IOMUXC_ENET_RD0__ENET_QOS_RGMII_RD0 0x90 + MX8MP_IOMUXC_ENET_RD1__ENET_QOS_RGMII_RD1 0x90 + MX8MP_IOMUXC_ENET_RD2__ENET_QOS_RGMII_RD2 0x90 + MX8MP_IOMUXC_ENET_RD3__ENET_QOS_RGMII_RD3 0x90 + MX8MP_IOMUXC_ENET_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK 0x90 + MX8MP_IOMUXC_ENET_RX_CTL__ENET_QOS_RGMII_RX_CTL 0x90 + MX8MP_IOMUXC_ENET_TD0__ENET_QOS_RGMII_TD0 0x16 + MX8MP_IOMUXC_ENET_TD1__ENET_QOS_RGMII_TD1 0x16 + MX8MP_IOMUXC_ENET_TD2__ENET_QOS_RGMII_TD2 0x16 + MX8MP_IOMUXC_ENET_TD3__ENET_QOS_RGMII_TD3 0x16 + MX8MP_IOMUXC_ENET_TX_CTL__ENET_QOS_RGMII_TX_CTL 0x16 + MX8MP_IOMUXC_ENET_TXC__CCM_ENET_QOS_CLOCK_GENERATE_TX_CLK 0x16 + MX8MP_IOMUXC_SAI2_RXC__GPIO4_IO22 0x10 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 39DECC43334 for ; Mon, 11 Jul 2022 10:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234330AbiGKKAr (ORCPT ); Mon, 11 Jul 2022 06:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234430AbiGKJ7e (ORCPT ); Mon, 11 Jul 2022 05:59:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9C474E0D; Mon, 11 Jul 2022 02:27: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 17920B80DB7; Mon, 11 Jul 2022 09:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5056AC34115; Mon, 11 Jul 2022 09:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531670; bh=OyjUG9OJISP1exqApWeTSGxAKba3do33WPDZ9BPAzV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqoMbCQ5+wWXYA6JmbHgvdMDCMflKOs1putUxSJLOLNT1hsWAM8nFjCNKRO9OU1K2 Z1VAaytxYphgAjy2vNG1xzix09ZTz4aBzo9SixDjz+omWd943JCcBHEaL+mQZ7sYxa HG9zTWGWXE3GfT+u8N4EgIIavPOX24dBrAH5R9Q8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 190/230] arm64: dts: imx8mp-evk: correct I2C1 pad settings Date: Mon, 11 Jul 2022 11:07:26 +0200 Message-Id: <20220711090609.496413034@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 05a7f43478e890513d571f36660bfedc1482a588 ] According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Although function is not broken, we should not set reserved bit. Fixes: 5497bc2a2bff ("arm64: dts: imx8mp-evk: Add PMIC device") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index 33664c217673..de6f3297fea4 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -357,8 +357,8 @@ =20 pinctrl_i2c1: i2c1grp { fsl,pins =3D < - MX8MP_IOMUXC_I2C1_SCL__I2C1_SCL 0x400001c3 - MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA 0x400001c3 + MX8MP_IOMUXC_I2C1_SCL__I2C1_SCL 0x400001c2 + MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA 0x400001c2 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 E7262C43334 for ; Mon, 11 Jul 2022 10:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbiGKKAn (ORCPT ); Mon, 11 Jul 2022 06:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234406AbiGKJ7b (ORCPT ); Mon, 11 Jul 2022 05:59:31 -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 DF80174E1E; Mon, 11 Jul 2022 02:27:54 -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 29A7B61366; Mon, 11 Jul 2022 09:27:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F43EC34115; Mon, 11 Jul 2022 09:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531673; bh=XYSrlgUfVeeMUNKDUAFz/eoIPxrvViOlDqPHy0wiAxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjXdiOPqbBJwFj9ToE4RgcGQoEbjpiOMNFsa4Et2xwsCpM1e8nyHGfKQq5/6WZ7YY hZpvXcVfIYK1LF981SMKrcw1Z/FHJC5taG4uUtj944a0SezBlVblDk/sF1r5104pOG lEegvqtHFBUGSziC2zpG7/c2qiTPcY6ch1NbVcyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 191/230] arm64: dts: imx8mp-evk: correct I2C3 pad settings Date: Mon, 11 Jul 2022 11:07:27 +0200 Message-Id: <20220711090609.524474701@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 0836de513ebaae5f03014641eac996290d67493d ] According to RM bit layout, BIT3 and BIT0 are reserved. 8 7 6 5 4 3 2 1 0 PE HYS PUE ODE FSEL X DSE X Although function is not broken, we should not set reserved bit. Fixes: 5e4a67ff7f69 ("arm64: dts: imx8mp-evk: Add i2c3 support") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot= /dts/freescale/imx8mp-evk.dts index de6f3297fea4..5c9fb39dd99e 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -364,8 +364,8 @@ =20 pinctrl_i2c3: i2c3grp { fsl,pins =3D < - MX8MP_IOMUXC_I2C3_SCL__I2C3_SCL 0x400001c3 - MX8MP_IOMUXC_I2C3_SDA__I2C3_SDA 0x400001c3 + MX8MP_IOMUXC_I2C3_SCL__I2C3_SCL 0x400001c2 + MX8MP_IOMUXC_I2C3_SDA__I2C3_SDA 0x400001c2 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 1A53CC43334 for ; Mon, 11 Jul 2022 10:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234386AbiGKKAu (ORCPT ); Mon, 11 Jul 2022 06:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234488AbiGKJ7l (ORCPT ); Mon, 11 Jul 2022 05:59:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F0174E37; Mon, 11 Jul 2022 02:27: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 E4AF26136E; Mon, 11 Jul 2022 09:27:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E91A1C34115; Mon, 11 Jul 2022 09:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531676; bh=eChDofblrc/z9HyIYPzqly3n06khJx7Bm7VoQk/EUFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJpJwCYu8Wu/gnTj6vMXBmTqeT0oOYOGuPwSlAWoVax/N3lcwPFAkz/rqKKmJuom+ vlAybCSZcHqgcTD1MeEPgv5Qbi+KwlTgwYfi/+64a7vAyMxUQ7pb2mcFr93IM/udv2 +GJXHpiqufwYtjs798lB+LyaLFRElZkoq5U+3ZNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 192/230] arm64: dts: imx8mp-phyboard-pollux-rdk: correct uart pad settings Date: Mon, 11 Jul 2022 11:07:28 +0200 Message-Id: <20220711090609.552212460@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 e266c155bd88e95f9b86379d6b0add6ac6e5452e ] BIT3 and BIT0 are reserved bits, should not touch. Fixes: 846f752866bd ("arm64: dts: imx8mp-phyboard-pollux-rdk: Change debug = UART") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts b= /arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts index 984a6b9ded8d..e34076954897 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts @@ -156,8 +156,8 @@ =20 pinctrl_uart1: uart1grp { fsl,pins =3D < - MX8MP_IOMUXC_UART1_RXD__UART1_DCE_RX 0x49 - MX8MP_IOMUXC_UART1_TXD__UART1_DCE_TX 0x49 + MX8MP_IOMUXC_UART1_RXD__UART1_DCE_RX 0x40 + MX8MP_IOMUXC_UART1_TXD__UART1_DCE_TX 0x40 >; }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 67ADDC43334 for ; Mon, 11 Jul 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiGKKBA (ORCPT ); Mon, 11 Jul 2022 06:01:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234528AbiGKJ7o (ORCPT ); Mon, 11 Jul 2022 05:59:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03787B7D4F; Mon, 11 Jul 2022 02:28: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 40E4761366; Mon, 11 Jul 2022 09:28:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FB49C34115; Mon, 11 Jul 2022 09:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531681; bh=Ydhnk3Ka6/gypkyrryB/mwM0eu6Jyl/rqSPH0WbVd+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F76I7drQwhPj0VVXAATVmChoSce8SVqioSSp6Plk4Fvrj2NmDVwNEPJ1czbDhzRxZ tBdgEqY6M6wGZpklJFX9cjKJrI+3ooFqAXFeNUxbS/j1J7AgTQwz5dSnS/XJZEg2MZ 3awVPQfEo+4SeO1NDV8vZq+sZ09lDcmoWgLL6KRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 193/230] arm64: dts: imx8mp-phyboard-pollux-rdk: correct eqos pad settings Date: Mon, 11 Jul 2022 11:07:29 +0200 Message-Id: <20220711090609.580096778@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 bae4de618efe1c41d34aa2e6cef8b08e46256667 ] BIT3 and BIT0 are reserved bits, should not touch. Fixes: 6f96852619d5 ("arm64: dts: freescale: Add support EQOS MAC on phyBOA= RD-Pollux-i.MX8MP") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../freescale/imx8mp-phyboard-pollux-rdk.dts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts b= /arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts index e34076954897..cefd3d36f93f 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts @@ -116,20 +116,20 @@ &iomuxc { pinctrl_eqos: eqosgrp { fsl,pins =3D < - MX8MP_IOMUXC_ENET_MDC__ENET_QOS_MDC 0x3 - MX8MP_IOMUXC_ENET_MDIO__ENET_QOS_MDIO 0x3 - MX8MP_IOMUXC_ENET_RD0__ENET_QOS_RGMII_RD0 0x91 - MX8MP_IOMUXC_ENET_RD1__ENET_QOS_RGMII_RD1 0x91 - MX8MP_IOMUXC_ENET_RD2__ENET_QOS_RGMII_RD2 0x91 - MX8MP_IOMUXC_ENET_RD3__ENET_QOS_RGMII_RD3 0x91 - MX8MP_IOMUXC_ENET_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK 0x91 - MX8MP_IOMUXC_ENET_RX_CTL__ENET_QOS_RGMII_RX_CTL 0x91 - MX8MP_IOMUXC_ENET_TD0__ENET_QOS_RGMII_TD0 0x1f - MX8MP_IOMUXC_ENET_TD1__ENET_QOS_RGMII_TD1 0x1f - MX8MP_IOMUXC_ENET_TD2__ENET_QOS_RGMII_TD2 0x1f - MX8MP_IOMUXC_ENET_TD3__ENET_QOS_RGMII_TD3 0x1f - MX8MP_IOMUXC_ENET_TX_CTL__ENET_QOS_RGMII_TX_CTL 0x1f - MX8MP_IOMUXC_ENET_TXC__CCM_ENET_QOS_CLOCK_GENERATE_TX_CLK 0x1f + MX8MP_IOMUXC_ENET_MDC__ENET_QOS_MDC 0x2 + MX8MP_IOMUXC_ENET_MDIO__ENET_QOS_MDIO 0x2 + MX8MP_IOMUXC_ENET_RD0__ENET_QOS_RGMII_RD0 0x90 + MX8MP_IOMUXC_ENET_RD1__ENET_QOS_RGMII_RD1 0x90 + MX8MP_IOMUXC_ENET_RD2__ENET_QOS_RGMII_RD2 0x90 + MX8MP_IOMUXC_ENET_RD3__ENET_QOS_RGMII_RD3 0x90 + MX8MP_IOMUXC_ENET_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK 0x90 + MX8MP_IOMUXC_ENET_RX_CTL__ENET_QOS_RGMII_RX_CTL 0x90 + MX8MP_IOMUXC_ENET_TD0__ENET_QOS_RGMII_TD0 0x16 + MX8MP_IOMUXC_ENET_TD1__ENET_QOS_RGMII_TD1 0x16 + MX8MP_IOMUXC_ENET_TD2__ENET_QOS_RGMII_TD2 0x16 + MX8MP_IOMUXC_ENET_TD3__ENET_QOS_RGMII_TD3 0x16 + MX8MP_IOMUXC_ENET_TX_CTL__ENET_QOS_RGMII_TX_CTL 0x16 + MX8MP_IOMUXC_ENET_TXC__CCM_ENET_QOS_CLOCK_GENERATE_TX_CLK 0x16 MX8MP_IOMUXC_SAI1_MCLK__GPIO4_IO20 0x10 >; }; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 952FDC43334 for ; Mon, 11 Jul 2022 10:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234400AbiGKKBH (ORCPT ); Mon, 11 Jul 2022 06:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234574AbiGKJ7t (ORCPT ); Mon, 11 Jul 2022 05:59:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E95B7D61; Mon, 11 Jul 2022 02:28:07 -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 B67C1B80DB7; Mon, 11 Jul 2022 09:28:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07876C34115; Mon, 11 Jul 2022 09:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531684; bh=bbeGwcWQa70BYWRXUbdD0HP8EK6OulIySJ6Ht6nUEmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=169gmadEDs0YR/2gzG5NZJGSdL0eo9zdwUzwn8+1UNHbGIB6DZrAgYAJXzNZRsNO/ sI0vrpjWO4hJ3BJ4bhuFmbUH5u3qMar1uQJQK3uzvm60a//KHcxX7vFq4pDChhZnbe YDAmkZjvwgtzmRaP2KggTX5QbVcFewLD7QdYDVHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Rasmus Villemoes , Shawn Guo , Sasha Levin Subject: [PATCH 5.15 194/230] arm64: dts: imx8mp-phyboard-pollux-rdk: correct i2c2 & mmc settings Date: Mon, 11 Jul 2022 11:07:30 +0200 Message-Id: <20220711090609.607923246@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 242d8ee9111171a6e68249aaff62643c513be6ec ] BIT3 and BIT0 are reserved bits, should not touch. Fixes: 88f7f6bcca37 ("arm64: dts: freescale: Add support for phyBOARD-Pollu= x-i.MX8MP") Signed-off-by: Peng Fan Reviewed-by: Rasmus Villemoes Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- .../dts/freescale/imx8mp-phyboard-pollux-rdk.dts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts b= /arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts index cefd3d36f93f..6aa720bafe28 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-phyboard-pollux-rdk.dts @@ -136,21 +136,21 @@ =20 pinctrl_i2c2: i2c2grp { fsl,pins =3D < - MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x400001c3 - MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA 0x400001c3 + MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x400001c2 + MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA 0x400001c2 >; }; =20 pinctrl_i2c2_gpio: i2c2gpiogrp { fsl,pins =3D < - MX8MP_IOMUXC_I2C2_SCL__GPIO5_IO16 0x1e3 - MX8MP_IOMUXC_I2C2_SDA__GPIO5_IO17 0x1e3 + MX8MP_IOMUXC_I2C2_SCL__GPIO5_IO16 0x1e2 + MX8MP_IOMUXC_I2C2_SDA__GPIO5_IO17 0x1e2 >; }; =20 pinctrl_reg_usdhc2_vmmc: regusdhc2vmmcgrp { fsl,pins =3D < - MX8MP_IOMUXC_SD2_RESET_B__GPIO2_IO19 0x41 + MX8MP_IOMUXC_SD2_RESET_B__GPIO2_IO19 0x40 >; }; =20 @@ -175,7 +175,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d0 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d0 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d0 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; =20 @@ -187,7 +187,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d4 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d4 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d4 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; =20 @@ -199,7 +199,7 @@ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d6 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d6 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d6 - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc1 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; }; }; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 20629C43334 for ; Mon, 11 Jul 2022 10:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234345AbiGKKBZ (ORCPT ); Mon, 11 Jul 2022 06:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234312AbiGKKAS (ORCPT ); Mon, 11 Jul 2022 06:00:18 -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 58125B7D7D; Mon, 11 Jul 2022 02:28:11 -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 93FACCE1268; Mon, 11 Jul 2022 09:28:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B010CC34115; Mon, 11 Jul 2022 09:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531687; bh=csgxy4ICyoSPVF+d/lXJiIiPKT9K0NdUJw6mNZnSrfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fm/63oiVykF8aNE/G7mhRnpAa0q641V1+ZednRSEq2Hd9eGakPFVCA70jimn07BmK lfp/udmRsryySUQLREfUTEzk0tNlvFQ5FZKQe3Kb6mKdnzOHdKX4SfrwnmRXlQfrJ9 XCzfgmvYVTvxZd91cCvX86L4LWBd/g+YV3krhZ70= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrei Lalaev , Samuel Holland , Linus Walleij , Sasha Levin Subject: [PATCH 5.15 195/230] pinctrl: sunxi: sunxi_pconf_set: use correct offset Date: Mon, 11 Jul 2022 11:07:31 +0200 Message-Id: <20220711090609.639568498@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Andrei Lalaev [ Upstream commit cd4c1e65a32afd003b08ad4aafe1e4d3e4e8e61b ] Some Allwinner SoCs have 2 pinctrls (PIO and R_PIO). Previous implementation used absolute pin numbering and it was incorrect for R_PIO pinctrl. It's necessary to take into account the base pin number. Fixes: 90be64e27621 ("pinctrl: sunxi: implement pin_config_set") Signed-off-by: Andrei Lalaev Reviewed-by: Samuel Holland Link: https://lore.kernel.org/r/20220525190423.410609-1-andrey.lalaev@gmail= .com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/= pinctrl-sunxi.c index ce3f9ea41511..1431ab21aca6 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -544,6 +544,8 @@ static int sunxi_pconf_set(struct pinctrl_dev *pctldev,= unsigned pin, struct sunxi_pinctrl *pctl =3D pinctrl_dev_get_drvdata(pctldev); int i; =20 + pin -=3D pctl->desc->pin_base; + for (i =3D 0; i < num_configs; i++) { enum pin_config_param param; unsigned long flags; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 254DCC433EF for ; Mon, 11 Jul 2022 10:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234415AbiGKKBo (ORCPT ); Mon, 11 Jul 2022 06:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234296AbiGKKAx (ORCPT ); Mon, 11 Jul 2022 06:00:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F22D77A53; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id 40FC0B80E87; Mon, 11 Jul 2022 09:28:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 868A7C34115; Mon, 11 Jul 2022 09:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531689; bh=Hvax53qgUXZsqWatbkd00eJvztr3uDyt+Tr8Kc4Y1WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=thFOMEOuQ/TJ8yXUr0jnn+wrg+aRKY96wHoDsM4RMf2T5T4splbu+KdJHe75Gd2pJ RpZzSP55hGbr9PH8CX8I5bKqXEHDWcvwrwGSeUgKnduQIV/Y7AJJ38Uv2mI1vxipwQ ONVWxvIXM+ixbbj5jSlQGT/kQoODtH3vjlveNX2Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Konrad Dybcio , Stephan Gerhold , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 196/230] arm64: dts: qcom: msm8992-*: Fix vdd_lvs1_2-supply typo Date: Mon, 11 Jul 2022 11:07:32 +0200 Message-Id: <20220711090609.667912132@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Stephan Gerhold [ Upstream commit 5fb779558f1c97e2bf2794cb59553e569c38e2f9 ] "make dtbs_check" complains about the missing "-supply" suffix for vdd_lvs1_2 which is clearly a typo, originally introduced in the msm8994-smd-rpm.dtsi file and apparently later copied to msm8992-xiaomi-libra.dts: msm8992-lg-bullhead-rev-10/101.dtb: pm8994-regulators: 'vdd_lvs1_2' does not match any of the regexes: '.*-supply$', '^((s|l|lvs|5vs)[0-9]*)|(boost-bypass)|(bob)$', 'pinctrl-[0= -9]+' >From schema: regulator/qcom,smd-rpm-regulator.yaml msm8992-xiaomi-libra.dtb: pm8994-regulators: 'vdd_lvs1_2' does not match any of the regexes: '.*-supply$', '^((s|l|lvs|5vs)[0-9]*)|(boost-bypass)|(bob)$', 'pinctrl-[0= -9]+' >From schema: regulator/qcom,smd-rpm-regulator.yaml Reported-by: Rob Herring Cc: Konrad Dybcio Fixes: f3b2c99e73be ("arm64: dts: Enable onboard SDHCI on msm8992") Fixes: 0f5cdb31e850 ("arm64: dts: qcom: Add Xiaomi Libra (Mi 4C) device tre= e") Signed-off-by: Stephan Gerhold Reviewed-by: Konrad Dybcio Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220627135938.2901871-1-stephan.gerhold@ke= rnkonzept.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts | 2 +- arch/arm64/boot/dts/qcom/msm8992-xiaomi-libra.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts b/arch/a= rm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts index 1ccca83292ac..c7d191dc6d4b 100644 --- a/arch/arm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts +++ b/arch/arm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts @@ -74,7 +74,7 @@ vdd_l17_29-supply =3D <&vph_pwr>; vdd_l20_21-supply =3D <&vph_pwr>; vdd_l25-supply =3D <&pm8994_s5>; - vdd_lvs1_2 =3D <&pm8994_s4>; + vdd_lvs1_2-supply =3D <&pm8994_s4>; =20 /* S1, S2, S6 and S12 are managed by RPMPD */ =20 diff --git a/arch/arm64/boot/dts/qcom/msm8992-xiaomi-libra.dts b/arch/arm64= /boot/dts/qcom/msm8992-xiaomi-libra.dts index 357d55496e75..a3d6340a0c55 100644 --- a/arch/arm64/boot/dts/qcom/msm8992-xiaomi-libra.dts +++ b/arch/arm64/boot/dts/qcom/msm8992-xiaomi-libra.dts @@ -142,7 +142,7 @@ vdd_l17_29-supply =3D <&vph_pwr>; vdd_l20_21-supply =3D <&vph_pwr>; vdd_l25-supply =3D <&pm8994_s5>; - vdd_lvs1_2 =3D <&pm8994_s4>; + vdd_lvs1_2-supply =3D <&pm8994_s4>; =20 /* S1, S2, S6 and S12 are managed by RPMPD */ =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 36E6CC43334 for ; Mon, 11 Jul 2022 10:01:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbiGKKBv (ORCPT ); Mon, 11 Jul 2022 06:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbiGKKBJ (ORCPT ); Mon, 11 Jul 2022 06:01:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F75B65591; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id D742DB80DB7; Mon, 11 Jul 2022 09:28:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48CBBC34115; Mon, 11 Jul 2022 09:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531692; bh=PUrwvXpZf3kjuBlfa0vWThShC/dMqMVn9zvTW94sEUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqbhz0yMU3M+ENI5fm0WiibTOq2oXWv7RZoApSDQQmkofqe4q7vgPm9UbwA5hOBt2 6lv+DoAfCO3pNTlixrGGtunc/A84bsT9z9Djijva+9C9o+sLj5hxJmLUInQJKTIl9h jpicK5TjxLga0VcyAzloazdjds5hUFevI8Hhl9gM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 197/230] ARM: at91: pm: use proper compatible for sama5d2s rtc Date: Mon, 11 Jul 2022 11:07:33 +0200 Message-Id: <20220711090609.695919459@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Claudiu Beznea [ Upstream commit ddc980da8043779119acaca106c6d9b445c9b65b ] Use proper compatible strings for SAMA5D2's RTC IPs. This is necessary for configuring wakeup sources for ULP1 PM mode. Fixes: d7484f5c6b3b ("ARM: at91: pm: configure wakeup sources for ULP1 mode= ") Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220523092421.317345-2-claudiu.beznea@micr= ochip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/mach-at91/pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 8711d6824c1f..cde99c9d0b2e 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -146,7 +146,7 @@ static const struct wakeup_source_info ws_info[] =3D { =20 static const struct of_device_id sama5d2_ws_ids[] =3D { { .compatible =3D "atmel,sama5d2-gem", .data =3D &ws_info[0] }, - { .compatible =3D "atmel,at91rm9200-rtc", .data =3D &ws_info[1] }, + { .compatible =3D "atmel,sama5d2-rtc", .data =3D &ws_info[1] }, { .compatible =3D "atmel,sama5d3-udc", .data =3D &ws_info[2] }, { .compatible =3D "atmel,at91rm9200-ohci", .data =3D &ws_info[2] }, { .compatible =3D "usb-ohci", .data =3D &ws_info[2] }, --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 47A45C43334 for ; Mon, 11 Jul 2022 10:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234323AbiGKKBz (ORCPT ); Mon, 11 Jul 2022 06:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233923AbiGKKBO (ORCPT ); Mon, 11 Jul 2022 06:01:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0976B77A60; Mon, 11 Jul 2022 02:28: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 3541261366; Mon, 11 Jul 2022 09:28:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12D7BC34115; Mon, 11 Jul 2022 09:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531695; bh=Or4tIqfLqjMcniUqYUencXEWyVzhntDagN+f+Ni14uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=he8GnsEvWzDPcR2rmADst47IRTKn9TRF/im3d1/xAM4mS06tG7EwjIkTEmDPGqq92 /P9vrsEVmAkOFa5F0B9/UREicCfLwrlAgtlgFcdOFLJtOBZe23krsrtHrl+ugct3DG N8Cuo78ibhwx3YWEcEHf7e4EjeK8E189XYQ1DgUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 198/230] ARM: at91: pm: use proper compatibles for sam9x60s rtc and rtt Date: Mon, 11 Jul 2022 11:07:34 +0200 Message-Id: <20220711090609.723851867@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Claudiu Beznea [ Upstream commit 641522665dbb25ce117c78746df1aad8b58c80e5 ] Use proper compatible strings for SAM9X60's RTC and RTT IPs. These are necessary for configuring wakeup sources for ULP1 PM mode. Fixes: eaedc0d379da ("ARM: at91: pm: add ULP1 support for SAM9X60") Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220523092421.317345-3-claudiu.beznea@micr= ochip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/mach-at91/pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index cde99c9d0b2e..cbad3609b783 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -157,12 +157,12 @@ static const struct of_device_id sama5d2_ws_ids[] =3D= { }; =20 static const struct of_device_id sam9x60_ws_ids[] =3D { - { .compatible =3D "atmel,at91sam9x5-rtc", .data =3D &ws_info[1] }, + { .compatible =3D "microchip,sam9x60-rtc", .data =3D &ws_info[1] }, { .compatible =3D "atmel,at91rm9200-ohci", .data =3D &ws_info[2] }, { .compatible =3D "usb-ohci", .data =3D &ws_info[2] }, { .compatible =3D "atmel,at91sam9g45-ehci", .data =3D &ws_info[2] }, { .compatible =3D "usb-ehci", .data =3D &ws_info[2] }, - { .compatible =3D "atmel,at91sam9260-rtt", .data =3D &ws_info[4] }, + { .compatible =3D "microchip,sam9x60-rtt", .data =3D &ws_info[4] }, { .compatible =3D "cdns,sam9x60-macb", .data =3D &ws_info[5] }, { /* sentinel */ } }; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 32BD9C433EF for ; Mon, 11 Jul 2022 10:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbiGKKCA (ORCPT ); Mon, 11 Jul 2022 06:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234220AbiGKKBU (ORCPT ); Mon, 11 Jul 2022 06:01:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91E4E77A45; Mon, 11 Jul 2022 02:28: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 23C6A6112E; Mon, 11 Jul 2022 09:28:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27F7BC34115; Mon, 11 Jul 2022 09:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531698; bh=TPxYeKuUgkoMrwZ+PMEsZ71J1Z5bfX/5jk1Gf9ssH+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzZFjOaFr5RyXAgxxPati74guiy/ffyn6GddfPlJxt/J4iw1cmH3NKFDw72ijJ3YQ aWELLQH4SXyItH59NtpgzQfk+P/qpeIiUWlJk233vEuqFE22iDJJqDfjEzvnp2aooQ egzPsFwOyEBtr2FdZccw1JOjWzN326MXmhheW4aU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 199/230] ARM: at91: pm: use proper compatibles for sama7g5s rtc and rtt Date: Mon, 11 Jul 2022 11:07:35 +0200 Message-Id: <20220711090609.751765224@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Claudiu Beznea [ Upstream commit 1c40169b35ad58906814d53a517ac92db3d20d5f ] Use proper compatible strings for SAMA7G5's RTC and RTT IPs. These are necessary for configuring wakeup sources for ULP1 PM mode. Fixes: 6501330f9f5e ("ARM: at91: pm: add pm support for SAMA7G5") Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220523092421.317345-4-claudiu.beznea@micr= ochip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/mach-at91/pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index cbad3609b783..ed1050404ef0 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -168,13 +168,13 @@ static const struct of_device_id sam9x60_ws_ids[] =3D= { }; =20 static const struct of_device_id sama7g5_ws_ids[] =3D { - { .compatible =3D "atmel,at91sam9x5-rtc", .data =3D &ws_info[1] }, + { .compatible =3D "microchip,sama7g5-rtc", .data =3D &ws_info[1] }, { .compatible =3D "microchip,sama7g5-ohci", .data =3D &ws_info[2] }, { .compatible =3D "usb-ohci", .data =3D &ws_info[2] }, { .compatible =3D "atmel,at91sam9g45-ehci", .data =3D &ws_info[2] }, { .compatible =3D "usb-ehci", .data =3D &ws_info[2] }, { .compatible =3D "microchip,sama7g5-sdhci", .data =3D &ws_info[3] }, - { .compatible =3D "atmel,at91sam9260-rtt", .data =3D &ws_info[4] }, + { .compatible =3D "microchip,sama7g5-rtt", .data =3D &ws_info[4] }, { /* sentinel */ } }; =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 DACC7C433EF for ; Mon, 11 Jul 2022 10:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234333AbiGKKCF (ORCPT ); Mon, 11 Jul 2022 06:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234277AbiGKKBV (ORCPT ); Mon, 11 Jul 2022 06:01:21 -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 DB1CB77A7A; Mon, 11 Jul 2022 02:28: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 98010B80E6D; Mon, 11 Jul 2022 09:28:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0232DC341CF; Mon, 11 Jul 2022 09:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531701; bh=jhc/ulTw10SoBS56aSkgurPUpyWUw86gbF4tzyLdDKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nV8ft7Nfno3T7snPDxyvUvsKTFqSls+Z3vuihy/bk+jKKxUqB4HRkcjM3Ws762x9G MNNMMZqn0PdtTcvbK1jjIoHy/9MeEKGqHQOLFidm94VcJ5p9hFFF92qHweNCoeKPx3 Tkr9udK4DKV02IBO6n433Z5tjlTX6ntHXgNHShfM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugen Hristev , Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 200/230] ARM: dts: at91: sam9x60ek: fix eeprom compatible and size Date: Mon, 11 Jul 2022 11:07:36 +0200 Message-Id: <20220711090609.779176726@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Eugen Hristev [ Upstream commit f2cbbc3f926316ccf8ef9363d8a60c1110afc1c7 ] The board has a microchip 24aa025e48 eeprom, which is a 2 Kbits memory, so it's compatible with at24c02 not at24c32. Also the size property is wrong, it's not 128 bytes, but 256 bytes. Thus removing and leaving it to the default (256). Fixes: 1e5f532c27371 ("ARM: dts: at91: sam9x60: add device tree for soc and= board") Signed-off-by: Eugen Hristev Reviewed-by: Claudiu Beznea Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220607090455.80433-1-eugen.hristev@microc= hip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/boot/dts/at91-sam9x60ek.dts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/at91-sam9x60ek.dts b/arch/arm/boot/dts/at91-= sam9x60ek.dts index b1068cca4228..fd8dc1183b3e 100644 --- a/arch/arm/boot/dts/at91-sam9x60ek.dts +++ b/arch/arm/boot/dts/at91-sam9x60ek.dts @@ -233,10 +233,9 @@ status =3D "okay"; =20 eeprom@53 { - compatible =3D "atmel,24c32"; + compatible =3D "atmel,24c02"; reg =3D <0x53>; pagesize =3D <16>; - size =3D <128>; status =3D "okay"; }; }; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 238D5C43334 for ; Mon, 11 Jul 2022 10:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234444AbiGKKCL (ORCPT ); Mon, 11 Jul 2022 06:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234366AbiGKKB0 (ORCPT ); Mon, 11 Jul 2022 06:01: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 E94EEB8E93; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id 70161B80E87; Mon, 11 Jul 2022 09:28:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39FBC34115; Mon, 11 Jul 2022 09:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531704; bh=D0dFsVUx046MH+rBA7BhQb8BfgSRDc1hnJB8uhlMA2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXMPf3yxFRi5PDyisCfHj+nFWajPHs86ymgiXzTARdriAYEMngfUhzd2OiTMcolko j9AHdMEXI8Xl4MaUxbPFaIIHR0gZuiassMoggaLTldbYyBZCRSD9ScgCQgw+A6vxYV V/OXNPNNQk7qwDtPQhvKZrleF2ZtRNfVqeiqTjMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugen Hristev , Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 201/230] ARM: dts: at91: sama5d2_icp: fix eeprom compatibles Date: Mon, 11 Jul 2022 11:07:37 +0200 Message-Id: <20220711090609.807367021@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Eugen Hristev [ Upstream commit 416ce193d73a734ded6d09fe141017b38af1c567 ] The eeprom memories on the board are microchip 24aa025e48, which are 2 Kbits and are compatible with at24c02 not at24c32. Fixes: 68a95ef72cefe ("ARM: dts: at91: sama5d2-icp: add SAMA5D2-ICP") Signed-off-by: Eugen Hristev Reviewed-by: Claudiu Beznea Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220607090455.80433-2-eugen.hristev@microc= hip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/boot/dts/at91-sama5d2_icp.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/at91-sama5d2_icp.dts b/arch/arm/boot/dts/at9= 1-sama5d2_icp.dts index e06b58724ca8..fd1a288f686b 100644 --- a/arch/arm/boot/dts/at91-sama5d2_icp.dts +++ b/arch/arm/boot/dts/at91-sama5d2_icp.dts @@ -323,21 +323,21 @@ status =3D "okay"; =20 eeprom@50 { - compatible =3D "atmel,24c32"; + compatible =3D "atmel,24c02"; reg =3D <0x50>; pagesize =3D <16>; status =3D "okay"; }; =20 eeprom@52 { - compatible =3D "atmel,24c32"; + compatible =3D "atmel,24c02"; reg =3D <0x52>; pagesize =3D <16>; status =3D "disabled"; }; =20 eeprom@53 { - compatible =3D "atmel,24c32"; + compatible =3D "atmel,24c02"; reg =3D <0x53>; pagesize =3D <16>; status =3D "disabled"; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 E99FAC43334 for ; Mon, 11 Jul 2022 10:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234121AbiGKKCQ (ORCPT ); Mon, 11 Jul 2022 06:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234369AbiGKKB3 (ORCPT ); Mon, 11 Jul 2022 06:01:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24168B8E9E; Mon, 11 Jul 2022 02:28: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 8CA886136E; Mon, 11 Jul 2022 09:28:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936F8C34115; Mon, 11 Jul 2022 09:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531707; bh=J9gjBr0TQqFK/KpB6aju9Ih/fw36Qss8gW2FcaEI0Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kAtBgykUXR6gPR9lIBZ35/3un8woDyvMRyS7qk9tOUxGDm9IypagT12tirj9cDBbv saFv53xaX5ZwelyNnmOawlWv4ijYJ07gvcwqvi9TWthWExJgKLqwDtRGv3d6hedIjF 0DFTqmWOXKMnKyH6graij2ajzZXsr8nKNyj/fgtg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mihai Sain , Claudiu Beznea , Sasha Levin Subject: [PATCH 5.15 202/230] ARM: at91: fix soc detection for SAM9X60 SiPs Date: Mon, 11 Jul 2022 11:07:38 +0200 Message-Id: <20220711090609.835572698@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Mihai Sain [ Upstream commit 35074df65a8d8c5328a83e2eea948f7bbc8e6e08 ] Fix SoC detection for SAM9X60 SiPs: SAM9X60D5M SAM9X60D1G SAM9X60D6K Fixes: af3a10513cd6 ("drivers: soc: atmel: add per soc id and version match= masks") Signed-off-by: Mihai Sain Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220616081344.1978664-1-claudiu.beznea@mic= rochip.com Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/soc/atmel/soc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c index a490ad7e090f..9e3d37011447 100644 --- a/drivers/soc/atmel/soc.c +++ b/drivers/soc/atmel/soc.c @@ -91,14 +91,14 @@ static const struct at91_soc socs[] __initconst =3D { AT91_SOC(SAM9X60_CIDR_MATCH, AT91_CIDR_MATCH_MASK, AT91_CIDR_VERSION_MASK, SAM9X60_EXID_MATCH, "sam9x60", "sam9x60"), - AT91_SOC(SAM9X60_CIDR_MATCH, SAM9X60_D5M_EXID_MATCH, - AT91_CIDR_VERSION_MASK, SAM9X60_EXID_MATCH, + AT91_SOC(SAM9X60_CIDR_MATCH, AT91_CIDR_MATCH_MASK, + AT91_CIDR_VERSION_MASK, SAM9X60_D5M_EXID_MATCH, "sam9x60 64MiB DDR2 SiP", "sam9x60"), - AT91_SOC(SAM9X60_CIDR_MATCH, SAM9X60_D1G_EXID_MATCH, - AT91_CIDR_VERSION_MASK, SAM9X60_EXID_MATCH, + AT91_SOC(SAM9X60_CIDR_MATCH, AT91_CIDR_MATCH_MASK, + AT91_CIDR_VERSION_MASK, SAM9X60_D1G_EXID_MATCH, "sam9x60 128MiB DDR2 SiP", "sam9x60"), - AT91_SOC(SAM9X60_CIDR_MATCH, SAM9X60_D6K_EXID_MATCH, - AT91_CIDR_VERSION_MASK, SAM9X60_EXID_MATCH, + AT91_SOC(SAM9X60_CIDR_MATCH, AT91_CIDR_MATCH_MASK, + AT91_CIDR_VERSION_MASK, SAM9X60_D6K_EXID_MATCH, "sam9x60 8MiB SDRAM SiP", "sam9x60"), #endif #ifdef CONFIG_SOC_SAMA5 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 DDBA3CCA47B for ; Mon, 11 Jul 2022 10:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbiGKKCa (ORCPT ); Mon, 11 Jul 2022 06:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234226AbiGKKBy (ORCPT ); Mon, 11 Jul 2022 06:01:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DBF2AF; Mon, 11 Jul 2022 02:28: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 dfw.source.kernel.org (Postfix) with ESMTPS id 24F356136E; Mon, 11 Jul 2022 09:28:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F0F5C34115; Mon, 11 Jul 2022 09:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531712; bh=uHtkAaK8JZ0OMEbRWgllIsKnn+tOA3YooURssre3hfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oks0lPyIG79MGinnRJSmGDZOIuokU3lKgNjt7wvQM37xdXzZggU95P+JVEGC5hVeS o/PDrzBM9N8kScbfrljF+rwMuNPVTa1xmSqlrA2J5fYBCXmBkQji3pXtSChL7dE1Y3 6T5GBTp2GqG37H2W46OefmlQPxLzahKEI8EZ0A9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Malov , Daniel Borkmann , Magnus Karlsson , Sasha Levin Subject: [PATCH 5.15 203/230] xsk: Clear page contiguity bit when unmapping pool Date: Mon, 11 Jul 2022 11:07:39 +0200 Message-Id: <20220711090609.863252807@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Ivan Malov [ Upstream commit 512d1999b8e94a5d43fba3afc73e774849674742 ] When a XSK pool gets mapped, xp_check_dma_contiguity() adds bit 0x1 to pages' DMA addresses that go in ascending order and at 4K stride. The problem is that the bit does not get cleared before doing unmap. As a result, a lot of warnings from iommu_dma_unmap_page() are seen in dmesg, which indicates that lookups by iommu_iova_to_phys() fail. Fixes: 2b43470add8c ("xsk: Introduce AF_XDP buffer allocation API") Signed-off-by: Ivan Malov Signed-off-by: Daniel Borkmann Acked-by: Magnus Karlsson Link: https://lore.kernel.org/bpf/20220628091848.534803-1-ivan.malov@oktetl= abs.ru Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- net/xdp/xsk_buff_pool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c index fc7fbfc1e586..ccedbbd27692 100644 --- a/net/xdp/xsk_buff_pool.c +++ b/net/xdp/xsk_buff_pool.c @@ -326,6 +326,7 @@ static void __xp_dma_unmap(struct xsk_dma_map *dma_map,= unsigned long attrs) for (i =3D 0; i < dma_map->dma_pages_cnt; i++) { dma =3D &dma_map->dma_pages[i]; if (*dma) { + *dma &=3D ~XSK_NEXT_PG_CONTIG_MASK; dma_unmap_page_attrs(dma_map->dev, *dma, PAGE_SIZE, DMA_BIDIRECTIONAL, attrs); *dma =3D 0; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 78A9CC433EF for ; Mon, 11 Jul 2022 10:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234173AbiGKKCp (ORCPT ); Mon, 11 Jul 2022 06:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234336AbiGKKCG (ORCPT ); Mon, 11 Jul 2022 06:02:06 -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 042C12BDB; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id 8FDEBB80E6D; Mon, 11 Jul 2022 09:28:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E050AC34115; Mon, 11 Jul 2022 09:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531715; bh=vWqdF/QbE599LGS+3jp14cUHjUuyTGGqsN3uKJFlhX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BISEjTt7U6nHgeyNI7YOqNU9uatGFXTU+YMNVFgSwgQf+4mPzqZCK9KcGWqbqobGg +m+m9fbW29EOQmv7BDijLdI1Q2mer7ls/SpCHckMfz1g/wji7/MRgc5GQIfGNnBW66 dL79/4BdW4f4uQGVz+2QJKGxM8HPyw/WbmQyfeaQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jean Delvare , Yi Zhang , Terry Bowman , Terry Bowman , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 204/230] i2c: piix4: Fix a memory leak in the EFCH MMIO support Date: Mon, 11 Jul 2022 11:07:40 +0200 Message-Id: <20220711090609.891213114@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Jean Delvare [ Upstream commit 8ad59b397f86a4d8014966fdc0552095a0c4fb2b ] The recently added support for EFCH MMIO regions introduced a memory leak in that code path. The leak is caused by the fact that release_resource() merely removes the resource from the tree but does not free its memory. We need to call release_mem_region() instead, which does free the memory. As a nice side effect, this brings back some symmetry between the legacy and MMIO paths. Signed-off-by: Jean Delvare Reported-by: Yi Zhang Tested-by: Yi Zhang Reviewed-by: Terry Bowman Tested-by: Terry Bowman Fixes: 7c148722d074 ("i2c: piix4: Add EFCH MMIO support to region request a= nd release") Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/i2c/busses/i2c-piix4.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index ac8e7d60672a..39cb1b7bb865 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -161,7 +161,6 @@ static const char *piix4_aux_port_name_sb800 =3D " port= 1"; =20 struct sb800_mmio_cfg { void __iomem *addr; - struct resource *res; bool use_mmio; }; =20 @@ -179,13 +178,11 @@ static int piix4_sb800_region_request(struct device *= dev, struct sb800_mmio_cfg *mmio_cfg) { if (mmio_cfg->use_mmio) { - struct resource *res; void __iomem *addr; =20 - res =3D request_mem_region_muxed(SB800_PIIX4_FCH_PM_ADDR, - SB800_PIIX4_FCH_PM_SIZE, - "sb800_piix4_smb"); - if (!res) { + if (!request_mem_region_muxed(SB800_PIIX4_FCH_PM_ADDR, + SB800_PIIX4_FCH_PM_SIZE, + "sb800_piix4_smb")) { dev_err(dev, "SMBus base address memory region 0x%x already in use.\n", SB800_PIIX4_FCH_PM_ADDR); @@ -195,12 +192,12 @@ static int piix4_sb800_region_request(struct device *= dev, addr =3D ioremap(SB800_PIIX4_FCH_PM_ADDR, SB800_PIIX4_FCH_PM_SIZE); if (!addr) { - release_resource(res); + release_mem_region(SB800_PIIX4_FCH_PM_ADDR, + SB800_PIIX4_FCH_PM_SIZE); dev_err(dev, "SMBus base address mapping failed.\n"); return -ENOMEM; } =20 - mmio_cfg->res =3D res; mmio_cfg->addr =3D addr; =20 return 0; @@ -222,7 +219,8 @@ static void piix4_sb800_region_release(struct device *d= ev, { if (mmio_cfg->use_mmio) { iounmap(mmio_cfg->addr); - release_resource(mmio_cfg->res); + release_mem_region(SB800_PIIX4_FCH_PM_ADDR, + SB800_PIIX4_FCH_PM_SIZE); return; } =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 B7439C43334 for ; Mon, 11 Jul 2022 10:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234469AbiGKKCr (ORCPT ); Mon, 11 Jul 2022 06:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbiGKKCV (ORCPT ); Mon, 11 Jul 2022 06:02:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA9422602; Mon, 11 Jul 2022 02:28:40 -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 4BE86B80E7E; Mon, 11 Jul 2022 09:28:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3B76C34115; Mon, 11 Jul 2022 09:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531718; bh=tQ/y6cIUUAenbZxTo2XXuVWy7dH1VpP2+QnoGUYXgUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwxxN8poqrUwsGqOgHoZUXmI3wdyxA3RUwVcY7sTl8wKquKdtSzXewHtY3lHXxTlf rIooSzf12SHWJdXygm3dEr0am42Ttn3l75lDiTTFYYCN1gB4Gaxlu729DuoG/1ngRZ l+S8lqP16xSTuyQIswPGcAn3g41eMqRcCu7PmRXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukasz Cieplicki , Jedrzej Jagielski , Tony Nguyen , Sasha Levin , Gurucharan Subject: [PATCH 5.15 205/230] i40e: Fix dropped jumbo frames statistics Date: Mon, 11 Jul 2022 11:07:41 +0200 Message-Id: <20220711090609.919394511@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Lukasz Cieplicki [ Upstream commit 1adb1563e7b7ec659379a18e607e8bc3522d8a78 ] Dropped packets caused by too large frames were not included in dropped RX packets statistics. Issue was caused by not reading the GL_RXERR1 register. That register stores count of packet which was have been dropped due to too large size. Fix it by reading GL_RXERR1 register for each interface. Repro steps: Send a packet larger than the set MTU to SUT Observe rx statists: ethtool -S | grep rx | grep -v ": 0" Fixes: 41a9e55c89be ("i40e: add missing VSI statistics") Signed-off-by: Lukasz Cieplicki Signed-off-by: Jedrzej Jagielski Tested-by: Gurucharan (A Contingent worker at Int= el) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/intel/i40e/i40e.h | 16 ++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 73 +++++++++++++++++++ .../net/ethernet/intel/i40e/i40e_register.h | 13 ++++ drivers/net/ethernet/intel/i40e/i40e_type.h | 1 + 4 files changed, 103 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/= intel/i40e/i40e.h index 56a3a6d1dbe4..210f09118ede 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "i40e_type.h" #include "i40e_prototype.h" #include @@ -1087,6 +1088,21 @@ static inline void i40e_write_fd_input_set(struct i4= 0e_pf *pf, (u32)(val & 0xFFFFFFFFULL)); } =20 +/** + * i40e_get_pf_count - get PCI PF count. + * @hw: pointer to a hw. + * + * Reports the function number of the highest PCI physical + * function plus 1 as it is loaded from the NVM. + * + * Return: PCI PF count. + **/ +static inline u32 i40e_get_pf_count(struct i40e_hw *hw) +{ + return FIELD_GET(I40E_GLGEN_PCIFCNCNT_PCIPFCNT_MASK, + rd32(hw, I40E_GLGEN_PCIFCNCNT)); +} + /* needed by i40e_ethtool.c */ int i40e_up(struct i40e_vsi *vsi); void i40e_down(struct i40e_vsi *vsi); diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethe= rnet/intel/i40e/i40e_main.c index 9bc05d671ad5..02594e4d6258 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -549,6 +549,47 @@ void i40e_pf_reset_stats(struct i40e_pf *pf) pf->hw_csum_rx_error =3D 0; } =20 +/** + * i40e_compute_pci_to_hw_id - compute index form PCI function. + * @vsi: ptr to the VSI to read from. + * @hw: ptr to the hardware info. + **/ +static u32 i40e_compute_pci_to_hw_id(struct i40e_vsi *vsi, struct i40e_hw = *hw) +{ + int pf_count =3D i40e_get_pf_count(hw); + + if (vsi->type =3D=3D I40E_VSI_SRIOV) + return (hw->port * BIT(7)) / pf_count + vsi->vf_id; + + return hw->port + BIT(7); +} + +/** + * i40e_stat_update64 - read and update a 64 bit stat from the chip. + * @hw: ptr to the hardware info. + * @hireg: the high 32 bit reg to read. + * @loreg: the low 32 bit reg to read. + * @offset_loaded: has the initial offset been loaded yet. + * @offset: ptr to current offset value. + * @stat: ptr to the stat. + * + * Since the device stats are not reset at PFReset, they will not + * be zeroed when the driver starts. We'll save the first values read + * and use them as offsets to be subtracted from the raw values in order + * to report stats that count from zero. + **/ +static void i40e_stat_update64(struct i40e_hw *hw, u32 hireg, u32 loreg, + bool offset_loaded, u64 *offset, u64 *stat) +{ + u64 new_data; + + new_data =3D rd64(hw, loreg); + + if (!offset_loaded || new_data < *offset) + *offset =3D new_data; + *stat =3D new_data - *offset; +} + /** * i40e_stat_update48 - read and update a 48 bit stat from the chip * @hw: ptr to the hardware info @@ -620,6 +661,34 @@ static void i40e_stat_update_and_clear32(struct i40e_h= w *hw, u32 reg, u64 *stat) *stat +=3D new_data; } =20 +/** + * i40e_stats_update_rx_discards - update rx_discards. + * @vsi: ptr to the VSI to be updated. + * @hw: ptr to the hardware info. + * @stat_idx: VSI's stat_counter_idx. + * @offset_loaded: ptr to the VSI's stat_offsets_loaded. + * @stat_offset: ptr to stat_offset to store first read of specific regist= er. + * @stat: ptr to VSI's stat to be updated. + **/ +static void +i40e_stats_update_rx_discards(struct i40e_vsi *vsi, struct i40e_hw *hw, + int stat_idx, bool offset_loaded, + struct i40e_eth_stats *stat_offset, + struct i40e_eth_stats *stat) +{ + u64 rx_rdpc, rx_rxerr; + + i40e_stat_update32(hw, I40E_GLV_RDPC(stat_idx), offset_loaded, + &stat_offset->rx_discards, &rx_rdpc); + i40e_stat_update64(hw, + I40E_GL_RXERR1H(i40e_compute_pci_to_hw_id(vsi, hw)), + I40E_GL_RXERR1L(i40e_compute_pci_to_hw_id(vsi, hw)), + offset_loaded, &stat_offset->rx_discards_other, + &rx_rxerr); + + stat->rx_discards =3D rx_rdpc + rx_rxerr; +} + /** * i40e_update_eth_stats - Update VSI-specific ethernet statistics counter= s. * @vsi: the VSI to be updated @@ -679,6 +748,10 @@ void i40e_update_eth_stats(struct i40e_vsi *vsi) I40E_GLV_BPTCL(stat_idx), vsi->stat_offsets_loaded, &oes->tx_broadcast, &es->tx_broadcast); + + i40e_stats_update_rx_discards(vsi, hw, stat_idx, + vsi->stat_offsets_loaded, oes, es); + vsi->stat_offsets_loaded =3D true; } =20 diff --git a/drivers/net/ethernet/intel/i40e/i40e_register.h b/drivers/net/= ethernet/intel/i40e/i40e_register.h index 1908eed4fa5e..7339003aa17c 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_register.h +++ b/drivers/net/ethernet/intel/i40e/i40e_register.h @@ -211,6 +211,11 @@ #define I40E_GLGEN_MSRWD_MDIWRDATA_SHIFT 0 #define I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT 16 #define I40E_GLGEN_MSRWD_MDIRDDATA_MASK I40E_MASK(0xFFFF, I40E_GLGEN_MSRWD= _MDIRDDATA_SHIFT) +#define I40E_GLGEN_PCIFCNCNT 0x001C0AB4 /* Reset: PCIR */ +#define I40E_GLGEN_PCIFCNCNT_PCIPFCNT_SHIFT 0 +#define I40E_GLGEN_PCIFCNCNT_PCIPFCNT_MASK I40E_MASK(0x1F, I40E_GLGEN_PCI= FCNCNT_PCIPFCNT_SHIFT) +#define I40E_GLGEN_PCIFCNCNT_PCIVFCNT_SHIFT 16 +#define I40E_GLGEN_PCIFCNCNT_PCIVFCNT_MASK I40E_MASK(0xFF, I40E_GLGEN_PCI= FCNCNT_PCIVFCNT_SHIFT) #define I40E_GLGEN_RSTAT 0x000B8188 /* Reset: POR */ #define I40E_GLGEN_RSTAT_DEVSTATE_SHIFT 0 #define I40E_GLGEN_RSTAT_DEVSTATE_MASK I40E_MASK(0x3, I40E_GLGEN_RSTAT_DEV= STATE_SHIFT) @@ -643,6 +648,14 @@ #define I40E_VFQF_HKEY1_MAX_INDEX 12 #define I40E_VFQF_HLUT1(_i, _VF) (0x00220000 + ((_i) * 1024 + (_VF) * 4)) = /* _i=3D0...15, _VF=3D0...127 */ /* Reset: CORER */ #define I40E_VFQF_HLUT1_MAX_INDEX 15 +#define I40E_GL_RXERR1H(_i) (0x00318004 + ((_i) * 8)) /* _i=3D= 0...143 */ /* Reset: CORER */ +#define I40E_GL_RXERR1H_MAX_INDEX 143 +#define I40E_GL_RXERR1H_RXERR1H_SHIFT 0 +#define I40E_GL_RXERR1H_RXERR1H_MASK I40E_MASK(0xFFFFFFFF, I40E_GL_RXER= R1H_RXERR1H_SHIFT) +#define I40E_GL_RXERR1L(_i) (0x00318000 + ((_i) * 8)) /* _i=3D= 0...143 */ /* Reset: CORER */ +#define I40E_GL_RXERR1L_MAX_INDEX 143 +#define I40E_GL_RXERR1L_RXERR1L_SHIFT 0 +#define I40E_GL_RXERR1L_RXERR1L_MASK I40E_MASK(0xFFFFFFFF, I40E_GL_RXER= R1L_RXERR1L_SHIFT) #define I40E_GLPRT_BPRCH(_i) (0x003005E4 + ((_i) * 8)) /* _i=3D0...3 */ /*= Reset: CORER */ #define I40E_GLPRT_BPRCL(_i) (0x003005E0 + ((_i) * 8)) /* _i=3D0...3 */ /*= Reset: CORER */ #define I40E_GLPRT_BPTCH(_i) (0x00300A04 + ((_i) * 8)) /* _i=3D0...3 */ /*= Reset: CORER */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethe= rnet/intel/i40e/i40e_type.h index 36a4ca1ffb1a..7b3f30beb757 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_type.h +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h @@ -1172,6 +1172,7 @@ struct i40e_eth_stats { u64 tx_broadcast; /* bptc */ u64 tx_discards; /* tdpc */ u64 tx_errors; /* tepc */ + u64 rx_discards_other; /* rxerr1 */ }; =20 /* Statistics collected per VEB per TC */ --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 6A9D0C43334 for ; Mon, 11 Jul 2022 10:02:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbiGKKC5 (ORCPT ); Mon, 11 Jul 2022 06:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234454AbiGKKCY (ORCPT ); Mon, 11 Jul 2022 06:02:24 -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 680529593; Mon, 11 Jul 2022 02:28:43 -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 F20AAB80E6D; Mon, 11 Jul 2022 09:28:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E045C34115; Mon, 11 Jul 2022 09:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531720; bh=USo+M3DHAhHc2pbi1o05Z2x2BwKbfW9LYqYjyf340dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yqs249eQu6FiIRg0Yhok7F8tSTNPRVNf8Gy/PnVKnQrFRgEJ9sHiuA+cyVghsLmp4 awc7Uj7sB5JQTZUQobzB4QMWKhmmUxGKUouVVw0vERRJxG6aBWpRWU9myh6Q3WgOC6 gHl6i6n6yc4pHBqhKKeyoXf/C0CL9uqOzyGctWtQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Norbert Zulinski , Jan Sokolowski , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 206/230] i40e: Fix VFs MAC Address change on VM Date: Mon, 11 Jul 2022 11:07:42 +0200 Message-Id: <20220711090609.948014233@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Norbert Zulinski [ Upstream commit fed0d9f13266a22ce1fc9a97521ef9cdc6271a23 ] Clear VF MAC from parent PF and remove VF filter from VSI when both conditions are true: -VIRTCHNL_VF_OFFLOAD_USO is not used -VM MAC was not set from PF level It affects older version of IAVF and it allow them to change MAC Address on VM, newer IAVF won't change their behaviour. Previously it wasn't possible to change VF's MAC Address on VM because there is flag on IAVF driver that won't allow to change MAC Address if this address is given from PF driver. Fixes: 155f0ac2c96b ("iavf: allow permanent MAC address to change") Signed-off-by: Norbert Zulinski Signed-off-by: Jan Sokolowski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/n= et/ethernet/intel/i40e/i40e_virtchnl_pf.c index 6c1e668f4ebf..d78ac5e7f658 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -2147,6 +2147,10 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_= vf *vf, u8 *msg) /* VFs only use TC 0 */ vfres->vsi_res[0].qset_handle =3D le16_to_cpu(vsi->info.qs_handle[0]); + if (!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_USO) && !vf->pf_set_mac) { + i40e_del_mac_filter(vsi, vf->default_lan_addr.addr); + eth_zero_addr(vf->default_lan_addr.addr); + } ether_addr_copy(vfres->vsi_res[0].default_mac_addr, vf->default_lan_addr.addr); } --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 DBD07C433EF for ; Mon, 11 Jul 2022 10:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbiGKKDC (ORCPT ); Mon, 11 Jul 2022 06:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234455AbiGKKCY (ORCPT ); Mon, 11 Jul 2022 06:02: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 CC973B7D7; Mon, 11 Jul 2022 02:28: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 dfw.source.kernel.org (Postfix) with ESMTPS id 05ABF612E8; Mon, 11 Jul 2022 09:28:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14485C34115; Mon, 11 Jul 2022 09:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531723; bh=hd3BvXFtrDlYs7GBArIMajBN6rCnoaaFqeDLoOJf8pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c45vFQ16/U6zNSG0VAzN/tfQX+gexhb05fPQKEtqGm9kPfFoaU/tdwtXWzxWNF54L csJqRPT+xt19lnNt+4nezszcOHjIcxuPgM45cfeZgmeT+X2qxL3bwQnczfrCNqb01A dY2xJ5l+G1Zxu9TVfTfVIx6InCU0uKE4Wz25hqO0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amelie Delaunay , Alexandre Torgue , Sasha Levin Subject: [PATCH 5.15 207/230] ARM: dts: stm32: use usbphyc ck_usbo_48m as USBH OHCI clock on stm32mp151 Date: Mon, 11 Jul 2022 11:07:43 +0200 Message-Id: <20220711090609.975961001@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Amelie Delaunay [ Upstream commit db7be2cb87ae65e2d033a9f61f7fb94bce505177 ] Referring to the note under USBH reset and clocks chapter of RM0436, "In order to access USBH_OHCI registers it is necessary to activate the USB clocks by enabling the PLL controlled by USBPHYC" (ck_usbo_48m). The point is, when USBPHYC PLL is not enabled, OHCI register access freezes the resume from STANDBY. It is the case when dual USBH is enabled, instead of OTG + single USBH. When OTG is probed, as ck_usbo_48m is USBO clock parent, then USBPHYC PLL is enabled and OHCI register access is OK. This patch adds ck_usbo_48m (provided by USBPHYC PLL) as clock of USBH OHCI, thus USBPHYC PLL will be enabled and OHCI register access will be OK. Signed-off-by: Amelie Delaunay Signed-off-by: Alexandre Torgue Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/boot/dts/stm32mp151.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/stm32mp151.dtsi b/arch/arm/boot/dts/stm32mp1= 51.dtsi index 6992a4b0ba79..f693a7d24247 100644 --- a/arch/arm/boot/dts/stm32mp151.dtsi +++ b/arch/arm/boot/dts/stm32mp151.dtsi @@ -1452,7 +1452,7 @@ usbh_ohci: usb@5800c000 { compatible =3D "generic-ohci"; reg =3D <0x5800c000 0x1000>; - clocks =3D <&rcc USBH>; + clocks =3D <&rcc USBH>, <&usbphyc>; resets =3D <&rcc USBH_R>; interrupts =3D ; status =3D "disabled"; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 AEC14C43334 for ; Mon, 11 Jul 2022 10:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234422AbiGKKDJ (ORCPT ); Mon, 11 Jul 2022 06:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbiGKKC1 (ORCPT ); Mon, 11 Jul 2022 06:02:27 -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 5AE2E260F; Mon, 11 Jul 2022 02:28: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 dfw.source.kernel.org (Postfix) with ESMTPS id C78FD612E8; Mon, 11 Jul 2022 09:28:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49D0C34115; Mon, 11 Jul 2022 09:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531726; bh=W330BuO/QgEK9onhs732Q0+O+61gx2NMWC+q5/3nn3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxDXCl7YQuiwepOb7EgmnWmNvUmTWjhKsFcCDHM9Cuvil+tjZcbDhBEaeqVR2DTfK 2d0+XbMs2YPacoqXsUCKJoIbHJ+lCpY97/Da8K7BX6Neh35suJ82neftrvm4SwMrb/ Kj5osqQLeDPQYAH4t5fwcIBjAAsHFA4p7vc0Q3nI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabrice Gasnier , Alexandre Torgue , Sasha Levin Subject: [PATCH 5.15 208/230] ARM: dts: stm32: add missing usbh clock and fix clk order on stm32mp15 Date: Mon, 11 Jul 2022 11:07:44 +0200 Message-Id: <20220711090610.004779852@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Fabrice Gasnier [ Upstream commit 1d0c1aadf1fd9f3de95d1532b3651e8634546e71 ] The USBH composed of EHCI and OHCI controllers needs the PHY clock to be initialized first, before enabling (gating) them. The reverse is also required when going to suspend. So, add USBPHY clock as 1st entry in both controllers, so the USBPHY PLL gets enabled 1st upon controller init. Upon suspend/resume, this also makes the clock to be disabled/re-enabled in the correct order. This fixes some IRQ storm conditions seen when going to low-power, due to PHY PLL being disabled before all clocks are cleanly gated. Fixes: 949a0c0dec85 ("ARM: dts: stm32: add USB Host (USBH) support to stm32= mp157c") Fixes: db7be2cb87ae ("ARM: dts: stm32: use usbphyc ck_usbo_48m as USBH OHCI= clock on stm32mp151") Signed-off-by: Fabrice Gasnier Signed-off-by: Alexandre Torgue Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- arch/arm/boot/dts/stm32mp151.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/stm32mp151.dtsi b/arch/arm/boot/dts/stm32mp1= 51.dtsi index f693a7d24247..a9b65b3bfda5 100644 --- a/arch/arm/boot/dts/stm32mp151.dtsi +++ b/arch/arm/boot/dts/stm32mp151.dtsi @@ -1452,7 +1452,7 @@ usbh_ohci: usb@5800c000 { compatible =3D "generic-ohci"; reg =3D <0x5800c000 0x1000>; - clocks =3D <&rcc USBH>, <&usbphyc>; + clocks =3D <&usbphyc>, <&rcc USBH>; resets =3D <&rcc USBH_R>; interrupts =3D ; status =3D "disabled"; @@ -1461,7 +1461,7 @@ usbh_ehci: usb@5800d000 { compatible =3D "generic-ehci"; reg =3D <0x5800d000 0x1000>; - clocks =3D <&rcc USBH>; + clocks =3D <&usbphyc>, <&rcc USBH>; resets =3D <&rcc USBH_R>; interrupts =3D ; companion =3D <&usbh_ohci>; --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 1CF7ACCA47B for ; Mon, 11 Jul 2022 10:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbiGKKDQ (ORCPT ); Mon, 11 Jul 2022 06:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234416AbiGKKCa (ORCPT ); Mon, 11 Jul 2022 06:02: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 01DC91B794; Mon, 11 Jul 2022 02:28:50 -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 95F2461366; Mon, 11 Jul 2022 09:28:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A3F2C34115; Mon, 11 Jul 2022 09:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531729; bh=PADmlo9O/8tn5m9t7EE44DUsKNUB7YYvd7Vr1vib+qY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdMeJQA6W0Vncvf5M4PTmQuI5Sz87TIzNdJQj1ZK/Dxquzuo+/wJneeM6BpE0t7LD WK0ThgbCStnoqX7ASF/Z0ZiOfY66SPXbPUIxQRxSx8nHSZAi2jZvmAINBVIVwbekWy B/BgND91xCHU4tHAo2unmekls1VJTYdeQkApxKwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Child , Brian King , Rick Lindsley , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 209/230] ibmvnic: Properly dispose of all skbs during a failover. Date: Mon, 11 Jul 2022 11:07:45 +0200 Message-Id: <20220711090610.032788549@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Rick Lindsley [ Upstream commit 1b18f09d31cfa7148df15a7d5c5e0e86f105f7d1 ] During a reset, there may have been transmits in flight that are no longer valid and cannot be fulfilled. Resetting and clearing the queues is insufficient; each skb also needs to be explicitly freed so that upper levels are not left waiting for confirmation of a transmit that will never happen. If this happens frequently enough, the apparent backlog will cause TCP to begin "congestion control" unnecessarily, culminating in permanently decreased throughput. Fixes: d7c0ef36bde03 ("ibmvnic: Free and re-allocate scrqs when tx/rx scrqs= change") Tested-by: Nick Child Reviewed-by: Brian King Signed-off-by: Rick Lindsley Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/ibm/ibmvnic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index 28344c3dfea1..4a070724a8fb 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5585,6 +5585,15 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter= *adapter, bool reset) release_sub_crqs(adapter, 0); rc =3D init_sub_crqs(adapter); } else { + /* no need to reinitialize completely, but we do + * need to clean up transmits that were in flight + * when we processed the reset. Failure to do so + * will confound the upper layer, usually TCP, by + * creating the illusion of transmits that are + * awaiting completion. + */ + clean_tx_pools(adapter); + rc =3D reset_sub_crq_queues(adapter); } } else { --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 CD80AC433EF for ; Mon, 11 Jul 2022 10:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbiGKKDR (ORCPT ); Mon, 11 Jul 2022 06:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234225AbiGKKCi (ORCPT ); Mon, 11 Jul 2022 06:02:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD93322BE8; Mon, 11 Jul 2022 02:28: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 4EA536140C; Mon, 11 Jul 2022 09:28:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57ECDC34115; Mon, 11 Jul 2022 09:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531731; bh=9Rl/IJpVZJsRv5g1izN06w6Q5uHipioH/PgUA/9atJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hL3vCSfvACKq0XP6sROZWbctLgFIPqaietOhPLCDsmdXkII5ap+3suPeu+Y3sfwSc D45S+OYcA2G+NsWDi0WlSu3cvBwTuvKGjdG1uFBIMysUiqfdM4+zywB7gvkGXYRCkR LWFsYjB6XTo+Hyd9mgEW1myPHk5A7nXFmrW46Jsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 210/230] selftests: forwarding: fix flood_unicast_test when h2 supports IFF_UNICAST_FLT Date: Mon, 11 Jul 2022 11:07:46 +0200 Message-Id: <20220711090610.060546738@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 b8e629b05f5d23f9649c901bef09fab8b0c2e4b9 ] As mentioned in the blamed commit, flood_unicast_test() works by checking the match count on a tc filter placed on the receiving interface. But the second host interface (host2_if) has no interest in receiving a packet with MAC DA de:ad:be:ef:13:37, so its RX filter drops it even before the ingress tc filter gets to be executed. So we will incorrectly get the message "Packet was not flooded when should", when in fact, the packet was flooded as expected but dropped due to an unrelated reason, at some other layer on the receiving side. Force h2 to accept this packet by temporarily placing it in promiscuous mode. Alternatively we could either deliver to its MAC address or use tcpdump_start, but this has the fewest complications. This fixes the "flooding" test from bridge_vlan_aware.sh and bridge_vlan_unaware.sh, which calls flood_test from the lib. Fixes: 236dd50bf67a ("selftests: forwarding: Add a test for flooded traffic= ") Signed-off-by: Vladimir Oltean Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- tools/testing/selftests/net/forwarding/lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/= selftests/net/forwarding/lib.sh index 92087d423bcf..8a9c55fe841a 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1215,6 +1215,7 @@ flood_test_do() =20 # Add an ACL on `host2_if` which will tell us whether the packet # was flooded to it or not. + ip link set $host2_if promisc on tc qdisc add dev $host2_if ingress tc filter add dev $host2_if ingress protocol ip pref 1 handle 101 \ flower dst_mac $mac action drop @@ -1232,6 +1233,7 @@ flood_test_do() =20 tc filter del dev $host2_if ingress protocol ip pref 1 handle 101 flower tc qdisc del dev $host2_if ingress + ip link set $host2_if promisc off =20 return $err } --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 060DEC43334 for ; Mon, 11 Jul 2022 10:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234470AbiGKKDk (ORCPT ); Mon, 11 Jul 2022 06:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbiGKKCy (ORCPT ); Mon, 11 Jul 2022 06:02:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301165C9C8; Mon, 11 Jul 2022 02:28: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 ams.source.kernel.org (Postfix) with ESMTPS id BE39BB80E88; Mon, 11 Jul 2022 09:28:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10884C34115; Mon, 11 Jul 2022 09:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531734; bh=Tusqk7Lmxx7rh/jamATplaHs7GoHvwB/yxhV6tXDDpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wSb9rBYYZCja/7xNC38W/ZDsFFm/858YLJePFOL26atYUIwuKo+BOknD8n8UtN0Dd IMsJP0AJfdBWyOXuQLYAJgRIgLAhuuYovE4q6e18LGDXkBkBhFe96LVlDRI/yZcmEE FZr4ov1r4Qwy2yLNr2/S0HEKKAvNQn94yHKpPi9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 211/230] selftests: forwarding: fix learning_test when h1 supports IFF_UNICAST_FLT Date: Mon, 11 Jul 2022 11:07:47 +0200 Message-Id: <20220711090610.089221940@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 1a635d3e1c80626237fdae47a5545b6655d8d81c ] The first host interface has by default no interest in receiving packets MAC DA de:ad:be:ef:13:37, so it might drop them before they hit the tc filter and this might confuse the selftest. Enable promiscuous mode such that the filter properly counts received packets. Fixes: d4deb01467ec ("selftests: forwarding: Add a test for FDB learning") Signed-off-by: Vladimir Oltean Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- tools/testing/selftests/net/forwarding/lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/= selftests/net/forwarding/lib.sh index 8a9c55fe841a..0db6ea8d7e05 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1149,6 +1149,7 @@ learning_test() # FDB entry was installed. bridge link set dev $br_port1 flood off =20 + ip link set $host1_if promisc on tc qdisc add dev $host1_if ingress tc filter add dev $host1_if ingress protocol ip pref 1 handle 101 \ flower dst_mac $mac action drop @@ -1198,6 +1199,7 @@ learning_test() =20 tc filter del dev $host1_if ingress protocol ip pref 1 handle 101 flower tc qdisc del dev $host1_if ingress + ip link set $host1_if promisc off =20 bridge link set dev $br_port1 flood on =20 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 4EABACCA480 for ; Mon, 11 Jul 2022 10:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbiGKKDf (ORCPT ); Mon, 11 Jul 2022 06:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234468AbiGKKCr (ORCPT ); Mon, 11 Jul 2022 06:02:47 -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 30D9D64E39; Mon, 11 Jul 2022 02:28: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 AB58561366; Mon, 11 Jul 2022 09:28:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6896C34115; Mon, 11 Jul 2022 09:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531737; bh=nRZ2ev52J18zqlSet3uQyM6CKCgYTI5uU0dUwqorEtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uzZ+09J67zVOrwS9GMYgY1ou+obXJ2FP78aYBoyhGZhRV/XYHOtqTKcRM2hpV+ezI 5Z8fbLVbomEFCFCAqITEuZVqOOz6cp7g08KVJg9N/7UX3knIWBAfkf/h94gJdebby1 QcmgORfiL8ffia+F6I5xw/PwaPxEloQxbjaynlfA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 212/230] selftests: forwarding: fix error message in learning_test Date: Mon, 11 Jul 2022 11:07:48 +0200 Message-Id: <20220711090610.116942090@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 83844aacab2015da1dba1df0cc61fc4b4c4e8076 ] When packets are not received, they aren't received on $host1_if, so the message talking about the second host not receiving them is incorrect. Fix it. Fixes: d4deb01467ec ("selftests: forwarding: Add a test for FDB learning") Signed-off-by: Vladimir Oltean Reviewed-by: Ido Schimmel Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- tools/testing/selftests/net/forwarding/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/= selftests/net/forwarding/lib.sh index 0db6ea8d7e05..c9507df9c05b 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1160,7 +1160,7 @@ learning_test() tc -j -s filter show dev $host1_if ingress \ | jq -e ".[] | select(.options.handle =3D=3D 101) \ | select(.options.actions[0].stats.packets =3D=3D 1)" &> /dev/null - check_fail $? "Packet reached second host when should not" + check_fail $? "Packet reached first host when should not" =20 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q sleep 1 --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 C40CBC433EF for ; Mon, 11 Jul 2022 10:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234412AbiGKKDr (ORCPT ); Mon, 11 Jul 2022 06:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234486AbiGKKC7 (ORCPT ); Mon, 11 Jul 2022 06:02:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B884165D79; Mon, 11 Jul 2022 02:29: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 07A8CB80D2C; Mon, 11 Jul 2022 09:29:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49A5EC34115; Mon, 11 Jul 2022 09:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531742; bh=6IuiY1HugTIx1SU5L9n82AdNrldTGSqKut4Yoswi2KI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GH4ZEyVfO+XDDPxLduuP0fwLE//sEosvDzda0GlXrv5GGQl2a+hdlsUpqO/30adBy RB/4SntwdQBFutZqkIIpWzG7zcOvftP8rdgWpJEogVyiGNoKYk0OfiSW3iKlncr59V r/4UiuHaquJennfMXXygIcSdoTE0t1fzbm7/ZSdE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Erhard F." , Heiner Kallweit , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 213/230] r8169: fix accessing unset transport header Date: Mon, 11 Jul 2022 11:07:49 +0200 Message-Id: <20220711090610.144898907@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Heiner Kallweit [ Upstream commit faa4e04e5e140a6d02260289a8fba8fd8d7a3003 ] 66e4c8d95008 ("net: warn if transport header was not set") added a check that triggers a warning in r8169, see [0]. The commit referenced in the Fixes tag refers to the change from which the patch applies cleanly, there's nothing wrong with this commit. It seems the actual issue (not bug, because the warning is harmless here) was introduced with bdfa4ed68187 ("r8169: use Giant Send"). [0] https://bugzilla.kernel.org/show_bug.cgi?id=3D216157 Fixes: 8d520b4de3ed ("r8169: work around RTL8125 UDP hw bug") Reported-by: Erhard F. Tested-by: Erhard F. Signed-off-by: Heiner Kallweit Link: https://lore.kernel.org/r/1b2c2b29-3dc0-f7b6-5694-97ec526d51a0@gmail.= com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/net/ethernet/realtek/r8169_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethern= et/realtek/r8169_main.c index 2918947dd57c..2af4c76bcf02 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4177,7 +4177,6 @@ static void rtl8169_tso_csum_v1(struct sk_buff *skb, = u32 *opts) static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp, struct sk_buff *skb, u32 *opts) { - u32 transport_offset =3D (u32)skb_transport_offset(skb); struct skb_shared_info *shinfo =3D skb_shinfo(skb); u32 mss =3D shinfo->gso_size; =20 @@ -4194,7 +4193,7 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_privat= e *tp, WARN_ON_ONCE(1); } =20 - opts[0] |=3D transport_offset << GTTCPHO_SHIFT; + opts[0] |=3D skb_transport_offset(skb) << GTTCPHO_SHIFT; opts[1] |=3D mss << TD1_MSS_SHIFT; } else if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { u8 ip_protocol; @@ -4222,7 +4221,7 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_privat= e *tp, else WARN_ON_ONCE(1); =20 - opts[1] |=3D transport_offset << TCPHO_SHIFT; + opts[1] |=3D skb_transport_offset(skb) << TCPHO_SHIFT; } else { unsigned int padto =3D rtl_quirk_packet_padto(tp, skb); =20 @@ -4389,14 +4388,13 @@ static netdev_features_t rtl8169_features_check(str= uct sk_buff *skb, struct net_device *dev, netdev_features_t features) { - int transport_offset =3D skb_transport_offset(skb); struct rtl8169_private *tp =3D netdev_priv(dev); =20 if (skb_is_gso(skb)) { if (tp->mac_version =3D=3D RTL_GIGA_MAC_VER_34) features =3D rtl8168evl_fix_tso(skb, features); =20 - if (transport_offset > GTTCPHO_MAX && + if (skb_transport_offset(skb) > GTTCPHO_MAX && rtl_chip_supports_csum_v2(tp)) features &=3D ~NETIF_F_ALL_TSO; } else if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { @@ -4407,7 +4405,7 @@ static netdev_features_t rtl8169_features_check(struc= t sk_buff *skb, if (rtl_quirk_packet_padto(tp, skb)) features &=3D ~NETIF_F_CSUM_MASK; =20 - if (transport_offset > TCPHO_MAX && + if (skb_transport_offset(skb) > TCPHO_MAX && rtl_chip_supports_csum_v2(tp)) features &=3D ~NETIF_F_CSUM_MASK; } --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 C86C0C43334 for ; Mon, 11 Jul 2022 10:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbiGKKDu (ORCPT ); Mon, 11 Jul 2022 06:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbiGKKDA (ORCPT ); Mon, 11 Jul 2022 06:03: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 3356E66AF8; Mon, 11 Jul 2022 02:29:07 -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 42CDB61360; Mon, 11 Jul 2022 09:29:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D3D4C34115; Mon, 11 Jul 2022 09:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531745; bh=7eKPgAvwlYCxbUAwj8QUdkVCmwJ5akFGqrV1jD3Hl4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYsvFXAIZgVoI0ewNtcDMRNHOD7ddjqCMqdRQ7YVGRiebLl9HBrekqoYqqH/TLG63 lwZSi7OPkbuM5sDW6UczpKXq/t+Cz0qlZ/7U7z26S0f5DpSyGQqoz1hoC0+WPDJPQB /ALO5xcjTFB771Z8yy1SMicGZ8jEnAMfyuxToZpg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Satish Nagireddy , Lars-Peter Clausen , Michal Simek , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 214/230] i2c: cadence: Unregister the clk notifier in error path Date: Mon, 11 Jul 2022 11:07:50 +0200 Message-Id: <20220711090610.172418878@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Satish Nagireddy [ Upstream commit 3501f0c663063513ad604fb1b3f06af637d3396d ] This patch ensures that the clock notifier is unregistered when driver probe is returning error. Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller") Signed-off-by: Satish Nagireddy Tested-by: Lars-Peter Clausen Reviewed-by: Michal Simek Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/i2c/busses/i2c-cadence.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cade= nce.c index b4c1ad19cdae..3d6f8ee355bf 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -1338,6 +1338,7 @@ static int cdns_i2c_probe(struct platform_device *pde= v) return 0; =20 err_clk_dis: + clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); clk_disable_unprepare(id->clk); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); --=20 2.35.1 From nobody Sat Apr 18 21:00:49 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 5C17FC43334 for ; Mon, 11 Jul 2022 10:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234549AbiGKKDx (ORCPT ); Mon, 11 Jul 2022 06:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234503AbiGKKDR (ORCPT ); Mon, 11 Jul 2022 06:03:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2697866B98; Mon, 11 Jul 2022 02:29: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1BEDB6136E; Mon, 11 Jul 2022 09:29:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24A93C34115; Mon, 11 Jul 2022 09:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531748; bh=rwYDbgqaFOd3kXq3xU6cJ8+EHfNvjHPitVnigsdKzyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRc8d9oLy2b5IkvCvSuzevc52EvTISpGBLMZ2l4i0L1lV4G9UPvOQ+GpH5UuNtFyS c3N99aES9ch8vfIjZhzhhXPoyBvhWo9lQHGnYoebO3BHqLod+Nz3aXvUL2wHDy7nvV ptOJ7QKtHW9sacVNzqNsiQr6Qn/0slmF+jq3sLn0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Robinson , Fabio Estevam , Vinod Koul Subject: [PATCH 5.15 215/230] dmaengine: imx-sdma: Allow imx8m for imx7 FW revs Date: Mon, 11 Jul 2022 11:07:51 +0200 Message-Id: <20220711090610.201031861@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Peter Robinson commit a7cd3cf0b2e5aaacfe5e02c472bd28e98e640be7 upstream. The revision of the imx-sdma IP that is in the i.MX8M series is the same is that as that in the i.MX7 series but the imx7d MODULE_FIRMWARE directive is wrapped in a condiditional which means it's not defined when built for aarch64 SOC_IMX8M platforms and hence you get the following errors when the driver loads on imx8m devices: imx-sdma 302c0000.dma-controller: Direct firmware load for imx/sdma/sdma-im= x7d.bin failed with error -2 imx-sdma 302c0000.dma-controller: external firmware not found, using ROM fi= rmware Add the SOC_IMX8M into the check so the firmware can load on i.MX8. Fixes: 1474d48bd639 ("arm64: dts: imx8mq: Add SDMA nodes") Fixes: 941acd566b18 ("dmaengine: imx-sdma: Only check ratio on parts that s= upport 1:1") Signed-off-by: Peter Robinson Cc: stable@vger.kernel.org # v5.2+ Reviewed-by: Fabio Estevam Link: https://lore.kernel.org/r/20220606161034.3544803-1-pbrobinson@gmail.c= om Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/imx-sdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -2264,7 +2264,7 @@ MODULE_DESCRIPTION("i.MX SDMA driver"); #if IS_ENABLED(CONFIG_SOC_IMX6Q) MODULE_FIRMWARE("imx/sdma/sdma-imx6q.bin"); #endif -#if IS_ENABLED(CONFIG_SOC_IMX7D) +#if IS_ENABLED(CONFIG_SOC_IMX7D) || IS_ENABLED(CONFIG_SOC_IMX8M) MODULE_FIRMWARE("imx/sdma/sdma-imx7d.bin"); #endif MODULE_LICENSE("GPL"); From nobody Sat Apr 18 21:00:49 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 91962C43334 for ; Mon, 11 Jul 2022 10:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231370AbiGKKD6 (ORCPT ); Mon, 11 Jul 2022 06:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234434AbiGKKDZ (ORCPT ); Mon, 11 Jul 2022 06:03: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 D850A67595; Mon, 11 Jul 2022 02:29: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 ams.source.kernel.org (Postfix) with ESMTPS id 87AC1B80D2C; Mon, 11 Jul 2022 09:29:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFDF6C34115; Mon, 11 Jul 2022 09:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531751; bh=FM/xnDTajo5tg/nDWYB6juALM7uDbh8bArFdijDwNc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DS5XBgfcz8q8Vom+REhCMxJ+9oTvFhtjLDAxdvdKbY/bfbDcsf5tCMjHKSnUaxrC+ 4qKB+1OWBOHWhqJg1AojfB2jqodbURqnjWJSleuX5yJar0BEigmFVYmhGczMtBNMHh FR3fuJqOBwfnBPqqxCRRbRbZoJOSHptA7bAVjaJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 5.15 216/230] misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer Date: Mon, 11 Jul 2022 11:07:52 +0200 Message-Id: <20220711090610.229544893@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Shuah Khan commit eb7f8e28420372787933eec079735c35034bda7d upstream. rtsx_usb driver allocates coherent dma buffer for urb transfers. This buffer is passed to usb_bulk_msg() and usb core tries to map already mapped buffer running into a dma mapping error. xhci_hcd 0000:01:00.0: rejecting DMA map of vmalloc memory WARNING: CPU: 1 PID: 279 at include/linux/dma-mapping.h:326 usb_ hcd_map_ur= b_for_dma+0x7d6/0x820 ... xhci_map_urb_for_dma+0x291/0x4e0 usb_hcd_submit_urb+0x199/0x12b0 ... usb_submit_urb+0x3b8/0x9e0 usb_start_wait_urb+0xe3/0x2d0 usb_bulk_msg+0x115/0x240 rtsx_usb_transfer_data+0x185/0x1a8 [rtsx_usb] rtsx_usb_send_cmd+0xbb/0x123 [rtsx_usb] rtsx_usb_write_register+0x12c/0x143 [rtsx_usb] rtsx_usb_probe+0x226/0x4b2 [rtsx_usb] Fix it to use kmalloc() to get DMA-able memory region instead. Signed-off-by: Shuah Khan Cc: stable Link: https://lore.kernel.org/r/667d627d502e1ba9ff4f9b94966df3299d2d3c0d.16= 56642167.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/misc/cardreader/rtsx_usb.c | 13 +++++++------ include/linux/rtsx_usb.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -631,8 +631,7 @@ static int rtsx_usb_probe(struct usb_int =20 ucr->pusb_dev =3D usb_dev; =20 - ucr->iobuf =3D usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE, - GFP_KERNEL, &ucr->iobuf_dma); + ucr->iobuf =3D kmalloc(IOBUF_SIZE, GFP_KERNEL); if (!ucr->iobuf) return -ENOMEM; =20 @@ -668,8 +667,9 @@ static int rtsx_usb_probe(struct usb_int =20 out_init_fail: usb_set_intfdata(ucr->pusb_intf, NULL); - usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, - ucr->iobuf_dma); + kfree(ucr->iobuf); + ucr->iobuf =3D NULL; + ucr->cmd_buf =3D ucr->rsp_buf =3D NULL; return ret; } =20 @@ -682,8 +682,9 @@ static void rtsx_usb_disconnect(struct u mfd_remove_devices(&intf->dev); =20 usb_set_intfdata(ucr->pusb_intf, NULL); - usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, - ucr->iobuf_dma); + kfree(ucr->iobuf); + ucr->iobuf =3D NULL; + ucr->cmd_buf =3D ucr->rsp_buf =3D NULL; } =20 #ifdef CONFIG_PM --- a/include/linux/rtsx_usb.h +++ b/include/linux/rtsx_usb.h @@ -55,7 +55,6 @@ struct rtsx_ucr { struct usb_interface *pusb_intf; struct usb_sg_request current_sg; unsigned char *iobuf; - dma_addr_t iobuf_dma; =20 struct timer_list sg_timer; struct mutex dev_mutex; From nobody Sat Apr 18 21:00:49 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 AF059C43334 for ; Mon, 11 Jul 2022 10:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234641AbiGKKGA (ORCPT ); Mon, 11 Jul 2022 06:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbiGKKEY (ORCPT ); Mon, 11 Jul 2022 06:04:24 -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 0954487F79; Mon, 11 Jul 2022 02:30: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 3C604B80E90; Mon, 11 Jul 2022 09:30:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A210EC341C0; Mon, 11 Jul 2022 09:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531806; bh=6P8CXs3MGbhhmsH5Oe+Hzg9axBWkQxRbYazFIsEe6KE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3XTbgQlgNzf7lQVX7iE5b9n1qqgojN6w0twAbwdzDBlgu/rKf2wazhm1zifY4jAa sblxIXBeJp71HBJst9+yxJe4wIbPB8kUtZlEEtOOLDBY0gOTNMe2++JKLtPq0iKMPE 2Td5GUoA0dy661lxVd2Gq/FHjgt4rwSzdRV6IUTg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 5.15 217/230] misc: rtsx_usb: use separate command and response buffers Date: Mon, 11 Jul 2022 11:07:53 +0200 Message-Id: <20220711090610.256939326@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Shuah Khan commit 3776c78559853fd151be7c41e369fd076fb679d5 upstream. rtsx_usb uses same buffer for command and response. There could be a potential conflict using the same buffer for both especially if retries and timeouts are involved. Use separate command and response buffers to avoid conflicts. Signed-off-by: Shuah Khan Cc: stable Link: https://lore.kernel.org/r/07e3721804ff07aaab9ef5b39a5691d0718b9ade.16= 56642167.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/misc/cardreader/rtsx_usb.c | 26 +++++++++++++++++--------- include/linux/rtsx_usb.h | 1 - 2 files changed, 17 insertions(+), 10 deletions(-) --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -631,15 +631,18 @@ static int rtsx_usb_probe(struct usb_int =20 ucr->pusb_dev =3D usb_dev; =20 - ucr->iobuf =3D kmalloc(IOBUF_SIZE, GFP_KERNEL); - if (!ucr->iobuf) + ucr->cmd_buf =3D kmalloc(IOBUF_SIZE, GFP_KERNEL); + if (!ucr->cmd_buf) return -ENOMEM; =20 + ucr->rsp_buf =3D kmalloc(IOBUF_SIZE, GFP_KERNEL); + if (!ucr->rsp_buf) + goto out_free_cmd_buf; + usb_set_intfdata(intf, ucr); =20 ucr->vendor_id =3D id->idVendor; ucr->product_id =3D id->idProduct; - ucr->cmd_buf =3D ucr->rsp_buf =3D ucr->iobuf; =20 mutex_init(&ucr->dev_mutex); =20 @@ -667,9 +670,11 @@ static int rtsx_usb_probe(struct usb_int =20 out_init_fail: usb_set_intfdata(ucr->pusb_intf, NULL); - kfree(ucr->iobuf); - ucr->iobuf =3D NULL; - ucr->cmd_buf =3D ucr->rsp_buf =3D NULL; + kfree(ucr->rsp_buf); + ucr->rsp_buf =3D NULL; +out_free_cmd_buf: + kfree(ucr->cmd_buf); + ucr->cmd_buf =3D NULL; return ret; } =20 @@ -682,9 +687,12 @@ static void rtsx_usb_disconnect(struct u mfd_remove_devices(&intf->dev); =20 usb_set_intfdata(ucr->pusb_intf, NULL); - kfree(ucr->iobuf); - ucr->iobuf =3D NULL; - ucr->cmd_buf =3D ucr->rsp_buf =3D NULL; + + kfree(ucr->cmd_buf); + ucr->cmd_buf =3D NULL; + + kfree(ucr->rsp_buf); + ucr->rsp_buf =3D NULL; } =20 #ifdef CONFIG_PM --- a/include/linux/rtsx_usb.h +++ b/include/linux/rtsx_usb.h @@ -54,7 +54,6 @@ struct rtsx_ucr { struct usb_device *pusb_dev; struct usb_interface *pusb_intf; struct usb_sg_request current_sg; - unsigned char *iobuf; =20 struct timer_list sg_timer; struct mutex dev_mutex; From nobody Sat Apr 18 21:00:49 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 2CF4DCCA482 for ; Mon, 11 Jul 2022 10:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234532AbiGKKFA (ORCPT ); Mon, 11 Jul 2022 06:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234519AbiGKKDc (ORCPT ); Mon, 11 Jul 2022 06:03:32 -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 057773F308; Mon, 11 Jul 2022 02:29: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 sin.source.kernel.org (Postfix) with ESMTPS id 5CA3BCE126A; Mon, 11 Jul 2022 09:29:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6899EC341C0; Mon, 11 Jul 2022 09:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531770; bh=lh7AYL4Z8YvuRd3eo1vbbmlhCCo0hOo/6FSah1I1Stk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eG+wWQmEMXi7PiLczA2aU9Nw5GRY5jYUrNpki+0www8Md2EnKh7PHGiLPcjZmeHG7 +lf4cr7gWZ40AULs5UpCEs9wRQFCRHPFBefAQSyY39htHASiDws4rsZhp1mOPnN7kf 7+AAUnlpdVypDEJFz6g9Rpq7khiy6tJtptkV6Etk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , stable , Shuah Khan Subject: [PATCH 5.15 218/230] misc: rtsx_usb: set return value in rsp_buf alloc err path Date: Mon, 11 Jul 2022 11:07:54 +0200 Message-Id: <20220711090610.285193241@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Shuah Khan commit 2cd37c2e72449a7add6da1183d20a6247d6db111 upstream. Set return value in rsp_buf alloc error path before going to error handling. drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used u= ninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!ucr->rsp_buf) ^~~~~~~~~~~~~ drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs= here return ret; ^~~ drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its c= ondition is always false if (!ucr->rsp_buf) ^~~~~~~~~~~~~~~~~~ drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable = 'ret' to silence this warning int ret; ^ =3D 0 Fixes: 3776c7855985 ("misc: rtsx_usb: use separate command and response buf= fers") Reported-by: kernel test robot Cc: stable Signed-off-by: Shuah Khan Link: https://lore.kernel.org/r/20220701165352.15687-1-skhan@linuxfoundatio= n.org Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/misc/cardreader/rtsx_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -636,8 +636,10 @@ static int rtsx_usb_probe(struct usb_int return -ENOMEM; =20 ucr->rsp_buf =3D kmalloc(IOBUF_SIZE, GFP_KERNEL); - if (!ucr->rsp_buf) + if (!ucr->rsp_buf) { + ret =3D -ENOMEM; goto out_free_cmd_buf; + } =20 usb_set_intfdata(intf, ucr); From nobody Sat Apr 18 21:00:49 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 04A33C433EF for ; Mon, 11 Jul 2022 10:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234646AbiGKKGP (ORCPT ); Mon, 11 Jul 2022 06:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233909AbiGKKDh (ORCPT ); Mon, 11 Jul 2022 06:03:37 -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 7074D66AFC; Mon, 11 Jul 2022 02:29: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 020A161411; Mon, 11 Jul 2022 09:29:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11603C34115; Mon, 11 Jul 2022 09:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531784; bh=t9YP5Tngn5X3VBS+MR/tAb2ZKRQvST36CAK14z8o50Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0MIh8IgOWwcyRU+BLwu/3VvBkcDQonJd2yfZdSgD80leERKtdz1C/UOxA8w7FTba8 RwazltTILfzPPLP8enyuFwJLKTDp5oL1yinQOy6vkNeLJHR85530EiMGJGD9Gi1HZw yeKFM0ZVOb/mExWN3CSFCt/e4j0Esa85AN907+rA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naoya Horiguchi , Miaohe Lin , Mike Kravetz , Yang Shi , Dan Carpenter , Andrew Morton Subject: [PATCH 5.15 219/230] Revert "mm/memory-failure.c: fix race with changing page compound again" Date: Mon, 11 Jul 2022 11:07:55 +0200 Message-Id: <20220711090610.314638268@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Naoya Horiguchi commit 2ba2b008a8bf5fd268a43d03ba79e0ad464d6836 upstream. Reverts commit 888af2701db7 ("mm/memory-failure.c: fix race with changing page compound again") because now we fetch the page refcount under hugetlb_lock in try_memory_failure_hugetlb() so that the race check is no longer necessary. Link: https://lkml.kernel.org/r/20220408135323.1559401-4-naoya.horiguchi@li= nux.dev Signed-off-by: Naoya Horiguchi Suggested-by: Miaohe Lin Reviewed-by: Miaohe Lin Reviewed-by: Mike Kravetz Cc: Miaohe Lin Cc: Yang Shi Cc: Dan Carpenter Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- include/linux/mm.h | 1 - include/ras/ras_event.h | 1 - mm/memory-failure.c | 11 ----------- 3 files changed, 13 deletions(-) --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3175,7 +3175,6 @@ enum mf_action_page_type { MF_MSG_BUDDY_2ND, MF_MSG_DAX, MF_MSG_UNSPLIT_THP, - MF_MSG_DIFFERENT_PAGE_SIZE, MF_MSG_UNKNOWN, }; =20 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -376,7 +376,6 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \ EM ( MF_MSG_DAX, "dax page" ) \ EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ - EM ( MF_MSG_DIFFERENT_PAGE_SIZE, "different page size" ) \ EMe ( MF_MSG_UNKNOWN, "unknown page" ) =20 /* --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -741,7 +741,6 @@ static const char * const action_page_ty [MF_MSG_BUDDY_2ND] =3D "free buddy page (2nd try)", [MF_MSG_DAX] =3D "dax page", [MF_MSG_UNSPLIT_THP] =3D "unsplit thp", - [MF_MSG_DIFFERENT_PAGE_SIZE] =3D "different page size", [MF_MSG_UNKNOWN] =3D "unknown page", }; =20 @@ -1526,16 +1525,6 @@ retry: return res =3D=3D MF_RECOVERED ? 0 : -EBUSY; } =20 - /* - * The page could have changed compound pages due to race window. - * If this happens just bail out. - */ - if (!PageHuge(p) || compound_head(p) !=3D head) { - action_result(pfn, MF_MSG_DIFFERENT_PAGE_SIZE, MF_IGNORED); - res =3D -EBUSY; - goto out; - } - page_flags =3D head->flags; =20 /* From nobody Sat Apr 18 21:00:49 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 A3229C433EF for ; Mon, 11 Jul 2022 10:05:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234560AbiGKKFU (ORCPT ); Mon, 11 Jul 2022 06:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbiGKKDh (ORCPT ); Mon, 11 Jul 2022 06:03:37 -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 C060D691E9; Mon, 11 Jul 2022 02:29: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 6D4F8B80D2C; Mon, 11 Jul 2022 09:29:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5602C34115; Mon, 11 Jul 2022 09:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531787; bh=BzvaL6bz8Q8ZGA95+tzigYDNQurz4yyyNUfD7glyKlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pOBw93q3ObykYJWu1JfV+PWd0fq0a9EakPHDsnP8T6rnL0hsA2IUQhTEcH1nX5Rkr 7g0yVChunkKCTdPhRGNR6ttj7oboOX2tZs6yHNS+RzWd8/y1JdI1VywAN9t0voMLEx aCCCXt1ZruWjtbFOwBGgAkeOaIwp1B1ITDpTxEoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, AngeloGioacchino Del Regno , "kernelci.org bot" Subject: [PATCH 5.15 220/230] Revert "serial: 8250_mtk: Make sure to select the right FEATURE_SEL" Date: Mon, 11 Jul 2022 11:07:56 +0200 Message-Id: <20220711090610.343165021@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: AngeloGioacchino Del Regno commit f0136f65285bcfb7e8f90d1013723076a35acd51 upstream. It was found that some MediaTek SoCs are incompatible with this change. Also, this register was mistakenly understood as it was related to the 16550A register layout selection but, at least on some IPs, if not all, it's related to something else unknown. This reverts commit 6f81fdded0d024c7d4084d434764f30bca1cd6b1. Signed-off-by: AngeloGioacchino Del Regno Fixes: 6f81fdded0d0 ("serial: 8250_mtk: Make sure to select the right FEATU= RE_SEL") Reported-by: "kernelci.org bot" Link: https://lore.kernel.org/r/20220510122620.150342-1-angelogioacchino.de= lregno@collabora.com Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/tty/serial/8250/8250_mtk.c | 7 ------- 1 file changed, 7 deletions(-) --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -57,9 +57,6 @@ #define MTK_UART_XON1 40 /* I/O: Xon character 1 */ #define MTK_UART_XOFF1 42 /* I/O: Xoff character 1 */ =20 -#define MTK_UART_FEATURE_SEL 39 /* Feature Selection register */ -#define MTK_UART_FEAT_NEWRMAP BIT(0) /* Use new register map */ - #ifdef CONFIG_SERIAL_8250_DMA enum dma_rx_status { DMA_RX_START =3D 0, @@ -575,10 +572,6 @@ static int mtk8250_probe(struct platform uart.dma =3D data->dma; #endif =20 - /* Set AP UART new register map */ - writel(MTK_UART_FEAT_NEWRMAP, uart.port.membase + - (MTK_UART_FEATURE_SEL << uart.port.regshift)); - /* Disable Rate Fix function */ writel(0x0, uart.port.membase + (MTK_UART_RATE_FIX << uart.port.regshift)); From nobody Sat Apr 18 21:00:49 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 7BCE5C43334 for ; Mon, 11 Jul 2022 10:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234582AbiGKKFX (ORCPT ); Mon, 11 Jul 2022 06:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbiGKKDi (ORCPT ); Mon, 11 Jul 2022 06:03:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB82691D2; Mon, 11 Jul 2022 02:29: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 1CB28B80E8C; Mon, 11 Jul 2022 09:29:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F5C2C341C8; Mon, 11 Jul 2022 09:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531789; bh=Rt/Sio1pJh64bojAYm8X1d6JRxSAP0jT01fXLbbdLhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BSq56OeMPbWV4fvPVm1l7ugcbDLNG1x4O2Y2hMMsRZRv1UHg1iPQ6mPq6CP793TUD Qr+0cqwSsky17NQ8oiTm54APMmvTsLr4zxKXMcONtvVM8i+D3uiuXi5SjkB1PB5Mkh QVBQ/a9k6h+Sn1awlb7IHMxx4cuHmas8RkTlpwkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Holland , Rob Herring , Vinod Koul Subject: [PATCH 5.15 221/230] dt-bindings: dma: allwinner,sun50i-a64-dma: Fix min/max typo Date: Mon, 11 Jul 2022 11:07:57 +0200 Message-Id: <20220711090610.371563095@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 commit 607a48c78e6b427b0b684d24e61c19e846ad65d6 upstream. The conditional block for variants with a second clock should have set minItems, not maxItems, which was already 2. Since clock-names requires two items, this typo should not have caused any problems. Fixes: edd14218bd66 ("dt-bindings: dmaengine: Convert Allwinner A31 and A64= DMA to a schema") Signed-off-by: Samuel Holland Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20220702031903.21703-1-samuel@sholland.org Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- Documentation/devicetree/bindings/dma/allwinner,sun50i-a64-dma.yaml | 2= +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/Documentation/devicetree/bindings/dma/allwinner,sun50i-a64-dma.yaml +++ b/Documentation/devicetree/bindings/dma/allwinner,sun50i-a64-dma.yaml @@ -64,7 +64,7 @@ if: then: properties: clocks: - maxItems: 2 + minItems: 2 =20 required: - clock-names From nobody Sat Apr 18 21:00:49 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 278AFC43334 for ; Mon, 11 Jul 2022 10:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234586AbiGKKFa (ORCPT ); Mon, 11 Jul 2022 06:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234289AbiGKKDq (ORCPT ); Mon, 11 Jul 2022 06:03:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 745DD6BC09; Mon, 11 Jul 2022 02:29: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 DAF5DB80D2C; Mon, 11 Jul 2022 09:29:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A2D2C341CB; Mon, 11 Jul 2022 09:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531792; bh=T7xOkgvjtE3PbkwxKocejNJRefdrZpo1wFeudSfDjeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ6EmFb0RsdPW86K+p6fal3F8omq/vA48AAIjEjpLd8+zNHCRmwdJImvKkNreN7Ex FI0MKbXndWp5Nyo1OmgBmHMdnLVNWHA1xhiRmnrWeXQbfBVdX6jdvWzk+4Y/zHJ0mL kOOMbzv3aMOgl+ZTuq3wHiEZTB0eT/kRKqe6oOYQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Itay Iellin , Matthew Wilcox , Linus Torvalds Subject: [PATCH 5.15 222/230] ida: dont use BUG_ON() for debugging Date: Mon, 11 Jul 2022 11:07:58 +0200 Message-Id: <20220711090610.399846271@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Torvalds commit fc82bbf4dede758007763867d0282353c06d1121 upstream. This is another old BUG_ON() that just shouldn't exist (see also commit a382f8fee42c: "signal handling: don't use BUG_ON() for debugging"). In fact, as Matthew Wilcox points out, this condition shouldn't really even result in a warning, since a negative id allocation result is just a normal allocation failure: "I wonder if we should even warn here -- sure, the caller is trying to free something that wasn't allocated, but we don't warn for kfree(NULL)" and goes on to point out how that current error check is only causing people to unnecessarily do their own index range checking before freeing it. This was noted by Itay Iellin, because the bluetooth HCI socket cookie code does *not* do that range checking, and ends up just freeing the error case too, triggering the BUG_ON(). The HCI code requires CAP_NET_RAW, and seems to just result in an ugly splat, but there really is no reason to BUG_ON() here, and we have generally striven for allocation models where it's always ok to just do free(alloc()); even if the allocation were to fail for some random reason (usually obviously that "random" reason being some resource limit). Fixes: 88eca0207cf1 ("ida: simplified functions for id allocation") Reported-by: Itay Iellin Suggested-by: Matthew Wilcox Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- lib/idr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/lib/idr.c +++ b/lib/idr.c @@ -491,7 +491,8 @@ void ida_free(struct ida *ida, unsigned struct ida_bitmap *bitmap; unsigned long flags; =20 - BUG_ON((int)id < 0); + if ((int)id < 0) + return; =20 xas_lock_irqsave(&xas, flags); bitmap =3D xas_load(&xas); From nobody Sat Apr 18 21:00:49 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 C0B74C433EF for ; Mon, 11 Jul 2022 10:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234594AbiGKKFe (ORCPT ); Mon, 11 Jul 2022 06:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234555AbiGKKD7 (ORCPT ); Mon, 11 Jul 2022 06:03:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A3456C11A; Mon, 11 Jul 2022 02:29: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 dfw.source.kernel.org (Postfix) with ESMTPS id CE158612AC; Mon, 11 Jul 2022 09:29:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2050C34115; Mon, 11 Jul 2022 09:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531795; bh=p0lflOcWHVfiMHk1+KUAd/x8/pQZqrbHUD1i0/M/Vz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAJie0SPqKYkir47RX/RB1Q7I5BCVW49VM+CKRcY88G3pqGSBr+lTZjulOmrIvtIn fJouk7fkEjTZzf1iVn8Wc5ML1a4jAy0ARZl4TlwqqhmHFn42+u9Cj0dEXWPLZsNX9U A2rozooDT/bi7VtBTzVflhForshN0rNWOdWM+v28= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Vinod Koul Subject: [PATCH 5.15 223/230] dmaengine: pl330: Fix lockdep warning about non-static key Date: Mon, 11 Jul 2022 11:07:59 +0200 Message-Id: <20220711090610.427754018@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dmitry Osipenko commit b64b3b2f1d81f83519582e1feee87d77f51f5f17 upstream. The DEFINE_SPINLOCK() macro shouldn't be used for dynamically allocated spinlocks. The lockdep warns about this and disables locking validator. Fix the warning by making lock static. INFO: trying to register non-static key. The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator. Hardware name: Radxa ROCK Pi 4C (DT) Call trace: dump_backtrace.part.0+0xcc/0xe0 show_stack+0x18/0x6c dump_stack_lvl+0x8c/0xb8 dump_stack+0x18/0x34 register_lock_class+0x4a8/0x4cc __lock_acquire+0x78/0x20cc lock_acquire.part.0+0xe0/0x230 lock_acquire+0x68/0x84 _raw_spin_lock_irqsave+0x84/0xc4 add_desc+0x44/0xc0 pl330_get_desc+0x15c/0x1d0 pl330_prep_dma_cyclic+0x100/0x270 snd_dmaengine_pcm_trigger+0xec/0x1c0 dmaengine_pcm_trigger+0x18/0x24 ... Fixes: e588710311ee ("dmaengine: pl330: fix descriptor allocation fail") Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20220520181432.149904-1-dmitry.osipenko@col= labora.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/pl330.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2589,7 +2589,7 @@ static struct dma_pl330_desc *pl330_get_ =20 /* If the DMAC pool is empty, alloc new */ if (!desc) { - DEFINE_SPINLOCK(lock); + static DEFINE_SPINLOCK(lock); LIST_HEAD(pool); =20 if (!add_desc(&pool, &lock, GFP_ATOMIC, 1)) From nobody Sat Apr 18 21:00:49 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 7FB4DC433EF for ; Mon, 11 Jul 2022 10:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234601AbiGKKFg (ORCPT ); Mon, 11 Jul 2022 06:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234599AbiGKKEO (ORCPT ); Mon, 11 Jul 2022 06:04:14 -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 97BC26E8A8; Mon, 11 Jul 2022 02:30:00 -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 2CD01B80E8B; Mon, 11 Jul 2022 09:29:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96627C341C8; Mon, 11 Jul 2022 09:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531798; bh=maPocCFDUREvXM9pIbr4oBu9Z1mY1qtMxmnH6+RDnnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzJqY58bcTfB9IE6A1aYRtYFLRATNQAi2q6fzitnqkIE0UkBmPkeJQ40cR7+cNnLf C9htqRTc5XfWPn4XLzAgbeZr7/KhA0y6MMwBumR0vItOnKsk7HK33iqW2QjjXJ0EMS V2ac8aUFV59ABE7Oj60BnovQNZqu/5wzMN00hweg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Vinod Koul Subject: [PATCH 5.15 224/230] dmaengine: lgm: Fix an error handling path in intel_ldma_probe() Date: Mon, 11 Jul 2022 11:08:00 +0200 Message-Id: <20220711090610.455446478@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Christophe JAILLET commit 1dbe67b9faea0bc340cce894018076679c16cb71 upstream. ldma_clk_disable() calls both: clk_disable_unprepare(d->core_clk); reset_control_assert(d->rst); So, should devm_reset_control_get_optional() fail, core_clk should not be prepare_enable'd before it, otherwise it will never be disable_unprepare'd. Reorder the code to handle the error handling path as expected. Fixes: 32d31c79a1a4 ("dmaengine: Add Intel LGM SoC DMA support.") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/18504549bc4d2b62a72a02cb22a2e4d8e6a58720.16= 53241224.git.christophe.jaillet@wanadoo.fr Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/lgm/lgm-dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/dma/lgm/lgm-dma.c +++ b/drivers/dma/lgm/lgm-dma.c @@ -1593,11 +1593,12 @@ static int intel_ldma_probe(struct platf d->core_clk =3D devm_clk_get_optional(dev, NULL); if (IS_ERR(d->core_clk)) return PTR_ERR(d->core_clk); - clk_prepare_enable(d->core_clk); =20 d->rst =3D devm_reset_control_get_optional(dev, NULL); if (IS_ERR(d->rst)) return PTR_ERR(d->rst); + + clk_prepare_enable(d->core_clk); reset_control_deassert(d->rst); =20 ret =3D devm_add_action_or_reset(dev, ldma_clk_disable, d); From nobody Sat Apr 18 21:00:49 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 5A792C43334 for ; Mon, 11 Jul 2022 10:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbiGKKFn (ORCPT ); Mon, 11 Jul 2022 06:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234610AbiGKKEP (ORCPT ); Mon, 11 Jul 2022 06:04: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 DD2526B240; Mon, 11 Jul 2022 02:30: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 380FE61366; Mon, 11 Jul 2022 09:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47A9FC341C0; Mon, 11 Jul 2022 09:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531800; bh=xt4NEgXT0d2LmycCmZuF3LNneav+UrDruuVxsj07tQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8X1n+O0/jNHHhlzi5f8w6R2gmavJ1GAkI+Xqy4gGbex/qIm54jRSpvCk/vvpQOBn GimJ2dZL1NoBAD/qj8azTq0l+gXq7F05oQPuUYwO+MbQjRiCqrSu7kzuY6IA33HtG/ YYcmvz0OncQxdM/ExN5TpyC42iqnJNCt0E24FOeg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Vinod Koul Subject: [PATCH 5.15 225/230] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Date: Mon, 11 Jul 2022 11:08:01 +0200 Message-Id: <20220711090610.483398165@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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 Walle commit 3770d92bd5237d686e49da7b2fb86f53ee6ed259 upstream. It seems that it is valid to have less than the requested number of descriptors. But what is not valid and leads to subsequent errors is to have zero descriptors. In that case, abort the probing. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended D= MA Controller driver") Signed-off-by: Michael Walle Link: https://lore.kernel.org/r/20220526135111.1470926-1-michael@walle.cc Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/at_xdmac.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1898,6 +1898,11 @@ static int at_xdmac_alloc_chan_resources for (i =3D 0; i < init_nr_desc_per_channel; i++) { desc =3D at_xdmac_alloc_desc(chan, GFP_KERNEL); if (!desc) { + if (i =3D=3D 0) { + dev_warn(chan2dev(chan), + "can't allocate any descriptors\n"); + return -EIO; + } dev_warn(chan2dev(chan), "only %d descriptors have been allocated\n", i); break; From nobody Sat Apr 18 21:00:49 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 20586C433EF for ; Mon, 11 Jul 2022 10:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234385AbiGKKFx (ORCPT ); Mon, 11 Jul 2022 06:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234665AbiGKKEV (ORCPT ); Mon, 11 Jul 2022 06:04:21 -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 4CC5387F64; Mon, 11 Jul 2022 02:30: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 89BE2B80E8B; Mon, 11 Jul 2022 09:30:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3E20C34115; Mon, 11 Jul 2022 09:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531803; bh=Hk/f5HEXN2CGqKGi2hWX/5xqot39iQo6TVSPqo3c+18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aaaZU+T6N2xn6uaYNS9ObW2lvXhRE8TsVmiUdVzG2N1pvAzUE1Opnj+mpSgfxfpAQ 8BUQhiSmzW957QSw41tfgH51W/MiiG5rJQwG9Tg9RGxU4ZGQ7QNel8bO2npQbemQxD k6yAaYgHK5FR5/BZJJFAdSJoVghjAK3H1SFrf0oQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Vinod Koul Subject: [PATCH 5.15 226/230] dmaengine: ti: Fix refcount leak in ti_dra7_xbar_route_allocate Date: Mon, 11 Jul 2022 11:08:02 +0200 Message-Id: <20220711090610.512450424@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Miaoqian Lin commit c132fe78ad7b4ce8b5d49a501a15c29d08eeb23a upstream. of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. Add missing of_node_put() in to fix this. Fixes: ec9bfa1e1a79 ("dmaengine: ti-dma-crossbar: dra7: Use bitops instead = of idr") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220605042723.17668-2-linmq006@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/ti/dma-crossbar.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/dma/ti/dma-crossbar.c +++ b/drivers/dma/ti/dma-crossbar.c @@ -268,6 +268,7 @@ static void *ti_dra7_xbar_route_allocate mutex_unlock(&xbar->mutex); dev_err(&pdev->dev, "Run out of free DMA requests\n"); kfree(map); + of_node_put(dma_spec->np); return ERR_PTR(-ENOMEM); } set_bit(map->xbar_out, xbar->dma_inuse); From nobody Sat Apr 18 21:00:49 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 1A5E4C433EF for ; Mon, 11 Jul 2022 10:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbiGKKFD (ORCPT ); Mon, 11 Jul 2022 06:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234464AbiGKKDe (ORCPT ); Mon, 11 Jul 2022 06:03:34 -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 3FF54BC5; Mon, 11 Jul 2022 02:29: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 EFB13B80D2C; Mon, 11 Jul 2022 09:29:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A386C34115; Mon, 11 Jul 2022 09:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531773; bh=ur65PibzAH0/HeYoG7xlVWHkoCmHI6P0kGITk0OY2Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPzx/UQuW+AFW8yAyqXhl0n78DpmG2lA2NvZbU8jpaXs0pDCIbORE7PT7x27+Bkua V0ZvPgiMzHKux7gX8X4YmXqBEcnaGDZrYxOQD4Pt8G2XwqC1pTdjfdRX6VW/lOAGmW FtNP0yMqkQgnnhGYbIFWNveLymlRkoEfBN0uwqW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Gerhold , Caleb Connolly , Vinod Koul Subject: [PATCH 5.15 227/230] dmaengine: qcom: bam_dma: fix runtime PM underflow Date: Mon, 11 Jul 2022 11:08:03 +0200 Message-Id: <20220711090610.541031728@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Caleb Connolly commit 0ac9c3dd0d6fe293cd5044cfad10bec27d171e4e upstream. Commit dbad41e7bb5f ("dmaengine: qcom: bam_dma: check if the runtime pm ena= bled") caused unbalanced pm_runtime_get/put() calls when the bam is controlled remotely. This commit reverts it and just enables pm_runtime in all cases, the clk_* functions already just nop when the clock is NULL. Also clean up a bit by removing unnecessary bamclk null checks. Suggested-by: Stephan Gerhold Fixes: dbad41e7bb5f ("dmaengine: qcom: bam_dma: check if the runtime pm ena= bled") Signed-off-by: Caleb Connolly Link: https://lore.kernel.org/r/20220629140559.118537-1-caleb.connolly@lina= ro.org Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/qcom/bam_dma.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -515,14 +515,6 @@ static int bam_alloc_chan(struct dma_cha return 0; } =20 -static int bam_pm_runtime_get_sync(struct device *dev) -{ - if (pm_runtime_enabled(dev)) - return pm_runtime_get_sync(dev); - - return 0; -} - /** * bam_free_chan - Frees dma resources associated with specific channel * @chan: specified channel @@ -538,7 +530,7 @@ static void bam_free_chan(struct dma_cha unsigned long flags; int ret; =20 - ret =3D bam_pm_runtime_get_sync(bdev->dev); + ret =3D pm_runtime_get_sync(bdev->dev); if (ret < 0) return; =20 @@ -734,7 +726,7 @@ static int bam_pause(struct dma_chan *ch unsigned long flag; int ret; =20 - ret =3D bam_pm_runtime_get_sync(bdev->dev); + ret =3D pm_runtime_get_sync(bdev->dev); if (ret < 0) return ret; =20 @@ -760,7 +752,7 @@ static int bam_resume(struct dma_chan *c unsigned long flag; int ret; =20 - ret =3D bam_pm_runtime_get_sync(bdev->dev); + ret =3D pm_runtime_get_sync(bdev->dev); if (ret < 0) return ret; =20 @@ -869,7 +861,7 @@ static irqreturn_t bam_dma_irq(int irq, if (srcs & P_IRQ) tasklet_schedule(&bdev->task); =20 - ret =3D bam_pm_runtime_get_sync(bdev->dev); + ret =3D pm_runtime_get_sync(bdev->dev); if (ret < 0) return IRQ_NONE; =20 @@ -987,7 +979,7 @@ static void bam_start_dma(struct bam_cha if (!vd) return; =20 - ret =3D bam_pm_runtime_get_sync(bdev->dev); + ret =3D pm_runtime_get_sync(bdev->dev); if (ret < 0) return; =20 @@ -1350,11 +1342,6 @@ static int bam_dma_probe(struct platform if (ret) goto err_unregister_dma; =20 - if (!bdev->bamclk) { - pm_runtime_disable(&pdev->dev); - return 0; - } - pm_runtime_irq_safe(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(&pdev->dev); @@ -1438,10 +1425,8 @@ static int __maybe_unused bam_dma_suspen { struct bam_device *bdev =3D dev_get_drvdata(dev); =20 - if (bdev->bamclk) { - pm_runtime_force_suspend(dev); - clk_unprepare(bdev->bamclk); - } + pm_runtime_force_suspend(dev); + clk_unprepare(bdev->bamclk); =20 return 0; } @@ -1451,13 +1436,11 @@ static int __maybe_unused bam_dma_resume struct bam_device *bdev =3D dev_get_drvdata(dev); int ret; =20 - if (bdev->bamclk) { - ret =3D clk_prepare(bdev->bamclk); - if (ret) - return ret; + ret =3D clk_prepare(bdev->bamclk); + if (ret) + return ret; =20 - pm_runtime_force_resume(dev); - } + pm_runtime_force_resume(dev); =20 return 0; } From nobody Sat Apr 18 21:00:49 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 1BFEAC433EF for ; Mon, 11 Jul 2022 10:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234517AbiGKKFP (ORCPT ); Mon, 11 Jul 2022 06:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234483AbiGKKDg (ORCPT ); Mon, 11 Jul 2022 06:03:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9616948EA6; Mon, 11 Jul 2022 02:29: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 E4CD7612E8; Mon, 11 Jul 2022 09:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 021A0C34115; Mon, 11 Jul 2022 09:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531776; bh=VEDEAuGYpp7Jizzi0f+s+J5j7QxYR9ToluTbgD9NrJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q46REEw08bYod3pgcXBoUqlE//Lu17Z9fRUrHZI/FqErZXaw77nlMbbL8FWeCKGe8 9KhKwDijXs/gYctlrUTW3Y5he843wLSEXBk/3/G5P3MgMRV4OrX4AWmqngZiESStZh lIqsTFCMPoYrYJHMIRw5zhsh0aZ4DE6riGaUj+sc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Peter Ujfalusi , Vinod Koul Subject: [PATCH 5.15 228/230] dmaengine: ti: Add missing put_device in ti_dra7_xbar_route_allocate Date: Mon, 11 Jul 2022 11:08:04 +0200 Message-Id: <20220711090610.569137684@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Miaoqian Lin commit 615a4bfc426e11dba05c2cf343f9ac752fb381d2 upstream. of_find_device_by_node() takes reference, we should use put_device() to release it when not need anymore. Fixes: a074ae38f859 ("dmaengine: Add driver for TI DMA crossbar on DRA7x") Signed-off-by: Miaoqian Lin Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20220605042723.17668-1-linmq006@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/ti/dma-crossbar.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/dma/ti/dma-crossbar.c +++ b/drivers/dma/ti/dma-crossbar.c @@ -245,6 +245,7 @@ static void *ti_dra7_xbar_route_allocate if (dma_spec->args[0] >=3D xbar->xbar_requests) { dev_err(&pdev->dev, "Invalid XBAR request number: %d\n", dma_spec->args[0]); + put_device(&pdev->dev); return ERR_PTR(-EINVAL); } =20 @@ -252,12 +253,14 @@ static void *ti_dra7_xbar_route_allocate dma_spec->np =3D of_parse_phandle(ofdma->of_node, "dma-masters", 0); if (!dma_spec->np) { dev_err(&pdev->dev, "Can't get DMA master\n"); + put_device(&pdev->dev); return ERR_PTR(-EINVAL); } =20 map =3D kzalloc(sizeof(*map), GFP_KERNEL); if (!map) { of_node_put(dma_spec->np); + put_device(&pdev->dev); return ERR_PTR(-ENOMEM); } =20 @@ -269,6 +272,7 @@ static void *ti_dra7_xbar_route_allocate dev_err(&pdev->dev, "Run out of free DMA requests\n"); kfree(map); of_node_put(dma_spec->np); + put_device(&pdev->dev); return ERR_PTR(-ENOMEM); } set_bit(map->xbar_out, xbar->dma_inuse); From nobody Sat Apr 18 21:00:49 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 8C293CCA480 for ; Mon, 11 Jul 2022 10:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234516AbiGKKFI (ORCPT ); Mon, 11 Jul 2022 06:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234485AbiGKKDg (ORCPT ); Mon, 11 Jul 2022 06:03:36 -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 128CF48EB0; Mon, 11 Jul 2022 02:29:40 -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 9AAF361366; Mon, 11 Jul 2022 09:29:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB014C34115; Mon, 11 Jul 2022 09:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531779; bh=4P9xq6q8hGoQvb8Sigl3/Po/KZymH+V3vIWWDe8U1Uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sp8LOhS7MXPRFIee/jhapWJ/JWVTzjy5/XOBtIkKeROUoxMLFG70rSnf4B3Q69pdp 4Ojvo1cUt3L36jzrbQoK3B+DeLtAbNyX0H+d2cOiwtL9zGJCeZBWW9ts82Uj6+W1ts qZ+FvEPrQ91QDW2oVuPT/F8c+Jb733gJoiTfnwBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Zhu , Dave Jiang , Fenghua Yu , Vinod Koul Subject: [PATCH 5.15 229/230] dmaengine: idxd: force wq context cleanup on device disable path Date: Mon, 11 Jul 2022 11:08:05 +0200 Message-Id: <20220711090610.597250131@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Dave Jiang commit 44c4237cf3436bda2b185ff728123651ad133f69 upstream. Testing shown that when a wq mode is setup to be dedicated and then torn down and reconfigured to shared, the wq configured end up being dedicated anyays. The root cause is when idxd_device_wqs_clear_state() gets called during idxd_driver removal, idxd_wq_disable_cleanup() does not get called vs when the wq driver is removed first. The check of wq state being "enabled" causes the cleanup to be bypassed. However, idxd_driver->remove() releases all wq drivers. So the wqs goes to "disabled" state and will never be "enabled". By that point, the driver has no idea if the wq was previously configured or clean. So force call idxd_wq_disable_cleanup() on all wqs always to make sure everything gets cleaned up. Reported-by: Tony Zhu Tested-by: Tony Zhu Fixes: 0dcfe41e9a4c ("dmanegine: idxd: cleanup all device related bits afte= r disabling device") Signed-off-by: Dave Jiang Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20220628230056.2527816-1-fenghua.yu@intel.c= om Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- drivers/dma/idxd/device.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -720,10 +720,7 @@ static void idxd_device_wqs_clear_state( for (i =3D 0; i < idxd->max_wqs; i++) { struct idxd_wq *wq =3D idxd->wqs[i]; =20 - if (wq->state =3D=3D IDXD_WQ_ENABLED) { - idxd_wq_disable_cleanup(wq); - wq->state =3D IDXD_WQ_DISABLED; - } + idxd_wq_disable_cleanup(wq); idxd_wq_device_reset_cleanup(wq); } } From nobody Sat Apr 18 21:00:49 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 7A1BBC433EF for ; Mon, 11 Jul 2022 10:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbiGKKFM (ORCPT ); Mon, 11 Jul 2022 06:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbiGKKDg (ORCPT ); Mon, 11 Jul 2022 06:03:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B650748EB7; Mon, 11 Jul 2022 02:29: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 dfw.source.kernel.org (Postfix) with ESMTPS id 5355F6141D; Mon, 11 Jul 2022 09:29:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C607C34115; Mon, 11 Jul 2022 09:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531781; bh=RfUoO/kK49NxXAgZqG2VhQS9b0PB98R1OjGwGJyKmy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Du0LzbZ4k/N5rbFGyLMfgQgDiubnTOBYh450011xeUtAHvrUHzGrt51VUOiGtgmq U5h+2tObRQ8/H9RFvFD+zVWxjeWFV5cX0dDg3XEicrRi8U3DMLKsAek3MsFgl2ZbuB xYySAoJ2YSLEeK1Sm3e9w8SI975JZL7TK5HUjZHU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangbin Liu , Andrii Nakryiko , Jakub Kicinski Subject: [PATCH 5.15 230/230] selftests/net: fix section name when using xdp_dummy.o Date: Mon, 11 Jul 2022 11:08:06 +0200 Message-Id: <20220711090610.625380037@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 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: Hangbin Liu commit d28b25a62a47a8c8aa19bd543863aab6717e68c9 upstream. Since commit 8fffa0e3451a ("selftests/bpf: Normalize XDP section names in selftests") the xdp_dummy.o's section name has changed to xdp. But some tests are still using "section xdp_dummy", which make the tests failed. Fix them by updating to the new section name. Fixes: 8fffa0e3451a ("selftests/bpf: Normalize XDP section names in selftes= ts") Signed-off-by: Hangbin Liu Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/r/20220630062228.3453016-1-liuhangbin@gmail.c= om Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Bagas Sanjaya Reported-by: Linux Kernel Functional Testing Tested-by: Bagas Sanjaya --- tools/testing/selftests/net/udpgro.sh | 2 +- tools/testing/selftests/net/udpgro_bench.sh | 2 +- tools/testing/selftests/net/udpgro_fwd.sh | 2 +- tools/testing/selftests/net/veth.sh | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) --- a/tools/testing/selftests/net/udpgro.sh +++ b/tools/testing/selftests/net/udpgro.sh @@ -34,7 +34,7 @@ cfg_veth() { ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24 ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad ip -netns "${PEER_NS}" link set dev veth1 up - ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section x= dp_dummy + ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section x= dp } =20 run_one() { --- a/tools/testing/selftests/net/udpgro_bench.sh +++ b/tools/testing/selftests/net/udpgro_bench.sh @@ -34,7 +34,7 @@ run_one() { ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad ip -netns "${PEER_NS}" link set dev veth1 up =20 - ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section x= dp_dummy + ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section x= dp ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r & ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r & =20 --- a/tools/testing/selftests/net/udpgro_fwd.sh +++ b/tools/testing/selftests/net/udpgro_fwd.sh @@ -46,7 +46,7 @@ create_ns() { ip -n $BASE$ns addr add dev veth$ns $BM_NET_V4$ns/24 ip -n $BASE$ns addr add dev veth$ns $BM_NET_V6$ns/64 nodad done - ip -n $NS_DST link set veth$DST xdp object ../bpf/xdp_dummy.o section xdp= _dummy 2>/dev/null + ip -n $NS_DST link set veth$DST xdp object ../bpf/xdp_dummy.o section xdp= 2>/dev/null } =20 create_vxlan_endpoint() { --- a/tools/testing/selftests/net/veth.sh +++ b/tools/testing/selftests/net/veth.sh @@ -289,14 +289,14 @@ if [ $CPUS -gt 1 ]; then ip netns exec $NS_SRC ethtool -L veth$SRC rx 1 tx 2 2>/dev/null printf "%-60s" "bad setting: XDP with RX nr less than TX" ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o \ - section xdp_dummy 2>/dev/null &&\ + section xdp 2>/dev/null &&\ echo "fail - set operation successful ?!?" || echo " ok " =20 # the following tests will run with multiple channels active ip netns exec $NS_SRC ethtool -L veth$SRC rx 2 ip netns exec $NS_DST ethtool -L veth$DST rx 2 ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o \ - section xdp_dummy 2>/dev/null + section xdp 2>/dev/null printf "%-60s" "bad setting: reducing RX nr below peer TX with XDP set" ip netns exec $NS_DST ethtool -L veth$DST rx 1 2>/dev/null &&\ echo "fail - set operation successful ?!?" || echo " ok " @@ -311,7 +311,7 @@ if [ $CPUS -gt 2 ]; then chk_channels "setting invalid channels nr" $DST 2 2 fi =20 -ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o section = xdp_dummy 2>/dev/null +ip -n $NS_DST link set dev veth$DST xdp object ../bpf/xdp_dummy.o section = xdp 2>/dev/null chk_gro_flag "with xdp attached - gro flag" $DST on chk_gro_flag " - peer gro flag" $SRC off chk_tso_flag " - tso flag" $SRC off