From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB723C4321E for ; Mon, 7 Feb 2022 12:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391184AbiBGL6l (ORCPT ); Mon, 7 Feb 2022 06:58:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385472AbiBGLby (ORCPT ); Mon, 7 Feb 2022 06:31:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 139F2C02B671; Mon, 7 Feb 2022 03:30:28 -0800 (PST) Received: from smtp.kernel.org (relay.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 9BDFF60AB0; Mon, 7 Feb 2022 11:30:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6103FC004E1; Mon, 7 Feb 2022 11:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233427; bh=A1rMhRx1IR6nDl1kC20YzOonK0OAz8N4dIY/i/zc29s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s1MrCR0qp/J/w0ZGpB8yeAmPe+MYTNmhdK/BG87/s+8CPQT4lYLv8rLb/+K/Kyakj UGDkcyi8sVuUg47p1pseoUNrg69rAvkVl4800iAT4z29OVk+/06nN5EA411ok1W0LI 02akeL7wxdrJ5x35DDxv5uaY27y/tiQxC8+OPe5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Uma Shankar , Mario Kleiner Subject: [PATCH 5.16 001/126] drm/i915: Disable DSB usage for now Date: Mon, 7 Feb 2022 12:05:32 +0100 Message-Id: <20220207103804.104537478@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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 commit 99510e1afb4863a225207146bd988064c5fd0629 upstream. Turns out the DSB has trouble correctly loading the gamma LUT. >From a cursory look maybe like some entries do not load properly, or they get loaded with some gibberish. Unfortunately our current kms_color/etc. tests do not seem to catch this. I had a brief look at the generated DSB batch and it looked correct. Tried a few quick tricks like writing the index register twice/etc. but didn't see any improvement. Also tried switching to the 10bit gamma mode in case there is yet another issue with the multi-segment mode, but even the 10bit mode was showing issues. Switching to mmio fixes all of it. I suppose one theory is that maybe the DSB bangs on the LUT too quickly and it can't keep up and instead some data either gets dropped or corrupted. To confirm that someone should try to slow down the DSB's progress a bit. Another thought was that maybe the LUT has crappy dual porting and you get contention if you try to load it during active scanout. But why then would the mmio path work, unless it's just sufficiently slow? Whatever the case, this is currently busted so let's disable it until we get to the root of the problem. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3916 Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20211014181856.17581-2-= ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar Cc: Mario Kleiner Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/i915_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -866,7 +866,7 @@ static const struct intel_device_info js TGL_CURSOR_OFFSETS, \ .has_global_mocs =3D 1, \ .has_pxp =3D 1, \ - .display.has_dsb =3D 1 + .display.has_dsb =3D 0 /* FIXME: LUT load is broken with DSB */ =20 static const struct intel_device_info tgl_info =3D { GEN12_FEATURES, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D604BC35280 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391148AbiBGL6f (ORCPT ); Mon, 7 Feb 2022 06:58:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385577AbiBGLcA (ORCPT ); Mon, 7 Feb 2022 06:32:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C866C03E900; Mon, 7 Feb 2022 03:30:59 -0800 (PST) Received: from smtp.kernel.org (relay.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 D748260B20; Mon, 7 Feb 2022 11:30:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 928EFC004E1; Mon, 7 Feb 2022 11:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233458; bh=CEnQ53IN8cOKxoel8rwqWyPAl4pA6ktgqF4J4Ryl9Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slXwP7ydxJjdQt9SxgTnXORdEKAM4eipLco7soygARe9G+IwdIln5vevNyxrIe4Ut FWJoY+dSqcdmv2hoY8XBR3lGUqzX/GmYcsem6e21DrrNT4Y97bV4bkm0tPfejpx0NQ 8eMtBAp0fnarL1Sihrjr84MkXwO2xrWgFutCqj8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vratislav Bendel , Paul Moore Subject: [PATCH 5.16 002/126] selinux: fix double free of cond_list on error paths Date: Mon, 7 Feb 2022 12:05:33 +0100 Message-Id: <20220207103804.140013578@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Vratislav Bendel commit 186edf7e368c40d06cf727a1ad14698ea67b74ad upstream. On error path from cond_read_list() and duplicate_policydb_cond_list() the cond_list_destroy() gets called a second time in caller functions, resulting in NULL pointer deref. Fix this by resetting the cond_list_len to 0 in cond_list_destroy(), making subsequent calls a noop. Also consistently reset the cond_list pointer to NULL after freeing. Cc: stable@vger.kernel.org Signed-off-by: Vratislav Bendel [PM: fix line lengths in the description] Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- security/selinux/ss/conditional.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -152,6 +152,8 @@ static void cond_list_destroy(struct pol for (i =3D 0; i < p->cond_list_len; i++) cond_node_destroy(&p->cond_list[i]); kfree(p->cond_list); + p->cond_list =3D NULL; + p->cond_list_len =3D 0; } =20 void cond_policydb_destroy(struct policydb *p) @@ -441,7 +443,6 @@ int cond_read_list(struct policydb *p, v return 0; err: cond_list_destroy(p); - p->cond_list =3D NULL; return rc; } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67F22C433F5 for ; Mon, 7 Feb 2022 11:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388158AbiBGLnF (ORCPT ); Mon, 7 Feb 2022 06:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385579AbiBGLcA (ORCPT ); Mon, 7 Feb 2022 06:32:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BF8C03E97F; Mon, 7 Feb 2022 03:31:02 -0800 (PST) Received: from smtp.kernel.org (relay.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 A220160A67; Mon, 7 Feb 2022 11:31:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA051C004E1; Mon, 7 Feb 2022 11:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233461; bh=vhAEzco/UHCmcxF7QDa7KCLTLJqPXpSuTCLSQsFmnXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHcYlGNlKz6rSh3D9psngqxbqTnTlB4SYgE6Ign+3lSs1Ikuzhy2cEUMzw1JqCzXF JbiItU6eE0WxqX7Pohj/7UJTuHnoFSPFj9bsPHy5E7fwN4n707SEJq2ydhXRPrdLTR J7Wjy4RM9hB6cPe61vbyafj0xZDBEXq6iwpIQoOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gaosheng Cui , Richard Guy Briggs , Paul Moore Subject: [PATCH 5.16 003/126] audit: improve audit queue handling when "audit=1" on cmdline Date: Mon, 7 Feb 2022 12:05:34 +0100 Message-Id: <20220207103804.178436990@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Moore commit f26d04331360d42dbd6b58448bd98e4edbfbe1c5 upstream. When an admin enables audit at early boot via the "audit=3D1" kernel command line the audit queue behavior is slightly different; the audit subsystem goes to greater lengths to avoid dropping records, which unfortunately can result in problems when the audit daemon is forcibly stopped for an extended period of time. This patch makes a number of changes designed to improve the audit queuing behavior so that leaving the audit daemon in a stopped state for an extended period does not cause a significant impact to the system. - kauditd_send_queue() is now limited to looping through the passed queue only once per call. This not only prevents the function from looping indefinitely when records are returned to the current queue, it also allows any recovery handling in kauditd_thread() to take place when kauditd_send_queue() returns. - Transient netlink send errors seen as -EAGAIN now cause the record to be returned to the retry queue instead of going to the hold queue. The intention of the hold queue is to store, perhaps for an extended period of time, the events which led up to the audit daemon going offline. The retry queue remains a temporary queue intended to protect against transient issues between the kernel and the audit daemon. - The retry queue is now limited by the audit_backlog_limit setting, the same as the other queues. This allows admins to bound the size of all of the audit queues on the system. - kauditd_rehold_skb() now returns records to the end of the hold queue to ensure ordering is preserved in the face of recent changes to kauditd_send_queue(). Cc: stable@vger.kernel.org Fixes: 5b52330bbfe63 ("audit: fix auditd/kernel connection state tracking") Fixes: f4b3ee3c85551 ("audit: improve robustness of the audit queue handlin= g") Reported-by: Gaosheng Cui Tested-by: Gaosheng Cui Reviewed-by: Richard Guy Briggs Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/audit.c | 62 +++++++++++++++++++++++++++++++++++++++-------------= ----- 1 file changed, 43 insertions(+), 19 deletions(-) --- a/kernel/audit.c +++ b/kernel/audit.c @@ -541,20 +541,22 @@ static void kauditd_printk_skb(struct sk /** * kauditd_rehold_skb - Handle a audit record send failure in the hold que= ue * @skb: audit record + * @error: error code (unused) * * Description: * This should only be used by the kauditd_thread when it fails to flush t= he * hold queue. */ -static void kauditd_rehold_skb(struct sk_buff *skb) +static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int er= ror) { - /* put the record back in the queue at the same place */ - skb_queue_head(&audit_hold_queue, skb); + /* put the record back in the queue */ + skb_queue_tail(&audit_hold_queue, skb); } =20 /** * kauditd_hold_skb - Queue an audit record, waiting for auditd * @skb: audit record + * @error: error code * * Description: * Queue the audit record, waiting for an instance of auditd. When this @@ -564,19 +566,31 @@ static void kauditd_rehold_skb(struct sk * and queue it, if we have room. If we want to hold on to the record, bu= t we * don't have room, record a record lost message. */ -static void kauditd_hold_skb(struct sk_buff *skb) +static void kauditd_hold_skb(struct sk_buff *skb, int error) { /* at this point it is uncertain if we will ever send this to auditd so * try to send the message via printk before we go any further */ kauditd_printk_skb(skb); =20 /* can we just silently drop the message? */ - if (!audit_default) { - kfree_skb(skb); - return; + if (!audit_default) + goto drop; + + /* the hold queue is only for when the daemon goes away completely, + * not -EAGAIN failures; if we are in a -EAGAIN state requeue the + * record on the retry queue unless it's full, in which case drop it + */ + if (error =3D=3D -EAGAIN) { + if (!audit_backlog_limit || + skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + skb_queue_tail(&audit_retry_queue, skb); + return; + } + audit_log_lost("kauditd retry queue overflow"); + goto drop; } =20 - /* if we have room, queue the message */ + /* if we have room in the hold queue, queue the message */ if (!audit_backlog_limit || skb_queue_len(&audit_hold_queue) < audit_backlog_limit) { skb_queue_tail(&audit_hold_queue, skb); @@ -585,24 +599,32 @@ static void kauditd_hold_skb(struct sk_b =20 /* we have no other options - drop the message */ audit_log_lost("kauditd hold queue overflow"); +drop: kfree_skb(skb); } =20 /** * kauditd_retry_skb - Queue an audit record, attempt to send again to aud= itd * @skb: audit record + * @error: error code (unused) * * Description: * Not as serious as kauditd_hold_skb() as we still have a connected audit= d, * but for some reason we are having problems sending it audit records so * queue the given record and attempt to resend. */ -static void kauditd_retry_skb(struct sk_buff *skb) +static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int err= or) { - /* NOTE: because records should only live in the retry queue for a - * short period of time, before either being sent or moved to the hold - * queue, we don't currently enforce a limit on this queue */ - skb_queue_tail(&audit_retry_queue, skb); + if (!audit_backlog_limit || + skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + skb_queue_tail(&audit_retry_queue, skb); + return; + } + + /* we have to drop the record, send it via printk as a last effort */ + kauditd_printk_skb(skb); + audit_log_lost("kauditd retry queue overflow"); + kfree_skb(skb); } =20 /** @@ -640,7 +662,7 @@ static void auditd_reset(const struct au /* flush the retry queue to the hold queue, but don't touch the main * queue since we need to process that normally for multicast */ while ((skb =3D skb_dequeue(&audit_retry_queue))) - kauditd_hold_skb(skb); + kauditd_hold_skb(skb, -ECONNREFUSED); } =20 /** @@ -714,16 +736,18 @@ static int kauditd_send_queue(struct soc struct sk_buff_head *queue, unsigned int retry_limit, void (*skb_hook)(struct sk_buff *skb), - void (*err_hook)(struct sk_buff *skb)) + void (*err_hook)(struct sk_buff *skb, int error)) { int rc =3D 0; - struct sk_buff *skb; + struct sk_buff *skb =3D NULL; + struct sk_buff *skb_tail; unsigned int failed =3D 0; =20 /* NOTE: kauditd_thread takes care of all our locking, we just use * the netlink info passed to us (e.g. sk and portid) */ =20 - while ((skb =3D skb_dequeue(queue))) { + skb_tail =3D skb_peek_tail(queue); + while ((skb !=3D skb_tail) && (skb =3D skb_dequeue(queue))) { /* call the skb_hook for each skb we touch */ if (skb_hook) (*skb_hook)(skb); @@ -731,7 +755,7 @@ static int kauditd_send_queue(struct soc /* can we send to anyone via unicast? */ if (!sk) { if (err_hook) - (*err_hook)(skb); + (*err_hook)(skb, -ECONNREFUSED); continue; } =20 @@ -745,7 +769,7 @@ retry: rc =3D=3D -ECONNREFUSED || rc =3D=3D -EPERM) { sk =3D NULL; if (err_hook) - (*err_hook)(skb); + (*err_hook)(skb, rc); if (rc =3D=3D -EAGAIN) rc =3D 0; /* continue to drain the queue */ From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E50E1C433EF for ; Mon, 7 Feb 2022 11:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388128AbiBGLnC (ORCPT ); Mon, 7 Feb 2022 06:43:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385604AbiBGLcB (ORCPT ); Mon, 7 Feb 2022 06:32:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88DD1C03E937; Mon, 7 Feb 2022 03:31:06 -0800 (PST) Received: from smtp.kernel.org (relay.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 4355BB80EC3; Mon, 7 Feb 2022 11:31:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CB5C004E1; Mon, 7 Feb 2022 11:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233464; bh=UBUGUaJZe93yLz+nk7Ton8WJCc+VGhP2Z/SUcF67TSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YFvrwteB+mdXqWaI/TEqe9p+HZVz/ssmC7faZDfiqz2w6yaAdXubolA2H6fgUqu3Z 5cNB74YztiImKAE4WdRGGT2B8eR2S/A4kPDWHx1CgghewNpGFcmFzJ82+JNRKDuyjr NQWH7NaHwj+obOgIRTqczbIAD6MoBue0dhM8lDIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Minghao Chi , Shakeel Butt , Manfred Spraul , Arnd Bergmann , Yang Guang , Davidlohr Bueso , Randy Dunlap , Bhaskar Chowdhury , Vasily Averin , Andrew Morton , Linus Torvalds Subject: [PATCH 5.16 004/126] ipc/sem: do not sleep with a spin lock held Date: Mon, 7 Feb 2022 12:05:35 +0100 Message-Id: <20220207103804.211134497@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Minghao Chi commit 520ba724061cef59763e2b6f5b26e8387c2e5822 upstream. We can't call kvfree() with a spin lock held, so defer it. Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com= .cn Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation= ") Reported-by: Zeal Robot Signed-off-by: Minghao Chi Reviewed-by: Shakeel Butt Reviewed-by: Manfred Spraul Cc: Arnd Bergmann Cc: Yang Guang Cc: Davidlohr Bueso Cc: Randy Dunlap Cc: Bhaskar Chowdhury Cc: Vasily Averin Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- ipc/sem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo( */ un =3D lookup_undo(ulp, semid); if (un) { + spin_unlock(&ulp->lock); kvfree(new); goto success; } @@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo( ipc_assert_locked_object(&sma->sem_perm); list_add(&new->list_id, &sma->list_id); un =3D new; - -success: spin_unlock(&ulp->lock); +success: sem_unlock(sma, -1); out: return un; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E54C4332F for ; Mon, 7 Feb 2022 11:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388114AbiBGLnA (ORCPT ); Mon, 7 Feb 2022 06:43:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385612AbiBGLcB (ORCPT ); Mon, 7 Feb 2022 06:32:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C4DC03CA49; Mon, 7 Feb 2022 03:31:09 -0800 (PST) Received: from smtp.kernel.org (relay.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 3E159B80EBD; Mon, 7 Feb 2022 11:31:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A95CC004E1; Mon, 7 Feb 2022 11:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233467; bh=OOrci6zsJTgNVekK33PRhoxSHZ4Cd74TJOKyCSGkGLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqs8VEO2XbAtpdbdgmxIuQJ+mid9ZZWNHVkkh2CZumU7zbcuAkaRm7nD2hTP4tlJW EDZ4niGYFjFVJ/iiSxldY1qcAX2c6913eIYFfUiRf0CYw2ufL+RgH29LHJcjeJjkgX x1QHuztrcbY4EUSFm6HQmRg5lqITBdxFne/TKmVk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrice Chotard , Lukas Wunner , Mark Brown Subject: [PATCH 5.16 005/126] spi: stm32-qspi: Update spi registering Date: Mon, 7 Feb 2022 12:05:36 +0100 Message-Id: <20220207103804.249514249@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Patrice Chotard commit e4d63473d3110afd170e6e0e48494d3789d26136 upstream. Some device driver need to communicate to qspi device during the remove process, qspi controller must be functional when spi_unregister_master() is called. To ensure this, replace devm_spi_register_master() by spi_register_master() and spi_unregister_master() is called directly in .remove callback before stopping the qspi controller. This issue was put in evidence using kernel v5.11 and later with a spi-nor which supports the software reset feature introduced by commit d73ee7534cc5 ("mtd: spi-nor: core: perform a Soft Reset on shutdown") Fixes: c530cd1d9d5e ("spi: spi-mem: add stm32 qspi controller") Signed-off-by: Patrice Chotard Cc: # 5.8.x Reviewed-by: Lukas Wunner Link: https://lore.kernel.org/r/20220117121744.29729-1-patrice.chotard@foss= .st.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-stm32-qspi.c | 47 +++++++++++++++-----------------------= ----- 1 file changed, 17 insertions(+), 30 deletions(-) --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -688,7 +688,7 @@ static int stm32_qspi_probe(struct platf struct resource *res; int ret, irq; =20 - ctrl =3D spi_alloc_master(dev, sizeof(*qspi)); + ctrl =3D devm_spi_alloc_master(dev, sizeof(*qspi)); if (!ctrl) return -ENOMEM; =20 @@ -697,58 +697,46 @@ static int stm32_qspi_probe(struct platf =20 res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi"); qspi->io_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(qspi->io_base)) { - ret =3D PTR_ERR(qspi->io_base); - goto err_master_put; - } + if (IS_ERR(qspi->io_base)) + return PTR_ERR(qspi->io_base); =20 qspi->phys_base =3D res->start; =20 res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm"); qspi->mm_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(qspi->mm_base)) { - ret =3D PTR_ERR(qspi->mm_base); - goto err_master_put; - } + if (IS_ERR(qspi->mm_base)) + return PTR_ERR(qspi->mm_base); =20 qspi->mm_size =3D resource_size(res); - if (qspi->mm_size > STM32_QSPI_MAX_MMAP_SZ) { - ret =3D -EINVAL; - goto err_master_put; - } + if (qspi->mm_size > STM32_QSPI_MAX_MMAP_SZ) + return -EINVAL; =20 irq =3D platform_get_irq(pdev, 0); - if (irq < 0) { - ret =3D irq; - goto err_master_put; - } + if (irq < 0) + return irq; =20 ret =3D devm_request_irq(dev, irq, stm32_qspi_irq, 0, dev_name(dev), qspi); if (ret) { dev_err(dev, "failed to request irq\n"); - goto err_master_put; + return ret; } =20 init_completion(&qspi->data_completion); init_completion(&qspi->match_completion); =20 qspi->clk =3D devm_clk_get(dev, NULL); - if (IS_ERR(qspi->clk)) { - ret =3D PTR_ERR(qspi->clk); - goto err_master_put; - } + if (IS_ERR(qspi->clk)) + return PTR_ERR(qspi->clk); =20 qspi->clk_rate =3D clk_get_rate(qspi->clk); - if (!qspi->clk_rate) { - ret =3D -EINVAL; - goto err_master_put; - } + if (!qspi->clk_rate) + return -EINVAL; =20 ret =3D clk_prepare_enable(qspi->clk); if (ret) { dev_err(dev, "can not enable the clock\n"); - goto err_master_put; + return ret; } =20 rstc =3D devm_reset_control_get_exclusive(dev, NULL); @@ -784,7 +772,7 @@ static int stm32_qspi_probe(struct platf pm_runtime_enable(dev); pm_runtime_get_noresume(dev); =20 - ret =3D devm_spi_register_master(dev, ctrl); + ret =3D spi_register_master(ctrl); if (ret) goto err_pm_runtime_free; =20 @@ -806,8 +794,6 @@ err_dma_free: stm32_qspi_dma_free(qspi); err_clk_disable: clk_disable_unprepare(qspi->clk); -err_master_put: - spi_master_put(qspi->ctrl); =20 return ret; } @@ -817,6 +803,7 @@ static int stm32_qspi_remove(struct plat struct stm32_qspi *qspi =3D platform_get_drvdata(pdev); =20 pm_runtime_get_sync(qspi->dev); + spi_unregister_master(qspi->ctrl); /* disable qspi */ writel_relaxed(0, qspi->io_base + QSPI_CR); stm32_qspi_dma_free(qspi); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F316FC35294 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391155AbiBGL6g (ORCPT ); Mon, 7 Feb 2022 06:58:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385613AbiBGLcB (ORCPT ); Mon, 7 Feb 2022 06:32:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4985CC03CA4B; Mon, 7 Feb 2022 03:31:11 -0800 (PST) Received: from smtp.kernel.org (relay.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 D4EAE60B20; Mon, 7 Feb 2022 11:31:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4D6C340EB; Mon, 7 Feb 2022 11:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233470; bh=5IsXqdmiyDuHjCKLVr33FdSRI3q+QbGeX0U1P/98KaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpdlaYUuFKDBNLzMrjnDoomZmrM2ls4juHZlczdsnRlA7BOCkZ7KrgxUsJwgsuvgx LyeA4mLciJDhPaTVlHVeZzdLsnnjIDTm/cVkMCBUc8iVqTMp+0uO9EdiZiM3t0jVtk AB+yJjdgLkM/nPoM+oMoyBd0QAabWhAVrFaOW+Dc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Mark Brown Subject: [PATCH 5.16 006/126] ASoC: hdmi-codec: Fix OOB memory accesses Date: Mon, 7 Feb 2022 12:05:37 +0100 Message-Id: <20220207103804.281396179@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 06feec6005c9d9500cd286ec440aabf8b2ddd94d upstream. Correct size of iec_status array by changing it to the size of status array of the struct snd_aes_iec958. This fixes out-of-bounds slab read accesses made by memcpy() of the hdmi-codec driver. This problem is reported by KASAN. Cc: stable@vger.kernel.org Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20220112195039.1329-1-digetx@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- include/uapi/sound/asound.h | 4 +++- sound/soc/codecs/hdmi-codec.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -56,8 +56,10 @@ * = * *************************************************************************= ***/ =20 +#define AES_IEC958_STATUS_SIZE 24 + struct snd_aes_iec958 { - unsigned char status[24]; /* AES/IEC958 channel status bits */ + unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel statu= s bits */ unsigned char subcode[147]; /* AES/IEC958 subcode bits */ unsigned char pad; /* nothing */ unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */ --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -277,7 +277,7 @@ struct hdmi_codec_priv { bool busy; struct snd_soc_jack *jack; unsigned int jack_status; - u8 iec_status[5]; + u8 iec_status[AES_IEC958_STATUS_SIZE]; }; =20 static const struct snd_soc_dapm_widget hdmi_widgets[] =3D { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29054C4332F for ; Mon, 7 Feb 2022 11:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388069AbiBGLmu (ORCPT ); Mon, 7 Feb 2022 06:42:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385628AbiBGLcD (ORCPT ); Mon, 7 Feb 2022 06:32:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25EF8C03C188; Mon, 7 Feb 2022 03:31:16 -0800 (PST) Received: from smtp.kernel.org (relay.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 7DC4EB80EC3; Mon, 7 Feb 2022 11:31:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D640CC004E1; Mon, 7 Feb 2022 11:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233473; bh=PXxvrLo0f5n0j+2ESXkHAGvNHfjbEgwhgKzsc6FW1F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hS3KZFwJCm2WI6hwWUN/YOrdvusyANhbjofhosbzGZ+JpWLVfeBlV7IMx+HYgxlGo tBKGrAqEkcWMpMlqewcqZDWqPvNNbKegp7Sz/FqKPvVdNAKDHUg5/0x1+f+b8XwjmY TVQKvnugsvNJ1L5qjIJo/9zhJsMLPKnTfGZMF8EU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.16 007/126] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Date: Mon, 7 Feb 2022 12:05:38 +0100 Message-Id: <20220207103804.313847490@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Brown commit 817f7c9335ec01e0f5e8caffc4f1dcd5e458a4c0 upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-2-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -316,13 +316,27 @@ int snd_soc_put_volsw(struct snd_kcontro if (sign_bit) mask =3D BIT(sign_bit + 1) - 1; =20 - val =3D ((ucontrol->value.integer.value[0] + min) & mask); + val =3D ucontrol->value.integer.value[0]; + if (mc->platform_max && val > mc->platform_max) + return -EINVAL; + if (val > max - min) + return -EINVAL; + if (val < 0) + return -EINVAL; + val =3D (val + min) & mask; if (invert) val =3D max - val; val_mask =3D mask << shift; val =3D val << shift; if (snd_soc_volsw_is_stereo(mc)) { - val2 =3D ((ucontrol->value.integer.value[1] + min) & mask); + val2 =3D ucontrol->value.integer.value[1]; + if (mc->platform_max && val2 > mc->platform_max) + return -EINVAL; + if (val2 > max - min) + return -EINVAL; + if (val2 < 0) + return -EINVAL; + val2 =3D (val2 + min) & mask; if (invert) val2 =3D max - val2; if (reg =3D=3D reg2) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99A9EC433F5 for ; Mon, 7 Feb 2022 11:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388084AbiBGLmy (ORCPT ); Mon, 7 Feb 2022 06:42:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385632AbiBGLcD (ORCPT ); Mon, 7 Feb 2022 06:32:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A7CC03E97B; Mon, 7 Feb 2022 03:31:17 -0800 (PST) Received: from smtp.kernel.org (relay.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 4E06A60A67; Mon, 7 Feb 2022 11:31:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D906C004E1; Mon, 7 Feb 2022 11:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233476; bh=u4UjAcFF1Zp7pNCg0/6sdayjl3EP4O06VFNJH8ux4dM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WCAusrYktKQ8Qrf5q/uFB54nitZyNWBjM3ha7v6/5G8PhdSFZg2RJH0TSmBOwZL/D VyxEdmDrpAyv+r12zzqmbhwE3JqvxQuALCDFdmKHtZY5P1ToZn+nJeSte1VxO97S30 9vFo/9pGfTQfKp/d3TVdVCHv6GExtTfolCUBh6KA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.16 008/126] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Date: Mon, 7 Feb 2022 12:05:39 +0100 Message-Id: <20220207103804.346066525@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Brown commit 4f1e50d6a9cf9c1b8c859d449b5031cacfa8404e upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-3-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -423,8 +423,15 @@ int snd_soc_put_volsw_sx(struct snd_kcon int err =3D 0; unsigned int val, val_mask; =20 + val =3D ucontrol->value.integer.value[0]; + if (mc->platform_max && val > mc->platform_max) + return -EINVAL; + if (val > max - min) + return -EINVAL; + if (val < 0) + return -EINVAL; val_mask =3D mask << shift; - val =3D (ucontrol->value.integer.value[0] + min) & mask; + val =3D (val + min) & mask; val =3D val << shift; =20 err =3D snd_soc_component_update_bits(component, reg, val_mask, val); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 105DEC35295 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391162AbiBGL6i (ORCPT ); Mon, 7 Feb 2022 06:58:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385637AbiBGLcE (ORCPT ); Mon, 7 Feb 2022 06:32:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16140C03C190; Mon, 7 Feb 2022 03:31:21 -0800 (PST) Received: from smtp.kernel.org (relay.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 A56E560A67; Mon, 7 Feb 2022 11:31:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A07C340EB; Mon, 7 Feb 2022 11:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233480; bh=/hAnYNohmzw9oQdX6Kt9aR6iA/2JH1LYTQg7rMfMCQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xg/DDpwgtmJJ3dWWn6TkfAhohJ5iubJY2PVbMBhiEfPs1HEkw+LF6aJ0eLLZSfMZ6 JOaxuN80+1wHdbWuD5OVsXyQotBTlBUvBUWimXofezIsWcsf1Hna8vsMOgCCPanbWX /lYymyUtsfO6dTv+jRAaH2efuh/1687vu8qYV648= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.16 009/126] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Date: Mon, 7 Feb 2022 12:05:40 +0100 Message-Id: <20220207103804.379642678@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Brown commit 4cf28e9ae6e2e11a044be1bcbcfa1b0d8675fe4d upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-4-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -879,6 +879,8 @@ int snd_soc_put_xr_sx(struct snd_kcontro long val =3D ucontrol->value.integer.value[0]; unsigned int i; =20 + if (val < mc->min || val > mc->max) + return -EINVAL; if (invert) val =3D max - val; val &=3D mask; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D62C35296 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391176AbiBGL6k (ORCPT ); Mon, 7 Feb 2022 06:58:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385484AbiBGLby (ORCPT ); Mon, 7 Feb 2022 06:31:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A17DC03F93F; Mon, 7 Feb 2022 03:30:31 -0800 (PST) Received: from smtp.kernel.org (relay.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 ABA3B60AB0; Mon, 7 Feb 2022 11:30:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84ACBC004E1; Mon, 7 Feb 2022 11:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233430; bh=xjkRWAuO6sjuAxBcS+6c7kSyPv7Q3Yfk0x1pK5sdx1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlWz7zmJ7oA1Xkk9qcUJGklv6hw8BLVngWURiJmsOYG2R9k3LRsErNjJR/v6XAdrp R06GCmQRsdrr4y6zUxA4aLH3rT4bUgY2BgDb1yxsPAf2qKscYqLkoXhtFdk26lPhFx eneCnyqo+BQjiBgEHYmyAQEZZ3wJdRpClOPB3zO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jukka Heikintalo , =?UTF-8?q?Pawe=C5=82=20Susicki?= , Jonas Hahnfeld , Takashi Iwai Subject: [PATCH 5.16 010/126] ALSA: usb-audio: Correct quirk for VF0770 Date: Mon, 7 Feb 2022 12:05:41 +0100 Message-Id: <20220207103804.413334168@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Jonas Hahnfeld commit 4ee02e20893d2f9e951c7888f2284fa608ddaa35 upstream. This device provides both audio and video. The original quirk added in commit 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770") used USB_DEVICE to match the vendor and product ID. Depending on module order, if snd-usb-audio was asked first, it would match the entire device and uvcvideo wouldn't get to see it. Change the matching to USB_AUDIO_DEVICE to restore uvcvideo matching in all cases. Fixes: 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770") Reported-by: Jukka Heikintalo Tested-by: Jukka Heikintalo Reported-by: Pawe=C5=82 Susicki Tested-by: Pawe=C5=82 Susicki Cc: # 5.4, 5.10, 5.14, 5.15 Signed-off-by: Jonas Hahnfeld Link: https://lore.kernel.org/r/20220131183516.61191-1-hahnjo@hahnjo.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/usb/quirks-table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -84,7 +84,7 @@ * combination. */ { - USB_DEVICE(0x041e, 0x4095), + USB_AUDIO_DEVICE(0x041e, 0x4095), .driver_info =3D (unsigned long) &(const struct snd_usb_audio_quirk) { .ifnum =3D QUIRK_ANY_INTERFACE, .type =3D QUIRK_COMPOSITE, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38164C4167B for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388422AbiBGLnl (ORCPT ); Mon, 7 Feb 2022 06:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385490AbiBGLbz (ORCPT ); Mon, 7 Feb 2022 06:31:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55260C03E952; Mon, 7 Feb 2022 03:30:34 -0800 (PST) Received: from smtp.kernel.org (relay.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 D9F346077B; Mon, 7 Feb 2022 11:30:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFE2DC004E1; Mon, 7 Feb 2022 11:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233433; bh=5OlD3dhXOCojKO3N7H+U3aupk719bOzjvga7rhxB4wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQlkwCeQH2nm+ActBsIL3oOEctHfOKCEpl504jYoNdbarnRLpTWZxBdPHJnsVzJbg Bn8zQWCzoTXvsJy/DbgKvojJvFvxybGsW86rexdbHrEnh+Khdw/ItsIKF42DCF4Dcs eUimsYSBk51YU72ZgbkX/2hNMUUs/MU9aPS5e58g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sergeyev , Takashi Iwai Subject: [PATCH 5.16 011/126] ALSA: hda: Fix UAF of leds class devs at unbinding Date: Mon, 7 Feb 2022 12:05:42 +0100 Message-Id: <20220207103804.452290450@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 549f8ffc7b2f7561bea7f90930b6c5104318e87b upstream. The LED class devices that are created by HD-audio codec drivers are registered via devm_led_classdev_register() and associated with the HD-audio codec device. Unfortunately, it turned out that the devres release doesn't work for this case; namely, since the codec resource release happens before the devm call chain, it triggers a NULL dereference or a UAF for a stale set_brightness_delay callback. For fixing the bug, this patch changes the LED class device register and unregister in a manual manner without devres, keeping the instances in hda_gen_spec. Reported-by: Alexander Sergeyev Cc: Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.l= ocaldomain Link: https://lore.kernel.org/r/20220126145011.16728-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_generic.c | 17 +++++++++++++++-- sound/pci/hda/hda_generic.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -91,6 +91,12 @@ static void snd_hda_gen_spec_free(struct free_kctls(spec); snd_array_free(&spec->paths); snd_array_free(&spec->loopback_list); +#ifdef CONFIG_SND_HDA_GENERIC_LEDS + if (spec->led_cdevs[LED_AUDIO_MUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); + if (spec->led_cdevs[LED_AUDIO_MICMUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); +#endif } =20 /* @@ -3922,7 +3928,10 @@ static int create_mute_led_cdev(struct h enum led_brightness), bool micmute) { + struct hda_gen_spec *spec =3D codec->spec; struct led_classdev *cdev; + int idx =3D micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE; + int err; =20 cdev =3D devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); if (!cdev) @@ -3932,10 +3941,14 @@ static int create_mute_led_cdev(struct h cdev->max_brightness =3D 1; cdev->default_trigger =3D micmute ? "audio-micmute" : "audio-mute"; cdev->brightness_set_blocking =3D callback; - cdev->brightness =3D ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_= AUDIO_MUTE); + cdev->brightness =3D ledtrig_audio_get(idx); cdev->flags =3D LED_CORE_SUSPENDRESUME; =20 - return devm_led_classdev_register(&codec->core.dev, cdev); + err =3D led_classdev_register(&codec->core.dev, cdev); + if (err < 0) + return err; + spec->led_cdevs[idx] =3D cdev; + return 0; } =20 /** --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -294,6 +294,9 @@ struct hda_gen_spec { struct hda_jack_callback *cb); void (*mic_autoswitch_hook)(struct hda_codec *codec, struct hda_jack_callback *cb); + + /* leds */ + struct led_classdev *led_cdevs[NUM_AUDIO_LEDS]; }; =20 /* values for add_stereo_mix_input flag */ From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3139C4167E for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388331AbiBGLnd (ORCPT ); Mon, 7 Feb 2022 06:43:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385522AbiBGLb4 (ORCPT ); Mon, 7 Feb 2022 06:31:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 141FAC03E963; Mon, 7 Feb 2022 03:30:38 -0800 (PST) Received: from smtp.kernel.org (relay.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 AD4AAB80EC3; Mon, 7 Feb 2022 11:30:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1FD8C004E1; Mon, 7 Feb 2022 11:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233436; bh=ax9fryblx6QV7qJ+qvkUKsP1d+CzKmmJDTBUlRRYv54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SofHlcAEqJe1VyQvKZkohCeYA5SPsoCkK7fsWFRdQeVI+mQBJzxyPDukVH+x5V7X5 uhXnXbICSGI6BBK3LuudArPlfGOw8U+JSJmSTe1PYaYGKtY13Vhur93x5/CqMyWZWA /38NsH1oEhiEykwR0McL+MJBw0daJUG+CGCDziGY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sergeyev , Takashi Iwai Subject: [PATCH 5.16 012/126] ALSA: hda: realtek: Fix race at concurrent COEF updates Date: Mon, 7 Feb 2022 12:05:43 +0100 Message-Id: <20220207103804.489874256@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 b837a9f5ab3bdfab9233c9f98a6bef717673a3e5 upstream. The COEF access is done with two steps: setting the index then read or write the data. When multiple COEF accesses are performed concurrently, the index and data might be paired unexpectedly. In most cases, this isn't a big problem as the COEF setup is done at the initialization, but some dynamic changes like the mute LED may hit such a race. For avoiding the racy COEF accesses, this patch introduces a new mutex coef_mutex to alc_spec, and wrap the COEF accessing functions with it. Reported-by: Alexander Sergeyev Cc: Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.l= ocaldomain Link: https://lore.kernel.org/r/20220131075738.24323-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 61 ++++++++++++++++++++++++++++++++++---= ----- 1 file changed, 50 insertions(+), 11 deletions(-) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -97,6 +97,7 @@ struct alc_spec { unsigned int gpio_mic_led_mask; struct alc_coef_led mute_led_coef; struct alc_coef_led mic_led_coef; + struct mutex coef_mutex; =20 hda_nid_t headset_mic_pin; hda_nid_t headphone_mic_pin; @@ -132,8 +133,8 @@ struct alc_spec { * COEF access helper functions */ =20 -static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, - unsigned int coef_idx) +static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx) { unsigned int val; =20 @@ -142,28 +143,61 @@ static int alc_read_coefex_idx(struct hd return val; } =20 +static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx) +{ + struct alc_spec *spec =3D codec->spec; + unsigned int val; + + mutex_lock(&spec->coef_mutex); + val =3D __alc_read_coefex_idx(codec, nid, coef_idx); + mutex_unlock(&spec->coef_mutex); + return val; +} + #define alc_read_coef_idx(codec, coef_idx) \ alc_read_coefex_idx(codec, 0x20, coef_idx) =20 -static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, - unsigned int coef_idx, unsigned int coef_val) +static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int coef_val) { snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); } =20 +static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int coef_val) +{ + struct alc_spec *spec =3D codec->spec; + + mutex_lock(&spec->coef_mutex); + __alc_write_coefex_idx(codec, nid, coef_idx, coef_val); + mutex_unlock(&spec->coef_mutex); +} + #define alc_write_coef_idx(codec, coef_idx, coef_val) \ alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) =20 +static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int mask, + unsigned int bits_set) +{ + unsigned int val =3D __alc_read_coefex_idx(codec, nid, coef_idx); + + if (val !=3D -1) + __alc_write_coefex_idx(codec, nid, coef_idx, + (val & ~mask) | bits_set); +} + static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx, unsigned int mask, unsigned int bits_set) { - unsigned int val =3D alc_read_coefex_idx(codec, nid, coef_idx); + struct alc_spec *spec =3D codec->spec; =20 - if (val !=3D -1) - alc_write_coefex_idx(codec, nid, coef_idx, - (val & ~mask) | bits_set); + mutex_lock(&spec->coef_mutex); + __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set); + mutex_unlock(&spec->coef_mutex); } =20 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \ @@ -196,13 +230,17 @@ struct coef_fw { static void alc_process_coef_fw(struct hda_codec *codec, const struct coef_fw *fw) { + struct alc_spec *spec =3D codec->spec; + + mutex_lock(&spec->coef_mutex); for (; fw->nid; fw++) { if (fw->mask =3D=3D (unsigned short)-1) - alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); + __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); else - alc_update_coefex_idx(codec, fw->nid, fw->idx, - fw->mask, fw->val); + __alc_update_coefex_idx(codec, fw->nid, fw->idx, + fw->mask, fw->val); } + mutex_unlock(&spec->coef_mutex); } =20 /* @@ -1148,6 +1186,7 @@ static int alc_alloc_spec(struct hda_cod codec->spdif_status_reset =3D 1; codec->forced_resume =3D 1; codec->patch_ops =3D alc_patch_ops; + mutex_init(&spec->coef_mutex); =20 err =3D alc_codec_rename_from_preset(codec); if (err < 0) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3896C4167B for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388318AbiBGLnb (ORCPT ); Mon, 7 Feb 2022 06:43:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385531AbiBGLb4 (ORCPT ); Mon, 7 Feb 2022 06:31:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75208C02B5C6; Mon, 7 Feb 2022 03:30:41 -0800 (PST) Received: from smtp.kernel.org (relay.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 AD839B8111C; Mon, 7 Feb 2022 11:30:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF1BBC004E1; Mon, 7 Feb 2022 11:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233439; bh=IEgE565Gtb1btIQogTZvSJuRAGwhj+7xF4Okv16Im2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KJVZJGB9XeDNqtMU83pmMnhY11ozCvms4nnNYQodItKv/o8xCZb7ugA7248MWVH9s c/PQsyvrbxTIBhOau/DiSFsDH81v6ThiShXNdkTG6ZGnjWmNim9gmpbuXDF+Eqs4e2 PCYdi9bduvIp1oQozT/LMa1In0ZwJz/xmC0ZDspY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Albert=20Geant=C4=83?= , Takashi Iwai Subject: [PATCH 5.16 013/126] ALSA: hda/realtek: Add quirk for ASUS GU603 Date: Mon, 7 Feb 2022 12:05:44 +0100 Message-Id: <20220207103804.527072518@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Albert Geant=C4=83 commit 94db9cc8f8fa2d5426ce79ec4ca16028f7084224 upstream. The ASUS GU603 (Zephyrus M16 - SSID 1043:16b2) requires a quirk similar to other ASUS devices for correctly routing the 4 integrated speakers. This fixes it by adding a corresponding quirk entry, which connects the bass speakers to the proper DAC. Signed-off-by: Albert Geant=C4=83 Cc: Link: https://lore.kernel.org/r/20220131010523.546386-1-albertgeanta@gmail.= com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- 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 @@ -8854,6 +8854,7 @@ static const struct snd_pci_quirk alc269 SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU50= 2_PINS), SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA40= 1), SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA40= 1), + SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401), SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2= ), SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA4DC47085 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391141AbiBGL6d (ORCPT ); Mon, 7 Feb 2022 06:58:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385551AbiBGLb6 (ORCPT ); Mon, 7 Feb 2022 06:31:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF23C02B5D0; Mon, 7 Feb 2022 03:30:45 -0800 (PST) Received: from smtp.kernel.org (relay.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 CA784B80EC3; Mon, 7 Feb 2022 11:30:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BAF3C004E1; Mon, 7 Feb 2022 11:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233442; bh=9q3/IOuZ6+o3g3xGCTBih0kUoMO02HHzHtG+4luzBNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JeLcifOo2SJbTLPSskN5jVemGbfYP8Yn6ijrplv6uLRYrLjnXTlJMUru85Q5qXJ30 HwvAcv0J6iUvgQD9P2LmcddEE2f3BfSy85pvE1bYPGDiADzn8f8GKq0naOBpYEWyBC PjEAkHn+IYvPepRc3INY1eJWPx7FD65kQkldis6Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.16 014/126] ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks Date: Mon, 7 Feb 2022 12:05:45 +0100 Message-Id: <20220207103804.559068497@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Lachner commit 63394a16086fc2152869d7902621e2525e14bc40 upstream. The initial commit of the new Gigabyte X570 ALC1220 quirks lacked the fixup-model entry in alc882_fixup_models[]. It seemed not to cause any ill effects but for completeness sake this commit makes up for that. Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-2-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- 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 @@ -2660,6 +2660,7 @@ static const struct hda_model_fixup alc8 {.id =3D ALC882_FIXUP_NO_PRIMARY_HP, .name =3D "no-primary-hp"}, {.id =3D ALC887_FIXUP_ASUS_BASS, .name =3D "asus-bass"}, {.id =3D ALC1220_FIXUP_GB_DUAL_CODECS, .name =3D "dual-codecs"}, + {.id =3D ALC1220_FIXUP_GB_X570, .name =3D "gb-x570"}, {.id =3D ALC1220_FIXUP_CLEVO_P950, .name =3D "clevo-p950"}, {} }; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1FBBC433F5 for ; Mon, 7 Feb 2022 11:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388231AbiBGLnO (ORCPT ); Mon, 7 Feb 2022 06:43:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385559AbiBGLb6 (ORCPT ); Mon, 7 Feb 2022 06:31:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569A7C02B5DA; Mon, 7 Feb 2022 03:30:48 -0800 (PST) Received: from smtp.kernel.org (relay.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 11D21B80EBD; Mon, 7 Feb 2022 11:30:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5107CC004E1; Mon, 7 Feb 2022 11:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233445; bh=rZvJ4ZyZHDyPNU3S/M+WkdB/RT1ucA3r+WNcdZmHxi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRq1Ff+bSvFfQX7p1IyEwGGiMsjN3Pb07Dg1J9KHv/qjRk9TQ/jywyrV/1sUqfzo7 iyY9U1GBwcClEa+9kIH/pukixK1Ckg1aRMTQC0nXqTtfXRrPdRiBHHEj0KRZPkH7Xl Xl/ouDELwrb21X4aoEW3Z6y5byzI44OpEQESrBDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.16 015/126] ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset) Date: Mon, 7 Feb 2022 12:05:46 +0100 Message-Id: <20220207103804.589176466@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Lachner commit 41a8601302ecbe704ac970552c33dc942300fc37 upstream. Newer versions of the X570 Master come with a newer revision of the mainboard chipset - the X570S. These boards have the same ALC1220 codec but seem to initialize the codec with a different parameter in Coef 0x7 which causes the output audio to be very low. We therefore write a known-good value to Coef 0x7 to fix that. As the value is the exact same as on the other X570(non-S) boards the same quirk-function can be shared between both generations. This commit adds the Gigabyte X570S Aorus Master to the list of boards using the ALC1220_FIXUP_GB_X570 quirk. This fixes both, the silent output and the no-audio after reboot from windows problems. This work has been tested by the folks over at the level1techs forum here: https://forum.level1techs.com/t/has-anybody-gotten-audio-working-in-linux-o= n-aorus-x570-master/154072 Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-3-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2159,6 +2159,7 @@ static void alc1220_fixup_gb_x570(struct { static const hda_nid_t conn1[] =3D { 0x0c }; static const struct coef_fw gb_x570_coefs[] =3D { + WRITE_COEF(0x07, 0x03c0), WRITE_COEF(0x1a, 0x01c1), WRITE_COEF(0x1b, 0x0202), WRITE_COEF(0x43, 0x3005), @@ -2586,6 +2587,7 @@ static const struct snd_pci_quirk alc882 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_D= UAL_CODECS), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP= _GB_X570), SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _CLEVO_P950), + SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXU= P_GB_X570), SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950), From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A2B3C43217 for ; Mon, 7 Feb 2022 11:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388216AbiBGLnN (ORCPT ); Mon, 7 Feb 2022 06:43:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385565AbiBGLb6 (ORCPT ); Mon, 7 Feb 2022 06:31:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B819C03E915; Mon, 7 Feb 2022 03:30:51 -0800 (PST) Received: from smtp.kernel.org (relay.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 2260DB80EC3; Mon, 7 Feb 2022 11:30:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B706C004E1; Mon, 7 Feb 2022 11:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233449; bh=Qt3S7UX4NFNycD6cNDXk6cbCpdwYlASoMUr9U9g1V+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLBzdjqbcGgDpEYCqF8RTHqvszVEz4sT11caX/gRsMF5NVEU1L7QwWYmBqwIZBBDv 3axiG4VK5YbJMDXSWrQ1S2YitL9JiykpKsrV9m84vKQKD99yW4HTcirJxr0Sg8MutO oT7LGaZche/UAmF1gpa3NSo/UCwnLmIUoduW2pNo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.16 016/126] ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows Date: Mon, 7 Feb 2022 12:05:47 +0100 Message-Id: <20220207103804.623303810@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Lachner commit ea3541961376f733373839cc90493aafa8a7f733 upstream. This commit switches the Gigabyte X570 Aorus Xtreme from using the ALC1220_FIXUP_CLEVO_P950 to the ALC1220_FIXUP_GB_X570 quirk. This fixes the no-audio after reboot from windows problem. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D205275 Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-4-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2586,7 +2586,7 @@ static const struct snd_pci_quirk alc882 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP= _FRONT_HP_NO_PRESENCE), SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_D= UAL_CODECS), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP= _GB_X570), - SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _CLEVO_P950), + SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _GB_X570), SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXU= P_GB_X570), SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE04AC3527D for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391134AbiBGL6a (ORCPT ); Mon, 7 Feb 2022 06:58:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385568AbiBGLb7 (ORCPT ); Mon, 7 Feb 2022 06:31:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83552C03E969; Mon, 7 Feb 2022 03:30:54 -0800 (PST) Received: from smtp.kernel.org (relay.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 4DA3CB80EBD; Mon, 7 Feb 2022 11:30:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 879BBC004E1; Mon, 7 Feb 2022 11:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233452; bh=ommyWLdHB1X5ao2pxgZFgQltSg+lALGtV7sFv7djEpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6vbk9/b8rxq0BGIoBa7l3rrlS9RSFVdIVtnEYvAKfI5INttm5FwmXK1ZcDxSVX6O P4aVJcrUHWOfzInlDvYwGX7Qnn2mqrow2N7PBE4O5LZ/QT6uC12s1kYRWTlhRUCI6e PJ0TJx+f3UoG4xDRmdNsDqvehV9WpdzR/aHupF2E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Lundin , Damien Le Moal Subject: [PATCH 5.16 017/126] ata: libata-core: Introduce ATA_HORKAGE_NO_LOG_DIR horkage Date: Mon, 7 Feb 2022 12:05:48 +0100 Message-Id: <20220207103804.653311531@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Anton Lundin commit ac9f0c810684a1b161c18eb4b91ce84cbc13c91d upstream. 06f6c4c6c3e8 ("ata: libata: add missing ata_identify_page_supported() calls= ") introduced additional calls to ata_identify_page_supported(), thus also adding indirectly accesses to the device log directory log page through ata_log_supported(). Reading this log page causes SATADOM-ML 3ME devices to lock up. Introduce the horkage flag ATA_HORKAGE_NO_LOG_DIR to prevent accesses to the log directory in ata_log_supported() and add a blacklist entry with this flag for "SATADOM-ML 3ME" devices. Fixes: 636f6e2af4fb ("libata: add horkage for missing Identify Device log") Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Anton Lundin Signed-off-by: Damien Le Moal Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/ata/libata-core.c | 10 ++++++++++ include/linux/libata.h | 1 + 2 files changed, 11 insertions(+) --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2043,6 +2043,9 @@ static bool ata_log_supported(struct ata { struct ata_port *ap =3D dev->link->ap; =20 + if (dev->horkage & ATA_HORKAGE_NO_LOG_DIR) + return false; + if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, ap->sector_buf, 1)) return false; return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false; @@ -4123,6 +4126,13 @@ static const struct ata_blacklist_entry { "WDC WD3000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, { "WDC WD3200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, =20 + /* + * This sata dom device goes on a walkabout when the ATA_LOG_DIRECTORY + * log page is accessed. Ensure we never ask for this log page with + * these devices. + */ + { "SATADOM-ML 3ME", NULL, ATA_HORKAGE_NO_LOG_DIR }, + /* End Marker */ { } }; --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -428,6 +428,7 @@ enum { ATA_HORKAGE_MAX_TRIM_128M =3D (1 << 26), /* Limit max trim size to 128M */ ATA_HORKAGE_NO_NCQ_ON_ATI =3D (1 << 27), /* Disable NCQ on ATI chipset */ ATA_HORKAGE_NO_ID_DEV_LOG =3D (1 << 28), /* Identify device log missing */ + ATA_HORKAGE_NO_LOG_DIR =3D (1 << 29), /* Do not read log directory */ =20 /* DMA mask for user DMA control: User visible values; DO NOT renumber */ From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E165EC4332F for ; Mon, 7 Feb 2022 11:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388188AbiBGLnJ (ORCPT ); Mon, 7 Feb 2022 06:43:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385570AbiBGLb7 (ORCPT ); Mon, 7 Feb 2022 06:31:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 273C1C03E96B; Mon, 7 Feb 2022 03:30:56 -0800 (PST) Received: from smtp.kernel.org (relay.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 AA7DB60AB0; Mon, 7 Feb 2022 11:30:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81337C004E1; Mon, 7 Feb 2022 11:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233455; bh=n9gapmnR3BmvRHyNXNq14LqFhx8NlinKmjcEoRr3GL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKJkgPv5zgFw4nyGZJDLXHTWyZPy5hNgyOi1azjp/yx1NwXslqOnJI1jwFVYRHOl3 z49EtoNQ5OkCWHSBkPN+1yptfMKLHr3ymrBEE+bp4j5zh6UmT+Qk1Vmbs43GoNfGXg QVuBUEjQJlS5QCrQc2PKpVmLO++d8o6RsHbX8Jqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , David Sterba Subject: [PATCH 5.16 018/126] btrfs: dont start transaction for scrub if the fs is mounted read-only Date: Mon, 7 Feb 2022 12:05:49 +0100 Message-Id: <20220207103804.695325273@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Qu Wenruo commit 2d192fc4c1abeb0d04d1c8cd54405ff4a0b0255b upstream. [BUG] The following super simple script would crash btrfs at unmount time, if CONFIG_BTRFS_ASSERT() is set. mkfs.btrfs -f $dev mount $dev $mnt xfs_io -f -c "pwrite 0 4k" $mnt/file umount $mnt mount -r ro $dev $mnt btrfs scrub start -Br $mnt umount $mnt This will trigger the following ASSERT() introduced by commit 0a31daa4b602 ("btrfs: add assertion for empty list of transactions at late stage of umount"). That patch is definitely not the cause, it just makes enough noise for developers. [CAUSE] We will start transaction for the following call chain during scrub: scrub_enumerate_chunks() |- btrfs_inc_block_group_ro() |- btrfs_join_transaction() However for RO mount, there is no running transaction at all, thus btrfs_join_transaction() will start a new transaction. Furthermore, since it's read-only mount, btrfs_sync_fs() will not call btrfs_commit_super() to commit the new but empty transaction. And leads to the ASSERT(). The bug has been there for a long time. Only the new ASSERT() makes it noisy enough to be noticed. [FIX] For read-only scrub on read-only mount, there is no need to start a transaction nor to allocate new chunks in btrfs_inc_block_group_ro(). Just do extra read-only mount check in btrfs_inc_block_group_ro(), and if it's read-only, skip all chunk allocation and go inc_block_group_ro() directly. CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/block-group.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2547,6 +2547,19 @@ int btrfs_inc_block_group_ro(struct btrf int ret; bool dirty_bg_running; =20 + /* + * This can only happen when we are doing read-only scrub on read-only + * mount. + * In that case we should not start a new transaction on read-only fs. + * Thus here we skip all chunk allocations. + */ + if (sb_rdonly(fs_info->sb)) { + mutex_lock(&fs_info->ro_block_group_mutex); + ret =3D inc_block_group_ro(cache, 0); + mutex_unlock(&fs_info->ro_block_group_mutex); + return ret; + } + do { trans =3D btrfs_join_transaction(fs_info->extent_root); if (IS_ERR(trans)) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0BEC43219 for ; Mon, 7 Feb 2022 11:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381426AbiBGLor (ORCPT ); Mon, 7 Feb 2022 06:44:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386021AbiBGLdT (ORCPT ); Mon, 7 Feb 2022 06:33:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D1D9C043181; Mon, 7 Feb 2022 03:33:17 -0800 (PST) Received: from smtp.kernel.org (relay.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 AFE8C60C09; Mon, 7 Feb 2022 11:33:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EC4DC004E1; Mon, 7 Feb 2022 11:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233596; bh=mV8DsrPe3++uwUUnd6mQxezPECdljouXy2pO7j6izm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPBJT+4tfTwHFjZs00E7OpY8rl1e/JZns1QTZX0dLgERtukc4BK5nsaXGln8+uGe9 kGFiGPMzF8XtPswN4xAJR/cQFjUe0CDVYEWjQ1NLENGtcAgev9FuNqzDh/g26S9S4g PgwnM3rapk80b6lYYIFo1A6y3qAQ/Zv/4g7ab2so= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Filipe Manana , Shinichiro Kawasaki , David Sterba Subject: [PATCH 5.16 019/126] btrfs: fix deadlock between quota disable and qgroup rescan worker Date: Mon, 7 Feb 2022 12:05:50 +0100 Message-Id: <20220207103804.729938278@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Shin'ichiro Kawasaki commit e804861bd4e69cc5fe1053eedcb024982dde8e48 upstream. Quota disable ioctl starts a transaction before waiting for the qgroup rescan worker completes. However, this wait can be infinite and results in deadlock because of circular dependency among the quota disable ioctl, the qgroup rescan worker and the other task with transaction such as block group relocation task. The deadlock happens with the steps following: 1) Task A calls ioctl to disable quota. It starts a transaction and waits for qgroup rescan worker completes. 2) Task B such as block group relocation task starts a transaction and joins to the transaction that task A started. Then task B commits to the transaction. In this commit, task B waits for a commit by task A. 3) Task C as the qgroup rescan worker starts its job and starts a transaction. In this transaction start, task C waits for completion of the transaction that task A started and task B committed. This deadlock was found with fstests test case btrfs/115 and a zoned null_blk device. The test case enables and disables quota, and the block group reclaim was triggered during the quota disable by chance. The deadlock was also observed by running quota enable and disable in parallel with 'btrfs balance' command on regular null_blk devices. An example report of the deadlock: [372.469894] INFO: task kworker/u16:6:103 blocked for more than 122 secon= ds. [372.479944] Not tainted 5.16.0-rc8 #7 [372.485067] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [372.493898] task:kworker/u16:6 state:D stack: 0 pid: 103 ppid: = 2 flags:0x00004000 [372.503285] Workqueue: btrfs-qgroup-rescan btrfs_work_helper [btrfs] [372.510782] Call Trace: [372.514092] [372.521684] __schedule+0xb56/0x4850 [372.530104] ? io_schedule_timeout+0x190/0x190 [372.538842] ? lockdep_hardirqs_on+0x7e/0x100 [372.547092] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [372.555591] schedule+0xe0/0x270 [372.561894] btrfs_commit_transaction+0x18bb/0x2610 [btrfs] [372.570506] ? btrfs_apply_pending_changes+0x50/0x50 [btrfs] [372.578875] ? free_unref_page+0x3f2/0x650 [372.585484] ? finish_wait+0x270/0x270 [372.591594] ? release_extent_buffer+0x224/0x420 [btrfs] [372.599264] btrfs_qgroup_rescan_worker+0xc13/0x10c0 [btrfs] [372.607157] ? lock_release+0x3a9/0x6d0 [372.613054] ? btrfs_qgroup_account_extent+0xda0/0xda0 [btrfs] [372.620960] ? do_raw_spin_lock+0x11e/0x250 [372.627137] ? rwlock_bug.part.0+0x90/0x90 [372.633215] ? lock_is_held_type+0xe4/0x140 [372.639404] btrfs_work_helper+0x1ae/0xa90 [btrfs] [372.646268] process_one_work+0x7e9/0x1320 [372.652321] ? lock_release+0x6d0/0x6d0 [372.658081] ? pwq_dec_nr_in_flight+0x230/0x230 [372.664513] ? rwlock_bug.part.0+0x90/0x90 [372.670529] worker_thread+0x59e/0xf90 [372.676172] ? process_one_work+0x1320/0x1320 [372.682440] kthread+0x3b9/0x490 [372.687550] ? _raw_spin_unlock_irq+0x24/0x50 [372.693811] ? set_kthread_struct+0x100/0x100 [372.700052] ret_from_fork+0x22/0x30 [372.705517] [372.709747] INFO: task btrfs-transacti:2347 blocked for more than 123 se= conds. [372.729827] Not tainted 5.16.0-rc8 #7 [372.745907] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [372.767106] task:btrfs-transacti state:D stack: 0 pid: 2347 ppid: = 2 flags:0x00004000 [372.787776] Call Trace: [372.801652] [372.812961] __schedule+0xb56/0x4850 [372.830011] ? io_schedule_timeout+0x190/0x190 [372.852547] ? lockdep_hardirqs_on+0x7e/0x100 [372.871761] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [372.886792] schedule+0xe0/0x270 [372.901685] wait_current_trans+0x22c/0x310 [btrfs] [372.919743] ? btrfs_put_transaction+0x3d0/0x3d0 [btrfs] [372.938923] ? finish_wait+0x270/0x270 [372.959085] ? join_transaction+0xc75/0xe30 [btrfs] [372.977706] start_transaction+0x938/0x10a0 [btrfs] [372.997168] transaction_kthread+0x19d/0x3c0 [btrfs] [373.013021] ? btrfs_cleanup_transaction.isra.0+0xfc0/0xfc0 [btrfs] [373.031678] kthread+0x3b9/0x490 [373.047420] ? _raw_spin_unlock_irq+0x24/0x50 [373.064645] ? set_kthread_struct+0x100/0x100 [373.078571] ret_from_fork+0x22/0x30 [373.091197] [373.105611] INFO: task btrfs:3145 blocked for more than 123 seconds. [373.114147] Not tainted 5.16.0-rc8 #7 [373.120401] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [373.130393] task:btrfs state:D stack: 0 pid: 3145 ppid: 31= 41 flags:0x00004000 [373.140998] Call Trace: [373.145501] [373.149654] __schedule+0xb56/0x4850 [373.155306] ? io_schedule_timeout+0x190/0x190 [373.161965] ? lockdep_hardirqs_on+0x7e/0x100 [373.168469] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [373.175468] schedule+0xe0/0x270 [373.180814] wait_for_commit+0x104/0x150 [btrfs] [373.187643] ? test_and_set_bit+0x20/0x20 [btrfs] [373.194772] ? kmem_cache_free+0x124/0x550 [373.201191] ? btrfs_put_transaction+0x69/0x3d0 [btrfs] [373.208738] ? finish_wait+0x270/0x270 [373.214704] ? __btrfs_end_transaction+0x347/0x7b0 [btrfs] [373.222342] btrfs_commit_transaction+0x44d/0x2610 [btrfs] [373.230233] ? join_transaction+0x255/0xe30 [btrfs] [373.237334] ? btrfs_record_root_in_trans+0x4d/0x170 [btrfs] [373.245251] ? btrfs_apply_pending_changes+0x50/0x50 [btrfs] [373.253296] relocate_block_group+0x105/0xc20 [btrfs] [373.260533] ? mutex_lock_io_nested+0x1270/0x1270 [373.267516] ? btrfs_wait_nocow_writers+0x85/0x180 [btrfs] [373.275155] ? merge_reloc_roots+0x710/0x710 [btrfs] [373.283602] ? btrfs_wait_ordered_extents+0xd30/0xd30 [btrfs] [373.291934] ? kmem_cache_free+0x124/0x550 [373.298180] btrfs_relocate_block_group+0x35c/0x930 [btrfs] [373.306047] btrfs_relocate_chunk+0x85/0x210 [btrfs] [373.313229] btrfs_balance+0x12f4/0x2d20 [btrfs] [373.320227] ? lock_release+0x3a9/0x6d0 [373.326206] ? btrfs_relocate_chunk+0x210/0x210 [btrfs] [373.333591] ? lock_is_held_type+0xe4/0x140 [373.340031] ? rcu_read_lock_sched_held+0x3f/0x70 [373.346910] btrfs_ioctl_balance+0x548/0x700 [btrfs] [373.354207] btrfs_ioctl+0x7f2/0x71b0 [btrfs] [373.360774] ? lockdep_hardirqs_on_prepare+0x410/0x410 [373.367957] ? lockdep_hardirqs_on_prepare+0x410/0x410 [373.375327] ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs] [373.383841] ? find_held_lock+0x2c/0x110 [373.389993] ? lock_release+0x3a9/0x6d0 [373.395828] ? mntput_no_expire+0xf7/0xad0 [373.402083] ? lock_is_held_type+0xe4/0x140 [373.408249] ? vfs_fileattr_set+0x9f0/0x9f0 [373.414486] ? selinux_file_ioctl+0x349/0x4e0 [373.420938] ? trace_raw_output_lock+0xb4/0xe0 [373.427442] ? selinux_inode_getsecctx+0x80/0x80 [373.434224] ? lockdep_hardirqs_on+0x7e/0x100 [373.440660] ? force_qs_rnp+0x2a0/0x6b0 [373.446534] ? lock_is_held_type+0x9b/0x140 [373.452763] ? __blkcg_punt_bio_submit+0x1b0/0x1b0 [373.459732] ? security_file_ioctl+0x50/0x90 [373.466089] __x64_sys_ioctl+0x127/0x190 [373.472022] do_syscall_64+0x3b/0x90 [373.477513] entry_SYSCALL_64_after_hwframe+0x44/0xae [373.484823] RIP: 0033:0x7f8f4af7e2bb [373.490493] RSP: 002b:00007ffcbf936178 EFLAGS: 00000246 ORIG_RAX: 000000= 0000000010 [373.500197] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f8f4af= 7e2bb [373.509451] RDX: 00007ffcbf936220 RSI: 00000000c4009420 RDI: 00000000000= 00003 [373.518659] RBP: 00007ffcbf93774a R08: 0000000000000013 R09: 00007f8f4b0= 2d4e0 [373.527872] R10: 00007f8f4ae87740 R11: 0000000000000246 R12: 00000000000= 00001 [373.537222] R13: 00007ffcbf936220 R14: 0000000000000000 R15: 00000000000= 00002 [373.546506] [373.550878] INFO: task btrfs:3146 blocked for more than 123 seconds. [373.559383] Not tainted 5.16.0-rc8 #7 [373.565748] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [373.575748] task:btrfs state:D stack: 0 pid: 3146 ppid: 21= 68 flags:0x00000000 [373.586314] Call Trace: [373.590846] [373.595121] __schedule+0xb56/0x4850 [373.600901] ? __lock_acquire+0x23db/0x5030 [373.607176] ? io_schedule_timeout+0x190/0x190 [373.613954] schedule+0xe0/0x270 [373.619157] schedule_timeout+0x168/0x220 [373.625170] ? usleep_range_state+0x150/0x150 [373.631653] ? mark_held_locks+0x9e/0xe0 [373.637767] ? do_raw_spin_lock+0x11e/0x250 [373.643993] ? lockdep_hardirqs_on_prepare+0x17b/0x410 [373.651267] ? _raw_spin_unlock_irq+0x24/0x50 [373.657677] ? lockdep_hardirqs_on+0x7e/0x100 [373.664103] wait_for_completion+0x163/0x250 [373.670437] ? bit_wait_timeout+0x160/0x160 [373.676585] btrfs_quota_disable+0x176/0x9a0 [btrfs] [373.683979] ? btrfs_quota_enable+0x12f0/0x12f0 [btrfs] [373.691340] ? down_write+0xd0/0x130 [373.696880] ? down_write_killable+0x150/0x150 [373.703352] btrfs_ioctl+0x3945/0x71b0 [btrfs] [373.710061] ? find_held_lock+0x2c/0x110 [373.716192] ? lock_release+0x3a9/0x6d0 [373.722047] ? __handle_mm_fault+0x23cd/0x3050 [373.728486] ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs] [373.737032] ? set_pte+0x6a/0x90 [373.742271] ? do_raw_spin_unlock+0x55/0x1f0 [373.748506] ? lock_is_held_type+0xe4/0x140 [373.754792] ? vfs_fileattr_set+0x9f0/0x9f0 [373.761083] ? selinux_file_ioctl+0x349/0x4e0 [373.767521] ? selinux_inode_getsecctx+0x80/0x80 [373.774247] ? __up_read+0x182/0x6e0 [373.780026] ? count_memcg_events.constprop.0+0x46/0x60 [373.787281] ? up_write+0x460/0x460 [373.792932] ? security_file_ioctl+0x50/0x90 [373.799232] __x64_sys_ioctl+0x127/0x190 [373.805237] do_syscall_64+0x3b/0x90 [373.810947] entry_SYSCALL_64_after_hwframe+0x44/0xae [373.818102] RIP: 0033:0x7f1383ea02bb [373.823847] RSP: 002b:00007fffeb4d71f8 EFLAGS: 00000202 ORIG_RAX: 000000= 0000000010 [373.833641] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1383e= a02bb [373.842961] RDX: 00007fffeb4d7210 RSI: 00000000c0109428 RDI: 00000000000= 00003 [373.852179] RBP: 0000000000000003 R08: 0000000000000003 R09: 00000000000= 00078 [373.861408] R10: 00007f1383daec78 R11: 0000000000000202 R12: 00007fffeb4= d874a [373.870647] R13: 0000000000493099 R14: 0000000000000001 R15: 00000000000= 00000 [373.879838] [373.884018] Showing all locks held in the system: [373.894250] 3 locks held by kworker/4:1/58: [373.900356] 1 lock held by khungtaskd/63: [373.906333] #0: ffffffff8945ff60 (rcu_read_lock){....}-{1:2}, at: debug= _show_all_locks+0x53/0x260 [373.917307] 3 locks held by kworker/u16:6/103: [373.923938] #0: ffff888127b4f138 ((wq_completion)btrfs-qgroup-rescan){+= .+.}-{0:0}, at: process_one_work+0x712/0x1320 [373.936555] #1: ffff88810b817dd8 ((work_completion)(&work->normal_work)= ){+.+.}-{0:0}, at: process_one_work+0x73f/0x1320 [373.951109] #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs= _qgroup_rescan_worker+0x1f6/0x10c0 [btrfs] [373.964027] 2 locks held by less/1803: [373.969982] #0: ffff88813ed56098 (&tty->ldisc_sem){++++}-{0:0}, at: tty= _ldisc_ref_wait+0x24/0x80 [373.981295] #1: ffffc90000b3b2e8 (&ldata->atomic_read_lock){+.+.}-{3:3}= , at: n_tty_read+0x9e2/0x1060 [373.992969] 1 lock held by btrfs-transacti/2347: [373.999893] #0: ffff88813d4887a8 (&fs_info->transaction_kthread_mutex){= +.+.}-{3:3}, at: transaction_kthread+0xe3/0x3c0 [btrfs] [374.015872] 3 locks held by btrfs/3145: [374.022298] #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs= _ioctl_balance+0xc3/0x700 [btrfs] [374.034456] #1: ffff88813d48a0a0 (&fs_info->reclaim_bgs_lock){+.+.}-{3:= 3}, at: btrfs_balance+0xfe5/0x2d20 [btrfs] [374.047646] #2: ffff88813d488838 (&fs_info->cleaner_mutex){+.+.}-{3:3},= at: btrfs_relocate_block_group+0x354/0x930 [btrfs] [374.063295] 4 locks held by btrfs/3146: [374.069647] #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs= _ioctl+0x38b1/0x71b0 [btrfs] [374.081601] #1: ffff88813d488bb8 (&fs_info->subvol_sem){+.+.}-{3:3}, at= : btrfs_ioctl+0x38fd/0x71b0 [btrfs] [374.094283] #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs= _quota_disable+0xc8/0x9a0 [btrfs] [374.106885] #3: ffff88813d489800 (&fs_info->qgroup_ioctl_lock){+.+.}-{3= :3}, at: btrfs_quota_disable+0xd5/0x9a0 [btrfs] [374.126780] =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 To avoid the deadlock, wait for the qgroup rescan worker to complete before starting the transaction for the quota disable ioctl. Clear BTRFS_FS_QUOTA_ENABLE flag before the wait and the transaction to request the worker to complete. On transaction start failure, set the BTRFS_FS_QUOTA_ENABLE flag again. These BTRFS_FS_QUOTA_ENABLE flag changes can be done safely since the function btrfs_quota_disable is not called concurrently because of fs_info->subvol_sem. Also check the BTRFS_FS_QUOTA_ENABLE flag in qgroup_rescan_init to avoid another qgroup rescan worker to start after the previous qgroup worker completed. CC: stable@vger.kernel.org # 5.4+ Suggested-by: Nikolay Borisov Reviewed-by: Filipe Manana Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/qgroup.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1185,9 +1185,24 @@ int btrfs_quota_disable(struct btrfs_fs_ struct btrfs_trans_handle *trans =3D NULL; int ret =3D 0; =20 + /* + * We need to have subvol_sem write locked, to prevent races between + * concurrent tasks trying to disable quotas, because we will unlock + * and relock qgroup_ioctl_lock across BTRFS_FS_QUOTA_ENABLED changes. + */ + lockdep_assert_held_write(&fs_info->subvol_sem); + mutex_lock(&fs_info->qgroup_ioctl_lock); if (!fs_info->quota_root) goto out; + + /* + * Request qgroup rescan worker to complete and wait for it. This wait + * must be done before transaction start for quota disable since it may + * deadlock with transaction by the qgroup rescan worker. + */ + clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); + btrfs_qgroup_wait_for_completion(fs_info, false); mutex_unlock(&fs_info->qgroup_ioctl_lock); =20 /* @@ -1205,14 +1220,13 @@ int btrfs_quota_disable(struct btrfs_fs_ if (IS_ERR(trans)) { ret =3D PTR_ERR(trans); trans =3D NULL; + set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); goto out; } =20 if (!fs_info->quota_root) goto out; =20 - clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); - btrfs_qgroup_wait_for_completion(fs_info, false); spin_lock(&fs_info->qgroup_lock); quota_root =3D fs_info->quota_root; fs_info->quota_root =3D NULL; @@ -3380,6 +3394,9 @@ qgroup_rescan_init(struct btrfs_fs_info btrfs_warn(fs_info, "qgroup rescan init failed, qgroup is not enabled"); ret =3D -EINVAL; + } else if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) { + /* Quota disable is in progress */ + ret =3D -EBUSY; } =20 if (ret) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41680C433FE for ; Mon, 7 Feb 2022 11:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388055AbiBGLmm (ORCPT ); Mon, 7 Feb 2022 06:42:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385650AbiBGLcE (ORCPT ); Mon, 7 Feb 2022 06:32:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00CF1C03C19A; Mon, 7 Feb 2022 03:31:26 -0800 (PST) Received: from smtp.kernel.org (relay.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 838466077B; Mon, 7 Feb 2022 11:31:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D88CC004E1; Mon, 7 Feb 2022 11:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233486; bh=Ga6OEc+mD3Ux1qJe8QMat14m+/koqLqZMqZCtgrUzDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jpl3HqBjM586ItpaTXD9O26G7F3n9v1ldgcpmsPADmWlH1fnYwciy8HjXa2zZN7zw kFL0f4eLk9yTqs8FRHxFth+nJShPf7eePON5LKIREwhKeNYdxLcPtvhkp6T2U+kyU3 tsjvFW2JUToYoINV2o8nHQHp82CIe0OzKc3Xd9ms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 5.16 020/126] btrfs: fix use-after-free after failure to create a snapshot Date: Mon, 7 Feb 2022 12:05:51 +0100 Message-Id: <20220207103804.763666588@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit 28b21c558a3753171097193b6f6602a94169093a upstream. At ioctl.c:create_snapshot(), we allocate a pending snapshot structure and then attach it to the transaction's list of pending snapshots. After that we call btrfs_commit_transaction(), and if that returns an error we jump to 'fail' label, where we kfree() the pending snapshot structure. This can result in a later use-after-free of the pending snapshot: 1) We allocated the pending snapshot and added it to the transaction's list of pending snapshots; 2) We call btrfs_commit_transaction(), and it fails either at the first call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups(). In both cases, we don't abort the transaction and we release our transaction handle. We jump to the 'fail' label and free the pending snapshot structure. We return with the pending snapshot still in the transaction's list; 3) Another task commits the transaction. This time there's no error at all, and then during the transaction commit it accesses a pointer to the pending snapshot structure that the snapshot creation task has already freed, resulting in a user-after-free. This issue could actually be detected by smatch, which produced the following warning: fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' no= t removed from list So fix this by not having the snapshot creation ioctl directly add the pending snapshot to the transaction's list. Instead add the pending snapshot to the transaction handle, and then at btrfs_commit_transaction() we add the snapshot to the list only when we can guarantee that any error returned after that point will result in a transaction abort, in which case the ioctl code can safely free the pending snapshot and no one can access it anymore. CC: stable@vger.kernel.org # 5.10+ Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/ioctl.c | 5 +---- fs/btrfs/transaction.c | 24 ++++++++++++++++++++++++ fs/btrfs/transaction.h | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -779,10 +779,7 @@ static int create_snapshot(struct btrfs_ goto fail; } =20 - spin_lock(&fs_info->trans_lock); - list_add(&pending_snapshot->list, - &trans->transaction->pending_snapshots); - spin_unlock(&fs_info->trans_lock); + trans->pending_snapshot =3D pending_snapshot; =20 ret =3D btrfs_commit_transaction(trans); if (ret) --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2032,6 +2032,27 @@ static inline void btrfs_wait_delalloc_f btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); } =20 +/* + * Add a pending snapshot associated with the given transaction handle to = the + * respective handle. This must be called after the transaction commit sta= rted + * and while holding fs_info->trans_lock. + * This serves to guarantee a caller of btrfs_commit_transaction() that it= can + * safely free the pending snapshot pointer in case btrfs_commit_transacti= on() + * returns an error. + */ +static void add_pending_snapshot(struct btrfs_trans_handle *trans) +{ + struct btrfs_transaction *cur_trans =3D trans->transaction; + + if (!trans->pending_snapshot) + return; + + lockdep_assert_held(&trans->fs_info->trans_lock); + ASSERT(cur_trans->state >=3D TRANS_STATE_COMMIT_START); + + list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots); +} + int btrfs_commit_transaction(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info =3D trans->fs_info; @@ -2105,6 +2126,8 @@ int btrfs_commit_transaction(struct btrf if (cur_trans->state >=3D TRANS_STATE_COMMIT_START) { enum btrfs_trans_state want_state =3D TRANS_STATE_COMPLETED; =20 + add_pending_snapshot(trans); + spin_unlock(&fs_info->trans_lock); refcount_inc(&cur_trans->use_count); =20 @@ -2195,6 +2218,7 @@ int btrfs_commit_transaction(struct btrf * COMMIT_DOING so make sure to wait for num_writers to =3D=3D 1 again. */ spin_lock(&fs_info->trans_lock); + add_pending_snapshot(trans); cur_trans->state =3D TRANS_STATE_COMMIT_DOING; spin_unlock(&fs_info->trans_lock); wait_event(cur_trans->writer_wait, --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -123,6 +123,8 @@ struct btrfs_trans_handle { struct btrfs_transaction *transaction; struct btrfs_block_rsv *block_rsv; struct btrfs_block_rsv *orig_rsv; + /* Set by a task that wants to create a snapshot. */ + struct btrfs_pending_snapshot *pending_snapshot; refcount_t use_count; unsigned int type; /* From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1C4C43217 for ; Mon, 7 Feb 2022 11:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388346AbiBGLne (ORCPT ); Mon, 7 Feb 2022 06:43:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385685AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B851BC0401D6; Mon, 7 Feb 2022 03:32:02 -0800 (PST) Received: from smtp.kernel.org (relay.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 262C560B5B; Mon, 7 Feb 2022 11:32:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAB6EC004E1; Mon, 7 Feb 2022 11:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233521; bh=4W2tn002ITYK63bmP9hov/JOOeTD9dndTF/zgZV7jQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NM9m2wmnnxuUSyF583pm1Uesbo0P054JKu+deh+Z4qCwlM9JNPxHrn6L4tMsoWi1B gpPbdephUtgqh+O/L687oJKVk1FBxJzn/eM7FU8twefmNX+cpkw67lW94ISuaUlbnl k1xcqtSPEAeoF5+nsakjnHLatG6D4UaRreuoIWj8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ron minnich , ng@0x80.stream, Dominique Martinet Subject: [PATCH 5.16 021/126] Revert "fs/9p: search open fids first" Date: Mon, 7 Feb 2022 12:05:52 +0100 Message-Id: <20220207103804.797485286@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Dominique Martinet commit 22e424feb6658c5d6789e45121830357809c59cb upstream. This reverts commit 478ba09edc1f2f2ee27180a06150cb2d1a686f9c. That commit was meant as a fix for setattrs with by fd (e.g. ftruncate) to use an open fid instead of the first fid it found on lookup. The proper fix for that is to use the fid associated with the open file struct, available in iattr->ia_file for such operations, and was actually done just before in 66246641609b ("9p: retrieve fid from file when file instance exist.") As such, this commit is no longer required. Furthermore, changing lookup to return open fids first had unwanted side effects, as it turns out the protocol forbids the use of open fids for further walks (e.g. clone_fid) and we broke mounts for some servers enforcing this rule. Note this only reverts to the old working behaviour, but it's still possible for lookup to return open fids if dentry->d_fsdata is not set, so more work is needed to make sure we respect this rule in the future, for example by adding a flag to the lookup functions to only match certain fid open modes depending on caller requirements. Link: https://lkml.kernel.org/r/20220130130651.712293-1-asmadeus@codewreck.= org Fixes: 478ba09edc1f ("fs/9p: search open fids first") Cc: stable@vger.kernel.org # v5.11+ Reported-by: ron minnich Reported-by: ng@0x80.stream Signed-off-by: Dominique Martinet Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/9p/fid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -96,12 +96,8 @@ static struct p9_fid *v9fs_fid_find(stru dentry, dentry, from_kuid(&init_user_ns, uid), any); ret =3D NULL; - - if (d_inode(dentry)) - ret =3D v9fs_fid_find_inode(d_inode(dentry), uid); - /* we'll recheck under lock if there's anything to look in */ - if (!ret && dentry->d_fsdata) { + if (dentry->d_fsdata) { struct hlist_head *h =3D (struct hlist_head *)&dentry->d_fsdata; =20 spin_lock(&dentry->d_lock); @@ -113,6 +109,9 @@ static struct p9_fid *v9fs_fid_find(stru } } spin_unlock(&dentry->d_lock); + } else { + if (dentry->d_inode) + ret =3D v9fs_fid_find_inode(dentry->d_inode, uid); } =20 return ret; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA18C4167E for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388568AbiBGLn7 (ORCPT ); Mon, 7 Feb 2022 06:43:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385802AbiBGLcj (ORCPT ); Mon, 7 Feb 2022 06:32:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 680D5C043181; Mon, 7 Feb 2022 03:32:38 -0800 (PST) Received: from smtp.kernel.org (relay.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 0432A60A67; Mon, 7 Feb 2022 11:32:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF73BC004E1; Mon, 7 Feb 2022 11:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233557; bh=JE/jV0p/vLig4xTmzfQk4lQFfn7O51vh4mZW9DF20YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPi1YNayf5ZDyviLTPPiUL4S/N4NrqR/zjg3rjdI633wRdB172qlVMC+a8UgN1qUX ePFT+LkAt3htfgpMnJ3NU6ioB9OtnCZJldboolpYrLO+jvdjk14JWEB/XeJce52haS ZYMibY4Fo3U61u40zhBk+zsCoKymrZj4TWCXx6rg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Lopez , Ilia Mirkin , Karol Herbst Subject: [PATCH 5.16 022/126] drm/nouveau: fix off by one in BIOS boundary checking Date: Mon, 7 Feb 2022 12:05:53 +0100 Message-Id: <20220207103804.925676047@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Nick Lopez commit 1b777d4d9e383d2744fc9b3a09af6ec1893c8b1a upstream. Bounds checking when parsing init scripts embedded in the BIOS reject access to the last byte. This causes driver initialization to fail on Apple eMac's with GeForce 2 MX GPUs, leaving the system with no working console. This is probably only seen on OpenFirmware machines like PowerPC Macs because the BIOS image provided by OF is only the used parts of the ROM, not a power-of-two blocks read from PCI directly so PCs always have empty bytes at the end that are never accessed. Signed-off-by: Nick Lopez Fixes: 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds access= es to image") Cc: # v4.10+ Reviewed-by: Ilia Mirkin Reviewed-by: Karol Herbst Signed-off-by: Karol Herbst Link: https://patchwork.freedesktop.org/patch/msgid/20220122081906.2633061-= 1-github@glowingmonkey.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c @@ -38,7 +38,7 @@ nvbios_addr(struct nvkm_bios *bios, u32 *addr +=3D bios->imaged_addr; } =20 - if (unlikely(*addr + size >=3D bios->size)) { + if (unlikely(*addr + size > bios->size)) { nvkm_error(&bios->subdev, "OOB %d %08x %08x\n", size, p, *addr); return false; } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF3F7C43217 for ; Mon, 7 Feb 2022 11:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388716AbiBGLoh (ORCPT ); Mon, 7 Feb 2022 06:44:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385888AbiBGLc6 (ORCPT ); Mon, 7 Feb 2022 06:32:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77FBDC043181; Mon, 7 Feb 2022 03:32:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 15FD560A69; Mon, 7 Feb 2022 11:32:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC07C004E1; Mon, 7 Feb 2022 11:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233576; bh=u8o5PCQAyIhvn8HqQIszupSztvY2NwO4h4QsnvWbks0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ze/sdS+0Ua3L8CxKh6A3Dw2ziDX1/Iujdvz32+6NJX0Wqhh2CpBhuvRvM2jgNwpGW RvAtqkW7yJApCyfgocg/45SUUtk8DsmSRTyjqyqyzCD/F7gIY0wNIFeWeSCG+//i9D q8M7vVhCrK9ez4iF+ELSP0ZEmezi8d42mn8JIVIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Imre Deak , Tvrtko Ursulin , Chia-Lin Kao Subject: [PATCH 5.16 023/126] drm/i915/adlp: Fix TypeC PHY-ready status readout Date: Mon, 7 Feb 2022 12:05:54 +0100 Message-Id: <20220207103804.958489222@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Imre Deak commit 3c6f13ad723e7206f03bb2752b01d18202b7fc9d upstream. The TCSS_DDI_STATUS register is indexed by tc_port not by the FIA port index, fix this up. This only caused an issue on TC#3/4 ports in legacy mode, as in all other cases the two indices either match (on TC#1/2) or the TCSS_DDI_STATUS_READY flag is set regardless of something being connected or not (on TC#1/2/3/4 in dp-alt and tbt-alt modes). Reported-and-tested-by: Chia-Lin Kao (AceLan) Fixes: 55ce306c2aa1 ("drm/i915/adl_p: Implement TC sequences") Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4698 Cc: Jos=C3=A9 Roberto de Souza Cc: # v5.14+ Signed-off-by: Imre Deak Reviewed-by: Jos=C3=A9 Roberto de Souza Link: https://patchwork.freedesktop.org/patch/msgid/20220126104356.2022975-= 1-imre.deak@intel.com (cherry picked from commit 516b33460c5bee78b2055637b0547bdb0e6af754) Signed-off-by: Tvrtko Ursulin Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/display/intel_tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/display/intel_tc.c +++ b/drivers/gpu/drm/i915/display/intel_tc.c @@ -345,10 +345,11 @@ static bool icl_tc_phy_status_complete(s static bool adl_tc_phy_status_complete(struct intel_digital_port *dig_port) { struct drm_i915_private *i915 =3D to_i915(dig_port->base.base.dev); + enum tc_port tc_port =3D intel_port_to_tc(i915, dig_port->base.port); struct intel_uncore *uncore =3D &i915->uncore; u32 val; =20 - val =3D intel_uncore_read(uncore, TCSS_DDI_STATUS(dig_port->tc_phy_fia_id= x)); + val =3D intel_uncore_read(uncore, TCSS_DDI_STATUS(tc_port)); if (val =3D=3D 0xffffffff) { drm_dbg_kms(&i915->drm, "Port %s: PHY in TCCOLD, assuming not complete\n", From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD89C4332F for ; Mon, 7 Feb 2022 11:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388701AbiBGLod (ORCPT ); Mon, 7 Feb 2022 06:44:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385893AbiBGLdB (ORCPT ); Mon, 7 Feb 2022 06:33:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75A3C043181; Mon, 7 Feb 2022 03:33:00 -0800 (PST) Received: from smtp.kernel.org (relay.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 66EE060A67; Mon, 7 Feb 2022 11:33:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A4F0C004E1; Mon, 7 Feb 2022 11:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233579; bh=0b2/NmoR00QawfH4Fcskg1rd4c91k5VvvsO+xnT9CSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAQ5K3juq+Gtali1zcUGtpIp1A9ljDwIRWtxuaMJFn1+kgyNXxb7RhVkp3bAg5Mcv y+cHKZaelkMKKVO6Ne15IKfJkMT16F2Z0kQhFcQNUvoRie17975ASa9IaqhXvSngJS Ut5SlUNX8twlSRCLsMkghQrdI04zwF8HWD4+Ai5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lang Yu , Lijo Lazar , Alex Deucher Subject: [PATCH 5.16 024/126] drm/amdgpu: fix a potential GPU hang on cyan skillfish Date: Mon, 7 Feb 2022 12:05:55 +0100 Message-Id: <20220207103804.991012702@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Lang Yu commit bca52455a3c07922ee976714b00563a13a29ab15 upstream. We observed a GPU hang when querying GMC CG state(i.e., cat amdgpu_pm_info) on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features. Just prevent it from accessing GMC CG registers. Signed-off-by: Lang Yu Reviewed-by: Lijo Lazar Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c @@ -1147,6 +1147,9 @@ static void gmc_v10_0_get_clockgating_st { struct amdgpu_device *adev =3D (struct amdgpu_device *)handle; =20 + if (adev->ip_versions[GC_HWIP][0] =3D=3D IP_VERSION(10, 1, 3)) + return; + adev->mmhub.funcs->get_clockgating(adev, flags); =20 if (adev->ip_versions[ATHUB_HWIP][0] >=3D IP_VERSION(2, 1, 0)) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 008A1C43219 for ; Mon, 7 Feb 2022 11:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381445AbiBGLoi (ORCPT ); Mon, 7 Feb 2022 06:44:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385920AbiBGLdE (ORCPT ); Mon, 7 Feb 2022 06:33:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14041C043181; Mon, 7 Feb 2022 03:33:04 -0800 (PST) Received: from smtp.kernel.org (relay.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 A58B660A69; Mon, 7 Feb 2022 11:33:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FC0DC004E1; Mon, 7 Feb 2022 11:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233583; bh=qo1pc4HKb26wpACQTb3j2bo0TYaK5ZqtGgd+5l84YT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwvIMRgeurN1v7wK+jr13nbY2Lak2iILtNQNj13/sPx2nwq1eQLu0zZ5DgmxA/qls 61CbGTRiNiWLRrgyT3MmrIo1CErsR85Xvz7p+TQD1QMf3DDUmd1Ck5xVXWoeFHT+Df 42omg1xQBw9gA1CTuOeL88ZX9cpBF0Zg8bTRExv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Quan , Alex Deucher Subject: [PATCH 5.16 025/126] drm/amd/pm: correct the MGpuFanBoost support for Beige Goby Date: Mon, 7 Feb 2022 12:05:56 +0100 Message-Id: <20220207103805.022861512@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Evan Quan commit 3ec5586b4699cfb75cdfa09425e11d121db40773 upstream. The existing way cannot handle Beige Goby well as a different PPTable data structure(PPTable_beige_goby_t instead of PPTable_t) is used there. Signed-off-by: Evan Quan Acked-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -3681,14 +3681,14 @@ static ssize_t sienna_cichlid_get_gpu_me =20 static int sienna_cichlid_enable_mgpu_fan_boost(struct smu_context *smu) { - struct smu_table_context *table_context =3D &smu->smu_table; - PPTable_t *smc_pptable =3D table_context->driver_pptable; + uint16_t *mgpu_fan_boost_limit_rpm; =20 + GET_PPTABLE_MEMBER(MGpuFanBoostLimitRpm, &mgpu_fan_boost_limit_rpm); /* * Skip the MGpuFanBoost setting for those ASICs * which do not support it */ - if (!smc_pptable->MGpuFanBoostLimitRpm) + if (*mgpu_fan_boost_limit_rpm =3D=3D 0) return 0; =20 return smu_cmn_send_smc_msg_with_param(smu, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8828BC3526C for ; Mon, 7 Feb 2022 11:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344573AbiBGLok (ORCPT ); Mon, 7 Feb 2022 06:44:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385934AbiBGLdH (ORCPT ); Mon, 7 Feb 2022 06:33:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44100C043181; Mon, 7 Feb 2022 03:33:07 -0800 (PST) Received: from smtp.kernel.org (relay.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 D561C60A69; Mon, 7 Feb 2022 11:33:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC3B6C004E1; Mon, 7 Feb 2022 11:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233586; bh=4F2nWKHa8/0nbptm9EJn9sUIXqQlFVWQZzv/dM3bWag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VAkM7QTLfG3FYHUD0eIEehaUwe/TuHmwICqHNlBOn69zLshT618KmxsimtdPleOwM C6f28YpfIPeXrqeDYv0OF1kDKDvk6nVSNfXLwCelzknnZxrZeLGpku5aYBTx6mKka1 OdixEw2mRBSUIoJhdUwsTBOhGagM+MFeGi0UjX3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhan Liu , Agustin Gutierrez , Alex Deucher Subject: [PATCH 5.16 026/126] drm/amd/display: Update watermark values for DCN301 Date: Mon, 7 Feb 2022 12:05:57 +0100 Message-Id: <20220207103805.054427398@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Agustin Gutierrez commit 2d8ae25d233767171942a9fba5fd8f4a620996be upstream. [Why] There is underflow / visual corruption DCN301, for high bandwidth MST DSC configurations such as 2x1440p144 or 2x4k60. [How] Use up-to-date watermark values for DCN301. Reviewed-by: Zhan Liu Signed-off-by: Agustin Gutierrez Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c | 16 ++++++--= ----- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c @@ -582,32 +582,32 @@ static struct wm_table lpddr5_wm_table =3D .wm_inst =3D WM_A, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.65333, - .sr_exit_time_us =3D 7.95, - .sr_enter_plus_exit_time_us =3D 9, + .sr_exit_time_us =3D 13.5, + .sr_enter_plus_exit_time_us =3D 16.5, .valid =3D true, }, { .wm_inst =3D WM_B, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.65333, - .sr_exit_time_us =3D 9.82, - .sr_enter_plus_exit_time_us =3D 11.196, + .sr_exit_time_us =3D 13.5, + .sr_enter_plus_exit_time_us =3D 16.5, .valid =3D true, }, { .wm_inst =3D WM_C, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.65333, - .sr_exit_time_us =3D 9.89, - .sr_enter_plus_exit_time_us =3D 11.24, + .sr_exit_time_us =3D 13.5, + .sr_enter_plus_exit_time_us =3D 16.5, .valid =3D true, }, { .wm_inst =3D WM_D, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.65333, - .sr_exit_time_us =3D 9.748, - .sr_enter_plus_exit_time_us =3D 11.102, + .sr_exit_time_us =3D 13.5, + .sr_enter_plus_exit_time_us =3D 16.5, .valid =3D true, }, } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18DDEC4167D for ; Mon, 7 Feb 2022 11:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344905AbiBGLon (ORCPT ); Mon, 7 Feb 2022 06:44:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385967AbiBGLdM (ORCPT ); Mon, 7 Feb 2022 06:33:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2710AC043181; Mon, 7 Feb 2022 03:33:11 -0800 (PST) Received: from smtp.kernel.org (relay.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 B1FE8B8111C; Mon, 7 Feb 2022 11:33:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C26FEC004E1; Mon, 7 Feb 2022 11:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233589; bh=45tOOHDrjTYStgkC+9Zc7z5T7IhQblOXUrM1/Oiv+8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ni7sS6sNoeweGTWwLpr2YI0+Zb3VRj+d+Mgxezjih31L9++P6XrrWPLh+uK6EjY+d 3vkIZ46fRmBTDGDwxXQ48xE6VuMb80oGCRftB0fdxgCB4V6JC6ftARpX8Y0bq9R2Pa ztBeRzJ7qSP0TfrrVz+z2LNH/+JJp7jcMm9zbYt8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Wheeler , Aric Cyr , Stylon Wang , Paul Hsieh , Alex Deucher Subject: [PATCH 5.16 027/126] drm/amd/display: watermark latencies is not enough on DCN31 Date: Mon, 7 Feb 2022 12:05:58 +0100 Message-Id: <20220207103805.085322616@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Hsieh commit f5fa54f45ab41cbb1f99b1208f49554132ffb207 upstream. [Why] The original latencies were causing underflow in some modes. Resolution: 2880x1620@60p when HDR enable [How] 1. Replace with the up-to-date watermark values based on new measurments 2. Correct the ddr_wm_table name to DDR5 on DCN31 Tested-by: Daniel Wheeler Reviewed-by: Aric Cyr Acked-by: Stylon Wang Signed-off-by: Paul Hsieh Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c | 20 +++++-= ----- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c @@ -329,38 +329,38 @@ static struct clk_bw_params dcn31_bw_par =20 }; =20 -static struct wm_table ddr4_wm_table =3D { +static struct wm_table ddr5_wm_table =3D { .entries =3D { { .wm_inst =3D WM_A, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 6.09, - .sr_enter_plus_exit_time_us =3D 7.14, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_B, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_C, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_D, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, } @@ -688,7 +688,7 @@ void dcn31_clk_mgr_construct( if (ctx->dc_bios->integrated_info->memory_type =3D=3D LpDdr5MemType) { dcn31_bw_params.wm_table =3D lpddr5_wm_table; } else { - dcn31_bw_params.wm_table =3D ddr4_wm_table; + dcn31_bw_params.wm_table =3D ddr5_wm_table; } /* Saved clocks configured at boot for debug purposes */ dcn31_dump_clk_registers(&clk_mgr->base.base.boot_snapshot, &clk_mgr->b= ase.base, &log_info); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1971EC433FE for ; Mon, 7 Feb 2022 11:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376352AbiBGLop (ORCPT ); Mon, 7 Feb 2022 06:44:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385982AbiBGLdO (ORCPT ); Mon, 7 Feb 2022 06:33:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E93C043181; Mon, 7 Feb 2022 03:33:13 -0800 (PST) Received: from smtp.kernel.org (relay.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 51A8460B20; Mon, 7 Feb 2022 11:33:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C6D0C004E1; Mon, 7 Feb 2022 11:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233592; bh=XQ2A7nbGwX4O6tcgG0WTiKbbbmm4PnYNbnVuQr6D52U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QmLCciIucW2XiuaHt+dW8etwOL3zlLathUBaCasX6Rq6U72op6974LrFCMErT/t9T dSUSxCYftG0fafBy17zoOBGgkTDtNdehTpbOF1gmyQT9yX9XFXAzAPYM20jT7XhsPn xOPOEOBf0r9EWYsBNwVorWDE2HMjh4ut3cwaYXb8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aun-Ali Zaidi , Harry Wentland , Aditya Garg , Alex Deucher Subject: [PATCH 5.16 028/126] drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels Date: Mon, 7 Feb 2022 12:05:59 +0100 Message-Id: <20220207103805.117814786@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Aun-Ali Zaidi commit 30fbce374745a9c6af93c775a5ac49a97f822fda upstream. The eDP link rate reported by the DP_MAX_LINK_RATE dpcd register (0xa) is contradictory to the highest rate supported reported by EDID (0xc =3D LINK_RATE_RBR2). The effects of this compounded with commit '4a8ca46bae8a ("drm/amd/display: Default max bpc to 16 for eDP")' results in no display modes being found and a dark panel. For now, simply force the maximum supported link rate for the eDP attached 2018 15" Apple Retina panels. Additionally, we must also check the firmware revision since the device ID reported by the DPCD is identical to that of the more capable 16,1, incorrectly quirking it. We also use said firmware check to quirk the refreshed 15,1 models with Vega graphics as they use a slightly newer firmware version. Tested-by: Aun-Ali Zaidi Reviewed-by: Harry Wentland Signed-off-by: Aun-Ali Zaidi Signed-off-by: Aditya Garg Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 20 ++++++++++++++++++= ++ 1 file changed, 20 insertions(+) --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c @@ -4730,6 +4730,26 @@ static bool retrieve_link_cap(struct dc_ dp_hw_fw_revision.ieee_fw_rev, sizeof(dp_hw_fw_revision.ieee_fw_rev)); =20 + /* Quirk for Apple MBP 2018 15" Retina panels: wrong DP_MAX_LINK_RATE */ + { + uint8_t str_mbp_2018[] =3D { 101, 68, 21, 103, 98, 97 }; + uint8_t fwrev_mbp_2018[] =3D { 7, 4 }; + uint8_t fwrev_mbp_2018_vega[] =3D { 8, 4 }; + + /* We also check for the firmware revision as 16,1 models have an + * identical device id and are incorrectly quirked otherwise. + */ + if ((link->dpcd_caps.sink_dev_id =3D=3D 0x0010fa) && + !memcmp(link->dpcd_caps.sink_dev_id_str, str_mbp_2018, + sizeof(str_mbp_2018)) && + (!memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018, + sizeof(fwrev_mbp_2018)) || + !memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018_vega, + sizeof(fwrev_mbp_2018_vega)))) { + link->reported_link_cap.link_rate =3D LINK_RATE_RBR2; + } + } + memset(&link->dpcd_caps.dsc_caps, '\0', sizeof(link->dpcd_caps.dsc_caps)); memset(&link->dpcd_caps.fec_cap, '\0', sizeof(link->dpcd_caps.fec_cap)); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAD10C433FE for ; Mon, 7 Feb 2022 11:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388099AbiBGLm6 (ORCPT ); Mon, 7 Feb 2022 06:42:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385657AbiBGLcE (ORCPT ); Mon, 7 Feb 2022 06:32:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 876C6C03E903; Mon, 7 Feb 2022 03:31:31 -0800 (PST) Received: from smtp.kernel.org (relay.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 4508BB80EBD; Mon, 7 Feb 2022 11:31:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64EE4C340F0; Mon, 7 Feb 2022 11:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233489; bh=A2S0A4K151GBnvxQG7aw3dDzjm91yV1nf3hlhXkSIF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3ntiaDnFaHb/ArPFfUwQ++YH0jy5aDey17EqgxdDTNd2uhxFHtMwaCRIbTmTV+3R RykrFTeIu5S1wTTy1tLCVXSNTOqPen4pfj0V5QJImkbaHL1SVkblKvfadRz6DKW8e6 9aj/fvcKH29gUQjIY3sJGsA7HN5WBx+/LO+59WEM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Uday Shankar , James Smart , Sagi Grimberg , Christoph Hellwig Subject: [PATCH 5.16 029/126] nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts() Date: Mon, 7 Feb 2022 12:06:00 +0100 Message-Id: <20220207103805.152074287@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Uday Shankar commit 6a51abdeb259a56d95f13cc67e3a0838bcda0377 upstream. Controller deletion/reset, immediately followed by or concurrent with a reconnect, is hard failing the connect attempt resulting in a complete loss of connectivity to the controller. In the connect request, fabrics looks for an existing controller with the same address components and aborts the connect if a controller already exists and the duplicate connect option isn't set. The match routine filters out controllers that are dead or dying, so they don't interfere with the new connect request. When NVME_CTRL_DELETING_NOIO was added, it missed updating the state filters in the nvmf_ctlr_matches_baseopts() routine. Thus, when in this new state, it's seen as a live controller and fails the connect request. Correct by adding the DELETING_NIO state to the match checks. Fixes: ecca390e8056 ("nvme: fix deadlock in disconnect during scan_work and= /or ana_work") Cc: # v5.7+ Signed-off-by: Uday Shankar Reviewed-by: James Smart Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/nvme/host/fabrics.h | 1 + 1 file changed, 1 insertion(+) --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -170,6 +170,7 @@ nvmf_ctlr_matches_baseopts(struct nvme_c struct nvmf_ctrl_options *opts) { if (ctrl->state =3D=3D NVME_CTRL_DELETING || + ctrl->state =3D=3D NVME_CTRL_DELETING_NOIO || ctrl->state =3D=3D NVME_CTRL_DEAD || strcmp(opts->subsysnqn, ctrl->opts->subsysnqn) || strcmp(opts->host->nqn, ctrl->opts->host->nqn) || From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83DBFC433EF for ; Mon, 7 Feb 2022 11:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388144AbiBGLnD (ORCPT ); Mon, 7 Feb 2022 06:43:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385664AbiBGLcE (ORCPT ); Mon, 7 Feb 2022 06:32:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71FBC0401C0; Mon, 7 Feb 2022 03:31:34 -0800 (PST) Received: from smtp.kernel.org (relay.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 8F508B811A6; Mon, 7 Feb 2022 11:31:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2F50C340EB; Mon, 7 Feb 2022 11:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233492; bh=LLYIADvuVzP5s+T9xBErFHnFjFO3FixGAqGldwSpfRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSVa6Sc7P6GqAxYjNDCbVDm+HR7yAHaadrWC1HWVBUF2jEyvQIz6k3v8/f9aUvkzs 0w1ZrRDoIVLBM5OargRLnHVj0ErFWDb5lXwN9+qbmwdvN2HKv4amwrbiTBAEmhqGrr AIB/JHzBtBwUwBB890S7zaoLIJW3JNMfQgOIq0GI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pasha Tatashin , Zi Yan , David Rientjes , Anshuman Khandual , Paul Turner , Wei Xu , Greg Thelen , Ingo Molnar , Will Deacon , Mike Rapoport , Dave Hansen , "H. Peter Anvin" , "Aneesh Kumar K.V" , Jiri Slaby , Muchun Song , Hugh Dickins , Andrew Morton , Linus Torvalds Subject: [PATCH 5.16 030/126] mm/debug_vm_pgtable: remove pte entry from the page table Date: Mon, 7 Feb 2022 12:06:01 +0100 Message-Id: <20220207103805.185385774@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Pasha Tatashin commit fb5222aae64fe25e5f3ebefde8214dcf3ba33ca5 upstream. Patch series "page table check fixes and cleanups", v5. This patch (of 4): The pte entry that is used in pte_advanced_tests() is never removed from the page table at the end of the test. The issue is detected by page_table_check, to repro compile kernel with the following configs: CONFIG_DEBUG_VM_PGTABLE=3Dy CONFIG_PAGE_TABLE_CHECK=3Dy CONFIG_PAGE_TABLE_CHECK_ENFORCED=3Dy During the boot the following BUG is printed: debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture pa= ge table helpers ------------[ cut here ]------------ kernel BUG at mm/page_table_check.c:162! invalid opcode: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0-11413-g2c271fe77d52 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-= g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 ... The entry should be properly removed from the page table before the page is released to the free list. Link: https://lkml.kernel.org/r/20220131203249.2832273-1-pasha.tatashin@sol= een.com Link: https://lkml.kernel.org/r/20220131203249.2832273-2-pasha.tatashin@sol= een.com Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced ar= ch page table helpers") Signed-off-by: Pasha Tatashin Reviewed-by: Zi Yan Tested-by: Zi Yan Acked-by: David Rientjes Reviewed-by: Anshuman Khandual Cc: Paul Turner Cc: Wei Xu Cc: Greg Thelen Cc: Ingo Molnar Cc: Will Deacon Cc: Mike Rapoport Cc: Dave Hansen Cc: H. Peter Anvin Cc: Aneesh Kumar K.V Cc: Jiri Slaby Cc: Muchun Song Cc: Hugh Dickins Cc: [5.9+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- mm/debug_vm_pgtable.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -171,6 +171,8 @@ static void __init pte_advanced_tests(st ptep_test_and_clear_young(args->vma, args->vaddr, args->ptep); pte =3D ptep_get(args->ptep); WARN_ON(pte_young(pte)); + + ptep_get_and_clear_full(args->mm, args->vaddr, args->ptep, 1); } =20 static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB723C433FE for ; Mon, 7 Feb 2022 11:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388172AbiBGLnI (ORCPT ); Mon, 7 Feb 2022 06:43:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385667AbiBGLcF (ORCPT ); Mon, 7 Feb 2022 06:32:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE31EC0401C1; Mon, 7 Feb 2022 03:31:36 -0800 (PST) Received: from smtp.kernel.org (relay.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 41C2A60B5B; Mon, 7 Feb 2022 11:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECAA8C004E1; Mon, 7 Feb 2022 11:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233495; bh=5kuKbyyGYmLTOSeoatF/Dlu5tcSfSUYM07uZYakDJNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLU+MzoFYkCueOsp8BwjQH5MdVdoq8ML8zoDLHy2NZWCAhm2KuG2y2ewCYqcaRE02 RClKM2bBVhLcPQHR3ygRk90N+V6/Vs/j3Fw3UQveiHm5eJQ0kSiZ+RSbzeCv0+/sSs /e5XWaeNmcmm81NjPmrtehJHirtJJxRIbKdXHfXg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Rapoport , Christian Dietrich , Khalid Aziz , Andrew Morton , Linus Torvalds Subject: [PATCH 5.16 031/126] mm/pgtable: define pte_index so that preprocessor could recognize it Date: Mon, 7 Feb 2022 12:06:02 +0100 Message-Id: <20220207103805.216538888@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Rapoport commit 314c459a6fe0957b5885fbc65c53d51444092880 upstream. Since commit 974b9b2c68f3 ("mm: consolidate pte_index() and pte_offset_*() definitions") pte_index is a static inline and there is no define for it that can be recognized by the preprocessor. As a result, vm_insert_pages() uses slower loop over vm_insert_page() instead of insert_pages() that amortizes the cost of spinlock operations when inserting multiple pages. Link: https://lkml.kernel.org/r/20220111145457.20748-1-rppt@kernel.org Fixes: 974b9b2c68f3 ("mm: consolidate pte_index() and pte_offset_*() defini= tions") Signed-off-by: Mike Rapoport Reported-by: Christian Dietrich Reviewed-by: Khalid Aziz Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- include/linux/pgtable.h | 1 + 1 file changed, 1 insertion(+) --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -62,6 +62,7 @@ static inline unsigned long pte_index(un { return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); } +#define pte_index pte_index =20 #ifndef pmd_index static inline unsigned long pmd_index(unsigned long address) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D1B8C433EF for ; Mon, 7 Feb 2022 11:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388201AbiBGLnL (ORCPT ); Mon, 7 Feb 2022 06:43:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385674AbiBGLcF (ORCPT ); Mon, 7 Feb 2022 06:32:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4BC4C0401C9; Mon, 7 Feb 2022 03:31:39 -0800 (PST) Received: from smtp.kernel.org (relay.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 645C560A67; Mon, 7 Feb 2022 11:31:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59056C004E1; Mon, 7 Feb 2022 11:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233498; bh=/mdKNCS/v4khbOY4M1DC21Yj9S+GLexjOpKckihNDzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+oba4UUyt62SP5tlCY52jKeRqJ1CvlMZ0laSxfnAS7aoI8EsYXoRJC0qMeu7+K6a OzbnWJ8Lr9RaeKtgf/CS5aMLv//vBzxIMf5nmIcKJD9CNFOsfdlZIN7lE5sjncgf9j GWc7IT6MackzAj0+me3ccKQQ4sXFF3xBtnPFbWhM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lang Yu , David Hildenbrand , Catalin Marinas , Oscar Salvador , Andrew Morton , Linus Torvalds Subject: [PATCH 5.16 032/126] mm/kmemleak: avoid scanning potential huge holes Date: Mon, 7 Feb 2022 12:06:03 +0100 Message-Id: <20220207103805.249337543@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Lang Yu commit c10a0f877fe007021d70f9cada240f42adc2b5db upstream. When using devm_request_free_mem_region() and devm_memremap_pages() to add ZONE_DEVICE memory, if requested free mem region's end pfn were huge(e.g., 0x400000000), the node_end_pfn() will be also huge (see move_pfn_range_to_zone()). Thus it creates a huge hole between node_start_pfn() and node_end_pfn(). We found on some AMD APUs, amdkfd requested such a free mem region and created a huge hole. In such a case, following code snippet was just doing busy test_bit() looping on the huge hole. for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { struct page *page =3D pfn_to_online_page(pfn); if (!page) continue; ... } So we got a soft lockup: watchdog: BUG: soft lockup - CPU#6 stuck for 26s! [bash:1221] CPU: 6 PID: 1221 Comm: bash Not tainted 5.15.0-custom #1 RIP: 0010:pfn_to_online_page+0x5/0xd0 Call Trace: ? kmemleak_scan+0x16a/0x440 kmemleak_write+0x306/0x3a0 ? common_file_perm+0x72/0x170 full_proxy_write+0x5c/0x90 vfs_write+0xb9/0x260 ksys_write+0x67/0xe0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae I did some tests with the patch. (1) amdgpu module unloaded before the patch: real 0m0.976s user 0m0.000s sys 0m0.968s after the patch: real 0m0.981s user 0m0.000s sys 0m0.973s (2) amdgpu module loaded before the patch: real 0m35.365s user 0m0.000s sys 0m35.354s after the patch: real 0m1.049s user 0m0.000s sys 0m1.042s Link: https://lkml.kernel.org/r/20211108140029.721144-1-lang.yu@amd.com Signed-off-by: Lang Yu Acked-by: David Hildenbrand Acked-by: Catalin Marinas Cc: Oscar Salvador Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- mm/kmemleak.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1403,7 +1403,8 @@ static void kmemleak_scan(void) { unsigned long flags; struct kmemleak_object *object; - int i; + struct zone *zone; + int __maybe_unused i; int new_leaks =3D 0; =20 jiffies_last_scan =3D jiffies; @@ -1443,9 +1444,9 @@ static void kmemleak_scan(void) * Struct page scanning for each node. */ get_online_mems(); - for_each_online_node(i) { - unsigned long start_pfn =3D node_start_pfn(i); - unsigned long end_pfn =3D node_end_pfn(i); + for_each_populated_zone(zone) { + unsigned long start_pfn =3D zone->zone_start_pfn; + unsigned long end_pfn =3D zone_end_pfn(zone); unsigned long pfn; =20 for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { @@ -1454,8 +1455,8 @@ static void kmemleak_scan(void) if (!page) continue; =20 - /* only scan pages belonging to this node */ - if (page_to_nid(page) !=3D i) + /* only scan pages belonging to this zone */ + if (page_zone(page) !=3D zone) continue; /* only scan if page is in use */ if (page_count(page) =3D=3D 0) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47045C4332F for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388246AbiBGLnQ (ORCPT ); Mon, 7 Feb 2022 06:43:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385678AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B23C0401CF; Mon, 7 Feb 2022 03:31:44 -0800 (PST) Received: from smtp.kernel.org (relay.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 32B73B8111C; Mon, 7 Feb 2022 11:31:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67714C004E1; Mon, 7 Feb 2022 11:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233502; bh=BLyOJI36eHMt72Wa5DjaMq8TiYzOPzbxdmmTZTFuakE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5lj6MudxBokfGNhilrYbXrsejSDtaBleDEr32pa4DV/YzWy1m7xjmJi/DUnTGgCd neHhHhPI1O0aiCtBJ/I2xbwPey7P751tgjw9PM0+w3UnDJwrRaQhqrai+z+QCW0378 eQ2Wcy0+BYPB9P4oJgZgTnMuCKVnkEwMVMXS3zXc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Monakhov , Dmitry Ivanov , Alexey Lyashkov , "Martin K. Petersen" , Jens Axboe Subject: [PATCH 5.16 033/126] block: bio-integrity: Advance seed correctly for larger interval sizes Date: Mon, 7 Feb 2022 12:06:04 +0100 Message-Id: <20220207103805.284934022@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Martin K. Petersen commit b13e0c71856817fca67159b11abac350e41289f5 upstream. Commit 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update integrity seed") added code to update the integrity seed value when advancing a bio. However, it failed to take into account that the integrity interval might be larger than the 512-byte block layer sector size. This broke bio splitting on PI devices with 4KB logical blocks. The seed value should be advanced by bio_integrity_intervals() and not the number of sectors. Cc: Dmitry Monakhov Cc: stable@vger.kernel.org Fixes: 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update inte= grity seed") Tested-by: Dmitry Ivanov Reported-by: Alexey Lyashkov Signed-off-by: Martin K. Petersen Link: https://lore.kernel.org/r/20220204034209.4193-1-martin.petersen@oracl= e.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- block/bio-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -373,7 +373,7 @@ void bio_integrity_advance(struct bio *b struct blk_integrity *bi =3D blk_get_integrity(bio->bi_bdev->bd_disk); unsigned bytes =3D bio_integrity_bytes(bi, bytes_done >> 9); =20 - bip->bip_iter.bi_sector +=3D bytes_done >> 9; + bip->bip_iter.bi_sector +=3D bio_integrity_intervals(bi, bytes_done >> 9); bvec_iter_advance(bip->bip_vec, &bip->bip_iter, bytes); } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 250A7C352A1 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391169AbiBGL6j (ORCPT ); Mon, 7 Feb 2022 06:58:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385679AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27452C0401D1; Mon, 7 Feb 2022 03:31:46 -0800 (PST) Received: from smtp.kernel.org (relay.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 B774160A67; Mon, 7 Feb 2022 11:31:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1232C004E1; Mon, 7 Feb 2022 11:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233505; bh=F68DvOu11U/2Izi/Om2gsPqtu/mO84SiK259QUL0IZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eF9j0nENq4C7nqbR1fLvWKTxfu31z4UzteH2CfdwLVKyi6UbKmO1McZ4MENy8UGbk FgMOFoctl/W3AAOtnKfS+3hbDKUAzxZPE9sQe7OLT0TxEKqqN3c1fCEMSRWubcQrzF 1D0hZ0LKN1tzkBkbEwgjYpb/6P9/3Ch8dh3NAxNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paulo Alcantara (SUSE)" , Ryan Bair , Steve French Subject: [PATCH 5.16 034/126] cifs: fix workstation_name for multiuser mounts Date: Mon, 7 Feb 2022 12:06:05 +0100 Message-Id: <20220207103805.320263296@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Ryan Bair commit d3b331fb51f326d5b5326010bf2b5841bb86cdc6 upstream. Set workstation_name from the master_tcon for multiuser mounts. Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name. Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session se= tup") Cc: stable@vger.kernel.org # 5.16 Reviewed-by: Paulo Alcantara (SUSE) Signed-off-by: Ryan Bair Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/cifs/connect.c | 13 +++++++++++++ fs/cifs/sess.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1945,6 +1945,19 @@ cifs_set_cifscreds(struct smb3_fs_contex } } =20 + ctx->workstation_name =3D kstrdup(ses->workstation_name, GFP_KERNEL); + if (!ctx->workstation_name) { + cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n"); + rc =3D -ENOMEM; + kfree(ctx->username); + ctx->username =3D NULL; + kfree_sensitive(ctx->password); + ctx->password =3D NULL; + kfree(ctx->domainname); + ctx->domainname =3D NULL; + goto out_key_put; + } + out_key_put: up_read(&key->sem); key_put(key); --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -675,7 +675,11 @@ static int size_of_ntlmssp_blob(struct c else sz +=3D sizeof(__le16); =20 - sz +=3D sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTAT= ION_LEN); + if (ses->workstation_name) + sz +=3D sizeof(__le16) * strnlen(ses->workstation_name, + CIFS_MAX_WORKSTATION_LEN); + else + sz +=3D sizeof(__le16); =20 return sz; } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67019C43219 for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388260AbiBGLnR (ORCPT ); Mon, 7 Feb 2022 06:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385680AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49DC9C0401D2; Mon, 7 Feb 2022 03:31:51 -0800 (PST) Received: from smtp.kernel.org (relay.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 DD8A8B811A6; Mon, 7 Feb 2022 11:31:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3824C004E1; Mon, 7 Feb 2022 11:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233508; bh=n9ts40NzW/gNgiYJSJZjAg4qmKmz5RkYXFbhssIVcNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQ96lTIDG8I5CUJToi1mE5Axn7Ph7YUezwQzkwh/7KoY/14LOKfhFXYPx1S0PkAcF WFeAesJCmUVZvXkrCZrFKiUphOWJVXkCY1bdcrV+HplUyOfX6EZQtW7F2Yjbari5zf IS23lqYytpfCwmZoYdbTFrrAJpn7Fd6KclrIts4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordy Zomer , John Stultz , Sumit Semwal Subject: [PATCH 5.16 035/126] dma-buf: heaps: Fix potential spectre v1 gadget Date: Mon, 7 Feb 2022 12:06:06 +0100 Message-Id: <20220207103805.354301991@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Jordy Zomer commit 92c4cfaee6872038563c5b6f2e8e613f9d84d47d upstream. It appears like nr could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec. Signed-off-by: Jordy Zomer Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework") Cc: # v5.6+ Acked-by: John Stultz Signed-off-by: Sumit Semwal [sumits: added fixes and cc: stable tags] Link: https://patchwork.freedesktop.org/patch/msgid/20220129150604.3461652-= 1-jordy@pwning.systems Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/dma-buf/dma-heap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,7 @@ static long dma_heap_ioctl(struct file * if (nr >=3D ARRAY_SIZE(dma_heap_ioctl_cmds)) return -EINVAL; =20 + nr =3D array_index_nospec(nr, ARRAY_SIZE(dma_heap_ioctl_cmds)); /* Get the kernel ioctl cmd that matches */ kcmd =3D dma_heap_ioctl_cmds[nr]; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B99C4167D for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388304AbiBGLn1 (ORCPT ); Mon, 7 Feb 2022 06:43:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385683AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F32C0401D3; Mon, 7 Feb 2022 03:31:53 -0800 (PST) Received: from smtp.kernel.org (relay.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 9A6A160A67; Mon, 7 Feb 2022 11:31:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DE7CC004E1; Mon, 7 Feb 2022 11:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233512; bh=se97KZL3JpsFxJ8ZQy95Brw1C50SVIoarbrezIf3j+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0nCAo6feEwdEQyvwNeUd/5ZZiVny/BI64UJu5IkSBuT3MBZAi58Av5Oecz26dOwCw 6XsFJTPGRXMHAI4Any1hvy6eHXiWl9uxAfe31JCBwMtHS72+hp0GTs/mW9lxwnB48P LsSmPJpSmaZk/F5cwpOxTPQfzSkun/IFTL4JtLFc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.16 036/126] IB/hfi1: Fix panic with larger ipoib send_queue_size Date: Mon, 7 Feb 2022 12:06:07 +0100 Message-Id: <20220207103805.388207888@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Marciniszyn commit 8c83d39cc730378bbac64d67a551897b203a606e upstream. When the ipoib send_queue_size is increased from the default the following panic happens: RIP: 0010:hfi1_ipoib_drain_tx_ring+0x45/0xf0 [hfi1] Code: 31 e4 eb 0f 8b 85 c8 02 00 00 41 83 c4 01 44 39 e0 76 60 8b 8d cc 0= 2 00 00 44 89 e3 be 01 00 00 00 d3 e3 48 03 9d c0 02 00 00 83 18 01 00= 00 00 00 00 00 48 8b bb 30 01 00 00 e8 25 af a7 e0 RSP: 0018:ffffc9000798f4a0 EFLAGS: 00010286 RAX: 0000000000008000 RBX: ffffc9000aa0f000 RCX: 000000000000000f RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000 RBP: ffff88810ff08000 R08: ffff88889476d900 R09: 0000000000000101 R10: 0000000000000000 R11: ffffc90006590ff8 R12: 0000000000000200 R13: ffffc9000798fba8 R14: 0000000000000000 R15: 0000000000000001 FS: 00007fd0f79cc3c0(0000) GS:ffff88885fb00000(0000) knlGS:0000000000000= 000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc9000aa0f118 CR3: 0000000889c84001 CR4: 00000000001706e0 Call Trace: hfi1_ipoib_napi_tx_disable+0x45/0x60 [hfi1] hfi1_ipoib_dev_stop+0x18/0x80 [hfi1] ipoib_ib_dev_stop+0x1d/0x40 [ib_ipoib] ipoib_stop+0x48/0xc0 [ib_ipoib] __dev_close_many+0x9e/0x110 __dev_change_flags+0xd9/0x210 dev_change_flags+0x21/0x60 do_setlink+0x31c/0x10f0 ? __nla_validate_parse+0x12d/0x1a0 ? __nla_parse+0x21/0x30 ? inet6_validate_link_af+0x5e/0xf0 ? cpumask_next+0x1f/0x20 ? __snmp6_fill_stats64.isra.53+0xbb/0x140 ? __nla_validate_parse+0x47/0x1a0 __rtnl_newlink+0x530/0x910 ? pskb_expand_head+0x73/0x300 ? __kmalloc_node_track_caller+0x109/0x280 ? __nla_put+0xc/0x20 ? cpumask_next_and+0x20/0x30 ? update_sd_lb_stats.constprop.144+0xd3/0x820 ? _raw_spin_unlock_irqrestore+0x25/0x37 ? __wake_up_common_lock+0x87/0xc0 ? kmem_cache_alloc_trace+0x3d/0x3d0 rtnl_newlink+0x43/0x60 The issue happens when the shift that should have been a function of the txq item size mistakenly used the ring size. Fix by using the item size. Cc: stable@vger.kernel.org Fixes: d47dfc2b00e6 ("IB/hfi1: Remove cache and embed txreq in ring") Link: https://lore.kernel.org/r/1642287756-182313-2-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/hfi1/ipoib_tx.c +++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c @@ -731,7 +731,7 @@ int hfi1_ipoib_txreq_init(struct hfi1_ip goto free_txqs; =20 txq->tx_ring.max_items =3D tx_ring_size; - txq->tx_ring.shift =3D ilog2(tx_ring_size); + txq->tx_ring.shift =3D ilog2(tx_item_size); txq->tx_ring.avail =3D hfi1_ipoib_ring_hwat(txq); =20 netif_tx_napi_add(dev, &txq->napi, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E309C4321E for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388276AbiBGLnV (ORCPT ); Mon, 7 Feb 2022 06:43:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385681AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E381C0401D4; Mon, 7 Feb 2022 03:31:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 5F35CB8111C; Mon, 7 Feb 2022 11:31:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95434C004E1; Mon, 7 Feb 2022 11:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233515; bh=QVmF++sgL5K8mV3wQlECsBRirJ5ovffGWfToglpzGLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xaAhfGqRXaeQntRv/zLuSiU5H15SMHBuMqZv7cL4ewpvNzA/QFPz76NxokQCn2Ikn cLdP9tJTEg7ya5hV1TNo2ZUPAfGHzwh+kQ/H2O870gJ1D2uYajEDODS4mVlWwA4m6n FhbiF6Ixp1IAgN5EO+mHLrtyIVck92RtgfVJQeSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.16 037/126] IB/hfi1: Fix alloc failure with larger txqueuelen Date: Mon, 7 Feb 2022 12:06:08 +0100 Message-Id: <20220207103805.418161681@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Marciniszyn commit b1151b74ff68cc83c2a8e1a618efe7d056e4f237 upstream. The following allocation with large txqueuelen will result in the following warning: Call Trace: __alloc_pages_nodemask+0x283/0x2c0 kmalloc_large_node+0x3c/0xa0 __kmalloc_node+0x22a/0x2f0 hfi1_ipoib_txreq_init+0x19f/0x330 [hfi1] hfi1_ipoib_setup_rn+0xd3/0x1a0 [hfi1] rdma_init_netdev+0x5a/0x80 [ib_core] ipoib_intf_init+0x6c/0x350 [ib_ipoib] ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib] ipoib_add_one+0xbe/0x300 [ib_ipoib] add_client_context+0x12c/0x1a0 [ib_core] ib_register_client+0x147/0x190 [ib_core] ipoib_init_module+0xdd/0x132 [ib_ipoib] do_one_initcall+0x46/0x1c3 do_init_module+0x5a/0x220 load_module+0x14c5/0x17f0 __do_sys_init_module+0x13b/0x180 do_syscall_64+0x5b/0x1a0 entry_SYSCALL_64_after_hwframe+0x65/0xca For ipoib, the txqueuelen is modified with the module parameter send_queue_size. Fix by changing to use kv versions of the same allocator to handle the large allocations. The allocation embeds a hdr struct that is dma mapped. Change that struct to a pointer to a kzalloced struct. Cc: stable@vger.kernel.org Fixes: d99dc602e2a5 ("IB/hfi1: Add functions to transmit datagram ipoib pac= kets") Link: https://lore.kernel.org/r/1642287756-182313-3-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib.h | 2 - drivers/infiniband/hw/hfi1/ipoib_tx.c | 36 +++++++++++++++++++++++------= ----- 2 files changed, 26 insertions(+), 12 deletions(-) --- a/drivers/infiniband/hw/hfi1/ipoib.h +++ b/drivers/infiniband/hw/hfi1/ipoib.h @@ -55,7 +55,7 @@ union hfi1_ipoib_flow { */ struct ipoib_txreq { struct sdma_txreq txreq; - struct hfi1_sdma_header sdma_hdr; + struct hfi1_sdma_header *sdma_hdr; int sdma_status; int complete; struct hfi1_ipoib_dev_priv *priv; --- a/drivers/infiniband/hw/hfi1/ipoib_tx.c +++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c @@ -122,7 +122,7 @@ static void hfi1_ipoib_free_tx(struct ip dd_dev_warn(priv->dd, "%s: Status =3D 0x%x pbc 0x%llx txq =3D %d sde =3D %d\n", __func__, tx->sdma_status, - le64_to_cpu(tx->sdma_hdr.pbc), tx->txq->q_idx, + le64_to_cpu(tx->sdma_hdr->pbc), tx->txq->q_idx, tx->txq->sde->this_idx); } =20 @@ -231,7 +231,7 @@ static int hfi1_ipoib_build_tx_desc(stru { struct hfi1_devdata *dd =3D txp->dd; struct sdma_txreq *txreq =3D &tx->txreq; - struct hfi1_sdma_header *sdma_hdr =3D &tx->sdma_hdr; + struct hfi1_sdma_header *sdma_hdr =3D tx->sdma_hdr; u16 pkt_bytes =3D sizeof(sdma_hdr->pbc) + (txp->hdr_dwords << 2) + tx->skb->len; int ret; @@ -256,7 +256,7 @@ static void hfi1_ipoib_build_ib_tx_heade struct ipoib_txparms *txp) { struct hfi1_ipoib_dev_priv *priv =3D tx->txq->priv; - struct hfi1_sdma_header *sdma_hdr =3D &tx->sdma_hdr; + struct hfi1_sdma_header *sdma_hdr =3D tx->sdma_hdr; struct sk_buff *skb =3D tx->skb; struct hfi1_pportdata *ppd =3D ppd_from_ibp(txp->ibp); struct rdma_ah_attr *ah_attr =3D txp->ah_attr; @@ -483,7 +483,7 @@ static int hfi1_ipoib_send_dma_single(st if (likely(!ret)) { tx_ok: trace_sdma_output_ibhdr(txq->priv->dd, - &tx->sdma_hdr.hdr, + &tx->sdma_hdr->hdr, ib_is_sc5(txp->flow.sc5)); hfi1_ipoib_check_queue_depth(txq); return NETDEV_TX_OK; @@ -547,7 +547,7 @@ static int hfi1_ipoib_send_dma_list(stru hfi1_ipoib_check_queue_depth(txq); =20 trace_sdma_output_ibhdr(txq->priv->dd, - &tx->sdma_hdr.hdr, + &tx->sdma_hdr->hdr, ib_is_sc5(txp->flow.sc5)); =20 if (!netdev_xmit_more()) @@ -683,7 +683,8 @@ int hfi1_ipoib_txreq_init(struct hfi1_ip { struct net_device *dev =3D priv->netdev; u32 tx_ring_size, tx_item_size; - int i; + struct hfi1_ipoib_circ_buf *tx_ring; + int i, j; =20 /* * Ring holds 1 less than tx_ring_size @@ -701,7 +702,9 @@ int hfi1_ipoib_txreq_init(struct hfi1_ip =20 for (i =3D 0; i < dev->num_tx_queues; i++) { struct hfi1_ipoib_txq *txq =3D &priv->txqs[i]; + struct ipoib_txreq *tx; =20 + tx_ring =3D &txq->tx_ring; iowait_init(&txq->wait, 0, hfi1_ipoib_flush_txq, @@ -725,14 +728,19 @@ int hfi1_ipoib_txreq_init(struct hfi1_ip priv->dd->node); =20 txq->tx_ring.items =3D - kcalloc_node(tx_ring_size, tx_item_size, - GFP_KERNEL, priv->dd->node); + kvzalloc_node(array_size(tx_ring_size, tx_item_size), + GFP_KERNEL, priv->dd->node); if (!txq->tx_ring.items) goto free_txqs; =20 txq->tx_ring.max_items =3D tx_ring_size; txq->tx_ring.shift =3D ilog2(tx_item_size); txq->tx_ring.avail =3D hfi1_ipoib_ring_hwat(txq); + tx_ring =3D &txq->tx_ring; + for (j =3D 0; j < tx_ring_size; j++) + hfi1_txreq_from_idx(tx_ring, j)->sdma_hdr =3D + kzalloc_node(sizeof(*tx->sdma_hdr), + GFP_KERNEL, priv->dd->node); =20 netif_tx_napi_add(dev, &txq->napi, hfi1_ipoib_poll_tx_ring, @@ -746,7 +754,10 @@ free_txqs: struct hfi1_ipoib_txq *txq =3D &priv->txqs[i]; =20 netif_napi_del(&txq->napi); - kfree(txq->tx_ring.items); + tx_ring =3D &txq->tx_ring; + for (j =3D 0; j < tx_ring_size; j++) + kfree(hfi1_txreq_from_idx(tx_ring, j)->sdma_hdr); + kvfree(tx_ring->items); } =20 kfree(priv->txqs); @@ -780,17 +791,20 @@ static void hfi1_ipoib_drain_tx_list(str =20 void hfi1_ipoib_txreq_deinit(struct hfi1_ipoib_dev_priv *priv) { - int i; + int i, j; =20 for (i =3D 0; i < priv->netdev->num_tx_queues; i++) { struct hfi1_ipoib_txq *txq =3D &priv->txqs[i]; + struct hfi1_ipoib_circ_buf *tx_ring =3D &txq->tx_ring; =20 iowait_cancel_work(&txq->wait); iowait_sdma_drain(&txq->wait); hfi1_ipoib_drain_tx_list(txq); netif_napi_del(&txq->napi); hfi1_ipoib_drain_tx_ring(txq); - kfree(txq->tx_ring.items); + for (j =3D 0; j < tx_ring->max_items; j++) + kfree(hfi1_txreq_from_idx(tx_ring, j)->sdma_hdr); + kvfree(tx_ring->items); } =20 kfree(priv->txqs); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90259C433EF for ; Mon, 7 Feb 2022 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388291AbiBGLnY (ORCPT ); Mon, 7 Feb 2022 06:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385682AbiBGLcG (ORCPT ); Mon, 7 Feb 2022 06:32:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE58CC0401D5; Mon, 7 Feb 2022 03:32:00 -0800 (PST) Received: from smtp.kernel.org (relay.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 74B0BB80EBD; Mon, 7 Feb 2022 11:31:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1D77C004E1; Mon, 7 Feb 2022 11:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233518; bh=mEtObQG33qfn2d7Uum/gcizK3oGUXgWfZ3PZj7UOunU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1BOsNOeU6sJ3MloAvZxzwcSi8Ix6s2vF9F0Q0GbliX91B10MPLjwGDvtLW7EmEB87 cGBxP9q+bY7fcJrgbgz85e89FmhvHxLp+GvBfE/jZ0DuHPsgmXlDyM5Vax5A+WVSq9 nHZmEqcUEpgu/opnJgnS5boe7vi2/YrYcypWhRpA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.16 038/126] IB/hfi1: Fix AIP early init panic Date: Mon, 7 Feb 2022 12:06:09 +0100 Message-Id: <20220207103805.449533570@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Marciniszyn commit 5f8f55b92edd621f056bdf09e572092849fabd83 upstream. An early failure in hfi1_ipoib_setup_rn() can lead to the following panic: BUG: unable to handle kernel NULL pointer dereference at 00000000000001b0 PGD 0 P4D 0 Oops: 0002 [#1] SMP NOPTI Workqueue: events work_for_cpu_fn RIP: 0010:try_to_grab_pending+0x2b/0x140 Code: 1f 44 00 00 41 55 41 54 55 48 89 d5 53 48 89 fb 9c 58 0f 1f 44 00 0= 0 48 89 c2 fa 66 0f 1f 44 00 00 48 89 55 00 40 84 f6 75 77 48 0f ba 2b= 00 72 09 31 c0 5b 5d 41 5c 41 5d c3 48 89 df e8 6c RSP: 0018:ffffb6b3cf7cfa48 EFLAGS: 00010046 RAX: 0000000000000246 RBX: 00000000000001b0 RCX: 0000000000000000 RDX: 0000000000000246 RSI: 0000000000000000 RDI: 00000000000001b0 RBP: ffffb6b3cf7cfa70 R08: 0000000000000f09 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 R13: ffffb6b3cf7cfa90 R14: ffffffff9b2fbfc0 R15: ffff8a4fdf244690 FS: 0000000000000000(0000) GS:ffff8a527f400000(0000) knlGS:0000000000000= 000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000001b0 CR3: 00000017e2410003 CR4: 00000000007706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __cancel_work_timer+0x42/0x190 ? dev_printk_emit+0x4e/0x70 iowait_cancel_work+0x15/0x30 [hfi1] hfi1_ipoib_txreq_deinit+0x5a/0x220 [hfi1] ? dev_err+0x6c/0x90 hfi1_ipoib_netdev_dtor+0x15/0x30 [hfi1] hfi1_ipoib_setup_rn+0x10e/0x150 [hfi1] rdma_init_netdev+0x5a/0x80 [ib_core] ? hfi1_ipoib_free_rdma_netdev+0x20/0x20 [hfi1] ipoib_intf_init+0x6c/0x350 [ib_ipoib] ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib] ipoib_add_one+0xbe/0x300 [ib_ipoib] add_client_context+0x12c/0x1a0 [ib_core] enable_device_and_get+0xdc/0x1d0 [ib_core] ib_register_device+0x572/0x6b0 [ib_core] rvt_register_device+0x11b/0x220 [rdmavt] hfi1_register_ib_device+0x6b4/0x770 [hfi1] do_init_one.isra.20+0x3e3/0x680 [hfi1] local_pci_probe+0x41/0x90 work_for_cpu_fn+0x16/0x20 process_one_work+0x1a7/0x360 ? create_worker+0x1a0/0x1a0 worker_thread+0x1cf/0x390 ? create_worker+0x1a0/0x1a0 kthread+0x116/0x130 ? kthread_flush_work_fn+0x10/0x10 ret_from_fork+0x1f/0x40 The panic happens in hfi1_ipoib_txreq_deinit() because there is a NULL deref when hfi1_ipoib_netdev_dtor() is called in this error case. hfi1_ipoib_txreq_init() and hfi1_ipoib_rxq_init() are self unwinding so fix by adjusting the error paths accordingly. Other changes: - hfi1_ipoib_free_rdma_netdev() is deleted including the free_netdev() since the netdev core code deletes calls free_netdev() - The switch to the accelerated entrances is moved to the success path. Cc: stable@vger.kernel.org Fixes: d99dc602e2a5 ("IB/hfi1: Add functions to transmit datagram ipoib pac= kets") Link: https://lore.kernel.org/r/1642287756-182313-4-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib_main.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) --- a/drivers/infiniband/hw/hfi1/ipoib_main.c +++ b/drivers/infiniband/hw/hfi1/ipoib_main.c @@ -168,12 +168,6 @@ static void hfi1_ipoib_netdev_dtor(struc free_percpu(dev->tstats); } =20 -static void hfi1_ipoib_free_rdma_netdev(struct net_device *dev) -{ - hfi1_ipoib_netdev_dtor(dev); - free_netdev(dev); -} - static void hfi1_ipoib_set_id(struct net_device *dev, int id) { struct hfi1_ipoib_dev_priv *priv =3D hfi1_ipoib_priv(dev); @@ -211,24 +205,23 @@ static int hfi1_ipoib_setup_rn(struct ib priv->port_num =3D port_num; priv->netdev_ops =3D netdev->netdev_ops; =20 - netdev->netdev_ops =3D &hfi1_ipoib_netdev_ops; - ib_query_pkey(device, port_num, priv->pkey_index, &priv->pkey); =20 rc =3D hfi1_ipoib_txreq_init(priv); if (rc) { dd_dev_err(dd, "IPoIB netdev TX init - failed(%d)\n", rc); - hfi1_ipoib_free_rdma_netdev(netdev); return rc; } =20 rc =3D hfi1_ipoib_rxq_init(netdev); if (rc) { dd_dev_err(dd, "IPoIB netdev RX init - failed(%d)\n", rc); - hfi1_ipoib_free_rdma_netdev(netdev); + hfi1_ipoib_txreq_deinit(priv); return rc; } =20 + netdev->netdev_ops =3D &hfi1_ipoib_netdev_ops; + netdev->priv_destructor =3D hfi1_ipoib_netdev_dtor; netdev->needs_free_netdev =3D true; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F2AAC46467 for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388361AbiBGLng (ORCPT ); Mon, 7 Feb 2022 06:43:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385696AbiBGLcK (ORCPT ); Mon, 7 Feb 2022 06:32:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C85C0401D7; Mon, 7 Feb 2022 03:32:07 -0800 (PST) Received: from smtp.kernel.org (relay.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 51C21B80EC3; Mon, 7 Feb 2022 11:32:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DA4CC004E1; Mon, 7 Feb 2022 11:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233525; bh=UMuad2bx9Cjml8iZvAN+BfDGavEA1WugxXYh5A/eIBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZ8rRoS1ywB7KSq7OWENfEonjL62/pv4sI+Af6+uAUkzaXM+Wl5X2pICij6NhAWSZ o+WRwmpcUEMcvey4VZQUw70Rye6GIj6RAzeyxBbMa5gdU/tXKTQgTcqFvv0jiIGTw8 ccjRUM2Jp/cjhDiglHS2Du3H1KF4H55pegciQz5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Geert Uytterhoeven , Sven Schnelle , Daniel Vetter Subject: [PATCH 5.16 039/126] Revert "fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)" Date: Mon, 7 Feb 2022 12:06:10 +0100 Message-Id: <20220207103805.481274163@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 1148836fd3226c20de841084aba24184d4fbbe77 upstream. This reverts commit b3ec8cdf457e5e63d396fe1346cc788cf7c1b578. Revert the second (of 2) commits which disabled scrolling acceleration in fbcon/fbdev. It introduced a regression for fbdev-supported graphic cards because of the performance penalty by doing screen scrolling by software instead of using the existing graphic card 2D hardware acceleration. Console scrolling acceleration was disabled by dropping code which checked at runtime the driver hardware capabilities for the BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move screen contents. After dropping those checks scrollmode was hard-wired to SCROLL_REDRAW instead, which forces all graphic cards to redraw every character at the new screen position when scrolling. This change effectively disabled all hardware-based scrolling acceleration = for ALL drivers, because now all kind of 2D hardware acceleration (bitblt, fillrect) in the drivers isn't used any longer. The original commit message mentions that only 3 DRM drivers (nouveau, omap= drm and gma500) used hardware acceleration in the past and thus code for checki= ng and using scrolling acceleration is obsolete. This statement is NOT TRUE, because beside the DRM drivers there are around= 35 other fbdev drivers which depend on fbdev/fbcon and still provide hardware acceleration for fbdev/fbcon. The original commit message also states that syzbot found lots of bugs in f= bcon and thus it's "often the solution to just delete code and remove features". This is true, and the bugs - which actually affected all users of fbcon, including DRM - were fixed, or code was dropped like e.g. the support for software scrollback in vgacon (commit 973c096f6a85). So to further analyze which bugs were found by syzbot, I've looked through = all patches in drivers/video which were tagged with syzbot or syzkaller back to year 2005. The vast majority fixed the reported issues on a higher level, e= .g. when screen is to be resized, or when font size is to be changed. The few o= nes which touched driver code fixed a real driver bug, e.g. by adding a check. But NONE of those patches touched code of either the SCROLL_MOVE or the SCROLL_REDRAW case. That means, there was no real reason why SCROLL_MOVE had to be ripped-out a= nd just SCROLL_REDRAW had to be used instead. The only reason I can imagine so= far was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it could go away. That argument completely missed the fact that SCROLL_MOVE is still heavily used by fbdev (non-DRM) drivers. Some people mention that using memcpy() instead of the hardware acceleratio= n is pretty much the same speed. But that's not true, at least not for older gra= phic cards and machines where we see speed decreases by factor 10 and more and t= hus this change leads to console responsiveness way worse than before. That's why the original commit is to be reverted. By reverting we reintroduce hardware-based scrolling acceleration and fix the performance regression for fbdev drivers. There isn't any impact on DRM when reverting those patches. Signed-off-by: Helge Deller Acked-by: Geert Uytterhoeven Acked-by: Sven Schnelle Cc: stable@vger.kernel.org # v5.16+ Signed-off-by: Helge Deller Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-2-= deller@gmx.de Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- Documentation/gpu/todo.rst | 13=20 drivers/video/fbdev/core/bitblit.c | 16 + drivers/video/fbdev/core/fbcon.c | 509 +++++++++++++++++++++++++++= +++-- drivers/video/fbdev/core/fbcon.h | 59 +++ drivers/video/fbdev/core/fbcon_ccw.c | 28 + drivers/video/fbdev/core/fbcon_cw.c | 28 + drivers/video/fbdev/core/fbcon_rotate.h | 9=20 drivers/video/fbdev/core/fbcon_ud.c | 37 +- drivers/video/fbdev/core/tileblit.c | 16 + drivers/video/fbdev/skeletonfb.c | 12=20 include/linux/fb.h | 2=20 11 files changed, 678 insertions(+), 51 deletions(-) --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -314,19 +314,16 @@ Level: Advanced Garbage collect fbdev scrolling acceleration -------------------------------------------- =20 -Scroll acceleration has been disabled in fbcon. Now it works as the old -SCROLL_REDRAW mode. A ton of code was removed in fbcon.c and the hook bmov= e was -removed from fbcon_ops. -Remaining tasks: +Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =3D +SCROLL_REDRAW. There's a ton of code this will allow us to remove: =20 -- a bunch of the hooks in fbcon_ops could be removed or simplified by call= ing +- lots of code in fbcon.c + +- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be ca= lled directly instead of the function table (with a switch on p->rotate) =20 - fb_copyarea is unused after this, and can be deleted from all drivers =20 -- after that, fb_copyarea can be deleted from fb_ops in include/linux/fb.h= as - well as cfb_copyarea - Note that not all acceleration code can be deleted, since clearing and cur= sor support is still accelerated, which might be good candidates for further deletion projects. --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -43,6 +43,21 @@ static void update_attr(u8 *dst, u8 *src } } =20 +static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fb_copyarea area; + + area.sx =3D sx * vc->vc_font.width; + area.sy =3D sy * vc->vc_font.height; + area.dx =3D dx * vc->vc_font.width; + area.dy =3D dy * vc->vc_font.height; + area.height =3D height * vc->vc_font.height; + area.width =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { @@ -378,6 +393,7 @@ static int bit_update_start(struct fb_in =20 void fbcon_set_bitops(struct fbcon_ops *ops) { + ops->bmove =3D bit_bmove; ops->clear =3D bit_clear; ops->putcs =3D bit_putcs; ops->clear_margins =3D bit_clear_margins; --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -173,6 +173,8 @@ static void fbcon_putcs(struct vc_data * int count, int ypos, int xpos); static void fbcon_clear_margins(struct vc_data *vc, int bottom_only); static void fbcon_cursor(struct vc_data *vc, int mode); +static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, + int height, int width); static int fbcon_switch(struct vc_data *vc); static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch); static void fbcon_set_palette(struct vc_data *vc, const unsigned char *tab= le); @@ -180,8 +182,16 @@ static void fbcon_set_palette(struct vc_ /* * Internal routines */ +static __inline__ void ywrap_up(struct vc_data *vc, int count); +static __inline__ void ywrap_down(struct vc_data *vc, int count); +static __inline__ void ypan_up(struct vc_data *vc, int count); +static __inline__ void ypan_down(struct vc_data *vc, int count); +static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, i= nt sy, int sx, + int dy, int dx, int height, int width, u_int y_break); static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo = *var, int unit); +static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p, + int line, int count, int dy); static void fbcon_modechanged(struct fb_info *info); static void fbcon_set_all_vcs(struct fb_info *info); static void fbcon_start(void); @@ -1126,6 +1136,14 @@ static void fbcon_init(struct vc_data *v ops->graphics =3D 0; =20 /* + * No more hw acceleration for fbcon. + * + * FIXME: Garbage collect all the now dead code after sufficient time + * has passed. + */ + p->scrollmode =3D SCROLL_REDRAW; + + /* * ++guenther: console.c:vc_allocate() relies on initializing * vc_{cols,rows}, but we must not set those if we are only * resizing the console. @@ -1211,13 +1229,14 @@ finished: * This system is now divided into two levels because of complications * caused by hardware scrolling. Top level functions: * - * fbcon_clear(), fbcon_putc(), fbcon_clear_margins() + * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins() * * handles y values in range [0, scr_height-1] that correspond to real * screen positions. y_wrap shift means that first line of bitmap may be * anywhere on this display. These functions convert lineoffsets to * bitmap offsets and deal with the wrap-around case by splitting blits. * + * fbcon_bmove_physical_8() -- These functions fast implementations * fbcon_clear_physical_8() -- of original fbcon_XXX fns. * fbcon_putc_physical_8() -- (font width !=3D 8) may be added later * @@ -1390,6 +1409,224 @@ static void fbcon_set_disp(struct fb_inf } } =20 +static __inline__ void ywrap_up(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll +=3D count; + if (p->yscroll >=3D p->vrows) /* Deal with wrap */ + p->yscroll -=3D p->vrows; + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode |=3D FB_VMODE_YWRAP; + ops->update_start(info); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ywrap_down(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll -=3D count; + if (p->yscroll < 0) /* Deal with wrap */ + p->yscroll +=3D p->vrows; + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode |=3D FB_VMODE_YWRAP; + ops->update_start(info); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static __inline__ void ypan_up(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + struct fbcon_ops *ops =3D info->fbcon_par; + + p->yscroll +=3D count; + if (p->yscroll > p->vrows - vc->vc_rows) { + ops->bmove(vc, info, p->vrows - vc->vc_rows, + 0, 0, 0, vc->vc_rows, vc->vc_cols); + p->yscroll -=3D p->vrows - vc->vc_rows; + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll +=3D count; + + if (p->yscroll > p->vrows - vc->vc_rows) { + p->yscroll -=3D p->vrows - vc->vc_rows; + fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t); + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ypan_down(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + struct fbcon_ops *ops =3D info->fbcon_par; + + p->yscroll -=3D count; + if (p->yscroll < 0) { + ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows, + 0, vc->vc_rows, vc->vc_cols); + p->yscroll +=3D p->vrows - vc->vc_rows; + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int cou= nt) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll -=3D count; + + if (p->yscroll < 0) { + p->yscroll +=3D p->vrows - vc->vc_rows; + fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count); + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p, + int line, int count, int dy) +{ + unsigned short *s =3D (unsigned short *) + (vc->vc_origin + vc->vc_size_row * line); + + while (count--) { + unsigned short *start =3D s; + unsigned short *le =3D advance_row(s, 1); + unsigned short c; + int x =3D 0; + unsigned short attr =3D 1; + + do { + c =3D scr_readw(s); + if (attr !=3D (c & 0xff00)) { + attr =3D c & 0xff00; + if (s > start) { + fbcon_putcs(vc, start, s - start, + dy, x); + x +=3D s - start; + start =3D s; + } + } + console_conditional_schedule(); + s++; + } while (s < le); + if (s > start) + fbcon_putcs(vc, start, s - start, dy, x); + console_conditional_schedule(); + dy++; + } +} + +static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info, + struct fbcon_display *p, int line, int count, int ycount) +{ + int offset =3D ycount * vc->vc_cols; + unsigned short *d =3D (unsigned short *) + (vc->vc_origin + vc->vc_size_row * line); + unsigned short *s =3D d + offset; + struct fbcon_ops *ops =3D info->fbcon_par; + + while (count--) { + unsigned short *start =3D s; + unsigned short *le =3D advance_row(s, 1); + unsigned short c; + int x =3D 0; + + do { + c =3D scr_readw(s); + + if (c =3D=3D scr_readw(d)) { + if (s > start) { + ops->bmove(vc, info, line + ycount, x, + line, x, 1, s-start); + x +=3D s - start + 1; + start =3D s + 1; + } else { + x++; + start++; + } + } + + scr_writew(c, d); + console_conditional_schedule(); + s++; + d++; + } while (s < le); + if (s > start) + ops->bmove(vc, info, line + ycount, x, line, x, 1, + s-start); + console_conditional_schedule(); + if (ycount > 0) + line++; + else { + line--; + /* NOTE: We subtract two lines from these pointers */ + s -=3D vc->vc_size_row; + d -=3D vc->vc_size_row; + } + } +} + static void fbcon_redraw(struct vc_data *vc, struct fbcon_display *p, int line, int count, int offset) { @@ -1450,6 +1687,7 @@ static bool fbcon_scroll(struct vc_data { struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; struct fbcon_display *p =3D &fb_display[vc->vc_num]; + int scroll_partial =3D info->flags & FBINFO_PARTIAL_PAN_OK; =20 if (fbcon_is_inactive(vc, info)) return true; @@ -1466,32 +1704,249 @@ static bool fbcon_scroll(struct vc_data case SM_UP: if (count > vc->vc_rows) /* Maximum realistic size */ count =3D vc->vc_rows; - fbcon_redraw(vc, p, t, b - t - count, - count * vc->vc_cols); - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); - scr_memsetw((unsigned short *) (vc->vc_origin + - vc->vc_size_row * - (b - count)), - vc->vc_video_erase_char, - vc->vc_size_row * count); - return true; + if (logo_shown >=3D 0) + goto redraw_up; + switch (p->scrollmode) { + case SCROLL_MOVE: + fbcon_redraw_blit(vc, info, p, t, b - t - count, + count); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + (b - count)), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + + case SCROLL_WRAP_MOVE: + if (b - t - count > 3 * vc->vc_rows >> 2) { + if (t > 0) + fbcon_bmove(vc, 0, 0, count, 0, t, + vc->vc_cols); + ywrap_up(vc, count); + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b - count, 0, b, 0, + vc->vc_rows - b, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t + count, 0, t, 0, + b - t - count, vc->vc_cols); + else + goto redraw_up; + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_REDRAW: + if ((p->yscroll + count <=3D + 2 * (p->vrows - vc->vc_rows)) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (t > 0) + fbcon_redraw_move(vc, p, 0, t, count); + ypan_up_redraw(vc, t, count); + if (vc->vc_rows - b > 0) + fbcon_redraw_move(vc, p, b, + vc->vc_rows - b, b); + } else + fbcon_redraw_move(vc, p, t + count, b - t - count, t); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_MOVE: + if ((p->yscroll + count <=3D + 2 * (p->vrows - vc->vc_rows)) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (t > 0) + fbcon_bmove(vc, 0, 0, count, 0, t, + vc->vc_cols); + ypan_up(vc, count); + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b - count, 0, b, 0, + vc->vc_rows - b, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t + count, 0, t, 0, + b - t - count, vc->vc_cols); + else + goto redraw_up; + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_REDRAW: + redraw_up: + fbcon_redraw(vc, p, t, b - t - count, + count * vc->vc_cols); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + (b - count)), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + } + break; =20 case SM_DOWN: if (count > vc->vc_rows) /* Maximum realistic size */ count =3D vc->vc_rows; - fbcon_redraw(vc, p, b - 1, b - t - count, - -count * vc->vc_cols); - fbcon_clear(vc, t, 0, count, vc->vc_cols); - scr_memsetw((unsigned short *) (vc->vc_origin + - vc->vc_size_row * - t), - vc->vc_video_erase_char, - vc->vc_size_row * count); - return true; + if (logo_shown >=3D 0) + goto redraw_down; + switch (p->scrollmode) { + case SCROLL_MOVE: + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, + -count); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + t), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + + case SCROLL_WRAP_MOVE: + if (b - t - count > 3 * vc->vc_rows >> 2) { + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b, 0, b - count, 0, + vc->vc_rows - b, + vc->vc_cols); + ywrap_down(vc, count); + if (t > 0) + fbcon_bmove(vc, count, 0, 0, 0, t, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t, 0, t + count, 0, + b - t - count, vc->vc_cols); + else + goto redraw_down; + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_MOVE: + if ((count - p->yscroll <=3D p->vrows - vc->vc_rows) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b, 0, b - count, 0, + vc->vc_rows - b, + vc->vc_cols); + ypan_down(vc, count); + if (t > 0) + fbcon_bmove(vc, count, 0, 0, 0, t, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t, 0, t + count, 0, + b - t - count, vc->vc_cols); + else + goto redraw_down; + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_REDRAW: + if ((count - p->yscroll <=3D p->vrows - vc->vc_rows) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (vc->vc_rows - b > 0) + fbcon_redraw_move(vc, p, b, vc->vc_rows - b, + b - count); + ypan_down_redraw(vc, t, count); + if (t > 0) + fbcon_redraw_move(vc, p, count, t, 0); + } else + fbcon_redraw_move(vc, p, t, b - t - count, t + count); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_REDRAW: + redraw_down: + fbcon_redraw(vc, p, b - 1, b - t - count, + -count * vc->vc_cols); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + t), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + } } return false; } =20 + +static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, + int height, int width) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + if (fbcon_is_inactive(vc, info)) + return; + + if (!width || !height) + return; + + /* Split blits that cross physical y_wrap case. + * Pathological case involves 4 blits, better to use recursive + * code rather than unrolled case + * + * Recursive invocations don't need to erase the cursor over and + * over again, so we use fbcon_bmove_rec() + */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width, + p->vrows - p->yscroll); +} + +static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, i= nt sy, int sx, + int dy, int dx, int height, int width, u_int y_break) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + u_int b; + + if (sy < y_break && sy + height > y_break) { + b =3D y_break - sy; + if (dy < sy) { /* Avoid trashing self */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + } else { + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + } + return; + } + + if (dy < y_break && dy + height > y_break) { + b =3D y_break - dy; + if (dy < sy) { /* Avoid trashing self */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + } else { + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + } + return; + } + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx, + height, width); +} + static void updatescrollmode(struct fbcon_display *p, struct fb_info *info, struct vc_data *vc) @@ -1664,7 +2119,21 @@ static int fbcon_switch(struct vc_data * =20 updatescrollmode(p, info, vc); =20 - scrollback_phys_max =3D 0; + switch (p->scrollmode) { + case SCROLL_WRAP_MOVE: + scrollback_phys_max =3D p->vrows - vc->vc_rows; + break; + case SCROLL_PAN_MOVE: + case SCROLL_PAN_REDRAW: + scrollback_phys_max =3D p->vrows - 2 * vc->vc_rows; + if (scrollback_phys_max < 0) + scrollback_phys_max =3D 0; + break; + default: + scrollback_phys_max =3D 0; + break; + } + scrollback_max =3D 0; scrollback_current =3D 0; =20 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -29,6 +29,7 @@ struct fbcon_display { /* Filled in by the low-level console driver */ const u_char *fontdata; int userfont; /* !=3D 0 if fontdata kmalloc()ed */ + u_short scrollmode; /* Scroll Method */ u_short inverse; /* !=3D 0 text black on white as defau= lt */ short yscroll; /* Hardware scrolling */ int vrows; /* number of virtual rows */ @@ -51,6 +52,8 @@ struct fbcon_display { }; =20 struct fbcon_ops { + void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width); void (*clear)(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width); void (*putcs)(struct vc_data *vc, struct fb_info *info, @@ -149,6 +152,62 @@ static inline int attr_col_ec(int shift, #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) =20 + /* + * Scroll Method + */ + +/* There are several methods fbcon can use to move text around the screen: + * + * Operation Pan Wrap + *--------------------------------------------- + * SCROLL_MOVE copyarea No No + * SCROLL_PAN_MOVE copyarea Yes No + * SCROLL_WRAP_MOVE copyarea No Yes + * SCROLL_REDRAW imageblit No No + * SCROLL_PAN_REDRAW imageblit Yes No + * SCROLL_WRAP_REDRAW imageblit No Yes + * + * (SCROLL_WRAP_REDRAW is not implemented yet) + * + * In general, fbcon will choose the best scrolling + * method based on the rule below: + * + * Pan/Wrap > accel imageblit > accel copyarea > + * soft imageblit > (soft copyarea) + * + * Exception to the rule: Pan + accel copyarea is + * preferred over Pan + accel imageblit. + * + * The above is typical for PCI/AGP cards. Unless + * overridden, fbcon will never use soft copyarea. + * + * If you need to override the above rule, set the + * appropriate flags in fb_info->flags. For example, + * to prefer copyarea over imageblit, set + * FBINFO_READS_FAST. + * + * Other notes: + * + use the hardware engine to move the text + * (hw-accelerated copyarea() and fillrect()) + * + use hardware-supported panning on a large virtual screen + * + amifb can not only pan, but also wrap the display by N lines + * (i.e. visible line i =3D physical line (i+N) % yres). + * + read what's already rendered on the screen and + * write it in a different place (this is cfb_copyarea()) + * + re-render the text to the screen + * + * Whether to use wrapping or panning can only be figured out at + * runtime (when we know whether our font height is a multiple + * of the pan/wrap step) + * + */ + +#define SCROLL_MOVE 0x001 +#define SCROLL_PAN_MOVE 0x002 +#define SCROLL_WRAP_MOVE 0x003 +#define SCROLL_REDRAW 0x004 +#define SCROLL_PAN_REDRAW 0x005 + #ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); #endif --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -59,12 +59,31 @@ static void ccw_update_attr(u8 *dst, u8 } } =20 + +static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + + area.sx =3D sy * vc->vc_font.height; + area.sy =3D vyres - ((sx + width) * vc->vc_font.width); + area.dx =3D dy * vc->vc_font.height; + area.dy =3D vyres - ((dx + width) * vc->vc_font.width); + area.width =3D height * vc->vc_font.height; + area.height =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D sy * vc->vc_font.height; @@ -121,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -210,7 +229,7 @@ static void ccw_cursor(struct vc_data *v int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -368,7 +387,7 @@ static int ccw_update_start(struct fb_in { struct fbcon_ops *ops =3D info->fbcon_par; u32 yoffset; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); int err; =20 yoffset =3D (vyres - info->var.yres) - ops->var.xoffset; @@ -383,6 +402,7 @@ static int ccw_update_start(struct fb_in =20 void fbcon_rotate_ccw(struct fbcon_ops *ops) { + ops->bmove =3D ccw_bmove; ops->clear =3D ccw_clear; ops->putcs =3D ccw_putcs; ops->clear_margins =3D ccw_clear_margins; --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -44,12 +44,31 @@ static void cw_update_attr(u8 *dst, u8 * } } =20 + +static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + + area.sx =3D vxres - ((sy + height) * vc->vc_font.height); + area.sy =3D sx * vc->vc_font.width; + area.dx =3D vxres - ((dy + height) * vc->vc_font.height); + area.dy =3D dx * vc->vc_font.width; + area.width =3D height * vc->vc_font.height; + area.height =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D vxres - ((sy + height) * vc->vc_font.height); @@ -106,7 +125,7 @@ static void cw_putcs(struct vc_data *vc, u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -193,7 +212,7 @@ static void cw_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -350,7 +369,7 @@ static void cw_cursor(struct vc_data *vc static int cw_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); u32 xoffset; int err; =20 @@ -366,6 +385,7 @@ static int cw_update_start(struct fb_inf =20 void fbcon_rotate_cw(struct fbcon_ops *ops) { + ops->bmove =3D cw_bmove; ops->clear =3D cw_clear; ops->putcs =3D cw_putcs; ops->clear_margins =3D cw_clear_margins; --- a/drivers/video/fbdev/core/fbcon_rotate.h +++ b/drivers/video/fbdev/core/fbcon_rotate.h @@ -11,6 +11,15 @@ #ifndef _FBCON_ROTATE_H #define _FBCON_ROTATE_H =20 +#define GETVYRES(s,i) ({ \ + (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE) ? \ + (i)->var.yres : (i)->var.yres_virtual; }) + +#define GETVXRES(s,i) ({ \ + (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE || !(i)->fix.xpans= tep) ? \ + (i)->var.xres : (i)->var.xres_virtual; }) + + static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pa= t) { u32 tmp =3D (y * pitch) + x, index =3D tmp / 8, bit =3D tmp % 8; --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -44,13 +44,33 @@ static void ud_update_attr(u8 *dst, u8 * } } =20 + +static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + + area.sy =3D vyres - ((sy + height) * vc->vc_font.height); + area.sx =3D vxres - ((sx + width) * vc->vc_font.width); + area.dy =3D vyres - ((dy + height) * vc->vc_font.height); + area.dx =3D vxres - ((dx + width) * vc->vc_font.width); + area.height =3D height * vc->vc_font.height; + area.width =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dy =3D vyres - ((sy + height) * vc->vc_font.height); @@ -142,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, u32 mod =3D vc->vc_font.width % 8, cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -239,8 +259,8 @@ static void ud_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -390,8 +410,8 @@ static int ud_update_start(struct fb_inf { struct fbcon_ops *ops =3D info->fbcon_par; int xoffset, yoffset; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); int err; =20 xoffset =3D vxres - info->var.xres - ops->var.xoffset; @@ -409,6 +429,7 @@ static int ud_update_start(struct fb_inf =20 void fbcon_rotate_ud(struct fbcon_ops *ops) { + ops->bmove =3D ud_bmove; ops->clear =3D ud_clear; ops->putcs =3D ud_putcs; ops->clear_margins =3D ud_clear_margins; --- a/drivers/video/fbdev/core/tileblit.c +++ b/drivers/video/fbdev/core/tileblit.c @@ -16,6 +16,21 @@ #include #include "fbcon.h" =20 +static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fb_tilearea area; + + area.sx =3D sx; + area.sy =3D sy; + area.dx =3D dx; + area.dy =3D dy; + area.height =3D height; + area.width =3D width; + + info->tileops->fb_tilecopy(info, &area); +} + static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { @@ -118,6 +133,7 @@ void fbcon_set_tileops(struct vc_data *v struct fb_tilemap map; struct fbcon_ops *ops =3D info->fbcon_par; =20 + ops->bmove =3D tile_bmove; ops->clear =3D tile_clear; ops->putcs =3D tile_putcs; ops->clear_margins =3D tile_clear_margins; --- a/drivers/video/fbdev/skeletonfb.c +++ b/drivers/video/fbdev/skeletonfb.c @@ -505,15 +505,15 @@ void xxxfb_fillrect(struct fb_info *p, c } =20 /** - * xxxfb_copyarea - OBSOLETE function. + * xxxfb_copyarea - REQUIRED function. Can use generic routines if + * non acclerated hardware and packed pixel based. * Copies one area of the screen to another area. - * Will be deleted in a future version * * @info: frame buffer structure that represents a single frame buffer * @area: Structure providing the data to copy the framebuffer conten= ts * from one region to another. * - * This drawing operation copied a rectangular area from one area of = the + * This drawing operation copies a rectangular area from one area of = the * screen to another area. */ void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)=20 @@ -645,9 +645,9 @@ static const struct fb_ops xxxfb_ops =3D { .fb_setcolreg =3D xxxfb_setcolreg, .fb_blank =3D xxxfb_blank, .fb_pan_display =3D xxxfb_pan_display, - .fb_fillrect =3D xxxfb_fillrect, /* Needed !!! */ - .fb_copyarea =3D xxxfb_copyarea, /* Obsolete */ - .fb_imageblit =3D xxxfb_imageblit, /* Needed !!! */ + .fb_fillrect =3D xxxfb_fillrect, /* Needed !!! */ + .fb_copyarea =3D xxxfb_copyarea, /* Needed !!! */ + .fb_imageblit =3D xxxfb_imageblit, /* Needed !!! */ .fb_cursor =3D xxxfb_cursor, /* Optional !!! */ .fb_sync =3D xxxfb_sync, .fb_ioctl =3D xxxfb_ioctl, --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -262,7 +262,7 @@ struct fb_ops { =20 /* Draws a rectangle */ void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect= ); - /* Copy data from area to another. Obsolete. */ + /* Copy data from area to another */ void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *regi= on); /* Draws a image to the display */ void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8839C35275 for ; Mon, 7 Feb 2022 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388392AbiBGLnj (ORCPT ); Mon, 7 Feb 2022 06:43:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385695AbiBGLcK (ORCPT ); Mon, 7 Feb 2022 06:32:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84375C0401D8; Mon, 7 Feb 2022 03:32:09 -0800 (PST) Received: from smtp.kernel.org (relay.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 210BB60B20; Mon, 7 Feb 2022 11:32:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC198C004E1; Mon, 7 Feb 2022 11:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233528; bh=rfau10TEWfiRA3xex5IvwTz7/kPBt7AmT1dqmMihsZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcUvSGDV8WNj9Lr4YtbROblNVLFGC8ArxuZon2AAWURDoRDe8194UHlbh+43kZf07 62vaysUWPEVroYkHSqT2WiyZ6vHaYY755hArTI0iYrRCxkbjTBKBboqD48eCDyJT4s kkgHsYEOievQ6ikcZ3Nga9LNayBrBXSK60JxwIak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Geert Uytterhoeven , Sven Schnelle , Daniel Vetter Subject: [PATCH 5.16 040/126] Revert "fbcon: Disable accelerated scrolling" Date: Mon, 7 Feb 2022 12:06:11 +0100 Message-Id: <20220207103805.511971144@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 87ab9f6b7417349aa197a6c7098d4fdd4beebb74 upstream. This reverts commit 39aead8373b3c20bb5965c024dfb51a94e526151. Revert the first (of 2) commits which disabled scrolling acceleration in fbcon/fbdev. It introduced a regression for fbdev-supported graphic cards because of the performance penalty by doing screen scrolling by software instead of using the existing graphic card 2D hardware acceleration. Console scrolling acceleration was disabled by dropping code which checked at runtime the driver hardware capabilities for the BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move screen contents. After dropping those checks scrollmode was hard-wired to SCROLL_REDRAW instead, which forces all graphic cards to redraw every character at the new screen position when scrolling. This change effectively disabled all hardware-based scrolling acceleration = for ALL drivers, because now all kind of 2D hardware acceleration (bitblt, fillrect) in the drivers isn't used any longer. The original commit message mentions that only 3 DRM drivers (nouveau, omap= drm and gma500) used hardware acceleration in the past and thus code for checki= ng and using scrolling acceleration is obsolete. This statement is NOT TRUE, because beside the DRM drivers there are around= 35 other fbdev drivers which depend on fbdev/fbcon and still provide hardware acceleration for fbdev/fbcon. The original commit message also states that syzbot found lots of bugs in f= bcon and thus it's "often the solution to just delete code and remove features". This is true, and the bugs - which actually affected all users of fbcon, including DRM - were fixed, or code was dropped like e.g. the support for software scrollback in vgacon (commit 973c096f6a85). So to further analyze which bugs were found by syzbot, I've looked through = all patches in drivers/video which were tagged with syzbot or syzkaller back to year 2005. The vast majority fixed the reported issues on a higher level, e= .g. when screen is to be resized, or when font size is to be changed. The few o= nes which touched driver code fixed a real driver bug, e.g. by adding a check. But NONE of those patches touched code of either the SCROLL_MOVE or the SCROLL_REDRAW case. That means, there was no real reason why SCROLL_MOVE had to be ripped-out a= nd just SCROLL_REDRAW had to be used instead. The only reason I can imagine so= far was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it could go away. That argument completely missed the fact that SCROLL_MOVE is still heavily used by fbdev (non-DRM) drivers. Some people mention that using memcpy() instead of the hardware acceleratio= n is pretty much the same speed. But that's not true, at least not for older gra= phic cards and machines where we see speed decreases by factor 10 and more and t= hus this change leads to console responsiveness way worse than before. That's why the original commit is to be reverted. By reverting we reintroduce hardware-based scrolling acceleration and fix the performance regression for fbdev drivers. There isn't any impact on DRM when reverting those patches. Signed-off-by: Helge Deller Acked-by: Geert Uytterhoeven Acked-by: Sven Schnelle Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-= deller@gmx.de Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- Documentation/gpu/todo.rst | 21 ------------------ drivers/video/fbdev/core/fbcon.c | 45 ++++++++++++++++++++++++++++++++--= ----- 2 files changed, 37 insertions(+), 29 deletions(-) --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -311,27 +311,6 @@ Contact: Daniel Vetter, Noralf Tronnes =20 Level: Advanced =20 -Garbage collect fbdev scrolling acceleration --------------------------------------------- - -Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =3D -SCROLL_REDRAW. There's a ton of code this will allow us to remove: - -- lots of code in fbcon.c - -- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be ca= lled - directly instead of the function table (with a switch on p->rotate) - -- fb_copyarea is unused after this, and can be deleted from all drivers - -Note that not all acceleration code can be deleted, since clearing and cur= sor -support is still accelerated, which might be good candidates for further -deletion projects. - -Contact: Daniel Vetter - -Level: Intermediate - idr_init_base() --------------- =20 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1025,7 +1025,7 @@ static void fbcon_init(struct vc_data *v struct vc_data *svc =3D *default_mode; struct fbcon_display *t, *p =3D &fb_display[vc->vc_num]; int logo =3D 1, new_rows, new_cols, rows, cols; - int ret; + int cap, ret; =20 if (WARN_ON(info_idx =3D=3D -1)) return; @@ -1034,6 +1034,7 @@ static void fbcon_init(struct vc_data *v con2fb_map[vc->vc_num] =3D info_idx; =20 info =3D registered_fb[con2fb_map[vc->vc_num]]; + cap =3D info->flags; =20 if (logo_shown < 0 && console_loglevel <=3D CONSOLE_LOGLEVEL_QUIET) logo_shown =3D FBCON_LOGO_DONTSHOW; @@ -1135,13 +1136,11 @@ static void fbcon_init(struct vc_data *v =20 ops->graphics =3D 0; =20 - /* - * No more hw acceleration for fbcon. - * - * FIXME: Garbage collect all the now dead code after sufficient time - * has passed. - */ - p->scrollmode =3D SCROLL_REDRAW; + if ((cap & FBINFO_HWACCEL_COPYAREA) && + !(cap & FBINFO_HWACCEL_DISABLED)) + p->scrollmode =3D SCROLL_MOVE; + else /* default to something safe */ + p->scrollmode =3D SCROLL_REDRAW; =20 /* * ++guenther: console.c:vc_allocate() relies on initializing @@ -1953,15 +1952,45 @@ static void updatescrollmode(struct fbco { struct fbcon_ops *ops =3D info->fbcon_par; int fh =3D vc->vc_font.height; + int cap =3D info->flags; + u16 t =3D 0; + int ypan =3D FBCON_SWAP(ops->rotate, info->fix.ypanstep, + info->fix.xpanstep); + int ywrap =3D FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); int yres =3D FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); int vyres =3D FBCON_SWAP(ops->rotate, info->var.yres_virtual, info->var.xres_virtual); + int good_pan =3D (cap & FBINFO_HWACCEL_YPAN) && + divides(ypan, vc->vc_font.height) && vyres > yres; + int good_wrap =3D (cap & FBINFO_HWACCEL_YWRAP) && + divides(ywrap, vc->vc_font.height) && + divides(vc->vc_font.height, vyres) && + divides(vc->vc_font.height, yres); + int reading_fast =3D cap & FBINFO_READS_FAST; + int fast_copyarea =3D (cap & FBINFO_HWACCEL_COPYAREA) && + !(cap & FBINFO_HWACCEL_DISABLED); + int fast_imageblit =3D (cap & FBINFO_HWACCEL_IMAGEBLIT) && + !(cap & FBINFO_HWACCEL_DISABLED); =20 p->vrows =3D vyres/fh; if (yres > (fh * (vc->vc_rows + 1))) p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; if ((yres % fh) && (vyres % fh < yres % fh)) p->vrows--; + + if (good_wrap || good_pan) { + if (reading_fast || fast_copyarea) + p->scrollmode =3D good_wrap ? + SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; + else + p->scrollmode =3D good_wrap ? SCROLL_REDRAW : + SCROLL_PAN_REDRAW; + } else { + if (reading_fast || (fast_copyarea && !fast_imageblit)) + p->scrollmode =3D SCROLL_MOVE; + else + p->scrollmode =3D SCROLL_REDRAW; + } } =20 #define PITCH(w) (((w) + 7) >> 3) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 573F2C433EF for ; Mon, 7 Feb 2022 11:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388376AbiBGLnh (ORCPT ); Mon, 7 Feb 2022 06:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385712AbiBGLcQ (ORCPT ); Mon, 7 Feb 2022 06:32:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C72BC043181; Mon, 7 Feb 2022 03:32:14 -0800 (PST) Received: from smtp.kernel.org (relay.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 079E9B80EC3; Mon, 7 Feb 2022 11:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ADA9C004E1; Mon, 7 Feb 2022 11:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233531; bh=aD0fW2QKN7a3SuoAXXSIuJoa4pm6mYQpb4fAe05NYCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVBO4VzqJHBbBJ0MGFkMmPEsQh8iFxBZxr4lel4TkNFASsS+Ka62IYOoRF1BrtQgZ hHWr0IrzRwowboDiV/0gFRiXr+ssXFOlJNY+lTyeyErXxvviYZzlhocIneInHN2wZC BbTlpdYDpIlSb04bE/7c7t+BlcMiJY6qUjL2OSjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Daniel Vetter Subject: [PATCH 5.16 041/126] fbcon: Add option to enable legacy hardware acceleration Date: Mon, 7 Feb 2022 12:06:12 +0100 Message-Id: <20220207103805.545207852@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 a3f781a9d6114c1d1e01defb7aa234dec45d2a5f upstream. Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to enable bitblt and fillrect hardware acceleration in the framebuffer console. If disabled, such acceleration will not be used, even if it is supported by the graphics hardware driver. If you plan to use DRM as your main graphics output system, you should disable this option since it will prevent compiling in code which isn't used later on when DRM takes over. For all other configurations, e.g. if none of your graphic cards support DRM (yet), DRM isn't available for your architecture, or you can't be sure that the graphic card in the target system will support DRM, you most likely want to enable this option. In the non-accelerated case (e.g. when DRM is used), the inlined fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such t= he compiler is able to optimize much unneccesary code away. In this v3 patch version I additionally changed the GETVYRES() and GETVXRES= () macros to take a pointer to the fbcon_display struct. This fixes the build = when console rotation is enabled and helps the compiler again to optimize out co= de. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-= deller@gmx.de Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/video/console/Kconfig | 20 ++++++++++++++++ drivers/video/fbdev/core/fbcon.c | 39 ++++++++++++++++++++++-----= ----- drivers/video/fbdev/core/fbcon.h | 15 +++++++++++- drivers/video/fbdev/core/fbcon_ccw.c | 10 ++++---- drivers/video/fbdev/core/fbcon_cw.c | 10 ++++---- drivers/video/fbdev/core/fbcon_rotate.h | 4 +-- drivers/video/fbdev/core/fbcon_ud.c | 20 ++++++++-------- 7 files changed, 84 insertions(+), 34 deletions(-) --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -78,6 +78,26 @@ config FRAMEBUFFER_CONSOLE help Low-level framebuffer-based console driver. =20 +config FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + bool "Enable legacy fbcon hardware acceleration code" + depends on FRAMEBUFFER_CONSOLE + default y if PARISC + default n + help + This option enables the fbcon (framebuffer text-based) hardware + acceleration for graphics drivers which were written for the fbdev + graphics interface. + + On modern machines, on mainstream machines (like x86-64) or when + using a modern Linux distribution those fbdev drivers usually aren't us= ed. + So enabling this option wouldn't have any effect, which is why you want + to disable this option on such newer machines. + + If you compile this kernel for older machines which still require the + fbdev drivers, you may want to say Y. + + If unsure, select n. + config FRAMEBUFFER_CONSOLE_DETECT_PRIMARY bool "Map the console to the primary display device" depends on FRAMEBUFFER_CONSOLE --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1136,11 +1136,13 @@ static void fbcon_init(struct vc_data *v =20 ops->graphics =3D 0; =20 +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION if ((cap & FBINFO_HWACCEL_COPYAREA) && !(cap & FBINFO_HWACCEL_DISABLED)) p->scrollmode =3D SCROLL_MOVE; else /* default to something safe */ p->scrollmode =3D SCROLL_REDRAW; +#endif =20 /* * ++guenther: console.c:vc_allocate() relies on initializing @@ -1705,7 +1707,7 @@ static bool fbcon_scroll(struct vc_data count =3D vc->vc_rows; if (logo_shown >=3D 0) goto redraw_up; - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, t, b - t - count, count); @@ -1795,7 +1797,7 @@ static bool fbcon_scroll(struct vc_data count =3D vc->vc_rows; if (logo_shown >=3D 0) goto redraw_down; - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, -count); @@ -1946,12 +1948,12 @@ static void fbcon_bmove_rec(struct vc_da height, width); } =20 -static void updatescrollmode(struct fbcon_display *p, +static void updatescrollmode_accel(struct fbcon_display *p, struct fb_info *info, struct vc_data *vc) { +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION struct fbcon_ops *ops =3D info->fbcon_par; - int fh =3D vc->vc_font.height; int cap =3D info->flags; u16 t =3D 0; int ypan =3D FBCON_SWAP(ops->rotate, info->fix.ypanstep, @@ -1972,12 +1974,6 @@ static void updatescrollmode(struct fbco int fast_imageblit =3D (cap & FBINFO_HWACCEL_IMAGEBLIT) && !(cap & FBINFO_HWACCEL_DISABLED); =20 - p->vrows =3D vyres/fh; - if (yres > (fh * (vc->vc_rows + 1))) - p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; - if ((yres % fh) && (vyres % fh < yres % fh)) - p->vrows--; - if (good_wrap || good_pan) { if (reading_fast || fast_copyarea) p->scrollmode =3D good_wrap ? @@ -1991,6 +1987,27 @@ static void updatescrollmode(struct fbco else p->scrollmode =3D SCROLL_REDRAW; } +#endif +} + +static void updatescrollmode(struct fbcon_display *p, + struct fb_info *info, + struct vc_data *vc) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + int fh =3D vc->vc_font.height; + int yres =3D FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); + int vyres =3D FBCON_SWAP(ops->rotate, info->var.yres_virtual, + info->var.xres_virtual); + + p->vrows =3D vyres/fh; + if (yres > (fh * (vc->vc_rows + 1))) + p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; + if ((yres % fh) && (vyres % fh < yres % fh)) + p->vrows--; + + /* update scrollmode in case hardware acceleration is used */ + updatescrollmode_accel(p, info, vc); } =20 #define PITCH(w) (((w) + 7) >> 3) @@ -2148,7 +2165,7 @@ static int fbcon_switch(struct vc_data * =20 updatescrollmode(p, info, vc); =20 - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_WRAP_MOVE: scrollback_phys_max =3D p->vrows - vc->vc_rows; break; --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -29,7 +29,9 @@ struct fbcon_display { /* Filled in by the low-level console driver */ const u_char *fontdata; int userfont; /* !=3D 0 if fontdata kmalloc()ed */ - u_short scrollmode; /* Scroll Method */ +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + u_short scrollmode; /* Scroll Method, use fb_scrollmode() = */ +#endif u_short inverse; /* !=3D 0 text black on white as defau= lt */ short yscroll; /* Hardware scrolling */ int vrows; /* number of virtual rows */ @@ -208,6 +210,17 @@ static inline int attr_col_ec(int shift, #define SCROLL_REDRAW 0x004 #define SCROLL_PAN_REDRAW 0x005 =20 +static inline u_short fb_scrollmode(struct fbcon_display *fb) +{ +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + return fb->scrollmode; +#else + /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */ + return SCROLL_REDRAW; +#endif +} + + #ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); #endif --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -65,7 +65,7 @@ static void ccw_bmove(struct vc_data *vc { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 area.sx =3D sy * vc->vc_font.height; area.sy =3D vyres - ((sx + width) * vc->vc_font.width); @@ -83,7 +83,7 @@ static void ccw_clear(struct vc_data *vc struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D sy * vc->vc_font.height; @@ -140,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -229,7 +229,7 @@ static void ccw_cursor(struct vc_data *v int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -387,7 +387,7 @@ static int ccw_update_start(struct fb_in { struct fbcon_ops *ops =3D info->fbcon_par; u32 yoffset; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); int err; =20 yoffset =3D (vyres - info->var.yres) - ops->var.xoffset; --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -50,7 +50,7 @@ static void cw_bmove(struct vc_data *vc, { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 area.sx =3D vxres - ((sy + height) * vc->vc_font.height); area.sy =3D sx * vc->vc_font.width; @@ -68,7 +68,7 @@ static void cw_clear(struct vc_data *vc, struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D vxres - ((sy + height) * vc->vc_font.height); @@ -125,7 +125,7 @@ static void cw_putcs(struct vc_data *vc, u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -212,7 +212,7 @@ static void cw_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -369,7 +369,7 @@ static void cw_cursor(struct vc_data *vc static int cw_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); u32 xoffset; int err; =20 --- a/drivers/video/fbdev/core/fbcon_rotate.h +++ b/drivers/video/fbdev/core/fbcon_rotate.h @@ -12,11 +12,11 @@ #define _FBCON_ROTATE_H =20 #define GETVYRES(s,i) ({ \ - (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE) ? \ + (fb_scrollmode(s) =3D=3D SCROLL_REDRAW || fb_scrollmode(s) =3D=3D = SCROLL_MOVE) ? \ (i)->var.yres : (i)->var.yres_virtual; }) =20 #define GETVXRES(s,i) ({ \ - (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE || !(i)->fix.xpans= tep) ? \ + (fb_scrollmode(s) =3D=3D SCROLL_REDRAW || fb_scrollmode(s) =3D=3D = SCROLL_MOVE || !(i)->fix.xpanstep) ? \ (i)->var.xres : (i)->var.xres_virtual; }) =20 =20 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -50,8 +50,8 @@ static void ud_bmove(struct vc_data *vc, { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 area.sy =3D vyres - ((sy + height) * vc->vc_font.height); area.sx =3D vxres - ((sx + width) * vc->vc_font.width); @@ -69,8 +69,8 @@ static void ud_clear(struct vc_data *vc, struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dy =3D vyres - ((sy + height) * vc->vc_font.height); @@ -162,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, u32 mod =3D vc->vc_font.width % 8, cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -259,8 +259,8 @@ static void ud_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -410,8 +410,8 @@ static int ud_update_start(struct fb_inf { struct fbcon_ops *ops =3D info->fbcon_par; int xoffset, yoffset; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); int err; =20 xoffset =3D vxres - info->var.xres - ops->var.xoffset; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBA98C35273 for ; Mon, 7 Feb 2022 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388407AbiBGLnk (ORCPT ); Mon, 7 Feb 2022 06:43:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385725AbiBGLcS (ORCPT ); Mon, 7 Feb 2022 06:32:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E7D1C043188; Mon, 7 Feb 2022 03:32:17 -0800 (PST) Received: from smtp.kernel.org (relay.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 F2F87B80EBD; Mon, 7 Feb 2022 11:32:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47B2AC004E1; Mon, 7 Feb 2022 11:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233534; bh=gnZ42VB8luOBpe47zX/EhN1MWbO2bGrsu/FWoeueKY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0ufMjgF8OXHfxvMxouB/e/S7DXY0A+ZlU3BLnyuRSwH+z1njXJ85+wtA1ln7yU// FVgZkFqTMLFIk03kK98hS/EVr7GbPpG+Vi5qswjjG2vamzrh02jdoMml7H6wHnQTGv Pc+6bv62sHMn2qU3j4jnJV/kCo5nvtIvvAIPIB3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , Jakub Kicinski Subject: [PATCH 5.16 042/126] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Date: Mon, 7 Feb 2022 12:06:13 +0100 Message-Id: <20220207103805.578390861@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Abeni commit 8e9eacad7ec7a9cbf262649ebf1fa6e6f6cc7d82 upstream. The MPTCP endpoint list is under RCU protection, guarded by the pernet spinlock. mptcp_nl_cmd_set_flags() traverses the list without acquiring the spin-lock nor under the RCU critical section. This change addresses the issue performing the lookup and the endpoint update under the pernet spinlock. [The upstream commit had to handle a lookup_by_id variable that is only present in 5.17. This version of the patch removes that variable, so the __lookup_addr() function only handles the lookup as it is implemented in 5.15 and 5.16. It also removes one 'const' keyword to prevent a warning due to differing const-ness in the 5.17 version of addresses_equal().] Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink") Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/mptcp/pm_netlink.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -459,6 +459,18 @@ static unsigned int fill_remote_addresse return i; } =20 +static struct mptcp_pm_addr_entry * +__lookup_addr(struct pm_nl_pernet *pernet, struct mptcp_addr_info *info) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &pernet->local_addr_list, list) { + if (addresses_equal(&entry->addr, info, true)) + return entry; + } + return NULL; +} + static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { struct sock *sk =3D (struct sock *)msk; @@ -1725,17 +1737,21 @@ static int mptcp_nl_cmd_set_flags(struct if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup =3D 1; =20 - list_for_each_entry(entry, &pernet->local_addr_list, list) { - if (addresses_equal(&entry->addr, &addr.addr, true)) { - mptcp_nl_addr_backup(net, &entry->addr, bkup); - - if (bkup) - entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; - else - entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; - } + spin_lock_bh(&pernet->lock); + entry =3D __lookup_addr(pernet, &addr.addr); + if (!entry) { + spin_unlock_bh(&pernet->lock); + return -EINVAL; } =20 + if (bkup) + entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; + else + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; + addr =3D *entry; + spin_unlock_bh(&pernet->lock); + + mptcp_nl_addr_backup(net, &addr.addr, bkup); return 0; } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05870C433F5 for ; Mon, 7 Feb 2022 11:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388485AbiBGLnq (ORCPT ); Mon, 7 Feb 2022 06:43:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385729AbiBGLcT (ORCPT ); Mon, 7 Feb 2022 06:32:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18EF5C043189; Mon, 7 Feb 2022 03:32:18 -0800 (PST) Received: from smtp.kernel.org (relay.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 7B4F660A67; Mon, 7 Feb 2022 11:32:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 611B5C004E1; Mon, 7 Feb 2022 11:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233537; bh=idzC9wTmQOAG07iR2RbTzqlDGaG9udT+X4x1GRMFd3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pFDLn3ArROto2tlYpRvyyvibYk2eozmsvmRJ6dEO8G/QR51U0oDMrft2s3pTv2QIP hvyFFWpoiJ3Fn5u9n7cYZWa+2bc5yxQoSAMAqNlxwSbwM2ZlUMKO0EqrvH3YOqJrbc 7dOB2YtvYlGla8t+wbSLjscrllnAgbcphp8f+bts= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Mark Brown , James Liao , Kevin Hilman , Frank Wunderlich , Daniel Golle , Guenter Roeck Subject: [PATCH 5.16 043/126] [PATCH] Revert "ASoC: mediatek: Check for error clk pointer" Date: Mon, 7 Feb 2022 12:06:14 +0100 Message-Id: <20220207103805.609153851@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Guenter Roeck This reverts commit e0bf3c9e05ca6837ac756ec7d9de70b44603da12 which is commit 9de2b9286a6dd16966959b3cb34fc2ddfd39213e upstream With this patch in the tree, Chromebooks running the affected hardware no longer boot. Bisect points to this patch, and reverting it fixes the problem. An analysis of the code with this patch applied shows: ret =3D init_clks(pdev, clk); if (ret) return ERR_PTR(ret); ... for (j =3D 0; j < MAX_CLKS && data->clk_id[j]; j++) { struct clk *c =3D clk[data->clk_id[j]]; if (IS_ERR(c)) { dev_err(&pdev->dev, "%s: clk unavailable\n", data->name); return ERR_CAST(c); } scpd->clk[j] =3D c; } Not all clocks in the clk_names array have to be present. Only the clocks in the data->clk_id array are actually needed. The code already checks if the required clocks are available and bails out if not. The assumption that all clocks have to be present is wrong, and commit 9de2b9286a6d needs to be reverted. Fixes: 9de2b9286a6d ("ASoC: mediatek: Check for error clk pointer") Cc: Jiasheng Jiang Cc: Mark Brown Cc: James Liao Cc: Kevin Hilman Cc: Matthias Brugger Cc: Daniel Golle Link: https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.n= et/ Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/soc/mediatek/mtk-scpsys.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -411,17 +411,12 @@ out: return ret; } =20 -static int init_clks(struct platform_device *pdev, struct clk **clk) +static void init_clks(struct platform_device *pdev, struct clk **clk) { int i; =20 - for (i =3D CLK_NONE + 1; i < CLK_MAX; i++) { + for (i =3D CLK_NONE + 1; i < CLK_MAX; i++) clk[i] =3D devm_clk_get(&pdev->dev, clk_names[i]); - if (IS_ERR(clk[i])) - return PTR_ERR(clk[i]); - } - - return 0; } =20 static struct scp *init_scp(struct platform_device *pdev, @@ -431,7 +426,7 @@ static struct scp *init_scp(struct platf { struct genpd_onecell_data *pd_data; struct resource *res; - int i, j, ret; + int i, j; struct scp *scp; struct clk *clk[CLK_MAX]; =20 @@ -486,9 +481,7 @@ static struct scp *init_scp(struct platf =20 pd_data->num_domains =3D num; =20 - ret =3D init_clks(pdev, clk); - if (ret) - return ERR_PTR(ret); + init_clks(pdev, clk); =20 for (i =3D 0; i < num; i++) { struct scp_domain *scpd =3D &scp->domains[i]; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC7BC3526C for ; Mon, 7 Feb 2022 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388453AbiBGLnn (ORCPT ); Mon, 7 Feb 2022 06:43:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385743AbiBGLcW (ORCPT ); Mon, 7 Feb 2022 06:32:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44084C0401C0; Mon, 7 Feb 2022 03:32:22 -0800 (PST) Received: from smtp.kernel.org (relay.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 CAB5F60C8E; Mon, 7 Feb 2022 11:32:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A75FC004E1; Mon, 7 Feb 2022 11:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233541; bh=lQLt55YV7KRT1YQaDNzbRPxe1nnNFn1F6OImQ/QhjhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Po0+TQeNXbuz2YREVx/MdCUjaX8E2GUek+Awkz3oK1m4q70j8YBG3wv2ns+SAcxWW WfhWJ1iPYJ2QRQkQGAQdU7E7m8H/psJihWRpOQbqxLo4TafN4Ew+0O+XXRnEw2tjc4 8MAeX5QznbsMqtcKKnYtFs9F1Nci9b7JfJxmgzw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mayuresh Chitale , Anup Patel Subject: [PATCH 5.16 044/126] RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode Date: Mon, 7 Feb 2022 12:06:15 +0100 Message-Id: <20220207103805.643776076@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mayuresh Chitale commit de1d7b6a51dab546160d252e47baa54adf104d4a upstream. Those applications that run in VU mode and access the time CSR cause a virtual instruction trap as Guest kernel currently does not initialize the scounteren CSR. To fix this, we should make CY, TM, and IR counters accessibile by default in VU mode (similar to OpenSBI). Fixes: a33c72faf2d73 ("RISC-V: KVM: Implement VCPU create, init and destroy functions") Cc: stable@vger.kernel.org Signed-off-by: Mayuresh Chitale Signed-off-by: Anup Patel Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/riscv/kvm/vcpu.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -74,6 +74,7 @@ int kvm_arch_vcpu_precreate(struct kvm * int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) { struct kvm_cpu_context *cntx; + struct kvm_vcpu_csr *reset_csr =3D &vcpu->arch.guest_reset_csr; =20 /* Mark this VCPU never ran */ vcpu->arch.ran_atleast_once =3D false; @@ -89,6 +90,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu cntx->hstatus |=3D HSTATUS_SPVP; cntx->hstatus |=3D HSTATUS_SPV; =20 + /* By default, make CY, TM, and IR counters accessible in VU mode */ + reset_csr->scounteren =3D 0x7; + /* Setup VCPU timer */ kvm_riscv_vcpu_timer_init(vcpu); =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0270C41535 for ; Mon, 7 Feb 2022 11:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388470AbiBGLnp (ORCPT ); Mon, 7 Feb 2022 06:43:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385754AbiBGLc1 (ORCPT ); Mon, 7 Feb 2022 06:32:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47ACC0401C2; Mon, 7 Feb 2022 03:32:26 -0800 (PST) Received: from smtp.kernel.org (relay.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 A5EF4B80EC3; Mon, 7 Feb 2022 11:32:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF268C004E1; Mon, 7 Feb 2022 11:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233544; bh=yXOodRqUYTtTkw1TE/eivAQOedKt74N5rdHbQhj10b0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1aeLTRz5CW7uScQNfnVmbne2QRbmRhBq0bJm3cpnwMcSiQmrNWAWAGgtJd2vszXG1 3eAo1SsMVlOvg0RPAFXedS3b9XFJxVYWgH+czJLMhgJoiYz0wfPhDpufenASrxbXcH Inthf4/Z5KdezFpsLYpZHR+cujcG1b90BZVTbJ1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Price , James Morse , Marc Zyngier Subject: [PATCH 5.16 045/126] KVM: arm64: Avoid consuming a stale esr value when SError occur Date: Mon, 7 Feb 2022 12:06:16 +0100 Message-Id: <20220207103805.675591778@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: James Morse commit 1c71dbc8a179d99dd9bb7e7fc1888db613cf85de upstream. When any exception other than an IRQ occurs, the CPU updates the ESR_EL2 register with the exception syndrome. An SError may also become pending, and will be synchronised by KVM. KVM notes the exception type, and whether an SError was synchronised in exit_code. When an exception other than an IRQ occurs, fixup_guest_exit() updates vcpu->arch.fault.esr_el2 from the hardware register. When an SError was synchronised, the vcpu esr value is used to determine if the exception was due to an HVC. If so, ELR_EL2 is moved back one instruction. This is so that KVM can process the SError first, and re-execute the HVC if the guest survives the SError. But if an IRQ synchronises an SError, the vcpu's esr value is stale. If the previous non-IRQ exception was an HVC, KVM will corrupt ELR_EL2, causing an unrelated guest instruction to be executed twice. Check ARM_EXCEPTION_CODE() before messing with ELR_EL2, IRQs don't update this register so don't need to check. Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP") Cc: stable@vger.kernel.org Reported-by: Steven Price Signed-off-by: James Morse Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127122052.1584324-3-james.morse@arm.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/hyp/include/hyp/switch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -446,7 +446,8 @@ static inline bool fixup_guest_exit(stru if (ARM_EXCEPTION_CODE(*exit_code) !=3D ARM_EXCEPTION_IRQ) vcpu->arch.fault.esr_el2 =3D read_sysreg_el2(SYS_ESR); =20 - if (ARM_SERROR_PENDING(*exit_code)) { + if (ARM_SERROR_PENDING(*exit_code) && + ARM_EXCEPTION_CODE(*exit_code) !=3D ARM_EXCEPTION_IRQ) { u8 esr_ec =3D kvm_vcpu_trap_get_class(vcpu); =20 /* From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73D1BC4332F for ; Mon, 7 Feb 2022 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388500AbiBGLnt (ORCPT ); Mon, 7 Feb 2022 06:43:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385760AbiBGLc3 (ORCPT ); Mon, 7 Feb 2022 06:32:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF456C043181; Mon, 7 Feb 2022 03:32:28 -0800 (PST) Received: from smtp.kernel.org (relay.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 7290460C99; Mon, 7 Feb 2022 11:32:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F1F7C004E1; Mon, 7 Feb 2022 11:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233547; bh=pejCLm/dhWAINZ/EwhvHtPsSwaQldnRAQnd2fBpHpUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A9hWeim76AJ8AxFR+JuDdCbICabx/yEa0DJVRJ6hk4e+uN1oAPLJ0aUYsEW3+IoPi 5neydjqRmgYNRYX/J+w74Ip9hzbP9EULMLqANiRKnNj6ZGglZK1bR1lsLw7+2CWLLM xfY5dt4qluHWwaYloXEA7UhXDduQuPiUmu9AmoBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Marc Zyngier Subject: [PATCH 5.16 046/126] KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs Date: Mon, 7 Feb 2022 12:06:17 +0100 Message-Id: <20220207103805.706627373@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: James Morse commit 1229630af88620f6e3a621a1ebd1ca14d9340df7 upstream. Prior to commit defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP"), when an SError is synchronised due to another exception, KVM handles the SError first. If the guest survives, the instruction that triggered the original exception is re-exectued to handle the first exception. HVC is treated as a special case as the instruction wouldn't normally be re-exectued, as its not a trap. Commit defe21f49bc9 didn't preserve the behaviour of the 'return 1' that skips the rest of handle_exit(). Since commit defe21f49bc9, KVM will try to handle the SError and the original exception at the same time. When the exception was an HVC, fixup_guest_exit() has already rolled back ELR_EL2, meaning if the guest has virtual SError masked, it will execute and handle the HVC twice. Restore the original behaviour. Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP") Cc: stable@vger.kernel.org Signed-off-by: James Morse Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127122052.1584324-4-james.morse@arm.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/handle_exit.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -226,6 +226,14 @@ int handle_exit(struct kvm_vcpu *vcpu, i { struct kvm_run *run =3D vcpu->run; =20 + if (ARM_SERROR_PENDING(exception_index)) { + /* + * The SError is handled by handle_exit_early(). If the guest + * survives it will re-execute the original instruction. + */ + return 1; + } + exception_index =3D ARM_EXCEPTION_CODE(exception_index); =20 switch (exception_index) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A82E2C35272 for ; Mon, 7 Feb 2022 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388519AbiBGLnx (ORCPT ); Mon, 7 Feb 2022 06:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385783AbiBGLce (ORCPT ); Mon, 7 Feb 2022 06:32:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A337FC043181; Mon, 7 Feb 2022 03:32:33 -0800 (PST) Received: from smtp.kernel.org (relay.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 59C2EB80EC3; Mon, 7 Feb 2022 11:32:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B0B9C004E1; Mon, 7 Feb 2022 11:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233551; bh=vrB/RKCrhUdnQqTQrbSnLENcZbcBygxjrdB7ZJt2Xcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g/kBZk8mDfTZUzDAXaj+S8znkuoNsqJ7qW44Wr5u9uuwWTR6tiWKwakZq8L4cxivA 0KtixKXf3lmpeLvl2GPx5skKLJRGIfbFlXXtn/4kcCaZoRQn7OrNu9RW2YQroiufYv TlColIHwEC/KblkFNZyJQsrcYZu/H+rJCVxmKqRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Will Deacon , Suzuki Poulose , linux-arm-kernel@lists.infradead.org, Anshuman Khandual , Mathieu Poirier Subject: [PATCH 5.16 047/126] arm64: Add Cortex-A510 CPU part definition Date: Mon, 7 Feb 2022 12:06:18 +0100 Message-Id: <20220207103805.746458741@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Anshuman Khandual commit 53960faf2b731dd2f9ed6e1334634b8ba6286850 upstream. Add the CPU Partnumbers for the new Arm designs. Cc: Catalin Marinas Cc: Will Deacon Cc: Suzuki Poulose Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Suzuki K Poulose Acked-by: Catalin Marinas Signed-off-by: Anshuman Khandual Link: https://lore.kernel.org/r/1643120437-14352-2-git-send-email-anshuman.= khandual@arm.com Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -73,6 +73,7 @@ #define ARM_CPU_PART_CORTEX_A76 0xD0B #define ARM_CPU_PART_NEOVERSE_N1 0xD0C #define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_CORTEX_A510 0xD46 #define ARM_CPU_PART_CORTEX_A710 0xD47 #define ARM_CPU_PART_NEOVERSE_N2 0xD49 =20 @@ -115,6 +116,7 @@ #define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTE= X_A76) #define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOV= ERSE_N1) #define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTE= X_A77) +#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORT= EX_A510) #define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORT= EX_A710) #define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOV= ERSE_N2) #define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_T= HUNDERX) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E736C41535 for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388536AbiBGLny (ORCPT ); Mon, 7 Feb 2022 06:43:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385786AbiBGLcf (ORCPT ); Mon, 7 Feb 2022 06:32:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C24C043188; Mon, 7 Feb 2022 03:32:35 -0800 (PST) Received: from smtp.kernel.org (relay.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 D870960B20; Mon, 7 Feb 2022 11:32:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF29C004E1; Mon, 7 Feb 2022 11:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233554; bh=c1+xPpj9w6ih7bgu3DWcQoQVtxFuv7Z/aEH2fqPUAlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wuy6jr3/sYTq5hdluXS7r3O7xi2F1+qaAabUoG5eqh+A1bu7938fHhh0WZ6kHNHU4 /gcLCB9FH9hK4Vum7sCl62jjhpmrOCDEoOrthUWR0+qaLMh+i0fDGEP6vDMKNXwbdo sGjAyIpT9YxPr3kq4Ext9+KiqEUs67fNjOe2gIpU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.16 048/126] RDMA/cma: Use correct address when leaving multicast group Date: Mon, 7 Feb 2022 12:06:19 +0100 Message-Id: <20220207103805.779925636@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Maor Gottlieb commit d9e410ebbed9d091b97bdf45b8a3792e2878dc48 upstream. In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate the mgid, otherwise we will generate an IGMP for an incorrect address. Fixes: b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast j= oin") Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.16= 42491047.git.leonro@nvidia.com Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/cma.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -67,8 +67,8 @@ static const char * const cma_events[] =3D [RDMA_CM_EVENT_TIMEWAIT_EXIT] =3D "timewait exit", }; =20 -static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr = *addr, - union ib_gid *mgid); +static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid, + enum ib_gid_type gid_type); =20 const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type eve= nt) { @@ -1846,17 +1846,19 @@ static void destroy_mc(struct rdma_id_pr if (dev_addr->bound_dev_if) ndev =3D dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if); - if (ndev) { + if (ndev && !send_only) { + enum ib_gid_type gid_type; union ib_gid mgid; =20 - cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr, - &mgid); - - if (!send_only) - cma_igmp_send(ndev, &mgid, false); - - dev_put(ndev); + gid_type =3D id_priv->cma_dev->default_gid_type + [id_priv->id.port_num - + rdma_start_port( + id_priv->cma_dev->device)]; + cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid, + gid_type); + cma_igmp_send(ndev, &mgid, false); } + dev_put(ndev); =20 cancel_work_sync(&mc->iboe_join.work); } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E514C4167E for ; Mon, 7 Feb 2022 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391211AbiBGL6p (ORCPT ); Mon, 7 Feb 2022 06:58:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385820AbiBGLcn (ORCPT ); Mon, 7 Feb 2022 06:32:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C14CDC043181; Mon, 7 Feb 2022 03:32:41 -0800 (PST) Received: from smtp.kernel.org (relay.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 5AE1360A67; Mon, 7 Feb 2022 11:32:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FF11C004E1; Mon, 7 Feb 2022 11:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233560; bh=nX/spthLodhzppYhHdGfbmaXFQuRzGLMi4gWVQbVVgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t96Jhu/VwdCHIKnat4IDiVCGjK8w09sDD026rLu6RJFnTrO89lBHU2EU3+yQ3Uyy+ ggJ6S0IvaCrTd1psHCJadBua898cn8wd8OylwikdEaqZUX324svYXge52acCc0z1BQ xe/AQTfXq36cMTr6bJ0ywdsG3uofuH/MCtsJnibE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com, Jason Gunthorpe , Maor Gottlieb , Leon Romanovsky Subject: [PATCH 5.16 049/126] RDMA/ucma: Protect mc during concurrent multicast leaves Date: Mon, 7 Feb 2022 12:06:20 +0100 Message-Id: <20220207103805.814493862@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Leon Romanovsky commit 36e8169ec973359f671f9ec7213547059cae972e upstream. Partially revert the commit mentioned in the Fixes line to make sure that allocation and erasing multicast struct are locked. BUG: KASAN: use-after-free in ucma_cleanup_multicast drivers/infiniband/c= ore/ucma.c:491 [inline] BUG: KASAN: use-after-free in ucma_destroy_private_ctx+0x914/0xb70 driver= s/infiniband/core/ucma.c:579 Read of size 8 at addr ffff88801bb74b00 by task syz-executor.1/25529 CPU: 0 PID: 25529 Comm: syz-executor.1 Not tainted 5.16.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS G= oogle 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:= 247 __kasan_report mm/kasan/report.c:433 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:450 ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline] ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579 ucma_destroy_id+0x1e6/0x280 drivers/infiniband/core/ucma.c:614 ucma_write+0x25c/0x350 drivers/infiniband/core/ucma.c:1732 vfs_write+0x28e/0xae0 fs/read_write.c:588 ksys_write+0x1ee/0x250 fs/read_write.c:643 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 Currently the xarray search can touch a concurrently freeing mc as the xa_for_each() is not surrounded by any lock. Rather than hold the lock for a full scan hold it only for the effected items, which is usually an empty list. Fixes: 95fe51096b7a ("RDMA/ucma: Remove mc_list and rely on xarray") Link: https://lore.kernel.org/r/1cda5fabb1081e8d16e39a48d3a4f8160cea88b8.16= 42491047.git.leonro@nvidia.com Reported-by: syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com Suggested-by: Jason Gunthorpe Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/ucma.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -95,6 +95,7 @@ struct ucma_context { u64 uid; =20 struct list_head list; + struct list_head mc_list; struct work_struct close_work; }; =20 @@ -105,6 +106,7 @@ struct ucma_multicast { =20 u64 uid; u8 join_state; + struct list_head list; struct sockaddr_storage addr; }; =20 @@ -198,6 +200,7 @@ static struct ucma_context *ucma_alloc_c =20 INIT_WORK(&ctx->close_work, ucma_close_id); init_completion(&ctx->comp); + INIT_LIST_HEAD(&ctx->mc_list); /* So list_del() will work if we don't do ucma_finish_ctx() */ INIT_LIST_HEAD(&ctx->list); ctx->file =3D file; @@ -484,19 +487,19 @@ err1: =20 static void ucma_cleanup_multicast(struct ucma_context *ctx) { - struct ucma_multicast *mc; - unsigned long index; + struct ucma_multicast *mc, *tmp; =20 - xa_for_each(&multicast_table, index, mc) { - if (mc->ctx !=3D ctx) - continue; + xa_lock(&multicast_table); + list_for_each_entry_safe(mc, tmp, &ctx->mc_list, list) { + list_del(&mc->list); /* * At this point mc->ctx->ref is 0 so the mc cannot leave the * lock on the reader and this is enough serialization */ - xa_erase(&multicast_table, index); + __xa_erase(&multicast_table, mc->id); kfree(mc); } + xa_unlock(&multicast_table); } =20 static void ucma_cleanup_mc_events(struct ucma_multicast *mc) @@ -1469,12 +1472,16 @@ static ssize_t ucma_process_join(struct mc->uid =3D cmd->uid; memcpy(&mc->addr, addr, cmd->addr_size); =20 - if (xa_alloc(&multicast_table, &mc->id, NULL, xa_limit_32b, + xa_lock(&multicast_table); + if (__xa_alloc(&multicast_table, &mc->id, NULL, xa_limit_32b, GFP_KERNEL)) { ret =3D -ENOMEM; goto err_free_mc; } =20 + list_add_tail(&mc->list, &ctx->mc_list); + xa_unlock(&multicast_table); + mutex_lock(&ctx->mutex); ret =3D rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr, join_state, mc); @@ -1500,8 +1507,11 @@ err_leave_multicast: mutex_unlock(&ctx->mutex); ucma_cleanup_mc_events(mc); err_xa_erase: - xa_erase(&multicast_table, mc->id); + xa_lock(&multicast_table); + list_del(&mc->list); + __xa_erase(&multicast_table, mc->id); err_free_mc: + xa_unlock(&multicast_table); kfree(mc); err_put_ctx: ucma_put_ctx(ctx); @@ -1569,15 +1579,17 @@ static ssize_t ucma_leave_multicast(stru mc =3D ERR_PTR(-EINVAL); else if (!refcount_inc_not_zero(&mc->ctx->ref)) mc =3D ERR_PTR(-ENXIO); - else - __xa_erase(&multicast_table, mc->id); - xa_unlock(&multicast_table); =20 if (IS_ERR(mc)) { + xa_unlock(&multicast_table); ret =3D PTR_ERR(mc); goto out; } =20 + list_del(&mc->list); + __xa_erase(&multicast_table, mc->id); + xa_unlock(&multicast_table); + mutex_lock(&mc->ctx->mutex); rdma_leave_multicast(mc->ctx->cm_id, (struct sockaddr *) &mc->addr); mutex_unlock(&mc->ctx->mutex); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A3FBC433EF for ; Mon, 7 Feb 2022 11:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388626AbiBGLoK (ORCPT ); Mon, 7 Feb 2022 06:44:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385837AbiBGLcr (ORCPT ); Mon, 7 Feb 2022 06:32:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CBB5C043181; Mon, 7 Feb 2022 03:32:46 -0800 (PST) Received: from smtp.kernel.org (relay.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 564B2B80EC3; Mon, 7 Feb 2022 11:32:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 717FAC004E1; Mon, 7 Feb 2022 11:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233564; bh=4jVbnwfVC3bF207Ch0FiydCtVRc8MucTpP3gbvg3VWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8lieLTQs9tksiOZnPLQwP0FPEujde2GbR25deL5t/kvpZn3vVOyturPU9oH6OVwN bZ/6ICU36FbM7W7YDP2gOqqrpYwoynYgweFmHYQSOd11Dptf9ptUygtxk6WF/u5GCu AES8CXp/hDvEglzHJHRjw1ith9Kht4J9kKxEhKKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Leon Romanovsky , Bernard Metzler , Jason Gunthorpe Subject: [PATCH 5.16 050/126] RDMA/siw: Fix refcounting leak in siw_create_qp() Date: Mon, 7 Feb 2022 12:06:21 +0100 Message-Id: <20220207103805.844976517@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 a75badebfdc0b3823054bedf112edb54d6357c75 upstream. The atomic_inc() needs to be paired with an atomic_dec() on the error path. Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory") Link: https://lore.kernel.org/r/20220118091104.GA11671@kili Signed-off-by: Dan Carpenter Reviewed-by: Leon Romanovsky Reviewed-by: Bernard Metzler Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/sw/siw/siw_verbs.c +++ b/drivers/infiniband/sw/siw/siw_verbs.c @@ -311,7 +311,8 @@ int siw_create_qp(struct ib_qp *ibqp, st =20 if (atomic_inc_return(&sdev->num_qp) > SIW_MAX_QP) { siw_dbg(base_dev, "too many QP's\n"); - return -ENOMEM; + rv =3D -ENOMEM; + goto err_atomic; } if (attrs->qp_type !=3D IB_QPT_RC) { siw_dbg(base_dev, "only RC QP's supported\n"); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28BEBC4332F for ; Mon, 7 Feb 2022 11:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388657AbiBGLoW (ORCPT ); Mon, 7 Feb 2022 06:44:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385851AbiBGLcv (ORCPT ); Mon, 7 Feb 2022 06:32:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF71C043181; Mon, 7 Feb 2022 03:32:49 -0800 (PST) Received: from smtp.kernel.org (relay.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 78F3DB80EBD; Mon, 7 Feb 2022 11:32:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0263C004E1; Mon, 7 Feb 2022 11:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233567; bh=gn4OAdhu+hH8rfibNVVxX0yqlvsmy0BuWCaHNaM1xOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=prOl8y9c6JD/WCjf6T8MWgEcWM+J7EtelLBTv74abrq02MvTCmjFw12PW21DDVT4G 2xCuyy7WjPKUQ017DM4oVmHIPkDqb++GFnrCVUEhw67JLqk6Xt4OfaXd8+Zh7qeGyE ZX8q8TQm/S3Di2HCN01G7T17OMKgGg+YsqiYFyoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.16 051/126] IB/rdmavt: Validate remote_addr during loopback atomic tests Date: Mon, 7 Feb 2022 12:06:22 +0100 Message-Id: <20220207103805.876644010@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Marciniszyn commit 4028bccb003cf67e46632dee7f97ddc5d7b6e685 upstream. The rdma-core test suite sends an unaligned remote address and expects a failure. ERROR: test_atomic_non_aligned_addr (tests.test_atomic.AtomicTest) The qib/hfi1 rc handling validates properly, but the test has the client and server on the same system. The loopback of these operations is a distinct code path. Fix by syntaxing the proposed remote address in the loopback code path. Fixes: 15703461533a ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt") Link: https://lore.kernel.org/r/1642584489-141005-1-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/rdmavt/qp.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -3073,6 +3073,8 @@ do_write: case IB_WR_ATOMIC_FETCH_AND_ADD: if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC))) goto inv_err; + if (unlikely(wqe->atomic_wr.remote_addr & (sizeof(u64) - 1))) + goto inv_err; if (unlikely(!rvt_rkey_ok(qp, &qp->r_sge.sge, sizeof(u64), wqe->atomic_wr.remote_addr, wqe->atomic_wr.rkey, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EE94C433F5 for ; Mon, 7 Feb 2022 11:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388671AbiBGLo2 (ORCPT ); Mon, 7 Feb 2022 06:44:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385861AbiBGLcw (ORCPT ); Mon, 7 Feb 2022 06:32:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A257C043188; Mon, 7 Feb 2022 03:32:51 -0800 (PST) Received: from smtp.kernel.org (relay.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 0077160A67; Mon, 7 Feb 2022 11:32:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B77FFC340F0; Mon, 7 Feb 2022 11:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233570; bh=lV1mkuh7zyPWVcvLXzJOB2GkO6mowb3cwC8cFqZQMqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/bZJPj2Y9ph58jwNLPAf9NPLUmeVVT5Nj765uIEgedxjkIJo+8oBVtv+PG/nos1b oy5YKNAO+C+UjiasiApBwLE7qlecButwf++mk6H9BgxSHGaRfIgi+G1udUgSL3CV9U KkGuHJUHFdmhSUoN2RZukUWWMrGnEY0yalF+hNGg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jared Holzman , Bernard Metzler , Jason Gunthorpe Subject: [PATCH 5.16 052/126] RDMA/siw: Fix broken RDMA Read Fence/Resume logic. Date: Mon, 7 Feb 2022 12:06:23 +0100 Message-Id: <20220207103805.913090166@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Bernard Metzler commit b43a76f423aa304037603fd6165c4a534d2c09a7 upstream. Code unconditionally resumed fenced SQ processing after next RDMA Read completion, even if other RDMA Read responses are still outstanding, or ORQ is full. Also adds comments for better readability of fence processing, and removes orq_get_tail() helper, which is not needed anymore. Fixes: 8b6a361b8c48 ("rdma/siw: receive path") Fixes: a531975279f3 ("rdma/siw: main include file") Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com Reported-by: Jared Holzman Signed-off-by: Bernard Metzler Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/siw/siw.h | 7 +------ drivers/infiniband/sw/siw/siw_qp_rx.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -644,14 +644,9 @@ static inline struct siw_sqe *orq_get_cu return &qp->orq[qp->orq_get % qp->attrs.orq_size]; } =20 -static inline struct siw_sqe *orq_get_tail(struct siw_qp *qp) -{ - return &qp->orq[qp->orq_put % qp->attrs.orq_size]; -} - static inline struct siw_sqe *orq_get_free(struct siw_qp *qp) { - struct siw_sqe *orq_e =3D orq_get_tail(qp); + struct siw_sqe *orq_e =3D &qp->orq[qp->orq_put % qp->attrs.orq_size]; =20 if (READ_ONCE(orq_e->flags) =3D=3D 0) return orq_e; --- a/drivers/infiniband/sw/siw/siw_qp_rx.c +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c @@ -1153,11 +1153,12 @@ static int siw_check_tx_fence(struct siw =20 spin_lock_irqsave(&qp->orq_lock, flags); =20 - rreq =3D orq_get_current(qp); - /* free current orq entry */ + rreq =3D orq_get_current(qp); WRITE_ONCE(rreq->flags, 0); =20 + qp->orq_get++; + if (qp->tx_ctx.orq_fence) { if (unlikely(tx_waiting->wr_status !=3D SIW_WR_QUEUED)) { pr_warn("siw: [QP %u]: fence resume: bad status %d\n", @@ -1165,10 +1166,12 @@ static int siw_check_tx_fence(struct siw rv =3D -EPROTO; goto out; } - /* resume SQ processing */ + /* resume SQ processing, if possible */ if (tx_waiting->sqe.opcode =3D=3D SIW_OP_READ || tx_waiting->sqe.opcode =3D=3D SIW_OP_READ_LOCAL_INV) { - rreq =3D orq_get_tail(qp); + + /* SQ processing was stopped because of a full ORQ */ + rreq =3D orq_get_free(qp); if (unlikely(!rreq)) { pr_warn("siw: [QP %u]: no ORQE\n", qp_id(qp)); rv =3D -EPROTO; @@ -1181,15 +1184,14 @@ static int siw_check_tx_fence(struct siw resume_tx =3D 1; =20 } else if (siw_orq_empty(qp)) { + /* + * SQ processing was stopped by fenced work request. + * Resume since all previous Read's are now completed. + */ qp->tx_ctx.orq_fence =3D 0; resume_tx =3D 1; - } else { - pr_warn("siw: [QP %u]: fence resume: orq idx: %d:%d\n", - qp_id(qp), qp->orq_get, qp->orq_put); - rv =3D -EPROTO; } } - qp->orq_get++; out: spin_unlock_irqrestore(&qp->orq_lock, flags); =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EB5EC433EF for ; Mon, 7 Feb 2022 11:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388686AbiBGLoa (ORCPT ); Mon, 7 Feb 2022 06:44:30 -0500 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 S1385880AbiBGLc4 (ORCPT ); Mon, 7 Feb 2022 06:32:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18079C043181; Mon, 7 Feb 2022 03:32:55 -0800 (PST) Received: from smtp.kernel.org (relay.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 ACFC1B80EBD; Mon, 7 Feb 2022 11:32:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00017C004E1; Mon, 7 Feb 2022 11:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233573; bh=0amyQrwO/l9Xpx9ZFXvom4ZEQ7XuUf/uQHAxWPyi1UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YfHfWlBKwAS5Gsa+mhhNu/97a0g/M81UrBz5H5KUfVtRKzyEm61b5cFdOcAfyOlhA pEcIwXyF+PZQ2uyIi23OkTST9Eu6k3kojMj+E+5fo+GMSprHIW5XMPf2aIQ6dLHvvV faMCYGpvl6GgQ6socJb6OZDm8CKoNPESv2but3fQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Jason Gunthorpe Subject: [PATCH 5.16 053/126] RDMA/mlx4: Dont continue event handler after memory allocation failure Date: Mon, 7 Feb 2022 12:06:24 +0100 Message-Id: <20220207103805.945560237@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Leon Romanovsky commit f3136c4ce7acf64bee43135971ca52a880572e32 upstream. The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE event handler will cause skip the assignment logic, but ib_dispatch_event() will be called anyway. Fix it by calling to return instead of break after memory allocation failure. Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp= _snoop") Link: https://lore.kernel.org/r/12a0e83f18cfad4b5f62654f141e240d04915e10.16= 43622264.git.leonro@nvidia.com Signed-off-by: Leon Romanovsky Reviewed-by: H=C3=A5kon Bugge Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/mlx4/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -3247,7 +3247,7 @@ static void mlx4_ib_event(struct mlx4_de case MLX4_DEV_EVENT_PORT_MGMT_CHANGE: ew =3D kmalloc(sizeof *ew, GFP_ATOMIC); if (!ew) - break; + return; =20 INIT_WORK(&ew->work, handle_port_mgmt_change_event); memcpy(&ew->ib_eqe, eqe, sizeof *eqe); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8328AC4332F for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356477AbiBGLtL (ORCPT ); Mon, 7 Feb 2022 06:49:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386636AbiBGLfN (ORCPT ); Mon, 7 Feb 2022 06:35:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B4AC043181; Mon, 7 Feb 2022 03:35:13 -0800 (PST) Received: from smtp.kernel.org (relay.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 CB421B80EBD; Mon, 7 Feb 2022 11:35:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D09B7C004E1; Mon, 7 Feb 2022 11:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233710; bh=+IY6A+HUlenz/HqGjjxj3obMOLESQN8pG2bZR8pv5QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VHuxb3Hxz6I0A4XEIYBuYkZJi7q92A+cBMD/eFCkjFrHSAnj690EO0Ayi90kQDR+G dx9asc8xyX6WXzLfk0/fFpubIJmerjHAqTAIq0eeUzobecQ6nncp4S9Z1t4JBGFhbV 1K8ZuQg3h7WSFd/jDVVLCafNELVdl2mjPIqdSjKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Takashi Iwai Subject: [PATCH 5.16 054/126] ALSA: usb-audio: initialize variables that could ignore errors Date: Mon, 7 Feb 2022 12:06:25 +0100 Message-Id: <20220207103805.976127340@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 3da4b7403db87d39bc2613cfd790de1de99a70ab upstream. clang static analysis reports this representative issue mixer.c:1548:35: warning: Assigned value is garbage or undefined ucontrol->value.integer.value[0] =3D val; ^ ~~~ The filter_error() macro allows errors to be ignored. If errors can be ignored, initialize variables so garbage will not be used. Fixes: 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops= , too") Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20220126182142.1184819-1-trix@redhat.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/usb/mixer.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1526,6 +1526,10 @@ error: usb_audio_err(chip, "cannot get connectors status: req =3D %#x, wValue =3D %#x, wIndex =3D = %#x, type =3D %d\n", UAC_GET_CUR, validx, idx, cval->val_type); + + if (val) + *val =3D 0; + return filter_error(cval, ret); } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B60E0C4167B for ; Mon, 7 Feb 2022 11:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385570AbiBGLo6 (ORCPT ); Mon, 7 Feb 2022 06:44:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386025AbiBGLdU (ORCPT ); Mon, 7 Feb 2022 06:33:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BD5C043181; Mon, 7 Feb 2022 03:33:20 -0800 (PST) Received: from smtp.kernel.org (relay.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 0E6AD60C8E; Mon, 7 Feb 2022 11:33:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD58C004E1; Mon, 7 Feb 2022 11:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233599; bh=8eH1MdEVdu2hKNRuGIzmCqaimYky5xcS1WJ3g2iEc98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYBjP/lpsYMSpxS2KGxgpjebAfpxTLD9ORgOuV013wD4J8V1fPzwukRYrJbXRsIbf J2t7UxSXcvhcDQj6YHRhSGJyhBibqJWtAARj3QtAUwFpGtfiBGhm+pZ34wqhJLwCHz nhLb3pWzNtxwGHYa7ajQ3ZOkIp2ey8Z1BpiTjxMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Takashi Iwai Subject: [PATCH 5.16 055/126] ALSA: hda: Fix signedness of sscanf() arguments Date: Mon, 7 Feb 2022 12:06:26 +0100 Message-Id: <20220207103806.014919306@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 0444f82766f0b5b9c8302ad802dafa5dd0e722d0 upstream. The %x format of sscanf() takes an unsigned int pointer, while we pass a signed int pointer. Practically it's OK, but this may result in a compile warning. Let's fix it. Fixes: a235d5b8e550 ("ALSA: hda: Allow model option to specify PCI SSID ali= as") Reported-by: kernel test robot Link: https://lore.kernel.org/r/20220127135717.31751-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_auto_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -985,7 +985,7 @@ void snd_hda_pick_fixup(struct hda_codec int id =3D HDA_FIXUP_ID_NOT_SET; const char *name =3D NULL; const char *type =3D NULL; - int vendor, device; + unsigned int vendor, device; =20 if (codec->fixup_id !=3D HDA_FIXUP_ID_NOT_SET) return; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B935C35272 for ; Mon, 7 Feb 2022 11:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389132AbiBGLqO (ORCPT ); Mon, 7 Feb 2022 06:46:14 -0500 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 S1386206AbiBGLd5 (ORCPT ); Mon, 7 Feb 2022 06:33:57 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133FEC043181; Mon, 7 Feb 2022 03:33:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 C3C1BB8102E; Mon, 7 Feb 2022 11:33:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9334C004E1; Mon, 7 Feb 2022 11:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233634; bh=wgI2JfwnGs9YATRBKGTUEYM00WplHCkNomidae7ocq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5hJrcYu2fgD30Z5xz5W3arU6JP9ykG3Zt4ozcxDXkAgl688Ufa1Mce1Vhi+K8J8S XBUdt69pqAsuki+d4es/NBP7AM+XvedSWvp4p4W9VawdiRQvljzqk2LKyiDCiRfZUk FEiRktLy6wEXGDtAVTsYjTzm2h8/HnmRuvpuX2Ek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guennadi Liakhovetski , Peter Ujfalusi , Takashi Iwai Subject: [PATCH 5.16 056/126] ALSA: hda: Skip codec shutdown in case the codec is not registered Date: Mon, 7 Feb 2022 12:06:27 +0100 Message-Id: <20220207103806.052435714@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit 1c7f0e349aa5f8f80b1cac3d4917405332e14cdf upstream. If the codec->registered is not set then it means that pm_runtime is not yet enabled and the codec->pcm_list_head has not been initialized. The access to the not initialized pcm_list_head will lead a kernel crash during shutdown. Reported-by: Guennadi Liakhovetski Signed-off-by: Peter Ujfalusi Tested-by: Guennadi Liakhovetski Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown") Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux= .intel.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_codec.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3000,6 +3000,10 @@ void snd_hda_codec_shutdown(struct hda_c { struct hda_pcm *cpcm; =20 + /* Skip the shutdown if codec is not registered */ + if (!codec->registered) + return; + list_for_each_entry(cpcm, &codec->pcm_list_head, list) snd_pcm_suspend_all(cpcm->pcm); =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91052C4321E for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389247AbiBGLrz (ORCPT ); Mon, 7 Feb 2022 06:47:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386407AbiBGLef (ORCPT ); Mon, 7 Feb 2022 06:34:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71186C043188; Mon, 7 Feb 2022 03:34:34 -0800 (PST) Received: from smtp.kernel.org (relay.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 2C0DBB80EC3; Mon, 7 Feb 2022 11:34:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E3CC340F0; Mon, 7 Feb 2022 11:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233672; bh=klD1XoqszxDtG3NN+zWwtPmHx71bBeUBfpAm8Kv5nLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DC+mZTHfHuUOVWPqwCt5AEmCMqMBqu+tS0o6Sv5dzh/XhMbCzOBQr5zZf7gtTFHrd 6tj/FIXL7zhPdbp60shnCk2KpavFi8RczGzhrEg6q1yNd2YAWEwwzwYq+6nytnZN96 UzQkunneK1g3ZdUYydABRZzmzJcfRZQ+kDzzhg8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lu Baolu , Guoqing Jiang , Joerg Roedel Subject: [PATCH 5.16 057/126] iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() Date: Mon, 7 Feb 2022 12:06:28 +0100 Message-Id: <20220207103806.082667303@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Guoqing Jiang commit 99e675d473eb8cf2deac1376a0f840222fc1adcf upstream. After commit e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionally allocated"). For tear down scenario, fn is only freed after fail to allocate ir_domain, though it also should be freed in case dmar_enable_qi returns error. Besides free fn, irq_domain and ir_msi_domain need to be removed as well if intel_setup_irq_remapping fails to enable queued invalidation. Improve the rewinding path by add out_free_ir_domain and out_free_fwnode lables per Baolu's suggestion. Fixes: e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionall= y allocated") Suggested-by: Lu Baolu Signed-off-by: Guoqing Jiang Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.= dev Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.int= el.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/iommu/intel/irq_remapping.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -569,9 +569,8 @@ static int intel_setup_irq_remapping(str fn, &intel_ir_domain_ops, iommu); if (!iommu->ir_domain) { - irq_domain_free_fwnode(fn); pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id); - goto out_free_bitmap; + goto out_free_fwnode; } iommu->ir_msi_domain =3D arch_create_remap_msi_irq_domain(iommu->ir_domain, @@ -595,7 +594,7 @@ static int intel_setup_irq_remapping(str =20 if (dmar_enable_qi(iommu)) { pr_err("Failed to enable queued invalidation\n"); - goto out_free_bitmap; + goto out_free_ir_domain; } } =20 @@ -619,6 +618,14 @@ static int intel_setup_irq_remapping(str =20 return 0; =20 +out_free_ir_domain: + if (iommu->ir_msi_domain) + irq_domain_remove(iommu->ir_msi_domain); + iommu->ir_msi_domain =3D NULL; + irq_domain_remove(iommu->ir_domain); + iommu->ir_domain =3D NULL; +out_free_fwnode: + irq_domain_free_fwnode(fn); out_free_bitmap: bitmap_free(bitmap); out_free_pages: From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28EC8C35271 for ; Mon, 7 Feb 2022 12:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389453AbiBGLse (ORCPT ); Mon, 7 Feb 2022 06:48:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386550AbiBGLez (ORCPT ); Mon, 7 Feb 2022 06:34:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 271D1C043181; Mon, 7 Feb 2022 03:34:54 -0800 (PST) Received: from smtp.kernel.org (relay.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 C7D42B80EBD; Mon, 7 Feb 2022 11:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8BE4C004E1; Mon, 7 Feb 2022 11:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233691; bh=ScHomgUOORKGXC3cq+pTzaGi0+yCAoM+r4g/KqfAQEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6QgdKTnJHWnHESXfj7+tS8sTK7eOFbfUnqtSeXxHHR6hf4U23rx1SoRoc27Pw3Ku s2DtfT+JWsbsp++0kcWA2zZT6VTWo6LRPcCJqlZGmrzod5hIP/ccjmmao64N62pCCo jOdgZJE72U9TVbCHi11MMvM1zT4kxujWLvLFfMv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel Subject: [PATCH 5.16 058/126] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Date: Mon, 7 Feb 2022 12:06:29 +0100 Message-Id: <20220207103806.115758833@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Joerg Roedel commit 9b45a7738eec52bf0f5d8d3d54e822962781c5f2 upstream. The polling loop for the register change in iommu_ga_log_enable() needs to have a udelay() in it. Otherwise the CPU might be faster than the IOMMU hardware and wrongly trigger the WARN_ON() further down the code stream. Use a 10us for udelay(), has there is some hardware where activation of the GA log can take more than a 100ms. A future optimization should move the activation check of the GA log to the point where it gets used for the first time. But that is a bigger change and not suitable for a fix. Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log") Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -834,6 +835,7 @@ static int iommu_ga_log_enable(struct am status =3D readl(iommu->mmio_base + MMIO_STATUS_OFFSET); if (status & (MMIO_STATUS_GALOG_RUN_MASK)) break; + udelay(10); } =20 if (WARN_ON(i >=3D LOOP_TIMEOUT)) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44F84C41535 for ; Mon, 7 Feb 2022 12:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389478AbiBGLsg (ORCPT ); Mon, 7 Feb 2022 06:48:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386568AbiBGLe6 (ORCPT ); Mon, 7 Feb 2022 06:34:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D975C043181; Mon, 7 Feb 2022 03:34:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 F3C79B8102E; Mon, 7 Feb 2022 11:34:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D71C004E1; Mon, 7 Feb 2022 11:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233694; bh=kbXvknl46C1yh96qPSzRoU7OAGKJq3nYu1ZxHS+sLKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dADbWCjsWp4AZCsTwDibgrXq5Pnw1uE4PfUmeClOg2k4lk2S/1BCwzlwllkEx7Iq0 D8nwpdvDSMN8Rn1LGWdZ2pYVmuLj+AFox73N5UYNqp3n8oHFUGMaW4dWkHmFGPKxY+ xxnjLYYXUg/QUg6O0wG1/hxzBAvaRl6umNYYEi3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Dasu , Florian Fainelli , Mark Brown Subject: [PATCH 5.16 059/126] spi: bcm-qspi: check for valid cs before applying chip select Date: Mon, 7 Feb 2022 12:06:30 +0100 Message-Id: <20220207103806.153211332@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Kamal Dasu commit 2cbd27267ffe020af1442b95ec57f59a157ba85c upstream. Apply only valid chip select value. This change fixes case where chip select is set to initial value of '-1' during probe and PM supend and subsequent resume can try to use the value with undefined behaviour. Also in case where gpio based chip select, the check in bcm_qspi_chip_select() shall prevent undefined behaviour on resume. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-bcm-qspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -573,7 +573,7 @@ static void bcm_qspi_chip_select(struct u32 rd =3D 0; u32 wr =3D 0; =20 - if (qspi->base[CHIP_SELECT]) { + if (cs >=3D 0 && qspi->base[CHIP_SELECT]) { rd =3D bcm_qspi_read(qspi, CHIP_SELECT, 0); wr =3D (rd & ~0xff) | (1 << cs); if (rd =3D=3D wr) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E70C433FE for ; Mon, 7 Feb 2022 11:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389513AbiBGLsl (ORCPT ); Mon, 7 Feb 2022 06:48:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386576AbiBGLe7 (ORCPT ); Mon, 7 Feb 2022 06:34:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248B0C043181; Mon, 7 Feb 2022 03:34:59 -0800 (PST) Received: from smtp.kernel.org (relay.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 A22EA60A69; Mon, 7 Feb 2022 11:34:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61440C004E1; Mon, 7 Feb 2022 11:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233698; bh=UQXmFZvWzDM7T2wZ+gPuu+7zNQpmp5zPgxWJTNgyGXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZTWr3rb/UrazV5JHkPO9kARU2YTVigRGvgI1dmjf6hN/pmJEEpwoN5O9dPEVk+Zx3 SaDBoQgaYQyIzyU6SfaalTQ53YL/5Len9Nmi8oj5GnTrur3s2CwTMF7OSH4m68LCfy 72cisVMkFrmO+gsWD+zf4GahYTp5I3uqUaiQG0zQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Gaignard , Mark Brown Subject: [PATCH 5.16 060/126] spi: mediatek: Avoid NULL pointer crash in interrupt Date: Mon, 7 Feb 2022 12:06:31 +0100 Message-Id: <20220207103806.184560242@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Benjamin Gaignard commit f83a96e5f033fbbd21764705cb9c04234b96218e upstream. In some case, like after a transfer timeout, master->cur_msg pointer is NULL which led to a kernel crash when trying to use master->cur_msg->spi. mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter avoid the problem by setting NULL as second parameter. Fixes: a568231f46322 ("spi: mediatek: Add spi bus for Mediatek MT8173") Signed-off-by: Benjamin Gaignard Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@c= ollabora.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -624,7 +624,7 @@ static irqreturn_t mtk_spi_interrupt(int else mdata->state =3D MTK_SPI_IDLE; =20 - if (!master->can_dma(master, master->cur_msg->spi, trans)) { + if (!master->can_dma(master, NULL, trans)) { if (trans->rx_buf) { cnt =3D mdata->xfer_len / 4; ioread32_rep(mdata->base + SPI_RX_DATA_REG, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23447C433FE for ; Mon, 7 Feb 2022 12:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbiBGLso (ORCPT ); Mon, 7 Feb 2022 06:48:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386588AbiBGLfC (ORCPT ); Mon, 7 Feb 2022 06:35:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 267B1C043181; Mon, 7 Feb 2022 03:35:02 -0800 (PST) Received: from smtp.kernel.org (relay.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 B865560B20; Mon, 7 Feb 2022 11:35:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9261DC004E1; Mon, 7 Feb 2022 11:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233701; bh=ndaHqpqn4sqHYZzskELwPY5K5zp5TlQe607bssm09fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q8JmGnj7iFobmTk9HLAvFFV3Liw/EOetAd/BnGLaZc5bDItI4jCRSk3Pd5K3nDNTp WjnRjXhnbikUA1UmMHbVR2fa8M7Iy0+eCXMDZNZy1tv0z3oL0snLiJLh1T91XhjP5v VcDrTbNaAd/EjcjAJ3q/RX6iWewjM9UcIZ1GKEMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mark Brown Subject: [PATCH 5.16 061/126] spi: meson-spicc: add IRQ check in meson_spicc_probe Date: Mon, 7 Feb 2022 12:06:32 +0100 Message-Id: <20220207103806.214069033@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 e937440f7fc444a3e3f1fb75ea65292d6f433a44 upstream. This check misses checking for platform_get_irq()'s call and may passes the negative error codes to devm_request_irq(), which takes unsigned IRQ #, causing it to fail with -EINVAL, overriding an original error code. Stop calling devm_request_irq() with invalid IRQ #s. Fixes: 454fa271bc4e ("spi: Add Meson SPICC driver") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220126110447.24549-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-meson-spicc.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -693,6 +693,11 @@ static int meson_spicc_probe(struct plat writel_relaxed(0, spicc->base + SPICC_INTREG); =20 irq =3D platform_get_irq(pdev, 0); + if (irq < 0) { + ret =3D irq; + goto out_master; + } + ret =3D devm_request_irq(&pdev->dev, irq, meson_spicc_irq, 0, NULL, spicc); if (ret) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 531FEC433F5 for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242021AbiBGLsw (ORCPT ); Mon, 7 Feb 2022 06:48:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386606AbiBGLfI (ORCPT ); Mon, 7 Feb 2022 06:35:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB677C043181; Mon, 7 Feb 2022 03:35:06 -0800 (PST) Received: from smtp.kernel.org (relay.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 9B8A8B8102E; Mon, 7 Feb 2022 11:35:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBDA3C004E1; Mon, 7 Feb 2022 11:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233704; bh=+G3hb5+RB2uCCKVlicO2SP2tFVuFlczkrJDxVN1aZDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfPcXSW9PE62VB75Dcvz6jkSPkfDll7dkH4i1VCZmliLNR7x22CRCCp9H2FzRnx/Q S2ZKV7a8TTR4O/EK35Q+U5tdjIbGlujaPhXUWq7+W7EmWP5j5iMc6GKp8n7V7Zy9Vi HAVdK1i+iN5DYa8UGaigqQqJMaVXhVWb1FimUnRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Xiong , Xiyu Yang , Xin Tan , Kunihiko Hayashi , Mark Brown Subject: [PATCH 5.16 062/126] spi: uniphier: fix reference count leak in uniphier_spi_probe() Date: Mon, 7 Feb 2022 12:06:33 +0100 Message-Id: <20220207103806.254652960@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Xin Xiong commit 37c2c83ca4f1ef4b6908181ac98e18360af89b42 upstream. The issue happens in several error paths in uniphier_spi_probe(). When either dma_get_slave_caps() or devm_spi_register_master() returns an error code, the function forgets to decrease the refcount of both `dma_rx` and `dma_tx` objects, which may lead to refcount leaks. Fix it by decrementing the reference count of specific objects in those error paths. Signed-off-by: Xin Xiong Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Reviewed-by: Kunihiko Hayashi Fixes: 28d1dddc59f6 ("spi: uniphier: Add DMA transfer mode support") Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-uniphier.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-uniphier.c +++ b/drivers/spi/spi-uniphier.c @@ -726,7 +726,7 @@ static int uniphier_spi_probe(struct pla if (ret) { dev_err(&pdev->dev, "failed to get TX DMA capacities: %d\n", ret); - goto out_disable_clk; + goto out_release_dma; } dma_tx_burst =3D caps.max_burst; } @@ -735,7 +735,7 @@ static int uniphier_spi_probe(struct pla if (IS_ERR_OR_NULL(master->dma_rx)) { if (PTR_ERR(master->dma_rx) =3D=3D -EPROBE_DEFER) { ret =3D -EPROBE_DEFER; - goto out_disable_clk; + goto out_release_dma; } master->dma_rx =3D NULL; dma_rx_burst =3D INT_MAX; @@ -744,7 +744,7 @@ static int uniphier_spi_probe(struct pla if (ret) { dev_err(&pdev->dev, "failed to get RX DMA capacities: %d\n", ret); - goto out_disable_clk; + goto out_release_dma; } dma_rx_burst =3D caps.max_burst; } @@ -753,10 +753,20 @@ static int uniphier_spi_probe(struct pla =20 ret =3D devm_spi_register_master(&pdev->dev, master); if (ret) - goto out_disable_clk; + goto out_release_dma; =20 return 0; =20 +out_release_dma: + if (!IS_ERR_OR_NULL(master->dma_rx)) { + dma_release_channel(master->dma_rx); + master->dma_rx =3D NULL; + } + if (!IS_ERR_OR_NULL(master->dma_tx)) { + dma_release_channel(master->dma_tx); + master->dma_tx =3D NULL; + } + out_disable_clk: clk_disable_unprepare(priv->clk); =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73AFCC433EF for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349745AbiBGLtE (ORCPT ); Mon, 7 Feb 2022 06:49:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386615AbiBGLfK (ORCPT ); Mon, 7 Feb 2022 06:35:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18513C043181; Mon, 7 Feb 2022 03:35:10 -0800 (PST) Received: from smtp.kernel.org (relay.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 D2B1FB8102E; Mon, 7 Feb 2022 11:35:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDD02C004E1; Mon, 7 Feb 2022 11:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233707; bh=D1iJwyfsHLPr5Rqzs8UxZzRupRZ+cg/8d6hqnSL8FKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHbA8ExLyYb/hHuRwGz+wwL7HtSuzn0WGo56zt5OBi4gI5vcgN3RHrzhr16Y4+gzd f5zkizOwbXvSTZ8LbvI1VqZCvXCtmJeXP8KFsaZNOmcz2Huk/5GN2yCC/7eaRRgNF7 AxEwWZmluCmRe8GFU8mkhiGGFJRdPR5US82/2ybM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.16 063/126] IB/hfi1: Fix tstats alloc and dealloc Date: Mon, 7 Feb 2022 12:06:34 +0100 Message-Id: <20220207103806.284725902@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Mike Marciniszyn commit e5cce44aff3be9ad2cd52f63f35edbd706181d50 upstream. The tstats allocation is done in the accelerated ndo_init function but the allocation is not tested to succeed. The deallocation is not done in the accelerated ndo_uninit function. Resolve issues by testing for an allocation failure and adding the free_percpu in the uninit function. Fixes: aa0616a9bd52 ("IB/hfi1: switch to core handling of rx/tx byte/packet= counters") Link: https://lore.kernel.org/r/1642287756-182313-5-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/infiniband/hw/hfi1/ipoib_main.c +++ b/drivers/infiniband/hw/hfi1/ipoib_main.c @@ -22,26 +22,35 @@ static int hfi1_ipoib_dev_init(struct ne int ret; =20 dev->tstats =3D netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + if (!dev->tstats) + return -ENOMEM; =20 ret =3D priv->netdev_ops->ndo_init(dev); if (ret) - return ret; + goto out_ret; =20 ret =3D hfi1_netdev_add_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr), dev); if (ret < 0) { priv->netdev_ops->ndo_uninit(dev); - return ret; + goto out_ret; } =20 return 0; +out_ret: + free_percpu(dev->tstats); + dev->tstats =3D NULL; + return ret; } =20 static void hfi1_ipoib_dev_uninit(struct net_device *dev) { struct hfi1_ipoib_dev_priv *priv =3D hfi1_ipoib_priv(dev); =20 + free_percpu(dev->tstats); + dev->tstats =3D NULL; + hfi1_netdev_remove_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr)); =20 priv->netdev_ops->ndo_uninit(dev); @@ -166,6 +175,7 @@ static void hfi1_ipoib_netdev_dtor(struc hfi1_ipoib_rxq_deinit(priv->netdev); =20 free_percpu(dev->tstats); + dev->tstats =3D NULL; } =20 static void hfi1_ipoib_set_id(struct net_device *dev, int id) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 135D0C4332F for ; Mon, 7 Feb 2022 11:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388791AbiBGLpK (ORCPT ); Mon, 7 Feb 2022 06:45:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386060AbiBGLdZ (ORCPT ); Mon, 7 Feb 2022 06:33:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E859C043181; Mon, 7 Feb 2022 03:33:25 -0800 (PST) Received: from smtp.kernel.org (relay.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 E0E9CB80EBD; Mon, 7 Feb 2022 11:33:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A97FC004E1; Mon, 7 Feb 2022 11:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233602; bh=7QUCjhG7b2OWuM/D+SKi0gaN56aTrCQMmg2TU98RO+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Elpu5vbNyhAESYf4JMD5PXDd5HdWz6/cp0zb2CTbFrU4BmQSA3CWLpPZFidyA/ANR ayHBxg9o/I92c/wjZKz4lByrVy3sdRpLa1s62xu8FntSoEFGU60gyARkvdfqCPBSfy dna+RLXPy3NNJOLd0dVBiFT5QSgyc8z+hJS8kmsg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Zhang , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.16 064/126] IB/cm: Release previously acquired reference counter in the cm_id_priv Date: Mon, 7 Feb 2022 12:06:35 +0100 Message-Id: <20220207103806.314771662@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Zhang commit b856101a1774b5f1c8c99e8dfdef802856520732 upstream. In failure flow, the reference counter acquired was not released, and the following error was reported: drivers/infiniband/core/cm.c:3373 cm_lap_handler() warn: inconsistent refcounting 'cm_id_priv->refcount.refs.counter': Fixes: 7345201c3963 ("IB/cm: Improve the calling of cm_init_av_for_lap and = cm_init_av_by_path") Link: https://lore.kernel.org/r/7615f23bbb5c5b66d03f6fa13e1c99d51dae6916.16= 42581448.git.leonro@nvidia.com Reported-by: Dan Carpenter Signed-off-by: Mark Zhang Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -3322,7 +3322,7 @@ static int cm_lap_handler(struct cm_work ret =3D cm_init_av_by_path(param->alternate_path, NULL, &alt_av); if (ret) { rdma_destroy_ah_attr(&ah_attr); - return -EINVAL; + goto deref; } =20 spin_lock_irq(&cm_id_priv->lock); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21E9EC43217 for ; Mon, 7 Feb 2022 11:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388818AbiBGLpe (ORCPT ); Mon, 7 Feb 2022 06:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386073AbiBGLd3 (ORCPT ); Mon, 7 Feb 2022 06:33:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6010FC043181; Mon, 7 Feb 2022 03:33:28 -0800 (PST) Received: from smtp.kernel.org (relay.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 1A956B811BC; Mon, 7 Feb 2022 11:33:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4553CC004E1; Mon, 7 Feb 2022 11:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233606; bh=BrOeKKIu/c6Ewayd+Wwum8dmrbUTc5f982drrQndTvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LP5x+7jcczX8smoNSUOfNkGoznmRkQ1P1Bmh4jFkOP2R623PhJasMux7BEfmEYSPI ig+c+r484wSRhN1PDsezTXrJC0I22VFI4ZJziBAD3Lmx0j3OGZxtEy7TccO02R8QAV Il8xaDb0yrUwNoe+bwPXK3ly5uQr13PeeXSUKVsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.16 065/126] net: ieee802154: hwsim: Ensure proper channel selection at probe time Date: Mon, 7 Feb 2022 12:06:36 +0100 Message-Id: <20220207103806.346244291@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Miquel Raynal commit 1293fccc9e892712d910ec96079d3717307f1d2d upstream. Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13. Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: Miquel Raynal [stefan@datenfreihafen.org: fixed assigment from page to channel] Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-2-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/mac802154_hwsim.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_inf goto err_pib; } =20 + pib->channel =3D 13; rcu_assign_pointer(phy->pib, pib); phy->idx =3D idx; INIT_LIST_HEAD(&phy->edges); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C995C4707A for ; Mon, 7 Feb 2022 11:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388858AbiBGLpo (ORCPT ); Mon, 7 Feb 2022 06:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386086AbiBGLdc (ORCPT ); Mon, 7 Feb 2022 06:33:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7595C043181; Mon, 7 Feb 2022 03:33:31 -0800 (PST) Received: from smtp.kernel.org (relay.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 62BB8B811BC; Mon, 7 Feb 2022 11:33:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B024C004E1; Mon, 7 Feb 2022 11:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233609; bh=b13qAo4YSP2y+ta2ne27FSUAmi4yqSLi1KWG0FFTyEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvwME7pb6qxAxVNpAV2WipxvQ7OdIDoBSHdfJ2tH9ooPafsofed+3UH/1LrOeck3J aBXYCsywaORVRa4SmfXwTVu63l+sMiTKVaHVAYRqM28rnRxxoSTocI3X4z7AY58jZQ rDaCm6DSGLAPF6rXWNJADelqzYzzkaKIljWq/pKQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.16 066/126] net: ieee802154: mcr20a: Fix lifs/sifs periods Date: Mon, 7 Feb 2022 12:06:37 +0100 Message-Id: <20220207103806.385321823@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Miquel Raynal commit d753c4004820a888ec007dd88b271fa9c3172c5c upstream. These periods are expressed in time units (microseconds) while 40 and 12 are the number of symbol durations these periods will last. We need to multiply them both with phy->symbol_duration in order to get these values in microseconds. Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver = driver") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-3-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/mcr20a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ieee802154/mcr20a.c +++ b/drivers/net/ieee802154/mcr20a.c @@ -976,8 +976,8 @@ static void mcr20a_hw_setup(struct mcr20 dev_dbg(printdev(lp), "%s\n", __func__); =20 phy->symbol_duration =3D 16; - phy->lifs_period =3D 40; - phy->sifs_period =3D 12; + phy->lifs_period =3D 40 * phy->symbol_duration; + phy->sifs_period =3D 12 * phy->symbol_duration; =20 hw->flags =3D IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT | From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EC4CC4332F for ; Mon, 7 Feb 2022 11:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388929AbiBGLpt (ORCPT ); Mon, 7 Feb 2022 06:45:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386091AbiBGLde (ORCPT ); Mon, 7 Feb 2022 06:33:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 655C0C043181; Mon, 7 Feb 2022 03:33:33 -0800 (PST) Received: from smtp.kernel.org (relay.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 ECF2460B20; Mon, 7 Feb 2022 11:33:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD72FC004E1; Mon, 7 Feb 2022 11:33:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233612; bh=0G4mg7JrTwEv++ARZxUJpNZ1oLOwrJ8UNREcb0ZZ/f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1fTyPHCa7ONPxbl19duLpzzj7yqyatT2z35ElYvoNxnwXrfYRZbeix9syhTFF/Tv 1AXJ77aLkCBAKZme5KqVKWXGsGPmVm7r7wb8wPFVH/u98GrR78Mav0FIhQzu/8lgLy Ka9n5JgvP6c+cqxL/eKBSJzB6pqE13nSRHDyKxMY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.16 067/126] net: ieee802154: ca8210: Stop leaking skbs Date: Mon, 7 Feb 2022 12:06:38 +0100 Message-Id: <20220207103806.426048917@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Miquel Raynal commit 621b24b09eb61c63f262da0c9c5f0e93348897e5 upstream. Upon error the ieee802154_xmit_complete() helper is not called. Only ieee802154_wake_queue() is called manually. We then leak the skb structure. Free the skb structure upon error before returning. Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-5-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/ca8210.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -1771,6 +1771,7 @@ static int ca8210_async_xmit_complete( status ); if (status !=3D MAC_TRANSACTION_OVERFLOW) { + dev_kfree_skb_any(priv->tx_skb); ieee802154_wake_queue(priv->hw); return 0; } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C0CAC43219 for ; Mon, 7 Feb 2022 11:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389009AbiBGLpx (ORCPT ); Mon, 7 Feb 2022 06:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386113AbiBGLdj (ORCPT ); Mon, 7 Feb 2022 06:33:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157DFC043181; Mon, 7 Feb 2022 03:33:38 -0800 (PST) Received: from smtp.kernel.org (relay.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 CFE27B80EBD; Mon, 7 Feb 2022 11:33:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34DD8C004E1; Mon, 7 Feb 2022 11:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233615; bh=56VyBmj+bRsCsk2a9Y/xPAhsRALIjjZvUHbCqINZASk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MvmIUapKyYuACRlhKOH9xvMDDUaXaS73G95dFiU6YUZORKE4rxbiOGo1luLjOFhhB glpG8qjrnblDpQ3ejMe+v/YDGAUEQL4xf755oMpw/tDfSIH6Lq3zr3cAGbWFqDDREA oPH2B8WPS6O8GxUAvqJdAXM2qqipS8q8twmlIDv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Sutter , Pablo Neira Ayuso Subject: [PATCH 5.16 068/126] netfilter: nft_reject_bridge: Fix for missing reply from prerouting Date: Mon, 7 Feb 2022 12:06:39 +0100 Message-Id: <20220207103806.467774635@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Phil Sutter commit aeac4554eb549037ff2f719200c0a9c1c25e7eaa upstream. Prior to commit fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff creation helpers"), nft_reject_bridge did not assign to nskb->dev before passing nskb on to br_forward(). The shared skbuff creation helpers introduced in above commit do which seems to confuse br_forward() as reject statements in prerouting hook won't emit a packet anymore. Fix this by simply passing NULL instead of 'dev' to the helpers - they use the pointer for just that assignment, nothing else. Fixes: fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff creation hel= pers") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/bridge/netfilter/nft_reject_bridge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/bridge/netfilter/nft_reject_bridge.c +++ b/net/bridge/netfilter/nft_reject_bridge.c @@ -49,7 +49,7 @@ static void nft_reject_br_send_v4_tcp_re { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v4_tcp_reset(net, oldskb, dev, hook); + nskb =3D nf_reject_skb_v4_tcp_reset(net, oldskb, NULL, hook); if (!nskb) return; =20 @@ -65,7 +65,7 @@ static void nft_reject_br_send_v4_unreac { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v4_unreach(net, oldskb, dev, hook, code); + nskb =3D nf_reject_skb_v4_unreach(net, oldskb, NULL, hook, code); if (!nskb) return; =20 @@ -81,7 +81,7 @@ static void nft_reject_br_send_v6_tcp_re { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v6_tcp_reset(net, oldskb, dev, hook); + nskb =3D nf_reject_skb_v6_tcp_reset(net, oldskb, NULL, hook); if (!nskb) return; =20 @@ -98,7 +98,7 @@ static void nft_reject_br_send_v6_unreac { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v6_unreach(net, oldskb, dev, hook, code); + nskb =3D nf_reject_skb_v6_unreach(net, oldskb, NULL, hook, code); if (!nskb) return; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FEFBC433EF for ; Mon, 7 Feb 2022 11:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389046AbiBGLpz (ORCPT ); Mon, 7 Feb 2022 06:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386114AbiBGLdk (ORCPT ); Mon, 7 Feb 2022 06:33:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BFEC043188; Mon, 7 Feb 2022 03:33:39 -0800 (PST) Received: from smtp.kernel.org (relay.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 70E7E60B20; Mon, 7 Feb 2022 11:33:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78667C004E1; Mon, 7 Feb 2022 11:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233618; bh=KWI6vSg9iJAy0sZw7ylDuPKoHk9LZwGvR0dTqATAMdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w4qt7SZjbl8vHaAcNHvLu/sZpw4gsGAh+WATpV8aonEq9m/DlWq7VP9L2B5Klper1 UUtgZoFYF2qoVcO3gC0JyUJ5CWwdxaByXgrpbB7tjmXOyi0s8ykEFaeVTezPO4CTWI lhdJvW8WAM2X2sR63Oqz4qqZXdUnFzlrmBN9Ovuw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.16 069/126] net: ieee802154: Return meaningful error codes from the netlink helpers Date: Mon, 7 Feb 2022 12:06:40 +0100 Message-Id: <20220207103806.498790321@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Miquel Raynal commit 79c37ca73a6e9a33f7b2b7783ba6af07a448c8a9 upstream. Returning -1 does not indicate anything useful. Use a standard and meaningful error code instead. Fixes: a26c5fd7622d ("nl802154: add support for security layer") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-6-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/ieee802154/nl802154.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -1441,7 +1441,7 @@ static int nl802154_send_key(struct sk_b =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1634,7 +1634,7 @@ static int nl802154_send_device(struct s =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1812,7 +1812,7 @@ static int nl802154_send_devkey(struct s =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1988,7 +1988,7 @@ static int nl802154_send_seclevel(struct =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0EC1C43217 for ; Mon, 7 Feb 2022 11:59:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389066AbiBGLp7 (ORCPT ); Mon, 7 Feb 2022 06:45:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386130AbiBGLdq (ORCPT ); Mon, 7 Feb 2022 06:33:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD7F5C043181; Mon, 7 Feb 2022 03:33:44 -0800 (PST) Received: from smtp.kernel.org (relay.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 53F9EB811BE; Mon, 7 Feb 2022 11:33:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0E3DC004E1; Mon, 7 Feb 2022 11:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233622; bh=T8REWhQ1Mtb0fl1o94ZEi9V/KsvtSXXcW/qQBovErYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9w7bmO64uvKfM8HyGpaDEOHltfS4tzySexlgteJ3qglW3mId6wCECDPfP4TIX9wI y1IESLRqEywzo1YsoO/ey7o+jjJ0DI+PLX/dU3GrCKhSNrJmZbIQxjxgYgD8ua1Wrg Lm9cIBPhgG+nmV4FVIQhPiUhir+s8cq2aWhj46pg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karsten Graul , Wen Gu , "David S. Miller" Subject: [PATCH 5.16 070/126] net/smc: Forward wakeup to smc socket waitqueue after fallback Date: Mon, 7 Feb 2022 12:06:41 +0100 Message-Id: <20220207103806.531120414@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Wen Gu commit 341adeec9adad0874f29a0a1af35638207352a39 upstream. When we replace TCP with SMC and a fallback occurs, there may be some socket waitqueue entries remaining in smc socket->wq, such as eppoll_entries inserted by userspace applications. After the fallback, data flows over TCP/IP and only clcsocket->wq will be woken up. Applications can't be notified by the entries which were inserted in smc socket->wq before fallback. So we need a mechanism to wake up smc socket->wq at the same time if some entries remaining in it. The current workaround is to transfer the entries from smc socket->wq to clcsock->wq during the fallback. But this may cause a crash like this: general protection fault, probably for non-canonical address 0xdead0000000= 00100: 0000 [#1] PREEMPT SMP PTI CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Tainted: G E 5.16.0+ #107 RIP: 0010:__wake_up_common+0x65/0x170 Call Trace: __wake_up_common_lock+0x7a/0xc0 sock_def_readable+0x3c/0x70 tcp_data_queue+0x4a7/0xc40 tcp_rcv_established+0x32f/0x660 ? sk_filter_trim_cap+0xcb/0x2e0 tcp_v4_do_rcv+0x10b/0x260 tcp_v4_rcv+0xd2a/0xde0 ip_protocol_deliver_rcu+0x3b/0x1d0 ip_local_deliver_finish+0x54/0x60 ip_local_deliver+0x6a/0x110 ? tcp_v4_early_demux+0xa2/0x140 ? tcp_v4_early_demux+0x10d/0x140 ip_sublist_rcv_finish+0x49/0x60 ip_sublist_rcv+0x19d/0x230 ip_list_rcv+0x13e/0x170 __netif_receive_skb_list_core+0x1c2/0x240 netif_receive_skb_list_internal+0x1e6/0x320 napi_complete_done+0x11d/0x190 mlx5e_napi_poll+0x163/0x6b0 [mlx5_core] __napi_poll+0x3c/0x1b0 net_rx_action+0x27c/0x300 __do_softirq+0x114/0x2d2 irq_exit_rcu+0xb4/0xe0 common_interrupt+0xba/0xe0 The crash is caused by privately transferring waitqueue entries from smc socket->wq to clcsock->wq. The owners of these entries, such as epoll, have no idea that the entries have been transferred to a different socket wait queue and still use original waitqueue spinlock (smc socket->wq.wait.lock) to make the entries operation exclusive, but it doesn't work. The operations to the entries, such as removing from the waitqueue (now is clcsock->wq after fallback), may cause a crash when clcsock waitqueue is being iterated over at the moment. This patch tries to fix this by no longer transferring wait queue entries privately, but introducing own implementations of clcsock's callback functions in fallback situation. The callback functions will forward the wakeup to smc socket->wq if clcsock->wq is actually woken up and smc socket->wq has remaining entries. Fixes: 2153bd1e3d3d ("net/smc: Transfer remaining wait queue entries during= fallback") Suggested-by: Karsten Graul Signed-off-by: Wen Gu Acked-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/smc/af_smc.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++--= ----- net/smc/smc.h | 20 +++++++- 2 files changed, 137 insertions(+), 16 deletions(-) --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -566,17 +566,115 @@ static void smc_stat_fallback(struct smc mutex_unlock(&net->smc.mutex_fback_rsn); } =20 +/* must be called under rcu read lock */ +static void smc_fback_wakeup_waitqueue(struct smc_sock *smc, void *key) +{ + struct socket_wq *wq; + __poll_t flags; + + wq =3D rcu_dereference(smc->sk.sk_wq); + if (!skwq_has_sleeper(wq)) + return; + + /* wake up smc sk->sk_wq */ + if (!key) { + /* sk_state_change */ + wake_up_interruptible_all(&wq->wait); + } else { + flags =3D key_to_poll(key); + if (flags & (EPOLLIN | EPOLLOUT)) + /* sk_data_ready or sk_write_space */ + wake_up_interruptible_sync_poll(&wq->wait, flags); + else if (flags & EPOLLERR) + /* sk_error_report */ + wake_up_interruptible_poll(&wq->wait, flags); + } +} + +static int smc_fback_mark_woken(wait_queue_entry_t *wait, + unsigned int mode, int sync, void *key) +{ + struct smc_mark_woken *mark =3D + container_of(wait, struct smc_mark_woken, wait_entry); + + mark->woken =3D true; + mark->key =3D key; + return 0; +} + +static void smc_fback_forward_wakeup(struct smc_sock *smc, struct sock *cl= csk, + void (*clcsock_callback)(struct sock *sk)) +{ + struct smc_mark_woken mark =3D { .woken =3D false }; + struct socket_wq *wq; + + init_waitqueue_func_entry(&mark.wait_entry, + smc_fback_mark_woken); + rcu_read_lock(); + wq =3D rcu_dereference(clcsk->sk_wq); + if (!wq) + goto out; + add_wait_queue(sk_sleep(clcsk), &mark.wait_entry); + clcsock_callback(clcsk); + remove_wait_queue(sk_sleep(clcsk), &mark.wait_entry); + + if (mark.woken) + smc_fback_wakeup_waitqueue(smc, mark.key); +out: + rcu_read_unlock(); +} + +static void smc_fback_state_change(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_state_change); +} + +static void smc_fback_data_ready(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_data_ready); +} + +static void smc_fback_write_space(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_write_space); +} + +static void smc_fback_error_report(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_error_report); +} + static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) { - wait_queue_head_t *smc_wait =3D sk_sleep(&smc->sk); - wait_queue_head_t *clc_wait; - unsigned long flags; + struct sock *clcsk; =20 mutex_lock(&smc->clcsock_release_lock); if (!smc->clcsock) { mutex_unlock(&smc->clcsock_release_lock); return -EBADF; } + clcsk =3D smc->clcsock->sk; + smc->use_fallback =3D true; smc->fallback_rsn =3D reason_code; smc_stat_fallback(smc); @@ -587,16 +685,22 @@ static int smc_switch_to_fallback(struct smc->clcsock->wq.fasync_list =3D smc->sk.sk_socket->wq.fasync_list; =20 - /* There may be some entries remaining in - * smc socket->wq, which should be removed - * to clcsocket->wq during the fallback. + /* There might be some wait entries remaining + * in smc sk->sk_wq and they should be woken up + * as clcsock's wait queue is woken up. */ - clc_wait =3D sk_sleep(smc->clcsock->sk); - spin_lock_irqsave(&smc_wait->lock, flags); - spin_lock_nested(&clc_wait->lock, SINGLE_DEPTH_NESTING); - list_splice_init(&smc_wait->head, &clc_wait->head); - spin_unlock(&clc_wait->lock); - spin_unlock_irqrestore(&smc_wait->lock, flags); + smc->clcsk_state_change =3D clcsk->sk_state_change; + smc->clcsk_data_ready =3D clcsk->sk_data_ready; + smc->clcsk_write_space =3D clcsk->sk_write_space; + smc->clcsk_error_report =3D clcsk->sk_error_report; + + clcsk->sk_state_change =3D smc_fback_state_change; + clcsk->sk_data_ready =3D smc_fback_data_ready; + clcsk->sk_write_space =3D smc_fback_write_space; + clcsk->sk_error_report =3D smc_fback_error_report; + + smc->clcsock->sk->sk_user_data =3D + (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); } mutex_unlock(&smc->clcsock_release_lock); return 0; @@ -2111,10 +2215,9 @@ out: =20 static void smc_clcsock_data_ready(struct sock *listen_clcsock) { - struct smc_sock *lsmc; + struct smc_sock *lsmc =3D + smc_clcsock_user_data(listen_clcsock); =20 - lsmc =3D (struct smc_sock *) - ((uintptr_t)listen_clcsock->sk_user_data & ~SK_USER_DATA_NOCOPY); if (!lsmc) return; lsmc->clcsk_data_ready(listen_clcsock); --- a/net/smc/smc.h +++ b/net/smc/smc.h @@ -139,6 +139,12 @@ enum smc_urg_state { SMC_URG_READ =3D 3, /* data was already read */ }; =20 +struct smc_mark_woken { + bool woken; + void *key; + wait_queue_entry_t wait_entry; +}; + struct smc_connection { struct rb_node alert_node; struct smc_link_group *lgr; /* link group of connection */ @@ -227,8 +233,14 @@ struct smc_connection { struct smc_sock { /* smc sock container */ struct sock sk; struct socket *clcsock; /* internal tcp socket */ + void (*clcsk_state_change)(struct sock *sk); + /* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk); - /* original data_ready fct. **/ + /* original data_ready fct. */ + void (*clcsk_write_space)(struct sock *sk); + /* original write_space fct. */ + void (*clcsk_error_report)(struct sock *sk); + /* original error_report fct. */ struct smc_connection conn; /* smc connection */ struct smc_sock *listen_smc; /* listen parent */ struct work_struct connect_work; /* handle non-blocking connect*/ @@ -263,6 +275,12 @@ static inline struct smc_sock *smc_sk(co return (struct smc_sock *)sk; } =20 +static inline struct smc_sock *smc_clcsock_user_data(struct sock *clcsk) +{ + return (struct smc_sock *) + ((uintptr_t)clcsk->sk_user_data & ~SK_USER_DATA_NOCOPY); +} + extern struct workqueue_struct *smc_hs_wq; /* wq for handshake work */ extern struct workqueue_struct *smc_close_wq; /* wq for close work */ =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F1CCC4167D for ; Mon, 7 Feb 2022 11:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389085AbiBGLqD (ORCPT ); Mon, 7 Feb 2022 06:46:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386137AbiBGLdq (ORCPT ); Mon, 7 Feb 2022 06:33:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F52C043181; Mon, 7 Feb 2022 03:33:46 -0800 (PST) Received: from smtp.kernel.org (relay.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 F09D560180; Mon, 7 Feb 2022 11:33:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4CC1C004E1; Mon, 7 Feb 2022 11:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233625; bh=Cufcp3rMZnSu8TxXUO/67GgkkFgPiEJAJLQFh2QPqxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q0KJG2hfMnwymoXPUcrY0qiviILp7m2LDS0tBZnAjnjB/q5CCdqmj9j1AmxihxKVb 8igWSx6bDNEworP8PSUTPqAoJyCW/L068w8KKSN0f6/5iKEfBtVfz8Jx/slkz8mBrP Sf9ilVUI6XfWe6y2Ef7RzCmtDryop2JxQVJV+HHE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Yuji Ishikawa , Nobuhiro Iwamatsu , "David S. Miller" Subject: [PATCH 5.16 071/126] net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request. Date: Mon, 7 Feb 2022 12:06:42 +0100 Message-Id: <20220207103806.567514812@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Yuji Ishikawa commit 928d6fe996f69330ded6b887baf4534c5fac7988 upstream. Variable clk_sel_val is not initialized in the default case of the first sw= itch statement. In that case, the function should return immediately without any changes to= the hardware. Reported-by: kernel test robot Reported-by: Dan Carpenter Fixes: b38dd98ff8d0 ("net: stmmac: Add Toshiba Visconti SoCs glue driver") Signed-off-by: Yuji Ishikawa Reviewed-by: Nobuhiro Iwamatsu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c @@ -49,13 +49,15 @@ struct visconti_eth { void __iomem *reg; u32 phy_intf_sel; struct clk *phy_ref_clk; + struct device *dev; spinlock_t lock; /* lock to protect register update */ }; =20 static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed) { struct visconti_eth *dwmac =3D priv; - unsigned int val, clk_sel_val; + struct net_device *netdev =3D dev_get_drvdata(dwmac->dev); + unsigned int val, clk_sel_val =3D 0; unsigned long flags; =20 spin_lock_irqsave(&dwmac->lock, flags); @@ -85,7 +87,9 @@ static void visconti_eth_fix_mac_speed(v break; default: /* No bit control */ - break; + netdev_err(netdev, "Unsupported speed request (%d)", speed); + spin_unlock_irqrestore(&dwmac->lock, flags); + return; } =20 writel(val, dwmac->reg + MAC_CTRL_REG); @@ -229,6 +233,7 @@ static int visconti_eth_dwmac_probe(stru =20 spin_lock_init(&dwmac->lock); dwmac->reg =3D stmmac_res.addr; + dwmac->dev =3D &pdev->dev; plat_dat->bsp_priv =3D dwmac; plat_dat->fix_mac_speed =3D visconti_eth_fix_mac_speed; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA009C4707A for ; Mon, 7 Feb 2022 11:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389101AbiBGLqF (ORCPT ); Mon, 7 Feb 2022 06:46:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386178AbiBGLdv (ORCPT ); Mon, 7 Feb 2022 06:33:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9803C043181; Mon, 7 Feb 2022 03:33:50 -0800 (PST) Received: from smtp.kernel.org (relay.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 8484CB80EBD; Mon, 7 Feb 2022 11:33:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04032C004E1; Mon, 7 Feb 2022 11:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233628; bh=o1t4E6p5M9wQ+MHWk250rjIPmobh5t6vtkwJdpEGO38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oo82QG5XgnEcm6ioYhn6Z9qClGtujVqmQs0JIAq1mlxD2JS1UG5jCLA+2uiRgim5l TlkOQBUu11Cnz6svqUtOCH4jCeOJgK03UX/7gojPTUscI9NbfElznOH0lDjhEeVkqV u+Ne7iCNCkppRUkmFAkQ8kGQd7qGprYA+14uakAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jisheng Zhang , "David S. Miller" Subject: [PATCH 5.16 072/126] net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() Date: Mon, 7 Feb 2022 12:06:43 +0100 Message-Id: <20220207103806.598653654@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Jisheng Zhang commit 6449520391dfc3d2cef134f11a91251a054ff7d0 upstream. There are two issues with runtime pm handling in stmmac_dvr_remove(): 1. the mac is runtime suspended before stopping dma and rx/tx. We need to ensure the device is properly resumed back. 2. the stmmaceth clk enable/disable isn't balanced in both exit and error handling code path. Take the exit code path for example, when we unbind the driver or rmmod the driver module, the mac is runtime suspended as said above, so the stmmaceth clk is disabled, but stmmac_dvr_remove() stmmac_remove_config_dt() clk_disable_unprepare() CCF will complain this time. The error handling code path suffers from the similar situtaion. Here are kernel warnings in error handling code path on Allwinner D1 platform: [ 1.604695] ------------[ cut here ]------------ [ 1.609328] bus-emac already disabled [ 1.613015] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:952 clk_core_di= sable+0xcc/0xec [ 1.621039] CPU: 0 PID: 38 Comm: kworker/u2:1 Not tainted 5.14.0-rc4#1 [ 1.627653] Hardware name: Allwinner D1 NeZha (DT) [ 1.632443] Workqueue: events_unbound deferred_probe_work_func [ 1.638286] epc : clk_core_disable+0xcc/0xec [ 1.642561] ra : clk_core_disable+0xcc/0xec [ 1.646835] epc : ffffffff8023c2ec ra : ffffffff8023c2ec sp : ffffffd004= 11bb10 [ 1.654054] gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : ffffffff80= ed6a6f [ 1.661272] t1 : ffffffff80ed6a60 t2 : 0000000000000000 s0 : ffffffe001= 509e00 [ 1.668489] s1 : 0000000000000001 a0 : 0000000000000019 a1 : ffffffff80= e80bd8 [ 1.675707] a2 : 00000000ffffefff a3 : 00000000000000f4 a4 : 0000000000= 000002 [ 1.682924] a5 : 0000000000000001 a6 : 0000000000000030 a7 : 0000000002= 8f5c29 [ 1.690141] s2 : 0000000000000800 s3 : ffffffe001375000 s4 : ffffffe01f= df7a80 [ 1.697358] s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffff= ffffff [ 1.704577] s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001= b80000 [ 1.711794] s11: ffffffe001b80760 t3 : 0000000000000062 t4 : ffffffffff= ffffff [ 1.719012] t5 : ffffffff80e0f6d8 t6 : ffffffd00411b8f0 [ 1.724321] status: 8000000201800100 badaddr: 0000000000000000 cause: 00= 00000000000003 [ 1.732233] [] clk_core_disable+0xcc/0xec [ 1.737810] [] clk_disable+0x38/0x78 [ 1.742956] [] worker_thread+0x1a8/0x4d8 [ 1.748451] [] stmmac_remove_config_dt+0x1c/0x4c [ 1.754646] [] sun8i_dwmac_probe+0x378/0x82c [ 1.760484] [] worker_thread+0x1a8/0x4d8 [ 1.765975] [] platform_probe+0x64/0xf0 [ 1.771382] [] really_probe.part.0+0x8c/0x30c [ 1.777305] [] __driver_probe_device+0xa0/0x148 [ 1.783402] [] driver_probe_device+0x38/0x138 [ 1.789324] [] __device_attach_driver+0xd0/0x170 [ 1.795508] [] __driver_attach_async_helper+0xbc/0xc0 [ 1.802125] [] bus_for_each_drv+0x68/0xb4 [ 1.807701] [] __device_attach+0xd8/0x184 [ 1.813277] [] bus_probe_device+0x98/0xbc [ 1.818852] [] deferred_probe_work_func+0x90/0xd4 [ 1.825122] [] process_one_work+0x1e4/0x390 [ 1.830872] [] worker_thread+0x31c/0x4d8 [ 1.836362] [] kthreadd+0x94/0x188 [ 1.841335] [] kthreadd+0x94/0x188 [ 1.846304] [] process_one_work+0x38c/0x390 [ 1.852054] [] kthread+0x124/0x160 [ 1.857021] [] set_kthread_struct+0x5c/0x60 [ 1.862770] [] ret_from_syscall_rejected+0x8/0xc [ 1.868956] ---[ end trace 8d5c6046255f84a0 ]--- [ 1.873675] ------------[ cut here ]------------ [ 1.878366] bus-emac already unprepared [ 1.882378] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:810 clk_core_un= prepare+0xe4/0x168 [ 1.890673] CPU: 0 PID: 38 Comm: kworker/u2:1 Tainted: G W 5.14.0= -rc4 #1 [ 1.898674] Hardware name: Allwinner D1 NeZha (DT) [ 1.903464] Workqueue: events_unbound deferred_probe_work_func [ 1.909305] epc : clk_core_unprepare+0xe4/0x168 [ 1.913840] ra : clk_core_unprepare+0xe4/0x168 [ 1.918375] epc : ffffffff8023d6cc ra : ffffffff8023d6cc sp : ffffffd004= 11bb10 [ 1.925593] gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : 0000000000= 000002 [ 1.932811] t1 : ffffffe01f743be0 t2 : 0000000000000040 s0 : ffffffe001= 509e00 [ 1.940029] s1 : 0000000000000001 a0 : 000000000000001b a1 : ffffffe001= 43a800 [ 1.947246] a2 : 0000000000000000 a3 : 00000000000000f4 a4 : 0000000000= 000001 [ 1.954463] a5 : 0000000000000000 a6 : 0000000005fce2a5 a7 : 0000000000= 000001 [ 1.961680] s2 : 0000000000000800 s3 : ffffffff80afeb90 s4 : ffffffe01f= df7a80 [ 1.968898] s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffff= ffffff [ 1.976115] s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001= b80000 [ 1.983333] s11: ffffffe001b80760 t3 : ffffffff80b39120 t4 : 0000000000= 000001 [ 1.990550] t5 : 0000000000000000 t6 : ffffffe001600002 [ 1.995859] status: 8000000201800120 badaddr: 0000000000000000 cause: 00= 00000000000003 [ 2.003771] [] clk_core_unprepare+0xe4/0x168 [ 2.009609] [] clk_unprepare+0x24/0x3c [ 2.014929] [] stmmac_remove_config_dt+0x24/0x4c [ 2.021125] [] sun8i_dwmac_probe+0x378/0x82c [ 2.026965] [] worker_thread+0x1a8/0x4d8 [ 2.032463] [] platform_probe+0x64/0xf0 [ 2.037871] [] really_probe.part.0+0x8c/0x30c [ 2.043795] [] __driver_probe_device+0xa0/0x148 [ 2.049892] [] driver_probe_device+0x38/0x138 [ 2.055815] [] __device_attach_driver+0xd0/0x170 [ 2.061999] [] __driver_attach_async_helper+0xbc/0xc0 [ 2.068616] [] bus_for_each_drv+0x68/0xb4 [ 2.074193] [] __device_attach+0xd8/0x184 [ 2.079769] [] bus_probe_device+0x98/0xbc [ 2.085345] [] deferred_probe_work_func+0x90/0xd4 [ 2.091616] [] process_one_work+0x1e4/0x390 [ 2.097367] [] worker_thread+0x31c/0x4d8 [ 2.102858] [] kthreadd+0x94/0x188 [ 2.107830] [] kthreadd+0x94/0x188 [ 2.112800] [] process_one_work+0x38c/0x390 [ 2.118551] [] kthread+0x124/0x160 [ 2.123520] [] set_kthread_struct+0x5c/0x60 [ 2.129268] [] ret_from_syscall_rejected+0x8/0xc [ 2.135455] ---[ end trace 8d5c6046255f84a1 ]--- Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver") Signed-off-by: Jisheng Zhang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7137,6 +7137,10 @@ int stmmac_dvr_remove(struct device *dev =20 netdev_info(priv->dev, "%s: removing driver", __func__); =20 + pm_runtime_get_sync(dev); + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + stmmac_stop_all_dma(priv); stmmac_mac_set(priv, priv->ioaddr, false); netif_carrier_off(ndev); @@ -7155,8 +7159,6 @@ int stmmac_dvr_remove(struct device *dev if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); - pm_runtime_put(dev); - pm_runtime_disable(dev); if (priv->hw->pcs !=3D STMMAC_PCS_TBI && priv->hw->pcs !=3D STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D61FBC433EF for ; Mon, 7 Feb 2022 11:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389115AbiBGLqK (ORCPT ); Mon, 7 Feb 2022 06:46:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386194AbiBGLdz (ORCPT ); Mon, 7 Feb 2022 06:33:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02AA9C043181; Mon, 7 Feb 2022 03:33:53 -0800 (PST) Received: from smtp.kernel.org (relay.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 B36C1B811BD; Mon, 7 Feb 2022 11:33:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D765BC004E1; Mon, 7 Feb 2022 11:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233631; bh=a/ZBpKbDDQqi+MpGt1DElsti8XZTAvY6yZ+reuerCY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1e9wP5hQXHZbKyQJuQARp7gBbJ9zkcCDm4iFfSTODniHj6bwn4kllJFstheV/8nYQ rk+dnp8wBpOyJ8pvaPqLKKIZda2/K9Qj9vsOXJotdroEa5TcgFOy93V7hH9qehpO5r PK9zUZ7AsZCRrcWRGE9DxmQ6uvMka2mXBNaWcg4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lior Nahmanson , Raed Salem , Antoine Tenart , Jakub Kicinski Subject: [PATCH 5.16 073/126] net: macsec: Fix offload support for NETDEV_UNREGISTER event Date: Mon, 7 Feb 2022 12:06:44 +0100 Message-Id: <20220207103806.631360833@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Lior Nahmanson commit 9cef24c8b76c1f6effe499d2f131807c90f7ce9a upstream. Current macsec netdev notify handler handles NETDEV_UNREGISTER event by releasing relevant SW resources only, this causes resources leak in case of macsec HW offload, as the underlay driver was not notified to clean it's macsec offload resources. Fix by calling the underlay driver to clean it's relevant resources by moving offload handling from macsec_dellink() to macsec_common_dellink() when handling NETDEV_UNREGISTER event. Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure") Signed-off-by: Lior Nahmanson Reviewed-by: Raed Salem Signed-off-by: Raed Salem Reviewed-by: Antoine Tenart Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvi= dia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/macsec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct struct macsec_dev *macsec =3D macsec_priv(dev); struct net_device *real_dev =3D macsec->real_dev; =20 + /* If h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops =3D macsec_get_ops(netdev_priv(dev), &ctx); + if (ops) { + ctx.secy =3D &macsec->secy; + macsec_offload(ops->mdo_del_secy, &ctx); + } + } + unregister_netdevice_queue(dev, head); list_del_rcu(&macsec->secys); macsec_del_dev(macsec); @@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_de struct net_device *real_dev =3D macsec->real_dev; struct macsec_rxh_data *rxd =3D macsec_data_rtnl(real_dev); =20 - /* If h/w offloading is available, propagate to the device */ - if (macsec_is_offloaded(macsec)) { - const struct macsec_ops *ops; - struct macsec_context ctx; - - ops =3D macsec_get_ops(netdev_priv(dev), &ctx); - if (ops) { - ctx.secy =3D &macsec->secy; - macsec_offload(ops->mdo_del_secy, &ctx); - } - } - macsec_common_dellink(dev, head); =20 if (list_empty(&rxd->secys)) { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 257A1C433F5 for ; Mon, 7 Feb 2022 11:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389146AbiBGLqR (ORCPT ); Mon, 7 Feb 2022 06:46:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386222AbiBGLeA (ORCPT ); Mon, 7 Feb 2022 06:34:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3975AC043181; Mon, 7 Feb 2022 03:34:00 -0800 (PST) Received: from smtp.kernel.org (relay.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 EC2E9B80EBD; Mon, 7 Feb 2022 11:33:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29714C004E1; Mon, 7 Feb 2022 11:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233637; bh=kXZdNLArO7qlWpDU7iG2egpXkmF2NNZxXC7x7oXDF0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mYSgyyJiIUw42U6hSoh4I+xPe3pKQISWP4U3dzeVa5fmpl/KYawYS3xuJtqQXEpHo TSjofIxn0pxAqkvnmpM+BYlWFFWV3NuZbmhL2l/3lYXvIflMPBd+YZdXEcXFbomZYi ZjHiJRaDPvhkUtfv96ex2d+5W9t6fVnbIYRuUOiI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lior Nahmanson , Raed Salem , Jakub Kicinski Subject: [PATCH 5.16 074/126] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Date: Mon, 7 Feb 2022 12:06:45 +0100 Message-Id: <20220207103806.662170192@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Lior Nahmanson commit d0cfa548dbde354de986911d3913897b5448faad upstream. When setting Tx sci explicit, the Rx side is expected to use this sci and not recalculate it from the packet.However, in case of Tx sci is explicit and send_sci is off, the receiver is wrongly recalculate the sci from the source MAC address which most likely be different than the explicit sci. Fix by preventing such configuration when macsec newlink is established and return EINVAL error code on such cases. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Lior Nahmanson Reviewed-by: Raed Salem Signed-off-by: Raed Salem Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvi= dia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/macsec.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -4018,6 +4018,15 @@ static int macsec_newlink(struct net *ne !macsec_check_offload(macsec->offload, macsec)) return -EOPNOTSUPP; =20 + /* send_sci must be set to true when transmit sci explicitly is set */ + if ((data && data[IFLA_MACSEC_SCI]) && + (data && data[IFLA_MACSEC_INC_SCI])) { + u8 send_sci =3D !!nla_get_u8(data[IFLA_MACSEC_INC_SCI]); + + if (!send_sci) + return -EINVAL; + } + if (data && data[IFLA_MACSEC_ICV_LEN]) icv_len =3D nla_get_u8(data[IFLA_MACSEC_ICV_LEN]); mtu =3D real_dev->mtu - icv_len - macsec_extra_len(true); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB30BC4332F for ; Mon, 7 Feb 2022 11:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389159AbiBGLqY (ORCPT ); Mon, 7 Feb 2022 06:46:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386230AbiBGLeC (ORCPT ); Mon, 7 Feb 2022 06:34:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1EC2C043181; Mon, 7 Feb 2022 03:34:01 -0800 (PST) Received: from smtp.kernel.org (relay.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 8B3EB60A69; Mon, 7 Feb 2022 11:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C10C004E1; Mon, 7 Feb 2022 11:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233641; bh=EtbOZiAqtWbT4t6/B/vsUfgMMXkYyFMWs8SFTUx3QU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iLON1TxALfT8aPijy2aukgpFGhgLHZi8m8QF3IHPM7lpJr46NSw5AQucWyd0Q8s9P +DHqqj1kuwC5BRYohyUtZizOAAln428lbYC5gz5d99N39rEy/ZKXlziHlRvAZG/XYJ OxlyMHTVytNb0Uho/UdVypJjG7skXTtUalrK27Y4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Camel Guo , Jakub Kicinski Subject: [PATCH 5.16 075/126] net: stmmac: dump gmac4 DMA registers correctly Date: Mon, 7 Feb 2022 12:06:46 +0100 Message-Id: <20220207103806.694567104@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Camel Guo commit 7af037c39b600bac2c716dd1228e8ddbe149573f upstream. Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump gmac4 DMA registers correctly, this commit checks if a net_device has gmac4 and uses different logic to dump its DMA registers. This fixes the following KASAN warning, which can normally be triggered by a command similar like "ethtool -d eth0": BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30 Write of size 4 at addr ffffffc010177100 by task ethtool/1839 kasan_report+0x200/0x21c __asan_report_store4_noabort+0x34/0x60 dwmac4_dump_dma_regs+0x6d4/0xb30 stmmac_ethtool_gregs+0x110/0x204 ethtool_get_regs+0x200/0x4b0 dev_ethtool+0x1dac/0x3800 dev_ioctl+0x7c0/0xb50 sock_ioctl+0x298/0x6c4 ... Fixes: fbf68229ffe7 ("net: stmmac: unify registers dumps methods") Signed-off-by: Camel Guo Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 19 ++++++++++++++= +++-- 2 files changed, 18 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h @@ -150,6 +150,7 @@ =20 #define NUM_DWMAC100_DMA_REGS 9 #define NUM_DWMAC1000_DMA_REGS 23 +#define NUM_DWMAC4_DMA_REGS 27 =20 void dwmac_enable_dma_transmission(void __iomem *ioaddr); void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan, bool rx, bool tx= ); --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -21,10 +21,18 @@ #include "dwxgmac2.h" =20 #define REG_SPACE_SIZE 0x1060 +#define GMAC4_REG_SPACE_SIZE 0x116C #define MAC100_ETHTOOL_NAME "st_mac100" #define GMAC_ETHTOOL_NAME "st_gmac" #define XGMAC_ETHTOOL_NAME "st_xgmac" =20 +/* Same as DMA_CHAN_BASE_ADDR defined in dwmac4_dma.h + * + * It is here because dwmac_dma.h and dwmac4_dam.h can not be included at = the + * same time due to the conflicting macro names. + */ +#define GMAC4_DMA_CHAN_BASE_ADDR 0x00001100 + #define ETHTOOL_DMA_OFFSET 55 =20 struct stmmac_stats { @@ -435,6 +443,8 @@ static int stmmac_ethtool_get_regs_len(s =20 if (priv->plat->has_xgmac) return XGMAC_REGSIZE * 4; + else if (priv->plat->has_gmac4) + return GMAC4_REG_SPACE_SIZE; return REG_SPACE_SIZE; } =20 @@ -447,8 +457,13 @@ static void stmmac_ethtool_gregs(struct stmmac_dump_mac_regs(priv, priv->hw, reg_space); stmmac_dump_dma_regs(priv, priv->ioaddr, reg_space); =20 - if (!priv->plat->has_xgmac) { - /* Copy DMA registers to where ethtool expects them */ + /* Copy DMA registers to where ethtool expects them */ + if (priv->plat->has_gmac4) { + /* GMAC4 dumps its DMA registers at its DMA_CHAN_BASE_ADDR */ + memcpy(®_space[ETHTOOL_DMA_OFFSET], + ®_space[GMAC4_DMA_CHAN_BASE_ADDR / 4], + NUM_DWMAC4_DMA_REGS * 4); + } else if (!priv->plat->has_xgmac) { memcpy(®_space[ETHTOOL_DMA_OFFSET], ®_space[DMA_BUS_MODE / 4], NUM_DWMAC1000_DMA_REGS * 4); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD2D5C43219 for ; Mon, 7 Feb 2022 11:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234002AbiBGLqg (ORCPT ); Mon, 7 Feb 2022 06:46:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386249AbiBGLeI (ORCPT ); Mon, 7 Feb 2022 06:34:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F5DC043181; Mon, 7 Feb 2022 03:34:06 -0800 (PST) Received: from smtp.kernel.org (relay.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 642D6B80EBD; Mon, 7 Feb 2022 11:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EFA6C004E1; Mon, 7 Feb 2022 11:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233644; bh=uDfKvlFIo9V9/gtSAHiZdG/PPB0gTl8EG/gwzeM/smU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaRPBxrQ9pNob+pedp846bUTHPTC/XBmVb6jGXg93UjfBnDVxA5UuSd4ONCU1cvZc 5To4dZgkjDr0HqOApByxgIqzxaSMHYWvvhi538mCTdnSvv8fYsCSqaHBAOUdGk+dN/ 3fvZHsL6aQdxeJor7tQXtdJpsS3CqYzYTJUjdL+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com, Daniel Borkmann , Eric Dumazet , Roopa Prabhu , David Ahern , Jakub Kicinski Subject: [PATCH 5.16 076/126] net, neigh: Do not trigger immediate probes on NUD_FAILED from neigh_managed_work Date: Mon, 7 Feb 2022 12:06:47 +0100 Message-Id: <20220207103806.731818986@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 4a81f6da9cb2d1ef911131a6fd8bd15cb61fc772 upstream. syzkaller was able to trigger a deadlock for NTF_MANAGED entries [0]: kworker/0:16/14617 is trying to acquire lock: ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: ___neigh_create+0x9e1/0x29= 90 net/core/neighbour.c:652 [...] but task is already holding lock: ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: neigh_managed_work+0x35/0x= 250 net/core/neighbour.c:1572 The neighbor entry turned to NUD_FAILED state, where __neigh_event_send() triggered an immediate probe as per commit cd28ca0a3dd1 ("neigh: reduce arp latency") via neigh_probe() given table lock was held. One option to fix this situation is to defer the neigh_probe() back to the neigh_timer_handler() similarly as pre cd28ca0a3dd1. For the case of NTF_MANAGED, this deferral is acceptable given this only happens on actual failure state and regular / expected state is NUD_VALID with the entry already present. The fix adds a parameter to __neigh_event_send() in order to communicate whether immediate probe is allowed or disallowed. Existing call-sites of neigh_event_send() default as-is to immediate probe. However, the neigh_managed_work() disables it via use of neigh_event_send_probe(). [0] __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_deadlock_bug kernel/locking/lockdep.c:2956 [inline] check_deadlock kernel/locking/lockdep.c:2999 [inline] validate_chain kernel/locking/lockdep.c:3788 [inline] __lock_acquire.cold+0x149/0x3ab kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5639 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604 __raw_write_lock_bh include/linux/rwlock_api_smp.h:202 [inline] _raw_write_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:334 ___neigh_create+0x9e1/0x2990 net/core/neighbour.c:652 ip6_finish_output2+0x1070/0x14f0 net/ipv6/ip6_output.c:123 __ip6_finish_output net/ipv6/ip6_output.c:191 [inline] __ip6_finish_output+0x61e/0xe90 net/ipv6/ip6_output.c:170 ip6_finish_output+0x32/0x200 net/ipv6/ip6_output.c:201 NF_HOOK_COND include/linux/netfilter.h:296 [inline] ip6_output+0x1e4/0x530 net/ipv6/ip6_output.c:224 dst_output include/net/dst.h:451 [inline] NF_HOOK include/linux/netfilter.h:307 [inline] ndisc_send_skb+0xa99/0x17f0 net/ipv6/ndisc.c:508 ndisc_send_ns+0x3a9/0x840 net/ipv6/ndisc.c:650 ndisc_solicit+0x2cd/0x4f0 net/ipv6/ndisc.c:742 neigh_probe+0xc2/0x110 net/core/neighbour.c:1040 __neigh_event_send+0x37d/0x1570 net/core/neighbour.c:1201 neigh_event_send include/net/neighbour.h:470 [inline] neigh_managed_work+0x162/0x250 net/core/neighbour.c:1574 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307 worker_thread+0x657/0x1110 kernel/workqueue.c:2454 kthread+0x2e9/0x3a0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Fixes: 7482e3841d52 ("net, neigh: Add NTF_MANAGED flag for managed neighbor= entries") Reported-by: syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com Signed-off-by: Daniel Borkmann Cc: Eric Dumazet Cc: Roopa Prabhu Tested-by: syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com Reviewed-by: David Ahern Link: https://lore.kernel.org/r/20220201193942.5055-1-daniel@iogearbox.net Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- include/net/neighbour.h | 18 +++++++++++++----- net/core/neighbour.c | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -336,7 +336,8 @@ static inline struct neighbour *neigh_cr return __neigh_create(tbl, pkey, dev, true); } void neigh_destroy(struct neighbour *neigh); -int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb); +int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb, + const bool immediate_ok); int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, u32 fl= ags, u32 nlmsg_pid); void __neigh_set_probe_once(struct neighbour *neigh); @@ -446,17 +447,24 @@ static inline struct neighbour * neigh_c =20 #define neigh_hold(n) refcount_inc(&(n)->refcnt) =20 -static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff= *skb) +static __always_inline int neigh_event_send_probe(struct neighbour *neigh, + struct sk_buff *skb, + const bool immediate_ok) { unsigned long now =3D jiffies; -=09 + if (READ_ONCE(neigh->used) !=3D now) WRITE_ONCE(neigh->used, now); - if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) - return __neigh_event_send(neigh, skb); + if (!(neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE))) + return __neigh_event_send(neigh, skb, immediate_ok); return 0; } =20 +static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff= *skb) +{ + return neigh_event_send_probe(neigh, skb, true); +} + #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb) { --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1133,7 +1133,8 @@ out: neigh_release(neigh); } =20 -int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) +int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb, + const bool immediate_ok) { int rc; bool immediate_probe =3D false; @@ -1154,12 +1155,17 @@ int __neigh_event_send(struct neighbour atomic_set(&neigh->probes, NEIGH_VAR(neigh->parms, UCAST_PROBES)); neigh_del_timer(neigh); - neigh->nud_state =3D NUD_INCOMPLETE; + neigh->nud_state =3D NUD_INCOMPLETE; neigh->updated =3D now; - next =3D now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME), - HZ/100); + if (!immediate_ok) { + next =3D now + 1; + } else { + immediate_probe =3D true; + next =3D now + max(NEIGH_VAR(neigh->parms, + RETRANS_TIME), + HZ / 100); + } neigh_add_timer(neigh, next); - immediate_probe =3D true; } else { neigh->nud_state =3D NUD_FAILED; neigh->updated =3D jiffies; @@ -1571,7 +1577,7 @@ static void neigh_managed_work(struct wo =20 write_lock_bh(&tbl->lock); list_for_each_entry(neigh, &tbl->managed_list, managed_list) - neigh_event_send(neigh, NULL); + neigh_event_send_probe(neigh, NULL, false); queue_delayed_work(system_power_efficient_wq, &tbl->managed_work, NEIGH_VAR(&tbl->parms, DELAY_PROBE_TIME)); write_unlock_bh(&tbl->lock); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D34FFC43217 for ; Mon, 7 Feb 2022 11:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239388AbiBGLqn (ORCPT ); Mon, 7 Feb 2022 06:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386252AbiBGLeJ (ORCPT ); Mon, 7 Feb 2022 06:34:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4990DC043188; Mon, 7 Feb 2022 03:34:08 -0800 (PST) Received: from smtp.kernel.org (relay.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 DCA4260A69; Mon, 7 Feb 2022 11:34:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D135AC004E1; Mon, 7 Feb 2022 11:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233647; bh=l41qFpCCnF7zcx7W10sjE/r96IdLrzfLg4iNeaeKeis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CqBo7iVC5N34b3DaUt11dA6GZQWZfewM7/vnokEVZZl4bIwfW530IRhGTR5XtfmM8 h/ykPLqmQk5Nv+jcUUBNK7qWTdXWWt9tRQvkzqcuK0U6E2Q8IV5ABt5l9xC/yY/7I0 K4kI8PwnCSMxM1DK0R/lfRbIBZAkhRFO5JHfBRV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yannick Vignon , "Russell King (Oracle)" , Jakub Kicinski Subject: [PATCH 5.16 077/126] net: stmmac: ensure PTP time register reads are consistent Date: Mon, 7 Feb 2022 12:06:48 +0100 Message-Id: <20220207103806.773594103@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Yannick Vignon commit 80d4609008e6d696a279e39ae7458c916fcd44c1 upstream. Even if protected from preemption and interrupts, a small time window remains when the 2 register reads could return inconsistent values, each time the "seconds" register changes. This could lead to an about 1-second error in the reported time. Add logic to ensure the "seconds" and "nanoseconds" values are consistent. Fixes: 92ba6888510c ("stmmac: add the support for PTP hw clock driver") Signed-off-by: Yannick Vignon Reviewed-by: Russell King (Oracle) Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.= nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 17 +++++++++++--= ---- 1 file changed, 11 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -145,15 +145,20 @@ static int adjust_systime(void __iomem * =20 static void get_systime(void __iomem *ioaddr, u64 *systime) { - u64 ns; + u64 ns, sec0, sec1; =20 - /* Get the TSSS value */ - ns =3D readl(ioaddr + PTP_STNSR); - /* Get the TSS and convert sec time value to nanosecond */ - ns +=3D readl(ioaddr + PTP_STSR) * 1000000000ULL; + /* Get the TSS value */ + sec1 =3D readl_relaxed(ioaddr + PTP_STSR); + do { + sec0 =3D sec1; + /* Get the TSSS value */ + ns =3D readl_relaxed(ioaddr + PTP_STNSR); + /* Get the TSS value */ + sec1 =3D readl_relaxed(ioaddr + PTP_STSR); + } while (sec0 !=3D sec1); =20 if (systime) - *systime =3D ns; + *systime =3D ns + (sec1 * 1000000000ULL); } =20 static void get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C6BFC4332F for ; Mon, 7 Feb 2022 12:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381692AbiBGLq6 (ORCPT ); Mon, 7 Feb 2022 06:46:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386260AbiBGLeN (ORCPT ); Mon, 7 Feb 2022 06:34:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 096F0C043181; Mon, 7 Feb 2022 03:34:13 -0800 (PST) Received: from smtp.kernel.org (relay.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 BC6C7B8102E; Mon, 7 Feb 2022 11:34:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3913C004E1; Mon, 7 Feb 2022 11:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233650; bh=sRT0SUtVKDDdJobDZ2zVLyItWfN68H3/PvgmN5nr8u4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pAQX48k1KpaRE1imS8OK63hG2Fs2FQgVHrj599ZYMUKQ3C8yDmTK6wE4atbM+D1AG tZP+JKGGGF+thWWS0TG56Z8yWbfSVSfZApLCIOV67+BcrChMvh56152mRD/4FCbJq3 1+oEOdiQVX82SAz7sF2gNyuO8vsV6W0UiUW2vr3M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Stein , Marek Vasut Subject: [PATCH 5.16 078/126] drm: mxsfb: Fix NULL pointer dereference Date: Mon, 7 Feb 2022 12:06:49 +0100 Message-Id: <20220207103806.805730351@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Stein commit 622c9a3a7868e1eeca39c55305ca3ebec4742b64 upstream. mxsfb should not ever dereference the NULL pointer which drm_atomic_get_new_bridge_state is allowed to return. Assume a fixed format instead. Fixes: b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if= present") Signed-off-by: Alexander Stein Signed-off-by: Marek Vasut Link: https://patchwork.freedesktop.org/patch/msgid/20220202081755.145716-3= -alexander.stein@ew.tq-group.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -361,7 +361,11 @@ static void mxsfb_crtc_atomic_enable(str bridge_state =3D drm_atomic_get_new_bridge_state(state, mxsfb->bridge); - bus_format =3D bridge_state->input_bus_cfg.format; + if (!bridge_state) + bus_format =3D MEDIA_BUS_FMT_FIXED; + else + bus_format =3D bridge_state->input_bus_cfg.format; + if (bus_format =3D=3D MEDIA_BUS_FMT_FIXED) { dev_warn_once(drm->dev, "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB8= 88_1X24.\n" From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5DF3C433EF for ; Mon, 7 Feb 2022 12:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381823AbiBGLrM (ORCPT ); Mon, 7 Feb 2022 06:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386278AbiBGLeR (ORCPT ); Mon, 7 Feb 2022 06:34:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225C4C043181; Mon, 7 Feb 2022 03:34:16 -0800 (PST) Received: from smtp.kernel.org (relay.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 CF01EB80EC3; Mon, 7 Feb 2022 11:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB1CC004E1; Mon, 7 Feb 2022 11:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233653; bh=G53Ov27bx25K4bYLcs+JBgsqz22eleL4UIUrJ3J1pmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4O+dtUZyn9w4uOmLcCsjj76FbeEeJDMWByXkhgRLMvChhhIsRA+tYhtELnAuSV8c cwnbrhvZj/5v8b/2+QlJ70KQtnjP4MDVwmLx0naO77e4RxjGlnEHjRyNP/y42F5Ux0 A37PwZ/kA4hDanyD7t6Rdatr0uXEy4WiJfU4ebgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anitha Chrisanthus , Kees Cook Subject: [PATCH 5.16 079/126] drm/kmb: Fix for build errors with Warray-bounds Date: Mon, 7 Feb 2022 12:06:50 +0100 Message-Id: <20220207103806.838794122@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Anitha Chrisanthus commit 43f2517955875be5d96b641fba33d73097fe3cd9 upstream. This fixes the following build error drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable': drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above a= rray bounds of 'struct layer_status[2]' [-Werror=3Darray-bounds] 165 | kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL2_ENABLE; | ~~~~~~~~~~~~~~~~~^~~~~~~~~~ In file included from drivers/gpu/drm/kmb/kmb_plane.c:17: drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_statu= s' 61 | struct layer_status plane_status[KMB_MAX_PLANES]; | ^~~~~~~~~~~~ drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above= array bounds of 'struct layer_status[2]' [-Werror=3Darray-bounds] 162 | kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL1_ENABLE; | ~~~~~~~~~~~~~~~~~^~~~~~~~~~ In file included from drivers/gpu/drm/kmb/kmb_plane.c:17: drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_statu= s' 61 | struct layer_status plane_status[KMB_MAX_PLANES]; | ^~~~~~~~~~~~ Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display") Signed-off-by: Anitha Chrisanthus Reviewed-by: Kees Cook Link: https://patchwork.freedesktop.org/patch/msgid/20220127194227.2213608-= 1-anitha.chrisanthus@intel.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/kmb/kmb_plane.c | 6 ------ 1 file changed, 6 deletions(-) --- a/drivers/gpu/drm/kmb/kmb_plane.c +++ b/drivers/gpu/drm/kmb/kmb_plane.c @@ -158,12 +158,6 @@ static void kmb_plane_atomic_disable(str case LAYER_1: kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_VL2_ENABLE; break; - case LAYER_2: - kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL1_ENABLE; - break; - case LAYER_3: - kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL2_ENABLE; - break; } =20 kmb->plane_status[plane_id].disable =3D true; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9B2BC433F5 for ; Mon, 7 Feb 2022 12:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381852AbiBGLr1 (ORCPT ); Mon, 7 Feb 2022 06:47:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386308AbiBGLeW (ORCPT ); Mon, 7 Feb 2022 06:34:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA2F9C043181; Mon, 7 Feb 2022 03:34:21 -0800 (PST) Received: from smtp.kernel.org (relay.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 7669AB80EC3; Mon, 7 Feb 2022 11:34:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64705C004E1; Mon, 7 Feb 2022 11:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233659; bh=VQ0um3hPcWFFTWCtrxqzMA54VF4LBJGzFd1GZ0+xhEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CrE/U1ODBRTA5pLcI3e90D6P65Ux2G0a/CSdoGqC4WElYm6AMYBnAnAoisWVXkNHs ZnAYbMX4zZA9MQlRBZw4wQVhPuR/UyGX6EiRlw74xer9CcgIz7IoYOSlcVPMffzffU QczU7xMR4hMwy6+jF4PnBuPLL2w9SZU70g79VbVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Tvrtko Ursulin Subject: [PATCH 5.16 080/126] drm/i915/overlay: Prevent divide by zero bugs in scaling Date: Mon, 7 Feb 2022 12:06:51 +0100 Message-Id: <20220207103806.869724629@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Dan Carpenter commit 90a3d22ff02b196d5884e111f39271a1d4ee8e3e upstream. Smatch detected a divide by zero bug in check_overlay_scaling(). drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_height'. drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_width'. Prevent this by ensuring that the dst height and width are non-zero. Fixes: 02e792fbaadb ("drm/i915: implement drmmode overlay support v4") Signed-off-by: Dan Carpenter Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@= kili (cherry picked from commit cf5b64f7f10b28bebb9b7c9d25e7aee5cbe43918) Signed-off-by: Tvrtko Ursulin Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/display/intel_overlay.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/i915/display/intel_overlay.c +++ b/drivers/gpu/drm/i915/display/intel_overlay.c @@ -959,6 +959,9 @@ static int check_overlay_dst(struct inte const struct intel_crtc_state *pipe_config =3D overlay->crtc->config; =20 + if (rec->dst_height =3D=3D 0 || rec->dst_width =3D=3D 0) + return -EINVAL; + if (rec->dst_x < pipe_config->pipe_src_w && rec->dst_x + rec->dst_width <=3D pipe_config->pipe_src_w && rec->dst_y < pipe_config->pipe_src_h && From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47F22C433FE for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381893AbiBGLrh (ORCPT ); Mon, 7 Feb 2022 06:47:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386318AbiBGLeX (ORCPT ); Mon, 7 Feb 2022 06:34:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71210C043181; Mon, 7 Feb 2022 03:34:23 -0800 (PST) Received: from smtp.kernel.org (relay.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 EC03C60A69; Mon, 7 Feb 2022 11:34:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEB9BC004E1; Mon, 7 Feb 2022 11:34:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233662; bh=+47cr8N7Htw4ywLt3V8sL2iOcTtpPvwzUNFzThO3/TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIGzIqSWd69oa1ICWHmWNpxAi3TmYbY1hZPLwSnju8GcMXImRJWHqXGPFaR4/wvmW Y4lHW4Mt22HwkHTEqT7uWZkvv+3n2jkb1Il9dvakpwXGHiQXwFpEf7XVyA54h/vAVP 8Md/kzXyWBAZdPSNG7E5KbiCBUa4BJ/QtBX/wvHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Brost , John Harrison , Tvrtko Ursulin Subject: [PATCH 5.16 081/126] drm/i915: Lock timeline mutex directly in error path of eb_pin_timeline Date: Mon, 7 Feb 2022 12:06:52 +0100 Message-Id: <20220207103806.903419880@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit 5ae13c305ef8cb54efc4f0ba4565709b9f320fed upstream. Don't use the interruptable version of the timeline mutex lock in the error path of eb_pin_timeline as the cleanup must always happen. v2: (John Harrison) - Don't check for interrupt during mutex lock v3: (Tvrtko) - A comment explaining why lock helper isn't used Fixes: 544460c33821 ("drm/i915: Multi-BB execbuf") Signed-off-by: Matthew Brost Reviewed-by: John Harrison Signed-off-by: John Harrison Link: https://patchwork.freedesktop.org/patch/msgid/20220111163929.14017-1-= matthew.brost@intel.com (cherry picked from commit cb935c4618bd2ff9058feee4af7088446da6a763) Signed-off-by: Tvrtko Ursulin Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -2372,9 +2372,14 @@ static int eb_pin_timeline(struct i915_e timeout) < 0) { i915_request_put(rq); =20 - tl =3D intel_context_timeline_lock(ce); + /* + * Error path, cannot use intel_context_timeline_lock as + * that is user interruptable and this clean up step + * must be done. + */ + mutex_lock(&ce->timeline->mutex); intel_context_exit(ce); - intel_context_timeline_unlock(tl); + mutex_unlock(&ce->timeline->mutex); =20 if (nonblock) return -EWOULDBLOCK; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F198C43219 for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386073AbiBGLro (ORCPT ); Mon, 7 Feb 2022 06:47:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386343AbiBGLe1 (ORCPT ); Mon, 7 Feb 2022 06:34:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B765C043188; Mon, 7 Feb 2022 03:34:26 -0800 (PST) Received: from smtp.kernel.org (relay.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 3807960A69; Mon, 7 Feb 2022 11:34:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FFBDC340EB; Mon, 7 Feb 2022 11:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233665; bh=s14nD2quE399c8hfQLD03MTXJcFy5vW6jF2FKaj+ikI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yoji33AEsgSUL5DwknxFpPNtL34GCQEQ1QIA/eE1dOUrCD05nAgSVIReJSzPDngpB oA7ODv++MfxQHMUevWIwcWKZKdzRWpKo5t1VEPXUkkQx+nT/L32eGve3n+b7I5gDvH uyIADeK+GX7S9uXZcWvXPBIGsCOoRQ3esufmf5OY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher , Mario Limonciello Subject: [PATCH 5.16 082/126] drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled Date: Mon, 7 Feb 2022 12:06:53 +0100 Message-Id: <20220207103806.941917412@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit e55a3aea418269266d84f426b3bd70794d3389c8 upstream. dGPUs connected to Intel systems configured for suspend to idle will not have the power rails cut at suspend and resetting the GPU may lead to problematic behaviors. Fixes: e25443d2765f4 ("drm/amdgpu: add a dev_pm_ops prepare callback (v2)") Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1879 Reviewed-by: Alex Deucher Signed-off-by: Mario Limonciello Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2241,8 +2241,7 @@ static int amdgpu_pmops_prepare(struct d * DPM_FLAG_SMART_SUSPEND works properly */ if (amdgpu_device_supports_boco(drm_dev)) - return pm_runtime_suspended(dev) && - pm_suspend_via_firmware(); + return pm_runtime_suspended(dev); =20 return 0; } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76735C43217 for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389201AbiBGLrt (ORCPT ); Mon, 7 Feb 2022 06:47:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386372AbiBGLea (ORCPT ); Mon, 7 Feb 2022 06:34:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB468C043181; Mon, 7 Feb 2022 03:34:29 -0800 (PST) Received: from smtp.kernel.org (relay.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 475DC60A69; Mon, 7 Feb 2022 11:34:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24DEFC004E1; Mon, 7 Feb 2022 11:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233668; bh=/4zaqO1frzMWWspUOZDtfP70ydPhujaV0aPOS7JO4DI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuXw6MRRUEz7JXZZ4EtCUVXrSCjH2FOiFKETMcMTGALHlIiBpwkBZ4ij84lyY2ibh PKzk7gqgkmfYyVB9XG9cEoVusBZZ5UGGzCgcw89cosXfeJhWlUMn87zcniTmXIg3Gj t8kg6kOt7rUGc2sWKrmEcn+66P0m2hR1Bp7ZFT9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Mark Brown Subject: [PATCH 5.16 083/126] ASoC: rt5682: Fix deadlock on resume Date: Mon, 7 Feb 2022 12:06:54 +0100 Message-Id: <20220207103806.973310761@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit 4045daf0fa87846a27f56329fddad2deeb5ca354 upstream. 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: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- 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(-) --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -59,18 +59,12 @@ static void rt5682_jd_check_handler(stru 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) @@ -198,7 +192,6 @@ static int rt5682_i2c_probe(struct i2c_c } =20 mutex_init(&rt5682->calibrate_mutex); - mutex_init(&rt5682->jdet_mutex); rt5682_calibrate(rt5682); =20 rt5682_apply_patch_list(rt5682, &i2c->dev); --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -922,15 +922,13 @@ static void rt5682_enable_push_button_ir * * 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 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 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 w { 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 while (!rt5682->component) @@ -1102,7 +1098,9 @@ void rt5682_jack_detect_handler(struct w while (!rt5682->component->card->instantiated) usleep_range(10000, 15000); =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) @@ -1162,6 +1160,9 @@ void rt5682_jack_detect_handler(struct w 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 | @@ -1174,9 +1175,6 @@ void rt5682_jack_detect_handler(struct w 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 @@ -1526,7 +1524,6 @@ static int rt5682_hp_event(struct snd_so { 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: @@ -1538,17 +1535,12 @@ static int rt5682_hp_event(struct snd_so 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: --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1463,7 +1463,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]; @@ -1473,7 +1472,6 @@ int rt5682_sel_asrc_clk_src(struct snd_s =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); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A38C4167B for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389299AbiBGLsC (ORCPT ); Mon, 7 Feb 2022 06:48:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386438AbiBGLei (ORCPT ); Mon, 7 Feb 2022 06:34:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20BDC043181; Mon, 7 Feb 2022 03:34:37 -0800 (PST) Received: from smtp.kernel.org (relay.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 5FC9EB80EC3; Mon, 7 Feb 2022 11:34:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B6CCC340EB; Mon, 7 Feb 2022 11:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233675; bh=oockd+H0nbljZXJvxJaW8xs5secCp/bASldZOrm0rlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hnepjqggb4fFZ9QXOCbVAQQABUx+CXgXD2Yv8vnLY7PMRj0FhtupB5N10n3CxUDQM TyZgbY+4qIDcHfeR/KRwnQaqjF90l/NkamH8zdrBl0nV78xJRT9j6CkJNO5rBl7FuD U1elwJ4ryMNHmsTnbIYuzDG/rcxSKdzPtjRlEZgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mark Brown Subject: [PATCH 5.16 084/126] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Date: Mon, 7 Feb 2022 12:06:55 +0100 Message-Id: <20220207103807.005469068@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 fb25621da5702c104ce0a48de5b174ced09e5b4e upstream. Add the missing platform_device_put() and platform_device_del() before return from pcm030_fabric_probe in the error handling case. Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/fsl/pcm030-audio-fabric.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -93,16 +93,21 @@ static int pcm030_fabric_probe(struct pl dev_err(&op->dev, "platform_device_alloc() failed\n"); =20 ret =3D platform_device_add(pdata->codec_device); - if (ret) + if (ret) { dev_err(&op->dev, "platform_device_add() failed: %d\n", ret); + platform_device_put(pdata->codec_device); + } =20 ret =3D snd_soc_register_card(card); - if (ret) + if (ret) { dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); + platform_device_del(pdata->codec_device); + platform_device_put(pdata->codec_device); + } =20 platform_set_drvdata(op, pdata); - return ret; + } =20 static int pcm030_fabric_remove(struct platform_device *op) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE26FC4167D for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389343AbiBGLsJ (ORCPT ); Mon, 7 Feb 2022 06:48:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386466AbiBGLel (ORCPT ); Mon, 7 Feb 2022 06:34:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D79ECC043188; Mon, 7 Feb 2022 03:34:40 -0800 (PST) Received: from smtp.kernel.org (relay.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 83428B8102E; Mon, 7 Feb 2022 11:34:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF56C004E1; Mon, 7 Feb 2022 11:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233678; bh=fQ6HmfmTWZIJTOD7EvLAW2lH/Y8C1gMM3DzkQZuDHbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1Eb7/Nr8lZkZDw6JN1b+uS7apohpv2bZaC8i7YRlGS98pPkXkG75RnGkmF218Dke NgAcoE6GNx3izqk6I7+232bfpU3mHrY1sSJjcaZlSg7iKBdwf2keDZfRkwKzXMhf2h DN+o+OZGBk60zDqTyilxtoCxUik/5wQ7CDcFX+MU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Devarsh Thakkar , Robert Hancock , Mark Brown Subject: [PATCH 5.16 085/126] ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes Date: Mon, 7 Feb 2022 12:06:56 +0100 Message-Id: <20220207103807.036853878@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Robert Hancock commit e958b5884725dac86d36c1e7afe5a55f31feb0b2 upstream. This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make buffer bytes multiple of period bytes" by Devarsh Thakkar. The same issue exists in the mainline version of the driver. The original patch description is as follows: "The Xilinx Audio Formatter IP has a constraint on period bytes to be multiple of 64. This leads to driver changing the period size to suitable frames such that period bytes are multiple of 64. Now since period bytes and period size are updated but not the buffer bytes, this may make the buffer bytes unaligned and not multiple of period bytes. When this happens we hear popping noise as while DMA is being done the buffer bytes are not enough to complete DMA access for last period of frame within the application buffer boundary. To avoid this, align buffer bytes too as multiple of 64, and set another constraint to always enforce number of periods as integer. Now since, there is already a rule in alsa core to enforce Buffer size =3D Number of Periods * Period Size this automatically aligns buffer bytes as multiple of period bytes." Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver") Cc: Devarsh Thakkar Signed-off-by: Robert Hancock Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@cal= ian.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/xilinx/xlnx_formatter_pcm.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -37,6 +37,7 @@ #define XLNX_AUD_XFER_COUNT 0x28 #define XLNX_AUD_CH_STS_START 0x2C #define XLNX_BYTES_PER_CH 0x44 +#define XLNX_AUD_ALIGN_BYTES 64 =20 #define AUD_STS_IOC_IRQ_MASK BIT(31) #define AUD_STS_CH_STS_MASK BIT(29) @@ -368,12 +369,32 @@ static int xlnx_formatter_pcm_open(struc snd_soc_set_runtime_hwparams(substream, &xlnx_pcm_hardware); runtime->private_data =3D stream_data; =20 - /* Resize the period size divisible by 64 */ + /* Resize the period bytes as divisible by 64 */ err =3D snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64); + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, + XLNX_AUD_ALIGN_BYTES); if (err) { dev_err(component->dev, - "unable to set constraint on period bytes\n"); + "Unable to set constraint on period bytes\n"); + return err; + } + + /* Resize the buffer bytes as divisible by 64 */ + err =3D snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, + XLNX_AUD_ALIGN_BYTES); + if (err) { + dev_err(component->dev, + "Unable to set constraint on buffer bytes\n"); + return err; + } + + /* Set periods as integer multiple */ + err =3D snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (err < 0) { + dev_err(component->dev, + "Unable to set constraint on periods to be integer\n"); return err; } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D021AC4167E for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389357AbiBGLsR (ORCPT ); Mon, 7 Feb 2022 06:48:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386484AbiBGLen (ORCPT ); Mon, 7 Feb 2022 06:34:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E40FC043188; Mon, 7 Feb 2022 03:34:42 -0800 (PST) Received: from smtp.kernel.org (relay.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 2E23460B20; Mon, 7 Feb 2022 11:34:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA4C8C004E1; Mon, 7 Feb 2022 11:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233681; bh=biUjx9epFYxUc5njJ7zZT0O1LrXh9iSxhzE0Ljx4fBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acK0AEvzcsRWnjlSTHrgqnF7pc66renLvcoXEOyw27QUwFkIpOiqoXzCClYJ/E99x V7xuScTHN+4+xl92/yCZL0xzuU85JQInL3lwuBDvPOrHDWn8eO2w4Paxx4DRnSZLdN n2lbe8EAM1hU7el4KH8w5IKEib7S/coj3U+Cq/0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Mark Brown Subject: [PATCH 5.16 086/126] ASoC: simple-card: fix probe failure on platform component Date: Mon, 7 Feb 2022 12:06:57 +0100 Message-Id: <20220207103807.070239935@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Robert Hancock commit a64067f4cecaaa4deed8e33d3266bc0bcc189142 upstream. A previous change to simple-card resulted in asoc_simple_parse_dai attempting to retrieve the dai_name for platform components, which are unlikely to have a valid DAI name. This caused simple-card to fail to probe when using the xlnx_formatter_pcm as the platform component, since it does not register any DAI components. Since the dai_name is not used for platform components, just skip trying to retrieve it for those. Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component= style for cpu") Signed-off-by: Robert Hancock Link: https://lore.kernel.org/r/20220107214711.1100162-6-robert.hancock@cal= ian.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/generic/simple-card.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -28,6 +28,30 @@ static const struct snd_soc_ops simple_o .hw_params =3D asoc_simple_hw_params, }; =20 +static int asoc_simple_parse_platform(struct device_node *node, + struct snd_soc_dai_link_component *dlc) +{ + struct of_phandle_args args; + int ret; + + if (!node) + return 0; + + /* + * Get node via "sound-dai =3D <&phandle port>" + * it will be used as xxx_of_node on soc_bind_dai_link() + */ + ret =3D of_parse_phandle_with_args(node, DAI, CELL, 0, &args); + if (ret) + return ret; + + /* dai_name is not required and may not exist for plat component */ + + dlc->of_node =3D args.np; + + return 0; +} + static int asoc_simple_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, int *is_single_link) @@ -289,7 +313,7 @@ static int simple_dai_link_of(struct aso if (ret < 0) goto dai_link_of_err; =20 - ret =3D asoc_simple_parse_dai(plat, platforms, NULL); + ret =3D asoc_simple_parse_platform(plat, platforms); if (ret < 0) goto dai_link_of_err; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3B10C433EF for ; Mon, 7 Feb 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389370AbiBGLsZ (ORCPT ); Mon, 7 Feb 2022 06:48:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386505AbiBGLes (ORCPT ); Mon, 7 Feb 2022 06:34:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7546C043188; Mon, 7 Feb 2022 03:34:47 -0800 (PST) Received: from smtp.kernel.org (relay.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 93480B8102E; Mon, 7 Feb 2022 11:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84BA3C004E1; Mon, 7 Feb 2022 11:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233685; bh=u3/akX/dz9ZO7Yp9P/0+QWrmMr/uEK5Ppvyr2pAXRic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5xaD/2lVVp7c10OGGCY4dM0ctnj/8/lPZuvw9wSxgmcXEAzdwR9AtCqcueAUVjRR i/R2xT0SJC4l1+xIxnNkOYyELp9V/D4/wLyX1CGGNqVunfpXiG/pPKMwVGC65QJTk/ GkXnu7B6tJ5lT5nqVxIbxGsqKosV6qo7iHKSMW/o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Mark Brown Subject: [PATCH 5.16 087/126] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Date: Mon, 7 Feb 2022 12:06:58 +0100 Message-Id: <20220207103807.103050951@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Jiasheng Jiang commit f7a6021aaf02088870559f82fc13c58cda7fea1a upstream. If the device does not exist, of_get_child_by_name() will return NULL pointer. And devm_snd_soc_register_component() does not check it. Also, I have noticed that cpcap_codec_driver has not been used yet. Therefore, it should be better to check it in order to avoid the future dereference of the NULL pointer. Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec") Signed-off-by: Jiasheng Jiang Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/cpcap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -1667,6 +1667,8 @@ static int cpcap_codec_probe(struct plat { struct device_node *codec_node =3D of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); + if (!codec_node) + return -ENODEV; =20 pdev->dev.of_node =3D codec_node; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DAFAC4332F for ; Mon, 7 Feb 2022 12:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389412AbiBGLsb (ORCPT ); Mon, 7 Feb 2022 06:48:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386516AbiBGLeu (ORCPT ); Mon, 7 Feb 2022 06:34:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E340C043181; Mon, 7 Feb 2022 03:34:49 -0800 (PST) Received: from smtp.kernel.org (relay.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 0D93460A69; Mon, 7 Feb 2022 11:34:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDD52C004E1; Mon, 7 Feb 2022 11:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233688; bh=07DXET1mUt27c2qdzB5vxavcElMoUr/eGhq3NzQRh/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hvF6/WHNvnkyYukTcnELgni6vkbOKyPjxJS/NlRh+HBP9noyZrCSzdbevRHH0FZpu KmSqTMPbkR8VLqJ1mg3KN0Sf0lMTXbwTakJqfsAwB/4gtN3sHZVdSPApyOy7q3exms j9cnseCBsQ+4+EqlZBq/t1vdEExH0WfHgMNxWlXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Brown Subject: [PATCH 5.16 088/126] ASoC: max9759: fix underflow in speaker_gain_control_put() Date: Mon, 7 Feb 2022 12:06:59 +0100 Message-Id: <20220207103807.134290154@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 4c907bcd9dcd233da6707059d777ab389dcbd964 upstream. Check for negative values of "priv->gain" to prevent an out of bounds access. The concern is that these might come from the user via: -> snd_ctl_elem_write_user() -> snd_ctl_elem_write() -> kctl->put() Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20220119123101.GA9509@kili Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/max9759.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/soc/codecs/max9759.c +++ b/sound/soc/codecs/max9759.c @@ -64,7 +64,8 @@ static int speaker_gain_control_put(stru struct snd_soc_component *c =3D snd_soc_kcontrol_component(kcontrol); struct max9759 *priv =3D snd_soc_component_get_drvdata(c); =20 - if (ucontrol->value.integer.value[0] > 3) + if (ucontrol->value.integer.value[0] < 0 || + ucontrol->value.integer.value[0] > 3) return -EINVAL; =20 priv->gain =3D ucontrol->value.integer.value[0]; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33864C3A589 for ; Mon, 7 Feb 2022 12:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391530AbiBGMCH (ORCPT ); Mon, 7 Feb 2022 07:02:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386797AbiBGLhI (ORCPT ); Mon, 7 Feb 2022 06:37:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E340C043181; Mon, 7 Feb 2022 03:37:07 -0800 (PST) Received: from smtp.kernel.org (relay.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 DEFE660B5B; Mon, 7 Feb 2022 11:37:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D750C004E1; Mon, 7 Feb 2022 11:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233826; bh=mghb54hZFOF3Tf8Tw34fghEoY09mRRxhydg5x0NVEVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sB5/vD+jyShTn+H+Vhx2AIt1T3JZgCgjcEyGTvt2VxZxJSXZNqDOcA8O3oG6IYUMx Ww3wnIRicgLPPosHJbtXu06LNkB+rqvtoLmmzL9xY8Hsd1WMF355fRiiDtIFqnYUyT B2bEZVIXx/FQj+2qoNs8ZauMV4ZcAoEeitcVO+S8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.16 089/126] ASoC: codecs: wcd938x: fix incorrect used of portid Date: Mon, 7 Feb 2022 12:07:00 +0100 Message-Id: <20220207103807.170220798@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Srinivas Kandagatla commit c5c1546a654f613e291a7c5d6f3660fc1eb6d0c7 upstream. Mixer controls have the channel id in mixer->reg, which is not same as port id. port id should be derived from chan_info array. So fix this. Without this, its possible that we could corrupt struct wcd938x_sdw_priv by accessing port_map array out of range with channel id instead of port id. Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-2-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/wcd938x.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -1432,14 +1432,10 @@ static int wcd938x_sdw_connect_port(stru return 0; } =20 -static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 ch_id, u8= enable) +static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 port_num,= u8 ch_id, u8 enable) { - u8 port_num; - - port_num =3D wcd->ch_info[ch_id].port_num; - return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id], - &wcd->port_config[port_num], + &wcd->port_config[port_num - 1], enable); } =20 @@ -2593,6 +2589,7 @@ static int wcd938x_set_compander(struct struct wcd938x_priv *wcd938x =3D snd_soc_component_get_drvdata(component); struct wcd938x_sdw_priv *wcd; int value =3D ucontrol->value.integer.value[0]; + int portidx; struct soc_mixer_control *mc; bool hphr; =20 @@ -2606,10 +2603,12 @@ static int wcd938x_set_compander(struct else wcd938x->comp1_enable =3D value; =20 + portidx =3D wcd->ch_info[mc->reg].port_num; + if (value) - wcd938x_connect_port(wcd, mc->reg, true); + wcd938x_connect_port(wcd, portidx, mc->reg, true); else - wcd938x_connect_port(wcd, mc->reg, false); + wcd938x_connect_port(wcd, portidx, mc->reg, false); =20 return 0; } @@ -2882,9 +2881,11 @@ static int wcd938x_get_swr_port(struct s struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer =3D (struct soc_mixer_control *)kcontrol-= >private_value; int dai_id =3D mixer->shift; - int portidx =3D mixer->reg; + int portidx, ch_idx =3D mixer->reg; + =20 wcd =3D wcd938x->sdw_priv[dai_id]; + portidx =3D wcd->ch_info[ch_idx].port_num; =20 ucontrol->value.integer.value[0] =3D wcd->port_enable[portidx]; =20 @@ -2899,12 +2900,14 @@ static int wcd938x_set_swr_port(struct s struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer =3D (struct soc_mixer_control *)kcontrol->private_value; - int portidx =3D mixer->reg; + int ch_idx =3D mixer->reg; + int portidx; int dai_id =3D mixer->shift; bool enable; =20 wcd =3D wcd938x->sdw_priv[dai_id]; =20 + portidx =3D wcd->ch_info[ch_idx].port_num; if (ucontrol->value.integer.value[0]) enable =3D true; else @@ -2912,7 +2915,7 @@ static int wcd938x_set_swr_port(struct s =20 wcd->port_enable[portidx] =3D enable; =20 - wcd938x_connect_port(wcd, portidx, enable); + wcd938x_connect_port(wcd, portidx, ch_idx, enable); =20 return 0; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98B6EC43217 for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381659AbiBGLt3 (ORCPT ); Mon, 7 Feb 2022 06:49:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386657AbiBGLfR (ORCPT ); Mon, 7 Feb 2022 06:35:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 516ACC043181; Mon, 7 Feb 2022 03:35:16 -0800 (PST) Received: from smtp.kernel.org (relay.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 EF8FAB8102E; Mon, 7 Feb 2022 11:35:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01F14C004E1; Mon, 7 Feb 2022 11:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233713; bh=QSzRICIWp+0GChseBdZWcjIxGZHnKp6X93Ah6uWn+to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gIzCZtlQjkuvD8V8KtlewN6eM2FxVXvAddALChJKOvywZso9NBzGcHW2aj4Q8XU3+ 5D2XSjCKeyCZ0RMi4zWxbDSriFF8ugOEVgbOWARacUYMY7k+JhmurRudODM/DZMqQI +MDGZEejixzvVPMVhRzLDqdOUEBneSYK9Jjr1UOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.16 090/126] ASoC: codecs: lpass-rx-macro: fix sidetone register offsets Date: Mon, 7 Feb 2022 12:07:01 +0100 Message-Id: <20220207103807.201367072@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Srinivas Kandagatla commit fca041a3ab70a099a6d5519ecb689b6279bd04f3 upstream. For some reason we ended up with incorrect register offfset calcuations for sidetone. regmap clearly throw errors when accessing these incorrect registers as these do not belong to any read/write ranges. so fix them to point to correct register offsets. Fixes: f3ce6f3c9a99 ("ASoC: codecs: lpass-rx-macro: add iir widgets") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-3-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/lpass-rx-macro.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -2688,8 +2688,8 @@ static uint32_t get_iir_band_coeff(struc int reg, b2_reg; =20 /* Address does not automatically update if reading */ - reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; - b2_reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; + b2_reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; =20 snd_soc_component_write(component, reg, ((band_idx * BAND_MAX + coeff_idx) * @@ -2718,7 +2718,7 @@ static uint32_t get_iir_band_coeff(struc static void set_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, uint32_t value) { - int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; =20 snd_soc_component_write(component, reg, (value & 0xFF)); snd_soc_component_write(component, reg, (value >> 8) & 0xFF); @@ -2739,7 +2739,7 @@ static int rx_macro_put_iir_band_audio_m int iir_idx =3D ctl->iir_idx; int band_idx =3D ctl->band_idx; u32 coeff[BAND_MAX]; - int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; + int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; =20 memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71294C41535 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241789AbiBGL7K (ORCPT ); Mon, 7 Feb 2022 06:59:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378775AbiBGLf5 (ORCPT ); Mon, 7 Feb 2022 06:35:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383F0C0401D9; Mon, 7 Feb 2022 03:35:50 -0800 (PST) Received: from smtp.kernel.org (relay.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 A411160B20; Mon, 7 Feb 2022 11:35:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EB8EC004E1; Mon, 7 Feb 2022 11:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233749; bh=esiT/hIJxVX2S5Y8Ay8ItBQhf+iGcOTS78pGTHXvBrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4iRpQEH5NPZLRRias6/jFUGCGSjoodc/6YTDZPOWvOq93K+v/bJeJDzt300XAn0o Y+tNYDtNmJQxrUOloNJHwZt90bXWfHMt6REXgqouMDjZdMSRWzOx6ZTcMc9F3sgBVG lvqlwvxmIx+KwEGRPdosiHnj9HWpifyT9F2eMnvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.16 091/126] ASoC: codecs: wcd938x: fix return value of mixer put function Date: Mon, 7 Feb 2022 12:07:02 +0100 Message-Id: <20220207103807.234352095@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Srinivas Kandagatla commit bd2347fd67d8da0fa76296507cc556da0a233bcb upstream. wcd938x_ear_pa_put_gain, wcd938x_set_swr_port and wcd938x_set_compander currently returns zero eventhough it changes the value. Fix this, so that change notifications are sent correctly. Fixes: e8ba1e05bdc01 ("ASoC: codecs: wcd938x: add basic controls") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-4-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/wcd938x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -2559,7 +2559,7 @@ static int wcd938x_ear_pa_put_gain(struc WCD938X_EAR_GAIN_MASK, ucontrol->value.integer.value[0]); =20 - return 0; + return 1; } =20 static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, @@ -2610,7 +2610,7 @@ static int wcd938x_set_compander(struct else wcd938x_connect_port(wcd, portidx, mc->reg, false); =20 - return 0; + return 1; } =20 static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, @@ -2917,7 +2917,7 @@ static int wcd938x_set_swr_port(struct s =20 wcd938x_connect_port(wcd, portidx, ch_idx, enable); =20 - return 0; + return 1; =20 } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CDD5C47089 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382171AbiBGMAw (ORCPT ); Mon, 7 Feb 2022 07:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386743AbiBGLga (ORCPT ); Mon, 7 Feb 2022 06:36:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B082C0401E2; Mon, 7 Feb 2022 03:36:29 -0800 (PST) Received: from smtp.kernel.org (relay.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 F2C61B80EBD; Mon, 7 Feb 2022 11:36:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 508B0C004E1; Mon, 7 Feb 2022 11:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233786; bh=vyXTZ8AOqJjuqo2aDoJFDqpiBjhdsEXIRrAn431eoUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tg1E62YzPok89s6TcrEKoVEWje4T8Xjdz6acw+E1d715BM+ojwGxxRayzuVZ2Z6Z0 CcOH/+2SIt3HvUxzHL0TBv2LNGrNGpNdK56JK8nvxHFjQQaBUSO37xjndQU/MHiDQW 1hnsePQOjGUqvK9AkKwcqIRO7/8IRvvx23kqzjOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.16 092/126] ASoC: qdsp6: q6apm-dai: only stop graphs that are started Date: Mon, 7 Feb 2022 12:07:03 +0100 Message-Id: <20220207103807.265670256@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Srinivas Kandagatla commit 8f2e5c65ec7534cce6d315fccf2c3aef023f68f0 upstream. Its possible that the sound card is just opened and closed without actually playing stream, ex: if the audio file itself is missing. Even in such cases we do call stop on graphs that are not yet started. DSP can throw errors in such cases, so add a check to see if the graph was started before stopping it. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-5-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/qcom/qdsp6/q6apm-dai.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -308,8 +308,11 @@ static int q6apm_dai_close(struct snd_so struct snd_pcm_runtime *runtime =3D substream->runtime; struct q6apm_dai_rtd *prtd =3D runtime->private_data; =20 - q6apm_graph_stop(prtd->graph); - q6apm_unmap_memory_regions(prtd->graph, substream->stream); + if (prtd->state) { /* only stop graph that is started */ + q6apm_graph_stop(prtd->graph); + q6apm_unmap_memory_regions(prtd->graph, substream->stream); + } + q6apm_graph_close(prtd->graph); prtd->graph =3D NULL; kfree(prtd); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A478C38A05 for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391398AbiBGMBn (ORCPT ); Mon, 7 Feb 2022 07:01:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386786AbiBGLgs (ORCPT ); Mon, 7 Feb 2022 06:36:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 612B4C043188; Mon, 7 Feb 2022 03:36:48 -0800 (PST) Received: from smtp.kernel.org (relay.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 25A07B80EBD; Mon, 7 Feb 2022 11:36:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D4D2C004E1; Mon, 7 Feb 2022 11:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233805; bh=8QV6oXiFaB4PUA8JqIhf7y6Mx274xZaFC/RUXpTItBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fsxEVEihRELWBcOnRSCsR3mal7aBaDAOcKFbeyPMLjmSDOaDQ/gq5nPgwMtevj9CC f8x1JoOjXTk1uxNW3fwSblZ5UapIHYQrZNfOB1wW8lnYb/sL2FioD9RzIHYDHJJuiY ez6zOllcYjmyISOrPcqI87GWYbEP/66ZapRbr2nM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, SASANO Takayoshi , Andre Przywara , Jernej Skrabec , Samuel Holland , Linus Walleij Subject: [PATCH 5.16 093/126] pinctrl: sunxi: Fix H616 I2S3 pin data Date: Mon, 7 Feb 2022 12:07:04 +0100 Message-Id: <20220207103807.297452660@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Andre Przywara commit 1fd6bb5b47a65eacb063b37e6fa6df2b8fa92959 upstream. Two bugs have sneaked in the H616 pinctrl data: - PH9 uses the mux value of 0x3 twice (one should be 0x5 instead) - PH8 and PH9 use the "i2s3" function name twice in each pin For the double pin name we use the same trick we pulled for i2s0: append the pin function to the group name to designate the special function. Fixes: 25adc29407fb ("pinctrl: sunxi: Add support for the Allwinner H616 pi= n controller") Reported-by: SASANO Takayoshi Signed-off-by: Andre Przywara Reviewed-by: Jernej Skrabec Reviewed-by: Samuel Holland Link: https://lore.kernel.org/r/20220105172952.23347-1-andre.przywara@arm.c= om Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c @@ -363,16 +363,16 @@ static const struct sunxi_desc_pin h616_ SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ - SUNXI_FUNCTION(0x3, "i2s3"), /* DO0 */ + SUNXI_FUNCTION(0x3, "i2s3_dout0"), /* DO0 */ SUNXI_FUNCTION(0x4, "spi1"), /* MISO */ - SUNXI_FUNCTION(0x5, "i2s3"), /* DI1 */ + SUNXI_FUNCTION(0x5, "i2s3_din1"), /* DI1 */ SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 8)), /* PH_EINT8 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 9), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x3, "i2s3"), /* DI0 */ + SUNXI_FUNCTION(0x3, "i2s3_din0"), /* DI0 */ SUNXI_FUNCTION(0x4, "spi1"), /* CS1 */ - SUNXI_FUNCTION(0x3, "i2s3"), /* DO1 */ + SUNXI_FUNCTION(0x5, "i2s3_dout1"), /* DO1 */ SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 9)), /* PH_EINT9 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 10), SUNXI_FUNCTION(0x0, "gpio_in"), From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABC7EC38A06 for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391427AbiBGMBt (ORCPT ); Mon, 7 Feb 2022 07:01:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386787AbiBGLgv (ORCPT ); Mon, 7 Feb 2022 06:36:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46D8C043181; Mon, 7 Feb 2022 03:36:50 -0800 (PST) Received: from smtp.kernel.org (relay.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 491B460A69; Mon, 7 Feb 2022 11:36:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 645F1C004E1; Mon, 7 Feb 2022 11:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233809; bh=ugirauE7wsGqXb36nXK6gxIvb+7wGHj2bprs0GCSXLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=njsGotnMmV+snq/HyLqoPNzSLQnyztyPDzqvb6/c0IA+A1lPqF+vOHfUgYMQy+vNV xRAQvNdSThVWNYZObGtrg1imdM7LFKoXsrPxHNhK8iCFksJuTUgegVEC5RkN5ySnLP pMc+mIKOoW8kwh444wUcY0SpGdeM4N7kgygS4YhU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kane Chen , Andy Shevchenko , Mika Westerberg , Grace Kao Subject: [PATCH 5.16 094/126] pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line Date: Mon, 7 Feb 2022 12:07:05 +0100 Message-Id: <20220207103807.329696976@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Andy Shevchenko commit e12963c453263d5321a2c610e98cbc731233b685 upstream. The commit af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer when switching to GPIO") hadn't taken into account an update of the IRQ flags scenario. When updating the IRQ flags on the preconfigured line the ->irq_set_type() is called again. In such case the sequential Rx buffer configuration changes may trigger a falling or rising edge interrupt that may lead, on some platforms, to an undesired event. This may happen because each of intel_gpio_set_gpio_mode() and __intel_gpio_set_direction() updates the pad configuration with a different value of the GPIORXDIS bit. Notable, that the intel_gpio_set_gpio_mode() is called only for the pads that are configured as an input. Due to this fact, integrate the logic of __intel_gpio_set_direction() call into the intel_gpio_set_gpio_mode() so that the Rx buffer won't be disabled and immediately re-enabled. Fixes: af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer when = switching to GPIO") Reported-by: Kane Chen Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg Tested-by: Grace Kao Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/intel/pinctrl-intel.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -451,8 +451,8 @@ static void intel_gpio_set_gpio_mode(voi value &=3D ~PADCFG0_PMODE_MASK; value |=3D PADCFG0_PMODE_GPIO; =20 - /* Disable input and output buffers */ - value |=3D PADCFG0_GPIORXDIS; + /* Disable TX buffer and enable RX (this will be input) */ + value &=3D ~PADCFG0_GPIORXDIS; value |=3D PADCFG0_GPIOTXDIS; =20 /* Disable SCI/SMI/NMI generation */ @@ -497,9 +497,6 @@ static int intel_gpio_request_enable(str =20 intel_gpio_set_gpio_mode(padcfg0); =20 - /* Disable TX buffer and enable RX (this will be input) */ - __intel_gpio_set_direction(padcfg0, true); - raw_spin_unlock_irqrestore(&pctrl->lock, flags); =20 return 0; @@ -1115,9 +1112,6 @@ static int intel_gpio_irq_type(struct ir =20 intel_gpio_set_gpio_mode(reg); =20 - /* Disable TX buffer and enable RX (this will be input) */ - __intel_gpio_set_direction(reg, true); - value =3D readl(reg); =20 value &=3D ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C09E2C38A2C for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391461AbiBGMBw (ORCPT ); Mon, 7 Feb 2022 07:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386788AbiBGLg4 (ORCPT ); Mon, 7 Feb 2022 06:36:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF70C043181; Mon, 7 Feb 2022 03:36:55 -0800 (PST) Received: from smtp.kernel.org (relay.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 291BEB80EBD; Mon, 7 Feb 2022 11:36:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5282AC004E1; Mon, 7 Feb 2022 11:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233813; bh=HlwO99kzVVDq/w0vcBsb1+gvp57k51VTn37EzEf+CmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dExP08jtTf0gfebk03t2yMiAGcOk6QsK6HXMbIm55sybph8yVJwo7lol+3FGtqB40 OcDak+6xOLjqf1i7dTlTlLyOn2dJ6q5XFpdWCKoLt+x63RtyTX1i3pwfp8XeO1TTPb ynmWyJqacMJZ1nNWa/6aKUy3k1ClOFpRGpjlE7qg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Andy Shevchenko Subject: [PATCH 5.16 095/126] pinctrl: intel: fix unexpected interrupt Date: Mon, 7 Feb 2022 12:07:06 +0100 Message-Id: <20220207103807.363627234@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: =C5=81ukasz Bartosik commit e986f0e602f19ecb7880b04dd1db415ed9bca3f6 upstream. ASUS Chromebook C223 with Celeron N3350 crashes sometimes during cold booot. Inspection of the kernel log showed that it gets into an inifite loop logging the following message: ->handle_irq(): 000000009cdb51e8, handle_bad_irq+0x0/0x251 ->irq_data.chip(): 000000005ec212a7, 0xffffa043009d8e7 ->action(): 00000 IRQ_NOPROBE set unexpected IRQ trap at vector 7c The issue happens during cold boot but only if cold boot happens at most several dozen seconds after Chromebook is powered off. For longer intervals between power off and power on (cold boot) the issue does not reproduce. The unexpected interrupt is sourced from INT3452 GPIO pin which is used for SD card detect. Investigation relevealed that when the interval between power off and power on (cold boot) is less than several dozen seconds then values of INT3452 GPIO interrupt enable and interrupt pending registers survive power off and power on sequence and interrupt for SD card detect pin is enabled and pending during probe of SD controller which causes the unexpected IRQ message. "Intel Pentium and Celeron Processor N- and J- Series" volume 3 doc mentions that GPIO interrupt enable and status registers default value is 0x0. The fix clears INT3452 GPIO interrupt enabled and interrupt pending registers in its probe function. Fixes: 7981c0015af2 ("pinctrl: intel: Add Intel Sunrisepoint pin controller= and GPIO support") Signed-off-by: =C5=81ukasz Bartosik Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/intel/pinctrl-intel.c | 54 +++++++++++++++++++++--------= ----- 1 file changed, 34 insertions(+), 20 deletions(-) --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1210,6 +1210,39 @@ static irqreturn_t intel_gpio_irq(int ir return IRQ_RETVAL(ret); } =20 +static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) +{ + int i; + + for (i =3D 0; i < pctrl->ncommunities; i++) { + const struct intel_community *community; + void __iomem *base; + unsigned int gpp; + + community =3D &pctrl->communities[i]; + base =3D community->regs; + + for (gpp =3D 0; gpp < community->ngpps; gpp++) { + /* Mask and clear all interrupts */ + writel(0, base + community->ie_offset + gpp * 4); + writel(0xffff, base + community->is_offset + gpp * 4); + } + } +} + +static int intel_gpio_irq_init_hw(struct gpio_chip *gc) +{ + struct intel_pinctrl *pctrl =3D gpiochip_get_data(gc); + + /* + * Make sure the interrupt lines are in a proper state before + * further configuration. + */ + intel_gpio_irq_init(pctrl); + + return 0; +} + static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl, const struct intel_community *community) { @@ -1314,6 +1347,7 @@ static int intel_gpio_probe(struct intel girq->num_parents =3D 0; girq->default_type =3D IRQ_TYPE_NONE; girq->handler =3D handle_bad_irq; + girq->init_hw =3D intel_gpio_irq_init_hw; =20 ret =3D devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl); if (ret) { @@ -1689,26 +1723,6 @@ int intel_pinctrl_suspend_noirq(struct d } EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq); =20 -static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) -{ - size_t i; - - for (i =3D 0; i < pctrl->ncommunities; i++) { - const struct intel_community *community; - void __iomem *base; - unsigned int gpp; - - community =3D &pctrl->communities[i]; - base =3D community->regs; - - for (gpp =3D 0; gpp < community->ngpps; gpp++) { - /* Mask and clear all interrupts */ - writel(0, base + community->ie_offset + gpp * 4); - writel(0xffff, base + community->is_offset + gpp * 4); - } - } -} - static bool intel_gpio_update_reg(void __iomem *reg, u32 mask, u32 value) { u32 curr, updated; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D869EC38A2B for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391475AbiBGMB4 (ORCPT ); Mon, 7 Feb 2022 07:01:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386790AbiBGLg6 (ORCPT ); Mon, 7 Feb 2022 06:36:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FC2DC043181; Mon, 7 Feb 2022 03:36:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 9FFC960B20; Mon, 7 Feb 2022 11:36:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7712BC004E1; Mon, 7 Feb 2022 11:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233816; bh=DX9ZtOOKRH0mzrq1ltNPjopdAWTDfpB8KXDdSkYRa0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwZtTThMYaLka2Bz9ylYBwSRYQqX3F3bmhDQmi1PjpUEBjx+kqoOE0bOEejqdPYTn s4mdLLqKAqgRksu9iEOvsgjiG7Pyf6JK30ws9HyvqMpXAk68xZRA9fctKaD5+jnIdY uSSMuRGSWlZ0vMoW3ZOTAXNOTD9axa6b9R96k1OE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Linus Walleij Subject: [PATCH 5.16 096/126] pinctrl: bcm2835: Fix a few error paths Date: Mon, 7 Feb 2022 12:07:07 +0100 Message-Id: <20220207103807.395308718@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Fainelli commit 5297c693d8c8e08fa742e3112cf70723f7a04da2 upstream. After commit 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") a few error paths would not unwind properly the registration of gpio ranges. Correct that by assigning a single error label and goto it whenever we encounter a fatal error. Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1264,16 +1264,18 @@ static int bcm2835_pinctrl_probe(struct sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) { - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return -ENOMEM; + err =3D -ENOMEM; + goto out_remove; } =20 if (is_7211) { pc->wake_irq =3D devm_kcalloc(dev, BCM2835_NUM_IRQS, sizeof(*pc->wake_irq), GFP_KERNEL); - if (!pc->wake_irq) - return -ENOMEM; + if (!pc->wake_irq) { + err =3D -ENOMEM; + goto out_remove; + } } =20 /* @@ -1301,8 +1303,10 @@ static int bcm2835_pinctrl_probe(struct =20 len =3D strlen(dev_name(pc->dev)) + 16; name =3D devm_kzalloc(pc->dev, len, GFP_KERNEL); - if (!name) - return -ENOMEM; + if (!name) { + err =3D -ENOMEM; + goto out_remove; + } =20 snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); =20 @@ -1321,11 +1325,14 @@ static int bcm2835_pinctrl_probe(struct err =3D gpiochip_add_data(&pc->gpio_chip, pc); if (err) { dev_err(dev, "could not add GPIO chip\n"); - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return err; + goto out_remove; } =20 return 0; + +out_remove: + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); + return err; } =20 static struct platform_driver bcm2835_pinctrl_driver =3D { From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECCA3C38A2E for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391496AbiBGMCA (ORCPT ); Mon, 7 Feb 2022 07:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386791AbiBGLhA (ORCPT ); Mon, 7 Feb 2022 06:37:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF85C043188; Mon, 7 Feb 2022 03:37:00 -0800 (PST) Received: from smtp.kernel.org (relay.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 CCA996091A; Mon, 7 Feb 2022 11:36:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FE55C004E1; Mon, 7 Feb 2022 11:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233819; bh=djEWEpnDCk7CcnGly2CXbCMMBRAixEGBx4BvC4JPjCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Apvbl6NMzg4LjzuN/CnA6CrezgJeMBL1lvWsGDMtmpY7DPCW3g6o16VItoiqHWKle 9EIttKGVBCHVQ/AoCPSP1RAwDUrg67S+QpbRDESFfPKOh6by5REbhAWXjyyvd6TyjX on4DPoNxD2AnCZi+LGqvWxj9oSwiahcZO7sqninY= 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.16 097/126] btrfs: fix use of uninitialized variable at rm device ioctl Date: Mon, 7 Feb 2022 12:07:08 +0100 Message-Id: <20220207103807.431628136@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Linux Kernel Functional Testing --- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3310,7 +3310,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 Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A561C35272 for ; Mon, 7 Feb 2022 12:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391514AbiBGMCE (ORCPT ); Mon, 7 Feb 2022 07:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386796AbiBGLhF (ORCPT ); Mon, 7 Feb 2022 06:37:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151E8C043188; Mon, 7 Feb 2022 03:37:05 -0800 (PST) Received: from smtp.kernel.org (relay.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 C5698B8112C; Mon, 7 Feb 2022 11:37:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8170C004E1; Mon, 7 Feb 2022 11:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233822; bh=dDv+O0Tzmkl7n2hL6tah/Kh7Z2X5dd7k5qI4BVpOqWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k23FOMvLZS1geTYfhGMuytgHJTAExTZsN9nJrjST35y46Bj78bv3gV+YMpmDqZ1Q0 h1YfZoHEB80JN6VPxK+T9w9fPEYKBQrh4qTU102X8/JFAxkrwPwMok5aDVZE2DqSE1 Zb+5ClnIeXt0v9SBtfKzff6epJIc6lLhgSRlhod0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guangwu Zhang , Saurav Kashyap , John Meneghini , "Martin K. Petersen" Subject: [PATCH 5.16 098/126] scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe Date: Mon, 7 Feb 2022 12:07:09 +0100 Message-Id: <20220207103807.462139400@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: John Meneghini commit 936bd03405fc83ba039d42bc93ffd4b88418f1d3 upstream. Running tests with a debug kernel shows that bnx2fc_recv_frame() is modifying the per_cpu lport stats counters in a non-mpsafe way. Just boot a debug kernel and run the bnx2fc driver with the hardware enabled. [ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code= : bnx2fc_ [ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc] [ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted= : G B [ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013 [ 1391.699183] Call Trace: [ 1391.699188] dump_stack_lvl+0x57/0x7d [ 1391.699198] check_preemption_disabled+0xc8/0xd0 [ 1391.699205] bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc] [ 1391.699215] ? do_raw_spin_trylock+0xb5/0x180 [ 1391.699221] ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc] [ 1391.699229] ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc] [ 1391.699240] bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc] [ 1391.699250] ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc] [ 1391.699258] kthread+0x364/0x420 [ 1391.699263] ? _raw_spin_unlock_irq+0x24/0x50 [ 1391.699268] ? set_kthread_struct+0x100/0x100 [ 1391.699273] ret_from_fork+0x22/0x30 Restore the old get_cpu/put_cpu code with some modifications to reduce the size of the critical section. Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com Fixes: d576a5e80cd0 ("bnx2fc: Improve stats update mechanism") Tested-by: Guangwu Zhang Acked-by: Saurav Kashyap Signed-off-by: John Meneghini Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -508,7 +508,8 @@ static int bnx2fc_l2_rcv_thread(void *ar =20 static void bnx2fc_recv_frame(struct sk_buff *skb) { - u32 fr_len; + u64 crc_err; + u32 fr_len, fr_crc; struct fc_lport *lport; struct fcoe_rcv_info *fr; struct fc_stats *stats; @@ -542,6 +543,11 @@ static void bnx2fc_recv_frame(struct sk_ skb_pull(skb, sizeof(struct fcoe_hdr)); fr_len =3D skb->len - sizeof(struct fcoe_crc_eof); =20 + stats =3D per_cpu_ptr(lport->stats, get_cpu()); + stats->RxFrames++; + stats->RxWords +=3D fr_len / FCOE_WORD_TO_BYTE; + put_cpu(); + fp =3D (struct fc_frame *)skb; fc_frame_init(fp); fr_dev(fp) =3D lport; @@ -624,16 +630,15 @@ static void bnx2fc_recv_frame(struct sk_ return; } =20 - stats =3D per_cpu_ptr(lport->stats, smp_processor_id()); - stats->RxFrames++; - stats->RxWords +=3D fr_len / FCOE_WORD_TO_BYTE; + fr_crc =3D le32_to_cpu(fr_crc(fp)); =20 - if (le32_to_cpu(fr_crc(fp)) !=3D - ~crc32(~0, skb->data, fr_len)) { - if (stats->InvalidCRCCount < 5) + if (unlikely(fr_crc !=3D ~crc32(~0, skb->data, fr_len))) { + stats =3D per_cpu_ptr(lport->stats, get_cpu()); + crc_err =3D (stats->InvalidCRCCount++); + put_cpu(); + if (crc_err < 5) printk(KERN_WARNING PFX "dropping frame with " "CRC error\n"); - stats->InvalidCRCCount++; kfree_skb(skb); return; } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8760C4321E for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386252AbiBGLtk (ORCPT ); Mon, 7 Feb 2022 06:49:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386685AbiBGLfU (ORCPT ); Mon, 7 Feb 2022 06:35:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3900C043181; Mon, 7 Feb 2022 03:35:19 -0800 (PST) Received: from smtp.kernel.org (relay.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 0831AB80EBD; Mon, 7 Feb 2022 11:35:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4637EC004E1; Mon, 7 Feb 2022 11:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233716; bh=TdKdDS8mr/Iv2O+Ke94fu/1lpmuGq84s4HlElW3efN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBpMiAfmmj6gTrQC8RXLZpwpaeWCEgS8CtOidTXx+kYzyCTpLF2EF0h3Ue8kZyW+d DsIoAU4LOg3pq67pfEq9S0s3vLKGhN/QNTrGNMnsjHPSyAaqjL09HoIUFlzunXcklS QDiq2+Ho95DCxkNfdOWn6QHXclgmd5q0o9T0BU90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dai Ngo , Chuck Lever , Bruce Fields Subject: [PATCH 5.16 099/126] nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client. Date: Mon, 7 Feb 2022 12:07:10 +0100 Message-Id: <20220207103807.498649276@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Dai Ngo commit ab451ea952fe9d7afefae55ddb28943a148247fe upstream. >From RFC 7530 Section 16.34.5: o The server has not recorded an unconfirmed { v, x, c, *, * } and has recorded a confirmed { v, x, c, *, s }. If the principals of the record and of SETCLIENTID_CONFIRM do not match, the server returns NFS4ERR_CLID_INUSE without removing any relevant leased client state, and without changing recorded callback and callback_ident values for client { x }. The current code intends to do what the spec describes above but it forgot to set 'old' to NULL resulting to the confirmed client to be expired. Fixes: 2b63482185e6 ("nfsd: fix clid_inuse on mount with security change") Signed-off-by: Dai Ngo Signed-off-by: Chuck Lever Reviewed-by: Bruce Fields Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs4state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4112,8 +4112,10 @@ nfsd4_setclientid_confirm(struct svc_rqs status =3D nfserr_clid_inuse; if (client_has_state(old) && !same_creds(&unconf->cl_cred, - &old->cl_cred)) + &old->cl_cred)) { + old =3D NULL; goto out; + } status =3D mark_client_expired_locked(old); if (status) { old =3D NULL; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0B4CC4167B for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386484AbiBGLtr (ORCPT ); Mon, 7 Feb 2022 06:49:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386692AbiBGLfY (ORCPT ); Mon, 7 Feb 2022 06:35:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14237C043181; Mon, 7 Feb 2022 03:35:22 -0800 (PST) Received: from smtp.kernel.org (relay.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 98659B8112C; Mon, 7 Feb 2022 11:35:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDEBEC004E1; Mon, 7 Feb 2022 11:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233720; bh=ltgwrwtKt8xHd3CXYRwUOLL0p3DAs3UWKiWzsRUVJi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xkUbl18pbkIbI+wYslySfQ06iNueEAuDHHucBzeWTdgqP/iW0QWTtUuf429dsNyHc FSbQCFj9wdKZCwIUvZ3bf3h/yuzHlp2aBG13KfwQRYCMGVj+6K4RxCBIpN/nVnS13r BlNGQpOYvKMopKCy0udvqV59ftgoEbb7f8Pn7LnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haiyue Wang , "David S. Miller" Subject: [PATCH 5.16 100/126] gve: fix the wrong AdminQ buffer queue index check Date: Mon, 7 Feb 2022 12:07:11 +0100 Message-Id: <20220207103807.532064652@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Haiyue Wang commit 1f84a9450d75e08af70d9e2f2d5e1c0ac0c881d2 upstream. The 'tail' and 'head' are 'unsigned int' type free-running count, when 'head' is overflow, the 'int i (=3D tail) < u32 head' will be false: Only '- loop 0: idx =3D 63' result is shown, so it needs to use 'int' type to compare, it can handle the overflow correctly. typedef uint32_t u32; int main() { u32 tail, head; int stail, shead; int i, loop; tail =3D 0xffffffff; head =3D 0x00000000; for (i =3D tail, loop =3D 0; i < head; i++) { unsigned int idx =3D i & 63; printf("+ loop %d: idx =3D %u\n", loop++, idx); } stail =3D tail; shead =3D head; for (i =3D stail, loop =3D 0; i < shead; i++) { unsigned int idx =3D i & 63; printf("- loop %d: idx =3D %u\n", loop++, idx); } return 0; } Fixes: 5cdad90de62c ("gve: Batch AQ commands for creating and destroying qu= eues.") Signed-off-by: Haiyue Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/google/gve/gve_adminq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -301,7 +301,7 @@ static int gve_adminq_parse_err(struct g */ static int gve_adminq_kick_and_wait(struct gve_priv *priv) { - u32 tail, head; + int tail, head; int i; =20 tail =3D ioread32be(&priv->reg_bar0->adminq_event_counter); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0D60C43219 for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389516AbiBGLtu (ORCPT ); Mon, 7 Feb 2022 06:49:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386696AbiBGLfZ (ORCPT ); Mon, 7 Feb 2022 06:35:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F07C043188; Mon, 7 Feb 2022 03:35:24 -0800 (PST) Received: from smtp.kernel.org (relay.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 189E360180; Mon, 7 Feb 2022 11:35:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E56BEC004E1; Mon, 7 Feb 2022 11:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233723; bh=FaEL32L8jTCbwx8zIa5szTEouuCoK0lO5+KhZu49YAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1/krfcy1K2hqBrDEZ5O75BE8zWMFiSWf7yB/ip/zYBnJImyk+O80tnwX5tFFMWrJY NeG9BjqQMq2Bc1gG1YhOB8RxQhtfAVxbN7xMf7r2NHYsUBB36atMcpmwws1KbZGVaQ YPjZZwaq+nm+jrerNBhZIAXkC6btzJp/SJ8tOZWQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com, Hou Tao , Andrii Nakryiko Subject: [PATCH 5.16 101/126] bpf: Use VM_MAP instead of VM_ALLOC for ringbuf Date: Mon, 7 Feb 2022 12:07:12 +0100 Message-Id: <20220207103807.566411893@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit b293dcc473d22a62dc6d78de2b15e4f49515db56 upstream. After commit 2fd3fb0be1d1 ("kasan, vmalloc: unpoison VM_ALLOC pages after mapping"), non-VM_ALLOC mappings will be marked as accessible in __get_vm_area_node() when KASAN is enabled. But now the flag for ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access after vmap() returns. Because the ringbuf area is created by mapping allocated pages, so use VM_MAP instead. After the change, info in /proc/vmallocinfo also changes from [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmalloc user to [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmap user Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support f= or it") Reported-by: syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com Signed-off-by: Hou Tao Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220202060158.6260-1-houtao1@huawei.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -104,7 +104,7 @@ static struct bpf_ringbuf *bpf_ringbuf_a } =20 rb =3D vmap(pages, nr_meta_pages + 2 * nr_data_pages, - VM_ALLOC | VM_USERMAP, PAGE_KERNEL); + VM_MAP | VM_USERMAP, PAGE_KERNEL); if (rb) { kmemleak_not_leak(pages); rb->pages =3D pages; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6C62C4167E for ; Mon, 7 Feb 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389528AbiBGLt6 (ORCPT ); Mon, 7 Feb 2022 06:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377058AbiBGLf2 (ORCPT ); Mon, 7 Feb 2022 06:35:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8465CC043188; Mon, 7 Feb 2022 03:35:27 -0800 (PST) Received: from smtp.kernel.org (relay.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 2276360DBF; Mon, 7 Feb 2022 11:35:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03BB3C004E1; Mon, 7 Feb 2022 11:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233726; bh=+nRe8g/tE2F5FU0y+dnQVbMd4p5XFCbxsci5pHSsjd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SLTGvaF2+Ia63l5vsb5kLATfzRw1NAGbj2MDCGwUH1QMnOsO1UKjvPVKQ3shoTj8q vvoyKVZ7sGPgZZ2H3V1Bf2oYEmAH1xgoDWELVARoyZr2aI9Z4LOfsoTspeKxvhOXcY uJ05GFa1WcrZboBrip/s6UQaP9vihZusdzHmwzRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Usama Anjum , Shuah Khan Subject: [PATCH 5.16 102/126] selftests/exec: Remove pipe from TEST_GEN_FILES Date: Mon, 7 Feb 2022 12:07:13 +0100 Message-Id: <20220207103807.598278314@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Muhammad Usama Anjum commit 908a26e139e8cf21093acc56d8e90ddad2ad1eff upstream. pipe named FIFO special file is being created in execveat.c to perform some tests. Makefile doesn't need to do anything with the pipe. When it isn't found, Makefile generates the following build error: make: *** No rule to make target '../tools/testing/selftests/exec/pipe', needed by 'all'. Stop. pipe is created and removed during test run-time. Amended change log to add pipe remove info: Shuah Khan Fixes: 61016db15b8e ("selftests/exec: Verify execve of non-regular files fa= il") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Shuah Khan Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/exec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile @@ -5,7 +5,7 @@ CFLAGS +=3D -D_GNU_SOURCE =20 TEST_PROGS :=3D binfmt_script non-regular TEST_GEN_PROGS :=3D execveat load_address_4096 load_address_2097152 load_a= ddress_16777216 -TEST_GEN_FILES :=3D execveat.symlink execveat.denatured script subdir pipe +TEST_GEN_FILES :=3D execveat.symlink execveat.denatured script subdir # Makefile is a run-time dependency, since it's accessed by the execveat t= est TEST_FILES :=3D Makefile =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4C5AC4707E for ; Mon, 7 Feb 2022 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391224AbiBGL6q (ORCPT ); Mon, 7 Feb 2022 06:58:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234254AbiBGLfb (ORCPT ); Mon, 7 Feb 2022 06:35:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8268C0401C0; Mon, 7 Feb 2022 03:35:30 -0800 (PST) Received: from smtp.kernel.org (relay.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 48C3760C8E; Mon, 7 Feb 2022 11:35:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15078C34115; Mon, 7 Feb 2022 11:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233729; bh=72vwZ6kvzEMAGleLWY/VTPiDOeZhPnE8/1zmPpNqG64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzCR8vh5EaY05i3punSAkUhOEpAbMnOjShiYVd8TXlrdi6zKwiFGMFPXLPKSD2FKu l7+0IobBfZt2AmcSq3t9nwcSznc8yYt6AalUF3KHG9CDnYXmrLrM+598kWceYTv2Ua KEVVz7iGvESIRXRbBYxDM/24wdgkwJbobC6PFHVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Usama Anjum , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Shuah Khan Subject: [PATCH 5.16 103/126] selftests: futex: Use variable MAKE instead of make Date: Mon, 7 Feb 2022 12:07:14 +0100 Message-Id: <20220207103807.628539253@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Muhammad Usama Anjum commit b9199181a9ef8252e47e207be8c23e1f50662620 upstream. Recursive make commands should always use the variable MAKE, not the explicit command name =E2=80=98make=E2=80=99. This has benefits and removes= the following warning when multiple jobs are used for the build: make[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make= rule. Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/futex/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile @@ -11,7 +11,7 @@ all: @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ - make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ if [ -e $$DIR/$(TEST_PROGS) ]; then \ rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \ fi \ @@ -32,6 +32,6 @@ override define CLEAN @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ - make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ done endef From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74402C433F5 for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391235AbiBGL6r (ORCPT ); Mon, 7 Feb 2022 06:58:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377374AbiBGLfl (ORCPT ); Mon, 7 Feb 2022 06:35:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC1AC043181; Mon, 7 Feb 2022 03:35:35 -0800 (PST) Received: from smtp.kernel.org (relay.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 1E1C2B8102E; Mon, 7 Feb 2022 11:35:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F280C004E1; Mon, 7 Feb 2022 11:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233732; bh=rG2zIR8em5dhqg9au0dA4l5hkYO7yd8NVH3Wp/6VZIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1apEzEnvBsg4VpLViCOUh4rdVxLvuGvg7ZFJQTUTCczIMFo4ZKwAt/wLnH49F7Pr eoQI2J2GBah31nB0SQ5z8FyNkjfURov/EsiquhX2uDRmdVha7hJp1vdVclMpcZo2Po 8OzOoqkAWEMaXHr1+zgPyDQa28CHyHChDMd9OFaE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Daniel Borkmann Subject: [PATCH 5.16 104/126] tools/resolve_btfids: Do not print any commands when building silently Date: Mon, 7 Feb 2022 12:07:15 +0100 Message-Id: <20220207103807.658593946@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Nathan Chancellor commit 7f3bdbc3f13146eb9d07de81ea71f551587a384b upstream. When building with 'make -s', there is some output from resolve_btfids: $ make -sj"$(nproc)" oldconfig prepare MKDIR .../tools/bpf/resolve_btfids/libbpf/ MKDIR .../tools/bpf/resolve_btfids//libsubcmd LINK resolve_btfids Silent mode means that no information should be emitted about what is currently being done. Use the $(silent) variable from Makefile.include to avoid defining the msg macro so that there is no information printed. Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in EL= F object") Signed-off-by: Nathan Chancellor Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20220201212503.731732-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/bpf/resolve_btfids/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -9,7 +9,11 @@ ifeq ($(V),1) msg =3D else Q =3D @ - msg =3D @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3)= )"; + ifeq ($(silent),1) + msg =3D + else + msg =3D @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(= 3))"; + endif MAKEFLAGS=3D--no-print-directory endif =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CEC8C433FE for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391248AbiBGL6t (ORCPT ); Mon, 7 Feb 2022 06:58:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377733AbiBGLfq (ORCPT ); Mon, 7 Feb 2022 06:35:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23AA2C0401F6; Mon, 7 Feb 2022 03:35:37 -0800 (PST) Received: from smtp.kernel.org (relay.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 A887B60B20; Mon, 7 Feb 2022 11:35:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D16C004E1; Mon, 7 Feb 2022 11:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233736; bh=KaEEvikqmO26oxdyVGpMjrHrH9qyqqylOufY9OgAjLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5Ro1r8Who5MF/UvYIxjxEWBob1BNUcYZ4a53aIZLo7oI5Tn9a0iYexpRpS1VuAE8 1B3lq0vGJJZfECEe9qzH9lJWj10ZReZbWYP7qMiaBl/sZoG4NFE66hbHV/IYybuctm W5E51rTUwYw5sq/AQLnsN2lK70kkxA1i8BVU3hxs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Dima Ruinskiy , Sasha Neftin , Nechama Kraus , Tony Nguyen Subject: [PATCH 5.16 105/126] e1000e: Separate ADP board type from TGP Date: Mon, 7 Feb 2022 12:07:16 +0100 Message-Id: <20220207103807.690836971@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Sasha Neftin commit 68defd528f94ed1cf11f49a75cc1875dccd781fa upstream. We have the same LAN controller on different PCH's. Separate ADP board type from a TGP which will allow for specific fixes to be applied for ADP platforms. Suggested-by: Kai-Heng Feng Suggested-by: Dima Ruinskiy Signed-off-by: Sasha Neftin Tested-by: Nechama Kraus Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/intel/e1000e/e1000.h | 4 ++- drivers/net/ethernet/intel/e1000e/ich8lan.c | 20 ++++++++++++++++ drivers/net/ethernet/intel/e1000e/netdev.c | 33 ++++++++++++++---------= ----- 3 files changed, 40 insertions(+), 17 deletions(-) --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -115,7 +115,8 @@ enum e1000_boards { board_pch_lpt, board_pch_spt, board_pch_cnp, - board_pch_tgp + board_pch_tgp, + board_pch_adp }; =20 struct e1000_ps_page { @@ -502,6 +503,7 @@ extern const struct e1000_info e1000_pch extern const struct e1000_info e1000_pch_spt_info; extern const struct e1000_info e1000_pch_cnp_info; extern const struct e1000_info e1000_pch_tgp_info; +extern const struct e1000_info e1000_pch_adp_info; extern const struct e1000_info e1000_es2_info; =20 void e1000e_ptp_init(struct e1000_adapter *adapter); --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -6021,3 +6021,23 @@ const struct e1000_info e1000_pch_tgp_in .phy_ops =3D &ich8_phy_ops, .nvm_ops =3D &spt_nvm_ops, }; + +const struct e1000_info e1000_pch_adp_info =3D { + .mac =3D e1000_pch_adp, + .flags =3D FLAG_IS_ICH + | FLAG_HAS_WOL + | FLAG_HAS_HW_TIMESTAMP + | FLAG_HAS_CTRLEXT_ON_LOAD + | FLAG_HAS_AMT + | FLAG_HAS_FLASH + | FLAG_HAS_JUMBO_FRAMES + | FLAG_APME_IN_WUC, + .flags2 =3D FLAG2_HAS_PHY_STATS + | FLAG2_HAS_EEE, + .pba =3D 26, + .max_hw_frame_size =3D 9022, + .get_variants =3D e1000_get_variants_ich8lan, + .mac_ops =3D &ich8_mac_ops, + .phy_ops =3D &ich8_phy_ops, + .nvm_ops =3D &spt_nvm_ops, +}; --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -52,6 +52,7 @@ static const struct e1000_info *e1000_in [board_pch_spt] =3D &e1000_pch_spt_info, [board_pch_cnp] =3D &e1000_pch_cnp_info, [board_pch_tgp] =3D &e1000_pch_tgp_info, + [board_pch_adp] =3D &e1000_pch_adp_info, }; =20 struct e1000_reg_info { @@ -7904,22 +7905,22 @@ static const struct pci_device_id e1000_ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V14), board_pch_tgp }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_LM15), board_pch_tgp }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V15), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM23), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V23), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM16), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V16), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM17), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V17), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM22), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V22), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM18), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V18), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM19), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V19), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM20), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V20), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM21), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V21), board_pch_tgp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM23), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V23), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM16), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V16), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM17), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V17), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM22), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V22), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM18), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V18), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM19), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V19), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM20), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V20), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM21), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V21), board_pch_adp }, =20 { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */ }; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F486C433EF for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391260AbiBGL6w (ORCPT ); Mon, 7 Feb 2022 06:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377754AbiBGLfr (ORCPT ); Mon, 7 Feb 2022 06:35:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 638DEC03FEC8; Mon, 7 Feb 2022 03:35:40 -0800 (PST) Received: from smtp.kernel.org (relay.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 D62E260180; Mon, 7 Feb 2022 11:35:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96E11C004E1; Mon, 7 Feb 2022 11:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233739; bh=DFsm60ujwlq6xrmRluf3V0gZYV+0uKA4KIhEf3z/2VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODjv018DgL4WC527PwuUfriM21P3W+DY7QmWol6Nv8tcIKGfRw7XMhztC4ewTrqry 64dPLMpyuND8FDRAnMIddDMGjnqjpkYRsXEuCniR8PkNu/QPhRJK+E6YtgqhThLbGx jxTHPHEAp0N//JuKPATpbGTgMWan9LToxGwZtez4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riwen Lu , Eric Wong , =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alexandre Belloni Subject: [PATCH 5.16 106/126] rtc: cmos: Evaluate century appropriate Date: Mon, 7 Feb 2022 12:07:17 +0100 Message-Id: <20220207103807.720623227@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Riwen Lu commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream. There's limiting the year to 2069. When setting the rtc year to 2070, reading it returns 1970. Evaluate century starting from 19 to count the correct year. $ sudo date -s 20700106 Mon 06 Jan 2070 12:00:00 AM CST $ sudo hwclock -w $ sudo hwclock -r 1970-01-06 12:00:49.604968+08:00 Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte") Signed-off-by: Riwen Lu Acked-by: Eric Wong Reviewed-by: Mateusz Jo=C5=84czyk Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn Signed-off-by: Mateusz Jo=C5=84czyk # preparation for s= table Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/rtc/rtc-mc146818-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -104,7 +104,7 @@ again: time->tm_year +=3D real_year - 72; #endif =20 - if (century > 20) + if (century > 19) time->tm_year +=3D (century - 19) * 100; =20 /* From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF009C4332F for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391272AbiBGL6y (ORCPT ); Mon, 7 Feb 2022 06:58:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378322AbiBGLfu (ORCPT ); Mon, 7 Feb 2022 06:35:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66ED9C0401C3; Mon, 7 Feb 2022 03:35:43 -0800 (PST) Received: from smtp.kernel.org (relay.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 042A060B5B; Mon, 7 Feb 2022 11:35:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCDE2C004E1; Mon, 7 Feb 2022 11:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233742; bh=Z7H7oZrmQOOS5dhXt+kfnsPedSGfqT1i5+pCQHO2n5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QT4Km53LWiJ+Bg3Evq/VAcdYGefZvDoDtkhEs2JagNk8vVcFDbt3XKHGhFs6Phy69 Z6hgqrurdgpQdeQxmk9m+Ax5s9lrf5Z3gC8aUx3ttehbB7xqStJV95lyT4UqlFnf/t NXyxf40NuQDRHwe5xzKfgEJfBbasYrZRUgCNNKhk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Borowski , =?UTF-8?q?Martin=20Li=C5=A1ka?= , Sergei Trofimovich , Josh Poimboeuf , Sasha Levin Subject: [PATCH 5.16 107/126] objtool: Fix truncated string warning Date: Mon, 7 Feb 2022 12:07:18 +0100 Message-Id: <20220207103807.759609312@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Sergei Trofimovich [ Upstream commit 82880283d7fcd0a1d20964a56d6d1a5cc0df0713 ] On GCC 12, the build fails due to a possible truncated string: check.c: In function 'validate_call': check.c:2865:58: error: '%d' directive output may be truncated writing = between 1 and 10 bytes into a region of size 9 [-Werror=3Dformat-truncation= =3D] 2865 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", = idx); | ^~ In theory it's a valid bug: static char pvname[16]; int idx; ... idx =3D (rel->addend / sizeof(void *)); snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx); There are only 7 chars for %d while it could take up to 9, so the printed "pv_ops[%d]" string could get truncated. In reality the bug should never happen, because pv_ops only has ~80 entries, so 7 chars for the integer is more than enough. Still, it's worth fixing. Bump the buffer size by 2 bytes to silence the warning. [ jpoimboe: changed size to 19; massaged changelog ] Fixes: db2b0c5d7b6f ("objtool: Support pv_opsindirect calls for noinstr") Reported-by: Adam Borowski Reported-by: Martin Li=C5=A1ka Signed-off-by: Sergei Trofimovich Signed-off-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20220120233748.2062559-1-slyich@gmail.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 21735829b860c..750ef1c446c8a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2823,7 +2823,7 @@ static inline bool func_uaccess_safe(struct symbol *f= unc) =20 static inline const char *call_dest_name(struct instruction *insn) { - static char pvname[16]; + static char pvname[19]; struct reloc *rel; int idx; =20 --=20 2.34.1 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B482C352A8 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233173AbiBGL65 (ORCPT ); Mon, 7 Feb 2022 06:58:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378601AbiBGLf4 (ORCPT ); Mon, 7 Feb 2022 06:35:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE4CC0401C2; Mon, 7 Feb 2022 03:35:48 -0800 (PST) Received: from smtp.kernel.org (relay.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 DA6E6B8112C; Mon, 7 Feb 2022 11:35:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9BD2C004E1; Mon, 7 Feb 2022 11:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233745; bh=L7Ua2JQNOCa06ZsUU44srCbAmLOJXVGTcK1MykbM4Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qX054NArC84lEl8xczT06RMS/Ueu2VsOaLpocVYuVmGADv40cFoTtH3oacPD3JPd2 O+2q1oprRVPF15q4rrTD5WGaMhgNBI3k/ixAQfqJyyObszTMGci4E3hfsYEX/3kgFX PtZnoryfH+LdH9rQzdJzDI3aWr/SgPu5JNIjZSPU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Mark Rutland , Marc Zyngier , Alexandru Elisei , Catalin Marinas , Frederic Weisbecker , James Morse , Paolo Bonzini , "Paul E. McKenney" , Suzuki K Poulose , Will Deacon , Sasha Levin Subject: [PATCH 5.16 108/126] kvm/arm64: rework guest entry logic Date: Mon, 7 Feb 2022 12:07:19 +0100 Message-Id: <20220207103807.791632381@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 8cfe148a7136bc60452a5c6b7ac2d9d15c36909b ] In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to exiting the EQS by calling guest_exit(). As the IRQ entry code will not wake RCU in this case, we may run the core IRQ code and IRQ handler without RCU watching, leading to various potential problems. Additionally, we do not inform lockdep or tracing that interrupts will be enabled during guest execution, which caan lead to misleading traces and warnings that interrupts have been enabled for overly-long periods. This patch fixes these issues by using the new timing and context entry/exit helpers to ensure that interrupts are handled during guest vtime but with RCU watching, with a sequence: guest_timing_enter_irqoff(); guest_state_enter_irqoff(); < run the vcpu > guest_state_exit_irqoff(); < take any pending IRQs > guest_timing_exit_irqoff(); Since instrumentation may make use of RCU, we must also ensure that no instrumented code is run during the EQS. I've split out the critical section into a new kvm_arm_enter_exit_vcpu() helper which is marked noinstr. Fixes: 1b3d546daf85ed2b ("arm/arm64: KVM: Properly account for guest CPU ti= me") Reported-by: Nicolas Saenz Julienne Signed-off-by: Mark Rutland Reviewed-by: Marc Zyngier Reviewed-by: Nicolas Saenz Julienne Cc: Alexandru Elisei Cc: Catalin Marinas Cc: Frederic Weisbecker Cc: James Morse Cc: Paolo Bonzini Cc: Paul E. McKenney Cc: Suzuki K Poulose Cc: Will Deacon Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/arm.c | 51 ++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e4727dc771bf3..b2222d8eb0b55 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -764,6 +764,24 @@ static bool kvm_vcpu_exit_request(struct kvm_vcpu *vcp= u, int *ret) xfer_to_guest_mode_work_pending(); } =20 +/* + * Actually run the vCPU, entering an RCU extended quiescent state (EQS) w= hile + * the vCPU is running. + * + * This must be noinstr as instrumentation may make use of RCU, and this i= s not + * safe during the EQS. + */ +static int noinstr kvm_arm_vcpu_enter_exit(struct kvm_vcpu *vcpu) +{ + int ret; + + guest_state_enter_irqoff(); + ret =3D kvm_call_hyp_ret(__kvm_vcpu_run, vcpu); + guest_state_exit_irqoff(); + + return ret; +} + /** * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest c= ode * @vcpu: The VCPU pointer @@ -854,9 +872,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) * Enter the guest */ trace_kvm_entry(*vcpu_pc(vcpu)); - guest_enter_irqoff(); + guest_timing_enter_irqoff(); =20 - ret =3D kvm_call_hyp_ret(__kvm_vcpu_run, vcpu); + ret =3D kvm_arm_vcpu_enter_exit(vcpu); =20 vcpu->mode =3D OUTSIDE_GUEST_MODE; vcpu->stat.exits++; @@ -891,26 +909,23 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_arch_vcpu_ctxsync_fp(vcpu); =20 /* - * We may have taken a host interrupt in HYP mode (ie - * while executing the guest). This interrupt is still - * pending, as we haven't serviced it yet! + * We must ensure that any pending interrupts are taken before + * we exit guest timing so that timer ticks are accounted as + * guest time. Transiently unmask interrupts so that any + * pending interrupts are taken. * - * We're now back in SVC mode, with interrupts - * disabled. Enabling the interrupts now will have - * the effect of taking the interrupt again, in SVC - * mode this time. + * Per ARM DDI 0487G.b section D1.13.4, an ISB (or other + * context synchronization event) is necessary to ensure that + * pending interrupts are taken. */ local_irq_enable(); + isb(); + local_irq_disable(); + + guest_timing_exit_irqoff(); + + local_irq_enable(); =20 - /* - * We do local_irq_enable() before calling guest_exit() so - * that if a timer interrupt hits while running the guest we - * account that tick as being spent in the guest. We enable - * preemption after calling guest_exit() so that if we get - * preempted we make sure ticks after that is not counted as - * guest time. - */ - guest_exit(); trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu)); =20 /* Exit types that need handling before we can be preempted */ --=20 2.34.1 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2428C47086 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350081AbiBGL71 (ORCPT ); Mon, 7 Feb 2022 06:59:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382918AbiBGLf7 (ORCPT ); Mon, 7 Feb 2022 06:35:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 166C6C03FEC0; Mon, 7 Feb 2022 03:35:56 -0800 (PST) Received: from smtp.kernel.org (relay.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 C24A3B8102E; Mon, 7 Feb 2022 11:35:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7EBEC004E1; Mon, 7 Feb 2022 11:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233753; bh=fkBbCu26Q7qpm8psYy59pDkbehGMf3egVEF0vTplVJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HE0mrW9W8MeA9Wpe8m4c9iwVZwlql/IFrUq69jQGFai0AnO4/A04Bxs9UPgsZzHev vYh0AvM2gL8ST8DKZkVBqI/QSvEauKEH7UAPk/Uo6TQuzlkAZ1Vz8o3YYeYgrF+3PN fDsZS99gnSQ9yM5+9AyS3xNMEf9kJiZJU6SFfkYg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Marco Elver , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.16 109/126] perf: Copy perf_event_attr::sig_data on modification Date: Mon, 7 Feb 2022 12:07:20 +0100 Message-Id: <20220207103807.824862640@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Marco Elver [ Upstream commit 3c25fc97f5590060464cabfa25710970ecddbc96 ] The intent has always been that perf_event_attr::sig_data should also be modifiable along with PERF_EVENT_IOC_MODIFY_ATTRIBUTES, because it is observable by user space if SIGTRAP on events is requested. Currently only PERF_TYPE_BREAKPOINT is modifiable, and explicitly copies relevant breakpoint-related attributes in hw_breakpoint_copy_attr(). This misses copying perf_event_attr::sig_data. Since sig_data is not specific to PERF_TYPE_BREAKPOINT, introduce a helper to copy generic event-type-independent attributes on modification. Fixes: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events") Reported-by: Dmitry Vyukov Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dmitry Vyukov Link: https://lore.kernel.org/r/20220131103407.1971678-1-elver@google.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/events/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 6ed890480c4aa..04e6e2dae60e4 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3234,6 +3234,15 @@ static int perf_event_modify_breakpoint(struct perf_= event *bp, return err; } =20 +/* + * Copy event-type-independent attributes that may be modified. + */ +static void perf_event_modify_copy_attr(struct perf_event_attr *to, + const struct perf_event_attr *from) +{ + to->sig_data =3D from->sig_data; +} + static int perf_event_modify_attr(struct perf_event *event, struct perf_event_attr *attr) { @@ -3256,10 +3265,17 @@ static int perf_event_modify_attr(struct perf_event= *event, WARN_ON_ONCE(event->ctx->parent_ctx); =20 mutex_lock(&event->child_mutex); + /* + * Event-type-independent attributes must be copied before event-type + * modification, which will validate that final attributes match the + * source attributes after all relevant attributes have been copied. + */ + perf_event_modify_copy_attr(&event->attr, attr); err =3D func(event, attr); if (err) goto out; list_for_each_entry(child, &event->child_list, child_list) { + perf_event_modify_copy_attr(&child->attr, attr); err =3D func(child, attr); if (err) goto out; --=20 2.34.1 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC9B1C352AA for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359282AbiBGL7r (ORCPT ); Mon, 7 Feb 2022 06:59:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383135AbiBGLgC (ORCPT ); Mon, 7 Feb 2022 06:36:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8105C0401F1; Mon, 7 Feb 2022 03:35:57 -0800 (PST) Received: from smtp.kernel.org (relay.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 519AB60B5B; Mon, 7 Feb 2022 11:35:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06451C004E1; Mon, 7 Feb 2022 11:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233756; bh=fPYdKdWpnGHTHXZCbhnIuCJs8ENy0yQAD1fLx+dFIIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n323L2HBP4yIp3cYkzuaxs45whH3Cz7kRsppZd2/BxVpU23tP9CsJ8fFmijeZkUmU m2erVCxVQHV/Bn0VWNlpJlDABqRILV03+3zWqpmQv5x5n438fdI3lwEsBSf349jMyb rScTUe6HRaee2623h2Di9HnoT59A2JQd9ElAUDaY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Ian Rogers , Alexander Shishkin , Alexandre Torgue , Asaf Yaffe , Caleb Biggers , Ingo Molnar , James Clark , Jiri Olsa , John Garry , Kan Liang , Kshipra Bopardikar , Mark Rutland , Maxime Coquelin , Namhyung Kim , Perry Taylor , Peter Zijlstra , Stephane Eranian , Vineet Singh , Zhengjun Xing , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.16 110/126] perf stat: Fix display of grouped aliased events Date: Mon, 7 Feb 2022 12:07:21 +0100 Message-Id: <20220207103807.857049867@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Ian Rogers [ Upstream commit b2b1aa73ade982c175ac926a1fd34e76ad628b94 ] An event may have a number of uncore aliases that when added to the evlist are consecutive. If there are multiple uncore events in a group then parse_events__set_leader_for_uncore_aliase will reorder the evlist so that events on the same PMU are adjacent. The collect_all_aliases function assumes that aliases are in blocks so that only the first counter is printed and all others are marked merged. The reordering for groups breaks the assumption and so all counts are printed. This change removes the assumption from collect_all_aliases that the events are in blocks and instead processes the entire evlist. Before: ``` $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INS= ERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1 Performance counter stats for 'system wide': CPU0 256,866 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 494,413 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 967 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,738 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 285,161 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 429,920 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 955 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,443 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 310,753 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 416,657 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,231 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,573 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 416,067 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 405,966 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,481 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,447 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 312,911 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 408,154 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,086 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,380 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 333,994 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 370,349 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,287 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,335 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 188,107 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 302,423 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 701 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,070 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 307,221 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 383,642 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,036 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,158 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 318,479 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 821,545 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,028 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,550 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 227,618 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 372,272 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 903 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,456 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 376,783 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 419,827 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,406 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,453 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 286,583 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 429,956 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 999 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,436 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 313,867 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 370,159 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,114 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,291 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,083 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 409,111 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,399 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,684 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 365,828 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 376,037 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,378 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,411 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 382,456 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 621,743 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,232 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,955 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,316 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 385,067 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,176 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,268 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 373,588 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 386,163 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,394 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,464 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 381,206 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 546,891 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,266 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,712 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 221,176 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 392,069 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 831 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,456 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 355,401 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 705,595 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,235 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,216 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 371,436 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 428,103 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,306 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,442 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 384,352 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 504,200 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,468 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,860 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 228,856 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 287,976 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 832 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,060 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 215,121 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 334,162 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 681 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,026 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 296,179 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 436,083 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,084 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,525 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 262,296 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 416,573 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 986 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,533 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 285,852 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 359,842 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,073 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,326 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 303,379 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 367,222 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,008 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,156 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 273,487 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 425,449 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 932 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,367 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 297,596 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 414,793 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,140 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,601 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,365 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 360,422 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,291 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,342 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 327,196 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 580,858 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,122 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,014 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 296,564 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 452,817 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,087 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,694 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 375,002 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 389,393 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,478 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,540 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 365,213 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 594,685 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,401 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,222 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 1,000,749,060 ns duration_time 1.000749060 seconds time elapsed ``` After: ``` Performance counter stats for 'system wide': CPU0 20,547,434 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 45,202,862 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 82,001 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 159,688 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 1,000,464,828 ns duration_time 1.000464828 seconds time elapsed ``` Fixes: 3cdc5c2cb924acb4 ("perf parse-events: Handle uncore event aliases in= small groups properly") Reviewed-by: Andi Kleen Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Alexandre Torgue Cc: Asaf Yaffe Cc: Caleb Biggers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: John Garry Cc: Kan Liang Cc: Kshipra Bopardikar Cc: Mark Rutland Cc: Maxime Coquelin Cc: Namhyung Kim Cc: Perry Taylor Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vineet Singh Cc: Zhengjun Xing Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- tools/perf/util/stat-display.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 588601000f3f9..db00ca6a67deb 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -584,15 +584,16 @@ static void collect_all_aliases(struct perf_stat_conf= ig *config, struct evsel *c =20 alias =3D list_prepare_entry(counter, &(evlist->core.entries), core.node); list_for_each_entry_continue (alias, &evlist->core.entries, core.node) { - if (strcmp(evsel__name(alias), evsel__name(counter)) || - alias->scale !=3D counter->scale || - alias->cgrp !=3D counter->cgrp || - strcmp(alias->unit, counter->unit) || - evsel__is_clock(alias) !=3D evsel__is_clock(counter) || - !strcmp(alias->pmu_name, counter->pmu_name)) - break; - alias->merged_stat =3D true; - cb(config, alias, data, false); + /* Merge events with the same name, etc. but on different PMUs. */ + if (!strcmp(evsel__name(alias), evsel__name(counter)) && + alias->scale =3D=3D counter->scale && + alias->cgrp =3D=3D counter->cgrp && + !strcmp(alias->unit, counter->unit) && + evsel__is_clock(alias) =3D=3D evsel__is_clock(counter) && + strcmp(alias->pmu_name, counter->pmu_name)) { + alias->merged_stat =3D true; + cb(config, alias, data, false); + } } } =20 --=20 2.34.1 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 313FDC38A02 for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391337AbiBGMB0 (ORCPT ); Mon, 7 Feb 2022 07:01:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383182AbiBGLgD (ORCPT ); Mon, 7 Feb 2022 06:36:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3323C0401C0; Mon, 7 Feb 2022 03:36:01 -0800 (PST) Received: from smtp.kernel.org (relay.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 1CF7E6091A; Mon, 7 Feb 2022 11:36:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 642DDC004E1; Mon, 7 Feb 2022 11:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233760; bh=f1ORtPDAHpcxACauP0gFG5EboxWBRvFWuxzNa3VLo2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyH0591SOjN3aGAdvTqGjtNjPRDog2JXFvBhVdZoSX+mBoD3YVSvtri/7F+HU4Jib 7G2E+MaVhXAsbdFzkMncto2rmKfnM2Ec7OzRdpHQezzns39Uxx2dhORobTpgHLQ29W 0u6qNXf3mvdI2aLyT1v4FzmXNtqsz28bjt28EG7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tristan Hume , "Peter Zijlstra (Intel)" , Adrian Hunter , stable@kernel.org Subject: [PATCH 5.16 111/126] perf/x86/intel/pt: Fix crash with stop filters in single-range mode Date: Mon, 7 Feb 2022 12:07:22 +0100 Message-Id: <20220207103807.890497222@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Tristan Hume commit 1d9093457b243061a9bba23543c38726e864a643 upstream. Add a check for !buf->single before calling pt_buffer_region_size in a place where a missing check can cause a kernel crash. Fixes a bug introduced by commit 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode"), which added a support for PT single-range output mode. Since that commit if a PT stop filter range is hit while tracing, the kernel will crash because of a null pointer dereference in pt_handle_status due to calling pt_buffer_region_size without a ToPA configured. The commit which introduced single-range mode guarded almost all uses of the ToPA buffer variables with checks of the buf->single variable, but missed the case where tracing was stopped by the PT hardware, which happens when execution hits a configured stop filter. Tested that hitting a stop filter while PT recording successfully records a trace with this patch but crashes without this patch. Fixes: 670638477aed ("perf/x86/intel/pt: Opportunistically use single range= output mode") Signed-off-by: Tristan Hume Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Adrian Hunter Cc: stable@kernel.org Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/x86/events/intel/pt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -897,8 +897,9 @@ static void pt_handle_status(struct pt * * means we are already losing data; need to let the decoder * know. */ - if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || - buf->output_off =3D=3D pt_buffer_region_size(buf)) { + if (!buf->single && + (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || + buf->output_off =3D=3D pt_buffer_region_size(buf))) { perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_TRUNCATED); advance++; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD89BC352B6 for ; Mon, 7 Feb 2022 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245160AbiBGMAA (ORCPT ); Mon, 7 Feb 2022 07:00:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383800AbiBGLgH (ORCPT ); Mon, 7 Feb 2022 06:36:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC37C0401D4; Mon, 7 Feb 2022 03:36:06 -0800 (PST) Received: from smtp.kernel.org (relay.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 26001B8102E; Mon, 7 Feb 2022 11:36:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41559C004E1; Mon, 7 Feb 2022 11:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233764; bh=GZjfwiDTZrXgySDAJnA5L8SeTfEpLi6S8B2FyT7h61A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nD3vUdiQD3MCkjnHl2RxeXODzgdho2WRv5XOfUA1g1LVF620xDCdFfV6FZUukiz5s UdFsuELNjnYoXdqpKCNG6fWHdP/kwSbn7lEY5sOgMuFq64AwQApWaUZQwezgAANNJ6 Izbm5PZX0v6YBvC3pl3J6r1JYiyXP8KqfQgZM/78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kyle Huey , Andrew Cooper , "Peter Zijlstra (Intel)" , stable@kernel.org Subject: [PATCH 5.16 112/126] x86/perf: Default set FREEZE_ON_SMI for all Date: Mon, 7 Feb 2022 12:07:23 +0100 Message-Id: <20220207103807.927118056@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 Zijlstra commit a01994f5e5c79d3a35e5e8cf4252c7f2147323c3 upstream. Kyle reported that rr[0] has started to malfunction on Comet Lake and later CPUs due to EFI starting to make use of CPL3 [1] and the PMU event filtering not distinguishing between regular CPL3 and SMM CPL3. Since this is a privilege violation, default disable SMM visibility where possible. Administrators wanting to observe SMM cycles can easily change this using the sysfs attribute while regular users don't have access to this file. [0] https://rr-project.org/ [1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform" at https://bugzilla.kernel.org/attachment.cgi?id=3D300300, particularly the end of page 5. Reported-by: Kyle Huey Suggested-by: Andrew Cooper Signed-off-by: Peter Zijlstra (Intel) Cc: stable@kernel.org Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-as= s.net Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/x86/events/intel/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -4709,6 +4709,19 @@ static __initconst const struct x86_pmu .lbr_read =3D intel_pmu_lbr_read_64, .lbr_save =3D intel_pmu_lbr_save, .lbr_restore =3D intel_pmu_lbr_restore, + + /* + * SMM has access to all 4 rings and while traditionally SMM code only + * ran in CPL0, 2021-era firmware is starting to make use of CPL3 in SMM. + * + * Since the EVENTSEL.{USR,OS} CPL filtering makes no distinction + * between SMM or not, this results in what should be pure userspace + * counters including SMM data. + * + * This is a clear privilege issue, therefore globally disable + * counting SMM by default. + */ + .attr_freeze_on_smi =3D 1, }; =20 static __init void intel_clovertown_quirk(void) From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E81EC47087 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232621AbiBGMAQ (ORCPT ); Mon, 7 Feb 2022 07:00:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383937AbiBGLgK (ORCPT ); Mon, 7 Feb 2022 06:36:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CA17C0401DB; Mon, 7 Feb 2022 03:36:10 -0800 (PST) Received: from smtp.kernel.org (relay.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 C6C1CB811BB; Mon, 7 Feb 2022 11:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD8E5C004E1; Mon, 7 Feb 2022 11:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233767; bh=s67VpVP7MXMILns6SrqsrSdBqMFhRM8QKqe4wHf8zNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pu5knsQSiGi7JKEUAhUgpiIBJKfW9Up6J7cR0nlvY8OIrkN4q1bCiY7jHxeIvWoDy bnMoi+0LnP//O9tYSvWNV5uNfyy+eSauLWWhosJopPC/luGhd1eQ49kuBcb/tyj4TT Mqrk4dzuE8PMal0w3zjiX6IoWxf8pQablqpe48/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Borislav Petkov , Dinh Nguyen Subject: [PATCH 5.16 113/126] EDAC/altera: Fix deferred probing Date: Mon, 7 Feb 2022 12:07:24 +0100 Message-Id: <20220207103807.958903019@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Sergey Shtylyov commit 279eb8575fdaa92c314a54c0d583c65e26229107 upstream. The driver overrides the error codes returned by platform_get_irq() to -ENODEV for some strange reason, so if it returns -EPROBE_DEFER, the driver will fail the probe permanently instead of the deferred probing. Switch to propagating the proper error codes to platform driver code upwards. [ bp: Massage commit message. ] Fixes: 71bcada88b0f ("edac: altera: Add Altera SDRAM EDAC support") Signed-off-by: Sergey Shtylyov Signed-off-by: Borislav Petkov Acked-by: Dinh Nguyen Cc: Link: https://lore.kernel.org/r/20220124185503.6720-2-s.shtylyov@omp.ru Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/edac/altera_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -350,7 +350,7 @@ static int altr_sdram_probe(struct platf if (irq < 0) { edac_printk(KERN_ERR, EDAC_MC, "No irq %d in DT\n", irq); - return -ENODEV; + return irq; } =20 /* Arria10 has a 2nd IRQ */ From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D45F8C4708A for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385250AbiBGMBM (ORCPT ); Mon, 7 Feb 2022 07:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384022AbiBGLgO (ORCPT ); Mon, 7 Feb 2022 06:36:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5666CC0401DF; Mon, 7 Feb 2022 03:36:13 -0800 (PST) Received: from smtp.kernel.org (relay.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 EE175B8102E; Mon, 7 Feb 2022 11:36:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 251B4C004E1; Mon, 7 Feb 2022 11:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233770; bh=3+OdnXHnwYipTw8qEI909/tZBBwnRXIhertLR4aPfWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yn4IoS0TXkfnN8WsmQB3AwU6QV0on7QW+JGjgwf5qVdjw0G8BdYIbIKCMzS5nE+/8 7B5oeMjwKx4N9sQEq+2b0m4RbJAHzrk4lCaPvpQGW+XQ7qjB/z3rzAfAe8AHQSSGJG ID8CVnzLQlXU4NSRMI7iOsyksWrGHnLkVsFH/TEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Borislav Petkov Subject: [PATCH 5.16 114/126] EDAC/xgene: Fix deferred probing Date: Mon, 7 Feb 2022 12:07:25 +0100 Message-Id: <20220207103808.000129286@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Sergey Shtylyov commit dfd0dfb9a7cc04acf93435b440dd34c2ca7b4424 upstream. The driver overrides error codes returned by platform_get_irq_optional() to -EINVAL for some strange reason, so if it returns -EPROBE_DEFER, the driver will fail the probe permanently instead of the deferred probing. Switch to propagating the proper error codes to platform driver code upwards. [ bp: Massage commit message. ] Fixes: 0d4429301c4a ("EDAC: Add APM X-Gene SoC EDAC driver") Signed-off-by: Sergey Shtylyov Signed-off-by: Borislav Petkov Cc: Link: https://lore.kernel.org/r/20220124185503.6720-3-s.shtylyov@omp.ru Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/edac/xgene_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/edac/xgene_edac.c +++ b/drivers/edac/xgene_edac.c @@ -1919,7 +1919,7 @@ static int xgene_edac_probe(struct platf irq =3D platform_get_irq_optional(pdev, i); if (irq < 0) { dev_err(&pdev->dev, "No IRQ resource\n"); - rc =3D -EINVAL; + rc =3D irq; goto out_err; } rc =3D devm_request_irq(&pdev->dev, irq, From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C14C2C388F3 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382219AbiBGMBE (ORCPT ); Mon, 7 Feb 2022 07:01:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386710AbiBGLgR (ORCPT ); Mon, 7 Feb 2022 06:36:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D70C0401E6; Mon, 7 Feb 2022 03:36:16 -0800 (PST) Received: from smtp.kernel.org (relay.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 6EBC1B8112C; Mon, 7 Feb 2022 11:36:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67C04C004E1; Mon, 7 Feb 2022 11:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233774; bh=TU7dy6IjSz60N6jVr/tfuxaZIh8qCIsBtKViXY1Pn5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2reOLNQvyw2VZddMSPDm1sjlVLb8GQwjzEOXbcceXUCwla6f7USxsIKwZ0PC/X4s/ lFPmSoVKI572gG5DAfef9EBH2M7cBA5ykeyHYxmJKlE+L8FV4sa4esCBKpI66Y6Voq DbXv8zY6owXfzJcGHwQrWj7ZIYVZRFkYAzsvFrlQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Yin , Theodore Tso , stable@kernel.org Subject: [PATCH 5.16 115/126] ext4: prevent used blocks from being allocated during fast commit replay Date: Mon, 7 Feb 2022 12:07:26 +0100 Message-Id: <20220207103808.033200848@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Xin Yin commit 599ea31d13617c5484c40cdf50d88301dc351cfc upstream. During fast commit replay procedure, we clear inode blocks bitmap in ext4_ext_clear_bb(), this may cause ext4_mb_new_blocks_simple() allocate blocks still in use. Make ext4_fc_record_regions() also record physical disk regions used by inodes during replay procedure. Then ext4_mb_new_blocks_simple() can excludes these blocks in use. Signed-off-by: Xin Yin Link: https://lore.kernel.org/r/20220110035141.1980-2-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 3 +++ fs/ext4/extents.c | 4 ++++ fs/ext4/fast_commit.c | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2936,6 +2936,9 @@ void ext4_fc_replay_cleanup(struct super int ext4_fc_commit(journal_t *journal, tid_t commit_tid); int __init ext4_fc_init_dentry_cache(void); void ext4_fc_destroy_dentry_cache(void); +int ext4_fc_record_regions(struct super_block *sb, int ino, + ext4_lblk_t lblk, ext4_fsblk_t pblk, + int len, int replay); =20 /* mballoc.c */ extern const struct seq_operations ext4_mb_seq_groups_ops; --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -6101,11 +6101,15 @@ int ext4_ext_clear_bb(struct inode *inod =20 ext4_mb_mark_bb(inode->i_sb, path[j].p_block, 1, 0); + ext4_fc_record_regions(inode->i_sb, inode->i_ino, + 0, path[j].p_block, 1, 1); } ext4_ext_drop_refs(path); kfree(path); } ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0); + ext4_fc_record_regions(inode->i_sb, inode->i_ino, + map.m_lblk, map.m_pblk, map.m_len, 1); } cur =3D cur + map.m_len; } --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1606,16 +1606,23 @@ out: } =20 /* - * Record physical disk regions which are in use as per fast commit area. = Our - * simple replay phase allocator excludes these regions from allocation. + * Record physical disk regions which are in use as per fast commit area, + * and used by inodes during replay phase. Our simple replay phase + * allocator excludes these regions from allocation. */ -static int ext4_fc_record_regions(struct super_block *sb, int ino, - ext4_lblk_t lblk, ext4_fsblk_t pblk, int len) +int ext4_fc_record_regions(struct super_block *sb, int ino, + ext4_lblk_t lblk, ext4_fsblk_t pblk, int len, int replay) { struct ext4_fc_replay_state *state; struct ext4_fc_alloc_region *region; =20 state =3D &EXT4_SB(sb)->s_fc_replay_state; + /* + * during replay phase, the fc_regions_valid may not same as + * fc_regions_used, update it when do new additions. + */ + if (replay && state->fc_regions_used !=3D state->fc_regions_valid) + state->fc_regions_used =3D state->fc_regions_valid; if (state->fc_regions_used =3D=3D state->fc_regions_size) { state->fc_regions_size +=3D EXT4_FC_REPLAY_REALLOC_INCREMENT; @@ -1633,6 +1640,9 @@ static int ext4_fc_record_regions(struct region->pblk =3D pblk; region->len =3D len; =20 + if (replay) + state->fc_regions_valid++; + return 0; } =20 @@ -1980,7 +1990,7 @@ static int ext4_fc_replay_scan(journal_t ret =3D ext4_fc_record_regions(sb, le32_to_cpu(ext.fc_ino), le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex), - ext4_ext_get_actual_len(ex)); + ext4_ext_get_actual_len(ex), 0); if (ret < 0) break; ret =3D JBD2_FC_REPLAY_CONTINUE; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A9BBC35271 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351245AbiBGMA2 (ORCPT ); Mon, 7 Feb 2022 07:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386714AbiBGLgT (ORCPT ); Mon, 7 Feb 2022 06:36:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32ED0C0401EB; Mon, 7 Feb 2022 03:36:18 -0800 (PST) Received: from smtp.kernel.org (relay.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 C624A6091A; Mon, 7 Feb 2022 11:36:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABBE3C004E1; Mon, 7 Feb 2022 11:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233777; bh=R4imgKnV8m32j4qt81S3AnOiSUStzzwNsdj4QWnDjis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hxz/Ec2FZheIlL+dI7q0x/Cd3iV6Yxadd4rX43s5puD+WX8aqZAfkU/07nHW+cwP1 JjCMD1Zvm1zfO/H3Li97e9huYc1vqb8EKYHJygGvf7R68cSxv8kLF+v7maV7DnpueP DDWKpu+tQ5ZpOsPmtf1y14s/QQ+a6zYHriFYjSjE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Yin , Harshad Shirwadkar , Theodore Tso , stable@kernel.org Subject: [PATCH 5.16 116/126] ext4: modify the logic of ext4_mb_new_blocks_simple Date: Mon, 7 Feb 2022 12:07:27 +0100 Message-Id: <20220207103808.065831948@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Xin Yin commit 31a074a0c62dc0d2bfb9b543142db4fe27f9e5eb upstream. For now in ext4_mb_new_blocks_simple, if we found a block which should be excluded then will switch to next group, this may probably cause 'group' run out of range. Change to check next block in the same group when get a block should be excluded. Also change the search range to EXT4_CLUSTERS_PER_GROUP and add error checking. Signed-off-by: Xin Yin Reviewed-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20220110035141.1980-3-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/mballoc.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5753,7 +5753,8 @@ static ext4_fsblk_t ext4_mb_new_blocks_s struct super_block *sb =3D ar->inode->i_sb; ext4_group_t group; ext4_grpblk_t blkoff; - int i =3D sb->s_blocksize; + ext4_grpblk_t max =3D EXT4_CLUSTERS_PER_GROUP(sb); + ext4_grpblk_t i =3D 0; ext4_fsblk_t goal, block; struct ext4_super_block *es =3D EXT4_SB(sb)->s_es; =20 @@ -5775,19 +5776,26 @@ static ext4_fsblk_t ext4_mb_new_blocks_s ext4_get_group_no_and_offset(sb, max(ext4_group_first_block_no(sb, group), goal), NULL, &blkoff); - i =3D mb_find_next_zero_bit(bitmap_bh->b_data, sb->s_blocksize, + while (1) { + i =3D mb_find_next_zero_bit(bitmap_bh->b_data, max, blkoff); + if (i >=3D max) + break; + if (ext4_fc_replay_check_excluded(sb, + ext4_group_first_block_no(sb, group) + i)) { + blkoff =3D i + 1; + } else + break; + } brelse(bitmap_bh); - if (i >=3D sb->s_blocksize) - continue; - if (ext4_fc_replay_check_excluded(sb, - ext4_group_first_block_no(sb, group) + i)) - continue; - break; + if (i < max) + break; } =20 - if (group >=3D ext4_get_groups_count(sb) && i >=3D sb->s_blocksize) + if (group >=3D ext4_get_groups_count(sb) || i >=3D max) { + *errp =3D -ENOSPC; return 0; + } =20 block =3D ext4_group_first_block_no(sb, group) + i; ext4_mb_mark_bb(sb, block, 1, 1); From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E501C47088 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381985AbiBGMAj (ORCPT ); Mon, 7 Feb 2022 07:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386730AbiBGLgX (ORCPT ); Mon, 7 Feb 2022 06:36:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D89C03FECD; Mon, 7 Feb 2022 03:36:22 -0800 (PST) Received: from smtp.kernel.org (relay.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 800BCB80EBD; Mon, 7 Feb 2022 11:36:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6957C004E1; Mon, 7 Feb 2022 11:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233780; bh=CfF5WdTDKr8HJN9/b0LVxkEDlz1x+4lkrQSzwtW1+XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLNoFxxPvUd5BUSM5eKiDgMHpUeVHGGKR97mwM1dFfmsVFZStvQKQ2f1CvVCMHfmd rOGaxP76d426LmdQbLZHP/CnoOxlQXKfwMU46EWv3HA7xqNak0i+FiPdfG9jp3YyEO zV4ZgYOTj3/o/BnQ6yaamzh7sQ0FV67xoSRBlB60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Whitney , Ritesh Harjani , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.16 117/126] ext4: fix error handling in ext4_restore_inline_data() Date: Mon, 7 Feb 2022 12:07:28 +0100 Message-Id: <20220207103808.102750557@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Ritesh Harjani commit 897026aaa73eb2517dfea8d147f20ddb0b813044 upstream. While running "./check -I 200 generic/475" it sometimes gives below kernel BUG(). Ideally we should not call ext4_write_inline_data() if ext4_create_inline_data() has failed. [73131.453234] kernel BUG at fs/ext4/inline.c:223! 212 static void ext4_write_inline_data(struct inode *inode, struct ext4_il= oc *iloc, 213 void *buffer, loff_t pos, unsigned = int len) 214 { <...> 223 BUG_ON(!EXT4_I(inode)->i_inline_off); 224 BUG_ON(pos + len > EXT4_I(inode)->i_inline_size); This patch handles the error and prints out a emergency msg saying potential data loss for the given inode (since we couldn't restore the original inline_data due to some previous error). [ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- pot= ential data loss! (inode 1703982, error -30) Reported-by: Eric Whitney Signed-off-by: Ritesh Harjani Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/9f4cd7dfd54fa58ff27270881823d94ddf78dd07.16= 42416995.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/inline.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1133,7 +1133,15 @@ static void ext4_restore_inline_data(han struct ext4_iloc *iloc, void *buf, int inline_size) { - ext4_create_inline_data(handle, inode, inline_size); + int ret; + + ret =3D ext4_create_inline_data(handle, inode, inline_size); + if (ret) { + ext4_msg(inode->i_sb, KERN_EMERG, + "error restoring inline_data for inode -- potential data loss! (inode %= lu, error %d)", + inode->i_ino, ret); + return; + } ext4_write_inline_data(inode, iloc, buf, 0, inline_size); ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB8DFC3526C for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382192AbiBGMA5 (ORCPT ); Mon, 7 Feb 2022 07:00:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386741AbiBGLg3 (ORCPT ); Mon, 7 Feb 2022 06:36:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61CB5C03FED2; Mon, 7 Feb 2022 03:36:26 -0800 (PST) Received: from smtp.kernel.org (relay.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 DEBEBB8102E; Mon, 7 Feb 2022 11:36:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8032C004E1; Mon, 7 Feb 2022 11:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233783; bh=o8tPfxgrZHOaxIilLIOW80FOCyLWdjQ7p85OGcBk3uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K4ao3HnvBije//pTJYXSjXAOLife03v9r+OVKPR/8fhhwBFrB+a6WoIqkEM+RwtbD ucNl2WzlBGlR9Ol38Bv9gJAnkUKg1Oewth4N4tLR2IEOnUQiD2/oWtcfKKU7UC5lk1 59ijy5q2fuIlG8EPjcCIPVmEXF6e+exylVjxKAlw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, luo penghao , Lukas Czerner , Ritesh Harjani , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.16 118/126] ext4: fix error handling in ext4_fc_record_modified_inode() Date: Mon, 7 Feb 2022 12:07:29 +0100 Message-Id: <20220207103808.137191937@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Ritesh Harjani commit cdce59a1549190b66f8e3fe465c2b2f714b98a94 upstream. Current code does not fully takes care of krealloc() error case, which could lead to silent memory corruption or a kernel bug. This patch fixes that. Also it cleans up some duplicated error handling logic from various functions in fast_commit.c file. Reported-by: luo penghao Suggested-by: Lukas Czerner Signed-off-by: Ritesh Harjani Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/62e8b6a1cce9359682051deb736a3c0953c9d1e9.16= 42416995.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/fast_commit.c | 64 ++++++++++++++++++++++-----------------------= ----- 1 file changed, 29 insertions(+), 35 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1435,14 +1435,15 @@ static int ext4_fc_record_modified_inode if (state->fc_modified_inodes[i] =3D=3D ino) return 0; if (state->fc_modified_inodes_used =3D=3D state->fc_modified_inodes_size)= { - state->fc_modified_inodes_size +=3D - EXT4_FC_REPLAY_REALLOC_INCREMENT; state->fc_modified_inodes =3D krealloc( - state->fc_modified_inodes, sizeof(int) * - state->fc_modified_inodes_size, - GFP_KERNEL); + state->fc_modified_inodes, + sizeof(int) * (state->fc_modified_inodes_size + + EXT4_FC_REPLAY_REALLOC_INCREMENT), + GFP_KERNEL); if (!state->fc_modified_inodes) return -ENOMEM; + state->fc_modified_inodes_size +=3D + EXT4_FC_REPLAY_REALLOC_INCREMENT; } state->fc_modified_inodes[state->fc_modified_inodes_used++] =3D ino; return 0; @@ -1474,7 +1475,9 @@ static int ext4_fc_replay_inode(struct s } inode =3D NULL; =20 - ext4_fc_record_modified_inode(sb, ino); + ret =3D ext4_fc_record_modified_inode(sb, ino); + if (ret) + goto out; =20 raw_fc_inode =3D (struct ext4_inode *) (val + offsetof(struct ext4_fc_inode, fc_raw_inode)); @@ -1674,6 +1677,8 @@ static int ext4_fc_replay_add_range(stru } =20 ret =3D ext4_fc_record_modified_inode(sb, inode->i_ino); + if (ret) + goto out; =20 start =3D le32_to_cpu(ex->ee_block); start_pblk =3D ext4_ext_pblock(ex); @@ -1691,18 +1696,14 @@ static int ext4_fc_replay_add_range(stru map.m_pblk =3D 0; ret =3D ext4_map_blocks(NULL, inode, &map, 0); =20 - if (ret < 0) { - iput(inode); - return 0; - } + if (ret < 0) + goto out; =20 if (ret =3D=3D 0) { /* Range is not mapped */ path =3D ext4_find_extent(inode, cur, NULL, 0); - if (IS_ERR(path)) { - iput(inode); - return 0; - } + if (IS_ERR(path)) + goto out; memset(&newex, 0, sizeof(newex)); newex.ee_block =3D cpu_to_le32(cur); ext4_ext_store_pblock( @@ -1716,10 +1717,8 @@ static int ext4_fc_replay_add_range(stru up_write((&EXT4_I(inode)->i_data_sem)); ext4_ext_drop_refs(path); kfree(path); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; goto next; } =20 @@ -1732,10 +1731,8 @@ static int ext4_fc_replay_add_range(stru ret =3D ext4_ext_replay_update_ex(inode, cur, map.m_len, ext4_ext_is_unwritten(ex), start_pblk + cur - start); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; /* * Mark the old blocks as free since they aren't used * anymore. We maintain an array of all the modified @@ -1755,10 +1752,8 @@ static int ext4_fc_replay_add_range(stru ext4_ext_is_unwritten(ex), map.m_pblk); ret =3D ext4_ext_replay_update_ex(inode, cur, map.m_len, ext4_ext_is_unwritten(ex), map.m_pblk); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; /* * We may have split the extent tree while toggling the state. * Try to shrink the extent tree now. @@ -1770,6 +1765,7 @@ next: } ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >> sb->s_blocksize_bits); +out: iput(inode); return 0; } @@ -1799,6 +1795,8 @@ ext4_fc_replay_del_range(struct super_bl } =20 ret =3D ext4_fc_record_modified_inode(sb, inode->i_ino); + if (ret) + goto out; =20 jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n", inode->i_ino, le32_to_cpu(lrange.fc_lblk), @@ -1808,10 +1806,8 @@ ext4_fc_replay_del_range(struct super_bl map.m_len =3D remaining; =20 ret =3D ext4_map_blocks(NULL, inode, &map, 0); - if (ret < 0) { - iput(inode); - return 0; - } + if (ret < 0) + goto out; if (ret > 0) { remaining -=3D ret; cur +=3D ret; @@ -1826,15 +1822,13 @@ ext4_fc_replay_del_range(struct super_bl ret =3D ext4_ext_remove_space(inode, lrange.fc_lblk, lrange.fc_lblk + lrange.fc_len - 1); up_write(&EXT4_I(inode)->i_data_sem); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >> sb->s_blocksize_bits); ext4_mark_inode_dirty(NULL, inode); +out: iput(inode); - return 0; } =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5231BC38162 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382047AbiBGMAn (ORCPT ); Mon, 7 Feb 2022 07:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386748AbiBGLgb (ORCPT ); Mon, 7 Feb 2022 06:36:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026E9C043181; Mon, 7 Feb 2022 03:36:30 -0800 (PST) Received: from smtp.kernel.org (relay.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 8208A60A69; Mon, 7 Feb 2022 11:36:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4948FC004E1; Mon, 7 Feb 2022 11:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233790; bh=rrCuu477wj4X6lM0wC9UJqAp+SzH0iPa855DMsGM5eA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vG77KdU+pylEYjlWOPzMxMSbX14SwUoD5v7P5xZOLe/pWjKIHyCcXzjAAtITeRoGa X0c2tLjZ5MMEwWj8YHKKaWxNMZ3afwq8huyP6jLe8oPlxvEAhVrbNbVCsdujIvcBFd JI8OoSDS2Nk9KLPb+KutkijQ+6D6AWYBsA/AYKKA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , stable@kernel.org, Xin Yin , Ritesh Harjani , Theodore Tso Subject: [PATCH 5.16 119/126] ext4: fix incorrect type issue during replay_del_range Date: Mon, 7 Feb 2022 12:07:30 +0100 Message-Id: <20220207103808.170434877@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Xin Yin commit 8fca8a2b0a822f7936130af7299d2fd7f0a66714 upstream. should not use fast commit log data directly, add le32_to_cpu(). Reported-by: kernel test robot Fixes: 0b5b5a62b945 ("ext4: use ext4_ext_remove_space() for fast commit rep= lay delete range") Cc: stable@kernel.org Signed-off-by: Xin Yin Reviewed-by: Ritesh Harjani Link: https://lore.kernel.org/r/20220126063146.2302-1-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/fast_commit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1819,8 +1819,9 @@ ext4_fc_replay_del_range(struct super_bl } =20 down_write(&EXT4_I(inode)->i_data_sem); - ret =3D ext4_ext_remove_space(inode, lrange.fc_lblk, - lrange.fc_lblk + lrange.fc_len - 1); + ret =3D ext4_ext_remove_space(inode, le32_to_cpu(lrange.fc_lblk), + le32_to_cpu(lrange.fc_lblk) + + le32_to_cpu(lrange.fc_len) - 1); up_write(&EXT4_I(inode)->i_data_sem); if (ret) goto out; From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EDF9C38161 for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382140AbiBGMAt (ORCPT ); Mon, 7 Feb 2022 07:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386757AbiBGLgf (ORCPT ); Mon, 7 Feb 2022 06:36:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B29C043188; Mon, 7 Feb 2022 03:36:34 -0800 (PST) Received: from smtp.kernel.org (relay.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 B4A9F60A69; Mon, 7 Feb 2022 11:36:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DF9CC004E1; Mon, 7 Feb 2022 11:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233793; bh=q0nvyZV4sYkd7gzOHWgjUx1R62mGh98lgexTYH8IfgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=auThh9oh5bknORGhf+fjUVvyhbsvzF+qVnZ09AytsynPao/IdPE42G3JdYvN6nDS8 hlc2aHSaWJAq5bFCnpIPIVQB6lK2ynH64+h6tQUoE0BbFqrK3ER2HbZGv/Huu6jXiq 7XQU0GRwXnRjvo6/1Yj/4UPpQPnakkGOCfQNUzKQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Andrew Lunn , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.16 120/126] net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY Date: Mon, 7 Feb 2022 12:07:31 +0100 Message-Id: <20220207103808.201468652@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Ar=C4=B1n=C3=A7 =C3=9CNAL commit 4223f86512877b04c932e7203648b37eec931731 upstream. Make MediaTek MT753x DSA driver enable MediaTek Gigabit PHYs driver to properly control MT7530 and MT7531 switch PHYs. A noticeable change is that the behaviour of switchport interfaces going up-down-up-down is no longer there. Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 sw= itch") Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20220129062703.595-1-arinc.unal@arinc9.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/dsa/Kconfig | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -36,6 +36,7 @@ config NET_DSA_LANTIQ_GSWIP config NET_DSA_MT7530 tristate "MediaTek MT753x and MT7621 Ethernet switch support" select NET_DSA_TAG_MTK + select MEDIATEK_GE_PHY help This enables support for the MediaTek MT7530, MT7531, and MT7621 Ethernet switch chips. From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 181DCC4708B for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391280AbiBGMBU (ORCPT ); Mon, 7 Feb 2022 07:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386774AbiBGLgj (ORCPT ); Mon, 7 Feb 2022 06:36:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F578C0401C0; Mon, 7 Feb 2022 03:36:38 -0800 (PST) Received: from smtp.kernel.org (relay.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 5E6E0B8112C; Mon, 7 Feb 2022 11:36:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6E5AC004E1; Mon, 7 Feb 2022 11:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233796; bh=A8AXPBtYBDFFG2VgJ8Qp7mlnjDSOfbScHXZaILBJqkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xAAVsUUEOFOgNoXcxoFsLN1dL25gRCcHHENquP+n9yn/oSqA1c8fZTPkMvhO4Y92G OIEcUAX+f+zuRRgMQWu703g1qGYBY4zEPnto2I9+78i/VdH8BeYitiFeiIZnlfwhLC IZhK5gKTVkCdmbTQyLuzL8+fUqM03XDWOKQUkFgs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Phil Auld , Tejun Heo Subject: [PATCH 5.16 121/126] cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning Date: Mon, 7 Feb 2022 12:07:32 +0100 Message-Id: <20220207103808.231751970@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Waiman Long commit 2bdfd2825c9662463371e6691b1a794e97fa36b4 upstream. It was found that a "suspicious RCU usage" lockdep warning was issued with the rcu_read_lock() call in update_sibling_cpumasks(). It is because the update_cpumasks_hier() function may sleep. So we have to release the RCU lock, call update_cpumasks_hier() and reacquire it afterward. Also add a percpu_rwsem_assert_held() in update_sibling_cpumasks() instead of stating that in the comment. Fixes: 4716909cc5c5 ("cpuset: Track cpusets that use parent's effective_cpu= s") Signed-off-by: Waiman Long Tested-by: Phil Auld Reviewed-by: Phil Auld Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/cgroup/cpuset.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1530,10 +1530,15 @@ static void update_sibling_cpumasks(stru struct cpuset *sibling; struct cgroup_subsys_state *pos_css; =20 + percpu_rwsem_assert_held(&cpuset_rwsem); + /* * Check all its siblings and call update_cpumasks_hier() * if their use_parent_ecpus flag is set in order for them * to use the right effective_cpus value. + * + * The update_cpumasks_hier() function may sleep. So we have to + * release the RCU read lock before calling it. */ rcu_read_lock(); cpuset_for_each_child(sibling, pos_css, parent) { @@ -1541,8 +1546,13 @@ static void update_sibling_cpumasks(stru continue; if (!sibling->use_parent_ecpus) continue; + if (!css_tryget_online(&sibling->css)) + continue; =20 + rcu_read_unlock(); update_cpumasks_hier(sibling, tmp); + rcu_read_lock(); + css_put(&sibling->css); } rcu_read_unlock(); } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F36ABC4167D for ; Mon, 7 Feb 2022 12:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385679AbiBGMBP (ORCPT ); Mon, 7 Feb 2022 07:01:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386776AbiBGLgl (ORCPT ); Mon, 7 Feb 2022 06:36:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456E0C043188; Mon, 7 Feb 2022 03:36:40 -0800 (PST) Received: from smtp.kernel.org (relay.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 D67DA60B20; Mon, 7 Feb 2022 11:36:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A026AC004E1; Mon, 7 Feb 2022 11:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233799; bh=OtP5r+gyCFy9t1qM39CdxkthGbobIllUleGvZdo9M9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZPmCA9K8TJo+PAHgWDGs0Qq0jvCQWjQPrKAPpP13HK8lbQHpIdId3OWkt7n2cCqTt gwxNKYcBh0xhNh9Zb8wdUsM/xKbxdjd5KQm0pBYeRNcr65Li8Hcx5pOred7wC1OBgy Mr9NQ3Umoa02xP3Tpz+egYP9to8gQxEViMt/RwBM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Mark Brown , Takashi Iwai , Arnaldo Carvalho de Melo Subject: [PATCH 5.16 122/126] tools include UAPI: Sync sound/asound.h copy with the kernel sources Date: Mon, 7 Feb 2022 12:07:33 +0100 Message-Id: <20220207103808.264148455@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Arnaldo Carvalho de Melo commit 4f2492731ada9d702ffdfaa6ec1ff64820a1664c upstream. Picking the changes from: 06feec6005c9d950 ("ASoC: hdmi-codec: Fix OOB memory accesses") Which entails no changes in the tooling side as it doesn't introduce new SNDRV_PCM_IOCTL_ ioctls. To silence this perf tools build warning: Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h' differs= from latest version at 'include/uapi/sound/asound.h' diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h Cc: Dmitry Osipenko Cc: Mark Brown Cc: Takashi Iwai Link: https://lore.kernel.org/lkml/Yf+6OT+2eMrYDEeX@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/include/uapi/sound/asound.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/tools/include/uapi/sound/asound.h +++ b/tools/include/uapi/sound/asound.h @@ -56,8 +56,10 @@ * = * *************************************************************************= ***/ =20 +#define AES_IEC958_STATUS_SIZE 24 + struct snd_aes_iec958 { - unsigned char status[24]; /* AES/IEC958 channel status bits */ + unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel statu= s bits */ unsigned char subcode[147]; /* AES/IEC958 subcode bits */ unsigned char pad; /* nothing */ unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */ From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABD7C4708C for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391384AbiBGMBi (ORCPT ); Mon, 7 Feb 2022 07:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386785AbiBGLgq (ORCPT ); Mon, 7 Feb 2022 06:36:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188F1C043181; Mon, 7 Feb 2022 03:36:45 -0800 (PST) Received: from smtp.kernel.org (relay.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 D0415B8112E; Mon, 7 Feb 2022 11:36:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D55A6C004E1; Mon, 7 Feb 2022 11:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233802; bh=Bhdf+S29ZevkiMeS0rzmUpQEcBMlLRTwt6TQNWmKMNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOgyTYF1ZRY+aRc9Dy9//oH1HNDjAO1LnHFmBRuFG5jcnCqEJSC3MVPEa0gjOK+z/ tSry8nGC+VYla98xNGcPRf8p1T+hhi5f4KcJkjz/LKVXy9Kj5kZzPTl7VIUAE56FoG ok1P64yIA70by5o+U3kVoc2sZhUMd2UFC0bZkog4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abaci Robot , Yang Li , Bartosz Golaszewski Subject: [PATCH 5.16 123/126] gpio: idt3243x: Fix an ignored error return from platform_get_irq() Date: Mon, 7 Feb 2022 12:07:34 +0100 Message-Id: <20220207103808.296043047@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Yang Li commit 7c1cf55577782725ea2bc24687767c8fe8e57486 upstream. The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'parent_irq', so making 'parent_irq' an int. Eliminate the following coccicheck warning: ./drivers/gpio/gpio-idt3243x.c:167:6-16: WARNING: Unsigned expression compared with zero: parent_irq < 0 Reported-by: Abaci Robot Fixes: 30fee1d7462a ("gpio: idt3243x: Fix IRQ check in idt_gpio_probe") Signed-off-by: Yang Li Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpio/gpio-idt3243x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpio/gpio-idt3243x.c +++ b/drivers/gpio/gpio-idt3243x.c @@ -132,7 +132,7 @@ static int idt_gpio_probe(struct platfor struct device *dev =3D &pdev->dev; struct gpio_irq_chip *girq; struct idt_gpio_ctrl *ctrl; - unsigned int parent_irq; + int parent_irq; int ngpios; int ret; =20 From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BE0AC3A59D for ; Mon, 7 Feb 2022 12:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391572AbiBGMCS (ORCPT ); Mon, 7 Feb 2022 07:02:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386801AbiBGLhT (ORCPT ); Mon, 7 Feb 2022 06:37:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB99FC043181; Mon, 7 Feb 2022 03:37:18 -0800 (PST) Received: from smtp.kernel.org (relay.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 9683AB8112C; Mon, 7 Feb 2022 11:37:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFACBC004E1; Mon, 7 Feb 2022 11:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233836; bh=/caNl0v9RwhFS+XEpOgKYAUioaM4gZ0FnbqNGD2i7JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0oe2GnF8jeJNv+Gvf67AU8NwenlZoN6gBWltIkiSIhenb9DSbEKVNykFG4tFpyADA 6ckzE2g4TdEEKHTa2iQLituZYnndmEtTI974HrE+iHsPX1iuhPuTlMBuGMaOi79XW/ uMTJa7TGZLsipOwDSveMdsOZN0k00ZhRRrXXOTWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abaci Robot , Yang Li , Bartosz Golaszewski Subject: [PATCH 5.16 124/126] gpio: mpc8xxx: Fix an ignored error return from platform_get_irq() Date: Mon, 7 Feb 2022 12:07:35 +0100 Message-Id: <20220207103808.328037387@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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: Yang Li commit 9f51ce0b9e73f83bab2442b36d5e247a81bd3401 upstream. The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irqn', so making 'irqn' an int. Eliminate the following coccicheck warning: ./drivers/gpio/gpio-mpc8xxx.c:391:5-21: WARNING: Unsigned expression compared with zero: mpc8xxx_gc -> irqn < 0 Reported-by: Abaci Robot Fixes: 0b39536cc699 ("gpio: mpc8xxx: Fix IRQ check in mpc8xxx_probe") Signed-off-by: Yang Li Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpio/gpio-mpc8xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -47,7 +47,7 @@ struct mpc8xxx_gpio_chip { unsigned offset, int value); =20 struct irq_domain *irq; - unsigned int irqn; + int irqn; }; =20 /* From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C79C4708D for ; Mon, 7 Feb 2022 12:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391543AbiBGMCL (ORCPT ); Mon, 7 Feb 2022 07:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386798AbiBGLhL (ORCPT ); Mon, 7 Feb 2022 06:37:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A8DC043181; Mon, 7 Feb 2022 03:37:10 -0800 (PST) Received: from smtp.kernel.org (relay.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 0D9456091A; Mon, 7 Feb 2022 11:37:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C98CAC004E1; Mon, 7 Feb 2022 11:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233829; bh=MLFw33SBS/pqg+VfKau4wYtPr8pye3UBHws0wWK4l+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lC37KSiNZZ3Eo+zA76rTPrLD+9L9jfE7GAphPivjiMbi0gBfsvPWBrl/Ll/j2quHv Hn1MK3w8ADdClI3uaRCmZv/smT4ynw+nYK48YzRjYGPCSb7+yAlDrvPqubBK2VC4iG jsXkqiHxoVZpXrVHUhocajoD7suAZZOpUbJ6K5UA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Stefano Brivio , Pablo Neira Ayuso Subject: [PATCH 5.16 125/126] selftests: nft_concat_range: add test for reload with no element add/del Date: Mon, 7 Feb 2022 12:07:36 +0100 Message-Id: <20220207103808.361008101@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit eda0cf1202acf1ef47f93d8f92d4839213431424 upstream. Add a specific test for the reload issue fixed with commit 23c54263efd7cb ("netfilter: nft_set_pipapo: allocate pcpu scratch ma= ps on clone"). Add to set, then flush set content + restore without other add/remove in the transaction. On kernels before the fix, this test case fails: net,mac with reload [FAIL] Signed-off-by: Florian Westphal Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/netfilter/nft_concat_range.sh | 72 +++++++++++++= ++++- 1 file changed, 71 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/netfilter/nft_concat_range.sh +++ b/tools/testing/selftests/netfilter/nft_concat_range.sh @@ -27,7 +27,7 @@ TYPES=3D"net_port port_net net6_port port_ net6_port_net6_port net_port_mac_proto_net" =20 # Reported bugs, also described by TYPE_ variables below -BUGS=3D"flush_remove_add" +BUGS=3D"flush_remove_add reload" =20 # List of possible paths to pktgen script from kernel tree for performance= tests PKTGEN_SCRIPT_PATHS=3D" @@ -354,6 +354,23 @@ TYPE_flush_remove_add=3D" display Add two elements, flush, re-add " =20 +TYPE_reload=3D" +display net,mac with reload +type_spec ipv4_addr . ether_addr +chain_spec ip daddr . ether saddr +dst addr4 +src mac +start 1 +count 1 +src_delta 2000 +tools sendip nc bash +proto udp + +race_repeat 0 + +perf_duration 0 +" + # Set template for all tests, types and rules are filled in depending on t= est set_template=3D' flush ruleset @@ -1473,6 +1490,59 @@ test_bug_flush_remove_add() { nft flush ruleset } =20 +# - add ranged element, check that packets match it +# - reload the set, check packets still match +test_bug_reload() { + setup veth send_"${proto}" set || return ${KSELFTEST_SKIP} + rstart=3D${start} + + range_size=3D1 + for i in $(seq "${start}" $((start + count))); do + end=3D$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=3D${end} + end=3D$((end + 1)) + fi + srcstart=3D$((start + src_delta)) + srcend=3D$((end + src_delta)) + + add "$(format)" || return 1 + range_size=3D$((range_size + 1)) + start=3D$((end + range_size)) + done + + # check kernel does allocate pcpu sctrach map + # for reload with no elemet add/delete + ( echo flush set inet filter test ; + nft list set inet filter test ) | nft -f - + + start=3D${rstart} + range_size=3D1 + + for i in $(seq "${start}" $((start + count))); do + end=3D$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=3D${end} + end=3D$((end + 1)) + fi + srcstart=3D$((start + src_delta)) + srcend=3D$((end + src_delta)) + + for j in $(seq ${start} $((range_size / 2 + 1)) ${end}); do + send_match "${j}" $((j + src_delta)) || return 1 + done + + range_size=3D$((range_size + 1)) + start=3D$((end + range_size)) + done + + nft flush ruleset +} + test_reported_issues() { eval test_bug_"${subtest}" } From nobody Mon Jun 29 16:42:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63140C38A2D for ; Mon, 7 Feb 2022 12:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391557AbiBGMCN (ORCPT ); Mon, 7 Feb 2022 07:02:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386800AbiBGLhP (ORCPT ); Mon, 7 Feb 2022 06:37:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C67C043181; Mon, 7 Feb 2022 03:37:14 -0800 (PST) Received: from smtp.kernel.org (relay.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 A0C836091A; Mon, 7 Feb 2022 11:37:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3316FC340EB; Mon, 7 Feb 2022 11:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233833; bh=YXdkOb+AW7YT32Y3DFc/rWRM/5lbSEXUizTTYCWC+2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLJ3vXDAQr9sSJno+YYmUnThc2nOTRbzsYe1DJK6WSK5/AB5FOGKNBB2NZhrI0RH+ Cat6tFG7Xr0FZhbRtxCsF3i6fICMfJzRdIQCohgEK68GQZatHzIXgc9EA2jx+A6W4M BHmrvJgHWVW49WNNVEw0RYwR8SO0Vyo9sEdKo+xs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.16 126/126] selftests: netfilter: check stateless nat udp checksum fixup Date: Mon, 7 Feb 2022 12:07:37 +0100 Message-Id: <20220207103808.392194264@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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 commit aad51ca71ad83273e8826d6cfdcf53c98748d1fa upstream. Add a test that sends large udp packet (which is fragmented) via a stateless nft nat rule, i.e. 'ip saddr set 10.2.3.4' and check that the datagram is received by peer. On kernels without commit 4e1860a38637 ("netfilter: nft_payload: do not update layer 4 checksu= m when mangling fragments")', this will fail with: cmp: EOF on /tmp/tmp.V1q0iXJyQF which is empty -rw------- 1 root root 4096 Jan 24 22:03 /tmp/tmp.Aaqnq4rBKS -rw------- 1 root root 0 Jan 24 22:03 /tmp/tmp.V1q0iXJyQF ERROR: in and output file mismatch when checking udp with stateless nat FAIL: nftables v1.0.0 (Fearless Fosdick #2) On patched kernels, this will show: PASS: IP statless for ns2-PFp89amx Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/netfilter/nft_nat.sh | 152 ++++++++++++++++++++++= +++++ 1 file changed, 152 insertions(+) --- a/tools/testing/selftests/netfilter/nft_nat.sh +++ b/tools/testing/selftests/netfilter/nft_nat.sh @@ -898,6 +898,144 @@ EOF ip netns exec "$ns0" nft delete table $family nat } =20 +test_stateless_nat_ip() +{ + local lret=3D0 + + ip netns exec "$ns0" sysctl net.ipv4.conf.veth0.forwarding=3D1 > /dev/null + ip netns exec "$ns0" sysctl net.ipv4.conf.veth1.forwarding=3D1 > /dev/null + + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 + if [ $? -ne 0 ] ; then + echo "ERROR: cannot ping $ns1 from $ns2 before loading stateless rules" + return 1 + fi + +ip netns exec "$ns0" nft -f /dev/stdin < /dev/null # ping ns2->ns1 + if [ $? -ne 0 ] ; then + echo "ERROR: cannot ping $ns1 from $ns2 with stateless rules" + lret=3D1 + fi + + # ns1 should have seen packets from .2.2, due to stateless rewrite. + expect=3D"packets 1 bytes 84" + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns0insl | grep = -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0insl "$expect" "test_stateless 1" + lret=3D1 + fi + + for dir in "in" "out" ; do + cnt=3D$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns2" ns1$dir "$expect" "test_stateless 2" + lret=3D1 + fi + done + + # ns1 should not have seen packets from ns2, due to masquerade + expect=3D"packets 0 bytes 0" + for dir in "in" "out" ; do + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0$dir "$expect" "test_stateless 3" + lret=3D1 + fi + + cnt=3D$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns0" ns1$dir "$expect" "test_stateless 4" + lret=3D1 + fi + done + + reset_counters + + socat -h > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "SKIP: Could not run stateless nat frag test without socat tool" + if [ $lret -eq 0 ]; then + return $ksft_skip + fi + + ip netns exec "$ns0" nft delete table ip stateless + return $lret + fi + + local tmpfile=3D$(mktemp) + dd if=3D/dev/urandom of=3D$tmpfile bs=3D4096 count=3D1 2>/dev/null + + local outfile=3D$(mktemp) + ip netns exec "$ns1" timeout 3 socat -u UDP4-RECV:4233 OPEN:$outfile < /d= ev/null & + sc_r=3D$! + + sleep 1 + # re-do with large ping -> ip fragmentation + ip netns exec "$ns2" timeout 3 socat - UDP4-SENDTO:"10.0.1.99:4233" < "$t= mpfile" > /dev/null + if [ $? -ne 0 ] ; then + echo "ERROR: failed to test udp $ns1 to $ns2 with stateless ip nat" 1>&2 + lret=3D1 + fi + + wait + + cmp "$tmpfile" "$outfile" + if [ $? -ne 0 ]; then + ls -l "$tmpfile" "$outfile" + echo "ERROR: in and output file mismatch when checking udp with stateles= s nat" 1>&2 + lret=3D1 + fi + + rm -f "$tmpfile" "$outfile" + + # ns1 should have seen packets from 2.2, due to stateless rewrite. + expect=3D"packets 3 bytes 4164" + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns0insl | grep = -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0insl "$expect" "test_stateless 5" + lret=3D1 + fi + + ip netns exec "$ns0" nft delete table ip stateless + if [ $? -ne 0 ]; then + echo "ERROR: Could not delete table ip stateless" 1>&2 + lret=3D1 + fi + + test $lret -eq 0 && echo "PASS: IP statless for $ns2" + + return $lret +} + # ip netns exec "$ns0" ping -c 1 -q 10.0.$i.99 for i in 0 1 2; do ip netns exec ns$i-$sfx nft -f /dev/stdin <