From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5D42C433F5 for ; Mon, 7 Mar 2022 10:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238953AbiCGJ5s (ORCPT ); Mon, 7 Mar 2022 04:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239305AbiCGJjg (ORCPT ); Mon, 7 Mar 2022 04:39:36 -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 80EC96D4DF; Mon, 7 Mar 2022 01: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 ams.source.kernel.org (Postfix) with ESMTPS id 9A313B810B9; Mon, 7 Mar 2022 09:35:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01C71C340E9; Mon, 7 Mar 2022 09:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645699; bh=OKUJ1VFByJYAVz6NAr0y42oP8C8o9h3GY4OVSvu1guQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W2abqdSvSTmAkkF76E+V+wY6hZR7zLlWI9mAC4sQ+5RvwHUCI0QRgTvxW/0TsgWtM kmYm7DqLRKzkSEgJZBKGpvpKOfjAfJMzF3UCbLZuPZv8M5uAk8Vt84jOw06tnP706Y /FGbIGtZTDCemN+N9+6rj+5il9dR22xo9EnGi69I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Beichler , Johannes Berg , Sasha Levin Subject: [PATCH 5.15 001/262] mac80211_hwsim: report NOACK frames in tx_status Date: Mon, 7 Mar 2022 10:15:45 +0100 Message-Id: <20220307091702.423093657@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Benjamin Beichler [ Upstream commit 42a79960ffa50bfe9e0bf5d6280be89bf563a5dd ] Add IEEE80211_TX_STAT_NOACK_TRANSMITTED to tx_status flags to have proper statistics for non-acked frames. Signed-off-by: Benjamin Beichler Link: https://lore.kernel.org/r/20220111221327.1499881-1-benjamin.beichler@= uni-rostock.de Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/wireless/mac80211_hwsim.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/m= ac80211_hwsim.c index 0adae76eb8df1..52f13afb7cba2 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3641,6 +3641,10 @@ static int hwsim_tx_info_frame_received_nl(struct sk= _buff *skb_2, } txi->flags |=3D IEEE80211_TX_STAT_ACK; } + + if (hwsim_flags & HWSIM_TX_CTL_NO_ACK) + txi->flags |=3D IEEE80211_TX_STAT_NOACK_TRANSMITTED; + ieee80211_tx_status_irqsafe(data2->hw, skb); return 0; out: --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7B3BC43217 for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239205AbiCGJ6V (ORCPT ); Mon, 7 Mar 2022 04:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239589AbiCGJjw (ORCPT ); Mon, 7 Mar 2022 04:39: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 AEF1371CBE; Mon, 7 Mar 2022 01:36: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 01B6261140; Mon, 7 Mar 2022 09:35:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08846C340E9; Mon, 7 Mar 2022 09:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645733; bh=S7UFBE1M6W1pYJfWfX3QTKA9zcn2mP6wX1gDD703PA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYCTId9uLG0HlGcw+fUXnxulJH1Uta3YKOioiESgjjsHAsWrdP0tNyedNXX0JrH4c qy2Ob873C6mcT/WUt0tmkcof5naRMTv/+aPXrvCry4t/QnipnUEBzWnxNK0+U4uS3+ tyiOKSpoWkA7ovXUvEiorf71RXJvcpYyt5pQdPJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, JaeMan Park , Johannes Berg , Sasha Levin Subject: [PATCH 5.15 002/262] mac80211_hwsim: initialize ieee80211_tx_info at hw_scan_work Date: Mon, 7 Mar 2022 10:15:46 +0100 Message-Id: <20220307091702.450460848@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: JaeMan Park [ Upstream commit cacfddf82baf1470e5741edeecb187260868f195 ] In mac80211_hwsim, the probe_req frame is created and sent while scanning. It is sent with ieee80211_tx_info which is not initialized. Uninitialized ieee80211_tx_info can cause problems when using mac80211_hwsim with wmediumd. wmediumd checks the tx_rates field of ieee80211_tx_info and doesn't relay probe_req frame to other clients even if it is a broadcasting message. Call ieee80211_tx_prepare_skb() to initialize ieee80211_tx_info for the probe_req that is created by hw_scan_work in mac80211_hwsim. Signed-off-by: JaeMan Park Link: https://lore.kernel.org/r/20220113060235.546107-1-jaeman@google.com [fix memory leak] Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/wireless/mac80211_hwsim.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/m= ac80211_hwsim.c index 52f13afb7cba2..0aeb1e1ec93ff 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -2336,6 +2336,15 @@ static void hw_scan_work(struct work_struct *work) if (req->ie_len) skb_put_data(probe, req->ie, req->ie_len); =20 + if (!ieee80211_tx_prepare_skb(hwsim->hw, + hwsim->hw_scan_vif, + probe, + hwsim->tmp_chan->band, + NULL)) { + kfree_skb(probe); + continue; + } + local_bh_disable(); mac80211_hwsim_tx_frame(hwsim->hw, probe, hwsim->tmp_chan); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A50C46467 for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239355AbiCGJ6x (ORCPT ); Mon, 7 Mar 2022 04:58:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240109AbiCGJkh (ORCPT ); Mon, 7 Mar 2022 04:40:37 -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 2C4116E360; Mon, 7 Mar 2022 01: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 B182EB810E0; Mon, 7 Mar 2022 09:36:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2814AC36AF6; Mon, 7 Mar 2022 09:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645769; bh=YfYYgfEG/tUw+RF/Z5+2ChlPUubhZWSVdHx6WExWyhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtB7qqOIC34PFc3jvEqOu2e+la7PXppg2CRwOuBlcHgDrHBzCqo4GEcpeYsLR6old 8ubFeLe3685eIRs34slqtqUs8YDfCsWf9sGQ3O+Ee6vSaAJuT5WWkzbZ+A9sAYd6Rp nWmNFsoWbdY5n9EPxLAaHsfLLdwoN5ecaQlzIoDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Anholt , Stefan Wahren , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 003/262] i2c: bcm2835: Avoid clock stretching timeouts Date: Mon, 7 Mar 2022 10:15:47 +0100 Message-Id: <20220307091702.477693191@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Anholt [ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt Signed-off-by: Stefan Wahren BugLink: https://github.com/raspberrypi/linux/issues/3064 Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i2c/busses/i2c-bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2= 835.c index 37443edbf7546..ad3b124a2e376 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -23,6 +23,11 @@ #define BCM2835_I2C_FIFO 0x10 #define BCM2835_I2C_DIV 0x14 #define BCM2835_I2C_DEL 0x18 +/* + * 16-bit field for the number of SCL cycles to wait after rising SCL + * before deciding the slave is not responding. 0 disables the + * timeout detection. + */ #define BCM2835_I2C_CLKT 0x1c =20 #define BCM2835_I2C_C_READ BIT(0) @@ -477,6 +482,12 @@ static int bcm2835_i2c_probe(struct platform_device *p= dev) adap->dev.of_node =3D pdev->dev.of_node; adap->quirks =3D of_device_get_match_data(&pdev->dev); =20 + /* + * Disable the hardware clock stretching timeout. SMBUS + * specifies a limit for how long the device can stretch the + * clock, but core I2C doesn't. + */ + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0); bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); =20 ret =3D i2c_add_adapter(adap); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B465C35295 for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239807AbiCGJuL (ORCPT ); Mon, 7 Mar 2022 04:50:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240157AbiCGJko (ORCPT ); Mon, 7 Mar 2022 04:40:44 -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 F38D5674F0; Mon, 7 Mar 2022 01:37: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 ams.source.kernel.org (Postfix) with ESMTPS id 8BE6FB810CF; Mon, 7 Mar 2022 09:36:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F649C340E9; Mon, 7 Mar 2022 09:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645804; bh=wZH01uOAO4UsGv9C+T2IqqCCfADRCqC0wjWMBt/crTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkDnvw+8OwFO3vRCX0c4nEsIzXUoY15fj38qFRoOPs5ZPKDghBjOgQzYH/nazIlPT TQRapya1PEdBbJsI4PT7Wpfdo00+sYp8mkbYb2STDXcsXD/J3EAg6MnTiO3srYLu+n RJrB7gW97PbwLlLnY9Ou0ZLkU3Tk+G/SMgKSvnWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Bard Liao , Ranjani Sridharan , Pierre-Louis Bossart , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Shuming Fan , Mark Brown , Sasha Levin Subject: [PATCH 5.15 004/262] ASoC: rt5668: do not block workqueue if card is unbound Date: Mon, 7 Mar 2022 10:15:48 +0100 Message-Id: <20220307091702.505018653@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Kai Vehmanen [ Upstream commit a6d78661dc903d90a327892bbc34268f3a5f4b9c ] The current rt5668_jack_detect_handler() assumes the component and card will always show up and implements an infinite usleep loop waiting for them to show up. This does not hold true if a codec interrupt (or other event) occurs when the card is unbound. The codec driver's remove or shutdown functions cannot cancel the workqueue due to the wait loop. As a result, code can either end up blocking the workqueue, or hit a kernel oops when the card is freed. Fix the issue by rescheduling the jack detect handler in case the card is not ready. In case card never shows up, the shutdown/remove/suspend calls can now cancel the detect task. Signed-off-by: Kai Vehmanen Reviewed-by: Bard Liao Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: P=C3=A9ter Ujfalusi Reviewed-by: Shuming Fan Link: https://lore.kernel.org/r/20220207153000.3452802-2-kai.vehmanen@linux= .intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/rt5668.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/rt5668.c b/sound/soc/codecs/rt5668.c index 6ab1a8bc37352..1186ceb5a978e 100644 --- a/sound/soc/codecs/rt5668.c +++ b/sound/soc/codecs/rt5668.c @@ -1022,11 +1022,13 @@ static void rt5668_jack_detect_handler(struct work_= struct *work) container_of(work, struct rt5668_priv, jack_detect_work.work); int val, btn_type; =20 - while (!rt5668->component) - usleep_range(10000, 15000); - - while (!rt5668->component->card->instantiated) - usleep_range(10000, 15000); + if (!rt5668->component || !rt5668->component->card || + !rt5668->component->card->instantiated) { + /* card not yet ready, try later */ + mod_delayed_work(system_power_efficient_wq, + &rt5668->jack_detect_work, msecs_to_jiffies(15)); + return; + } =20 mutex_lock(&rt5668->calibrate_mutex); =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0118AC433EF for ; Mon, 7 Mar 2022 09:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239779AbiCGJuH (ORCPT ); Mon, 7 Mar 2022 04:50:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240159AbiCGJko (ORCPT ); Mon, 7 Mar 2022 04:40:44 -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 4CFD06E4C5; Mon, 7 Mar 2022 01:37: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 E4B8561140; Mon, 7 Mar 2022 09:36:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8A3FC340E9; Mon, 7 Mar 2022 09:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645807; bh=mqQlBlOzmeSF6kjm5/81gVYISa9Xaknvi26FPi+wghc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZSiqUfDTyEW3aX2kr9tzL1CIETWHldVwTMdzbTUZIyUbv7sXYaTlEEnI6nFsuMUY Od0QUUxfG+D7sEHBg/08htJljvd2k/axjFuVx8oHActnd5N7OOWH4bbCdkA+B1hfD8 fsZWBMjNMIHQ8q5BnIssyWUxR4a2SeX4NOGdhnm4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Bard Liao , Ranjani Sridharan , Pierre-Louis Bossart , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Shuming Fan , Mark Brown , Sasha Levin Subject: [PATCH 5.15 005/262] ASoC: rt5682: do not block workqueue if card is unbound Date: Mon, 7 Mar 2022 10:15:49 +0100 Message-Id: <20220307091702.532460974@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Kai Vehmanen [ Upstream commit 4c33de0673ced9c7c37b3bbd9bfe0fda72340b2a ] The current rt5682_jack_detect_handler() assumes the component and card will always show up and implements an infinite usleep loop waiting for them to show up. This does not hold true if a codec interrupt (or other event) occurs when the card is unbound. The codec driver's remove or shutdown functions cannot cancel the workqueue due to the wait loop. As a result, code can either end up blocking the workqueue, or hit a kernel oops when the card is freed. Fix the issue by rescheduling the jack detect handler in case the card is not ready. In case card never shows up, the shutdown/remove/suspend calls can now cancel the detect task. Signed-off-by: Kai Vehmanen Reviewed-by: Bard Liao Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: P=C3=A9ter Ujfalusi Reviewed-by: Shuming Fan Link: https://lore.kernel.org/r/20220207153000.3452802-3-kai.vehmanen@linux= .intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/rt5682.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 757d1362b5f48..6ad3159eceb98 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -1090,11 +1090,13 @@ void rt5682_jack_detect_handler(struct work_struct = *work) container_of(work, struct rt5682_priv, jack_detect_work.work); int val, btn_type; =20 - while (!rt5682->component) - usleep_range(10000, 15000); - - while (!rt5682->component->card->instantiated) - usleep_range(10000, 15000); + if (!rt5682->component || !rt5682->component->card || + !rt5682->component->card->instantiated) { + /* card not yet ready, try later */ + mod_delayed_work(system_power_efficient_wq, + &rt5682->jack_detect_work, msecs_to_jiffies(15)); + return; + } =20 mutex_lock(&rt5682->calibrate_mutex); =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68821C4707A for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239397AbiCGJ67 (ORCPT ); Mon, 7 Mar 2022 04:58:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240198AbiCGJkr (ORCPT ); Mon, 7 Mar 2022 04:40: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 1C2206949E; Mon, 7 Mar 2022 01:37: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 1CA1E612E7; Mon, 7 Mar 2022 09:36:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1134FC340E9; Mon, 7 Mar 2022 09:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645810; bh=/TuSRVhhNgcRtaFhCwFzRY1d6sThkyuKd+NanmVdqy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8iMOqqg3VfkfBOx39U4bHMEtdUbkZenCPtsHejCN6p9Fx2NvA0ABCXfpBbT6JWYO +4H2ywy+7np6P52snj3QwfGJYoaC1JBuQjh6IhNVEBbyIGrgAz8X/fJ2NlGU7U9uGw Lx388bDPK/RxDEXsSRYAF/EuaUsQqHJWBmrxuWQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Barta , Mark Brown , Sasha Levin Subject: [PATCH 5.15 006/262] regulator: core: fix false positive in regulator_late_cleanup() Date: Mon, 7 Mar 2022 10:15:50 +0100 Message-Id: <20220307091702.560296010@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Oliver Barta [ Upstream commit 4e2a354e3775870ca823f1fb29bbbffbe11059a6 ] The check done by regulator_late_cleanup() to detect whether a regulator is on was inconsistent with the check done by _regulator_is_enabled(). While _regulator_is_enabled() takes the enable GPIO into account, regulator_late_cleanup() was not doing that. This resulted in a false positive, e.g. when a GPIO-controlled fixed regulator was used, which was not enabled at boot time, e.g. reg_disp_1v2: reg_disp_1v2 { compatible =3D "regulator-fixed"; regulator-name =3D "display_1v2"; regulator-min-microvolt =3D <1200000>; regulator-max-microvolt =3D <1200000>; gpio =3D <&tlmm 148 0>; enable-active-high; }; Such regulator doesn't have an is_enabled() operation. Nevertheless it's state can be determined based on the enable GPIO. The check in regulator_late_cleanup() wrongly assumed that the regulator is on and tried to disable it. Signed-off-by: Oliver Barta Link: https://lore.kernel.org/r/20220208084645.8686-1-oliver.barta@aptiv.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/regulator/core.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ca6caba8a191a..46e76b5b21efe 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -6010,9 +6010,8 @@ core_initcall(regulator_init); static int regulator_late_cleanup(struct device *dev, void *data) { struct regulator_dev *rdev =3D dev_to_rdev(dev); - const struct regulator_ops *ops =3D rdev->desc->ops; struct regulation_constraints *c =3D rdev->constraints; - int enabled, ret; + int ret; =20 if (c && c->always_on) return 0; @@ -6025,14 +6024,8 @@ static int regulator_late_cleanup(struct device *dev= , void *data) if (rdev->use_count) goto unlock; =20 - /* If we can't read the status assume it's always on. */ - if (ops->is_enabled) - enabled =3D ops->is_enabled(rdev); - else - enabled =3D 1; - - /* But if reading the status failed, assume that it's off. */ - if (enabled <=3D 0) + /* If reading the status failed, assume that it's off. */ + if (_regulator_is_enabled(rdev) <=3D 0) goto unlock; =20 if (have_full_constraints()) { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F2EC433FE for ; Mon, 7 Mar 2022 10:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239531AbiCGJ71 (ORCPT ); Mon, 7 Mar 2022 04:59:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240302AbiCGJkx (ORCPT ); Mon, 7 Mar 2022 04:40:53 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B036212A; Mon, 7 Mar 2022 01:37: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 sin.source.kernel.org (Postfix) with ESMTPS id 4F26ACE0EAA; Mon, 7 Mar 2022 09:36:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67060C340E9; Mon, 7 Mar 2022 09:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645813; bh=Kd7tWJSaOdAD0nh7OxQbtG+Qpn/HeAoCK+1NZS/YSUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD55zRLkGxEiZE//iQf4qaGrw7MligeTV1hibvXlNnr/370TG9qX3+5i3GuSAMCxz T3GtLlXcri2jquMshORYrBoqqFqyN6U5WGU5eXTiPVEGTYpIxBbcp1g/lnyUB+LGEz 3cuaHnLV/y44tOExE1GdSk2CF4eOutS3Tc9PhhiU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Hutterer , Benjamin Tissoires , Jiri Kosina , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 007/262] Input: clear BTN_RIGHT/MIDDLE on buttonpads Date: Mon, 7 Mar 2022 10:15:51 +0100 Message-Id: <20220307091702.587190838@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Jos=C3=A9 Exp=C3=B3sito [ Upstream commit 37ef4c19b4c659926ce65a7ac709ceaefb211c40 ] Buttonpads are expected to map the INPUT_PROP_BUTTONPAD property bit and the BTN_LEFT key bit. As explained in the specification, where a device has a button type value of 0 (click-pad) or 1 (pressure-pad) there should not be discrete buttons: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelin= es/touchpad-windows-precision-touchpad-collection#device-capabilities-featu= re-report However, some drivers map the BTN_RIGHT and/or BTN_MIDDLE key bits even though the device is a buttonpad and therefore does not have those buttons. This behavior has forced userspace applications like libinput to implement different workarounds and quirks to detect buttonpads and offer to the user the right set of features and configuration options. For more information: https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/726 In order to avoid this issue clear the BTN_RIGHT and BTN_MIDDLE key bits when the input device is register if the INPUT_PROP_BUTTONPAD property bit is set. Notice that this change will not affect udev because it does not check for buttons. See systemd/src/udev/udev-builtin-input_id.c. List of known affected hardware: - Chuwi AeroBook Plus - Chuwi Gemibook - Framework Laptop - GPD Win Max - Huawei MateBook 2020 - Prestigio Smartbook 141 C2 - Purism Librem 14v1 - StarLite Mk II - AMI firmware - StarLite Mk II - Coreboot firmware - StarLite Mk III - AMI firmware - StarLite Mk III - Coreboot firmware - StarLabTop Mk IV - AMI firmware - StarLabTop Mk IV - Coreboot firmware - StarBook Mk V Acked-by: Peter Hutterer Acked-by: Benjamin Tissoires Acked-by: Jiri Kosina Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Link: https://lore.kernel.org/r/20220208174806.17183-1-jose.exposito89@gmai= l.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/input/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index ccaeb24263854..c3139bc2aa0db 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2285,6 +2285,12 @@ int input_register_device(struct input_dev *dev) /* KEY_RESERVED is not supposed to be transmitted to userspace. */ __clear_bit(KEY_RESERVED, dev->keybit); =20 + /* Buttonpads should not map BTN_RIGHT and/or BTN_MIDDLE. */ + if (test_bit(INPUT_PROP_BUTTONPAD, dev->propbit)) { + __clear_bit(BTN_RIGHT, dev->keybit); + __clear_bit(BTN_MIDDLE, dev->keybit); + } + /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ input_cleanse_bitmasks(dev); =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3993DC35296 for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239888AbiCGJuT (ORCPT ); Mon, 7 Mar 2022 04:50:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240257AbiCGJkv (ORCPT ); Mon, 7 Mar 2022 04:40:51 -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 BF6AA6E570; Mon, 7 Mar 2022 01:37: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 64D4FB810D1; Mon, 7 Mar 2022 09:36:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81D34C340E9; Mon, 7 Mar 2022 09:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645817; bh=ogsP3s5MeLbN7aR6oo7GJS1vGcKrwQu0DklK25U2cWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDNk8Ls+4KEStO/oAsxyprRsuLf48wIJHa0JBjYStwsgqekU1ZXyu0e85V8lxR7zy e24sqoT+Z8oCWDE6aYynDoyJPpPM80xg5sZjcRZWvM9HsAYKP3QBlDHzt94pRmkmNN hL2ZAHt4k+oePNEiL2YsCrX+xX0Sg4JUw1NpeDzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Omar Sandoval , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 5.15 008/262] btrfs: get rid of warning on transaction commit when using flushoncommit Date: Mon, 7 Mar 2022 10:15:52 +0100 Message-Id: <20220307091702.615122612@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Filipe Manana [ Upstream commit a0f0cf8341e34e5d2265bfd3a7ad68342da1e2aa ] When using the flushoncommit mount option, during almost every transaction commit we trigger a warning from __writeback_inodes_sb_nr(): $ cat fs/fs-writeback.c: (...) static void __writeback_inodes_sb_nr(struct super_block *sb, ... { (...) WARN_ON(!rwsem_is_locked(&sb->s_umount)); (...) } (...) The trace produced in dmesg looks like the following: [947.473890] WARNING: CPU: 5 PID: 930 at fs/fs-writeback.c:2610 __writeba= ck_inodes_sb_nr+0x7e/0xb3 [947.481623] Modules linked in: nfsd nls_cp437 cifs asn1_decoder cifs_arc= 4 fscache cifs_md4 ipmi_ssif [947.489571] CPU: 5 PID: 930 Comm: btrfs-transacti Not tainted 95.16.3-sr= b-asrock-00001-g36437ad63879 #186 [947.497969] RIP: 0010:__writeback_inodes_sb_nr+0x7e/0xb3 [947.502097] Code: 24 10 4c 89 44 24 18 c6 (...) [947.519760] RSP: 0018:ffffc90000777e10 EFLAGS: 00010246 [947.523818] RAX: 0000000000000000 RBX: 0000000000963300 RCX: 00000000000= 00000 [947.529765] RDX: 0000000000000000 RSI: 000000000000fa51 RDI: ffffc900007= 77e50 [947.535740] RBP: ffff888101628a90 R08: ffff888100955800 R09: ffff8881009= 56000 [947.541701] R10: 0000000000000002 R11: 0000000000000001 R12: ffff8881009= 63488 [947.547645] R13: ffff888100963000 R14: ffff888112fb7200 R15: ffff8881009= 63460 [947.553621] FS: 0000000000000000(0000) GS:ffff88841fd40000(0000) knlGS:= 0000000000000000 [947.560537] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [947.565122] CR2: 0000000008be50c4 CR3: 000000000220c000 CR4: 00000000001= 006e0 [947.571072] Call Trace: [947.572354] [947.573266] btrfs_commit_transaction+0x1f1/0x998 [947.576785] ? start_transaction+0x3ab/0x44e [947.579867] ? schedule_timeout+0x8a/0xdd [947.582716] transaction_kthread+0xe9/0x156 [947.585721] ? btrfs_cleanup_transaction.isra.0+0x407/0x407 [947.590104] kthread+0x131/0x139 [947.592168] ? set_kthread_struct+0x32/0x32 [947.595174] ret_from_fork+0x22/0x30 [947.597561] [947.598553] ---[ end trace 644721052755541c ]--- This is because we started using writeback_inodes_sb() to flush delalloc when committing a transaction (when using -o flushoncommit), in order to avoid deadlocks with filesystem freeze operations. This change was made by commit ce8ea7cc6eb313 ("btrfs: don't call btrfs_start_delalloc_roots in flushoncommit"). After that change we started producing that warning, and every now and then a user reports this since the warning happens too often, it spams dmesg/syslog, and a user is unsure if this reflects any problem that might compromise the filesystem's reliability. We can not just lock the sb->s_umount semaphore before calling writeback_inodes_sb(), because that would at least deadlock with filesystem freezing, since at fs/super.c:freeze_super() sync_filesystem() is called while we are holding that semaphore in write mode, and that can trigger a transaction commit, resulting in a deadlock. It would also trigger the same type of deadlock in the unmount path. Possibly, it could also introduce some other locking dependencies that lockdep would report. To fix this call try_to_writeback_inodes_sb() instead of writeback_inodes_sb(), because that will try to read lock sb->s_umount and then will only call writeback_inodes_sb() if it was able to lock it. This is fine because the cases where it can't read lock sb->s_umount are during a filesystem unmount or during a filesystem freeze - in those cases sb->s_umount is write locked and sync_filesystem() is called, which calls writeback_inodes_sb(). In other words, in all cases where we can't take a read lock on sb->s_umount, writeback is already being triggered elsewhere. An alternative would be to call btrfs_start_delalloc_roots() with a number of pages different from LONG_MAX, for example matching the number of delalloc bytes we currently have, in which case we would end up starting all delalloc with filemap_fdatawrite_wbc() and not with an async flush via filemap_flush() - that is only possible after the rather recent commit e076ab2a2ca70a ("btrfs: shrink delalloc pages instead of full inodes"). However that creates a whole new can of worms due to new lock dependencies, which lockdep complains, like for example: [ 8948.247280] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D [ 8948.247823] WARNING: possible circular locking dependency detected [ 8948.248353] 5.17.0-rc1-btrfs-next-111 #1 Not tainted [ 8948.248786] ------------------------------------------------------ [ 8948.249320] kworker/u16:18/933570 is trying to acquire lock: [ 8948.249812] ffff9b3de1591690 (sb_internal#2){.+.+}-{0:0}, at: find_free_= extent+0x141e/0x1590 [btrfs] [ 8948.250638] but task is already holding lock: [ 8948.251140] ffff9b3e09c717d8 (&root->delalloc_mutex){+.+.}-{3:3}, at: st= art_delalloc_inodes+0x78/0x400 [btrfs] [ 8948.252018] which lock already depends on the new lock. [ 8948.252710] the existing dependency chain (in reverse order) is: [ 8948.253343] -> #2 (&root->delalloc_mutex){+.+.}-{3:3}: [ 8948.253950] __mutex_lock+0x90/0x900 [ 8948.254354] start_delalloc_inodes+0x78/0x400 [btrfs] [ 8948.254859] btrfs_start_delalloc_roots+0x194/0x2a0 [btrfs] [ 8948.255408] btrfs_commit_transaction+0x32f/0xc00 [btrfs] [ 8948.255942] btrfs_mksubvol+0x380/0x570 [btrfs] [ 8948.256406] btrfs_mksnapshot+0x81/0xb0 [btrfs] [ 8948.256870] __btrfs_ioctl_snap_create+0x17f/0x190 [btrfs] [ 8948.257413] btrfs_ioctl_snap_create_v2+0xbb/0x140 [btrfs] [ 8948.257961] btrfs_ioctl+0x1196/0x3630 [btrfs] [ 8948.258418] __x64_sys_ioctl+0x83/0xb0 [ 8948.258793] do_syscall_64+0x3b/0xc0 [ 8948.259146] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 8948.259709] -> #1 (&fs_info->delalloc_root_mutex){+.+.}-{3:3}: [ 8948.260330] __mutex_lock+0x90/0x900 [ 8948.260692] btrfs_start_delalloc_roots+0x97/0x2a0 [btrfs] [ 8948.261234] btrfs_commit_transaction+0x32f/0xc00 [btrfs] [ 8948.261766] btrfs_set_free_space_cache_v1_active+0x38/0x60 [btrfs] [ 8948.262379] btrfs_start_pre_rw_mount+0x119/0x180 [btrfs] [ 8948.262909] open_ctree+0x1511/0x171e [btrfs] [ 8948.263359] btrfs_mount_root.cold+0x12/0xde [btrfs] [ 8948.263863] legacy_get_tree+0x30/0x50 [ 8948.264242] vfs_get_tree+0x28/0xc0 [ 8948.264594] vfs_kern_mount.part.0+0x71/0xb0 [ 8948.265017] btrfs_mount+0x11d/0x3a0 [btrfs] [ 8948.265462] legacy_get_tree+0x30/0x50 [ 8948.265851] vfs_get_tree+0x28/0xc0 [ 8948.266203] path_mount+0x2d4/0xbe0 [ 8948.266554] __x64_sys_mount+0x103/0x140 [ 8948.266940] do_syscall_64+0x3b/0xc0 [ 8948.267300] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 8948.267790] -> #0 (sb_internal#2){.+.+}-{0:0}: [ 8948.268322] __lock_acquire+0x12e8/0x2260 [ 8948.268733] lock_acquire+0xd7/0x310 [ 8948.269092] start_transaction+0x44c/0x6e0 [btrfs] [ 8948.269591] find_free_extent+0x141e/0x1590 [btrfs] [ 8948.270087] btrfs_reserve_extent+0x14b/0x280 [btrfs] [ 8948.270588] cow_file_range+0x17e/0x490 [btrfs] [ 8948.271051] btrfs_run_delalloc_range+0x345/0x7a0 [btrfs] [ 8948.271586] writepage_delalloc+0xb5/0x170 [btrfs] [ 8948.272071] __extent_writepage+0x156/0x3c0 [btrfs] [ 8948.272579] extent_write_cache_pages+0x263/0x460 [btrfs] [ 8948.273113] extent_writepages+0x76/0x130 [btrfs] [ 8948.273573] do_writepages+0xd2/0x1c0 [ 8948.273942] filemap_fdatawrite_wbc+0x68/0x90 [ 8948.274371] start_delalloc_inodes+0x17f/0x400 [btrfs] [ 8948.274876] btrfs_start_delalloc_roots+0x194/0x2a0 [btrfs] [ 8948.275417] flush_space+0x1f2/0x630 [btrfs] [ 8948.275863] btrfs_async_reclaim_data_space+0x108/0x1b0 [btrfs] [ 8948.276438] process_one_work+0x252/0x5a0 [ 8948.276829] worker_thread+0x55/0x3b0 [ 8948.277189] kthread+0xf2/0x120 [ 8948.277506] ret_from_fork+0x22/0x30 [ 8948.277868] other info that might help us debug this: [ 8948.278548] Chain exists of: sb_internal#2 --> &fs_info->delalloc_root_mutex --> &root-= >delalloc_mutex [ 8948.279601] Possible unsafe locking scenario: [ 8948.280102] CPU0 CPU1 [ 8948.280508] ---- ---- [ 8948.280915] lock(&root->delalloc_mutex); [ 8948.281271] lock(&fs_info->delalloc_root_= mutex); [ 8948.281915] lock(&root->delalloc_mutex); [ 8948.282487] lock(sb_internal#2); [ 8948.282800] *** DEADLOCK *** [ 8948.283333] 4 locks held by kworker/u16:18/933570: [ 8948.283750] #0: ffff9b3dc00a9d48 ((wq_completion)events_unbound){+.+.}-= {0:0}, at: process_one_work+0x1d2/0x5a0 [ 8948.284609] #1: ffffa90349dafe70 ((work_completion)(&fs_info->async_dat= a_reclaim_work)){+.+.}-{0:0}, at: process_one_work+0x1d2/0x5a0 [ 8948.285637] #2: ffff9b3e14db5040 (&fs_info->delalloc_root_mutex){+.+.}-= {3:3}, at: btrfs_start_delalloc_roots+0x97/0x2a0 [btrfs] [ 8948.286674] #3: ffff9b3e09c717d8 (&root->delalloc_mutex){+.+.}-{3:3}, a= t: start_delalloc_inodes+0x78/0x400 [btrfs] [ 8948.287596] stack backtrace: [ 8948.287975] CPU: 3 PID: 933570 Comm: kworker/u16:18 Not tainted 5.17.0-r= c1-btrfs-next-111 #1 [ 8948.288677] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS = rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [ 8948.289649] Workqueue: events_unbound btrfs_async_reclaim_data_space [bt= rfs] [ 8948.290298] Call Trace: [ 8948.290517] [ 8948.290700] dump_stack_lvl+0x59/0x73 [ 8948.291026] check_noncircular+0xf3/0x110 [ 8948.291375] ? start_transaction+0x228/0x6e0 [btrfs] [ 8948.291826] __lock_acquire+0x12e8/0x2260 [ 8948.292241] lock_acquire+0xd7/0x310 [ 8948.292714] ? find_free_extent+0x141e/0x1590 [btrfs] [ 8948.293241] ? lock_is_held_type+0xea/0x140 [ 8948.293601] start_transaction+0x44c/0x6e0 [btrfs] [ 8948.294055] ? find_free_extent+0x141e/0x1590 [btrfs] [ 8948.294518] find_free_extent+0x141e/0x1590 [btrfs] [ 8948.294957] ? _raw_spin_unlock+0x29/0x40 [ 8948.295312] ? btrfs_get_alloc_profile+0x124/0x290 [btrfs] [ 8948.295813] btrfs_reserve_extent+0x14b/0x280 [btrfs] [ 8948.296270] cow_file_range+0x17e/0x490 [btrfs] [ 8948.296691] btrfs_run_delalloc_range+0x345/0x7a0 [btrfs] [ 8948.297175] ? find_lock_delalloc_range+0x247/0x270 [btrfs] [ 8948.297678] writepage_delalloc+0xb5/0x170 [btrfs] [ 8948.298123] __extent_writepage+0x156/0x3c0 [btrfs] [ 8948.298570] extent_write_cache_pages+0x263/0x460 [btrfs] [ 8948.299061] extent_writepages+0x76/0x130 [btrfs] [ 8948.299495] do_writepages+0xd2/0x1c0 [ 8948.299817] ? sched_clock_cpu+0xd/0x110 [ 8948.300160] ? lock_release+0x155/0x4a0 [ 8948.300494] filemap_fdatawrite_wbc+0x68/0x90 [ 8948.300874] ? do_raw_spin_unlock+0x4b/0xa0 [ 8948.301243] start_delalloc_inodes+0x17f/0x400 [btrfs] [ 8948.301706] ? lock_release+0x155/0x4a0 [ 8948.302055] btrfs_start_delalloc_roots+0x194/0x2a0 [btrfs] [ 8948.302564] flush_space+0x1f2/0x630 [btrfs] [ 8948.302970] btrfs_async_reclaim_data_space+0x108/0x1b0 [btrfs] [ 8948.303510] process_one_work+0x252/0x5a0 [ 8948.303860] ? process_one_work+0x5a0/0x5a0 [ 8948.304221] worker_thread+0x55/0x3b0 [ 8948.304543] ? process_one_work+0x5a0/0x5a0 [ 8948.304904] kthread+0xf2/0x120 [ 8948.305184] ? kthread_complete_and_exit+0x20/0x20 [ 8948.305598] ret_from_fork+0x22/0x30 [ 8948.305921] It all comes from the fact that btrfs_start_delalloc_roots() takes the delalloc_root_mutex, in the transaction commit path we are holding a read lock on one of the superblock's freeze semaphores (via sb_start_intwrite()), the async reclaim task can also do a call to btrfs_start_delalloc_roots(), which ends up triggering writeback with calls to filemap_fdatawrite_wbc(), resulting in extent allocation which in turn can call btrfs_start_transaction(), which will result in taking the freeze semaphore via sb_start_intwrite(), forming a nasty dependency on all those locks which can be taken in different orders by different code paths. So just adopt the simple approach of calling try_to_writeback_inodes_sb() at btrfs_start_delalloc_flush(). Link: https://lore.kernel.org/linux-btrfs/20220130005258.GA7465@cuci.nl/ Link: https://lore.kernel.org/linux-btrfs/43acc426-d683-d1b6-729d-c6bc4a2ff= f4d@gmail.com/ Link: https://lore.kernel.org/linux-btrfs/6833930a-08d7-6fbc-0141-eb9cdfd6b= b4d@gmail.com/ Link: https://lore.kernel.org/linux-btrfs/20190322041731.GF16651@hungrycats= .org/ Reviewed-by: Omar Sandoval Signed-off-by: Filipe Manana [ add more link reports ] Signed-off-by: David Sterba Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/btrfs/transaction.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index f1ae5a5b79c68..e3e9c58ea66fa 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2014,16 +2014,24 @@ static void btrfs_cleanup_pending_block_groups(stru= ct btrfs_trans_handle *trans) static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) { /* - * We use writeback_inodes_sb here because if we used + * We use try_to_writeback_inodes_sb() here because if we used * btrfs_start_delalloc_roots we would deadlock with fs freeze. * Currently are holding the fs freeze lock, if we do an async flush * we'll do btrfs_join_transaction() and deadlock because we need to * wait for the fs freeze lock. Using the direct flushing we benefit * from already being in a transaction and our join_transaction doesn't * have to re-take the fs freeze lock. + * + * Note that try_to_writeback_inodes_sb() will only trigger writeback + * if it can read lock sb->s_umount. It will always be able to lock it, + * except when the filesystem is being unmounted or being frozen, but in + * those cases sync_filesystem() is called, which results in calling + * writeback_inodes_sb() while holding a write lock on sb->s_umount. + * Note that we don't call writeback_inodes_sb() directly, because it + * will emit a warning if sb->s_umount is not locked. */ if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) - writeback_inodes_sb(fs_info->sb, WB_REASON_SYNC); + try_to_writeback_inodes_sb(fs_info->sb, WB_REASON_SYNC); return 0; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81403C352A1 for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239944AbiCGJu0 (ORCPT ); Mon, 7 Mar 2022 04:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240358AbiCGJk4 (ORCPT ); Mon, 7 Mar 2022 04:40: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 95D8165830; Mon, 7 Mar 2022 01:37: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 A8899B810BD; Mon, 7 Mar 2022 09:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4B31C340F3; Mon, 7 Mar 2022 09:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645820; bh=pJlFBvjxuJ7foblMFzRm/Bg/OJGdmZY6qGEQYa19W1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOSq5QQjHHKSQjNED9VfmvyqfNJV9EsABx00pLbRgN4jgZE1S6U2kO5QS7+pRFGsP zObAn4ZpUlZmgAhVO8wCVzJRv9Exlv7DB304fLrJXVz6z6PVOwpFwhIeZx4cV+aQ8a hbxsCESgtInaZeLhnDYyiDPtubufyWsPHRDVQcyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Marc Zyngier , Sasha Levin Subject: [PATCH 5.15 009/262] KVM: arm64: vgic: Read HW interrupt pending state from the HW Date: Mon, 7 Mar 2022 10:15:53 +0100 Message-Id: <20220307091702.642074598@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marc Zyngier [ Upstream commit 5bfa685e62e9ba93c303a9a8db646c7228b9b570 ] It appears that a read access to GIC[DR]_I[CS]PENDRn doesn't always result in the pending interrupts being accurately reported if they are mapped to a HW interrupt. This is particularily visible when acking the timer interrupt and reading the GICR_ISPENDR1 register immediately after, for example (the interrupt appears as not-pending while it really is...). This is because a HW interrupt has its 'active and pending state' kept in the *physical* distributor, and not in the virtual one, as mandated by the spec (this is what allows the direct deactivation). The virtual distributor only caries the pending and active *states* (note the plural, as these are two independent and non-overlapping states). Fix it by reading the HW state back, either from the timer itself or from the distributor if necessary. Reported-by: Ricardo Koller Tested-by: Ricardo Koller Reviewed-by: Ricardo Koller Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220208123726.3604198-1-maz@kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/vgic/vgic-mmio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmi= o.c index 48c6067fc5ecb..f972992682746 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.c +++ b/arch/arm64/kvm/vgic/vgic-mmio.c @@ -248,6 +248,8 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *v= cpu, IRQCHIP_STATE_PENDING, &val); WARN_RATELIMIT(err, "IRQ %d", irq->host_irq); + } else if (vgic_irq_is_mapped_level(irq)) { + val =3D vgic_get_phys_line_level(irq); } else { val =3D irq_is_pending(irq); } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA4E6C43219 for ; Mon, 7 Mar 2022 09:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239268AbiCGJtV (ORCPT ); Mon, 7 Mar 2022 04:49:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239336AbiCGJjh (ORCPT ); Mon, 7 Mar 2022 04:39:37 -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 C9BFF6D84E; Mon, 7 Mar 2022 01: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 ams.source.kernel.org (Postfix) with ESMTPS id DA445B810CF; Mon, 7 Mar 2022 09:35:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 364B3C340E9; Mon, 7 Mar 2022 09:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645702; bh=rW27RDIxb4zRm6FShjRgjJye5PiLNdSUc2enKTspRag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zyr9OPbpyEPPoTTdBZjQEm6LgcZYRC2day2ou8r5B4CmWT8jZxpVo9eGlekpjcEV1 PhL63/uHSS3+okyM6nGtrWJi7WTK659iXAA0bV8tXx2iQNle4WOW/Ia6VbuHJ98XJF 34u5AnfLlDZ5rS8H3S6QX8bl+OdNcEzDVUzTWCRo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Vivek Goyal , Pei Zhang , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 010/262] block: loop:use kstatfs.f_bsize of backing file to set discard granularity Date: Mon, 7 Mar 2022 10:15:54 +0100 Message-Id: <20220307091702.668709970@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ming Lei [ Upstream commit 06582bc86d7f48d35cd044098ca1e246e8c7c52e ] If backing file's filesystem has implemented ->fallocate(), we think the loop device can support discard, then pass sb->s_blocksize as discard_granularity. However, some underlying FS, such as overlayfs, doesn't set sb->s_blocksize, and causes discard_granularity to be set as zero, then the warning in __blkdev_issue_discard() is triggered. Christoph suggested to pass kstatfs.f_bsize as discard granularity, and this way is fine because kstatfs.f_bsize means 'Optimal transfer block size', which still matches with definition of discard granularity. So fix the issue by setting discard_granularity as kstatfs.f_bsize if it is available, otherwise claims discard isn't supported. Cc: Christoph Hellwig Cc: Vivek Goyal Reported-by: Pei Zhang Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220126035830.296465-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/block/loop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c00ae30fde89e..92f9d32bfae5e 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -79,6 +79,7 @@ #include #include #include +#include =20 #include "loop.h" =20 @@ -939,8 +940,13 @@ static void loop_config_discard(struct loop_device *lo) granularity =3D 0; =20 } else { + struct kstatfs sbuf; + max_discard_sectors =3D UINT_MAX >> 9; - granularity =3D inode->i_sb->s_blocksize; + if (!vfs_statfs(&file->f_path, &sbuf)) + granularity =3D sbuf.f_bsize; + else + max_discard_sectors =3D 0; } =20 if (max_discard_sectors) { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AB9AC433EF for ; Mon, 7 Mar 2022 09:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239180AbiCGJtO (ORCPT ); Mon, 7 Mar 2022 04:49:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239355AbiCGJji (ORCPT ); Mon, 7 Mar 2022 04:39:38 -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 C84C46D85B; Mon, 7 Mar 2022 01:35: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 00956612B2; Mon, 7 Mar 2022 09:35:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D70FC36AE2; Mon, 7 Mar 2022 09:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645705; bh=+oaw10vcsziuPG1r4+KJScrE4s0dXjQd4Jd7dTVsJvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=joxgDVKSG9zig1Q/6oALOFaE0nEHn7VtOfMx5BX1b+nyVLO+DNIZgARvTF8zxc3Ag pFDqB3d9SkpwAJ9wrta3yLVrfaLdpApjiGSb/GVcl5viGRQuqBu0OmKnm+BbbkTzyl ExUprCp9eOfgtv6U6F1NNd0miBFskO7Y60U2ciLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 011/262] tipc: fix a bit overflow in tipc_crypto_key_rcv() Date: Mon, 7 Mar 2022 10:15:55 +0100 Message-Id: <20220307091702.697205977@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua [ Upstream commit 143de8d97d79316590475dc2a84513c63c863ddf ] msg_data_sz return a 32bit value, but size is 16bit. This may lead to a bit overflow. Signed-off-by: Hangyu Hua Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- net/tipc/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index d293614d5fc65..b5074957e8812 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -2287,7 +2287,7 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *r= x, struct tipc_msg *hdr) struct tipc_crypto *tx =3D tipc_net(rx->net)->crypto_tx; struct tipc_aead_key *skey =3D NULL; u16 key_gen =3D msg_key_gen(hdr); - u16 size =3D msg_data_sz(hdr); + u32 size =3D msg_data_sz(hdr); u8 *data =3D msg_data(hdr); unsigned int keylen; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C13BC433F5 for ; Mon, 7 Mar 2022 09:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238813AbiCGJyk (ORCPT ); Mon, 7 Mar 2022 04:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241094AbiCGJlw (ORCPT ); Mon, 7 Mar 2022 04:41: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 9AA0DE89; Mon, 7 Mar 2022 01:40: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 16B5D612D2; Mon, 7 Mar 2022 09:35:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E1CCC340F4; Mon, 7 Mar 2022 09:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645708; bh=pGLG2SOVo6AjJURheQjGN51ViP8G0Dfy41nopw84HZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YNOM8EOjidNS1n+jQCNcNUBm8AoqhamfoxW3Ha0T+t4IW8ouO/tFlzaZWi69NXSIl Tk33tfC+jYyAziuzxksMv5jx0canoekxAmuXIW2X8fn5geBD6LhHUpoqOI1p7qby8e LFK+8RN/L9bvP7sSAZ87Y7fUwJNV9Wdz5++4FiR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French , Sasha Levin Subject: [PATCH 5.15 012/262] cifs: do not use uninitialized data in the owner/group sid Date: Mon, 7 Mar 2022 10:15:56 +0100 Message-Id: <20220307091702.724625798@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ronnie Sahlberg [ Upstream commit 26d3dadebbcbddfaf1d9caad42527a28a0ed28d8 ] When idsfromsid is used we create a special SID for owner/group. This structure must be initialized or else the first 5 bytes of the Authority field of the SID will contain uninitialized data and thus not be a valid SID. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/cifs/cifsacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index ee3aab3dd4ac6..5df21d63dd04e 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -1297,7 +1297,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, st= ruct cifs_ntsd *pnntsd, =20 if (uid_valid(uid)) { /* chown */ uid_t id; - nowner_sid_ptr =3D kmalloc(sizeof(struct cifs_sid), + nowner_sid_ptr =3D kzalloc(sizeof(struct cifs_sid), GFP_KERNEL); if (!nowner_sid_ptr) { rc =3D -ENOMEM; @@ -1326,7 +1326,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, st= ruct cifs_ntsd *pnntsd, } if (gid_valid(gid)) { /* chgrp */ gid_t id; - ngroup_sid_ptr =3D kmalloc(sizeof(struct cifs_sid), + ngroup_sid_ptr =3D kzalloc(sizeof(struct cifs_sid), GFP_KERNEL); if (!ngroup_sid_ptr) { rc =3D -ENOMEM; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80283C433EF for ; Mon, 7 Mar 2022 09:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238896AbiCGJ52 (ORCPT ); Mon, 7 Mar 2022 04:57:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239248AbiCGJj3 (ORCPT ); Mon, 7 Mar 2022 04:39:29 -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 218AD6D4D2; Mon, 7 Mar 2022 01: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 B55E8B80F9F; Mon, 7 Mar 2022 09:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13724C340F3; Mon, 7 Mar 2022 09:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645711; bh=Ra6DSi5bIDoWq86BCG9yfjDB7xSjKtqlRHLvOn2gM+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8QmOlJaG2i7v5joZAgbsywktMAAlqyzf8T6nI/sejDWNa8TwMx3Ete1ofX384gqK Y9+5JvSk9fOgXA2UNBzV2BU6mBfrmbDhE1BIHsUYWhTloYuQSUmQ457nQd5E4/jlBu nZw2ttLHY0U5mock0cKvC+D4xQ0/VghyeTa/houM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shyam Prasad N , Ronnie Sahlberg , Steve French , Sasha Levin Subject: [PATCH 5.15 013/262] cifs: fix double free race when mount fails in cifs_get_root() Date: Mon, 7 Mar 2022 10:15:57 +0100 Message-Id: <20220307091702.752137797@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ronnie Sahlberg [ Upstream commit 3d6cc9898efdfb062efb74dc18cfc700e082f5d5 ] When cifs_get_root() fails during cifs_smb3_do_mount() we call deactivate_locked_super() which eventually will call delayed_free() which will free the context. In this situation we should not proceed to enter the out: section in cifs_smb3_do_mount() and free the same resources a second time. [Thu Feb 10 12:59:06 2022] BUG: KASAN: use-after-free in rcu_cblist_dequeue= +0x32/0x60 [Thu Feb 10 12:59:06 2022] Read of size 8 at addr ffff888364f4d110 by task = swapper/1/0 [Thu Feb 10 12:59:06 2022] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G = OE 5.17.0-rc3+ #4 [Thu Feb 10 12:59:06 2022] Hardware name: Microsoft Corporation Virtual Mac= hine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 12/17/2019 [Thu Feb 10 12:59:06 2022] Call Trace: [Thu Feb 10 12:59:06 2022] [Thu Feb 10 12:59:06 2022] dump_stack_lvl+0x5d/0x78 [Thu Feb 10 12:59:06 2022] print_address_description.constprop.0+0x24/0x150 [Thu Feb 10 12:59:06 2022] ? rcu_cblist_dequeue+0x32/0x60 [Thu Feb 10 12:59:06 2022] kasan_report.cold+0x7d/0x117 [Thu Feb 10 12:59:06 2022] ? rcu_cblist_dequeue+0x32/0x60 [Thu Feb 10 12:59:06 2022] __asan_load8+0x86/0xa0 [Thu Feb 10 12:59:06 2022] rcu_cblist_dequeue+0x32/0x60 [Thu Feb 10 12:59:06 2022] rcu_core+0x547/0xca0 [Thu Feb 10 12:59:06 2022] ? call_rcu+0x3c0/0x3c0 [Thu Feb 10 12:59:06 2022] ? __this_cpu_preempt_check+0x13/0x20 [Thu Feb 10 12:59:06 2022] ? lock_is_held_type+0xea/0x140 [Thu Feb 10 12:59:06 2022] rcu_core_si+0xe/0x10 [Thu Feb 10 12:59:06 2022] __do_softirq+0x1d4/0x67b [Thu Feb 10 12:59:06 2022] __irq_exit_rcu+0x100/0x150 [Thu Feb 10 12:59:06 2022] irq_exit_rcu+0xe/0x30 [Thu Feb 10 12:59:06 2022] sysvec_hyperv_stimer0+0x9d/0xc0 ... [Thu Feb 10 12:59:07 2022] Freed by task 58179: [Thu Feb 10 12:59:07 2022] kasan_save_stack+0x26/0x50 [Thu Feb 10 12:59:07 2022] kasan_set_track+0x25/0x30 [Thu Feb 10 12:59:07 2022] kasan_set_free_info+0x24/0x40 [Thu Feb 10 12:59:07 2022] ____kasan_slab_free+0x137/0x170 [Thu Feb 10 12:59:07 2022] __kasan_slab_free+0x12/0x20 [Thu Feb 10 12:59:07 2022] slab_free_freelist_hook+0xb3/0x1d0 [Thu Feb 10 12:59:07 2022] kfree+0xcd/0x520 [Thu Feb 10 12:59:07 2022] cifs_smb3_do_mount+0x149/0xbe0 [cifs] [Thu Feb 10 12:59:07 2022] smb3_get_tree+0x1a0/0x2e0 [cifs] [Thu Feb 10 12:59:07 2022] vfs_get_tree+0x52/0x140 [Thu Feb 10 12:59:07 2022] path_mount+0x635/0x10c0 [Thu Feb 10 12:59:07 2022] __x64_sys_mount+0x1bf/0x210 [Thu Feb 10 12:59:07 2022] do_syscall_64+0x5c/0xc0 [Thu Feb 10 12:59:07 2022] entry_SYSCALL_64_after_hwframe+0x44/0xae [Thu Feb 10 12:59:07 2022] Last potentially related work creation: [Thu Feb 10 12:59:07 2022] kasan_save_stack+0x26/0x50 [Thu Feb 10 12:59:07 2022] __kasan_record_aux_stack+0xb6/0xc0 [Thu Feb 10 12:59:07 2022] kasan_record_aux_stack_noalloc+0xb/0x10 [Thu Feb 10 12:59:07 2022] call_rcu+0x76/0x3c0 [Thu Feb 10 12:59:07 2022] cifs_umount+0xce/0xe0 [cifs] [Thu Feb 10 12:59:07 2022] cifs_kill_sb+0xc8/0xe0 [cifs] [Thu Feb 10 12:59:07 2022] deactivate_locked_super+0x5d/0xd0 [Thu Feb 10 12:59:07 2022] cifs_smb3_do_mount+0xab9/0xbe0 [cifs] [Thu Feb 10 12:59:07 2022] smb3_get_tree+0x1a0/0x2e0 [cifs] [Thu Feb 10 12:59:07 2022] vfs_get_tree+0x52/0x140 [Thu Feb 10 12:59:07 2022] path_mount+0x635/0x10c0 [Thu Feb 10 12:59:07 2022] __x64_sys_mount+0x1bf/0x210 [Thu Feb 10 12:59:07 2022] do_syscall_64+0x5c/0xc0 [Thu Feb 10 12:59:07 2022] entry_SYSCALL_64_after_hwframe+0x44/0xae Reported-by: Shyam Prasad N Reviewed-by: Shyam Prasad N Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/cifs/cifsfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 9fa930dfd78d6..21bf82fc22783 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -909,6 +909,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, =20 out_super: deactivate_locked_super(sb); + return root; out: if (cifs_sb) { kfree(cifs_sb->prepath); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14424C4707A for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239372AbiCGJti (ORCPT ); Mon, 7 Mar 2022 04:49:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239709AbiCGJkK (ORCPT ); Mon, 7 Mar 2022 04:40: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 650647462F; Mon, 7 Mar 2022 01:36:15 -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 5DBA5B810CB; Mon, 7 Mar 2022 09:35:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8166BC340F3; Mon, 7 Mar 2022 09:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645715; bh=jYOCEESGGUxiDOEqLIhNHU12YnnrJU8lDTaewAq9ipg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFxlzrxlGVxwSvTLie2azdI+DRaXuPsOwJJ9pJ1Qr5jZfdsroy8gnTT7tU4qYsDum apcIGYvDsr+A1fUwOQ6+WSCtdsfTewSWOZzsbM7HsTrgoPOf1N42+quof/Xfz2H/pL 5Lqu7YrbGrLy+LjvRo87NIDmWd7aK/hpcXiQNtYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Basavaraj Natikar , Jiri Kosina , Sasha Levin Subject: [PATCH 5.15 014/262] HID: amd_sfh: Handle amd_sfh work buffer in PM ops Date: Mon, 7 Mar 2022 10:15:58 +0100 Message-Id: <20220307091702.779646657@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Basavaraj Natikar [ Upstream commit 0cf74235f4403b760a37f77271d2ca3424001ff9 ] Since in the current amd_sfh design the sensor data is periodically obtained in the form of poll data, during the suspend/resume cycle, scheduling a delayed work adds no value. So, cancel the work and restart back during the suspend/resume cycle respectively. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-h= id/amd_sfh_pcie.c index f7a4eaf3a2e07..4198a8a786c8a 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -287,6 +287,8 @@ static int __maybe_unused amd_mp2_pci_resume(struct dev= ice *dev) } } =20 + schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDL= E_LOOP)); + return 0; } =20 @@ -310,6 +312,8 @@ static int __maybe_unused amd_mp2_pci_suspend(struct de= vice *dev) } } =20 + cancel_delayed_work_sync(&cl_data->work_buffer); + return 0; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BD2C4321E for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239259AbiCGJ6c (ORCPT ); Mon, 7 Mar 2022 04:58:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239784AbiCGJkQ (ORCPT ); Mon, 7 Mar 2022 04:40:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B626374DE3; Mon, 7 Mar 2022 01: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 47EADB810D1; Mon, 7 Mar 2022 09:35:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4B5DC36AF7; Mon, 7 Mar 2022 09:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645718; bh=wtrHf0DEt28ZtCuvZ3yqQpW63WsACzFgMtatO3d91GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzjB10wNxIuNqZpYkJvfyT0E8WqAkuPrI9SKRB4TwtlDkw7z++oUPVge24sh3Se3A nztcf8szdUtAOlcT2bkJQJwDmg5+pLv5n3r/Vih+PlsB2EbYYrIgjs4wpnSwitM9LO W8QoaSrYsXiTjYCeRl0sbtLdWOmIuzpCMoVvaKnk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Basavaraj Natikar , Jiri Kosina , Sasha Levin Subject: [PATCH 5.15 015/262] HID: amd_sfh: Add functionality to clear interrupts Date: Mon, 7 Mar 2022 10:15:59 +0100 Message-Id: <20220307091702.806610384@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Basavaraj Natikar [ Upstream commit fb75a3791a8032848c987db29b622878d8fe2b1c ] Newer AMD platforms with SFH may generate interrupts on some events which are unwarranted. Until this is cleared the actual MP2 data processing maybe stalled in some cases. Add a mechanism to clear the pending interrupts (if any) during the driver initialization and sensor command operations. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 25 ++++++++++++++++++++++++- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-h= id/amd_sfh_pcie.c index 4198a8a786c8a..f1efeeaa465a2 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -88,6 +88,20 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *p= rivdata) writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0); } =20 +static void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata) +{ + if (readl(privdata->mmio + AMD_P2C_MSG(4))) { + writel(0, privdata->mmio + AMD_P2C_MSG(4)); + writel(0xf, privdata->mmio + AMD_P2C_MSG(5)); + } +} + +static void amd_sfh_clear_intr(struct amd_mp2_dev *privdata) +{ + if (privdata->mp2_ops->clear_intr) + privdata->mp2_ops->clear_intr(privdata); +} + void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_= info info) { union sfh_cmd_param cmd_param; @@ -192,6 +206,7 @@ static void amd_mp2_pci_remove(void *privdata) struct amd_mp2_dev *mp2 =3D privdata; amd_sfh_hid_client_deinit(privdata); mp2->mp2_ops->stop_all(mp2); + amd_sfh_clear_intr(mp2); } =20 static const struct amd_mp2_ops amd_sfh_ops_v2 =3D { @@ -199,6 +214,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 =3D { .stop =3D amd_stop_sensor_v2, .stop_all =3D amd_stop_all_sensor_v2, .response =3D amd_sfh_wait_response_v2, + .clear_intr =3D amd_sfh_clear_intr_v2, }; =20 static const struct amd_mp2_ops amd_sfh_ops =3D { @@ -258,8 +274,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, con= st struct pci_device_id *i mp2_select_ops(privdata); =20 rc =3D amd_sfh_hid_client_init(privdata); - if (rc) + if (rc) { + amd_sfh_clear_intr(privdata); + dev_err(&pdev->dev, "amd_sfh_hid_client_init failed\n"); return rc; + } + + amd_sfh_clear_intr(privdata); =20 return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); } @@ -288,6 +309,7 @@ static int __maybe_unused amd_mp2_pci_resume(struct dev= ice *dev) } =20 schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDL= E_LOOP)); + amd_sfh_clear_intr(mp2); =20 return 0; } @@ -313,6 +335,7 @@ static int __maybe_unused amd_mp2_pci_suspend(struct de= vice *dev) } =20 cancel_delayed_work_sync(&cl_data->work_buffer); + amd_sfh_clear_intr(mp2); =20 return 0; } diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-h= id/amd_sfh_pcie.h index 9c9119227135e..ee9818d3082e3 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -140,5 +140,6 @@ struct amd_mp2_ops { void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx); void (*stop_all)(struct amd_mp2_dev *privdata); int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); + void (*clear_intr)(struct amd_mp2_dev *privdata); }; #endif --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE33C433EF for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239028AbiCGJ5z (ORCPT ); Mon, 7 Mar 2022 04:57:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239483AbiCGJjq (ORCPT ); Mon, 7 Mar 2022 04:39:46 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341FF710C3; Mon, 7 Mar 2022 01:35: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 sin.source.kernel.org (Postfix) with ESMTPS id 9038FCE0EA3; Mon, 7 Mar 2022 09:35:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D4A0C340F3; Mon, 7 Mar 2022 09:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645720; bh=QHeZbhsKAtDR0ZnRTik/K7NwB+77pHUkW1jMEsSkNIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LS8mU4gXcS/RS71K6cd5k3O0zm03Qa5J7Tq05vs+i612eltb+DJ6w/xNJz++amgxD OYyIsLkaV+7QmvKQQG0uGAKocdVPl5755q9EyJ1mNZpFSum5oJEtc8KbjoDDwWHheq JANITCz8+PbE1Rt8jZzA6dXPfutTZvHkPeMaS7Vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Basavaraj Natikar , Jiri Kosina , Sasha Levin Subject: [PATCH 5.15 016/262] HID: amd_sfh: Add interrupt handler to process interrupts Date: Mon, 7 Mar 2022 10:16:00 +0100 Message-Id: <20220307091702.833738569@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Basavaraj Natikar [ Upstream commit 7f016b35ca7623c71b31facdde080e8ce171a697 ] On newer AMD platforms with SFH, it is observed that random interrupts get generated on the SFH hardware and until this is cleared the firmware sensor processing is stalled, resulting in no data been received to driver side. Add routines to handle these interrupts, so that firmware operations are not stalled. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 40 ++++++++++++++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + 2 files changed, 41 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-h= id/amd_sfh_pcie.c index f1efeeaa465a2..561bb27f42b10 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -102,6 +102,30 @@ static void amd_sfh_clear_intr(struct amd_mp2_dev *pri= vdata) privdata->mp2_ops->clear_intr(privdata); } =20 +static irqreturn_t amd_sfh_irq_handler(int irq, void *data) +{ + amd_sfh_clear_intr(data); + + return IRQ_HANDLED; +} + +static int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata) +{ + int rc; + + pci_intx(privdata->pdev, true); + + rc =3D devm_request_irq(&privdata->pdev->dev, privdata->pdev->irq, + amd_sfh_irq_handler, 0, DRIVER_NAME, privdata); + if (rc) { + dev_err(&privdata->pdev->dev, "failed to request irq %d err=3D%d\n", + privdata->pdev->irq, rc); + return rc; + } + + return 0; +} + void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_= info info) { union sfh_cmd_param cmd_param; @@ -206,6 +230,7 @@ static void amd_mp2_pci_remove(void *privdata) struct amd_mp2_dev *mp2 =3D privdata; amd_sfh_hid_client_deinit(privdata); mp2->mp2_ops->stop_all(mp2); + pci_intx(mp2->pdev, false); amd_sfh_clear_intr(mp2); } =20 @@ -215,6 +240,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 =3D { .stop_all =3D amd_stop_all_sensor_v2, .response =3D amd_sfh_wait_response_v2, .clear_intr =3D amd_sfh_clear_intr_v2, + .init_intr =3D amd_sfh_irq_init_v2, }; =20 static const struct amd_mp2_ops amd_sfh_ops =3D { @@ -240,6 +266,14 @@ static void mp2_select_ops(struct amd_mp2_dev *privdat= a) } } =20 +static int amd_sfh_irq_init(struct amd_mp2_dev *privdata) +{ + if (privdata->mp2_ops->init_intr) + return privdata->mp2_ops->init_intr(privdata); + + return 0; +} + static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device= _id *id) { struct amd_mp2_dev *privdata; @@ -273,6 +307,12 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, con= st struct pci_device_id *i =20 mp2_select_ops(privdata); =20 + rc =3D amd_sfh_irq_init(privdata); + if (rc) { + dev_err(&pdev->dev, "amd_sfh_irq_init failed\n"); + return rc; + } + rc =3D amd_sfh_hid_client_init(privdata); if (rc) { amd_sfh_clear_intr(privdata); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-h= id/amd_sfh_pcie.h index ee9818d3082e3..00fc083dc1239 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -141,5 +141,6 @@ struct amd_mp2_ops { void (*stop_all)(struct amd_mp2_dev *privdata); int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); void (*clear_intr)(struct amd_mp2_dev *privdata); + int (*init_intr)(struct amd_mp2_dev *privdata); }; #endif --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10711C4332F for ; Mon, 7 Mar 2022 09:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239213AbiCGJtQ (ORCPT ); Mon, 7 Mar 2022 04:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239513AbiCGJjr (ORCPT ); Mon, 7 Mar 2022 04:39: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 5D75471EE4; Mon, 7 Mar 2022 01:35: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 60850B80E70; Mon, 7 Mar 2022 09:35:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89E3FC340E9; Mon, 7 Mar 2022 09:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645724; bh=kS8D6bkfgqqgmMhggKntZnsLULvt63AbdUvRgellOS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhvs7o3dW8BRkgWjn3AgKnFQt/2L1AizQoC62Hb/8lZyCek3Rao59C3Lpdx3P7f4K yCy76/7z91VfDPpWW5AmC8qPJIQLumLgj2MXEosfPOeTZAm4RnuNsXAvSiprAcefYE zc5olZbjQUr8RiKThAmx3Y8iClY7sdxpzA1FHeuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Shyam Prasad N , Steve French , Sasha Levin Subject: [PATCH 5.15 017/262] cifs: modefromsids must add an ACE for authenticated users Date: Mon, 7 Mar 2022 10:16:01 +0100 Message-Id: <20220307091702.861572644@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ronnie Sahlberg [ Upstream commit 0c6f4ebf8835d01866eb686d47578cde80097981 ] When we create a file with modefromsids we set an ACL that has one ACE for the magic modefromsid as well as a second ACE that grants full access to all authenticated users. When later we chante the mode on the file we strip away this, and other, ACE for authenticated users in set_chmod_dacl() and then just add back/upda= te the modefromsid ACE. Thus leaving the file with a single ACE that is for the mode and no ACE to grant any user any rights to access the file. Fix this by always adding back also the modefromsid ACE so that we do not drop the rights to access the file. Signed-off-by: Ronnie Sahlberg Reviewed-by: Shyam Prasad N Signed-off-by: Steve French Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/cifs/cifsacl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 5df21d63dd04e..bf861fef2f0c3 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -949,6 +949,9 @@ static void populate_new_aces(char *nacl_base, pnntace =3D (struct cifs_ace *) (nacl_base + nsize); nsize +=3D setup_special_mode_ACE(pnntace, nmode); num_aces++; + pnntace =3D (struct cifs_ace *) (nacl_base + nsize); + nsize +=3D setup_authusers_ACE(pnntace); + num_aces++; goto set_size; } =20 @@ -1613,7 +1616,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *= path, __u64 *pnmode, nsecdesclen =3D secdesclen; if (pnmode && *pnmode !=3D NO_CHANGE_64) { /* chmod */ if (mode_from_sid) - nsecdesclen +=3D sizeof(struct cifs_ace); + nsecdesclen +=3D 2 * sizeof(struct cifs_ace); else /* cifsacl */ nsecdesclen +=3D 5 * sizeof(struct cifs_ace); } else { /* chown */ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86C13C43217 for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239546AbiCGJty (ORCPT ); Mon, 7 Mar 2022 04:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239831AbiCGJkS (ORCPT ); Mon, 7 Mar 2022 04:40:18 -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 9203B7520D; Mon, 7 Mar 2022 01:36: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 4192EB810CE; Mon, 7 Mar 2022 09:35:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87EE4C340E9; Mon, 7 Mar 2022 09:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645727; bh=124lfYyWE+LaMgjw4Q4I4/7cB+m2kmkCj43VRGmBnI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPIxhcwRgXOIQy2tC1ntpvJlscSk1+sjAjm/mii8sK/ymH7GrXrqE1c9MTLn4IFbq KQ1HlnYiz6bK8jYKHW7w+C2enuIdVE8PyP8ijK+7WXpZKJlFq4b78KJ2ZaLjOo3mdH iR+Xccz0DcqderPTsq3s92eFCMGo4g4P7jr189Fg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sherry Yang , Kees Cook , Shuah Khan , Sasha Levin Subject: [PATCH 5.15 018/262] selftests/seccomp: Fix seccomp failure by adding missing headers Date: Mon, 7 Mar 2022 10:16:02 +0100 Message-Id: <20220307091702.888893436@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sherry Yang [ Upstream commit 21bffcb76ee2fbafc7d5946cef10abc9df5cfff7 ] seccomp_bpf failed on tests 47 global.user_notification_filter_empty and 48 global.user_notification_filter_empty_threaded when it's tested on updated kernel but with old kernel headers. Because old kernel headers don't have definition of macro __NR_clone3 which is required for these two tests. Since under selftests/, we can install headers once for all tests (the default INSTALL_HDR_PATH is usr/include), fix it by adding usr/include to the list of directories to be searched. Use "-isystem" to indicate it's a system directory as the real kernel headers directories are. Signed-off-by: Sherry Yang Tested-by: Sherry Yang Reviewed-by: Kees Cook Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/seccomp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selft= ests/seccomp/Makefile index 0ebfe8b0e147f..585f7a0c10cbe 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS +=3D -Wl,-no-as-needed -Wall +CFLAGS +=3D -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/ LDFLAGS +=3D -lpthread =20 TEST_GEN_PROGS :=3D seccomp_bpf seccomp_benchmark --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92665C433FE for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239157AbiCGJ6J (ORCPT ); Mon, 7 Mar 2022 04:58:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239567AbiCGJjv (ORCPT ); Mon, 7 Mar 2022 04:39:51 -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 CB305723E2; Mon, 7 Mar 2022 01:35:58 -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 CB13C612D3; Mon, 7 Mar 2022 09:35:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D44F7C36AF3; Mon, 7 Mar 2022 09:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645730; bh=4elDJmekbpHSuGzdCGnNgGITkMRxnGVlgc0WvZ0hlY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gviEJugfmMFEZvIYJ7+1JuurM4uB1pJgbD4TBn/Ym5SRqoN9ZzWLftTT/Z0OJsPU8 us2wzJywoFL6V9jsMAOlGwgvv58GSDlpYUpI7dsOqmptNGoT8wQ6aJsrHOCE1D4UF6 1J1/7DfCe5nMWz2RC+qMuBGae7T6TnTKFGjmMyPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Quan , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 019/262] drm/amd/pm: correct UMD pstate clocks for Dimgrey Cavefish and Beige Goby Date: Mon, 7 Mar 2022 10:16:03 +0100 Message-Id: <20220307091702.916393646@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 0136f5844b006e2286f873457c3fcba8c45a3735 ] Correct the UMD pstate profiling clocks for Dimgrey Cavefish and Beige Goby. Signed-off-by: Evan Quan Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 26 +++++++++++++++---- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.h | 8 ++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/driv= ers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c index b8896882b6f01..574a9d7f7a5e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -1308,21 +1308,37 @@ static int sienna_cichlid_populate_umd_state_clk(st= ruct smu_context *smu) &dpm_context->dpm_tables.soc_table; struct smu_umd_pstate_table *pstate_table =3D &smu->pstate_table; + struct amdgpu_device *adev =3D smu->adev; =20 pstate_table->gfxclk_pstate.min =3D gfx_table->min; pstate_table->gfxclk_pstate.peak =3D gfx_table->max; - if (gfx_table->max >=3D SIENNA_CICHLID_UMD_PSTATE_PROFILING_GFXCLK) - pstate_table->gfxclk_pstate.standard =3D SIENNA_CICHLID_UMD_PSTATE_PROFI= LING_GFXCLK; =20 pstate_table->uclk_pstate.min =3D mem_table->min; pstate_table->uclk_pstate.peak =3D mem_table->max; - if (mem_table->max >=3D SIENNA_CICHLID_UMD_PSTATE_PROFILING_MEMCLK) - pstate_table->uclk_pstate.standard =3D SIENNA_CICHLID_UMD_PSTATE_PROFILI= NG_MEMCLK; =20 pstate_table->socclk_pstate.min =3D soc_table->min; pstate_table->socclk_pstate.peak =3D soc_table->max; - if (soc_table->max >=3D SIENNA_CICHLID_UMD_PSTATE_PROFILING_SOCCLK) + + switch (adev->asic_type) { + case CHIP_SIENNA_CICHLID: + case CHIP_NAVY_FLOUNDER: + pstate_table->gfxclk_pstate.standard =3D SIENNA_CICHLID_UMD_PSTATE_PROFI= LING_GFXCLK; + pstate_table->uclk_pstate.standard =3D SIENNA_CICHLID_UMD_PSTATE_PROFILI= NG_MEMCLK; pstate_table->socclk_pstate.standard =3D SIENNA_CICHLID_UMD_PSTATE_PROFI= LING_SOCCLK; + break; + case CHIP_DIMGREY_CAVEFISH: + pstate_table->gfxclk_pstate.standard =3D DIMGREY_CAVEFISH_UMD_PSTATE_PRO= FILING_GFXCLK; + pstate_table->uclk_pstate.standard =3D DIMGREY_CAVEFISH_UMD_PSTATE_PROFI= LING_MEMCLK; + pstate_table->socclk_pstate.standard =3D DIMGREY_CAVEFISH_UMD_PSTATE_PRO= FILING_SOCCLK; + break; + case CHIP_BEIGE_GOBY: + pstate_table->gfxclk_pstate.standard =3D BEIGE_GOBY_UMD_PSTATE_PROFILING= _GFXCLK; + pstate_table->uclk_pstate.standard =3D BEIGE_GOBY_UMD_PSTATE_PROFILING_M= EMCLK; + pstate_table->socclk_pstate.standard =3D BEIGE_GOBY_UMD_PSTATE_PROFILING= _SOCCLK; + break; + default: + break; + } =20 return 0; } diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.h b/driv= ers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.h index 38cd0ece24f6b..42f705c7a36f8 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.h @@ -33,6 +33,14 @@ typedef enum { #define SIENNA_CICHLID_UMD_PSTATE_PROFILING_SOCCLK 960 #define SIENNA_CICHLID_UMD_PSTATE_PROFILING_MEMCLK 1000 =20 +#define DIMGREY_CAVEFISH_UMD_PSTATE_PROFILING_GFXCLK 1950 +#define DIMGREY_CAVEFISH_UMD_PSTATE_PROFILING_SOCCLK 960 +#define DIMGREY_CAVEFISH_UMD_PSTATE_PROFILING_MEMCLK 676 + +#define BEIGE_GOBY_UMD_PSTATE_PROFILING_GFXCLK 2200 +#define BEIGE_GOBY_UMD_PSTATE_PROFILING_SOCCLK 960 +#define BEIGE_GOBY_UMD_PSTATE_PROFILING_MEMCLK 1000 + extern void sienna_cichlid_set_ppt_funcs(struct smu_context *smu); =20 #endif --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A19FCC43219 for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239184AbiCGJ6Q (ORCPT ); Mon, 7 Mar 2022 04:58:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239656AbiCGJkH (ORCPT ); Mon, 7 Mar 2022 04:40: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 8FCF1723CE; Mon, 7 Mar 2022 01:36: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 3A92D612EC; Mon, 7 Mar 2022 09:35:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E089C340F3; Mon, 7 Mar 2022 09:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645736; bh=bUoUjXun1H5cleJ/gc0H1qiSuKbmHGKHPKKSjZmqy6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+4ihXbDswtzuIrNfKKY9d+ZeQbVHV/KDu3dzbhQYOpsFlOL/zFKg6y3CprPNIao8 r9W47Zd5lKcHHnsE9/IbUuWsS9H/uto4roELW11RYlzze4ZRhKMpoAtcfrqdENguSm 2QeJe9Zg+1oghJq8BjlHQECpVGz8mcpuKvT3ADzg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Shuah Khan , Sebastian Andrzej Siewior , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 5.15 020/262] selftests/ftrace: Do not trace do_softirq because of PREEMPT_RT Date: Mon, 7 Mar 2022 10:16:04 +0100 Message-Id: <20220307091702.944597336@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Krzysztof Kozlowski [ Upstream commit 6fec1ab67f8d60704cc7de64abcfd389ab131542 ] The PREEMPT_RT patchset does not use do_softirq() function thus trying to filter for do_softirq fails for such kernel: echo do_softirq ftracetest: 81: echo: echo: I/O error Choose some other visible function for the test. The function does not have to be actually executed during the test, because it is only testing filter API interface. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Shuah Khan Acked-by: Sebastian Andrzej Siewior Reviewed-by: Steven Rostedt (Google) Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_f= ile.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.= tc index e96e279e0533a..25432b8cd5bd2 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc @@ -19,7 +19,7 @@ fail() { # mesg =20 FILTER=3Dset_ftrace_filter FUNC1=3D"schedule" -FUNC2=3D"do_softirq" +FUNC2=3D"scheduler_tick" =20 ALL_FUNCS=3D"#### all functions enabled ####" =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32887C38162 for ; Mon, 7 Mar 2022 09:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239342AbiCGJtg (ORCPT ); Mon, 7 Mar 2022 04:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239671AbiCGJkI (ORCPT ); Mon, 7 Mar 2022 04:40:08 -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 9D44474616; Mon, 7 Mar 2022 01:36:12 -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 7E10B61185; Mon, 7 Mar 2022 09:35:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 790CEC340F4; Mon, 7 Mar 2022 09:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645739; bh=3Q6HfLvnyk20c5KteC9b+hLzCTbQ2st3hb44bFNMDzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iExzYQpolPWYmeHG/Y2iqg+cTXQ1LrVDUvRXZ4ztpS/W349Ec5gvec+pmVewLPmEw ipSOVWcZJiPNfVEBN1C64VCWg49kn6V1ZriCXJkPgQCV6z1A6xYj72G5VWoLP8BiWY k4+g1Jk2h3u1S5Hs8UD9DGW+vTNqPpKE6LhONR7E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongzhi Liu , Vinod Koul , Sasha Levin Subject: [PATCH 5.15 021/262] dmaengine: shdma: Fix runtime PM imbalance on error Date: Mon, 7 Mar 2022 10:16:05 +0100 Message-Id: <20220307091702.972709358@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yongzhi Liu [ Upstream commit 455896c53d5b803733ddd84e1bf8a430644439b6 ] pm_runtime_get_() increments the runtime PM usage counter even when it returns an error code, thus a matching decrement is needed on the error handling path to keep the counter balanced. Signed-off-by: Yongzhi Liu Link: https://lore.kernel.org/r/1642311296-87020-1-git-send-email-lyz_cs@pk= u.edu.cn Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/dma/sh/shdma-base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index 7f72b3f4cd1ae..19ac95c0098f0 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c @@ -115,8 +115,10 @@ static dma_cookie_t shdma_tx_submit(struct dma_async_t= x_descriptor *tx) ret =3D pm_runtime_get(schan->dev); =20 spin_unlock_irq(&schan->chan_lock); - if (ret < 0) + if (ret < 0) { dev_err(schan->dev, "%s(): GET =3D %d\n", __func__, ret); + pm_runtime_put(schan->dev); + } =20 pm_runtime_barrier(schan->dev); =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAE8EC4332F for ; Mon, 7 Mar 2022 10:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236882AbiCGKEh (ORCPT ); Mon, 7 Mar 2022 05:04:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241143AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41: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 BD95238BF; Mon, 7 Mar 2022 01:40: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 28E8BB810B9; Mon, 7 Mar 2022 09:35:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 746CFC340F3; Mon, 7 Mar 2022 09:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645742; bh=TTpzorY7CU9ZxKx5aL88krYIEwNU8a+X9B4wT5I8UsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCs4xrsCHeWsCrgXoLl7mMDSLFrIEh7Ldhe8sBOr/prDMZri5ZvEnszKRTE2nqVy6 lmKJ7aYgZPw74b/eZC25MmVTl/W5gBct7YyAAtwtELRheO0rcubVRj1p+GJT5BYK9s 9YJTWunzTIi/kovEMYtD+eZxOST082We+MBJmIRk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wolfram Sang , Michal Simek , Sasha Levin Subject: [PATCH 5.15 022/262] i2c: cadence: allow COMPILE_TEST Date: Mon, 7 Mar 2022 10:16:06 +0100 Message-Id: <20220307091702.999931181@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wolfram Sang [ Upstream commit 0b0dcb3882c8f08bdeafa03adb4487e104d26050 ] Driver builds fine with COMPILE_TEST. Enable it for wider test coverage and easier maintenance. Signed-off-by: Wolfram Sang Acked-by: Michal Simek Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index e17790fe35a74..652b754a66db0 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -488,7 +488,7 @@ config I2C_BRCMSTB =20 config I2C_CADENCE tristate "Cadence I2C Controller" - depends on ARCH_ZYNQ || ARM64 || XTENSA + depends on ARCH_ZYNQ || ARM64 || XTENSA || COMPILE_TEST help Say yes here to select Cadence I2C Host Controller. This controller is e.g. used by Xilinx Zynq. --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16354C433EF for ; Mon, 7 Mar 2022 10:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239120AbiCGJ6F (ORCPT ); Mon, 7 Mar 2022 04:58:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239468AbiCGJjp (ORCPT ); Mon, 7 Mar 2022 04:39:45 -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 BE8FC71C9C; Mon, 7 Mar 2022 01:35: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 889EE60FF6; Mon, 7 Mar 2022 09:35:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8191FC340E9; Mon, 7 Mar 2022 09:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645746; bh=iiiU8DN3ENwStLSi/sYPdqOZyIuha6jES6Cbw9b1hww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSed6adwTY113ldscxCHOA0L8b7sctcjmKwwaTYc22nOlHxYY5LwdxFlxqlWNYfcB VnD57arwTfAr24Y1SQu2B/5WmhxWniXtEumS7gFr21TFsX4vD9KQA0DyIDW/wmFJF6 F+CV/bV745YkK5VS2mq6SDAR2lhjGG/FdsEizVWw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wolfram Sang , Oleksij Rempel , Sasha Levin Subject: [PATCH 5.15 023/262] i2c: imx: allow COMPILE_TEST Date: Mon, 7 Mar 2022 10:16:07 +0100 Message-Id: <20220307091703.027193405@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wolfram Sang [ Upstream commit 2ce4462f2724d1b3cedccea441c6d18bb360629a ] Driver builds fine with COMPILE_TEST. Enable it for wider test coverage and easier maintenance. Signed-off-by: Wolfram Sang Acked-by: Oleksij Rempel Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 652b754a66db0..f76aaf9559365 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -677,7 +677,7 @@ config I2C_IMG =20 config I2C_IMX tristate "IMX I2C interface" - depends on ARCH_MXC || ARCH_LAYERSCAPE || COLDFIRE + depends on ARCH_MXC || ARCH_LAYERSCAPE || COLDFIRE || COMPILE_TEST select I2C_SLAVE help Say Y here if you want to use the IIC bus controller on --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA0DEC4167B for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239229AbiCGJ61 (ORCPT ); Mon, 7 Mar 2022 04:58:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239744AbiCGJkN (ORCPT ); Mon, 7 Mar 2022 04:40: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 891227486F; Mon, 7 Mar 2022 01:36: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 423B8B810BD; Mon, 7 Mar 2022 09:35:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79FE2C36AE2; Mon, 7 Mar 2022 09:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645749; bh=KFjAbm0DbIrJYdiTFFJY1+Id3/hhVIdMaWYvBSCbkok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPmlqS63BG6ITv+D6jjZXpnytIR4TyZanA42vl9qwpXKzNsjQaijq/FCT9BDjmEPC CmSiNsoPBkwXpC2KsldYaGQTUAOkjCED4RUPyFk1i/AYmNltBxpzyILmhM4sM2NUK8 ZFlMII/bNOXiAswi3pTuzhABy8CsnClpAS60lSJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 024/262] i2c: qup: allow COMPILE_TEST Date: Mon, 7 Mar 2022 10:16:08 +0100 Message-Id: <20220307091703.054130062@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wolfram Sang [ Upstream commit 5de717974005fcad2502281e9f82e139ca91f4bb ] Driver builds fine with COMPILE_TEST. Enable it for wider test coverage and easier maintenance. Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index f76aaf9559365..fea403431f228 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -921,7 +921,7 @@ config I2C_QCOM_GENI =20 config I2C_QUP tristate "Qualcomm QUP based I2C controller" - depends on ARCH_QCOM + depends on ARCH_QCOM || COMPILE_TEST help If you say yes to this option, support will be included for the built-in I2C interface on the Qualcomm SoCs. --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17047C41535 for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239302AbiCGJ6o (ORCPT ); Mon, 7 Mar 2022 04:58:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240026AbiCGJkc (ORCPT ); Mon, 7 Mar 2022 04:40:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2959D7664F; Mon, 7 Mar 2022 01:36: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 65504B810D2; Mon, 7 Mar 2022 09:35:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98D2BC340F3; Mon, 7 Mar 2022 09:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645752; bh=zu9GGypCn49npQPsC4pSb6zw7vWim0NA15BG2j6ZpXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xbA7ln3/FSWzxQK9+4klQBW1UmsCzry8c+tIvQFFIsL/KXnxCJK1oVBE/XN/4B34+ kByZLrqA83rceikt1/K2AfJblyGPeJdRa0wOKJSmlOZ9keXsnOPc7Ujo1d5/inKCAx frOtj5fAF/uFJv7ZfpWDsE71I5pOlPsnYoztYVC8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 025/262] net: usb: cdc_mbim: avoid altsetting toggling for Telit FN990 Date: Mon, 7 Mar 2022 10:16:09 +0100 Message-Id: <20220307091703.081063490@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Daniele Palmas [ Upstream commit 21e8a96377e6b6debae42164605bf9dcbe5720c5 ] Add quirk CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE for Telit FN990 0x1071 composition in order to avoid bind error. Signed-off-by: Daniele Palmas Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/usb/cdc_mbim.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c index 82bb5ed94c485..c0b8b4aa78f37 100644 --- a/drivers/net/usb/cdc_mbim.c +++ b/drivers/net/usb/cdc_mbim.c @@ -659,6 +659,11 @@ static const struct usb_device_id mbim_devs[] =3D { .driver_info =3D (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle, }, =20 + /* Telit FN990 */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1071, USB_CLASS_COMM, USB_CDC_S= UBCLASS_MBIM, USB_CDC_PROTO_NONE), + .driver_info =3D (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle, + }, + /* default entry */ { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO= _NONE), .driver_info =3D (unsigned long)&cdc_mbim_info_zlp, --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 796C3C433F5 for ; Mon, 7 Mar 2022 09:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236204AbiCGJz1 (ORCPT ); Mon, 7 Mar 2022 04:55:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241155AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41:56 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D007264FE; Mon, 7 Mar 2022 01:40:58 -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 sin.source.kernel.org (Postfix) with ESMTPS id D1100CE0E89; Mon, 7 Mar 2022 09:35:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A97D4C340E9; Mon, 7 Mar 2022 09:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645755; bh=Y0ydCJdLcvb/muRQhxCjXoK2Jvm2kqf39/xsowfr3bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nazNRakXxHo8uO3Z85jayodr9WgLoEerQgl1W9F6Jn7Jx7bK6GZF/xjWpmr9nxOBd HiOHBjNC3GqlDmUy6bOUStYWVb3pYeVlv8U3YZnWGqFInuqC2l5IQZrqdTpAP7lT1t UABeM7o6LZ8Af+4xE9/48Ja1ehO7LVR7UtwELxTU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haimin Zhang , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 026/262] block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern Date: Mon, 7 Mar 2022 10:16:10 +0100 Message-Id: <20220307091703.108905285@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Haimin Zhang [ Upstream commit cc8f7fe1f5eab010191aa4570f27641876fa1267 ] Add __GFP_ZERO flag for alloc_page in function bio_copy_kern to initialize the buffer of a bio. Signed-off-by: Haimin Zhang Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220216084038.15635-1-tcs.kernel@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- block/blk-map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-map.c b/block/blk-map.c index 4526adde01564..c7f71d83eff18 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -446,7 +446,7 @@ static struct bio *bio_copy_kern(struct request_queue *= q, void *data, if (bytes > len) bytes =3D len; =20 - page =3D alloc_page(GFP_NOIO | gfp_mask); + page =3D alloc_page(GFP_NOIO | __GFP_ZERO | gfp_mask); if (!page) goto cleanup; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 435F2C3527C for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239443AbiCGJtn (ORCPT ); Mon, 7 Mar 2022 04:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239852AbiCGJkT (ORCPT ); Mon, 7 Mar 2022 04:40: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 AC23875608; Mon, 7 Mar 2022 01:36:32 -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 BEB3A612A1; Mon, 7 Mar 2022 09:36:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A631C340E9; Mon, 7 Mar 2022 09:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645760; bh=GU1qZ8dbEsL6J9ZZT5ufr9ok5ZV+KF9ztqFDg6yIkCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKEAVa6Y52Ayc4E4yjsvm+UL71ewIi5HwxouM69qvpJ9dFPZgjzc0EVkNs6xIIiJN 1JiNDTI00VlHQHBWwPSLiBm3vm66pPCjANWIkjv2rhf/xpe5+ZqCyU4Q3GJD/4KNaj qc1xdLHCaELWiskXYK8hvgrt/+y74XITRQ70Obrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Hangyu Hua Subject: [PATCH 5.15 027/262] usb: gadget: dont release an existing dev->buf Date: Mon, 7 Mar 2022 10:16:11 +0100 Message-Id: <20220307091703.136302286@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua commit 89f3594d0de58e8a57d92d497dea9fee3d4b9cda upstream. dev->buf does not need to be released if it already exists before executing dev_config. Acked-by: Alan Stern Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20211231172138.7993-2-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/usb/gadget/legacy/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -1829,8 +1829,9 @@ dev_config (struct file *fd, const char spin_lock_irq (&dev->lock); value =3D -EINVAL; if (dev->buf) { + spin_unlock_irq(&dev->lock); kfree(kbuf); - goto fail; + return value; } dev->buf =3D kbuf; From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7EA4C433FE for ; Mon, 7 Mar 2022 10:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239833AbiCGKEw (ORCPT ); Mon, 7 Mar 2022 05:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241177AbiCGJl7 (ORCPT ); Mon, 7 Mar 2022 04:41: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 2D2D1DE8A; Mon, 7 Mar 2022 01:41: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 98ABFB810C6; Mon, 7 Mar 2022 09:36:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA89FC340E9; Mon, 7 Mar 2022 09:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645763; bh=stdlv2J1UkzSjlsuBLGDoszBpm+lXxb2VHMR9D1vs1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCK73jG/EYtxYCdpOSeHC9GVTZLgqKZuL76YENH5zteWdtNGLKrypV2ZaHVyWwtXK 6zWX8ls1sxetRwcq0lbVawA7HwuvYnMNpnE3Jgxm1cjOFM8K2YomKLo9pI9R19R0Fp gQhWEyIHAsjsl/wJZ4RJREAX05iwOjUnigTSy8HQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Hangyu Hua Subject: [PATCH 5.15 028/262] usb: gadget: clear related members when goto fail Date: Mon, 7 Mar 2022 10:16:12 +0100 Message-Id: <20220307091703.163852605@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua commit 501e38a5531efbd77d5c73c0ba838a889bfc1d74 upstream. dev->config and dev->hs_config and dev->dev need to be cleaned if dev_config fails to avoid UAF. Acked-by: Alan Stern Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20211231172138.7993-3-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/usb/gadget/legacy/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -1878,8 +1878,8 @@ dev_config (struct file *fd, const char =20 value =3D usb_gadget_probe_driver(&gadgetfs_driver); if (value !=3D 0) { - kfree (dev->buf); - dev->buf =3D NULL; + spin_lock_irq(&dev->lock); + goto fail; } else { /* at this point "good" hardware has for the first time * let the USB the host see us. alternatively, if users @@ -1896,6 +1896,9 @@ dev_config (struct file *fd, const char return value; =20 fail: + dev->config =3D NULL; + dev->hs_config =3D NULL; + dev->dev =3D NULL; spin_unlock_irq (&dev->lock); pr_debug ("%s: %s fail %zd, %p\n", shortname, __func__, value, dev); kfree (dev->buf); From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F8E0C43219 for ; Mon, 7 Mar 2022 09:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239862AbiCGJuR (ORCPT ); Mon, 7 Mar 2022 04:50:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240239AbiCGJku (ORCPT ); Mon, 7 Mar 2022 04:40:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C006E565; Mon, 7 Mar 2022 01:37: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 DD759B810DE; Mon, 7 Mar 2022 09:36:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28CDDC340E9; Mon, 7 Mar 2022 09:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645766; bh=PxzTc57IQdrmDgTvi0EtjhOekh9QUtO7TK6zL07Nh+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=POhx8CJ5ps5AZMwNsD/qCvlnPPI9nMPgovkoxx3/5W9eJGcMRkY6WLRU+OGc2dpB8 ET4SHBSfT08MRy5jLPPEnGvHvbVZXvc+U9wDncnUKdIZg16JS7LptruSwqOr3FVLN5 eyg76EHI66A2DPMCIoMTCivcdf/tPSwoDvNPzmEs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Vu-Brugier , Namjae Jeon , Sasha Levin Subject: [PATCH 5.15 029/262] exfat: reuse exfat_inode_info variable instead of calling EXFAT_I() Date: Mon, 7 Mar 2022 10:16:13 +0100 Message-Id: <20220307091703.191142889@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christophe Vu-Brugier [ Upstream commit 7dee6f57d7f22a89dd214518c778aec448270d4c ] Also add a local "struct exfat_inode_info *ei" variable to exfat_truncate() to simplify the code. Signed-off-by: Christophe Vu-Brugier Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/exfat/file.c | 14 +++++++------- fs/exfat/inode.c | 9 ++++----- fs/exfat/namei.c | 6 +++--- fs/exfat/super.c | 6 +++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 6af0191b648f1..848166d6d5e9d 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -110,8 +110,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_si= ze) exfat_set_volume_dirty(sb); =20 num_clusters_new =3D EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi); - num_clusters_phys =3D - EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, sbi); + num_clusters_phys =3D EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); =20 exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags); =20 @@ -228,12 +227,13 @@ void exfat_truncate(struct inode *inode, loff_t size) { struct super_block *sb =3D inode->i_sb; struct exfat_sb_info *sbi =3D EXFAT_SB(sb); + struct exfat_inode_info *ei =3D EXFAT_I(inode); unsigned int blocksize =3D i_blocksize(inode); loff_t aligned_size; int err; =20 mutex_lock(&sbi->s_lock); - if (EXFAT_I(inode)->start_clu =3D=3D 0) { + if (ei->start_clu =3D=3D 0) { /* * Empty start_clu !=3D ~0 (not allocated) */ @@ -260,11 +260,11 @@ void exfat_truncate(struct inode *inode, loff_t size) aligned_size++; } =20 - if (EXFAT_I(inode)->i_size_ondisk > i_size_read(inode)) - EXFAT_I(inode)->i_size_ondisk =3D aligned_size; + if (ei->i_size_ondisk > i_size_read(inode)) + ei->i_size_ondisk =3D aligned_size; =20 - if (EXFAT_I(inode)->i_size_aligned > i_size_read(inode)) - EXFAT_I(inode)->i_size_aligned =3D aligned_size; + if (ei->i_size_aligned > i_size_read(inode)) + ei->i_size_aligned =3D aligned_size; mutex_unlock(&sbi->s_lock); } =20 diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 1c7aa1ea4724c..aca2e64d045b6 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -114,10 +114,9 @@ static int exfat_map_cluster(struct inode *inode, unsi= gned int clu_offset, unsigned int local_clu_offset =3D clu_offset; unsigned int num_to_be_allocated =3D 0, num_clusters =3D 0; =20 - if (EXFAT_I(inode)->i_size_ondisk > 0) + if (ei->i_size_ondisk > 0) num_clusters =3D - EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, - sbi); + EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); =20 if (clu_offset >=3D num_clusters) num_to_be_allocated =3D clu_offset - num_clusters + 1; @@ -416,10 +415,10 @@ static int exfat_write_end(struct file *file, struct = address_space *mapping, =20 err =3D generic_write_end(file, mapping, pos, len, copied, pagep, fsdata); =20 - if (EXFAT_I(inode)->i_size_aligned < i_size_read(inode)) { + if (ei->i_size_aligned < i_size_read(inode)) { exfat_fs_error(inode->i_sb, "invalid size(size(%llu) > aligned(%llu)\n", - i_size_read(inode), EXFAT_I(inode)->i_size_aligned); + i_size_read(inode), ei->i_size_aligned); return -EIO; } =20 diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 24b41103d1cc0..9d8ada781250b 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -395,9 +395,9 @@ static int exfat_find_empty_entry(struct inode *inode, =20 /* directory inode should be updated in here */ i_size_write(inode, size); - EXFAT_I(inode)->i_size_ondisk +=3D sbi->cluster_size; - EXFAT_I(inode)->i_size_aligned +=3D sbi->cluster_size; - EXFAT_I(inode)->flags =3D p_dir->flags; + ei->i_size_ondisk +=3D sbi->cluster_size; + ei->i_size_aligned +=3D sbi->cluster_size; + ei->flags =3D p_dir->flags; inode->i_blocks +=3D 1 << sbi->sect_per_clus_bits; } =20 diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 5539ffc20d164..1a2115d73a48a 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -366,9 +366,9 @@ static int exfat_read_root(struct inode *inode) =20 inode->i_blocks =3D ((i_size_read(inode) + (sbi->cluster_size - 1)) & ~(sbi->cluster_size - 1)) >> inode->i_blkbits; - EXFAT_I(inode)->i_pos =3D ((loff_t)sbi->root_dir << 32) | 0xffffffff; - EXFAT_I(inode)->i_size_aligned =3D i_size_read(inode); - EXFAT_I(inode)->i_size_ondisk =3D i_size_read(inode); + ei->i_pos =3D ((loff_t)sbi->root_dir << 32) | 0xffffffff; + ei->i_size_aligned =3D i_size_read(inode); + ei->i_size_ondisk =3D i_size_read(inode); =20 exfat_save_attr(inode, ATTR_SUBDIR); inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D ei->i_crtime =3D --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACDF0C35278 for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239463AbiCGJ7M (ORCPT ); Mon, 7 Mar 2022 04:59:12 -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 S240231AbiCGJkt (ORCPT ); Mon, 7 Mar 2022 04:40:49 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB62C6E543; Mon, 7 Mar 2022 01:37: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 sin.source.kernel.org (Postfix) with ESMTPS id 2B231CE0EAF; Mon, 7 Mar 2022 09:36:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C397C340F4; Mon, 7 Mar 2022 09:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645772; bh=nSBScjLwDnnYYus0dcXkbfFcQ4AK2NVjbpG/fiVlMl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IPdgbH5aPBkTKZobqTG49F6KNTC2CK1FLDB+R57qFnbpDta8JZf3OZp1mAyShct+r JTbaIVq4AKH2BNa2S37wncWJbmr5HxQ1W+0X6+avO4nnnKfhLBlA56QQqQ0I0NTM30 VTJWz+CiIgTEC9CrM9j2ClTkPFxIpc5ZmCu0IA/o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Wilcox , Sungjong Seo , Christophe Vu-Brugier , Namjae Jeon , Sasha Levin Subject: [PATCH 5.15 030/262] exfat: fix i_blocks for files truncated over 4 GiB Date: Mon, 7 Mar 2022 10:16:14 +0100 Message-Id: <20220307091703.217794610@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christophe Vu-Brugier [ Upstream commit 92fba084b79e6bc7b12fc118209f1922c1a2df56 ] In exfat_truncate(), the computation of inode->i_blocks is wrong if the file is larger than 4 GiB because a 32-bit variable is used as a mask. This is fixed and simplified by using round_up(). Also fix the same buggy computation in exfat_read_root() and another (correct) one in exfat_fill_inode(). The latter was fixed another way last month but can be simplified by using round_up() as well. See: commit 0c336d6e33f4 ("exfat: fix incorrect loading of i_blocks for large files") Fixes: 98d917047e8b ("exfat: add file operations") Cc: stable@vger.kernel.org # v5.7+ Suggested-by: Matthew Wilcox Reviewed-by: Sungjong Seo Signed-off-by: Christophe Vu-Brugier Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/exfat/file.c | 4 ++-- fs/exfat/inode.c | 4 ++-- fs/exfat/super.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 848166d6d5e9d..d890fd34bb2d0 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -251,8 +251,8 @@ void exfat_truncate(struct inode *inode, loff_t size) else mark_inode_dirty(inode); =20 - inode->i_blocks =3D ((i_size_read(inode) + (sbi->cluster_size - 1)) & - ~(sbi->cluster_size - 1)) >> inode->i_blkbits; + inode->i_blocks =3D round_up(i_size_read(inode), sbi->cluster_size) >> + inode->i_blkbits; write_size: aligned_size =3D i_size_read(inode); if (aligned_size & (blocksize - 1)) { diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index aca2e64d045b6..72a0ccfb616c3 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -602,8 +602,8 @@ static int exfat_fill_inode(struct inode *inode, struct= exfat_dir_entry *info) =20 exfat_save_attr(inode, info->attr); =20 - inode->i_blocks =3D ((i_size_read(inode) + (sbi->cluster_size - 1)) & - ~((loff_t)sbi->cluster_size - 1)) >> inode->i_blkbits; + inode->i_blocks =3D round_up(i_size_read(inode), sbi->cluster_size) >> + inode->i_blkbits; inode->i_mtime =3D info->mtime; inode->i_ctime =3D info->mtime; ei->i_crtime =3D info->crtime; diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 1a2115d73a48a..4b5d02b1df585 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -364,8 +364,8 @@ static int exfat_read_root(struct inode *inode) inode->i_op =3D &exfat_dir_inode_operations; inode->i_fop =3D &exfat_dir_operations; =20 - inode->i_blocks =3D ((i_size_read(inode) + (sbi->cluster_size - 1)) - & ~(sbi->cluster_size - 1)) >> inode->i_blkbits; + inode->i_blocks =3D round_up(i_size_read(inode), sbi->cluster_size) >> + inode->i_blkbits; ei->i_pos =3D ((loff_t)sbi->root_dir << 32) | 0xffffffff; ei->i_size_aligned =3D i_size_read(inode); ei->i_size_ondisk =3D i_size_read(inode); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 040E7C35294 for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239735AbiCGJuG (ORCPT ); Mon, 7 Mar 2022 04:50:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240158AbiCGJko (ORCPT ); Mon, 7 Mar 2022 04:40:44 -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 E1468674CA; Mon, 7 Mar 2022 01:37: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 251E6612C9; Mon, 7 Mar 2022 09:36:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 378A8C340F3; Mon, 7 Mar 2022 09:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645775; bh=i/dInXHbqdngtNoBmPgKldeNX01DdNJXkoStjnB2ALM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCQMHw280hUm9lWMxhF/jsW8imMrBnre0pvsxvC0RGAs+2+4lrPJw/54jk+D3i4Er L5wuCe1s6KzlyF8e8RUW12br5lg6OnsmWiBVp8HBlXWcZX4KckOJ/qaMJ5T1VPQ7jM DFrmW39AeexzAwiv4p4q9v25EqVFtRQU3DJFXMrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Andrew Morton , Masami Hiramatsu , Tom Zanussi , Pingfan Liu , Steven Rostedt , Sasha Levin Subject: [PATCH 5.15 031/262] tracing: Add test for user space strings when filtering on string pointers Date: Mon, 7 Mar 2022 10:16:15 +0100 Message-Id: <20220307091703.246410965@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Steven Rostedt [ Upstream commit 77360f9bbc7e5e2ab7a2c8b4c0244fbbfcfc6f62 ] Pingfan reported that the following causes a fault: echo "filename ~ \"cpu\"" > events/syscalls/sys_enter_openat/filter echo 1 > events/syscalls/sys_enter_at/enable The reason is that trace event filter treats the user space pointer defined by "filename" as a normal pointer to compare against the "cpu" string. The following bug happened: kvm-03-guest16 login: [72198.026181] BUG: unable to handle page fault for = address: 00007fffaae8ef60 #PF: supervisor read access in kernel mode #PF: error_code(0x0001) - permissions violation PGD 80000001008b7067 P4D 80000001008b7067 PUD 2393f1067 PMD 2393ec067 PTE = 8000000108f47867 Oops: 0001 [#1] PREEMPT SMP PTI CPU: 1 PID: 1 Comm: systemd Kdump: loaded Not tainted 5.14.0-32.el9.x86_64= #1 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:strlen+0x0/0x20 Code: 48 89 f9 74 09 48 83 c1 01 80 39 00 75 f7 31 d2 44 0f b6 04 16 44 88= 04 11 48 83 c2 01 45 84 c0 75 ee c3 0f 1f 80 00 00 00 00 <80> 3f 00 74 10 = 48 89 f8 48 83 c0 01 80 38 00 75 f7 48 29 f8 c3 31 RSP: 0018:ffffb5b900013e48 EFLAGS: 00010246 RAX: 0000000000000018 RBX: ffff8fc1c49ede00 RCX: 0000000000000000 RDX: 0000000000000020 RSI: ffff8fc1c02d601c RDI: 00007fffaae8ef60 RBP: 00007fffaae8ef60 R08: 0005034f4ddb8ea4 R09: 0000000000000000 R10: ffff8fc1c02d601c R11: 0000000000000000 R12: ffff8fc1c8a6e380 R13: 0000000000000000 R14: ffff8fc1c02d6010 R15: ffff8fc1c00453c0 FS: 00007fa86123db40(0000) GS:ffff8fc2ffd00000(0000) knlGS:00000000000000= 00 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fffaae8ef60 CR3: 0000000102880001 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: filter_pred_pchar+0x18/0x40 filter_match_preds+0x31/0x70 ftrace_syscall_enter+0x27a/0x2c0 syscall_trace_enter.constprop.0+0x1aa/0x1d0 do_syscall_64+0x16/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fa861d88664 The above happened because the kernel tried to access user space directly and triggered a "supervisor read access in kernel mode" fault. Worse yet, the memory could not even be loaded yet, and a SEGFAULT could happen as well. This could be true for kernel space accessing as well. To be even more robust, test both kernel and user space strings. If the string fails to read, then simply have the filter fail. Note, TASK_SIZE is used to determine if the pointer is user or kernel space and the appropriate strncpy_from_kernel/user_nofault() function is used to copy the memory. For some architectures, the compare to TASK_SIZE may always pick user space or kernel space. If it gets it wrong, the only thing is that the filter will fail to match. In the future, this needs to be fixed to have the event denote which should be used. But failing a filter is much better than panicing the machine, and that can be solved later. Link: https://lore.kernel.org/all/20220107044951.22080-1-kernelfans@gmail.c= om/ Link: https://lkml.kernel.org/r/20220110115532.536088fd@gandalf.local.home Cc: stable@vger.kernel.org Cc: Ingo Molnar Cc: Andrew Morton Cc: Masami Hiramatsu Cc: Tom Zanussi Reported-by: Pingfan Liu Tested-by: Pingfan Liu Fixes: 87a342f5db69d ("tracing/filters: Support filtering for char * string= s") Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- Documentation/trace/events.rst | 10 +++++ kernel/trace/trace_events_filter.c | 66 ++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index 8ddb9b09451c8..45e66a60a816a 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -230,6 +230,16 @@ Currently the caret ('^') for an error always appears = at the beginning of the filter string; the error message should still be useful though even without more accurate position info. =20 +5.2.1 Filter limitations +------------------------ + +If a filter is placed on a string pointer ``(char *)`` that does not point +to a string on the ring buffer, but instead points to kernel or user space +memory, then, for safety reasons, at most 1024 bytes of the content is +copied onto a temporary buffer to do the compare. If the copy of the memory +faults (the pointer points to memory that should not be accessed), then the +string compare will be treated as not matching. + 5.3 Clearing filters -------------------- =20 diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events= _filter.c index c9124038b140f..d3eb3c630f601 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -5,6 +5,7 @@ * Copyright (C) 2009 Tom Zanussi */ =20 +#include #include #include #include @@ -654,6 +655,47 @@ DEFINE_EQUALITY_PRED(32); DEFINE_EQUALITY_PRED(16); DEFINE_EQUALITY_PRED(8); =20 +/* user space strings temp buffer */ +#define USTRING_BUF_SIZE 1024 + +struct ustring_buffer { + char buffer[USTRING_BUF_SIZE]; +}; + +static __percpu struct ustring_buffer *ustring_per_cpu; + +static __always_inline char *test_string(char *str) +{ + struct ustring_buffer *ubuf; + char __user *ustr; + char *kstr; + + if (!ustring_per_cpu) + return NULL; + + ubuf =3D this_cpu_ptr(ustring_per_cpu); + kstr =3D ubuf->buffer; + + /* + * We use TASK_SIZE to denote user or kernel space, but this will + * not work for all architectures. If it picks the wrong one, it may + * just fail the filter (but will not bug). + * + * TODO: Have a way to properly denote which one this is for. + */ + if (likely((unsigned long)str >=3D TASK_SIZE)) { + /* For safety, do not trust the string pointer */ + if (!strncpy_from_kernel_nofault(kstr, str, USTRING_BUF_SIZE)) + return NULL; + } else { + /* user space address? */ + ustr =3D (char __user *)str; + if (!strncpy_from_user_nofault(kstr, ustr, USTRING_BUF_SIZE)) + return NULL; + } + return kstr; +} + /* Filter predicate for fixed sized arrays of characters */ static int filter_pred_string(struct filter_pred *pred, void *event) { @@ -671,10 +713,16 @@ static int filter_pred_string(struct filter_pred *pre= d, void *event) static int filter_pred_pchar(struct filter_pred *pred, void *event) { char **addr =3D (char **)(event + pred->offset); + char *str; int cmp, match; - int len =3D strlen(*addr) + 1; /* including tailing '\0' */ + int len; =20 - cmp =3D pred->regex.match(*addr, &pred->regex, len); + str =3D test_string(*addr); + if (!str) + return 0; + + len =3D strlen(str) + 1; /* including tailing '\0' */ + cmp =3D pred->regex.match(str, &pred->regex, len); =20 match =3D cmp ^ pred->not; =20 @@ -1320,8 +1368,17 @@ static int parse_pred(const char *str, void *data, =20 } else if (field->filter_type =3D=3D FILTER_DYN_STRING) pred->fn =3D filter_pred_strloc; - else + else { + + if (!ustring_per_cpu) { + /* Once allocated, keep it around for good */ + ustring_per_cpu =3D alloc_percpu(struct ustring_buffer); + if (!ustring_per_cpu) + goto err_mem; + } + pred->fn =3D filter_pred_pchar; + } /* go past the last quote */ i++; =20 @@ -1387,6 +1444,9 @@ static int parse_pred(const char *str, void *data, err_free: kfree(pred); return -EINVAL; +err_mem: + kfree(pred); + return -ENOMEM; } =20 enum { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BD53C3527D for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239416AbiCGJtl (ORCPT ); Mon, 7 Mar 2022 04:49:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239740AbiCGJkN (ORCPT ); Mon, 7 Mar 2022 04:40:13 -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 26B027486D; Mon, 7 Mar 2022 01:36: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 dfw.source.kernel.org (Postfix) with ESMTPS id 0985A612D3; Mon, 7 Mar 2022 09:36:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C311C340F4; Mon, 7 Mar 2022 09:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645778; bh=A/cVJysrcNZ88bGi6amsSTyVG/MHvtNWgsg5yu+OjgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQqMpomHdTwXV3+nnyzph2Sod4SpbYMY9grGwB7NpVQ3/vUij87LvLq7Rp6fXola1 HPqa3oTYpc+nMz9XeYPzdvIUE/wpM9iT4e9qtvCBUuO+VGfH5n3oKlgiF2UUQi5Tr6 1Ufmap/IiFNBU1GKB/GEJxux284wHs34XSVZGLf8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Mark Brown , Catalin Marinas , Sasha Levin Subject: [PATCH 5.15 032/262] arm64: Mark start_backtrace() notrace and NOKPROBE_SYMBOL Date: Mon, 7 Mar 2022 10:16:16 +0100 Message-Id: <20220307091703.274086183@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Masami Hiramatsu [ Upstream commit 1e0924bd09916fab795fc2a21ec1d148f24299fd ] Mark the start_backtrace() as notrace and NOKPROBE_SYMBOL because this function is called from ftrace and lockdep to get the caller address via return_address(). The lockdep is used in kprobes, it should also be NOKPROBE_SYMBOL. Fixes: b07f3499661c ("arm64: stacktrace: Move start_backtrace() out of the = header") Cc: # 5.13.x Signed-off-by: Masami Hiramatsu Reviewed-by: Mark Brown Link: https://lore.kernel.org/r/164301227374.1433152.12808232644267107415.s= tgit@devnote2 Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/kernel/stacktrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 8982a2b78acfc..3b8dc538a4c42 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -33,7 +33,7 @@ */ =20 =20 -void start_backtrace(struct stackframe *frame, unsigned long fp, +notrace void start_backtrace(struct stackframe *frame, unsigned long fp, unsigned long pc) { frame->fp =3D fp; @@ -55,6 +55,7 @@ void start_backtrace(struct stackframe *frame, unsigned l= ong fp, frame->prev_fp =3D 0; frame->prev_type =3D STACK_TYPE_UNKNOWN; } +NOKPROBE_SYMBOL(start_backtrace); =20 /* * Unwind from one frame record (A) to the next frame record (B). --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54294C46467 for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239471AbiCGJtq (ORCPT ); Mon, 7 Mar 2022 04:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240003AbiCGJkb (ORCPT ); Mon, 7 Mar 2022 04:40:31 -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 9D5C76E298; Mon, 7 Mar 2022 01:36:52 -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 CF1B3B810C2; Mon, 7 Mar 2022 09:36:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10875C340F3; Mon, 7 Mar 2022 09:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645781; bh=79BBtJCvrd7O12tzZuDbSN/2vkImyTVHbL+QeoTs2V8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t0Lgt0yKoww3hL5giEpKoVLlMnzqqxl/mOcmstb5ScZoxG36dmT8iMYfoBCmAz9gr 6V7TWrCeejI4FpAegJ/MP1xByGoVJ2+R/TqFSqqtng4lHkXlXzk3NoP25LL5XO3jLt CJi1K+YGWsoSltF0Dswr6upAq0uVn9o+dWpi5VIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Valentin Caron , Sasha Levin Subject: [PATCH 5.15 033/262] serial: stm32: prevent TDR register overwrite when sending x_char Date: Mon, 7 Mar 2022 10:16:17 +0100 Message-Id: <20220307091703.301925709@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Valentin Caron [ Upstream commit d3d079bde07e1b7deaeb57506dc0b86010121d17 ] When sending x_char in stm32_usart_transmit_chars(), driver can overwrite the value of TDR register by the value of x_char. If this happens, the previous value that was present in TDR register will not be sent through uart. This code checks if the previous value in TDR register is sent before writing the x_char value into register. Fixes: 48a6092fb41f ("serial: stm32-usart: Add STM32 USART Driver") Cc: stable Signed-off-by: Valentin Caron Link: https://lore.kernel.org/r/20220111164441.6178-2-valentin.caron@foss.s= t.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/tty/serial/stm32-usart.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-us= art.c index 200cd293d14d5..810a1b0b65203 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -421,10 +421,22 @@ static void stm32_usart_transmit_chars(struct uart_po= rt *port) struct stm32_port *stm32_port =3D to_stm32_port(port); const struct stm32_usart_offsets *ofs =3D &stm32_port->info->ofs; struct circ_buf *xmit =3D &port->state->xmit; + u32 isr; + int ret; =20 if (port->x_char) { if (stm32_port->tx_dma_busy) stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); + + /* Check that TDR is empty before filling FIFO */ + ret =3D + readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, + isr, + (isr & USART_SR_TXE), + 10, 1000); + if (ret) + dev_warn(port->dev, "1 character may be erased\n"); + writel_relaxed(port->x_char, port->membase + ofs->tdr); port->x_char =3D 0; port->icount.tx++; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37FAEC4167E for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239327AbiCGJ6r (ORCPT ); Mon, 7 Mar 2022 04:58:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240038AbiCGJkd (ORCPT ); Mon, 7 Mar 2022 04:40:33 -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 CF09C76653; Mon, 7 Mar 2022 01:36: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4CB5660FF6; Mon, 7 Mar 2022 09:36:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B2BBC340E9; Mon, 7 Mar 2022 09:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645784; bh=VaOmKGxQ+cGj1k1AnIumsW+U0WowPvpi5pKTa3n9e5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=be14d1Yy8CQQCkY/zXU5CF2CHQZsFfMbLMKZjtiSKP9UjyAu1KP5xUIgS1rmGvs5Q ObUyHl04fdNAs7qKcDD1VTey2p9UMu7oKK6FsVhfrsUtNknrGfnFEj5/U6qVL447V0 zjqwYaVQGaW2rJBAvxH1+HJoBTwhZV7k0yu/Tkiw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harshad Shirwadkar , Theodore Tso , Sasha Levin Subject: [PATCH 5.15 034/262] ext4: drop ineligible txn start stop APIs Date: Mon, 7 Mar 2022 10:16:18 +0100 Message-Id: <20220307091703.485324988@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Harshad Shirwadkar [ Upstream commit 7bbbe241ec7ce0def9f71464c878fdbd2b0dcf37 ] This patch drops ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() APIs. Fast commit ineligible transactions should simply call ext4_fc_mark_ineligible() after starting the trasaction. Signed-off-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20211223202140.2061101-3-harshads@google.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 6 ++-- fs/ext4/extents.c | 6 ++-- fs/ext4/fast_commit.c | 79 ++++++++----------------------------------- fs/ext4/ioctl.c | 3 +- fs/ext4/super.c | 1 - 5 files changed, 20 insertions(+), 75 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 7ebc816ae39f8..58829af68fed1 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1724,9 +1724,9 @@ struct ext4_sb_info { */ struct work_struct s_error_work; =20 - /* Ext4 fast commit stuff */ + /* Ext4 fast commit sub transaction ID */ atomic_t s_fc_subtid; - atomic_t s_fc_ineligible_updates; + /* * After commit starts, the main queue gets locked, and the further * updates get added in the staging queue. @@ -2925,8 +2925,6 @@ void __ext4_fc_track_create(handle_t *handle, struct = inode *inode, void ext4_fc_track_create(handle_t *handle, struct dentry *dentry); void ext4_fc_track_inode(handle_t *handle, struct inode *inode); void ext4_fc_mark_ineligible(struct super_block *sb, int reason); -void ext4_fc_start_ineligible(struct super_block *sb, int reason); -void ext4_fc_stop_ineligible(struct super_block *sb); void ext4_fc_start_update(struct inode *inode); void ext4_fc_stop_update(struct inode *inode); void ext4_fc_del(struct inode *inode); diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c35cb6d9b7b5f..c19813402ce98 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5340,7 +5340,7 @@ static int ext4_collapse_range(struct inode *inode, l= off_t offset, loff_t len) ret =3D PTR_ERR(handle); goto out_mmap; } - ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); =20 down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode, 0); @@ -5379,7 +5379,6 @@ static int ext4_collapse_range(struct inode *inode, l= off_t offset, loff_t len) =20 out_stop: ext4_journal_stop(handle); - ext4_fc_stop_ineligible(sb); out_mmap: filemap_invalidate_unlock(mapping); out_mutex: @@ -5481,7 +5480,7 @@ static int ext4_insert_range(struct inode *inode, lof= f_t offset, loff_t len) ret =3D PTR_ERR(handle); goto out_mmap; } - ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); =20 /* Expand file to avoid data loss if there is error while shifting */ inode->i_size +=3D len; @@ -5556,7 +5555,6 @@ static int ext4_insert_range(struct inode *inode, lof= f_t offset, loff_t len) =20 out_stop: ext4_journal_stop(handle); - ext4_fc_stop_ineligible(sb); out_mmap: filemap_invalidate_unlock(mapping); out_mutex: diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 7bcd3be07ee46..43da096d9b85e 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -65,21 +65,11 @@ * * Fast Commit Ineligibility * ------------------------- - * Not all operations are supported by fast commits today (e.g extended - * attributes). Fast commit ineligibility is marked by calling one of the - * two following functions: - * - * - ext4_fc_mark_ineligible(): This makes next fast commit operation to f= all - * back to full commit. This is useful in case of transient errors. * - * - ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() - This makes= all - * the fast commits happening between ext4_fc_start_ineligible() and - * ext4_fc_stop_ineligible() and one fast commit after the call to - * ext4_fc_stop_ineligible() to fall back to full commits. It is importa= nt to - * make one more fast commit to fall back to full commit after stop call= so - * that it guaranteed that the fast commit ineligible operation contained - * within ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() is - * followed by at least 1 full commit. + * Not all operations are supported by fast commits today (e.g extended + * attributes). Fast commit ineligibility is marked by calling + * ext4_fc_mark_ineligible(): This makes next fast commit operation to fal= l back + * to full commit. * * Atomicity of commits * -------------------- @@ -328,44 +318,6 @@ void ext4_fc_mark_ineligible(struct super_block *sb, i= nt reason) sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; } =20 -/* - * Start a fast commit ineligible update. Any commits that happen while - * such an operation is in progress fall back to full commits. - */ -void ext4_fc_start_ineligible(struct super_block *sb, int reason) -{ - struct ext4_sb_info *sbi =3D EXT4_SB(sb); - - if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || - (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) - return; - - WARN_ON(reason >=3D EXT4_FC_REASON_MAX); - sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; - atomic_inc(&sbi->s_fc_ineligible_updates); -} - -/* - * Stop a fast commit ineligible update. We set EXT4_MF_FC_INELIGIBLE flag= here - * to ensure that after stopping the ineligible update, at least one full - * commit takes place. - */ -void ext4_fc_stop_ineligible(struct super_block *sb) -{ - if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || - (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) - return; - - ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); - atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates); -} - -static inline int ext4_fc_is_ineligible(struct super_block *sb) -{ - return (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE) || - atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates)); -} - /* * Generic fast commit tracking function. If this is the first time this w= e are * called after a full commit, we initialize fast commit fields and then c= all @@ -391,7 +343,7 @@ static int ext4_fc_track_template( (sbi->s_mount_state & EXT4_FC_REPLAY)) return -EOPNOTSUPP; =20 - if (ext4_fc_is_ineligible(inode->i_sb)) + if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) return -EINVAL; =20 tid =3D handle->h_transaction->t_tid; @@ -1140,11 +1092,8 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_= tid) =20 start_time =3D ktime_get(); =20 - if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || - (ext4_fc_is_ineligible(sb))) { - reason =3D EXT4_FC_REASON_INELIGIBLE; - goto out; - } + if (!test_opt2(sb, JOURNAL_FAST_COMMIT)) + return jbd2_complete_transaction(journal, commit_tid); =20 restart_fc: ret =3D jbd2_fc_begin_commit(journal, commit_tid); @@ -1160,6 +1109,14 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_= tid) reason =3D EXT4_FC_REASON_FC_START_FAILED; goto out; } + /* + * After establishing journal barrier via jbd2_fc_begin_commit(), check + * if we are fast commit ineligible. + */ + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)) { + reason =3D EXT4_FC_REASON_INELIGIBLE; + goto out; + } =20 fc_bufs_before =3D (sbi->s_fc_bytes + bsize - 1) / bsize; ret =3D ext4_fc_perform_commit(journal); @@ -1178,12 +1135,6 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_= tid) atomic_inc(&sbi->s_fc_subtid); jbd2_fc_end_commit(journal); out: - /* Has any ineligible update happened since we started? */ - if (reason =3D=3D EXT4_FC_REASON_OK && ext4_fc_is_ineligible(sb)) { - sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; - reason =3D EXT4_FC_REASON_INELIGIBLE; - } - spin_lock(&sbi->s_fc_lock); if (reason !=3D EXT4_FC_REASON_OK && reason !=3D EXT4_FC_REASON_ALREADY_COMMITTED) { diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 220a4c8178b5e..fd70bebb14370 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -169,7 +169,7 @@ static long swap_inode_boot_loader(struct super_block *= sb, err =3D -EINVAL; goto err_out; } - ext4_fc_start_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT); =20 /* Protect extent tree against block allocations via delalloc */ ext4_double_down_write_data_sem(inode, inode_bl); @@ -252,7 +252,6 @@ static long swap_inode_boot_loader(struct super_block *= sb, =20 err_out1: ext4_journal_stop(handle); - ext4_fc_stop_ineligible(sb); ext4_double_up_write_data_sem(inode, inode_bl); =20 err_out: diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 877c5c17e61f0..538a33c3b1176 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4613,7 +4613,6 @@ static int ext4_fill_super(struct super_block *sb, vo= id *data, int silent) =20 /* Initialize fast commit stuff */ atomic_set(&sbi->s_fc_subtid, 0); - atomic_set(&sbi->s_fc_ineligible_updates, 0); INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]); INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]); INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68FB9C4707E for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239510AbiCGJtt (ORCPT ); Mon, 7 Mar 2022 04:49:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240040AbiCGJkd (ORCPT ); Mon, 7 Mar 2022 04:40:33 -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 BF16776657; Mon, 7 Mar 2022 01: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 dfw.source.kernel.org (Postfix) with ESMTPS id 8466F6116E; Mon, 7 Mar 2022 09:36:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CD37C340F3; Mon, 7 Mar 2022 09:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645788; bh=iIPEpz/CBBrLzoyfUIZWekUXSfppdsfqcZtxS9xKWy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHuSdnLkzQNLeK4xe7pdp7Q+vCMm9YbDqxirPOuL1LncywfbspXw0vLTkTQ0pvXfu b/bKuf9lnZZx40BFzoWnw5hiy8or4XFIFSEpEcyP0nuLCG9l3UMcWr6vc6NAuYzHsW 029WYvMX91Ol0Cg83Sp0Etz7uQiuugMFOCxuhbGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harshad Shirwadkar , Theodore Tso , Sasha Levin Subject: [PATCH 5.15 035/262] ext4: simplify updating of fast commit stats Date: Mon, 7 Mar 2022 10:16:19 +0100 Message-Id: <20220307091703.516234643@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Harshad Shirwadkar [ Upstream commit 0915e464cb274648e1ef1663e1356e53ff400983 ] Move fast commit stats updating logic to a separate function from ext4_fc_commit(). This significantly improves readability of ext4_fc_commit(). Signed-off-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20211223202140.2061101-4-harshads@google.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 1 - fs/ext4/fast_commit.c | 99 +++++++++++++++++++++++-------------------- fs/ext4/fast_commit.h | 27 ++++++------ 3 files changed, 68 insertions(+), 59 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 58829af68fed1..7448e24cd5459 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1746,7 +1746,6 @@ struct ext4_sb_info { spinlock_t s_fc_lock; struct buffer_head *s_fc_bh; struct ext4_fc_stats s_fc_stats; - u64 s_fc_avg_commit_time; #ifdef CONFIG_EXT4_DEBUG int s_fc_debug_max_replay; #endif diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 43da096d9b85e..f8915dff82eee 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1073,6 +1073,32 @@ static int ext4_fc_perform_commit(journal_t *journal) return ret; } =20 +static void ext4_fc_update_stats(struct super_block *sb, int status, + u64 commit_time, int nblks) +{ + struct ext4_fc_stats *stats =3D &EXT4_SB(sb)->s_fc_stats; + + jbd_debug(1, "Fast commit ended with status =3D %d", status); + if (status =3D=3D EXT4_FC_STATUS_OK) { + stats->fc_num_commits++; + stats->fc_numblks +=3D nblks; + if (likely(stats->s_fc_avg_commit_time)) + stats->s_fc_avg_commit_time =3D + (commit_time + + stats->s_fc_avg_commit_time * 3) / 4; + else + stats->s_fc_avg_commit_time =3D commit_time; + } else if (status =3D=3D EXT4_FC_STATUS_FAILED || + status =3D=3D EXT4_FC_STATUS_INELIGIBLE) { + if (status =3D=3D EXT4_FC_STATUS_FAILED) + stats->fc_failed_commits++; + stats->fc_ineligible_commits++; + } else { + stats->fc_skipped_commits++; + } + trace_ext4_fc_commit_stop(sb, nblks, status); +} + /* * The main commit entry point. Performs a fast commit for transaction * commit_tid if needed. If it's not possible to perform a fast commit @@ -1085,7 +1111,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_t= id) struct ext4_sb_info *sbi =3D EXT4_SB(sb); int nblks =3D 0, ret, bsize =3D journal->j_blocksize; int subtid =3D atomic_read(&sbi->s_fc_subtid); - int reason =3D EXT4_FC_REASON_OK, fc_bufs_before =3D 0; + int status =3D EXT4_FC_STATUS_OK, fc_bufs_before =3D 0; ktime_t start_time, commit_time; =20 trace_ext4_fc_commit_start(sb); @@ -1102,69 +1128,52 @@ int ext4_fc_commit(journal_t *journal, tid_t commit= _tid) if (atomic_read(&sbi->s_fc_subtid) <=3D subtid && commit_tid > journal->j_commit_sequence) goto restart_fc; - reason =3D EXT4_FC_REASON_ALREADY_COMMITTED; - goto out; + ext4_fc_update_stats(sb, EXT4_FC_STATUS_SKIPPED, 0, 0); + return 0; } else if (ret) { - sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; - reason =3D EXT4_FC_REASON_FC_START_FAILED; - goto out; + /* + * Commit couldn't start. Just update stats and perform a + * full commit. + */ + ext4_fc_update_stats(sb, EXT4_FC_STATUS_FAILED, 0, 0); + return jbd2_complete_transaction(journal, commit_tid); } + /* * After establishing journal barrier via jbd2_fc_begin_commit(), check * if we are fast commit ineligible. */ if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)) { - reason =3D EXT4_FC_REASON_INELIGIBLE; - goto out; + status =3D EXT4_FC_STATUS_INELIGIBLE; + goto fallback; } =20 fc_bufs_before =3D (sbi->s_fc_bytes + bsize - 1) / bsize; ret =3D ext4_fc_perform_commit(journal); if (ret < 0) { - sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; - reason =3D EXT4_FC_REASON_FC_FAILED; - goto out; + status =3D EXT4_FC_STATUS_FAILED; + goto fallback; } nblks =3D (sbi->s_fc_bytes + bsize - 1) / bsize - fc_bufs_before; ret =3D jbd2_fc_wait_bufs(journal, nblks); if (ret < 0) { - sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; - reason =3D EXT4_FC_REASON_FC_FAILED; - goto out; + status =3D EXT4_FC_STATUS_FAILED; + goto fallback; } atomic_inc(&sbi->s_fc_subtid); - jbd2_fc_end_commit(journal); -out: - spin_lock(&sbi->s_fc_lock); - if (reason !=3D EXT4_FC_REASON_OK && - reason !=3D EXT4_FC_REASON_ALREADY_COMMITTED) { - sbi->s_fc_stats.fc_ineligible_commits++; - } else { - sbi->s_fc_stats.fc_num_commits++; - sbi->s_fc_stats.fc_numblks +=3D nblks; - } - spin_unlock(&sbi->s_fc_lock); - nblks =3D (reason =3D=3D EXT4_FC_REASON_OK) ? nblks : 0; - trace_ext4_fc_commit_stop(sb, nblks, reason); - commit_time =3D ktime_to_ns(ktime_sub(ktime_get(), start_time)); + ret =3D jbd2_fc_end_commit(journal); /* - * weight the commit time higher than the average time so we don't - * react too strongly to vast changes in the commit time + * weight the commit time higher than the average time so we + * don't react too strongly to vast changes in the commit time */ - if (likely(sbi->s_fc_avg_commit_time)) - sbi->s_fc_avg_commit_time =3D (commit_time + - sbi->s_fc_avg_commit_time * 3) / 4; - else - sbi->s_fc_avg_commit_time =3D commit_time; - jbd_debug(1, - "Fast commit ended with blks =3D %d, reason =3D %d, subtid - %d", - nblks, reason, subtid); - if (reason =3D=3D EXT4_FC_REASON_FC_FAILED) - return jbd2_fc_end_commit_fallback(journal); - if (reason =3D=3D EXT4_FC_REASON_FC_START_FAILED || - reason =3D=3D EXT4_FC_REASON_INELIGIBLE) - return jbd2_complete_transaction(journal, commit_tid); - return 0; + commit_time =3D ktime_to_ns(ktime_sub(ktime_get(), start_time)); + ext4_fc_update_stats(sb, status, commit_time, nblks); + return ret; + +fallback: + ret =3D jbd2_fc_end_commit_fallback(journal); + ext4_fc_update_stats(sb, status, 0, 0); + return ret; } =20 /* @@ -2125,7 +2134,7 @@ int ext4_fc_info_show(struct seq_file *seq, void *v) "fc stats:\n%ld commits\n%ld ineligible\n%ld numblks\n%lluus avg_commit_= time\n", stats->fc_num_commits, stats->fc_ineligible_commits, stats->fc_numblks, - div_u64(sbi->s_fc_avg_commit_time, 1000)); + div_u64(stats->s_fc_avg_commit_time, 1000)); seq_puts(seq, "Ineligible reasons:\n"); for (i =3D 0; i < EXT4_FC_REASON_MAX; i++) seq_printf(seq, "\"%s\":\t%d\n", fc_ineligible_reasons[i], diff --git a/fs/ext4/fast_commit.h b/fs/ext4/fast_commit.h index 937c381b4c85e..083ad1cb705a7 100644 --- a/fs/ext4/fast_commit.h +++ b/fs/ext4/fast_commit.h @@ -71,21 +71,19 @@ struct ext4_fc_tail { }; =20 /* - * Fast commit reason codes + * Fast commit status codes + */ +enum { + EXT4_FC_STATUS_OK =3D 0, + EXT4_FC_STATUS_INELIGIBLE, + EXT4_FC_STATUS_SKIPPED, + EXT4_FC_STATUS_FAILED, +}; + +/* + * Fast commit ineligiblity reasons: */ enum { - /* - * Commit status codes: - */ - EXT4_FC_REASON_OK =3D 0, - EXT4_FC_REASON_INELIGIBLE, - EXT4_FC_REASON_ALREADY_COMMITTED, - EXT4_FC_REASON_FC_START_FAILED, - EXT4_FC_REASON_FC_FAILED, - - /* - * Fast commit ineligiblity reasons: - */ EXT4_FC_REASON_XATTR =3D 0, EXT4_FC_REASON_CROSS_RENAME, EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, @@ -117,7 +115,10 @@ struct ext4_fc_stats { unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX]; unsigned long fc_num_commits; unsigned long fc_ineligible_commits; + unsigned long fc_failed_commits; + unsigned long fc_skipped_commits; unsigned long fc_numblks; + u64 s_fc_avg_commit_time; }; =20 #define EXT4_FC_REPLAY_REALLOC_INCREMENT 4 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DAB4C3527E for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239588AbiCGJt5 (ORCPT ); Mon, 7 Mar 2022 04:49:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239842AbiCGJkT (ORCPT ); Mon, 7 Mar 2022 04:40: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 5DE2F74850; Mon, 7 Mar 2022 01:36:32 -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 22F63612EC; Mon, 7 Mar 2022 09:36:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA42C340E9; Mon, 7 Mar 2022 09:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645791; bh=QPUe18yDHt9ud+Sn6BhZ6z9MBS4enrRlDzVxFjImzZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCCDyjqsExTh5PYZQGtX0uP1Eu/M7eLydTz6PX22/UDwhfeLtZvzKuCzq0svEA5dI 6rIsedl1O2U3SAkIKM0ubDVh10Rxv5kwrtztAxI077IMMDpQvikBZNyWM/jHjRvRM7 7iDy8zvX8vKQvxi7TiXpXy3PRsxk+TjLraFFD4C4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Ritesh Harjani , Harshad Shirwadkar , Xin Yin , Theodore Tso , stable@kernel.org, Sasha Levin Subject: [PATCH 5.15 036/262] ext4: fast commit may not fallback for ineligible commit Date: Mon, 7 Mar 2022 10:16:20 +0100 Message-Id: <20220307091703.544901888@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit e85c81ba8859a4c839bcd69c5d83b32954133a5b ] For the follow scenario: 1. jbd start commit transaction n 2. task A get new handle for transaction n+1 3. task A do some ineligible actions and mark FC_INELIGIBLE 4. jbd complete transaction n and clean FC_INELIGIBLE 5. task A call fsync In this case fast commit will not fallback to full commit and transaction n+1 also not handled by jbd. Make ext4_fc_mark_ineligible() also record transaction tid for latest ineligible case, when call ext4_fc_cleanup() check current transaction tid, if small than latest ineligible tid do not clear the EXT4_MF_FC_INELIGIBLE. Reported-by: kernel test robot Reported-by: Dan Carpenter Reported-by: Ritesh Harjani Suggested-by: Harshad Shirwadkar Signed-off-by: Xin Yin Link: https://lore.kernel.org/r/20220117093655.35160-2-yinxin.x@bytedance.c= om Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 3 ++- fs/ext4/extents.c | 4 ++-- fs/ext4/fast_commit.c | 33 +++++++++++++++++++++++++-------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 4 ++-- fs/ext4/namei.c | 4 ++-- fs/ext4/super.c | 1 + fs/ext4/xattr.c | 6 +++--- fs/jbd2/commit.c | 2 +- fs/jbd2/journal.c | 2 +- include/linux/jbd2.h | 2 +- 11 files changed, 42 insertions(+), 23 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 7448e24cd5459..2b67c7d1677bb 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1746,6 +1746,7 @@ struct ext4_sb_info { spinlock_t s_fc_lock; struct buffer_head *s_fc_bh; struct ext4_fc_stats s_fc_stats; + tid_t s_fc_ineligible_tid; #ifdef CONFIG_EXT4_DEBUG int s_fc_debug_max_replay; #endif @@ -2923,7 +2924,7 @@ void __ext4_fc_track_create(handle_t *handle, struct = inode *inode, struct dentry *dentry); void ext4_fc_track_create(handle_t *handle, struct dentry *dentry); void ext4_fc_track_inode(handle_t *handle, struct inode *inode); -void ext4_fc_mark_ineligible(struct super_block *sb, int reason); +void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t = *handle); void ext4_fc_start_update(struct inode *inode); void ext4_fc_stop_update(struct inode *inode); void ext4_fc_del(struct inode *inode); diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c19813402ce98..b81c008e66755 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5340,7 +5340,7 @@ static int ext4_collapse_range(struct inode *inode, l= off_t offset, loff_t len) ret =3D PTR_ERR(handle); goto out_mmap; } - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle); =20 down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode, 0); @@ -5480,7 +5480,7 @@ static int ext4_insert_range(struct inode *inode, lof= f_t offset, loff_t len) ret =3D PTR_ERR(handle); goto out_mmap; } - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle); =20 /* Expand file to avoid data loss if there is error while shifting */ inode->i_size +=3D len; diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index f8915dff82eee..96fac6ac18f46 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -302,18 +302,32 @@ void ext4_fc_del(struct inode *inode) } =20 /* - * Mark file system as fast commit ineligible. This means that next commit - * operation would result in a full jbd2 commit. + * Mark file system as fast commit ineligible, and record latest + * ineligible transaction tid. This means until the recorded + * transaction, commit operation would result in a full jbd2 commit. */ -void ext4_fc_mark_ineligible(struct super_block *sb, int reason) +void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t = *handle) { struct ext4_sb_info *sbi =3D EXT4_SB(sb); + tid_t tid; =20 if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) return; =20 ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); + if (handle && !IS_ERR(handle)) + tid =3D handle->h_transaction->t_tid; + else { + read_lock(&sbi->s_journal->j_state_lock); + tid =3D sbi->s_journal->j_running_transaction ? + sbi->s_journal->j_running_transaction->t_tid : 0; + read_unlock(&sbi->s_journal->j_state_lock); + } + spin_lock(&sbi->s_fc_lock); + if (sbi->s_fc_ineligible_tid < tid) + sbi->s_fc_ineligible_tid =3D tid; + spin_unlock(&sbi->s_fc_lock); WARN_ON(reason >=3D EXT4_FC_REASON_MAX); sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; } @@ -389,7 +403,7 @@ static int __track_dentry_update(struct inode *inode, v= oid *arg, bool update) mutex_unlock(&ei->i_fc_lock); node =3D kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS); if (!node) { - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL); mutex_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -402,7 +416,7 @@ static int __track_dentry_update(struct inode *inode, v= oid *arg, bool update) if (!node->fcd_name.name) { kmem_cache_free(ext4_fc_dentry_cachep, node); ext4_fc_mark_ineligible(inode->i_sb, - EXT4_FC_REASON_NOMEM); + EXT4_FC_REASON_NOMEM, NULL); mutex_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -504,7 +518,7 @@ void ext4_fc_track_inode(handle_t *handle, struct inode= *inode) =20 if (ext4_should_journal_data(inode)) { ext4_fc_mark_ineligible(inode->i_sb, - EXT4_FC_REASON_INODE_JOURNAL_DATA); + EXT4_FC_REASON_INODE_JOURNAL_DATA, handle); return; } =20 @@ -1180,7 +1194,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_t= id) * Fast commit cleanup routine. This is called after every fast commit and * full commit. full is true if we are called after a full commit. */ -static void ext4_fc_cleanup(journal_t *journal, int full) +static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) { struct super_block *sb =3D journal->j_private; struct ext4_sb_info *sbi =3D EXT4_SB(sb); @@ -1228,7 +1242,10 @@ static void ext4_fc_cleanup(journal_t *journal, int = full) &sbi->s_fc_q[FC_Q_MAIN]); =20 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); - ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); + if (tid >=3D sbi->s_fc_ineligible_tid) { + sbi->s_fc_ineligible_tid =3D 0; + ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); + } =20 if (full) sbi->s_fc_bytes =3D 0; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index b6746cc86cee3..22a5140546fb6 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -337,7 +337,7 @@ void ext4_evict_inode(struct inode *inode) return; no_delete: if (!list_empty(&EXT4_I(inode)->i_fc_list)) - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL); ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ } =20 @@ -5969,7 +5969,7 @@ int ext4_change_inode_journal_flag(struct inode *inod= e, int val) return PTR_ERR(handle); =20 ext4_fc_mark_ineligible(inode->i_sb, - EXT4_FC_REASON_JOURNAL_FLAG_CHANGE); + EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, handle); err =3D ext4_mark_inode_dirty(handle, inode); ext4_handle_sync(handle); ext4_journal_stop(handle); diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index fd70bebb14370..f61b59045c6d3 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -169,7 +169,7 @@ static long swap_inode_boot_loader(struct super_block *= sb, err =3D -EINVAL; goto err_out; } - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT, handle); =20 /* Protect extent tree against block allocations via delalloc */ ext4_double_down_write_data_sem(inode, inode_bl); @@ -1075,7 +1075,7 @@ static long __ext4_ioctl(struct file *filp, unsigned = int cmd, unsigned long arg) =20 err =3D ext4_resize_fs(sb, n_blocks_count); if (EXT4_SB(sb)->s_journal) { - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_RESIZE); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_RESIZE, NULL); jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); err2 =3D jbd2_journal_flush(EXT4_SB(sb)->s_journal, 0); jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index da7698341d7d3..192ea90e757cc 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3889,7 +3889,7 @@ static int ext4_rename(struct user_namespace *mnt_use= rns, struct inode *old_dir, * dirents in directories. */ ext4_fc_mark_ineligible(old.inode->i_sb, - EXT4_FC_REASON_RENAME_DIR); + EXT4_FC_REASON_RENAME_DIR, handle); } else { if (new.inode) ext4_fc_track_unlink(handle, new.dentry); @@ -4049,7 +4049,7 @@ static int ext4_cross_rename(struct inode *old_dir, s= truct dentry *old_dentry, if (unlikely(retval)) goto end_rename; ext4_fc_mark_ineligible(new.inode->i_sb, - EXT4_FC_REASON_CROSS_RENAME); + EXT4_FC_REASON_CROSS_RENAME, handle); if (old.dir_bh) { retval =3D ext4_rename_dir_finish(handle, &old, new.dir->i_ino); if (retval) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 538a33c3b1176..eb5d55cf277ce 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4620,6 +4620,7 @@ static int ext4_fill_super(struct super_block *sb, vo= id *data, int silent) sbi->s_fc_bytes =3D 0; ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); + sbi->s_fc_ineligible_tid =3D 0; spin_lock_init(&sbi->s_fc_lock); memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats)); sbi->s_fc_replay_state.fc_regions =3D NULL; diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 1e0fc1ed845bf..0423253490986 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2408,7 +2408,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode = *inode, int name_index, if (IS_SYNC(inode)) ext4_handle_sync(handle); } - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, handle); =20 cleanup: brelse(is.iloc.bh); @@ -2486,7 +2486,7 @@ ext4_xattr_set(struct inode *inode, int name_index, c= onst char *name, if (error =3D=3D 0) error =3D error2; } - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, NULL); =20 return error; } @@ -2920,7 +2920,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct = inode *inode, error); goto cleanup; } - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, handle); } error =3D 0; cleanup: diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 3cc4ab2ba7f4f..d188fa913a075 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -1170,7 +1170,7 @@ void jbd2_journal_commit_transaction(journal_t *journ= al) if (journal->j_commit_callback) journal->j_commit_callback(journal, commit_transaction); if (journal->j_fc_cleanup_callback) - journal->j_fc_cleanup_callback(journal, 1); + journal->j_fc_cleanup_callback(journal, 1, commit_transaction->t_tid); =20 trace_jbd2_end_commit(journal, commit_transaction); jbd_debug(1, "JBD2: commit %d complete, head %d\n", diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index bd9ac98916043..1f8493ef181d6 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -769,7 +769,7 @@ EXPORT_SYMBOL(jbd2_fc_begin_commit); static int __jbd2_fc_end_commit(journal_t *journal, tid_t tid, bool fallba= ck) { if (journal->j_fc_cleanup_callback) - journal->j_fc_cleanup_callback(journal, 0); + journal->j_fc_cleanup_callback(journal, 0, tid); write_lock(&journal->j_state_lock); journal->j_flags &=3D ~JBD2_FAST_COMMIT_ONGOING; if (fallback) diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index fd933c45281af..d63b8106796e2 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1295,7 +1295,7 @@ struct journal_s * Clean-up after fast commit or full commit. JBD2 calls this function * after every commit operation. */ - void (*j_fc_cleanup_callback)(struct journal_s *journal, int); + void (*j_fc_cleanup_callback)(struct journal_s *journal, int full, tid_t = tid); =20 /** * @j_fc_replay_callback: --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6D5BC4321E for ; Mon, 7 Mar 2022 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239640AbiCGJt7 (ORCPT ); Mon, 7 Mar 2022 04:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240111AbiCGJkh (ORCPT ); Mon, 7 Mar 2022 04:40:37 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0364C6E358; Mon, 7 Mar 2022 01: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 sin.source.kernel.org (Postfix) with ESMTPS id 98062CE0EA3; Mon, 7 Mar 2022 09:36:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D77CC340E9; Mon, 7 Mar 2022 09:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645795; bh=5wMO910uLKj1RUUohNLFQ35FHteA0OxBm4Nv9BZy/DQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mt3LKcuVLakWGC/MQLdkMifBEr7AlG5LI04jscsohM2nFLOJ8O7jYMGfvg05bT63h SdTRahqbQ29M1tHKNKVJHQ4x1Z7uiu96cB27WhD7n4Yps6igfV6uq8NtyOD+T28pIO bEOJETXzurmQcU6ESAbP5uaZ7XnRmT+H2eJs1DP8= 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, Sasha Levin Subject: [PATCH 5.15 037/262] ext4: fast commit may miss file actions Date: Mon, 7 Mar 2022 10:16:21 +0100 Message-Id: <20220307091703.573340245@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit bdc8a53a6f2f0b1cb5f991440f2100732299eb93 ] in the follow scenario: 1. jbd start transaction n 2. task A get new handle for transaction n+1 3. task A do some actions and add inode to FC_Q_MAIN fc_q 4. jbd complete transaction n and clear FC_Q_MAIN fc_q 5. task A call fsync Fast commit will lost the file actions during a full commit. we should also add updates to staging queue during a full commit. and in ext4_fc_cleanup(), when reset a inode's fc track range, check it's i_sync_tid, if it bigger than current transaction tid, do not rest it, or we will lost the track range. And EXT4_MF_FC_COMMITTING is not needed anymore, so drop it. Signed-off-by: Xin Yin Link: https://lore.kernel.org/r/20220117093655.35160-3-yinxin.x@bytedance.c= om Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 5 +---- fs/ext4/fast_commit.c | 11 ++++++----- fs/ext4/super.c | 1 - 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 2b67c7d1677bb..db981619f6c8e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1792,10 +1792,7 @@ static inline int ext4_valid_inum(struct super_block= *sb, unsigned long ino) enum { EXT4_MF_MNTDIR_SAMPLED, EXT4_MF_FS_ABORTED, /* Fatal error detected */ - EXT4_MF_FC_INELIGIBLE, /* Fast commit ineligible */ - EXT4_MF_FC_COMMITTING /* File system underoing a fast - * commit. - */ + EXT4_MF_FC_INELIGIBLE /* Fast commit ineligible */ }; =20 static inline void ext4_set_mount_flag(struct super_block *sb, int bit) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 96fac6ac18f46..285c91b0166c0 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -377,7 +377,8 @@ static int ext4_fc_track_template( spin_lock(&sbi->s_fc_lock); if (list_empty(&EXT4_I(inode)->i_fc_list)) list_add_tail(&EXT4_I(inode)->i_fc_list, - (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) ? + (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || + sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ? &sbi->s_fc_q[FC_Q_STAGING] : &sbi->s_fc_q[FC_Q_MAIN]); spin_unlock(&sbi->s_fc_lock); @@ -430,7 +431,8 @@ static int __track_dentry_update(struct inode *inode, v= oid *arg, bool update) node->fcd_name.len =3D dentry->d_name.len; =20 spin_lock(&sbi->s_fc_lock); - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) + if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || + sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) list_add_tail(&node->fcd_list, &sbi->s_fc_dentry_q[FC_Q_STAGING]); else @@ -894,7 +896,6 @@ static int ext4_fc_submit_inode_data_all(journal_t *jou= rnal) int ret =3D 0; =20 spin_lock(&sbi->s_fc_lock); - ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING); list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING); while (atomic_read(&ei->i_fc_updates)) { @@ -1212,7 +1213,8 @@ static void ext4_fc_cleanup(journal_t *journal, int f= ull, tid_t tid) list_del_init(&iter->i_fc_list); ext4_clear_inode_state(&iter->vfs_inode, EXT4_STATE_FC_COMMITTING); - ext4_fc_reset_inode(&iter->vfs_inode); + if (iter->i_sync_tid <=3D tid) + ext4_fc_reset_inode(&iter->vfs_inode); /* Make sure EXT4_STATE_FC_COMMITTING bit is clear */ smp_mb(); #if (BITS_PER_LONG < 64) @@ -1241,7 +1243,6 @@ static void ext4_fc_cleanup(journal_t *journal, int f= ull, tid_t tid) list_splice_init(&sbi->s_fc_q[FC_Q_STAGING], &sbi->s_fc_q[FC_Q_MAIN]); =20 - ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); if (tid >=3D sbi->s_fc_ineligible_tid) { sbi->s_fc_ineligible_tid =3D 0; ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index eb5d55cf277ce..fd4d34deb9fc6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4619,7 +4619,6 @@ static int ext4_fill_super(struct super_block *sb, vo= id *data, int silent) INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]); sbi->s_fc_bytes =3D 0; ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); - ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); sbi->s_fc_ineligible_tid =3D 0; spin_lock_init(&sbi->s_fc_lock); memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats)); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A3BCC433F5 for ; Mon, 7 Mar 2022 10:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240219AbiCGKGG (ORCPT ); Mon, 7 Mar 2022 05:06:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238364AbiCGJpB (ORCPT ); Mon, 7 Mar 2022 04:45:01 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E219265483; Mon, 7 Mar 2022 01:41: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 sin.source.kernel.org (Postfix) with ESMTPS id 05C2CCE0EA6; Mon, 7 Mar 2022 09:36:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1127C340E9; Mon, 7 Mar 2022 09:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645798; bh=M4VKDxamwSQeNGGlXuPwb4g02Kpws/cOYKRyL0pwvRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t8sRntp/kr8TtsDHdDPWlVvgpenw3AJ6CQYuUk6ZcJ5QEFXtiqYKBUQPMqMEJdKFk SZyyl93ttJGsntpisTvufp9mrtZkCJGk9afCKTrk2zIpsZ+2HmPvYALFzG9dMp7GMd 6ppQd+jM1FCGgrufW5O7KmJyCPAcZWaNK+ERiIH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+af7a719bc92395ee41b3@syzkaller.appspotmail.com, Tadeusz Struk , "Peter Zijlstra (Intel)" , Dietmar Eggemann , Sasha Levin Subject: [PATCH 5.15 038/262] sched/fair: Fix fault in reweight_entity Date: Mon, 7 Mar 2022 10:16:22 +0100 Message-Id: <20220307091703.600785457@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Tadeusz Struk [ Upstream commit 13765de8148f71fa795e0a6607de37c49ea5915a ] Syzbot found a GPF in reweight_entity. This has been bisected to commit 4ef0c5c6b5ba ("kernel/sched: Fix sched_fork() access an invalid sched_task_group") There=C2=A0is a race between sched_post_fork() and setpriority(PRIO_PGRP) within a thread group that causes a null-ptr-deref=C2=A0in reweight_entity() in CFS. The scenario is that the main process spawns number of new threads, which then call setpriority(PRIO_PGRP, 0, -20), wait, and exit. For each of the new threads the copy_process() gets invoked, which adds the new task_struct and calls sched_post_fork() for it. In the above scenario there is a possibility that setpriority(PRIO_PGRP) and set_one_prio() will be called for a thread in the group that is just being created by copy_process(), and for which the sched_post_fork() has not been executed yet. This will trigger a null pointer dereference in reweight_entity(),=C2=A0as it will try to access the run queue pointer, which hasn't been set. Before the mentioned change the cfs_rq pointer for the task has been set in sched_fork(), which is called much earlier in copy_process(), before the new task is added to the thread_group. Now it is done in the sched_post_fork(), which is called after that. To fix the issue the remove the update_load param from the update_load param() function and call reweight_task() only if the task flag doesn't have the TASK_NEW flag set. Fixes: 4ef0c5c6b5ba ("kernel/sched: Fix sched_fork() access an invalid sche= d_task_group") Reported-by: syzbot+af7a719bc92395ee41b3@syzkaller.appspotmail.com Signed-off-by: Tadeusz Struk Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dietmar Eggemann Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20220203161846.1160750-1-tadeusz.struk@lina= ro.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/sched/core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c2dec6ce98091..57e5c79142964 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1199,8 +1199,9 @@ int tg_nop(struct task_group *tg, void *data) } #endif =20 -static void set_load_weight(struct task_struct *p, bool update_load) +static void set_load_weight(struct task_struct *p) { + bool update_load =3D !(READ_ONCE(p->__state) & TASK_NEW); int prio =3D p->static_prio - MAX_RT_PRIO; struct load_weight *load =3D &p->se.load; =20 @@ -4358,7 +4359,7 @@ int sched_fork(unsigned long clone_flags, struct task= _struct *p) p->static_prio =3D NICE_TO_PRIO(0); =20 p->prio =3D p->normal_prio =3D p->static_prio; - set_load_weight(p, false); + set_load_weight(p); =20 /* * We don't need the reset flag anymore after the fork. It has @@ -6902,7 +6903,7 @@ void set_user_nice(struct task_struct *p, long nice) put_prev_task(rq, p); =20 p->static_prio =3D NICE_TO_PRIO(nice); - set_load_weight(p, true); + set_load_weight(p); old_prio =3D p->prio; p->prio =3D effective_prio(p); =20 @@ -7193,7 +7194,7 @@ static void __setscheduler_params(struct task_struct = *p, */ p->rt_priority =3D attr->sched_priority; p->normal_prio =3D normal_prio(p); - set_load_weight(p, true); + set_load_weight(p); } =20 /* @@ -9431,7 +9432,7 @@ void __init sched_init(void) #endif } =20 - set_load_weight(&init_task, false); + set_load_weight(&init_task); =20 /* * The boot idle thread does lazy MMU switching as well: --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC88FC4167D for ; Mon, 7 Mar 2022 10:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239278AbiCGJ6i (ORCPT ); Mon, 7 Mar 2022 04:58:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239930AbiCGJkY (ORCPT ); Mon, 7 Mar 2022 04:40:24 -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 CC7EC75C18; Mon, 7 Mar 2022 01:36: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 ams.source.kernel.org (Postfix) with ESMTPS id 6DA1CB810BD; Mon, 7 Mar 2022 09:36:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC41EC340F3; Mon, 7 Mar 2022 09:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645801; bh=4nV0Rt1hVSFqqgPnAUQQsOzvV1i7xstj0KiqKOkxUws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnoGJU+4hIiQTErbqokR29qtOlO58B23QLZFnOTTZHtK7UqALkLRqv/EH9f88KZPZ 2y+fOVkMkmoX27M1oQSvSHVRUdOo9Qb4p/vy0GZWQtR33pwFUAct58JyqPd+AH9mw2 4Uctk1dVjJ5DOp4C248zfTgjugv4yBGQM4ESkAD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Damien Le Moal , Sasha Levin Subject: [PATCH 5.15 039/262] ata: pata_hpt37x: fix PCI clock detection Date: Mon, 7 Mar 2022 10:16:23 +0100 Message-Id: <20220307091703.628670051@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 5f6b0f2d037c8864f20ff15311c695f65eb09db5 ] The f_CNT register (at the PCI config. address 0x78) is 16-bit, not 8-bit! The bug was there from the very start... :-( Signed-off-by: Sergey Shtylyov Fixes: 669a5db411d8 ("[libata] Add a bunch of PATA drivers.") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/ata/pata_hpt37x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index ae8375e9d2681..9d371859e81ed 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -964,14 +964,14 @@ static int hpt37x_init_one(struct pci_dev *dev, const= struct pci_device_id *id) =20 if ((freq >> 12) !=3D 0xABCDE) { int i; - u8 sr; + u16 sr; u32 total =3D 0; =20 pr_warn("BIOS has not set timing clocks\n"); =20 /* This is the process the HPT371 BIOS is reported to use */ for (i =3D 0; i < 128; i++) { - pci_read_config_byte(dev, 0x78, &sr); + pci_read_config_word(dev, 0x78, &sr); total +=3D sr & 0x1FF; udelay(15); } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1E8DC4167E for ; Mon, 7 Mar 2022 09:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238658AbiCGJxA (ORCPT ); Mon, 7 Mar 2022 04:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241032AbiCGJlq (ORCPT ); Mon, 7 Mar 2022 04:41:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 503B26D4EF; Mon, 7 Mar 2022 01:39: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 DD3E261219; Mon, 7 Mar 2022 09:39:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC75C340E9; Mon, 7 Mar 2022 09:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645963; bh=itkFADjjYEkMvDwj674Xo1U+p/cXui1ckfMneVVXOnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ELDa++y8eHgC1GFJ3ZZwyIN8vjgVx00xKFvZJ5KbNCA0/PIZGM02sduwObOi/qonC R0ig2hdRClA5Koh19t+YNUP859KvHlljOeRohIEJ5mN6WOqlN7cz8QDb3l3wDX6pP9 I8PVBFgyFjiFpqUBF0OxPEAi8hQuL15XkRc+77z8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , =?UTF-8?q?Christian=20K=C3=B6nig?= , Qiang Yu , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 040/262] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Date: Mon, 7 Mar 2022 10:16:24 +0100 Message-Id: <20220307091703.656240750@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Qiang Yu [ Upstream commit c1a66c3bc425ff93774fb2f6eefa67b83170dd7e ] Workstation application ANSA/META v21.1.4 get this error dmesg when running CI test suite provided by ANSA/META: [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't update BO_VA (-16) This is caused by: 1. create a 256MB buffer in invisible VRAM 2. CPU map the buffer and access it causes vm_fault and try to move it to visible VRAM 3. force visible VRAM space and traverse all VRAM bos to check if evicting this bo is valuable 4. when checking a VM bo (in invisible VRAM), amdgpu_vm_evictable() will set amdgpu_vm->evicting, but latter due to not in visible VRAM, won't really evict it so not add it to amdgpu_vm->evicted 5. before next CS to clear the amdgpu_vm->evicting, user VM ops ioctl will pass amdgpu_vm_ready() (check amdgpu_vm->evicted) but fail in amdgpu_vm_bo_update_mapping() (check amdgpu_vm->evicting) and get this error log This error won't affect functionality as next CS will finish the waiting VM ops. But we'd better clear the error log by checking the amdgpu_vm->evicting flag in amdgpu_vm_ready() to stop calling amdgpu_vm_bo_update_mapping() later. Another reason is amdgpu_vm->evicted list holds all BOs (both user buffer and page table), but only page table BOs' eviction prevent VM ops. amdgpu_vm->evicting flag is set only for page table BOs, so we should use evicting flag instead of evicted list in amdgpu_vm_ready(). The side effect of this change is: previously blocked VM op (user buffer in "evicted" list but no page table in it) gets done immediately. v2: update commit comments. Acked-by: Paul Menzel Reviewed-by: Christian K=C3=B6nig Signed-off-by: Qiang Yu Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/a= mdgpu/amdgpu_vm.c index 6b15cad78de9d..a33cb2f4d7444 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -768,11 +768,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *a= dev, struct amdgpu_vm *vm, * Check if all VM PDs/PTs are ready for updates * * Returns: - * True if eviction list is empty. + * True if VM is not evicting. */ bool amdgpu_vm_ready(struct amdgpu_vm *vm) { - return list_empty(&vm->evicted); + bool ret; + + amdgpu_vm_eviction_lock(vm); + ret =3D !vm->evicting; + amdgpu_vm_eviction_unlock(vm); + return ret; } =20 /** --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E2A4C433EF for ; Mon, 7 Mar 2022 10:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239996AbiCGKGl (ORCPT ); Mon, 7 Mar 2022 05:06:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238446AbiCGJqh (ORCPT ); Mon, 7 Mar 2022 04:46:37 -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 54D40694A6; Mon, 7 Mar 2022 01:42: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 7A008B80E70; Mon, 7 Mar 2022 09:37:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF8B3C340E9; Mon, 7 Mar 2022 09:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645827; bh=H62Pa9TB5DcGbjeRngxOfMiTImh+GHsLdwD6eP3n3iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjLeFdemughK/SezbBlzaaaXHpkQxA3wzW+fzX2o82n2aUT2ck1bcumBHHIPYO7m7 xZNMHUtBJf+/Gi5YdkR2hSSvejEd75G0D65G5phJllsPhCLpAEdVOZRUfXZwdiNtq3 OOmCN6cGDY76S7RqX/PiR/4dWxxugkIkemYTkf+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , Steven Rostedt , Sasha Levin Subject: [PATCH 5.15 041/262] tracing: Add ustring operation to filtering string pointers Date: Mon, 7 Mar 2022 10:16:25 +0100 Message-Id: <20220307091703.683855708@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Steven Rostedt [ Upstream commit f37c3bbc635994eda203a6da4ba0f9d05165a8d6 ] Since referencing user space pointers is special, if the user wants to filter on a field that is a pointer to user space, then they need to specify it. Add a ".ustring" attribute to the field name for filters to state that the field is pointing to user space such that the kernel can take the appropriate action to read that pointer. Link: https://lore.kernel.org/all/yt9d8rvmt2jq.fsf@linux.ibm.com/ Fixes: 77360f9bbc7e ("tracing: Add test for user space strings when filteri= ng on string pointers") Tested-by: Sven Schnelle Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- Documentation/trace/events.rst | 9 ++++ kernel/trace/trace_events_filter.c | 81 +++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 24 deletions(-) diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index 45e66a60a816a..c47f381d0c002 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -198,6 +198,15 @@ The glob (~) accepts a wild card character (\*,?) and = character classes prev_comm ~ "*sh*" prev_comm ~ "ba*sh" =20 +If the field is a pointer that points into user space (for example +"filename" from sys_enter_openat), then you have to append ".ustring" to t= he +field name:: + + filename.ustring ~ "password" + +As the kernel will have to know how to retrieve the memory that the pointer +is at from user space. + 5.2 Setting filters ------------------- =20 diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events= _filter.c index d3eb3c630f601..06d6318ee5377 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -665,6 +665,23 @@ struct ustring_buffer { static __percpu struct ustring_buffer *ustring_per_cpu; =20 static __always_inline char *test_string(char *str) +{ + struct ustring_buffer *ubuf; + char *kstr; + + if (!ustring_per_cpu) + return NULL; + + ubuf =3D this_cpu_ptr(ustring_per_cpu); + kstr =3D ubuf->buffer; + + /* For safety, do not trust the string pointer */ + if (!strncpy_from_kernel_nofault(kstr, str, USTRING_BUF_SIZE)) + return NULL; + return kstr; +} + +static __always_inline char *test_ustring(char *str) { struct ustring_buffer *ubuf; char __user *ustr; @@ -676,23 +693,11 @@ static __always_inline char *test_string(char *str) ubuf =3D this_cpu_ptr(ustring_per_cpu); kstr =3D ubuf->buffer; =20 - /* - * We use TASK_SIZE to denote user or kernel space, but this will - * not work for all architectures. If it picks the wrong one, it may - * just fail the filter (but will not bug). - * - * TODO: Have a way to properly denote which one this is for. - */ - if (likely((unsigned long)str >=3D TASK_SIZE)) { - /* For safety, do not trust the string pointer */ - if (!strncpy_from_kernel_nofault(kstr, str, USTRING_BUF_SIZE)) - return NULL; - } else { - /* user space address? */ - ustr =3D (char __user *)str; - if (!strncpy_from_user_nofault(kstr, ustr, USTRING_BUF_SIZE)) - return NULL; - } + /* user space address? */ + ustr =3D (char __user *)str; + if (!strncpy_from_user_nofault(kstr, ustr, USTRING_BUF_SIZE)) + return NULL; + return kstr; } =20 @@ -709,24 +714,42 @@ static int filter_pred_string(struct filter_pred *pre= d, void *event) return match; } =20 +static __always_inline int filter_pchar(struct filter_pred *pred, char *st= r) +{ + int cmp, match; + int len; + + len =3D strlen(str) + 1; /* including tailing '\0' */ + cmp =3D pred->regex.match(str, &pred->regex, len); + + match =3D cmp ^ pred->not; + + return match; +} /* Filter predicate for char * pointers */ static int filter_pred_pchar(struct filter_pred *pred, void *event) { char **addr =3D (char **)(event + pred->offset); char *str; - int cmp, match; - int len; =20 str =3D test_string(*addr); if (!str) return 0; =20 - len =3D strlen(str) + 1; /* including tailing '\0' */ - cmp =3D pred->regex.match(str, &pred->regex, len); + return filter_pchar(pred, str); +} =20 - match =3D cmp ^ pred->not; +/* Filter predicate for char * pointers in user space*/ +static int filter_pred_pchar_user(struct filter_pred *pred, void *event) +{ + char **addr =3D (char **)(event + pred->offset); + char *str; =20 - return match; + str =3D test_ustring(*addr); + if (!str) + return 0; + + return filter_pchar(pred, str); } =20 /* @@ -1206,6 +1229,7 @@ static int parse_pred(const char *str, void *data, struct filter_pred *pred =3D NULL; char num_buf[24]; /* Big enough to hold an address */ char *field_name; + bool ustring =3D false; char q; u64 val; int len; @@ -1240,6 +1264,12 @@ static int parse_pred(const char *str, void *data, return -EINVAL; } =20 + /* See if the field is a user space string */ + if ((len =3D str_has_prefix(str + i, ".ustring"))) { + ustring =3D true; + i +=3D len; + } + while (isspace(str[i])) i++; =20 @@ -1377,7 +1407,10 @@ static int parse_pred(const char *str, void *data, goto err_mem; } =20 - pred->fn =3D filter_pred_pchar; + if (ustring) + pred->fn =3D filter_pred_pchar_user; + else + pred->fn =3D filter_pred_pchar; } /* go past the last quote */ i++; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54DEAC4167B for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240332AbiCGJu5 (ORCPT ); Mon, 7 Mar 2022 04:50:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240591AbiCGJlK (ORCPT ); Mon, 7 Mar 2022 04:41:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E4F1AD8D; Mon, 7 Mar 2022 01:37: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 3D51E612D7; Mon, 7 Mar 2022 09:37:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46CB9C340F3; Mon, 7 Mar 2022 09:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645861; bh=sYbuwiC4MIOoYGRtKxJRfiWqXcomYzDpMfPm5hwNmro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0LBOsr0LIeCjOxhS6H599R39P0aRU1NdE735e646h0tcMLyYI5jjW5vq1nFV2gVi8 GipxyJt9DiPW7MZZ1fruhzONBGpa6txogXoQOZW4qHEFIc+aRdV7vVl4MBNsaEsLWD lVbqD+5IGnynOacJo8Lql1zNytfNtSjvoZnPPuQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Taehee Yoo , Cong Wang , David Ahern , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 042/262] ipv6: fix skb drops in igmp6_event_query() and igmp6_event_report() Date: Mon, 7 Mar 2022 10:16:26 +0100 Message-Id: <20220307091703.710711878@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit 2d3916f3189172d5c69d33065c3c21119fe539fc ] While investigating on why a synchronize_net() has been added recently in ipv6_mc_down(), I found that igmp6_event_query() and igmp6_event_report() might drop skbs in some cases. Discussion about removing synchronize_net() from ipv6_mc_down() will happen in a different thread. Fixes: f185de28d9ae ("mld: add new workqueues for process mld events") Signed-off-by: Eric Dumazet Cc: Taehee Yoo Cc: Cong Wang Cc: David Ahern Link: https://lore.kernel.org/r/20220303173728.937869-1-eric.dumazet@gmail.= com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- include/net/ndisc.h | 4 ++-- net/ipv6/mcast.c | 32 ++++++++++++-------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/include/net/ndisc.h b/include/net/ndisc.h index 38e4094960cee..e97ef508664f4 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h @@ -487,9 +487,9 @@ int igmp6_late_init(void); void igmp6_cleanup(void); void igmp6_late_cleanup(void); =20 -int igmp6_event_query(struct sk_buff *skb); +void igmp6_event_query(struct sk_buff *skb); =20 -int igmp6_event_report(struct sk_buff *skb); +void igmp6_event_report(struct sk_buff *skb); =20 =20 #ifdef CONFIG_SYSCTL diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index a8861db52c187..909f937befd71 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -1371,27 +1371,23 @@ static void mld_process_v2(struct inet6_dev *idev, = struct mld2_query *mld, } =20 /* called with rcu_read_lock() */ -int igmp6_event_query(struct sk_buff *skb) +void igmp6_event_query(struct sk_buff *skb) { struct inet6_dev *idev =3D __in6_dev_get(skb->dev); =20 - if (!idev) - return -EINVAL; - - if (idev->dead) { - kfree_skb(skb); - return -ENODEV; - } + if (!idev || idev->dead) + goto out; =20 spin_lock_bh(&idev->mc_query_lock); if (skb_queue_len(&idev->mc_query_queue) < MLD_MAX_SKBS) { __skb_queue_tail(&idev->mc_query_queue, skb); if (!mod_delayed_work(mld_wq, &idev->mc_query_work, 0)) in6_dev_hold(idev); + skb =3D NULL; } spin_unlock_bh(&idev->mc_query_lock); - - return 0; +out: + kfree_skb(skb); } =20 static void __mld_query_work(struct sk_buff *skb) @@ -1542,27 +1538,23 @@ static void mld_query_work(struct work_struct *work) } =20 /* called with rcu_read_lock() */ -int igmp6_event_report(struct sk_buff *skb) +void igmp6_event_report(struct sk_buff *skb) { struct inet6_dev *idev =3D __in6_dev_get(skb->dev); =20 - if (!idev) - return -EINVAL; - - if (idev->dead) { - kfree_skb(skb); - return -ENODEV; - } + if (!idev || idev->dead) + goto out; =20 spin_lock_bh(&idev->mc_report_lock); if (skb_queue_len(&idev->mc_report_queue) < MLD_MAX_SKBS) { __skb_queue_tail(&idev->mc_report_queue, skb); if (!mod_delayed_work(mld_wq, &idev->mc_report_work, 0)) in6_dev_hold(idev); + skb =3D NULL; } spin_unlock_bh(&idev->mc_report_lock); - - return 0; +out: + kfree_skb(skb); } =20 static void __mld_report_work(struct sk_buff *skb) --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F01C433EF for ; Mon, 7 Mar 2022 10:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237903AbiCGKCR (ORCPT ); Mon, 7 Mar 2022 05:02:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240827AbiCGJlh (ORCPT ); Mon, 7 Mar 2022 04:41:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 927C96AA4D; Mon, 7 Mar 2022 01:38: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 1E21661224; Mon, 7 Mar 2022 09:38:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21B3CC340F3; Mon, 7 Mar 2022 09:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645896; bh=rMRkmQDClOKJ7+4mjLGLVxSR6PLJXwDyQbTZU1l4vh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lknYoZ5e/eX7VlHqVCq/m9I9S8qkq2Nx7lq7UqFMhGgLCA2BGGXQyYK8lLkPwU0be l9B65uSPogHiDJbhoIvJ8djk9PH4sLZGBgf0/J2BTFYw4pZTcVjbOLmGG926tLgeH1 HgPLF3ZJf/M5/1d27DOQGRrhFT9sIiWKVJpxzZAQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 5.15 043/262] NFSD: Have legacy NFSD WRITE decoders use xdr_stream_subsegment() Date: Mon, 7 Mar 2022 10:16:27 +0100 Message-Id: <20220307091703.738616612@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit dae9a6cab8009e526570e7477ce858dcdfeb256e ] Refactor. Now that the NFSv2 and NFSv3 XDR decoders have been converted to use xdr_streams, the WRITE decoder functions can use xdr_stream_subsegment() to extract the WRITE payload into its own xdr_buf, just as the NFSv4 WRITE XDR decoder currently does. That makes it possible to pass the first kvec, pages array + length, page_base, and total payload length via a single function parameter. The payload's page_base is not yet assigned or used, but will be in subsequent patches. Signed-off-by: Chuck Lever Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs3proc.c | 3 +-- fs/nfsd/nfs3xdr.c | 12 ++---------- fs/nfsd/nfs4proc.c | 3 +-- fs/nfsd/nfsproc.c | 3 +-- fs/nfsd/nfsxdr.c | 9 +-------- fs/nfsd/xdr.h | 2 +- fs/nfsd/xdr3.h | 2 +- include/linux/sunrpc/svc.h | 3 +-- net/sunrpc/svc.c | 11 ++++++----- 9 files changed, 15 insertions(+), 33 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 9918d6ad23ec9..354bbfcd96aae 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -210,8 +210,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp) =20 fh_copy(&resp->fh, &argp->fh); resp->committed =3D argp->stable; - nvecs =3D svc_fill_write_vector(rqstp, rqstp->rq_arg.pages, - &argp->first, cnt); + nvecs =3D svc_fill_write_vector(rqstp, &argp->payload); if (!nvecs) { resp->status =3D nfserr_io; goto out; diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 7a900131d20ca..0ee156b9c9d71 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -621,9 +621,6 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32= *p) struct xdr_stream *xdr =3D &rqstp->rq_arg_stream; struct nfsd3_writeargs *args =3D rqstp->rq_argp; u32 max_blocksize =3D svc_max_payload(rqstp); - struct kvec *head =3D rqstp->rq_arg.head; - struct kvec *tail =3D rqstp->rq_arg.tail; - size_t remaining; =20 if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) return 0; @@ -641,17 +638,12 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be= 32 *p) /* request sanity */ if (args->count !=3D args->len) return 0; - remaining =3D head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; - remaining -=3D xdr_stream_pos(xdr); - if (remaining < xdr_align_size(args->len)) - return 0; if (args->count > max_blocksize) { args->count =3D max_blocksize; args->len =3D max_blocksize; } - - args->first.iov_base =3D xdr->p; - args->first.iov_len =3D head->iov_len - xdr_stream_pos(xdr); + if (!xdr_stream_subsegment(xdr, &args->payload, args->count)) + return 0; =20 return 1; } diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 4b9a3b90a41ff..65200910107f3 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1038,8 +1038,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_comp= ound_state *cstate, =20 write->wr_how_written =3D write->wr_stable_how; =20 - nvecs =3D svc_fill_write_vector(rqstp, write->wr_payload.pages, - write->wr_payload.head, write->wr_buflen); + nvecs =3D svc_fill_write_vector(rqstp, &write->wr_payload); WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); =20 status =3D nfsd_vfs_write(rqstp, &cstate->current_fh, nf, diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 19c568b8a527f..de282f3273c50 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -234,8 +234,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) SVCFH_fmt(&argp->fh), argp->len, argp->offset); =20 - nvecs =3D svc_fill_write_vector(rqstp, rqstp->rq_arg.pages, - &argp->first, cnt); + nvecs =3D svc_fill_write_vector(rqstp, &argp->payload); if (!nvecs) { resp->status =3D nfserr_io; goto out; diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index a06c05fe3b421..26a42f87c2409 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -325,10 +325,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32= *p) { struct xdr_stream *xdr =3D &rqstp->rq_arg_stream; struct nfsd_writeargs *args =3D rqstp->rq_argp; - struct kvec *head =3D rqstp->rq_arg.head; - struct kvec *tail =3D rqstp->rq_arg.tail; u32 beginoffset, totalcount; - size_t remaining; =20 if (!svcxdr_decode_fhandle(xdr, &args->fh)) return 0; @@ -346,12 +343,8 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32= *p) return 0; if (args->len > NFSSVC_MAXBLKSIZE_V2) return 0; - remaining =3D head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; - remaining -=3D xdr_stream_pos(xdr); - if (remaining < xdr_align_size(args->len)) + if (!xdr_stream_subsegment(xdr, &args->payload, args->len)) return 0; - args->first.iov_base =3D xdr->p; - args->first.iov_len =3D head->iov_len - xdr_stream_pos(xdr); =20 return 1; } diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index f45b4bc93f527..80fd6d7f3404a 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -33,7 +33,7 @@ struct nfsd_writeargs { svc_fh fh; __u32 offset; int len; - struct kvec first; + struct xdr_buf payload; }; =20 struct nfsd_createargs { diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 933008382bbeb..712c117300cb7 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -40,7 +40,7 @@ struct nfsd3_writeargs { __u32 count; int stable; __u32 len; - struct kvec first; + struct xdr_buf payload; }; =20 struct nfsd3_createargs { diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 064c96157d1f0..6263410c948a0 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -532,8 +532,7 @@ int svc_encode_result_payload(struct svc_rqst *rqst= p, unsigned int offset, unsigned int length); unsigned int svc_fill_write_vector(struct svc_rqst *rqstp, - struct page **pages, - struct kvec *first, size_t total); + struct xdr_buf *payload); char *svc_fill_symlink_pathname(struct svc_rqst *rqstp, struct kvec *first, void *p, size_t total); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index a3bbe5ce4570f..08ca797bb8a46 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1676,16 +1676,17 @@ EXPORT_SYMBOL_GPL(svc_encode_result_payload); /** * svc_fill_write_vector - Construct data argument for VFS write call * @rqstp: svc_rqst to operate on - * @pages: list of pages containing data payload - * @first: buffer containing first section of write payload - * @total: total number of bytes of write payload + * @payload: xdr_buf containing only the write data payload * * Fills in rqstp::rq_vec, and returns the number of elements. */ -unsigned int svc_fill_write_vector(struct svc_rqst *rqstp, struct page **p= ages, - struct kvec *first, size_t total) +unsigned int svc_fill_write_vector(struct svc_rqst *rqstp, + struct xdr_buf *payload) { + struct page **pages =3D payload->pages; + struct kvec *first =3D payload->head; struct kvec *vec =3D rqstp->rq_vec; + size_t total =3D payload->len; unsigned int i; =20 /* Some types of transport can present the write payload --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 215AAC433FE for ; Mon, 7 Mar 2022 09:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235493AbiCGJv4 (ORCPT ); Mon, 7 Mar 2022 04:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240976AbiCGJln (ORCPT ); Mon, 7 Mar 2022 04:41:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB9CF5BE42; Mon, 7 Mar 2022 01:38: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 7E0AAB810BD; Mon, 7 Mar 2022 09:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90E43C340E9; Mon, 7 Mar 2022 09:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645932; bh=np/VDDuSzK0U7l3ywkzyCKXrtcwvE2mSNRZWXCFH3oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AcxYnBHMOOcFKCUaZreVlVcOaV8GiigyfFlbbWi14nMM0kvmwwOfWkyD+tcUl404l bmFPPxWeDnZvr9D8LYdoA7XnG1q2oX4AAjOOoPlAS6iSk7LbZ6mdwueIEO8kOBhDCP lp5nQ6TG5zgC8qfDfFnth2ajJ5SoVJ/1IV+8smUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 044/262] NFSD: Fix zero-length NFSv3 WRITEs Date: Mon, 7 Mar 2022 10:16:28 +0100 Message-Id: <20220307091703.765871345@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit 6a2f774424bfdcc2df3e17de0cefe74a4269cad5 ] The Linux NFS server currently responds to a zero-length NFSv3 WRITE request with NFS3ERR_IO. It responds to a zero-length NFSv4 WRITE with NFS4_OK and count of zero. RFC 1813 says of the WRITE procedure's @count argument: count The number of bytes of data to be written. If count is 0, the WRITE will succeed and return a count of 0, barring errors due to permissions checking. RFC 8881 has similar language for NFSv4, though NFSv4 removed the explicit @count argument because that value is already contained in the opaque payload array. The synthetic client pynfs's WRT4 and WRT15 tests do emit zero- length WRITEs to exercise this spec requirement. Commit fdec6114ee1f ("nfsd4: zero-length WRITE should succeed") addressed the same problem there with the same fix. But interestingly the Linux NFS client does not appear to emit zero- length WRITEs, instead squelching them. I'm not aware of a test that can generate such WRITEs for NFSv3, so I wrote a naive C program to generate a zero-length WRITE and test this fix. Fixes: 8154ef2776aa ("NFSD: Clean up legacy NFS WRITE argument XDR decoders= ") Reported-by: Trond Myklebust Signed-off-by: Chuck Lever Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs3proc.c | 6 +----- fs/nfsd/nfsproc.c | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 354bbfcd96aae..b540489ea240d 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -211,15 +211,11 @@ nfsd3_proc_write(struct svc_rqst *rqstp) fh_copy(&resp->fh, &argp->fh); resp->committed =3D argp->stable; nvecs =3D svc_fill_write_vector(rqstp, &argp->payload); - if (!nvecs) { - resp->status =3D nfserr_io; - goto out; - } + resp->status =3D nfsd_write(rqstp, &resp->fh, argp->offset, rqstp->rq_vec, nvecs, &cnt, resp->committed, resp->verf); resp->count =3D cnt; -out: return rpc_success; } =20 diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index de282f3273c50..312fd289be583 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -235,10 +235,6 @@ nfsd_proc_write(struct svc_rqst *rqstp) argp->len, argp->offset); =20 nvecs =3D svc_fill_write_vector(rqstp, &argp->payload); - if (!nvecs) { - resp->status =3D nfserr_io; - goto out; - } =20 resp->status =3D nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), argp->offset, rqstp->rq_vec, nvecs, @@ -247,7 +243,6 @@ nfsd_proc_write(struct svc_rqst *rqstp) resp->status =3D fh_getattr(&resp->fh, &resp->stat); else if (resp->status =3D=3D nfserr_jukebox) return rpc_drop_reply; -out: return rpc_success; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB6EAC433FE for ; Mon, 7 Mar 2022 09:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238533AbiCGJwl (ORCPT ); Mon, 7 Mar 2022 04:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241014AbiCGJlp (ORCPT ); Mon, 7 Mar 2022 04:41:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3C2C6D3A0; Mon, 7 Mar 2022 01:39: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 B5EE46116E; Mon, 7 Mar 2022 09:39:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63707C340E9; Mon, 7 Mar 2022 09:39:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645948; bh=jelnZl3ZRX+l4OmSRmakzD+X6v4N54ckjAV75aGfZgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1/kOnKLvjsq13SrCsmcX0rCXteKxIB01PGC4xHC4O/UvT0iRSw6q5Wv+V6Wx740Y GJuNdtSWx+880Cj6UYf1H3EY23qvPQGS4UjiN626SVpm7QXgP1wb1WPAjyIqx7zq29 pylDWorkLiUoSxTXZdmlTbqhdSAw+J4M9mImOZLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Xu , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 045/262] io_uring: fix no lock protection for ctx->cq_extra Date: Mon, 7 Mar 2022 10:16:29 +0100 Message-Id: <20220307091703.794659099@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hao Xu [ Upstream commit e302f1046f4c209291b07ff7bc4d15ca26891f16 ] ctx->cq_extra should be protected by completion lock so that the req_need_defer() does the right check. Cc: stable@vger.kernel.org Signed-off-by: Hao Xu Link: https://lore.kernel.org/r/20211125092103.224502-2-haoxu@linux.alibaba= .com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/io_uring.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index d7e49e87b49b9..156c54ebb62b7 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6573,11 +6573,14 @@ static bool io_drain_req(struct io_kiocb *req) } =20 /* Still need defer if there is pending req in defer list. */ + spin_lock(&ctx->completion_lock); if (likely(list_empty_careful(&ctx->defer_list) && !(req->flags & REQ_F_IO_DRAIN))) { + spin_unlock(&ctx->completion_lock); ctx->drain_active =3D false; return false; } + spin_unlock(&ctx->completion_lock); =20 seq =3D io_get_sequence(req); /* Still a chance to pass the sequence check */ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB2ADC4167D for ; Mon, 7 Mar 2022 10:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239567AbiCGKDY (ORCPT ); Mon, 7 Mar 2022 05:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241017AbiCGJlp (ORCPT ); Mon, 7 Mar 2022 04:41:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C70786D4D0; Mon, 7 Mar 2022 01:39: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 7B106B8102B; Mon, 7 Mar 2022 09:39:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0C99C340E9; Mon, 7 Mar 2022 09:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645951; bh=vW4LO60/Ru4RMZgw8XnXaD6rZPUU5Xd040JeN7CbI14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQAEv/MJrgifxKAEZ/wh92/lV9KsFzw948yfAsTkPGi8c0OEw6FcRWq2rQMBTsHGB q8sOyV69BHwxUwm+4FPAKS+mac3b/rbnsW/KgvTe9IlXruWOuTP3neGn5AMJW8dxQL n9iHVJq2wHh0d0dnypO7SYSRZBMV1Jg+NQGvk4Xs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.15 046/262] tools/resolve_btf_ids: Close ELF file on error Date: Mon, 7 Mar 2022 10:16:30 +0100 Message-Id: <20220307091703.822165908@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andrii Nakryiko [ Upstream commit 1144ab9bdf3430e1b5b3f22741e5283841951add ] Fix one case where we don't do explicit clean up. Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in EL= F object") Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20211124002325.1737739-2-andrii@kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- tools/bpf/resolve_btfids/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/mai= n.c index de6365b53c9ca..45e0d640618ac 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -166,7 +166,7 @@ static struct btf_id *btf_id__find(struct rb_root *root= , const char *name) return NULL; } =20 -static struct btf_id* +static struct btf_id * btf_id__add(struct rb_root *root, char *name, bool unique) { struct rb_node **p =3D &root->rb_node; @@ -720,7 +720,8 @@ int main(int argc, const char **argv) if (no_fail) return 0; pr_err("FAILED to find needed sections\n"); - return -1; + err =3D 0; + goto out; } =20 if (symbols_collect(&obj)) --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A30D9C4332F for ; Mon, 7 Mar 2022 09:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231971AbiCGJxP (ORCPT ); Mon, 7 Mar 2022 04:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241019AbiCGJlp (ORCPT ); Mon, 7 Mar 2022 04:41:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B1D193E3; Mon, 7 Mar 2022 01:39:15 -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 8E3A7B80F9F; Mon, 7 Mar 2022 09:39:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E536BC340F4; Mon, 7 Mar 2022 09:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645954; bh=7uufl7fOJxR6MEWi6zzls+R5+wCjkkg82U+p4qsirB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+kuDejsGk+s8FBcJdru+q2BvgGFAPjviYJrE5C2sQ+EpaaE5nxnN12y9MaLduIM+ za4mMIQfWvM2nfZVSDVKeCpUxH2KBfXIImyabBspFRoYOMxxOBTW5ulL0jlzPEgMH5 dGECCXbZvKlCqn79kT4r+Oq1M+7yApm1XomFvFSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Pratyush Yadav , Sasha Levin Subject: [PATCH 5.15 047/262] mtd: spi-nor: Fix mtd size for s3an flashes Date: Mon, 7 Mar 2022 10:16:31 +0100 Message-Id: <20220307091703.849344962@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tudor Ambarus [ Upstream commit f656b419d41aabafb6b526abc3988dfbf2e5c1ba ] As it was before the blamed commit, s3an_nor_scan() was called after mtd size was set with params->size, and it overwrote the mtd size value with '8 * nor->page_size * nor->info->n_sectors' when XSR_PAGESIZE was set. With the introduction of s3an_post_sfdp_fixups(), we missed to update the mtd size for the s3an flashes. Fix the mtd size by updating both nor->params->size, (which will update the mtd_info size later on) and nor->mtd.size (which is used in spi_nor_set_addr_width()). Fixes: 641edddb4f43 ("mtd: spi-nor: Add s3an_post_sfdp_fixups()") Signed-off-by: Tudor Ambarus Reviewed-by: Pratyush Yadav Link: https://lore.kernel.org/r/20211207140254.87681-2-tudor.ambarus@microc= hip.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/mtd/spi-nor/xilinx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c index 1138bdbf41998..75dd13a390404 100644 --- a/drivers/mtd/spi-nor/xilinx.c +++ b/drivers/mtd/spi-nor/xilinx.c @@ -66,7 +66,8 @@ static int xilinx_nor_setup(struct spi_nor *nor, /* Flash in Power of 2 mode */ nor->page_size =3D (nor->page_size =3D=3D 264) ? 256 : 512; nor->mtd.writebufsize =3D nor->page_size; - nor->mtd.size =3D 8 * nor->page_size * nor->info->n_sectors; + nor->params->size =3D 8 * nor->page_size * nor->info->n_sectors; + nor->mtd.size =3D nor->params->size; nor->mtd.erasesize =3D 8 * nor->page_size; } else { /* Flash in Default addressing mode */ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C8C9C3526E for ; Mon, 7 Mar 2022 09:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238762AbiCGJxE (ORCPT ); Mon, 7 Mar 2022 04:53:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241023AbiCGJlq (ORCPT ); Mon, 7 Mar 2022 04:41: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 CF00C673C5; Mon, 7 Mar 2022 01:39: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 7FEFAB8102B; Mon, 7 Mar 2022 09:39:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E38D2C340E9; Mon, 7 Mar 2022 09:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645957; bh=UEr6jH3P2BowYwBbVhZYQxWJENxUh46S+7dTIkNHJuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UeRuYoEuzZ9blFRZqtExGr/PhY2xSp/6YrYaOnek2++L7vTChFSE/KQYr2EotHBZx GmeZvDrfZl6YCuEYgSdLes0yBX8MHQQC+R3nmZIepq+OVw2G+/2ZUC9xqNUKY714AA xb3kpKtHQ+pRlNxsXpNng7Fx0rVE4KrYGHCPS2hk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Tao , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.15 048/262] bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC Date: Mon, 7 Mar 2022 10:16:32 +0100 Message-Id: <20220307091703.876970710@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hou Tao [ Upstream commit e4a41c2c1fa916547e63440c73a51a5eb06247af ] The following error is reported when running "./test_progs -t for_each" under arm64: bpf_jit: multi-func JIT bug 58 !=3D 56 [...] JIT doesn't support bpf-to-bpf calls The root cause is the size of BPF_PSEUDO_FUNC instruction increases from 2 to 3 after the address of called bpf-function is settled and there are two bpf-to-bpf calls in test_pkt_access. The generated instructions are shown below: 0x48: 21 00 C0 D2 movz x1, #0x1, lsl #32 0x4c: 21 00 80 F2 movk x1, #0x1 0x48: E1 3F C0 92 movn x1, #0x1ff, lsl #32 0x4c: 41 FE A2 F2 movk x1, #0x17f2, lsl #16 0x50: 81 70 9F F2 movk x1, #0xfb84 Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so the size of jited image will not change. Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper") Signed-off-by: Hou Tao Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20211231151018.3781550-1-houtao1@huawei.c= om Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/net/bpf_jit_comp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 465c44d0c72fc..3d7381ffc1712 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -788,7 +788,10 @@ static int build_insn(const struct bpf_insn *insn, str= uct jit_ctx *ctx, u64 imm64; =20 imm64 =3D (u64)insn1.imm << 32 | (u32)imm; - emit_a64_mov_i64(dst, imm64, ctx); + if (bpf_pseudo_func(insn)) + emit_addr_mov_i64(dst, imm64, ctx); + else + emit_a64_mov_i64(dst, imm64, ctx); =20 return 1; } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3725C46467 for ; Mon, 7 Mar 2022 09:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238632AbiCGJwy (ORCPT ); Mon, 7 Mar 2022 04:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241031AbiCGJlq (ORCPT ); Mon, 7 Mar 2022 04:41: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 E2CC76D4E5; Mon, 7 Mar 2022 01:39: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 86808B80F9F; Mon, 7 Mar 2022 09:39:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBB5CC340F3; Mon, 7 Mar 2022 09:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645960; bh=dLkJHSehkvwf6TVlYKXzLag1jRfBp/iDlklf0WRr+0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgP7/r19XFBUNpsyxOgroVwO/0zBxRXms+ZmGfIu1RUl2aRwVkiMVzhAUK2r5fN3X et1al/B2scbfv1/Ms/m5O65wPTM5r+DhpriHLXwmUmYvCTU9I58feJpjesABevs0Xb 7MApC4nsDzkvEJ44p6Zukoybe00MZmO6Ueq0COVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huang Pei , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.15 049/262] MIPS: fix local_{add,sub}_return on MIPS64 Date: Mon, 7 Mar 2022 10:16:33 +0100 Message-Id: <20220307091703.904636269@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Huang Pei [ Upstream commit 277c8cb3e8ac199f075bf9576ad286687ed17173 ] Use "daddu/dsubu" for long int on MIPS64 instead of "addu/subu" Fixes: 7232311ef14c ("local_t: mips extension") Signed-off-by: Huang Pei Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/mips/include/asm/local.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h index ecda7295ddcd1..3fa6340903882 100644 --- a/arch/mips/include/asm/local.h +++ b/arch/mips/include/asm/local.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,7 @@ static __inline__ long local_add_return(long i, local_t *= l) " .set arch=3Dr4000 \n" __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_add_return \n" - " addu %0, %1, %3 \n" + __stringify(LONG_ADDU) " %0, %1, %3 \n" __SC "%0, %2 \n" " beqzl %0, 1b \n" " addu %0, %1, %3 \n" @@ -55,7 +56,7 @@ static __inline__ long local_add_return(long i, local_t *= l) " .set "MIPS_ISA_ARCH_LEVEL" \n" __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_add_return \n" - " addu %0, %1, %3 \n" + __stringify(LONG_ADDU) " %0, %1, %3 \n" __SC "%0, %2 \n" " beqz %0, 1b \n" " addu %0, %1, %3 \n" @@ -88,7 +89,7 @@ static __inline__ long local_sub_return(long i, local_t *= l) " .set arch=3Dr4000 \n" __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_sub_return \n" - " subu %0, %1, %3 \n" + __stringify(LONG_SUBU) " %0, %1, %3 \n" __SC "%0, %2 \n" " beqzl %0, 1b \n" " subu %0, %1, %3 \n" @@ -104,7 +105,7 @@ static __inline__ long local_sub_return(long i, local_t= * l) " .set "MIPS_ISA_ARCH_LEVEL" \n" __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_sub_return \n" - " subu %0, %1, %3 \n" + __stringify(LONG_SUBU) " %0, %1, %3 \n" __SC "%0, %2 \n" " beqz %0, 1b \n" " subu %0, %1, %3 \n" --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC5E0C4707F for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239979AbiCGJu3 (ORCPT ); Mon, 7 Mar 2022 04:50:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240442AbiCGJlC (ORCPT ); Mon, 7 Mar 2022 04:41:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 140C041327; Mon, 7 Mar 2022 01:37: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 75539B810CB; Mon, 7 Mar 2022 09:37:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC81EC340E9; Mon, 7 Mar 2022 09:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645830; bh=Pbxjfsz5h7lA5AO4pfCoeS41QbTB3ix6m1vRTueHYLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNtaSpiUMzEGz569F3/kSyBvOfRmw3YN+9iBT8coP49S9pVOcm+f47AYz2f+ievCy 7f2vBkoFhlOJ1p28NZqJQCFJtEMfiw0UxTKwgOtI9MXu6gjhOk5zgzpRTvlF16j+N4 EzGH1Mjef4yC39JqkF/DgQlIE3r2sLbXBV+g7SNA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , "Eric W. Biederman" , Sasha Levin Subject: [PATCH 5.15 050/262] signal: In get_signal test for signal_group_exit every time through the loop Date: Mon, 7 Mar 2022 10:16:34 +0100 Message-Id: <20220307091703.932029160@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric W. Biederman [ Upstream commit e7f7c99ba911f56bc338845c1cd72954ba591707 ] Recently while investigating a problem with rr and signals I noticed that siglock is dropped in ptrace_signal and get_signal does not jump to relock. Looking farther to see if the problem is anywhere else I see that do_signal_stop also returns if signal_group_exit is true. I believe that test can now never be true, but it is a bit hard to trace through and be certain. Testing signal_group_exit is not expensive, so move the test for signal_group_exit into the for loop inside of get_signal to ensure the test is never skipped improperly. This has been a potential problem since I added the test for signal_group_exit was added. Fixes: 35634ffa1751 ("signal: Always notice exiting tasks") Reviewed-by: Kees Cook Link: https://lkml.kernel.org/r/875yssekcd.fsf_-_@email.froward.int.ebieder= m.org Signed-off-by: "Eric W. Biederman" Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/signal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index aea93d6a5520a..6e3dbb3d12170 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2710,19 +2710,19 @@ bool get_signal(struct ksignal *ksig) goto relock; } =20 - /* Has this task already been marked for death? */ - if (signal_group_exit(signal)) { - ksig->info.si_signo =3D signr =3D SIGKILL; - sigdelset(¤t->pending.signal, SIGKILL); - trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, - &sighand->action[SIGKILL - 1]); - recalc_sigpending(); - goto fatal; - } - for (;;) { struct k_sigaction *ka; =20 + /* Has this task already been marked for death? */ + if (signal_group_exit(signal)) { + ksig->info.si_signo =3D signr =3D SIGKILL; + sigdelset(¤t->pending.signal, SIGKILL); + trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, + &sighand->action[SIGKILL - 1]); + recalc_sigpending(); + goto fatal; + } + if (unlikely(current->jobctl & JOBCTL_STOP_PENDING) && do_signal_stop(0)) goto relock; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBF17C4707F for ; Mon, 7 Mar 2022 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239490AbiCGJ7Q (ORCPT ); Mon, 7 Mar 2022 04:59:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240275AbiCGJkv (ORCPT ); Mon, 7 Mar 2022 04:40:51 -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 50ACC5D67E; Mon, 7 Mar 2022 01:37: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 207A5611D5; Mon, 7 Mar 2022 09:37:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CD63C340F3; Mon, 7 Mar 2022 09:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645833; bh=fXl+KhFkFNVvhrHdnsaC4Mi8oIwGhOlNMCYqYf9MWAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YDoYklcHSIDqxQuz5pJHZge9mRrFjmkZy+C/1jUfPamSYjIhO0+YK7UN/9L5L9rgU 2JouQ+DviyXEPvzSEBfUtVbnK3i8Omb7zqmqBrHATmvIkF2Hdg3npuVSY4x6yI8HbD zZIevQcbYpOeMdXhFM/ZdSoUhxuN9C4FD3x7wUlc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qizhong Cheng , Jianjun Wang , Lorenzo Pieralisi , Tzung-Bi Shih , Matthias Brugger , Sasha Levin Subject: [PATCH 5.15 051/262] PCI: mediatek-gen3: Disable DVFSRC voltage request Date: Mon, 7 Mar 2022 10:16:35 +0100 Message-Id: <20220307091703.958788169@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jianjun Wang [ Upstream commit ab344fd43f2958726d17d651c0cb692c67dca382 ] When the DVFSRC (dynamic voltage and frequency scaling resource collector) feature is not implemented, the PCIe hardware will assert a voltage request signal when exit from the L1 PM Substates to request a specific Vcore voltage, but cannot receive the voltage ready signal, which will cause the link to fail to exit the L1 PM Substates. Disable DVFSRC voltage request by default, we need to find a common way to enable it in the future. Link: https://lore.kernel.org/r/20211015063602.29058-1-jianjun.wang@mediate= k.com Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT81= 92") Tested-by: Qizhong Cheng Signed-off-by: Jianjun Wang Signed-off-by: Lorenzo Pieralisi Reviewed-by: Tzung-Bi Shih Reviewed-by: Matthias Brugger Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pcie-mediatek-gen3.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/cont= roller/pcie-mediatek-gen3.c index 17c59b0d6978b..21207df680ccf 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -79,6 +79,9 @@ #define PCIE_ICMD_PM_REG 0x198 #define PCIE_TURN_OFF_LINK BIT(4) =20 +#define PCIE_MISC_CTRL_REG 0x348 +#define PCIE_DISABLE_DVFSRC_VLT_REQ BIT(1) + #define PCIE_TRANS_TABLE_BASE_REG 0x800 #define PCIE_ATR_SRC_ADDR_MSB_OFFSET 0x4 #define PCIE_ATR_TRSL_ADDR_LSB_OFFSET 0x8 @@ -297,6 +300,11 @@ static int mtk_pcie_startup_port(struct mtk_pcie_port = *port) val &=3D ~PCIE_INTX_ENABLE; writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); =20 + /* Disable DVFSRC voltage request */ + val =3D readl_relaxed(port->base + PCIE_MISC_CTRL_REG); + val |=3D PCIE_DISABLE_DVFSRC_VLT_REQ; + writel_relaxed(val, port->base + PCIE_MISC_CTRL_REG); + /* Assert all reset signals */ val =3D readl_relaxed(port->base + PCIE_RST_CTRL_REG); val |=3D PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 848EAC352A8 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240450AbiCGJvC (ORCPT ); Mon, 7 Mar 2022 04:51:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240672AbiCGJl0 (ORCPT ); Mon, 7 Mar 2022 04:41:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933536622F; Mon, 7 Mar 2022 01:38: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 dfw.source.kernel.org (Postfix) with ESMTPS id 28AB761052; Mon, 7 Mar 2022 09:37:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5B98C340F3; Mon, 7 Mar 2022 09:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645836; bh=4pr7UGilxZNytlmkhrPKXqgNFt/dZXUg+ThhVt8OKo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qU3m8IX9muLwSPjcQJBoYd6IdGuAkv8ZoON6tXdqcKRxKGLE3rRk5PWSaKNUvsR3S VpmwXeQO9Cvb9fDHU8fQQQsg4tNDLxTXk24yrx9ELo8TcHNb1wyMvHUubMqbWJ9sM/ jsolx9+IWEg+BMPu7uCQMJh76AaR8Ox5a1y2ff5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Lorenzo Pieralisi , Geert Uytterhoeven , Randy Dunlap , Arnd Bergmann , Bjorn Helgaas , Stephen Boyd , Wolfram Sang , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Sasha Levin Subject: [PATCH 5.15 052/262] PCI: rcar: Check if device is runtime suspended instead of __clk_is_enabled() Date: Mon, 7 Mar 2022 10:16:36 +0100 Message-Id: <20220307091703.985954255@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marek Vasut [ Upstream commit d2a14b54989e9ccea8401895fdfbc213bd1f56af ] Replace __clk_is_enabled() with pm_runtime_suspended(), as __clk_is_enabled() was checking the wrong bus clock and caused the following build error too: arm-linux-gnueabi-ld: drivers/pci/controller/pcie-rcar-host.o: in functio= n `rcar_pcie_aarch32_abort_handler': pcie-rcar-host.c:(.text+0xdd0): undefined reference to `__clk_is_enabled' Link: https://lore.kernel.org/r/20211115204641.12941-1-marek.vasut@gmail.com Fixes: a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook= ") Signed-off-by: Marek Vasut Signed-off-by: Lorenzo Pieralisi Reviewed-by: Geert Uytterhoeven Acked-by: Randy Dunlap Cc: Arnd Bergmann Cc: Bjorn Helgaas Cc: Geert Uytterhoeven Cc: Lorenzo Pieralisi Cc: Stephen Boyd Cc: Wolfram Sang Cc: Yoshihiro Shimoda Cc: linux-renesas-soc@vger.kernel.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pcie-rcar-host.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controll= er/pcie-rcar-host.c index 8f3131844e777..bfb13f358d073 100644 --- a/drivers/pci/controller/pcie-rcar-host.c +++ b/drivers/pci/controller/pcie-rcar-host.c @@ -52,10 +52,10 @@ struct rcar_msi { */ static void __iomem *pcie_base; /* - * Static copy of bus clock pointer, so we can check whether the clock - * is enabled or not. + * Static copy of PCIe device pointer, so we can check whether the + * device is runtime suspended or not. */ -static struct clk *pcie_bus_clk; +static struct device *pcie_dev; #endif =20 /* Structure representing the PCIe interface */ @@ -794,7 +794,7 @@ static int rcar_pcie_get_resources(struct rcar_pcie_hos= t *host) #ifdef CONFIG_ARM /* Cache static copy for L1 link state fixup hook on aarch32 */ pcie_base =3D pcie->base; - pcie_bus_clk =3D host->bus_clk; + pcie_dev =3D pcie->dev; #endif =20 return 0; @@ -1064,7 +1064,7 @@ static int rcar_pcie_aarch32_abort_handler(unsigned l= ong addr, =20 spin_lock_irqsave(&pmsr_lock, flags); =20 - if (!pcie_base || !__clk_is_enabled(pcie_bus_clk)) { + if (!pcie_base || pm_runtime_suspended(pcie_dev)) { ret =3D 1; goto unlock_exit; } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE5FBC4332F for ; Mon, 7 Mar 2022 10:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239752AbiCGKAC (ORCPT ); Mon, 7 Mar 2022 05:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240712AbiCGJla (ORCPT ); Mon, 7 Mar 2022 04:41:30 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCEF2BB2C; Mon, 7 Mar 2022 01:38: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 sin.source.kernel.org (Postfix) with ESMTPS id 8EA23CE0B91; Mon, 7 Mar 2022 09:37:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 510B0C340E9; Mon, 7 Mar 2022 09:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645839; bh=+2VXaBSzPCczrSieBa6Z5FKW8gMdw7eVMp/ZAnh4K0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIXouci0gDacMxoGTWmwQZxrOrFV1PoDd1zvysz5DXQlKrqDYaMigzoLOoTQ1ToRP xanS1EjcKtMZ6W2OXt1RxXdKG60nQQYVY2Q5pwmm27jxuMSRBtzODcvv4Z76tM4jJ+ GNq1EY5gpYvUwgZlTRd7KuIDQevQAoy3yf8XtvnQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tim Harvey , Lorenzo Pieralisi , Rob Herring , Richard Zhu , Sasha Levin Subject: [PATCH 5.15 053/262] PCI: dwc: Do not remap invalid res Date: Mon, 7 Mar 2022 10:16:37 +0100 Message-Id: <20220307091704.013388515@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tim Harvey [ Upstream commit 6e5ebc96ec651b67131f816d7e3bf286c635e749 ] On imx6 and perhaps others when pcie probes you get a: imx6q-pcie 33800000.pcie: invalid resource This occurs because the atu is not specified in the DT and as such it should not be remapped. Link: https://lore.kernel.org/r/20211101180243.23761-1-tharvey@gateworks.com Fixes: 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows") Signed-off-by: Tim Harvey Signed-off-by: Lorenzo Pieralisi Reviewed-by: Rob Herring Acked-by: Richard Zhu Cc: Richard Zhu Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/dwc/pcie-designware.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/con= troller/dwc/pcie-designware.c index a945f0c0e73dc..3254f60d1713f 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -671,10 +671,11 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci) if (!pci->atu_base) { struct resource *res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "atu"); - if (res) + if (res) { pci->atu_size =3D resource_size(res); - pci->atu_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(pci->atu_base)) + pci->atu_base =3D devm_ioremap_resource(dev, res); + } + if (!pci->atu_base || IS_ERR(pci->atu_base)) pci->atu_base =3D pci->dbi_base + DEFAULT_DBI_ATU_OFFSET; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74B50C433F5 for ; Mon, 7 Mar 2022 09:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240105AbiCGJuk (ORCPT ); Mon, 7 Mar 2022 04:50:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240538AbiCGJlH (ORCPT ); Mon, 7 Mar 2022 04:41:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46742273D; Mon, 7 Mar 2022 01:37: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 70CCB6128E; Mon, 7 Mar 2022 09:37:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88B50C340E9; Mon, 7 Mar 2022 09:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645842; bh=r8Ao5v/dnH/vW+0w9rwvC1D8D+2q8aKGa6MHCS65ao0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2rSomsNqZ3KF3N153HPViLt3E4JlxJ2CmKXonjsv9Ff2bh1NfAqCP8/ATtpbCPCt yH703DOP4kMSV1Pjn+43cQ1VDmW118xYFuQg6lh32Vuw2XTEjhCg66sAmtunP/9A0m aQK+lkPFk/ExOVKBVCFnjJCiuk6Znu56KcR50AR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 054/262] PCI: aardvark: Fix checking for MEM resource type Date: Mon, 7 Mar 2022 10:16:38 +0100 Message-Id: <20220307091704.040305642@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 2070b2ddea89f5b604fac3d27ade5cb6d19a5706 ] IORESOURCE_MEM_64 is not a resource type but a type flag. Remove incorrect check for type IORESOURCE_MEM_64. Link: https://lore.kernel.org/r/20211125160148.26029-2-kabel@kernel.org Fixes: 64f160e19e92 ("PCI: aardvark: Configure PCIe resources from 'ranges'= DT property") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Marek Beh=C3=BAn Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-aardvark.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller= /pci-aardvark.c index 85323cbc4888a..b2217e2b3efde 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1537,8 +1537,7 @@ static int advk_pcie_probe(struct platform_device *pd= ev) * only PIO for issuing configuration transfers which does * not use PCIe window configuration. */ - if (type !=3D IORESOURCE_MEM && type !=3D IORESOURCE_MEM_64 && - type !=3D IORESOURCE_IO) + if (type !=3D IORESOURCE_MEM && type !=3D IORESOURCE_IO) continue; =20 /* @@ -1546,8 +1545,7 @@ static int advk_pcie_probe(struct platform_device *pd= ev) * configuration is set to transparent memory access so it * does not need window configuration. */ - if ((type =3D=3D IORESOURCE_MEM || type =3D=3D IORESOURCE_MEM_64) && - entry->offset =3D=3D 0) + if (type =3D=3D IORESOURCE_MEM && entry->offset =3D=3D 0) continue; =20 /* --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FEEC433F5 for ; Mon, 7 Mar 2022 10:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239511AbiCGJ7S (ORCPT ); Mon, 7 Mar 2022 04:59:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240317AbiCGJky (ORCPT ); Mon, 7 Mar 2022 04:40:54 -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 E58BB6D3A2; Mon, 7 Mar 2022 01:37: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 20875B810D2; Mon, 7 Mar 2022 09:37:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D9B3C340E9; Mon, 7 Mar 2022 09:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645845; bh=+IC5SxFlPCTwimrhYxrbf0C6EBpcKCzs3MZ8Q9Z5Lf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BU3sqPlBCvv42D/BPPJITwOio0kWb/XTz04BSIaPABiinhefGRJhjQh8SBmFmzZ0/ 2WgnuvnpYHjlr2jykGR/3ydE1GZ54IZ/Lbzu8L5pcuGsETJfqDqdAuh6FPDH8o8WgF KdLQYAdY4vikcrLr9ydEyKkurIWl6XAGYzIwrocM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 055/262] KVM: VMX: Dont unblock vCPU w/ Posted IRQ if IRQs are disabled in guest Date: Mon, 7 Mar 2022 10:16:39 +0100 Message-Id: <20220307091704.067414668@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini [ Upstream commit 1831fa44df743a7cdffdf1c12c799bf6f3c12b8c ] Don't configure the wakeup handler when a vCPU is blocking with IRQs disabled, in which case any IRQ, posted or otherwise, should not be recognized and thus should not wake the vCPU. Fixes: bf9f6ac8d749 ("KVM: Update Posted-Interrupts Descriptor when vCPU is= blocked") Signed-off-by: Sean Christopherson Message-Id: <20211009021236.4122790-2-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/kvm/vmx/posted_intr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 21ea58d25771f..696ad48ab5daa 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -147,7 +147,8 @@ int pi_pre_block(struct kvm_vcpu *vcpu) struct pi_desc old, new; struct pi_desc *pi_desc =3D vcpu_to_pi_desc(vcpu); =20 - if (!vmx_can_use_vtd_pi(vcpu->kvm)) + if (!vmx_can_use_vtd_pi(vcpu->kvm) || + vmx_interrupt_blocked(vcpu)) return 0; =20 WARN_ON(irqs_disabled()); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6142EC4167D for ; Mon, 7 Mar 2022 09:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239919AbiCGJuW (ORCPT ); Mon, 7 Mar 2022 04:50:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240334AbiCGJkz (ORCPT ); Mon, 7 Mar 2022 04:40:55 -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 6AA686E78C; Mon, 7 Mar 2022 01:37: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 E533961140; Mon, 7 Mar 2022 09:37:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9180C340E9; Mon, 7 Mar 2022 09:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645849; bh=OqwpDpAO0JkmgKqsYR2dsCCX5pvu10TxmU2ZMAnKeSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LllTfxksbJm/e2IcnFJbGhm2ELdgjEIjIRC5NlpS3fqHdcyVDzaxfHHgceBn+3jXA eBIaS6x58nbmGjcun9GMbpBqTMlxrJdhqdaLFe8MuIHxOWkafmyBejbu/EFTQ1l6qQ Tnkhx0XltIviYqGmbKBZiuyxsrdyZOvzC9Hn9s5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Borntraeger , Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 056/262] KVM: s390: Ensure kvm_arch_no_poll() is read once when blocking vCPU Date: Mon, 7 Mar 2022 10:16:40 +0100 Message-Id: <20220307091704.094220587@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson [ Upstream commit 6f390916c4fb359507d9ac4bf1b28a4f8abee5c0 ] Wrap s390's halt_poll_max_steal with READ_ONCE and snapshot the result of kvm_arch_no_poll() in kvm_vcpu_block() to avoid a mostly-theoretical, largely benign bug on s390 where the result of kvm_arch_no_poll() could change due to userspace modifying halt_poll_max_steal while the vCPU is blocking. The bug is largely benign as it will either cause KVM to skip updating halt-polling times (no_poll toggles false=3D>true) or to update halt-polling times with a slightly flawed block_ns. Note, READ_ONCE is unnecessary in the current code, add it in case the arch hook is ever inlined, and to provide a hint that userspace can change the param at will. Fixes: 8b905d28ee17 ("KVM: s390: provide kvm_arch_no_poll function") Reviewed-by: Christian Borntraeger Signed-off-by: Sean Christopherson Message-Id: <20211009021236.4122790-4-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/s390/kvm/kvm-s390.c | 2 +- virt/kvm/kvm_main.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 9a8c086528f56..402597f9d0505 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3447,7 +3447,7 @@ bool kvm_arch_no_poll(struct kvm_vcpu *vcpu) { /* do not poll with more than halt_poll_max_steal percent of steal time */ if (S390_lowcore.avg_steal_timer * 100 / (TICK_USEC << 12) >=3D - halt_poll_max_steal) { + READ_ONCE(halt_poll_max_steal)) { vcpu->stat.halt_no_poll_steal++; return true; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 13aff136e6eef..f8b42e19bc775 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3222,6 +3222,7 @@ update_halt_poll_stats(struct kvm_vcpu *vcpu, u64 pol= l_ns, bool waited) */ void kvm_vcpu_block(struct kvm_vcpu *vcpu) { + bool halt_poll_allowed =3D !kvm_arch_no_poll(vcpu); ktime_t start, cur, poll_end; bool waited =3D false; u64 block_ns; @@ -3229,7 +3230,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) kvm_arch_vcpu_blocking(vcpu); =20 start =3D cur =3D poll_end =3D ktime_get(); - if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) { + if (vcpu->halt_poll_ns && halt_poll_allowed) { ktime_t stop =3D ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); =20 ++vcpu->stat.generic.halt_attempted_poll; @@ -3284,7 +3285,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) update_halt_poll_stats( vcpu, ktime_to_ns(ktime_sub(poll_end, start)), waited); =20 - if (!kvm_arch_no_poll(vcpu)) { + if (halt_poll_allowed) { if (!vcpu_valid_wakeup(vcpu)) { shrink_halt_poll_ns(vcpu); } else if (vcpu->kvm->max_halt_poll_ns) { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC8FC433EF for ; Mon, 7 Mar 2022 10:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239555AbiCGJ7b (ORCPT ); Mon, 7 Mar 2022 04:59:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240364AbiCGJk4 (ORCPT ); Mon, 7 Mar 2022 04:40:56 -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 E15E12D1D5; Mon, 7 Mar 2022 01:37: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 0CCCF60F63; Mon, 7 Mar 2022 09:37:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0729EC340E9; Mon, 7 Mar 2022 09:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645852; bh=UMz2txwKo30Dyf7QnStl7t4dAxLp9RmLZ4ZsAfzY8d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LS15UwDrFAU+y2WXNOjLV2+SYWBhc8wC/T+6LmDXSaXtkkO4L/4RyCeQzdEr17lJ6 xEkRw6bXXRD2KgecKvszsfMQQfYMpZKSFjiSxSee0rqP3X4bbrz6JuCSE1RigQCJB5 d1o/Tt/pUDPdxZ+yEMOguO+YRq9fEN4G1uNCmWyA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 057/262] KVM: VMX: Read Posted Interrupt "control" exactly once per loop iteration Date: Mon, 7 Mar 2022 10:16:41 +0100 Message-Id: <20220307091704.121672878@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson [ Upstream commit cfb0e1306a3790eb055ebf7cdb7b0ee8a23e9b6e ] Use READ_ONCE() when loading the posted interrupt descriptor control field to ensure "old" and "new" have the same base value. If the compiler emits separate loads, and loads into "new" before "old", KVM could theoretically drop the ON bit if it were set between the loads. Fixes: 28b835d60fcc ("KVM: Update Posted-Interrupts Descriptor when vCPU is= preempted") Signed-off-by: Sean Christopherson Message-Id: <20211009021236.4122790-27-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/kvm/vmx/posted_intr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 696ad48ab5daa..46fb83d6a286e 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -51,7 +51,7 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) =20 /* The full case. */ do { - old.control =3D new.control =3D pi_desc->control; + old.control =3D new.control =3D READ_ONCE(pi_desc->control); =20 dest =3D cpu_physical_id(cpu); =20 @@ -104,7 +104,7 @@ static void __pi_post_block(struct kvm_vcpu *vcpu) unsigned int dest; =20 do { - old.control =3D new.control =3D pi_desc->control; + old.control =3D new.control =3D READ_ONCE(pi_desc->control); WARN(old.nv !=3D POSTED_INTR_WAKEUP_VECTOR, "Wakeup handler not enabled while the VCPU is blocked\n"); =20 @@ -163,7 +163,7 @@ int pi_pre_block(struct kvm_vcpu *vcpu) } =20 do { - old.control =3D new.control =3D pi_desc->control; + old.control =3D new.control =3D READ_ONCE(pi_desc->control); =20 WARN((pi_desc->sn =3D=3D 1), "Warning: SN field of posted-interrupts " --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0468DC47080 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240019AbiCGJuf (ORCPT ); Mon, 7 Mar 2022 04:50:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240511AbiCGJlG (ORCPT ); Mon, 7 Mar 2022 04:41:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE31DFC7; Mon, 7 Mar 2022 01:37:52 -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 452CA6116E; Mon, 7 Mar 2022 09:37:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B716C340F7; Mon, 7 Mar 2022 09:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645855; bh=BCiFTI1+xuXNxubvOt6Xtivf8YgM8q/uu4hh6OT7LUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kj8kFhk3DyEhPFdjN4mU0hQ0e2DbYvUB9ny2LWCAXf05LG9/sHKRC67T+JUzlkQJr sNA3iFF8hDGj7Gcx+cR5/ZYVbyWLt+aQjhMd/50HvXIJ6Sy9HwnqlC/iNmd8zEjWFm FmwmN4Lqb3v5gSzXcmDkQkicCIEteeqekezIwd3w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lai Jiangshan , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 058/262] KVM: X86: Ensure that dirty PDPTRs are loaded Date: Mon, 7 Mar 2022 10:16:42 +0100 Message-Id: <20220307091704.149043890@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan [ Upstream commit 2c5653caecc4807b8abfe9c41880ac38417be7bf ] For VMX with EPT, dirty PDPTRs need to be loaded before the next vmentry via vmx_load_mmu_pgd() But not all paths that call load_pdptrs() will cause vmx_load_mmu_pgd() to be invoked. Normally, kvm_mmu_reset_context() is used to cause KVM_REQ_LOAD_MMU_PGD, but sometimes it is skipped: * commit d81135a57aa6("KVM: x86: do not reset mmu if CR0.CD and CR0.NW are changed") skips kvm_mmu_reset_context() after load_pdptrs() when changing CR0.CD and CR0.NW. * commit 21823fbda552("KVM: x86: Invalidate all PGDs for the current PCID on MOV CR3 w/ flush") skips KVM_REQ_LOAD_MMU_PGD after load_pdptrs() when rewriting the CR3 with the same value. * commit a91a7c709600("KVM: X86: Don't reset mmu context when toggling X86_CR4_PGE") skips kvm_mmu_reset_context() after load_pdptrs() when changing CR4.PGE. Fixes: d81135a57aa6 ("KVM: x86: do not reset mmu if CR0.CD and CR0.NW are c= hanged") Fixes: 21823fbda552 ("KVM: x86: Invalidate all PGDs for the current PCID on= MOV CR3 w/ flush") Fixes: a91a7c709600 ("KVM: X86: Don't reset mmu context when toggling X86_C= R4_PGE") Signed-off-by: Lai Jiangshan Message-Id: <20211108124407.12187-2-jiangshanlai@gmail.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 33cb065181248..33457b27e220b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -848,6 +848,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *= mmu, unsigned long cr3) =20 memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs)); kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR); + kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu); vcpu->arch.pdptrs_from_userspace =3D false; =20 out: --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F3D3C4321E for ; Mon, 7 Mar 2022 09:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240242AbiCGJur (ORCPT ); Mon, 7 Mar 2022 04:50:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240558AbiCGJlI (ORCPT ); Mon, 7 Mar 2022 04:41:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A3715A05; Mon, 7 Mar 2022 01:37: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 dfw.source.kernel.org (Postfix) with ESMTPS id 61372611D5; Mon, 7 Mar 2022 09:37:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64442C340E9; Mon, 7 Mar 2022 09:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645858; bh=XC2dYqop3svzaK/jPsZIDCG3s790ZpIO28tWyxJ4SzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ij87L2xmUqrWr+aK6YDXj+UjWhmQN0DPaR7u7tZVkkorwqDT661fiS8ZBuDhn7lKZ ww+zC1frWH8ZZ4B16grZp0DtFCopmCIL95dfFXVcJ6jUDYcuuWqihIC2hjRONkf4z9 Uq30V26sitzJJT4TmXwRVg6UFATr2jjCvwP8x5pU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 059/262] KVM: x86: Handle 32-bit wrap of EIP for EMULTYPE_SKIP with flat code seg Date: Mon, 7 Mar 2022 10:16:43 +0100 Message-Id: <20220307091704.176390443@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson [ Upstream commit 5e854864ee4384736f27a986633bae21731a4e4e ] Truncate the new EIP to a 32-bit value when handling EMULTYPE_SKIP as the decode phase does not truncate _eip. Wrapping the 32-bit boundary is legal if and only if CS is a flat code segment, but that check is implicitly handled in the form of limit checks in the decode phase. Opportunstically prepare for a future fix by storing the result of any truncation in "eip" instead of "_eip". Fixes: 1957aa63be53 ("KVM: VMX: Handle single-step #DB for EMULTYPE_SKIP on= EPT misconfig") Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Message-Id: <093eabb1eab2965201c9b018373baf26ff256d85.1635842679.git.houwen= long93@linux.alibaba.com> Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/kvm/x86.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 33457b27e220b..6b76486702ded 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7999,7 +7999,12 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, g= pa_t cr2_or_gpa, * updating interruptibility state and injecting single-step #DBs. */ if (emulation_type & EMULTYPE_SKIP) { - kvm_rip_write(vcpu, ctxt->_eip); + if (ctxt->mode !=3D X86EMUL_MODE_PROT64) + ctxt->eip =3D (u32)ctxt->_eip; + else + ctxt->eip =3D ctxt->_eip; + + kvm_rip_write(vcpu, ctxt->eip); if (ctxt->eflags & X86_EFLAGS_RF) kvm_set_rflags(vcpu, ctxt->eflags & ~X86_EFLAGS_RF); return 1; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63845C433FE for ; Mon, 7 Mar 2022 10:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239696AbiCGJ7y (ORCPT ); Mon, 7 Mar 2022 04:59:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240602AbiCGJlL (ORCPT ); Mon, 7 Mar 2022 04:41:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F644B43A; Mon, 7 Mar 2022 01:37: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 ADBBD60FF6; Mon, 7 Mar 2022 09:37:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51AF6C340F4; Mon, 7 Mar 2022 09:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645865; bh=tgNigy6iluIbCmY3PIKN2TAhpdqPD7xQ2/sANhsu4tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=junW8Bo3SGds9qNJ9VJ7cDRCCxYuhF+puwRfzUFivJgxhLfCrDb1qenJoG8Osyxl9 TKoH+FpiqDAzcD+bq/Ju832KVlODnod5uGG2R/VXKh6i4Kn0MTK9cht/lEpM4HQABx +ywZtvxRi7EiGUIRgEueSjVFmSRgH/VLg8WRuCqE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Wenlong , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 060/262] KVM: x86: Exit to userspace if emulation prepared a completion callback Date: Mon, 7 Mar 2022 10:16:44 +0100 Message-Id: <20220307091704.203349969@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 Wenlong [ Upstream commit adbfb12d4c4517a8adde23a7fc46538953d56eea ] em_rdmsr() and em_wrmsr() return X86EMUL_IO_NEEDED if MSR accesses required an exit to userspace. However, x86_emulate_insn() doesn't return X86EMUL_*, so x86_emulate_instruction() doesn't directly act on X86EMUL_IO_NEEDED; instead, it looks for other signals to differentiate between PIO, MMIO, etc. causing RDMSR/WRMSR emulation not to exit to userspace now. Nevertheless, if the userspace_msr_exit_test testcase in selftests is changed to test RDMSR/WRMSR with a forced emulation prefix, the test passes. What happens is that first userspace exit information is filled but the userspace exit does not happen. Because x86_emulate_instruction() returns 1, the guest retries the instruction---but this time RIP has already been adjusted past the forced emulation prefix, so the guest executes RDMSR/WRMSR and the userspace exit finally happens. Since the X86EMUL_IO_NEEDED path has provided a complete_userspace_io callback, x86_emulate_instruction() can just return 0 if the callback is not NULL. Then RDMSR/WRMSR instruction emulation will exit to userspace directly, without the RDMSR/WRMSR vmexit. Fixes: 1ae099540e8c7 ("KVM: x86: Allow deflecting unknown MSR accesses to u= ser space") Signed-off-by: Hou Wenlong Signed-off-by: Paolo Bonzini Message-Id: <56f9df2ee5c05a81155e2be366c9dc1f7adc8817.1635842679.git.houwen= long93@linux.alibaba.com> Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6b76486702ded..8213f7fb71a7b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8068,6 +8068,9 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gp= a_t cr2_or_gpa, writeback =3D false; r =3D 0; vcpu->arch.complete_userspace_io =3D complete_emulated_mmio; + } else if (vcpu->arch.complete_userspace_io) { + writeback =3D false; + r =3D 0; } else if (r =3D=3D EMULATION_RESTART) goto restart; else --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A88C43217 for ; Mon, 7 Mar 2022 10:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235509AbiCGKCE (ORCPT ); Mon, 7 Mar 2022 05:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240698AbiCGJl2 (ORCPT ); Mon, 7 Mar 2022 04:41:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78338FD2F; Mon, 7 Mar 2022 01:38: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 5CCE4B810D2; Mon, 7 Mar 2022 09:37:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5542C340E9; Mon, 7 Mar 2022 09:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645868; bh=VbmKCL72Oen/J1WzvyZ7/8kn5y0mhpkYsLrA1c3G/+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYwOu194p0/yDL9w2DOtG9/zMYF2gujpjzcY4U3whg0kyvgPtuUtLTeYWENba7r71 3CmdCDbjR38IUK3rehHxno9Tqkvow79w3G7s4cVzaH1ui8EpepSUzGSPeIf2fjpH5h b+2/kZ3m5LtMVURlW8DFqD+iOWiEi3sU0jnPaHbQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Alexandre Belloni , Jamie Iles , Sasha Levin Subject: [PATCH 5.15 061/262] i3c: fix incorrect address slot lookup on 64-bit Date: Mon, 7 Mar 2022 10:16:45 +0100 Message-Id: <20220307091704.230344957@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jamie Iles [ Upstream commit f18f98110f2b179792cb70d85cba697320a3790f ] The address slot bitmap is an array of unsigned long's which are the same size as an int on 32-bit platforms but not 64-bit. Loading the bitmap into an int could result in the incorrect status being returned for a slot and slots being reported as the wrong status. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Cc: Boris Brezillon Cc: Alexandre Belloni Signed-off-by: Jamie Iles Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20210922165600.179394-1-quic_jiles@quicinc.= com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i3c/master.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index c3b4c677b4429..dfe18dcd008d4 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -343,7 +343,8 @@ struct bus_type i3c_bus_type =3D { static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) { - int status, bitpos =3D addr * 2; + unsigned long status; + int bitpos =3D addr * 2; =20 if (addr > I2C_MAX_ADDR) return I3C_ADDR_SLOT_RSVD; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41A4FC352A7 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240303AbiCGJuv (ORCPT ); Mon, 7 Mar 2022 04:50:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240583AbiCGJlK (ORCPT ); Mon, 7 Mar 2022 04:41: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 55DEA15A0C; Mon, 7 Mar 2022 01:37: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 A2209B8102B; Mon, 7 Mar 2022 09:37:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D84C340E9; Mon, 7 Mar 2022 09:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645871; bh=C1j676FUP8iWuGVMyB82H13nsJjOvitU5NC+K+waxcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tvzc7kQOeAPcNzkkKWj3+aijpADHdN0SZ3qBb+0qDqQYs9i9r+HojgC1K/x2utLRj 80mr1WXhSYEPqSOIqnxk9OrfI3BB2kzrqvLPyqCBEi0W6Q9Czu+YZJab6Ld1zu3yI5 c03zoI0WPkp4ZYgXvXTc1SaOCAhvZgz+hdUUnfZ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Nicolas Pitre , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 062/262] i3c/master/mipi-i3c-hci: Fix a potentially infinite loop in hci_dat_v1_get_index() Date: Mon, 7 Mar 2022 10:16:46 +0100 Message-Id: <20220307091704.258121933@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christophe JAILLET [ Upstream commit 3f43926f271287fb1744c9ac9ae1122497f2b0c2 ] The code in 'hci_dat_v1_get_index()' really looks like a hand coded version of 'for_each_set_bit()', except that a +1 is missing when searching for the next set bit. This really looks odd and it seems that it will loop until 'dat_w0_read()' returns the expected result. So use 'for_each_set_bit()' instead. It is less verbose and should be more correct. Fixes: 9ad9a52cce28 ("i3c/master: introduce the mipi-i3c-hci driver") Signed-off-by: Christophe JAILLET Acked-by: Nicolas Pitre Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/0cdf3cb10293ead1acd271fdb8a70369c298c082.16= 37186628.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i3c/master/mipi-i3c-hci/dat_v1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c b/drivers/i3c/master/= mipi-i3c-hci/dat_v1.c index 783e551a2c85a..97bb49ff5b53b 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c +++ b/drivers/i3c/master/mipi-i3c-hci/dat_v1.c @@ -160,9 +160,7 @@ static int hci_dat_v1_get_index(struct i3c_hci *hci, u8= dev_addr) unsigned int dat_idx; u32 dat_w0; =20 - for (dat_idx =3D find_first_bit(hci->DAT_data, hci->DAT_entries); - dat_idx < hci->DAT_entries; - dat_idx =3D find_next_bit(hci->DAT_data, hci->DAT_entries, dat_idx))= { + for_each_set_bit(dat_idx, hci->DAT_data, hci->DAT_entries) { dat_w0 =3D dat_w0_read(dat_idx); if (FIELD_GET(DAT_0_DYNAMIC_ADDRESS, dat_w0) =3D=3D dev_addr) return dat_idx; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27A5AC433F5 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240186AbiCGJuo (ORCPT ); Mon, 7 Mar 2022 04:50:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240563AbiCGJlJ (ORCPT ); Mon, 7 Mar 2022 04:41: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 2B63919C26; Mon, 7 Mar 2022 01:37: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 dfw.source.kernel.org (Postfix) with ESMTPS id E5DFD61315; Mon, 7 Mar 2022 09:37:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB796C340E9; Mon, 7 Mar 2022 09:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645874; bh=txZiybrD915wwKLju2sxLOgQZmzPqRXIaL4AxPBJ8fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z/D7U+v8afo/mLEebYJKUEOdSZF4KEfEu10GAwZJ4EO17uyE9V8iqIeUXL80awLcL vHGhDZb1cXpwn5ZDLuI5+29vmOa5Ky5VKhC78osb4YFnsKSP2pY0EDoIrNwOsfwsVS w4DrYQWSihH709AP+IzL6QkCwHihzlsYNTZ2vpPQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Beau Belgrave , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 5.15 063/262] tracing: Do not let synth_events block other dyn_event systems during create Date: Mon, 7 Mar 2022 10:16:47 +0100 Message-Id: <20220307091704.285254438@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Beau Belgrave [ Upstream commit 4f67cca70c0f615e9cfe6ac42244f3416ec60877 ] synth_events is returning -EINVAL if the dyn_event create command does not contain ' \t'. This prevents other systems from getting called back. synth_events needs to return -ECANCELED in these cases when the command is not targeting the synth_event system. Link: https://lore.kernel.org/linux-trace-devel/20210930223821.11025-1-beau= b@linux.microsoft.com Fixes: c9e759b1e8456 ("tracing: Rework synthetic event command parsing") Reviewed-by: Masami Hiramatsu Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/trace/trace_events_synth.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_= synth.c index 22db3ce95e74f..8c26092db8dee 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -2053,6 +2053,13 @@ static int create_synth_event(const char *raw_comman= d) =20 last_cmd_set(raw_command); =20 + name =3D raw_command; + + /* Don't try to process if not our system */ + if (name[0] !=3D 's' || name[1] !=3D ':') + return -ECANCELED; + name +=3D 2; + p =3D strpbrk(raw_command, " \t"); if (!p) { synth_err(SYNTH_ERR_INVALID_CMD, 0); @@ -2061,12 +2068,6 @@ static int create_synth_event(const char *raw_comman= d) =20 fields =3D skip_spaces(p); =20 - name =3D raw_command; - - if (name[0] !=3D 's' || name[1] !=3D ':') - return -ECANCELED; - name +=3D 2; - /* This interface accepts group name prefix */ if (strchr(name, '/')) { len =3D str_has_prefix(name, SYNTH_SYSTEM "/"); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F49DC433FE for ; Mon, 7 Mar 2022 10:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239714AbiCGJ7z (ORCPT ); Mon, 7 Mar 2022 04:59:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240601AbiCGJlL (ORCPT ); Mon, 7 Mar 2022 04:41: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 20E734B412; Mon, 7 Mar 2022 01:37: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 3F24461185; Mon, 7 Mar 2022 09:37:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BFEFC340E9; Mon, 7 Mar 2022 09:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645877; bh=2obqsxI+/SH42dQ+X0D1aLLfemkok/28qdVTR7fdTIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vkXlIAYoXmIkxwstjhK32pG+WmHgGLR37qO70jLSOEFJY/ezqAHfBJD/yDOGZ3/be q4yLmJaR89d+Gn8pt4oGI+vOsY/c2qNRce1uz57nohAERsLxejAsqJFkOtgTZyc70k U2TJ8J5BH9srxkAgXiDlOp48Gy1ClMphxtZiO42M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dario Binacchi , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 064/262] Input: ti_am335x_tsc - set ADCREFM for X configuration Date: Mon, 7 Mar 2022 10:16:48 +0100 Message-Id: <20220307091704.312755928@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dario Binacchi [ Upstream commit 73cca71a903202cddc8279fc76b2da4995da5bea ] As reported by the STEPCONFIG[1-16] registered field descriptions of the TI reference manual, for the ADC "in single ended, SEL_INM_SWC_3_0 must be 1xxx". Unlike the Y and Z coordinates, this bit has not been set for the step configuration registers used to sample the X coordinate. Fixes: 1b8be32e6914 ("Input: add support for TI Touchscreen controller") Signed-off-by: Dario Binacchi Link: https://lore.kernel.org/r/20211212125358.14416-2-dariobin@libero.it Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/input/touchscreen/ti_am335x_tsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touc= hscreen/ti_am335x_tsc.c index 83e685557a197..fd3ffdd23470b 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -131,7 +131,8 @@ static void titsc_step_config(struct titsc *ts_dev) u32 stepenable; =20 config =3D STEPCONFIG_MODE_HWSYNC | - STEPCONFIG_AVG_16 | ts_dev->bit_xp; + STEPCONFIG_AVG_16 | ts_dev->bit_xp | + STEPCONFIG_INM_ADCREFM; switch (ts_dev->wires) { case 4: config |=3D STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 669D8C47081 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240382AbiCGJu7 (ORCPT ); Mon, 7 Mar 2022 04:50:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240646AbiCGJlW (ORCPT ); Mon, 7 Mar 2022 04:41:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06EA95F8F2; Mon, 7 Mar 2022 01:38: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 3D95F6128E; Mon, 7 Mar 2022 09:38:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 460B5C340F4; Mon, 7 Mar 2022 09:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645880; bh=nwhDRCmxaQ9ylnl0o8WM7gB9W7pbXqOdwinkHErgie8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WM4phyTYBuiRqboNYfQXa/KJOAw5t4PNz111SA4VoeSaPHPXTqQJqxDgOO3EKMia4 EsywdHHrYNkUGp3fD9OEnIyeMhypUed2zHxlW86jTXNhinjLRdaYScslb6bLWmvJzA CgcWZvJROSkxuIQG0yoSq+p40m6IE4MELOd8l6tY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dario Binacchi , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 065/262] Input: ti_am335x_tsc - fix STEPCONFIG setup for Z2 Date: Mon, 7 Mar 2022 10:16:49 +0100 Message-Id: <20220307091704.339869663@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dario Binacchi [ Upstream commit 6bfeb6c21e1bdc11c328b7d996d20f0f73c6b9b0 ] The Z2 step configuration doesn't erase the SEL_INP_SWC_3_0 bit-field before setting the ADC channel. This way its value could be corrupted by the ADC channel selected for the Z1 coordinate. Fixes: 8c896308feae ("input: ti_am335x_adc: use only FIFO0 and clean up a l= ittle") Signed-off-by: Dario Binacchi Link: https://lore.kernel.org/r/20211212125358.14416-3-dariobin@libero.it Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/input/touchscreen/ti_am335x_tsc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touc= hscreen/ti_am335x_tsc.c index fd3ffdd23470b..cfc943423241f 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -196,7 +196,10 @@ static void titsc_step_config(struct titsc *ts_dev) STEPCONFIG_OPENDLY); =20 end_step++; - config |=3D STEPCONFIG_INP(ts_dev->inp_yn); + config =3D STEPCONFIG_MODE_HWSYNC | + STEPCONFIG_AVG_16 | ts_dev->bit_yp | + ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM | + STEPCONFIG_INP(ts_dev->inp_yn); titsc_writel(ts_dev, REG_STEPCONFIG(end_step), config); titsc_writel(ts_dev, REG_STEPDELAY(end_step), STEPCONFIG_OPENDLY); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95140C433F5 for ; Mon, 7 Mar 2022 10:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239731AbiCGJ76 (ORCPT ); Mon, 7 Mar 2022 04:59:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240688AbiCGJl2 (ORCPT ); Mon, 7 Mar 2022 04:41:28 -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 7940550440; Mon, 7 Mar 2022 01:38: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 6EA4FB810D1; Mon, 7 Mar 2022 09:38:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3B33C340F3; Mon, 7 Mar 2022 09:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645884; bh=gR9Qsy0DHrQHAX3LlOQEhO5NH64Tn0o3wJWUrAWaPhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8nRTp+xPNNDfo4R15CA9syWxUKEe26fbA1lF2db4S3EOcyPM4lN2KrxpUNMgQ+IN Cn+qaPqtqCPRWf0Zux6fnAbq2tmle8Fe5jAmlJaflU7KIAy8I8rOR5/0AtwgqGei2V HIiFi4IiJUbcyEPQT79NS6F7PM0a8/xQ2u4I2/M8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 066/262] PCI: mvebu: Check for errors from pci_bridge_emul_init() call Date: Mon, 7 Mar 2022 10:16:50 +0100 Message-Id: <20220307091704.367272135@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 5d18d702e5c9309f4195653475c7a7fdde4ca71f ] Function pci_bridge_emul_init() may fail so correctly check for errors. Link: https://lore.kernel.org/r/20211125124605.25915-3-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 2dc6890dbcaa2..f4971fc72a772 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -570,7 +570,7 @@ static struct pci_bridge_emul_ops mvebu_pci_bridge_emul= _ops =3D { * Initialize the configuration space of the PCI-to-PCI bridge * associated with the given PCIe interface. */ -static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port) +static int mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port) { struct pci_bridge_emul *bridge =3D &port->bridge; u32 pcie_cap =3D mvebu_readl(port, PCIE_CAP_PCIEXP); @@ -597,7 +597,7 @@ static void mvebu_pci_bridge_emul_init(struct mvebu_pci= e_port *port) bridge->data =3D port; bridge->ops =3D &mvebu_pci_bridge_emul_ops; =20 - pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR); + return pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR); } =20 static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys) @@ -1120,9 +1120,18 @@ static int mvebu_pcie_probe(struct platform_device *= pdev) continue; } =20 + ret =3D mvebu_pci_bridge_emul_init(port); + if (ret < 0) { + dev_err(dev, "%s: cannot init emulated bridge\n", + port->name); + devm_iounmap(dev, port->base); + port->base =3D NULL; + mvebu_pcie_powerdown(port); + continue; + } + mvebu_pcie_setup_hw(port); mvebu_pcie_set_local_dev_nr(port, 1); - mvebu_pci_bridge_emul_init(port); } =20 pcie->nports =3D i; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FBA7C352AA for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240507AbiCGJvE (ORCPT ); Mon, 7 Mar 2022 04:51:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240769AbiCGJld (ORCPT ); Mon, 7 Mar 2022 04:41:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157E666AD7; Mon, 7 Mar 2022 01:38:12 -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 7F660B810CF; Mon, 7 Mar 2022 09:38:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8201C340E9; Mon, 7 Mar 2022 09:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645887; bh=Eh2WeKqTavGzTnH3f6/Gs+4fsRnL4WgUk8uScgtTKnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XagP2rc4YP4NphB6xYcQBiOXM/XokaitXh/Gbaga0U0+D+bbtLO+uOSuJ/j2g4m77 mr1JyO9o5HLaRFQPUxriUkAGME+Z2Eq6sT8YTDsT7shDTvuwEHha6cUPeFz+XBVWLY 2EAjyVOn/KQz1yhumARGuvJBFn/7FyBgk37zV0HY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 067/262] PCI: mvebu: Do not modify PCI IO type bits in conf_write Date: Mon, 7 Mar 2022 10:16:51 +0100 Message-Id: <20220307091704.394222002@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 2cf150216e5b5619d7c25180ccf2cc8ac7bebc13 ] PCI IO type bits are already initialized in mvebu_pci_bridge_emul_init() function and only when IO support is enabled. These type bits are read-only and pci-bridge-emul.c code already does not allow to modify them from upper layers. When IO support is disabled then all IO registers should be read-only and return zeros. Therefore do not modify PCI IO type bits in mvebu_pci_bridge_emul_base_conf_write() callback. Link: https://lore.kernel.org/r/20211125124605.25915-8-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index f4971fc72a772..5d5f23b1d355b 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -497,13 +497,6 @@ mvebu_pci_bridge_emul_base_conf_write(struct pci_bridg= e_emul *bridge, } =20 case PCI_IO_BASE: - /* - * We keep bit 1 set, it is a read-only bit that - * indicates we support 32 bits addressing for the - * I/O - */ - conf->iobase |=3D PCI_IO_RANGE_TYPE_32; - conf->iolimit |=3D PCI_IO_RANGE_TYPE_32; mvebu_pcie_handle_iobase_change(port); break; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0461EC35274 for ; Mon, 7 Mar 2022 09:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240684AbiCGJvO (ORCPT ); Mon, 7 Mar 2022 04:51:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240789AbiCGJle (ORCPT ); Mon, 7 Mar 2022 04:41:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183936A066; Mon, 7 Mar 2022 01:38: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 B970E611D5; Mon, 7 Mar 2022 09:38:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0B0AC340E9; Mon, 7 Mar 2022 09:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645890; bh=8H1O5Gd8aWDSuSOPM7T7kVZcc3Rbn5AoTu7LfcSiU3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gw4BipxD8M6uPRSqIwxZfgwOrgamlXOhCdYSK9y53hX6ONHgLZcZEfS6QeC1eXTbL u4k503wwAzqVrnqcYhUBlPzPP6ui1dBX2IF7h15gyVEDvyMzcAcAT6K3aYX1GAFFUZ hjFyXEA+hnXThWYqb9xyDrCbYBu2Gkp7/S38QXhM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 068/262] PCI: mvebu: Fix support for bus mastering and PCI_COMMAND on emulated bridge Date: Mon, 7 Mar 2022 10:16:52 +0100 Message-Id: <20220307091704.421592444@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit e42b85583719adb87ab88dc7bcd41b38011f7d11 ] According to PCI specifications bits [0:2] of Command Register, this should be by default disabled on reset. So explicitly disable these bits at early beginning of driver initialization. Also remove code which unconditionally enables all 3 bits and let kernel code (via pci_set_master() function) to handle bus mastering of PCI Bridge via emulated PCI_COMMAND on emulated bridge. Adjust existing functions mvebu_pcie_handle_iobase_change() and mvebu_pcie_handle_membase_change() to handle PCI_IO_BASE and PCI_MEM_BASE registers correctly even when bus mastering on emulated bridge is disabled. Link: https://lore.kernel.org/r/20211125124605.25915-7-pali@kernel.org Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 52 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 5d5f23b1d355b..2e69455400288 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -215,16 +215,14 @@ static void mvebu_pcie_setup_hw(struct mvebu_pcie_por= t *port) { u32 cmd, mask; =20 - /* Point PCIe unit MBUS decode windows to DRAM space. */ - mvebu_pcie_setup_wins(port); - - /* Master + slave enable. */ + /* Disable Root Bridge I/O space, memory space and bus mastering. */ cmd =3D mvebu_readl(port, PCIE_CMD_OFF); - cmd |=3D PCI_COMMAND_IO; - cmd |=3D PCI_COMMAND_MEMORY; - cmd |=3D PCI_COMMAND_MASTER; + cmd &=3D ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); mvebu_writel(port, cmd, PCIE_CMD_OFF); =20 + /* Point PCIe unit MBUS decode windows to DRAM space. */ + mvebu_pcie_setup_wins(port); + /* Enable interrupt lines A-D. */ mask =3D mvebu_readl(port, PCIE_MASK_OFF); mask |=3D PCIE_MASK_ENABLE_INTS; @@ -371,8 +369,7 @@ static void mvebu_pcie_handle_iobase_change(struct mveb= u_pcie_port *port) =20 /* Are the new iobase/iolimit values invalid? */ if (conf->iolimit < conf->iobase || - conf->iolimitupper < conf->iobaseupper || - !(conf->command & PCI_COMMAND_IO)) { + conf->iolimitupper < conf->iobaseupper) { mvebu_pcie_set_window(port, port->io_target, port->io_attr, &desired, &port->iowin); return; @@ -409,8 +406,7 @@ static void mvebu_pcie_handle_membase_change(struct mve= bu_pcie_port *port) struct pci_bridge_emul_conf *conf =3D &port->bridge.conf; =20 /* Are the new membase/memlimit values invalid? */ - if (conf->memlimit < conf->membase || - !(conf->command & PCI_COMMAND_MEMORY)) { + if (conf->memlimit < conf->membase) { mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, &desired, &port->memwin); return; @@ -430,6 +426,24 @@ static void mvebu_pcie_handle_membase_change(struct mv= ebu_pcie_port *port) &port->memwin); } =20 +static pci_bridge_emul_read_status_t +mvebu_pci_bridge_emul_base_conf_read(struct pci_bridge_emul *bridge, + int reg, u32 *value) +{ + struct mvebu_pcie_port *port =3D bridge->data; + + switch (reg) { + case PCI_COMMAND: + *value =3D mvebu_readl(port, PCIE_CMD_OFF); + break; + + default: + return PCI_BRIDGE_EMUL_NOT_HANDLED; + } + + return PCI_BRIDGE_EMUL_HANDLED; +} + static pci_bridge_emul_read_status_t mvebu_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, int reg, u32 *value) @@ -484,17 +498,14 @@ mvebu_pci_bridge_emul_base_conf_write(struct pci_brid= ge_emul *bridge, =20 switch (reg) { case PCI_COMMAND: - { - if (!mvebu_has_ioport(port)) - conf->command &=3D ~PCI_COMMAND_IO; - - if ((old ^ new) & PCI_COMMAND_IO) - mvebu_pcie_handle_iobase_change(port); - if ((old ^ new) & PCI_COMMAND_MEMORY) - mvebu_pcie_handle_membase_change(port); + if (!mvebu_has_ioport(port)) { + conf->command =3D cpu_to_le16( + le16_to_cpu(conf->command) & ~PCI_COMMAND_IO); + new &=3D ~PCI_COMMAND_IO; + } =20 + mvebu_writel(port, new, PCIE_CMD_OFF); break; - } =20 case PCI_IO_BASE: mvebu_pcie_handle_iobase_change(port); @@ -554,6 +565,7 @@ mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridge= _emul *bridge, } =20 static struct pci_bridge_emul_ops mvebu_pci_bridge_emul_ops =3D { + .read_base =3D mvebu_pci_bridge_emul_base_conf_read, .write_base =3D mvebu_pci_bridge_emul_base_conf_write, .read_pcie =3D mvebu_pci_bridge_emul_pcie_conf_read, .write_pcie =3D mvebu_pci_bridge_emul_pcie_conf_write, --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8A6EC352B6 for ; Mon, 7 Mar 2022 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240564AbiCGJvJ (ORCPT ); Mon, 7 Mar 2022 04:51:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240785AbiCGJle (ORCPT ); Mon, 7 Mar 2022 04:41:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1695C673F9; Mon, 7 Mar 2022 01:38: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 B9DA561052; Mon, 7 Mar 2022 09:38:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5B7FC340E9; Mon, 7 Mar 2022 09:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645893; bh=9/buMwFS7Y8UssTi4NtLWSigzMdyRLdbfYR//WrF/1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiq/QFS7TPFTr06dGSefvn835Ha9qAnbW34K8MvjlU1PgnVLhQxXnxwPOd2iI432X CNT5sAC5nW6z2mIDtxNNhN0oCPu2QWwq62iTNbk6AswVLOirm+A+ectRiBhI/edRDj aEqAmVgBt2XV7B2+l+md/Raz9Y5CevqsMyLvD9Mo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 069/262] PCI: mvebu: Fix configuring secondary bus of PCIe Root Port via emulated bridge Date: Mon, 7 Mar 2022 10:16:53 +0100 Message-Id: <20220307091704.448542471@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 91a8d79fc797d3486ae978beebdfc55261c7d65b ] It looks like that mvebu PCIe controller has for each PCIe link fully independent PCIe host bridge and so every PCIe Root Port is isolated not only on its own bus but also isolated from each others. But in past device tree structure was defined to put all PCIe Root Ports (as PCI Bridge devices) into one root bus 0 and this bus is emulated by pci-mvebu.c driver. Probably reason for this decision was incorrect understanding of PCIe topology of these Armada SoCs and also reason of misunderstanding how is PCIe controller generating Type 0 and Type 1 config requests (it is fully different compared to other drivers). Probably incorrect setup leaded to very surprised things like having PCIe Root Port (PCI Bridge device, with even incorrect Device Class set to Memory Controller) and the PCIe device behind the Root Port on the same PCI bus, which obviously was needed to somehow hack (as these two devices cannot be in reality on the same bus). Properly set mvebu local bus number and mvebu local device number based on PCI Bridge secondary bus number configuration. Also correctly report configured secondary bus number in config space. And explain in driver comment why this setup is correct. Link: https://lore.kernel.org/r/20211125124605.25915-12-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 99 +++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 2e69455400288..76f35d0773b79 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -125,6 +125,11 @@ static bool mvebu_pcie_link_up(struct mvebu_pcie_port = *port) return !(mvebu_readl(port, PCIE_STAT_OFF) & PCIE_STAT_LINK_DOWN); } =20 +static u8 mvebu_pcie_get_local_bus_nr(struct mvebu_pcie_port *port) +{ + return (mvebu_readl(port, PCIE_STAT_OFF) & PCIE_STAT_BUS) >> 8; +} + static void mvebu_pcie_set_local_bus_nr(struct mvebu_pcie_port *port, int = nr) { u32 stat; @@ -437,6 +442,20 @@ mvebu_pci_bridge_emul_base_conf_read(struct pci_bridge= _emul *bridge, *value =3D mvebu_readl(port, PCIE_CMD_OFF); break; =20 + case PCI_PRIMARY_BUS: { + /* + * From the whole 32bit register we support reading from HW only + * secondary bus number which is mvebu local bus number. + * Other bits are retrieved only from emulated config buffer. + */ + __le32 *cfgspace =3D (__le32 *)&bridge->conf; + u32 val =3D le32_to_cpu(cfgspace[PCI_PRIMARY_BUS / 4]); + val &=3D ~0xff00; + val |=3D mvebu_pcie_get_local_bus_nr(port) << 8; + *value =3D val; + break; + } + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -520,7 +539,8 @@ mvebu_pci_bridge_emul_base_conf_write(struct pci_bridge= _emul *bridge, break; =20 case PCI_PRIMARY_BUS: - mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus); + if (mask & 0xff00) + mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus); break; =20 default: @@ -1135,8 +1155,83 @@ static int mvebu_pcie_probe(struct platform_device *= pdev) continue; } =20 + /* + * PCIe topology exported by mvebu hw is quite complicated. In + * reality has something like N fully independent host bridges + * where each host bridge has one PCIe Root Port (which acts as + * PCI Bridge device). Each host bridge has its own independent + * internal registers, independent access to PCI config space, + * independent interrupt lines, independent window and memory + * access configuration. But additionally there is some kind of + * peer-to-peer support between PCIe devices behind different + * host bridges limited just to forwarding of memory and I/O + * transactions (forwarding of error messages and config cycles + * is not supported). So we could say there are N independent + * PCIe Root Complexes. + * + * For this kind of setup DT should have been structured into + * N independent PCIe controllers / host bridges. But instead + * structure in past was defined to put PCIe Root Ports of all + * host bridges into one bus zero, like in classic multi-port + * Root Complex setup with just one host bridge. + * + * This means that pci-mvebu.c driver provides "virtual" bus 0 + * on which registers all PCIe Root Ports (PCI Bridge devices) + * specified in DT by their BDF addresses and virtually routes + * PCI config access of each PCI bridge device to specific PCIe + * host bridge. + * + * Normally PCI Bridge should choose between Type 0 and Type 1 + * config requests based on primary and secondary bus numbers + * configured on the bridge itself. But because mvebu PCI Bridge + * does not have registers for primary and secondary bus numbers + * in its config space, it determinates type of config requests + * via its own custom way. + * + * There are two options how mvebu determinate type of config + * request. + * + * 1. If Secondary Bus Number Enable bit is not set or is not + * available (applies for pre-XP PCIe controllers) then Type 0 + * is used if target bus number equals Local Bus Number (bits + * [15:8] in register 0x1a04) and target device number differs + * from Local Device Number (bits [20:16] in register 0x1a04). + * Type 1 is used if target bus number differs from Local Bus + * Number. And when target bus number equals Local Bus Number + * and target device equals Local Device Number then request is + * routed to Local PCI Bridge (PCIe Root Port). + * + * 2. If Secondary Bus Number Enable bit is set (bit 7 in + * register 0x1a2c) then mvebu hw determinate type of config + * request like compliant PCI Bridge based on primary bus number + * which is configured via Local Bus Number (bits [15:8] in + * register 0x1a04) and secondary bus number which is configured + * via Secondary Bus Number (bits [7:0] in register 0x1a2c). + * Local PCI Bridge (PCIe Root Port) is available on primary bus + * as device with Local Device Number (bits [20:16] in register + * 0x1a04). + * + * Secondary Bus Number Enable bit is disabled by default and + * option 2. is not available on pre-XP PCIe controllers. Hence + * this driver always use option 1. + * + * Basically it means that primary and secondary buses shares + * one virtual number configured via Local Bus Number bits and + * Local Device Number bits determinates if accessing primary + * or secondary bus. Set Local Device Number to 1 and redirect + * all writes of PCI Bridge Secondary Bus Number register to + * Local Bus Number (bits [15:8] in register 0x1a04). + * + * So when accessing devices on buses behind secondary bus + * number it would work correctly. And also when accessing + * device 0 at secondary bus number via config space would be + * correctly routed to secondary bus. Due to issues described + * in mvebu_pcie_setup_hw(), PCI Bridges at primary bus (zero) + * are not accessed directly via PCI config space but rarher + * indirectly via kernel emulated PCI bridge driver. + */ mvebu_pcie_setup_hw(port); - mvebu_pcie_set_local_dev_nr(port, 1); + mvebu_pcie_set_local_dev_nr(port, 0); } =20 pcie->nports =3D i; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E355BC433F5 for ; Mon, 7 Mar 2022 10:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236170AbiCGKCN (ORCPT ); Mon, 7 Mar 2022 05:02:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240836AbiCGJlh (ORCPT ); Mon, 7 Mar 2022 04:41:37 -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 C292933A14; Mon, 7 Mar 2022 01:38: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 5E9EF6116E; Mon, 7 Mar 2022 09:38:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58EE3C340E9; Mon, 7 Mar 2022 09:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645899; bh=767pS48mze7kEkVmJgO5FSWffwNgEcf7SCPcoCPnOfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QCUDvp3m+NUFiWX4YUxJZd6bLme/noDBLv/jqvQ6izxe2x6mM8CP2IWKenKa7CboZ Pp+xedgWzLfYuDSbS28Isv8+U/RUyWQKvzYBWTioo/Iql6ktIm7X+rmiPBEZwDw01Q Ll2jUOismdh8+p9qDuYFz8NSdHgLxhqbHhKxgC+4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 070/262] PCI: mvebu: Setup PCIe controller to Root Complex mode Date: Mon, 7 Mar 2022 10:16:54 +0100 Message-Id: <20220307091704.475773855@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit df08ac016124bd88b8598ac0599d7b89c0642774 ] This driver operates only in Root Complex mode, so ensure that hardware is properly configured in Root Complex mode. Link: https://lore.kernel.org/r/20211125124605.25915-10-pali@kernel.org Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 76f35d0773b79..e2d4bd8442a80 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -55,6 +55,7 @@ #define PCIE_MASK_ENABLE_INTS 0x0f000000 #define PCIE_CTRL_OFF 0x1a00 #define PCIE_CTRL_X1_MODE 0x0001 +#define PCIE_CTRL_RC_MODE BIT(1) #define PCIE_STAT_OFF 0x1a04 #define PCIE_STAT_BUS 0xff00 #define PCIE_STAT_DEV 0x1f0000 @@ -218,7 +219,12 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_po= rt *port) =20 static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port) { - u32 cmd, mask; + u32 ctrl, cmd, mask; + + /* Setup PCIe controller to Root Complex mode. */ + ctrl =3D mvebu_readl(port, PCIE_CTRL_OFF); + ctrl |=3D PCIE_CTRL_RC_MODE; + mvebu_writel(port, ctrl, PCIE_CTRL_OFF); =20 /* Disable Root Bridge I/O space, memory space and bus mastering. */ cmd =3D mvebu_readl(port, PCIE_CMD_OFF); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E1A5C4332F for ; Mon, 7 Mar 2022 10:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238716AbiCGKC0 (ORCPT ); Mon, 7 Mar 2022 05:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240842AbiCGJlh (ORCPT ); Mon, 7 Mar 2022 04:41:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F7D66B08C; Mon, 7 Mar 2022 01:38: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 F3F1C6128E; Mon, 7 Mar 2022 09:38:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E50ECC340E9; Mon, 7 Mar 2022 09:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645903; bh=YU1Vn6+28zS0qXcWI5p6LeDttNBRhF0fSEo7j/aBBGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sW2a9lxbx8HSDhdjmGj/oOtV3dcZWvtQHwF7zQ8e2P4bKfRAg6l+rsJqs2niDQDx/ W4bxK96EWbQsmPZG1TNJYLNXLIr+2oQfy/UeQjFonXYio9ZK8YDjl8Ke4oJUVSZLlC ygg507CgwPFb8x4tOQeTZptzsMBxA31Dsvfu/Yk4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 071/262] PCI: mvebu: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge Date: Mon, 7 Mar 2022 10:16:55 +0100 Message-Id: <20220307091704.502609814@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit d75404cc08832206f173668bd35391c581fea121 ] Hardware supports PCIe Hot Reset via PCIE_CTRL_OFF register. Use it for implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL register on emulated bridge. With this change the function pci_reset_secondary_bus() starts working and can reset connected PCIe card. Link: https://lore.kernel.org/r/20211125124605.25915-13-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index e2d4bd8442a80..3563301e772ae 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -56,6 +56,7 @@ #define PCIE_CTRL_OFF 0x1a00 #define PCIE_CTRL_X1_MODE 0x0001 #define PCIE_CTRL_RC_MODE BIT(1) +#define PCIE_CTRL_MASTER_HOT_RESET BIT(24) #define PCIE_STAT_OFF 0x1a04 #define PCIE_STAT_BUS 0xff00 #define PCIE_STAT_DEV 0x1f0000 @@ -462,6 +463,22 @@ mvebu_pci_bridge_emul_base_conf_read(struct pci_bridge= _emul *bridge, break; } =20 + case PCI_INTERRUPT_LINE: { + /* + * From the whole 32bit register we support reading from HW only + * one bit: PCI_BRIDGE_CTL_BUS_RESET. + * Other bits are retrieved only from emulated config buffer. + */ + __le32 *cfgspace =3D (__le32 *)&bridge->conf; + u32 val =3D le32_to_cpu(cfgspace[PCI_INTERRUPT_LINE / 4]); + if (mvebu_readl(port, PCIE_CTRL_OFF) & PCIE_CTRL_MASTER_HOT_RESET) + val |=3D PCI_BRIDGE_CTL_BUS_RESET << 16; + else + val &=3D ~(PCI_BRIDGE_CTL_BUS_RESET << 16); + *value =3D val; + break; + } + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -549,6 +566,17 @@ mvebu_pci_bridge_emul_base_conf_write(struct pci_bridg= e_emul *bridge, mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus); break; =20 + case PCI_INTERRUPT_LINE: + if (mask & (PCI_BRIDGE_CTL_BUS_RESET << 16)) { + u32 ctrl =3D mvebu_readl(port, PCIE_CTRL_OFF); + if (new & (PCI_BRIDGE_CTL_BUS_RESET << 16)) + ctrl |=3D PCIE_CTRL_MASTER_HOT_RESET; + else + ctrl &=3D ~PCIE_CTRL_MASTER_HOT_RESET; + mvebu_writel(port, ctrl, PCIE_CTRL_OFF); + } + break; + default: break; } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 344C4C4332F for ; Mon, 7 Mar 2022 10:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238853AbiCGKCp (ORCPT ); Mon, 7 Mar 2022 05:02:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240873AbiCGJli (ORCPT ); Mon, 7 Mar 2022 04:41:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17406B094; Mon, 7 Mar 2022 01:38: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 2EEB8B810CF; Mon, 7 Mar 2022 09:38:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62041C340E9; Mon, 7 Mar 2022 09:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645906; bh=ZTvWv+f7xdGh/iyHa1ekwbqb+LeXwVZZsUofm01tb8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnH9c6Z+Apu7pGLtAlDVMhfCxPowYmk5NtzKHJsFowkro7hqAnJ+AGrEI5eT8wkyd K93PQ/qKEM4ep4yiOnfcJgdmlKz8MXWNS/mjoXuCM0hSMDUzo6Cyb5RhdmpazcaL1z DuJOObzEBD/TxvQ7MKpotTx5Yw52nWq/DqmxmsLo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 072/262] PCI: mvebu: Fix support for PCI_EXP_DEVCTL on emulated bridge Date: Mon, 7 Mar 2022 10:16:56 +0100 Message-Id: <20220307091704.530226403@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit ecae073e393e65ee7be7ebf3fdd5258ab99f1636 ] Comment in Armada 370 functional specification is misleading. PCI_EXP_DEVCTL_*RE bits are supported and configures receiving of error interrupts. Link: https://lore.kernel.org/r/20211125124605.25915-14-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 3563301e772ae..6100608e6413e 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -498,9 +498,7 @@ mvebu_pci_bridge_emul_pcie_conf_read(struct pci_bridge_= emul *bridge, break; =20 case PCI_EXP_DEVCTL: - *value =3D mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL) & - ~(PCI_EXP_DEVCTL_URRE | PCI_EXP_DEVCTL_FERE | - PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_CERE); + *value =3D mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL); break; =20 case PCI_EXP_LNKCAP: @@ -590,13 +588,6 @@ mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridg= e_emul *bridge, =20 switch (reg) { case PCI_EXP_DEVCTL: - /* - * Armada370 data says these bits must always - * be zero when in root complex mode. - */ - new &=3D ~(PCI_EXP_DEVCTL_URRE | PCI_EXP_DEVCTL_FERE | - PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_CERE); - mvebu_writel(port, new, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL); break; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5ED0C43217 for ; Mon, 7 Mar 2022 10:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233116AbiCGKCk (ORCPT ); Mon, 7 Mar 2022 05:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240874AbiCGJli (ORCPT ); Mon, 7 Mar 2022 04:41:38 -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 0656F6B0A4; Mon, 7 Mar 2022 01:38: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 9D96C61052; Mon, 7 Mar 2022 09:38:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C104C340E9; Mon, 7 Mar 2022 09:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645910; bh=+ydD8jfkmQrg22C8MDPUxGUem+btIMG6oKkZUd0OCME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m/eoOW00yOQ8zbcI+cX/TH45Fujfxysw6gdwM0z+N3hcb5csFTvbnCqaKFre+AGCv QLwpiEnDW80sss5lD09tyqJb1PxabWmbte9PARr/yAhX8w78OvR+ZQnw770SJa5yJq 82Im1DHw8cUUQaXe4n9kqd9wMUBhde6LuzUHD3qk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 073/262] PCI: mvebu: Fix support for PCI_EXP_RTSTA on emulated bridge Date: Mon, 7 Mar 2022 10:16:57 +0100 Message-Id: <20220307091704.556896173@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 838ff44a398ff47fe9b924961d91aee325821220 ] PME Status bit in Root Status Register (PCIE_RC_RTSTA_OFF) is read-only and can be cleared only by writing 0b to the Interrupt Cause RW0C register (PCIE_INT_CAUSE_OFF). Link: https://lore.kernel.org/r/20211125124605.25915-15-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index 6100608e6413e..b690768d5a413 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -51,6 +51,8 @@ PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where) | \ PCIE_CONF_ADDR_EN) #define PCIE_CONF_DATA_OFF 0x18fc +#define PCIE_INT_CAUSE_OFF 0x1900 +#define PCIE_INT_PM_PME BIT(28) #define PCIE_MASK_OFF 0x1910 #define PCIE_MASK_ENABLE_INTS 0x0f000000 #define PCIE_CTRL_OFF 0x1a00 @@ -604,7 +606,14 @@ mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridg= e_emul *bridge, break; =20 case PCI_EXP_RTSTA: - mvebu_writel(port, new, PCIE_RC_RTSTA); + /* + * PME Status bit in Root Status Register (PCIE_RC_RTSTA) + * is read-only and can be cleared only by writing 0b to the + * Interrupt Cause RW0C register (PCIE_INT_CAUSE_OFF). So + * clear PME via Interrupt Cause. + */ + if (new & PCI_EXP_RTSTA_PME) + mvebu_writel(port, ~PCIE_INT_PM_PME, PCIE_INT_CAUSE_OFF); break; } } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0ECDC433F5 for ; Mon, 7 Mar 2022 09:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234801AbiCGJvX (ORCPT ); Mon, 7 Mar 2022 04:51:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240881AbiCGJlj (ORCPT ); Mon, 7 Mar 2022 04:41:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F6E26AA5C; Mon, 7 Mar 2022 01:38: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 847576116E; Mon, 7 Mar 2022 09:38:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880D9C340E9; Mon, 7 Mar 2022 09:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645912; bh=wxtsX5+trDGKaAuQRjEP830qBdsbiq53aku4x6QZ0Qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZARjuEHJ2sR8kg95ZATUlZDyX16Mxvn8ejcYfti1a4Lb0ra4Uwn/Aa5yDDJdC9/hj dGYDu8g7pk2VQcm5TrfHoIUsAfZDG1wvHT9WsqPaWrjXJt61bCPygYupBP/dMqs/aW gm/wfd82sUNx8aJaste6y24X/W/eK0zfFoLm67Jw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.15 074/262] PCI: mvebu: Fix support for DEVCAP2, DEVCTL2 and LNKCTL2 registers on emulated bridge Date: Mon, 7 Mar 2022 10:16:58 +0100 Message-Id: <20220307091704.584066309@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Pali Roh=C3=A1r [ Upstream commit 4ab34548c55fbbb3898306a47dfaccd4860e1ccb ] Armada XP and new hardware supports access to DEVCAP2, DEVCTL2 and LNKCTL2 configuration registers of PCIe core via PCIE_CAP_PCIEXP. So export them via emulated software root bridge. Pre-XP hardware does not support these registers and returns zeros. Link: https://lore.kernel.org/r/20211125124605.25915-16-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config spa= ce") Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/pci/controller/pci-mvebu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pc= i-mvebu.c index b690768d5a413..357e9a293edf7 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -524,6 +524,18 @@ mvebu_pci_bridge_emul_pcie_conf_read(struct pci_bridge= _emul *bridge, *value =3D mvebu_readl(port, PCIE_RC_RTSTA); break; =20 + case PCI_EXP_DEVCAP2: + *value =3D mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCAP2); + break; + + case PCI_EXP_DEVCTL2: + *value =3D mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL2); + break; + + case PCI_EXP_LNKCTL2: + *value =3D mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL2); + break; + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -615,6 +627,17 @@ mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridg= e_emul *bridge, if (new & PCI_EXP_RTSTA_PME) mvebu_writel(port, ~PCIE_INT_PM_PME, PCIE_INT_CAUSE_OFF); break; + + case PCI_EXP_DEVCTL2: + mvebu_writel(port, new, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL2); + break; + + case PCI_EXP_LNKCTL2: + mvebu_writel(port, new, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL2); + break; + + default: + break; } } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3221C43219 for ; Mon, 7 Mar 2022 09:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237980AbiCGJvd (ORCPT ); Mon, 7 Mar 2022 04:51:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240902AbiCGJlk (ORCPT ); Mon, 7 Mar 2022 04:41:40 -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 150A16B093; Mon, 7 Mar 2022 01:38: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 8A7E861052; Mon, 7 Mar 2022 09:38:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C43C340E9; Mon, 7 Mar 2022 09:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645916; bh=cyWzbIxql255JUsXipN0FGy6Xn/m+PPh2sgzaVi+aJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uC4KOyf2PRbMu4mPH4xX8j97UXlHJbUdeg1Al6iWZVHHScEUcnsZN5shIwG7y4riK iJSjn0Fid1HvmkIyjsPH5nkor8Ln4DQl1bzFAgMMqydQ1CNBVYm5Jh9g/3bMcgHcpJ fluUEmxE2Yts7hgbOUdq981uosUUyha0qtbqEIeo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rick Macklem , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 075/262] NFSD: Fix verifier returned in stable WRITEs Date: Mon, 7 Mar 2022 10:16:59 +0100 Message-Id: <20220307091704.611403510@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit f11ad7aa653130b71e2e89bed207f387718216d5 ] RFC 8881 explains the purpose of the write verifier this way: > The final portion of the result is the field writeverf. This field > is the write verifier and is a cookie that the client can use to > determine whether a server has changed instance state (e.g., server > restart) between a call to WRITE and a subsequent call to either > WRITE or COMMIT. But then it says: > This cookie MUST be unchanged during a single instance of the > NFSv4.1 server and MUST be unique between instances of the NFSv4.1 > server. If the cookie changes, then the client MUST assume that > any data written with an UNSTABLE4 value for committed and an old > writeverf in the reply has been lost and will need to be > recovered. RFC 1813 has similar language for NFSv3. NFSv2 does not have a write verifier since it doesn't implement the COMMIT procedure. Since commit 19e0663ff9bc ("nfsd: Ensure sampling of the write verifier is atomic with the write"), the Linux NFS server has returned a boot-time-based verifier for UNSTABLE WRITEs, but a zero verifier for FILE_SYNC and DATA_SYNC WRITEs. FILE_SYNC and DATA_SYNC WRITEs are not followed up with a COMMIT, so there's no need for clients to compare verifiers for stable writes. However, by returning a different verifier for stable and unstable writes, the above commit puts the Linux NFS server a step farther out of compliance with the first MUST above. At least one NFS client (FreeBSD) noticed the difference, making this a potential regression. Reported-by: Rick Macklem Link: https://lore.kernel.org/linux-nfs/YQXPR0101MB096857EEACF04A6DF1FC6D9B= DD749@YQXPR0101MB0968.CANPRD01.PROD.OUTLOOK.COM/T/ Fixes: 19e0663ff9bc ("nfsd: Ensure sampling of the write verifier is atomic= with the write") Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/nfsd/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 78df038434124..271f7c15d6e52 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -993,6 +993,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *= fhp, struct nfsd_file *nf, iov_iter_kvec(&iter, WRITE, vec, vlen, *cnt); if (flags & RWF_SYNC) { down_write(&nf->nf_rwsem); + if (verf) + nfsd_copy_boot_verifier(verf, + net_generic(SVC_NET(rqstp), + nfsd_net_id)); host_err =3D vfs_iter_write(file, &iter, &pos, flags); if (host_err < 0) nfsd_reset_boot_verifier(net_generic(SVC_NET(rqstp), --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E9AFC433EF for ; Mon, 7 Mar 2022 09:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238258AbiCGJvm (ORCPT ); Mon, 7 Mar 2022 04:51:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240926AbiCGJll (ORCPT ); Mon, 7 Mar 2022 04:41:41 -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 897526B0B0; Mon, 7 Mar 2022 01:38: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 4055AB810CF; Mon, 7 Mar 2022 09:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A79A3C340E9; Mon, 7 Mar 2022 09:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645919; bh=+Bkcp0VCYZzyHwRdT0c8Yl/OQ/o5Uwu0mG4gMVfVeC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2T2qPKZMQ55Dlg/nuXUyRQU/Ymi0pVWQ7TqELTf79pUS+bHMDQ66GKdjcY6Ta1mu6 XEsIACRD7s7ya7j5UQhInLbELSZ2CnRVwSatSgqGQeP81lGtWLK2DZE8prDCjBhItX aH0pFJ5nmF7oFvk0w/U4xkkF/X6O9WhlqMa6e9z0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Sasha Levin Subject: [PATCH 5.15 076/262] Revert "nfsd: skip some unnecessary stats in the v4 case" Date: Mon, 7 Mar 2022 10:17:00 +0100 Message-Id: <20220307091704.638467217@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit 58f258f65267542959487dbe8b5641754411843d ] On the wire, I observed NFSv4 OPEN(CREATE) operations sometimes returning a reasonable-looking value in the cinfo.before field and zero in the cinfo.after field. RFC 8881 Section 10.8.1 says: > When a client is making changes to a given directory, it needs to > determine whether there have been changes made to the directory by > other clients. It does this by using the change attribute as > reported before and after the directory operation in the associated > change_info4 value returned for the operation. and > ... The post-operation change > value needs to be saved as the basis for future change_info4 > comparisons. A good quality client implementation therefore saves the zero cinfo.after value. During a subsequent OPEN operation, it will receive a different non-zero value in the cinfo.before field for that directory, and it will incorrectly believe the directory has changed, triggering an undesirable directory cache invalidation. There are filesystem types where fs_supports_change_attribute() returns false, tmpfs being one. On NFSv4 mounts, this means the fh_getattr() call site in fill_pre_wcc() and fill_post_wcc() is never invoked. Subsequently, nfsd4_change_attribute() is invoked with an uninitialized @stat argument. In fill_pre_wcc(), @stat contains stale stack garbage, which is then placed on the wire. In fill_post_wcc(), ->fh_post_wc is all zeroes, so zero is placed on the wire. Both of these values are meaningless. This fix can be applied immediately to stable kernels. Once there are more regression tests in this area, this optimization can be attempted again. Fixes: 428a23d2bf0c ("nfsd: skip some unnecessary stats in the v4 case") Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs3xdr.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 0ee156b9c9d71..48d4f99b7f901 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -487,11 +487,6 @@ svcxdr_encode_wcc_data(struct svc_rqst *rqstp, struct = xdr_stream *xdr, return true; } =20 -static bool fs_supports_change_attribute(struct super_block *sb) -{ - return sb->s_flags & SB_I_VERSION || sb->s_export_op->fetch_iversion; -} - /* * Fill in the pre_op attr for the wcc data */ @@ -500,26 +495,24 @@ void fill_pre_wcc(struct svc_fh *fhp) struct inode *inode; struct kstat stat; bool v4 =3D (fhp->fh_maxsize =3D=3D NFS4_FHSIZE); + __be32 err; =20 if (fhp->fh_no_wcc || fhp->fh_pre_saved) return; inode =3D d_inode(fhp->fh_dentry); - if (fs_supports_change_attribute(inode->i_sb) || !v4) { - __be32 err =3D fh_getattr(fhp, &stat); - - if (err) { - /* Grab the times from inode anyway */ - stat.mtime =3D inode->i_mtime; - stat.ctime =3D inode->i_ctime; - stat.size =3D inode->i_size; - } - fhp->fh_pre_mtime =3D stat.mtime; - fhp->fh_pre_ctime =3D stat.ctime; - fhp->fh_pre_size =3D stat.size; + err =3D fh_getattr(fhp, &stat); + if (err) { + /* Grab the times from inode anyway */ + stat.mtime =3D inode->i_mtime; + stat.ctime =3D inode->i_ctime; + stat.size =3D inode->i_size; } if (v4) fhp->fh_pre_change =3D nfsd4_change_attribute(&stat, inode); =20 + fhp->fh_pre_mtime =3D stat.mtime; + fhp->fh_pre_ctime =3D stat.ctime; + fhp->fh_pre_size =3D stat.size; fhp->fh_pre_saved =3D true; } =20 @@ -530,6 +523,7 @@ void fill_post_wcc(struct svc_fh *fhp) { bool v4 =3D (fhp->fh_maxsize =3D=3D NFS4_FHSIZE); struct inode *inode =3D d_inode(fhp->fh_dentry); + __be32 err; =20 if (fhp->fh_no_wcc) return; @@ -537,16 +531,12 @@ void fill_post_wcc(struct svc_fh *fhp) if (fhp->fh_post_saved) printk("nfsd: inode locked twice during operation.\n"); =20 - fhp->fh_post_saved =3D true; - - if (fs_supports_change_attribute(inode->i_sb) || !v4) { - __be32 err =3D fh_getattr(fhp, &fhp->fh_post_attr); - - if (err) { - fhp->fh_post_saved =3D false; - fhp->fh_post_attr.ctime =3D inode->i_ctime; - } - } + err =3D fh_getattr(fhp, &fhp->fh_post_attr); + if (err) { + fhp->fh_post_saved =3D false; + fhp->fh_post_attr.ctime =3D inode->i_ctime; + } else + fhp->fh_post_saved =3D true; if (v4) fhp->fh_post_change =3D nfsd4_change_attribute(&fhp->fh_post_attr, inode); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82000C41535 for ; Mon, 7 Mar 2022 10:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238990AbiCGKCz (ORCPT ); Mon, 7 Mar 2022 05:02:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240938AbiCGJlm (ORCPT ); Mon, 7 Mar 2022 04:41:42 -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 884CD5B893; Mon, 7 Mar 2022 01:38: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 1D0BA6116E; Mon, 7 Mar 2022 09:38:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE02C340F3; Mon, 7 Mar 2022 09:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645922; bh=3/kkwC3GonZthDwBJEBTO1peZX/rHod02QG4EBjZFYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDpYAQgN+JdKvL8Qj9uBcFcTZE9Hee+S4DwnbKbA6FrFrP6EINk8YOH+7eCLlq9Gn y2HNruxXnBFW+g1M5764jKM15Ex41FmnC/8GZupFrVDsWS5S7XqXdwySGRWETf2J7+ HDd9wnH2Lr/RmMmHEbZZVhAQCox7+k8na8jkF+lc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, rtm@csail.mit.edu, "J. Bruce Fields" , Chuck Lever , Olga Kornievskaia , Sasha Levin Subject: [PATCH 5.15 077/262] nfsd: fix crash on COPY_NOTIFY with special stateid Date: Mon, 7 Mar 2022 10:17:01 +0100 Message-Id: <20220307091704.665272036@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: J. Bruce Fields [ Upstream commit 074b07d94e0bb6ddce5690a9b7e2373088e8b33a ] RTM says "If the special ONE stateid is passed to nfs4_preprocess_stateid_op(), it returns status=3D0 but does not set *cstid. nfsd4_copy_notify() depends on stid being set if status=3D0, and thus can crash if the client sends the right COPY_NOTIFY RPC." RFC 7862 says "The cna_src_stateid MUST refer to either open or locking states provided earlier by the server. If it is invalid, then the operation MUST fail." The RFC doesn't specify an error, and the choice doesn't matter much as this is clearly illegal client behavior, but bad_stateid seems reasonable. Simplest is just to guarantee that nfs4_preprocess_stateid_op, called with non-NULL cstid, errors out if it can't return a stateid. Reported-by: rtm@csail.mit.edu Fixes: 624322f1adc5 ("NFSD add COPY_NOTIFY operation") Signed-off-by: J. Bruce Fields Signed-off-by: Chuck Lever Reviewed-by: Olga Kornievskaia Tested-by: Olga Kornievskaia Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs4state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 97090ddcfc94d..db4a47a280dc5 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6042,7 +6042,11 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, *nfp =3D NULL; =20 if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) { - status =3D check_special_stateids(net, fhp, stateid, flags); + if (cstid) + status =3D nfserr_bad_stateid; + else + status =3D check_special_stateids(net, fhp, stateid, + flags); goto done; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20FDDC4167B for ; Mon, 7 Mar 2022 10:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238956AbiCGKCv (ORCPT ); Mon, 7 Mar 2022 05:02:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240957AbiCGJlm (ORCPT ); Mon, 7 Mar 2022 04:41:42 -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 397B96CA4C; Mon, 7 Mar 2022 01:38: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 CEA9AB810BD; Mon, 7 Mar 2022 09:38:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB86C340F3; Mon, 7 Mar 2022 09:38:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645925; bh=ifDCbOlvlfDMlQSljIfCesPKWuSzZT3V2906vyaUncs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+MYAYI+/zPJ55gjXUZVxKKrOrsipUSMFQacs9b7mbhDyHs/LRqSmF687m+zkHAzP EU5gtox9U3PaPpBy/0NLo/NA3uT6Nb97MIbe3v8uae5AEwnng5U4g4EuCZPvp8AU9i h0dYbPF+Ae0kDOltf60Tp2ObqUdD74msROTmh4uA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.15 078/262] x86/hyperv: Properly deal with empty cpumasks in hyperv_flush_tlb_multi() Date: Mon, 7 Mar 2022 10:17:02 +0100 Message-Id: <20220307091704.692711717@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov [ Upstream commit 51500b71d500f251037ed339047a4d9e7d7e295b ] KASAN detected the following issue: BUG: KASAN: slab-out-of-bounds in hyperv_flush_tlb_multi+0xf88/0x1060 Read of size 4 at addr ffff8880011ccbc0 by task kcompactd0/33 CPU: 1 PID: 33 Comm: kcompactd0 Not tainted 5.14.0-39.el9.x86_64+debug #1 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 12/17/2019 Call Trace: dump_stack_lvl+0x57/0x7d print_address_description.constprop.0+0x1f/0x140 ? hyperv_flush_tlb_multi+0xf88/0x1060 __kasan_report.cold+0x7f/0x11e ? hyperv_flush_tlb_multi+0xf88/0x1060 kasan_report+0x38/0x50 hyperv_flush_tlb_multi+0xf88/0x1060 flush_tlb_mm_range+0x1b1/0x200 ptep_clear_flush+0x10e/0x150 ... Allocated by task 0: kasan_save_stack+0x1b/0x40 __kasan_kmalloc+0x7c/0x90 hv_common_init+0xae/0x115 hyperv_init+0x97/0x501 apic_intr_mode_init+0xb3/0x1e0 x86_late_time_init+0x92/0xa2 start_kernel+0x338/0x3eb secondary_startup_64_no_verify+0xc2/0xcb The buggy address belongs to the object at ffff8880011cc800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 960 bytes inside of 1024-byte region [ffff8880011cc800, ffff8880011ccc00) 'hyperv_flush_tlb_multi+0xf88/0x1060' points to hv_cpu_number_to_vp_number() and '960 bytes' means we're trying to get VP_INDEX for CPU#240. 'nr_cpus' here is exactly 240 so we're trying to access past hv_vp_index's last element. This can (and will) happen when 'cpus' mask is empty and cpumask_last() will return '>=3Dnr_cpus'. Commit ad0a6bad4475 ("x86/hyperv: check cpu mask after interrupt has been disabled") tried to deal with empty cpumask situation but apparently didn't fully fix the issue. 'cpus' cpumask which is passed to hyperv_flush_tlb_multi() is 'mm_cpumask(mm)' (which is '&mm->cpu_bitmap'). This mask changes every time the particular mm is scheduled/unscheduled on some CPU (see switch_mm_irqs_off()), disabling IRQs on the CPU which is performing remote TLB flush has zero influence on whether the particular process can get scheduled/unscheduled on _other_ CPUs so e.g. in the case where the mm was scheduled on one other CPU and got unscheduled during hyperv_flush_tlb_multi()'s execution will lead to cpumask becoming empty. It doesn't seem that there's a good way to protect 'mm_cpumask(mm)' from changing during hyperv_flush_tlb_multi()'s execution. It would be possible to copy it in the very beginning of the function but this is a waste. It seems we can deal with changing cpumask just fine. When 'cpus' cpumask changes during hyperv_flush_tlb_multi()'s execution, there are two possible issues: - 'Under-flushing': we will not flush TLB on a CPU which got added to the mask while hyperv_flush_tlb_multi() was already running. This is not a problem as this is equal to mm getting scheduled on that CPU right after TLB flush. - 'Over-flushing': we may flush TLB on a CPU which is already cleared from the mask. First, extra TLB flush preserves correctness. Second, Hyper-V's TLB flush hypercall takes 'mm->pgd' argument so Hyper-V may avoid the flush if CR3 doesn't match. Fix the immediate issue with cpumask_last()/hv_cpu_number_to_vp_number() and remove the pointless cpumask_empty() check from the beginning of the function as it really doesn't protect anything. Also, avoid the hypercall altogether when 'flush->processor_mask' ends up being empty. Fixes: ad0a6bad4475 ("x86/hyperv: check cpu mask after interrupt has been d= isabled") Signed-off-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20220106094611.1404218-1-vkuznets@redhat.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/x86/hyperv/mmu.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index bd13736d0c054..0ad2378fe6ad7 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -68,15 +68,6 @@ static void hyperv_flush_tlb_multi(const struct cpumask = *cpus, =20 local_irq_save(flags); =20 - /* - * Only check the mask _after_ interrupt has been disabled to avoid the - * mask changing under our feet. - */ - if (cpumask_empty(cpus)) { - local_irq_restore(flags); - return; - } - flush_pcpu =3D (struct hv_tlb_flush **) this_cpu_ptr(hyperv_pcpu_input_arg); =20 @@ -115,7 +106,9 @@ static void hyperv_flush_tlb_multi(const struct cpumask= *cpus, * must. We will also check all VP numbers when walking the * supplied CPU set to remain correct in all cases. */ - if (hv_cpu_number_to_vp_number(cpumask_last(cpus)) >=3D 64) + cpu =3D cpumask_last(cpus); + + if (cpu < nr_cpumask_bits && hv_cpu_number_to_vp_number(cpu) >=3D 64) goto do_ex_hypercall; =20 for_each_cpu(cpu, cpus) { @@ -131,6 +124,12 @@ static void hyperv_flush_tlb_multi(const struct cpumas= k *cpus, __set_bit(vcpu, (unsigned long *) &flush->processor_mask); } + + /* nothing to flush if 'processor_mask' ends up being empty */ + if (!flush->processor_mask) { + local_irq_restore(flags); + return; + } } =20 /* --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C199C433FE for ; Mon, 7 Mar 2022 09:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238320AbiCGJwE (ORCPT ); Mon, 7 Mar 2022 04:52:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240973AbiCGJln (ORCPT ); Mon, 7 Mar 2022 04:41:43 -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 B11206C1CA; Mon, 7 Mar 2022 01:38: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 392C4B8102B; Mon, 7 Mar 2022 09:38:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73EFCC340F3; Mon, 7 Mar 2022 09:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645928; bh=Ljpn8FdyEg3DeGHMfdNwKAXkMrJs/1K06M6QjXTJynQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+4GFnPo+NGMku5ctl6vTPh7ZNUoS8xH6WCamUda8Lar1oMz4SnQgvywckPqGLDkw /A1GqFMBNgihf5i3d76rMDgQWUV71xw16ZzVswqx3cfS+uJ4Qi3Dhql4YR19F3GaaG txNHgn50N7Sm13degQ2STguVvEbwzdKHT7lsjrU0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Tvrtko Ursulin , Sasha Levin Subject: [PATCH 5.15 079/262] drm/i915: dont call free_mmap_offset when purging Date: Mon, 7 Mar 2022 10:17:03 +0100 Message-Id: <20220307091704.720213737@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Matthew Auld [ Upstream commit 4c2602ba8d74c35d550ed3d518809c697de08d88 ] The TTM backend is in theory the only user here(also purge should only be called once we have dropped the pages), where it is setup at object creation and is only removed once the object is destroyed. Also resetting the node here might be iffy since the ttm fault handler uses the stored fake offset to determine the page offset within the pages array. This also blows up in the dontneed-before-mmap test, since the expectation is that the vma_node will live on, until the object is destroyed: <2> [749.062902] kernel BUG at drivers/gpu/drm/i915/gem/i915_gem_ttm.c:943! <4> [749.062923] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI <4> [749.062928] CPU: 0 PID: 1643 Comm: gem_madvise Tainted: G U W = 5.16.0-rc8-CI-CI_DRM_11046+ #1 <4> [749.062933] Hardware name: Gigabyte Technology Co., Ltd. GB-Z390 Garud= a/GB-Z390 Garuda-CF, BIOS IG1c 11/19/2019 <4> [749.062937] RIP: 0010:i915_ttm_mmap_offset.cold.35+0x5b/0x5d [i915] <4> [749.063044] Code: 00 48 c7 c2 a0 23 4e a0 48 c7 c7 26 df 4a a0 e8 95 1= d d0 e0 bf 01 00 00 00 e8 8b ec cf e0 31 f6 bf 09 00 00 00 e8 5f 30 c0 e0 <= 0f> 0b 48 c7 c1 24 4b 56 a0 ba 5b 03 00 00 48 c7 c6 c0 23 4e a0 48 <4> [749.063052] RSP: 0018:ffffc90002ab7d38 EFLAGS: 00010246 <4> [749.063056] RAX: 0000000000000240 RBX: ffff88811f2e61c0 RCX: 000000000= 0000006 <4> [749.063060] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000= 0000009 <4> [749.063063] RBP: ffffc90002ab7e58 R08: 0000000000000001 R09: 000000000= 0000001 <4> [749.063067] R10: 000000000123d0f8 R11: ffffc90002ab7b20 R12: ffff88811= 2a1a000 <4> [749.063071] R13: 0000000000000004 R14: ffff88811f2e61c0 R15: ffff88811= 2a1a000 <4> [749.063074] FS: 00007f6e5fcad500(0000) GS:ffff8884ad600000(0000) knlG= S:0000000000000000 <4> [749.063078] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 <4> [749.063081] CR2: 00007efd264e39f0 CR3: 0000000115fd6005 CR4: 000000000= 03706f0 <4> [749.063085] Call Trace: <4> [749.063087] <4> [749.063089] __assign_mmap_offset+0x41/0x300 [i915] <4> [749.063171] __assign_mmap_offset_handle+0x159/0x270 [i915] <4> [749.063248] ? i915_gem_dumb_mmap_offset+0x70/0x70 [i915] <4> [749.063325] drm_ioctl_kernel+0xae/0x140 <4> [749.063330] drm_ioctl+0x201/0x3d0 <4> [749.063333] ? i915_gem_dumb_mmap_offset+0x70/0x70 [i915] <4> [749.063409] ? do_user_addr_fault+0x200/0x670 <4> [749.063415] __x64_sys_ioctl+0x6d/0xa0 <4> [749.063419] do_syscall_64+0x3a/0xb0 <4> [749.063423] entry_SYSCALL_64_after_hwframe+0x44/0xae <4> [749.063428] RIP: 0033:0x7f6e5f100317 Testcase: igt/gem_madvise/dontneed-before-mmap Fixes: cf3e3e86d779 ("drm/i915: Use ttm mmap handling for ttm bo's.") Signed-off-by: Matthew Auld Cc: Thomas Hellstr=C3=B6m Reviewed-by: Thomas Hellstr=C3=B6m Link: https://patchwork.freedesktop.org/patch/msgid/20220106174910.280616-1= -matthew.auld@intel.com (cherry picked from commit 658a0c632625e1db51837ff754fe18a6a7f2ccf8) Signed-off-by: Tvrtko Ursulin Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/gem/i915_gem_pages.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i9= 15/gem/i915_gem_pages.c index 8d6c38a622016..9053cea3395a6 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c @@ -162,7 +162,6 @@ int i915_gem_object_pin_pages_unlocked(struct drm_i915_= gem_object *obj) /* Immediately discard the backing storage */ void i915_gem_object_truncate(struct drm_i915_gem_object *obj) { - drm_gem_free_mmap_offset(&obj->base); if (obj->ops->truncate) obj->ops->truncate(obj); } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90539C43217 for ; Mon, 7 Mar 2022 09:51:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238486AbiCGJwR (ORCPT ); Mon, 7 Mar 2022 04:52:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240986AbiCGJlo (ORCPT ); Mon, 7 Mar 2022 04:41:44 -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 8C9A06D193; Mon, 7 Mar 2022 01:38: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 189446116E; Mon, 7 Mar 2022 09:38:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20C93C340E9; Mon, 7 Mar 2022 09:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645935; bh=vUUx7TDfvi9NLzfwhBM7JvnGySc+0jCcgOAbRK5rt/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlVMajugN+JxMxA+O9lTJv4FhRyRj2ssg8ajocIMQK+dLkTa1MtlJwEPBNhfeN4it SwVb7js1lwqmZWUIOgBU40qnkzaPRPO2lcmUpIfAC5Li6VwK9QSf/HylRjOFeVXD0e upBdULY6cdLijjReitXyMC+Hn2tXlmy8TP7Uc4j8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Sasha Levin Subject: [PATCH 5.15 080/262] SUNRPC: Fix sockaddr handling in the svc_xprt_create_error trace point Date: Mon, 7 Mar 2022 10:17:04 +0100 Message-Id: <20220307091704.747088295@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit dc6c6fb3d639756a532bcc47d4a9bf9f3965881b ] While testing, I got an unexpected KASAN splat: Jan 08 13:50:27 oracle-102.nfsv4.dev kernel: BUG: KASAN: stack-out-of-bound= s in trace_event_raw_event_svc_xprt_create_err+0x190/0x210 [sunrpc] Jan 08 13:50:27 oracle-102.nfsv4.dev kernel: Read of size 28 at addr ffffc9= 000008f728 by task mount.nfs/4628 The memcpy() in the TP_fast_assign section of this trace point copies the size of the destination buffer in order that the buffer won't be overrun. In other similar trace points, the source buffer for this memcpy is a "struct sockaddr_storage" so the actual length of the source buffer is always long enough to prevent the memcpy from reading uninitialized or unallocated memory. However, for this trace point, the source buffer can be as small as a "struct sockaddr_in". For AF_INET sockaddrs, the memcpy() reads memory that follows the source buffer, which is not always valid memory. To avoid copying past the end of the passed-in sockaddr, make the source address's length available to the memcpy(). It would be a little nicer if the tracing infrastructure was more friendly about storing socket addresses that are not AF_INET, but I could not find a way to make printk("%pIS") work with a dynamic array. Reported-by: KASAN Fixes: 4b8f380e46e4 ("SUNRPC: Tracepoint to record errors in svc_xpo_create= ()") Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- include/trace/events/sunrpc.h | 5 +++-- net/sunrpc/svc_xprt.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index daaf407e9e494..1213c078dcca5 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -1727,10 +1727,11 @@ TRACE_EVENT(svc_xprt_create_err, const char *program, const char *protocol, struct sockaddr *sap, + size_t salen, const struct svc_xprt *xprt ), =20 - TP_ARGS(program, protocol, sap, xprt), + TP_ARGS(program, protocol, sap, salen, xprt), =20 TP_STRUCT__entry( __field(long, error) @@ -1743,7 +1744,7 @@ TRACE_EVENT(svc_xprt_create_err, __entry->error =3D PTR_ERR(xprt); __assign_str(program, program); __assign_str(protocol, protocol); - memcpy(__entry->addr, sap, sizeof(__entry->addr)); + memcpy(__entry->addr, sap, min(salen, sizeof(__entry->addr))); ), =20 TP_printk("addr=3D%pISpc program=3D%s protocol=3D%s error=3D%ld", diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 6316bd2b8f37b..d4b663401be14 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -243,7 +243,7 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xpr= t_class *xcl, xprt =3D xcl->xcl_ops->xpo_create(serv, net, sap, len, flags); if (IS_ERR(xprt)) trace_svc_xprt_create_err(serv->sv_program->pg_name, - xcl->xcl_name, sap, xprt); + xcl->xcl_name, sap, len, xprt); return xprt; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8121C433FE for ; Mon, 7 Mar 2022 09:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238518AbiCGJw3 (ORCPT ); Mon, 7 Mar 2022 04:52:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240992AbiCGJlo (ORCPT ); Mon, 7 Mar 2022 04:41:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 892926582B; Mon, 7 Mar 2022 01:39: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 ams.source.kernel.org (Postfix) with ESMTPS id B9EBBB810CC; Mon, 7 Mar 2022 09:38:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22E7BC340E9; Mon, 7 Mar 2022 09:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645938; bh=i57U6srCUY6x6p72vBcDx7z8RlmPz/tzafs1rL/YY9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+WpiIcW57nBgieETTuRAzzyUNcUStMCBTb7EIjC+rMsQsVVAiuw9Vfn1OM5yeltg EAa20eX8oAEZSNnEarurhu55d/5fTch/jZWc0xwVFFNMQNbBxPunVB7AOyn1RU8h7+ Yvacny5bKFRAW3Y9kMuYa5+SjVliuSISrMyIctBs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Sasha Levin Subject: [PATCH 5.15 081/262] SUNRPC: Fix sockaddr handling in svcsock_accept_class trace points Date: Mon, 7 Mar 2022 10:17:05 +0100 Message-Id: <20220307091704.773768226@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chuck Lever [ Upstream commit 16720861675393a35974532b3c837d9fd7bfe08c ] Avoid potentially hazardous memory copying and the needless use of "%pIS" -- in the kernel, an RPC service listener is always bound to ANYADDR. Having the network namespace is helpful when recording errors, though. Fixes: a0469f46faab ("SUNRPC: Replace dprintk call sites in TCP state chang= e callouts") Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- include/trace/events/sunrpc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index 1213c078dcca5..7c48613c18304 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -2112,17 +2112,17 @@ DECLARE_EVENT_CLASS(svcsock_accept_class, TP_STRUCT__entry( __field(long, status) __string(service, service) - __array(unsigned char, addr, sizeof(struct sockaddr_in6)) + __field(unsigned int, netns_ino) ), =20 TP_fast_assign( __entry->status =3D status; __assign_str(service, service); - memcpy(__entry->addr, &xprt->xpt_local, sizeof(__entry->addr)); + __entry->netns_ino =3D xprt->xpt_net->ns.inum; ), =20 - TP_printk("listener=3D%pISpc service=3D%s status=3D%ld", - __entry->addr, __get_str(service), __entry->status + TP_printk("addr=3Dlistener service=3D%s status=3D%ld", + __get_str(service), __entry->status ) ); =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4718C3527B for ; Mon, 7 Mar 2022 10:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239059AbiCGKC7 (ORCPT ); Mon, 7 Mar 2022 05:02:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241000AbiCGJlo (ORCPT ); Mon, 7 Mar 2022 04:41:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1101C6D1B1; Mon, 7 Mar 2022 01:39: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 ams.source.kernel.org (Postfix) with ESMTPS id 1B89FB80F9F; Mon, 7 Mar 2022 09:39:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34DE8C340E9; Mon, 7 Mar 2022 09:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645941; bh=2E50KrbVkwR/nqccvG/b6nh+kvOETHtkUWtyTvxMPhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZ51RF0K5GHjlsGyL/uzWF1n5D2+G6pkOHE4Je2LL09JG+xOAgHfEnOGN3pCCpLrV 1a8fWocLO7k2dCM/O5WCxdj4ybyfOrjJqtLcW3mhtJX2lsHRV7/Xz/M3IFjNPozNKm 7D8YzAPSB7/ACpr42FkcUUb+GLRsGOU+efbYIIwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Maxime Ripard , Sasha Levin Subject: [PATCH 5.15 082/262] drm/sun4i: dw-hdmi: Fix missing put_device() call in sun8i_hdmi_phy_get Date: Mon, 7 Mar 2022 10:17:06 +0100 Message-Id: <20220307091704.800843121@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaoqian Lin [ Upstream commit c71af3dae3e34d2fde0c19623cf7f8483321f0e3 ] The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add the corresponding 'put_device()' in the error handling path. Fixes: 9bf3797796f5 ("drm/sun4i: dw-hdmi: Make HDMI PHY into a platform dev= ice") Signed-off-by: Miaoqian Lin Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/20220107083633.20843-1-= linmq006@gmail.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i= /sun8i_hdmi_phy.c index b64d93da651d2..5e2b0175df36f 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -658,8 +658,10 @@ int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, str= uct device_node *node) return -EPROBE_DEFER; =20 phy =3D platform_get_drvdata(pdev); - if (!phy) + if (!phy) { + put_device(&pdev->dev); return -EPROBE_DEFER; + } =20 hdmi->phy =3D phy; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A9C8C433EF for ; Mon, 7 Mar 2022 09:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238559AbiCGJwr (ORCPT ); Mon, 7 Mar 2022 04:52:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241011AbiCGJlp (ORCPT ); Mon, 7 Mar 2022 04:41:45 -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 810D46D393; Mon, 7 Mar 2022 01:39: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 2BCF6B810B2; Mon, 7 Mar 2022 09:39:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D8F9C340E9; Mon, 7 Mar 2022 09:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645944; bh=R8/1XpnUCRmWuxRq57W415mmpgzGhzNlkkynV5S82N0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qgSkcnEPNH2k5aHF0wwmZwIftXBSAnjFUbvTvr0DjSEX7TvZrTQInTnKwdyTVvT/L ZC+kqJqWTveqs3elVwe538HmuJi2EaFbDSA0jlepmbo4hriFojvWYFhmKUf2YDyYfA +mcloMJ/iva1vHr712DHWAS6xmgqUXswhhnbD8ww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Paul , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alex Deucher , Liu Ying , Sasha Levin Subject: [PATCH 5.15 083/262] drm/atomic: Check new_crtc_state->active to determine if CRTC needs disable in self refresh mode Date: Mon, 7 Mar 2022 10:17:07 +0100 Message-Id: <20220307091704.827402975@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Liu Ying [ Upstream commit 69e630016ef4e4a1745310c446f204dc6243e907 ] Actual hardware state of CRTC is controlled by the member 'active' in struct drm_crtc_state instead of the member 'enable', according to the kernel doc of the member 'enable'. In fact, the drm client modeset and atomic helpers are using the member 'active' to do the control. Referencing the member 'enable' of new_crtc_state, the function crtc_needs_disable() may fail to reflect if CRTC needs disable in self refresh mode, e.g., when the framebuffer emulation will be blanked through the client modeset helper with the next commit, the member 'enable' of new_crtc_state is still true while the member 'active' is false, hence the relevant potential encoder and bridges won't be disabled. So, let's check new_crtc_state->active to determine if CRTC needs disable in self refresh mode instead of new_crtc_state->enable. Fixes: 1452c25b0e60 ("drm: Add helpers to kick off self refresh mode in dri= vers") Cc: Sean Paul Cc: Rob Clark Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Reviewed-by: Alex Deucher Signed-off-by: Liu Ying Signed-off-by: Alex Deucher Link: https://patchwork.freedesktop.org/patch/msgid/20211230040626.646807-1= -victor.liu@nxp.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/drm_atomic_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atom= ic_helper.c index 2c0c6ec928200..ff2bc9a118011 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1001,7 +1001,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state, * it's in self refresh mode and needs to be fully disabled. */ return old_state->active || - (old_state->self_refresh_active && !new_state->enable) || + (old_state->self_refresh_active && !new_state->active) || new_state->self_refresh_active; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DF06C433EF for ; Mon, 7 Mar 2022 10:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237871AbiCGKGE (ORCPT ); Mon, 7 Mar 2022 05:06:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238303AbiCGJpB (ORCPT ); Mon, 7 Mar 2022 04:45: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 6EC7C65432; Mon, 7 Mar 2022 01:41: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 dfw.source.kernel.org (Postfix) with ESMTPS id EC64F612C9; Mon, 7 Mar 2022 09:41:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4053C340F3; Mon, 7 Mar 2022 09:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646103; bh=ZRudVY4cCl8/MQQO5V8VjUC2mo62hikaH/uo7E/qylE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WuQMm6qa3dqfBS5uEaTT7yYFViHRx2O/T5d7UIL8aYlmRFDHC0E68bM8mKwWhXjsb 7YOeUPgUfDaCWigEJaZIfZTqV/rcPVQmUyv9u0ubH7YWoRGkw8KL+Q3Osmt86HaHLt n0y5l5NG1+XIR4pqqhqUU+Y//dBxSTzp7BuPXxUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Pallotta , Kelvin Cao , Jon Mason , Sasha Levin Subject: [PATCH 5.15 084/262] ntb_hw_switchtec: Fix pff ioread to read into mmio_part_cfg_all Date: Mon, 7 Mar 2022 10:17:08 +0100 Message-Id: <20220307091704.855171721@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jeremy Pallotta [ Upstream commit 32c3d375b0ed84b6acb51ae5ebef35ff0d649d85 ] Array mmio_part_cfg_all holds the partition configuration of all partitions, with partition number as index. Fix this by reading into mmio_part_cfg_all for pff. Fixes: 0ee28f26f378 ("NTB: switchtec_ntb: Add link management") Signed-off-by: Jeremy Pallotta Signed-off-by: Kelvin Cao Signed-off-by: Jon Mason Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/n= tb_hw_switchtec.c index 4c6eb61a6ac62..6603c77c0a848 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -419,8 +419,8 @@ static void switchtec_ntb_part_link_speed(struct switch= tec_ntb *sndev, enum ntb_width *width) { struct switchtec_dev *stdev =3D sndev->stdev; - - u32 pff =3D ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id); + u32 pff =3D + ioread32(&stdev->mmio_part_cfg_all[partition].vep_pff_inst_id); u32 linksta =3D ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]); =20 if (speed) --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E8AC433F5 for ; Mon, 7 Mar 2022 09:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238603AbiCGJwv (ORCPT ); Mon, 7 Mar 2022 04:52:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241035AbiCGJlq (ORCPT ); Mon, 7 Mar 2022 04:41:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DBB16D4F9; Mon, 7 Mar 2022 01:39: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 E2E2D611D5; Mon, 7 Mar 2022 09:39:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3A01C340E9; Mon, 7 Mar 2022 09:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645966; bh=PuPDInC1r/GLcY+Vi+sQObVdNBoB1cbEQ8SKVAlGUU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnZD1aCBBo4aEGUnDWd7ZfJ0djITBUMWgdOV+KNvyajLbhnyyM+uXQSffXBM69CKM kHZcAZ2cwAJaBM16FvrJnn0eBgKIOyQtIFBvtwBLSVtlkgXZI8anUJFjFlSP8tDCAx Zn5if8l+E8iAdZHuoGBsy8Kkk68Y5wG5HDtrd/tY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wesley Sheng , Kelvin Cao , Jon Mason , Sasha Levin Subject: [PATCH 5.15 085/262] ntb_hw_switchtec: Fix bug with more than 32 partitions Date: Mon, 7 Mar 2022 10:17:09 +0100 Message-Id: <20220307091704.882023540@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wesley Sheng [ Upstream commit 7ff351c86b6b258f387502ab2c9b9d04f82c1c3d ] Switchtec could support as mush as 48 partitions, but ffs & fls are for 32 bit argument, in case of partition index larger than 31, the current code could not parse the peer partition index correctly. Change to the 64 bit version __ffs64 & fls64 accordingly to fix this bug. Fixes: 3df54c870f52 ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-= partition setups") Signed-off-by: Wesley Sheng Signed-off-by: Kelvin Cao Signed-off-by: Jon Mason Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/n= tb_hw_switchtec.c index 6603c77c0a848..ec9cb6c81edae 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -840,7 +840,6 @@ static int switchtec_ntb_init_sndev(struct switchtec_nt= b *sndev) u64 tpart_vec; int self; u64 part_map; - int bit; =20 sndev->ntb.pdev =3D sndev->stdev->pdev; sndev->ntb.topo =3D NTB_TOPO_SWITCH; @@ -861,29 +860,28 @@ static int switchtec_ntb_init_sndev(struct switchtec_= ntb *sndev) part_map =3D ioread64(&sndev->mmio_ntb->ep_map); part_map &=3D ~(1 << sndev->self_partition); =20 - if (!ffs(tpart_vec)) { + if (!tpart_vec) { if (sndev->stdev->partition_count !=3D 2) { dev_err(&sndev->stdev->dev, "ntb target partition not defined\n"); return -ENODEV; } =20 - bit =3D ffs(part_map); - if (!bit) { + if (!part_map) { dev_err(&sndev->stdev->dev, "peer partition is not NT partition\n"); return -ENODEV; } =20 - sndev->peer_partition =3D bit - 1; + sndev->peer_partition =3D __ffs64(part_map); } else { - if (ffs(tpart_vec) !=3D fls(tpart_vec)) { + if (__ffs64(tpart_vec) !=3D (fls64(tpart_vec) - 1)) { dev_err(&sndev->stdev->dev, "ntb driver only supports 1 pair of 1-1 ntb mapping\n"); return -ENODEV; } =20 - sndev->peer_partition =3D ffs(tpart_vec) - 1; + sndev->peer_partition =3D __ffs64(tpart_vec); if (!(part_map & (1ULL << sndev->peer_partition))) { dev_err(&sndev->stdev->dev, "ntb target partition is not NT partition\n"); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 580A3C433EF for ; Mon, 7 Mar 2022 09:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbiCGJyJ (ORCPT ); Mon, 7 Mar 2022 04:54:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241080AbiCGJlt (ORCPT ); Mon, 7 Mar 2022 04:41:49 -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 A6529674D0; Mon, 7 Mar 2022 01:40: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 86DA5611D5; Mon, 7 Mar 2022 09:40:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96376C340E9; Mon, 7 Mar 2022 09:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646001; bh=zDHN0pvH5VbPZU6z9GYhPXlHtcv0MaHvgRH814qRAaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpTibsm7pdkkvNb+iDiHpG4i/PGcHsH+zVq8RkfgxAv53K6vc24r9up7W4uab6NPf x9R9xoGobddQXlzZHVvKRuivgYIunQiGF9s1Xtoxdf3MJVZLO+5+DshmNvlprtpLRM /GsiPiSWq1mm1EYCexPriqQwYG35cPH3JtpIkeak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 086/262] drm/amdkfd: Check for null pointer after calling kmemdup Date: Mon, 7 Mar 2022 10:17:10 +0100 Message-Id: <20220307091704.909430741@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit abfaf0eee97925905e742aa3b0b72e04a918fa9e ] As the possible failure of the allocation, kmemdup() may return NULL pointer. Therefore, it should be better to check the 'props2' in order to prevent the dereference of NULL pointer. Fixes: 3a87177eb141 ("drm/amdkfd: Add topology support for dGPUs") Signed-off-by: Jiasheng Jiang Reviewed-by: Felix Kuehling Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/am= dkfd/kfd_crat.c index cfedfb1e8596c..c33d689f29e8e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -1060,6 +1060,9 @@ static int kfd_parse_subtype_iolink(struct crat_subty= pe_iolink *iolink, return -ENODEV; /* same everything but the other direction */ props2 =3D kmemdup(props, sizeof(*props2), GFP_KERNEL); + if (!props2) + return -ENOMEM; + props2->node_from =3D id_to; props2->node_to =3D id_from; props2->kobj =3D NULL; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBC4C433F5 for ; Mon, 7 Mar 2022 09:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235076AbiCGJzT (ORCPT ); Mon, 7 Mar 2022 04:55:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241139AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06192DDA; Mon, 7 Mar 2022 01:40: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 sin.source.kernel.org (Postfix) with ESMTPS id 4C995CE0EAA; Mon, 7 Mar 2022 09:40:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 096F2C340E9; Mon, 7 Mar 2022 09:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646040; bh=nRMkltgKgdbuMr9XsmL+FvkFhQmImYJklYWMTfuJkEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qIFohVh5zglX7NqyymdpzGXLSW5aBr36F26GP+s8p70MIyhmbZLfuElpr4pZElB9E tlHCCq/ohncNrs32YeTFbI1zAlfNxHl/4xE0KyluokrjkpQiZgRtpyEdINF3inhDkE GxLvnyqf5C1YuiAu9a8+xx3GslCOsouU9aJzR2fk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guchun Chen , Alex Deucher , Kelly Zytaruk , Sasha Levin Subject: [PATCH 5.15 087/262] drm/amdgpu: use spin_lock_irqsave to avoid deadlock by local interrupt Date: Mon, 7 Mar 2022 10:17:11 +0100 Message-Id: <20220307091704.936659224@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Guchun Chen [ Upstream commit 2096b74b1da5ca418827b54ac4904493bd9de89c ] This is observed in SRIOV case with virtual KMS as display. _raw_spin_lock_irqsave+0x37/0x40 drm_handle_vblank+0x69/0x350 [drm] ? try_to_wake_up+0x432/0x5c0 ? amdgpu_vkms_prepare_fb+0x1c0/0x1c0 [amdgpu] drm_crtc_handle_vblank+0x17/0x20 [drm] amdgpu_vkms_vblank_simulate+0x4d/0x80 [amdgpu] __hrtimer_run_queues+0xfb/0x230 hrtimer_interrupt+0x109/0x220 __sysvec_apic_timer_interrupt+0x64/0xe0 asm_call_irq_on_stack+0x12/0x20 Fixes: 84ec374bd580 ("drm/amdgpu: create amdgpu_vkms (v4)") Signed-off-by: Guchun Chen Acked-by: Alex Deucher Tested-by: Kelly Zytaruk Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd= /amdgpu/amdgpu_vkms.c index ac9a8cd21c4b6..7d58bf410be05 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c @@ -142,15 +142,16 @@ static void amdgpu_vkms_crtc_atomic_disable(struct dr= m_crtc *crtc, static void amdgpu_vkms_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) { + unsigned long flags; if (crtc->state->event) { - spin_lock(&crtc->dev->event_lock); + spin_lock_irqsave(&crtc->dev->event_lock, flags); =20 if (drm_crtc_vblank_get(crtc) !=3D 0) drm_crtc_send_vblank_event(crtc, crtc->state->event); else drm_crtc_arm_vblank_event(crtc, crtc->state->event); =20 - spin_unlock(&crtc->dev->event_lock); + spin_unlock_irqrestore(&crtc->dev->event_lock, flags); =20 crtc->state->event =3D NULL; } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E22F7C433EF for ; Mon, 7 Mar 2022 10:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236987AbiCGKFQ (ORCPT ); Mon, 7 Mar 2022 05:05:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237557AbiCGJmN (ORCPT ); Mon, 7 Mar 2022 04:42:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69610B17; Mon, 7 Mar 2022 01:41:15 -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 ED9AD6133D; Mon, 7 Mar 2022 09:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E379AC340F5; Mon, 7 Mar 2022 09:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646074; bh=03pwDSBP+lXwFiG1Ofa2EZe72cX38XTIjIzWaZXLmhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVomNK3YUPpUJsHq0XJEys+aS+1j0cmwgtZbtxcaS91iAk3jvNrTz69r7t7OdRR0f H6iHEvAWbipsmCgLtuBiY1FE7a1nJ3JsaDFQBTfD+Y8iCavo+hbxfbVJMMl98uNYiv gDYCHuEOLSipv6qeJDmVcOkZeV4uGmkvi6Qw2sv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 088/262] i3c: master: dw: check return of dw_i3c_master_get_free_pos() Date: Mon, 7 Mar 2022 10:17:12 +0100 Message-Id: <20220307091704.964098126@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 13462ba1815db5a96891293a9cfaa2451f7bd623 ] Clang static analysis reports this problem dw-i3c-master.c:799:9: warning: The result of the left shift is undefined because the left operand is negative COMMAND_PORT_DEV_INDEX(pos) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ pos can be negative because dw_i3c_master_get_free_pos() can return an error. So check for an error. Fixes: 1dd728f5d4d4 ("i3c: master: Add driver for Synopsys DesignWare IP") Signed-off-by: Tom Rix Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220108150948.3988790-1-trix@redhat.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/i3c/master/dw-i3c-master.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c= -master.c index 03a368da51b95..51a8608203de7 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -793,6 +793,10 @@ static int dw_i3c_master_daa(struct i3c_master_control= ler *m) return -ENOMEM; =20 pos =3D dw_i3c_master_get_free_pos(master); + if (pos < 0) { + dw_i3c_master_free_xfer(xfer); + return pos; + } cmd =3D &xfer->cmds[0]; cmd->cmd_hi =3D 0x1; cmd->cmd_lo =3D COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) | --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69B11C433F5 for ; Mon, 7 Mar 2022 10:04:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240174AbiCGKFk (ORCPT ); Mon, 7 Mar 2022 05:05:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238186AbiCGJmw (ORCPT ); Mon, 7 Mar 2022 04:42: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 9709136E27; Mon, 7 Mar 2022 01:41: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 23FD361349; Mon, 7 Mar 2022 09:41:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09445C340E9; Mon, 7 Mar 2022 09:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646087; bh=yGF2yk0DciZXVKy44TwKN8EX+j1uAZ+XFwglFSQ1H9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ceu3A1KBOnLdp0AQNrVQ11uJKT+kySSW4hcqA3CoK0dSMqpYJBc2QhFRftaEtXJIx XBoxXATFuJm+eIsTNtHkKMexjqz5tBH+noc8AsNe+o+lsQLSidLYFgEJ5o3J0ii8J9 BG2FWAGmgHS0rJoCQqQSz0mfPgW33RpzXbe03fZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Weizhao Ouyang , John Stultz , Sumit Semwal , Sasha Levin Subject: [PATCH 5.15 089/262] dma-buf: cma_heap: Fix mutex locking section Date: Mon, 7 Mar 2022 10:17:13 +0100 Message-Id: <20220307091704.991374478@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Weizhao Ouyang [ Upstream commit 54329e6f7beea6af56c1230da293acc97d6a6ee7 ] Fix cma_heap_buffer mutex locking critical section to protect vmap_cnt and vaddr. Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_h= eap implementation") Signed-off-by: Weizhao Ouyang Acked-by: John Stultz Signed-off-by: Sumit Semwal Link: https://patchwork.freedesktop.org/patch/msgid/20220104073545.124244-1= -o451686892@gmail.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/dma-buf/heaps/cma_heap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_h= eap.c index 0c05b79870f96..83f02bd51dda6 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -124,10 +124,11 @@ static int cma_heap_dma_buf_begin_cpu_access(struct d= ma_buf *dmabuf, struct cma_heap_buffer *buffer =3D dmabuf->priv; struct dma_heap_attachment *a; =20 + mutex_lock(&buffer->lock); + if (buffer->vmap_cnt) invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); =20 - mutex_lock(&buffer->lock); list_for_each_entry(a, &buffer->attachments, list) { if (!a->mapped) continue; @@ -144,10 +145,11 @@ static int cma_heap_dma_buf_end_cpu_access(struct dma= _buf *dmabuf, struct cma_heap_buffer *buffer =3D dmabuf->priv; struct dma_heap_attachment *a; =20 + mutex_lock(&buffer->lock); + if (buffer->vmap_cnt) flush_kernel_vmap_range(buffer->vaddr, buffer->len); =20 - mutex_lock(&buffer->lock); list_for_each_entry(a, &buffer->attachments, list) { if (!a->mapped) continue; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFD85C433EF for ; Mon, 7 Mar 2022 10:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240181AbiCGKFq (ORCPT ); Mon, 7 Mar 2022 05:05:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237683AbiCGJnZ (ORCPT ); Mon, 7 Mar 2022 04:43:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DDA4755B; Mon, 7 Mar 2022 01:41: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 7420A6133D; Mon, 7 Mar 2022 09:41:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6984DC340E9; Mon, 7 Mar 2022 09:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646090; bh=hE1OjF1rUYQ93f+jl9N9Z+d4/F4G4HcNLRNh4ttkmPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRK1ybxs+KTAakoXEUz18IyxgdZm9wWqhGFUacbfataoArVp++r7OaWvQNhzhFxqa c29h0+17qZHdZkzphTxArQLC38tHItoeloY+CpWP208jwIPBMW8BDGNiHMmk3DDHj2 Fo9rXp2V9t24Nq3xZNU5RtbZ1oW0qed6egMv7dvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Xiaoke Wang , Steven Rostedt , Sasha Levin Subject: [PATCH 5.15 090/262] tracing/uprobes: Check the return value of kstrdup() for tu->filename Date: Mon, 7 Mar 2022 10:17:14 +0100 Message-Id: <20220307091705.018135219@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xiaoke Wang [ Upstream commit 8c7224245557707c613f130431cafbaaa4889615 ] kstrdup() returns NULL when some internal memory errors happen, it is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/tencent_3C2E330722056D7891D2C83F29C802734B0= 6@qq.com Acked-by: Masami Hiramatsu Fixes: 33ea4b24277b ("perf/core: Implement the 'perf_uprobe' PMU") Signed-off-by: Xiaoke Wang Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/trace/trace_uprobe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index f5f0039d31e5a..78ec1c16ccf4b 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -1619,6 +1619,11 @@ create_local_trace_uprobe(char *name, unsigned long = offs, tu->path =3D path; tu->ref_ctr_offset =3D ref_ctr_offset; tu->filename =3D kstrdup(name, GFP_KERNEL); + if (!tu->filename) { + ret =3D -ENOMEM; + goto error; + } + init_trace_event_call(tu); =20 ptype =3D is_ret_probe(tu) ? PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66C99C433F5 for ; Mon, 7 Mar 2022 10:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240081AbiCGKFz (ORCPT ); Mon, 7 Mar 2022 05:05:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238068AbiCGJol (ORCPT ); Mon, 7 Mar 2022 04:44:41 -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 C12CE58382; Mon, 7 Mar 2022 01:41: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 ams.source.kernel.org (Postfix) with ESMTPS id 74910B810B2; Mon, 7 Mar 2022 09:41:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7DA1C340E9; Mon, 7 Mar 2022 09:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646094; bh=7DerX0b8DALAtu6wevcGsJHv/dcYVQh4/h5h4IeCgWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1NF3XcU9X1nAjL5kbeniCm+ANEGnWdjdLGY10vMfZ1Nc0JDqfuxIc9e5uTHIbYFOC 3XlvpYSFmQ1OM5/mh6REEPA5JulKNyvsJI6rhUeFZHbtVmnkr98uLapDG2ipgljoKw zADgDJPFiv4wDwOkxNNk+IuGv/pn+HDoRzGCwTgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Xiaoke Wang , Steven Rostedt , Sasha Levin Subject: [PATCH 5.15 091/262] tracing/probes: check the return value of kstrndup() for pbuf Date: Mon, 7 Mar 2022 10:17:15 +0100 Message-Id: <20220307091705.045364043@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xiaoke Wang [ Upstream commit 1c1857d400355e96f0fe8b32adc6fa7594d03b52 ] kstrndup() is a memory allocation-related function, it returns NULL when some internal memory errors happen. It is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/tencent_4D6E270731456EB88712ED7F13883C33490= 6@qq.com Acked-by: Masami Hiramatsu Fixes: a42e3c4de964 ("tracing/probe: Add immediate string parameter support= ") Signed-off-by: Xiaoke Wang Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/trace/trace_probe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 3ed2a3f372972..bb4605b60de79 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -356,6 +356,8 @@ static int __parse_imm_string(char *str, char **pbuf, i= nt offs) return -EINVAL; } *pbuf =3D kstrndup(str, len - 1, GFP_KERNEL); + if (!*pbuf) + return -ENOMEM; return 0; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0144C433EF for ; Mon, 7 Mar 2022 10:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240208AbiCGKFu (ORCPT ); Mon, 7 Mar 2022 05:05:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238100AbiCGJor (ORCPT ); Mon, 7 Mar 2022 04:44: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 BA6FB5BD36; Mon, 7 Mar 2022 01:41: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 0BD2D612D7; Mon, 7 Mar 2022 09:41:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D57A9C340E9; Mon, 7 Mar 2022 09:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646097; bh=vRXxws9LRGqahZWQKNiPbugRmNbvuogicON+e6RMCy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5VoSIRVdXADoBFp2jP1aDChGs0rjlmrk0msrtE8puXkgei8TO1J16EJKn7V/bIM3 tARg5zxUtRbowatLA+xvRs8et7ZBbGfx9zi/Hs6G/K6xyu/T2s5xL84s88djftIH3q rLhiK7by0FQxX25h6vaBSKbcBKsNjNMbgqX+iMzI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kefeng Wang , Yongqiang Liu , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Catalin Marinas , Will Deacon , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Alexander Potapenko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 092/262] mm: defer kmemleak object creation of module_alloc() Date: Mon, 7 Mar 2022 10:17:16 +0100 Message-Id: <20220307091705.072621156@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kefeng Wang [ Upstream commit 60115fa54ad7b913b7cb5844e6b7ffeb842d55f2 ] Yongqiang reports a kmemleak panic when module insmod/rmmod with KASAN enabled(without KASAN_VMALLOC) on x86[1]. When the module area allocates memory, it's kmemleak_object is created successfully, but the KASAN shadow memory of module allocation is not ready, so when kmemleak scan the module's pointer, it will panic due to no shadow memory with KASAN check. module_alloc __vmalloc_node_range kmemleak_vmalloc kmemleak_scan update_checksum kasan_module_alloc kmemleak_ignore Note, there is no problem if KASAN_VMALLOC enabled, the modules area entire shadow memory is preallocated. Thus, the bug only exits on ARCH which supports dynamic allocation of module area per module load, for now, only x86/arm64/s390 are involved. Add a VM_DEFER_KMEMLEAK flags, defer vmalloc'ed object register of kmemleak in module_alloc() to fix this issue. [1] https://lore.kernel.org/all/6d41e2b9-4692-5ec4-b1cd-cbe29ae89739@huawei= .com/ [wangkefeng.wang@huawei.com: fix build] Link: https://lkml.kernel.org/r/20211125080307.27225-1-wangkefeng.wang@hu= awei.com [akpm@linux-foundation.org: simplify ifdefs, per Andrey] Link: https://lkml.kernel.org/r/CA+fCnZcnwJHUQq34VuRxpdoY6_XbJCDJ-jopksS5= Eia4PijPzw@mail.gmail.com Link: https://lkml.kernel.org/r/20211124142034.192078-1-wangkefeng.wang@hua= wei.com Fixes: 793213a82de4 ("s390/kasan: dynamic shadow mem allocation for modules= ") Fixes: 39d114ddc682 ("arm64: add KASAN support") Fixes: bebf56a1b176 ("kasan: enable instrumentation of global variables") Signed-off-by: Kefeng Wang Reported-by: Yongqiang Liu Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Catalin Marinas Cc: Will Deacon Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Cc: Alexander Gordeev Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: Alexander Potapenko Cc: Kefeng Wang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/kernel/module.c | 4 ++-- arch/s390/kernel/module.c | 5 +++-- arch/x86/kernel/module.c | 7 ++++--- include/linux/kasan.h | 4 ++-- include/linux/vmalloc.h | 7 +++++++ mm/kasan/shadow.c | 9 +++++++-- mm/vmalloc.c | 3 ++- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index b5ec010c481f3..309a27553c875 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -36,7 +36,7 @@ void *module_alloc(unsigned long size) module_alloc_end =3D MODULES_END; =20 p =3D __vmalloc_node_range(size, MODULE_ALIGN, module_alloc_base, - module_alloc_end, gfp_mask, PAGE_KERNEL, 0, + module_alloc_end, gfp_mask, PAGE_KERNEL, VM_DEFER_KMEMLEAK, NUMA_NO_NODE, __builtin_return_address(0)); =20 if (!p && IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) && @@ -58,7 +58,7 @@ void *module_alloc(unsigned long size) PAGE_KERNEL, 0, NUMA_NO_NODE, __builtin_return_address(0)); =20 - if (p && (kasan_module_alloc(p, size) < 0)) { + if (p && (kasan_module_alloc(p, size, gfp_mask) < 0)) { vfree(p); return NULL; } diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c index a805ea5cb92d1..b032e556eeb71 100644 --- a/arch/s390/kernel/module.c +++ b/arch/s390/kernel/module.c @@ -37,14 +37,15 @@ =20 void *module_alloc(unsigned long size) { + gfp_t gfp_mask =3D GFP_KERNEL; void *p; =20 if (PAGE_ALIGN(size) > MODULES_LEN) return NULL; p =3D __vmalloc_node_range(size, MODULE_ALIGN, MODULES_VADDR, MODULES_END, - GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, + gfp_mask, PAGE_KERNEL_EXEC, VM_DEFER_KMEMLEAK, NUMA_NO_NODE, __builtin_return_address(0)); - if (p && (kasan_module_alloc(p, size) < 0)) { + if (p && (kasan_module_alloc(p, size, gfp_mask) < 0)) { vfree(p); return NULL; } diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index 5e9a34b5bd741..867a341a0c7e8 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -67,6 +67,7 @@ static unsigned long int get_module_load_offset(void) =20 void *module_alloc(unsigned long size) { + gfp_t gfp_mask =3D GFP_KERNEL; void *p; =20 if (PAGE_ALIGN(size) > MODULES_LEN) @@ -74,10 +75,10 @@ void *module_alloc(unsigned long size) =20 p =3D __vmalloc_node_range(size, MODULE_ALIGN, MODULES_VADDR + get_module_load_offset(), - MODULES_END, GFP_KERNEL, - PAGE_KERNEL, 0, NUMA_NO_NODE, + MODULES_END, gfp_mask, + PAGE_KERNEL, VM_DEFER_KMEMLEAK, NUMA_NO_NODE, __builtin_return_address(0)); - if (p && (kasan_module_alloc(p, size) < 0)) { + if (p && (kasan_module_alloc(p, size, gfp_mask) < 0)) { vfree(p); return NULL; } diff --git a/include/linux/kasan.h b/include/linux/kasan.h index dd874a1ee862a..f407e937241af 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -461,12 +461,12 @@ static inline void kasan_release_vmalloc(unsigned lon= g start, * allocations with real shadow memory. With KASAN vmalloc, the special * case is unnecessary, as the work is handled in the generic case. */ -int kasan_module_alloc(void *addr, size_t size); +int kasan_module_alloc(void *addr, size_t size, gfp_t gfp_mask); void kasan_free_shadow(const struct vm_struct *vm); =20 #else /* (CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS) && !CONFIG_KASAN_V= MALLOC */ =20 -static inline int kasan_module_alloc(void *addr, size_t size) { return 0; } +static inline int kasan_module_alloc(void *addr, size_t size, gfp_t gfp_ma= sk) { return 0; } static inline void kasan_free_shadow(const struct vm_struct *vm) {} =20 #endif /* (CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS) && !CONFIG_KASAN_= VMALLOC */ diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 671d402c3778f..4fe9e885bbfac 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -28,6 +28,13 @@ struct notifier_block; /* in notifier.h */ #define VM_MAP_PUT_PAGES 0x00000200 /* put pages and free array in vfree */ #define VM_NO_HUGE_VMAP 0x00000400 /* force PAGE_SIZE pte mapping */ =20 +#if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \ + !defined(CONFIG_KASAN_VMALLOC) +#define VM_DEFER_KMEMLEAK 0x00000800 /* defer kmemleak object creation */ +#else +#define VM_DEFER_KMEMLEAK 0 +#endif + /* * VM_KASAN is used slightly differently depending on CONFIG_KASAN_VMALLOC. * diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c index 8d95ee52d0194..dd79840e60964 100644 --- a/mm/kasan/shadow.c +++ b/mm/kasan/shadow.c @@ -493,7 +493,7 @@ void kasan_release_vmalloc(unsigned long start, unsigne= d long end, =20 #else /* CONFIG_KASAN_VMALLOC */ =20 -int kasan_module_alloc(void *addr, size_t size) +int kasan_module_alloc(void *addr, size_t size, gfp_t gfp_mask) { void *ret; size_t scaled_size; @@ -515,9 +515,14 @@ int kasan_module_alloc(void *addr, size_t size) __builtin_return_address(0)); =20 if (ret) { + struct vm_struct *vm =3D find_vm_area(addr); __memset(ret, KASAN_SHADOW_INIT, shadow_size); - find_vm_area(addr)->flags |=3D VM_KASAN; + vm->flags |=3D VM_KASAN; kmemleak_ignore(ret); + + if (vm->flags & VM_DEFER_KMEMLEAK) + kmemleak_vmalloc(vm, size, gfp_mask); + return 0; } =20 diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e8a807c781107..8375eecc55de5 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3032,7 +3032,8 @@ void *__vmalloc_node_range(unsigned long size, unsign= ed long align, clear_vm_uninitialized_flag(area); =20 size =3D PAGE_ALIGN(size); - kmemleak_vmalloc(area, size, gfp_mask); + if (!(vm_flags & VM_DEFER_KMEMLEAK)) + kmemleak_vmalloc(area, size, gfp_mask); =20 return addr; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D77FC433F5 for ; Mon, 7 Mar 2022 10:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240094AbiCGKF6 (ORCPT ); Mon, 7 Mar 2022 05:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238230AbiCGJo7 (ORCPT ); Mon, 7 Mar 2022 04:44: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 C528961A20; Mon, 7 Mar 2022 01:41: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 ams.source.kernel.org (Postfix) with ESMTPS id 72E0DB8102B; Mon, 7 Mar 2022 09:41:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4A4FC340E9; Mon, 7 Mar 2022 09:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646100; bh=SmVEn4GoyNBFLoGjar7lW6qHLF92Ww9k0BA4JayBMZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKzLqa1HFsWdkxPz4EWFnB0/ej0Hcl2SbipmVHGLx+7zv38wIYRaNir7orw9yuO1i 0wYbGZGrpzC9tdEvoa3i+oB0DlppH25iK4Sgkehzr6/fRCu14i0/6NHJoZVxsmEru0 yvjAMPYQL9XE6R2q7seDCfmFRdS8YNG+nwPdGFog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Marco Elver , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 093/262] kasan: fix quarantine conflicting with init_on_free Date: Mon, 7 Mar 2022 10:17:17 +0100 Message-Id: <20220307091705.100178265@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andrey Konovalov [ Upstream commit 26dca996ea7b1ac7008b6b6063fc88b849e3ac3e ] KASAN's quarantine might save its metadata inside freed objects. As this happens after the memory is zeroed by the slab allocator when init_on_free is enabled, the memory coming out of quarantine is not properly zeroed. This causes lib/test_meminit.c tests to fail with Generic KASAN. Zero the metadata when the object is removed from quarantine. Link: https://lkml.kernel.org/r/2805da5df4b57138fdacd671f5d227d58950ba54.16= 40037083.git.andreyknvl@google.com Fixes: 6471384af2a6 ("mm: security: introduce init_on_alloc=3D1 and init_on= _free=3D1 boot options") Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Andrey Ryabinin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- mm/kasan/quarantine.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index d8ccff4c1275e..47ed4fc33a29e 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -132,11 +132,22 @@ static void *qlink_to_object(struct qlist_node *qlink= , struct kmem_cache *cache) static void qlink_free(struct qlist_node *qlink, struct kmem_cache *cache) { void *object =3D qlink_to_object(qlink, cache); + struct kasan_free_meta *meta =3D kasan_get_free_meta(cache, object); unsigned long flags; =20 if (IS_ENABLED(CONFIG_SLAB)) local_irq_save(flags); =20 + /* + * If init_on_free is enabled and KASAN's free metadata is stored in + * the object, zero the metadata. Otherwise, the object's memory will + * not be properly zeroed, as KASAN saves the metadata after the slab + * allocator zeroes the object. + */ + if (slab_want_init_on_free(cache) && + cache->kasan_info.free_meta_offset =3D=3D 0) + memzero_explicit(meta, sizeof(*meta)); + /* * As the object now gets freed from the quarantine, assume that its * free track is no longer valid. --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92F1CC43217 for ; Mon, 7 Mar 2022 10:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239412AbiCGKDS (ORCPT ); Mon, 7 Mar 2022 05:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241043AbiCGJlr (ORCPT ); Mon, 7 Mar 2022 04:41:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B64C6D86F; Mon, 7 Mar 2022 01:39:32 -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 E94F2B80F9F; Mon, 7 Mar 2022 09:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42AF7C340E9; Mon, 7 Mar 2022 09:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645969; bh=KZ+PuEy7mAb5pB9eyH1/wpOvcih8ATnl/GdjS9UgtVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JibjPwX3FSAD/HjA14AYvOlf9aI2sUbTP8bDdtwT/FpZKv9pDZodrrFNicHl2oZoL wUevBcxgmyngGT1PR7wS2Moiwym9WUZ0cd22fwEmuosrBHIXhQ/mDP/7R/1dV4ww4F CAyH8B134qKxifh0qhwg9/ab8f9L0UfXvG2rMEus= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Mina Almasry , Shuah Khan , Mike Kravetz , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 094/262] selftests/vm: make charge_reserved_hugetlb.sh work with existing cgroup setting Date: Mon, 7 Mar 2022 10:17:18 +0100 Message-Id: <20220307091705.127621717@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 209376ed2a8431ccb4c40fdcef11194fc1e749b0 ] The hugetlb cgroup reservation test charge_reserved_hugetlb.sh assume that no cgroup filesystems are mounted before running the test. That is not true in many cases. As a result, the test fails to run. Fix that by querying the current cgroup mount setting and using the existing cgroup setup instead before attempting to freshly mount a cgroup filesystem. Similar change is also made for hugetlb_reparenting_test.sh as well, though it still has problem if cgroup v2 isn't used. The patched test scripts were run on a centos 8 based system to verify that they ran properly. Link: https://lkml.kernel.org/r/20220106201359.1646575-1-longman@redhat.com Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests") Signed-off-by: Waiman Long Acked-by: Mina Almasry Cc: Shuah Khan Cc: Mike Kravetz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../selftests/vm/charge_reserved_hugetlb.sh | 34 +++++++++++-------- .../selftests/vm/hugetlb_reparenting_test.sh | 21 +++++++----- .../selftests/vm/write_hugetlb_memory.sh | 2 +- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh b/tools/= testing/selftests/vm/charge_reserved_hugetlb.sh index fe8fcfb334e06..a5cb4b09a46c4 100644 --- a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh @@ -24,19 +24,23 @@ if [[ "$1" =3D=3D "-cgroup-v2" ]]; then reservation_usage_file=3Drsvd.current fi =20 -cgroup_path=3D/dev/cgroup/memory -if [[ ! -e $cgroup_path ]]; then - mkdir -p $cgroup_path - if [[ $cgroup2 ]]; then +if [[ $cgroup2 ]]; then + cgroup_path=3D$(mount -t cgroup2 | head -1 | awk -e '{print $3}') + if [[ -z "$cgroup_path" ]]; then + cgroup_path=3D/dev/cgroup/memory mount -t cgroup2 none $cgroup_path - else + do_umount=3D1 + fi + echo "+hugetlb" >$cgroup_path/cgroup.subtree_control +else + cgroup_path=3D$(mount -t cgroup | grep ",hugetlb" | awk -e '{print $3}') + if [[ -z "$cgroup_path" ]]; then + cgroup_path=3D/dev/cgroup/memory mount -t cgroup memory,hugetlb $cgroup_path + do_umount=3D1 fi fi - -if [[ $cgroup2 ]]; then - echo "+hugetlb" >/dev/cgroup/memory/cgroup.subtree_control -fi +export cgroup_path =20 function cleanup() { if [[ $cgroup2 ]]; then @@ -108,7 +112,7 @@ function setup_cgroup() { =20 function wait_for_hugetlb_memory_to_get_depleted() { local cgroup=3D"$1" - local path=3D"/dev/cgroup/memory/$cgroup/hugetlb.${MB}MB.$reservation_us= age_file" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$reservation_usage_fi= le" # Wait for hugetlbfs memory to get depleted. while [ $(cat $path) !=3D 0 ]; do echo Waiting for hugetlb memory to get depleted. @@ -121,7 +125,7 @@ function wait_for_hugetlb_memory_to_get_reserved() { local cgroup=3D"$1" local size=3D"$2" =20 - local path=3D"/dev/cgroup/memory/$cgroup/hugetlb.${MB}MB.$reservation_us= age_file" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$reservation_usage_fi= le" # Wait for hugetlbfs memory to get written. while [ $(cat $path) !=3D $size ]; do echo Waiting for hugetlb memory reservation to reach size $size. @@ -134,7 +138,7 @@ function wait_for_hugetlb_memory_to_get_written() { local cgroup=3D"$1" local size=3D"$2" =20 - local path=3D"/dev/cgroup/memory/$cgroup/hugetlb.${MB}MB.$fault_usage_fi= le" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$fault_usage_file" # Wait for hugetlbfs memory to get written. while [ $(cat $path) !=3D $size ]; do echo Waiting for hugetlb memory to reach size $size. @@ -574,5 +578,7 @@ for populate in "" "-o"; do done # populate done # method =20 -umount $cgroup_path -rmdir $cgroup_path +if [[ $do_umount ]]; then + umount $cgroup_path + rmdir $cgroup_path +fi diff --git a/tools/testing/selftests/vm/hugetlb_reparenting_test.sh b/tools= /testing/selftests/vm/hugetlb_reparenting_test.sh index 4a9a3afe9fd4d..bf2d2a684edfd 100644 --- a/tools/testing/selftests/vm/hugetlb_reparenting_test.sh +++ b/tools/testing/selftests/vm/hugetlb_reparenting_test.sh @@ -18,19 +18,24 @@ if [[ "$1" =3D=3D "-cgroup-v2" ]]; then usage_file=3Dcurrent fi =20 -CGROUP_ROOT=3D'/dev/cgroup/memory' -MNT=3D'/mnt/huge/' =20 -if [[ ! -e $CGROUP_ROOT ]]; then - mkdir -p $CGROUP_ROOT - if [[ $cgroup2 ]]; then +if [[ $cgroup2 ]]; then + CGROUP_ROOT=3D$(mount -t cgroup2 | head -1 | awk -e '{print $3}') + if [[ -z "$CGROUP_ROOT" ]]; then + CGROUP_ROOT=3D/dev/cgroup/memory mount -t cgroup2 none $CGROUP_ROOT - sleep 1 - echo "+hugetlb +memory" >$CGROUP_ROOT/cgroup.subtree_control - else + do_umount=3D1 + fi + echo "+hugetlb +memory" >$CGROUP_ROOT/cgroup.subtree_control +else + CGROUP_ROOT=3D$(mount -t cgroup | grep ",hugetlb" | awk -e '{print $3}') + if [[ -z "$CGROUP_ROOT" ]]; then + CGROUP_ROOT=3D/dev/cgroup/memory mount -t cgroup memory,hugetlb $CGROUP_ROOT + do_umount=3D1 fi fi +MNT=3D'/mnt/huge/' =20 function get_machine_hugepage_size() { hpz=3D$(grep -i hugepagesize /proc/meminfo) diff --git a/tools/testing/selftests/vm/write_hugetlb_memory.sh b/tools/tes= ting/selftests/vm/write_hugetlb_memory.sh index d3d0d108924d4..70a02301f4c27 100644 --- a/tools/testing/selftests/vm/write_hugetlb_memory.sh +++ b/tools/testing/selftests/vm/write_hugetlb_memory.sh @@ -14,7 +14,7 @@ want_sleep=3D$8 reserve=3D$9 =20 echo "Putting task in cgroup '$cgroup'" -echo $$ > /dev/cgroup/memory/"$cgroup"/cgroup.procs +echo $$ > ${cgroup_path:-/dev/cgroup/memory}/"$cgroup"/cgroup.procs =20 echo "Method is $method" =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B52C2C47081 for ; Mon, 7 Mar 2022 10:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239166AbiCGKDK (ORCPT ); Mon, 7 Mar 2022 05:03:10 -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 S241044AbiCGJlr (ORCPT ); Mon, 7 Mar 2022 04:41:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E51D6D872; Mon, 7 Mar 2022 01:39: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 2794860F63; Mon, 7 Mar 2022 09:39:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36D08C340E9; Mon, 7 Mar 2022 09:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645972; bh=i6eWzl/jBwIItkoI0ahapdrJ09185ZksOOhX4gEGG0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pbyft/bXq93m406sNkEG+jwu9ljZiF+BHbqUrrwuARIGVvph7bkwi36B0uzcwCAdS OgQjWtiqB//gkCYgZ52no1651Z+Prw3ADsgMJ9ML06MvhH2fEBboYoFxz4kay1vzSS vaK8E3rmUI1JGhFuSySKdkIvfGh8akjpC64uIflE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , syzbot+4e697fe80a31aa7efe21@syzkaller.appspotmail.com, Mike Kravetz , Paolo Bonzini , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 095/262] hugetlbfs: fix off-by-one error in hugetlb_vmdelete_list() Date: Mon, 7 Mar 2022 10:17:19 +0100 Message-Id: <20220307091705.155232526@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson [ Upstream commit d6aba4c8e20d4d2bf65d589953f6d891c178f3a3 ] Pass "end - 1" instead of "end" when walking the interval tree in hugetlb_vmdelete_list() to fix an inclusive vs. exclusive bug. The two callers that pass a non-zero "end" treat it as exclusive, whereas the interval tree iterator expects an inclusive "last". E.g. punching a hole in a file that precisely matches the size of a single hugepage, with a vma starting right on the boundary, will result in unmap_hugepage_range() being called twice, with the second call having start=3D=3Dend. The off-by-one error doesn't cause functional problems as __unmap_hugepage_range() turns into a massive nop due to short-circuiting its for-loop on "address < end". But, the mmu_notifier invocations to invalid_range_{start,end}() are passed a bogus zero-sized range, which may be unexpected behavior for secondary MMUs. The bug was exposed by commit ed922739c919 ("KVM: Use interval tree to do fast hva lookup in memslots"), currently queued in the KVM tree for 5.17, which added a WARN to detect ranges with start=3D=3Dend. Link: https://lkml.kernel.org/r/20211228234257.1926057-1-seanjc@google.com Fixes: 1bfad99ab425 ("hugetlbfs: hugetlb_vmtruncate_list() needs to take a = range to delete") Signed-off-by: Sean Christopherson Reported-by: syzbot+4e697fe80a31aa7efe21@syzkaller.appspotmail.com Reviewed-by: Mike Kravetz Cc: Paolo Bonzini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- fs/hugetlbfs/inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index cdfb1ae78a3f8..54c4e0b0dda4a 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -409,10 +409,11 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pg= off_t start, pgoff_t end) struct vm_area_struct *vma; =20 /* - * end =3D=3D 0 indicates that the entire range after - * start should be unmapped. + * end =3D=3D 0 indicates that the entire range after start should be + * unmapped. Note, end is exclusive, whereas the interval tree takes + * an inclusive "last". */ - vma_interval_tree_foreach(vma, root, start, end ? end : ULONG_MAX) { + vma_interval_tree_foreach(vma, root, start, end ? end - 1 : ULONG_MAX) { unsigned long v_offset; unsigned long v_end; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B31E7C4332F for ; Mon, 7 Mar 2022 09:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbiCGJxV (ORCPT ); Mon, 7 Mar 2022 04:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241052AbiCGJlr (ORCPT ); Mon, 7 Mar 2022 04:41:47 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0909A6D952; Mon, 7 Mar 2022 01:39: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 sin.source.kernel.org (Postfix) with ESMTPS id 712A6CE0EA0; Mon, 7 Mar 2022 09:39:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 351A9C340E9; Mon, 7 Mar 2022 09:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645975; bh=UCPDdBc0WVD3RBg0+FDOGg5k3at7tdAwOx+sSeviBEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ng2JHgAqR42Z41TQjZIqKHVjYPPDWuQh53QYNJZrnfxel6weOMtuzL3WO3Z9nTXaZ PLsnJjWFVpQMMt8AfEkFpzVSfgZM/8HQFu2FrVqGKlJTfc+6RxgbV/GEoZbLp96bSF k4Okar2rCVWLsuB6yeZXva+ak0PMfJ4KiG8yjQ40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher , Harry Wentland , Nicholas Kazlauskas , Sasha Levin Subject: [PATCH 5.15 096/262] drm/amdgpu/display: Only set vblank_disable_immediate when PSR is not enabled Date: Mon, 7 Mar 2022 10:17:20 +0100 Message-Id: <20220307091705.182446530@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nicholas Kazlauskas [ Upstream commit 70897848730470cc477d5d89e6222c0f6a9ac173 ] [Why] PSR currently relies on the kernel's delayed vblank on/off mechanism as an implicit bufferring mechanism to prevent excessive entry/exit. Without this delay the user experience is impacted since it can take a few frames to enter/exit. [How] Only allow vblank disable immediate for DC when psr is not supported. Leave a TODO indicating that this support should be extended in the future to delay independent of the vblank interrupt. Fixes: 92020e81ddbeac ("drm/amdgpu/display: set vblank_disable_immediate fo= r DC") Acked-by: Alex Deucher Reviewed-by: Harry Wentland Signed-off-by: Nicholas Kazlauskas Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gp= u/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 5ae9b8133d6da..76967adc51606 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1279,9 +1279,6 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) adev_to_drm(adev)->mode_config.cursor_width =3D adev->dm.dc->caps.max_cur= sor_size; adev_to_drm(adev)->mode_config.cursor_height =3D adev->dm.dc->caps.max_cu= rsor_size; =20 - /* Disable vblank IRQs aggressively for power-saving */ - adev_to_drm(adev)->vblank_disable_immediate =3D true; - if (drm_vblank_init(adev_to_drm(adev), adev->dm.display_indexes_num)) { DRM_ERROR( "amdgpu: failed to initialize sw for display support.\n"); @@ -3866,6 +3863,14 @@ static int amdgpu_dm_initialize_drm_device(struct am= dgpu_device *adev) =20 } =20 + /* + * Disable vblank IRQs aggressively for power-saving. + * + * TODO: Fix vblank control helpers to delay PSR entry to allow this when= PSR + * is also supported. + */ + adev_to_drm(adev)->vblank_disable_immediate =3D !psr_feature_enabled; + /* Software is initialized. Now we can register interrupt handlers. */ switch (adev->asic_type) { #if defined(CONFIG_DRM_AMD_DC_SI) --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55832C433F5 for ; Mon, 7 Mar 2022 09:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235190AbiCGJxZ (ORCPT ); Mon, 7 Mar 2022 04:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241055AbiCGJls (ORCPT ); Mon, 7 Mar 2022 04:41:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 477DA6D95F; Mon, 7 Mar 2022 01:39: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 F2035B8102B; Mon, 7 Mar 2022 09:39:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 640E9C340E9; Mon, 7 Mar 2022 09:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645978; bh=K+Fd1FaBWbLR/t5pMs2rK/LmQ6NKxWaD2YAukPbuW0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cpsyP4IKHEjeYSGuZsoa5DBVvW2KRCo4kygPbXb/W5UAE60uhqDl0SQUDMix2A/Ld +40+fFp9XuiHDcW5/pNjfwHTqCL3HiZUwtAjOLpOHAxkzzQAdR9XyevUPdCbskBhgA ADFlnObE3RpadC3TO08dfonNdFfVy+OF6BZeGQRQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher , Sasha Levin , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH 5.15 097/262] drm/amdgpu: filter out radeon PCI device IDs Date: Mon, 7 Mar 2022 10:17:21 +0100 Message-Id: <20220307091705.217514411@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Deucher [ Upstream commit bdbeb0dde4258586bb2f481b12da1e83aa4766f3 ] Once we claim all 0x1002 PCI display class devices, we will need to filter out devices owned by radeon. v2: rename radeon id array to make it more clear that the devices are not supported by amdgpu. add r128, mach64 pci ids as well Acked-by: Christian K=C3=B6nig (v1) Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 638 +++++++++++++++++++++++- 1 file changed, 637 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index a8465e3195a67..82bb3e80219cd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -891,6 +891,636 @@ MODULE_PARM_DESC(smu_pptable_id, "specify pptable id to be used (-1 =3D auto(default) value, 0 =3D use ppt= able from vbios, > 0 =3D soft pptable id)"); module_param_named(smu_pptable_id, amdgpu_smu_pptable_id, int, 0444); =20 +/* These devices are not supported by amdgpu. + * They are supported by the mach64, r128, radeon drivers + */ +static const u16 amdgpu_unsupported_pciidlist[] =3D { + /* mach64 */ + 0x4354, + 0x4358, + 0x4554, + 0x4742, + 0x4744, + 0x4749, + 0x474C, + 0x474D, + 0x474E, + 0x474F, + 0x4750, + 0x4751, + 0x4752, + 0x4753, + 0x4754, + 0x4755, + 0x4756, + 0x4757, + 0x4758, + 0x4759, + 0x475A, + 0x4C42, + 0x4C44, + 0x4C47, + 0x4C49, + 0x4C4D, + 0x4C4E, + 0x4C50, + 0x4C51, + 0x4C52, + 0x4C53, + 0x5654, + 0x5655, + 0x5656, + /* r128 */ + 0x4c45, + 0x4c46, + 0x4d46, + 0x4d4c, + 0x5041, + 0x5042, + 0x5043, + 0x5044, + 0x5045, + 0x5046, + 0x5047, + 0x5048, + 0x5049, + 0x504A, + 0x504B, + 0x504C, + 0x504D, + 0x504E, + 0x504F, + 0x5050, + 0x5051, + 0x5052, + 0x5053, + 0x5054, + 0x5055, + 0x5056, + 0x5057, + 0x5058, + 0x5245, + 0x5246, + 0x5247, + 0x524b, + 0x524c, + 0x534d, + 0x5446, + 0x544C, + 0x5452, + /* radeon */ + 0x3150, + 0x3151, + 0x3152, + 0x3154, + 0x3155, + 0x3E50, + 0x3E54, + 0x4136, + 0x4137, + 0x4144, + 0x4145, + 0x4146, + 0x4147, + 0x4148, + 0x4149, + 0x414A, + 0x414B, + 0x4150, + 0x4151, + 0x4152, + 0x4153, + 0x4154, + 0x4155, + 0x4156, + 0x4237, + 0x4242, + 0x4336, + 0x4337, + 0x4437, + 0x4966, + 0x4967, + 0x4A48, + 0x4A49, + 0x4A4A, + 0x4A4B, + 0x4A4C, + 0x4A4D, + 0x4A4E, + 0x4A4F, + 0x4A50, + 0x4A54, + 0x4B48, + 0x4B49, + 0x4B4A, + 0x4B4B, + 0x4B4C, + 0x4C57, + 0x4C58, + 0x4C59, + 0x4C5A, + 0x4C64, + 0x4C66, + 0x4C67, + 0x4E44, + 0x4E45, + 0x4E46, + 0x4E47, + 0x4E48, + 0x4E49, + 0x4E4A, + 0x4E4B, + 0x4E50, + 0x4E51, + 0x4E52, + 0x4E53, + 0x4E54, + 0x4E56, + 0x5144, + 0x5145, + 0x5146, + 0x5147, + 0x5148, + 0x514C, + 0x514D, + 0x5157, + 0x5158, + 0x5159, + 0x515A, + 0x515E, + 0x5460, + 0x5462, + 0x5464, + 0x5548, + 0x5549, + 0x554A, + 0x554B, + 0x554C, + 0x554D, + 0x554E, + 0x554F, + 0x5550, + 0x5551, + 0x5552, + 0x5554, + 0x564A, + 0x564B, + 0x564F, + 0x5652, + 0x5653, + 0x5657, + 0x5834, + 0x5835, + 0x5954, + 0x5955, + 0x5974, + 0x5975, + 0x5960, + 0x5961, + 0x5962, + 0x5964, + 0x5965, + 0x5969, + 0x5a41, + 0x5a42, + 0x5a61, + 0x5a62, + 0x5b60, + 0x5b62, + 0x5b63, + 0x5b64, + 0x5b65, + 0x5c61, + 0x5c63, + 0x5d48, + 0x5d49, + 0x5d4a, + 0x5d4c, + 0x5d4d, + 0x5d4e, + 0x5d4f, + 0x5d50, + 0x5d52, + 0x5d57, + 0x5e48, + 0x5e4a, + 0x5e4b, + 0x5e4c, + 0x5e4d, + 0x5e4f, + 0x6700, + 0x6701, + 0x6702, + 0x6703, + 0x6704, + 0x6705, + 0x6706, + 0x6707, + 0x6708, + 0x6709, + 0x6718, + 0x6719, + 0x671c, + 0x671d, + 0x671f, + 0x6720, + 0x6721, + 0x6722, + 0x6723, + 0x6724, + 0x6725, + 0x6726, + 0x6727, + 0x6728, + 0x6729, + 0x6738, + 0x6739, + 0x673e, + 0x6740, + 0x6741, + 0x6742, + 0x6743, + 0x6744, + 0x6745, + 0x6746, + 0x6747, + 0x6748, + 0x6749, + 0x674A, + 0x6750, + 0x6751, + 0x6758, + 0x6759, + 0x675B, + 0x675D, + 0x675F, + 0x6760, + 0x6761, + 0x6762, + 0x6763, + 0x6764, + 0x6765, + 0x6766, + 0x6767, + 0x6768, + 0x6770, + 0x6771, + 0x6772, + 0x6778, + 0x6779, + 0x677B, + 0x6840, + 0x6841, + 0x6842, + 0x6843, + 0x6849, + 0x684C, + 0x6850, + 0x6858, + 0x6859, + 0x6880, + 0x6888, + 0x6889, + 0x688A, + 0x688C, + 0x688D, + 0x6898, + 0x6899, + 0x689b, + 0x689c, + 0x689d, + 0x689e, + 0x68a0, + 0x68a1, + 0x68a8, + 0x68a9, + 0x68b0, + 0x68b8, + 0x68b9, + 0x68ba, + 0x68be, + 0x68bf, + 0x68c0, + 0x68c1, + 0x68c7, + 0x68c8, + 0x68c9, + 0x68d8, + 0x68d9, + 0x68da, + 0x68de, + 0x68e0, + 0x68e1, + 0x68e4, + 0x68e5, + 0x68e8, + 0x68e9, + 0x68f1, + 0x68f2, + 0x68f8, + 0x68f9, + 0x68fa, + 0x68fe, + 0x7100, + 0x7101, + 0x7102, + 0x7103, + 0x7104, + 0x7105, + 0x7106, + 0x7108, + 0x7109, + 0x710A, + 0x710B, + 0x710C, + 0x710E, + 0x710F, + 0x7140, + 0x7141, + 0x7142, + 0x7143, + 0x7144, + 0x7145, + 0x7146, + 0x7147, + 0x7149, + 0x714A, + 0x714B, + 0x714C, + 0x714D, + 0x714E, + 0x714F, + 0x7151, + 0x7152, + 0x7153, + 0x715E, + 0x715F, + 0x7180, + 0x7181, + 0x7183, + 0x7186, + 0x7187, + 0x7188, + 0x718A, + 0x718B, + 0x718C, + 0x718D, + 0x718F, + 0x7193, + 0x7196, + 0x719B, + 0x719F, + 0x71C0, + 0x71C1, + 0x71C2, + 0x71C3, + 0x71C4, + 0x71C5, + 0x71C6, + 0x71C7, + 0x71CD, + 0x71CE, + 0x71D2, + 0x71D4, + 0x71D5, + 0x71D6, + 0x71DA, + 0x71DE, + 0x7200, + 0x7210, + 0x7211, + 0x7240, + 0x7243, + 0x7244, + 0x7245, + 0x7246, + 0x7247, + 0x7248, + 0x7249, + 0x724A, + 0x724B, + 0x724C, + 0x724D, + 0x724E, + 0x724F, + 0x7280, + 0x7281, + 0x7283, + 0x7284, + 0x7287, + 0x7288, + 0x7289, + 0x728B, + 0x728C, + 0x7290, + 0x7291, + 0x7293, + 0x7297, + 0x7834, + 0x7835, + 0x791e, + 0x791f, + 0x793f, + 0x7941, + 0x7942, + 0x796c, + 0x796d, + 0x796e, + 0x796f, + 0x9400, + 0x9401, + 0x9402, + 0x9403, + 0x9405, + 0x940A, + 0x940B, + 0x940F, + 0x94A0, + 0x94A1, + 0x94A3, + 0x94B1, + 0x94B3, + 0x94B4, + 0x94B5, + 0x94B9, + 0x9440, + 0x9441, + 0x9442, + 0x9443, + 0x9444, + 0x9446, + 0x944A, + 0x944B, + 0x944C, + 0x944E, + 0x9450, + 0x9452, + 0x9456, + 0x945A, + 0x945B, + 0x945E, + 0x9460, + 0x9462, + 0x946A, + 0x946B, + 0x947A, + 0x947B, + 0x9480, + 0x9487, + 0x9488, + 0x9489, + 0x948A, + 0x948F, + 0x9490, + 0x9491, + 0x9495, + 0x9498, + 0x949C, + 0x949E, + 0x949F, + 0x94C0, + 0x94C1, + 0x94C3, + 0x94C4, + 0x94C5, + 0x94C6, + 0x94C7, + 0x94C8, + 0x94C9, + 0x94CB, + 0x94CC, + 0x94CD, + 0x9500, + 0x9501, + 0x9504, + 0x9505, + 0x9506, + 0x9507, + 0x9508, + 0x9509, + 0x950F, + 0x9511, + 0x9515, + 0x9517, + 0x9519, + 0x9540, + 0x9541, + 0x9542, + 0x954E, + 0x954F, + 0x9552, + 0x9553, + 0x9555, + 0x9557, + 0x955f, + 0x9580, + 0x9581, + 0x9583, + 0x9586, + 0x9587, + 0x9588, + 0x9589, + 0x958A, + 0x958B, + 0x958C, + 0x958D, + 0x958E, + 0x958F, + 0x9590, + 0x9591, + 0x9593, + 0x9595, + 0x9596, + 0x9597, + 0x9598, + 0x9599, + 0x959B, + 0x95C0, + 0x95C2, + 0x95C4, + 0x95C5, + 0x95C6, + 0x95C7, + 0x95C9, + 0x95CC, + 0x95CD, + 0x95CE, + 0x95CF, + 0x9610, + 0x9611, + 0x9612, + 0x9613, + 0x9614, + 0x9615, + 0x9616, + 0x9640, + 0x9641, + 0x9642, + 0x9643, + 0x9644, + 0x9645, + 0x9647, + 0x9648, + 0x9649, + 0x964a, + 0x964b, + 0x964c, + 0x964e, + 0x964f, + 0x9710, + 0x9711, + 0x9712, + 0x9713, + 0x9714, + 0x9715, + 0x9802, + 0x9803, + 0x9804, + 0x9805, + 0x9806, + 0x9807, + 0x9808, + 0x9809, + 0x980A, + 0x9900, + 0x9901, + 0x9903, + 0x9904, + 0x9905, + 0x9906, + 0x9907, + 0x9908, + 0x9909, + 0x990A, + 0x990B, + 0x990C, + 0x990D, + 0x990E, + 0x990F, + 0x9910, + 0x9913, + 0x9917, + 0x9918, + 0x9919, + 0x9990, + 0x9991, + 0x9992, + 0x9993, + 0x9994, + 0x9995, + 0x9996, + 0x9997, + 0x9998, + 0x9999, + 0x999A, + 0x999B, + 0x999C, + 0x999D, + 0x99A0, + 0x99A2, + 0x99A4, +}; + static const struct pci_device_id pciidlist[] =3D { #ifdef CONFIG_DRM_AMDGPU_SI {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, @@ -1273,7 +1903,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, struct drm_device *ddev; struct amdgpu_device *adev; unsigned long flags =3D ent->driver_data; - int ret, retry =3D 0; + int ret, retry =3D 0, i; bool supports_atomic =3D false; bool is_fw_fb; resource_size_t base, size; @@ -1281,6 +1911,12 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, if (amdgpu_aspm =3D=3D -1 && !pcie_aspm_enabled(pdev)) amdgpu_aspm =3D 0; =20 + /* skip devices which are owned by radeon */ + for (i =3D 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) { + if (amdgpu_unsupported_pciidlist[i] =3D=3D pdev->device) + return -ENODEV; + } + if (amdgpu_virtual_display || amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK)) supports_atomic =3D true; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 670A9C433F5 for ; Mon, 7 Mar 2022 09:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238695AbiCGJxu (ORCPT ); Mon, 7 Mar 2022 04:53:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241061AbiCGJls (ORCPT ); Mon, 7 Mar 2022 04:41:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E36E6D953; Mon, 7 Mar 2022 01:39: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 ams.source.kernel.org (Postfix) with ESMTPS id E79F7B80F9F; Mon, 7 Mar 2022 09:39:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 573ADC340F3; Mon, 7 Mar 2022 09:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645981; bh=nQvkdzM2YBwqxdxMmCeSg7GZgPuxTQOZqpEjIrd4Ekc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKBP9eLcVNuP+9kpZz7cF6vkBYpEMd7p08pA9+0lmxQ77NqiBJopwWqfZ+ryunRdA 0LHaTdm80r6d1/Shfp9PQor2g/uYyrKocE2HcV5sp6NalTrHvJKfqx8dLh2uy5ldEX b2Zm5o30LtSRxEF7jyIAE3YrYsHrC4V+ONWgLrY4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 098/262] drm/amdgpu: filter out radeon secondary ids as well Date: Mon, 7 Mar 2022 10:17:22 +0100 Message-Id: <20220307091705.246592441@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Deucher [ Upstream commit 9e5a14bce2402e84251a10269df0235cd7ce9234 ] Older radeon boards (r2xx-r5xx) had secondary PCI functions which we solely there for supporting multi-head on OSs with special requirements. Add them to the unsupported list as well so we don't attempt to bind to them. The driver would fail to bind to them anyway, but this does so in a cleaner way that should not confuse the user. Cc: stable@vger.kernel.org Acked-by: Christian K=C3=B6nig Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 81 +++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index 82bb3e80219cd..5a7fef324c820 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1519,6 +1519,87 @@ static const u16 amdgpu_unsupported_pciidlist[] =3D { 0x99A0, 0x99A2, 0x99A4, + /* radeon secondary ids */ + 0x3171, + 0x3e70, + 0x4164, + 0x4165, + 0x4166, + 0x4168, + 0x4170, + 0x4171, + 0x4172, + 0x4173, + 0x496e, + 0x4a69, + 0x4a6a, + 0x4a6b, + 0x4a70, + 0x4a74, + 0x4b69, + 0x4b6b, + 0x4b6c, + 0x4c6e, + 0x4e64, + 0x4e65, + 0x4e66, + 0x4e67, + 0x4e68, + 0x4e69, + 0x4e6a, + 0x4e71, + 0x4f73, + 0x5569, + 0x556b, + 0x556d, + 0x556f, + 0x5571, + 0x5854, + 0x5874, + 0x5940, + 0x5941, + 0x5b72, + 0x5b73, + 0x5b74, + 0x5b75, + 0x5d44, + 0x5d45, + 0x5d6d, + 0x5d6f, + 0x5d72, + 0x5d77, + 0x5e6b, + 0x5e6d, + 0x7120, + 0x7124, + 0x7129, + 0x712e, + 0x712f, + 0x7162, + 0x7163, + 0x7166, + 0x7167, + 0x7172, + 0x7173, + 0x71a0, + 0x71a1, + 0x71a3, + 0x71a7, + 0x71bb, + 0x71e0, + 0x71e1, + 0x71e2, + 0x71e6, + 0x71e7, + 0x71f2, + 0x7269, + 0x726b, + 0x726e, + 0x72a0, + 0x72a8, + 0x72b1, + 0x72b3, + 0x793f, }; =20 static const struct pci_device_id pciidlist[] =3D { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7516C433F5 for ; Mon, 7 Mar 2022 09:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237951AbiCGJxg (ORCPT ); Mon, 7 Mar 2022 04:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241060AbiCGJls (ORCPT ); Mon, 7 Mar 2022 04:41:48 -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 989916D973; Mon, 7 Mar 2022 01:39: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 dfw.source.kernel.org (Postfix) with ESMTPS id 38F65611D5; Mon, 7 Mar 2022 09:39:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C0CFC340F4; Mon, 7 Mar 2022 09:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645984; bh=SNmdDb/KWY/UBhJnHPu+wPZKAzGOM7GjBTFAMw0j1cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WvmQHur5GBZsOinvyhJfznJnzrqtiEehXDNQWs95uzQEC+yZmmuItouGJTUf2UatP EufewXn1aiYXxfrDydXYwe5LiyQel8ZYu+XBrEnWPPjXzTvzpRHMbGnAv8F6OnVrcf HX2bb3R6MraU+KLGU6Acb9wVPKGOwkclOyWBrMjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhan Liu , Rodrigo Siqueira , Nikola Cornij , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 099/262] drm/amd/display: Use adjusted DCN301 watermarks Date: Mon, 7 Mar 2022 10:17:23 +0100 Message-Id: <20220307091705.274209090@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nikola Cornij [ Upstream commit 808643ea56a2f96a42873d5e11c399957d6493aa ] [why] If DCN30 watermark calc is used for DCN301, the calculated values are wrong due to the data structure mismatch between DCN30 and DCN301. However, using the original DCN301 watermark values causes underflow. [how] - Add DCN21-style watermark calculations - Adjust DCN301 watermark values to remove the underflow Reviewed-by: Zhan Liu Acked-by: Rodrigo Siqueira Signed-off-by: Nikola Cornij Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../display/dc/clk_mgr/dcn301/vg_clk_mgr.c | 4 +- .../amd/display/dc/dcn301/dcn301_resource.c | 96 ++++++++++++++++++- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c b/d= rivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c index 7046da14bb2a5..3eee32faa208c 100644 --- 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,8 +582,8 @@ 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 5.32, - .sr_enter_plus_exit_time_us =3D 6.38, + .sr_exit_time_us =3D 7.95, + .sr_enter_plus_exit_time_us =3D 9, .valid =3D true, }, { diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c b/driv= ers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c index 26ebe00a55f67..dea358b01791c 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c @@ -1622,12 +1622,106 @@ static void dcn301_update_bw_bounding_box(struct d= c *dc, struct clk_bw_params *b dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30); } =20 +static void calculate_wm_set_for_vlevel( + int vlevel, + struct wm_range_table_entry *table_entry, + struct dcn_watermarks *wm_set, + struct display_mode_lib *dml, + display_e2e_pipe_params_st *pipes, + int pipe_cnt) +{ + double dram_clock_change_latency_cached =3D dml->soc.dram_clock_change_la= tency_us; + + ASSERT(vlevel < dml->soc.num_states); + /* only pipe 0 is read for voltage and dcf/soc clocks */ + pipes[0].clks_cfg.voltage =3D vlevel; + pipes[0].clks_cfg.dcfclk_mhz =3D dml->soc.clock_limits[vlevel].dcfclk_mhz; + pipes[0].clks_cfg.socclk_mhz =3D dml->soc.clock_limits[vlevel].socclk_mhz; + + dml->soc.dram_clock_change_latency_us =3D table_entry->pstate_latency_us; + dml->soc.sr_exit_time_us =3D table_entry->sr_exit_time_us; + dml->soc.sr_enter_plus_exit_time_us =3D table_entry->sr_enter_plus_exit_t= ime_us; + + wm_set->urgent_ns =3D get_wm_urgent(dml, pipes, pipe_cnt) * 1000; + wm_set->cstate_pstate.cstate_enter_plus_exit_ns =3D get_wm_stutter_enter_= exit(dml, pipes, pipe_cnt) * 1000; + wm_set->cstate_pstate.cstate_exit_ns =3D get_wm_stutter_exit(dml, pipes, = pipe_cnt) * 1000; + wm_set->cstate_pstate.pstate_change_ns =3D get_wm_dram_clock_change(dml, = pipes, pipe_cnt) * 1000; + wm_set->pte_meta_urgent_ns =3D get_wm_memory_trip(dml, pipes, pipe_cnt) *= 1000; + wm_set->frac_urg_bw_nom =3D get_fraction_of_urgent_bandwidth(dml, pipes, = pipe_cnt) * 1000; + wm_set->frac_urg_bw_flip =3D get_fraction_of_urgent_bandwidth_imm_flip(dm= l, pipes, pipe_cnt) * 1000; + wm_set->urgent_latency_ns =3D get_urgent_latency(dml, pipes, pipe_cnt) * = 1000; + dml->soc.dram_clock_change_latency_us =3D dram_clock_change_latency_cache= d; + +} + +static void dcn301_calculate_wm_and_dlg( + struct dc *dc, struct dc_state *context, + display_e2e_pipe_params_st *pipes, + int pipe_cnt, + int vlevel_req) +{ + int i, pipe_idx; + int vlevel, vlevel_max; + struct wm_range_table_entry *table_entry; + struct clk_bw_params *bw_params =3D dc->clk_mgr->bw_params; + + ASSERT(bw_params); + + vlevel_max =3D bw_params->clk_table.num_entries - 1; + + /* WM Set D */ + table_entry =3D &bw_params->wm_table.entries[WM_D]; + if (table_entry->wm_type =3D=3D WM_TYPE_RETRAINING) + vlevel =3D 0; + else + vlevel =3D vlevel_max; + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.d, + &context->bw_ctx.dml, pipes, pipe_cnt); + /* WM Set C */ + table_entry =3D &bw_params->wm_table.entries[WM_C]; + vlevel =3D min(max(vlevel_req, 2), vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.c, + &context->bw_ctx.dml, pipes, pipe_cnt); + /* WM Set B */ + table_entry =3D &bw_params->wm_table.entries[WM_B]; + vlevel =3D min(max(vlevel_req, 1), vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.b, + &context->bw_ctx.dml, pipes, pipe_cnt); + + /* WM Set A */ + table_entry =3D &bw_params->wm_table.entries[WM_A]; + vlevel =3D min(vlevel_req, vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.a, + &context->bw_ctx.dml, pipes, pipe_cnt); + + for (i =3D 0, pipe_idx =3D 0; i < dc->res_pool->pipe_count; i++) { + if (!context->res_ctx.pipe_ctx[i].stream) + continue; + + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D get_dispclk_calculated(&context= ->bw_ctx.dml, pipes, pipe_cnt); + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D get_dppclk_calculated(&context->= bw_ctx.dml, pipes, pipe_cnt, pipe_idx); + + if (dc->config.forced_clocks) { + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D context->bw_ctx.dml.soc.clock_= limits[0].dispclk_mhz; + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D context->bw_ctx.dml.soc.clock_l= imits[0].dppclk_mhz; + } + if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * = 1000) + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D dc->debug.min_disp_clk_khz / 1= 000.0; + if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 10= 00) + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D dc->debug.min_dpp_clk_khz / 100= 0.0; + + pipe_idx++; + } + + dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel); +} + static struct resource_funcs dcn301_res_pool_funcs =3D { .destroy =3D dcn301_destroy_resource_pool, .link_enc_create =3D dcn301_link_encoder_create, .panel_cntl_create =3D dcn301_panel_cntl_create, .validate_bandwidth =3D dcn30_validate_bandwidth, - .calculate_wm_and_dlg =3D dcn30_calculate_wm_and_dlg, + .calculate_wm_and_dlg =3D dcn301_calculate_wm_and_dlg, .update_soc_for_wm_a =3D dcn30_update_soc_for_wm_a, .populate_dml_pipes =3D dcn30_populate_dml_pipes_from_context, .acquire_idle_pipe_for_layer =3D dcn20_acquire_idle_pipe_for_layer, --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC840C433EF for ; Mon, 7 Mar 2022 09:52:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235271AbiCGJxa (ORCPT ); Mon, 7 Mar 2022 04:53:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241066AbiCGJls (ORCPT ); Mon, 7 Mar 2022 04:41:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E05D6D96D; Mon, 7 Mar 2022 01:39: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 59D65B8102B; Mon, 7 Mar 2022 09:39:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F894C340E9; Mon, 7 Mar 2022 09:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645988; bh=15NCdDwgdan47lX7Z/DQ3J3B52NIddNo5T2bsAMTDkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSwnqSs94/zA9j2BOTzD1vxQPnJDZkaWxlt7kTst+FQuiNNdSCarCtZ/v/AvYO+wA jFw0IB/pM8PnUQhZ/cjGGV64wAfE4UdJu7iZ0R1Fuyha2q60zfWyzzf+6FriNNvGCx 7rxrldDI9wXrrifyID+JVUPR4+3FwSwsEMA7zSWs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Hersen Wu , Anson Jacob , Harry Wentland , Rodrigo Siqueira , Agustin Gutierrez , Daniel Wheeler , Qingqing Zhuo , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 100/262] drm/amd/display: move FPU associated DSC code to DML folder Date: Mon, 7 Mar 2022 10:17:24 +0100 Message-Id: <20220307091705.301226097@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Qingqing Zhuo [ Upstream commit d738db6883df3e3c513f9e777c842262693f951b ] [Why & How] As part of the FPU isolation work documented in https://patchwork.freedesktop.org/series/93042/, isolate code that uses FPU in DSC to DML, where all FPU code should locate. This change does not refactor any functions but move code around. Cc: Christian K=C3=B6nig Cc: Hersen Wu Cc: Anson Jacob Cc: Harry Wentland Reviewed-by: Rodrigo Siqueira Acked-by: Agustin Gutierrez Tested-by: Anson Jacob Tested-by: Daniel Wheeler Signed-off-by: Qingqing Zhuo Acked-by: Christian K=C3=B6nig Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/dml/Makefile | 3 + .../amd/display/dc/{ =3D> dml}/dsc/qp_tables.h | 0 .../drm/amd/display/dc/dml/dsc/rc_calc_fpu.c | 291 ++++++++++++++++++ .../drm/amd/display/dc/dml/dsc/rc_calc_fpu.h | 94 ++++++ drivers/gpu/drm/amd/display/dc/dsc/Makefile | 29 -- drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c | 259 ---------------- drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h | 50 +-- .../gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c | 1 - 8 files changed, 389 insertions(+), 338 deletions(-) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/dsc/qp_tables.h (100%) create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.h diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index 56055df2e8d2e..9009b92490f34 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -70,6 +70,7 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_mode_vba_30.o := =3D $(dml_ccflags) $(fram CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(dml_ccfl= ags) +CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_ccflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o :=3D $(dml_rcflags) @@ -84,6 +85,7 @@ CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_c= alc_30.o :=3D $(dml_rcfla CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o :=3D $(dml_= rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(d= ml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_rcflags) +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_rcflags) endif CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o :=3D $(dml_ccflags) @@ -99,6 +101,7 @@ DML +=3D dcn20/display_rq_dlg_calc_20v2.o dcn20/display_= mode_vba_20v2.o DML +=3D dcn21/display_rq_dlg_calc_21.o dcn21/display_mode_vba_21.o DML +=3D dcn30/display_mode_vba_30.o dcn30/display_rq_dlg_calc_30.o DML +=3D dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o +DML +=3D dsc/rc_calc_fpu.o endif =20 AMD_DAL_DML =3D $(addprefix $(AMDDALPATH)/dc/dml/,$(DML)) diff --git a/drivers/gpu/drm/amd/display/dc/dsc/qp_tables.h b/drivers/gpu/d= rm/amd/display/dc/dml/dsc/qp_tables.h similarity index 100% rename from drivers/gpu/drm/amd/display/dc/dsc/qp_tables.h rename to drivers/gpu/drm/amd/display/dc/dml/dsc/qp_tables.h diff --git a/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c b/drivers= /gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c new file mode 100644 index 0000000000000..3ee858f311d12 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c @@ -0,0 +1,291 @@ +/* + * Copyright 2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software= "), + * to deal in the Software without restriction, including without limitati= on + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#include "rc_calc_fpu.h" + +#include "qp_tables.h" +#include "amdgpu_dm/dc_fpu.h" + +#define table_hash(mode, bpc, max_min) ((mode << 16) | (bpc << 8) | max_mi= n) + +#define MODE_SELECT(val444, val422, val420) \ + (cm =3D=3D CM_444 || cm =3D=3D CM_RGB) ? (val444) : (cm =3D=3D CM_422 ? (= val422) : (val420)) + + +#define TABLE_CASE(mode, bpc, max) case (table_hash(mode, BPC_##bpc, max= )): \ + table =3D qp_table_##mode##_##bpc##bpc_##max; \ + table_size =3D sizeof(qp_table_##mode##_##bpc##bpc_##max)/sizeof(*qp_tabl= e_##mode##_##bpc##bpc_##max); \ + break + +static int median3(int a, int b, int c) +{ + if (a > b) + swap(a, b); + if (b > c) + swap(b, c); + if (a > b) + swap(b, c); + + return b; +} + +static double dsc_roundf(double num) +{ + if (num < 0.0) + num =3D num - 0.5; + else + num =3D num + 0.5; + + return (int)(num); +} + +static double dsc_ceil(double num) +{ + double retval =3D (int)num; + + if (retval !=3D num && num > 0) + retval =3D num + 1; + + return (int)retval; +} + +static void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp= bpc, + enum max_min max_min, float bpp) +{ + int mode =3D MODE_SELECT(444, 422, 420); + int sel =3D table_hash(mode, bpc, max_min); + int table_size =3D 0; + int index; + const struct qp_entry *table =3D 0L; + + // alias enum + enum { min =3D DAL_MM_MIN, max =3D DAL_MM_MAX }; + switch (sel) { + TABLE_CASE(444, 8, max); + TABLE_CASE(444, 8, min); + TABLE_CASE(444, 10, max); + TABLE_CASE(444, 10, min); + TABLE_CASE(444, 12, max); + TABLE_CASE(444, 12, min); + TABLE_CASE(422, 8, max); + TABLE_CASE(422, 8, min); + TABLE_CASE(422, 10, max); + TABLE_CASE(422, 10, min); + TABLE_CASE(422, 12, max); + TABLE_CASE(422, 12, min); + TABLE_CASE(420, 8, max); + TABLE_CASE(420, 8, min); + TABLE_CASE(420, 10, max); + TABLE_CASE(420, 10, min); + TABLE_CASE(420, 12, max); + TABLE_CASE(420, 12, min); + } + + if (table =3D=3D 0) + return; + + index =3D (bpp - table[0].bpp) * 2; + + /* requested size is bigger than the table */ + if (index >=3D table_size) { + dm_error("ERROR: Requested rc_calc to find a bpp entry that exceeds the = table size\n"); + return; + } + + memcpy(qps, table[index].qps, sizeof(qp_set)); +} + +static void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) +{ + int *p =3D ofs; + + if (mode =3D=3D CM_444 || mode =3D=3D CM_RGB) { + *p++ =3D (bpp <=3D 6) ? (0) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (2)= : ((bpp >=3D 15) ? (10) : ((((bpp > 6) && (bpp < 8))) ? (0 + dsc_roundf((b= pp - 6) * (2 / 2.0))) : (2 + dsc_roundf((bpp - 12) * (8 / 3.0)))))); + *p++ =3D (bpp <=3D 6) ? (-2) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (0= ) : ((bpp >=3D 15) ? (8) : ((((bpp > 6) && (bpp < 8))) ? (-2 + dsc_roundf((= bpp - 6) * (2 / 2.0))) : (0 + dsc_roundf((bpp - 12) * (8 / 3.0)))))); + *p++ =3D (bpp <=3D 6) ? (-2) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (0= ) : ((bpp >=3D 15) ? (6) : ((((bpp > 6) && (bpp < 8))) ? (-2 + dsc_roundf((= bpp - 6) * (2 / 2.0))) : (0 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); + *p++ =3D (bpp <=3D 6) ? (-4) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (-= 2) : ((bpp >=3D 15) ? (4) : ((((bpp > 6) && (bpp < 8))) ? (-4 + dsc_roundf(= (bpp - 6) * (2 / 2.0))) : (-2 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); + *p++ =3D (bpp <=3D 6) ? (-6) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (-= 4) : ((bpp >=3D 15) ? (2) : ((((bpp > 6) && (bpp < 8))) ? (-6 + dsc_roundf(= (bpp - 6) * (2 / 2.0))) : (-4 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); + *p++ =3D (bpp <=3D 12) ? (-6) : ((bpp >=3D 15) ? (0) : (-6 + dsc_roundf(= (bpp - 12) * (6 / 3.0)))); + *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-2) : (-8 + dsc_roundf= ((bpp - 12) * (6 / 3.0)))); + *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-4) : (-8 + dsc_roundf= ((bpp - 12) * (4 / 3.0)))); + *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-6) : (-8 + dsc_roundf= ((bpp - 12) * (2 / 3.0)))); + *p++ =3D (bpp <=3D 12) ? (-10) : ((bpp >=3D 15) ? (-8) : (-10 + dsc_roun= df((bpp - 12) * (2 / 3.0)))); + *p++ =3D -10; + *p++ =3D (bpp <=3D 6) ? (-12) : ((bpp >=3D 8) ? (-10) : (-12 + dsc_rou= ndf((bpp - 6) * (2 / 2.0)))); + *p++ =3D -12; + *p++ =3D -12; + *p++ =3D -12; + } else if (mode =3D=3D CM_422) { + *p++ =3D (bpp <=3D 8) ? (2) : ((bpp >=3D 10) ? (10) : (2 + dsc_roundf((= bpp - 8) * (8 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (0) : ((bpp >=3D 10) ? (8) : (0 + dsc_roundf((b= pp - 8) * (8 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (0) : ((bpp >=3D 10) ? (6) : (0 + dsc_roundf((b= pp - 8) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-2) : ((bpp >=3D 10) ? (4) : (-2 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-4) : ((bpp >=3D 10) ? (2) : (-4 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-6) : ((bpp >=3D 10) ? (0) : (-6 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-2) : (-8 + dsc_roundf= ((bpp - 8) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-4) : (-8 + dsc_roundf= ((bpp - 8) * (4 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-6) : (-8 + dsc_roundf= ((bpp - 8) * (2 / 2.0)))); + *p++ =3D (bpp <=3D 8) ? (-10) : ((bpp >=3D 10) ? (-8) : (-10 + dsc_roun= df((bpp - 8) * (2 / 2.0)))); + *p++ =3D -10; + *p++ =3D (bpp <=3D 6) ? (-12) : ((bpp >=3D 7) ? (-10) : (-12 + dsc_roun= df((bpp - 6) * (2.0 / 1)))); + *p++ =3D -12; + *p++ =3D -12; + *p++ =3D -12; + } else { + *p++ =3D (bpp <=3D 6) ? (2) : ((bpp >=3D 8) ? (10) : (2 + dsc_roundf((= bpp - 6) * (8 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (0) : ((bpp >=3D 8) ? (8) : (0 + dsc_roundf((b= pp - 6) * (8 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (0) : ((bpp >=3D 8) ? (6) : (0 + dsc_roundf((b= pp - 6) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-2) : ((bpp >=3D 8) ? (4) : (-2 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-4) : ((bpp >=3D 8) ? (2) : (-4 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-6) : ((bpp >=3D 8) ? (0) : (-6 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-2) : (-8 + dsc_roundf= ((bpp - 6) * (6 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-4) : (-8 + dsc_roundf= ((bpp - 6) * (4 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-6) : (-8 + dsc_roundf= ((bpp - 6) * (2 / 2.0)))); + *p++ =3D (bpp <=3D 6) ? (-10) : ((bpp >=3D 8) ? (-8) : (-10 + dsc_roun= df((bpp - 6) * (2 / 2.0)))); + *p++ =3D -10; + *p++ =3D (bpp <=3D 4) ? (-12) : ((bpp >=3D 5) ? (-10) : (-12 + dsc_rou= ndf((bpp - 4) * (2 / 1.0)))); + *p++ =3D -12; + *p++ =3D -12; + *p++ =3D -12; + } +} + +void _do_calc_rc_params(struct rc_params *rc, + enum colour_mode cm, + enum bits_per_comp bpc, + u16 drm_bpp, + bool is_navite_422_or_420, + int slice_width, + int slice_height, + int minor_version) +{ + float bpp; + float bpp_group; + float initial_xmit_delay_factor; + int padding_pixels; + int i; + + dc_assert_fp_enabled(); + + bpp =3D ((float)drm_bpp / 16.0); + /* in native_422 or native_420 modes, the bits_per_pixel is double the + * target bpp (the latter is what calc_rc_params expects) + */ + if (is_navite_422_or_420) + bpp /=3D 2.0; + + rc->rc_quant_incr_limit0 =3D ((bpc =3D=3D BPC_8) ? 11 : (bpc =3D=3D BPC_1= 0 ? 15 : 19)) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : 0); + rc->rc_quant_incr_limit1 =3D ((bpc =3D=3D BPC_8) ? 11 : (bpc =3D=3D BPC_1= 0 ? 15 : 19)) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : 0); + + bpp_group =3D MODE_SELECT(bpp, bpp * 2.0, bpp * 2.0); + + switch (cm) { + case CM_420: + rc->initial_fullness_offset =3D (bpp >=3D 6) ? (2048) : ((bpp <=3D 4) = ? (6144) : ((((bpp > 4) && (bpp <=3D 5))) ? (6144 - dsc_roundf((bpp - 4) = * (512))) : (5632 - dsc_roundf((bpp - 5) * (3584))))); + rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)((3 * bpc * 3) - (3 * bpp_group))); + rc->second_line_bpg_offset =3D median3(0, 12, (int)((3 * bpc * 3) - (3 = * bpp_group))); + break; + case CM_422: + rc->initial_fullness_offset =3D (bpp >=3D 8) ? (2048) : ((bpp <=3D 7) = ? (5632) : (5632 - dsc_roundf((bpp - 7) * (3584)))); + rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)((3 * bpc * 4) - (3 * bpp_group))); + rc->second_line_bpg_offset =3D 0; + break; + case CM_444: + case CM_RGB: + rc->initial_fullness_offset =3D (bpp >=3D 12) ? (2048) : ((bpp <=3D 8) = ? (6144) : ((((bpp > 8) && (bpp <=3D 10))) ? (6144 - dsc_roundf((bpp - 8) = * (512 / 2))) : (5632 - dsc_roundf((bpp - 10) * (3584 / 2))))); + rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)(((3 * bpc + (cm =3D=3D CM_444 ? 0 : 2)) * 3) - (= 3 * bpp_group))); + rc->second_line_bpg_offset =3D 0; + break; + } + + initial_xmit_delay_factor =3D (cm =3D=3D CM_444 || cm =3D=3D CM_RGB) ? 1.= 0 : 2.0; + rc->initial_xmit_delay =3D dsc_roundf(8192.0/2.0/bpp/initial_xmit_delay_f= actor); + + if (cm =3D=3D CM_422 || cm =3D=3D CM_420) + slice_width /=3D 2; + + padding_pixels =3D ((slice_width % 3) !=3D 0) ? (3 - (slice_width % 3)) *= (rc->initial_xmit_delay / slice_width) : 0; + if (3 * bpp_group >=3D (((rc->initial_xmit_delay + 2) / 3) * (3 + (cm =3D= =3D CM_422)))) { + if ((rc->initial_xmit_delay + padding_pixels) % 3 =3D=3D 1) + rc->initial_xmit_delay++; + } + + rc->flatness_min_qp =3D ((bpc =3D=3D BPC_8) ? (3) : ((bpc =3D=3D BPC= _10) ? (7) : (11))) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : = 0); + rc->flatness_max_qp =3D ((bpc =3D=3D BPC_8) ? (12) : ((bpc =3D=3D BPC= _10) ? (16) : (20))) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : = 0); + rc->flatness_det_thresh =3D 2 << (bpc - 8); + + get_qp_set(rc->qp_min, cm, bpc, DAL_MM_MIN, bpp); + get_qp_set(rc->qp_max, cm, bpc, DAL_MM_MAX, bpp); + if (cm =3D=3D CM_444 && minor_version =3D=3D 1) { + for (i =3D 0; i < QP_SET_SIZE; ++i) { + rc->qp_min[i] =3D rc->qp_min[i] > 0 ? rc->qp_min[i] - 1 : 0; + rc->qp_max[i] =3D rc->qp_max[i] > 0 ? rc->qp_max[i] - 1 : 0; + } + } + get_ofs_set(rc->ofs, cm, bpp); + + /* fixed parameters */ + rc->rc_model_size =3D 8192; + rc->rc_edge_factor =3D 6; + rc->rc_tgt_offset_hi =3D 3; + rc->rc_tgt_offset_lo =3D 3; + + rc->rc_buf_thresh[0] =3D 896; + rc->rc_buf_thresh[1] =3D 1792; + rc->rc_buf_thresh[2] =3D 2688; + rc->rc_buf_thresh[3] =3D 3584; + rc->rc_buf_thresh[4] =3D 4480; + rc->rc_buf_thresh[5] =3D 5376; + rc->rc_buf_thresh[6] =3D 6272; + rc->rc_buf_thresh[7] =3D 6720; + rc->rc_buf_thresh[8] =3D 7168; + rc->rc_buf_thresh[9] =3D 7616; + rc->rc_buf_thresh[10] =3D 7744; + rc->rc_buf_thresh[11] =3D 7872; + rc->rc_buf_thresh[12] =3D 8000; + rc->rc_buf_thresh[13] =3D 8064; +} + +u32 _do_bytes_per_pixel_calc(int slice_width, + u16 drm_bpp, + bool is_navite_422_or_420) +{ + float bpp; + u32 bytes_per_pixel; + double d_bytes_per_pixel; + + dc_assert_fp_enabled(); + + bpp =3D ((float)drm_bpp / 16.0); + d_bytes_per_pixel =3D dsc_ceil(bpp * slice_width / 8.0) / slice_width; + // TODO: Make sure the formula for calculating this is precise (ceiling + // vs. floor, and at what point they should be applied) + if (is_navite_422_or_420) + d_bytes_per_pixel /=3D 2; + + bytes_per_pixel =3D (u32)dsc_ceil(d_bytes_per_pixel * 0x10000000); + + return bytes_per_pixel; +} diff --git a/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.h b/drivers= /gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.h new file mode 100644 index 0000000000000..b93b95409fbe2 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.h @@ -0,0 +1,94 @@ +/* + * Copyright 2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software= "), + * to deal in the Software without restriction, including without limitati= on + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __RC_CALC_FPU_H__ +#define __RC_CALC_FPU_H__ + +#include "os_types.h" +#include + +#define QP_SET_SIZE 15 + +typedef int qp_set[QP_SET_SIZE]; + +struct rc_params { + int rc_quant_incr_limit0; + int rc_quant_incr_limit1; + int initial_fullness_offset; + int initial_xmit_delay; + int first_line_bpg_offset; + int second_line_bpg_offset; + int flatness_min_qp; + int flatness_max_qp; + int flatness_det_thresh; + qp_set qp_min; + qp_set qp_max; + qp_set ofs; + int rc_model_size; + int rc_edge_factor; + int rc_tgt_offset_hi; + int rc_tgt_offset_lo; + int rc_buf_thresh[QP_SET_SIZE - 1]; +}; + +enum colour_mode { + CM_RGB, /* 444 RGB */ + CM_444, /* 444 YUV or simple 422 */ + CM_422, /* native 422 */ + CM_420 /* native 420 */ +}; + +enum bits_per_comp { + BPC_8 =3D 8, + BPC_10 =3D 10, + BPC_12 =3D 12 +}; + +enum max_min { + DAL_MM_MIN =3D 0, + DAL_MM_MAX =3D 1 +}; + +struct qp_entry { + float bpp; + const qp_set qps; +}; + +typedef struct qp_entry qp_table[]; + +u32 _do_bytes_per_pixel_calc(int slice_width, + u16 drm_bpp, + bool is_navite_422_or_420); + +void _do_calc_rc_params(struct rc_params *rc, + enum colour_mode cm, + enum bits_per_comp bpc, + u16 drm_bpp, + bool is_navite_422_or_420, + int slice_width, + int slice_height, + int minor_version); + +#endif diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/= amd/display/dc/dsc/Makefile index 8d31eb75c6a6e..a2537229ee88b 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile @@ -1,35 +1,6 @@ # SPDX-License-Identifier: MIT # # Makefile for the 'dsc' sub-component of DAL. - -ifdef CONFIG_X86 -dsc_ccflags :=3D -mhard-float -msse -endif - -ifdef CONFIG_PPC64 -dsc_ccflags :=3D -mhard-float -maltivec -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC =3D 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-bound= ary=3D3 -# (8B stack alignment). -dsc_ccflags +=3D -mpreferred-stack-boundary=3D4 -else -dsc_ccflags +=3D -msse2 -endif -endif - -CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc.o :=3D $(dsc_ccflags) -CFLAGS_REMOVE_$(AMDDALPATH)/dc/dsc/rc_calc.o :=3D $(dsc_rcflags) - DSC =3D dc_dsc.o rc_calc.o rc_calc_dpi.o =20 AMD_DAL_DSC =3D $(addprefix $(AMDDALPATH)/dc/dsc/,$(DSC)) diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c b/drivers/gpu/drm= /amd/display/dc/dsc/rc_calc.c index 7b294f637881a..b19d3aeb5962c 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c +++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c @@ -23,266 +23,7 @@ * Authors: AMD * */ -#include - -#include "os_types.h" #include "rc_calc.h" -#include "qp_tables.h" - -#define table_hash(mode, bpc, max_min) ((mode << 16) | (bpc << 8) | max_mi= n) - -#define MODE_SELECT(val444, val422, val420) \ - (cm =3D=3D CM_444 || cm =3D=3D CM_RGB) ? (val444) : (cm =3D=3D CM_422 ? (= val422) : (val420)) - - -#define TABLE_CASE(mode, bpc, max) case (table_hash(mode, BPC_##bpc, max= )): \ - table =3D qp_table_##mode##_##bpc##bpc_##max; \ - table_size =3D sizeof(qp_table_##mode##_##bpc##bpc_##max)/sizeof(*qp_tabl= e_##mode##_##bpc##bpc_##max); \ - break - - -static void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp= bpc, - enum max_min max_min, float bpp) -{ - int mode =3D MODE_SELECT(444, 422, 420); - int sel =3D table_hash(mode, bpc, max_min); - int table_size =3D 0; - int index; - const struct qp_entry *table =3D 0L; - - // alias enum - enum { min =3D DAL_MM_MIN, max =3D DAL_MM_MAX }; - switch (sel) { - TABLE_CASE(444, 8, max); - TABLE_CASE(444, 8, min); - TABLE_CASE(444, 10, max); - TABLE_CASE(444, 10, min); - TABLE_CASE(444, 12, max); - TABLE_CASE(444, 12, min); - TABLE_CASE(422, 8, max); - TABLE_CASE(422, 8, min); - TABLE_CASE(422, 10, max); - TABLE_CASE(422, 10, min); - TABLE_CASE(422, 12, max); - TABLE_CASE(422, 12, min); - TABLE_CASE(420, 8, max); - TABLE_CASE(420, 8, min); - TABLE_CASE(420, 10, max); - TABLE_CASE(420, 10, min); - TABLE_CASE(420, 12, max); - TABLE_CASE(420, 12, min); - } - - if (table =3D=3D 0) - return; - - index =3D (bpp - table[0].bpp) * 2; - - /* requested size is bigger than the table */ - if (index >=3D table_size) { - dm_error("ERROR: Requested rc_calc to find a bpp entry that exceeds the = table size\n"); - return; - } - - memcpy(qps, table[index].qps, sizeof(qp_set)); -} - -static double dsc_roundf(double num) -{ - if (num < 0.0) - num =3D num - 0.5; - else - num =3D num + 0.5; - - return (int)(num); -} - -static double dsc_ceil(double num) -{ - double retval =3D (int)num; - - if (retval !=3D num && num > 0) - retval =3D num + 1; - - return (int)retval; -} - -static void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) -{ - int *p =3D ofs; - - if (mode =3D=3D CM_444 || mode =3D=3D CM_RGB) { - *p++ =3D (bpp <=3D 6) ? (0) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (2)= : ((bpp >=3D 15) ? (10) : ((((bpp > 6) && (bpp < 8))) ? (0 + dsc_roundf((b= pp - 6) * (2 / 2.0))) : (2 + dsc_roundf((bpp - 12) * (8 / 3.0)))))); - *p++ =3D (bpp <=3D 6) ? (-2) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (0= ) : ((bpp >=3D 15) ? (8) : ((((bpp > 6) && (bpp < 8))) ? (-2 + dsc_roundf((= bpp - 6) * (2 / 2.0))) : (0 + dsc_roundf((bpp - 12) * (8 / 3.0)))))); - *p++ =3D (bpp <=3D 6) ? (-2) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (0= ) : ((bpp >=3D 15) ? (6) : ((((bpp > 6) && (bpp < 8))) ? (-2 + dsc_roundf((= bpp - 6) * (2 / 2.0))) : (0 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); - *p++ =3D (bpp <=3D 6) ? (-4) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (-= 2) : ((bpp >=3D 15) ? (4) : ((((bpp > 6) && (bpp < 8))) ? (-4 + dsc_roundf(= (bpp - 6) * (2 / 2.0))) : (-2 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); - *p++ =3D (bpp <=3D 6) ? (-6) : ((((bpp >=3D 8) && (bpp <=3D 12))) ? (-= 4) : ((bpp >=3D 15) ? (2) : ((((bpp > 6) && (bpp < 8))) ? (-6 + dsc_roundf(= (bpp - 6) * (2 / 2.0))) : (-4 + dsc_roundf((bpp - 12) * (6 / 3.0)))))); - *p++ =3D (bpp <=3D 12) ? (-6) : ((bpp >=3D 15) ? (0) : (-6 + dsc_roundf(= (bpp - 12) * (6 / 3.0)))); - *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-2) : (-8 + dsc_roundf= ((bpp - 12) * (6 / 3.0)))); - *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-4) : (-8 + dsc_roundf= ((bpp - 12) * (4 / 3.0)))); - *p++ =3D (bpp <=3D 12) ? (-8) : ((bpp >=3D 15) ? (-6) : (-8 + dsc_roundf= ((bpp - 12) * (2 / 3.0)))); - *p++ =3D (bpp <=3D 12) ? (-10) : ((bpp >=3D 15) ? (-8) : (-10 + dsc_roun= df((bpp - 12) * (2 / 3.0)))); - *p++ =3D -10; - *p++ =3D (bpp <=3D 6) ? (-12) : ((bpp >=3D 8) ? (-10) : (-12 + dsc_rou= ndf((bpp - 6) * (2 / 2.0)))); - *p++ =3D -12; - *p++ =3D -12; - *p++ =3D -12; - } else if (mode =3D=3D CM_422) { - *p++ =3D (bpp <=3D 8) ? (2) : ((bpp >=3D 10) ? (10) : (2 + dsc_roundf((= bpp - 8) * (8 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (0) : ((bpp >=3D 10) ? (8) : (0 + dsc_roundf((b= pp - 8) * (8 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (0) : ((bpp >=3D 10) ? (6) : (0 + dsc_roundf((b= pp - 8) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-2) : ((bpp >=3D 10) ? (4) : (-2 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-4) : ((bpp >=3D 10) ? (2) : (-4 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-6) : ((bpp >=3D 10) ? (0) : (-6 + dsc_roundf(= (bpp - 8) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-2) : (-8 + dsc_roundf= ((bpp - 8) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-4) : (-8 + dsc_roundf= ((bpp - 8) * (4 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-8) : ((bpp >=3D 10) ? (-6) : (-8 + dsc_roundf= ((bpp - 8) * (2 / 2.0)))); - *p++ =3D (bpp <=3D 8) ? (-10) : ((bpp >=3D 10) ? (-8) : (-10 + dsc_roun= df((bpp - 8) * (2 / 2.0)))); - *p++ =3D -10; - *p++ =3D (bpp <=3D 6) ? (-12) : ((bpp >=3D 7) ? (-10) : (-12 + dsc_roun= df((bpp - 6) * (2.0 / 1)))); - *p++ =3D -12; - *p++ =3D -12; - *p++ =3D -12; - } else { - *p++ =3D (bpp <=3D 6) ? (2) : ((bpp >=3D 8) ? (10) : (2 + dsc_roundf((= bpp - 6) * (8 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (0) : ((bpp >=3D 8) ? (8) : (0 + dsc_roundf((b= pp - 6) * (8 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (0) : ((bpp >=3D 8) ? (6) : (0 + dsc_roundf((b= pp - 6) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-2) : ((bpp >=3D 8) ? (4) : (-2 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-4) : ((bpp >=3D 8) ? (2) : (-4 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-6) : ((bpp >=3D 8) ? (0) : (-6 + dsc_roundf(= (bpp - 6) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-2) : (-8 + dsc_roundf= ((bpp - 6) * (6 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-4) : (-8 + dsc_roundf= ((bpp - 6) * (4 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-8) : ((bpp >=3D 8) ? (-6) : (-8 + dsc_roundf= ((bpp - 6) * (2 / 2.0)))); - *p++ =3D (bpp <=3D 6) ? (-10) : ((bpp >=3D 8) ? (-8) : (-10 + dsc_roun= df((bpp - 6) * (2 / 2.0)))); - *p++ =3D -10; - *p++ =3D (bpp <=3D 4) ? (-12) : ((bpp >=3D 5) ? (-10) : (-12 + dsc_rou= ndf((bpp - 4) * (2 / 1.0)))); - *p++ =3D -12; - *p++ =3D -12; - *p++ =3D -12; - } -} - -static int median3(int a, int b, int c) -{ - if (a > b) - swap(a, b); - if (b > c) - swap(b, c); - if (a > b) - swap(b, c); - - return b; -} - -static void _do_calc_rc_params(struct rc_params *rc, enum colour_mode cm, - enum bits_per_comp bpc, u16 drm_bpp, - bool is_navite_422_or_420, - int slice_width, int slice_height, - int minor_version) -{ - float bpp; - float bpp_group; - float initial_xmit_delay_factor; - int padding_pixels; - int i; - - bpp =3D ((float)drm_bpp / 16.0); - /* in native_422 or native_420 modes, the bits_per_pixel is double the - * target bpp (the latter is what calc_rc_params expects) - */ - if (is_navite_422_or_420) - bpp /=3D 2.0; - - rc->rc_quant_incr_limit0 =3D ((bpc =3D=3D BPC_8) ? 11 : (bpc =3D=3D BPC_1= 0 ? 15 : 19)) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : 0); - rc->rc_quant_incr_limit1 =3D ((bpc =3D=3D BPC_8) ? 11 : (bpc =3D=3D BPC_1= 0 ? 15 : 19)) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : 0); - - bpp_group =3D MODE_SELECT(bpp, bpp * 2.0, bpp * 2.0); - - switch (cm) { - case CM_420: - rc->initial_fullness_offset =3D (bpp >=3D 6) ? (2048) : ((bpp <=3D 4) = ? (6144) : ((((bpp > 4) && (bpp <=3D 5))) ? (6144 - dsc_roundf((bpp - 4) = * (512))) : (5632 - dsc_roundf((bpp - 5) * (3584))))); - rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)((3 * bpc * 3) - (3 * bpp_group))); - rc->second_line_bpg_offset =3D median3(0, 12, (int)((3 * bpc * 3) - (3 = * bpp_group))); - break; - case CM_422: - rc->initial_fullness_offset =3D (bpp >=3D 8) ? (2048) : ((bpp <=3D 7) = ? (5632) : (5632 - dsc_roundf((bpp - 7) * (3584)))); - rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)((3 * bpc * 4) - (3 * bpp_group))); - rc->second_line_bpg_offset =3D 0; - break; - case CM_444: - case CM_RGB: - rc->initial_fullness_offset =3D (bpp >=3D 12) ? (2048) : ((bpp <=3D 8) = ? (6144) : ((((bpp > 8) && (bpp <=3D 10))) ? (6144 - dsc_roundf((bpp - 8) = * (512 / 2))) : (5632 - dsc_roundf((bpp - 10) * (3584 / 2))))); - rc->first_line_bpg_offset =3D median3(0, (12 + (int) (0.09 * min(34, = slice_height - 8))), (int)(((3 * bpc + (cm =3D=3D CM_444 ? 0 : 2)) * 3) - (= 3 * bpp_group))); - rc->second_line_bpg_offset =3D 0; - break; - } - - initial_xmit_delay_factor =3D (cm =3D=3D CM_444 || cm =3D=3D CM_RGB) ? 1.= 0 : 2.0; - rc->initial_xmit_delay =3D dsc_roundf(8192.0/2.0/bpp/initial_xmit_delay_f= actor); - - if (cm =3D=3D CM_422 || cm =3D=3D CM_420) - slice_width /=3D 2; - - padding_pixels =3D ((slice_width % 3) !=3D 0) ? (3 - (slice_width % 3)) *= (rc->initial_xmit_delay / slice_width) : 0; - if (3 * bpp_group >=3D (((rc->initial_xmit_delay + 2) / 3) * (3 + (cm =3D= =3D CM_422)))) { - if ((rc->initial_xmit_delay + padding_pixels) % 3 =3D=3D 1) - rc->initial_xmit_delay++; - } - - rc->flatness_min_qp =3D ((bpc =3D=3D BPC_8) ? (3) : ((bpc =3D=3D BPC= _10) ? (7) : (11))) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : = 0); - rc->flatness_max_qp =3D ((bpc =3D=3D BPC_8) ? (12) : ((bpc =3D=3D BPC= _10) ? (16) : (20))) - ((minor_version =3D=3D 1 && cm =3D=3D CM_444) ? 1 : = 0); - rc->flatness_det_thresh =3D 2 << (bpc - 8); - - get_qp_set(rc->qp_min, cm, bpc, DAL_MM_MIN, bpp); - get_qp_set(rc->qp_max, cm, bpc, DAL_MM_MAX, bpp); - if (cm =3D=3D CM_444 && minor_version =3D=3D 1) { - for (i =3D 0; i < QP_SET_SIZE; ++i) { - rc->qp_min[i] =3D rc->qp_min[i] > 0 ? rc->qp_min[i] - 1 : 0; - rc->qp_max[i] =3D rc->qp_max[i] > 0 ? rc->qp_max[i] - 1 : 0; - } - } - get_ofs_set(rc->ofs, cm, bpp); - - /* fixed parameters */ - rc->rc_model_size =3D 8192; - rc->rc_edge_factor =3D 6; - rc->rc_tgt_offset_hi =3D 3; - rc->rc_tgt_offset_lo =3D 3; - - rc->rc_buf_thresh[0] =3D 896; - rc->rc_buf_thresh[1] =3D 1792; - rc->rc_buf_thresh[2] =3D 2688; - rc->rc_buf_thresh[3] =3D 3584; - rc->rc_buf_thresh[4] =3D 4480; - rc->rc_buf_thresh[5] =3D 5376; - rc->rc_buf_thresh[6] =3D 6272; - rc->rc_buf_thresh[7] =3D 6720; - rc->rc_buf_thresh[8] =3D 7168; - rc->rc_buf_thresh[9] =3D 7616; - rc->rc_buf_thresh[10] =3D 7744; - rc->rc_buf_thresh[11] =3D 7872; - rc->rc_buf_thresh[12] =3D 8000; - rc->rc_buf_thresh[13] =3D 8064; -} - -static u32 _do_bytes_per_pixel_calc(int slice_width, u16 drm_bpp, - bool is_navite_422_or_420) -{ - float bpp; - u32 bytes_per_pixel; - double d_bytes_per_pixel; - - bpp =3D ((float)drm_bpp / 16.0); - d_bytes_per_pixel =3D dsc_ceil(bpp * slice_width / 8.0) / slice_width; - // TODO: Make sure the formula for calculating this is precise (ceiling - // vs. floor, and at what point they should be applied) - if (is_navite_422_or_420) - d_bytes_per_pixel /=3D 2; - - bytes_per_pixel =3D (u32)dsc_ceil(d_bytes_per_pixel * 0x10000000); - - return bytes_per_pixel; -} =20 /** * calc_rc_params - reads the user's cmdline mode diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h b/drivers/gpu/drm= /amd/display/dc/dsc/rc_calc.h index 262f06afcbf95..c2340e001b578 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h +++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h @@ -27,55 +27,7 @@ #ifndef __RC_CALC_H__ #define __RC_CALC_H__ =20 - -#define QP_SET_SIZE 15 - -typedef int qp_set[QP_SET_SIZE]; - -struct rc_params { - int rc_quant_incr_limit0; - int rc_quant_incr_limit1; - int initial_fullness_offset; - int initial_xmit_delay; - int first_line_bpg_offset; - int second_line_bpg_offset; - int flatness_min_qp; - int flatness_max_qp; - int flatness_det_thresh; - qp_set qp_min; - qp_set qp_max; - qp_set ofs; - int rc_model_size; - int rc_edge_factor; - int rc_tgt_offset_hi; - int rc_tgt_offset_lo; - int rc_buf_thresh[QP_SET_SIZE - 1]; -}; - -enum colour_mode { - CM_RGB, /* 444 RGB */ - CM_444, /* 444 YUV or simple 422 */ - CM_422, /* native 422 */ - CM_420 /* native 420 */ -}; - -enum bits_per_comp { - BPC_8 =3D 8, - BPC_10 =3D 10, - BPC_12 =3D 12 -}; - -enum max_min { - DAL_MM_MIN =3D 0, - DAL_MM_MAX =3D 1 -}; - -struct qp_entry { - float bpp; - const qp_set qps; -}; - -typedef struct qp_entry qp_table[]; +#include "dml/dsc/rc_calc_fpu.h" =20 void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps= ); u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps); diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c b/drivers/gpu= /drm/amd/display/dc/dsc/rc_calc_dpi.c index ef830aded5b1c..1e19dd674e5a2 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c +++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c @@ -22,7 +22,6 @@ * Authors: AMD * */ -#include "os_types.h" #include #include "dscc_types.h" #include "rc_calc.h" --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF00C433EF for ; Mon, 7 Mar 2022 09:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233279AbiCGJy1 (ORCPT ); Mon, 7 Mar 2022 04:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241069AbiCGJls (ORCPT ); Mon, 7 Mar 2022 04:41:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA656C959; Mon, 7 Mar 2022 01:39: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 5AF7EB810C3; Mon, 7 Mar 2022 09:39:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4DAEC340F6; Mon, 7 Mar 2022 09:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645992; bh=s1Rvpah1kdWvaIFESTjDAXHzwufI8fAKVcXRymfAcsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Evog7hAokIQlP66iVgQv6sXNsou3IBBlWZLNYq+VRFcspjOxIyA0/khIrZGli6uK7 LYgFiBgBbkEuM6Npo+sFhrbJjIWgrohngldb+kfWAnKxXZAja2l/+ZdiXofR9ddRbA w0yCZPyxJMHk8fnnaQKwMqU8RlQxTqMWfBB6Kuug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Harry Wentland , Rodrigo Siqueira , Zhan Liu , Daniel Wheeler , Qingqing Zhuo , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 101/262] drm/amd/display: move FPU associated DCN301 code to DML folder Date: Mon, 7 Mar 2022 10:17:25 +0100 Message-Id: <20220307091705.329177641@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Qingqing Zhuo [ Upstream commit 31484207feb23e6cdb12827560442ab294855923 ] [Why & How] As part of the FPU isolation work documented in https://patchwork.freedesktop.org/series/93042/, isolate code that uses FPU in DCN301 to DML, where all FPU code should locate. Cc: Christian K=C3=B6nig Cc: Harry Wentland Cc: Rodrigo Siqueira Tested-by: Zhan Liu Tested-by: Daniel Wheeler Signed-off-by: Qingqing Zhuo Reviewed-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../drm/amd/display/dc/dcn30/dcn30_resource.c | 2 + .../gpu/drm/amd/display/dc/dcn301/Makefile | 26 -- .../amd/display/dc/dcn301/dcn301_resource.c | 349 +--------------- .../amd/display/dc/dcn301/dcn301_resource.h | 3 + drivers/gpu/drm/amd/display/dc/dml/Makefile | 3 + .../amd/display/dc/dml/dcn301/dcn301_fpu.c | 390 ++++++++++++++++++ .../amd/display/dc/dml/dcn301/dcn301_fpu.h | 42 ++ 7 files changed, 450 insertions(+), 365 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c index 0294d0cc47595..db4a9d2760cd1 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c @@ -2319,7 +2319,9 @@ bool dcn30_validate_bandwidth(struct dc *dc, goto validate_out; } =20 + DC_FP_START(); dc->res_pool->funcs->calculate_wm_and_dlg(dc, context, pipes, pipe_cnt, v= level); + DC_FP_END(); =20 BW_VAL_TRACE_END_WATERMARKS(); =20 diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/Makefile b/drivers/gpu/d= rm/amd/display/dc/dcn301/Makefile index 09264716d1dc9..7aa628c219734 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn301/Makefile @@ -13,32 +13,6 @@ DCN301 =3D dcn301_init.o dcn301_resource.o dcn301_dccg.o \ dcn301_dio_link_encoder.o dcn301_hwseq.o dcn301_panel_cntl.o dcn301_hubb= ub.o =20 -ifdef CONFIG_X86 -CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o :=3D -msse -endif - -ifdef CONFIG_PPC64 -CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o :=3D -mhard-float -maltiv= ec -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC =3D 1 -endif -CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o +=3D -mhard-float -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-bound= ary=3D3 -# (8B stack alignment). -CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o +=3D -mpreferred-stack-bo= undary=3D4 -else -CFLAGS_$(AMDDALPATH)/dc/dcn301/dcn301_resource.o +=3D -msse2 -endif -endif - AMD_DAL_DCN301 =3D $(addprefix $(AMDDALPATH)/dc/dcn301/,$(DCN301)) =20 AMD_DISPLAY_FILES +=3D $(AMD_DAL_DCN301) diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c b/driv= ers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c index dea358b01791c..d17994bb318f7 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c @@ -82,6 +82,7 @@ #include "dce/dce_i2c.h" =20 #include "dml/dcn30/display_mode_vba_30.h" +#include "dml/dcn301/dcn301_fpu.h" #include "vm_helper.h" #include "dcn20/dcn20_vmid.h" #include "amdgpu_socbb.h" @@ -91,184 +92,6 @@ =20 #define DC_LOGGER_INIT(logger) =20 -struct _vcs_dpi_ip_params_st dcn3_01_ip =3D { - .odm_capable =3D 1, - .gpuvm_enable =3D 1, - .hostvm_enable =3D 1, - .gpuvm_max_page_table_levels =3D 1, - .hostvm_max_page_table_levels =3D 2, - .hostvm_cached_page_table_levels =3D 0, - .pte_group_size_bytes =3D 2048, - .num_dsc =3D 3, - .rob_buffer_size_kbytes =3D 184, - .det_buffer_size_kbytes =3D 184, - .dpte_buffer_size_in_pte_reqs_luma =3D 64, - .dpte_buffer_size_in_pte_reqs_chroma =3D 32, - .pde_proc_buffer_size_64k_reqs =3D 48, - .dpp_output_buffer_pixels =3D 2560, - .opp_output_buffer_lines =3D 1, - .pixel_chunk_size_kbytes =3D 8, - .meta_chunk_size_kbytes =3D 2, - .writeback_chunk_size_kbytes =3D 8, - .line_buffer_size_bits =3D 789504, - .is_line_buffer_bpp_fixed =3D 0, // ? - .line_buffer_fixed_bpp =3D 48, // ? - .dcc_supported =3D true, - .writeback_interface_buffer_size_kbytes =3D 90, - .writeback_line_buffer_buffer_size =3D 656640, - .max_line_buffer_lines =3D 12, - .writeback_luma_buffer_size_kbytes =3D 12, // writeback_line_buffer_buff= er_size =3D 656640 - .writeback_chroma_buffer_size_kbytes =3D 8, - .writeback_chroma_line_buffer_width_pixels =3D 4, - .writeback_max_hscl_ratio =3D 1, - .writeback_max_vscl_ratio =3D 1, - .writeback_min_hscl_ratio =3D 1, - .writeback_min_vscl_ratio =3D 1, - .writeback_max_hscl_taps =3D 1, - .writeback_max_vscl_taps =3D 1, - .writeback_line_buffer_luma_buffer_size =3D 0, - .writeback_line_buffer_chroma_buffer_size =3D 14643, - .cursor_buffer_size =3D 8, - .cursor_chunk_size =3D 2, - .max_num_otg =3D 4, - .max_num_dpp =3D 4, - .max_num_wb =3D 1, - .max_dchub_pscl_bw_pix_per_clk =3D 4, - .max_pscl_lb_bw_pix_per_clk =3D 2, - .max_lb_vscl_bw_pix_per_clk =3D 4, - .max_vscl_hscl_bw_pix_per_clk =3D 4, - .max_hscl_ratio =3D 6, - .max_vscl_ratio =3D 6, - .hscl_mults =3D 4, - .vscl_mults =3D 4, - .max_hscl_taps =3D 8, - .max_vscl_taps =3D 8, - .dispclk_ramp_margin_percent =3D 1, - .underscan_factor =3D 1.11, - .min_vblank_lines =3D 32, - .dppclk_delay_subtotal =3D 46, - .dynamic_metadata_vm_enabled =3D true, - .dppclk_delay_scl_lb_only =3D 16, - .dppclk_delay_scl =3D 50, - .dppclk_delay_cnvc_formatter =3D 27, - .dppclk_delay_cnvc_cursor =3D 6, - .dispclk_delay_subtotal =3D 119, - .dcfclk_cstate_latency =3D 5.2, // SRExitTime - .max_inter_dcn_tile_repeaters =3D 8, - .max_num_hdmi_frl_outputs =3D 0, - .odm_combine_4to1_supported =3D true, - - .xfc_supported =3D false, - .xfc_fill_bw_overhead_percent =3D 10.0, - .xfc_fill_constant_bytes =3D 0, - .gfx7_compat_tiling_supported =3D 0, - .number_of_cursors =3D 1, -}; - -struct _vcs_dpi_soc_bounding_box_st dcn3_01_soc =3D { - .clock_limits =3D { - { - .state =3D 0, - .dram_speed_mts =3D 2400.0, - .fabricclk_mhz =3D 600, - .socclk_mhz =3D 278.0, - .dcfclk_mhz =3D 400.0, - .dscclk_mhz =3D 206.0, - .dppclk_mhz =3D 1015.0, - .dispclk_mhz =3D 1015.0, - .phyclk_mhz =3D 600.0, - }, - { - .state =3D 1, - .dram_speed_mts =3D 2400.0, - .fabricclk_mhz =3D 688, - .socclk_mhz =3D 278.0, - .dcfclk_mhz =3D 400.0, - .dscclk_mhz =3D 206.0, - .dppclk_mhz =3D 1015.0, - .dispclk_mhz =3D 1015.0, - .phyclk_mhz =3D 600.0, - }, - { - .state =3D 2, - .dram_speed_mts =3D 4267.0, - .fabricclk_mhz =3D 1067, - .socclk_mhz =3D 278.0, - .dcfclk_mhz =3D 608.0, - .dscclk_mhz =3D 296.0, - .dppclk_mhz =3D 1015.0, - .dispclk_mhz =3D 1015.0, - .phyclk_mhz =3D 810.0, - }, - - { - .state =3D 3, - .dram_speed_mts =3D 4267.0, - .fabricclk_mhz =3D 1067, - .socclk_mhz =3D 715.0, - .dcfclk_mhz =3D 676.0, - .dscclk_mhz =3D 338.0, - .dppclk_mhz =3D 1015.0, - .dispclk_mhz =3D 1015.0, - .phyclk_mhz =3D 810.0, - }, - - { - .state =3D 4, - .dram_speed_mts =3D 4267.0, - .fabricclk_mhz =3D 1067, - .socclk_mhz =3D 953.0, - .dcfclk_mhz =3D 810.0, - .dscclk_mhz =3D 338.0, - .dppclk_mhz =3D 1015.0, - .dispclk_mhz =3D 1015.0, - .phyclk_mhz =3D 810.0, - }, - }, - - .sr_exit_time_us =3D 9.0, - .sr_enter_plus_exit_time_us =3D 11.0, - .urgent_latency_us =3D 4.0, - .urgent_latency_pixel_data_only_us =3D 4.0, - .urgent_latency_pixel_mixed_with_vm_data_us =3D 4.0, - .urgent_latency_vm_data_only_us =3D 4.0, - .urgent_out_of_order_return_per_channel_pixel_only_bytes =3D 4096, - .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes =3D 4096, - .urgent_out_of_order_return_per_channel_vm_only_bytes =3D 4096, - .pct_ideal_dram_sdp_bw_after_urgent_pixel_only =3D 80.0, - .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm =3D 75.0, - .pct_ideal_dram_sdp_bw_after_urgent_vm_only =3D 40.0, - .max_avg_sdp_bw_use_normal_percent =3D 60.0, - .max_avg_dram_bw_use_normal_percent =3D 60.0, - .writeback_latency_us =3D 12.0, - .max_request_size_bytes =3D 256, - .dram_channel_width_bytes =3D 4, - .fabric_datapath_to_dcn_data_return_bytes =3D 32, - .dcn_downspread_percent =3D 0.5, - .downspread_percent =3D 0.38, - .dram_page_open_time_ns =3D 50.0, - .dram_rw_turnaround_time_ns =3D 17.5, - .dram_return_buffer_per_channel_bytes =3D 8192, - .round_trip_ping_latency_dcfclk_cycles =3D 191, - .urgent_out_of_order_return_per_channel_bytes =3D 4096, - .channel_interleave_bytes =3D 256, - .num_banks =3D 8, - .num_chans =3D 4, - .gpuvm_min_page_size_bytes =3D 4096, - .hostvm_min_page_size_bytes =3D 4096, - .dram_clock_change_latency_us =3D 23.84, - .writeback_dram_clock_change_latency_us =3D 23.0, - .return_bus_width_bytes =3D 64, - .dispclk_dppclk_vco_speed_mhz =3D 3550, - .xfc_bus_transport_time_us =3D 20, // ? - .xfc_xbuf_latency_tolerance_us =3D 4, // ? - .use_urgent_burst_bw =3D 1, // ? - .num_states =3D 5, - .do_urgent_latency_adjustment =3D false, - .urgent_latency_adjustment_fabric_clock_component_us =3D 0, - .urgent_latency_adjustment_fabric_clock_reference_mhz =3D 0, -}; - enum dcn301_clk_src_array_id { DCN301_CLK_SRC_PLL0, DCN301_CLK_SRC_PLL1, @@ -1476,8 +1299,6 @@ static struct dc_cap_funcs cap_funcs =3D { .get_dcc_compression_cap =3D dcn20_get_dcc_compression_cap }; =20 -#define fixed16_to_double(x) (((double) x) / ((double) (1 << 16))) -#define fixed16_to_double_to_cpu(x) fixed16_to_double(le32_to_cpu(x)) =20 static bool is_soc_bounding_box_valid(struct dc *dc) { @@ -1504,26 +1325,24 @@ static bool init_soc_bounding_box(struct dc *dc, =20 loaded_ip->max_num_otg =3D pool->base.res_cap->num_timing_generator; loaded_ip->max_num_dpp =3D pool->base.pipe_count; + DC_FP_START(); dcn20_patch_bounding_box(dc, loaded_bb); + DC_FP_END(); =20 if (dc->ctx->dc_bios->funcs->get_soc_bb_info) { struct bp_soc_bb_info bb_info =3D {0}; =20 if (dc->ctx->dc_bios->funcs->get_soc_bb_info(dc->ctx->dc_bios, &bb_info)= =3D=3D BP_RESULT_OK) { - if (bb_info.dram_clock_change_latency_100ns > 0) - dcn3_01_soc.dram_clock_change_latency_us =3D bb_info.dram_clock_change= _latency_100ns * 10; - - if (bb_info.dram_sr_enter_exit_latency_100ns > 0) - dcn3_01_soc.sr_enter_plus_exit_time_us =3D bb_info.dram_sr_enter_exit_= latency_100ns * 10; - - if (bb_info.dram_sr_exit_latency_100ns > 0) - dcn3_01_soc.sr_exit_time_us =3D bb_info.dram_sr_exit_latency_100ns * 1= 0; + DC_FP_START(); + dcn301_fpu_init_soc_bounding_box(bb_info); + DC_FP_END(); } } =20 return true; } =20 + static void set_wm_ranges( struct pp_smu_funcs *pp_smu, struct _vcs_dpi_soc_bounding_box_st *loaded_bb) @@ -1546,9 +1365,9 @@ static void set_wm_ranges( ranges.reader_wm_sets[i].wm_inst =3D i; ranges.reader_wm_sets[i].min_drain_clk_mhz =3D PP_SMU_WM_SET_RANGE_CLK_= UNCONSTRAINED_MIN; ranges.reader_wm_sets[i].max_drain_clk_mhz =3D PP_SMU_WM_SET_RANGE_CLK_= UNCONSTRAINED_MAX; - ranges.reader_wm_sets[i].min_fill_clk_mhz =3D (i > 0) ? (loaded_bb->clo= ck_limits[i - 1].dram_speed_mts / 16) + 1 : 0; - ranges.reader_wm_sets[i].max_fill_clk_mhz =3D loaded_bb->clock_limits[i= ].dram_speed_mts / 16; - + DC_FP_START(); + dcn301_fpu_set_wm_ranges(i, &ranges, loaded_bb); + DC_FP_END(); ranges.num_reader_wm_sets =3D i + 1; } =20 @@ -1568,154 +1387,6 @@ static void set_wm_ranges( pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges); } =20 -static void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_par= ams *bw_params) -{ - struct dcn301_resource_pool *pool =3D TO_DCN301_RES_POOL(dc->res_pool); - struct clk_limit_table *clk_table =3D &bw_params->clk_table; - struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES]; - unsigned int i, closest_clk_lvl; - int j; - - // Default clock levels are used for diags, which may lead to overclockin= g. - if (!IS_DIAG_DC(dc->ctx->dce_environment)) { - dcn3_01_ip.max_num_otg =3D pool->base.res_cap->num_timing_generator; - dcn3_01_ip.max_num_dpp =3D pool->base.pipe_count; - dcn3_01_soc.num_chans =3D bw_params->num_channels; - - ASSERT(clk_table->num_entries); - for (i =3D 0; i < clk_table->num_entries; i++) { - /* loop backwards*/ - for (closest_clk_lvl =3D 0, j =3D dcn3_01_soc.num_states - 1; j >=3D 0;= j--) { - if ((unsigned int) dcn3_01_soc.clock_limits[j].dcfclk_mhz <=3D clk_tab= le->entries[i].dcfclk_mhz) { - closest_clk_lvl =3D j; - break; - } - } - - clock_limits[i].state =3D i; - clock_limits[i].dcfclk_mhz =3D clk_table->entries[i].dcfclk_mhz; - clock_limits[i].fabricclk_mhz =3D clk_table->entries[i].fclk_mhz; - clock_limits[i].socclk_mhz =3D clk_table->entries[i].socclk_mhz; - clock_limits[i].dram_speed_mts =3D clk_table->entries[i].memclk_mhz * 2; - - clock_limits[i].dispclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lv= l].dispclk_mhz; - clock_limits[i].dppclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dppclk_mhz; - clock_limits[i].dram_bw_per_chan_gbps =3D dcn3_01_soc.clock_limits[clos= est_clk_lvl].dram_bw_per_chan_gbps; - clock_limits[i].dscclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dscclk_mhz; - clock_limits[i].dtbclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dtbclk_mhz; - clock_limits[i].phyclk_d18_mhz =3D dcn3_01_soc.clock_limits[closest_clk= _lvl].phyclk_d18_mhz; - clock_limits[i].phyclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].phyclk_mhz; - } - for (i =3D 0; i < clk_table->num_entries; i++) - dcn3_01_soc.clock_limits[i] =3D clock_limits[i]; - if (clk_table->num_entries) { - dcn3_01_soc.num_states =3D clk_table->num_entries; - /* duplicate last level */ - dcn3_01_soc.clock_limits[dcn3_01_soc.num_states] =3D dcn3_01_soc.clock_= limits[dcn3_01_soc.num_states - 1]; - dcn3_01_soc.clock_limits[dcn3_01_soc.num_states].state =3D dcn3_01_soc.= num_states; - } - } - - dcn3_01_soc.dispclk_dppclk_vco_speed_mhz =3D dc->clk_mgr->dentist_vco_fre= q_khz / 1000.0; - dc->dml.soc.dispclk_dppclk_vco_speed_mhz =3D dc->clk_mgr->dentist_vco_fre= q_khz / 1000.0; - - dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30); -} - -static void calculate_wm_set_for_vlevel( - int vlevel, - struct wm_range_table_entry *table_entry, - struct dcn_watermarks *wm_set, - struct display_mode_lib *dml, - display_e2e_pipe_params_st *pipes, - int pipe_cnt) -{ - double dram_clock_change_latency_cached =3D dml->soc.dram_clock_change_la= tency_us; - - ASSERT(vlevel < dml->soc.num_states); - /* only pipe 0 is read for voltage and dcf/soc clocks */ - pipes[0].clks_cfg.voltage =3D vlevel; - pipes[0].clks_cfg.dcfclk_mhz =3D dml->soc.clock_limits[vlevel].dcfclk_mhz; - pipes[0].clks_cfg.socclk_mhz =3D dml->soc.clock_limits[vlevel].socclk_mhz; - - dml->soc.dram_clock_change_latency_us =3D table_entry->pstate_latency_us; - dml->soc.sr_exit_time_us =3D table_entry->sr_exit_time_us; - dml->soc.sr_enter_plus_exit_time_us =3D table_entry->sr_enter_plus_exit_t= ime_us; - - wm_set->urgent_ns =3D get_wm_urgent(dml, pipes, pipe_cnt) * 1000; - wm_set->cstate_pstate.cstate_enter_plus_exit_ns =3D get_wm_stutter_enter_= exit(dml, pipes, pipe_cnt) * 1000; - wm_set->cstate_pstate.cstate_exit_ns =3D get_wm_stutter_exit(dml, pipes, = pipe_cnt) * 1000; - wm_set->cstate_pstate.pstate_change_ns =3D get_wm_dram_clock_change(dml, = pipes, pipe_cnt) * 1000; - wm_set->pte_meta_urgent_ns =3D get_wm_memory_trip(dml, pipes, pipe_cnt) *= 1000; - wm_set->frac_urg_bw_nom =3D get_fraction_of_urgent_bandwidth(dml, pipes, = pipe_cnt) * 1000; - wm_set->frac_urg_bw_flip =3D get_fraction_of_urgent_bandwidth_imm_flip(dm= l, pipes, pipe_cnt) * 1000; - wm_set->urgent_latency_ns =3D get_urgent_latency(dml, pipes, pipe_cnt) * = 1000; - dml->soc.dram_clock_change_latency_us =3D dram_clock_change_latency_cache= d; - -} - -static void dcn301_calculate_wm_and_dlg( - struct dc *dc, struct dc_state *context, - display_e2e_pipe_params_st *pipes, - int pipe_cnt, - int vlevel_req) -{ - int i, pipe_idx; - int vlevel, vlevel_max; - struct wm_range_table_entry *table_entry; - struct clk_bw_params *bw_params =3D dc->clk_mgr->bw_params; - - ASSERT(bw_params); - - vlevel_max =3D bw_params->clk_table.num_entries - 1; - - /* WM Set D */ - table_entry =3D &bw_params->wm_table.entries[WM_D]; - if (table_entry->wm_type =3D=3D WM_TYPE_RETRAINING) - vlevel =3D 0; - else - vlevel =3D vlevel_max; - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.d, - &context->bw_ctx.dml, pipes, pipe_cnt); - /* WM Set C */ - table_entry =3D &bw_params->wm_table.entries[WM_C]; - vlevel =3D min(max(vlevel_req, 2), vlevel_max); - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.c, - &context->bw_ctx.dml, pipes, pipe_cnt); - /* WM Set B */ - table_entry =3D &bw_params->wm_table.entries[WM_B]; - vlevel =3D min(max(vlevel_req, 1), vlevel_max); - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.b, - &context->bw_ctx.dml, pipes, pipe_cnt); - - /* WM Set A */ - table_entry =3D &bw_params->wm_table.entries[WM_A]; - vlevel =3D min(vlevel_req, vlevel_max); - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.a, - &context->bw_ctx.dml, pipes, pipe_cnt); - - for (i =3D 0, pipe_idx =3D 0; i < dc->res_pool->pipe_count; i++) { - if (!context->res_ctx.pipe_ctx[i].stream) - continue; - - pipes[pipe_idx].clks_cfg.dispclk_mhz =3D get_dispclk_calculated(&context= ->bw_ctx.dml, pipes, pipe_cnt); - pipes[pipe_idx].clks_cfg.dppclk_mhz =3D get_dppclk_calculated(&context->= bw_ctx.dml, pipes, pipe_cnt, pipe_idx); - - if (dc->config.forced_clocks) { - pipes[pipe_idx].clks_cfg.dispclk_mhz =3D context->bw_ctx.dml.soc.clock_= limits[0].dispclk_mhz; - pipes[pipe_idx].clks_cfg.dppclk_mhz =3D context->bw_ctx.dml.soc.clock_l= imits[0].dppclk_mhz; - } - if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * = 1000) - pipes[pipe_idx].clks_cfg.dispclk_mhz =3D dc->debug.min_disp_clk_khz / 1= 000.0; - if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 10= 00) - pipes[pipe_idx].clks_cfg.dppclk_mhz =3D dc->debug.min_dpp_clk_khz / 100= 0.0; - - pipe_idx++; - } - - dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel); -} - static struct resource_funcs dcn301_res_pool_funcs =3D { .destroy =3D dcn301_destroy_resource_pool, .link_enc_create =3D dcn301_link_encoder_create, diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.h b/driv= ers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.h index 17e4e91ff4b8e..ae8672680cdd1 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.h +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.h @@ -32,6 +32,9 @@ struct dc; struct resource_pool; struct _vcs_dpi_display_pipe_params_st; =20 +extern struct _vcs_dpi_ip_params_st dcn3_01_ip; +extern struct _vcs_dpi_soc_bounding_box_st dcn3_01_soc; + struct dcn301_resource_pool { struct resource_pool base; }; diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index 9009b92490f34..069f0cf113f30 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -70,6 +70,7 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_mode_vba_30.o := =3D $(dml_ccflags) $(fram CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(dml_ccfl= ags) +CFLAGS_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_ccflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_rcflags) @@ -84,6 +85,7 @@ CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn30/display_mode_vba= _30.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o :=3D $(d= ml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o :=3D $(dml_= rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(d= ml_rcflags) +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_rcflags) endif @@ -101,6 +103,7 @@ DML +=3D dcn20/display_rq_dlg_calc_20v2.o dcn20/display= _mode_vba_20v2.o DML +=3D dcn21/display_rq_dlg_calc_21.o dcn21/display_mode_vba_21.o DML +=3D dcn30/display_mode_vba_30.o dcn30/display_rq_dlg_calc_30.o DML +=3D dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o +DML +=3D dcn301/dcn301_fpu.o DML +=3D dsc/rc_calc_fpu.o endif =20 diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c b/drive= rs/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c new file mode 100644 index 0000000000000..94c32832a0e7b --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c @@ -0,0 +1,390 @@ +/* + * Copyright 2019-2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software= "), + * to deal in the Software without restriction, including without limitati= on + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include "resource.h" +#include "clk_mgr.h" +#include "dcn20/dcn20_resource.h" +#include "dcn301/dcn301_resource.h" + +#include "dml/dcn20/dcn20_fpu.h" +#include "dcn301_fpu.h" + +#define TO_DCN301_RES_POOL(pool)\ + container_of(pool, struct dcn301_resource_pool, base) + +/* Based on: //vidip/dc/dcn3/doc/architecture/DCN3x_Display_Mode.xlsm#83 */ +struct _vcs_dpi_ip_params_st dcn3_01_ip =3D { + .odm_capable =3D 1, + .gpuvm_enable =3D 1, + .hostvm_enable =3D 1, + .gpuvm_max_page_table_levels =3D 1, + .hostvm_max_page_table_levels =3D 2, + .hostvm_cached_page_table_levels =3D 0, + .pte_group_size_bytes =3D 2048, + .num_dsc =3D 3, + .rob_buffer_size_kbytes =3D 184, + .det_buffer_size_kbytes =3D 184, + .dpte_buffer_size_in_pte_reqs_luma =3D 64, + .dpte_buffer_size_in_pte_reqs_chroma =3D 32, + .pde_proc_buffer_size_64k_reqs =3D 48, + .dpp_output_buffer_pixels =3D 2560, + .opp_output_buffer_lines =3D 1, + .pixel_chunk_size_kbytes =3D 8, + .meta_chunk_size_kbytes =3D 2, + .writeback_chunk_size_kbytes =3D 8, + .line_buffer_size_bits =3D 789504, + .is_line_buffer_bpp_fixed =3D 0, // ? + .line_buffer_fixed_bpp =3D 48, // ? + .dcc_supported =3D true, + .writeback_interface_buffer_size_kbytes =3D 90, + .writeback_line_buffer_buffer_size =3D 656640, + .max_line_buffer_lines =3D 12, + .writeback_luma_buffer_size_kbytes =3D 12, // writeback_line_buffer_buff= er_size =3D 656640 + .writeback_chroma_buffer_size_kbytes =3D 8, + .writeback_chroma_line_buffer_width_pixels =3D 4, + .writeback_max_hscl_ratio =3D 1, + .writeback_max_vscl_ratio =3D 1, + .writeback_min_hscl_ratio =3D 1, + .writeback_min_vscl_ratio =3D 1, + .writeback_max_hscl_taps =3D 1, + .writeback_max_vscl_taps =3D 1, + .writeback_line_buffer_luma_buffer_size =3D 0, + .writeback_line_buffer_chroma_buffer_size =3D 14643, + .cursor_buffer_size =3D 8, + .cursor_chunk_size =3D 2, + .max_num_otg =3D 4, + .max_num_dpp =3D 4, + .max_num_wb =3D 1, + .max_dchub_pscl_bw_pix_per_clk =3D 4, + .max_pscl_lb_bw_pix_per_clk =3D 2, + .max_lb_vscl_bw_pix_per_clk =3D 4, + .max_vscl_hscl_bw_pix_per_clk =3D 4, + .max_hscl_ratio =3D 6, + .max_vscl_ratio =3D 6, + .hscl_mults =3D 4, + .vscl_mults =3D 4, + .max_hscl_taps =3D 8, + .max_vscl_taps =3D 8, + .dispclk_ramp_margin_percent =3D 1, + .underscan_factor =3D 1.11, + .min_vblank_lines =3D 32, + .dppclk_delay_subtotal =3D 46, + .dynamic_metadata_vm_enabled =3D true, + .dppclk_delay_scl_lb_only =3D 16, + .dppclk_delay_scl =3D 50, + .dppclk_delay_cnvc_formatter =3D 27, + .dppclk_delay_cnvc_cursor =3D 6, + .dispclk_delay_subtotal =3D 119, + .dcfclk_cstate_latency =3D 5.2, // SRExitTime + .max_inter_dcn_tile_repeaters =3D 8, + .max_num_hdmi_frl_outputs =3D 0, + .odm_combine_4to1_supported =3D true, + + .xfc_supported =3D false, + .xfc_fill_bw_overhead_percent =3D 10.0, + .xfc_fill_constant_bytes =3D 0, + .gfx7_compat_tiling_supported =3D 0, + .number_of_cursors =3D 1, +}; + +struct _vcs_dpi_soc_bounding_box_st dcn3_01_soc =3D { + .clock_limits =3D { + { + .state =3D 0, + .dram_speed_mts =3D 2400.0, + .fabricclk_mhz =3D 600, + .socclk_mhz =3D 278.0, + .dcfclk_mhz =3D 400.0, + .dscclk_mhz =3D 206.0, + .dppclk_mhz =3D 1015.0, + .dispclk_mhz =3D 1015.0, + .phyclk_mhz =3D 600.0, + }, + + { + .state =3D 1, + .dram_speed_mts =3D 2400.0, + .fabricclk_mhz =3D 688, + .socclk_mhz =3D 278.0, + .dcfclk_mhz =3D 400.0, + .dscclk_mhz =3D 206.0, + .dppclk_mhz =3D 1015.0, + .dispclk_mhz =3D 1015.0, + .phyclk_mhz =3D 600.0, + }, + + { + .state =3D 2, + .dram_speed_mts =3D 4267.0, + .fabricclk_mhz =3D 1067, + .socclk_mhz =3D 278.0, + .dcfclk_mhz =3D 608.0, + .dscclk_mhz =3D 296.0, + .dppclk_mhz =3D 1015.0, + .dispclk_mhz =3D 1015.0, + .phyclk_mhz =3D 810.0, + }, + + { + .state =3D 3, + .dram_speed_mts =3D 4267.0, + .fabricclk_mhz =3D 1067, + .socclk_mhz =3D 715.0, + .dcfclk_mhz =3D 676.0, + .dscclk_mhz =3D 338.0, + .dppclk_mhz =3D 1015.0, + .dispclk_mhz =3D 1015.0, + .phyclk_mhz =3D 810.0, + }, + + { + .state =3D 4, + .dram_speed_mts =3D 4267.0, + .fabricclk_mhz =3D 1067, + .socclk_mhz =3D 953.0, + .dcfclk_mhz =3D 810.0, + .dscclk_mhz =3D 338.0, + .dppclk_mhz =3D 1015.0, + .dispclk_mhz =3D 1015.0, + .phyclk_mhz =3D 810.0, + }, + }, + + .sr_exit_time_us =3D 9.0, + .sr_enter_plus_exit_time_us =3D 11.0, + .urgent_latency_us =3D 4.0, + .urgent_latency_pixel_data_only_us =3D 4.0, + .urgent_latency_pixel_mixed_with_vm_data_us =3D 4.0, + .urgent_latency_vm_data_only_us =3D 4.0, + .urgent_out_of_order_return_per_channel_pixel_only_bytes =3D 4096, + .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes =3D 4096, + .urgent_out_of_order_return_per_channel_vm_only_bytes =3D 4096, + .pct_ideal_dram_sdp_bw_after_urgent_pixel_only =3D 80.0, + .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm =3D 75.0, + .pct_ideal_dram_sdp_bw_after_urgent_vm_only =3D 40.0, + .max_avg_sdp_bw_use_normal_percent =3D 60.0, + .max_avg_dram_bw_use_normal_percent =3D 60.0, + .writeback_latency_us =3D 12.0, + .max_request_size_bytes =3D 256, + .dram_channel_width_bytes =3D 4, + .fabric_datapath_to_dcn_data_return_bytes =3D 32, + .dcn_downspread_percent =3D 0.5, + .downspread_percent =3D 0.38, + .dram_page_open_time_ns =3D 50.0, + .dram_rw_turnaround_time_ns =3D 17.5, + .dram_return_buffer_per_channel_bytes =3D 8192, + .round_trip_ping_latency_dcfclk_cycles =3D 191, + .urgent_out_of_order_return_per_channel_bytes =3D 4096, + .channel_interleave_bytes =3D 256, + .num_banks =3D 8, + .num_chans =3D 4, + .gpuvm_min_page_size_bytes =3D 4096, + .hostvm_min_page_size_bytes =3D 4096, + .dram_clock_change_latency_us =3D 23.84, + .writeback_dram_clock_change_latency_us =3D 23.0, + .return_bus_width_bytes =3D 64, + .dispclk_dppclk_vco_speed_mhz =3D 3550, + .xfc_bus_transport_time_us =3D 20, // ? + .xfc_xbuf_latency_tolerance_us =3D 4, // ? + .use_urgent_burst_bw =3D 1, // ? + .num_states =3D 5, + .do_urgent_latency_adjustment =3D false, + .urgent_latency_adjustment_fabric_clock_component_us =3D 0, + .urgent_latency_adjustment_fabric_clock_reference_mhz =3D 0, +}; + +static void calculate_wm_set_for_vlevel(int vlevel, + struct wm_range_table_entry *table_entry, + struct dcn_watermarks *wm_set, + struct display_mode_lib *dml, + display_e2e_pipe_params_st *pipes, + int pipe_cnt) +{ + double dram_clock_change_latency_cached =3D dml->soc.dram_clock_change_la= tency_us; + + ASSERT(vlevel < dml->soc.num_states); + /* only pipe 0 is read for voltage and dcf/soc clocks */ + pipes[0].clks_cfg.voltage =3D vlevel; + pipes[0].clks_cfg.dcfclk_mhz =3D dml->soc.clock_limits[vlevel].dcfclk_mhz; + pipes[0].clks_cfg.socclk_mhz =3D dml->soc.clock_limits[vlevel].socclk_mhz; + + dml->soc.dram_clock_change_latency_us =3D table_entry->pstate_latency_us; + dml->soc.sr_exit_time_us =3D table_entry->sr_exit_time_us; + dml->soc.sr_enter_plus_exit_time_us =3D table_entry->sr_enter_plus_exit_t= ime_us; + + wm_set->urgent_ns =3D get_wm_urgent(dml, pipes, pipe_cnt) * 1000; + wm_set->cstate_pstate.cstate_enter_plus_exit_ns =3D get_wm_stutter_enter_= exit(dml, pipes, pipe_cnt) * 1000; + wm_set->cstate_pstate.cstate_exit_ns =3D get_wm_stutter_exit(dml, pipes, = pipe_cnt) * 1000; + wm_set->cstate_pstate.pstate_change_ns =3D get_wm_dram_clock_change(dml, = pipes, pipe_cnt) * 1000; + wm_set->pte_meta_urgent_ns =3D get_wm_memory_trip(dml, pipes, pipe_cnt) *= 1000; + wm_set->frac_urg_bw_nom =3D get_fraction_of_urgent_bandwidth(dml, pipes, = pipe_cnt) * 1000; + wm_set->frac_urg_bw_flip =3D get_fraction_of_urgent_bandwidth_imm_flip(dm= l, pipes, pipe_cnt) * 1000; + wm_set->urgent_latency_ns =3D get_urgent_latency(dml, pipes, pipe_cnt) * = 1000; + dml->soc.dram_clock_change_latency_us =3D dram_clock_change_latency_cache= d; + +} + +void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw= _params) +{ + struct dcn301_resource_pool *pool =3D TO_DCN301_RES_POOL(dc->res_pool); + struct clk_limit_table *clk_table =3D &bw_params->clk_table; + struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES]; + unsigned int i, closest_clk_lvl; + int j; + + dc_assert_fp_enabled(); + + /* Default clock levels are used for diags, which may lead to overclockin= g. */ + if (!IS_DIAG_DC(dc->ctx->dce_environment)) { + dcn3_01_ip.max_num_otg =3D pool->base.res_cap->num_timing_generator; + dcn3_01_ip.max_num_dpp =3D pool->base.pipe_count; + dcn3_01_soc.num_chans =3D bw_params->num_channels; + + ASSERT(clk_table->num_entries); + for (i =3D 0; i < clk_table->num_entries; i++) { + /* loop backwards*/ + for (closest_clk_lvl =3D 0, j =3D dcn3_01_soc.num_states - 1; j >=3D 0;= j--) { + if ((unsigned int) dcn3_01_soc.clock_limits[j].dcfclk_mhz <=3D clk_tab= le->entries[i].dcfclk_mhz) { + closest_clk_lvl =3D j; + break; + } + } + + clock_limits[i].state =3D i; + clock_limits[i].dcfclk_mhz =3D clk_table->entries[i].dcfclk_mhz; + clock_limits[i].fabricclk_mhz =3D clk_table->entries[i].fclk_mhz; + clock_limits[i].socclk_mhz =3D clk_table->entries[i].socclk_mhz; + clock_limits[i].dram_speed_mts =3D clk_table->entries[i].memclk_mhz * 2; + + clock_limits[i].dispclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lv= l].dispclk_mhz; + clock_limits[i].dppclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dppclk_mhz; + clock_limits[i].dram_bw_per_chan_gbps =3D dcn3_01_soc.clock_limits[clos= est_clk_lvl].dram_bw_per_chan_gbps; + clock_limits[i].dscclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dscclk_mhz; + clock_limits[i].dtbclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].dtbclk_mhz; + clock_limits[i].phyclk_d18_mhz =3D dcn3_01_soc.clock_limits[closest_clk= _lvl].phyclk_d18_mhz; + clock_limits[i].phyclk_mhz =3D dcn3_01_soc.clock_limits[closest_clk_lvl= ].phyclk_mhz; + } + + for (i =3D 0; i < clk_table->num_entries; i++) + dcn3_01_soc.clock_limits[i] =3D clock_limits[i]; + + if (clk_table->num_entries) { + dcn3_01_soc.num_states =3D clk_table->num_entries; + /* duplicate last level */ + dcn3_01_soc.clock_limits[dcn3_01_soc.num_states] =3D dcn3_01_soc.clock_= limits[dcn3_01_soc.num_states - 1]; + dcn3_01_soc.clock_limits[dcn3_01_soc.num_states].state =3D dcn3_01_soc.= num_states; + } + } + + dcn3_01_soc.dispclk_dppclk_vco_speed_mhz =3D dc->clk_mgr->dentist_vco_fre= q_khz / 1000.0; + dc->dml.soc.dispclk_dppclk_vco_speed_mhz =3D dc->clk_mgr->dentist_vco_fre= q_khz / 1000.0; + + dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30); +} + +void dcn301_fpu_set_wm_ranges(int i, + struct pp_smu_wm_range_sets *ranges, + struct _vcs_dpi_soc_bounding_box_st *loaded_bb) +{ + dc_assert_fp_enabled(); + + ranges->reader_wm_sets[i].min_fill_clk_mhz =3D (i > 0) ? (loaded_bb->cloc= k_limits[i - 1].dram_speed_mts / 16) + 1 : 0; + ranges->reader_wm_sets[i].max_fill_clk_mhz =3D loaded_bb->clock_limits[i]= .dram_speed_mts / 16; +} + +void dcn301_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info) +{ + dc_assert_fp_enabled(); + + if (bb_info.dram_clock_change_latency_100ns > 0) + dcn3_01_soc.dram_clock_change_latency_us =3D bb_info.dram_clock_change_l= atency_100ns * 10; + + if (bb_info.dram_sr_enter_exit_latency_100ns > 0) + dcn3_01_soc.sr_enter_plus_exit_time_us =3D bb_info.dram_sr_enter_exit_la= tency_100ns * 10; + + if (bb_info.dram_sr_exit_latency_100ns > 0) + dcn3_01_soc.sr_exit_time_us =3D bb_info.dram_sr_exit_latency_100ns * 10; +} + +void dcn301_calculate_wm_and_dlg(struct dc *dc, + struct dc_state *context, + display_e2e_pipe_params_st *pipes, + int pipe_cnt, + int vlevel_req) +{ + int i, pipe_idx; + int vlevel, vlevel_max; + struct wm_range_table_entry *table_entry; + struct clk_bw_params *bw_params =3D dc->clk_mgr->bw_params; + + ASSERT(bw_params); + dc_assert_fp_enabled(); + + vlevel_max =3D bw_params->clk_table.num_entries - 1; + + /* WM Set D */ + table_entry =3D &bw_params->wm_table.entries[WM_D]; + if (table_entry->wm_type =3D=3D WM_TYPE_RETRAINING) + vlevel =3D 0; + else + vlevel =3D vlevel_max; + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.d, + &context->bw_ctx.dml, pipes, pipe_cnt); + /* WM Set C */ + table_entry =3D &bw_params->wm_table.entries[WM_C]; + vlevel =3D min(max(vlevel_req, 2), vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.c, + &context->bw_ctx.dml, pipes, pipe_cnt); + /* WM Set B */ + table_entry =3D &bw_params->wm_table.entries[WM_B]; + vlevel =3D min(max(vlevel_req, 1), vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.b, + &context->bw_ctx.dml, pipes, pipe_cnt); + + /* WM Set A */ + table_entry =3D &bw_params->wm_table.entries[WM_A]; + vlevel =3D min(vlevel_req, vlevel_max); + calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.= watermarks.a, + &context->bw_ctx.dml, pipes, pipe_cnt); + + for (i =3D 0, pipe_idx =3D 0; i < dc->res_pool->pipe_count; i++) { + if (!context->res_ctx.pipe_ctx[i].stream) + continue; + + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D get_dispclk_calculated(&context= ->bw_ctx.dml, pipes, pipe_cnt); + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D get_dppclk_calculated(&context->= bw_ctx.dml, pipes, pipe_cnt, pipe_idx); + + if (dc->config.forced_clocks) { + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D context->bw_ctx.dml.soc.clock_= limits[0].dispclk_mhz; + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D context->bw_ctx.dml.soc.clock_l= imits[0].dppclk_mhz; + } + if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * = 1000) + pipes[pipe_idx].clks_cfg.dispclk_mhz =3D dc->debug.min_disp_clk_khz / 1= 000.0; + if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 10= 00) + pipes[pipe_idx].clks_cfg.dppclk_mhz =3D dc->debug.min_dpp_clk_khz / 100= 0.0; + pipe_idx++; + } + + dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel); +} diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h b/drive= rs/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h new file mode 100644 index 0000000000000..fc7065d178422 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h @@ -0,0 +1,42 @@ +/* + * Copyright 2019-2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software= "), + * to deal in the Software without restriction, including without limitati= on + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __DCN301_FPU_H__ +#define __DCN301_FPU_H__ + +void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw= _params); + +void dcn301_fpu_set_wm_ranges(int i, + struct pp_smu_wm_range_sets *ranges, + struct _vcs_dpi_soc_bounding_box_st *loaded_bb); + +void dcn301_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info); + +void dcn301_calculate_wm_and_dlg(struct dc *dc, + struct dc_state *context, + display_e2e_pipe_params_st *pipes, + int pipe_cnt, + int vlevel_req); +#endif /* __DCN301_FPU_H__*/ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9E0BC433EF for ; Mon, 7 Mar 2022 09:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238411AbiCGJyQ (ORCPT ); Mon, 7 Mar 2022 04:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241074AbiCGJlt (ORCPT ); Mon, 7 Mar 2022 04:41:49 -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 B767E674C6; Mon, 7 Mar 2022 01:39: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 5F2CFB8102B; Mon, 7 Mar 2022 09:39:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73C7EC340E9; Mon, 7 Mar 2022 09:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645994; bh=mwHGz5my3kdOnsfHVXD1eY4BLPH1ibOUm3wCthFc8UY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C06GmzR2eQU57997rx9H1fXNAtU+JwPyIvmT6jW2rxzEsB2kRMRBDePwO/maPwR31 66UUJI9VoYVqNQPz5/Al00Z4dG/uZwjM+RsKcSU/O+8QXK5MdL8QdELoD9GiKyqoV2 /2KBH0CVDI4tknzByi0I1O/95faD3RZHkkidaLms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bas Nieuwenhuizen , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 102/262] drm/amd/display: Wrap dcn301_calculate_wm_and_dlg for FPU. Date: Mon, 7 Mar 2022 10:17:26 +0100 Message-Id: <20220307091705.356758501@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bas Nieuwenhuizen [ Upstream commit 25f1488bdbba63415239ff301fe61a8546140d9f ] Mirrors the logic for dcn30. Cue lots of WARNs and some kernel panics without this fix. Cc: stable@vger.kernel.org Signed-off-by: Bas Nieuwenhuizen Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 11 +++++++++++ .../gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c | 2 +- .../gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c b/driv= ers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c index d17994bb318f7..34b01cc8f548b 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c @@ -1387,6 +1387,17 @@ static void set_wm_ranges( pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges); } =20 +static void dcn301_calculate_wm_and_dlg( + struct dc *dc, struct dc_state *context, + display_e2e_pipe_params_st *pipes, + int pipe_cnt, + int vlevel) +{ + DC_FP_START(); + dcn301_calculate_wm_and_dlg_fp(dc, context, pipes, pipe_cnt, vlevel); + DC_FP_END(); +} + static struct resource_funcs dcn301_res_pool_funcs =3D { .destroy =3D dcn301_destroy_resource_pool, .link_enc_create =3D dcn301_link_encoder_create, diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c b/drive= rs/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c index 94c32832a0e7b..0a7a338649731 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c @@ -327,7 +327,7 @@ void dcn301_fpu_init_soc_bounding_box(struct bp_soc_bb_= info bb_info) dcn3_01_soc.sr_exit_time_us =3D bb_info.dram_sr_exit_latency_100ns * 10; } =20 -void dcn301_calculate_wm_and_dlg(struct dc *dc, +void dcn301_calculate_wm_and_dlg_fp(struct dc *dc, struct dc_state *context, display_e2e_pipe_params_st *pipes, int pipe_cnt, diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h b/drive= rs/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h index fc7065d178422..774b0fdfc80be 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h @@ -34,7 +34,7 @@ void dcn301_fpu_set_wm_ranges(int i, =20 void dcn301_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info); =20 -void dcn301_calculate_wm_and_dlg(struct dc *dc, +void dcn301_calculate_wm_and_dlg_fp(struct dc *dc, struct dc_state *context, display_e2e_pipe_params_st *pipes, int pipe_cnt, --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AEC9C35280 for ; Mon, 7 Mar 2022 10:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239672AbiCGKDf (ORCPT ); Mon, 7 Mar 2022 05:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241072AbiCGJlt (ORCPT ); Mon, 7 Mar 2022 04:41:49 -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 6150F66AEC; Mon, 7 Mar 2022 01:39: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 A1D8B61219; Mon, 7 Mar 2022 09:39:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86A6FC340F4; Mon, 7 Mar 2022 09:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645998; bh=GxjjCsKo7A5cdJcZZChpjxpBbwzR2bIJcqLI7N/1ee8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Don1FKx4OxSHYmPxsfZAhQGpqPYKDlQGU/21CmYowoyf+jBlj0te0/y7h/F28mEj8 s90KV4TIrQbQ7jXZN1yJK1nPcfVX2vNoJksDiDWufWWnquRpDXs78sBxNj8Up9ivsh J48AzNqpXshRK1Uhc+OooDXQWY1aGp5Xr/+nlYzw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Tal , Ido Schimmel , Gal Pressman , Amit Cohen , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 103/262] ethtool: Fix link extended state for big endian Date: Mon, 7 Mar 2022 10:17:27 +0100 Message-Id: <20220307091705.383984434@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Moshe Tal [ Upstream commit e2f08207c558bc0bc8abaa557cdb29bad776ac7b ] The link extended sub-states are assigned as enum that is an integer size but read from a union as u8, this is working for small values on little endian systems but for big endian this always give 0. Fix the variable in the union to match the enum size. Fixes: ecc31c60240b ("ethtool: Add link extended state") Signed-off-by: Moshe Tal Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel Reviewed-by: Gal Pressman Reviewed-by: Amit Cohen Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- include/linux/ethtool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 849524b55d89a..3fad741df53ef 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -94,7 +94,7 @@ struct ethtool_link_ext_state_info { enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismat= ch; enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; enum ethtool_link_ext_substate_cable_issue cable_issue; - u8 __link_ext_substate; + u32 __link_ext_substate; }; }; =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 059B8C433EF for ; Mon, 7 Mar 2022 09:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238820AbiCGJyq (ORCPT ); Mon, 7 Mar 2022 04:54:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241092AbiCGJlw (ORCPT ); Mon, 7 Mar 2022 04:41:52 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D27F5D19F; Mon, 7 Mar 2022 01:40: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 884D5B80F9F; Mon, 7 Mar 2022 09:40:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1268C340E9; Mon, 7 Mar 2022 09:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646004; bh=ycM/QmibiU7Q/BdwlMZj3lZ2noC+UzaK8jXmgw66M10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cv8CkeHqCaCv6lVMqQKWELTV/n3kOJ42/HHlLNhw3iO+fBtNmXQURcsUceJeNiRII qAnV8JJGtHT0MrtPW6V1k0u0AfPmdT+69GHpgEpDsHsFFKSsRb76x/uibgB33Q7nQb RdmFisxkEMm0JhDhY8f/5ttb6EXka1NPu4/KwTTM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kiran Kumar K , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 104/262] octeontx2-af: Optimize KPU1 processing for variable-length headers Date: Mon, 7 Mar 2022 10:17:28 +0100 Message-Id: <20220307091705.411688952@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kiran Kumar K [ Upstream commit edadeb38dc2fa2550801995b748110c3e5e59557 ] Optimized KPU1 entry processing for variable-length custom L2 headers of size 24B, 90B by - Moving LA LTYPE parsing for 24B and 90B headers to PKIND. - Removing LA flags assignment for 24B and 90B headers. - Reserving a PKIND 55 to parse variable length headers. Also, new mailbox(NPC_SET_PKIND) added to configure PKIND with corresponding variable-length offset, mask, and shift count (NPC_AF_KPUX_ENTRYX_ACTION0). Signed-off-by: Kiran Kumar K Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../net/ethernet/marvell/octeontx2/af/mbox.h | 20 +- .../net/ethernet/marvell/octeontx2/af/npc.h | 9 +- .../marvell/octeontx2/af/npc_profile.h | 382 +++--------------- .../net/ethernet/marvell/octeontx2/af/rvu.h | 5 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 4 + .../ethernet/marvell/octeontx2/af/rvu_npc.c | 96 +++++ 7 files changed, 195 insertions(+), 323 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net= /ethernet/marvell/octeontx2/af/mbox.h index 26ad71842b3b2..472eb2a5697a4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -84,7 +84,7 @@ struct mbox_msghdr { #define OTX2_MBOX_REQ_SIG (0xdead) #define OTX2_MBOX_RSP_SIG (0xbeef) u16 sig; /* Signature, for validating corrupted msgs */ -#define OTX2_MBOX_VERSION (0x0009) +#define OTX2_MBOX_VERSION (0x000a) u16 ver; /* Version of msg's structure for this ID */ u16 next_msgoff; /* Offset of next msg within mailbox region */ int rc; /* Msg process'ed response code */ @@ -229,6 +229,8 @@ M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \ M(NPC_MCAM_READ_ENTRY, 0x600f, npc_mcam_read_entry, \ npc_mcam_read_entry_req, \ npc_mcam_read_entry_rsp) \ +M(NPC_SET_PKIND, 0x6010, npc_set_pkind, \ + npc_set_pkind, msg_rsp) \ M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule, \ msg_req, npc_mcam_read_base_rule_rsp) \ M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats, \ @@ -593,6 +595,22 @@ struct rpm_stats_rsp { u64 tx_stats[RPM_TX_STATS_COUNT]; }; =20 +struct npc_set_pkind { + struct mbox_msghdr hdr; +#define OTX2_PRIV_FLAGS_DEFAULT BIT_ULL(0) +#define OTX2_PRIV_FLAGS_CUSTOM BIT_ULL(63) + u64 mode; +#define PKIND_TX BIT_ULL(0) +#define PKIND_RX BIT_ULL(1) + u8 dir; + u8 pkind; /* valid only in case custom flag */ + u8 var_len_off; /* Offset of custom header length field. + * Valid only for pkind NPC_RX_CUSTOM_PRE_L2_PKIND + */ + u8 var_len_off_mask; /* Mask for length with in offset */ + u8 shift_dir; /* shift direction to get length of the header at var_len_o= ff */ +}; + /* NPA mbox message formats */ =20 /* NPA mailbox error codes diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h b/drivers/net/= ethernet/marvell/octeontx2/af/npc.h index 3a819b24accc6..6e1192f526089 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h @@ -31,9 +31,9 @@ enum npc_kpu_la_ltype { NPC_LT_LA_HIGIG2_ETHER, NPC_LT_LA_IH_NIX_HIGIG2_ETHER, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_LT_LA_CH_LEN_90B_ETHER, NPC_LT_LA_CPT_HDR, NPC_LT_LA_CUSTOM_L2_24B_ETHER, + NPC_LT_LA_CUSTOM_PRE_L2_ETHER, NPC_LT_LA_CUSTOM0 =3D 0xE, NPC_LT_LA_CUSTOM1 =3D 0xF, }; @@ -148,10 +148,11 @@ enum npc_kpu_lh_ltype { * Software assigns pkind for each incoming port such as CGX * Ethernet interfaces, LBK interfaces, etc. */ -#define NPC_UNRESERVED_PKIND_COUNT NPC_RX_VLAN_EXDSA_PKIND +#define NPC_UNRESERVED_PKIND_COUNT NPC_RX_CUSTOM_PRE_L2_PKIND =20 enum npc_pkind_type { NPC_RX_LBK_PKIND =3D 0ULL, + NPC_RX_CUSTOM_PRE_L2_PKIND =3D 55ULL, NPC_RX_VLAN_EXDSA_PKIND =3D 56ULL, NPC_RX_CHLEN24B_PKIND =3D 57ULL, NPC_RX_CPT_HDR_PKIND, @@ -162,6 +163,10 @@ enum npc_pkind_type { NPC_TX_DEF_PKIND, /* NIX-TX PKIND */ }; =20 +enum npc_interface_type { + NPC_INTF_MODE_DEF, +}; + /* list of known and supported fields in packet header and * fields present in key structure. */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h b/driv= ers/net/ethernet/marvell/octeontx2/af/npc_profile.h index 588822a0cf21e..2b7030886daec 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h @@ -176,9 +176,8 @@ enum npc_kpu_parser_state { NPC_S_KPU1_EXDSA, NPC_S_KPU1_HIGIG2, NPC_S_KPU1_IH_NIX_HIGIG2, - NPC_S_KPU1_CUSTOM_L2_90B, + NPC_S_KPU1_CUSTOM_PRE_L2, NPC_S_KPU1_CPT_HDR, - NPC_S_KPU1_CUSTOM_L2_24B, NPC_S_KPU1_VLAN_EXDSA, NPC_S_KPU2_CTAG, NPC_S_KPU2_CTAG2, @@ -979,8 +978,8 @@ static struct npc_kpu_profile_action ikpu_action_entrie= s[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 12, 16, 20, 0, 0, - NPC_S_KPU1_ETHER, 0, 0, - NPC_LID_LA, NPC_LT_NA, + NPC_S_KPU1_CUSTOM_PRE_L2, 0, 1, + NPC_LID_LA, NPC_LT_LA_CUSTOM_PRE_L2_ETHER, 0, 0, 0, 0, 0, =20 @@ -996,9 +995,9 @@ static struct npc_kpu_profile_action ikpu_action_entrie= s[] =3D { }, { NPC_ERRLEV_RE, NPC_EC_NOERR, - 36, 40, 44, 0, 0, - NPC_S_KPU1_CUSTOM_L2_24B, 0, 0, - NPC_LID_LA, NPC_LT_NA, + 12, 16, 20, 0, 0, + NPC_S_KPU1_CUSTOM_PRE_L2, 24, 1, + NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, 0, 0, 0, 0, 0, =20 @@ -1014,9 +1013,9 @@ static struct npc_kpu_profile_action ikpu_action_entr= ies[] =3D { }, { NPC_ERRLEV_RE, NPC_EC_NOERR, - 102, 106, 110, 0, 0, - NPC_S_KPU1_CUSTOM_L2_90B, 0, 0, - NPC_LID_LA, NPC_LT_NA, + 12, 16, 20, 0, 0, + NPC_S_KPU1_CUSTOM_PRE_L2, 90, 1, + NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, 0, 0, 0, 0, 0, =20 @@ -1711,7 +1710,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_IP, 0xffff, 0x0000, @@ -1720,7 +1719,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_IP6, 0xffff, 0x0000, @@ -1729,7 +1728,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_ARP, 0xffff, 0x0000, @@ -1738,7 +1737,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_RARP, 0xffff, 0x0000, @@ -1747,7 +1746,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_PTP, 0xffff, 0x0000, @@ -1756,7 +1755,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_FCOE, 0xffff, 0x0000, @@ -1765,7 +1764,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_CTAG, 0xffff, NPC_ETYPE_CTAG, @@ -1774,7 +1773,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_CTAG, 0xffff, 0x0000, @@ -1783,7 +1782,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_SBTAG, 0xffff, 0x0000, @@ -1792,7 +1791,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_QINQ, 0xffff, 0x0000, @@ -1801,7 +1800,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_ETAG, 0xffff, 0x0000, @@ -1810,7 +1809,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_MPLSU, 0xffff, 0x0000, @@ -1819,7 +1818,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_MPLSM, 0xffff, 0x0000, @@ -1828,7 +1827,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, NPC_ETYPE_NSH, 0xffff, 0x0000, @@ -1837,7 +1836,7 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[] = =3D { 0x0000, }, { - NPC_S_KPU1_CUSTOM_L2_90B, 0xff, + NPC_S_KPU1_CUSTOM_PRE_L2, 0xff, 0x0000, 0x0000, 0x0000, @@ -1926,141 +1925,6 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[= ] =3D { 0x0000, 0x0000, }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_IP, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_IP6, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_ARP, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_RARP, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_PTP, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_FCOE, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_CTAG, - 0xffff, - NPC_ETYPE_CTAG, - 0xffff, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_CTAG, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_SBTAG, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_QINQ, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_ETAG, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_MPLSU, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_MPLSM, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - NPC_ETYPE_NSH, - 0xffff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CUSTOM_L2_24B, 0xff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, { NPC_S_KPU1_VLAN_EXDSA, 0xff, NPC_ETYPE_CTAG, @@ -9192,121 +9056,121 @@ static struct npc_kpu_profile_action kpu1_action_= entries[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 0, 6, 3, 0, - NPC_S_KPU5_IP, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_IP, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 6, 0, 0, 3, 0, - NPC_S_KPU5_IP6, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_IP6, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 0, 0, 0, 3, 0, - NPC_S_KPU5_ARP, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_ARP, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 0, 0, 0, 3, 0, - NPC_S_KPU5_RARP, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_RARP, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 0, 0, 0, 3, 0, - NPC_S_KPU5_PTP, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_PTP, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 0, 0, 0, 3, 0, - NPC_S_KPU5_FCOE, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, + NPC_S_KPU5_FCOE, 14, 0, + NPC_LID_LA, NPC_LT_NA, 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 12, 0, 0, 0, - NPC_S_KPU2_CTAG2, 102, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, + NPC_S_KPU2_CTAG2, 12, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 4, 8, 0, 0, 0, - NPC_S_KPU2_CTAG, 102, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, + NPC_S_KPU2_CTAG, 12, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 4, 8, 22, 0, 0, - NPC_S_KPU2_SBTAG, 102, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, + NPC_S_KPU2_SBTAG, 12, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 4, 8, 0, 0, 0, - NPC_S_KPU2_QINQ, 102, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, + NPC_S_KPU2_QINQ, 12, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 12, 26, 0, 0, - NPC_S_KPU2_ETAG, 102, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_ETAG, + NPC_S_KPU2_ETAG, 12, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 2, 6, 10, 2, 0, - NPC_S_KPU4_MPLS, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_L_WITH_MPLS, + NPC_S_KPU4_MPLS, 14, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 2, 6, 10, 2, 0, - NPC_S_KPU4_MPLS, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_L_WITH_MPLS, + NPC_S_KPU4_MPLS, 14, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 2, 0, 0, 2, 0, - NPC_S_KPU4_NSH, 104, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_L_WITH_NSH, + NPC_S_KPU4_NSH, 14, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 0, 0, 0, 0, 1, - NPC_S_NA, 0, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_90B_ETHER, - NPC_F_LA_L_UNK_ETYPE, + NPC_S_NA, 0, 0, + NPC_LID_LA, NPC_LT_NA, + 0, 0, 0, 0, 0, }, { @@ -9381,126 +9245,6 @@ static struct npc_kpu_profile_action kpu1_action_en= tries[] =3D { NPC_F_LA_L_UNK_ETYPE, 0, 0, 0, 0, }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 8, 0, 6, 3, 0, - NPC_S_KPU5_IP, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 6, 0, 0, 3, 0, - NPC_S_KPU5_IP6, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 3, 0, - NPC_S_KPU5_ARP, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 3, 0, - NPC_S_KPU5_RARP, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 3, 0, - NPC_S_KPU5_PTP, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 3, 0, - NPC_S_KPU5_FCOE, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 8, 12, 0, 0, 0, - NPC_S_KPU2_CTAG2, 36, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 4, 8, 0, 0, 0, - NPC_S_KPU2_CTAG, 36, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 4, 8, 22, 0, 0, - NPC_S_KPU2_SBTAG, 36, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 4, 8, 0, 0, 0, - NPC_S_KPU2_QINQ, 36, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 8, 12, 26, 0, 0, - NPC_S_KPU2_ETAG, 36, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_ETAG, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 2, 6, 10, 2, 0, - NPC_S_KPU4_MPLS, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_L_WITH_MPLS, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 2, 6, 10, 2, 0, - NPC_S_KPU4_MPLS, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_L_WITH_MPLS, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 2, 0, 0, 2, 0, - NPC_S_KPU4_NSH, 38, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_L_WITH_NSH, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 0, 1, - NPC_S_NA, 0, 1, - NPC_LID_LA, NPC_LT_LA_CUSTOM_L2_24B_ETHER, - NPC_F_LA_L_UNK_ETYPE, - 0, 0, 0, 0, - }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 12, 0, 0, 1, 0, diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index 1d9411232f1da..c3979ec2bb86d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -237,6 +237,7 @@ struct rvu_pfvf { bool cgx_in_use; /* this PF/VF using CGX? */ int cgx_users; /* number of cgx users - used only by PFs */ =20 + int intf_mode; u8 nix_blkaddr; /* BLKADDR_NIX0/1 assigned to this PF */ u8 nix_rx_intf; /* NIX0_RX/NIX1_RX interface to NPC */ u8 nix_tx_intf; /* NIX0_TX/NIX1_TX interface to NPC */ @@ -794,6 +795,7 @@ void npc_enable_mcam_entry(struct rvu *rvu, struct npc_= mcam *mcam, void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, int blkaddr, u16 src, struct mcam_entry *entry, u8 *intf, u8 *ena); +bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc); bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature); u32 rvu_cgx_get_fifolen(struct rvu *rvu); void *rvu_first_cgx_pdata(struct rvu *rvu); @@ -827,4 +829,7 @@ void rvu_switch_enable(struct rvu *rvu); void rvu_switch_disable(struct rvu *rvu); void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc); =20 +int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir, + u64 pkind, u8 var_len_off, u8 var_len_off_mask, + u8 shift_dir); #endif /* RVU_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_cgx.c index 81e8ea9ee30ea..21e5906bcc372 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -411,7 +411,7 @@ int rvu_cgx_exit(struct rvu *rvu) * VF's of mapped PF and other PFs are not allowed. This fn() checks * whether a PFFUNC is permitted to do the config or not. */ -static bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc) +inline bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc) { if ((pcifunc & RVU_PFVF_FUNC_MASK) || !is_pf_cgxmapped(rvu, rvu_get_pf(pcifunc))) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_nix.c index 959266894cf15..f43df4683943d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -4555,6 +4555,10 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifun= c, int blkaddr, int nixlf) dev_err(rvu->dev, "CQ ctx disable failed\n"); } =20 + /* reset HW config done for Switch headers */ + rvu_npc_set_parse_mode(rvu, pcifunc, OTX2_PRIV_FLAGS_DEFAULT, + (PKIND_TX | PKIND_RX), 0, 0, 0, 0); + nix_ctx_free(rvu, pfvf); =20 nix_free_all_bandprof(rvu, pcifunc); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_npc.c index 87f18e32b4634..2f347e937f00a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -3183,6 +3183,102 @@ int rvu_mbox_handler_npc_get_kex_cfg(struct rvu *rv= u, struct msg_req *req, return 0; } =20 +int +npc_set_var_len_offset_pkind(struct rvu *rvu, u16 pcifunc, u64 pkind, + u8 var_len_off, u8 var_len_off_mask, u8 shift_dir) +{ + struct npc_kpu_action0 *act0; + u8 shift_count =3D 0; + int blkaddr; + u64 val; + + if (!var_len_off_mask) + return -EINVAL; + + if (var_len_off_mask !=3D 0xff) { + if (shift_dir) + shift_count =3D __ffs(var_len_off_mask); + else + shift_count =3D (8 - __fls(var_len_off_mask)); + } + blkaddr =3D rvu_get_blkaddr(rvu, BLKTYPE_NPC, pcifunc); + if (blkaddr < 0) { + dev_err(rvu->dev, "%s: NPC block not implemented\n", __func__); + return -EINVAL; + } + val =3D rvu_read64(rvu, blkaddr, NPC_AF_PKINDX_ACTION0(pkind)); + act0 =3D (struct npc_kpu_action0 *)&val; + act0->var_len_shift =3D shift_count; + act0->var_len_right =3D shift_dir; + act0->var_len_mask =3D var_len_off_mask; + act0->var_len_offset =3D var_len_off; + rvu_write64(rvu, blkaddr, NPC_AF_PKINDX_ACTION0(pkind), val); + return 0; +} + +int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir, + u64 pkind, u8 var_len_off, u8 var_len_off_mask, + u8 shift_dir) + +{ + struct rvu_pfvf *pfvf =3D rvu_get_pfvf(rvu, pcifunc); + int blkaddr, nixlf, rc, intf_mode; + int pf =3D rvu_get_pf(pcifunc); + u64 rxpkind, txpkind; + u8 cgx_id, lmac_id; + + /* use default pkind to disable edsa/higig */ + rxpkind =3D rvu_npc_get_pkind(rvu, pf); + txpkind =3D NPC_TX_DEF_PKIND; + intf_mode =3D NPC_INTF_MODE_DEF; + + if (mode & OTX2_PRIV_FLAGS_CUSTOM) { + if (pkind =3D=3D NPC_RX_CUSTOM_PRE_L2_PKIND) { + rc =3D npc_set_var_len_offset_pkind(rvu, pcifunc, pkind, + var_len_off, + var_len_off_mask, + shift_dir); + if (rc) + return rc; + } + rxpkind =3D pkind; + txpkind =3D pkind; + } + + if (dir & PKIND_RX) { + /* rx pkind set req valid only for cgx mapped PFs */ + if (!is_cgx_config_permitted(rvu, pcifunc)) + return 0; + rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); + + rc =3D cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, + rxpkind); + if (rc) + return rc; + } + + if (dir & PKIND_TX) { + /* Tx pkind set request valid if PCIFUNC has NIXLF attached */ + rc =3D nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr); + if (rc) + return rc; + + rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), + txpkind); + } + + pfvf->intf_mode =3D intf_mode; + return 0; +} + +int rvu_mbox_handler_npc_set_pkind(struct rvu *rvu, struct npc_set_pkind *= req, + struct msg_rsp *rsp) +{ + return rvu_npc_set_parse_mode(rvu, req->hdr.pcifunc, req->mode, + req->dir, req->pkind, req->var_len_off, + req->var_len_off_mask, req->shift_dir); +} + int rvu_mbox_handler_npc_read_base_steer_rule(struct rvu *rvu, struct msg_req *req, struct npc_mcam_read_base_rule_rsp *rsp) --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E529C433EF for ; Mon, 7 Mar 2022 09:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238792AbiCGJy3 (ORCPT ); Mon, 7 Mar 2022 04:54:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241093AbiCGJlw (ORCPT ); Mon, 7 Mar 2022 04:41:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 841525D655; Mon, 7 Mar 2022 01:40: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 1DF726116E; Mon, 7 Mar 2022 09:40:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13467C340E9; Mon, 7 Mar 2022 09:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646007; bh=4hul46E6M13tu7nqzKV9JHzMnYCa+y8ZDlItbvwDFVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b38pec++lOYtlvsEdhM+n93Bm4e+kARxeLObnCfeuTkFAIMrlx4FxcXNrmvX+C3hR uiaXtcNDKSwiQBs/bPQifhigcUihtaYSPyFatoOPuTZoYIONZCkKMUM31bP8h8U2IX wia0WxLONJJoeWdBZ5azlv3YzX+TJGx8GEjP3kFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harman Kalra , Hariprasad Kelam , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 105/262] octeontx2-af: Reset PTP config in FLR handler Date: Mon, 7 Mar 2022 10:17:29 +0100 Message-Id: <20220307091705.439572677@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Harman Kalra [ Upstream commit e37e08fffc373206ad4e905c05729ea6bbdcb22c ] Upon receiving ptp config request from netdev interface , Octeontx2 MAC block CGX is configured to append timestamp to every incoming packet and NPC config is updated with DMAC offset change. Currently this configuration is not reset in FLR handler. This patch resets the same. Signed-off-by: Harman Kalra Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 3 +++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index c3979ec2bb86d..8f81e468be048 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -220,6 +220,7 @@ struct rvu_pfvf { u16 maxlen; u16 minlen; =20 + bool hw_rx_tstamp_en; /* Is rx_tstamp enabled */ u8 mac_addr[ETH_ALEN]; /* MAC address of this PF/VF */ u8 default_mac[ETH_ALEN]; /* MAC address from FWdata */ =20 diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_cgx.c index 21e5906bcc372..a5c717ad12c15 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -694,6 +694,7 @@ int rvu_mbox_handler_cgx_promisc_disable(struct rvu *rv= u, struct msg_req *req, =20 static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) { + struct rvu_pfvf *pfvf =3D rvu_get_pfvf(rvu, pcifunc); int pf =3D rvu_get_pf(pcifunc); u8 cgx_id, lmac_id; void *cgxd; @@ -718,6 +719,8 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcif= unc, bool enable) */ if (npc_config_ts_kpuaction(rvu, pf, pcifunc, enable)) return -EINVAL; + /* This flag is required to clean up CGX conf if app gets killed */ + pfvf->hw_rx_tstamp_en =3D enable; =20 return 0; } diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_nix.c index f43df4683943d..8c94e30d0499e 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -4519,6 +4519,9 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc= , int blkaddr, int nixlf) { struct rvu_pfvf *pfvf =3D rvu_get_pfvf(rvu, pcifunc); struct hwctx_disable_req ctx_req; + int pf =3D rvu_get_pf(pcifunc); + u8 cgx_id, lmac_id; + void *cgxd; int err; =20 ctx_req.hdr.pcifunc =3D pcifunc; @@ -4559,6 +4562,17 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifun= c, int blkaddr, int nixlf) rvu_npc_set_parse_mode(rvu, pcifunc, OTX2_PRIV_FLAGS_DEFAULT, (PKIND_TX | PKIND_RX), 0, 0, 0, 0); =20 + /* Disabling CGX and NPC config done for PTP */ + if (pfvf->hw_rx_tstamp_en) { + rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); + cgxd =3D rvu_cgx_pdata(cgx_id, rvu); + cgx_lmac_ptp_config(cgxd, lmac_id, false); + /* Undo NPC config done for PTP */ + if (npc_config_ts_kpuaction(rvu, pf, pcifunc, false)) + dev_err(rvu->dev, "NPC config for PTP failed\n"); + pfvf->hw_rx_tstamp_en =3D false; + } + nix_ctx_free(rvu, pfvf); =20 nix_free_all_bandprof(rvu, pcifunc); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73731C4332F for ; Mon, 7 Mar 2022 10:02:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239872AbiCGKDl (ORCPT ); Mon, 7 Mar 2022 05:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241105AbiCGJlx (ORCPT ); Mon, 7 Mar 2022 04:41:53 -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 39C6A229; Mon, 7 Mar 2022 01:40: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 E50E5B8102B; Mon, 7 Mar 2022 09:40:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CC5CC340E9; Mon, 7 Mar 2022 09:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646015; bh=PRioSQYfQKeMU8Wa12OiSRW07y/KbzapIdF6LmgaBdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wYoLBy5MJc/wG+glrAkNrG/2d9a8CDp/nh7+Dhk1HkMP442KgkCkLleC6kT5HDrox Q7FUZz4qDB1MZnu1NhqzOa5V3P53swSjBNbVxOI3Ebv3Z1+wjeKBWhsOvybZI1Ly6E vVJWq0nJ82ObRD0AiwUwR4AViWuugSIT4XrcfRuE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hariprasad Kelam , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 106/262] octeontx2-af: cn10k: RPM hardware timestamp configuration Date: Mon, 7 Mar 2022 10:17:30 +0100 Message-Id: <20220307091705.467083438@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hariprasad Kelam [ Upstream commit d1489208681dfe432609fdaa49b160219c6e221c ] MAC on CN10K support hardware timestamping such that 8 bytes addition header is prepended to incoming packets. This patch does necessary configuration to enable Hardware time stamping upon receiving request from PF netdev interfaces. Timestamp configuration is different on MAC (CGX) Octeontx2 silicon and MAC (RPM) OcteonTX3 CN10k. Based on silicon variant appropriate fn() pointer is called. Refactor MAC specific mbox messages to remove unnecessary gaps in mboxids. Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../net/ethernet/marvell/octeontx2/af/cgx.c | 10 ++--- .../marvell/octeontx2/af/lmac_common.h | 5 +++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 41 ++++++++++--------- .../net/ethernet/marvell/octeontx2/af/rpm.c | 17 ++++++++ .../net/ethernet/marvell/octeontx2/af/rpm.h | 3 ++ .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 4 +- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 4 +- 7 files changed, 58 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/= ethernet/marvell/octeontx2/af/cgx.c index 34a089b71e554..d379a35c4618f 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -838,9 +838,6 @@ void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool = enable) if (!cgx) return; =20 - if (is_dev_rpm(cgx)) - return; - if (enable) { /* Enable inbound PTP timestamping */ cfg =3D cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL); @@ -1545,9 +1542,11 @@ static int cgx_lmac_exit(struct cgx *cgx) static void cgx_populate_features(struct cgx *cgx) { if (is_dev_rpm(cgx)) - cgx->hw_features =3D (RVU_MAC_RPM | RVU_LMAC_FEAT_FC); + cgx->hw_features =3D (RVU_LMAC_FEAT_DMACF | RVU_MAC_RPM | + RVU_LMAC_FEAT_FC | RVU_LMAC_FEAT_PTP); else - cgx->hw_features =3D (RVU_LMAC_FEAT_FC | RVU_LMAC_FEAT_PTP); + cgx->hw_features =3D (RVU_LMAC_FEAT_FC | RVU_LMAC_FEAT_HIGIG2 | + RVU_LMAC_FEAT_PTP | RVU_LMAC_FEAT_DMACF); } =20 static struct mac_ops cgx_mac_ops =3D { @@ -1571,6 +1570,7 @@ static struct mac_ops cgx_mac_ops =3D { .mac_get_pause_frm_status =3D cgx_lmac_get_pause_frm_status, .mac_enadis_pause_frm =3D cgx_lmac_enadis_pause_frm, .mac_pause_frm_config =3D cgx_lmac_pause_frm_config, + .mac_enadis_ptp_config =3D cgx_lmac_ptp_config, }; =20 static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h b/driv= ers/net/ethernet/marvell/octeontx2/af/lmac_common.h index c38306b3384a7..fc6e7423cbd81 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h @@ -102,6 +102,11 @@ struct mac_ops { void (*mac_pause_frm_config)(void *cgxd, int lmac_id, bool enable); + + /* Enable/Disable Inbound PTP */ + void (*mac_enadis_ptp_config)(void *cgxd, + int lmac_id, + bool enable); }; =20 struct cgx { diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net= /ethernet/marvell/octeontx2/af/mbox.h index 472eb2a5697a4..c6643c7db1fc4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -154,23 +154,23 @@ M(CGX_PTP_RX_ENABLE, 0x20C, cgx_ptp_rx_enable, msg_re= q, msg_rsp) \ M(CGX_PTP_RX_DISABLE, 0x20D, cgx_ptp_rx_disable, msg_req, msg_rsp) \ M(CGX_CFG_PAUSE_FRM, 0x20E, cgx_cfg_pause_frm, cgx_pause_frm_cfg, \ cgx_pause_frm_cfg) \ -M(CGX_FEC_SET, 0x210, cgx_set_fec_param, fec_mode, fec_mode) \ -M(CGX_FEC_STATS, 0x211, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \ -M(CGX_GET_PHY_FEC_STATS, 0x212, cgx_get_phy_fec_stats, msg_req, msg_rsp) \ -M(CGX_FW_DATA_GET, 0x213, cgx_get_aux_link_info, msg_req, cgx_fw_data) \ -M(CGX_SET_LINK_MODE, 0x214, cgx_set_link_mode, cgx_set_link_mode_req,\ - cgx_set_link_mode_rsp) \ -M(CGX_FEATURES_GET, 0x215, cgx_features_get, msg_req, \ - cgx_features_info_msg) \ -M(RPM_STATS, 0x216, rpm_stats, msg_req, rpm_stats_rsp) \ -M(CGX_MAC_ADDR_ADD, 0x217, cgx_mac_addr_add, cgx_mac_addr_add_req, \ - cgx_mac_addr_add_rsp) \ -M(CGX_MAC_ADDR_DEL, 0x218, cgx_mac_addr_del, cgx_mac_addr_del_req, \ +M(CGX_FW_DATA_GET, 0x20F, cgx_get_aux_link_info, msg_req, cgx_fw_data) \ +M(CGX_FEC_SET, 0x210, cgx_set_fec_param, fec_mode, fec_mode) \ +M(CGX_MAC_ADDR_ADD, 0x211, cgx_mac_addr_add, cgx_mac_addr_add_req, \ + cgx_mac_addr_add_rsp) \ +M(CGX_MAC_ADDR_DEL, 0x212, cgx_mac_addr_del, cgx_mac_addr_del_req, \ msg_rsp) \ -M(CGX_MAC_MAX_ENTRIES_GET, 0x219, cgx_mac_max_entries_get, msg_req, \ +M(CGX_MAC_MAX_ENTRIES_GET, 0x213, cgx_mac_max_entries_get, msg_req, \ cgx_max_dmac_entries_get_rsp) \ -M(CGX_MAC_ADDR_RESET, 0x21A, cgx_mac_addr_reset, msg_req, msg_rsp) \ -M(CGX_MAC_ADDR_UPDATE, 0x21B, cgx_mac_addr_update, cgx_mac_addr_update_req= , \ +M(CGX_FEC_STATS, 0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \ +M(CGX_SET_LINK_MODE, 0x218, cgx_set_link_mode, cgx_set_link_mode_req,\ + cgx_set_link_mode_rsp) \ +M(CGX_GET_PHY_FEC_STATS, 0x219, cgx_get_phy_fec_stats, msg_req, msg_rsp) \ +M(CGX_FEATURES_GET, 0x21B, cgx_features_get, msg_req, \ + cgx_features_info_msg) \ +M(RPM_STATS, 0x21C, rpm_stats, msg_req, rpm_stats_rsp) \ +M(CGX_MAC_ADDR_RESET, 0x21D, cgx_mac_addr_reset, msg_req, msg_rsp) \ +M(CGX_MAC_ADDR_UPDATE, 0x21E, cgx_mac_addr_update, cgx_mac_addr_update_req= , \ msg_rsp) \ /* NPA mbox IDs (range 0x400 - 0x5FF) */ \ M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \ @@ -577,10 +577,13 @@ struct cgx_mac_addr_update_req { }; =20 #define RVU_LMAC_FEAT_FC BIT_ULL(0) /* pause frames */ -#define RVU_LMAC_FEAT_PTP BIT_ULL(1) /* precision time protocol */ -#define RVU_MAC_VERSION BIT_ULL(2) -#define RVU_MAC_CGX BIT_ULL(3) -#define RVU_MAC_RPM BIT_ULL(4) +#define RVU_LMAC_FEAT_HIGIG2 BIT_ULL(1) + /* flow control from physical link higig2 messages */ +#define RVU_LMAC_FEAT_PTP BIT_ULL(2) /* precison time protocol */ +#define RVU_LMAC_FEAT_DMACF BIT_ULL(3) /* DMAC FILTER */ +#define RVU_MAC_VERSION BIT_ULL(4) +#define RVU_MAC_CGX BIT_ULL(5) +#define RVU_MAC_RPM BIT_ULL(6) =20 struct cgx_features_info_msg { struct mbox_msghdr hdr; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/= ethernet/marvell/octeontx2/af/rpm.c index b3803577324e6..c8f20b36adc89 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c @@ -29,6 +29,7 @@ static struct mac_ops rpm_mac_ops =3D { .mac_get_pause_frm_status =3D rpm_lmac_get_pause_frm_status, .mac_enadis_pause_frm =3D rpm_lmac_enadis_pause_frm, .mac_pause_frm_config =3D rpm_lmac_pause_frm_config, + .mac_enadis_ptp_config =3D rpm_lmac_ptp_config, }; =20 struct mac_ops *rpm_get_mac_ops(void) @@ -267,3 +268,19 @@ int rpm_lmac_internal_loopback(void *rpmd, int lmac_id= , bool enable) =20 return 0; } + +void rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable) +{ + rpm_t *rpm =3D rpmd; + u64 cfg; + + if (!is_lmac_valid(rpm, lmac_id)) + return; + + cfg =3D rpm_read(rpm, lmac_id, RPMX_CMRX_CFG); + if (enable) + cfg |=3D RPMX_RX_TS_PREPEND; + else + cfg &=3D ~RPMX_RX_TS_PREPEND; + rpm_write(rpm, lmac_id, RPMX_CMRX_CFG, cfg); +} diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.h b/drivers/net/= ethernet/marvell/octeontx2/af/rpm.h index f0b069442dccb..57c8a687b488a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.h @@ -14,6 +14,8 @@ #define PCI_DEVID_CN10K_RPM 0xA060 =20 /* Registers */ +#define RPMX_CMRX_CFG 0x00 +#define RPMX_RX_TS_PREPEND BIT_ULL(22) #define RPMX_CMRX_SW_INT 0x180 #define RPMX_CMRX_SW_INT_W1S 0x188 #define RPMX_CMRX_SW_INT_ENA_W1S 0x198 @@ -54,4 +56,5 @@ int rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8= tx_pause, u8 rx_pause); int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat); int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat); +void rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable); #endif /* RPM_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_cgx.c index a5c717ad12c15..5bdbc77aa721d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -696,6 +696,7 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcif= unc, bool enable) { struct rvu_pfvf *pfvf =3D rvu_get_pfvf(rvu, pcifunc); int pf =3D rvu_get_pf(pcifunc); + struct mac_ops *mac_ops; u8 cgx_id, lmac_id; void *cgxd; =20 @@ -712,7 +713,8 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcif= unc, bool enable) rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); cgxd =3D rvu_cgx_pdata(cgx_id, rvu); =20 - cgx_lmac_ptp_config(cgxd, lmac_id, enable); + mac_ops =3D get_mac_ops(cgxd); + mac_ops->mac_enadis_ptp_config(cgxd, lmac_id, true); /* If PTP is enabled then inform NPC that packets to be * parsed by this PF will have their data shifted by 8 bytes * and if PTP is disabled then no shift is required diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_nix.c index 8c94e30d0499e..143b554d044bf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -4520,6 +4520,7 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc= , int blkaddr, int nixlf) struct rvu_pfvf *pfvf =3D rvu_get_pfvf(rvu, pcifunc); struct hwctx_disable_req ctx_req; int pf =3D rvu_get_pf(pcifunc); + struct mac_ops *mac_ops; u8 cgx_id, lmac_id; void *cgxd; int err; @@ -4566,7 +4567,8 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc= , int blkaddr, int nixlf) if (pfvf->hw_rx_tstamp_en) { rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); cgxd =3D rvu_cgx_pdata(cgx_id, rvu); - cgx_lmac_ptp_config(cgxd, lmac_id, false); + mac_ops =3D get_mac_ops(cgxd); + mac_ops->mac_enadis_ptp_config(cgxd, lmac_id, false); /* Undo NPC config done for PTP */ if (npc_config_ts_kpuaction(rvu, pf, pcifunc, false)) dev_err(rvu->dev, "NPC config for PTP failed\n"); --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7142C433EF for ; Mon, 7 Mar 2022 09:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbiCGJyy (ORCPT ); Mon, 7 Mar 2022 04:54:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241113AbiCGJlx (ORCPT ); Mon, 7 Mar 2022 04:41:53 -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 B4F08B4D; Mon, 7 Mar 2022 01:40: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 ams.source.kernel.org (Postfix) with ESMTPS id 28606B810B2; Mon, 7 Mar 2022 09:40:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57B07C340F3; Mon, 7 Mar 2022 09:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646018; bh=EfXEDqoaenIu8ZmjzzJ9FjIo06SO7hiocNVYack6g20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NF/Aw27UrpEJ1oMSZAqmWACdgsMAC6pWZEmFbsbgJpGiC3KiQ5yqrsrDpYiKpD14u lr4GNyGcedE8rZNuyskjMHM8Vqmo3/lVe/eRZXDF3nFHCfpTVK/HvhkJeYfZqPk6rG tKN8NObVmI9E7izvT6S1yVS3DifLncwq7hfFr3h4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geetha sowjanya , Subbaraya Sundeep , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 107/262] octeontx2-af: cn10k: Use appropriate register for LMAC enable Date: Mon, 7 Mar 2022 10:17:31 +0100 Message-Id: <20220307091705.495024442@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Geetha sowjanya [ Upstream commit fae80edeafbbba5ef9a0423aa5e5515518626433 ] CN10K platforms uses RPM(0..2)_MTI_MAC100(0..3)_COMMAND_CONFIG register for lmac TX/RX enable whereas CN9xxx platforms use CGX_CMRX_CONFIG register. This config change was missed when adding support for CN10K RPM. Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support") Signed-off-by: Geetha sowjanya Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../net/ethernet/marvell/octeontx2/af/cgx.c | 2 + .../marvell/octeontx2/af/lmac_common.h | 3 ++ .../net/ethernet/marvell/octeontx2/af/rpm.c | 39 +++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rpm.h | 4 ++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 14 ++++++- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 10 ++--- 7 files changed, 66 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/= ethernet/marvell/octeontx2/af/cgx.c index d379a35c4618f..6b335139abe7f 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1571,6 +1571,8 @@ static struct mac_ops cgx_mac_ops =3D { .mac_enadis_pause_frm =3D cgx_lmac_enadis_pause_frm, .mac_pause_frm_config =3D cgx_lmac_pause_frm_config, .mac_enadis_ptp_config =3D cgx_lmac_ptp_config, + .mac_rx_tx_enable =3D cgx_lmac_rx_tx_enable, + .mac_tx_enable =3D cgx_lmac_tx_enable, }; =20 static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h b/driv= ers/net/ethernet/marvell/octeontx2/af/lmac_common.h index fc6e7423cbd81..b33e7d1d0851c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h @@ -107,6 +107,9 @@ struct mac_ops { void (*mac_enadis_ptp_config)(void *cgxd, int lmac_id, bool enable); + + int (*mac_rx_tx_enable)(void *cgxd, int lmac_id, bool enable); + int (*mac_tx_enable)(void *cgxd, int lmac_id, bool enable); }; =20 struct cgx { diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/= ethernet/marvell/octeontx2/af/rpm.c index c8f20b36adc89..9ea2f6ac38ec1 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c @@ -30,6 +30,8 @@ static struct mac_ops rpm_mac_ops =3D { .mac_enadis_pause_frm =3D rpm_lmac_enadis_pause_frm, .mac_pause_frm_config =3D rpm_lmac_pause_frm_config, .mac_enadis_ptp_config =3D rpm_lmac_ptp_config, + .mac_rx_tx_enable =3D rpm_lmac_rx_tx_enable, + .mac_tx_enable =3D rpm_lmac_tx_enable, }; =20 struct mac_ops *rpm_get_mac_ops(void) @@ -54,6 +56,43 @@ int rpm_get_nr_lmacs(void *rpmd) return hweight8(rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS) & 0xFULL); } =20 +int rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable) +{ + rpm_t *rpm =3D rpmd; + u64 cfg, last; + + if (!is_lmac_valid(rpm, lmac_id)) + return -ENODEV; + + cfg =3D rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); + last =3D cfg; + if (enable) + cfg |=3D RPM_TX_EN; + else + cfg &=3D ~(RPM_TX_EN); + + if (cfg !=3D last) + rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); + return !!(last & RPM_TX_EN); +} + +int rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable) +{ + rpm_t *rpm =3D rpmd; + u64 cfg; + + if (!is_lmac_valid(rpm, lmac_id)) + return -ENODEV; + + cfg =3D rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); + if (enable) + cfg |=3D RPM_RX_EN | RPM_TX_EN; + else + cfg &=3D ~(RPM_RX_EN | RPM_TX_EN); + rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); + return 0; +} + void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable) { rpm_t *rpm =3D rpmd; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.h b/drivers/net/= ethernet/marvell/octeontx2/af/rpm.h index 57c8a687b488a..ff580311edd03 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.h @@ -43,6 +43,8 @@ #define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 =20 #define RPM_LMAC_FWI 0xa +#define RPM_TX_EN BIT_ULL(0) +#define RPM_RX_EN BIT_ULL(1) =20 /* Function Declarations */ int rpm_get_nr_lmacs(void *rpmd); @@ -57,4 +59,6 @@ int rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8= tx_pause, int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat); int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat); void rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable); +int rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable); +int rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable); #endif /* RPM_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index 8f81e468be048..a7213db38804b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -801,6 +801,7 @@ bool is_mac_feature_supported(struct rvu *rvu, int pf, = int feature); u32 rvu_cgx_get_fifolen(struct rvu *rvu); void *rvu_first_cgx_pdata(struct rvu *rvu); int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id); +int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable); =20 int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf, int type); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_cgx.c index 5bdbc77aa721d..28ff67819566c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -442,16 +442,26 @@ void rvu_cgx_enadis_rx_bp(struct rvu *rvu, int pf, bo= ol enable) int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start) { int pf =3D rvu_get_pf(pcifunc); + struct mac_ops *mac_ops; u8 cgx_id, lmac_id; + void *cgxd; =20 if (!is_cgx_config_permitted(rvu, pcifunc)) return LMAC_AF_ERR_PERM_DENIED; =20 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); + cgxd =3D rvu_cgx_pdata(cgx_id, rvu); + mac_ops =3D get_mac_ops(cgxd); + + return mac_ops->mac_rx_tx_enable(cgxd, lmac_id, start); +} =20 - cgx_lmac_rx_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, start); +int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable) +{ + struct mac_ops *mac_ops; =20 - return 0; + mac_ops =3D get_mac_ops(cgxd); + return mac_ops->mac_tx_enable(cgxd, lmac_id, enable); } =20 void rvu_cgx_disable_dmac_entries(struct rvu *rvu, u16 pcifunc) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_nix.c index 143b554d044bf..603361c94786a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -2068,8 +2068,8 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, /* enable cgx tx if disabled */ if (is_pf_cgxmapped(rvu, pf)) { rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); - restore_tx_en =3D !cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), - lmac_id, true); + restore_tx_en =3D !rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), + lmac_id, true); } =20 cfg =3D rvu_read64(rvu, blkaddr, NIX_AF_SMQX_CFG(smq)); @@ -2092,7 +2092,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, rvu_cgx_enadis_rx_bp(rvu, pf, true); /* restore cgx tx state */ if (restore_tx_en) - cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); + rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); return err; } =20 @@ -3878,7 +3878,7 @@ nix_config_link_credits(struct rvu *rvu, int blkaddr,= int link, /* Enable cgx tx if disabled for credits to be back */ if (is_pf_cgxmapped(rvu, pf)) { rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); - restore_tx_en =3D !cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), + restore_tx_en =3D !rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, true); } =20 @@ -3918,7 +3918,7 @@ nix_config_link_credits(struct rvu *rvu, int blkaddr,= int link, =20 /* Restore state of cgx tx */ if (restore_tx_en) - cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); + rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); =20 mutex_unlock(&rvu->rsrc_lock); return rc; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 711CFC433EF for ; Mon, 7 Mar 2022 09:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238756AbiCGJyv (ORCPT ); Mon, 7 Mar 2022 04:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241119AbiCGJly (ORCPT ); Mon, 7 Mar 2022 04:41:54 -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 3D4DDE19; Mon, 7 Mar 2022 01:40: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 ams.source.kernel.org (Postfix) with ESMTPS id D27ECB810B2; Mon, 7 Mar 2022 09:40:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28FC1C340E9; Mon, 7 Mar 2022 09:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646021; bh=Siwz6QpJRTt+Npz05OdW3g5gp8nlvX75Sj1MJGMROlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QcMnvj5oz9y1ARuvLkV7rLXXFrU4lBMdGr3HgpJN0DWPzJriQcRoT1NrEkES+I1Ff gWX5D2O23bG+ybYjNb2XsBgTfT4RlfQIwuYZC3qz68391zdGn/XMrWfFFuXi7Yt94U MfH6LKxVKwVYxr52SUocl2HVA8jABv23TYEAHYLQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kiran Kumar K , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 108/262] octeontx2-af: Adjust LA pointer for cpt parse header Date: Mon, 7 Mar 2022 10:17:32 +0100 Message-Id: <20220307091705.522456744@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kiran Kumar K [ Upstream commit 85212a127e469c5560daf63a9782755ee4b03619 ] In case of ltype NPC_LT_LA_CPT_HDR, LA pointer is pointing to the start of cpt parse header. Since cpt parse header has veriable length padding, this will be a problem for DMAC extraction. Adding KPU profile changes to adjust the LA pointer to start at ether header in case of cpt parse header by - Adding ptr advance in pkind 58 to a fixed value 40 - Adding variable length offset 7 and mask 7 (pad len in CPT_PARSE_HDR). Also added the missing static declaration for npc_set_var_len_offset_pkind function. Signed-off-by: Kiran Kumar K Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../marvell/octeontx2/af/npc_profile.h | 173 ++++++++---------- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 2 +- 2 files changed, 80 insertions(+), 95 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h b/driv= ers/net/ethernet/marvell/octeontx2/af/npc_profile.h index 2b7030886daec..fad5ecda4e647 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h @@ -187,6 +187,8 @@ enum npc_kpu_parser_state { NPC_S_KPU2_PREHEADER, NPC_S_KPU2_EXDSA, NPC_S_KPU2_NGIO, + NPC_S_KPU2_CPT_CTAG, + NPC_S_KPU2_CPT_QINQ, NPC_S_KPU3_CTAG, NPC_S_KPU3_STAG, NPC_S_KPU3_QINQ, @@ -1004,11 +1006,11 @@ static struct npc_kpu_profile_action ikpu_action_en= tries[] =3D { }, { NPC_ERRLEV_RE, NPC_EC_NOERR, - 40, 54, 58, 0, 0, - NPC_S_KPU1_CPT_HDR, 0, 0, + 12, 16, 20, 0, 0, + NPC_S_KPU1_CPT_HDR, 40, 0, NPC_LID_LA, NPC_LT_NA, 0, - 0, 0, 0, 0, + 7, 7, 0, 0, =20 }, { @@ -1846,80 +1848,35 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[= ] =3D { }, { NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, NPC_ETYPE_IP, 0xffff, 0x0000, 0x0000, - }, - { - NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, - NPC_ETYPE_IP6, - 0xffff, 0x0000, 0x0000, }, { NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, - NPC_ETYPE_CTAG, - 0xffff, - 0x0000, - 0x0000, - }, - { - NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, - NPC_ETYPE_QINQ, + NPC_ETYPE_IP6, 0xffff, 0x0000, 0x0000, - }, - { - NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, 0x0000, 0x0000, - NPC_ETYPE_IP, - 0xffff, }, { NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, + NPC_ETYPE_CTAG, 0xffff, 0x0000, 0x0000, - NPC_ETYPE_IP6, - 0xffff, - }, - { - NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, 0x0000, 0x0000, - NPC_ETYPE_CTAG, - 0xffff, }, { NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0xffff, - 0x0000, - 0x0000, NPC_ETYPE_QINQ, 0xffff, - }, - { - NPC_S_KPU1_CPT_HDR, 0xff, - 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, @@ -2929,6 +2886,42 @@ static struct npc_kpu_profile_cam kpu2_cam_entries[]= =3D { 0x0000, 0x0000, }, + { + NPC_S_KPU2_CPT_CTAG, 0xff, + NPC_ETYPE_IP, + 0xffff, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + }, + { + NPC_S_KPU2_CPT_CTAG, 0xff, + NPC_ETYPE_IP6, + 0xffff, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + }, + { + NPC_S_KPU2_CPT_QINQ, 0xff, + NPC_ETYPE_CTAG, + 0xffff, + NPC_ETYPE_IP, + 0xffff, + 0x0000, + 0x0000, + }, + { + NPC_S_KPU2_CPT_QINQ, 0xff, + NPC_ETYPE_CTAG, + 0xffff, + NPC_ETYPE_IP6, + 0xffff, + 0x0000, + 0x0000, + }, { NPC_S_NA, 0X00, 0x0000, @@ -9176,39 +9169,7 @@ static struct npc_kpu_profile_action kpu1_action_ent= ries[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 0, 6, 3, 0, - NPC_S_KPU5_CPT_IP, 56, 1, - NPC_LID_LA, NPC_LT_LA_CPT_HDR, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 6, 0, 0, 3, 0, - NPC_S_KPU5_CPT_IP6, 56, 1, - NPC_LID_LA, NPC_LT_LA_CPT_HDR, - 0, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 4, 8, 0, 0, 0, - NPC_S_KPU2_CTAG, 54, 1, - NPC_LID_LA, NPC_LT_LA_CPT_HDR, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 4, 8, 0, 0, 0, - NPC_S_KPU2_QINQ, 54, 1, - NPC_LID_LA, NPC_LT_LA_CPT_HDR, - NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, - 0, 0, 0, 0, - }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 8, 0, 6, 3, 0, - NPC_S_KPU5_CPT_IP, 60, 1, + NPC_S_KPU5_CPT_IP, 14, 1, NPC_LID_LA, NPC_LT_LA_CPT_HDR, 0, 0, 0, 0, 0, @@ -9216,7 +9177,7 @@ static struct npc_kpu_profile_action kpu1_action_entr= ies[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 6, 0, 0, 3, 0, - NPC_S_KPU5_CPT_IP6, 60, 1, + NPC_S_KPU5_CPT_IP6, 14, 1, NPC_LID_LA, NPC_LT_LA_CPT_HDR, 0, 0, 0, 0, 0, @@ -9224,7 +9185,7 @@ static struct npc_kpu_profile_action kpu1_action_entr= ies[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 4, 8, 0, 0, 0, - NPC_S_KPU2_CTAG, 58, 1, + NPC_S_KPU2_CPT_CTAG, 12, 1, NPC_LID_LA, NPC_LT_LA_CPT_HDR, NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, 0, 0, 0, 0, @@ -9232,19 +9193,11 @@ static struct npc_kpu_profile_action kpu1_action_en= tries[] =3D { { NPC_ERRLEV_RE, NPC_EC_NOERR, 4, 8, 0, 0, 0, - NPC_S_KPU2_QINQ, 58, 1, + NPC_S_KPU2_CPT_QINQ, 12, 1, NPC_LID_LA, NPC_LT_LA_CPT_HDR, NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, 0, 0, 0, 0, }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 0, 1, - NPC_S_NA, 0, 1, - NPC_LID_LA, NPC_LT_LA_CPT_HDR, - NPC_F_LA_L_UNK_ETYPE, - 0, 0, 0, 0, - }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 12, 0, 0, 1, 0, @@ -10138,6 +10091,38 @@ static struct npc_kpu_profile_action kpu2_action_e= ntries[] =3D { 0, 0, 0, 0, 0, }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 8, 0, 6, 2, 0, + NPC_S_KPU5_CPT_IP, 6, 1, + NPC_LID_LB, NPC_LT_LB_CTAG, + 0, + 0, 0, 0, 0, + }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 6, 0, 0, 2, 0, + NPC_S_KPU5_CPT_IP6, 6, 1, + NPC_LID_LB, NPC_LT_LB_CTAG, + 0, + 0, 0, 0, 0, + }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 8, 0, 6, 2, 0, + NPC_S_KPU5_CPT_IP, 10, 1, + NPC_LID_LB, NPC_LT_LB_STAG_QINQ, + NPC_F_LB_U_MORE_TAG | NPC_F_LB_L_WITH_CTAG, + 0, 0, 0, 0, + }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 6, 0, 0, 2, 0, + NPC_S_KPU5_CPT_IP6, 10, 1, + NPC_LID_LB, NPC_LT_LB_STAG_QINQ, + NPC_F_LB_U_MORE_TAG | NPC_F_LB_L_WITH_CTAG, + 0, 0, 0, 0, + }, { NPC_ERRLEV_LB, NPC_EC_L2_K3, 0, 0, 0, 0, 1, diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_npc.c index 2f347e937f00a..fbb573c40c1ac 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -3183,7 +3183,7 @@ int rvu_mbox_handler_npc_get_kex_cfg(struct rvu *rvu,= struct msg_req *req, return 0; } =20 -int +static int npc_set_var_len_offset_pkind(struct rvu *rvu, u16 pcifunc, u64 pkind, u8 var_len_off, u8 var_len_off_mask, u8 shift_dir) { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3D3EC433EF for ; Mon, 7 Mar 2022 10:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236497AbiCGKDr (ORCPT ); Mon, 7 Mar 2022 05:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241126AbiCGJly (ORCPT ); Mon, 7 Mar 2022 04:41:54 -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 39EDCB93; Mon, 7 Mar 2022 01:40: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 CD482B80F9F; Mon, 7 Mar 2022 09:40:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30218C340E9; Mon, 7 Mar 2022 09:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646024; bh=C2gY0yc/aIldAiiZrv3qT9aP3F8xRf8X+lBHt1DXKzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUTyM/IELB05h9gbToCrCFkj85as8lYiAyfJesff7SzRxHcoZJLA+R2eQivXe19ca OGgbp7r23ouVuc3neCeDQvJFenNK3diQWBEHrDbR9c/uH01aS/kck2gX2pAOxBJcaF 1M3XyfW+G2r8CJ8oVf6+zXiQMaEegjBJIWklxyX0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kiran Kumar K , Subbaraya Sundeep , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 109/262] octeontx2-af: Add KPU changes to parse NGIO as separate layer Date: Mon, 7 Mar 2022 10:17:33 +0100 Message-Id: <20220307091705.549988903@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kiran Kumar K [ Upstream commit 745166fcf01cecc4f5ff3defc6586868349a43f9 ] With current KPU profile NGIO is being parsed along with CTAG as a single layer. Because of this MCAM/ntuple rules installed with ethertype as 0x8842 are not being hit. Adding KPU profile changes to parse NGIO in separate ltype and CTAG in separate ltype. Fixes: f9c49be90c05 ("octeontx2-af: Update the default KPU profile and fixe= s") Signed-off-by: Kiran Kumar K Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../marvell/octeontx2/af/npc_profile.h | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h b/driv= ers/net/ethernet/marvell/octeontx2/af/npc_profile.h index fad5ecda4e647..695123e32ba85 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h @@ -186,7 +186,6 @@ enum npc_kpu_parser_state { NPC_S_KPU2_ETAG, NPC_S_KPU2_PREHEADER, NPC_S_KPU2_EXDSA, - NPC_S_KPU2_NGIO, NPC_S_KPU2_CPT_CTAG, NPC_S_KPU2_CPT_QINQ, NPC_S_KPU3_CTAG, @@ -213,6 +212,7 @@ enum npc_kpu_parser_state { NPC_S_KPU5_NSH, NPC_S_KPU5_CPT_IP, NPC_S_KPU5_CPT_IP6, + NPC_S_KPU5_NGIO, NPC_S_KPU6_IP6_EXT, NPC_S_KPU6_IP6_HOP_DEST, NPC_S_KPU6_IP6_ROUT, @@ -1117,15 +1117,6 @@ static struct npc_kpu_profile_cam kpu1_cam_entries[]= =3D { 0x0000, 0x0000, }, - { - NPC_S_KPU1_ETHER, 0xff, - NPC_ETYPE_CTAG, - 0xffff, - NPC_ETYPE_NGIO, - 0xffff, - 0x0000, - 0x0000, - }, { NPC_S_KPU1_ETHER, 0xff, NPC_ETYPE_CTAG, @@ -1986,6 +1977,15 @@ static struct npc_kpu_profile_cam kpu2_cam_entries[]= =3D { 0x0000, 0x0000, }, + { + NPC_S_KPU2_CTAG, 0xff, + NPC_ETYPE_NGIO, + 0xffff, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + }, { NPC_S_KPU2_CTAG, 0xff, NPC_ETYPE_PPPOE, @@ -2877,15 +2877,6 @@ static struct npc_kpu_profile_cam kpu2_cam_entries[]= =3D { 0x0000, 0x0000, }, - { - NPC_S_KPU2_NGIO, 0xff, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - }, { NPC_S_KPU2_CPT_CTAG, 0xff, NPC_ETYPE_IP, @@ -5205,6 +5196,15 @@ static struct npc_kpu_profile_cam kpu5_cam_entries[]= =3D { 0x0000, 0x0000, }, + { + NPC_S_KPU5_NGIO, 0xff, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + }, { NPC_S_NA, 0X00, 0x0000, @@ -8499,14 +8499,6 @@ static struct npc_kpu_profile_action kpu1_action_ent= ries[] =3D { 0, 0, 0, 0, 0, }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 8, 12, 0, 0, 0, - NPC_S_KPU2_NGIO, 12, 1, - NPC_LID_LA, NPC_LT_LA_ETHER, - 0, - 0, 0, 0, 0, - }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 12, 0, 0, 0, @@ -9291,6 +9283,14 @@ static struct npc_kpu_profile_action kpu2_action_ent= ries[] =3D { 0, 0, 0, 0, 0, }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 0, 0, 0, 2, 0, + NPC_S_KPU5_NGIO, 6, 1, + NPC_LID_LB, NPC_LT_LB_CTAG, + 0, + 0, 0, 0, 0, + }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 0, 6, 2, 0, @@ -10083,14 +10083,6 @@ static struct npc_kpu_profile_action kpu2_action_e= ntries[] =3D { NPC_F_LB_U_UNK_ETYPE | NPC_F_LB_L_EXDSA, 0, 0, 0, 0, }, - { - NPC_ERRLEV_RE, NPC_EC_NOERR, - 0, 0, 0, 0, 1, - NPC_S_NA, 0, 1, - NPC_LID_LC, NPC_LT_LC_NGIO, - 0, - 0, 0, 0, 0, - }, { NPC_ERRLEV_RE, NPC_EC_NOERR, 8, 0, 6, 2, 0, @@ -12154,6 +12146,14 @@ static struct npc_kpu_profile_action kpu5_action_e= ntries[] =3D { 0, 0, 0, 0, 0, }, + { + NPC_ERRLEV_RE, NPC_EC_NOERR, + 0, 0, 0, 0, 1, + NPC_S_NA, 0, 1, + NPC_LID_LC, NPC_LT_LC_NGIO, + 0, + 0, 0, 0, 0, + }, { NPC_ERRLEV_LC, NPC_EC_UNK, 0, 0, 0, 0, 1, --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B7AEC433FE for ; Mon, 7 Mar 2022 10:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239959AbiCGKES (ORCPT ); Mon, 7 Mar 2022 05:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241130AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -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 6F2232717; Mon, 7 Mar 2022 01:40: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 05B23B810BC; Mon, 7 Mar 2022 09:40:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C4A9C340E9; Mon, 7 Mar 2022 09:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646027; bh=8HHHIc/6dYPATmHRJwYrCr2nnQqxKaoscnZMWOcTvso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mnMgWn4R6yfj4tdoSN9enAvjy4clynQ+nQdVF2Y603b3QXNtTvdS8rORiHDrFMyAf d/EPvL+xDvE8Bq0ktyt/t9NJWTVoNN011i4LiZH1htLRcYPfC8DfXCRL/q/ZTAR/bg g8SzKnB+ZAamLjCrWCNor8quKZWSK27sYgDj//LY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raed Salem , Emeel Hakim , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 110/262] net/mlx5e: IPsec: Refactor checksum code in tx data path Date: Mon, 7 Mar 2022 10:17:34 +0100 Message-Id: <20220307091705.577114699@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Raed Salem [ Upstream commit 428ffea0711a11efa0c1c4ee1fac27903ed091be ] Part of code that is related solely to IPsec is always compiled in the driver code regardless if the IPsec functionality is enabled or disabled in the driver code, this will add unnecessary branch in case IPsec is disabled at Tx data path. Move IPsec related code to IPsec related file such that in case of IPsec is disabled and because of unlikely macro the compiler should be able to optimize and omit the checksum IPsec code all together from Tx data path Signed-off-by: Raed Salem Reviewed-by: Emeel Hakim Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 26 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tx.c | 20 ++------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h = b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h index 5120a59361e6a..b98db50c3418d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h @@ -127,6 +127,25 @@ mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_= features_t features) return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } =20 +static inline bool +mlx5e_ipsec_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *= skb, + struct mlx5_wqe_eth_seg *eseg) +{ + struct xfrm_offload *xo =3D xfrm_offload(skb); + + if (!mlx5e_ipsec_eseg_meta(eseg)) + return false; + + eseg->cs_flags =3D MLX5_ETH_WQE_L3_CSUM; + if (xo->inner_ipproto) { + eseg->cs_flags |=3D MLX5_ETH_WQE_L4_INNER_CSUM | MLX5_ETH_WQE_L3_INNER_C= SUM; + } else if (likely(skb->ip_summed =3D=3D CHECKSUM_PARTIAL)) { + eseg->cs_flags |=3D MLX5_ETH_WQE_L4_CSUM; + sq->stats->csum_partial_inner++; + } + + return true; +} #else static inline void mlx5e_ipsec_offload_handle_rx_skb(struct net_device *netdev, @@ -143,6 +162,13 @@ static inline bool mlx5_ipsec_is_rx_flow(struct mlx5_c= qe64 *cqe) { return false; static inline netdev_features_t mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t features) { return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } + +static inline bool +mlx5e_ipsec_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *= skb, + struct mlx5_wqe_eth_seg *eseg) +{ + return false; +} #endif /* CONFIG_MLX5_EN_IPSEC */ =20 #endif /* __MLX5E_IPSEC_RXTX_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tx.c index 188994d091c54..7fd33b356cc8d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c @@ -38,6 +38,7 @@ #include "en/txrx.h" #include "ipoib/ipoib.h" #include "en_accel/en_accel.h" +#include "en_accel/ipsec_rxtx.h" #include "en/ptp.h" =20 static void mlx5e_dma_unmap_wqe_err(struct mlx5e_txqsq *sq, u8 num_dma) @@ -213,30 +214,13 @@ static inline void mlx5e_insert_vlan(void *start, str= uct sk_buff *skb, u16 ihs) memcpy(&vhdr->h_vlan_encapsulated_proto, skb->data + cpy1_sz, cpy2_sz); } =20 -static void -ipsec_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, - struct mlx5_wqe_eth_seg *eseg) -{ - struct xfrm_offload *xo =3D xfrm_offload(skb); - - eseg->cs_flags =3D MLX5_ETH_WQE_L3_CSUM; - if (xo->inner_ipproto) { - eseg->cs_flags |=3D MLX5_ETH_WQE_L4_INNER_CSUM | MLX5_ETH_WQE_L3_INNER_C= SUM; - } else if (likely(skb->ip_summed =3D=3D CHECKSUM_PARTIAL)) { - eseg->cs_flags |=3D MLX5_ETH_WQE_L4_CSUM; - sq->stats->csum_partial_inner++; - } -} - static inline void mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct mlx5e_accel_tx_state *accel, struct mlx5_wqe_eth_seg *eseg) { - if (unlikely(mlx5e_ipsec_eseg_meta(eseg))) { - ipsec_txwqe_build_eseg_csum(sq, skb, eseg); + if (unlikely(mlx5e_ipsec_txwqe_build_eseg_csum(sq, skb, eseg))) return; - } =20 if (likely(skb->ip_summed =3D=3D CHECKSUM_PARTIAL)) { eseg->cs_flags =3D MLX5_ETH_WQE_L3_CSUM; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB46EC433F5 for ; Mon, 7 Mar 2022 10:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239910AbiCGKDz (ORCPT ); Mon, 7 Mar 2022 05:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241133AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -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 854C42BD5; Mon, 7 Mar 2022 01:40:32 -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 261D4B810B2; Mon, 7 Mar 2022 09:40:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FC60C340E9; Mon, 7 Mar 2022 09:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646030; bh=7aK5WAf+nonAj2USSSeA70CH5uGtCo/IGBvok/zj0bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+s4YIz55NtLeLgjTy7g1R1DFd+xb0N9+g46nzF8I7vb/6o0IyFYig2qrDteJY2sz kh6Qr1Xucm+T123k7Q/30OUnT/R1PGNbdJpupZtWGuvgeioymSvjUg3mau57mWX6RT H+uSKVBI/QKuEch84QnH34UXyypVQX1tz32KB2m8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raed Salem , Maor Dickman , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.15 111/262] net/mlx5e: IPsec: Fix crypto offload for non TCP/UDP encapsulated traffic Date: Mon, 7 Mar 2022 10:17:35 +0100 Message-Id: <20220307091705.604989043@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Raed Salem [ Upstream commit 5352859b3bfa0ca188b2f1d2c1436fddc781e3b6 ] IPsec crypto offload always set the ethernet segment checksum flags with the inner L4 header checksum flag enabled for encapsulated IPsec offloaded packet regardless of the encapsulated L4 header type, and even if it doesn't exists in the first place, this breaks non TCP/UDP traffic as such. Set the inner L4 checksum flag only when the encapsulated L4 header protocol is TCP/UDP using software parser swp_inner_l4_offset field as indication. Fixes: 5cfb540ef27b ("net/mlx5e: Set IPsec WAs only in IP's non checksum pa= rtial case.") Signed-off-by: Raed Salem Reviewed-by: Maor Dickman Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h = b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h index b98db50c3418d..428881e0adcbe 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h @@ -131,14 +131,17 @@ static inline bool mlx5e_ipsec_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *= skb, struct mlx5_wqe_eth_seg *eseg) { - struct xfrm_offload *xo =3D xfrm_offload(skb); + u8 inner_ipproto; =20 if (!mlx5e_ipsec_eseg_meta(eseg)) return false; =20 eseg->cs_flags =3D MLX5_ETH_WQE_L3_CSUM; - if (xo->inner_ipproto) { - eseg->cs_flags |=3D MLX5_ETH_WQE_L4_INNER_CSUM | MLX5_ETH_WQE_L3_INNER_C= SUM; + inner_ipproto =3D xfrm_offload(skb)->inner_ipproto; + if (inner_ipproto) { + eseg->cs_flags |=3D MLX5_ETH_WQE_L3_INNER_CSUM; + if (inner_ipproto =3D=3D IPPROTO_TCP || inner_ipproto =3D=3D IPPROTO_UDP) + eseg->cs_flags |=3D MLX5_ETH_WQE_L4_INNER_CSUM; } else if (likely(skb->ip_summed =3D=3D CHECKSUM_PARTIAL)) { eseg->cs_flags |=3D MLX5_ETH_WQE_L4_CSUM; sq->stats->csum_partial_inner++; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 027D6C4332F for ; Mon, 7 Mar 2022 10:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234760AbiCGKEH (ORCPT ); Mon, 7 Mar 2022 05:04:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241132AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B4DB8E; Mon, 7 Mar 2022 01:40: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 ams.source.kernel.org (Postfix) with ESMTPS id 640B8B810B2; Mon, 7 Mar 2022 09:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DCCCC340E9; Mon, 7 Mar 2022 09:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646034; bh=c13dRu7yauQhHB1XoNo/WGE5MsvdDFUEyJtchoxTz8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CMlYMGAEVbgNVDKMbvQd7Uolxak7wLJLHa1abqMhcp3QaX3Bh2ldDIn07ddDwvKuu 7d15+xqYfPlR9cfjmVV4zU99FIEtrAcn73oa/pZP7mhhc2gURCwxcAOxm6tUr+uAmA kS51MmwkPEdpYkQ9vYchDRMD5cr/P7NKQhyOzqVw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.15 112/262] bpf: Use u64_stats_t in struct bpf_prog_stats Date: Mon, 7 Mar 2022 10:17:36 +0100 Message-Id: <20220307091705.632463395@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit 61a0abaee2092eee69e44fe60336aa2f5b578938 ] Commit 316580b69d0a ("u64_stats: provide u64_stats_t type") fixed possible load/store tearing on 64bit arches. For instance the following C code stats->nsecs +=3D sched_clock() - start; Could be rightfully implemented like this by a compiler, confusing concurrent readers a lot: stats->nsecs +=3D sched_clock(); // arbitrary delay stats->nsecs -=3D start; Signed-off-by: Eric Dumazet Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20211026214133.3114279-4-eric.dumazet@gma= il.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- include/linux/filter.h | 10 +++++----- kernel/bpf/syscall.c | 18 ++++++++++++------ kernel/bpf/trampoline.c | 6 +++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 1611dc9d44207..a9956b681f090 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -554,9 +554,9 @@ struct bpf_binary_header { }; =20 struct bpf_prog_stats { - u64 cnt; - u64 nsecs; - u64 misses; + u64_stats_t cnt; + u64_stats_t nsecs; + u64_stats_t misses; struct u64_stats_sync syncp; } __aligned(2 * sizeof(u64)); =20 @@ -618,8 +618,8 @@ static __always_inline u32 __bpf_prog_run(const struct = bpf_prog *prog, ret =3D dfunc(ctx, prog->insnsi, prog->bpf_func); stats =3D this_cpu_ptr(prog->stats); flags =3D u64_stats_update_begin_irqsave(&stats->syncp); - stats->cnt++; - stats->nsecs +=3D sched_clock() - start; + u64_stats_inc(&stats->cnt); + u64_stats_add(&stats->nsecs, sched_clock() - start); u64_stats_update_end_irqrestore(&stats->syncp, flags); } else { ret =3D dfunc(ctx, prog->insnsi, prog->bpf_func); diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 53384622e8dac..42490c39dfbf5 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1824,8 +1824,14 @@ static int bpf_prog_release(struct inode *inode, str= uct file *filp) return 0; } =20 +struct bpf_prog_kstats { + u64 nsecs; + u64 cnt; + u64 misses; +}; + static void bpf_prog_get_stats(const struct bpf_prog *prog, - struct bpf_prog_stats *stats) + struct bpf_prog_kstats *stats) { u64 nsecs =3D 0, cnt =3D 0, misses =3D 0; int cpu; @@ -1838,9 +1844,9 @@ static void bpf_prog_get_stats(const struct bpf_prog = *prog, st =3D per_cpu_ptr(prog->stats, cpu); do { start =3D u64_stats_fetch_begin_irq(&st->syncp); - tnsecs =3D st->nsecs; - tcnt =3D st->cnt; - tmisses =3D st->misses; + tnsecs =3D u64_stats_read(&st->nsecs); + tcnt =3D u64_stats_read(&st->cnt); + tmisses =3D u64_stats_read(&st->misses); } while (u64_stats_fetch_retry_irq(&st->syncp, start)); nsecs +=3D tnsecs; cnt +=3D tcnt; @@ -1856,7 +1862,7 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, = struct file *filp) { const struct bpf_prog *prog =3D filp->private_data; char prog_tag[sizeof(prog->tag) * 2 + 1] =3D { }; - struct bpf_prog_stats stats; + struct bpf_prog_kstats stats; =20 bpf_prog_get_stats(prog, &stats); bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); @@ -3595,7 +3601,7 @@ static int bpf_prog_get_info_by_fd(struct file *file, struct bpf_prog_info __user *uinfo =3D u64_to_user_ptr(attr->info.info); struct bpf_prog_info info; u32 info_len =3D attr->info.info_len; - struct bpf_prog_stats stats; + struct bpf_prog_kstats stats; char __user *uinsns; u32 ulen; int err; diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index d3a307a8c42b9..6933a9bfee637 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -544,7 +544,7 @@ static void notrace inc_misses_counter(struct bpf_prog = *prog) =20 stats =3D this_cpu_ptr(prog->stats); u64_stats_update_begin(&stats->syncp); - stats->misses++; + u64_stats_inc(&stats->misses); u64_stats_update_end(&stats->syncp); } =20 @@ -589,8 +589,8 @@ static void notrace update_prog_stats(struct bpf_prog *= prog, =20 stats =3D this_cpu_ptr(prog->stats); flags =3D u64_stats_update_begin_irqsave(&stats->syncp); - stats->cnt++; - stats->nsecs +=3D sched_clock() - start; + u64_stats_inc(&stats->cnt); + u64_stats_add(&stats->nsecs, sched_clock() - start); u64_stats_update_end_irqrestore(&stats->syncp, flags); } } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16074C433EF for ; Mon, 7 Mar 2022 09:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233990AbiCGJzK (ORCPT ); Mon, 7 Mar 2022 04:55:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241136AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E8BE1163; Mon, 7 Mar 2022 01:40: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 ACA936116E; Mon, 7 Mar 2022 09:40:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A28C340E9; Mon, 7 Mar 2022 09:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646037; bh=1KdZZPBpmda3aO8BSAxIkdeJTjDLQGxFa1W+XSEQcWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYegaNKmYIugdqZLiR06O33mwA2bJG3ZCVEQbTIaS8CftjcOlxqWutq/+rQMLcwdA 4Kgb6R+rY2T7FgB1XlMUk27dmlkWHF2UK0sL+FMgYr+VIjhVDEnqpXG6gC1UQqaHhe /5iC3GhoUWmcTl8xkaMGFKo0R9XBt9DvZVwbFKps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, He Fengqing , John Fastabend , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.15 113/262] bpf: Fix possible race in inc_misses_counter Date: Mon, 7 Mar 2022 10:17:37 +0100 Message-Id: <20220307091705.660001804@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: He Fengqing [ Upstream commit 0e3135d3bfa5dfb658145238d2bc723a8e30c3a3 ] It seems inc_misses_counter() suffers from same issue fixed in the commit d979617aa84d ("bpf: Fixes possible race in update_prog_stats() for 32bit arches"): As it can run while interrupts are enabled, it could be re-entered and the u64_stats syncp could be mangled. Fixes: 9ed9e9ba2337 ("bpf: Count the number of times recursion was prevente= d") Signed-off-by: He Fengqing Acked-by: John Fastabend Link: https://lore.kernel.org/r/20220122102936.1219518-1-hefengqing@huawei.= com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/bpf/trampoline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index 6933a9bfee637..2660fbced9ad4 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -541,11 +541,12 @@ static u64 notrace bpf_prog_start_time(void) static void notrace inc_misses_counter(struct bpf_prog *prog) { struct bpf_prog_stats *stats; + unsigned int flags; =20 stats =3D this_cpu_ptr(prog->stats); - u64_stats_update_begin(&stats->syncp); + flags =3D u64_stats_update_begin_irqsave(&stats->syncp); u64_stats_inc(&stats->misses); - u64_stats_update_end(&stats->syncp); + u64_stats_update_end_irqrestore(&stats->syncp, flags); } =20 /* The logic is similar to bpf_prog_run(), but with an explicit --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 909F5C433F5 for ; Mon, 7 Mar 2022 09:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238837AbiCGJzA (ORCPT ); Mon, 7 Mar 2022 04:55:00 -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 S241141AbiCGJlz (ORCPT ); Mon, 7 Mar 2022 04:41:55 -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 8A02F2DF1; Mon, 7 Mar 2022 01:40: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2811A611D5; Mon, 7 Mar 2022 09:40:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 236B8C340E9; Mon, 7 Mar 2022 09:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646043; bh=pM04jYT3iEEc+cH4XO1fxzRYFDlUu4wBdsMG/Myc3Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MKSuvCxqc4TJBKta+7XK0B9yan3yLj6a/+uSJmlKDIFxcufavIqkVlWpdllyf2y17 BwDdCr1xvXvwGlMAQyVau9kDu2AdaCGyiT7bpBQsc5yNWrWztt1ZuA6t2LAq9VqMUp agYw0PwqP68FNBnfz793+wy77F3kIRlsrJOD8lS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhan Liu , Agustin Gutierrez , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 114/262] drm/amd/display: Update watermark values for DCN301 Date: Mon, 7 Mar 2022 10:17:38 +0100 Message-Id: <20220307091705.686545607@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 2d8ae25d233767171942a9fba5fd8f4a620996be ] [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: Sasha Levin Reported-by: Linux Kernel Functional Testing --- .../amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c b/d= rivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c index 3eee32faa208c..329ce4e84b83c 100644 --- 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, }, } --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2657C433FE for ; Mon, 7 Mar 2022 10:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240005AbiCGKE3 (ORCPT ); Mon, 7 Mar 2022 05:04:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241148AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41: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 3CCCC60FC; Mon, 7 Mar 2022 01:40: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 E3884B810B2; Mon, 7 Mar 2022 09:40:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA07C340F3; Mon, 7 Mar 2022 09:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646046; bh=vvaTcHyj7TRMBBCsqCwDzydb6UBT3bjKyJ+9yqUkG6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJ2KFavxBczo9sQxqZs2tP4v7BXG9fbTC/+rTnPgiUM4eAbSzaAlQ/jlptqVzDmA4 45Be+l5K3i242fPcUZzwjR7L2cYbzyWYG/xfjO8v6Hktwth/8/JmWhKkAPq0DgicQt BvdCrErU5aU6w7i5I4vLdUQwF/O88MkRT3L9WC1w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Kepplinger , =?UTF-8?q?Guido=20G=C3=BCnther?= , Lucas Stach , Sam Ravnborg , Stefan Agner , Sasha Levin Subject: [PATCH 5.15 115/262] drm: mxsfb: Set fallback bus format when the bridge doesnt provide one Date: Mon, 7 Mar 2022 10:17:39 +0100 Message-Id: <20220307091705.713819381@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Guido G=C3=BCnther [ Upstream commit 1db060509903b29d63fe2e39c14fd0f99c4a447e ] If a bridge doesn't do any bus format handling MEDIA_BUS_FMT_FIXED is returned. Fallback to a reasonable default (MEDIA_BUS_FMT_RGB888_1X24) in that case. This unbreaks e.g. using mxsfb with the nwl bridge and mipi dsi panels. Reported-by: Martin Kepplinger Signed-off-by: Guido G=C3=BCnther Reviewed-by: Lucas Stach Reviewed-by: Sam Ravnborg Acked-by: Stefan Agner Link: https://patchwork.freedesktop.org/patch/msgid/781f0352052cc50c823c199= ef5f53c84902d0580.1633959458.git.agx@sigxcpu.org Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsf= b_kms.c index 89dd618d78f31..b96ba348c68d9 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -362,6 +362,12 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *= crtc, drm_atomic_get_new_bridge_state(state, mxsfb->bridge); 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" + "Please fix bridge driver by handling atomic_get_input_bus_fmts.= \n"); + bus_format =3D MEDIA_BUS_FMT_RGB888_1X24; + } } =20 /* If there is no bridge, use bus format from connector */ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68BCEC433F5 for ; Mon, 7 Mar 2022 09:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238867AbiCGJza (ORCPT ); Mon, 7 Mar 2022 04:55:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241149AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41:56 -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 8BAC96252; Mon, 7 Mar 2022 01:40: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 2B73E611D5; Mon, 7 Mar 2022 09:40:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33BCDC340F3; Mon, 7 Mar 2022 09:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646049; bh=Lc8jc0mvjGKkI5mWqYol9JlaBHGpE0J/ZnEnk/UGLYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoKQpEghJ5iLiZtg8DzsvbZq3XaQ/RcawjIolPv13VTJk8sJQhpBZQikjaNU45IQH 3b9RJzSFcHiyhcclPk2S6DqUg9+0+CoyQ5jO8eKYg4X5W9K5GuLxZ3lkCv3VZJO/ZM C6FfSwUrK9a1/d3RFxJMxCQa0BxvYMBVVdsmrHDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Stein , Marek Vasut , Sasha Levin Subject: [PATCH 5.15 116/262] drm: mxsfb: Fix NULL pointer dereference Date: Mon, 7 Mar 2022 10:17:40 +0100 Message-Id: <20220307091705.741630517@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 [ Upstream commit 622c9a3a7868e1eeca39c55305ca3ebec4742b64 ] 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: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsf= b_kms.c index b96ba348c68d9..988bc4fbd78df 100644 --- 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(struct drm_crtc *= crtc, 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" --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB772C433F5 for ; Mon, 7 Mar 2022 10:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238683AbiCGKEZ (ORCPT ); Mon, 7 Mar 2022 05:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241151AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206466392; Mon, 7 Mar 2022 01:40: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 CDCBDB810B9; Mon, 7 Mar 2022 09:40:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D985C340F3; Mon, 7 Mar 2022 09:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646052; bh=4yB1WueRXrnEYauJd4KT8rCFKjgpOh9M/xBmzREYX8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TW++v8YhMpJvMXgLJ640u3ffqA4/qb8ZY36aGlB4DRVCP5EkutgyLpkUrwYSj4IQU Uui0Tlg5UnCmwl/AZ/uM3VJIksA9/ZafraQsDg2jtFHBpvhGClrisdZrFaJ7WzGc5o q+Fk+H25+lZgYWwwG/nsh19c9AfLn4GfY9t3lWrA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Myrtle Shah , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.15 117/262] riscv/mm: Add XIP_FIXUP for phys_ram_base Date: Mon, 7 Mar 2022 10:17:41 +0100 Message-Id: <20220307091705.768399587@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Palmer Dabbelt [ Upstream commit 4b1c70aa8ed8249608bb991380cb8ff423edf49e ] This manifests as a crash early in boot on VexRiscv. Signed-off-by: Myrtle Shah [Palmer: split commit] Fixes: 6d7f91d914bc ("riscv: Get rid of CONFIG_PHYS_RAM_BASE in kernel phys= ical address conversion") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/riscv/mm/init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 5e7decd875258..3de593b26850e 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -451,6 +451,7 @@ static uintptr_t __init best_map_size(phys_addr_t base,= phys_addr_t size) } =20 #ifdef CONFIG_XIP_KERNEL +#define phys_ram_base (*(phys_addr_t *)XIP_FIXUP(&phys_ram_base)) /* called from head.S with MMU off */ asmlinkage void __init __copy_data(void) { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4430C433EF for ; Mon, 7 Mar 2022 09:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238684AbiCGJzh (ORCPT ); Mon, 7 Mar 2022 04:55:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241153AbiCGJl4 (ORCPT ); Mon, 7 Mar 2022 04:41:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C3A6443; Mon, 7 Mar 2022 01:40: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 B0B03B80F9F; Mon, 7 Mar 2022 09:40:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA2BC340E9; Mon, 7 Mar 2022 09:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646055; bh=7qPx6svr1ypbJEN7EZmT8CJMxMbRTph2SY9fnF4VShQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wGJCMmOd/oV/QCNFoTc9AJCVuCKfMMaAYM5OFZw3EJEJUE79WAuDd0BTDSIygOHWw 3zQAo4nwqBQXe+pfWNR79q4OB0G9DcpICusjoB8keMJR+SEeOJ2ZTihVZutRQZqbjZ 3RjoXg0y0OITl3rCWMoHTO2MvI6AYILq0wHlxYF4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rodrigo Vivi , Jani Nikula , Sasha Levin Subject: [PATCH 5.15 118/262] drm/i915/display: split out dpt out of intel_display.c Date: Mon, 7 Mar 2022 10:17:42 +0100 Message-Id: <20220307091705.795422084@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Jani Nikula [ Upstream commit dc6d6158a6e8b11a11544a541583296d9323050f ] Let's try to reduce the size of intel_display.c, not increase it. Reviewed-by: Rodrigo Vivi Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/934a2a0db05e835f6843bef= ef6082e2034f23b3a.1629721467.git.jani.nikula@intel.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/display/intel_display.c | 220 +----------------- drivers/gpu/drm/i915/display/intel_dpt.c | 229 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dpt.h | 19 ++ 4 files changed, 250 insertions(+), 219 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_dpt.c create mode 100644 drivers/gpu/drm/i915/display/intel_dpt.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 335ba9f43d8f7..a4154fe14f8c0 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -211,6 +211,7 @@ i915-y +=3D \ display/intel_dpio_phy.o \ display/intel_dpll.o \ display/intel_dpll_mgr.o \ + display/intel_dpt.o \ display/intel_dsb.o \ display/intel_fb.o \ display/intel_fbc.o \ diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm= /i915/display/intel_display.c index 17f44ffea5866..625ce6975eeba 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -84,6 +84,7 @@ #include "intel_display_types.h" #include "intel_dmc.h" #include "intel_dp_link_training.h" +#include "intel_dpt.h" #include "intel_fbc.h" #include "intel_fdi.h" #include "intel_fbdev.h" @@ -126,182 +127,6 @@ static void ilk_pfit_enable(const struct intel_crtc_s= tate *crtc_state); static void intel_modeset_setup_hw_state(struct drm_device *dev, struct drm_modeset_acquire_ctx *ctx); =20 -struct i915_dpt { - struct i915_address_space vm; - - struct drm_i915_gem_object *obj; - struct i915_vma *vma; - void __iomem *iomem; -}; - -#define i915_is_dpt(vm) ((vm)->is_dpt) - -static inline struct i915_dpt * -i915_vm_to_dpt(struct i915_address_space *vm) -{ - BUILD_BUG_ON(offsetof(struct i915_dpt, vm)); - GEM_BUG_ON(!i915_is_dpt(vm)); - return container_of(vm, struct i915_dpt, vm); -} - -#define dpt_total_entries(dpt) ((dpt)->vm.total >> PAGE_SHIFT) - -static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte) -{ - writeq(pte, addr); -} - -static void dpt_insert_page(struct i915_address_space *vm, - dma_addr_t addr, - u64 offset, - enum i915_cache_level level, - u32 flags) -{ - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - gen8_pte_t __iomem *base =3D dpt->iomem; - - gen8_set_pte(base + offset / I915_GTT_PAGE_SIZE, - vm->pte_encode(addr, level, flags)); -} - -static void dpt_insert_entries(struct i915_address_space *vm, - struct i915_vma *vma, - enum i915_cache_level level, - u32 flags) -{ - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - gen8_pte_t __iomem *base =3D dpt->iomem; - const gen8_pte_t pte_encode =3D vm->pte_encode(0, level, flags); - struct sgt_iter sgt_iter; - dma_addr_t addr; - int i; - - /* - * Note that we ignore PTE_READ_ONLY here. The caller must be careful - * not to allow the user to override access to a read only page. - */ - - i =3D vma->node.start / I915_GTT_PAGE_SIZE; - for_each_sgt_daddr(addr, sgt_iter, vma->pages) - gen8_set_pte(&base[i++], pte_encode | addr); -} - -static void dpt_clear_range(struct i915_address_space *vm, - u64 start, u64 length) -{ -} - -static void dpt_bind_vma(struct i915_address_space *vm, - struct i915_vm_pt_stash *stash, - struct i915_vma *vma, - enum i915_cache_level cache_level, - u32 flags) -{ - struct drm_i915_gem_object *obj =3D vma->obj; - u32 pte_flags; - - /* Applicable to VLV (gen8+ do not support RO in the GGTT) */ - pte_flags =3D 0; - if (vma->vm->has_read_only && i915_gem_object_is_readonly(obj)) - pte_flags |=3D PTE_READ_ONLY; - if (i915_gem_object_is_lmem(obj)) - pte_flags |=3D PTE_LM; - - vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags); - - vma->page_sizes.gtt =3D I915_GTT_PAGE_SIZE; - - /* - * Without aliasing PPGTT there's no difference between - * GLOBAL/LOCAL_BIND, it's all the same ptes. Hence unconditionally - * upgrade to both bound if we bind either to avoid double-binding. - */ - atomic_or(I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND, &vma->flags); -} - -static void dpt_unbind_vma(struct i915_address_space *vm, struct i915_vma = *vma) -{ - vm->clear_range(vm, vma->node.start, vma->size); -} - -static void dpt_cleanup(struct i915_address_space *vm) -{ - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - - i915_gem_object_put(dpt->obj); -} - -static struct i915_address_space * -intel_dpt_create(struct intel_framebuffer *fb) -{ - struct drm_gem_object *obj =3D &intel_fb_obj(&fb->base)->base; - struct drm_i915_private *i915 =3D to_i915(obj->dev); - struct drm_i915_gem_object *dpt_obj; - struct i915_address_space *vm; - struct i915_dpt *dpt; - size_t size; - int ret; - - if (intel_fb_needs_pot_stride_remap(fb)) - size =3D intel_remapped_info_size(&fb->remapped_view.gtt.remapped); - else - size =3D DIV_ROUND_UP_ULL(obj->size, I915_GTT_PAGE_SIZE); - - size =3D round_up(size * sizeof(gen8_pte_t), I915_GTT_PAGE_SIZE); - - if (HAS_LMEM(i915)) - dpt_obj =3D i915_gem_object_create_lmem(i915, size, 0); - else - dpt_obj =3D i915_gem_object_create_stolen(i915, size); - if (IS_ERR(dpt_obj)) - return ERR_CAST(dpt_obj); - - ret =3D i915_gem_object_set_cache_level(dpt_obj, I915_CACHE_NONE); - if (ret) { - i915_gem_object_put(dpt_obj); - return ERR_PTR(ret); - } - - dpt =3D kzalloc(sizeof(*dpt), GFP_KERNEL); - if (!dpt) { - i915_gem_object_put(dpt_obj); - return ERR_PTR(-ENOMEM); - } - - vm =3D &dpt->vm; - - vm->gt =3D &i915->gt; - vm->i915 =3D i915; - vm->dma =3D i915->drm.dev; - vm->total =3D (size / sizeof(gen8_pte_t)) * I915_GTT_PAGE_SIZE; - vm->is_dpt =3D true; - - i915_address_space_init(vm, VM_CLASS_DPT); - - vm->insert_page =3D dpt_insert_page; - vm->clear_range =3D dpt_clear_range; - vm->insert_entries =3D dpt_insert_entries; - vm->cleanup =3D dpt_cleanup; - - vm->vma_ops.bind_vma =3D dpt_bind_vma; - vm->vma_ops.unbind_vma =3D dpt_unbind_vma; - vm->vma_ops.set_pages =3D ggtt_set_pages; - vm->vma_ops.clear_pages =3D clear_pages; - - vm->pte_encode =3D gen8_ggtt_pte_encode; - - dpt->obj =3D dpt_obj; - - return &dpt->vm; -} - -static void intel_dpt_destroy(struct i915_address_space *vm) -{ - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - - i915_vm_close(&dpt->vm); -} - /* returns HPLL frequency in kHz */ int vlv_get_hpll_vco(struct drm_i915_private *dev_priv) { @@ -1879,49 +1704,6 @@ static void intel_plane_disable_noatomic(struct inte= l_crtc *crtc, intel_wait_for_vblank(dev_priv, crtc->pipe); } =20 -static struct i915_vma *intel_dpt_pin(struct i915_address_space *vm) -{ - struct drm_i915_private *i915 =3D vm->i915; - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - intel_wakeref_t wakeref; - struct i915_vma *vma; - void __iomem *iomem; - - wakeref =3D intel_runtime_pm_get(&i915->runtime_pm); - atomic_inc(&i915->gpu_error.pending_fb_pin); - - vma =3D i915_gem_object_ggtt_pin(dpt->obj, NULL, 0, 4096, - HAS_LMEM(i915) ? 0 : PIN_MAPPABLE); - if (IS_ERR(vma)) - goto err; - - iomem =3D i915_vma_pin_iomap(vma); - i915_vma_unpin(vma); - if (IS_ERR(iomem)) { - vma =3D iomem; - goto err; - } - - dpt->vma =3D vma; - dpt->iomem =3D iomem; - - i915_vma_get(vma); - -err: - atomic_dec(&i915->gpu_error.pending_fb_pin); - intel_runtime_pm_put(&i915->runtime_pm, wakeref); - - return vma; -} - -static void intel_dpt_unpin(struct i915_address_space *vm) -{ - struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); - - i915_vma_unpin_iomap(dpt->vma); - i915_vma_put(dpt->vma); -} - static bool intel_reuse_initial_plane_obj(struct drm_i915_private *i915, const struct intel_initial_plane_config *plane_config, diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i91= 5/display/intel_dpt.c new file mode 100644 index 0000000000000..22acd945a9e47 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_dpt.c @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright =C2=A9 2021 Intel Corporation + */ + +#include "i915_drv.h" +#include "intel_display_types.h" +#include "intel_dpt.h" +#include "intel_fb.h" +#include "gt/gen8_ppgtt.h" + +struct i915_dpt { + struct i915_address_space vm; + + struct drm_i915_gem_object *obj; + struct i915_vma *vma; + void __iomem *iomem; +}; + +#define i915_is_dpt(vm) ((vm)->is_dpt) + +static inline struct i915_dpt * +i915_vm_to_dpt(struct i915_address_space *vm) +{ + BUILD_BUG_ON(offsetof(struct i915_dpt, vm)); + GEM_BUG_ON(!i915_is_dpt(vm)); + return container_of(vm, struct i915_dpt, vm); +} + +#define dpt_total_entries(dpt) ((dpt)->vm.total >> PAGE_SHIFT) + +static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte) +{ + writeq(pte, addr); +} + +static void dpt_insert_page(struct i915_address_space *vm, + dma_addr_t addr, + u64 offset, + enum i915_cache_level level, + u32 flags) +{ + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + gen8_pte_t __iomem *base =3D dpt->iomem; + + gen8_set_pte(base + offset / I915_GTT_PAGE_SIZE, + vm->pte_encode(addr, level, flags)); +} + +static void dpt_insert_entries(struct i915_address_space *vm, + struct i915_vma *vma, + enum i915_cache_level level, + u32 flags) +{ + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + gen8_pte_t __iomem *base =3D dpt->iomem; + const gen8_pte_t pte_encode =3D vm->pte_encode(0, level, flags); + struct sgt_iter sgt_iter; + dma_addr_t addr; + int i; + + /* + * Note that we ignore PTE_READ_ONLY here. The caller must be careful + * not to allow the user to override access to a read only page. + */ + + i =3D vma->node.start / I915_GTT_PAGE_SIZE; + for_each_sgt_daddr(addr, sgt_iter, vma->pages) + gen8_set_pte(&base[i++], pte_encode | addr); +} + +static void dpt_clear_range(struct i915_address_space *vm, + u64 start, u64 length) +{ +} + +static void dpt_bind_vma(struct i915_address_space *vm, + struct i915_vm_pt_stash *stash, + struct i915_vma *vma, + enum i915_cache_level cache_level, + u32 flags) +{ + struct drm_i915_gem_object *obj =3D vma->obj; + u32 pte_flags; + + /* Applicable to VLV (gen8+ do not support RO in the GGTT) */ + pte_flags =3D 0; + if (vma->vm->has_read_only && i915_gem_object_is_readonly(obj)) + pte_flags |=3D PTE_READ_ONLY; + if (i915_gem_object_is_lmem(obj)) + pte_flags |=3D PTE_LM; + + vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags); + + vma->page_sizes.gtt =3D I915_GTT_PAGE_SIZE; + + /* + * Without aliasing PPGTT there's no difference between + * GLOBAL/LOCAL_BIND, it's all the same ptes. Hence unconditionally + * upgrade to both bound if we bind either to avoid double-binding. + */ + atomic_or(I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND, &vma->flags); +} + +static void dpt_unbind_vma(struct i915_address_space *vm, struct i915_vma = *vma) +{ + vm->clear_range(vm, vma->node.start, vma->size); +} + +static void dpt_cleanup(struct i915_address_space *vm) +{ + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + + i915_gem_object_put(dpt->obj); +} + +struct i915_vma *intel_dpt_pin(struct i915_address_space *vm) +{ + struct drm_i915_private *i915 =3D vm->i915; + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + intel_wakeref_t wakeref; + struct i915_vma *vma; + void __iomem *iomem; + + wakeref =3D intel_runtime_pm_get(&i915->runtime_pm); + atomic_inc(&i915->gpu_error.pending_fb_pin); + + vma =3D i915_gem_object_ggtt_pin(dpt->obj, NULL, 0, 4096, + HAS_LMEM(i915) ? 0 : PIN_MAPPABLE); + if (IS_ERR(vma)) + goto err; + + iomem =3D i915_vma_pin_iomap(vma); + i915_vma_unpin(vma); + if (IS_ERR(iomem)) { + vma =3D iomem; + goto err; + } + + dpt->vma =3D vma; + dpt->iomem =3D iomem; + + i915_vma_get(vma); + +err: + atomic_dec(&i915->gpu_error.pending_fb_pin); + intel_runtime_pm_put(&i915->runtime_pm, wakeref); + + return vma; +} + +void intel_dpt_unpin(struct i915_address_space *vm) +{ + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + + i915_vma_unpin_iomap(dpt->vma); + i915_vma_put(dpt->vma); +} + +struct i915_address_space * +intel_dpt_create(struct intel_framebuffer *fb) +{ + struct drm_gem_object *obj =3D &intel_fb_obj(&fb->base)->base; + struct drm_i915_private *i915 =3D to_i915(obj->dev); + struct drm_i915_gem_object *dpt_obj; + struct i915_address_space *vm; + struct i915_dpt *dpt; + size_t size; + int ret; + + if (intel_fb_needs_pot_stride_remap(fb)) + size =3D intel_remapped_info_size(&fb->remapped_view.gtt.remapped); + else + size =3D DIV_ROUND_UP_ULL(obj->size, I915_GTT_PAGE_SIZE); + + size =3D round_up(size * sizeof(gen8_pte_t), I915_GTT_PAGE_SIZE); + + if (HAS_LMEM(i915)) + dpt_obj =3D i915_gem_object_create_lmem(i915, size, 0); + else + dpt_obj =3D i915_gem_object_create_stolen(i915, size); + if (IS_ERR(dpt_obj)) + return ERR_CAST(dpt_obj); + + ret =3D i915_gem_object_set_cache_level(dpt_obj, I915_CACHE_NONE); + if (ret) { + i915_gem_object_put(dpt_obj); + return ERR_PTR(ret); + } + + dpt =3D kzalloc(sizeof(*dpt), GFP_KERNEL); + if (!dpt) { + i915_gem_object_put(dpt_obj); + return ERR_PTR(-ENOMEM); + } + + vm =3D &dpt->vm; + + vm->gt =3D &i915->gt; + vm->i915 =3D i915; + vm->dma =3D i915->drm.dev; + vm->total =3D (size / sizeof(gen8_pte_t)) * I915_GTT_PAGE_SIZE; + vm->is_dpt =3D true; + + i915_address_space_init(vm, VM_CLASS_DPT); + + vm->insert_page =3D dpt_insert_page; + vm->clear_range =3D dpt_clear_range; + vm->insert_entries =3D dpt_insert_entries; + vm->cleanup =3D dpt_cleanup; + + vm->vma_ops.bind_vma =3D dpt_bind_vma; + vm->vma_ops.unbind_vma =3D dpt_unbind_vma; + vm->vma_ops.set_pages =3D ggtt_set_pages; + vm->vma_ops.clear_pages =3D clear_pages; + + vm->pte_encode =3D gen8_ggtt_pte_encode; + + dpt->obj =3D dpt_obj; + + return &dpt->vm; +} + +void intel_dpt_destroy(struct i915_address_space *vm) +{ + struct i915_dpt *dpt =3D i915_vm_to_dpt(vm); + + i915_vm_close(&dpt->vm); +} diff --git a/drivers/gpu/drm/i915/display/intel_dpt.h b/drivers/gpu/drm/i91= 5/display/intel_dpt.h new file mode 100644 index 0000000000000..45142b8f849f6 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_dpt.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright =C2=A9 2021 Intel Corporation + */ + +#ifndef __INTEL_DPT_H__ +#define __INTEL_DPT_H__ + +struct i915_address_space; +struct i915_vma; +struct intel_framebuffer; + +void intel_dpt_destroy(struct i915_address_space *vm); +struct i915_vma *intel_dpt_pin(struct i915_address_space *vm); +void intel_dpt_unpin(struct i915_address_space *vm); +struct i915_address_space * +intel_dpt_create(struct intel_framebuffer *fb); + +#endif /* __INTEL_DPT_H__ */ --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9353C4332F for ; Mon, 7 Mar 2022 10:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236892AbiCGKEp (ORCPT ); Mon, 7 Mar 2022 05:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241158AbiCGJl5 (ORCPT ); Mon, 7 Mar 2022 04:41:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 818DD7646; Mon, 7 Mar 2022 01:41: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 0C4C7611D5; Mon, 7 Mar 2022 09:41:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B55A0C340E9; Mon, 7 Mar 2022 09:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646059; bh=kUjMOKV3z1Uum3U+06QokrFE6mikD+Q4q9gk/QA4f+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJ6ajSMcVMbOwABK7AXDrpauU91U5UglkiEBn4Vlat+pKfsrFA3z+WVPUlbys/KEj hTfUF08pxnv9Ihq9GETqdu0xFWk1SyGmJqPSPO1olt6WM8wuNCYky8xzV0nbDmbEVi fRsGU4SJdcfv+azGCt2V7I+ym6yvSv944mwYBuIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rodrigo Vivi , Jani Nikula , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Sasha Levin Subject: [PATCH 5.15 119/262] drm/i915/display: Move DRRS code its own file Date: Mon, 7 Mar 2022 10:17:43 +0100 Message-Id: <20220307091705.823402348@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@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: Jos=C3=A9 Roberto de Souza [ Upstream commit a1b63119ee839c8ff622407aab25c9723943638a ] intel_dp.c is a 5k lines monster, so moving DRRS out of it to reduce some lines from it. Reviewed-by: Rodrigo Vivi Cc: Jani Nikula Cc: Rodrigo Vivi Signed-off-by: Jos=C3=A9 Roberto de Souza Link: https://patchwork.freedesktop.org/patch/msgid/20210827174253.51122-2-= jose.souza@intel.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- Documentation/gpu/i915.rst | 14 +- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/display/intel_ddi.c | 1 + .../drm/i915/display/intel_display_debugfs.c | 1 + drivers/gpu/drm/i915/display/intel_dp.c | 467 +---------------- drivers/gpu/drm/i915/display/intel_dp.h | 11 - drivers/gpu/drm/i915/display/intel_drrs.c | 477 ++++++++++++++++++ drivers/gpu/drm/i915/display/intel_drrs.h | 32 ++ .../gpu/drm/i915/display/intel_frontbuffer.c | 1 + 9 files changed, 521 insertions(+), 484 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_drrs.c create mode 100644 drivers/gpu/drm/i915/display/intel_drrs.h diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst index 204ebdaadb45a..03021dfa0dd81 100644 --- a/Documentation/gpu/i915.rst +++ b/Documentation/gpu/i915.rst @@ -183,25 +183,25 @@ Frame Buffer Compression (FBC) Display Refresh Rate Switching (DRRS) ------------------------------------- =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :doc: Display Refresh Rate Switching (DRRS) =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_dp_set_drrs_state =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_enable =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_disable =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_invalidate =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_flush =20 -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_dp_drrs_init =20 DPIO diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index a4154fe14f8c0..26cf754229451 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -212,6 +212,7 @@ i915-y +=3D \ display/intel_dpll.o \ display/intel_dpll_mgr.o \ display/intel_dpt.o \ + display/intel_drrs.o \ display/intel_dsb.o \ display/intel_fb.o \ display/intel_fbc.o \ diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i91= 5/display/intel_ddi.c index 82e5064b4ce7b..f61901e26409e 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -40,6 +40,7 @@ #include "intel_dp_link_training.h" #include "intel_dp_mst.h" #include "intel_dpio_phy.h" +#include "intel_drrs.h" #include "intel_dsi.h" #include "intel_fdi.h" #include "intel_fifo_underrun.h" diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers= /gpu/drm/i915/display/intel_display_debugfs.c index 8fdacb252bb19..b136a0fc0963b 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -13,6 +13,7 @@ #include "intel_display_types.h" #include "intel_dmc.h" #include "intel_dp.h" +#include "intel_drrs.h" #include "intel_fbc.h" #include "intel_hdcp.h" #include "intel_hdmi.h" diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915= /display/intel_dp.c index d55363f1fa102..dbff4b6aa22bf 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -56,6 +56,7 @@ #include "intel_dp_mst.h" #include "intel_dpio_phy.h" #include "intel_dpll.h" +#include "intel_drrs.h" #include "intel_fifo_underrun.h" #include "intel_hdcp.h" #include "intel_hdmi.h" @@ -1610,46 +1611,6 @@ intel_dp_compute_hdr_metadata_infoframe_sdp(struct i= ntel_dp *intel_dp, intel_hdmi_infoframe_enable(HDMI_PACKET_TYPE_GAMUT_METADATA); } =20 -static void -intel_dp_drrs_compute_config(struct intel_dp *intel_dp, - struct intel_crtc_state *pipe_config, - int output_bpp, bool constant_n) -{ - struct intel_connector *intel_connector =3D intel_dp->attached_connector; - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - int pixel_clock; - - if (pipe_config->vrr.enable) - return; - - /* - * DRRS and PSR can't be enable together, so giving preference to PSR - * as it allows more power-savings by complete shutting down display, - * so to guarantee this, intel_dp_drrs_compute_config() must be called - * after intel_psr_compute_config(). - */ - if (pipe_config->has_psr) - return; - - if (!intel_connector->panel.downclock_mode || - dev_priv->drrs.type !=3D SEAMLESS_DRRS_SUPPORT) - return; - - pipe_config->has_drrs =3D true; - - pixel_clock =3D intel_connector->panel.downclock_mode->clock; - if (pipe_config->splitter.enable) - pixel_clock /=3D pipe_config->splitter.link_count; - - intel_link_compute_m_n(output_bpp, pipe_config->lane_count, pixel_clock, - pipe_config->port_clock, &pipe_config->dp_m2_n2, - constant_n, pipe_config->fec_enable); - - /* FIXME: abstract this better */ - if (pipe_config->splitter.enable) - pipe_config->dp_m2_n2.gmch_m *=3D pipe_config->splitter.link_count; -} - int intel_dp_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config, @@ -4737,432 +4698,6 @@ intel_dp_add_properties(struct intel_dp *intel_dp, = struct drm_connector *connect drm_connector_attach_vrr_capable_property(connector); } =20 -/** - * intel_dp_set_drrs_state - program registers for RR switch to take effect - * @dev_priv: i915 device - * @crtc_state: a pointer to the active intel_crtc_state - * @refresh_rate: RR to be programmed - * - * This function gets called when refresh rate (RR) has to be changed from - * one frequency to another. Switches can be between high and low RR - * supported by the panel or to any other RR based on media playback (in - * this case, RR value needs to be passed from user space). - * - * The caller of this function needs to take a lock on dev_priv->drrs. - */ -static void intel_dp_set_drrs_state(struct drm_i915_private *dev_priv, - const struct intel_crtc_state *crtc_state, - int refresh_rate) -{ - struct intel_dp *intel_dp =3D dev_priv->drrs.dp; - struct intel_crtc *crtc =3D to_intel_crtc(crtc_state->uapi.crtc); - enum drrs_refresh_rate_type index =3D DRRS_HIGH_RR; - - if (refresh_rate <=3D 0) { - drm_dbg_kms(&dev_priv->drm, - "Refresh rate should be positive non-zero.\n"); - return; - } - - if (intel_dp =3D=3D NULL) { - drm_dbg_kms(&dev_priv->drm, "DRRS not supported.\n"); - return; - } - - if (!crtc) { - drm_dbg_kms(&dev_priv->drm, - "DRRS: intel_crtc not initialized\n"); - return; - } - - if (dev_priv->drrs.type < SEAMLESS_DRRS_SUPPORT) { - drm_dbg_kms(&dev_priv->drm, "Only Seamless DRRS supported.\n"); - return; - } - - if (drm_mode_vrefresh(intel_dp->attached_connector->panel.downclock_mode)= =3D=3D - refresh_rate) - index =3D DRRS_LOW_RR; - - if (index =3D=3D dev_priv->drrs.refresh_rate_type) { - drm_dbg_kms(&dev_priv->drm, - "DRRS requested for previously set RR...ignoring\n"); - return; - } - - if (!crtc_state->hw.active) { - drm_dbg_kms(&dev_priv->drm, - "eDP encoder disabled. CRTC not Active\n"); - return; - } - - if (DISPLAY_VER(dev_priv) >=3D 8 && !IS_CHERRYVIEW(dev_priv)) { - switch (index) { - case DRRS_HIGH_RR: - intel_dp_set_m_n(crtc_state, M1_N1); - break; - case DRRS_LOW_RR: - intel_dp_set_m_n(crtc_state, M2_N2); - break; - case DRRS_MAX_RR: - default: - drm_err(&dev_priv->drm, - "Unsupported refreshrate type\n"); - } - } else if (DISPLAY_VER(dev_priv) > 6) { - i915_reg_t reg =3D PIPECONF(crtc_state->cpu_transcoder); - u32 val; - - val =3D intel_de_read(dev_priv, reg); - if (index > DRRS_HIGH_RR) { - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) - val |=3D PIPECONF_EDP_RR_MODE_SWITCH_VLV; - else - val |=3D PIPECONF_EDP_RR_MODE_SWITCH; - } else { - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) - val &=3D ~PIPECONF_EDP_RR_MODE_SWITCH_VLV; - else - val &=3D ~PIPECONF_EDP_RR_MODE_SWITCH; - } - intel_de_write(dev_priv, reg, val); - } - - dev_priv->drrs.refresh_rate_type =3D index; - - drm_dbg_kms(&dev_priv->drm, "eDP Refresh Rate set to : %dHz\n", - refresh_rate); -} - -static void -intel_edp_drrs_enable_locked(struct intel_dp *intel_dp) -{ - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - - dev_priv->drrs.busy_frontbuffer_bits =3D 0; - dev_priv->drrs.dp =3D intel_dp; -} - -/** - * intel_edp_drrs_enable - init drrs struct if supported - * @intel_dp: DP struct - * @crtc_state: A pointer to the active crtc state. - * - * Initializes frontbuffer_bits and drrs.dp - */ -void intel_edp_drrs_enable(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state) -{ - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - - if (!crtc_state->has_drrs) - return; - - drm_dbg_kms(&dev_priv->drm, "Enabling DRRS\n"); - - mutex_lock(&dev_priv->drrs.mutex); - - if (dev_priv->drrs.dp) { - drm_warn(&dev_priv->drm, "DRRS already enabled\n"); - goto unlock; - } - - intel_edp_drrs_enable_locked(intel_dp); - -unlock: - mutex_unlock(&dev_priv->drrs.mutex); -} - -static void -intel_edp_drrs_disable_locked(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state) -{ - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - - if (dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_RR) { - int refresh; - - refresh =3D drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_= mode); - intel_dp_set_drrs_state(dev_priv, crtc_state, refresh); - } - - dev_priv->drrs.dp =3D NULL; -} - -/** - * intel_edp_drrs_disable - Disable DRRS - * @intel_dp: DP struct - * @old_crtc_state: Pointer to old crtc_state. - * - */ -void intel_edp_drrs_disable(struct intel_dp *intel_dp, - const struct intel_crtc_state *old_crtc_state) -{ - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - - if (!old_crtc_state->has_drrs) - return; - - mutex_lock(&dev_priv->drrs.mutex); - if (!dev_priv->drrs.dp) { - mutex_unlock(&dev_priv->drrs.mutex); - return; - } - - intel_edp_drrs_disable_locked(intel_dp, old_crtc_state); - mutex_unlock(&dev_priv->drrs.mutex); - - cancel_delayed_work_sync(&dev_priv->drrs.work); -} - -/** - * intel_edp_drrs_update - Update DRRS state - * @intel_dp: Intel DP - * @crtc_state: new CRTC state - * - * This function will update DRRS states, disabling or enabling DRRS when - * executing fastsets. For full modeset, intel_edp_drrs_disable() and - * intel_edp_drrs_enable() should be called instead. - */ -void -intel_edp_drrs_update(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state) -{ - struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); - - if (dev_priv->drrs.type !=3D SEAMLESS_DRRS_SUPPORT) - return; - - mutex_lock(&dev_priv->drrs.mutex); - - /* New state matches current one? */ - if (crtc_state->has_drrs =3D=3D !!dev_priv->drrs.dp) - goto unlock; - - if (crtc_state->has_drrs) - intel_edp_drrs_enable_locked(intel_dp); - else - intel_edp_drrs_disable_locked(intel_dp, crtc_state); - -unlock: - mutex_unlock(&dev_priv->drrs.mutex); -} - -static void intel_edp_drrs_downclock_work(struct work_struct *work) -{ - struct drm_i915_private *dev_priv =3D - container_of(work, typeof(*dev_priv), drrs.work.work); - struct intel_dp *intel_dp; - - mutex_lock(&dev_priv->drrs.mutex); - - intel_dp =3D dev_priv->drrs.dp; - - if (!intel_dp) - goto unlock; - - /* - * The delayed work can race with an invalidate hence we need to - * recheck. - */ - - if (dev_priv->drrs.busy_frontbuffer_bits) - goto unlock; - - if (dev_priv->drrs.refresh_rate_type !=3D DRRS_LOW_RR) { - struct drm_crtc *crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; - - intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, - drm_mode_vrefresh(intel_dp->attached_connector->panel.downclock_mode)); - } - -unlock: - mutex_unlock(&dev_priv->drrs.mutex); -} - -/** - * intel_edp_drrs_invalidate - Disable Idleness DRRS - * @dev_priv: i915 device - * @frontbuffer_bits: frontbuffer plane tracking bits - * - * This function gets called everytime rendering on the given planes start. - * Hence DRRS needs to be Upclocked, i.e. (LOW_RR -> HIGH_RR). - * - * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bit= s. - */ -void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv, - unsigned int frontbuffer_bits) -{ - struct intel_dp *intel_dp; - struct drm_crtc *crtc; - enum pipe pipe; - - if (dev_priv->drrs.type =3D=3D DRRS_NOT_SUPPORTED) - return; - - cancel_delayed_work(&dev_priv->drrs.work); - - mutex_lock(&dev_priv->drrs.mutex); - - intel_dp =3D dev_priv->drrs.dp; - if (!intel_dp) { - mutex_unlock(&dev_priv->drrs.mutex); - return; - } - - crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; - pipe =3D to_intel_crtc(crtc)->pipe; - - frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); - dev_priv->drrs.busy_frontbuffer_bits |=3D frontbuffer_bits; - - /* invalidate means busy screen hence upclock */ - if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_= RR) - intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, - drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_mode)); - - mutex_unlock(&dev_priv->drrs.mutex); -} - -/** - * intel_edp_drrs_flush - Restart Idleness DRRS - * @dev_priv: i915 device - * @frontbuffer_bits: frontbuffer plane tracking bits - * - * This function gets called every time rendering on the given planes has - * completed or flip on a crtc is completed. So DRRS should be upclocked - * (LOW_RR -> HIGH_RR). And also Idleness detection should be started agai= n, - * if no other planes are dirty. - * - * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bit= s. - */ -void intel_edp_drrs_flush(struct drm_i915_private *dev_priv, - unsigned int frontbuffer_bits) -{ - struct intel_dp *intel_dp; - struct drm_crtc *crtc; - enum pipe pipe; - - if (dev_priv->drrs.type =3D=3D DRRS_NOT_SUPPORTED) - return; - - cancel_delayed_work(&dev_priv->drrs.work); - - mutex_lock(&dev_priv->drrs.mutex); - - intel_dp =3D dev_priv->drrs.dp; - if (!intel_dp) { - mutex_unlock(&dev_priv->drrs.mutex); - return; - } - - crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; - pipe =3D to_intel_crtc(crtc)->pipe; - - frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); - dev_priv->drrs.busy_frontbuffer_bits &=3D ~frontbuffer_bits; - - /* flush means busy screen hence upclock */ - if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_= RR) - intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, - drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_mode)); - - /* - * flush also means no more activity hence schedule downclock, if all - * other fbs are quiescent too - */ - if (!dev_priv->drrs.busy_frontbuffer_bits) - schedule_delayed_work(&dev_priv->drrs.work, - msecs_to_jiffies(1000)); - mutex_unlock(&dev_priv->drrs.mutex); -} - -/** - * DOC: Display Refresh Rate Switching (DRRS) - * - * Display Refresh Rate Switching (DRRS) is a power conservation feature - * which enables swtching between low and high refresh rates, - * dynamically, based on the usage scenario. This feature is applicable - * for internal panels. - * - * Indication that the panel supports DRRS is given by the panel EDID, whi= ch - * would list multiple refresh rates for one resolution. - * - * DRRS is of 2 types - static and seamless. - * Static DRRS involves changing refresh rate (RR) by doing a full modeset - * (may appear as a blink on screen) and is used in dock-undock scenario. - * Seamless DRRS involves changing RR without any visual effect to the user - * and can be used during normal system usage. This is done by programming - * certain registers. - * - * Support for static/seamless DRRS may be indicated in the VBT based on - * inputs from the panel spec. - * - * DRRS saves power by switching to low RR based on usage scenarios. - * - * The implementation is based on frontbuffer tracking implementation. Wh= en - * there is a disturbance on the screen triggered by user activity or a pe= riodic - * system activity, DRRS is disabled (RR is changed to high RR). When the= re is - * no movement on screen, after a timeout of 1 second, a switch to low RR = is - * made. - * - * For integration with frontbuffer tracking code, intel_edp_drrs_invalida= te() - * and intel_edp_drrs_flush() are called. - * - * DRRS can be further extended to support other internal panels and also - * the scenario of video playback wherein RR is set based on the rate - * requested by userspace. - */ - -/** - * intel_dp_drrs_init - Init basic DRRS work and mutex. - * @connector: eDP connector - * @fixed_mode: preferred mode of panel - * - * This function is called only once at driver load to initialize basic - * DRRS stuff. - * - * Returns: - * Downclock mode if panel supports it, else return NULL. - * DRRS support is determined by the presence of downclock mode (apart - * from VBT setting). - */ -static struct drm_display_mode * -intel_dp_drrs_init(struct intel_connector *connector, - struct drm_display_mode *fixed_mode) -{ - struct drm_i915_private *dev_priv =3D to_i915(connector->base.dev); - struct drm_display_mode *downclock_mode =3D NULL; - - INIT_DELAYED_WORK(&dev_priv->drrs.work, intel_edp_drrs_downclock_work); - mutex_init(&dev_priv->drrs.mutex); - - if (DISPLAY_VER(dev_priv) <=3D 6) { - drm_dbg_kms(&dev_priv->drm, - "DRRS supported for Gen7 and above\n"); - return NULL; - } - - if (dev_priv->vbt.drrs_type !=3D SEAMLESS_DRRS_SUPPORT) { - drm_dbg_kms(&dev_priv->drm, "VBT doesn't support DRRS\n"); - return NULL; - } - - downclock_mode =3D intel_panel_edid_downclock_mode(connector, fixed_mode); - if (!downclock_mode) { - drm_dbg_kms(&dev_priv->drm, - "Downclock mode is not found. DRRS not supported\n"); - return NULL; - } - - dev_priv->drrs.type =3D dev_priv->vbt.drrs_type; - - dev_priv->drrs.refresh_rate_type =3D DRRS_HIGH_RR; - drm_dbg_kms(&dev_priv->drm, - "seamless DRRS supported for eDP panel.\n"); - return downclock_mode; -} - static bool intel_edp_init_connector(struct intel_dp *intel_dp, struct intel_connector *intel_connector) { diff --git a/drivers/gpu/drm/i915/display/intel_dp.h b/drivers/gpu/drm/i915= /display/intel_dp.h index 2121aaa9b8db0..3dd6ebc2f6b14 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.h +++ b/drivers/gpu/drm/i915/display/intel_dp.h @@ -70,17 +70,6 @@ int intel_dp_max_link_rate(struct intel_dp *intel_dp); int intel_dp_max_lane_count(struct intel_dp *intel_dp); int intel_dp_rate_select(struct intel_dp *intel_dp, int rate); =20 -void intel_edp_drrs_enable(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_disable(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_update(struct intel_dp *intel_dp, - const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv, - unsigned int frontbuffer_bits); -void intel_edp_drrs_flush(struct drm_i915_private *dev_priv, - unsigned int frontbuffer_bits); - void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock, u8 *link_bw, u8 *rate_select); bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp); diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c b/drivers/gpu/drm/i9= 15/display/intel_drrs.c new file mode 100644 index 0000000000000..be9b6d4482f04 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_drrs.c @@ -0,0 +1,477 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright =C2=A9 2021 Intel Corporation + */ + +#include "i915_drv.h" +#include "intel_atomic.h" +#include "intel_de.h" +#include "intel_display_types.h" +#include "intel_drrs.h" +#include "intel_panel.h" + +/** + * DOC: Display Refresh Rate Switching (DRRS) + * + * Display Refresh Rate Switching (DRRS) is a power conservation feature + * which enables swtching between low and high refresh rates, + * dynamically, based on the usage scenario. This feature is applicable + * for internal panels. + * + * Indication that the panel supports DRRS is given by the panel EDID, whi= ch + * would list multiple refresh rates for one resolution. + * + * DRRS is of 2 types - static and seamless. + * Static DRRS involves changing refresh rate (RR) by doing a full modeset + * (may appear as a blink on screen) and is used in dock-undock scenario. + * Seamless DRRS involves changing RR without any visual effect to the user + * and can be used during normal system usage. This is done by programming + * certain registers. + * + * Support for static/seamless DRRS may be indicated in the VBT based on + * inputs from the panel spec. + * + * DRRS saves power by switching to low RR based on usage scenarios. + * + * The implementation is based on frontbuffer tracking implementation. Wh= en + * there is a disturbance on the screen triggered by user activity or a pe= riodic + * system activity, DRRS is disabled (RR is changed to high RR). When the= re is + * no movement on screen, after a timeout of 1 second, a switch to low RR = is + * made. + * + * For integration with frontbuffer tracking code, intel_edp_drrs_invalida= te() + * and intel_edp_drrs_flush() are called. + * + * DRRS can be further extended to support other internal panels and also + * the scenario of video playback wherein RR is set based on the rate + * requested by userspace. + */ + +void +intel_dp_drrs_compute_config(struct intel_dp *intel_dp, + struct intel_crtc_state *pipe_config, + int output_bpp, bool constant_n) +{ + struct intel_connector *intel_connector =3D intel_dp->attached_connector; + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + int pixel_clock; + + if (pipe_config->vrr.enable) + return; + + /* + * DRRS and PSR can't be enable together, so giving preference to PSR + * as it allows more power-savings by complete shutting down display, + * so to guarantee this, intel_dp_drrs_compute_config() must be called + * after intel_psr_compute_config(). + */ + if (pipe_config->has_psr) + return; + + if (!intel_connector->panel.downclock_mode || + dev_priv->drrs.type !=3D SEAMLESS_DRRS_SUPPORT) + return; + + pipe_config->has_drrs =3D true; + + pixel_clock =3D intel_connector->panel.downclock_mode->clock; + if (pipe_config->splitter.enable) + pixel_clock /=3D pipe_config->splitter.link_count; + + intel_link_compute_m_n(output_bpp, pipe_config->lane_count, pixel_clock, + pipe_config->port_clock, &pipe_config->dp_m2_n2, + constant_n, pipe_config->fec_enable); + + /* FIXME: abstract this better */ + if (pipe_config->splitter.enable) + pipe_config->dp_m2_n2.gmch_m *=3D pipe_config->splitter.link_count; +} + +/** + * intel_dp_set_drrs_state - program registers for RR switch to take effect + * @dev_priv: i915 device + * @crtc_state: a pointer to the active intel_crtc_state + * @refresh_rate: RR to be programmed + * + * This function gets called when refresh rate (RR) has to be changed from + * one frequency to another. Switches can be between high and low RR + * supported by the panel or to any other RR based on media playback (in + * this case, RR value needs to be passed from user space). + * + * The caller of this function needs to take a lock on dev_priv->drrs. + */ +static void intel_dp_set_drrs_state(struct drm_i915_private *dev_priv, + const struct intel_crtc_state *crtc_state, + int refresh_rate) +{ + struct intel_dp *intel_dp =3D dev_priv->drrs.dp; + struct intel_crtc *crtc =3D to_intel_crtc(crtc_state->uapi.crtc); + enum drrs_refresh_rate_type index =3D DRRS_HIGH_RR; + + if (refresh_rate <=3D 0) { + drm_dbg_kms(&dev_priv->drm, + "Refresh rate should be positive non-zero.\n"); + return; + } + + if (intel_dp =3D=3D NULL) { + drm_dbg_kms(&dev_priv->drm, "DRRS not supported.\n"); + return; + } + + if (!crtc) { + drm_dbg_kms(&dev_priv->drm, + "DRRS: intel_crtc not initialized\n"); + return; + } + + if (dev_priv->drrs.type < SEAMLESS_DRRS_SUPPORT) { + drm_dbg_kms(&dev_priv->drm, "Only Seamless DRRS supported.\n"); + return; + } + + if (drm_mode_vrefresh(intel_dp->attached_connector->panel.downclock_mode)= =3D=3D + refresh_rate) + index =3D DRRS_LOW_RR; + + if (index =3D=3D dev_priv->drrs.refresh_rate_type) { + drm_dbg_kms(&dev_priv->drm, + "DRRS requested for previously set RR...ignoring\n"); + return; + } + + if (!crtc_state->hw.active) { + drm_dbg_kms(&dev_priv->drm, + "eDP encoder disabled. CRTC not Active\n"); + return; + } + + if (DISPLAY_VER(dev_priv) >=3D 8 && !IS_CHERRYVIEW(dev_priv)) { + switch (index) { + case DRRS_HIGH_RR: + intel_dp_set_m_n(crtc_state, M1_N1); + break; + case DRRS_LOW_RR: + intel_dp_set_m_n(crtc_state, M2_N2); + break; + case DRRS_MAX_RR: + default: + drm_err(&dev_priv->drm, + "Unsupported refreshrate type\n"); + } + } else if (DISPLAY_VER(dev_priv) > 6) { + i915_reg_t reg =3D PIPECONF(crtc_state->cpu_transcoder); + u32 val; + + val =3D intel_de_read(dev_priv, reg); + if (index > DRRS_HIGH_RR) { + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) + val |=3D PIPECONF_EDP_RR_MODE_SWITCH_VLV; + else + val |=3D PIPECONF_EDP_RR_MODE_SWITCH; + } else { + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) + val &=3D ~PIPECONF_EDP_RR_MODE_SWITCH_VLV; + else + val &=3D ~PIPECONF_EDP_RR_MODE_SWITCH; + } + intel_de_write(dev_priv, reg, val); + } + + dev_priv->drrs.refresh_rate_type =3D index; + + drm_dbg_kms(&dev_priv->drm, "eDP Refresh Rate set to : %dHz\n", + refresh_rate); +} + +static void +intel_edp_drrs_enable_locked(struct intel_dp *intel_dp) +{ + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + + dev_priv->drrs.busy_frontbuffer_bits =3D 0; + dev_priv->drrs.dp =3D intel_dp; +} + +/** + * intel_edp_drrs_enable - init drrs struct if supported + * @intel_dp: DP struct + * @crtc_state: A pointer to the active crtc state. + * + * Initializes frontbuffer_bits and drrs.dp + */ +void intel_edp_drrs_enable(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state) +{ + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + + if (!crtc_state->has_drrs) + return; + + drm_dbg_kms(&dev_priv->drm, "Enabling DRRS\n"); + + mutex_lock(&dev_priv->drrs.mutex); + + if (dev_priv->drrs.dp) { + drm_warn(&dev_priv->drm, "DRRS already enabled\n"); + goto unlock; + } + + intel_edp_drrs_enable_locked(intel_dp); + +unlock: + mutex_unlock(&dev_priv->drrs.mutex); +} + +static void +intel_edp_drrs_disable_locked(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state) +{ + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + + if (dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_RR) { + int refresh; + + refresh =3D drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_= mode); + intel_dp_set_drrs_state(dev_priv, crtc_state, refresh); + } + + dev_priv->drrs.dp =3D NULL; +} + +/** + * intel_edp_drrs_disable - Disable DRRS + * @intel_dp: DP struct + * @old_crtc_state: Pointer to old crtc_state. + * + */ +void intel_edp_drrs_disable(struct intel_dp *intel_dp, + const struct intel_crtc_state *old_crtc_state) +{ + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + + if (!old_crtc_state->has_drrs) + return; + + mutex_lock(&dev_priv->drrs.mutex); + if (!dev_priv->drrs.dp) { + mutex_unlock(&dev_priv->drrs.mutex); + return; + } + + intel_edp_drrs_disable_locked(intel_dp, old_crtc_state); + mutex_unlock(&dev_priv->drrs.mutex); + + cancel_delayed_work_sync(&dev_priv->drrs.work); +} + +/** + * intel_edp_drrs_update - Update DRRS state + * @intel_dp: Intel DP + * @crtc_state: new CRTC state + * + * This function will update DRRS states, disabling or enabling DRRS when + * executing fastsets. For full modeset, intel_edp_drrs_disable() and + * intel_edp_drrs_enable() should be called instead. + */ +void +intel_edp_drrs_update(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state) +{ + struct drm_i915_private *dev_priv =3D dp_to_i915(intel_dp); + + if (dev_priv->drrs.type !=3D SEAMLESS_DRRS_SUPPORT) + return; + + mutex_lock(&dev_priv->drrs.mutex); + + /* New state matches current one? */ + if (crtc_state->has_drrs =3D=3D !!dev_priv->drrs.dp) + goto unlock; + + if (crtc_state->has_drrs) + intel_edp_drrs_enable_locked(intel_dp); + else + intel_edp_drrs_disable_locked(intel_dp, crtc_state); + +unlock: + mutex_unlock(&dev_priv->drrs.mutex); +} + +static void intel_edp_drrs_downclock_work(struct work_struct *work) +{ + struct drm_i915_private *dev_priv =3D + container_of(work, typeof(*dev_priv), drrs.work.work); + struct intel_dp *intel_dp; + + mutex_lock(&dev_priv->drrs.mutex); + + intel_dp =3D dev_priv->drrs.dp; + + if (!intel_dp) + goto unlock; + + /* + * The delayed work can race with an invalidate hence we need to + * recheck. + */ + + if (dev_priv->drrs.busy_frontbuffer_bits) + goto unlock; + + if (dev_priv->drrs.refresh_rate_type !=3D DRRS_LOW_RR) { + struct drm_crtc *crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; + + intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, + drm_mode_vrefresh(intel_dp->attached_connector->panel.downclock_mode)= ); + } + +unlock: + mutex_unlock(&dev_priv->drrs.mutex); +} + +/** + * intel_edp_drrs_invalidate - Disable Idleness DRRS + * @dev_priv: i915 device + * @frontbuffer_bits: frontbuffer plane tracking bits + * + * This function gets called everytime rendering on the given planes start. + * Hence DRRS needs to be Upclocked, i.e. (LOW_RR -> HIGH_RR). + * + * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bit= s. + */ +void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv, + unsigned int frontbuffer_bits) +{ + struct intel_dp *intel_dp; + struct drm_crtc *crtc; + enum pipe pipe; + + if (dev_priv->drrs.type =3D=3D DRRS_NOT_SUPPORTED) + return; + + cancel_delayed_work(&dev_priv->drrs.work); + + mutex_lock(&dev_priv->drrs.mutex); + + intel_dp =3D dev_priv->drrs.dp; + if (!intel_dp) { + mutex_unlock(&dev_priv->drrs.mutex); + return; + } + + crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; + pipe =3D to_intel_crtc(crtc)->pipe; + + frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); + dev_priv->drrs.busy_frontbuffer_bits |=3D frontbuffer_bits; + + /* invalidate means busy screen hence upclock */ + if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_= RR) + intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, + drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_mode)); + + mutex_unlock(&dev_priv->drrs.mutex); +} + +/** + * intel_edp_drrs_flush - Restart Idleness DRRS + * @dev_priv: i915 device + * @frontbuffer_bits: frontbuffer plane tracking bits + * + * This function gets called every time rendering on the given planes has + * completed or flip on a crtc is completed. So DRRS should be upclocked + * (LOW_RR -> HIGH_RR). And also Idleness detection should be started agai= n, + * if no other planes are dirty. + * + * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bit= s. + */ +void intel_edp_drrs_flush(struct drm_i915_private *dev_priv, + unsigned int frontbuffer_bits) +{ + struct intel_dp *intel_dp; + struct drm_crtc *crtc; + enum pipe pipe; + + if (dev_priv->drrs.type =3D=3D DRRS_NOT_SUPPORTED) + return; + + cancel_delayed_work(&dev_priv->drrs.work); + + mutex_lock(&dev_priv->drrs.mutex); + + intel_dp =3D dev_priv->drrs.dp; + if (!intel_dp) { + mutex_unlock(&dev_priv->drrs.mutex); + return; + } + + crtc =3D dp_to_dig_port(intel_dp)->base.base.crtc; + pipe =3D to_intel_crtc(crtc)->pipe; + + frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); + dev_priv->drrs.busy_frontbuffer_bits &=3D ~frontbuffer_bits; + + /* flush means busy screen hence upclock */ + if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type =3D=3D DRRS_LOW_= RR) + intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, + drm_mode_vrefresh(intel_dp->attached_connector->panel.fixed_mode)); + + /* + * flush also means no more activity hence schedule downclock, if all + * other fbs are quiescent too + */ + if (!dev_priv->drrs.busy_frontbuffer_bits) + schedule_delayed_work(&dev_priv->drrs.work, + msecs_to_jiffies(1000)); + mutex_unlock(&dev_priv->drrs.mutex); +} + +/** + * intel_dp_drrs_init - Init basic DRRS work and mutex. + * @connector: eDP connector + * @fixed_mode: preferred mode of panel + * + * This function is called only once at driver load to initialize basic + * DRRS stuff. + * + * Returns: + * Downclock mode if panel supports it, else return NULL. + * DRRS support is determined by the presence of downclock mode (apart + * from VBT setting). + */ +struct drm_display_mode * +intel_dp_drrs_init(struct intel_connector *connector, + struct drm_display_mode *fixed_mode) +{ + struct drm_i915_private *dev_priv =3D to_i915(connector->base.dev); + struct drm_display_mode *downclock_mode =3D NULL; + + INIT_DELAYED_WORK(&dev_priv->drrs.work, intel_edp_drrs_downclock_work); + mutex_init(&dev_priv->drrs.mutex); + + if (DISPLAY_VER(dev_priv) <=3D 6) { + drm_dbg_kms(&dev_priv->drm, + "DRRS supported for Gen7 and above\n"); + return NULL; + } + + if (dev_priv->vbt.drrs_type !=3D SEAMLESS_DRRS_SUPPORT) { + drm_dbg_kms(&dev_priv->drm, "VBT doesn't support DRRS\n"); + return NULL; + } + + downclock_mode =3D intel_panel_edid_downclock_mode(connector, fixed_mode); + if (!downclock_mode) { + drm_dbg_kms(&dev_priv->drm, + "Downclock mode is not found. DRRS not supported\n"); + return NULL; + } + + dev_priv->drrs.type =3D dev_priv->vbt.drrs_type; + + dev_priv->drrs.refresh_rate_type =3D DRRS_HIGH_RR; + drm_dbg_kms(&dev_priv->drm, + "seamless DRRS supported for eDP panel.\n"); + return downclock_mode; +} diff --git a/drivers/gpu/drm/i915/display/intel_drrs.h b/drivers/gpu/drm/i9= 15/display/intel_drrs.h new file mode 100644 index 0000000000000..ffa175b4cf4f4 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_drrs.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright =C2=A9 2021 Intel Corporation + */ + +#ifndef __INTEL_DRRS_H__ +#define __INTEL_DRRS_H__ + +#include + +struct drm_i915_private; +struct intel_crtc_state; +struct intel_connector; +struct intel_dp; + +void intel_edp_drrs_enable(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_disable(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_update(struct intel_dp *intel_dp, + const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv, + unsigned int frontbuffer_bits); +void intel_edp_drrs_flush(struct drm_i915_private *dev_priv, + unsigned int frontbuffer_bits); +void intel_dp_drrs_compute_config(struct intel_dp *intel_dp, + struct intel_crtc_state *pipe_config, + int output_bpp, bool constant_n); +struct drm_display_mode *intel_dp_drrs_init(struct intel_connector *connec= tor, + struct drm_display_mode *fixed_mode); + +#endif /* __INTEL_DRRS_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu= /drm/i915/display/intel_frontbuffer.c index 8e75debcce1a9..e4834d84ce5e3 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -62,6 +62,7 @@ #include "intel_display_types.h" #include "intel_fbc.h" #include "intel_frontbuffer.h" +#include "intel_drrs.h" #include "intel_psr.h" =20 /** --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB10DC4321E for ; Mon, 7 Mar 2022 10:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240076AbiCGKEt (ORCPT ); Mon, 7 Mar 2022 05:04:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241164AbiCGJl6 (ORCPT ); Mon, 7 Mar 2022 04:41: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 49672AE46; Mon, 7 Mar 2022 01:41:03 -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 DD56F6116E; Mon, 7 Mar 2022 09:41:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9D2CC340E9; Mon, 7 Mar 2022 09:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646062; bh=DkGlqhUUDxKbqoNaMqWTGXbEulGkywmWWVJrxV+9pmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZyxI2k8Etem3wlhdLS3nsOi79E0HLjMHfAOj+iAx2G4VRuhwhXgJSQ3IL3aeffbM V9Wn9Yv7XYzKRD5XedA5PiNpHtjbr8wm+hwjfN1XehZPrELp7E3JXEPXX/Ou/JMs4q 6x8m+yzfs84j5HgtQ/H5S91fiTQ0GneZdn0LszD8= 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?= , Jani Nikula , Tvrtko Ursulin , Sasha Levin Subject: [PATCH 5.15 120/262] drm/i915: Disable DRRS on IVB/HSW port != A Date: Mon, 7 Mar 2022 10:17:44 +0100 Message-Id: <20220307091705.850700360@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ville Syrj=C3=A4l=C3=A4 [ Upstream commit ee59792c97176f12c1da31f29fc4c2aab187f06e ] Currently we allow DRRS on IVB PCH ports, but we're missing a few programming steps meaning it is guaranteed to not work. And on HSW DRRS is not supported on anything but port A ever as only transcoder EDP has the M2/N2 registers (though I'm not sure if HSW ever has eDP on any other port). Starting from BDW all transcoders have the dynamically reprogrammable M/N registers so DRRS could work on any port. Stop initializing DRRS on ports where it cannot possibly work. Cc: stable@vger.kernel.org Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20220128103757.22461-11= -ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula (cherry picked from commit f0d4ce59f4d48622044933054a0e0cefa91ba15e) Signed-off-by: Tvrtko Ursulin Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/display/intel_drrs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c b/drivers/gpu/drm/i9= 15/display/intel_drrs.c index be9b6d4482f04..3c7d6bf579484 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.c +++ b/drivers/gpu/drm/i915/display/intel_drrs.c @@ -445,6 +445,7 @@ intel_dp_drrs_init(struct intel_connector *connector, struct drm_display_mode *fixed_mode) { struct drm_i915_private *dev_priv =3D to_i915(connector->base.dev); + struct intel_encoder *encoder =3D connector->encoder; struct drm_display_mode *downclock_mode =3D NULL; =20 INIT_DELAYED_WORK(&dev_priv->drrs.work, intel_edp_drrs_downclock_work); @@ -456,6 +457,13 @@ intel_dp_drrs_init(struct intel_connector *connector, return NULL; } =20 + if ((DISPLAY_VER(dev_priv) < 8 && !HAS_GMCH(dev_priv)) && + encoder->port !=3D PORT_A) { + drm_dbg_kms(&dev_priv->drm, + "DRRS only supported on eDP port A\n"); + return NULL; + } + if (dev_priv->vbt.drrs_type !=3D SEAMLESS_DRRS_SUPPORT) { drm_dbg_kms(&dev_priv->drm, "VBT doesn't support DRRS\n"); return NULL; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50131C433EF for ; Mon, 7 Mar 2022 10:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237058AbiCGKFC (ORCPT ); Mon, 7 Mar 2022 05:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236508AbiCGJmC (ORCPT ); Mon, 7 Mar 2022 04:42:02 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B878422A; Mon, 7 Mar 2022 01:41: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 sin.source.kernel.org (Postfix) with ESMTPS id 306ADCE0EAA; Mon, 7 Mar 2022 09:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1194C340E9; Mon, 7 Mar 2022 09:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646065; bh=w3xW6sXuqTAEkeMEks1u2RQfpbj9vS7RE95tWEHFmkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A822l9Ea7/jXUa12UqALbJC5bfmtT4HvWQebdARmsHdi9mgRkEt4ui1ythMajKuFH xDNglMeWvveSDtVm55M6dq4EPeSEXKjZPjMuL/mqtb7rM2ELQhJ+ennoCqwdfiIiOx xz4u/DlDufOqz3dTkFvomr3XUhoowrBbraZWtDTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tao Liu , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 121/262] gve: Recording rx queue before sending to napi Date: Mon, 7 Mar 2022 10:17:45 +0100 Message-Id: <20220307091705.877888655@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tao Liu [ Upstream commit 084cbb2ec3af2d23be9de65fcc9493e21e265859 ] This caused a significant performance degredation when using generic XDP with multiple queues. Fixes: f5cedc84a30d2 ("gve: Add transmit and receive support") Signed-off-by: Tao Liu Link: https://lore.kernel.org/r/20220207175901.2486596-1-jeroendb@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/google/gve/gve_rx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/etherne= t/google/gve/gve_rx.c index 629d8ed08fc61..97431969a488f 100644 --- a/drivers/net/ethernet/google/gve/gve_rx.c +++ b/drivers/net/ethernet/google/gve/gve_rx.c @@ -450,6 +450,7 @@ static bool gve_rx(struct gve_rx_ring *rx, struct gve_r= x_desc *rx_desc, skb_set_hash(skb, be32_to_cpu(rx_desc->rss_hash), gve_rss_type(rx_desc->flags_seq)); =20 + skb_record_rx_queue(skb, rx->q_num); if (skb_is_nonlinear(skb)) napi_gro_frags(napi); else --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19D36C433F5 for ; Mon, 7 Mar 2022 10:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239977AbiCGKFM (ORCPT ); Mon, 7 Mar 2022 05:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236349AbiCGJmF (ORCPT ); Mon, 7 Mar 2022 04:42:05 -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 2EA9B2617; Mon, 7 Mar 2022 01:41: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 979BAB8102B; Mon, 7 Mar 2022 09:41:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4DB6C340E9; Mon, 7 Mar 2022 09:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646068; bh=fbeLY+CHCzdXGQgG50LPchB8OedOkqqonlZol/wh2iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T2uWPHhqmrHI1tTmAa39yKSid4l8IROTdftQmjJipqYXMo0j/8v4/kqYvcjhgwRp4 7SDn98aTQhO3QfydQIUCIaxflMUvvo+JUpCEXmm3fKkWw19R3mIB6kC8X+ZZoN455k Tl7r/xZepRBvSGw0hfETYD2w4cnejPlXx21jQmQ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Foster , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 122/262] net: dsa: ocelot: seville: utilize of_mdiobus_register Date: Mon, 7 Mar 2022 10:17:46 +0100 Message-Id: <20220307091705.905040960@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Colin Foster [ Upstream commit 5186c4a05b9713138b762a49467a8ab9753cdb36 ] Switch seville to use of_mdiobus_register(bus, NULL) instead of just mdiobus_register. This code is about to be pulled into a separate module that can optionally define ports by the device_node. Signed-off-by: Colin Foster Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/dsa/ocelot/seville_vsc9953.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/oce= lot/seville_vsc9953.c index de1d34a1f1e47..ca8c003b99bc5 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "felix.h" =20 #define MSCC_MIIM_CMD_OPR_WRITE BIT(1) @@ -1110,7 +1111,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocel= ot) snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); =20 /* Needed in order to initialize the bus mutex lock */ - rc =3D mdiobus_register(bus); + rc =3D of_mdiobus_register(bus, NULL); if (rc < 0) { dev_err(dev, "failed to register MDIO bus\n"); return rc; --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D635BC433F5 for ; Mon, 7 Mar 2022 10:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239968AbiCGKFH (ORCPT ); Mon, 7 Mar 2022 05:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234934AbiCGJmH (ORCPT ); Mon, 7 Mar 2022 04:42: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 8CCEEDED7; Mon, 7 Mar 2022 01:41:12 -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 1C6CF61354; Mon, 7 Mar 2022 09:41:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 108EDC340FF; Mon, 7 Mar 2022 09:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646071; bh=kRf2+Neh77iSMJt5sEjQ41gXstfFY7Iu39R7lcfHym4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eRSO8yPNB8e5XTqrtWExOIShYPSl/8PN1tOuo/kqrqIiLymL5p6pIsIWeSw5ZiT0q eGiu2eyaTGbDFexQiclnwfG0t5cUcXFnhgTuu2nYS+mBoS0Qa4Zz0nj8SPy+5o6lui zbUjrHyHz7c/f6RVvNQJEPqSvntW/W7T5bEC1VVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Florian Fainelli , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 123/262] net: dsa: seville: register the mdiobus under devres Date: Mon, 7 Mar 2022 10:17:47 +0100 Message-Id: <20220307091705.932468911@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit bd488afc3b39e045ba71aab472233f2a78726e7b ] As explained in commits: 74b6d7d13307 ("net: dsa: realtek: register the MDIO bus under devres") 5135e96a3dd2 ("net: dsa: don't allocate the slave_mii_bus using devres") mdiobus_free() will panic when called from devm_mdiobus_free() <- devres_release_all() <- __device_release_driver(), and that mdiobus was not previously unregistered. The Seville VSC9959 switch is a platform device, so the initial set of constraints that I thought would cause this (I2C or SPI buses which call ->remove on ->shutdown) do not apply. But there is one more which applies here. If the DSA master itself is on a bus that calls ->remove from ->shutdown (like dpaa2-eth, which is on the fsl-mc bus), there is a device link between the switch and the DSA master, and device_links_unbind_consumers() will unbind the seville switch driver on shutdown. So the same treatment must be applied to all DSA switch drivers, which is: either use devres for both the mdiobus allocation and registration, or don't use devres at all. The seville driver has a code structure that could accommodate both the mdiobus_unregister and mdiobus_free calls, but it has an external dependency upon mscc_miim_setup() from mdio-mscc-miim.c, which calls devm_mdiobus_alloc_size() on its behalf. So rather than restructuring that, and exporting yet one more symbol mscc_miim_teardown(), let's work with devres and replace of_mdiobus_register with the devres variant. When we use all-devres, we can ensure that devres doesn't free a still-registered bus (it either runs both callbacks, or none). Fixes: ac3a68d56651 ("net: phy: don't abuse devres in devm_mdiobus_register= ()") Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/oce= lot/seville_vsc9953.c index ca8c003b99bc5..05e4e75c01076 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -1111,7 +1111,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocel= ot) snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); =20 /* Needed in order to initialize the bus mutex lock */ - rc =3D of_mdiobus_register(bus, NULL); + rc =3D devm_of_mdiobus_register(dev, bus, NULL); if (rc < 0) { dev_err(dev, "failed to register MDIO bus\n"); return rc; @@ -1163,7 +1163,8 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocel= ot) mdio_device_free(pcs->mdio); lynx_pcs_destroy(pcs); } - mdiobus_unregister(felix->imdio); + + /* mdiobus_unregister and mdiobus_free handled by devres */ } =20 static const struct felix_info seville_info_vsc9953 =3D { --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B035EC433F5 for ; Mon, 7 Mar 2022 10:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240025AbiCGKFW (ORCPT ); Mon, 7 Mar 2022 05:05:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235301AbiCGJm2 (ORCPT ); Mon, 7 Mar 2022 04:42:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF93F10FE5; Mon, 7 Mar 2022 01:41: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 591876128E; Mon, 7 Mar 2022 09:41:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6595FC340E9; Mon, 7 Mar 2022 09:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646077; bh=FDzh0ZHeyKx2upDiIZLBZOLXmyWGOvmDhGV6edFVnBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2nGW+8wjxXbpLcY0JG1mmnPWd7FmhdxrVQKS9FagbDiSyETVg0okxKZF0eyyRLzK Z129sCZsnnpRQo+NJ8oN1JvzB0lVZ6Z5qIV4K9bBsXbcUi7FusgLh9Qzf1pr+RHoob A1ImySt8iejKJmTkZ0jo4UgJ3iEiTIkQKPNPybW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abdul Haleem , Sukadev Bhattiprolu , Dany Madden , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 124/262] ibmvnic: dont release napi in __ibmvnic_open() Date: Mon, 7 Mar 2022 10:17:48 +0100 Message-Id: <20220307091705.959547578@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sukadev Bhattiprolu [ Upstream commit 61772b0908c640d0309c40f7d41d062ca4e979fa ] If __ibmvnic_open() encounters an error such as when setting link state, it calls release_resources() which frees the napi structures needlessly. Instead, have __ibmvnic_open() only clean up the work it did so far (i.e. disable napi and irqs) and leave the rest to the callers. If caller of __ibmvnic_open() is ibmvnic_open(), it should release the resources immediately. If the caller is do_reset() or do_hard_reset(), they will release the resources on the next reset. This fixes following crash that occurred when running the drmgr command several times to add/remove a vnic interface: [102056] ibmvnic 30000003 env3: Disabling rx_scrq[6] irq [102056] ibmvnic 30000003 env3: Disabling rx_scrq[7] irq [102056] ibmvnic 30000003 env3: Replenished 8 pools Kernel attempted to read user page (10) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on read at 0x00000010 Faulting instruction address: 0xc000000000a3c840 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=3D64K MMU=3DRadix SMP NR_CPUS=3D2048 NUMA pSeries ... CPU: 9 PID: 102056 Comm: kworker/9:2 Kdump: loaded Not tainted 5.16.0-rc5-= autotest-g6441998e2e37 #1 Workqueue: events_long __ibmvnic_reset [ibmvnic] NIP: c000000000a3c840 LR: c0080000029b5378 CTR: c000000000a3c820 REGS: c0000000548e37e0 TRAP: 0300 Not tainted (5.16.0-rc5-autotest-g644= 1998e2e37) MSR: 8000000000009033 CR: 28248484 XER: 00000004 CFAR: c0080000029bdd24 DAR: 0000000000000010 DSISR: 40000000 IRQMASK: 0 GPR00: c0080000029b55d0 c0000000548e3a80 c0000000028f0200 0000000000000000 ... NIP [c000000000a3c840] napi_enable+0x20/0xc0 LR [c0080000029b5378] __ibmvnic_open+0xf0/0x430 [ibmvnic] Call Trace: [c0000000548e3a80] [0000000000000006] 0x6 (unreliable) [c0000000548e3ab0] [c0080000029b55d0] __ibmvnic_open+0x348/0x430 [ibmvnic] [c0000000548e3b40] [c0080000029bcc28] __ibmvnic_reset+0x500/0xdf0 [ibmvnic] [c0000000548e3c60] [c000000000176228] process_one_work+0x288/0x570 [c0000000548e3d00] [c000000000176588] worker_thread+0x78/0x660 [c0000000548e3da0] [c0000000001822f0] kthread+0x1c0/0x1d0 [c0000000548e3e10] [c00000000000cf64] ret_from_kernel_thread+0x5c/0x64 Instruction dump: 7d2948f8 792307e0 4e800020 60000000 3c4c01eb 384239e0 f821ffd1 39430010 38a0fff6 e92d1100 f9210028 39200000 f9010020 60420000 e9210020 ---[ end trace 5f8033b08fd27706 ]--- Fixes: ed651a10875f ("ibmvnic: Updated reset handling") Reported-by: Abdul Haleem Signed-off-by: Sukadev Bhattiprolu Reviewed-by: Dany Madden Link: https://lore.kernel.org/r/20220208001918.900602-1-sukadev@linux.ibm.c= om Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/ibm/ibmvnic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index 14a729ba737a8..cc5ab66a81850 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -108,6 +108,7 @@ static int init_crq_queue(struct ibmvnic_adapter *adapt= er); static int send_query_phys_parms(struct ibmvnic_adapter *adapter); static void ibmvnic_tx_scrq_clean_buffer(struct ibmvnic_adapter *adapter, struct ibmvnic_sub_crq_queue *tx_scrq); +static void ibmvnic_disable_irqs(struct ibmvnic_adapter *adapter); =20 struct ibmvnic_stat { char name[ETH_GSTRING_LEN]; @@ -1245,7 +1246,7 @@ static int __ibmvnic_open(struct net_device *netdev) rc =3D set_link_state(adapter, IBMVNIC_LOGICAL_LNK_UP); if (rc) { ibmvnic_napi_disable(adapter); - release_resources(adapter); + ibmvnic_disable_irqs(adapter); return rc; } =20 @@ -1295,7 +1296,6 @@ static int ibmvnic_open(struct net_device *netdev) rc =3D init_resources(adapter); if (rc) { netdev_err(netdev, "failed to initialize resources\n"); - release_resources(adapter); goto out; } } @@ -1312,6 +1312,11 @@ static int ibmvnic_open(struct net_device *netdev) adapter->state =3D VNIC_OPEN; rc =3D 0; } + + if (rc) { + release_resources(adapter); + } + return rc; } =20 --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEBB9C433EF for ; Mon, 7 Mar 2022 10:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236907AbiCGKF0 (ORCPT ); Mon, 7 Mar 2022 05:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238096AbiCGJmu (ORCPT ); Mon, 7 Mar 2022 04:42:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD8C15A18; Mon, 7 Mar 2022 01:41: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 ams.source.kernel.org (Postfix) with ESMTPS id 65A30B80F9F; Mon, 7 Mar 2022 09:41:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A74A7C340F3; Mon, 7 Mar 2022 09:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646081; bh=Wt7B/bnSJ1P0KwmJ/NMxbKs0Pkrp1FbTdd1lziXU4UY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rw3PMJiydzWuf8Nf5zWqeN+ROkTHZgS+qO9mu7+K7HrasMlyiAM08GZ0l4zw3CFwy kRX1fa2JfTUR05GrmqeS0XLXGPjzg2A0rEfMZuuOKf1DmazOjpzL+EUTGjKruEewju TSqqrk72W95IkHTNIhdsyFmZRcnMLKB74Z5HLXc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Jakub Kicinski , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 125/262] of: net: move of_net under net/ Date: Mon, 7 Mar 2022 10:17:49 +0100 Message-Id: <20220307091705.986552104@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski [ Upstream commit e330fb14590c5c80f7195c3d8c9b4bcf79e1a5cd ] Rob suggests to move of_net.c from under drivers/of/ somewhere to the networking code. Suggested-by: Rob Herring Signed-off-by: Jakub Kicinski Reviewed-by: Rob Herring Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/amd/Kconfig | 2 +- drivers/net/ethernet/arc/Kconfig | 4 ++-- drivers/net/ethernet/ezchip/Kconfig | 2 +- drivers/net/ethernet/litex/Kconfig | 2 +- drivers/net/ethernet/mscc/Kconfig | 2 +- drivers/of/Kconfig | 4 ---- drivers/of/Makefile | 1 - include/linux/of_net.h | 2 +- net/core/Makefile | 1 + net/core/net-sysfs.c | 2 +- {drivers/of =3D> net/core}/of_net.c | 0 11 files changed, 9 insertions(+), 13 deletions(-) rename {drivers/of =3D> net/core}/of_net.c (100%) diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kc= onfig index 4786f0504691d..899c8a2a34b6b 100644 --- a/drivers/net/ethernet/amd/Kconfig +++ b/drivers/net/ethernet/amd/Kconfig @@ -168,7 +168,7 @@ config SUNLANCE =20 config AMD_XGBE tristate "AMD 10GbE Ethernet driver" - depends on ((OF_NET && OF_ADDRESS) || ACPI || PCI) && HAS_IOMEM + depends on (OF_ADDRESS || ACPI || PCI) && HAS_IOMEM depends on X86 || ARM64 || COMPILE_TEST depends on PTP_1588_CLOCK_OPTIONAL select BITREVERSE diff --git a/drivers/net/ethernet/arc/Kconfig b/drivers/net/ethernet/arc/Kc= onfig index 92a79c4ffa2c7..0a67612af2281 100644 --- a/drivers/net/ethernet/arc/Kconfig +++ b/drivers/net/ethernet/arc/Kconfig @@ -26,7 +26,7 @@ config ARC_EMAC_CORE config ARC_EMAC tristate "ARC EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on ARC || COMPILE_TEST help On some legacy ARC (Synopsys) FPGA boards such as ARCAngel4/ML50x @@ -36,7 +36,7 @@ config ARC_EMAC config EMAC_ROCKCHIP tristate "Rockchip EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET && REGULATOR + depends on OF_IRQ && REGULATOR depends on ARCH_ROCKCHIP || COMPILE_TEST help Support for Rockchip RK3036/RK3066/RK3188 EMAC ethernet controllers. diff --git a/drivers/net/ethernet/ezchip/Kconfig b/drivers/net/ethernet/ezc= hip/Kconfig index 38aa824efb25d..9241b9b1c7a36 100644 --- a/drivers/net/ethernet/ezchip/Kconfig +++ b/drivers/net/ethernet/ezchip/Kconfig @@ -18,7 +18,7 @@ if NET_VENDOR_EZCHIP =20 config EZCHIP_NPS_MANAGEMENT_ENET tristate "EZchip NPS management enet support" - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on HAS_IOMEM help Simple LAN device for debug or management purposes. diff --git a/drivers/net/ethernet/litex/Kconfig b/drivers/net/ethernet/lite= x/Kconfig index 63bf01d28f0cf..f99adbf26ab4e 100644 --- a/drivers/net/ethernet/litex/Kconfig +++ b/drivers/net/ethernet/litex/Kconfig @@ -17,7 +17,7 @@ if NET_VENDOR_LITEX =20 config LITEX_LITEETH tristate "LiteX Ethernet support" - depends on OF_NET + depends on OF help If you wish to compile a kernel for hardware with a LiteX LiteEth device then you should answer Y to this. diff --git a/drivers/net/ethernet/mscc/Kconfig b/drivers/net/ethernet/mscc/= Kconfig index b6a73d151dec1..8dd8c7f425d2c 100644 --- a/drivers/net/ethernet/mscc/Kconfig +++ b/drivers/net/ethernet/mscc/Kconfig @@ -28,7 +28,7 @@ config MSCC_OCELOT_SWITCH depends on BRIDGE || BRIDGE=3Dn depends on NET_SWITCHDEV depends on HAS_IOMEM - depends on OF_NET + depends on OF select MSCC_OCELOT_SWITCH_LIB select GENERIC_PHY help diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 3dfeae8912dfc..80b5fd44ab1c7 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -70,10 +70,6 @@ config OF_IRQ def_bool y depends on !SPARC && IRQ_DOMAIN =20 -config OF_NET - depends on NETDEVICES - def_bool y - config OF_RESERVED_MEM def_bool OF_EARLY_FLATTREE =20 diff --git a/drivers/of/Makefile b/drivers/of/Makefile index c13b982084a3a..e0360a44306e2 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_OF_EARLY_FLATTREE) +=3D fdt_address.o obj-$(CONFIG_OF_PROMTREE) +=3D pdt.o obj-$(CONFIG_OF_ADDRESS) +=3D address.o obj-$(CONFIG_OF_IRQ) +=3D irq.o -obj-$(CONFIG_OF_NET) +=3D of_net.o obj-$(CONFIG_OF_UNITTEST) +=3D unittest.o obj-$(CONFIG_OF_RESERVED_MEM) +=3D of_reserved_mem.o obj-$(CONFIG_OF_RESOLVE) +=3D resolver.o diff --git a/include/linux/of_net.h b/include/linux/of_net.h index daef3b0d9270d..cf31188329b5a 100644 --- a/include/linux/of_net.h +++ b/include/linux/of_net.h @@ -8,7 +8,7 @@ =20 #include =20 -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF #include =20 struct net_device; diff --git a/net/core/Makefile b/net/core/Makefile index 35ced6201814c..4268846f2f475 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -36,3 +36,4 @@ obj-$(CONFIG_FAILOVER) +=3D failover.o obj-$(CONFIG_NET_SOCK_MSG) +=3D skmsg.o obj-$(CONFIG_BPF_SYSCALL) +=3D sock_map.o obj-$(CONFIG_BPF_SYSCALL) +=3D bpf_sk_storage.o +obj-$(CONFIG_OF) +=3D of_net.o diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index a4ae652633844..d7f9ee830d34c 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1927,7 +1927,7 @@ static struct class net_class __ro_after_init =3D { .get_ownership =3D net_get_ownership, }; =20 -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF static int of_dev_node_match(struct device *dev, const void *data) { for (; dev; dev =3D dev->parent) { diff --git a/drivers/of/of_net.c b/net/core/of_net.c similarity index 100% rename from drivers/of/of_net.c rename to net/core/of_net.c --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBD77C433EF for ; Mon, 7 Mar 2022 10:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240168AbiCGKFb (ORCPT ); Mon, 7 Mar 2022 05:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238150AbiCGJmv (ORCPT ); Mon, 7 Mar 2022 04:42:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11C0F26ACD; Mon, 7 Mar 2022 01:41: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 ams.source.kernel.org (Postfix) with ESMTPS id 8E4DBB810B2; Mon, 7 Mar 2022 09:41:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6D26C340E9; Mon, 7 Mar 2022 09:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646084; bh=LEOfSxMZuEod8sNoK5GbKy9hMr9peXP/MVpD+L3jJ7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WN+qQBYgJVlJOsmvcZExNmA6zi7iJoOiqD5hMvTSW+68eM696WN11YrVMHPmmN2je jTmSYPMT83lFFp+d8jtYYcXrwdfqPMYJDy6UjBIDAhBRtONpH2zN7uuLbbTw5KVaOC rmjhLej7A+rnBqA1d0oSmtIv5mJr+ktsbhH7bDNc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cai Huoqing , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 126/262] net: ethernet: litex: Add the dependency on HAS_IOMEM Date: Mon, 7 Mar 2022 10:17:50 +0100 Message-Id: <20220307091706.013985836@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Cai Huoqing [ Upstream commit 2427f03fb42f9dc14c53108f2c9b5563eb37e770 ] The LiteX driver uses devm io function API which needs HAS_IOMEM enabled, so add the dependency on HAS_IOMEM. Fixes: ee7da21ac4c3 ("net: Add driver for LiteX's LiteETH network interface= ") Signed-off-by: Cai Huoqing Link: https://lore.kernel.org/r/20220208013308.6563-1-cai.huoqing@linux.dev Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/litex/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/litex/Kconfig b/drivers/net/ethernet/lite= x/Kconfig index f99adbf26ab4e..04345b929d8e5 100644 --- a/drivers/net/ethernet/litex/Kconfig +++ b/drivers/net/ethernet/litex/Kconfig @@ -17,7 +17,7 @@ if NET_VENDOR_LITEX =20 config LITEX_LITEETH tristate "LiteX Ethernet support" - depends on OF + depends on OF && HAS_IOMEM help If you wish to compile a kernel for hardware with a LiteX LiteEth device then you should answer Y to this. --=20 2.34.1 From nobody Tue Jun 23 11:09:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CFDC4167B for ; Mon, 7 Mar 2022 10:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242339AbiCGKL0 (ORCPT ); Mon, 7 Mar 2022 05:11:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239978AbiCGJu3 (ORCPT ); Mon, 7 Mar 2022 04:50:29 -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 CD956723EE; Mon, 7 Mar 2022 01:43:58 -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 D77616128D; Mon, 7 Mar 2022 09:43:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7EA0C340E9; Mon, 7 Mar 2022 09:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646237; bh=AaSQdNddQqXP9BLD0YECfLSKujsXjMpmANtH8HAYALQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MnTH+S7ktJmFHWLfawW/5cmGzyE625MBLLTC0JUfvsRO+RiZx+cn0QeLW4f7VJdW2 pG4dqq8ROJMXIZaxAileCNyxr6xU3AtQcy9qHOtGDsX3/Ua1uBowa4QvyWsC+I0LaW kkvte2CftcxrfDFfWiq/4keuPLV1VNZUH8a3s+d4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jitao Shi , Chun-Kuang Hu , Enric Balletbo i Serra , Matthias Brugger , Sasha Levin Subject: [PATCH 5.15 127/262] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Date: Mon, 7 Mar 2022 10:17:51 +0100 Message-Id: <20220307091706.041051902@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Enric Balletbo i Serra [ Upstream commit 605c83753d97946aab176735020a33ebfb0b4615 ] Reset dsi0 HW to default when power on. This prevents to have different settingis between the bootloader and the kernel. As not all Mediatek boards have the reset consumer configured in their board description, also is not needed on all of them, the reset is optional, so the change is compatible with all boards. Cc: Jitao Shi Suggested-by: Chun-Kuang Hu Signed-off-by: Enric Balletbo i Serra Acked-by: Chun-Kuang Hu Reviewed-by: Matthias Brugger Link: https://lore.kernel.org/r/20210930103105.v4.7.Idbb4727ddf00ba2fe796b6= 30906baff10d994d89@changeid Signed-off-by: Matthias Brugger Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/mediatek/mtk_dsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/= mtk_dsi.c index 93b40c245f007..5d90d2eb00193 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include