diff --git a/recipes-kernel/linux/Patch_Status_Table.txt b/recipes-kernel/linux/Patch_Status_Table.txt index fa596ac65..9097346c2 100644 --- a/recipes-kernel/linux/Patch_Status_Table.txt +++ b/recipes-kernel/linux/Patch_Status_Table.txt @@ -478,31 +478,30 @@ Kernel-6.1 |0055-mellanox-Relocate-mlx-platform-driver.patch | | Downstream accepted | | | |0056-Documentation-ABI-Add-new-attribute-for-mlxreg-io-sy.patch | e7210563432a | Feature upstream | | | |0057-Documentation-ABI-Add-new-attribute-for-mlxreg-io-sy.patch | e7210563432a | Feature pending | | | -|0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch | 443a0a0f0cf | Feature upstream;skip[sonic] | | BF3 | -|0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch | d11f932808dc | Feature upstream;skip[sonic] | | BF3 | -|0063-gpio-mlxbf3-Add-gpio-driver-support.patch | cd33f216d241 | Feature upstream;skip[sonic] | | BF3 | -|0064-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch | 743d3336029f | Feature upstream;skip[sonic] | | BF3 | -|0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch | 95921151e043 | Downstream;skip[sonic] | | BF3 | -|0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch | cfd4ea4815d1 | Downstream;skip[sonic] | | BF3 | -|0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch | | Downstream;skip[sonic] | | BF3 | -|0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch | | Downstream;skip[sonic] | | BF3 | -|0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch | 7ad5e7a35c3f | Downstream;skip[sonic,cumulus] | v6.1.75 | BF3 v6.1.75 | -|0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch | 2321d69f92aa | Downstream;skip[sonic] | | BF3 | -|0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch | 20d03d4d9437 | Downstream;skip[sonic] | | BF3 | -|0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch | | Downstream;skip[sonic] | | BF3 | -|0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0080-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0081-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0082-UBUNTU-SAUCE-mlxbf-ptm-add-atx-debugfs-nodes.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch | | Downstream;skip[sonic,cumulus] | | BF3 | -|0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch | | Downstream;skip[sonic,cumulus] | | BF3 | +|0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch | 443a0a0f0cf4 | Feature upstream;skip[sonic,cumulus] | v6.1.92 | BF3 | +|0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch | d11f932808dc | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0063-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch | 743d3336029f | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0064-pinctrl-mlxbf3-Remove-gpio_disable_free.patch | 69657e60b8a7 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0065-gpio-mlxbf3-Add-gpio-driver-support.patch | cd33f216d241 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0066-gpio-mlxbf3-Support-add_pin_ranges.patch | 38a700efc510 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0067-gpio-mlxbf3-Fix-error-message.patch | | Downstream;skip[sonic,cumulus] | | BF3 | +|0068-mmc-sdhci-of-dwcmshc-enable-host-V4-support-for-Blue.patch | 95921151e043 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0069-mmc-sdhci-of-dwcmshc-add-the-missing-device-table-ID.patch | cfd4ea4815d1 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0070-mlxbf_gige-fix-receive-packet-race-condition.patch | ac5cbe931c43 | Feature upstream;skip[sonic,cumulus] | v6.1.75 | BF3 | +|0071-mlxbf_gige-Fix-intermittent-no-ip-issue.patch | 7ad5e7a35c3f | Feature upstream;skip[sonic,cumulus] | v6.1.75 | BF3 | +|0072-mlxbf_gige-Enable-the-GigE-port-in-mlxbf_gige_open.patch | 1b481cb53601 | Feature upstream;skip[sonic,cumulus] | v6.1.75 | BF3 | +|0073-mlxbf_gige-stop-PHY-during-open-error-paths.patch | 57beec623ac5 | Feature upstream;skip[sonic,cumulus] | v6.1.85 | BF3 | +|0074-mlxbf_gige-call-request_irq-after-NAPI-initialized.patch | 24444af5ddf7 | Feature upstream;skip[sonic,cumulus] | v6.1.85 | BF3 | +|0075-mlxbf_gige-stop-interface-during-shutdown.patch | 80247e0eca14 | Feature upstream;skip[sonic,cumulus] | v6.1.85 | BF3 | +|0076-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch | 2321d69f92aa | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0077-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch | 20d03d4d9437 | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0078-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch | cedd97737a1f | Feature upstream;skip[sonic,cumulus] | | BF3 | +|0079-UBUNTU-SAUCE-mlxbf_gige-add-RX_DMA-disable-to-NAPI-p.patch | | Downstream;skip[sonic,cumulus] | | BF3 | +|0080-mlxbf-bootctl-correctly-identify-secure-boot-with-de.patch | 646f1e9c1978 | Feature upstream;skip[sonic,cumulus] | v6.1.68 | BF3 | +|0081-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch | | Downstream;skip[sonic,cumulus] | | BF3 | +|0082-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch | | Downstream;skip[sonic,cumulus] | | BF3 | +|0083-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch | | Downstream;skip[sonic,cumulus] | | BF3 | |0085-hwmon-mlxreg-fan-Separate-methods-of-fan-setting-com.patch | | Bugfix pending | | | -|0086-gpio-mlxbf3-Fix-error-message.patch | | Downstream;skip[sonic] | | BF3 | |0087-platform-mellanox-indicate-deferred-I2C-bus-creation.patch | | Bugfix pending | | SN2201 | |0087-platform_data-mlxreg-Add-capability-bit-and-mask-fie.patch | | Downstream accepted | | | |0088-platform-mellanox-mlxreg-hotplug-Add-support-for-new.patch | | Downstream accepted | | | diff --git a/recipes-kernel/linux/linux-6.1/0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch b/recipes-kernel/linux/linux-6.1/0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch index ee2b41fb1..a929c648a 100644 --- a/recipes-kernel/linux/linux-6.1/0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch +++ b/recipes-kernel/linux/linux-6.1/0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch @@ -1,10 +1,8 @@ -From aa410417368e3141e96e5331c1353b0e9dcf60fa Mon Sep 17 00:00:00 2001 +From 443a0a0f0cf4f432c7af6654b7f2f920d411d379 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 19 Dec 2022 14:42:33 +0200 -Subject: [PATCH backport 6.1.42 61/85] pinctrl: Introduce struct pinfunction - and PINCTRL_PINFUNCTION() macro - -BugLink: https://bugs.launchpad.net/bugs/2012743 +Subject: [PATCH] pinctrl: Introduce struct pinfunction and + PINCTRL_PINFUNCTION() macro There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data @@ -14,17 +12,12 @@ for all pin control drivers. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Acked-by: Mika Westerberg -(cherry picked from commit 443a0a0f0cf4f432c7af6654b7f2f920d411d379) -Signed-off-by: Asmaa Mnebhi -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz --- include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h -index 487117ccb1bc..fb25085d0922 100644 +index a0d39b303431..4d252ea00ed1 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h @@ -206,6 +206,26 @@ extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, @@ -55,5 +48,5 @@ index 487117ccb1bc..fb25085d0922 100644 extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np); #else -- -2.20.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch b/recipes-kernel/linux/linux-6.1/0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch index 4836bc49a..3c1ffcef4 100644 --- a/recipes-kernel/linux/linux-6.1/0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch +++ b/recipes-kernel/linux/linux-6.1/0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch @@ -1,10 +1,7 @@ -From 1f79825ac209a5aac6e13c87903a6506a5b78565 Mon Sep 17 00:00:00 2001 +From d11f932808dc689717e409bbc81b5093e7902fc9 Mon Sep 17 00:00:00 2001 From: Asmaa Mnebhi Date: Wed, 15 Mar 2023 17:50:27 -0400 -Subject: [PATCH backport 6.1.42 62/85] pinctrl: mlxbf3: Add pinctrl driver - support - -BugLink: https://bugs.launchpad.net/bugs/2012743 +Subject: [PATCH] pinctrl: mlxbf3: Add pinctrl driver support NVIDIA BlueField-3 SoC has a few pins that can be used as GPIOs or take the default hardware functionality. Add a driver for @@ -14,11 +11,6 @@ Signed-off-by: Asmaa Mnebhi Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20230315215027.30685-3-asmaa@nvidia.com Signed-off-by: Linus Walleij -(cherry picked from commit d11f932808dc689717e409bbc81b5093e7902fc9 linux-next) -Signed-off-by: Asmaa Mnebhi -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/pinctrl/Kconfig | 13 ++ drivers/pinctrl/Makefile | 1 + @@ -27,10 +19,10 @@ Signed-off-by: Bartlomiej Zolnierkiewicz "); +MODULE_LICENSE("Dual BSD/GPL"); -- -2.20.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch b/recipes-kernel/linux/linux-6.1/0063-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch similarity index 86% rename from recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch rename to recipes-kernel/linux/linux-6.1/0063-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch index 388279b96..0fc4466f5 100644 --- a/recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch +++ b/recipes-kernel/linux/linux-6.1/0063-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch @@ -1,8 +1,8 @@ -From 00cba650c86f494b4a5905d89d304fef2380b0b7 Mon Sep 17 00:00:00 2001 +From 743d3336029ffe2bb38e982a3b572ced243c6d43 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 3 Apr 2023 20:45:01 -0400 -Subject: [PATCH backport 6.1.42 2/2] pinctrl: mlxbf3: set varaiable - mlxbf3_pmx_funcs storage-class-specifier to static +Subject: [PATCH] pinctrl: mlxbf3: set varaiable mlxbf3_pmx_funcs + storage-class-specifier to static smatch reports drivers/pinctrl/pinctrl-mlxbf3.c:162:20: warning: symbol @@ -31,5 +31,5 @@ index 3698f7bbd88d..d9944e6a0af9 100644 PINCTRL_PINFUNCTION("gpiofunc", mlxbf3_gpiofunc_group_names, 1), }; -- -2.25.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-Remove-gpio_disable_free.patch b/recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-Remove-gpio_disable_free.patch new file mode 100644 index 000000000..f5deec792 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0064-pinctrl-mlxbf3-Remove-gpio_disable_free.patch @@ -0,0 +1,65 @@ +From 69657e60b8a7faf83b583c658ec7ce1f5ece9eb3 Mon Sep 17 00:00:00 2001 +From: Asmaa Mnebhi +Date: Fri, 18 Aug 2023 12:43:13 -0400 +Subject: [PATCH] pinctrl: mlxbf3: Remove gpio_disable_free() + +Remove support for gpio_disable_free() because it is called when the libgpiod +command "gpioset" is invoked. This gives the GPIO control back to hardware which +cancels out the effort to set the GPIO value. + +Reminder of the code flow to change a GPIO value from software: +1) All GPIOs are controlled by hardware by default +2) To change the GPIO value, enable software control via a mux. +3) Once software has control over the GPIO pin, the gpio-mlxbf3 driver + will be able to change the direction and value of the GPIO. + +When the user runs "gpioset gpiochip0 0=0" for example, the gpio +pin value should change from 1 to 0. In this case, mlxbf3_gpio_request_enable() +is called via gpiochip_generic_request(). The latter switches GPIO control from +hardware to software. Then the GPIO value is changed from 1 to 0. However, +gpio_disable_free() is also called which changes control back to hardware +which changes the GPIO value back to 1. + +Fixes: d11f932808dc ("pinctrl: mlxbf3: Add pinctrl driver support") +Signed-off-by: Asmaa Mnebhi +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20230818164314.8505-2-asmaa@nvidia.com +Signed-off-by: Linus Walleij +--- + drivers/pinctrl/pinctrl-mlxbf3.c | 14 -------------- + 1 file changed, 14 deletions(-) + +diff --git a/drivers/pinctrl/pinctrl-mlxbf3.c b/drivers/pinctrl/pinctrl-mlxbf3.c +index 903606b64d2f..7d1713824a89 100644 +--- a/drivers/pinctrl/pinctrl-mlxbf3.c ++++ b/drivers/pinctrl/pinctrl-mlxbf3.c +@@ -223,26 +223,12 @@ static int mlxbf3_gpio_request_enable(struct pinctrl_dev *pctldev, + return 0; + } + +-static void mlxbf3_gpio_disable_free(struct pinctrl_dev *pctldev, +- struct pinctrl_gpio_range *range, +- unsigned int offset) +-{ +- struct mlxbf3_pinctrl *priv = pinctrl_dev_get_drvdata(pctldev); +- +- /* disable GPIO functionality by giving control back to hardware */ +- if (offset < MLXBF3_NGPIOS_GPIO0) +- writel(BIT(offset), priv->fw_ctrl_clr0); +- else +- writel(BIT(offset % MLXBF3_NGPIOS_GPIO0), priv->fw_ctrl_clr1); +-} +- + static const struct pinmux_ops mlxbf3_pmx_ops = { + .get_functions_count = mlxbf3_pmx_get_funcs_count, + .get_function_name = mlxbf3_pmx_get_func_name, + .get_function_groups = mlxbf3_pmx_get_groups, + .set_mux = mlxbf3_pmx_set, + .gpio_request_enable = mlxbf3_gpio_request_enable, +- .gpio_disable_free = mlxbf3_gpio_disable_free, + }; + + static struct pinctrl_desc mlxbf3_pin_desc = { +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0063-gpio-mlxbf3-Add-gpio-driver-support.patch b/recipes-kernel/linux/linux-6.1/0065-gpio-mlxbf3-Add-gpio-driver-support.patch similarity index 96% rename from recipes-kernel/linux/linux-6.1/0063-gpio-mlxbf3-Add-gpio-driver-support.patch rename to recipes-kernel/linux/linux-6.1/0065-gpio-mlxbf3-Add-gpio-driver-support.patch index e9b14960a..1f32b2739 100644 --- a/recipes-kernel/linux/linux-6.1/0063-gpio-mlxbf3-Add-gpio-driver-support.patch +++ b/recipes-kernel/linux/linux-6.1/0065-gpio-mlxbf3-Add-gpio-driver-support.patch @@ -1,7 +1,7 @@ -From 8623b9727f7dc08fef553dbdc2be96641929b7cc Mon Sep 17 00:00:00 2001 +From cd33f216d241520385a5166ae73a0771197a9f0b Mon Sep 17 00:00:00 2001 From: Asmaa Mnebhi Date: Wed, 15 Mar 2023 17:50:26 -0400 -Subject: [PATCH backport 6.1.42 1/1] gpio: mlxbf3: Add gpio driver support +Subject: [PATCH] gpio: mlxbf3: Add gpio driver support Add support for the BlueField-3 SoC GPIO driver. This driver configures and handles GPIO interrupts. It also enables a user @@ -20,10 +20,10 @@ Signed-off-by: Bartosz Golaszewski create mode 100644 drivers/gpio/gpio-mlxbf3.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig -index 3e8e5f4ffa59..aef128b3a1c2 100644 +index 3cb34896c26a..5e3a01f40c9b 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig -@@ -1532,6 +1532,19 @@ config GPIO_MLXBF2 +@@ -1599,6 +1599,19 @@ config GPIO_MLXBF2 help Say Y here if you want GPIO support on Mellanox BlueField 2 SoC. @@ -44,10 +44,10 @@ index 3e8e5f4ffa59..aef128b3a1c2 100644 tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" depends on X86 || COMPILE_TEST diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile -index 29e3beb6548c..c5e86fd24d2c 100644 +index 7843b16f5d59..c3ac51d47aa9 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile -@@ -98,6 +98,7 @@ obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o +@@ -104,6 +104,7 @@ obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o obj-$(CONFIG_GPIO_MLXBF2) += gpio-mlxbf2.o @@ -310,5 +310,5 @@ index 000000000000..e30cee108986 +MODULE_AUTHOR("Asmaa Mnebhi "); +MODULE_LICENSE("Dual BSD/GPL"); -- -2.25.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch b/recipes-kernel/linux/linux-6.1/0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch deleted file mode 100644 index fafb84df8..000000000 --- a/recipes-kernel/linux/linux-6.1/0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b7b422bbd95928b213444692d5b00ef081160c0b Mon Sep 17 00:00:00 2001 -From: Liming Sun -Date: Sat, 10 Dec 2022 13:55:54 -0500 -Subject: [PATCH backport 6.1.42 66/85] UBUNTU: SAUCE: sdhci-of-dwcmshc: Enable - host V4 support for BlueField-3 SoC - -BugLink: https://bugs.launchpad.net/bugs/1999309 - -This commit enables SDHCI Host V4 support on Bluefield-3 SoC to be -consistent with UEFI setting. - -Signed-off-by: Liming Sun -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -[bzolnier: use a short URL version for BugLink] -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/mmc/host/sdhci-of-dwcmshc.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c -index a7343d4bc50e..a1188508e75d 100644 ---- a/drivers/mmc/host/sdhci-of-dwcmshc.c -+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c -@@ -528,6 +528,12 @@ static int dwcmshc_probe(struct platform_device *pdev) - goto err_clk; - } - -+#ifdef CONFIG_ACPI -+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) { -+ sdhci_enable_v4_mode(host); -+ } -+#endif -+ - host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; - - err = sdhci_setup_host(host); --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0066-gpio-mlxbf3-Support-add_pin_ranges.patch b/recipes-kernel/linux/linux-6.1/0066-gpio-mlxbf3-Support-add_pin_ranges.patch new file mode 100644 index 000000000..f063cfd83 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0066-gpio-mlxbf3-Support-add_pin_ranges.patch @@ -0,0 +1,81 @@ +From 38a700efc51080c7184f71edbf5e49561da9754f Mon Sep 17 00:00:00 2001 +From: Asmaa Mnebhi +Date: Fri, 18 Aug 2023 12:43:14 -0400 +Subject: [PATCH] gpio: mlxbf3: Support add_pin_ranges() + +Support add_pin_ranges() so that pinctrl_gpio_request() can be called. +The GPIO value is not modified when the user runs the "gpioset" tool. +This is because when gpiochip_generic_request is invoked by the gpio-mlxbf3 +driver, "pin_ranges" is empty so it skips "pinctrl_gpio_request()". +pinctrl_gpio_request() is essential in the code flow because it changes the +mux value so that software has control over modifying the GPIO value. +Adding add_pin_ranges() creates a dependency on the pinctrl-mlxbf3.c driver. + +Fixes: cd33f216d24 ("gpio: mlxbf3: Add gpio driver support") +Signed-off-by: Asmaa Mnebhi +Reviewed-by: Andy Shevchenko +Reviewed-by: Linus Walleij +Signed-off-by: Bartosz Golaszewski +--- + drivers/gpio/gpio-mlxbf3.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/drivers/gpio/gpio-mlxbf3.c b/drivers/gpio/gpio-mlxbf3.c +index e30cee108986..0a5f241a8352 100644 +--- a/drivers/gpio/gpio-mlxbf3.c ++++ b/drivers/gpio/gpio-mlxbf3.c +@@ -19,6 +19,8 @@ + * gpio[1]: HOST_GPIO32->HOST_GPIO55 + */ + #define MLXBF3_GPIO_MAX_PINS_PER_BLOCK 32 ++#define MLXBF3_GPIO_MAX_PINS_BLOCK0 32 ++#define MLXBF3_GPIO_MAX_PINS_BLOCK1 24 + + /* + * fw_gpio[x] block registers and their offset +@@ -158,6 +160,26 @@ static const struct irq_chip gpio_mlxbf3_irqchip = { + GPIOCHIP_IRQ_RESOURCE_HELPERS, + }; + ++static int mlxbf3_gpio_add_pin_ranges(struct gpio_chip *chip) ++{ ++ unsigned int id; ++ ++ switch(chip->ngpio) { ++ case MLXBF3_GPIO_MAX_PINS_BLOCK0: ++ id = 0; ++ break; ++ case MLXBF3_GPIO_MAX_PINS_BLOCK1: ++ id = 1; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return gpiochip_add_pin_range(chip, "MLNXBF34:00", ++ chip->base, id * MLXBF3_GPIO_MAX_PINS_PER_BLOCK, ++ chip->ngpio); ++} ++ + static int mlxbf3_gpio_probe(struct platform_device *pdev) + { + struct device *dev = &pdev->dev; +@@ -197,6 +219,7 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev) + gc->request = gpiochip_generic_request; + gc->free = gpiochip_generic_free; + gc->owner = THIS_MODULE; ++ gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges; + + irq = platform_get_irq(pdev, 0); + if (irq >= 0) { +@@ -243,6 +266,7 @@ static struct platform_driver mlxbf3_gpio_driver = { + }; + module_platform_driver(mlxbf3_gpio_driver); + ++MODULE_SOFTDEP("pre: pinctrl-mlxbf3"); + MODULE_DESCRIPTION("NVIDIA BlueField-3 GPIO Driver"); + MODULE_AUTHOR("Asmaa Mnebhi "); + MODULE_LICENSE("Dual BSD/GPL"); +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch b/recipes-kernel/linux/linux-6.1/0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch deleted file mode 100644 index bfd038d7c..000000000 --- a/recipes-kernel/linux/linux-6.1/0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 07163b7fab5b23c01195a456d92e3dc9e73b538c Mon Sep 17 00:00:00 2001 -From: Liming Sun -Date: Fri, 3 Feb 2023 07:52:18 -0500 -Subject: [PATCH backport 6.1.42 67/85] UBUNTU: SAUCE: mmc: sdhci-of-dwcmshc: - add the missing device table IDs for acpi - -BugLink: https://bugs.launchpad.net/bugs/2004645 - -This commit adds the missing MODULE_DEVICE_TABLE for acpi, or else -it won't be loaded automatically when compiled as a kernel module. - -Signed-off-by: Liming Sun -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -[bzolnier: use a short URL version for BugLink] -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/mmc/host/sdhci-of-dwcmshc.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c -index a1188508e75d..7d657d29af21 100644 ---- a/drivers/mmc/host/sdhci-of-dwcmshc.c -+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c -@@ -446,6 +446,7 @@ static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = { - }, - {} - }; -+MODULE_DEVICE_TABLE(acpi, sdhci_dwcmshc_acpi_ids); - #endif - - static int dwcmshc_probe(struct platform_device *pdev) --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0086-gpio-mlxbf3-Fix-error-message.patch b/recipes-kernel/linux/linux-6.1/0067-gpio-mlxbf3-Fix-error-message.patch similarity index 87% rename from recipes-kernel/linux/linux-6.1/0086-gpio-mlxbf3-Fix-error-message.patch rename to recipes-kernel/linux/linux-6.1/0067-gpio-mlxbf3-Fix-error-message.patch index 6bbaceb3e..0fd759bb4 100644 --- a/recipes-kernel/linux/linux-6.1/0086-gpio-mlxbf3-Fix-error-message.patch +++ b/recipes-kernel/linux/linux-6.1/0067-gpio-mlxbf3-Fix-error-message.patch @@ -2,7 +2,6 @@ From d0a9112753248b67e8ad8c09e554866f1a74119c Mon Sep 17 00:00:00 2001 From: Felix Radensky Date: Mon, 16 Oct 2023 17:21:03 +0000 Subject: [PATCH] gpio: mlxbf3: Fix error message -X-NVConfidentiality: public Fix the following error message produced by gpio-mlxbf3 driver: @@ -20,12 +19,12 @@ Reviewed-by: Vadim Pasternak 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mlxbf3.c b/drivers/gpio/gpio-mlxbf3.c -index e30cee1..f40bab9 100644 +index 0a5f241a8..5fe57ae02 100644 --- a/drivers/gpio/gpio-mlxbf3.c +++ b/drivers/gpio/gpio-mlxbf3.c -@@ -198,7 +198,7 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev) - gc->free = gpiochip_generic_free; +@@ -221,7 +221,7 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev) gc->owner = THIS_MODULE; + gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges; - irq = platform_get_irq(pdev, 0); + irq = platform_get_irq_optional(pdev, 0); diff --git a/recipes-kernel/linux/linux-6.1/0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch b/recipes-kernel/linux/linux-6.1/0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch deleted file mode 100644 index 88d54dc70..000000000 --- a/recipes-kernel/linux/linux-6.1/0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch +++ /dev/null @@ -1,158 +0,0 @@ -From be8912e006b49c4f9febcd2556030876737e1b72 Mon Sep 17 00:00:00 2001 -From: Liming Sun -Date: Tue, 4 Apr 2023 19:30:00 -0400 -Subject: [PATCH backport 6.1.42 68/85] UBUNTU: SAUCE: mmc: sdhci-of-dwcmshc: - Add runtime PM operations for BlueField-3 - -BugLink: https://bugs.launchpad.net/bugs/2015307 - -This commit implements the runtime PM operations For BlueField-3 SoC -to disable eMMC card clock when idle. - -Reviewed-by: Khalil Blaiech -Signed-off-by: Liming Sun -Acked-by: Bartlomiej Zolnierkiewicz -Acked-by: Andrei Gherzan -[bzolnier: use a short URL version for BugLink] -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/mmc/host/sdhci-of-dwcmshc.c | 102 +++++++++++++++++++++++++++- - 1 file changed, 101 insertions(+), 1 deletion(-) - -diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c -index 7d657d29af21..32fd0668b427 100644 ---- a/drivers/mmc/host/sdhci-of-dwcmshc.c -+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - - #include "sdhci-pltfm.h" - -@@ -91,6 +92,21 @@ struct dwcmshc_priv { - void *priv; /* pointer to SoC private stuff */ - }; - -+/* Last jiffies when entering idle state */ -+static uint64_t idle_last_jiffies; -+ -+/* Total jiffies in idle state */ -+static uint64_t idle_total_jiffies; -+ -+/* Total idle time */ -+static int idle_time; -+module_param(idle_time, int, 0444); -+MODULE_PARM_DESC(idle_time, "idle time (seconds)"); -+ -+/* The current idle state */ -+static int idle_state; -+module_param(idle_state, int, 0444); -+MODULE_PARM_DESC(idle_state, "idle state (0: not idle, 1: idle)"); - /* - * If DMA addr spans 128MB boundary, we split the DMA transfer into two - * so that each DMA transfer doesn't exceed the boundary. -@@ -532,6 +548,7 @@ static int dwcmshc_probe(struct platform_device *pdev) - #ifdef CONFIG_ACPI - if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) { - sdhci_enable_v4_mode(host); -+ pm_runtime_enable(dev); - } - #endif - -@@ -635,7 +652,90 @@ static int dwcmshc_resume(struct device *dev) - } - #endif - --static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume); -+#ifdef CONFIG_PM -+ -+#ifdef CONFIG_ACPI -+static void dwcmshc_enable_card_clk(struct sdhci_host *host) -+{ -+ u16 ctrl; -+ -+ ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL); -+ ctrl |= SDHCI_CLOCK_CARD_EN; -+ sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL); -+} -+ -+static void dwcmshc_disable_card_clk(struct sdhci_host *host) -+{ -+ u16 ctrl; -+ -+ ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL); -+ ctrl &= ~SDHCI_CLOCK_CARD_EN; -+ sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL); -+} -+#endif -+ -+static int dwcmshc_runtime_suspend(struct device *dev) -+{ -+ struct sdhci_host *host = dev_get_drvdata(dev); -+ const struct sdhci_pltfm_data *pltfm_data; -+ int ret = 0; -+ -+ pltfm_data = device_get_match_data(dev); -+ if (!pltfm_data) -+ return -ENODEV; -+ -+#ifdef CONFIG_ACPI -+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) { -+ ret = sdhci_runtime_suspend_host(host); -+ if (!ret) { -+ dwcmshc_disable_card_clk(host); -+ -+ if (!idle_state) { -+ idle_state = 1; -+ idle_last_jiffies = jiffies; -+ } -+ } -+ } -+#endif -+ -+ return ret; -+} -+ -+static int dwcmshc_runtime_resume(struct device *dev) -+{ -+ struct sdhci_host *host = dev_get_drvdata(dev); -+ const struct sdhci_pltfm_data *pltfm_data; -+ int ret = 0; -+ -+ pltfm_data = device_get_match_data(dev); -+ if (!pltfm_data) -+ return -ENODEV; -+ -+#ifdef CONFIG_ACPI -+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) { -+ dwcmshc_enable_card_clk(host); -+ -+ if (idle_state) { -+ idle_state = 0; -+ idle_total_jiffies = jiffies - idle_last_jiffies; -+ idle_time += jiffies_to_msecs( -+ idle_total_jiffies) / 1000; -+ } -+ -+ ret = sdhci_runtime_resume_host(host, 0); -+ } -+#endif -+ -+ return ret; -+} -+ -+#endif -+ -+static const struct dev_pm_ops dwcmshc_pmops = { -+ SET_SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume) -+ SET_RUNTIME_PM_OPS(dwcmshc_runtime_suspend, -+ dwcmshc_runtime_resume, NULL) -+}; - - static struct platform_driver sdhci_dwcmshc_driver = { - .driver = { --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0068-mmc-sdhci-of-dwcmshc-enable-host-V4-support-for-Blue.patch b/recipes-kernel/linux/linux-6.1/0068-mmc-sdhci-of-dwcmshc-enable-host-V4-support-for-Blue.patch new file mode 100644 index 000000000..d2444cd89 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0068-mmc-sdhci-of-dwcmshc-enable-host-V4-support-for-Blue.patch @@ -0,0 +1,37 @@ +From 95921151e04335e9e2ddf4f294405e64be4ea947 Mon Sep 17 00:00:00 2001 +From: Liming Sun +Date: Wed, 11 Jan 2023 13:14:58 -0500 +Subject: [PATCH] mmc: sdhci-of-dwcmshc: enable host V4 support for BlueField-3 + SoC + +This commit enables SDHCI Host V4 support on Bluefield-3 SoC to be +consistent with the default setting in firmware(UEFI). + +Reviewed-by: David Woods +Signed-off-by: Liming Sun +Acked-by: Adrian Hunter +Link: https://lore.kernel.org/r/990885f566c32ac8e6888ad6b434fb70d1a5d7af.1673460632.git.limings@nvidia.com +Signed-off-by: Ulf Hansson +--- + drivers/mmc/host/sdhci-of-dwcmshc.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c +index a7343d4bc50e..49338670c89f 100644 +--- a/drivers/mmc/host/sdhci-of-dwcmshc.c ++++ b/drivers/mmc/host/sdhci-of-dwcmshc.c +@@ -528,6 +528,11 @@ static int dwcmshc_probe(struct platform_device *pdev) + goto err_clk; + } + ++#ifdef CONFIG_ACPI ++ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) ++ sdhci_enable_v4_mode(host); ++#endif ++ + host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; + + err = sdhci_setup_host(host); +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch b/recipes-kernel/linux/linux-6.1/0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch deleted file mode 100644 index add9431ad..000000000 --- a/recipes-kernel/linux/linux-6.1/0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 8c4980bc00f7be2d1172f047e148ecb07c43d955 Mon Sep 17 00:00:00 2001 -From: David Thompson -Date: Thu, 14 Jul 2022 17:47:18 -0400 -Subject: [PATCH backport 6.1.42 69/85] UBUNTU: SAUCE: mlxbf_gige: add ethtool - mlxbf_gige_set_ringparam - -This patch adds the "set_ringparam" callback, to be used by -ethtool when changing the size of the mlxbf_gige driver rings. - -BugLink: https://launchpad.net/bugs/1981766 - -Change-Id: I0198f6fbf6b8ea13bd34ed152e13298265138c76 -Signed-off-by: David Thompson -Signed-off-by: Asmaa Mnebhi -Signed-off-by: Ike Panhc ---- - .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c | 40 +++++++++++++++++++ - 1 file changed, 40 insertions(+) - -diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c -index 41ebef25a930..4becb39b5664 100644 ---- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c -+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c -@@ -45,6 +45,45 @@ mlxbf_gige_get_ringparam(struct net_device *netdev, - ering->tx_pending = priv->tx_q_entries; - } - -+static int mlxbf_gige_set_ringparam(struct net_device *netdev, -+ struct ethtool_ringparam *ering, -+ struct kernel_ethtool_ringparam *kernel_ring, -+ struct netlink_ext_ack *extack) -+{ -+ const struct net_device_ops *ops = netdev->netdev_ops; -+ struct mlxbf_gige *priv = netdev_priv(netdev); -+ int new_rx_q_entries, new_tx_q_entries; -+ -+ /* Device does not have separate queues for small/large frames */ -+ if (ering->rx_mini_pending || ering->rx_jumbo_pending) -+ return -EINVAL; -+ -+ /* Round up to supported values */ -+ new_rx_q_entries = roundup_pow_of_two(ering->rx_pending); -+ new_tx_q_entries = roundup_pow_of_two(ering->tx_pending); -+ -+ /* Check against min values, core checks against max values */ -+ if (new_tx_q_entries < MLXBF_GIGE_MIN_TXQ_SZ || -+ new_rx_q_entries < MLXBF_GIGE_MIN_RXQ_SZ) -+ return -EINVAL; -+ -+ /* If queue sizes did not change, exit now */ -+ if (new_rx_q_entries == priv->rx_q_entries && -+ new_tx_q_entries == priv->tx_q_entries) -+ return 0; -+ -+ if (netif_running(netdev)) -+ ops->ndo_stop(netdev); -+ -+ priv->rx_q_entries = new_rx_q_entries; -+ priv->tx_q_entries = new_tx_q_entries; -+ -+ if (netif_running(netdev)) -+ ops->ndo_open(netdev); -+ -+ return 0; -+} -+ - static const struct { - const char string[ETH_GSTRING_LEN]; - } mlxbf_gige_ethtool_stats_keys[] = { -@@ -127,6 +166,7 @@ static void mlxbf_gige_get_pauseparam(struct net_device *netdev, - const struct ethtool_ops mlxbf_gige_ethtool_ops = { - .get_link = ethtool_op_get_link, - .get_ringparam = mlxbf_gige_get_ringparam, -+ .set_ringparam = mlxbf_gige_set_ringparam, - .get_regs_len = mlxbf_gige_get_regs_len, - .get_regs = mlxbf_gige_get_regs, - .get_strings = mlxbf_gige_get_strings, --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0069-mmc-sdhci-of-dwcmshc-add-the-missing-device-table-ID.patch b/recipes-kernel/linux/linux-6.1/0069-mmc-sdhci-of-dwcmshc-add-the-missing-device-table-ID.patch new file mode 100644 index 000000000..4cc034e83 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0069-mmc-sdhci-of-dwcmshc-add-the-missing-device-table-ID.patch @@ -0,0 +1,32 @@ +From cfd4ea4815d16f7426723a5cb80ee5db811ea1f2 Mon Sep 17 00:00:00 2001 +From: Liming Sun +Date: Thu, 2 Feb 2023 10:29:15 -0500 +Subject: [PATCH] mmc: sdhci-of-dwcmshc: add the missing device table IDs for + acpi + +This commit adds the missing MODULE_DEVICE_TABLE for acpi, or else +it won't be loaded automatically when compiled as a kernel module. + +Reviewed-by: David Thompson +Signed-off-by: Liming Sun +Link: https://lore.kernel.org/r/f57ad0f8fdf663465bca74467c344dfa305a3199.1675305696.git.limings@nvidia.com +Signed-off-by: Ulf Hansson +--- + drivers/mmc/host/sdhci-of-dwcmshc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c +index 46b1ce7fabdc..d1490469184b 100644 +--- a/drivers/mmc/host/sdhci-of-dwcmshc.c ++++ b/drivers/mmc/host/sdhci-of-dwcmshc.c +@@ -451,6 +451,7 @@ static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = { + }, + {} + }; ++MODULE_DEVICE_TABLE(acpi, sdhci_dwcmshc_acpi_ids); + #endif + + static int dwcmshc_probe(struct platform_device *pdev) +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch b/recipes-kernel/linux/linux-6.1/0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch deleted file mode 100644 index 6550158ce..000000000 --- a/recipes-kernel/linux/linux-6.1/0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 8864f5ec2e1c0e1271a202859325900bd6727139 Mon Sep 17 00:00:00 2001 -From: David Thompson -Date: Wed, 20 Jul 2022 17:50:36 -0400 -Subject: [PATCH backport 6.1.42 70/85] UBUNTU: SAUCE: Fix OOB handling RX - packets in heavy traffic - -BugLink: https://bugs.launchpad.net/bugs/1982424 - -This is reproducible on systems which already have heavy background -traffic. On top of that, the user issues one of the 2 docker pulls below: -docker pull nvcr.io/ea-doca-hbn/hbn/hbn:latest -OR -docker pull gitlab-master.nvidia.com:5005/dl/dgx/tritonserver:22.02-py3-qa - -The second one is a very large container (17GB) - -When they run docker pull, the OOB interface stops being pingable, -the docker pull is interrupted for a very long time (>3mn) or -times out. - -The main reason for the above is because RX PI = RX CI. I have verified that -by reading RX_CQE_PACKET_CI and RX_WQE_PI. This means the WQEs are full and -HW has nowhere else to put the RX packets. - -I believe there is a race condition after SW receives a RX interrupt, -and the interrupt is disabled. I believe HW still tries to add RX -packets to the RX WQEs. So we need to stop the RX traffic by disabling -the DMA. Also, move reading the RX CI before writing the increased value -of RX PI to MLXBF_GIGE_RX_WQE_PI. Normally RX PI should always be > RX CI. -I suspect that when entering mlxbf_gige_rx_packet, for example we have: -MLXBF_GIGE_RX_WQE_PI = 128 -RX_CQE_PACKET_CI = 128 -(128 being the max size of the WQE) - -Then this code will make MLXBF_GIGE_RX_WQE_PI = 129: -rx_pi++; -/* Ensure completion of all writes before notifying HW of replenish */ -wmb(); -writeq(rx_pi, priv->base + MLXBF_GIGE_RX_WQE_PI); - -which means HW has one more slot to populate and in that time span, the HW -populates that WQE and increases the RX_CQE_PACKET_CI = 129. - -Then this code is subject to a race condition: - -rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); -rx_ci_rem = rx_ci % priv->rx_q_entries; -return rx_pi_rem != rx_ci_rem; - -because rx_pi_rem will be equal to rx_ci_rem. -so remaining_pkts will be 0 and we will exit mlxbf_gige_poll - -Change-Id: I25a816b9182471643db95b05c803b9f6349bcc87 -Signed-off-by: David Thompson -Signed-off-by: Asmaa Mnebhi -Signed-off-by: Ike Panhc ---- - .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 13 +++++++++++-- - 1 file changed, 11 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c -index 0d5a41a2ae01..dc05ab5b042a 100644 ---- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c -+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c -@@ -267,6 +267,9 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts) - priv->stats.rx_truncate_errors++; - } - -+ rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); -+ rx_ci_rem = rx_ci % priv->rx_q_entries; -+ - /* Let hardware know we've replenished one buffer */ - rx_pi++; - -@@ -279,8 +282,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts) - rx_pi_rem = rx_pi % priv->rx_q_entries; - if (rx_pi_rem == 0) - priv->valid_polarity ^= 1; -- rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); -- rx_ci_rem = rx_ci % priv->rx_q_entries; - - if (skb) - netif_receive_skb(skb); -@@ -300,6 +301,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) - - mlxbf_gige_handle_tx_complete(priv); - -+ data = readq(priv->base + MLXBF_GIGE_RX_DMA); -+ data &= ~MLXBF_GIGE_RX_DMA_EN; -+ writeq(data, priv->base + MLXBF_GIGE_RX_DMA); -+ - do { - remaining_pkts = mlxbf_gige_rx_packet(priv, &work_done); - } while (remaining_pkts && work_done < budget); -@@ -315,6 +320,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) - data = readq(priv->base + MLXBF_GIGE_INT_MASK); - data &= ~MLXBF_GIGE_INT_MASK_RX_RECEIVE_PACKET; - writeq(data, priv->base + MLXBF_GIGE_INT_MASK); -+ -+ data = readq(priv->base + MLXBF_GIGE_RX_DMA); -+ data |= MLXBF_GIGE_RX_DMA_EN; -+ writeq(data, priv->base + MLXBF_GIGE_RX_DMA); - } - - return work_done; --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0070-mlxbf_gige-fix-receive-packet-race-condition.patch b/recipes-kernel/linux/linux-6.1/0070-mlxbf_gige-fix-receive-packet-race-condition.patch new file mode 100644 index 000000000..d99b4ad08 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0070-mlxbf_gige-fix-receive-packet-race-condition.patch @@ -0,0 +1,61 @@ +From ac5cbe931c4355a8bd1628e2c8070efddb53e031 Mon Sep 17 00:00:00 2001 +From: David Thompson +Date: Wed, 20 Dec 2023 18:47:39 -0500 +Subject: [PATCH] mlxbf_gige: fix receive packet race condition + +[ Upstream commit dcea1bd45e6d111cc8fc1aaefa7e31694089bda3 ] + +Under heavy traffic, the BlueField Gigabit interface can +become unresponsive. This is due to a possible race condition +in the mlxbf_gige_rx_packet function, where the function exits +with producer and consumer indices equal but there are remaining +packet(s) to be processed. In order to prevent this situation, +read receive consumer index *before* the HW replenish so that +the mlxbf_gige_rx_packet function returns an accurate return +value even if a packet is received into just-replenished buffer +prior to exiting this routine. If the just-replenished buffer +is received and occupies the last RX ring entry, the interface +would not recover and instead would encounter RX packet drops +related to internal buffer shortages since the driver RX logic +is not being triggered to drain the RX ring. This patch will +address and prevent this "ring full" condition. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Reviewed-by: Asmaa Mnebhi +Signed-off-by: David Thompson +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +index 0d5a41a2ae01..227d01cace3f 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +@@ -267,6 +267,13 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts) + priv->stats.rx_truncate_errors++; + } + ++ /* Read receive consumer index before replenish so that this routine ++ * returns accurate return value even if packet is received into ++ * just-replenished buffer prior to exiting this routine. ++ */ ++ rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); ++ rx_ci_rem = rx_ci % priv->rx_q_entries; ++ + /* Let hardware know we've replenished one buffer */ + rx_pi++; + +@@ -279,8 +286,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts) + rx_pi_rem = rx_pi % priv->rx_q_entries; + if (rx_pi_rem == 0) + priv->valid_polarity ^= 1; +- rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); +- rx_ci_rem = rx_ci % priv->rx_q_entries; + + if (skb) + netif_receive_skb(skb); +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch b/recipes-kernel/linux/linux-6.1/0071-mlxbf_gige-Fix-intermittent-no-ip-issue.patch similarity index 67% rename from recipes-kernel/linux/linux-6.1/0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch rename to recipes-kernel/linux/linux-6.1/0071-mlxbf_gige-Fix-intermittent-no-ip-issue.patch index f8e11a704..2c3ea1080 100644 --- a/recipes-kernel/linux/linux-6.1/0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch +++ b/recipes-kernel/linux/linux-6.1/0071-mlxbf_gige-Fix-intermittent-no-ip-issue.patch @@ -1,21 +1,26 @@ -From 7a9c30f4e3f19eb533acce3d3c63de87d18bac1d Mon Sep 17 00:00:00 2001 +From 7ad5e7a35c3f55738fec0dd2b64bbefdfb992045 Mon Sep 17 00:00:00 2001 From: Asmaa Mnebhi -Date: Tue, 28 Feb 2023 18:03:12 -0500 -Subject: [PATCH backport 6.1.42 71/85] UBUNTU: SAUCE: mlxbf-gige: Fix - intermittent no ip issue +Date: Fri, 5 Jan 2024 10:59:46 -0500 +Subject: [PATCH] mlxbf_gige: Fix intermittent no ip issue -BugLink: https://bugs.launchpad.net/bugs/2008833 +[ Upstream commit ef210ef85d5cb543ce34a57803ed856d0c8c08c2 ] -During the reboot test, the OOB might not get an ip assigned. -This is due to a race condition between phy_startcall and the -RX DMA being enabled and depends on the amount of background -traffic received by the OOB. Enable the RX DMA after teh phy -is started. +Although the link is up, there is no ip assigned on setups with high background +traffic. Nothing is transmitted nor received. The RX error count keeps on +increasing. After several minutes, the RX error count stagnates and the +GigE interface finally gets an ip. +The issue is that mlxbf_gige_rx_init() is called before phy_start(). +As soon as the RX DMA is enabled in mlxbf_gige_rx_init(), the RX CI reaches the max +of 128, and becomes equal to RX PI. RX CI doesn't decrease since the code hasn't +ran phy_start yet. +Bring the PHY up before starting the RX. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Reviewed-by: David Thompson Signed-off-by: Asmaa Mnebhi -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 14 +++++++------- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 6 +++--- @@ -57,7 +62,7 @@ index 2292d63a279c..eafc0d3313fd 100644 free_irqs: mlxbf_gige_free_irqs(priv); diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c -index dc05ab5b042a..b9cf0a3c8b0f 100644 +index 227d01cace3f..699984358493 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c @@ -142,6 +142,9 @@ int mlxbf_gige_rx_init(struct mlxbf_gige *priv) @@ -81,5 +86,5 @@ index dc05ab5b042a..b9cf0a3c8b0f 100644 free_wqe_and_skb: -- -2.20.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-Enable-the-GigE-port-in-mlxbf_gige_open.patch b/recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-Enable-the-GigE-port-in-mlxbf_gige_open.patch new file mode 100644 index 000000000..142e63434 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-Enable-the-GigE-port-in-mlxbf_gige_open.patch @@ -0,0 +1,66 @@ +From 1b481cb53601856027ce1cc30b3874778d318f14 Mon Sep 17 00:00:00 2001 +From: Asmaa Mnebhi +Date: Fri, 5 Jan 2024 11:00:14 -0500 +Subject: [PATCH] mlxbf_gige: Enable the GigE port in mlxbf_gige_open + +[ Upstream commit a460f4a684511e007bbf1700758a41f05d9981e6 ] + +At the moment, the GigE port is enabled in the mlxbf_gige_probe +function. If the mlxbf_gige_open is not executed, this could cause +pause frames to increase in the case where there is high backgroud +traffic. This results in clogging the port. +So move enabling the OOB port to mlxbf_gige_open. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Reviewed-by: David Thompson +Signed-off-by: Asmaa Mnebhi +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +index eafc0d3313fd..83c4659390fd 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +@@ -130,9 +130,15 @@ static int mlxbf_gige_open(struct net_device *netdev) + { + struct mlxbf_gige *priv = netdev_priv(netdev); + struct phy_device *phydev = netdev->phydev; ++ u64 control; + u64 int_en; + int err; + ++ /* Perform general init of GigE block */ ++ control = readq(priv->base + MLXBF_GIGE_CONTROL); ++ control |= MLXBF_GIGE_CONTROL_PORT_EN; ++ writeq(control, priv->base + MLXBF_GIGE_CONTROL); ++ + err = mlxbf_gige_request_irqs(priv); + if (err) + return err; +@@ -279,7 +285,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev) + void __iomem *plu_base; + void __iomem *base; + int addr, phy_irq; +- u64 control; + int err; + + base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MAC); +@@ -294,11 +299,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev) + if (IS_ERR(plu_base)) + return PTR_ERR(plu_base); + +- /* Perform general init of GigE block */ +- control = readq(base + MLXBF_GIGE_CONTROL); +- control |= MLXBF_GIGE_CONTROL_PORT_EN; +- writeq(control, base + MLXBF_GIGE_CONTROL); +- + netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv)); + if (!netdev) + return -ENOMEM; +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-stop-PHY-during-open-error-paths.patch b/recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-stop-PHY-during-open-error-paths.patch new file mode 100644 index 000000000..2af2b2651 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-stop-PHY-during-open-error-paths.patch @@ -0,0 +1,48 @@ +From 57beec623ac5314c5e0e957624c7517d9efdfa59 Mon Sep 17 00:00:00 2001 +From: David Thompson +Date: Wed, 20 Mar 2024 15:31:17 -0400 +Subject: [PATCH] mlxbf_gige: stop PHY during open() error paths + +[ Upstream commit d6c30c5a168f8586b8bcc0d8e42e2456eb05209b ] + +The mlxbf_gige_open() routine starts the PHY as part of normal +initialization. The mlxbf_gige_open() routine must stop the +PHY during its error paths. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Signed-off-by: David Thompson +Reviewed-by: Asmaa Mnebhi +Reviewed-by: Andrew Lunn +Reviewed-by: Jiri Pirko +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +index 83c4659390fd..113e3d9d3353 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +@@ -157,7 +157,7 @@ static int mlxbf_gige_open(struct net_device *netdev) + + err = mlxbf_gige_tx_init(priv); + if (err) +- goto free_irqs; ++ goto phy_deinit; + err = mlxbf_gige_rx_init(priv); + if (err) + goto tx_deinit; +@@ -185,6 +185,9 @@ static int mlxbf_gige_open(struct net_device *netdev) + tx_deinit: + mlxbf_gige_tx_deinit(priv); + ++phy_deinit: ++ phy_stop(phydev); ++ + free_irqs: + mlxbf_gige_free_irqs(priv); + return err; +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-call-request_irq-after-NAPI-initialized.patch b/recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-call-request_irq-after-NAPI-initialized.patch new file mode 100644 index 000000000..8f2421f94 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-call-request_irq-after-NAPI-initialized.patch @@ -0,0 +1,166 @@ +From 24444af5ddf729376b90db0f135fa19973cb5dab Mon Sep 17 00:00:00 2001 +From: David Thompson +Date: Mon, 25 Mar 2024 14:36:27 -0400 +Subject: [PATCH] mlxbf_gige: call request_irq() after NAPI initialized + +[ Upstream commit f7442a634ac06b953fc1f7418f307b25acd4cfbc ] + +The mlxbf_gige driver encounters a NULL pointer exception in +mlxbf_gige_open() when kdump is enabled. The sequence to reproduce +the exception is as follows: +a) enable kdump +b) trigger kdump via "echo c > /proc/sysrq-trigger" +c) kdump kernel executes +d) kdump kernel loads mlxbf_gige module +e) the mlxbf_gige module runs its open() as the + the "oob_net0" interface is brought up +f) mlxbf_gige module will experience an exception + during its open(), something like: + + Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 + Mem abort info: + ESR = 0x0000000086000004 + EC = 0x21: IABT (current EL), IL = 32 bits + SET = 0, FnV = 0 + EA = 0, S1PTW = 0 + FSC = 0x04: level 0 translation fault + user pgtable: 4k pages, 48-bit VAs, pgdp=00000000e29a4000 + [0000000000000000] pgd=0000000000000000, p4d=0000000000000000 + Internal error: Oops: 0000000086000004 [#1] SMP + CPU: 0 PID: 812 Comm: NetworkManager Tainted: G OE 5.15.0-1035-bluefield #37-Ubuntu + Hardware name: https://www.mellanox.com BlueField-3 SmartNIC Main Card/BlueField-3 SmartNIC Main Card, BIOS 4.6.0.13024 Jan 19 2024 + pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) + pc : 0x0 + lr : __napi_poll+0x40/0x230 + sp : ffff800008003e00 + x29: ffff800008003e00 x28: 0000000000000000 x27: 00000000ffffffff + x26: ffff000066027238 x25: ffff00007cedec00 x24: ffff800008003ec8 + x23: 000000000000012c x22: ffff800008003eb7 x21: 0000000000000000 + x20: 0000000000000001 x19: ffff000066027238 x18: 0000000000000000 + x17: ffff578fcb450000 x16: ffffa870b083c7c0 x15: 0000aaab010441d0 + x14: 0000000000000001 x13: 00726f7272655f65 x12: 6769675f6662786c + x11: 0000000000000000 x10: 0000000000000000 x9 : ffffa870b0842398 + x8 : 0000000000000004 x7 : fe5a48b9069706ea x6 : 17fdb11fc84ae0d2 + x5 : d94a82549d594f35 x4 : 0000000000000000 x3 : 0000000000400100 + x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000066027238 + Call trace: + 0x0 + net_rx_action+0x178/0x360 + __do_softirq+0x15c/0x428 + __irq_exit_rcu+0xac/0xec + irq_exit+0x18/0x2c + handle_domain_irq+0x6c/0xa0 + gic_handle_irq+0xec/0x1b0 + call_on_irq_stack+0x20/0x2c + do_interrupt_handler+0x5c/0x70 + el1_interrupt+0x30/0x50 + el1h_64_irq_handler+0x18/0x2c + el1h_64_irq+0x7c/0x80 + __setup_irq+0x4c0/0x950 + request_threaded_irq+0xf4/0x1bc + mlxbf_gige_request_irqs+0x68/0x110 [mlxbf_gige] + mlxbf_gige_open+0x5c/0x170 [mlxbf_gige] + __dev_open+0x100/0x220 + __dev_change_flags+0x16c/0x1f0 + dev_change_flags+0x2c/0x70 + do_setlink+0x220/0xa40 + __rtnl_newlink+0x56c/0x8a0 + rtnl_newlink+0x58/0x84 + rtnetlink_rcv_msg+0x138/0x3c4 + netlink_rcv_skb+0x64/0x130 + rtnetlink_rcv+0x20/0x30 + netlink_unicast+0x2ec/0x360 + netlink_sendmsg+0x278/0x490 + __sock_sendmsg+0x5c/0x6c + ____sys_sendmsg+0x290/0x2d4 + ___sys_sendmsg+0x84/0xd0 + __sys_sendmsg+0x70/0xd0 + __arm64_sys_sendmsg+0x2c/0x40 + invoke_syscall+0x78/0x100 + el0_svc_common.constprop.0+0x54/0x184 + do_el0_svc+0x30/0xac + el0_svc+0x48/0x160 + el0t_64_sync_handler+0xa4/0x12c + el0t_64_sync+0x1a4/0x1a8 + Code: bad PC value + ---[ end trace 7d1c3f3bf9d81885 ]--- + Kernel panic - not syncing: Oops: Fatal exception in interrupt + Kernel Offset: 0x2870a7a00000 from 0xffff800008000000 + PHYS_OFFSET: 0x80000000 + CPU features: 0x0,000005c1,a3332a5a + Memory Limit: none + ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]--- + +The exception happens because there is a pending RX interrupt before the +call to request_irq(RX IRQ) executes. Then, the RX IRQ handler fires +immediately after this request_irq() completes. The RX IRQ handler runs +"napi_schedule()" before NAPI is fully initialized via "netif_napi_add()" +and "napi_enable()", both which happen later in the open() logic. + +The logic in mlxbf_gige_open() must fully initialize NAPI before any calls +to request_irq() execute. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Signed-off-by: David Thompson +Reviewed-by: Asmaa Mnebhi +Link: https://lore.kernel.org/r/20240325183627.7641-1-davthompson@nvidia.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +index 113e3d9d3353..65e92541db6e 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +@@ -139,13 +139,10 @@ static int mlxbf_gige_open(struct net_device *netdev) + control |= MLXBF_GIGE_CONTROL_PORT_EN; + writeq(control, priv->base + MLXBF_GIGE_CONTROL); + +- err = mlxbf_gige_request_irqs(priv); +- if (err) +- return err; + mlxbf_gige_cache_stats(priv); + err = mlxbf_gige_clean_port(priv); + if (err) +- goto free_irqs; ++ return err; + + /* Clear driver's valid_polarity to match hardware, + * since the above call to clean_port() resets the +@@ -166,6 +163,10 @@ static int mlxbf_gige_open(struct net_device *netdev) + napi_enable(&priv->napi); + netif_start_queue(netdev); + ++ err = mlxbf_gige_request_irqs(priv); ++ if (err) ++ goto napi_deinit; ++ + /* Set bits in INT_EN that we care about */ + int_en = MLXBF_GIGE_INT_EN_HW_ACCESS_ERROR | + MLXBF_GIGE_INT_EN_TX_CHECKSUM_INPUTS | +@@ -182,14 +183,17 @@ static int mlxbf_gige_open(struct net_device *netdev) + + return 0; + ++napi_deinit: ++ netif_stop_queue(netdev); ++ napi_disable(&priv->napi); ++ netif_napi_del(&priv->napi); ++ mlxbf_gige_rx_deinit(priv); ++ + tx_deinit: + mlxbf_gige_tx_deinit(priv); + + phy_deinit: + phy_stop(phydev); +- +-free_irqs: +- mlxbf_gige_free_irqs(priv); + return err; + } + +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch b/recipes-kernel/linux/linux-6.1/0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch deleted file mode 100644 index a79977d3c..000000000 --- a/recipes-kernel/linux/linux-6.1/0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 7124b7b040a0cda35c09be51ac40e8e52026ec2d Mon Sep 17 00:00:00 2001 -From: Asmaa Mnebhi -Date: Fri, 2 Jun 2023 13:04:25 -0400 -Subject: [PATCH backport 6.1.42 75/85] UBUNTU: SAUCE: mlxbf-gige: Fix kernel - panic at shutdown - -BugLink: https://bugs.launchpad.net/bugs/2022370 - -We occasionally see a race condition (once every 350 reboots) where napi is still -running (mlxbf_gige_poll) while a shutdown has been initiated through "reboot". -Since mlxbf_gige_poll is still running, it tries to access a NULL pointer and as -a result causes a kernel panic. - -The fix is to explicitly disable napi and dequeue it during shutdown. -mlxbf_gige_remove already calls: -unregister_netdev->unregister_netdevice->unregister_netdev_queue-> -rollback_registered->rollback_registered_many->dev_close_many-> -__dev_close_many->ndo_stop->mlxbf_gige_stop which stops napi - -So use mlxbf_gige_remove in place of the existing shutdown logic. - -Signed-off-by: Asmaa Mnebhi -Acked-by: Bartlomiej Zolnierkiewicz -Acked-by: Tim Gardner -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c -index 0af086703bcd..fe35b5a24219 100644 ---- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c -+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c -@@ -485,10 +485,7 @@ static int mlxbf_gige_remove(struct platform_device *pdev) - - static void mlxbf_gige_shutdown(struct platform_device *pdev) - { -- struct mlxbf_gige *priv = platform_get_drvdata(pdev); -- -- writeq(0, priv->base + MLXBF_GIGE_INT_EN); -- mlxbf_gige_clean_port(priv); -+ mlxbf_gige_remove(pdev); - } - - static const struct acpi_device_id __maybe_unused mlxbf_gige_acpi_match[] = { --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0075-mlxbf_gige-stop-interface-during-shutdown.patch b/recipes-kernel/linux/linux-6.1/0075-mlxbf_gige-stop-interface-during-shutdown.patch new file mode 100644 index 000000000..6bca29d60 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0075-mlxbf_gige-stop-interface-during-shutdown.patch @@ -0,0 +1,112 @@ +From 80247e0eca14ff177d565f58ecd3010f6b7910a4 Mon Sep 17 00:00:00 2001 +From: David Thompson +Date: Mon, 25 Mar 2024 17:09:29 -0400 +Subject: [PATCH] mlxbf_gige: stop interface during shutdown + +commit 09ba28e1cd3cf715daab1fca6e1623e22fd754a6 upstream. + +The mlxbf_gige driver intermittantly encounters a NULL pointer +exception while the system is shutting down via "reboot" command. +The mlxbf_driver will experience an exception right after executing +its shutdown() method. One example of this exception is: + +Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070 +Mem abort info: + ESR = 0x0000000096000004 + EC = 0x25: DABT (current EL), IL = 32 bits + SET = 0, FnV = 0 + EA = 0, S1PTW = 0 + FSC = 0x04: level 0 translation fault +Data abort info: + ISV = 0, ISS = 0x00000004 + CM = 0, WnR = 0 +user pgtable: 4k pages, 48-bit VAs, pgdp=000000011d373000 +[0000000000000070] pgd=0000000000000000, p4d=0000000000000000 +Internal error: Oops: 96000004 [#1] SMP +CPU: 0 PID: 13 Comm: ksoftirqd/0 Tainted: G S OE 5.15.0-bf.6.gef6992a #1 +Hardware name: https://www.mellanox.com BlueField SoC/BlueField SoC, BIOS 4.0.2.12669 Apr 21 2023 +pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) +pc : mlxbf_gige_handle_tx_complete+0xc8/0x170 [mlxbf_gige] +lr : mlxbf_gige_poll+0x54/0x160 [mlxbf_gige] +sp : ffff8000080d3c10 +x29: ffff8000080d3c10 x28: ffffcce72cbb7000 x27: ffff8000080d3d58 +x26: ffff0000814e7340 x25: ffff331cd1a05000 x24: ffffcce72c4ea008 +x23: ffff0000814e4b40 x22: ffff0000814e4d10 x21: ffff0000814e4128 +x20: 0000000000000000 x19: ffff0000814e4a80 x18: ffffffffffffffff +x17: 000000000000001c x16: ffffcce72b4553f4 x15: ffff80008805b8a7 +x14: 0000000000000000 x13: 0000000000000030 x12: 0101010101010101 +x11: 7f7f7f7f7f7f7f7f x10: c2ac898b17576267 x9 : ffffcce720fa5404 +x8 : ffff000080812138 x7 : 0000000000002e9a x6 : 0000000000000080 +x5 : ffff00008de3b000 x4 : 0000000000000000 x3 : 0000000000000001 +x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000 +Call trace: + mlxbf_gige_handle_tx_complete+0xc8/0x170 [mlxbf_gige] + mlxbf_gige_poll+0x54/0x160 [mlxbf_gige] + __napi_poll+0x40/0x1c8 + net_rx_action+0x314/0x3a0 + __do_softirq+0x128/0x334 + run_ksoftirqd+0x54/0x6c + smpboot_thread_fn+0x14c/0x190 + kthread+0x10c/0x110 + ret_from_fork+0x10/0x20 +Code: 8b070000 f9000ea0 f95056c0 f86178a1 (b9407002) +---[ end trace 7cc3941aa0d8e6a4 ]--- +Kernel panic - not syncing: Oops: Fatal exception in interrupt +Kernel Offset: 0x4ce722520000 from 0xffff800008000000 +PHYS_OFFSET: 0x80000000 +CPU features: 0x000005c1,a3330e5a +Memory Limit: none +---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]--- + +During system shutdown, the mlxbf_gige driver's shutdown() is always executed. +However, the driver's stop() method will only execute if networking interface +configuration logic within the Linux distribution has been setup to do so. + +If shutdown() executes but stop() does not execute, NAPI remains enabled +and this can lead to an exception if NAPI is scheduled while the hardware +interface has only been partially deinitialized. + +The networking interface managed by the mlxbf_gige driver must be properly +stopped during system shutdown so that IFF_UP is cleared, the hardware +interface is put into a clean state, and NAPI is fully deinitialized. + +Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") +Signed-off-by: David Thompson +Link: https://lore.kernel.org/r/20240325210929.25362-1-davthompson@nvidia.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + .../net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +index 65e92541db6e..d6b4d163bbbf 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + + #include "mlxbf_gige.h" +@@ -417,8 +418,13 @@ static void mlxbf_gige_shutdown(struct platform_device *pdev) + { + struct mlxbf_gige *priv = platform_get_drvdata(pdev); + +- writeq(0, priv->base + MLXBF_GIGE_INT_EN); +- mlxbf_gige_clean_port(priv); ++ rtnl_lock(); ++ netif_device_detach(priv->netdev); ++ ++ if (netif_running(priv->netdev)) ++ dev_close(priv->netdev); ++ ++ rtnl_unlock(); + } + + static const struct acpi_device_id __maybe_unused mlxbf_gige_acpi_match[] = { +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch b/recipes-kernel/linux/linux-6.1/0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch deleted file mode 100644 index d320f09fe..000000000 --- a/recipes-kernel/linux/linux-6.1/0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch +++ /dev/null @@ -1,1719 +0,0 @@ -From 4651b1520abcc8744493d41e1ebc1dbee3035904 Mon Sep 17 00:00:00 2001 -From: Shravan Kumar Ramani -Date: Wed, 6 Jul 2022 07:37:22 -0400 -Subject: [PATCH backport 6.1.42 76/85] UBUNTU: SAUCE: platform/mellanox: - Updates to mlxbf-bootctl - -BugLink: https://launchpad.net/bugs/1980832 - -The driver supports the VPD fields in the EEPROM and exposes -sysfs files for configuring and reading the same. -Also address buffer overflow and exclusion issues. - -Signed-off-by: Shravan Kumar Ramani -Signed-off-by: Ike Panhc ---- - drivers/platform/mellanox/mlxbf-bootctl.c | 1410 ++++++++++++++++++--- - drivers/platform/mellanox/mlxbf-bootctl.h | 88 +- - 2 files changed, 1268 insertions(+), 230 deletions(-) - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c -index 1c7a288b59a5..2302e1e09c7e 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.c -+++ b/drivers/platform/mellanox/mlxbf-bootctl.c -@@ -1,51 +1,129 @@ --// SPDX-License-Identifier: GPL-2.0+ -+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause - /* -- * Mellanox boot control driver -+ * Mellanox boot control driver -+ * This driver provides a sysfs interface for systems management -+ * software to manage reset-time actions. - * -- * This driver provides a sysfs interface for systems management -- * software to manage reset-time actions. -+ * Copyright (C) 2020 Mellanox Technologies. All rights reserved. - * -- * Copyright (C) 2019 Mellanox Technologies -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License v2.0 as published by -+ * the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. - */ - - #include - #include -+#include -+#include - #include - #include -- - #include "mlxbf-bootctl.h" - --#define MLXBF_BOOTCTL_SB_SECURE_MASK 0x03 --#define MLXBF_BOOTCTL_SB_TEST_MASK 0x0c -+#define DRIVER_NAME "mlxbf-bootctl" -+#define DRIVER_VERSION "1.5" -+#define DRIVER_DESCRIPTION "Mellanox boot control driver" -+ -+#define SB_MODE_SECURE_MASK 0x03 -+#define SB_MODE_TEST_MASK 0x0c -+#define SB_MODE_DEV_MASK 0x10 - --#define MLXBF_SB_KEY_NUM 4 -+#define SB_KEY_NUM 4 -+ -+struct boot_name { -+ int value; -+ const char name[12]; -+}; - --/* UUID used to probe ATF service. */ --static const char *mlxbf_bootctl_svc_uuid_str = -- "89c036b4-e7d7-11e6-8797-001aca00bfc4"; -+static struct boot_name boot_names[] = { -+ { MLNX_BOOT_EXTERNAL, "external" }, -+ { MLNX_BOOT_EMMC, "emmc" }, -+ { MLNX_BOOT_SWAP_EMMC, "swap_emmc" }, -+ { MLNX_BOOT_EMMC_LEGACY, "emmc_legacy" }, -+ { MLNX_BOOT_NONE, "none" }, -+ { -1, "" } -+}; - --struct mlxbf_bootctl_name { -- u32 value; -- const char *name; -+enum { -+ SB_LIFECYCLE_PRODUCTION = 0, -+ SB_LIFECYCLE_GA_SECURE = 1, -+ SB_LIFECYCLE_GA_NON_SECURE = 2, -+ SB_LIFECYCLE_RMA = 3 - }; - --static struct mlxbf_bootctl_name boot_names[] = { -- { MLXBF_BOOTCTL_EXTERNAL, "external" }, -- { MLXBF_BOOTCTL_EMMC, "emmc" }, -- { MLNX_BOOTCTL_SWAP_EMMC, "swap_emmc" }, -- { MLXBF_BOOTCTL_EMMC_LEGACY, "emmc_legacy" }, -- { MLXBF_BOOTCTL_NONE, "none" }, -+static char lifecycle_states[][16] = { -+ [SB_LIFECYCLE_PRODUCTION] = "Production", -+ [SB_LIFECYCLE_GA_SECURE] = "GA Secured", -+ [SB_LIFECYCLE_GA_NON_SECURE] = "GA Non-Secured", -+ [SB_LIFECYCLE_RMA] = "RMA", - }; - --static const char * const mlxbf_bootctl_lifecycle_states[] = { -- [0] = "Production", -- [1] = "GA Secured", -- [2] = "GA Non-Secured", -- [3] = "RMA", -+/* ctl/data register within the resource. */ -+#define RSH_SCRATCH_BUF_CTL_OFF 0 -+#define RSH_SCRATCH_BUF_DATA_OFF 0x10 -+ -+static void __iomem *rsh_boot_data; -+static void __iomem *rsh_boot_cnt; -+static void __iomem *rsh_semaphore; -+static void __iomem *rsh_scratch_buf_ctl; -+static void __iomem *rsh_scratch_buf_data; -+ -+static int rsh_log_clear_on_read; -+module_param(rsh_log_clear_on_read, int, 0644); -+MODULE_PARM_DESC(rsh_log_clear_on_read, "Clear rshim logging buffer after read."); -+ -+/* -+ * Objects are stored within the MFG partition per type. Type 0 is not -+ * supported. -+ */ -+enum { -+ MLNX_MFG_TYPE_OOB_MAC = 1, -+ MLNX_MFG_TYPE_OPN_0, -+ MLNX_MFG_TYPE_OPN_1, -+ MLNX_MFG_TYPE_OPN_2, -+ MLNX_MFG_TYPE_SKU_0, -+ MLNX_MFG_TYPE_SKU_1, -+ MLNX_MFG_TYPE_SKU_2, -+ MLNX_MFG_TYPE_MODL_0, -+ MLNX_MFG_TYPE_MODL_1, -+ MLNX_MFG_TYPE_MODL_2, -+ MLNX_MFG_TYPE_SN_0, -+ MLNX_MFG_TYPE_SN_1, -+ MLNX_MFG_TYPE_SN_2, -+ MLNX_MFG_TYPE_UUID_0, -+ MLNX_MFG_TYPE_UUID_1, -+ MLNX_MFG_TYPE_UUID_2, -+ MLNX_MFG_TYPE_UUID_3, -+ MLNX_MFG_TYPE_UUID_4, -+ MLNX_MFG_TYPE_REV, - }; - --/* ARM SMC call which is atomic and no need for lock. */ --static int mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg) -+/* This mutex is used to serialize MFG write and lock operations. */ -+static DEFINE_MUTEX(mfg_ops_lock); -+ -+#define MLNX_MFG_OOB_MAC_LEN ETH_ALEN -+#define MLNX_MFG_OPN_VAL_LEN 24 -+#define MLNX_MFG_SKU_VAL_LEN 24 -+#define MLNX_MFG_MODL_VAL_LEN 24 -+#define MLNX_MFG_SN_VAL_LEN 24 -+#define MLNX_MFG_UUID_VAL_LEN 40 -+#define MLNX_MFG_REV_VAL_LEN 8 -+#define MLNX_MFG_VAL_QWORD_CNT(type) \ -+ (MLNX_MFG_##type##_VAL_LEN / sizeof(u64)) -+ -+/* -+ * The MAC address consists of 6 bytes (2 digits each) separated by ':'. -+ * The expected format is: "XX:XX:XX:XX:XX:XX" -+ */ -+#define MLNX_MFG_OOB_MAC_FORMAT_LEN \ -+ ((MLNX_MFG_OOB_MAC_LEN * 2) + (MLNX_MFG_OOB_MAC_LEN - 1)) -+ -+/* The SMC calls in question are atomic, so we don't have to lock here. */ -+static int smc_call1(unsigned int smc_op, int smc_arg) - { - struct arm_smccc_res res; - -@@ -54,268 +132,1212 @@ static int mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg) - return res.a0; - } - --/* Return the action in integer or an error code. */ --static int mlxbf_bootctl_reset_action_to_val(const char *action) -+/* Syntactic sugar to avoid having to specify an unused argument. */ -+#define smc_call0(smc_op) smc_call1(smc_op, 0) -+ -+static int reset_action_to_val(const char *action, size_t len) - { -- int i; -+ struct boot_name *bn; -+ -+ /* Accept string either with or without a newline terminator */ -+ if (action[len-1] == '\n') -+ --len; - -- for (i = 0; i < ARRAY_SIZE(boot_names); i++) -- if (sysfs_streq(boot_names[i].name, action)) -- return boot_names[i].value; -+ for (bn = boot_names; bn->value >= 0; ++bn) -+ if (strncmp(bn->name, action, len) == 0) -+ break; - -- return -EINVAL; -+ return bn->value; - } - --/* Return the action in string. */ --static const char *mlxbf_bootctl_action_to_string(int action) -+static const char *reset_action_to_string(int action) - { -- int i; -+ struct boot_name *bn; - -- for (i = 0; i < ARRAY_SIZE(boot_names); i++) -- if (boot_names[i].value == action) -- return boot_names[i].name; -+ for (bn = boot_names; bn->value >= 0; ++bn) -+ if (bn->value == action) -+ break; - -- return "invalid action"; -+ return bn->name; - } - --static ssize_t post_reset_wdog_show(struct device *dev, -- struct device_attribute *attr, char *buf) -+static ssize_t post_reset_wdog_show(struct device_driver *drv, -+ char *buf) - { -- int ret; -+ return snprintf(buf, PAGE_SIZE, "%d\n", -+ smc_call0(MLNX_GET_POST_RESET_WDOG)); -+} - -- ret = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_POST_RESET_WDOG, 0); -- if (ret < 0) -- return ret; -+static ssize_t post_reset_wdog_store(struct device_driver *drv, -+ const char *buf, size_t count) -+{ -+ int err; -+ unsigned long watchdog; -+ -+ err = kstrtoul(buf, 10, &watchdog); -+ if (err) -+ return err; -+ -+ if (smc_call1(MLNX_SET_POST_RESET_WDOG, watchdog) < 0) -+ return -EINVAL; - -- return sprintf(buf, "%d\n", ret); -+ return count; - } - --static ssize_t post_reset_wdog_store(struct device *dev, -- struct device_attribute *attr, -- const char *buf, size_t count) -+static ssize_t reset_action_show(struct device_driver *drv, -+ char *buf) - { -- unsigned long value; -- int ret; -+ return snprintf(buf, PAGE_SIZE, "%s\n", reset_action_to_string( -+ smc_call0(MLNX_GET_RESET_ACTION))); -+} - -- ret = kstrtoul(buf, 10, &value); -- if (ret) -- return ret; -+static ssize_t reset_action_store(struct device_driver *drv, -+ const char *buf, size_t count) -+{ -+ int action = reset_action_to_val(buf, count); - -- ret = mlxbf_bootctl_smc(MLXBF_BOOTCTL_SET_POST_RESET_WDOG, value); -- if (ret < 0) -- return ret; -+ if (action < 0 || action == MLNX_BOOT_NONE) -+ return -EINVAL; -+ -+ if (smc_call1(MLNX_SET_RESET_ACTION, action) < 0) -+ return -EINVAL; - - return count; - } - --static ssize_t mlxbf_bootctl_show(int smc_op, char *buf) -+static ssize_t second_reset_action_show(struct device_driver *drv, -+ char *buf) - { -- int action; -+ return snprintf(buf, PAGE_SIZE, "%s\n", reset_action_to_string( -+ smc_call0(MLNX_GET_SECOND_RESET_ACTION))); -+} -+ -+static ssize_t second_reset_action_store(struct device_driver *drv, -+ const char *buf, size_t count) -+{ -+ int action = reset_action_to_val(buf, count); - -- action = mlxbf_bootctl_smc(smc_op, 0); - if (action < 0) -- return action; -+ return -EINVAL; -+ -+ if (smc_call1(MLNX_SET_SECOND_RESET_ACTION, action) < 0) -+ return -EINVAL; - -- return sprintf(buf, "%s\n", mlxbf_bootctl_action_to_string(action)); -+ return count; - } - --static int mlxbf_bootctl_store(int smc_op, const char *buf, size_t count) -+static ssize_t lifecycle_state_show(struct device_driver *drv, -+ char *buf) - { -- int ret, action; -+ int lc_state = smc_call1(MLNX_GET_TBB_FUSE_STATUS, -+ MLNX_FUSE_STATUS_LIFECYCLE); - -- action = mlxbf_bootctl_reset_action_to_val(buf); -- if (action < 0) -- return action; -+ if (lc_state < 0) -+ return -EINVAL; -+ -+ lc_state &= (SB_MODE_TEST_MASK | -+ SB_MODE_SECURE_MASK | -+ SB_MODE_DEV_MASK); - -- ret = mlxbf_bootctl_smc(smc_op, action); -- if (ret < 0) -- return ret; -+ /* -+ * If the test bits are set, we specify that the current state may be -+ * due to using the test bits. -+ */ -+ if ((lc_state & SB_MODE_TEST_MASK) != 0) { -+ -+ lc_state &= SB_MODE_SECURE_MASK; -+ -+ return snprintf(buf, PAGE_SIZE, "%s(test)\n", -+ lifecycle_states[lc_state]); -+ } else if ((lc_state & SB_MODE_SECURE_MASK) == SB_LIFECYCLE_GA_SECURE -+ && (lc_state & SB_MODE_DEV_MASK)) { -+ return snprintf(buf, PAGE_SIZE, "Secured (development)\n"); -+ } -+ -+ return snprintf(buf, PAGE_SIZE, "%s\n", lifecycle_states[lc_state]); -+} -+ -+static ssize_t secure_boot_fuse_state_show(struct device_driver *drv, -+ char *buf) -+{ -+ int key; -+ int buf_len = 0; -+ int upper_key_used = 0; -+ int sb_key_state = smc_call1(MLNX_GET_TBB_FUSE_STATUS, -+ MLNX_FUSE_STATUS_KEYS); -+ -+ if (sb_key_state < 0) -+ return -EINVAL; -+ -+ for (key = SB_KEY_NUM - 1; key >= 0; key--) { -+ int burnt = ((sb_key_state & (1 << key)) != 0); -+ int valid = ((sb_key_state & (1 << (key + SB_KEY_NUM))) != 0); -+ -+ buf_len += sprintf(buf + buf_len, "Ver%d:", key); -+ if (upper_key_used) { -+ if (burnt) { -+ if (valid) -+ buf_len += sprintf(buf + buf_len, -+ "Used"); -+ else -+ buf_len += sprintf(buf + buf_len, -+ "Wasted"); -+ } else { -+ if (valid) -+ buf_len += sprintf(buf + buf_len, -+ "Invalid"); -+ else -+ buf_len += sprintf(buf + buf_len, -+ "Skipped"); -+ } -+ } else { -+ if (burnt) { -+ if (valid) { -+ upper_key_used = 1; -+ buf_len += sprintf(buf + buf_len, -+ "In use"); -+ } else -+ buf_len += sprintf(buf + buf_len, -+ "Burn incomplete"); -+ } else { -+ if (valid) -+ buf_len += sprintf(buf + buf_len, -+ "Invalid"); -+ else -+ buf_len += sprintf(buf + buf_len, -+ "Free"); -+ } -+ } -+ buf_len += sprintf(buf + buf_len, "\n"); -+ } -+ -+ return buf_len; -+} -+ -+static ssize_t fw_reset_store(struct device_driver *drv, -+ const char *buf, size_t count) -+{ -+ int err; -+ unsigned long key; -+ -+ err = kstrtoul(buf, 16, &key); -+ if (err) -+ return err; -+ -+ if (smc_call1(MLNX_HANDLE_FW_RESET, key) < 0) -+ return -EINVAL; - - return count; - } - --static ssize_t reset_action_show(struct device *dev, -- struct device_attribute *attr, char *buf) -+static ssize_t oob_mac_show(struct device_driver *drv, char *buf) - { -- return mlxbf_bootctl_show(MLXBF_BOOTCTL_GET_RESET_ACTION, buf); -+ char mac_str[MLNX_MFG_OOB_MAC_FORMAT_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ u8 *mac_byte_ptr; -+ -+ mutex_lock(&mfg_ops_lock); -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, MLNX_MFG_TYPE_OOB_MAC, 0, 0, 0, -+ 0, 0, 0, &res); -+ mutex_unlock(&mfg_ops_lock); -+ if (res.a0) -+ return -EPERM; -+ -+ mac_byte_ptr = (u8 *)&res.a1; -+ -+ sprintf(mac_str, "%02X:%02X:%02X:%02X:%02X:%02X", -+ mac_byte_ptr[0], mac_byte_ptr[1], mac_byte_ptr[2], -+ mac_byte_ptr[3], mac_byte_ptr[4], mac_byte_ptr[5]); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", mac_str); - } - --static ssize_t reset_action_store(struct device *dev, -- struct device_attribute *attr, -- const char *buf, size_t count) -+static ssize_t oob_mac_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ int byte[MLNX_MFG_OOB_MAC_FORMAT_LEN] = { 0 }; -+ struct arm_smccc_res res; -+ u64 mac_addr = 0; -+ u8 *mac_byte_ptr; -+ int byte_idx, len; -+ -+ if ((count - 1) != MLNX_MFG_OOB_MAC_FORMAT_LEN) -+ return -EINVAL; -+ -+ len = sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", -+ &byte[0], &byte[1], &byte[2], -+ &byte[3], &byte[4], &byte[5]); -+ if (len != MLNX_MFG_OOB_MAC_LEN) -+ return -EINVAL; -+ -+ mac_byte_ptr = (u8 *)&mac_addr; -+ -+ for (byte_idx = 0; byte_idx < MLNX_MFG_OOB_MAC_LEN; byte_idx++) -+ mac_byte_ptr[byte_idx] = (u8) byte[byte_idx]; -+ -+ mutex_lock(&mfg_ops_lock); -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, MLNX_MFG_TYPE_OOB_MAC, -+ MLNX_MFG_OOB_MAC_LEN, mac_addr, 0, 0, 0, 0, &res); -+ mutex_unlock(&mfg_ops_lock); -+ -+ return res.a0 ? -EPERM : count; -+} -+ -+static ssize_t opn_show(struct device_driver *drv, char *buf) - { -- return mlxbf_bootctl_store(MLXBF_BOOTCTL_SET_RESET_ACTION, buf, count); -+ u64 opn_data[MLNX_MFG_VAL_QWORD_CNT(OPN)] = { 0 }; -+ char opn[MLNX_MFG_OPN_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(OPN); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_OPN_0 + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ opn_data[word] = res.a1; -+ } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(opn, opn_data, MLNX_MFG_OPN_VAL_LEN); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", opn); - } - --static ssize_t second_reset_action_show(struct device *dev, -- struct device_attribute *attr, -- char *buf) -+static ssize_t opn_store(struct device_driver *drv, const char *buf, -+ size_t count) - { -- return mlxbf_bootctl_show(MLXBF_BOOTCTL_GET_SECOND_RESET_ACTION, buf); -+ u64 opn[MLNX_MFG_VAL_QWORD_CNT(OPN)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ if (count > MLNX_MFG_OPN_VAL_LEN) -+ return -EINVAL; -+ -+ memcpy(opn, buf, count); -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(OPN); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_OPN_0 + word, -+ sizeof(u64), opn[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; - } - --static ssize_t second_reset_action_store(struct device *dev, -- struct device_attribute *attr, -- const char *buf, size_t count) -+static ssize_t sku_show(struct device_driver *drv, char *buf) - { -- return mlxbf_bootctl_store(MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION, buf, -- count); -+ u64 sku_data[MLNX_MFG_VAL_QWORD_CNT(SKU)] = { 0 }; -+ char sku[MLNX_MFG_SKU_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(SKU); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_SKU_0 + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ sku_data[word] = res.a1; -+ } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(sku, sku_data, MLNX_MFG_SKU_VAL_LEN); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", sku); - } - --static ssize_t lifecycle_state_show(struct device *dev, -- struct device_attribute *attr, char *buf) -+static ssize_t sku_store(struct device_driver *drv, const char *buf, -+ size_t count) - { -- int lc_state; -+ u64 sku[MLNX_MFG_VAL_QWORD_CNT(SKU)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; - -- lc_state = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS, -- MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE); -- if (lc_state < 0) -- return lc_state; -+ if (count > MLNX_MFG_SKU_VAL_LEN) -+ return -EINVAL; - -- lc_state &= -- MLXBF_BOOTCTL_SB_TEST_MASK | MLXBF_BOOTCTL_SB_SECURE_MASK; -+ memcpy(sku, buf, count); - -- /* -- * If the test bits are set, we specify that the current state may be -- * due to using the test bits. -- */ -- if (lc_state & MLXBF_BOOTCTL_SB_TEST_MASK) { -- lc_state &= MLXBF_BOOTCTL_SB_SECURE_MASK; -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(SKU); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_SKU_0 + word, -+ sizeof(u64), sku[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); - -- return sprintf(buf, "%s(test)\n", -- mlxbf_bootctl_lifecycle_states[lc_state]); -+ return count; -+} -+ -+static ssize_t modl_show(struct device_driver *drv, char *buf) -+{ -+ u64 modl_data[MLNX_MFG_VAL_QWORD_CNT(MODL)] = { 0 }; -+ char modl[MLNX_MFG_MODL_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(MODL); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_MODL_0 + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ modl_data[word] = res.a1; - } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(modl, modl_data, MLNX_MFG_MODL_VAL_LEN); - -- return sprintf(buf, "%s\n", mlxbf_bootctl_lifecycle_states[lc_state]); -+ return snprintf(buf, PAGE_SIZE, "%s", modl); - } - --static ssize_t secure_boot_fuse_state_show(struct device *dev, -- struct device_attribute *attr, -- char *buf) -+static ssize_t modl_store(struct device_driver *drv, const char *buf, -+ size_t count) - { -- int burnt, valid, key, key_state, buf_len = 0, upper_key_used = 0; -- const char *status; -+ u64 modl[MLNX_MFG_VAL_QWORD_CNT(MODL)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ if (count > MLNX_MFG_MODL_VAL_LEN) -+ return -EINVAL; -+ -+ memcpy(modl, buf, count); -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(MODL); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_MODL_0 + word, -+ sizeof(u64), modl[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; -+} -+ -+static ssize_t sn_show(struct device_driver *drv, char *buf) -+{ -+ u64 sn_data[MLNX_MFG_VAL_QWORD_CNT(SN)] = { 0 }; -+ char sn[MLNX_MFG_SN_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(SN); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_SN_0 + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ sn_data[word] = res.a1; -+ } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(sn, sn_data, MLNX_MFG_SN_VAL_LEN); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", sn); -+} -+ -+static ssize_t sn_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ u64 sn[MLNX_MFG_VAL_QWORD_CNT(SN)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ if (count > MLNX_MFG_SN_VAL_LEN) -+ return -EINVAL; -+ -+ memcpy(sn, buf, count); -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(SN); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_SN_0 + word, -+ sizeof(u64), sn[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; -+} -+ -+static ssize_t uuid_show(struct device_driver *drv, char *buf) -+{ -+ u64 uuid_data[MLNX_MFG_VAL_QWORD_CNT(UUID)] = { 0 }; -+ char uuid[MLNX_MFG_UUID_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(UUID); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_UUID_0 + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ uuid_data[word] = res.a1; -+ } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(uuid, uuid_data, MLNX_MFG_UUID_VAL_LEN); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", uuid); -+} -+ -+static ssize_t uuid_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ u64 uuid[MLNX_MFG_VAL_QWORD_CNT(UUID)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; - -- key_state = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS, -- MLXBF_BOOTCTL_FUSE_STATUS_KEYS); -- if (key_state < 0) -- return key_state; -+ if (count > MLNX_MFG_UUID_VAL_LEN) -+ return -EINVAL; -+ -+ memcpy(uuid, buf, count); -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(UUID); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_UUID_0 + word, -+ sizeof(u64), uuid[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; -+} -+ -+static ssize_t rev_show(struct device_driver *drv, char *buf) -+{ -+ u64 rev_data[MLNX_MFG_VAL_QWORD_CNT(REV)] = { 0 }; -+ char rev[MLNX_MFG_REV_VAL_LEN + 1] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(REV); word++) { -+ arm_smccc_smc(MLNX_HANDLE_GET_MFG_INFO, -+ MLNX_MFG_TYPE_REV + word, -+ 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ rev_data[word] = res.a1; -+ } -+ mutex_unlock(&mfg_ops_lock); -+ memcpy(rev, rev_data, MLNX_MFG_REV_VAL_LEN); -+ -+ return snprintf(buf, PAGE_SIZE, "%s", rev); -+} -+ -+static ssize_t rev_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ u64 rev[MLNX_MFG_VAL_QWORD_CNT(REV)] = { 0 }; -+ struct arm_smccc_res res; -+ int word; -+ -+ if (count > MLNX_MFG_REV_VAL_LEN) -+ return -EINVAL; -+ -+ memcpy(rev, buf, count); -+ -+ mutex_lock(&mfg_ops_lock); -+ for (word = 0; word < MLNX_MFG_VAL_QWORD_CNT(REV); word++) { -+ arm_smccc_smc(MLNX_HANDLE_SET_MFG_INFO, -+ MLNX_MFG_TYPE_REV + word, -+ sizeof(u64), rev[word], 0, 0, 0, 0, &res); -+ if (res.a0) { -+ mutex_unlock(&mfg_ops_lock); -+ return -EPERM; -+ } -+ } -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; -+} -+ -+static ssize_t mfg_lock_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ unsigned long val; -+ int err; -+ -+ err = kstrtoul(buf, 10, &val); -+ if (err) -+ return err; -+ -+ if (val != 1) -+ return -EINVAL; -+ -+ mutex_lock(&mfg_ops_lock); -+ smc_call0(MLNX_HANDLE_LOCK_MFG_INFO); -+ mutex_unlock(&mfg_ops_lock); -+ -+ return count; -+} -+ -+/* Log header format. */ -+#define RSH_LOG_TYPE_SHIFT 56 -+#define RSH_LOG_LEN_SHIFT 48 -+#define RSH_LOG_LEVEL_SHIFT 0 -+ -+/* Module ID and type used here. */ -+#define BF_RSH_LOG_TYPE_UNKNOWN 0x00ULL -+#define BF_RSH_LOG_TYPE_PANIC 0x01ULL -+#define BF_RSH_LOG_TYPE_EXCEPTION 0x02ULL -+#define BF_RSH_LOG_TYPE_UNUSED 0x03ULL -+#define BF_RSH_LOG_TYPE_MSG 0x04ULL -+ -+/* Utility macro. */ -+#define BF_RSH_LOG_MOD_MASK 0x0FULL -+#define BF_RSH_LOG_MOD_SHIFT 60 -+#define BF_RSH_LOG_TYPE_MASK 0x0FULL -+#define BF_RSH_LOG_TYPE_SHIFT 56 -+#define BF_RSH_LOG_LEN_MASK 0x7FULL -+#define BF_RSH_LOG_LEN_SHIFT 48 -+#define BF_RSH_LOG_ARG_MASK 0xFFFFFFFFULL -+#define BF_RSH_LOG_ARG_SHIFT 16 -+#define BF_RSH_LOG_HAS_ARG_MASK 0xFFULL -+#define BF_RSH_LOG_HAS_ARG_SHIFT 8 -+#define BF_RSH_LOG_LEVEL_MASK 0xFFULL -+#define BF_RSH_LOG_LEVEL_SHIFT 0 -+#define BF_RSH_LOG_PC_MASK 0xFFFFFFFFULL -+#define BF_RSH_LOG_PC_SHIFT 0 -+#define BF_RSH_LOG_SYNDROME_MASK 0xFFFFFFFFULL -+#define BF_RSH_LOG_SYNDROME_SHIFT 0 -+ -+#define BF_RSH_LOG_HEADER_GET(f, h) \ -+ (((h) >> BF_RSH_LOG_##f##_SHIFT) & BF_RSH_LOG_##f##_MASK) -+ -+/* Log message level. */ -+enum { -+ RSH_LOG_INFO, -+ RSH_LOG_WARN, -+ RSH_LOG_ERR -+}; -+ -+/* Log module */ -+const char * const rsh_log_mod[] = { -+ "MISC", "BL1", "BL2", "BL2R", "BL31", "UEFI" -+}; -+ -+const char *rsh_log_level[] = {"INFO", "WARN", "ERR", "ASSERT"}; -+ -+#define AARCH64_MRS_REG_SHIFT 5 -+#define AARCH64_MRS_REG_MASK 0xffff -+#define AARCH64_ESR_ELX_EXCEPTION_CLASS_SHIFT 26 -+ -+struct rsh_log_reg { -+ char *name; -+ u32 opcode; -+} rsh_log_reg; -+ -+static struct rsh_log_reg rsh_log_regs[] = { -+ {"actlr_el1", 0b1100000010000001}, -+ {"actlr_el2", 0b1110000010000001}, -+ {"actlr_el3", 0b1111000010000001}, -+ {"afsr0_el1", 0b1100001010001000}, -+ {"afsr0_el2", 0b1110001010001000}, -+ {"afsr0_el3", 0b1111001010001000}, -+ {"afsr1_el1", 0b1100001010001001}, -+ {"afsr1_el2", 0b1110001010001001}, -+ {"afsr1_el3", 0b1111001010001001}, -+ {"amair_el1", 0b1100010100011000}, -+ {"amair_el2", 0b1110010100011000}, -+ {"amair_el3", 0b1111010100011000}, -+ {"ccsidr_el1", 0b1100100000000000}, -+ {"clidr_el1", 0b1100100000000001}, -+ {"cntkctl_el1", 0b1100011100001000}, -+ {"cntp_ctl_el0", 0b1101111100010001}, -+ {"cntp_cval_el0", 0b1101111100010010}, -+ {"cntv_ctl_el0", 0b1101111100011001}, -+ {"cntv_cval_el0", 0b1101111100011010}, -+ {"contextidr_el1", 0b1100011010000001}, -+ {"cpacr_el1", 0b1100000010000010}, -+ {"cptr_el2", 0b1110000010001010}, -+ {"cptr_el3", 0b1111000010001010}, -+ {"vtcr_el2", 0b1110000100001010}, -+ {"ctr_el0", 0b1101100000000001}, -+ {"currentel", 0b1100001000010010}, -+ {"dacr32_el2", 0b1110000110000000}, -+ {"daif", 0b1101101000010001}, -+ {"dczid_el0", 0b1101100000000111}, -+ {"dlr_el0", 0b1101101000101001}, -+ {"dspsr_el0", 0b1101101000101000}, -+ {"elr_el1", 0b1100001000000001}, -+ {"elr_el2", 0b1110001000000001}, -+ {"elr_el3", 0b1111001000000001}, -+ {"esr_el1", 0b1100001010010000}, -+ {"esr_el2", 0b1110001010010000}, -+ {"esr_el3", 0b1111001010010000}, -+ {"esselr_el1", 0b1101000000000000}, -+ {"far_el1", 0b1100001100000000}, -+ {"far_el2", 0b1110001100000000}, -+ {"far_el3", 0b1111001100000000}, -+ {"fpcr", 0b1101101000100000}, -+ {"fpexc32_el2", 0b1110001010011000}, -+ {"fpsr", 0b1101101000100001}, -+ {"hacr_el2", 0b1110000010001111}, -+ {"har_el2", 0b1110000010001000}, -+ {"hpfar_el2", 0b1110001100000100}, -+ {"hstr_el2", 0b1110000010001011}, -+ {"far_el1", 0b1100001100000000}, -+ {"far_el2", 0b1110001100000000}, -+ {"far_el3", 0b1111001100000000}, -+ {"hcr_el2", 0b1110000010001000}, -+ {"hpfar_el2", 0b1110001100000100}, -+ {"id_aa64afr0_el1", 0b1100000000101100}, -+ {"id_aa64afr1_el1", 0b1100000000101101}, -+ {"id_aa64dfr0_el1", 0b1100000000101100}, -+ {"id_aa64isar0_el1", 0b1100000000110000}, -+ {"id_aa64isar1_el1", 0b1100000000110001}, -+ {"id_aa64mmfr0_el1", 0b1100000000111000}, -+ {"id_aa64mmfr1_el1", 0b1100000000111001}, -+ {"id_aa64pfr0_el1", 0b1100000000100000}, -+ {"id_aa64pfr1_el1", 0b1100000000100001}, -+ {"ifsr32_el2", 0b1110001010000001}, -+ {"isr_el1", 0b1100011000001000}, -+ {"mair_el1", 0b1100010100010000}, -+ {"mair_el2", 0b1110010100010000}, -+ {"mair_el3", 0b1111010100010000}, -+ {"midr_el1", 0b1100000000000000}, -+ {"mpidr_el1", 0b1100000000000101}, -+ {"nzcv", 0b1101101000010000}, -+ {"revidr_el1", 0b1100000000000110}, -+ {"rmr_el3", 0b1111011000000010}, -+ {"par_el1", 0b1100001110100000}, -+ {"rvbar_el3", 0b1111011000000001}, -+ {"scr_el3", 0b1111000010001000}, -+ {"sctlr_el1", 0b1100000010000000}, -+ {"sctlr_el2", 0b1110000010000000}, -+ {"sctlr_el3", 0b1111000010000000}, -+ {"sp_el0", 0b1100001000001000}, -+ {"sp_el1", 0b1110001000001000}, -+ {"spsel", 0b1100001000010000}, -+ {"spsr_abt", 0b1110001000011001}, -+ {"spsr_el1", 0b1100001000000000}, -+ {"spsr_el2", 0b1110001000000000}, -+ {"spsr_el3", 0b1111001000000000}, -+ {"spsr_fiq", 0b1110001000011011}, -+ {"spsr_irq", 0b1110001000011000}, -+ {"spsr_und", 0b1110001000011010}, -+ {"tcr_el1", 0b1100000100000010}, -+ {"tcr_el2", 0b1110000100000010}, -+ {"tcr_el3", 0b1111000100000010}, -+ {"tpidr_el0", 0b1101111010000010}, -+ {"tpidr_el1", 0b1100011010000100}, -+ {"tpidr_el2", 0b1110011010000010}, -+ {"tpidr_el3", 0b1111011010000010}, -+ {"tpidpro_el0", 0b1101111010000011}, -+ {"vbar_el1", 0b1100011000000000}, -+ {"vbar_el2", 0b1110011000000000}, -+ {"vbar_el3", 0b1111011000000000}, -+ {"vmpidr_el2", 0b1110000000000101}, -+ {"vpidr_el2", 0b1110000000000000}, -+ {"ttbr0_el1", 0b1100000100000000}, -+ {"ttbr0_el2", 0b1110000100000000}, -+ {"ttbr0_el3", 0b1111000100000000}, -+ {"ttbr1_el1", 0b1100000100000001}, -+ {"vtcr_el2", 0b1110000100001010}, -+ {"vttbr_el2", 0b1110000100001000}, -+ {NULL, 0b0000000000000000}, -+}; -+ -+/* Size(8-byte words) of the log buffer. */ -+#define RSH_SCRATCH_BUF_CTL_IDX_MASK 0x7f -+ -+static int rsh_log_sem_lock(void) -+{ -+ unsigned long timeout; -+ -+ /* Take the semaphore. */ -+ timeout = jiffies + msecs_to_jiffies(100); -+ while (readq(rsh_semaphore)) { -+ if (time_after(jiffies, timeout)) -+ return -ETIMEDOUT; -+ } -+ -+ return 0; -+} -+ -+static void rsh_log_sem_unlock(void) -+{ -+ writeq(0, rsh_semaphore); -+} -+ -+static ssize_t rsh_log_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ int idx, num, len, size = (int)count, level = RSH_LOG_INFO, rc; -+ u64 data; -+ -+ if (!size) -+ return -EINVAL; -+ -+ if (!rsh_semaphore || !rsh_scratch_buf_ctl) -+ return -EOPNOTSUPP; -+ -+ /* Ignore line break at the end. */ -+ if (buf[size-1] == 0xa) -+ size--; -+ -+ /* Check the message prefix. */ -+ for (idx = 0; idx < ARRAY_SIZE(rsh_log_level); idx++) { -+ len = strlen(rsh_log_level[idx]); -+ if (len + 1 < size && !strncmp(buf, rsh_log_level[idx], len)) { -+ buf += len + 1; -+ size -= len + 1; -+ level = idx; -+ break; -+ } -+ } -+ -+ /* Ignore leading spaces. */ -+ while (size > 0 && buf[0] == ' ') { -+ size--; -+ buf++; -+ } -+ -+ /* Take the semaphore. */ -+ rc = rsh_log_sem_lock(); -+ if (rc) -+ return rc; -+ -+ /* Calculate how many words are available. */ -+ num = (size + sizeof(u64) - 1) / sizeof(u64); -+ idx = readq(rsh_scratch_buf_ctl); -+ if (idx + num + 1 >= RSH_SCRATCH_BUF_CTL_IDX_MASK) -+ num = RSH_SCRATCH_BUF_CTL_IDX_MASK - idx - 1; -+ if (num <= 0) -+ goto done; -+ -+ /* Write Header. */ -+ data = (BF_RSH_LOG_TYPE_MSG << RSH_LOG_TYPE_SHIFT) | -+ ((u64)num << RSH_LOG_LEN_SHIFT) | -+ ((u64)level << RSH_LOG_LEVEL_SHIFT); -+ writeq(data, rsh_scratch_buf_data); -+ -+ /* Write message. */ -+ for (idx = 0, len = size; idx < num && len > 0; idx++) { -+ if (len <= sizeof(u64)) { -+ data = 0; -+ memcpy(&data, buf, len); -+ len = 0; -+ } else { -+ memcpy(&data, buf, sizeof(u64)); -+ len -= sizeof(u64); -+ buf += sizeof(u64); -+ } -+ writeq(data, rsh_scratch_buf_data); -+ } -+ -+done: -+ /* Release the semaphore. */ -+ rsh_log_sem_unlock(); -+ -+ /* Ignore the rest if no more space. */ -+ return count; -+} -+ -+static char *rsh_log_get_reg_name(u64 opcode) -+{ -+ struct rsh_log_reg *reg = rsh_log_regs; -+ -+ while (reg->name) { -+ if (reg->opcode == opcode) -+ return reg->name; -+ reg++; -+ } -+ -+ return "unknown"; -+} -+ -+static int rsh_log_show_crash(u64 hdr, char *buf, int size) -+{ -+ int i, module, type, len, n = 0; -+ u32 pc, syndrome, ec; -+ u64 opcode, data; -+ char *p = buf; -+ -+ module = BF_RSH_LOG_HEADER_GET(MOD, hdr); -+ if (module >= ARRAY_SIZE(rsh_log_mod)) -+ module = 0; -+ type = BF_RSH_LOG_HEADER_GET(TYPE, hdr); -+ len = BF_RSH_LOG_HEADER_GET(LEN, hdr); -+ -+ if (type == BF_RSH_LOG_TYPE_EXCEPTION) { -+ syndrome = BF_RSH_LOG_HEADER_GET(SYNDROME, hdr); -+ ec = syndrome >> AARCH64_ESR_ELX_EXCEPTION_CLASS_SHIFT; -+ n = snprintf(p, size, " Exception(%s): syndrome = 0x%x%s\n", -+ rsh_log_mod[module], syndrome, -+ (ec == 0x24 || ec == 0x25) ? "(Data Abort)" : -+ (ec == 0x2f) ? "(SError)" : ""); -+ } else if (type == BF_RSH_LOG_TYPE_PANIC) { -+ pc = BF_RSH_LOG_HEADER_GET(PC, hdr); -+ n = snprintf(p, size, -+ " PANIC(%s): PC = 0x%x\n", rsh_log_mod[module], -+ pc); -+ } -+ if (n > 0) { -+ p += n; -+ size -= n; -+ } - - /* -- * key_state contains the bits for 4 Key versions, loaded from eFuses -- * after a hard reset. Lower 4 bits are a thermometer code indicating -- * key programming has started for key n (0000 = none, 0001 = version 0, -- * 0011 = version 1, 0111 = version 2, 1111 = version 3). Upper 4 bits -- * are a thermometer code indicating key programming has completed for -- * key n (same encodings as the start bits). This allows for detection -- * of an interruption in the programming process which has left the key -- * partially programmed (and thus invalid). The process is to burn the -- * eFuse for the new key start bit, burn the key eFuses, then burn the -- * eFuse for the new key complete bit. -- * -- * For example 0000_0000: no key valid, 0001_0001: key version 0 valid, -- * 0011_0011: key 1 version valid, 0011_0111: key version 2 started -- * programming but did not complete, etc. The most recent key for which -- * both start and complete bit is set is loaded. On soft reset, this -- * register is not modified. -+ * Read the registers in a loop. 'len' is the total number of words in -+ * 8-bytes. Two words are read in each loop. - */ -- for (key = MLXBF_SB_KEY_NUM - 1; key >= 0; key--) { -- burnt = key_state & BIT(key); -- valid = key_state & BIT(key + MLXBF_SB_KEY_NUM); -+ for (i = 0; i < len/2; i++) { -+ opcode = readq(rsh_scratch_buf_data); -+ data = readq(rsh_scratch_buf_data); -+ -+ opcode = (opcode >> AARCH64_MRS_REG_SHIFT) & -+ AARCH64_MRS_REG_MASK; -+ n = snprintf(p, size, -+ " %-16s0x%llx\n", rsh_log_get_reg_name(opcode), -+ (unsigned long long)data); -+ if (n > 0) { -+ p += n; -+ size -= n; -+ } -+ } - -- if (burnt && valid) -- upper_key_used = 1; -+ return p - buf; -+} - -- if (upper_key_used) { -- if (burnt) -- status = valid ? "Used" : "Wasted"; -- else -- status = valid ? "Invalid" : "Skipped"; -- } else { -- if (burnt) -- status = valid ? "InUse" : "Incomplete"; -- else -- status = valid ? "Invalid" : "Free"; -+static int rsh_log_format_msg(char *buf, int size, const char *msg, ...) -+{ -+ va_list args; -+ int len; -+ -+ va_start(args, msg); -+ len = vsnprintf(buf, size, msg, args); -+ va_end(args); -+ -+ return len; -+} -+ -+static int rsh_log_show_msg(u64 hdr, char *buf, int size) -+{ -+ int has_arg = BF_RSH_LOG_HEADER_GET(HAS_ARG, hdr); -+ int level = BF_RSH_LOG_HEADER_GET(LEVEL, hdr); -+ int module = BF_RSH_LOG_HEADER_GET(MOD, hdr); -+ int len = BF_RSH_LOG_HEADER_GET(LEN, hdr); -+ u32 arg = BF_RSH_LOG_HEADER_GET(ARG, hdr); -+ char *msg, *p; -+ u64 data; -+ -+ if (len <= 0) -+ return -EINVAL; -+ -+ if (module >= ARRAY_SIZE(rsh_log_mod)) -+ module = 0; -+ -+ if (level >= ARRAY_SIZE(rsh_log_level)) -+ level = 0; -+ -+ msg = kmalloc(len * sizeof(u64) + 1, GFP_KERNEL); -+ if (!msg) -+ return 0; -+ p = msg; -+ -+ while (len--) { -+ data = readq(rsh_scratch_buf_data); -+ memcpy(p, &data, sizeof(data)); -+ p += sizeof(data); -+ } -+ *p = '\0'; -+ if (!has_arg) { -+ len = snprintf(buf, size, " %s[%s]: %s\n", rsh_log_level[level], -+ rsh_log_mod[module], msg); -+ } else { -+ len = snprintf(buf, size, " %s[%s]: ", rsh_log_level[level], -+ rsh_log_mod[module]); -+ len += rsh_log_format_msg(buf + len, size - len, msg, arg); -+ len += snprintf(buf + len, size - len, "\n"); -+ } -+ -+ kfree(msg); -+ return len; -+} -+ -+static ssize_t rsh_log_show(struct device_driver *drv, char *buf) -+{ -+ u64 hdr; -+ char *p = buf; -+ int i, n, rc, idx, type, len, size = PAGE_SIZE; -+ -+ if (!rsh_semaphore || !rsh_scratch_buf_ctl) -+ return -EOPNOTSUPP; -+ -+ /* Take the semaphore. */ -+ rc = rsh_log_sem_lock(); -+ if (rc) -+ return rc; -+ -+ /* Save the current index and read from 0. */ -+ idx = readq(rsh_scratch_buf_ctl) & RSH_SCRATCH_BUF_CTL_IDX_MASK; -+ if (!idx) -+ goto done; -+ writeq(0, rsh_scratch_buf_ctl); -+ -+ i = 0; -+ while (i < idx) { -+ hdr = readq(rsh_scratch_buf_data); -+ type = BF_RSH_LOG_HEADER_GET(TYPE, hdr); -+ len = BF_RSH_LOG_HEADER_GET(LEN, hdr); -+ i += 1 + len; -+ if (i > idx) -+ break; -+ -+ switch (type) { -+ case BF_RSH_LOG_TYPE_PANIC: -+ case BF_RSH_LOG_TYPE_EXCEPTION: -+ n = rsh_log_show_crash(hdr, p, size); -+ p += n; -+ size -= n; -+ break; -+ case BF_RSH_LOG_TYPE_MSG: -+ n = rsh_log_show_msg(hdr, p, size); -+ p += n; -+ size -= n; -+ break; -+ default: -+ /* Drain this message. */ -+ while (len--) -+ (void) readq(rsh_scratch_buf_data); -+ break; - } -- buf_len += sprintf(buf + buf_len, "%d:%s ", key, status); - } -- buf_len += sprintf(buf + buf_len, "\n"); - -- return buf_len; -+ if (rsh_log_clear_on_read) -+ writeq(0, rsh_scratch_buf_ctl); -+ else -+ writeq(idx, rsh_scratch_buf_ctl); -+ -+done: -+ /* Release the semaphore. */ -+ rsh_log_sem_unlock(); -+ -+ return p - buf; - } - --static DEVICE_ATTR_RW(post_reset_wdog); --static DEVICE_ATTR_RW(reset_action); --static DEVICE_ATTR_RW(second_reset_action); --static DEVICE_ATTR_RO(lifecycle_state); --static DEVICE_ATTR_RO(secure_boot_fuse_state); -+static DRIVER_ATTR_RW(post_reset_wdog); -+static DRIVER_ATTR_RW(reset_action); -+static DRIVER_ATTR_RW(second_reset_action); -+static DRIVER_ATTR_RO(lifecycle_state); -+static DRIVER_ATTR_RO(secure_boot_fuse_state); -+static DRIVER_ATTR_WO(fw_reset); -+static DRIVER_ATTR_RW(oob_mac); -+static DRIVER_ATTR_RW(opn); -+static DRIVER_ATTR_RW(sku); -+static DRIVER_ATTR_RW(modl); -+static DRIVER_ATTR_RW(sn); -+static DRIVER_ATTR_RW(uuid); -+static DRIVER_ATTR_RW(rev); -+static DRIVER_ATTR_WO(mfg_lock); -+static DRIVER_ATTR_RW(rsh_log); - --static struct attribute *mlxbf_bootctl_attrs[] = { -- &dev_attr_post_reset_wdog.attr, -- &dev_attr_reset_action.attr, -- &dev_attr_second_reset_action.attr, -- &dev_attr_lifecycle_state.attr, -- &dev_attr_secure_boot_fuse_state.attr, -+static struct attribute *mbc_dev_attrs[] = { -+ &driver_attr_post_reset_wdog.attr, -+ &driver_attr_reset_action.attr, -+ &driver_attr_second_reset_action.attr, -+ &driver_attr_lifecycle_state.attr, -+ &driver_attr_secure_boot_fuse_state.attr, -+ &driver_attr_fw_reset.attr, -+ &driver_attr_oob_mac.attr, -+ &driver_attr_opn.attr, -+ &driver_attr_sku.attr, -+ &driver_attr_modl.attr, -+ &driver_attr_sn.attr, -+ &driver_attr_uuid.attr, -+ &driver_attr_rev.attr, -+ &driver_attr_mfg_lock.attr, -+ &driver_attr_rsh_log.attr, - NULL - }; - --ATTRIBUTE_GROUPS(mlxbf_bootctl); -+static struct attribute_group mbc_attr_group = { -+ .attrs = mbc_dev_attrs -+}; - --static const struct acpi_device_id mlxbf_bootctl_acpi_ids[] = { -+static const struct attribute_group *mbc_attr_groups[] = { -+ &mbc_attr_group, -+ NULL -+}; -+ -+static const struct of_device_id mbc_dt_ids[] = { -+ {.compatible = "mellanox,bootctl"}, -+ {}, -+}; -+ -+MODULE_DEVICE_TABLE(of, mbc_dt_ids); -+ -+static const struct acpi_device_id mbc_acpi_ids[] = { - {"MLNXBF04", 0}, -- {} -+ {}, - }; - --MODULE_DEVICE_TABLE(acpi, mlxbf_bootctl_acpi_ids); -+MODULE_DEVICE_TABLE(acpi, mbc_acpi_ids); - --static bool mlxbf_bootctl_guid_match(const guid_t *guid, -- const struct arm_smccc_res *res) -+static ssize_t mbc_bootfifo_read_raw(struct file *filp, struct kobject *kobj, -+ struct bin_attribute *bin_attr, -+ char *buf, loff_t pos, size_t count) - { -- guid_t id = GUID_INIT(res->a0, res->a1, res->a1 >> 16, -- res->a2, res->a2 >> 8, res->a2 >> 16, -- res->a2 >> 24, res->a3, res->a3 >> 8, -- res->a3 >> 16, res->a3 >> 24); -+ unsigned long timeout = jiffies + HZ / 2; -+ char *p = buf; -+ int cnt = 0; -+ u64 data; - -- return guid_equal(guid, &id); -+ /* Give up reading if no more data within 500ms. */ -+ while (count >= sizeof(data)) { -+ if (!cnt) { -+ cnt = readq(rsh_boot_cnt); -+ if (!cnt) { -+ if (time_after(jiffies, timeout)) -+ break; -+ udelay(10); -+ continue; -+ } -+ } -+ -+ data = readq(rsh_boot_data); -+ memcpy(p, &data, sizeof(data)); -+ count -= sizeof(data); -+ p += sizeof(data); -+ cnt--; -+ timeout = jiffies + HZ / 2; -+ } -+ -+ return p - buf; - } - --static int mlxbf_bootctl_probe(struct platform_device *pdev) -+static struct bin_attribute mbc_bootfifo_sysfs_attr = { -+ .attr = { .name = "bootfifo", .mode = 0400 }, -+ .read = mbc_bootfifo_read_raw, -+}; -+ -+static int mbc_probe(struct platform_device *pdev) - { -- struct arm_smccc_res res = { 0 }; -- guid_t guid; -- int ret; -+ struct resource *resource; -+ struct arm_smccc_res res; -+ void __iomem *data; -+ int err; - -- /* Ensure we have the UUID we expect for this service. */ -- arm_smccc_smc(MLXBF_BOOTCTL_SIP_SVC_UID, 0, 0, 0, 0, 0, 0, 0, &res); -- guid_parse(mlxbf_bootctl_svc_uuid_str, &guid); -- if (!mlxbf_bootctl_guid_match(&guid, &res)) -+ resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ if (!resource) - return -ENODEV; -+ rsh_boot_data = devm_ioremap_resource(&pdev->dev, resource); -+ if (IS_ERR(rsh_boot_data)) -+ return PTR_ERR(rsh_boot_data); -+ -+ resource = platform_get_resource(pdev, IORESOURCE_MEM, 1); -+ if (!resource) -+ return -ENODEV; -+ rsh_boot_cnt = devm_ioremap_resource(&pdev->dev, resource); -+ if (IS_ERR(rsh_boot_cnt)) -+ return PTR_ERR(rsh_boot_cnt); -+ -+ resource = platform_get_resource(pdev, IORESOURCE_MEM, 2); -+ if (resource) { -+ data = devm_ioremap_resource(&pdev->dev, resource); -+ if (!IS_ERR(data)) -+ rsh_semaphore = data; -+ } -+ -+ resource = platform_get_resource(pdev, IORESOURCE_MEM, 3); -+ if (resource) { -+ data = devm_ioremap_resource(&pdev->dev, resource); -+ if (!IS_ERR(data)) { -+ rsh_scratch_buf_ctl = data + RSH_SCRATCH_BUF_CTL_OFF; -+ rsh_scratch_buf_data = data + RSH_SCRATCH_BUF_DATA_OFF; -+ } -+ } - - /* -- * When watchdog is used, it sets boot mode to MLXBF_BOOTCTL_SWAP_EMMC -+ * Ensure we have the UUID we expect for this service. -+ * Note that the functionality we want is present in the first -+ * released version of this service, so we don't check the version. -+ */ -+ arm_smccc_smc(MLNX_SIP_SVC_UID, 0, 0, 0, 0, 0, 0, 0, &res); -+ if (res.a0 != 0x89c036b4 || res.a1 != 0x11e6e7d7 || -+ res.a2 != 0x1a009787 || res.a3 != 0xc4bf00ca) -+ return -ENODEV; -+ -+ /* -+ * When watchdog is used, it sets the boot mode to MLNX_BOOT_SWAP_EMMC - * in case of boot failures. However it doesn't clear the state if there - * is no failure. Restore the default boot mode here to avoid any - * unnecessary boot partition swapping. - */ -- ret = mlxbf_bootctl_smc(MLXBF_BOOTCTL_SET_RESET_ACTION, -- MLXBF_BOOTCTL_EMMC); -- if (ret < 0) -- dev_warn(&pdev->dev, "Unable to reset the EMMC boot mode\n"); -+ if (smc_call1(MLNX_SET_RESET_ACTION, MLNX_BOOT_EMMC) < 0) -+ pr_err("Unable to reset the EMMC boot mode\n"); -+ -+ err = sysfs_create_bin_file(&pdev->dev.kobj, &mbc_bootfifo_sysfs_attr); -+ if (err) { -+ pr_err("Unable to create bootfifo sysfs file, error %d\n", err); -+ return err; -+ } -+ -+ pr_info("%s (version %s)\n", DRIVER_DESCRIPTION, DRIVER_VERSION); -+ -+ return 0; -+} -+ -+static int mbc_remove(struct platform_device *pdev) -+{ -+ sysfs_remove_bin_file(&pdev->dev.kobj, &mbc_bootfifo_sysfs_attr); - - return 0; - } - --static struct platform_driver mlxbf_bootctl_driver = { -- .probe = mlxbf_bootctl_probe, -+static struct platform_driver mbc_driver = { -+ .probe = mbc_probe, -+ .remove = mbc_remove, - .driver = { -- .name = "mlxbf-bootctl", -- .dev_groups = mlxbf_bootctl_groups, -- .acpi_match_table = mlxbf_bootctl_acpi_ids, -+ .name = DRIVER_NAME, -+ .groups = mbc_attr_groups, -+ .of_match_table = mbc_dt_ids, -+ .acpi_match_table = ACPI_PTR(mbc_acpi_ids), - } - }; - --module_platform_driver(mlxbf_bootctl_driver); -+module_platform_driver(mbc_driver); - --MODULE_DESCRIPTION("Mellanox boot control driver"); --MODULE_LICENSE("GPL v2"); --MODULE_AUTHOR("Mellanox Technologies"); -+MODULE_DESCRIPTION(DRIVER_DESCRIPTION); -+MODULE_VERSION(DRIVER_VERSION); -+MODULE_AUTHOR("Shravan Kumar Ramani "); -+MODULE_LICENSE("Dual BSD/GPL"); -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h -index 148fdb43b435..3e9dda829d6d 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.h -+++ b/drivers/platform/mellanox/mlxbf-bootctl.h -@@ -1,11 +1,22 @@ --/* SPDX-License-Identifier: GPL-2.0 */ -+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause - /* -- * Copyright (c) 2019, Mellanox Technologies. All rights reserved. -+ * Copyright (C) 2020 Mellanox Technologies. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License v2.0 as published by -+ * the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. - */ - - #ifndef __MLXBF_BOOTCTL_H__ - #define __MLXBF_BOOTCTL_H__ - -+/* BlueField-specific SMC function IDs */ -+ - /* - * Request that the on-chip watchdog be enabled, or disabled, after - * the next chip soft reset. This call does not affect the current -@@ -14,14 +25,14 @@ - * will not be enabled after the next soft reset. Non-zero errors are - * returned as documented below. - */ --#define MLXBF_BOOTCTL_SET_POST_RESET_WDOG 0x82000000 -+#define MLNX_SET_POST_RESET_WDOG 0x82000000 - - /* - * Query the status which has been requested for the on-chip watchdog - * after the next chip soft reset. Returns the interval as set by -- * MLXBF_BOOTCTL_SET_POST_RESET_WDOG. -+ * MLNX_SET_POST_RESET_WDOG. - */ --#define MLXBF_BOOTCTL_GET_POST_RESET_WDOG 0x82000001 -+#define MLNX_GET_POST_RESET_WDOG 0x82000001 - - /* - * Request that a specific boot action be taken at the next soft -@@ -32,72 +43,77 @@ - * invoked. See below for the available MLNX_BOOT_xxx parameter - * values. Non-zero errors are returned as documented below. - */ --#define MLXBF_BOOTCTL_SET_RESET_ACTION 0x82000002 -+#define MLNX_SET_RESET_ACTION 0x82000002 - - /* - * Return the specific boot action which will be taken at the next - * soft reset. Returns the reset action (see below for the parameter -- * values for MLXBF_BOOTCTL_SET_RESET_ACTION). -+ * values for MLNX_SET_RESET_ACTION). - */ --#define MLXBF_BOOTCTL_GET_RESET_ACTION 0x82000003 -+#define MLNX_GET_RESET_ACTION 0x82000003 - - /* - * Request that a specific boot action be taken at the soft reset - * after the next soft reset. For a specified valid boot mode, the - * effect of this call is identical to that of invoking -- * MLXBF_BOOTCTL_SET_RESET_ACTION after the next chip soft reset; in -+ * MLNX_SET_RESET_ACTION after the next chip soft reset; in - * particular, after that reset, the action for the now next reset can -- * be queried with MLXBF_BOOTCTL_GET_RESET_ACTION and modified with -- * MLXBF_BOOTCTL_SET_RESET_ACTION. You may also specify the parameter as -+ * be queried with MLNX_GET_RESET_ACTION and modified with -+ * MLNX_SET_RESET_ACTION. You may also specify the parameter as - * MLNX_BOOT_NONE, which is equivalent to specifying that no call to -- * MLXBF_BOOTCTL_SET_RESET_ACTION be taken after the next chip soft reset. -+ * MLNX_SET_RESET_ACTION be taken after the next chip soft reset. - * This call does not affect the action to be taken at the next soft - * reset. Non-zero errors are returned as documented below. - */ --#define MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION 0x82000004 -+#define MLNX_SET_SECOND_RESET_ACTION 0x82000004 - - /* - * Return the specific boot action which will be taken at the soft - * reset after the next soft reset; this will be one of the valid -- * actions for MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION. -+ * actions for MLNX_SET_SECOND_RESET_ACTION. - */ --#define MLXBF_BOOTCTL_GET_SECOND_RESET_ACTION 0x82000005 -+#define MLNX_GET_SECOND_RESET_ACTION 0x82000005 - - /* - * Return the fuse status of the current chip. The caller should specify - * with the second argument if the state of the lifecycle fuses or the - * version of secure boot fuse keys left should be returned. - */ --#define MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS 0x82000006 -+#define MLNX_GET_TBB_FUSE_STATUS 0x82000006 - --/* Reset eMMC by programming the RST_N register. */ --#define MLXBF_BOOTCTL_SET_EMMC_RST_N 0x82000007 -+/* -+ * Initiate Firmware Reset via TYU. This might be invoked during the reset -+ * flow in isolation mode. -+ */ -+#define MLNX_HANDLE_FW_RESET 0x8200000D - --#define MLXBF_BOOTCTL_GET_DIMM_INFO 0x82000008 -+/* -+ * SMC function IDs to set, get and reset the manufacturing information -+ * stored within the eeprom. -+ */ -+#define MLNX_HANDLE_SET_MFG_INFO 0x8200000E -+#define MLNX_HANDLE_GET_MFG_INFO 0x8200000F -+#define MLNX_HANDLE_LOCK_MFG_INFO 0x82000011 - - /* SMC function IDs for SiP Service queries */ --#define MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT 0x8200ff00 --#define MLXBF_BOOTCTL_SIP_SVC_UID 0x8200ff01 --#define MLXBF_BOOTCTL_SIP_SVC_VERSION 0x8200ff03 -- --/* ARM Standard Service Calls version numbers */ --#define MLXBF_BOOTCTL_SVC_VERSION_MAJOR 0x0 --#define MLXBF_BOOTCTL_SVC_VERSION_MINOR 0x2 -+#define MLNX_SIP_SVC_CALL_COUNT 0x8200ff00 -+#define MLNX_SIP_SVC_UID 0x8200ff01 -+#define MLNX_SIP_SVC_VERSION 0x8200ff03 - - /* Number of svc calls defined. */ --#define MLXBF_BOOTCTL_NUM_SVC_CALLS 12 -+#define MLNX_NUM_SVC_CALLS 16 - --/* Valid reset actions for MLXBF_BOOTCTL_SET_RESET_ACTION. */ --#define MLXBF_BOOTCTL_EXTERNAL 0 /* Not boot from eMMC */ --#define MLXBF_BOOTCTL_EMMC 1 /* From primary eMMC boot partition */ --#define MLNX_BOOTCTL_SWAP_EMMC 2 /* Swap eMMC boot partitions and reboot */ --#define MLXBF_BOOTCTL_EMMC_LEGACY 3 /* From primary eMMC in legacy mode */ -+/* Valid reset actions for MLNX_SET_RESET_ACTION. */ -+#define MLNX_BOOT_EXTERNAL 0 /* Do not boot from eMMC */ -+#define MLNX_BOOT_EMMC 1 /* Boot from primary eMMC boot partition */ -+#define MLNX_BOOT_SWAP_EMMC 2 /* Swap eMMC boot partitions and reboot */ -+#define MLNX_BOOT_EMMC_LEGACY 3 /* Boot from primary eMMC in legacy mode */ - - /* Valid arguments for requesting the fuse status. */ --#define MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE 0 /* Return lifecycle status. */ --#define MLXBF_BOOTCTL_FUSE_STATUS_KEYS 1 /* Return secure boot key status */ -+#define MLNX_FUSE_STATUS_LIFECYCLE 0 /* Return the lifecycle status. */ -+#define MLNX_FUSE_STATUS_KEYS 1 /* Return secure boot key status */ - --/* Additional value to disable the MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION. */ --#define MLXBF_BOOTCTL_NONE 0x7fffffff /* Don't change next boot action */ -+/* Additional parameter value to disable the MLNX_SET_SECOND_RESET_ACTION. */ -+#define MLNX_BOOT_NONE 0x7fffffff /* Don't change next boot action */ - - #endif /* __MLXBF_BOOTCTL_H__ */ --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch b/recipes-kernel/linux/linux-6.1/0076-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch similarity index 94% rename from recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch rename to recipes-kernel/linux/linux-6.1/0076-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch index 9dc9c9862..81092b99a 100644 --- a/recipes-kernel/linux/linux-6.1/0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch +++ b/recipes-kernel/linux/linux-6.1/0076-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch @@ -1,10 +1,7 @@ -From 0d3a669288079d5a197b95d1a4615301e61fb039 Mon Sep 17 00:00:00 2001 +From 2321d69f92aa7e6aa2cc98e7a8e005566943922f Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 12 Jan 2023 15:26:06 -0500 -Subject: [PATCH backport 6.1.42 72/85] mlxbf_gige: add MDIO support for - BlueField-3 - -BugLink: https://bugs.launchpad.net/bugs/2012649 +Subject: [PATCH] mlxbf_gige: add MDIO support for BlueField-3 This patch adds initial MDIO support for the BlueField-3 SoC. Separate header files for the BlueField-2 and the @@ -19,19 +16,14 @@ a mlxbf_gige_mdio_gw_t struct was created for this purpose. Signed-off-by: David Thompson Signed-off-by: Asmaa Mnebhi Signed-off-by: Jakub Kicinski -(cherry picked from commit 2321d69f92aa7e6aa2cc98e7a8e005566943922f) -Signed-off-by: David Thompson -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz --- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 19 ++ .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 2 + - .../mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 178 +++++++++++++----- + .../mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 172 +++++++++++++----- .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h | 53 ++++++ .../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h | 54 ++++++ .../mellanox/mlxbf_gige/mlxbf_gige_regs.h | 1 + - 6 files changed, 256 insertions(+), 51 deletions(-) + 6 files changed, 251 insertions(+), 50 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h @@ -73,7 +65,7 @@ index 5a1027b07215..421a0b1b766c 100644 /* Rx Work Queue Element definitions */ diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c -index eafc0d3313fd..a3bd14d5dbff 100644 +index 2292d63a279c..e08c07e914c1 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -315,6 +315,8 @@ static int mlxbf_gige_probe(struct platform_device *pdev) @@ -86,7 +78,7 @@ index eafc0d3313fd..a3bd14d5dbff 100644 err = mlxbf_gige_mdio_probe(pdev, priv); if (err) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c -index aa780b1614a3..4ee3df30c402 100644 +index aa780b1614a3..7ac06fd31011 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c @@ -23,9 +23,75 @@ @@ -327,23 +319,17 @@ index aa780b1614a3..4ee3df30c402 100644 } int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) -@@ -230,7 +297,14 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) +@@ -230,6 +297,9 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) struct resource *res; int ret; -- priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9); + if (priv->hw_version > MLXBF_GIGE_VERSION_BF3) + return -ENODEV; + -+ res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_MDIO9); -+ if (!res) -+ return -ENODEV; -+ -+ priv->mdio_io = devm_ioremap_resource(dev, res); + priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9); if (IS_ERR(priv->mdio_io)) return PTR_ERR(priv->mdio_io); - -@@ -242,13 +316,15 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) +@@ -242,13 +312,15 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) /* For backward compatibility with older ACPI tables, also keep * CLK resource internal to the driver. */ @@ -492,5 +478,5 @@ index 7be3a793984d..8d52dbef4adf 100644 #define MLXBF_GIGE_STATUS_READY BIT(0) #define MLXBF_GIGE_INT_STATUS 0x0028 -- -2.20.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch b/recipes-kernel/linux/linux-6.1/0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch deleted file mode 100644 index f46df5f9d..000000000 --- a/recipes-kernel/linux/linux-6.1/0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 61618188dadb1cc9b6708916e0e7a1c2e31d469d Mon Sep 17 00:00:00 2001 -From: Asmaa Mnebhi -Date: Mon, 31 Oct 2022 12:18:52 -0400 -Subject: [PATCH backport 6.1.42 77/85] UBUNTU: SAUCE: mlx-bootctl: support icm - carveout eeprom region read/write - -BugLink: https://bugs.launchpad.net/bugs/1995296 - -The BlueField-3 ICM carveout feature will enable NIC FW to bypass the SMMU block -to access DRAM memory. The amount of memory accessible by FW will be controlled by ARM. -This patch enables setting the size of the large ICM carveout from -userspace. The max size is 1TB, has a granularity of 128MB and will be passed -and printed in hex. The size unit is MB. - -Signed-off-by: Asmaa Mnebhi -Acked-by: Tim Gardner -Acked-by: Cory Todd -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/platform/mellanox/mlxbf-bootctl.c | 40 +++++++++++++++++++++++ - drivers/platform/mellanox/mlxbf-bootctl.h | 9 +++++ - 2 files changed, 49 insertions(+) - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c -index 2302e1e09c7e..e8877a19dda9 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.c -+++ b/drivers/platform/mellanox/mlxbf-bootctl.c -@@ -104,6 +104,7 @@ enum { - - /* This mutex is used to serialize MFG write and lock operations. */ - static DEFINE_MUTEX(mfg_ops_lock); -+static DEFINE_MUTEX(icm_ops_lock); - - #define MLNX_MFG_OOB_MAC_LEN ETH_ALEN - #define MLNX_MFG_OPN_VAL_LEN 24 -@@ -383,6 +384,43 @@ static ssize_t oob_mac_store(struct device_driver *drv, const char *buf, - return res.a0 ? -EPERM : count; - } - -+static ssize_t large_icm_show(struct device_driver *drv, char *buf) -+{ -+ char icm_str[MAX_ICM_BUFFER_SIZE] = { 0 }; -+ struct arm_smccc_res res; -+ -+ arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0, -+ 0, 0, 0, &res); -+ if (res.a0) -+ return -EPERM; -+ -+ sprintf(icm_str, "0x%lx", res.a1); -+ -+ return snprintf(buf, sizeof(icm_str), "%s", icm_str); -+} -+ -+static ssize_t large_icm_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ struct arm_smccc_res res; -+ unsigned long icm_data; -+ int err; -+ -+ err = kstrtoul(buf, 16, &icm_data); -+ if (err) -+ return err; -+ -+ if (((icm_data != 0) && (icm_data < 0x80)) || -+ (icm_data > 0x100000) || (icm_data % 128)) -+ return -EPERM; -+ -+ mutex_lock(&icm_ops_lock); -+ arm_smccc_smc(MLNX_HANDLE_SET_ICM_INFO, icm_data, 0, 0, 0, 0, 0, 0, &res); -+ mutex_unlock(&icm_ops_lock); -+ -+ return res.a0 ? -EPERM : count; -+} -+ - static ssize_t opn_show(struct device_driver *drv, char *buf) - { - u64 opn_data[MLNX_MFG_VAL_QWORD_CNT(OPN)] = { 0 }; -@@ -1170,6 +1208,7 @@ static DRIVER_ATTR_RW(uuid); - static DRIVER_ATTR_RW(rev); - static DRIVER_ATTR_WO(mfg_lock); - static DRIVER_ATTR_RW(rsh_log); -+static DRIVER_ATTR_RW(large_icm); - - static struct attribute *mbc_dev_attrs[] = { - &driver_attr_post_reset_wdog.attr, -@@ -1187,6 +1226,7 @@ static struct attribute *mbc_dev_attrs[] = { - &driver_attr_rev.attr, - &driver_attr_mfg_lock.attr, - &driver_attr_rsh_log.attr, -+ &driver_attr_large_icm.attr, - NULL - }; - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h -index 3e9dda829d6d..c70204770af3 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.h -+++ b/drivers/platform/mellanox/mlxbf-bootctl.h -@@ -95,6 +95,15 @@ - #define MLNX_HANDLE_GET_MFG_INFO 0x8200000F - #define MLNX_HANDLE_LOCK_MFG_INFO 0x82000011 - -+/* -+ * SMC function IDs to set and get the large ICM carveout size -+ * stored in the eeprom. -+ */ -+#define MLNX_HANDLE_SET_ICM_INFO 0x82000012 -+#define MLNX_HANDLE_GET_ICM_INFO 0x82000013 -+ -+#define MAX_ICM_BUFFER_SIZE 10 -+ - /* SMC function IDs for SiP Service queries */ - #define MLNX_SIP_SVC_CALL_COUNT 0x8200ff00 - #define MLNX_SIP_SVC_UID 0x8200ff01 --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch b/recipes-kernel/linux/linux-6.1/0077-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch similarity index 93% rename from recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch rename to recipes-kernel/linux/linux-6.1/0077-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch index de0aab883..92594d9a0 100644 --- a/recipes-kernel/linux/linux-6.1/0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch +++ b/recipes-kernel/linux/linux-6.1/0077-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch @@ -1,10 +1,7 @@ -From 4c1187581e9c7dc8cf354278c3257d8542209269 Mon Sep 17 00:00:00 2001 +From 20d03d4d9437771a9b6d38d4a6027a70d78d9865 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 12 Jan 2023 15:26:07 -0500 -Subject: [PATCH backport 6.1.42 73/85] mlxbf_gige: support 10M/100M/1G speeds - on BlueField-3 - -BugLink: https://bugs.launchpad.net/bugs/2012649 +Subject: [PATCH] mlxbf_gige: support 10M/100M/1G speeds on BlueField-3 The BlueField-3 OOB interface supports 10Mbps, 100Mbps, and 1Gbps speeds. The external PHY is responsible for autonegotiating the speed with the @@ -20,11 +17,6 @@ Signed-off-by: David Thompson Signed-off-by: Asmaa Mnebhi Reviewed-by: Andrew Lunn Signed-off-by: Jakub Kicinski -(cherry picked from commit 20d03d4d9437771a9b6d38d4a6027a70d78d9865) -Signed-off-by: David Thompson -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz --- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 8 ++ .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 105 +++++++++++++++--- @@ -65,7 +57,7 @@ index 421a0b1b766c..a453b9cd9033 100644 /* Rx Work Queue Element definitions */ diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c -index a3bd14d5dbff..0af086703bcd 100644 +index e08c07e914c1..32d7030eb2cf 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -263,13 +263,99 @@ static const struct net_device_ops mlxbf_gige_netdev_ops = { @@ -236,5 +228,5 @@ index 8d52dbef4adf..cd0973229c9b 100644 + #endif /* !defined(__MLXBF_GIGE_REGS_H__) */ -- -2.20.1 +2.44.0 diff --git a/recipes-kernel/linux/linux-6.1/0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch b/recipes-kernel/linux/linux-6.1/0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch deleted file mode 100644 index 94cc1d37b..000000000 --- a/recipes-kernel/linux/linux-6.1/0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 63f46d5beb56293f64ebb39f94a005acbe381f25 Mon Sep 17 00:00:00 2001 -From: Asmaa Mnebhi -Date: Thu, 30 Mar 2023 14:42:33 -0400 -Subject: [PATCH backport 6.1.42 78/85] UBUNTU: SAUCE: mlxbf-bootctl: support - SMC call for setting ARM boot state - -BugLink: https://bugs.launchpad.net/bugs/2013383 - -Add a new SMC call which allows setting the ARM boot progress state to "OS is up". - -Signed-off-by: Asmaa Mnebhi -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/platform/mellanox/mlxbf-bootctl.c | 23 +++++++++++++++++++++++ - drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++ - 2 files changed, 28 insertions(+) - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c -index e8877a19dda9..a68bf5b27013 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.c -+++ b/drivers/platform/mellanox/mlxbf-bootctl.c -@@ -105,6 +105,7 @@ enum { - /* This mutex is used to serialize MFG write and lock operations. */ - static DEFINE_MUTEX(mfg_ops_lock); - static DEFINE_MUTEX(icm_ops_lock); -+static DEFINE_MUTEX(os_up_lock); - - #define MLNX_MFG_OOB_MAC_LEN ETH_ALEN - #define MLNX_MFG_OPN_VAL_LEN 24 -@@ -747,6 +748,26 @@ static ssize_t mfg_lock_store(struct device_driver *drv, const char *buf, - return count; - } - -+static ssize_t os_up_store(struct device_driver *drv, const char *buf, -+ size_t count) -+{ -+ unsigned long val; -+ int err; -+ -+ err = kstrtoul(buf, 10, &val); -+ if (err) -+ return err; -+ -+ if (val != 1) -+ return -EINVAL; -+ -+ mutex_lock(&os_up_lock); -+ smc_call0(MLNX_HANDLE_OS_UP); -+ mutex_unlock(&os_up_lock); -+ -+ return count; -+} -+ - /* Log header format. */ - #define RSH_LOG_TYPE_SHIFT 56 - #define RSH_LOG_LEN_SHIFT 48 -@@ -1209,6 +1230,7 @@ static DRIVER_ATTR_RW(rev); - static DRIVER_ATTR_WO(mfg_lock); - static DRIVER_ATTR_RW(rsh_log); - static DRIVER_ATTR_RW(large_icm); -+static DRIVER_ATTR_WO(os_up); - - static struct attribute *mbc_dev_attrs[] = { - &driver_attr_post_reset_wdog.attr, -@@ -1227,6 +1249,7 @@ static struct attribute *mbc_dev_attrs[] = { - &driver_attr_mfg_lock.attr, - &driver_attr_rsh_log.attr, - &driver_attr_large_icm.attr, -+ &driver_attr_os_up.attr, - NULL - }; - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h -index c70204770af3..dc73f7e88914 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.h -+++ b/drivers/platform/mellanox/mlxbf-bootctl.h -@@ -102,6 +102,11 @@ - #define MLNX_HANDLE_SET_ICM_INFO 0x82000012 - #define MLNX_HANDLE_GET_ICM_INFO 0x82000013 - -+/* -+ * SMC function ID to set the ARM boot state to up -+ */ -+#define MLNX_HANDLE_OS_UP 0x82000014 -+ - #define MAX_ICM_BUFFER_SIZE 10 - - /* SMC function IDs for SiP Service queries */ --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch b/recipes-kernel/linux/linux-6.1/0078-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch similarity index 84% rename from recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch rename to recipes-kernel/linux/linux-6.1/0078-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch index e3dc4f7f8..e4fcc1e27 100644 --- a/recipes-kernel/linux/linux-6.1/0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch +++ b/recipes-kernel/linux/linux-6.1/0078-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch @@ -1,8 +1,7 @@ -From 58d63cc90771fb493f5cf735a05eb95331041be3 Mon Sep 17 00:00:00 2001 +From 7acd9b79a55a607d878aa7cff6dddb54494ae030 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 12 Jan 2023 15:26:08 -0500 -Subject: [PATCH backport 6.1.42 74/85] mlxbf_gige: add "set_link_ksettings" - ethtool callback +Subject: [PATCH] mlxbf_gige: add "set_link_ksettings" ethtool callback BugLink: https://bugs.launchpad.net/bugs/2012649 @@ -25,15 +24,15 @@ Signed-off-by: Bartlomiej Zolnierkiewicz +Date: Fri, 19 Jan 2024 12:19:05 -0500 +Subject: [PATCH] UBUNTU: SAUCE: mlxbf_gige: add RX_DMA disable to NAPI poll + routine + +BugLink: https://bugs.launchpad.net/bugs/2049930 + +After configuring many IP interfaces, including oob_net0 managed by +mlxbf_gige driver, there are periodic connectivity problems to the +oob_net0 IP address. This issue is a regression that started after +including these two commits into the kernel: + revert "UBUNTU: SAUCE: Fix OOB handling RX packets in heavy traffic" + addition of upstream "mlxbf_gige: fix receive packet race condition" +The fix is to modify the mlxbf_gige driver to include the RX_DMA disable +logic in its NAPI poll routine. This logic was part of + "UBUNTU: SAUCE: Fix OOB handling RX packets in heavy traffic" +but not part of + upstream "mlxbf_gige: fix receive packet race condition" + +Reviewed-by: Asmaa Mnebhi +Signed-off-by: David Thompson +Acked-by: Bartlomiej Zolnierkiewicz +Acked-by: Tim Gardner +Signed-off-by: Bartlomiej Zolnierkiewicz +--- + drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +index 1a1eca08bfb9..a18fa860e5cc 100644 +--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c ++++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +@@ -308,6 +308,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) + + mlxbf_gige_handle_tx_complete(priv); + ++ data = readq(priv->base + MLXBF_GIGE_RX_DMA); ++ data &= ~MLXBF_GIGE_RX_DMA_EN; ++ writeq(data, priv->base + MLXBF_GIGE_RX_DMA); ++ + do { + remaining_pkts = mlxbf_gige_rx_packet(priv, &work_done); + } while (remaining_pkts && work_done < budget); +@@ -323,6 +327,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) + data = readq(priv->base + MLXBF_GIGE_INT_MASK); + data &= ~MLXBF_GIGE_INT_MASK_RX_RECEIVE_PACKET; + writeq(data, priv->base + MLXBF_GIGE_INT_MASK); ++ ++ data = readq(priv->base + MLXBF_GIGE_RX_DMA); ++ data |= MLXBF_GIGE_RX_DMA_EN; ++ writeq(data, priv->base + MLXBF_GIGE_RX_DMA); + } + + return work_done; +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0080-mlxbf-bootctl-correctly-identify-secure-boot-with-de.patch b/recipes-kernel/linux/linux-6.1/0080-mlxbf-bootctl-correctly-identify-secure-boot-with-de.patch new file mode 100644 index 000000000..55ceb4eb7 --- /dev/null +++ b/recipes-kernel/linux/linux-6.1/0080-mlxbf-bootctl-correctly-identify-secure-boot-with-de.patch @@ -0,0 +1,123 @@ +From eb08f30b9d4a0d9a82fc6a2d5365d146e97c2ca7 Mon Sep 17 00:00:00 2001 +From: David Thompson +Date: Thu, 30 Nov 2023 13:35:15 -0500 +Subject: [PATCH] mlxbf-bootctl: correctly identify secure boot with + development keys +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BugLink: https://bugs.launchpad.net/bugs/2050858 + +[ Upstream commit d4eef75279f5e9d594f5785502038c763ce42268 ] + +The secure boot state of the BlueField SoC is represented by two bits: + 0 = production state + 1 = secure boot enabled + 2 = non-secure (secure boot disabled) + 3 = RMA state +There is also a single bit to indicate whether production keys or +development keys are being used when secure boot is enabled. +This single bit (specified by MLXBF_BOOTCTL_SB_DEV_MASK) only has +meaning if secure boot state equals 1 (secure boot enabled). + +The secure boot states are as follows: +- “GA secured” is when secure boot is enabled with official production keys. +- “Secured (development)” is when secure boot is enabled with development keys. + +Without this fix “GA Secured” is displayed on development cards which is +misleading. This patch updates the logic in "lifecycle_state_show()" to +handle the case where the SoC is configured for secure boot and is using +development keys. + +Fixes: 79e29cb8fbc5c ("platform/mellanox: Add bootctl driver for Mellanox BlueField Soc") +Reviewed-by: Khalil Blaiech +Signed-off-by: David Thompson +Link: https://lore.kernel.org/r/20231130183515.17214-1-davthompson@nvidia.com +Reviewed-by: Ilpo Järvinen +Signed-off-by: Ilpo Järvinen +Signed-off-by: Sasha Levin +Signed-off-by: Portia Stephens +Signed-off-by: Stefan Bader +--- + drivers/platform/mellanox/mlxbf-bootctl.c | 39 +++++++++++++++-------- + 1 file changed, 26 insertions(+), 13 deletions(-) + +diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c +index 1c7a288b59a5..6a171a4f9dc6 100644 +--- a/drivers/platform/mellanox/mlxbf-bootctl.c ++++ b/drivers/platform/mellanox/mlxbf-bootctl.c +@@ -17,6 +17,7 @@ + + #define MLXBF_BOOTCTL_SB_SECURE_MASK 0x03 + #define MLXBF_BOOTCTL_SB_TEST_MASK 0x0c ++#define MLXBF_BOOTCTL_SB_DEV_MASK BIT(4) + + #define MLXBF_SB_KEY_NUM 4 + +@@ -37,11 +38,18 @@ static struct mlxbf_bootctl_name boot_names[] = { + { MLXBF_BOOTCTL_NONE, "none" }, + }; + ++enum { ++ MLXBF_BOOTCTL_SB_LIFECYCLE_PRODUCTION = 0, ++ MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE = 1, ++ MLXBF_BOOTCTL_SB_LIFECYCLE_GA_NON_SECURE = 2, ++ MLXBF_BOOTCTL_SB_LIFECYCLE_RMA = 3 ++}; ++ + static const char * const mlxbf_bootctl_lifecycle_states[] = { +- [0] = "Production", +- [1] = "GA Secured", +- [2] = "GA Non-Secured", +- [3] = "RMA", ++ [MLXBF_BOOTCTL_SB_LIFECYCLE_PRODUCTION] = "Production", ++ [MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE] = "GA Secured", ++ [MLXBF_BOOTCTL_SB_LIFECYCLE_GA_NON_SECURE] = "GA Non-Secured", ++ [MLXBF_BOOTCTL_SB_LIFECYCLE_RMA] = "RMA", + }; + + /* ARM SMC call which is atomic and no need for lock. */ +@@ -165,25 +173,30 @@ static ssize_t second_reset_action_store(struct device *dev, + static ssize_t lifecycle_state_show(struct device *dev, + struct device_attribute *attr, char *buf) + { ++ int status_bits; ++ int use_dev_key; ++ int test_state; + int lc_state; + +- lc_state = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS, +- MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE); +- if (lc_state < 0) +- return lc_state; ++ status_bits = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS, ++ MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE); ++ if (status_bits < 0) ++ return status_bits; + +- lc_state &= +- MLXBF_BOOTCTL_SB_TEST_MASK | MLXBF_BOOTCTL_SB_SECURE_MASK; ++ use_dev_key = status_bits & MLXBF_BOOTCTL_SB_DEV_MASK; ++ test_state = status_bits & MLXBF_BOOTCTL_SB_TEST_MASK; ++ lc_state = status_bits & MLXBF_BOOTCTL_SB_SECURE_MASK; + + /* + * If the test bits are set, we specify that the current state may be + * due to using the test bits. + */ +- if (lc_state & MLXBF_BOOTCTL_SB_TEST_MASK) { +- lc_state &= MLXBF_BOOTCTL_SB_SECURE_MASK; +- ++ if (test_state) { + return sprintf(buf, "%s(test)\n", + mlxbf_bootctl_lifecycle_states[lc_state]); ++ } else if (use_dev_key && ++ (lc_state == MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE)) { ++ return sprintf(buf, "Secured (development)\n"); + } + + return sprintf(buf, "%s\n", mlxbf_bootctl_lifecycle_states[lc_state]); +-- +2.44.0 + diff --git a/recipes-kernel/linux/linux-6.1/0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch b/recipes-kernel/linux/linux-6.1/0081-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch similarity index 96% rename from recipes-kernel/linux/linux-6.1/0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch rename to recipes-kernel/linux/linux-6.1/0081-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch index 1b7f14260..365c9d27f 100644 --- a/recipes-kernel/linux/linux-6.1/0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch +++ b/recipes-kernel/linux/linux-6.1/0081-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch @@ -22,12 +22,12 @@ Signed-off-by: Bartlomiej Zolnierkiewicz -Date: Wed, 22 Mar 2023 11:39:56 -0400 -Subject: [PATCH backport 6.1.42 82/85] UBUNTU: SAUCE: mlxbf-ptm: add atx - debugfs nodes - -BugLink: https://bugs.launchpad.net/bugs/2011738 - -Add additional debugfs nodes that provide ATX status and -power profile data. - -Signed-off-by: Jitendra Lanka -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/platform/mellanox/mlxbf-ptm.c | 36 +++++++++++++++++++++++++++ - 1 file changed, 36 insertions(+) - -diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c -index aeb68dc42e32..a2845aa57c5b 100644 ---- a/drivers/platform/mellanox/mlxbf-ptm.c -+++ b/drivers/platform/mellanox/mlxbf-ptm.c -@@ -23,6 +23,9 @@ - #define MLNX_PTM_GET_MAX_TEMP 0x82000108 - #define MLNX_PTM_GET_PWR_EVT_CNT 0x82000109 - #define MLNX_PTM_GET_TEMP_EVT_CNT 0x8200010A -+#define MLNX_PTM_GET_POWER_ENVELOPE 0x8200010B -+#define MLNX_PTM_GET_ATX_PWR_STATE 0x8200010C -+#define MLNX_PTM_GET_CUR_PPROFILE 0x8200010D - - #define MLNX_POWER_ERROR 300 - -@@ -142,6 +145,33 @@ static int error_status_show(void *data, u64 *val) - DEFINE_SIMPLE_ATTRIBUTE(error_status_fops, - error_status_show, NULL, "%llu\n"); - -+static int power_envelope_show(void *data, u64 *val) -+{ -+ *val = smc_call0(MLNX_PTM_GET_POWER_ENVELOPE); -+ -+ return 0; -+} -+DEFINE_SIMPLE_ATTRIBUTE(power_envelope_fops, -+ power_envelope_show, NULL, "%llu\n"); -+ -+static int atx_status_show(void *data, u64 *val) -+{ -+ *val = smc_call0(MLNX_PTM_GET_ATX_PWR_STATE); -+ -+ return 0; -+} -+DEFINE_SIMPLE_ATTRIBUTE(atx_status_fops, -+ atx_status_show, NULL, "%lld\n"); -+ -+static int current_pprofile_show(void *data, u64 *val) -+{ -+ *val = smc_call0(MLNX_PTM_GET_CUR_PPROFILE); -+ -+ return 0; -+} -+DEFINE_SIMPLE_ATTRIBUTE(current_pprofile_fops, -+ current_pprofile_show, NULL, "%llu\n"); -+ - - static int __init mlxbf_ptm_init(void) - { -@@ -176,6 +206,12 @@ static int __init mlxbf_ptm_init(void) - NULL, &tthrottling_state_fops); - debugfs_create_file("error_state", 0444, status, - NULL, &error_status_fops); -+ debugfs_create_file("power_envelope", 0444, status, -+ NULL, &power_envelope_fops); -+ debugfs_create_file("atx_power_available", 0444, status, -+ NULL, &atx_status_fops); -+ debugfs_create_file("active_power_profile", 0444, status, -+ NULL, ¤t_pprofile_fops); - - return 0; - } --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0080-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch b/recipes-kernel/linux/linux-6.1/0082-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch similarity index 100% rename from recipes-kernel/linux/linux-6.1/0080-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch rename to recipes-kernel/linux/linux-6.1/0082-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch diff --git a/recipes-kernel/linux/linux-6.1/0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch b/recipes-kernel/linux/linux-6.1/0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch deleted file mode 100644 index 4498da412..000000000 --- a/recipes-kernel/linux/linux-6.1/0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch +++ /dev/null @@ -1,31 +0,0 @@ -From efaf25dc1e11de91140b9010e743182bc763124c Mon Sep 17 00:00:00 2001 -From: Jitendra Lanka -Date: Wed, 22 Mar 2023 11:39:57 -0400 -Subject: [PATCH backport 6.1.42 83/85] UBUNTU: SAUCE: mlxbf-ptm: update module - version - -BugLink: https://bugs.launchpad.net/bugs/2011738 - -update module version - -Signed-off-by: Jitendra Lanka -Acked-by: Tim Gardner -Acked-by: Bartlomiej Zolnierkiewicz -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/platform/mellanox/mlxbf-ptm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c -index a2845aa57c5b..eb4460cb058b 100644 ---- a/drivers/platform/mellanox/mlxbf-ptm.c -+++ b/drivers/platform/mellanox/mlxbf-ptm.c -@@ -227,4 +227,4 @@ module_exit(mlxbf_ptm_exit); - MODULE_AUTHOR("Jitendra Lanka "); - MODULE_DESCRIPTION("Nvidia Bluefield power and thermal debugfs driver"); - MODULE_LICENSE("Dual BSD/GPL"); --MODULE_VERSION("1.0"); -+MODULE_VERSION("1.1"); --- -2.20.1 - diff --git a/recipes-kernel/linux/linux-6.1/0081-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch b/recipes-kernel/linux/linux-6.1/0083-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch similarity index 100% rename from recipes-kernel/linux/linux-6.1/0081-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch rename to recipes-kernel/linux/linux-6.1/0083-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch diff --git a/recipes-kernel/linux/linux-6.1/0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch b/recipes-kernel/linux/linux-6.1/0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch deleted file mode 100644 index 433d88f13..000000000 --- a/recipes-kernel/linux/linux-6.1/0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 9c9944b7c98fc61161c204b7ef397a3ac05977ba Mon Sep 17 00:00:00 2001 -From: Asmaa Mnebhi -Date: Thu, 20 Jul 2023 16:37:37 -0400 -Subject: [PATCH backport 6.1.42 13/20] UBUNTU: SAUCE: mlxbf-bootctl: Fix - kernel panic due to buffer overflow - -BugLink: https://bugs.launchpad.net/bugs/2028309 - -Running the following LTP (linux-test-project) script, causes -a kernel panic and a reboot of the DPU: -ltp/testcases/bin/read_all -d /sys -q -r 10 - -The above test reads all directory and files under /sys. -Reading the sysfs entry "large_icm" causes the kernel panic -due to a garbage value returned via i2c read. That garbage -value causes a buffer overflow in sprintf. - -Replace sprintf with snprintf. And also add missing lock and -increase the buffer size to PAGE_SIZE. - -Signed-off-by: Asmaa Mnebhi -Acked-by: Bartlomiej Zolnierkiewicz -Acked-by: Tim Gardner -Signed-off-by: Bartlomiej Zolnierkiewicz ---- - drivers/platform/mellanox/mlxbf-bootctl.c | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c -index a68bf5b27013..52666ee360b2 100644 ---- a/drivers/platform/mellanox/mlxbf-bootctl.c -+++ b/drivers/platform/mellanox/mlxbf-bootctl.c -@@ -387,17 +387,16 @@ static ssize_t oob_mac_store(struct device_driver *drv, const char *buf, - - static ssize_t large_icm_show(struct device_driver *drv, char *buf) - { -- char icm_str[MAX_ICM_BUFFER_SIZE] = { 0 }; - struct arm_smccc_res res; - -+ mutex_lock(&icm_ops_lock); - arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0, - 0, 0, 0, &res); -+ mutex_unlock(&icm_ops_lock); - if (res.a0) - return -EPERM; - -- sprintf(icm_str, "0x%lx", res.a1); -- -- return snprintf(buf, sizeof(icm_str), "%s", icm_str); -+ return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1); - } - - static ssize_t large_icm_store(struct device_driver *drv, const char *buf, --- -2.25.1 -