6.11.11-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 513/817 PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 7d7cf89b119af433354f865fc01017b9f8aa411a ]
Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF deinit notify function pci_epc_deinit_notify() are called during the execution of qcom_pcie_perst_assert() i.e., when the host has asserted PERST#. But quickly after this step, refclk will also be disabled by the host.
All of the Qcom endpoint SoCs supported as of now depend on the refclk from the host for keeping the controller operational. Due to this limitation, any access to the hardware registers in the absence of refclk will result in a whole endpoint crash. Unfortunately, most of the controller cleanups require accessing the hardware registers (like eDMA cleanup performed in dw_pcie_ep_cleanup(), powering down MHI EPF etc...). So these cleanup functions are currently causing the crash in the endpoint SoC once host asserts PERST#.
One way to address this issue is by generating the refclk in the endpoint itself and not depending on the host. But that is not always possible as some of the endpoint designs do require the endpoint to consume refclk from the host (as I was told by the Qcom engineers).
Thus, fix this crash by moving the controller cleanups to the start of the qcom_pcie_perst_deassert() function. qcom_pcie_perst_deassert() is called whenever the host has deasserted PERST# and it is guaranteed that the refclk would be active at this point. So at the start of this function (after enabling resources), the controller cleanup can be performed. Once finished, rest of the code execution for PERST# deassert can continue as usual.
--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-qcom-ep.c +4 -2
@@ -395,6 +395,10 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)return ret; } +/* Perform cleanup that requires refclk */ +pci_epc_deinit_notify (pci->ep.epc); +dw_pcie_ep_cleanup (&pci->ep); +/* Assert WAKE# to RC to indicate device is ready */ gpiod_set_value_cansleep (pcie_ep->wake,1 );usleep_range (WAKE_DELAY_US ,WAKE_DELAY_US +500 );
@@ -534,8 +538,6 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci) {struct qcom_pcie_ep *pcie_ep =to_pcie_ep (pci); -pci_epc_deinit_notify (pci->ep.epc); -dw_pcie_ep_cleanup (&pci->ep);qcom_pcie_disable_resources (pcie_ep); pcie_ep->link_status =QCOM_PCIE_EP_LINK_DISABLED ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 514/817 PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 40e2125381dc11379112485e3eefdd25c6df5375 ]
Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF deinit notify function pci_epc_deinit_notify() are called during the execution of pex_ep_event_pex_rst_assert() i.e., when the host has asserted PERST#. But quickly after this step, refclk will also be disabled by the host.
All of the tegra194 endpoint SoCs supported as of now depend on the refclk from the host for keeping the controller operational. Due to this limitation, any access to the hardware registers in the absence of refclk will result in a whole endpoint crash. Unfortunately, most of the controller cleanups require accessing the hardware registers (like eDMA cleanup performed in dw_pcie_ep_cleanup(), etc...). So these cleanup functions can cause the crash in the endpoint SoC once host asserts PERST#.
One way to address this issue is by generating the refclk in the endpoint itself and not depending on the host. But that is not always possible as some of the endpoint designs do require the endpoint to consume refclk from the host.
Thus, fix this crash by moving the controller cleanups to the start of the pex_ep_event_pex_rst_deassert() function. This function is called whenever the host has deasserted PERST# and it is guaranteed that the refclk would be active at this point. So at the start of this function (after enabling resources) the controller cleanup can be performed. Once finished, rest of the code execution for PERST# deassert can continue as usual.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +4 -3
@@ -1709,9 +1709,6 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)if (ret)dev_err (pcie->dev,"Failed to go Detect state: %d\n" , ret); -pci_epc_deinit_notify (pcie->pci.ep.epc); -dw_pcie_ep_cleanup (&pcie->pci.ep); -reset_control_assert (pcie->core_rst);tegra_pcie_disable_phy (pcie);
@@ -1790,6 +1787,10 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie) goto fail_phy; } +/* Perform cleanup that requires refclk */ +pci_epc_deinit_notify (pcie->pci.ep.epc); +dw_pcie_ep_cleanup (&pcie->pci.ep); +/* Clear any stale interrupt statuses */ appl_writel (pcie,0xFFFFFFFF ,APPL_INTR_STATUS_L0 );appl_writel (pcie,0xFFFFFFFF ,APPL_INTR_STATUS_L1_0_0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 515/817 PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richard <[email protected]>
[ Upstream commit d1b6f2e2ce4d8b17d9f3558c98a1517b864bfd03 ]
The function cdns_pcie_host_setup() mixes probe structure and link setup.
The link setup must be done during the resume sequence. So extract it from cdns_pcie_host_setup() and create a dedicated function.
Stable-dep-of: 22a9120479a4 ("PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds")
--- .../controller/cadence/pcie-cadence-host.c | 39 ++++++++++++------- drivers/pci/controller/cadence/pcie-cadence.h | 6 +++ 2 files changed, 32 insertions(+), 13 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +26 -13
@@ -497,6 +497,30 @@ static int cdns_pcie_host_init(struct device *dev,return cdns_pcie_host_init_address_translation (rc); } +int cdns_pcie_host_link_setup (struct cdns_pcie_rc *rc) +{ +struct cdns_pcie *pcie = &rc->pcie; +struct device *dev = rc->pcie.dev; +int ret; + +if (rc->quirk_detect_quiet_flag) +cdns_pcie_detect_quiet_min_delay_set (&rc->pcie); + +cdns_pcie_host_enable_ptm_response (pcie); + + ret =cdns_pcie_start_link (pcie); +if (ret) { +dev_err (dev,"Failed to start link\n" ); +return ret; + } + + ret =cdns_pcie_host_start_link (rc); +if (ret) +dev_dbg (dev,"PCIe link never came up\n" ); + +return 0 ; +} +int cdns_pcie_host_setup (struct cdns_pcie_rc *rc) {struct device *dev = rc->pcie.dev;
@@ -533,20 +557,9 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)return PTR_ERR (rc->cfg_base); rc->cfg_res = res; -if (rc->quirk_detect_quiet_flag) -cdns_pcie_detect_quiet_min_delay_set (&rc->pcie); - -cdns_pcie_host_enable_ptm_response (pcie); - - ret =cdns_pcie_start_link (pcie); -if (ret) { -dev_err (dev,"Failed to start link\n" ); -return ret; - } - - ret =cdns_pcie_host_start_link (rc); + ret =cdns_pcie_host_link_setup (rc);if (ret) -dev_dbg (dev,"PCIe link never came up\n" ); +return ret;for (bar =RP_BAR0 ; bar <=RP_NO_BAR ; bar++) rc->avail_ib_bar[bar] = true;
drivers/pci/controller/cadence/pcie-cadence.h +6 -0
@@ -521,10 +521,16 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) }#ifdef CONFIG_PCIE_CADENCE_HOST +int cdns_pcie_host_link_setup (struct cdns_pcie_rc *rc);int cdns_pcie_host_setup (struct cdns_pcie_rc *rc);void __iomem *cdns_pci_map_bus (struct pci_bus *bus,unsigned int devfn,int where);#else +static inline int cdns_pcie_host_link_setup (struct cdns_pcie_rc *rc) +{ +return 0 ; +} +static inline int cdns_pcie_host_setup (struct cdns_pcie_rc *rc) {return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 516/817 PCI: cadence: Set cdns_pcie_host_init() global
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richard <[email protected]>
[ Upstream commit 063c938928dc80c2bfd66f34df48344db22e009b ]
During the resume sequence of the host, cdns_pcie_host_init() needs to be called, so set it global.
The dev function parameter is removed, as it isn't used.
Stable-dep-of: 22a9120479a4 ("PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds")
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 5 ++--- drivers/pci/controller/cadence/pcie-cadence.h | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +2 -3
@@ -485,8 +485,7 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)return cdns_pcie_host_map_dma_ranges (rc); } -static int cdns_pcie_host_init (struct device *dev, -struct cdns_pcie_rc *rc) +int cdns_pcie_host_init (struct cdns_pcie_rc *rc) {int err;
@@ -564,7 +563,7 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)for (bar =RP_BAR0 ; bar <=RP_NO_BAR ; bar++) rc->avail_ib_bar[bar] = true; - ret =cdns_pcie_host_init (dev, rc); + ret =cdns_pcie_host_init (rc);if (ret)return ret;
drivers/pci/controller/cadence/pcie-cadence.h +6 -0
@@ -522,6 +522,7 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie)#ifdef CONFIG_PCIE_CADENCE_HOST int cdns_pcie_host_link_setup (struct cdns_pcie_rc *rc); +int cdns_pcie_host_init (struct cdns_pcie_rc *rc);int cdns_pcie_host_setup (struct cdns_pcie_rc *rc);void __iomem *cdns_pci_map_bus (struct pci_bus *bus,unsigned int devfn,int where);
@@ -531,6 +532,11 @@ static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc)return 0 ; } +static inline int cdns_pcie_host_init (struct cdns_pcie_rc *rc) +{ +return 0 ; +} +static inline int cdns_pcie_host_setup (struct cdns_pcie_rc *rc) {return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 517/817 PCI: j721e: Add reset GPIO to struct j721e_pcie
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Théo Lebrun <[email protected]>
[ Upstream commit b8600b8791cb2b7c8be894846b1ecddba7291680 ]
Add reset GPIO to struct j721e_pcie, so it can be used at suspend and resume stages.
Stable-dep-of: 22a9120479a4 ("PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds")
--- drivers/pci/controller/cadence/pci-j721e.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/cadence/pci-j721e.c +2 -0
@@ -52,6 +52,7 @@ struct j721e_pcie {u32 mode;u32 num_lanes;u32 max_lanes; +struct gpio_desc *reset_gpio;void __iomem *user_cfg_base;void __iomem *intd_cfg_base;u32 linkdown_irq_regfield;
@@ -510,6 +511,7 @@ static int j721e_pcie_probe(struct platform_device *pdev)dev_err (dev,"Failed to get reset GPIO\n" ); goto err_get_sync; } + pcie->reset_gpio = gpiod; ret =cdns_pcie_init_phy (dev, cdns_pcie);if (ret) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 518/817 PCI: j721e: Use T_PERST_CLK_US macro
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richard <[email protected]>
[ Upstream commit f96b6971373382855bc964f1c067bd6dc41cf0ab ]
Use the T_PERST_CLK_US macro, and the fsleep() function instead of usleep_range().
Stable-dep-of: 22a9120479a4 ("PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds")
--- drivers/pci/controller/cadence/pci-j721e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/cadence/pci-j721e.c +1 -1
@@ -542,7 +542,7 @@ static int j721e_pcie_probe(struct platform_device *pdev)* after 100 us. */ if (gpiod) { -usleep_range (100 ,200 ); +fsleep (PCIE_T_PERST_CLK_US );gpiod_set_value_cansleep (gpiod,1 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 519/817 PCI: j721e: Add suspend and resume support
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Théo Lebrun <[email protected]>
[ Upstream commit c538d40f365b5b6d7433d371710f58e8b266fb19 ]
Add suspend and resume support. Only the Root Complex mode is supported.
During the suspend stage PERST# is asserted, then deasserted during the resume stage.
Stable-dep-of: 22a9120479a4 ("PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds")
--- drivers/pci/controller/cadence/pci-j721e.c | 98 ++++++++++++++++++++-- 1 file changed, 92 insertions(+), 6 deletions(-)
drivers/pci/controller/cadence/pci-j721e.c +92 -6
@@ -7,6 +7,8 @@*/ #include <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/container_of.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/io.h>
@@ -22,6 +24,8 @@#include "../../pci.h" #include "pcie-cadence.h" +#define cdns_pcie_to_rc (p) container_of(p, struct cdns_pcie_rc, pcie) +#define ENABLE_REG_SYS_2 0x108#define STATUS_REG_SYS_2 0x508#define STATUS_CLR_REG_SYS_2 0x708
@@ -534,12 +538,12 @@ static int j721e_pcie_probe(struct platform_device *pdev) pcie->refclk = clk;/* -* "Power Sequencing and Reset Signal Timings" table in -* PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 -* indicates PERST# should be deasserted after minimum of 100us -* once REFCLK is stable. The REFCLK to the connector in RC -* mode is selected while enabling the PHY. So deassert PERST# -* after 100 us. +* The "Power Sequencing and Reset Signal Timings" table of the +* PCI Express Card Electromechanical Specification, Revision +* 5.1, Section 2.9.2, Symbol "T_PERST-CLK", indicates PERST# +* should be deasserted after minimum of 100us once REFCLK is +* stable. The REFCLK to the connector in RC mode is selected +* while enabling the PHY. So deassert PERST# after 100 us. */ if (gpiod) {fsleep (PCIE_T_PERST_CLK_US );
@@ -591,6 +595,87 @@ static void j721e_pcie_remove(struct platform_device *pdev)pm_runtime_disable (dev); } +static int j721e_pcie_suspend_noirq (struct device *dev) +{ +struct j721e_pcie *pcie =dev_get_drvdata (dev); + +if (pcie->mode ==PCI_MODE_RC ) { +gpiod_set_value_cansleep (pcie->reset_gpio,0 ); +clk_disable_unprepare (pcie->refclk); + } + +cdns_pcie_disable_phy (pcie->cdns_pcie); + +return 0 ; +} + +static int j721e_pcie_resume_noirq (struct device *dev) +{ +struct j721e_pcie *pcie =dev_get_drvdata (dev); +struct cdns_pcie *cdns_pcie = pcie->cdns_pcie; +int ret; + + ret =j721e_pcie_ctrl_init (pcie); +if (ret <0 ) +return ret; + +j721e_pcie_config_link_irq (pcie); + +/* +* This is not called explicitly in the probe, it is called by +* cdns_pcie_init_phy(). +*/ + ret =cdns_pcie_enable_phy (pcie->cdns_pcie); +if (ret <0 ) +return ret; + +if (pcie->mode ==PCI_MODE_RC ) { +struct cdns_pcie_rc *rc =cdns_pcie_to_rc (cdns_pcie); + + ret =clk_prepare_enable (pcie->refclk); +if (ret <0 ) +return ret; + +/* +* The "Power Sequencing and Reset Signal Timings" table of the +* PCI Express Card Electromechanical Specification, Revision +* 5.1, Section 2.9.2, Symbol "T_PERST-CLK", indicates PERST# +* should be deasserted after minimum of 100us once REFCLK is +* stable. The REFCLK to the connector in RC mode is selected +* while enabling the PHY. So deassert PERST# after 100 us. +*/ +if (pcie->reset_gpio) { +fsleep (PCIE_T_PERST_CLK_US ); +gpiod_set_value_cansleep (pcie->reset_gpio,1 ); + } + + ret =cdns_pcie_host_link_setup (rc); +if (ret <0 ) { +clk_disable_unprepare (pcie->refclk); +return ret; + } + +/* +* Reset internal status of BARs to force reinitialization in +* cdns_pcie_host_init(). +*/ +for (enum cdns_pcie_rp_bar bar =RP_BAR0 ; bar <=RP_NO_BAR ; bar++) + rc->avail_ib_bar[bar] = true; + + ret =cdns_pcie_host_init (rc); +if (ret) { +clk_disable_unprepare (pcie->refclk); +return ret; + } + } + +return 0 ; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(j721e_pcie_pm_ops, + j721e_pcie_suspend_noirq, + j721e_pcie_resume_noirq); +static struct platform_driver j721e_pcie_driver = { .probe = j721e_pcie_probe, .remove_new = j721e_pcie_remove,
@@ -598,6 +683,7 @@ static struct platform_driver j721e_pcie_driver = { .name = "j721e-pcie", .of_match_table = of_j721e_pcie_match, .suppress_bind_attrs = true, + .pm = pm_sleep_ptr(&j721e_pcie_pm_ops), }, };builtin_platform_driver (j721e_pcie_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 520/817 PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Vadapalli <[email protected]>
[ Upstream commit 22a9120479a40a56c13c5e473a0100fad2e017c0 ]
According to Section 2.2 of the PCI Express Card Electromechanical Specification (Revision 5.1), in order to ensure that the power and the reference clock are stable, PERST# has to be deasserted after a delay of 100 milliseconds (TPVPERL).
Currently, it is being assumed that the power is already stable, which is not necessarily true.
Hence, change the delay to PCIE_T_PVPERL_MS to guarantee that power and reference clock are stable.
--- drivers/pci/controller/cadence/pci-j721e.c | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/pci/controller/cadence/pci-j721e.c +12 -14
@@ -538,15 +538,14 @@ static int j721e_pcie_probe(struct platform_device *pdev) pcie->refclk = clk;/* -* The "Power Sequencing and Reset Signal Timings" table of the -* PCI Express Card Electromechanical Specification, Revision -* 5.1, Section 2.9.2, Symbol "T_PERST-CLK", indicates PERST# -* should be deasserted after minimum of 100us once REFCLK is -* stable. The REFCLK to the connector in RC mode is selected -* while enabling the PHY. So deassert PERST# after 100 us. +* Section 2.2 of the PCI Express Card Electromechanical +* Specification (Revision 5.1) mandates that the deassertion +* of the PERST# signal should be delayed by 100 ms (TPVPERL). +* This shall ensure that the power and the reference clock +* are stable. */ if (gpiod) { -fsleep (PCIE_T_PERST_CLK_US ); +msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (gpiod,1 ); }
@@ -637,15 +636,14 @@ static int j721e_pcie_resume_noirq(struct device *dev)return ret;/* -* The "Power Sequencing and Reset Signal Timings" table of the -* PCI Express Card Electromechanical Specification, Revision -* 5.1, Section 2.9.2, Symbol "T_PERST-CLK", indicates PERST# -* should be deasserted after minimum of 100us once REFCLK is -* stable. The REFCLK to the connector in RC mode is selected -* while enabling the PHY. So deassert PERST# after 100 us. +* Section 2.2 of the PCI Express Card Electromechanical +* Specification (Revision 5.1) mandates that the deassertion +* of the PERST# signal should be delayed by 100 ms (TPVPERL). +* This shall ensure that the power and the reference clock +* are stable. */ if (pcie->reset_gpio) { -fsleep (PCIE_T_PERST_CLK_US ); +msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (pcie->reset_gpio,1 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 521/817 perf build: Add missing cflags when building with custom libtraceevent
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yicong Yang <[email protected]>
[ Upstream commit d5a0a4ab4af4c27de097b78d6f1b7e7f7e31908f ]
When building with custom libtraceevent, below errors occur:
$ make -C tools/perf NO_LIBPYTHON=1 PKG_CONFIG_PATH=<custom libtraceevent>
In file included from util/session.h:5,
from builtin-buildid-list.c:17:
util/trace-event.h:153:10: fatal error: traceevent/event-parse.h: No such file or directory
153 | #include <traceevent/event-parse.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
<snip similar errors of missing headers>This is because the include path is missed in the cflags. Add it.
--- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -1197,7 +1197,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent) LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 522/817 f2fs: fix race in concurrent f2fs_stop_gc_thread
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
[ Upstream commit 7b0033dbc48340a1c1c3f12448ba17d6587ca092 ]
In my test case, concurrent calls to f2fs shutdown report the following stack trace:
Oops: general protection fault, probably for non-canonical address 0xc6cfff63bb5513fc: 0000 [#1] PREEMPT SMP PTI CPU: 0 UID: 0 PID: 678 Comm: f2fs_rep_shutdo Not tainted 6.12.0-rc5-next-20241029-g6fb2fa9805c5-dirty #85 Call Trace: <TASK> ? show_regs+0x8b/0xa0 ? __die_body+0x26/0xa0 ? die_addr+0x54/0x90 ? exc_general_protection+0x24b/0x5c0 ? asm_exc_general_protection+0x26/0x30 ? kthread_stop+0x46/0x390 f2fs_stop_gc_thread+0x6c/0x110 f2fs_do_shutdown+0x309/0x3a0 f2fs_ioc_shutdown+0x150/0x1c0 __f2fs_ioctl+0xffd/0x2ac0 f2fs_ioctl+0x76/0xe0 vfs_ioctl+0x23/0x60 __x64_sys_ioctl+0xce/0xf0 x64_sys_call+0x2b1b/0x4540 do_syscall_64+0xa7/0x240 entry_SYSCALL_64_after_hwframe+0x76/0x7e
The root cause is a race condition in f2fs_stop_gc_thread() called from different f2fs shutdown paths:
[CPU0] [CPU1]
---------------------- -----------------------
f2fs_stop_gc_thread f2fs_stop_gc_thread
gc_th = sbi->gc_thread
gc_th = sbi->gc_thread
kfree(gc_th)
sbi->gc_thread = NULL
< gc_th != NULL >
kthread_stop(gc_th->f2fs_gc_task) //UAFThe commit c7f114d864ac ("f2fs: fix to avoid use-after-free in f2fs_stop_gc_thread()") attempted to fix this issue by using a read semaphore to prevent races between shutdown and remount threads, but it fails to prevent all race conditions.
Fix it by converting to write lock of s_umount in f2fs_do_shutdown().
--- fs/f2fs/file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/f2fs/file.c +6 -3
@@ -2349,9 +2349,12 @@ int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,if (readonly) goto out; -/* grab sb->s_umount to avoid racing w/ remount() */ +/* +* grab sb->s_umount to avoid racing w/ remount() and other shutdown +* paths. +*/ if (need_lock) -down_read (&sbi->sb->s_umount); +down_write (&sbi->sb->s_umount);f2fs_stop_gc_thread (sbi);f2fs_stop_discard_thread (sbi);
@@ -2360,7 +2363,7 @@ int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,clear_opt (sbi,DISCARD );if (need_lock) -up_read (&sbi->sb->s_umount); +up_write (&sbi->sb->s_umount);f2fs_update_time (sbi,REQ_TIME ); out:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 523/817 f2fs: fix to map blocks correctly for direct write
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 5dd00ebda337b9295e7027691fa70540da369ff2 ]
f2fs_map_blocks() supports to map continuous holes or preallocated address, we should avoid setting F2FS_MAP_MAPPED for these cases only, otherwise, it may fail f2fs_iomap_begin(), and make direct write fallbacking to use buffered IO and flush, result in performance regression.
--- fs/f2fs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
@@ -1677,7 +1677,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)/* reserved delalloc block should be mapped for fiemap. */ if (blkaddr ==NEW_ADDR ) map->m_flags |=F2FS_MAP_DELALLOC ; -if (flag !=F2FS_GET_BLOCK_DIO || !is_hole) +/* DIO READ and hole case, should not map the blocks. */ +if (!(flag ==F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create)) map->m_flags |=F2FS_MAP_MAPPED ; map->m_pblk = blkaddr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 524/817 f2fs: fix to avoid forcing direct write to use buffered IO on inline_data inode
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 26e6f59d0bbaac76fa3413462d780bd2b5f9f653 ]
Jinsu Lee reported a performance regression issue, after commit 5c8764f8679e ("f2fs: fix to force buffered IO on inline_data inode"), we forced direct write to use buffered IO on inline_data inode, it will cause performace regression due to memory copy and data flush.
It's fine to not force direct write to use buffered IO, as it can convert inline inode before committing direct write IO.
--- fs/f2fs/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/file.c +5 -1
@@ -868,7 +868,11 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw)return true;if (f2fs_compressed_file (inode))return true; -if (f2fs_has_inline_data (inode)) +/* +* only force direct read to use buffered IO, for direct write, +* it expects inline data conversion before committing IO. +*/ +if (f2fs_has_inline_data (inode) && rw ==READ )return true;/* disallow direct IO if any of devices has unaligned blksize */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 525/817 perf trace: avoid garbage when not printing a trace events arguments
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 5fb8e56542a3cf469fdf25d77f50e21cbff3ae7e ]
trace__fprintf_tp_fields may not print any tracepoint arguments. E.g., if the argument values are all zero. Previously, this would result in a totally uninitialized buffer being passed to fprintf, which could lead to garbage on the console. Fix the problem by passing the number of initialized bytes fprintf.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -2802,7 +2802,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, printed +=syscall_arg_fmt__scnprintf_val (arg, bf + printed, size - printed, &syscall_arg, val); } -return printed +fprintf (trace->output,"%s" , bf); +return printed +fprintf (trace->output,"%.*s" , (int )printed, bf); } static int trace__event_handler(struct trace *trace, struct evsel *evsel,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 526/817 m68k: mcfgpio: Fix incorrect register offset for CONFIG_M5441x
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Michel Hautbois <[email protected]>
[ Upstream commit f212140962c93cd5da43283a18e31681540fc23d ]
Fix a typo in the CONFIG_M5441x preprocessor condition, where the GPIO register offset was incorrectly set to 8 instead of 0. This prevented proper GPIO configuration for m5441x targets.
--- arch/m68k/include/asm/mcfgpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/include/asm/mcfgpio.h +1 -1
@@ -136,7 +136,7 @@ static inline void gpio_free(unsigned gpio)* read-modify-write as well as those controlled by the EPORT and GPIO modules. */ #define MCFGPIO_SCR_START 40 -#elif defined(CONFIGM5441x) +#elif defined(CONFIG_M5441x)/* The m5441x EPORT doesn't have its own GPIO port, uses PORT C */ #define MCFGPIO_SCR_START 0#else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 527/817 m68k: coldfire/device.c: only build FEC when HW macros are defined
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Quartulli <[email protected]>
[ Upstream commit 63a24cf8cc330e5a68ebd2e20ae200096974c475 ]
When CONFIG_FEC is set (due to COMPILE_TEST) along with CONFIG_M54xx, coldfire/device.c has compile errors due to missing MCFEC_* and MCF_IRQ_FEC_* symbols.
Make the whole FEC blocks dependent on having the HW macros defined, rather than on CONFIG_FEC itself.
This fix is very similar to commit e6e1e7b19fa1 ("m68k: coldfire/device.c: only build for MCF_EDMA when h/w macros are defined")
To: Greg Ungerer <[email protected]>
To: Geert Uytterhoeven <[email protected]>
--- arch/m68k/coldfire/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/m68k/coldfire/device.c +4 -4
@@ -93,7 +93,7 @@ static struct platform_device mcf_uart = { .dev.platform_data = mcf_uart_platform_data, }; -#if IS_ENABLED (CONFIG_FEC ) +#ifdef MCFFEC_BASE0 #ifdef CONFIG_M5441x#define FEC_NAME "enet-fec"
@@ -145,6 +145,7 @@ static struct platform_device mcf_fec0 = { .platform_data = FEC_PDATA, } }; +#endif /* MCFFEC_BASE0 */ #ifdef MCFFEC_BASE1 static struct resource mcf_fec1_resources[] = {
@@ -182,7 +183,6 @@ static struct platform_device mcf_fec1 = { } };#endif /* MCFFEC_BASE1 */ -#endif /* CONFIG_FEC */ #if IS_ENABLED (CONFIG_SPI_COLDFIRE_QSPI )/*
@@ -624,12 +624,12 @@ static struct platform_device mcf_flexcan0 = {static struct platform_device *mcf_devices[]__initdata = { &mcf_uart, -#if IS_ENABLED(CONFIG_FEC) +#ifdef MCFFEC_BASE0 &mcf_fec0, +#endif #ifdef MCFFEC_BASE1 &mcf_fec1, #endif -#endif #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) &mcf_qspi, #endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 528/817 svcrdma: Address an integer overflow
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 3c63d8946e578663b868cb9912dac616ea68bfd0 ]
Dan Carpenter reports:
Quoted 20 lines
Commit
78147ca8b4a9("svcrdma: Add a "parsed chunk list" data structure") from Jun 22, 2020 (linux-next), leads to the following Smatch static checker warning:
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c:498xdr_check_write_chunk()
warn: potential user controlled sizeof overflow 'segcount * 4 * 4'
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c488 static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt) 489 { 490 u32 segcount; 491 __be32 *p; 492 493 if (xdr_stream_decode_u32(&rctxt->rc_stream, &segcount)) ^^^^^^^^ 494 return false; 495 496 /* A bogus segcount causes this buffer overflow check to fail. */ 497 p = xdr_inline_decode(&rctxt->rc_stream,
Quoted 6 lines
--> 498 segcount *
rpcrdma_segment_maxsz*sizeof(*p));segcount is an untrusted u32. On 32bit systems anything >=
SIZE_MAX/ 16 will have an integer overflow and some those values will be accepted byxdr_inline_decode().
--- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +7 -1
@@ -493,7 +493,13 @@ static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt)if (xdr_stream_decode_u32 (&rctxt->rc_stream, &segcount))return false; -/* A bogus segcount causes this buffer overflow check to fail. */ +/* Before trusting the segcount value enough to use it in +* a computation, perform a simple range check. This is an +* arbitrary but sensible limit (ie, not architectural). +*/ +if (unlikely (segcount >RPCSVC_MAXPAGES )) +return false; + p =xdr_inline_decode (&rctxt->rc_stream, segcount * rpcrdma_segment_maxsz *sizeof (*p));return p !=NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 529/817 nfsd: drop inode parameter from nfsd4_change_attribute()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit f67eef8da0e8c54709fefdecd16ad8d70f0c9d20 ]
The inode that nfs4_open_delegation() passes to this function is wrong, which throws off the result. The inode will end up getting a directory-style change attr instead of a regular-file-style one.
Fix up nfs4_delegation_stat() to fetch STATX_MODE, and then drop the inode parameter from nfsd4_change_attribute(), since it's no longer needed.
--- fs/nfsd/nfs4state.c | 5 ++--- fs/nfsd/nfs4xdr.c | 2 +- fs/nfsd/nfsfh.c | 20 ++++++++++++-------- fs/nfsd/nfsfh.h | 3 +-- 4 files changed, 16 insertions(+), 14 deletions(-)
fs/nfsd/nfs4state.c +2 -3
@@ -5955,7 +5955,7 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, path.dentry =file_dentry (nf->nf_file); rc =vfs_getattr (&path, stat, - (STATX_SIZE |STATX_CTIME |STATX_CHANGE_COOKIE ), + (STATX_MODE |STATX_SIZE |STATX_CTIME |STATX_CHANGE_COOKIE ),AT_STATX_SYNC_AS_STAT );nfsd_file_put (nf);
@@ -6039,8 +6039,7 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, } open->op_delegate_type =NFS4_OPEN_DELEGATE_WRITE ; dp->dl_cb_fattr.ncf_cur_fsize = stat.size; - dp->dl_cb_fattr.ncf_initial_cinfo = -nfsd4_change_attribute (&stat,d_inode (currentfh->fh_dentry)); + dp->dl_cb_fattr.ncf_initial_cinfo =nfsd4_change_attribute (&stat);trace_nfsd_deleg_write (&dp->dl_stid.sc_stateid); }else { open->op_delegate_type =NFS4_OPEN_DELEGATE_READ ;
fs/nfsd/nfs4xdr.c +1 -1
@@ -3040,7 +3040,7 @@ static __be32 nfsd4_encode_fattr4_change(struct xdr_stream *xdr,return nfs_ok; } - c =nfsd4_change_attribute (&args->stat,d_inode (args->dentry)); + c =nfsd4_change_attribute (&args->stat);return nfsd4_encode_changeid4 (xdr, c); }
fs/nfsd/nfsfh.c +12 -8
@@ -618,20 +618,18 @@ fh_update(struct svc_fh *fhp)__be32 __must_check fh_fill_pre_attrs (struct svc_fh *fhp) {bool v4 = (fhp->fh_maxsize ==NFS4_FHSIZE ); -struct inode *inode;struct kstat stat;__be32 err;if (fhp->fh_no_wcc || fhp->fh_pre_saved)return nfs_ok; - inode =d_inode (fhp->fh_dentry); err =fh_getattr (fhp, &stat);if (err)return err;if (v4) - fhp->fh_pre_change =nfsd4_change_attribute (&stat, inode); + fhp->fh_pre_change =nfsd4_change_attribute (&stat); fhp->fh_pre_mtime = stat.mtime; fhp->fh_pre_ctime = stat.ctime;
@@ -648,7 +646,6 @@ __be32 __must_check fh_fill_pre_attrs(struct svc_fh *fhp)__be32 fh_fill_post_attrs (struct svc_fh *fhp) {bool v4 = (fhp->fh_maxsize ==NFS4_FHSIZE ); -struct inode *inode =d_inode (fhp->fh_dentry);__be32 err;if (fhp->fh_no_wcc)
@@ -664,7 +661,7 @@ __be32 fh_fill_post_attrs(struct svc_fh *fhp) fhp->fh_post_saved = true;if (v4) fhp->fh_post_change = -nfsd4_change_attribute (&fhp->fh_post_attr, inode); +nfsd4_change_attribute (&fhp->fh_post_attr);return nfs_ok; }
@@ -755,7 +752,14 @@ enum fsid_source fsid_source(const struct svc_fh *fhp)return FSIDSOURCE_DEV ; } -/* +/** +* nfsd4_change_attribute - Generate an NFSv4 change_attribute value +* @stat: inode attributes +* +* Caller must fill in @stat before calling, typically by invoking +* vfs_getattr() with STATX_MODE, STATX_CTIME, and STATX_CHANGE_COOKIE. +* Returns an unsigned 64-bit changeid4 value (RFC 8881 Section 3.2). +* * We could use i_version alone as the change attribute. However, i_version * can go backwards on a regular file after an unclean shutdown. On its own * that doesn't necessarily cause a problem, but if i_version goes backwards
@@ -772,13 +776,13 @@ enum fsid_source fsid_source(const struct svc_fh *fhp)* assume that the new change attr is always logged to stable storage in some * fashion before the results can be seen. */ -u64 nfsd4_change_attribute (const struct kstat *stat,const struct inode *inode) +u64 nfsd4_change_attribute (const struct kstat *stat) {u64 chattr;if (stat->result_mask &STATX_CHANGE_COOKIE ) { chattr = stat->change_cookie; -if (S_ISREG (inode->i_mode) && +if (S_ISREG (stat->mode) && !(stat->attributes &STATX_ATTR_CHANGE_MONOTONIC )) { chattr += (u64 )stat->ctime.tv_sec <<30 ; chattr += stat->ctime.tv_nsec;
fs/nfsd/nfsfh.h +1 -2
@@ -293,8 +293,7 @@ static inline void fh_clear_pre_post_attrs(struct svc_fh *fhp) fhp->fh_pre_saved = false; } -u64 nfsd4_change_attribute (const struct kstat *stat, -const struct inode *inode); +u64 nfsd4_change_attribute (const struct kstat *stat);__be32 __must_check fh_fill_pre_attrs (struct svc_fh *fhp);__be32 fh_fill_post_attrs (struct svc_fh *fhp);__be32 __must_check fh_fill_both_attrs (struct svc_fh *fhp);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 530/817 perf list: Fix topic and pmu_name argument order
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Philippe Romain <[email protected]>
[ Upstream commit d99b3125726aade4f5ec4aae04805134ab4b0abd ]
Fix function definitions to match header file declaration. Fix two callers to pass the arguments in the right order.
On Intel Tigerlake, before:
```
$ perf list -j|grep "\"Topic\""|sort|uniq
"Topic": "cache",
"Topic": "cpu",
"Topic": "floating point",
"Topic": "frontend",
"Topic": "memory",
"Topic": "other",
"Topic": "pfm icl",
"Topic": "pfm ix86arch",
"Topic": "pfm perf_raw",
"Topic": "pipeline",
"Topic": "tool",
"Topic": "uncore interconnect",
"Topic": "uncore memory",
"Topic": "uncore other",
"Topic": "virtual memory",
$ perf list -j|grep "\"Unit\""|sort|uniq
"Unit": "cache",
"Unit": "cpu",
"Unit": "cstate_core",
"Unit": "cstate_pkg",
"Unit": "i915",
"Unit": "icl",
"Unit": "intel_bts",
"Unit": "intel_pt",
"Unit": "ix86arch",
"Unit": "msr",
"Unit": "perf_raw",
"Unit": "power",
"Unit": "tool",
"Unit": "uncore_arb",
"Unit": "uncore_clock",
"Unit": "uncore_imc_free_running_0",
"Unit": "uncore_imc_free_running_1",
```After:
```
$ perf list -j|grep "\"Topic\""|sort|uniq
"Topic": "cache",
"Topic": "floating point",
"Topic": "frontend",
"Topic": "memory",
"Topic": "other",
"Topic": "pfm icl",
"Topic": "pfm ix86arch",
"Topic": "pfm perf_raw",
"Topic": "pipeline",
"Topic": "tool",
"Topic": "uncore interconnect",
"Topic": "uncore memory",
"Topic": "uncore other",
"Topic": "virtual memory",
$ perf list -j|grep "\"Unit\""|sort|uniq
"Unit": "cpu",
"Unit": "cstate_core",
"Unit": "cstate_pkg",
"Unit": "i915",
"Unit": "icl",
"Unit": "intel_bts",
"Unit": "intel_pt",
"Unit": "ix86arch",
"Unit": "msr",
"Unit": "perf_raw",
"Unit": "power",
"Unit": "tool",
"Unit": "uncore_arb",
"Unit": "uncore_clock",
"Unit": "uncore_imc_free_running_0",
"Unit": "uncore_imc_free_running_1",
```--- tools/perf/builtin-list.c | 4 ++-- tools/perf/util/pfm.c | 4 ++-- tools/perf/util/pmus.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/builtin-list.c +2 -2
@@ -112,7 +112,7 @@ static void wordwrap(FILE *fp, const char *s, int start, int max, int corr) } } -static void default_print_event(void *ps, const char *pmu_name, const char *topic, +static void default_print_event(void *ps, const char *topic, const char *pmu_name, const char *event_name, const char *event_alias, const char *scale_unit __maybe_unused, bool deprecated, const char *event_type_desc,
@@ -353,7 +353,7 @@ static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ..fputs (buf->buf, fp); } -static void json_print_event(void *ps, const char *pmu_name, const char *topic, +static void json_print_event(void *ps, const char *topic, const char *pmu_name, const char *event_name, const char *event_alias, const char *scale_unit, bool deprecated, const char *event_type_desc,
tools/perf/util/pfm.c +2 -2
@@ -233,7 +233,7 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state, }if (is_libpfm_event_supported (name, cpus, threads)) { - print_cb->print_event(print_state, pinfo->name, topic, + print_cb->print_event(print_state, topic, pinfo->name, name, info->equiv, /*scale_unit=*/NULL, /*deprecated=*/NULL, "PFM event",
@@ -267,8 +267,8 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state,continue ; print_cb->print_event(print_state, - pinfo->name, topic, + pinfo->name, name, /*alias=*/NULL, /*scale_unit=*/NULL, /*deprecated=*/NULL, "PFM event",
tools/perf/util/pmus.c +1 -1
@@ -492,8 +492,8 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p goto free; print_cb->print_event(print_state, - aliases[j].pmu_name, aliases[j].topic, + aliases[j].pmu_name, aliases[j].name, aliases[j].alias, aliases[j].scale_unit,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 531/817 perf trace: Fix tracing itself, creating feedback loops
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Howard Chu <[email protected]>
[ Upstream commit fe4f9b4124967ffb75d66994520831231b779550 ]
There exists a pids_filtered map in augmented_raw_syscalls.bpf.c that ceases to provide functionality after the BPF skeleton migration done in:
5e6da6be3082f77b ("perf trace: Migrate BPF augmentation to use a skeleton")
Before the migration, pid_filtered map works, courtesy of Arnaldo Carvalho de Melo <[email protected]>:
⬢ [acme@toolbox perf-tools]$ git log --oneline -5
6f769c3458b6cf2d (HEAD) perf tests trace+probe_vfs_getname.sh: Accept quotes surrounding the filename 7777ac3dfe29f55d perf test trace+probe_vfs_getname.sh: Remove stray \ before /
33d9c5062113a4bd perf script python: Add stub for PMU symbol to the python binding
e59fea47f83e8a9a perf symbols: Fix DSO kernel load and symbol process to correctly map DSO to its long_name, type and adjust_symbols 878460e8d0ff84a0 perf build: Remove -Wno-unused-but-set-variable from the flex flags when building with clang < 13.0.0
root@x1:/home/acme/git/perf-tools# perf trace -e /tmp/augmented_raw_syscalls.o -e write* --max-events=30 &
[1] 180632
root@x1:/home/acme/git/perf-tools# 0.000 ( 0.051 ms): NetworkManager/1127 write(fd: 3, buf: 0x7ffeb508ef70, count: 8) = 8
0.115 ( 0.010 ms): NetworkManager/1127 write(fd: 3, buf: 0x7ffeb508ef70, count: 8) = 8
0.916 ( 0.068 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 246) = 246
1.699 ( 0.047 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
2.167 ( 0.041 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
2.739 ( 0.042 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
3.138 ( 0.027 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
3.477 ( 0.027 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
3.738 ( 0.023 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
3.946 ( 0.024 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
4.195 ( 0.024 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 121) = 121
4.212 ( 0.026 ms): NetworkManager/1127 write(fd: 3, buf: 0x7ffeb508ef70, count: 8) = 8
4.285 ( 0.006 ms): NetworkManager/1127 write(fd: 3, buf: 0x7ffeb508ef70, count: 8) = 8
4.445 ( 0.018 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 260) = 260
4.508 ( 0.009 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 124) = 124
4.592 ( 0.010 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 116) = 116
4.666 ( 0.009 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 130) = 130
4.715 ( 0.010 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 95) = 95
4.765 ( 0.007 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 102) = 102
4.815 ( 0.009 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 79) = 79
4.890 ( 0.008 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 57) = 57
4.937 ( 0.007 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 89) = 89
5.009 ( 0.010 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 112) = 112
5.059 ( 0.010 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 112) = 112
5.116 ( 0.007 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 79) = 79
5.152 ( 0.009 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 33) = 33
5.215 ( 0.008 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 37) = 37
5.293 ( 0.010 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 128) = 128
5.339 ( 0.009 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 89) = 89
5.384 ( 0.008 ms): sudo/156867 write(fd: 8, buf: 0x55cb4cd2f650, count: 100) = 100[1]+ Done perf trace -e /tmp/augmented_raw_syscalls.o -e write* --max-events=30 root@x1:/home/acme/git/perf-tools#
No events for the 'perf trace' (pid 180632), i.e. no feedback loop.
If we leave it running:
root@x1:/home/acme/git/perf-tools# perf trace -e /tmp/augmented_raw_syscalls.o -e landlock_add_rule & [1] 181068 root@x1:/home/acme/git/perf-tools#
And then look at what maps it sets up:
root@x1:/home/acme/git/perf-tools# bpftool map | grep pids_filtered -A3
1190: hash name pids_filtered flags 0x0
key 4B value 1B max_entries 64 memlock 7264B
btf_id 1613
pids perf(181068)
root@x1:/home/acme/git/perf-tools#And ask for dumping its contents:
We see that we are _also_ setting it to filter those:
root@x1:/home/acme/git/perf-tools# bpftool map dump id 1190
[{
"key": 181068,
"value": 1
},{
"key": 156801,
"value": 1
}
]Now testing the migration commit:
perf $ git log
commit 5e6da6be3082f77be06894a1a94d52a90b4007dc (HEAD)
Author: Ian Rogers <[email protected]>
Date: Thu Aug 10 11:48:51 2023 -0700
perf trace: Migrate BPF augmentation to use a skeleton
perf $ ./perf trace -e write --max-events=10 & echo #!
[1] 1808653
perf $
0.000 ( 0.010 ms): :1808671/1808671 write(fd: 1, buf: 0x6003f5b26fc0, count: 11) = 11
0.162 ( ): perf/1808653 write(fd: 2, buf: 0x7fffc2174e50, count: 11) ...
0.174 ( ): perf/1808653 write(fd: 2, buf: 0x74ce21804563, count: 1) ...
0.184 ( ): perf/1808653 write(fd: 2, buf: 0x57b936589052, count: 5)The feedback loop is there.
Keep it running, look into the bpf map:
perf $ bpftool map | grep pids_filtered
10675: hash name pids_filtered flags 0x0
perf $ bpftool map dump id 10675
[]
The map is empty.
Now, this commit:
64917f4df048a064 ("perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string")
Temporarily fixed the feedback loop for perf trace -e write, that's because before using the heuristic, write is hooked to sys_enter_openat:
perf $ git log
commit 83a0943b1870944612a8aa0049f910826ebfd4f7 (HEAD)
Author: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu Aug 17 12:11:51 2023 -0300
perf trace: Use the augmented_raw_syscall BPF skel only for tracing syscalls
perf $ ./perf trace -e write --max-events=10 -v 2>&1 | grep Reusing Reusing "openat" BPF sys_enter augmenter for "write"
And after the heuristic fix, it's unaugmented:
perf $ git log
commit 64917f4df048a0649ea7901c2321f020e71e6f24 (HEAD)
Author: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu Aug 17 15:14:21 2023 -0300
perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string
perf $ ./perf trace -e write --max-events=10 -v 2>&1 | grep Reusing perf $
After using the heuristic, write is hooked to syscall_unaugmented, which returns 1.
SEC("tp/raw_syscalls/sys_enter")
int syscall_unaugmented(struct syscall_enter_args *args)
{
return 1;
}If the BPF program returns 1, the tracepoint filter will filter it (since the tracepoint filter for perf is correctly set), but before the heuristic, when it was hooked to a sys_enter_openat(), which is a BPF program that calls bpf_perf_event_output() and writes to the buffer, it didn't get filtered, thus creating feedback loop. So switching write to unaugmented accidentally fixed the problem.
But some syscalls are not so lucky, for example newfstatat:
perf $ ./perf trace -e newfstatat --max-events=100 & echo #!
[1] 2166948
457.718 ( ): perf/2166948 newfstatat(dfd: CWD, filename: "/proc/self/ns/mnt", statbuf: 0x7fff0132a9f0) ... 457.749 ( ): perf/2166948 newfstatat(dfd: CWD, filename: "/proc/2166950/ns/mnt", statbuf: 0x7fff0132aa80) ... 457.962 ( ): perf/2166948 newfstatat(dfd: CWD, filename: "/proc/self/ns/mnt", statbuf: 0x7fff0132a9f0) ...
Currently, write is augmented by the new BTF general augmenter (which calls bpf_perf_event_output()). The problem, which luckily got fixed, resurfaced, and that’s how it was discovered.
--- tools/perf/builtin-trace.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/builtin-trace.c +3 -0
@@ -3922,6 +3922,9 @@ static int trace__run(struct trace *trace, int argc, const char **argv) sizeof(__u32), BPF_ANY); } } + +if (trace->skel) + trace->filter_pids.map = trace->skel->maps.pids_filtered;#endif err =trace__set_filter_pids (trace);if (err <0 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 532/817 perf trace: Do not lose last events in a race
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 3fd7c36973a250e17a4ee305a31545a9426021f4 ]
If a perf trace event selector specifies a maximum number of events to output (i.e., "/nr=N/" syntax), the event printing handler, trace__event_handler, disables the event selector after the maximum number events are printed.
Furthermore, trace__event_handler checked if the event selector was disabled before doing any work. This avoided exceeding the maximum number of events to print if more events were in the buffer before the selector was disabled.
However, the event selector can be disabled for reasons other than exceeding the maximum number of events. In particular, when the traced subprocess exits, the main loop disables all event selectors. This meant the last events of a traced subprocess might be lost to the printing handler's short-circuiting logic.
This nondeterministic problem could be seen by running the following many times:
$ perf trace -e syscalls:sys_enter_exit_group true
trace__event_handler should simply check for exceeding the maximum number of events to print rather than the state of the event selector.
--- tools/perf/builtin-trace.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
tools/perf/builtin-trace.c +2 -7
@@ -2811,13 +2811,8 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel, {struct thread *thread;int callchain_ret =0 ; -/* -* Check if we called perf_evsel__disable(evsel) due to, for instance, -* this event's max_events having been hit and this is an entry coming -* from the ring buffer that we should discard, since the max events -* have already been considered/printed. -*/ -if (evsel->disabled) + +if (evsel->nr_events_printed >= evsel->max_events)return 0 ; thread =machine__findnew_thread (trace->host, sample->pid, sample->tid);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 533/817 perf trace: Avoid garbage when not printing a syscalls arguments
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 1302e352b26f34991b619b5d0b621b76d20a3883 ]
syscall__scnprintf_args may not place anything in the output buffer (e.g., because the arguments are all zero). If that happened in trace__fprintf_sys_enter, its fprintf would receive an unitialized buffer leading to garbage output.
Fix the problem by passing the (possibly zero) bounds of the argument buffer to the output fprintf.
--- tools/perf/builtin-trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +3 -2
@@ -2423,6 +2423,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,char msg[1024 ];void *args, *augmented_args =NULL ;int augmented_args_size; +size_t printed =0 ;if (sc ==NULL )return -1 ;
@@ -2438,8 +2439,8 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel, args =perf_evsel__sc_tp_ptr (evsel, args, sample); augmented_args =syscall__augmented_args (sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size); -syscall__scnprintf_args (sc, msg,sizeof (msg), args, augmented_args, augmented_args_size, trace, thread); -fprintf (trace->output,"%s" , msg); + printed +=syscall__scnprintf_args (sc, msg,sizeof (msg), args, augmented_args, augmented_args_size, trace, thread); +fprintf (trace->output,"%.*s" , (int )printed, msg); err =0 ; out_put:thread__put (thread);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 534/817 remoteproc: qcom: pas: Remove subdevs on the error path of adsp_probe()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit 587b67cf62a91b10a47f41c20ed8ad71db375334 ]
Current implementation of adsp_probe() in qcom_q6v5_pas.c does not remove the subdevs of adsp on the error path. Fix this bug by calling qcom_remove_{ssr,sysmon,pdm,smd,glink}_subdev(), qcom_q6v5_deinit(), and adsp_unassign_memory_region() appropriately.
--- drivers/remoteproc/qcom_q6v5_pas.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/remoteproc/qcom_q6v5_pas.c +15 -5
@@ -759,16 +759,16 @@ static int adsp_probe(struct platform_device *pdev) ret =adsp_init_clock (adsp);if (ret) - goto free_rproc; + goto unassign_mem; ret =adsp_init_regulator (adsp);if (ret) - goto free_rproc; + goto unassign_mem; ret =adsp_pds_attach (&pdev->dev, adsp->proxy_pds, desc->proxy_pd_names);if (ret <0 ) - goto free_rproc; + goto unassign_mem; adsp->proxy_pd_count = ret; ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, desc->load_state,
@@ -784,18 +784,28 @@ static int adsp_probe(struct platform_device *pdev) desc->ssctl_id);if (IS_ERR (adsp->sysmon)) { ret =PTR_ERR (adsp->sysmon); - goto detach_proxy_pds; + goto deinit_remove_pdm_smd_glink; }qcom_add_ssr_subdev (rproc, &adsp->ssr_subdev, desc->ssr_name); ret =rproc_add (rproc);if (ret) - goto detach_proxy_pds; + goto remove_ssr_sysmon;return 0 ; +remove_ssr_sysmon: +qcom_remove_ssr_subdev (rproc, &adsp->ssr_subdev); +qcom_remove_sysmon_subdev (adsp->sysmon); +deinit_remove_pdm_smd_glink: +qcom_remove_pdm_subdev (rproc, &adsp->pdm_subdev); +qcom_remove_smd_subdev (rproc, &adsp->smd_subdev); +qcom_remove_glink_subdev (rproc, &adsp->glink_subdev); +qcom_q6v5_deinit (&adsp->q6v5); detach_proxy_pds:adsp_pds_detach (adsp, adsp->proxy_pds, adsp->proxy_pd_count); +unassign_mem: +adsp_unassign_memory_region (adsp); free_rproc:device_init_wakeup (adsp->dev, false);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 535/817 remoteproc: qcom: adsp: Remove subdevs on the error path of adsp_probe()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit fe80d3205e91e36e67f4d3d6c326793298d15766 ]
Current implementation of adsp_probe() in qcom_q6v5_adsp.c and does not remove the subdevs of adsp on the error path. Fix this bug by calling qcom_remove_{ssr,sysmon,pdm,smd,glink}_subdev(), and qcom_q6v5_deinit() appropriately.
--- drivers/remoteproc/qcom_q6v5_adsp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/remoteproc/qcom_q6v5_adsp.c +9 -2
@@ -734,15 +734,22 @@ static int adsp_probe(struct platform_device *pdev) desc->ssctl_id);if (IS_ERR (adsp->sysmon)) { ret =PTR_ERR (adsp->sysmon); - goto disable_pm; + goto deinit_remove_glink_pdm_ssr; } ret =rproc_add (rproc);if (ret) - goto disable_pm; + goto remove_sysmon;return 0 ; +remove_sysmon: +qcom_remove_sysmon_subdev (adsp->sysmon); +deinit_remove_glink_pdm_ssr: +qcom_q6v5_deinit (&adsp->q6v5); +qcom_remove_glink_subdev (rproc, &adsp->glink_subdev); +qcom_remove_pdm_subdev (rproc, &adsp->pdm_subdev); +qcom_remove_ssr_subdev (rproc, &adsp->ssr_subdev); disable_pm:qcom_rproc_pds_detach (adsp);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 536/817 remoteproc: qcom: pas: add minidump_id to SM8350 resources
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e8983156d54f59f57e648ecd44f01c16572da842 ]
Specify minidump_id for the SM8350 DSPs. It was omitted for in the original commit e8b4e9a21af7 ("remoteproc: qcom: pas: Add SM8350 PAS remoteprocs").
--- drivers/remoteproc/qcom_q6v5_pas.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/qcom_q6v5_pas.c +2 -0
@@ -900,6 +900,7 @@ static const struct adsp_data sm8250_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, + .minidump_id = 5, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -1081,6 +1082,7 @@ static const struct adsp_data sm8350_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, + .minidump_id = 7, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 537/817 rpmsg: glink: use only lower 16-bits of param2 for CMD_OPEN name length
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Marek <[email protected]>
[ Upstream commit 06c59d97f63c1b8af521fa5aef8a716fb988b285 ]
The name len field of the CMD_OPEN packet is only 16-bits and the upper 16-bits of "param2" are a different "prio" field, which can be nonzero in certain situations, and CMD_OPEN packets can be unexpectedly dropped because of this.
Fix this by masking out the upper 16 bits of param2.
--- drivers/rpmsg/qcom_glink_native.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rpmsg/qcom_glink_native.c +2 -1
@@ -1117,7 +1117,8 @@ void qcom_glink_native_rx(struct qcom_glink *glink)qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ;case GLINK_CMD_OPEN : - ret =qcom_glink_rx_defer (glink, param2); +/* upper 16 bits of param2 are the "prio" field */ + ret =qcom_glink_rx_defer (glink, param2 &0xffff );break ;case GLINK_CMD_TX_DATA :case GLINK_CMD_TX_DATA_CONT :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 538/817 remoteproc: qcom_q6v5_mss: Re-order writes to the IMEM region
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sibi Sankar <[email protected]>
[ Upstream commit 7b22b7719fc17d5979a991c918c868ab041be5c8 ]
Any write access to the IMEM region when the Q6 is setting up XPU protection on it will result in a XPU violation. Fix this by ensuring IMEM writes related to the MBA post-mortem logs happen before the Q6 is brought out of reset.
--- drivers/remoteproc/qcom_q6v5_mss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +3 -3
@@ -1162,6 +1162,9 @@ static int q6v5_mba_load(struct q6v5 *qproc) goto disable_active_clks; } +if (qproc->has_mba_logs) +qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE ); +writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG );if (qproc->dp_size) {writel (qproc->mba_phys +SZ_1M , qproc->rmb_base +RMB_PMI_CODE_START_REG );
@@ -1172,9 +1175,6 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (ret) goto reclaim_mba; -if (qproc->has_mba_logs) -qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE ); - ret =q6v5_rmb_mba_wait (qproc,0 ,5000 );if (ret == -ETIMEDOUT ) {dev_err (qproc->dev,"MBA boot timed out\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 539/817 PCI: endpoint: epf-mhi: Avoid NULL dereference if DT lacks mmio
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
[ Upstream commit 5089b3d874e9933d9842e90410d3af1520494757 ]
If platform_get_resource_byname() fails and returns NULL because DT lacks an 'mmio' property for the MHI endpoint, dereferencing res->start will cause a NULL pointer access. Add a check to prevent it.
--- drivers/pci/endpoint/functions/pci-epf-mhi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/pci/endpoint/functions/pci-epf-mhi.c +6 -0
@@ -867,12 +867,18 @@ static int pci_epf_mhi_bind(struct pci_epf *epf) {struct pci_epf_mhi *epf_mhi =epf_get_drvdata (epf);struct pci_epc *epc = epf->epc; +struct device *dev = &epf->dev;struct platform_device *pdev =to_platform_device (epc->dev.parent);struct resource *res;int ret;/* Get MMIO base address from Endpoint controller */ res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mmio" ); +if (!res) { +dev_err (dev,"Failed to get \"mmio\" resource\n" ); +return -ENODEV ; + } + epf_mhi->mmio_phys = res->start; epf_mhi->mmio_size =resource_size (res);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 540/817 NFSD: Prevent NULL dereference in nfsd4_process_cb_update()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 1e02c641c3a43c88cecc08402000418e15578d38 ]
@ses is initialized to NULL. If __nfsd4_find_backchannel() finds no available backchannel session, setup_callback_client() will try to dereference @ses and segfault.
--- fs/nfsd/nfs4callback.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfsd/nfs4callback.c +2 -0
@@ -1455,6 +1455,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ses = c->cn_session; }spin_unlock (&clp->cl_lock); +if (!c) +return ; err =setup_callback_client (clp, &conn, ses);if (err) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 541/817 NFSD: Cap the number of bytes copied by nfs4_reset_recoverydir()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit f64ea4af43161bb86ffc77e6aeb5bcf5c3229df0 ]
It's only current caller already length-checks the string, but let's be safe.
--- fs/nfsd/nfs4recover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4recover.c +2 -1
@@ -659,7 +659,8 @@ nfs4_reset_recoverydir(char *recdir)return status; status = -ENOTDIR ;if (d_is_dir (path.dentry)) { -strcpy (user_recovery_dirname, recdir); +strscpy (user_recovery_dirname, recdir, +sizeof (user_recovery_dirname)); status =0 ; }path_put (&path);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 542/817 nfsd: release svc_expkey/svc_export with rcu_work
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Erkun <[email protected]>
[ Upstream commit f8c989a0c89a75d30f899a7cabdc14d72522bb8d ]
The last reference for cache_head can be reduced to zero in c_show and e_show(using rcu_read_lock and rcu_read_unlock). Consequently, svc_export_put and expkey_put will be invoked, leading to two issues:
1. The svc_export_put will directly free ex_uuid. However, e_show/c_show will access ex_uuid after cache_put, which can trigger a use-after-free issue, shown below.
==================================================================
BUG: KASAN: slab-use-after-free in svc_export_show+0x362/0x430 [nfsd]
Read of size 1 at addr ff11000010fdc120 by task cat/870
CPU: 1 UID: 0 PID: 870 Comm: cat Not tainted 6.12.0-rc3+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.16.1-2.fc37 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x53/0x70
print_address_description.constprop.0+0x2c/0x3a0
print_report+0xb9/0x280
kasan_report+0xae/0xe0
svc_export_show+0x362/0x430 [nfsd]
c_show+0x161/0x390 [sunrpc]
seq_read_iter+0x589/0x770
seq_read+0x1e5/0x270
proc_reg_read+0xe1/0x140
vfs_read+0x125/0x530
ksys_read+0xc1/0x160
do_syscall_64+0x5f/0x170
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Allocated by task 830:
kasan_save_stack+0x20/0x40
kasan_save_track+0x14/0x30
__kasan_kmalloc+0x8f/0xa0
__kmalloc_node_track_caller_noprof+0x1bc/0x400
kmemdup_noprof+0x22/0x50
svc_export_parse+0x8a9/0xb80 [nfsd]
cache_do_downcall+0x71/0xa0 [sunrpc]
cache_write_procfs+0x8e/0xd0 [sunrpc]
proc_reg_write+0xe1/0x140
vfs_write+0x1a5/0x6d0
ksys_write+0xc1/0x160
do_syscall_64+0x5f/0x170
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Freed by task 868:
kasan_save_stack+0x20/0x40
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x37/0x50
kfree+0xf3/0x3e0
svc_export_put+0x87/0xb0 [nfsd]
cache_purge+0x17f/0x1f0 [sunrpc]
nfsd_destroy_serv+0x226/0x2d0 [nfsd]
nfsd_svc+0x125/0x1e0 [nfsd]
write_threads+0x16a/0x2a0 [nfsd]
nfsctl_transaction_write+0x74/0xa0 [nfsd]
vfs_write+0x1a5/0x6d0
ksys_write+0xc1/0x160
do_syscall_64+0x5f/0x170
entry_SYSCALL_64_after_hwframe+0x76/0x7e2. We cannot sleep while using rcu_read_lock/rcu_read_unlock. However, svc_export_put/expkey_put will call path_put, which subsequently triggers a sleeping operation due to the following dput.
=============================
WARNING: suspicious RCU usage
5.10.0-dirty #141 Not tainted
-----------------------------
...
Call Trace: dump_stack+0x9a/0xd0 ___might_sleep+0x231/0x240 dput+0x39/0x600 path_put+0x1b/0x30 svc_export_put+0x17/0x80 e_show+0x1c9/0x200 seq_read_iter+0x63f/0x7c0 seq_read+0x226/0x2d0 vfs_read+0x113/0x2c0 ksys_read+0xc9/0x170 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x67/0xd1
Fix these issues by using rcu_work to help release svc_expkey/svc_export. This approach allows for an asynchronous context to invoke path_put and also facilitates the freeing of uuid/exp/key after an RCU grace period.
--- fs/nfsd/export.c | 31 +++++++++++++++++++++++++------ fs/nfsd/export.h | 4 ++-- 2 files changed, 27 insertions(+), 8 deletions(-)
fs/nfsd/export.c +25 -6
@@ -40,15 +40,24 @@#define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1) -static void expkey_put (struct kref *ref) +static void expkey_put_work (struct work_struct *work) { - struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); +struct svc_expkey *key = + container_of(to_rcu_work(work), struct svc_expkey, ek_rcu_work);if (test_bit (CACHE_VALID , &key->h.flags) && !test_bit (CACHE_NEGATIVE , &key->h.flags))path_put (&key->ek_path);auth_domain_put (key->ek_client); -kfree_rcu (key, ek_rcu); +kfree (key); +} + +static void expkey_put (struct kref *ref) +{ + struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); + +INIT_RCU_WORK (&key->ek_rcu_work, expkey_put_work); +queue_rcu_work (system_wq, &key->ek_rcu_work); }static int expkey_upcall (struct cache_detail *cd,struct cache_head *h)
@@ -355,16 +364,26 @@ static void export_stats_destroy(struct export_stats *stats) EXP_STATS_COUNTERS_NUM); } -static void svc_export_put (struct kref *ref) +static void svc_export_put_work (struct work_struct *work) { - struct svc_export *exp = container_of(ref, struct svc_export, h.ref); +struct svc_export *exp = + container_of(to_rcu_work(work), struct svc_export, ex_rcu_work); +path_put (&exp->ex_path);auth_domain_put (exp->ex_client);nfsd4_fslocs_free (&exp->ex_fslocs);export_stats_destroy (exp->ex_stats);kfree (exp->ex_stats);kfree (exp->ex_uuid); -kfree_rcu (exp, ex_rcu); +kfree (exp); +} + +static void svc_export_put (struct kref *ref) +{ + struct svc_export *exp = container_of(ref, struct svc_export, h.ref); + +INIT_RCU_WORK (&exp->ex_rcu_work, svc_export_put_work); +queue_rcu_work (system_wq, &exp->ex_rcu_work); }static int svc_export_upcall (struct cache_detail *cd,struct cache_head *h)
fs/nfsd/export.h +2 -2
@@ -75,7 +75,7 @@ struct svc_export {u32 ex_layout_types;struct nfsd4_deviceid_map *ex_devid_map;struct cache_detail *cd; -struct rcu_head ex_rcu; +struct rcu_work ex_rcu_work;unsigned long ex_xprtsec_modes;struct export_stats *ex_stats; };
@@ -92,7 +92,7 @@ struct svc_expkey {u32 ek_fsid[6 ];struct path ek_path; -struct rcu_head ek_rcu; +struct rcu_work ek_rcu_work; };#define EX_ISSYNC (exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 543/817 svcrdma: fix miss destroy percpu_counter in svc_rdma_proc_init()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit ce89e742a4c12b20f09a43fec1b21db33f2166cd ]
There's issue as follows:
RPC: Registered rdma transport module.
RPC: Registered rdma backchannel transport module.
RPC: Unregistered rdma transport module.
RPC: Unregistered rdma backchannel transport module.
BUG: unable to handle page fault for address: fffffbfff80c609a PGD 123fee067 P4D 123fee067 PUD 123fea067 PMD 10c624067 PTE 0 Oops: Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI RIP: 0010:percpu_counter_destroy_many+0xf7/0x2a0 Call Trace: <TASK> __die+0x1f/0x70 page_fault_oops+0x2cd/0x860 spurious_kernel_fault+0x36/0x450 do_kern_addr_fault+0xca/0x100 exc_page_fault+0x128/0x150 asm_exc_page_fault+0x26/0x30 percpu_counter_destroy_many+0xf7/0x2a0 mmdrop+0x209/0x350 finish_task_switch.isra.0+0x481/0x840 schedule_tail+0xe/0xd0 ret_from_fork+0x23/0x80 ret_from_fork_asm+0x1a/0x30 </TASK>
If register_sysctl() return NULL, then svc_rdma_proc_cleanup() will not destroy the percpu counters which init in svc_rdma_proc_init(). If CONFIG_HOTPLUG_CPU is enabled, residual nodes may be in the 'percpu_counters' list. The above issue may occur once the module is removed. If the CONFIG_HOTPLUG_CPU configuration is not enabled, memory leakage occurs.
To solve above issue just destroy all percpu counters when register_sysctl() return NULL.
--- net/sunrpc/xprtrdma/svc_rdma.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
net/sunrpc/xprtrdma/svc_rdma.c +14 -5
@@ -233,25 +233,34 @@ static int svc_rdma_proc_init(void) rc =percpu_counter_init (&svcrdma_stat_read,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err; rc =percpu_counter_init (&svcrdma_stat_recv,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_read; rc =percpu_counter_init (&svcrdma_stat_sq_starve,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_recv; rc =percpu_counter_init (&svcrdma_stat_write,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_sq; svcrdma_table_header =register_sysctl ("sunrpc/svc_rdma" , svcrdma_parm_table); +if (!svcrdma_table_header) + goto err_write; +return 0 ; -out_err: +err_write: + rc = -ENOMEM ; +percpu_counter_destroy (&svcrdma_stat_write); +err_sq:percpu_counter_destroy (&svcrdma_stat_sq_starve); +err_recv:percpu_counter_destroy (&svcrdma_stat_recv); +err_read:percpu_counter_destroy (&svcrdma_stat_read); +err:return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 544/817 NFSD: Fix nfsd4_shutdown_copy()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 62a8642ba00aa8ceb0a02ade942f5ec52e877c95 ]
nfsd4_shutdown_copy() is just this:
while ((copy = nfsd4_get_copy(clp)) != NULL) nfsd4_stop_copy(copy);
nfsd4_get_copy() bumps @copy's reference count, preventing nfsd4_stop_copy() from releasing @copy.
A while loop like this usually works by removing the first element of the list, but neither nfsd4_get_copy() nor nfsd4_stop_copy() alters the async_copies list.
Best I can tell, then, is that nfsd4_shutdown_copy() continues to loop until other threads manage to remove all the items from this list. The spinning loop blocks shutdown until these items are gone.
Possibly the reason we haven't seen this issue in the field is because client_has_state() prevents __destroy_client() from calling nfsd4_shutdown_copy() if there are any items on this list. In a subsequent patch I plan to remove that restriction.
--- fs/nfsd/nfs4proc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +5 -2
@@ -1291,7 +1291,7 @@ static void nfsd4_stop_copy(struct nfsd4_copy *copy)nfs4_put_copy (copy); } -static struct nfsd4_copy *nfsd4_get_copy (struct nfs4_client *clp) +static struct nfsd4_copy *nfsd4_unhash_copy (struct nfs4_client *clp) {struct nfsd4_copy *copy =NULL ;
@@ -1300,6 +1300,9 @@ static struct nfsd4_copy *nfsd4_get_copy(struct nfs4_client *clp) copy = list_first_entry(&clp->async_copies, struct nfsd4_copy, copies);refcount_inc (©->refcount); + copy->cp_clp =NULL ; +if (!list_empty (©->copies)) +list_del_init (©->copies); }spin_unlock (&clp->async_lock);return copy;
@@ -1309,7 +1312,7 @@ void nfsd4_shutdown_copy(struct nfs4_client *clp) {struct nfsd4_copy *copy; -while ((copy =nfsd4_get_copy (clp)) !=NULL ) +while ((copy =nfsd4_unhash_copy (clp)) !=NULL )nfsd4_stop_copy (copy); }#ifdef CONFIG_NFSD_V4_2_INTER_SSC
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 545/817 f2fs: clean up val{>>,<<}F2FS_BLKSIZE_BITS
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit 8fb9f31984bdc0aaa1b0f7c7e7a27bd3137f8744 ]
Use F2FS_BYTES_TO_BLK(bytes) and F2FS_BLK_TO_BYTES(blk) for cleanup
Stable-dep-of: 3273d8ad947d ("f2fs: fix to do cast in F2FS_{BLK_TO_BYTES, BTYES_TO_BLK} to avoid overflow")
--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/debug.c | 2 +- fs/f2fs/file.c | 6 +++--- fs/f2fs/node.c | 4 ++-- fs/f2fs/super.c | 2 +- include/linux/f2fs_fs.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)
fs/f2fs/checkpoint.c +1 -1
@@ -1551,7 +1551,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) blk = start_blk +BLKS_PER_SEG (sbi) - nm_i->nat_bits_blocks;for (i =0 ; i < nm_i->nat_bits_blocks; i++)f2fs_update_meta_page (sbi, nm_i->nat_bits + - (i <<F2FS_BLKSIZE_BITS ), blk + i); +F2FS_BLK_TO_BYTES (i), blk + i); }/* write out checkpoint buffer at block 0 */
fs/f2fs/debug.c +1 -1
@@ -275,7 +275,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)/* build nm */ si->base_mem +=sizeof (struct f2fs_nm_info ); si->base_mem +=__bitmap_size (sbi,NAT_BITMAP ); - si->base_mem += (NM_I (sbi)->nat_bits_blocks <<F2FS_BLKSIZE_BITS ); + si->base_mem +=F2FS_BLK_TO_BYTES (NM_I (sbi)->nat_bits_blocks); si->base_mem +=NM_I (sbi)->nat_blocks *f2fs_bitmap_size (NAT_ENTRY_PER_BLOCK ); si->base_mem +=NM_I (sbi)->nat_blocks /8 ;
fs/f2fs/file.c +3 -3
@@ -3013,9 +3013,9 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, }f2fs_lock_op (sbi); - ret =__exchange_data_block (src, dst, pos_in >>F2FS_BLKSIZE_BITS , - pos_out >>F2FS_BLKSIZE_BITS , - len >>F2FS_BLKSIZE_BITS , false); + ret =__exchange_data_block (src, dst,F2FS_BYTES_TO_BLK (pos_in), +F2FS_BYTES_TO_BLK (pos_out), +F2FS_BYTES_TO_BLK (len), false);if (!ret) {if (dst_max_i_size)
fs/f2fs/node.c +2 -2
@@ -3166,7 +3166,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) nm_i->nat_bits_blocks =F2FS_BLK_ALIGN ((nat_bits_bytes <<1 ) +8 ); nm_i->nat_bits =f2fs_kvzalloc (sbi, - nm_i->nat_bits_blocks <<F2FS_BLKSIZE_BITS ,GFP_KERNEL ); +F2FS_BLK_TO_BYTES (nm_i->nat_bits_blocks),GFP_KERNEL );if (!nm_i->nat_bits)return -ENOMEM ;
@@ -3185,7 +3185,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)if (IS_ERR (page))return PTR_ERR (page); -memcpy (nm_i->nat_bits + (i <<F2FS_BLKSIZE_BITS ), +memcpy (nm_i->nat_bits +F2FS_BLK_TO_BYTES (i),page_address (page),F2FS_BLKSIZE );f2fs_put_page (page,1 ); }
fs/f2fs/super.c +1 -1
@@ -3323,7 +3323,7 @@ loff_t max_file_blocks(struct inode *inode)* fit within U32_MAX + 1 data units. */ - result =min (result, (((loff_t )U32_MAX +1 ) *4096 ) >>F2FS_BLKSIZE_BITS ); + result =min (result,F2FS_BYTES_TO_BLK (((loff_t )U32_MAX +1 ) *4096 ));return result; }
include/linux/f2fs_fs.h +1 -1
@@ -19,7 +19,6 @@#define F2FS_BLKSIZE_BITS PAGE_SHIFT/* bits for F2FS_BLKSIZE */ #define F2FS_MAX_EXTENSION 64/* # of extension entries */ #define F2FS_EXTENSION_LEN 8/* max size of extension */ -#define F2FS_BLK_ALIGN (x) (((x) + F2FS_BLKSIZE - 1) >> F2FS_BLKSIZE_BITS)#define NULL_ADDR ((block_t)0)/* used as block_t addresses */ #define NEW_ADDR ((block_t)-1)/* used as block_t addresses */
@@ -28,6 +27,7 @@#define F2FS_BYTES_TO_BLK (bytes) ((bytes) >> F2FS_BLKSIZE_BITS)#define F2FS_BLK_TO_BYTES (blk) ((blk) << F2FS_BLKSIZE_BITS)#define F2FS_BLK_END_BYTES (blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1) +#define F2FS_BLK_ALIGN (x) (F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))/* 0, 1(node nid), 2(meta nid) are reserved node id */ #define F2FS_RESERVED_NODE_NUM 3
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 546/817 f2fs: fix to do cast in F2FS_{BLK_TO_BYTES, BTYES_TO_BLK} to avoid overflow
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 3273d8ad947dea925a65a78ca29e5351c960c801 ]
It missed to cast variable to unsigned long long type before bit shift, which will cause overflow, fix it.
--- fs/f2fs/super.c | 2 +- include/linux/f2fs_fs.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/f2fs/super.c +1 -1
@@ -3323,7 +3323,7 @@ loff_t max_file_blocks(struct inode *inode)* fit within U32_MAX + 1 data units. */ - result =min (result,F2FS_BYTES_TO_BLK (((loff_t )U32_MAX +1 ) *4096 )); + result =umin (result,F2FS_BYTES_TO_BLK (((loff_t )U32_MAX +1 ) *4096 ));return result; }
include/linux/f2fs_fs.h +3 -3
@@ -24,10 +24,10 @@#define NEW_ADDR ((block_t)-1)/* used as block_t addresses */ #define COMPRESS_ADDR ((block_t)-2)/* used as compressed data flag */ -#define F2FS_BYTES_TO_BLK (bytes) ((bytes) >> F2FS_BLKSIZE_BITS) -#define F2FS_BLK_TO_BYTES (blk) ((blk) << F2FS_BLKSIZE_BITS) +#define F2FS_BYTES_TO_BLK (bytes) ((unsigned long long)(bytes) >> F2FS_BLKSIZE_BITS) +#define F2FS_BLK_TO_BYTES (blk) ((unsigned long long)(blk) << F2FS_BLKSIZE_BITS)#define F2FS_BLK_END_BYTES (blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1) -#define F2FS_BLK_ALIGN (x) (F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1)) +#define F2FS_BLK_ALIGN (x) (F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))/* 0, 1(node nid), 2(meta nid) are reserved node id */ #define F2FS_RESERVED_NODE_NUM 3
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 547/817 hwmon: (tps23861) Fix reporting of negative temperatures
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit de2bf507fabba9c0c678cf5ed54beb546f5ca29a ]
Negative temperatures are reported as large positive temperatures due to missing sign extension from unsigned int to long. Cast unsigned raw register values to signed before performing the calculations to fix the problem.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Message-ID: <[email protected]>
--- drivers/hwmon/tps23861.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tps23861.c +1 -1
@@ -132,7 +132,7 @@ static int tps23861_read_temp(struct tps23861_data *data, long *val)if (err <0 )return err; - *val = (regval *TEMPERATURE_LSB ) -20000 ; + *val = ((long )regval *TEMPERATURE_LSB ) -20000 ;return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 548/817 hwmon: (aquacomputer_d5next) Fix length of speed_input array
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksa Savic <[email protected]>
[ Upstream commit 998b5a78a9ce1cc4378e7281e4ea310e37596170 ]
Commit 120584c728a6 ("hwmon: (aquacomputer_d5next) Add support for Octo flow sensor") added support for reading Octo flow sensor, but didn't update the priv->speed_input array length. Since Octo has 8 fans, with the addition of the flow sensor the proper length for speed_input is 9.
Reported by Arne Schwabe on Github [1], who received a UBSAN warning.
Message-ID: <[email protected]>
--- drivers/hwmon/aquacomputer_d5next.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/aquacomputer_d5next.c +1 -1
@@ -597,7 +597,7 @@ struct aqc_data {/* Sensor values */ s32 temp_input[20 ];/* Max 4 physical and 16 virtual or 8 physical and 12 virtual */ -s32 speed_input[8 ]; +s32 speed_input[9 ];u32 speed_input_min[1 ];u32 speed_input_target[1 ];u32 speed_input_max[1 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 549/817 phy: airoha: Fix REG_CSR_2L_PLL_CMN_RESERVE0 config in airoha_pcie_phy_init_clk_out()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 09a19fb75498985cbb598f1fa43a7d2416925c30 ]
Fix typo configuring REG_CSR_2L_PLL_CMN_RESERVE0 register in airoha_pcie_phy_init_clk_out routine.
--- drivers/phy/phy-airoha-pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-airoha-pcie.c +1 -1
@@ -456,7 +456,7 @@ static void airoha_pcie_phy_init_clk_out(struct airoha_pcie_phy *pcie_phy)airoha_phy_csr_2l_clear_bits (pcie_phy,REG_CSR_2L_CLKTX1_OFFSET ,CSR_2L_PXP_CLKTX1_SR );airoha_phy_csr_2l_update_field (pcie_phy,REG_CSR_2L_PLL_CMN_RESERVE0 , -CSR_2L_PXP_PLL_RESERVE_MASK ,0xdd ); +CSR_2L_PXP_PLL_RESERVE_MASK ,0xd0d ); }static void airoha_pcie_phy_init_csr_2l (struct airoha_pcie_phy *pcie_phy)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 550/817 phy: airoha: Fix REG_PCIE_PMA_TX_RESET config in airoha_pcie_phy_init_csr_2l()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit f9c5d6369d3e8e36b7beb15e86b1ef0911ace85f ]
Fix typos configuring REG_PCIE_PMA_TX_RESET register in airoha_pcie_phy_init_csr_2l routine for lane0 and lane1
--- drivers/phy/phy-airoha-pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-airoha-pcie.c +2 -2
@@ -468,9 +468,9 @@ static void airoha_pcie_phy_init_csr_2l(struct airoha_pcie_phy *pcie_phy)PCIE_SW_XFI_RXPCS_RST |PCIE_SW_REF_RST | PCIE_SW_RX_RST);airoha_phy_pma0_set_bits (pcie_phy,REG_PCIE_PMA_TX_RESET , -PCIE_TX_TOP_RST |REG_PCIE_PMA_TX_RESET ); +PCIE_TX_TOP_RST |PCIE_TX_CAL_RST );airoha_phy_pma1_set_bits (pcie_phy,REG_PCIE_PMA_TX_RESET , -PCIE_TX_TOP_RST |REG_PCIE_PMA_TX_RESET ); +PCIE_TX_TOP_RST |PCIE_TX_CAL_RST ); }static void airoha_pcie_phy_init_rx (struct airoha_pcie_phy *pcie_phy)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 551/817 phy: airoha: Fix REG_CSR_2L_JCPLL_SDM_HREN config in airoha_pcie_phy_init_ssc_jcpll()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6fd016c965d241673a2e62afbf9eeb4bcbfbbe45 ]
Fix typo configuring REG_CSR_2L_JCPLL_SDM_HREN register in airoha_pcie_phy_init_ssc_jcpll routine.
--- drivers/phy/phy-airoha-pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-airoha-pcie.c +1 -1
@@ -799,7 +799,7 @@ static void airoha_pcie_phy_init_ssc_jcpll(struct airoha_pcie_phy *pcie_phy)airoha_phy_csr_2l_set_bits (pcie_phy,REG_CSR_2L_JCPLL_SDM_IFM ,CSR_2L_PXP_JCPLL_SDM_IFM );airoha_phy_csr_2l_set_bits (pcie_phy,REG_CSR_2L_JCPLL_SDM_HREN , -REG_CSR_2L_JCPLL_SDM_HREN ); +CSR_2L_PXP_JCPLL_SDM_HREN );airoha_phy_csr_2l_clear_bits (pcie_phy,REG_CSR_2L_JCPLL_RST_DLY ,CSR_2L_PXP_JCPLL_SDM_DI_EN ); airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 552/817 phy: airoha: Fix REG_CSR_2L_RX{0,1}_REV0 definitions
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit e56272f2bb8314eb13b0eb0a4e8055831c700255 ]
Fix the following register definitions for REG_CSR_2L_RX{0,1}_REV0 registers:
- CSR_2L_PXP_VOS_PNINV
- CSR_2L_PXP_FE_GAIN_NORMAL_MODE
- CSR_2L_PXP_FE_GAIN_TRAIN_MODE
--- drivers/phy/phy-airoha-pcie-regs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/phy-airoha-pcie-regs.h +3 -3
@@ -197,9 +197,9 @@#define CSR_2L_PXP_TX1_MULTLANE_EN BIT(0)#define REG_CSR_2L_RX0_REV0 0x00fc -#define CSR_2L_PXP_VOS_PNINV GENMASK(3, 2) -#define CSR_2L_PXP_FE_GAIN_NORMAL_MODE GENMASK(6, 4) -#define CSR_2L_PXP_FE_GAIN_TRAIN_MODE GENMASK(10, 8) +#define CSR_2L_PXP_VOS_PNINV GENMASK(19, 18) +#define CSR_2L_PXP_FE_GAIN_NORMAL_MODE GENMASK(22, 20) +#define CSR_2L_PXP_FE_GAIN_TRAIN_MODE GENMASK(26, 24)#define REG_CSR_2L_RX0_PHYCK_DIV 0x0100#define CSR_2L_PXP_RX0_PHYCK_SEL GENMASK(9, 8)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 553/817 vdpa/mlx5: Fix suboptimal range on iotlb iteration
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Si-Wei Liu <[email protected]>
[ Upstream commit 35025963326e44d8bced3eecd42d2f040f4f0024 ]
The starting iova address to iterate iotlb map entry within a range was set to an irrelevant value when passing to the itree_next() iterator, although luckily it doesn't affect the outcome of finding out the granule of the smallest iotlb map size. Fix the code to make it consistent with the following for-loop.
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/core/mr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/vdpa/mlx5/core/mr.c +1 -3
@@ -227,7 +227,6 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mrunsigned long lgcd =0 ;int log_entity_size;unsigned long size; -u64 start =0 ;int err;struct page *pg;unsigned int nsg;
@@ -238,10 +237,9 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mrstruct device *dma = mvdev->vdev.dma_dev;for (map =vhost_iotlb_itree_first (iotlb, mr->start, mr->end -1 ); - map; map =vhost_iotlb_itree_next (map, start, mr->end -1 )) { + map; map =vhost_iotlb_itree_next (map, mr->start, mr->end -1 )) { size =maplen (map, mr); lgcd =gcd (lgcd, size); - start += size; } log_entity_size =ilog2 (lgcd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 554/817 vfio/mlx5: Fix an unwind issue in mlx5vf_add_migration_pages()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit 22e87bf3f77c18f5982c19ffe2732ef0c7a25f16 ]
Fix an unwind issue in mlx5vf_add_migration_pages().
If a set of pages is allocated but fails to be added to the SG table, they need to be freed to prevent a memory leak.
Any pages successfully added to the SG table will be freed as part of mlx5vf_free_data_buffer().
--- drivers/vfio/pci/mlx5/cmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/vfio/pci/mlx5/cmd.c +5 -1
@@ -423,6 +423,7 @@ static int mlx5vf_add_migration_pages(struct mlx5_vhca_data_buffer *buf,unsigned long filled;unsigned int to_fill;int ret; +int i; to_fill = min_t(unsigned int, npages, PAGE_SIZE / sizeof(*page_list)); page_list =kvzalloc (to_fill *sizeof (*page_list),GFP_KERNEL_ACCOUNT );
@@ -443,7 +444,7 @@ static int mlx5vf_add_migration_pages(struct mlx5_vhca_data_buffer *buf, GFP_KERNEL_ACCOUNT);if (ret) - goto err; + goto err_append; buf->allocated_length += filled *PAGE_SIZE ;/* clean input for another bulk allocation */ memset (page_list,0 , filled *sizeof (*page_list));
@@ -454,6 +455,9 @@ static int mlx5vf_add_migration_pages(struct mlx5_vhca_data_buffer *buf,kvfree (page_list);return 0 ; +err_append: +for (i = filled -1 ; i >=0 ; i--) +__free_page (page_list[i]); err:kvfree (page_list);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 555/817 vfio/mlx5: Fix unwind flows in mlx5vf_pci_save/resume_device_data()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit cb04444c243c001fc27f275e84792ff1c2b96867 ]
Fix unwind flows in mlx5vf_pci_save_device_data() and mlx5vf_pci_resume_device_data() to avoid freeing the migf pointer at the 'end' label, as this will be handled by fput(migf->filp) through mlx5vf_release_file().
To ensure mlx5vf_release_file() functions correctly, move the initialization of migf fields (such as migf->lock) to occur before any potential unwind flow, as these fields may be accessed within mlx5vf_release_file().
--- drivers/vfio/pci/mlx5/main.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/vfio/pci/mlx5/main.c +17 -18
@@ -641,14 +641,11 @@ mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev, bool track) O_RDONLY);if (IS_ERR (migf->filp)) { ret =PTR_ERR (migf->filp); - goto end; +kfree (migf); +return ERR_PTR (ret); } migf->mvdev = mvdev; - ret =mlx5vf_cmd_alloc_pd (migf); -if (ret) - goto out_free; -stream_open (migf->filp->f_inode, migf->filp);mutex_init (&migf->lock);init_waitqueue_head (&migf->poll_wait);
@@ -664,6 +661,11 @@ mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev, bool track)INIT_LIST_HEAD (&migf->buf_list);INIT_LIST_HEAD (&migf->avail_list);spin_lock_init (&migf->list_lock); + + ret =mlx5vf_cmd_alloc_pd (migf); +if (ret) + goto out; + ret =mlx5vf_cmd_query_vhca_migration_state (mvdev, &length, &full_size,0 );if (ret) goto out_pd;
@@ -693,10 +695,8 @@ mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev, bool track)mlx5vf_free_data_buffer (buf); out_pd:mlx5fv_cmd_clean_migf_resources (migf); -out_free: +out:fput (migf->filp); -end: -kfree (migf);return ERR_PTR (ret); }
@@ -1018,13 +1018,19 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) O_WRONLY);if (IS_ERR (migf->filp)) { ret =PTR_ERR (migf->filp); - goto end; +kfree (migf); +return ERR_PTR (ret); } +stream_open (migf->filp->f_inode, migf->filp); +mutex_init (&migf->lock); +INIT_LIST_HEAD (&migf->buf_list); +INIT_LIST_HEAD (&migf->avail_list); +spin_lock_init (&migf->list_lock); migf->mvdev = mvdev; ret =mlx5vf_cmd_alloc_pd (migf);if (ret) - goto out_free; + goto out; buf =mlx5vf_alloc_data_buffer (migf,0 ,DMA_TO_DEVICE );if (IS_ERR (buf)) {
@@ -1043,20 +1049,13 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) migf->buf_header[0 ] = buf; migf->load_state =MLX5_VF_LOAD_STATE_READ_HEADER ; -stream_open (migf->filp->f_inode, migf->filp); -mutex_init (&migf->lock); -INIT_LIST_HEAD (&migf->buf_list); -INIT_LIST_HEAD (&migf->avail_list); -spin_lock_init (&migf->list_lock);return migf; out_buf:mlx5vf_free_data_buffer (migf->buf[0 ]); out_pd:mlx5vf_cmd_dealloc_pd (migf); -out_free: +out:fput (migf->filp); -end: -kfree (migf);return ERR_PTR (ret); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 556/817 selftests/mount_setattr: Fix failures on 64K PAGE_SIZE kernels
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit f13242a46438e690067a4bf47068fde4d5719947 ]
Currently the mount_setattr_test fails on machines with a 64K PAGE_SIZE, with errors such as:
# RUN mount_setattr_idmapped.invalid_fd_negative ...
mkfs.ext4: No space left on device while writing out and closing file system
# mount_setattr_test.c:1055:invalid_fd_negative:Expected system("mkfs.ext4 -q /mnt/C/ext4.img") (256) == 0 (0) # invalid_fd_negative: Test terminated by assertion
# FAIL mount_setattr_idmapped.invalid_fd_negative
not ok 12 mount_setattr_idmapped.invalid_fd_negative
The code creates a 100,000 byte tmpfs:
ASSERT_EQ(mount("testing", "/mnt", "tmpfs", MS_NOATIME | MS_NODEV,
"size=100000,mode=700"), 0);And then a little later creates a 2MB ext4 filesystem in that tmpfs:
ASSERT_EQ(ftruncate(img_fd, 1024 * 2048), 0);
ASSERT_EQ(system("mkfs.ext4 -q /mnt/C/ext4.img"), 0);At first glance it seems like that should never work, after all 2MB is larger than 100,000 bytes. However the filesystem image doesn't actually occupy 2MB on "disk" (actually RAM, due to tmpfs). On 4K kernels the ext4.img uses ~84KB of actual space (according to du), which just fits.
However on 64K PAGE_SIZE kernels the ext4.img takes at least 256KB, which is too large to fit in the tmpfs, hence the errors.
It seems fraught to rely on the ext4.img taking less space on disk than the allocated size, so instead create the tmpfs with a size of 2MB. With that all 21 tests pass on 64K PAGE_SIZE kernels.
--- tools/testing/selftests/mount_setattr/mount_setattr_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mount_setattr/mount_setattr_test.c +1 -1
@@ -1026,7 +1026,7 @@ FIXTURE_SETUP(mount_setattr_idmapped) "size=100000,mode=700"), 0);ASSERT_EQ (mount ("testing" ,"/mnt" ,"tmpfs" ,MS_NOATIME |MS_NODEV , -"size=100000,mode=700" ),0 ); +"size=2m,mode=700" ),0 );ASSERT_EQ (mkdir ("/mnt/A" ,0777 ),0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 557/817 gpio: zevio: Add missed label initialisation
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 5bbed54ba66925ebca19092d0750630f943d7bf2 ]
Initialise the GPIO chip label correctly as it was done by of_mm_gpiochip_add_data() before the below mentioned change.
--- drivers/gpio/gpio-zevio.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpio/gpio-zevio.c +6 -0
@@ -11,6 +11,7 @@#include <linux/io.h> #include <linux/mod_devicetable.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -169,6 +170,7 @@ static const struct gpio_chip zevio_gpio_chip = {/* Initialization */ static int zevio_gpio_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct zevio_gpio *controller;int status, i;
@@ -180,6 +182,10 @@ static int zevio_gpio_probe(struct platform_device *pdev) controller->chip = zevio_gpio_chip; controller->chip.parent = &pdev->dev; + controller->chip.label =devm_kasprintf (dev,GFP_KERNEL ,"%pfw" ,dev_fwnode (dev)); +if (!controller->chip.label) +return -ENOMEM ; + controller->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (controller->regs)) return dev_err_probe(&pdev->dev, PTR_ERR(controller->regs),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 558/817 vfio/pci: Properly hide first-in-list PCIe extended capability
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avihai Horon <[email protected]>
[ Upstream commit fe4bf8d0b6716a423b16495d55b35d3fe515905d ]
There are cases where a PCIe extended capability should be hidden from the user. For example, an unknown capability (i.e., capability with ID greater than PCI_EXT_CAP_ID_MAX) or a capability that is intentionally chosen to be hidden from the user.
Hiding a capability is done by virtualizing and modifying the 'Next Capability Offset' field of the previous capability so it points to the capability after the one that should be hidden.
The special case where the first capability in the list should be hidden is handled differently because there is no previous capability that can be modified. In this case, the capability ID and version are zeroed while leaving the next pointer intact. This hides the capability and leaves an anchor for the rest of the capability list.
However, today, hiding the first capability in the list is not done properly if the capability is unknown, as struct vfio_pci_core_device->pci_config_map is set to the capability ID during initialization but the capability ID is not properly checked later when used in vfio_config_do_rw(). This leads to the following warning [1] and to an out-of-bounds access to ecap_perms array.
Fix it by checking cap_id in vfio_config_do_rw(), and if it is greater than PCI_EXT_CAP_ID_MAX, use an alternative struct perm_bits for direct read only access instead of the ecap_perms array.
Note that this is safe since the above is the only case where cap_id can exceed PCI_EXT_CAP_ID_MAX (except for the special capabilities, which are already checked before).
[1]
WARNING: CPU: 118 PID: 5329 at drivers/vfio/pci/vfio_pci_config.c:1900 vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] CPU: 118 UID: 0 PID: 5329 Comm: simx-qemu-syste Not tainted 6.12.0+ #1 (snip) Call Trace: <TASK> ? show_regs+0x69/0x80 ? __warn+0x8d/0x140 ? vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] ? report_bug+0x18f/0x1a0 ? handle_bug+0x63/0xa0 ? exc_invalid_op+0x19/0x70 ? asm_exc_invalid_op+0x1b/0x20 ? vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] ? vfio_pci_config_rw+0x244/0x430 [vfio_pci_core] vfio_pci_rw+0x101/0x1b0 [vfio_pci_core] vfio_pci_core_read+0x1d/0x30 [vfio_pci_core] vfio_device_fops_read+0x27/0x40 [vfio] vfs_read+0xbd/0x340 ? vfio_device_fops_unl_ioctl+0xbb/0x740 [vfio] ? __rseq_handle_notify_resume+0xa4/0x4b0 __x64_sys_pread64+0x96/0xc0 x64_sys_call+0x1c3d/0x20d0 do_syscall_64+0x4d/0x120 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- drivers/vfio/pci/vfio_pci_config.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci_config.c +14 -2
@@ -313,6 +313,10 @@ static int vfio_virt_config_read(struct vfio_pci_core_device *vdev, int pos,return count; } +static struct perm_bits direct_ro_perms = { + .readfn = vfio_direct_config_read, +}; +/* Default capability regions to read-only, no-virtualization */ static struct perm_bits cap_perms[PCI_CAP_ID_MAX +1 ] = { [0 ...PCI_CAP_ID_MAX ] = { .readfn = vfio_direct_config_read }
@@ -1897,9 +1901,17 @@ static ssize_t vfio_config_do_rw(struct vfio_pci_core_device *vdev, char __user cap_start = *ppos; }else {if (*ppos >=PCI_CFG_SPACE_SIZE ) { -WARN_ON (cap_id >PCI_EXT_CAP_ID_MAX ); +/* +* We can get a cap_id that exceeds PCI_EXT_CAP_ID_MAX +* if we're hiding an unknown capability at the start +* of the extended capability list. Use default, ro +* access, which will virtualize the id and next values. +*/ +if (cap_id >PCI_EXT_CAP_ID_MAX ) + perm = &direct_ro_perms; +else + perm = &ecap_perms[cap_id]; - perm = &ecap_perms[cap_id]; cap_start =vfio_find_cap_start (vdev, *ppos); }else {WARN_ON (cap_id >PCI_CAP_ID_MAX );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 559/817 fs_parser: update mount_api doc to match function signature
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit c66f759832a83cb273ba5a55c66dcc99384efa74 ]
Add the missing 'name' parameter to the mount_api documentation for fs_validate_description().
--- Documentation/filesystems/mount_api.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/mount_api.rst +2 -1
@@ -770,7 +770,8 @@ process the parameters it is given. * :: - bool fs_validate_description(const struct fs_parameter_description *desc); + bool fs_validate_description(const char *name, + const struct fs_parameter_description *desc); This performs some validation checks on a parameter description. It returns true if the description is good and false if it is not. It will
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 560/817 LoongArch: Fix build failure with GCC 15 (-std=gnu23)
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 947d5d036c788156f09e83e7f16322ffe8124384 ]
Whenever I try to build the kernel with upcoming GCC 15 which defaults to -std=gnu23 I get a build failure:
CC arch/loongarch/vdso/vgetcpu.o
In file included from ./include/uapi/linux/posix_types.h:5,
from ./include/uapi/linux/types.h:14,
from ./include/linux/types.h:6,
from ./include/linux/kasan-checks.h:5,
from ./include/asm-generic/rwonce.h:26,
from ./arch/loongarch/include/generated/asm/rwonce.h:1,
from ./include/linux/compiler.h:317,
from ./include/asm-generic/bug.h:5,
from ./arch/loongarch/include/asm/bug.h:60,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from ./include/linux/mm.h:6,
from ./arch/loongarch/include/asm/vdso.h:10,
from arch/loongarch/vdso/vgetcpu.c:6:
./include/linux/stddef.h:11:9: error: expected identifier before 'false'
11 | false = 0,
| ^~~~~
./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
35 | typedef _Bool bool;
| ^~~~
./include/linux/types.h:35:1: warning: useless type name in empty declaration
35 | typedef _Bool bool;
| ^~~~~~~The kernel builds explicitly with -std=gnu11 in top Makefile, but arch/loongarch/vdso does not use KBUILD_CFLAGS from the rest of the kernel, just add -std=gnu11 flag to arch/loongarch/vdso/Makefile.
By the way, commit e8c07082a810 ("Kbuild: move to -std=gnu11") did a similar change for arch/arm64/kernel/vdso32/Makefile.
--- arch/loongarch/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/vdso/Makefile +1 -1
@@ -18,7 +18,7 @@ ccflags-vdso := \ cflags-vdso := $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=include) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ + -std=gnu11 -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 561/817 LoongArch: BPF: Sign-extend return values
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 73c359d1d356cf10236ccd358bd55edab33e9424 ]
(1) Description of Problem:
When testing BPF JIT with the latest compiler toolchains on LoongArch, there exist some strange failed test cases, dmesg shows something like this:
# dmesg -t | grep FAIL | head -1 ... ret -3 != -3 (0xfffffffd != 0xfffffffd)FAIL ...
(2) Steps to Reproduce:
# echo 1 > /proc/sys/net/core/bpf_jit_enable # modprobe test_bpf
(3) Additional Info:
There are no failed test cases compiled with the lower version of GCC such as 13.3.0, while the problems only appear with higher version of GCC such as 14.2.0.
This is because the problems were hidden by the lower version of GCC due to redundant sign extension instructions generated by compiler, but with optimization of higher version of GCC, the sign extension instructions have been removed.
(4) Root Cause Analysis:
The LoongArch architecture does not expose sub-registers, and hold all 32-bit values in a sign-extended format. While BPF, on the other hand, exposes sub-registers, and use zero-extension (similar to arm64/x86).
This has led to some subtle bugs, where a BPF JITted program has not sign-extended the a0 register (return value in LoongArch land), passed the return value up the kernel, for example:
| int from_bpf(void);
|
| long foo(void)
| {
| return from_bpf();
| }Here, a0 would be 0xffffffff instead of the expected 0xffffffffffffffff.
Internally, the LoongArch JIT uses a5 as a dedicated register for BPF return values. That is to say, the LoongArch BPF uses a5 for BPF return values, which are zero-extended, whereas the LoongArch ABI uses a0 which is sign-extended.
(5) Final Solution:
Keep a5 zero-extended, but explicitly sign-extend a0 (which is used outside BPF land). Because libbpf currently defines the return value of an ebpf program as a 32-bit unsigned integer, just use addi.w to extend bit 31 into bits 63 through 32 of a5 to a0. This is similar to commit 2f1b0d3d7331 ("riscv, bpf: Sign-extend return values").
--- arch/loongarch/net/bpf_jit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/net/bpf_jit.c +1 -1
@@ -179,7 +179,7 @@ static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)if (!is_tail_call) {/* Set return value */ -move_reg (ctx,LOONGARCH_GPR_A0 , regmap[BPF_REG_0 ]); +emit_insn (ctx, addiw,LOONGARCH_GPR_A0 , regmap[BPF_REG_0 ],0 );/* Return to the caller */ emit_insn (ctx, jirl,LOONGARCH_GPR_RA ,LOONGARCH_GPR_ZERO ,0 ); }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 562/817 power: supply: core: Remove might_sleep() from power_supply_put()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit f6da4553ff24a5d1c959c9627c965323adc3d307 ]
The put_device() call in power_supply_put() may call power_supply_dev_release(). The latter function does not sleep so power_supply_put() doesn't sleep either. Hence, remove the might_sleep() call from power_supply_put(). This patch suppresses false positive complaints about calling a sleeping function from atomic context if power_supply_put() is called from atomic context.
--- drivers/power/supply/power_supply_core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/power/supply/power_supply_core.c +0 -2
@@ -483,8 +483,6 @@ EXPORT_SYMBOL_GPL(power_supply_get_by_name);*/ void power_supply_put (struct power_supply *psy) { -might_sleep (); -atomic_dec (&psy->use_cnt);put_device (&psy->dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 563/817 power: supply: bq27xxx: Fix registers of bq27426
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Barnabás Czémán <[email protected]>
[ Upstream commit 34f99d3b706a519e556841f405c224ca708b1f54 ]
Correct bq27426 registers, according to technical reference manual it does not have Design Capacity register so it is not register compatible with bq27421.
--- drivers/power/supply/bq27xxx_battery.c | 37 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
drivers/power/supply/bq27xxx_battery.c +35 -2
@@ -449,9 +449,29 @@ static u8 [BQ27XXX_REG_AP ] =0x18 ,BQ27XXX_DM_REG_ROWS , }, + bq27426_regs[BQ27XXX_REG_MAX ] = { + [BQ27XXX_REG_CTRL ] =0x00 , + [BQ27XXX_REG_TEMP ] =0x02 , + [BQ27XXX_REG_INT_TEMP ] =0x1e , + [BQ27XXX_REG_VOLT ] =0x04 , + [BQ27XXX_REG_AI ] =0x10 , + [BQ27XXX_REG_FLAGS ] =0x06 , + [BQ27XXX_REG_TTE ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTF ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTES ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTECP ] =INVALID_REG_ADDR , + [BQ27XXX_REG_NAC ] =0x08 , + [BQ27XXX_REG_RC ] =0x0c , + [BQ27XXX_REG_FCC ] =0x0e , + [BQ27XXX_REG_CYCT ] =INVALID_REG_ADDR , + [BQ27XXX_REG_AE ] =INVALID_REG_ADDR , + [BQ27XXX_REG_SOC ] =0x1c , + [BQ27XXX_REG_DCAP ] =INVALID_REG_ADDR , + [BQ27XXX_REG_AP ] =0x18 , +BQ27XXX_DM_REG_ROWS , + }, #define bq27411_regs bq27421_regs #define bq27425_regs bq27421_regs -#define bq27426_regs bq27421_regs #define bq27441_regs bq27421_regs #define bq27621_regs bq27421_regs bq27z561_regs[BQ27XXX_REG_MAX ] = {
@@ -769,10 +789,23 @@ static enum power_supply_property bq27421_props[] = { };#define bq27411_props bq27421_props#define bq27425_props bq27421_props -#define bq27426_props bq27421_props#define bq27441_props bq27421_props#define bq27621_props bq27421_props +static enum power_supply_property bq27426_props[] = { +POWER_SUPPLY_PROP_STATUS , +POWER_SUPPLY_PROP_PRESENT , +POWER_SUPPLY_PROP_VOLTAGE_NOW , +POWER_SUPPLY_PROP_CURRENT_NOW , +POWER_SUPPLY_PROP_CAPACITY , +POWER_SUPPLY_PROP_CAPACITY_LEVEL , +POWER_SUPPLY_PROP_TEMP , +POWER_SUPPLY_PROP_TECHNOLOGY , +POWER_SUPPLY_PROP_CHARGE_FULL , +POWER_SUPPLY_PROP_CHARGE_NOW , +POWER_SUPPLY_PROP_MANUFACTURER , +}; +static enum power_supply_property bq27z561_props[] = {POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_PRESENT ,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 564/817 power: supply: rt9471: Fix wrong WDT function regfield declaration
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChiYuan Huang <[email protected]>
[ Upstream commit d10ff07dd2b933e3864c592ca932996b07bbf22a ]
Fix F_WDT and F_WDT_RST wrong regfield declaration.
--- drivers/power/supply/rt9471.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/rt9471.c +2 -2
@@ -153,8 +153,8 @@ struct rt9471_chip { };static const struct reg_field rt9471_reg_fields[F_MAX_FIELDS ] = { - [F_WDT ] =REG_FIELD (RT9471_REG_TOP ,0 ,0 ), - [F_WDT_RST ] =REG_FIELD (RT9471_REG_TOP ,1 ,1 ), + [F_WDT ] =REG_FIELD (RT9471_REG_TOP ,0 ,1 ), + [F_WDT_RST ] =REG_FIELD (RT9471_REG_TOP ,2 ,2 ), [F_CHG_EN ] =REG_FIELD (RT9471_REG_FUNC ,0 ,0 ), [F_HZ ] =REG_FIELD (RT9471_REG_FUNC ,5 ,5 ), [F_BATFET_DIS ] =REG_FIELD (RT9471_REG_FUNC ,7 ,7 ),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 565/817 power: supply: rt9471: Use IC status regfield to report real charger status
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChiYuan Huang <[email protected]>
[ Upstream commit c46a9ee5c6210682611d3d4276436c23a95e1996 ]
Use IC status regfield to rewrite the 'get_staus' function. The original one cannot cover some special scenario like as charger OTG or JEITA case.
--- drivers/power/supply/rt9471.c | 48 ++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-)
drivers/power/supply/rt9471.c +31 -17
@@ -139,6 +139,19 @@ enum { RT9471_PORTSTAT_DCP, }; +enum { +RT9471_ICSTAT_SLEEP =0 , +RT9471_ICSTAT_VBUSRDY , +RT9471_ICSTAT_TRICKLECHG , +RT9471_ICSTAT_PRECHG , +RT9471_ICSTAT_FASTCHG , +RT9471_ICSTAT_IEOC , +RT9471_ICSTAT_BGCHG , +RT9471_ICSTAT_CHGDONE , +RT9471_ICSTAT_CHGFAULT , +RT9471_ICSTAT_OTG =15 , +}; +struct rt9471_chip {struct device *dev;struct regmap *regmap;
@@ -255,31 +268,32 @@ static int rt9471_get_ieoc(struct rt9471_chip *chip, int *microamp)static int rt9471_get_status (struct rt9471_chip *chip,int *status) { -unsigned int chg_ready, chg_done, fault_stat; +unsigned int ic_stat;int ret; - ret =regmap_field_read (chip->rm_fields[F_ST_CHG_RDY ], &chg_ready); -if (ret) -return ret; - - ret =regmap_field_read (chip->rm_fields[F_ST_CHG_DONE ], &chg_done); + ret =regmap_field_read (chip->rm_fields[F_IC_STAT ], &ic_stat);if (ret)return ret; - ret =regmap_read (chip->regmap,RT9471_REG_STAT1 , &fault_stat); -if (ret) -return ret; - - fault_stat &=RT9471_CHGFAULT_MASK ; - -if (chg_ready && chg_done) - *status =POWER_SUPPLY_STATUS_FULL ; -else if (chg_ready && fault_stat) +switch (ic_stat) { +case RT9471_ICSTAT_VBUSRDY : +case RT9471_ICSTAT_CHGFAULT : *status =POWER_SUPPLY_STATUS_NOT_CHARGING ; -else if (chg_ready && !fault_stat) +break ; + case RT9471_ICSTAT_TRICKLECHG ... RT9471_ICSTAT_BGCHG: *status =POWER_SUPPLY_STATUS_CHARGING ; -else +break ; +case RT9471_ICSTAT_CHGDONE : + *status =POWER_SUPPLY_STATUS_FULL ; +break ; +case RT9471_ICSTAT_SLEEP : +case RT9471_ICSTAT_OTG : *status =POWER_SUPPLY_STATUS_DISCHARGING ; +break ; +default : + *status =POWER_SUPPLY_STATUS_UNKNOWN ; +break ; + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 566/817 net: usb: lan78xx: Fix double free issue with interrupt buffer allocation
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit 03819abbeb11117dcbba40bfe322b88c0c88a6b6 ]
In lan78xx_probe(), the buffer buf was being freed twice: once implicitly through usb_free_urb(dev->urb_intr) with the URB_FREE_BUFFER flag and again explicitly by kfree(buf). This caused a double free issue.
To resolve this, reordered kmalloc() and usb_alloc_urb() calls to simplify the initialization sequence and removed the redundant kfree(buf). Now, buf is allocated after usb_alloc_urb(), ensuring it is correctly managed by usb_fill_int_urb() and freed by usb_free_urb() as intended.
--- drivers/net/usb/lan78xx.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/net/usb/lan78xx.c +14 -15
@@ -4414,29 +4414,30 @@ static int lan78xx_probe(struct usb_interface *intf, period = ep_intr->desc.bInterval; maxp =usb_maxpacket (dev->udev, dev->pipe_intr); - buf =kmalloc (maxp,GFP_KERNEL ); -if (!buf) { + + dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!dev->urb_intr) { ret = -ENOMEM ; goto out5; } - dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!dev->urb_intr) { + buf =kmalloc (maxp,GFP_KERNEL ); +if (!buf) { ret = -ENOMEM ; - goto out6; - }else { -usb_fill_int_urb (dev->urb_intr, dev->udev, - dev->pipe_intr, buf, maxp, - intr_complete, dev, period); - dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + goto free_urbs; } +usb_fill_int_urb (dev->urb_intr, dev->udev, + dev->pipe_intr, buf, maxp, + intr_complete, dev, period); + dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) { ret = -ENODEV ; - goto out6; + goto free_urbs; }/* driver requires remote-wakeup capability during autosuspend. */
@@ -4444,7 +4445,7 @@ static int lan78xx_probe(struct usb_interface *intf, ret =lan78xx_phy_init (dev);if (ret <0 ) - goto out7; + goto free_urbs; ret =register_netdev (netdev);if (ret !=0 ) {
@@ -4466,10 +4467,8 @@ static int lan78xx_probe(struct usb_interface *intf, out8:phy_disconnect (netdev->phydev); -out7: +free_urbs:usb_free_urb (dev->urb_intr); -out6: -kfree (buf); out5:lan78xx_unbind (dev, intf); out4:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 567/817 net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit ae7370e61c5d8f5bcefc2d4fca724bd4e9bbf789 ]
Add calls to phy_device_free after fixed_phy_unregister to fix a memory leak that occurs when the device is unplugged. This ensures proper cleanup of pseudo fixed-link PHYs.
--- drivers/net/usb/lan78xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +4 -1
@@ -2380,6 +2380,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)if (dev->chipid ==ID_REV_CHIP_ID_7801_ ) {if (phy_is_pseudo_fixed_link (phydev)) {fixed_phy_unregister (phydev); +phy_device_free (phydev); }else {phy_unregister_fixup_for_uid (PHY_KSZ9031RNX ,0xfffffff0 );
@@ -4246,8 +4247,10 @@ static void lan78xx_disconnect(struct usb_interface *intf)phy_disconnect (net->phydev); -if (phy_is_pseudo_fixed_link (phydev)) +if (phy_is_pseudo_fixed_link (phydev)) {fixed_phy_unregister (phydev); +phy_device_free (phydev); + }usb_scuttle_anchored_urbs (&dev->deferred);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 568/817 tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Chebbi <[email protected]>
[ Upstream commit 614f4d166eeeb9bd709b0ad29552f691c0f45776 ]
The hardware on Broadcom 1G chipsets have a known limitation where they cannot handle DMA addresses that cross over 4GB. When such an address is encountered, the hardware sets the address overflow error bit in the DMA status register and triggers a reset.
However, BCM57766 hardware is setting the overflow bit and triggering a reset in some cases when there is no actual underlying address overflow. The hardware team analyzed the issue and concluded that it is happening when the status block update has an address with higher (b16 to b31) bits as 0xffff following a previous update that had lowest bits as 0xffff.
To work around this bug in the BCM57766 hardware, set the coherent dma mask from the current 64b to 31b. This will ensure that upper bits of the status block DMA address are always at most 0x7fff, thus avoiding the improper overflow check described above. This work around is intended for only status block and ring memories and has no effect on TX and RX buffers as they do not require coherent memory.
--- drivers/net/ethernet/broadcom/tg3.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +3 -0
@@ -17805,6 +17805,9 @@ static int tg3_init_one(struct pci_dev *pdev, }else persist_dma_mask = dma_mask =DMA_BIT_MASK (64 ); +if (tg3_asic_rev (tp) ==ASIC_REV_57766 ) + persist_dma_mask =DMA_BIT_MASK (31 ); +/* Configure DMA attributes. */ if (dma_mask >DMA_BIT_MASK (32 )) { err =dma_set_mask (&pdev->dev, dma_mask);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 569/817 net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit e863ff806f72098bccaf8fa89c80d9ad6187c3b0 ]
Validate Wake-on-LAN (WoL) options in lan78xx_set_wol before calling usb_autopm_get_interface. This prevents USB autopm refcounting issues and ensures the adapter can properly enter autosuspend when invalid WoL options are provided.
--- drivers/net/usb/lan78xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/lan78xx.c +3 -3
@@ -1652,13 +1652,13 @@ static int lan78xx_set_wol(struct net_device *netdev,struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0 ]);int ret; +if (wol->wolopts & ~WAKE_ALL ) +return -EINVAL ; + ret =usb_autopm_get_interface (dev->intf);if (ret <0 )return ret; -if (wol->wolopts & ~WAKE_ALL ) -return -EINVAL ; - pdata->wol = wol->wolopts;device_set_wakeup_enable (&dev->udev->dev, (bool )wol->wolopts);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 570/817 net: microchip: vcap: Add typegroup table terminators in kunit tests
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit f164b296638d1eb1fb1c537e93ab5c8b49966546 ]
VCAP API unit tests fail randomly with errors such as
# vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:387 Expected 134 + 7 == iter.offset, but
134 + 7 == 141 (0x8d)
iter.offset == 17214 (0x433e)
# vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:388
Expected 5 == iter.reg_idx, but
iter.reg_idx == 702 (0x2be)
# vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:389
Expected 11 == iter.reg_bitpos, but
iter.reg_bitpos == 15 (0xf) # vcap_api_iterator_init_test: pass:0 fail:1 skip:0 total:1
Comments in the code state that "A typegroup table ends with an all-zero terminator". Add the missing terminators.
Some of the typegroups did have a terminator of ".offset = 0, .width = 0, .value = 0,". Replace those terminators with "{ }" (no trailing ',') for consistency and to excplicitly state "this is a terminator".
--- .../ethernet/microchip/vcap/vcap_api_kunit.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +10 -7
@@ -366,12 +366,13 @@ static void vcap_api_iterator_init_test(struct kunit *test)struct vcap_typegroup typegroups[] = { { .offset =0 , .width =2 , .value =2 , }, { .offset =156 , .width =1 , .value =0 , }, - { .offset =0 , .width =0 , .value =0 , }, + { } };struct vcap_typegroup typegroups2[] = { { .offset =0 , .width =3 , .value =4 , }, { .offset =49 , .width =2 , .value =0 , }, { .offset =98 , .width =2 , .value =0 , }, + { } };vcap_iter_init (&iter,52 , typegroups,86 );
@@ -399,6 +400,7 @@ static void vcap_api_iterator_next_test(struct kunit *test) { .offset = 147, .width = 3, .value = 0, }, { .offset = 196, .width = 2, .value = 0, }, { .offset = 245, .width = 1, .value = 0, }, + { } }; int idx;
@@ -433,7 +435,7 @@ static void vcap_api_encode_typegroups_test(struct kunit *test) { .offset = 147, .width = 3, .value = 5, }, { .offset = 196, .width = 2, .value = 2, }, { .offset = 245, .width = 5, .value = 27, }, - { .offset = 0, .width = 0, .value = 0, }, + { } }; vcap_encode_typegroups(stream, 49, typegroups, false);
@@ -463,6 +465,7 @@ static void vcap_api_encode_bit_test(struct kunit *test) { .offset = 147, .width = 3, .value = 5, }, { .offset = 196, .width = 2, .value = 2, }, { .offset = 245, .width = 1, .value = 0, }, + { } }; vcap_iter_init(&iter, 49, typegroups, 44);
@@ -489,7 +492,7 @@ static void vcap_api_encode_field_test(struct kunit *test) { .offset = 147, .width = 3, .value = 5, }, { .offset = 196, .width = 2, .value = 2, }, { .offset = 245, .width = 5, .value = 27, }, - { .offset = 0, .width = 0, .value = 0, }, + { } }; struct vcap_field rf = { .type = VCAP_FIELD_U32,
@@ -538,7 +541,7 @@ static void vcap_api_encode_short_field_test(struct kunit *test) { .offset = 0, .width = 3, .value = 7, }, { .offset = 21, .width = 2, .value = 3, }, { .offset = 42, .width = 1, .value = 1, }, - { .offset = 0, .width = 0, .value = 0, }, + { } }; struct vcap_field rf = { .type = VCAP_FIELD_U32,
@@ -608,7 +611,7 @@ static void vcap_api_encode_keyfield_test(struct kunit *test)struct vcap_typegroup tgt[] = { { .offset =0 , .width =2 , .value =2 , }, { .offset =156 , .width =1 , .value =1 , }, - { .offset =0 , .width =0 , .value =0 , }, + { } };vcap_test_api_init (&admin);
@@ -671,7 +674,7 @@ static void vcap_api_encode_max_keyfield_test(struct kunit *test)struct vcap_typegroup tgt[] = { { .offset =0 , .width =2 , .value =2 , }, { .offset =156 , .width =1 , .value =1 , }, - { .offset =0 , .width =0 , .value =0 , }, + { } };u32 keyres[] = {0x928e8a84 ,
@@ -732,7 +735,7 @@ static void vcap_api_encode_actionfield_test(struct kunit *test) { .offset = 0, .width = 2, .value = 2, }, { .offset = 21, .width = 1, .value = 1, }, { .offset = 42, .width = 1, .value = 0, }, - { .offset = 0, .width = 0, .value = 0, }, + { } }; vcap_encode_actionfield(&rule, &caf, &rf, tgt);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 571/817 netlink: fix false positive warning in extack during dumps
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 3bf39fa849ab8ed52abb6715922e6102d3df9f97 ]
Commit under fixes extended extack reporting to dumps. It works under normal conditions, because extack errors are usually reported during ->start() or the first ->dump(), it's quite rare that the dump starts okay but fails later. If the dump does fail later, however, the input skb will already have the initiating message pulled, so checking if bad attr falls within skb->data will fail.
Switch the check to using nlh, which is always valid.
syzbot found a way to hit that scenario by filling up the receive queue. In this case we initiate a dump but don't call ->dump() until there is read space for an skb.
WARNING: CPU: 1 PID: 5845 at net/netlink/af_netlink.c:2210 netlink_ack_tlv_fill+0x1a8/0x560 net/netlink/af_netlink.c:2209 RIP: 0010:netlink_ack_tlv_fill+0x1a8/0x560 net/netlink/af_netlink.c:2209 Call Trace: <TASK> netlink_dump_done+0x513/0x970 net/netlink/af_netlink.c:2250 netlink_dump+0x91f/0xe10 net/netlink/af_netlink.c:2351 netlink_recvmsg+0x6bb/0x11d0 net/netlink/af_netlink.c:1983 sock_recvmsg_nosec net/socket.c:1051 [inline] sock_recvmsg+0x22f/0x280 net/socket.c:1073 __sys_recvfrom+0x246/0x3d0 net/socket.c:2267 __do_sys_recvfrom net/socket.c:2285 [inline] __se_sys_recvfrom net/socket.c:2281 [inline] __x64_sys_recvfrom+0xde/0x100 net/socket.c:2281 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7ff37dd17a79
--- net/netlink/af_netlink.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
net/netlink/af_netlink.c +11 -10
@@ -2176,9 +2176,14 @@ netlink_ack_tlv_len(struct netlink_sock *nlk, int err,return tlvlen; } +static bool nlmsg_check_in_payload (const struct nlmsghdr *nlh,const void *addr) +{ +return !WARN_ON (addr <nlmsg_data (nlh) || + addr - (const void *) nlh >= nlh->nlmsg_len); +} +static void -netlink_ack_tlv_fill (struct sk_buff *in_skb,struct sk_buff *skb, -const struct nlmsghdr *nlh,int err, +netlink_ack_tlv_fill (struct sk_buff *skb,const struct nlmsghdr *nlh,int err,const struct netlink_ext_ack *extack) {if (extack->_msg)
@@ -2190,9 +2195,7 @@ netlink_ack_tlv_fill(struct sk_buff *in_skb, struct sk_buff *skb,if (!err)return ; -if (extack->bad_attr && - !WARN_ON ((u8 *)extack->bad_attr < in_skb->data || - (u8 *)extack->bad_attr >= in_skb->data + in_skb->len)) +if (extack->bad_attr &&nlmsg_check_in_payload (nlh, extack->bad_attr))WARN_ON (nla_put_u32 (skb,NLMSGERR_ATTR_OFFS , (u8 *)extack->bad_attr - (const u8 *)nlh));if (extack->policy)
@@ -2201,9 +2204,7 @@ netlink_ack_tlv_fill(struct sk_buff *in_skb, struct sk_buff *skb,if (extack->miss_type)WARN_ON (nla_put_u32 (skb,NLMSGERR_ATTR_MISS_TYPE , extack->miss_type)); -if (extack->miss_nest && - !WARN_ON ((u8 *)extack->miss_nest < in_skb->data || - (u8 *)extack->miss_nest > in_skb->data + in_skb->len)) +if (extack->miss_nest &&nlmsg_check_in_payload (nlh, extack->miss_nest))WARN_ON (nla_put_u32 (skb,NLMSGERR_ATTR_MISS_NEST , (u8 *)extack->miss_nest - (const u8 *)nlh)); }
@@ -2232,7 +2233,7 @@ static int netlink_dump_done(struct netlink_sock *nlk, struct sk_buff *skb,if (extack_len) { nlh->nlmsg_flags |=NLM_F_ACK_TLVS ;if (skb_tailroom (skb) >= extack_len) { -netlink_ack_tlv_fill (cb->skb, skb, cb->nlh, +netlink_ack_tlv_fill (skb, cb->nlh, nlk->dump_done_errno, extack);nlmsg_end (skb, nlh); }
@@ -2491,7 +2492,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, }if (tlvlen) -netlink_ack_tlv_fill (in_skb, skb, nlh, err, extack); +netlink_ack_tlv_fill (skb, nlh, err, extack);nlmsg_end (skb, rep);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 572/817 exfat: fix file being changed by unaligned direct write
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
[ Upstream commit 2e94e5bb94a3e641a25716a560bf474225fda83c ]
Unaligned direct writes are invalid and should return an error without making any changes, rather than extending ->valid_size and then returning an error. Therefore, alignment checking is required before extending ->valid_size.
--- fs/exfat/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/exfat/file.c +10 -0
@@ -578,6 +578,16 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)if (ret <0 ) goto unlock; +if (iocb->ki_flags &IOCB_DIRECT ) { +unsigned long align = pos |iov_iter_alignment (iter); + +if (!IS_ALIGNED (align,i_blocksize (inode)) && + !IS_ALIGNED (align,bdev_logical_block_size (inode->i_sb->s_bdev))) { + ret = -EINVAL ; + goto unlock; + } + } +if (pos > valid_size) { ret =exfat_file_zeroed_range (file, valid_size, pos);if (ret <0 && ret != -ENOSPC ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 573/817 s390/iucv: MSG_PEEK causes memory leak in iucv_sock_destruct()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sidraya Jayagond <[email protected]>
[ Upstream commit ebaf81317e42aa990ad20b113cfe3a7b20d4e937 ]
Passing MSG_PEEK flag to skb_recv_datagram() increments skb refcount (skb->users) and iucv_sock_recvmsg() does not decrement skb refcount at exit.
This results in skb memory leak in skb_queue_purge() and WARN_ON in iucv_sock_destruct() during socket close. To fix this decrease skb refcount by one if MSG_PEEK is set in order to prevent memory leak and WARN_ON.
WARNING: CPU: 2 PID: 6292 at net/iucv/af_iucv.c:286 iucv_sock_destruct+0x144/0x1a0 [af_iucv]
CPU: 2 PID: 6292 Comm: afiucv_test_msg Kdump: loaded Tainted: G W 6.10.0-rc7 #1
Hardware name: IBM 3931 A01 704 (z/VM 7.3.0)
Call Trace:
[<001587c682c4aa98>] iucv_sock_destruct+0x148/0x1a0 [af_iucv]
[<001587c682c4a9d0>] iucv_sock_destruct+0x80/0x1a0 [af_iucv]
[<001587c704117a32>] __sk_destruct+0x52/0x550
[<001587c704104a54>] __sock_release+0xa4/0x230
[<001587c704104c0c>] sock_close+0x2c/0x40
[<001587c702c5f5a8>] __fput+0x2e8/0x970
[<001587c7024148c4>] task_work_run+0x1c4/0x2c0
[<001587c7023b0716>] do_exit+0x996/0x1050
[<001587c7023b13aa>] do_group_exit+0x13a/0x360
[<001587c7023b1626>] __s390x_sys_exit_group+0x56/0x60
[<001587c7022bccca>] do_syscall+0x27a/0x380
[<001587c7049a6a0c>] __do_syscall+0x9c/0x160
[<001587c7049ce8a8>] system_call+0x70/0x98
Last Breaking-Event-Address:
[<001587c682c4a9d4>] iucv_sock_destruct+0x84/0x1a0 [af_iucv]--- net/iucv/af_iucv.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
net/iucv/af_iucv.c +17 -9
@@ -1236,7 +1236,9 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,return -EOPNOTSUPP ;/* receive/dequeue next skb: -* the function understands MSG_PEEK and, thus, does not dequeue skb */ +* the function understands MSG_PEEK and, thus, does not dequeue skb +* only refcount is increased. +*/ skb =skb_recv_datagram (sk, flags, &err);if (!skb) {if (sk->sk_shutdown &RCV_SHUTDOWN )
@@ -1252,9 +1254,8 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg, cskb = skb;if (skb_copy_datagram_msg (cskb, offset, msg, copied)) { -if (!(flags &MSG_PEEK )) -skb_queue_head (&sk->sk_receive_queue, skb); -return -EFAULT ; + err = -EFAULT ; + goto err_out; }/* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */
@@ -1271,11 +1272,8 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg, err =put_cmsg (msg,SOL_IUCV ,SCM_IUCV_TRGCLS ,sizeof (IUCV_SKB_CB (skb)->class), (void *)&IUCV_SKB_CB (skb)->class); -if (err) { -if (!(flags &MSG_PEEK )) -skb_queue_head (&sk->sk_receive_queue, skb); -return err; - } +if (err) + goto err_out;/* Mark read part of skb as used */ if (!(flags &MSG_PEEK )) {
@@ -1331,8 +1329,18 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,/* SOCK_SEQPACKET: return real length if MSG_TRUNC is set */ if (sk->sk_type ==SOCK_SEQPACKET && (flags &MSG_TRUNC )) copied = rlen; +if (flags &MSG_PEEK ) +skb_unref (skb);return copied; + +err_out: +if (!(flags &MSG_PEEK )) +skb_queue_head (&sk->sk_receive_queue, skb); +else +skb_unref (skb); + +return err; }static inline __poll_t iucv_accept_poll (struct sock *parent)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 574/817 net/ipv6: delete temporary address if mngtmpaddr is removed or unmanaged
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 00b5b7aab9e422d00d5a9d03d7e0760a76b5d57f ]
RFC8981 section 3.4 says that existing temporary addresses must have their lifetimes adjusted so that no temporary addresses should ever remain "valid" or "preferred" longer than the incoming SLAAC Prefix Information. This would strongly imply in Linux's case that if the "mngtmpaddr" address is deleted or un-flagged as such, its corresponding temporary addresses must be cleared out right away.
But now the temporary address is renewed even after ‘mngtmpaddr’ is removed or becomes unmanaged as manage_tempaddrs() set temporary addresses prefered/valid time to 0, and later in addrconf_verify_rtnl() all checkings failed to remove the addresses. Fix this by deleting the temporary address directly for these situations.
--- net/ipv6/addrconf.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
net/ipv6/addrconf.c +29 -12
@@ -2570,6 +2570,24 @@ static struct inet6_dev *addrconf_add_dev(struct net_device *dev)return idev; } +static void delete_tempaddrs (struct inet6_dev *idev, +struct inet6_ifaddr *ifp) +{ +struct inet6_ifaddr *ift, *tmp; + +write_lock_bh (&idev->lock); +list_for_each_entry_safe (ift, tmp, &idev->tempaddr_list, tmp_list) { +if (ift->ifpub != ifp) +continue ; + +in6_ifa_hold (ift); +write_unlock_bh (&idev->lock); +ipv6_del_addr (ift); +write_lock_bh (&idev->lock); + } +write_unlock_bh (&idev->lock); +} + static void manage_tempaddrs(struct inet6_dev *idev, struct inet6_ifaddr *ifp, __u32 valid_lft, __u32 prefered_lft,
@@ -3122,11 +3140,12 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,in6_ifa_hold (ifp);read_unlock_bh (&idev->lock); -if (!(ifp->flags &IFA_F_TEMPORARY ) && - (ifa_flags &IFA_F_MANAGETEMPADDR )) -manage_tempaddrs (idev, ifp,0 ,0 , false, - jiffies);ipv6_del_addr (ifp); + +if (!(ifp->flags &IFA_F_TEMPORARY ) && + (ifp->flags &IFA_F_MANAGETEMPADDR )) +delete_tempaddrs (idev, ifp); +addrconf_verify_rtnl (net);if (ipv6_addr_is_multicast (pfx)) { ipv6_mc_config(net->ipv6.mc_autojoin_sk,
@@ -4950,14 +4969,12 @@ static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp, }if (was_managetempaddr || ifp->flags &IFA_F_MANAGETEMPADDR ) { -if (was_managetempaddr && - !(ifp->flags &IFA_F_MANAGETEMPADDR )) { - cfg->valid_lft =0 ; - cfg->preferred_lft =0 ; - } -manage_tempaddrs (ifp->idev, ifp, cfg->valid_lft, - cfg->preferred_lft, !was_managetempaddr, - jiffies); +if (was_managetempaddr && !(ifp->flags &IFA_F_MANAGETEMPADDR )) +delete_tempaddrs (ifp->idev, ifp); +else +manage_tempaddrs (ifp->idev, ifp, cfg->valid_lft, + cfg->preferred_lft, !was_managetempaddr, + jiffies); }addrconf_verify_rtnl (net);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 575/817 net: mdio-ipq4019: add missing error check
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 9cc8d0ecdd2aad42e377e971e3bb114339df609e ]
If an optional resource is found but fails to remap, return on failure. Avoids any potential problems when using the iomapped resource as the assumption is that it's available.
--- drivers/net/mdio/mdio-ipq4019.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/mdio/mdio-ipq4019.c +4 -1
@@ -352,8 +352,11 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)/* The platform resource is provided on the chipset IPQ5018 */ /* This resource is optional */ res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (res) +if (res) { priv->eth_ldo_rdy =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (priv->eth_ldo_rdy)) +return PTR_ERR (priv->eth_ldo_rdy); + } bus->name ="ipq4019_mdio" ; bus->read = ipq4019_mdio_read_c22;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 576/817 marvell: pxa168_eth: fix call balance of pep->clk handling routines
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitalii Mordan <[email protected]>
[ Upstream commit b032ae57d4fe2b2445e3bc190db6fcaa8c102f68 ]
If the clock pep->clk was not enabled in pxa168_eth_probe, it should not be disabled in any path.
Conversely, if it was enabled in pxa168_eth_probe, it must be disabled in all error paths to ensure proper cleanup.
Use the devm_clk_get_enabled helper function to ensure proper call balance for pep->clk.
Found by Linux Verification Center (linuxtesting.org) with Klever.
--- drivers/net/ethernet/marvell/pxa168_eth.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/marvell/pxa168_eth.c +4 -10
@@ -1394,18 +1394,15 @@ static int pxa168_eth_probe(struct platform_device *pdev)printk (KERN_NOTICE "PXA168 10/100 Ethernet Driver\n" ); - clk =devm_clk_get (&pdev->dev,NULL ); + clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (clk)) { -dev_err (&pdev->dev,"Fast Ethernet failed to get clock\n" ); +dev_err (&pdev->dev,"Fast Ethernet failed to get and enable clock\n" );return -ENODEV ; } -clk_prepare_enable (clk); dev =alloc_etherdev (sizeof (struct pxa168_eth_private )); -if (!dev) { - err = -ENOMEM ; - goto err_clk; - } +if (!dev) +return -ENOMEM ;platform_set_drvdata (pdev, dev); pep =netdev_priv (dev);
@@ -1523,8 +1520,6 @@ static int pxa168_eth_probe(struct platform_device *pdev)mdiobus_free (pep->smi_bus); err_netdev:free_netdev (dev); -err_clk: -clk_disable_unprepare (clk);return err; }
@@ -1542,7 +1537,6 @@ static void pxa168_eth_remove(struct platform_device *pdev)if (dev->phydev)phy_disconnect (dev->phydev); -clk_disable_unprepare (pep->clk);mdiobus_unregister (pep->smi_bus);mdiobus_free (pep->smi_bus);unregister_netdev (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 577/817 net: stmmac: dwmac-socfpga: Set RX watchdog interrupt as broken
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 407618d66dba55e7db1278872e8be106808bbe91 ]
On DWMAC3 and later, there's a RX Watchdog interrupt that's used for interrupt coalescing. It's known to be buggy on some platforms, and dwmac-socfpga appears to be one of them. Changing the interrupt coalescing from ethtool doesn't appear to have any effect here.
Without disabling RIWT (Received Interrupt Watchdog Timer, I believe...), we observe latencies while receiving traffic that amount to around ~0.4ms. This was discovered with NTP but can be easily reproduced with a simple ping. Without this patch :
64 bytes from 192.168.5.2: icmp_seq=1 ttl=64 time=0.657 ms
With this patch :
64 bytes from 192.168.5.2: icmp_seq=1 ttl=64 time=0.254 ms
--- drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +2 -0
@@ -486,6 +486,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) plat_dat->pcs_exit = socfpga_dwmac_pcs_exit; plat_dat->select_pcs = socfpga_dwmac_select_pcs; + plat_dat->riwt_off =1 ; + ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret)return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 578/817 octeontx2-af: RPM: Fix mismatch in lmac type
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 7ebbbb23ea5b6d051509cb11399afac5042c9266 ]
Due to a bug in the previous patch, there is a mismatch between the lmac type reported by the driver and the actual hardware configuration.
--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +1 -1
@@ -467,7 +467,7 @@ u8 rpm_get_lmac_type(void *rpmd, int lmac_id)int err; req =FIELD_SET (CMDREG_ID ,CGX_CMD_GET_LINK_STS , req); - err =cgx_fwi_cmd_generic (req, &resp, rpm,0 ); + err =cgx_fwi_cmd_generic (req, &resp, rpm, lmac_id);if (!err)return FIELD_GET (RESP_LINKSTAT_LMAC_TYPE , resp);return err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 579/817 octeontx2-af: RPM: Fix low network performance
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit d1e8884e050c1255a9ceb477f5ff926ee9214a23 ]
Low network performance is observed even on RPMs with larger FIFO lengths.
The cn10kb silicon has three RPM blocks with the following FIFO sizes:
--------------------
| RPM0 | 256KB |
| RPM1 | 256KB |
| RPM2 | 128KB |
--------------------The current design stores the FIFO length in a common structure for all RPMs (mac_ops). As a result, the FIFO length of the last RPM is applied to all RPMs, leading to reduced network performance.
This patch resolved the problem by storing the fifo length in per MAC structure (cgx).
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 9 +++++++-- drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h | 5 ++++- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 6 +++--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 9 ++++----- 5 files changed, 19 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +7 -2
@@ -112,6 +112,11 @@ struct mac_ops *get_mac_ops(void *cgxd)return ((struct cgx *)cgxd)->mac_ops; } +u32 cgx_get_fifo_len (void *cgxd) +{ +return ((struct cgx *)cgxd)->fifo_len; +} +void cgx_write (struct cgx *cgx,u64 lmac,u64 offset,u64 val) { writeq(val, cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) +
@@ -501,7 +506,7 @@ static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)u8 num_lmacs;u32 fifo_len; - fifo_len = cgx->mac_ops->fifo_len; + fifo_len = cgx->fifo_len; num_lmacs = cgx->mac_ops->get_nr_lmacs (cgx);switch (num_lmacs) {
@@ -1764,7 +1769,7 @@ static void cgx_populate_features(struct cgx *cgx)u64 cfg; cfg =cgx_read (cgx,0 ,CGX_CONST ); - cgx->mac_ops->fifo_len =FIELD_GET (CGX_CONST_RXFIFO_SIZE , cfg); + cgx->fifo_len =FIELD_GET (CGX_CONST_RXFIFO_SIZE , cfg); cgx->max_lmac_per_mac =FIELD_GET (CGX_CONST_MAX_LMACS , cfg);if (is_dev_rpm (cgx))
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +1 -0
@@ -185,4 +185,5 @@ int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause,int verify_lmac_fc_cfg (void *cgxd,int lmac_id,u8 tx_pause,u8 rx_pause,int pfvf_idx);int cgx_lmac_reset (void *cgxd,int lmac_id,u8 pf_req_flr); +u32 cgx_get_fifo_len (void *cgxd);#endif /* CGX_H */
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +4 -1
@@ -72,7 +72,6 @@ struct mac_ops {u8 irq_offset;u8 int_ena_bit;u8 lmac_fwi; -u32 fifo_len;bool non_contiguous_serdes_lane;/* RPM & CGX differs in number of Receive/transmit stats */ u8 rx_stats_cnt;
@@ -142,6 +141,10 @@ struct cgx {u8 lmac_count;/* number of LMACs per MAC could be 4 or 8 */ u8 max_lmac_per_mac; +/* length of fifo varies depending on the number +* of LMACS +*/ +u32 fifo_len;#define MAX_LMAC_COUNT 8struct lmac *lmac_idmap[MAX_LMAC_COUNT ];struct work_struct cgx_cmd_work;
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +3 -3
@@ -480,7 +480,7 @@ u32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id)u8 num_lmacs;u32 fifo_len; - fifo_len = rpm->mac_ops->fifo_len; + fifo_len = rpm->fifo_len; num_lmacs = rpm->mac_ops->get_nr_lmacs (rpm);switch (num_lmacs) {
@@ -533,9 +533,9 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)*/ max_lmac = (rpm_read (rpm,0 ,CGX_CONST ) >>24 ) &0xFF ;if (max_lmac >4 ) - fifo_len = rpm->mac_ops->fifo_len /2 ; + fifo_len = rpm->fifo_len /2 ;else - fifo_len = rpm->mac_ops->fifo_len; + fifo_len = rpm->fifo_len;if (lmac_id <4 ) { num_lmacs =hweight8 (lmac_info &0xF );
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +4 -5
@@ -923,13 +923,12 @@ int rvu_mbox_handler_cgx_features_get(struct rvu *rvu,u32 rvu_cgx_get_fifolen (struct rvu *rvu) { -struct mac_ops *mac_ops; -u32 fifo_len; +void *cgxd =rvu_first_cgx_pdata (rvu); - mac_ops =get_mac_ops (rvu_first_cgx_pdata (rvu)); - fifo_len = mac_ops ? mac_ops->fifo_len :0 ; +if (!cgxd) +return 0 ; -return fifo_len; +return cgx_get_fifo_len (cgxd); }u32 rvu_cgx_get_lmac_fifolen (struct rvu *rvu,int cgx,int lmac)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 580/817 octeontx2-af: RPM: fix stale RSFEC counters
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 07cd1eb166a3fa7244afa74d48bd13c9df7c559d ]
The earlier patch sets the 'Stats control register' for RPM receive/transmit statistics instead of RSFEC statistics, causing the driver to return stale FEC counters.
--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 13 +++++++++---- drivers/net/ethernet/marvell/octeontx2/af/rpm.h | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +9 -4
@@ -699,6 +699,10 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)if (rpm->lmac_idmap[lmac_id]->link_info.fec ==OTX2_FEC_NONE )return 0 ; +/* latched registers FCFECX_CW_HI/RSFEC_STAT_FAST_DATA_HI_CDC are common +* for all counters. Acquire lock to ensure serialized reads +*/ +mutex_lock (&rpm->lock);if (rpm->lmac_idmap[lmac_id]->link_info.fec ==OTX2_FEC_BASER ) { val_lo =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_VL0_CCW_LO ); val_hi =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_CW_HI );
@@ -725,20 +729,21 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp) } }else {/* enable RS-FEC capture */ - cfg =rpm_read (rpm,0 ,RPMX_MTI_STAT_STATN_CONTROL ); + cfg =rpm_read (rpm,0 ,RPMX_MTI_RSFEC_STAT_STATN_CONTROL ); cfg |=RPMX_RSFEC_RX_CAPTURE |BIT (lmac_id); -rpm_write (rpm,0 ,RPMX_MTI_STAT_STATN_CONTROL , cfg); +rpm_write (rpm,0 ,RPMX_MTI_RSFEC_STAT_STATN_CONTROL , cfg); val_lo =rpm_read (rpm,0 ,RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2 ); - val_hi =rpm_read (rpm,0 ,RPMX_MTI_STAT_DATA_HI_CDC ); + val_hi =rpm_read (rpm,0 ,RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC ); rsp->fec_corr_blks = (val_hi <<32 | val_lo); val_lo =rpm_read (rpm,0 ,RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3 ); - val_hi =rpm_read (rpm,0 ,RPMX_MTI_STAT_DATA_HI_CDC ); + val_hi =rpm_read (rpm,0 ,RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC ); rsp->fec_uncorr_blks = (val_hi <<32 | val_lo); } +mutex_unlock (&rpm->lock);return 0 ; }
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +3 -1
@@ -84,9 +84,11 @@/* FEC stats */ #define RPMX_MTI_STAT_STATN_CONTROL 0x10018#define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 -#define RPMX_RSFEC_RX_CAPTURE BIT_ULL(27) +#define RPMX_RSFEC_RX_CAPTURE BIT_ULL(28)#define RPMX_CMD_CLEAR_RX BIT_ULL(30)#define RPMX_CMD_CLEAR_TX BIT_ULL(31) +#define RPMX_MTI_RSFEC_STAT_STATN_CONTROL 0x40018 +#define RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC 0x40000#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2 0x40050#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3 0x40058#define RPMX_MTI_FCFECX_VL0_CCW_LO 0x38618
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 581/817 octeontx2-af: RPM: fix stale FCFEC counters
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 6fc2164108462b913a1290fa2c44054c70b060ef ]
The corrected words register(FCFECX_VL0_CCW_LO)/Uncorrected words register (FCFECX_VL0_NCCW_LO) of FCFEC counter has different LMAC offset which needs to be accessed differently.
--- .../net/ethernet/marvell/octeontx2/af/rpm.c | 24 +++++++++---------- .../net/ethernet/marvell/octeontx2/af/rpm.h | 10 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +12 -12
@@ -704,27 +704,27 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)*/ mutex_lock (&rpm->lock);if (rpm->lmac_idmap[lmac_id]->link_info.fec ==OTX2_FEC_BASER ) { - val_lo =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_VL0_CCW_LO ); - val_hi =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_CW_HI ); + val_lo =rpm_read (rpm,0 ,RPMX_MTI_FCFECX_VL0_CCW_LO (lmac_id)); + val_hi =rpm_read (rpm,0 ,RPMX_MTI_FCFECX_CW_HI (lmac_id)); rsp->fec_corr_blks = (val_hi <<16 | val_lo); - val_lo =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_VL0_NCCW_LO ); - val_hi =rpm_read (rpm, lmac_id,RPMX_MTI_FCFECX_CW_HI ); + val_lo =rpm_read (rpm,0 ,RPMX_MTI_FCFECX_VL0_NCCW_LO (lmac_id)); + val_hi =rpm_read (rpm,0 ,RPMX_MTI_FCFECX_CW_HI (lmac_id)); rsp->fec_uncorr_blks = (val_hi <<16 | val_lo);/* 50G uses 2 Physical serdes lines */ if (rpm->lmac_idmap[lmac_id]->link_info.lmac_type_id ==LMAC_MODE_50G_R ) { - val_lo =rpm_read (rpm, lmac_id, -RPMX_MTI_FCFECX_VL1_CCW_LO ); - val_hi =rpm_read (rpm, lmac_id, -RPMX_MTI_FCFECX_CW_HI ); + val_lo =rpm_read (rpm,0 , +RPMX_MTI_FCFECX_VL1_CCW_LO (lmac_id)); + val_hi =rpm_read (rpm,0 , +RPMX_MTI_FCFECX_CW_HI (lmac_id)); rsp->fec_corr_blks += (val_hi <<16 | val_lo); - val_lo =rpm_read (rpm, lmac_id, -RPMX_MTI_FCFECX_VL1_NCCW_LO ); - val_hi =rpm_read (rpm, lmac_id, -RPMX_MTI_FCFECX_CW_HI ); + val_lo =rpm_read (rpm,0 , +RPMX_MTI_FCFECX_VL1_NCCW_LO (lmac_id)); + val_hi =rpm_read (rpm,0 , +RPMX_MTI_FCFECX_CW_HI (lmac_id)); rsp->fec_uncorr_blks += (val_hi <<16 | val_lo); } }else {
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +5 -5
@@ -91,11 +91,11 @@#define RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC 0x40000#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2 0x40050#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3 0x40058 -#define RPMX_MTI_FCFECX_VL0_CCW_LO 0x38618 -#define RPMX_MTI_FCFECX_VL0_NCCW_LO 0x38620 -#define RPMX_MTI_FCFECX_VL1_CCW_LO 0x38628 -#define RPMX_MTI_FCFECX_VL1_NCCW_LO 0x38630 -#define RPMX_MTI_FCFECX_CW_HI 0x38638 +#define RPMX_MTI_FCFECX_VL0_CCW_LO (a) (0x38618 + ((a) * 0x40)) +#define RPMX_MTI_FCFECX_VL0_NCCW_LO (a) (0x38620 + ((a) * 0x40)) +#define RPMX_MTI_FCFECX_VL1_CCW_LO (a) (0x38628 + ((a) * 0x40)) +#define RPMX_MTI_FCFECX_VL1_NCCW_LO (a) (0x38630 + ((a) * 0x40)) +#define RPMX_MTI_FCFECX_CW_HI (a) (0x38638 + ((a) * 0x40))/* CN10KB CSR Declaration */ #define RPM2_CMRX_SW_INT 0x1b0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 582/817 octeontx2-af: Quiesce traffic before NIX block reset
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 762ca6eed026346d9d41ed5ac633083c4f1e5071 ]
During initialization, the AF driver resets all blocks. The RPM (MAC) block and NIX block operate on a credit-based model. When the NIX block resets during active traffic flow, it doesn't release credits to the RPM block. This causes the RPM FIFO to overflow, leading to receive traffic struck.
To address this issue, the patch introduces the following changes:
1. Stop receiving traffic at the MAC level during AF driver initialization.
2. Perform an X2P reset (prevents RXFIFO of all LMACS from pushing data)
3. Reset the NIX block.
4. Clear the X2P reset and re-enable receiving traffic.
--- .../net/ethernet/marvell/octeontx2/af/cgx.c | 61 +++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/cgx.h | 4 ++ .../marvell/octeontx2/af/lmac_common.h | 2 + .../net/ethernet/marvell/octeontx2/af/rpm.c | 42 +++++++++++++ .../net/ethernet/marvell/octeontx2/af/rpm.h | 4 ++ .../net/ethernet/marvell/octeontx2/af/rvu.c | 1 + .../net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 36 +++++++++-- 8 files changed, 145 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +61 -0
@@ -214,6 +214,24 @@ u8 cgx_lmac_get_p2x(int cgx_id, int lmac_id)return (cfg &CMR_P2X_SEL_MASK ) >>CMR_P2X_SEL_SHIFT ; } +static u8 cgx_get_nix_resetbit (struct cgx *cgx) +{ +int first_lmac; +u8 p2x; + +/* non 98XX silicons supports only NIX0 block */ +if (cgx->pdev->subsystem_device !=PCI_SUBSYS_DEVID_98XX ) +return CGX_NIX0_RESET ; + + first_lmac =find_first_bit (&cgx->lmac_bmap, cgx->max_lmac_per_mac); + p2x =cgx_lmac_get_p2x (cgx->cgx_id, first_lmac); + +if (p2x ==CMR_P2X_SEL_NIX1 ) +return CGX_NIX1_RESET ; +else +return CGX_NIX0_RESET ; +} +/* Ensure the required lock for event queue(where asynchronous events are * posted) is acquired before calling this API. Else an asynchronous event(with * latest link status) can reach the destination before this function returns
@@ -1724,6 +1742,8 @@ static int cgx_lmac_init(struct cgx *cgx) lmac->lmac_type = cgx->mac_ops->get_lmac_type (cgx, lmac->lmac_id); } +/* Start X2P reset on given MAC block */ + cgx->mac_ops->mac_x2p_reset (cgx, true);return cgx_lmac_verify_fwi_version (cgx); err_bitmap_free:
@@ -1789,6 +1809,45 @@ static u8 cgx_get_rxid_mapoffset(struct cgx *cgx)return 0x60 ; } +static void cgx_x2p_reset (void *cgxd,bool enable) +{ +struct cgx *cgx = cgxd; +int lmac_id; +u64 cfg; + +if (enable) { +for_each_set_bit (lmac_id, &cgx->lmac_bmap, cgx->max_lmac_per_mac) + cgx->mac_ops->mac_enadis_rx (cgx, lmac_id, false); + +usleep_range (1000 ,2000 ); + + cfg =cgx_read (cgx,0 ,CGXX_CMR_GLOBAL_CONFIG ); + cfg |=cgx_get_nix_resetbit (cgx) |CGX_NSCI_DROP ; +cgx_write (cgx,0 ,CGXX_CMR_GLOBAL_CONFIG , cfg); + }else { + cfg =cgx_read (cgx,0 ,CGXX_CMR_GLOBAL_CONFIG ); + cfg &= ~(cgx_get_nix_resetbit (cgx) |CGX_NSCI_DROP ); +cgx_write (cgx,0 ,CGXX_CMR_GLOBAL_CONFIG , cfg); + } +} + +static int cgx_enadis_rx (void *cgxd,int lmac_id,bool enable) +{ +struct cgx *cgx = cgxd; +u64 cfg; + +if (!is_lmac_valid (cgx, lmac_id)) +return -ENODEV ; + + cfg =cgx_read (cgx, lmac_id,CGXX_CMRX_CFG ); +if (enable) + cfg |=DATA_PKT_RX_EN ; +else + cfg &= ~DATA_PKT_RX_EN ; +cgx_write (cgx, lmac_id,CGXX_CMRX_CFG , cfg); +return 0 ; +} +static struct mac_ops cgx_mac_ops = { .name ="cgx" , .csr_offset =0 ,
@@ -1820,6 +1879,8 @@ static struct mac_ops cgx_mac_ops = { .mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg, .mac_reset = cgx_lmac_reset, .mac_stats_reset = cgx_stats_reset, + .mac_x2p_reset = cgx_x2p_reset, + .mac_enadis_rx = cgx_enadis_rx, };static int cgx_probe (struct pci_dev *pdev,const struct pci_device_id *id)
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +4 -0
@@ -32,6 +32,10 @@#define CGX_LMAC_TYPE_MASK 0xF#define CGXX_CMRX_INT 0x040#define FW_CGX_INT BIT_ULL(1) +#define CGXX_CMR_GLOBAL_CONFIG 0x08 +#define CGX_NIX0_RESET BIT_ULL(2) +#define CGX_NIX1_RESET BIT_ULL(3) +#define CGX_NSCI_DROP BIT_ULL(9)#define CGXX_CMRX_INT_ENA_W1S 0x058#define CGXX_CMRX_RX_ID_MAP 0x060#define CGXX_CMRX_RX_STAT0 0x070
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +2 -0
@@ -132,6 +132,8 @@ struct mac_ops {int (*get_fec_stats)(void *cgxd,int lmac_id,struct cgx_fec_stats_rsp *rsp);int (*mac_stats_reset)(void *cgxd,int lmac_id); +void (*mac_x2p_reset)(void *cgxd,bool enable); +int (*mac_enadis_rx)(void *cgxd,int lmac_id,bool enable); };struct cgx {
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +42 -0
57 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +4 -0
@@ -17,6 +17,8 @@/* Registers */ #define RPMX_CMRX_CFG 0x00 +#define RPMX_CMR_GLOBAL_CFG 0x08 +#define RPM_NIX0_RESET BIT_ULL(3)#define RPMX_RX_TS_PREPEND BIT_ULL(22)#define RPMX_TX_PTP_1S_SUPPORT BIT_ULL(17)#define RPMX_CMRX_RX_ID_MAP 0x80
@@ -139,4 +141,6 @@ bool is_dev_rpm2(void *rpmd);int rpm_get_fec_stats (void *cgxd,int lmac_id,struct cgx_fec_stats_rsp *rsp);int rpm_lmac_reset (void *rpmd,int lmac_id,u8 pf_req_flr);int rpm_stats_reset (void *rpmd,int lmac_id); +void rpm_x2p_reset (void *rpmd,bool enable); +int rpm_enadis_rx (void *rpmd,int lmac_id,bool enable);#endif /* RPM_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -0
@@ -1162,6 +1162,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu) }rvu_program_channels (rvu); +cgx_start_linkup (rvu); err =rvu_mcs_init (rvu);if (err) {
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -967,6 +967,7 @@ int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_int rvu_cgx_cfg_pause_frm (struct rvu *rvu,u16 pcifunc,u8 tx_pause,u8 rx_pause);void rvu_mac_reset (struct rvu *rvu,u16 pcifunc);u32 rvu_cgx_get_lmac_fifolen (struct rvu *rvu,int cgx,int lmac); +void cgx_start_linkup (struct rvu *rvu);int npc_get_nixlf_mcam_index (struct npc_mcam *mcam,u16 pcifunc,int nixlf,int type); bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam, int blkaddr,
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +30 -6
@@ -349,6 +349,7 @@ static void rvu_cgx_wq_destroy(struct rvu *rvu)int rvu_cgx_init (struct rvu *rvu) { +struct mac_ops *mac_ops;int cgx, err;void *cgxd;
@@ -375,6 +376,15 @@ int rvu_cgx_init(struct rvu *rvu)if (err)return err; +/* Clear X2P reset on all MAC blocks */ +for (cgx =0 ; cgx < rvu->cgx_cnt_max; cgx++) { + cgxd =rvu_cgx_pdata (cgx, rvu); +if (!cgxd) +continue ; + mac_ops =get_mac_ops (cgxd); + mac_ops->mac_x2p_reset (cgxd, false); + } +/* Register for CGX events */ err =cgx_lmac_event_handler_init (rvu);if (err)
@@ -382,10 +392,26 @@ int rvu_cgx_init(struct rvu *rvu)mutex_init (&rvu->cgx_cfg_lock); -/* Ensure event handler registration is completed, before -* we turn on the links -*/ -mb (); +return 0 ; +} + +void cgx_start_linkup (struct rvu *rvu) +{ +unsigned long lmac_bmap; +struct mac_ops *mac_ops; +int cgx, lmac, err; +void *cgxd; + +/* Enable receive on all LMACS */ +for (cgx =0 ; cgx <= rvu->cgx_cnt_max; cgx++) { + cgxd =rvu_cgx_pdata (cgx, rvu); +if (!cgxd) +continue ; + mac_ops =get_mac_ops (cgxd); + lmac_bmap =cgx_get_lmac_bmap (cgxd); +for_each_set_bit (lmac, &lmac_bmap, rvu->hw->lmac_per_cgx) + mac_ops->mac_enadis_rx (cgxd, lmac, true); + }/* Do link up for all CGX ports */ for (cgx =0 ; cgx <= rvu->cgx_cnt_max; cgx++) {
@@ -398,8 +424,6 @@ int rvu_cgx_init(struct rvu *rvu)"Link up process failed to start on cgx %d\n" , cgx); } - -return 0 ; }int rvu_cgx_exit (struct rvu *rvu)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 583/817 spi: atmel-quadspi: Fix register name in verbose logging function
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Csókás, Bence <[email protected]>
[ Upstream commit 2ac40e6d0ccdd93031f8b1af61b0fe5cdd704923 ]
atmel_qspi_reg_name() is used for pretty-printing register offsets for verbose logging of register accesses. However, due to a typo (likely a copy-paste error), QSPI_RD's offset prints as "MR", the name of the previous register. Fix this typo.
--- drivers/spi/atmel-quadspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/atmel-quadspi.c +1 -1
@@ -183,7 +183,7 @@ static const char *atmel_qspi_reg_name(u32 offset, char *tmp, size_t sz)case QSPI_MR :return "MR" ;case QSPI_RD : -return "MR" ; +return "RD" ;case QSPI_TD :return "TD" ;case QSPI_SR :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 584/817 net: hsr: fix hsr_init_sk() vs network/transport headers.
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9cfb5e7f0ded2bfaabc270ceb5f91d13f0e805b9 ]
Following sequence in hsr_init_sk() is invalid :
skb_reset_mac_header(skb);
skb_reset_mac_len(skb);
skb_reset_network_header(skb);
skb_reset_transport_header(skb);It is invalid because skb_reset_mac_len() needs the correct network header, which should be after the mac header.
This patch moves the skb_reset_network_header() and skb_reset_transport_header() before
the call to dev_hard_header().
As a result skb->mac_len is no longer set to a value close to 65535.
--- net/hsr/hsr_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/hsr/hsr_device.c +2 -2
@@ -266,6 +266,8 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master) skb->dev = master->dev; skb->priority =TC_PRIO_CONTROL ; +skb_reset_network_header (skb); +skb_reset_transport_header (skb);if (dev_hard_header (skb, skb->dev,ETH_P_PRP , hsr->sup_multicast_addr, skb->dev->dev_addr, skb->len) <=0 )
@@ -273,8 +275,6 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master)skb_reset_mac_header (skb);skb_reset_mac_len (skb); -skb_reset_network_header (skb); -skb_reset_transport_header (skb);return skb; out:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 585/817 bnxt_en: Reserve rings after PCIe AER recovery if NIC interface is down
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravanan Vajravel <[email protected]>
[ Upstream commit 5311598f7f3293683cdc761df71ae3469327332c ]
After successful PCIe AER recovery, FW will reset all resource reservations. If it is IF_UP, the driver will call bnxt_open() and all resources will be reserved again. It it is IF_DOWN, we should call bnxt_reserve_rings() so that we can reserve resources including RoCE resources to allow RoCE to resume after AER. Without this patch, RoCE fails to resume in this IF_DOWN scenario.
Later, if it becomes IF_UP, bnxt_open() will see that resources have been reserved and will not reserve again.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -16171,8 +16171,12 @@ static void bnxt_io_resume(struct pci_dev *pdev)rtnl_lock (); err =bnxt_hwrm_func_qcaps (bp); -if (!err &&netif_running (netdev)) - err =bnxt_open (netdev); +if (!err) { +if (netif_running (netdev)) + err =bnxt_open (netdev); +else + err =bnxt_reserve_rings (bp, true); + }if (!err)netif_device_attach (netdev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 586/817 bnxt_en: Set backplane link modes correctly for ethtool
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shravya KN <[email protected]>
[ Upstream commit 5007991670941c132fb3bc0484c009cf4bcea30f ]
Use the return value from bnxt_get_media() to determine the port and link modes. bnxt_get_media() returns the proper BNXT_MEDIA_KR when the PHY is backplane. This will correct the ethtool settings for backplane devices.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +7 -2
@@ -2837,19 +2837,24 @@ static int bnxt_get_link_ksettings(struct net_device *dev, } base->port =PORT_NONE ; -if (link_info->media_type ==PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP ) { +if (media ==BNXT_MEDIA_TP ) { base->port =PORT_TP ;linkmode_set_bit (ETHTOOL_LINK_MODE_TP_BIT , lk_ksettings->link_modes.supported);linkmode_set_bit (ETHTOOL_LINK_MODE_TP_BIT , lk_ksettings->link_modes.advertising); + }else if (media ==BNXT_MEDIA_KR ) { +linkmode_set_bit (ETHTOOL_LINK_MODE_Backplane_BIT, + lk_ksettings->link_modes.supported); +linkmode_set_bit (ETHTOOL_LINK_MODE_Backplane_BIT, + lk_ksettings->link_modes.advertising); }else {linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , lk_ksettings->link_modes.supported);linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , lk_ksettings->link_modes.advertising); -if (link_info->media_type ==PORT_PHY_QCFG_RESP_MEDIA_TYPE_DAC ) +if (media ==BNXT_MEDIA_CR ) base->port =PORT_DA ;else base->port =PORT_FIBRE ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 587/817 bnxt_en: Fix receive ring space parameters when XDP is active
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shravya KN <[email protected]>
[ Upstream commit 3051a77a09dfe3022aa012071346937fdf059033 ]
The MTU setting at the time an XDP multi-buffer is attached determines whether the aggregation ring will be used and the rx_skb_func handler. This is done in bnxt_set_rx_skb_mode().
If the MTU is later changed, the aggregation ring setting may need to be changed and it may become out-of-sync with the settings initially done in bnxt_set_rx_skb_mode(). This may result in random memory corruption and crashes as the HW may DMA data larger than the allocated buffer size, such as:
BUG: kernel NULL pointer dereference, address: 00000000000003c0 PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 17 PID: 0 Comm: swapper/17 Kdump: loaded Tainted: G S OE 6.1.0-226bf9805506 #1 Hardware name: Wiwynn Delta Lake PVT BZA.02601.0150/Delta Lake-Class1, BIOS F0E_3A12 08/26/2021 RIP: 0010:bnxt_rx_pkt+0xe97/0x1ae0 [bnxt_en] Code: 8b 95 70 ff ff ff 4c 8b 9d 48 ff ff ff 66 41 89 87 b4 00 00 00 e9 0b f7 ff ff 0f b7 43 0a 49 8b 95 a8 04 00 00 25 ff 0f 00 00 <0f> b7 14 42 48 c1 e2 06 49 03 95 a0 04 00 00 0f b6 42 33f RSP: 0018:ffffa19f40cc0d18 EFLAGS: 00010202 RAX: 00000000000001e0 RBX: ffff8e2c805c6100 RCX: 00000000000007ff RDX: 0000000000000000 RSI: ffff8e2c271ab990 RDI: ffff8e2c84f12380 RBP: ffffa19f40cc0e48 R08: 000000000001000d R09: 974ea2fcddfa4cbf R10: 0000000000000000 R11: ffffa19f40cc0ff8 R12: ffff8e2c94b58980 R13: ffff8e2c952d6600 R14: 0000000000000016 R15: ffff8e2c271ab990 FS: 0000000000000000(0000) GS:ffff8e3b3f840000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000003c0 CR3: 0000000e8580a004 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <IRQ> __bnxt_poll_work+0x1c2/0x3e0 [bnxt_en]
To address the issue, we now call bnxt_set_rx_skb_mode() within bnxt_change_mtu() to properly set the AGG rings configuration and update rx_skb_func based on the new MTU value. Additionally, BNXT_FLAG_NO_AGG_RINGS is cleared at the beginning of bnxt_set_rx_skb_mode() to make sure it gets set or cleared based on the current MTU.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +9 -1
@@ -4589,7 +4589,7 @@ int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode)struct net_device *dev = bp->dev;if (page_mode) { - bp->flags &= ~BNXT_FLAG_AGG_RINGS ; + bp->flags &= ~(BNXT_FLAG_AGG_RINGS |BNXT_FLAG_NO_AGG_RINGS ); bp->flags |=BNXT_FLAG_RX_PAGE_MODE ;if (bp->xdp_prog->aux->xdp_has_frags)
@@ -14454,6 +14454,14 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)bnxt_close_nic (bp, true, false);WRITE_ONCE (dev->mtu, new_mtu); + +/* MTU change may change the AGG ring settings if an XDP multi-buffer +* program is attached. We need to set the AGG rings settings and +* rx_skb_func accordingly. +*/ +if (READ_ONCE (bp->xdp_prog)) +bnxt_set_rx_skb_mode (bp, true); +bnxt_set_ring_params (bp);if (netif_running (dev))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 588/817 bnxt_en: Refactor bnxt_ptp_init()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit 1e9614cd956268e10a669c0593e7e54d03d0c087 ]
Instead of passing the 2nd parameter phc_cfg to bnxt_ptp_init(). Store it in bp->ptp_cfg so that the caller doesn't need to know what the value should be.
In the next patch, we'll need to call bnxt_ptp_init() in bnxt_resume() and this will make it easier.
Stable-dep-of: 3661c05c54e8 ("bnxt_en: Unregister PTP during PCI shutdown and suspend")
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +++--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -3
@@ -9008,7 +9008,6 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp)struct hwrm_port_mac_ptp_qcfg_output *resp;struct hwrm_port_mac_ptp_qcfg_input *req;struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; -bool phc_cfg;u8 flags;int rc;
@@ -9055,8 +9054,9 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp) rc = -ENODEV ; goto exit; } - phc_cfg = (flags &PORT_MAC_PTP_QCFG_RESP_FLAGS_RTC_CONFIGURED ) !=0 ; - rc =bnxt_ptp_init (bp, phc_cfg); + ptp->rtc_configured = + (flags &PORT_MAC_PTP_QCFG_RESP_FLAGS_RTC_CONFIGURED ) !=0 ; + rc =bnxt_ptp_init (bp);if (rc)netdev_warn (bp->dev,"PTP initialization failed.\n" ); exit:
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +2 -2
@@ -1024,7 +1024,7 @@ static void bnxt_ptp_free(struct bnxt *bp) } } -int bnxt_ptp_init (struct bnxt *bp,bool phc_cfg) +int bnxt_ptp_init (struct bnxt *bp) {struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;int rc;
@@ -1047,7 +1047,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)if (BNXT_PTP_USE_RTC (bp)) {bnxt_ptp_timecounter_init (bp, false); - rc =bnxt_ptp_init_rtc (bp, phc_cfg); + rc =bnxt_ptp_init_rtc (bp, ptp->rtc_configured);if (rc) goto out; }else {
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +2 -1
@@ -133,6 +133,7 @@ struct bnxt_ptp_cfg { BNXT_PTP_MSG_PDELAY_REQ | \ BNXT_PTP_MSG_PDELAY_RESP) u8 tx_tstamp_en:1; + u8 rtc_configured:1;int rx_filter;u32 tstamp_filters;
@@ -180,6 +181,6 @@ void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, struct tx_ts_cmp *tscmp);void bnxt_ptp_rtc_timecounter_init (struct bnxt_ptp_cfg *ptp,u64 ns);int bnxt_ptp_init_rtc (struct bnxt *bp,bool phc_cfg); -int bnxt_ptp_init (struct bnxt *bp,bool phc_cfg); +int bnxt_ptp_init (struct bnxt *bp);void bnxt_ptp_clear (struct bnxt *bp);#endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 589/817 bnxt_en: Unregister PTP during PCI shutdown and suspend
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit 3661c05c54e8db7064aa96a0774654740974dffc ]
If we go through the PCI shutdown or suspend path, we shutdown the NIC but PTP remains registered. If the kernel continues to run for a little bit, the periodic PTP .do_aux_work() function may be called and it will read the PHC from the BAR register. Since the device has already been disabled, it will cause a PCIe completion timeout. Fix it by calling bnxt_ptp_clear() in the PCI shutdown/suspend handlers. bnxt_ptp_clear() will unregister from PTP and .do_aux_work() will be canceled.
In bnxt_resume(), we need to re-initialize PTP.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -0
@@ -15933,6 +15933,7 @@ static void bnxt_shutdown(struct pci_dev *pdev)if (netif_running (dev))dev_close (dev); +bnxt_ptp_clear (bp);bnxt_clear_int_mode (bp);pci_disable_device (pdev);
@@ -15960,6 +15961,7 @@ static int bnxt_suspend(struct device *device) rc =bnxt_close (dev); }bnxt_hwrm_func_drv_unrgtr (bp); +bnxt_ptp_clear (bp);pci_disable_device (bp->pdev);bnxt_free_ctx_mem (bp);rtnl_unlock ();
@@ -16001,6 +16003,10 @@ static int bnxt_resume(struct device *device) goto resume_exit; } +if (bnxt_ptp_init (bp)) { +kfree (bp->ptp_cfg); + bp->ptp_cfg =NULL ; + }bnxt_get_wol_settings (bp);if (netif_running (dev)) { rc =bnxt_open (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 590/817 Bluetooth: MGMT: Fix slab-use-after-free Read in set_powered_sync
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0b882940665ca2849386ee459d4331aa2f8c4e7d ]
This fixes the following crash:
==================================================================
BUG: KASAN: slab-use-after-free in set_powered_sync+0x3a/0xc0 net/bluetooth/mgmt.c:1353 Read of size 8 at addr ffff888029b4dd18 by task kworker/u9:0/54 CPU: 1 UID: 0 PID: 54 Comm: kworker/u9:0 Not tainted 6.11.0-rc6-syzkaller-01155-gf723224742fc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Workqueue: hci0 hci_cmd_sync_work Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 q kasan_report+0x143/0x180 mm/kasan/report.c:601 set_powered_sync+0x3a/0xc0 net/bluetooth/mgmt.c:1353 hci_cmd_sync_work+0x22b/0x400 net/bluetooth/hci_sync.c:328 process_one_work kernel/workqueue.c:3231 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312 worker_thread+0x86d/0xd10 kernel/workqueue.c:3389 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> Allocated by task 5247: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4193 kmalloc_noprof include/linux/slab.h:681 [inline] kzalloc_noprof include/linux/slab.h:807 [inline] mgmt_pending_new+0x65/0x250 net/bluetooth/mgmt_util.c:269 mgmt_pending_add+0x36/0x120 net/bluetooth/mgmt_util.c:296 set_powered+0x3cd/0x5e0 net/bluetooth/mgmt.c:1394 hci_mgmt_cmd+0xc47/0x11d0 net/bluetooth/hci_sock.c:1712 hci_sock_sendmsg+0x7b8/0x11c0 net/bluetooth/hci_sock.c:1832 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 sock_write_iter+0x2dd/0x400 net/socket.c:1160 new_sync_write fs/read_write.c:497 [inline] vfs_write+0xa72/0xc90 fs/read_write.c:590 ksys_write+0x1a0/0x2c0 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5246: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2256 [inline] slab_free mm/slub.c:4477 [inline] kfree+0x149/0x360 mm/slub.c:4598 settings_rsp+0x2bc/0x390 net/bluetooth/mgmt.c:1443 mgmt_pending_foreach+0xd1/0x130 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x112/0x420 net/bluetooth/mgmt.c:9455 hci_dev_close_sync+0x665/0x11a0 net/bluetooth/hci_sync.c:5191 hci_dev_do_close net/bluetooth/hci_core.c:483 [inline] hci_dev_close+0x112/0x210 net/bluetooth/hci_core.c:508 sock_do_ioctl+0x158/0x460 net/socket.c:1222 sock_ioctl+0x629/0x8e0 net/socket.c:1341 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83gv entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- net/bluetooth/mgmt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +9 -2
@@ -1317,7 +1317,8 @@ static void mgmt_set_powered_complete(struct hci_dev *hdev, void *data, int err)struct mgmt_mode *cp;/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_POWERED , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_POWERED , hdev))return ; cp = cmd->param;
@@ -1350,7 +1351,13 @@ static void mgmt_set_powered_complete(struct hci_dev *hdev, void *data, int err)static int set_powered_sync (struct hci_dev *hdev,void *data) {struct mgmt_pending_cmd *cmd = data; -struct mgmt_mode *cp = cmd->param; +struct mgmt_mode *cp; + +/* Make sure cmd still outstanding. */ +if (cmd !=pending_find (MGMT_OP_SET_POWERED , hdev)) +return -ECANCELED ; + + cp = cmd->param;BT_DBG ("%s" , hdev->name);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 591/817 Bluetooth: MGMT: Fix possible deadlocks
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit a66dfaf18fd61bb75ef8cee83db46b2aadf153d0 ]
This fixes possible deadlocks like the following caused by hci_cmd_sync_dequeue causing the destroy function to run:
INFO: task kworker/u19:0:143 blocked for more than 120 seconds.
Tainted: G W O 6.8.0-2024-03-19-intel-next-iLS-24ww14 #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u19:0 state:D stack:0 pid:143 tgid:143 ppid:2 flags:0x00004000
Workqueue: hci0 hci_cmd_sync_work [bluetooth]
Call Trace:
<TASK>
__schedule+0x374/0xaf0
schedule+0x3c/0xf0
schedule_preempt_disabled+0x1c/0x30
__mutex_lock.constprop.0+0x3ef/0x7a0
__mutex_lock_slowpath+0x13/0x20
mutex_lock+0x3c/0x50
mgmt_set_connectable_complete+0xa4/0x150 [bluetooth]
? kfree+0x211/0x2a0
hci_cmd_sync_dequeue+0xae/0x130 [bluetooth]
? __pfx_cmd_complete_rsp+0x10/0x10 [bluetooth]
cmd_complete_rsp+0x26/0x80 [bluetooth]
mgmt_pending_foreach+0x4d/0x70 [bluetooth]
__mgmt_power_off+0x8d/0x180 [bluetooth]
? _raw_spin_unlock_irq+0x23/0x40
hci_dev_close_sync+0x445/0x5b0 [bluetooth]
hci_set_powered_sync+0x149/0x250 [bluetooth]
set_powered_sync+0x24/0x60 [bluetooth]
hci_cmd_sync_work+0x90/0x150 [bluetooth]
process_one_work+0x13e/0x300
worker_thread+0x2f7/0x420
? __pfx_worker_thread+0x10/0x10
kthread+0x107/0x140
? __pfx_kthread+0x10/0x10
ret_from_fork+0x3d/0x60
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1b/0x30
</TASK>--- net/bluetooth/mgmt.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
net/bluetooth/mgmt.c +18 -9
@@ -1517,7 +1517,8 @@ static void mgmt_set_discoverable_complete(struct hci_dev *hdev, void *data,bt_dev_dbg (hdev,"err %d" , err);/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_DISCOVERABLE , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_DISCOVERABLE , hdev))return ;hci_dev_lock (hdev);
@@ -1691,7 +1692,8 @@ static void mgmt_set_connectable_complete(struct hci_dev *hdev, void *data,bt_dev_dbg (hdev,"err %d" , err);/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_CONNECTABLE , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_CONNECTABLE , hdev))return ;hci_dev_lock (hdev);
@@ -1923,7 +1925,7 @@ static void set_ssp_complete(struct hci_dev *hdev, void *data, int err)bool changed;/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_SSP , hdev)) +if (err == -ECANCELED || cmd !=pending_find (MGMT_OP_SET_SSP , hdev))return ;if (err) {
@@ -3789,7 +3791,8 @@ static void set_name_complete(struct hci_dev *hdev, void *data, int err)bt_dev_dbg (hdev,"err %d" , err); -if (cmd !=pending_find (MGMT_OP_SET_LOCAL_NAME , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_LOCAL_NAME , hdev))return ;if (status) {
@@ -3964,7 +3967,8 @@ static void set_default_phy_complete(struct hci_dev *hdev, void *data, int err)struct sk_buff *skb = cmd->skb;u8 status =mgmt_status (err); -if (cmd !=pending_find (MGMT_OP_SET_PHY_CONFIGURATION , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_PHY_CONFIGURATION , hdev))return ;if (!status) {
@@ -5855,13 +5859,16 @@ static void start_discovery_complete(struct hci_dev *hdev, void *data, int err) {struct mgmt_pending_cmd *cmd = data; +bt_dev_dbg (hdev,"err %d" , err); + +if (err == -ECANCELED ) +return ; +if (cmd !=pending_find (MGMT_OP_START_DISCOVERY , hdev) && cmd !=pending_find (MGMT_OP_START_LIMITED_DISCOVERY , hdev) && cmd !=pending_find (MGMT_OP_START_SERVICE_DISCOVERY , hdev))return ; -bt_dev_dbg (hdev,"err %d" , err); -mgmt_cmd_complete (cmd->sk, cmd->index, cmd->opcode,mgmt_status (err), cmd->param,1 );mgmt_pending_remove (cmd);
@@ -6094,7 +6101,8 @@ static void stop_discovery_complete(struct hci_dev *hdev, void *data, int err) {struct mgmt_pending_cmd *cmd = data; -if (cmd !=pending_find (MGMT_OP_STOP_DISCOVERY , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_STOP_DISCOVERY , hdev))return ;bt_dev_dbg (hdev,"err %d" , err);
@@ -8085,7 +8093,8 @@ static void read_local_oob_ext_data_complete(struct hci_dev *hdev, void *data,u8 status =mgmt_status (err);u16 eir_len; -if (cmd !=pending_find (MGMT_OP_READ_LOCAL_OOB_EXT_DATA , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_READ_LOCAL_OOB_EXT_DATA , hdev))return ;if (!status) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 592/817 llc: Improve setsockopt() handling of malformed user input
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 1465036b10be4b8b00eb31c879e86de633ad74c1 ]
copy_from_sockptr() is used incorrectly: return value is the number of bytes that could not be copied. Since it's deprecated, switch to copy_safe_from_sockptr().
Note: Keeping the optlen != sizeof(int) check as copy_safe_from_sockptr() by itself would also accept optlen > sizeof(int). Which would allow a more lenient handling of inputs.
--- net/llc/af_llc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/llc/af_llc.c +1 -1
@@ -1098,7 +1098,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,lock_sock (sk);if (unlikely (level !=SOL_LLC || optlen !=sizeof (int ))) goto out; - rc =copy_from_sockptr (&opt, optval,sizeof (opt)); + rc =copy_safe_from_sockptr (&opt,sizeof (opt), optval, optlen);if (rc) goto out; rc = -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 593/817 rxrpc: Improve setsockopt() handling of malformed user input
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 02020056647017e70509bb58c3096448117099e1 ]
copy_from_sockptr() does not return negative value on error; instead, it reports the number of bytes that failed to copy. Since it's deprecated, switch to copy_safe_from_sockptr().
Note: Keeping the optlen != sizeof(unsigned int) check as copy_safe_from_sockptr() by itself would also accept
optlen > sizeof(unsigned int). Which would allow a more lenient handling of inputs.
--- net/rxrpc/af_rxrpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/rxrpc/af_rxrpc.c +4 -3
@@ -707,9 +707,10 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, ret = -EISCONN ;if (rx->sk.sk_state !=RXRPC_UNBOUND ) goto error; - ret =copy_from_sockptr (&min_sec_level, optval, -sizeof (unsigned int )); -if (ret <0 ) + ret =copy_safe_from_sockptr (&min_sec_level, +sizeof (min_sec_level), + optval, optlen); +if (ret) goto error; ret = -EINVAL ;if (min_sec_level >RXRPC_SECURITY_MAX )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 594/817 tcp: Fix use-after-free of nreq in reqsk_timer_handler().
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit c31e72d021db2714df03df6c42855a1db592716c ]
The cited commit replaced inet_csk_reqsk_queue_drop_and_put() with __inet_csk_reqsk_queue_drop() and reqsk_put() in reqsk_timer_handler().
Then, oreq should be passed to reqsk_put() instead of req; otherwise use-after-free of nreq could happen when reqsk is migrated but the retry attempt failed (e.g. due to timeout).
Let's pass oreq to reqsk_put().
--- net/ipv4/inet_connection_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_connection_sock.c +1 -1
@@ -1188,7 +1188,7 @@ static void reqsk_timer_handler(struct timer_list *t) drop:__inet_csk_reqsk_queue_drop (sk_listener, oreq, true); -reqsk_put (req); +reqsk_put (oreq); } static bool reqsk_queue_hash_req(struct request_sock *req,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 595/817 ip6mr: fix tables suspicious RCU usage
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit f1553c9894b4dbeb10a2ab15ab1aa113b3b4047c ]
Several places call ip6mr_get_table() with no RCU nor RTNL lock. Add RCU protection inside such helper and provide a lockless variant for the few callers that already acquired the relevant lock.
Note that some users additionally reference the table outside the RCU lock. That is actually safe as the table deletion can happen only after all table accesses are completed.
--- net/ipv6/ip6mr.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-)
net/ipv6/ip6mr.c +27 -11
@@ -125,7 +125,7 @@ static struct mr_table *ip6mr_mr_table_iter(struct net *net,return ret; } -static struct mr_table *ip6mr_get_table (struct net *net,u32 id) +static struct mr_table *__ip6mr_get_table (struct net *net,u32 id) {struct mr_table *mrt;
@@ -136,6 +136,16 @@ static struct mr_table *ip6mr_get_table(struct net *net, u32 id)return NULL ; } +static struct mr_table *ip6mr_get_table (struct net *net,u32 id) +{ +struct mr_table *mrt; + +rcu_read_lock (); + mrt =__ip6mr_get_table (net, id); +rcu_read_unlock (); +return mrt; +} +static int ip6mr_fib_lookup (struct net *net,struct flowi6 *flp6,struct mr_table **mrt) {
@@ -177,7 +187,7 @@ static int ip6mr_rule_action(struct fib_rule *rule, struct flowi *flp, arg->table =fib_rule_get_table (rule, arg); - mrt =ip6mr_get_table (rule->fr_net, arg->table); + mrt =__ip6mr_get_table (rule->fr_net, arg->table);if (!mrt)return -EAGAIN ; res->mrt = mrt;
@@ -304,6 +314,8 @@ static struct mr_table *ip6mr_get_table(struct net *net, u32 id)return net->ipv6.mrt6; } +#define __ip6mr_get_table ip6mr_get_table +static int ip6mr_fib_lookup (struct net *net,struct flowi6 *flp6,struct mr_table **mrt) {
@@ -382,7 +394,7 @@ static struct mr_table *ip6mr_new_table(struct net *net, u32 id) {struct mr_table *mrt; - mrt =ip6mr_get_table (net, id); + mrt =__ip6mr_get_table (net, id);if (mrt)return mrt;
@@ -411,13 +423,15 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)struct net *net =seq_file_net (seq);struct mr_table *mrt; - mrt =ip6mr_get_table (net,RT6_TABLE_DFLT ); -if (!mrt) +rcu_read_lock (); + mrt =__ip6mr_get_table (net,RT6_TABLE_DFLT ); +if (!mrt) { +rcu_read_unlock ();return ERR_PTR (-ENOENT ); + } iter->mrt = mrt; -rcu_read_lock ();return mr_vif_seq_start (seq, pos); }
@@ -2275,11 +2289,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,struct mfc6_cache *cache;struct rt6_info *rt =dst_rt6_info (skb_dst (skb)); - mrt =ip6mr_get_table (net,RT6_TABLE_DFLT ); -if (!mrt) +rcu_read_lock (); + mrt =__ip6mr_get_table (net,RT6_TABLE_DFLT ); +if (!mrt) { +rcu_read_unlock ();return -ENOENT ; + } -rcu_read_lock (); cache =ip6mr_cache_find (mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr);if (!cache && skb->dev) {int vif =ip6mr_find_vif (mrt, skb->dev);
@@ -2560,7 +2576,7 @@ static int ip6mr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp =nla_get_in6_addr (tb[RTA_DST ]); tableid = tb[RTA_TABLE ] ?nla_get_u32 (tb[RTA_TABLE ]) :0 ; - mrt =ip6mr_get_table (net, tableid ?:RT_TABLE_DEFAULT ); + mrt =__ip6mr_get_table (net, tableid ?:RT_TABLE_DEFAULT );if (!mrt) {NL_SET_ERR_MSG_MOD (extack,"MR table does not exist" );return -ENOENT ;
@@ -2607,7 +2623,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)if (filter.table_id) {struct mr_table *mrt; - mrt =ip6mr_get_table (sock_net (skb->sk), filter.table_id); + mrt =__ip6mr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) {if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IP6MR )return skb->len;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 596/817 ipmr: fix tables suspicious RCU usage
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit fc9c273d6daaa9866f349bbe8cae25c67764c456 ]
Similar to the previous patch, plumb the RCU lock inside the ipmr_get_table(), provided a lockless variant and apply the latter in the few spots were the lock is already held.
--- net/ipv4/ipmr.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-)
net/ipv4/ipmr.c +29 -13
@@ -136,7 +136,7 @@ static struct mr_table *ipmr_mr_table_iter(struct net *net,return ret; } -static struct mr_table *ipmr_get_table (struct net *net,u32 id) +static struct mr_table *__ipmr_get_table (struct net *net,u32 id) {struct mr_table *mrt;
@@ -147,6 +147,16 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)return NULL ; } +static struct mr_table *ipmr_get_table (struct net *net,u32 id) +{ +struct mr_table *mrt; + +rcu_read_lock (); + mrt =__ipmr_get_table (net, id); +rcu_read_unlock (); +return mrt; +} +static int ipmr_fib_lookup (struct net *net,struct flowi4 *flp4,struct mr_table **mrt) {
@@ -188,7 +198,7 @@ static int ipmr_rule_action(struct fib_rule *rule, struct flowi *flp, arg->table =fib_rule_get_table (rule, arg); - mrt =ipmr_get_table (rule->fr_net, arg->table); + mrt =__ipmr_get_table (rule->fr_net, arg->table);if (!mrt)return -EAGAIN ; res->mrt = mrt;
@@ -314,6 +324,8 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)return net->ipv4.mrt; } +#define __ipmr_get_table ipmr_get_table +static int ipmr_fib_lookup (struct net *net,struct flowi4 *flp4,struct mr_table **mrt) {
@@ -402,7 +414,7 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id)if (id !=RT_TABLE_DEFAULT && id >=1000000000 )return ERR_PTR (-EINVAL ); - mrt =ipmr_get_table (net, id); + mrt =__ipmr_get_table (net, id);if (mrt)return mrt;
@@ -1373,7 +1385,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, goto out_unlock; } - mrt =ipmr_get_table (net,raw_sk (sk)->ipmr_table ? :RT_TABLE_DEFAULT ); + mrt =__ipmr_get_table (net,raw_sk (sk)->ipmr_table ? :RT_TABLE_DEFAULT );if (!mrt) { ret = -ENOENT ; goto out_unlock;
@@ -2261,11 +2273,13 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,struct mr_table *mrt;int err; - mrt =ipmr_get_table (net,RT_TABLE_DEFAULT ); -if (!mrt) +rcu_read_lock (); + mrt =__ipmr_get_table (net,RT_TABLE_DEFAULT ); +if (!mrt) { +rcu_read_unlock ();return -ENOENT ; + } -rcu_read_lock (); cache =ipmr_cache_find (mrt, saddr, daddr);if (!cache && skb->dev) {int vif =ipmr_find_vif (mrt, skb->dev);
@@ -2550,7 +2564,7 @@ static int ipmr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp = tb[RTA_DST ] ?nla_get_in_addr (tb[RTA_DST ]) :0 ; tableid = tb[RTA_TABLE ] ?nla_get_u32 (tb[RTA_TABLE ]) :0 ; - mrt =ipmr_get_table (net, tableid ? tableid :RT_TABLE_DEFAULT ); + mrt =__ipmr_get_table (net, tableid ? tableid :RT_TABLE_DEFAULT );if (!mrt) { err = -ENOENT ; goto errout_free;
@@ -2604,7 +2618,7 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)if (filter.table_id) {struct mr_table *mrt; - mrt =ipmr_get_table (sock_net (skb->sk), filter.table_id); + mrt =__ipmr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) {if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IPMR )return skb->len;
@@ -2712,7 +2726,7 @@ static int rtm_to_ipmr_mfcc(struct net *net, struct nlmsghdr *nlh,break ; } } - mrt =ipmr_get_table (net, tblid); + mrt =__ipmr_get_table (net, tblid);if (!mrt) { ret = -ENOENT ; goto out;
@@ -2920,13 +2934,15 @@ static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)struct net *net =seq_file_net (seq);struct mr_table *mrt; - mrt =ipmr_get_table (net,RT_TABLE_DEFAULT ); -if (!mrt) +rcu_read_lock (); + mrt =__ipmr_get_table (net,RT_TABLE_DEFAULT ); +if (!mrt) { +rcu_read_unlock ();return ERR_PTR (-ENOENT ); + } iter->mrt = mrt; -rcu_read_lock ();return mr_vif_seq_start (seq, pos); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 597/817 iio: light: al3010: Fix an error handling path in al3010_probe()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit a4b7064d34186cf4970fe0333c3b27346cf8f819 ]
If i2c_smbus_write_byte_data() fails in al3010_init(), al3010_set_pwr(false) is not called.
In order to avoid such a situation, move the devm_add_action_or_reset() witch calls al3010_set_pwr(false) right after a successful al3010_set_pwr(true).
--- drivers/iio/light/al3010.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/light/al3010.c +5 -6
@@ -87,7 +87,12 @@ static int al3010_init(struct al3010_data *data)int ret; ret =al3010_set_pwr (data->client, true); +if (ret <0 ) +return ret; + ret =devm_add_action_or_reset (&data->client->dev, + al3010_set_pwr_off, + data);if (ret <0 )return ret;
@@ -190,12 +195,6 @@ static int al3010_probe(struct i2c_client *client)return ret; } - ret =devm_add_action_or_reset (&client->dev, - al3010_set_pwr_off, - data); -if (ret <0 ) -return ret; -return devm_iio_device_register (&client->dev, indio_dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 598/817 usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
[ Upstream commit 44feafbaa66ec86232b123bb8437a6a262442025 ]
iowarrior_read() uses the iowarrior dev structure, but does not use any lock on the structure. This can cause various bugs including data-races, so it is more appropriate to use a mutex lock to safely protect the iowarrior dev structure. When using a mutex lock, you should split the branch to prevent blocking when the O_NONBLOCK flag is set.
In addition, it is unnecessary to check for NULL on the iowarrior dev structure obtained by reading file->private_data. Therefore, it is better to remove the check.
--- drivers/usb/misc/iowarrior.c | 46 ++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 10 deletions(-)
drivers/usb/misc/iowarrior.c +36 -10
@@ -277,28 +277,45 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,struct iowarrior *dev;int read_idx;int offset; +int retval; dev = file->private_data; +if (file->f_flags &O_NONBLOCK ) { + retval =mutex_trylock (&dev->mutex); +if (!retval) +return -EAGAIN ; + }else { + retval =mutex_lock_interruptible (&dev->mutex); +if (retval) +return -ERESTARTSYS ; + } +/* verify that the device wasn't unplugged */ -if (!dev || !dev->present) -return -ENODEV ; +if (!dev->present) { + retval = -ENODEV ; + goto exit; + }dev_dbg (&dev->interface->dev,"minor %d, count = %zd\n" , dev->minor, count);/* read count must be packet size (+ time stamp) */ if ((count != dev->report_size) - && (count != (dev->report_size +1 ))) -return -EINVAL ; + && (count != (dev->report_size +1 ))) { + retval = -EINVAL ; + goto exit; + }/* repeat until no buffer overrun in callback handler occur */ do { atomic_set(&dev->overflow_flag, 0); if ((read_idx = read_index(dev)) == -1) { /* queue empty */ - if (file->f_flags & O_NONBLOCK) - return -EAGAIN; + if (file->f_flags & O_NONBLOCK) { + retval = -EAGAIN; + goto exit; + } else { //next line will return when there is either new data, or the device is unplugged int r = wait_event_interruptible(dev->read_wait,
@@ -309,28 +326,37 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer, -1));if (r) {//we were interrupted by a signal -return -ERESTART ; + retval = -ERESTART ; + goto exit; }if (!dev->present) {//The device was unplugged -return -ENODEV ; + retval = -ENODEV ; + goto exit; }if (read_idx ==-1 ) {// Can this happen ??? -return 0 ; + retval =0 ; + goto exit; } } } offset = read_idx * (dev->report_size +1 );if (copy_to_user (buffer, dev->read_queue + offset, count)) { -return -EFAULT ; + retval = -EFAULT ; + goto exit; } }while (atomic_read (&dev->overflow_flag)); read_idx = ++read_idx ==MAX_INTERRUPT_BUFFER ?0 : read_idx;atomic_set (&dev->read_idx, read_idx); +mutex_unlock (&dev->mutex);return count; + +exit: +mutex_unlock (&dev->mutex); +return retval; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 599/817 usb: yurex: make waiting on yurex_write interruptible
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit e0aa9614ab0fd35b404e4b16ebe879f9fc152591 ]
The IO yurex_write() needs to wait for in order to have a device ready for writing again can take a long time time. Consequently the sleep is done in an interruptible state. Therefore others waiting for yurex_write() itself to finish should use mutex_lock_interruptible.
Rule: add
--- drivers/usb/misc/iowarrior.c | 4 ---- drivers/usb/misc/yurex.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/usb/misc/iowarrior.c +0 -4
@@ -911,7 +911,6 @@ static int iowarrior_probe(struct usb_interface *interface,static void iowarrior_disconnect (struct usb_interface *interface) {struct iowarrior *dev =usb_get_intfdata (interface); -int minor = dev->minor;usb_deregister_dev (interface, &iowarrior_class);
@@ -935,9 +934,6 @@ static void iowarrior_disconnect(struct usb_interface *interface)mutex_unlock (&dev->mutex);iowarrior_delete (dev); } - -dev_info (&interface->dev,"I/O-Warror #%d now disconnected\n" , - minor -IOWARRIOR_MINOR_BASE ); }/* usb specific object needed to register this driver with the usb subsystem */
drivers/usb/misc/yurex.c +4 -1
@@ -441,7 +441,10 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,if (count ==0 ) goto error; -mutex_lock (&dev->io_mutex); + retval =mutex_lock_interruptible (&dev->io_mutex); +if (retval <0 ) +return -EINTR ; +if (dev->disconnected) {/* already disconnected */ mutex_unlock (&dev->io_mutex); retval = -ENODEV ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 600/817 USB: chaoskey: fail open after removal
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 422dc0a4d12d0b80dd3aab3fe5943f665ba8f041 ]
chaoskey_open() takes the lock only to increase the counter of openings. That means that the mutual exclusion with chaoskey_disconnect() cannot prevent an increase of the counter and chaoskey_open() returning a success.
If that race is hit, chaoskey_disconnect() will happily free all resources associated with the device after it has dropped the lock, as it has read the counter as zero.
To prevent this race chaoskey_open() has to check the presence of the device under the lock. However, the current per device lock cannot be used, because it is a part of the data structure to be freed. Hence an additional global mutex is needed. The issue is as old as the driver.
Rule: add
--- drivers/usb/misc/chaoskey.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/usb/misc/chaoskey.c +24 -11
@@ -27,6 +27,8 @@ static struct usb_class_driver chaoskey_class;static int chaoskey_rng_read (struct hwrng *rng,void *data,size_t max,bool wait); +static DEFINE_MUTEX (chaoskey_list_lock); + #define usb_dbg(usb_if, format, arg...) \ dev_dbg(&(usb_if)->dev, format, ## arg)
@@ -230,6 +232,7 @@ static void chaoskey_disconnect(struct usb_interface *interface)if (dev->hwrng_registered)hwrng_unregister (&dev->hwrng); +mutex_lock (&chaoskey_list_lock);usb_deregister_dev (interface, &chaoskey_class);usb_set_intfdata (interface,NULL );
@@ -244,6 +247,7 @@ static void chaoskey_disconnect(struct usb_interface *interface) }else mutex_unlock (&dev->lock); +mutex_unlock (&chaoskey_list_lock);usb_dbg (interface,"disconnect done" ); }
@@ -251,6 +255,7 @@ static int chaoskey_open(struct inode *inode, struct file *file) {struct chaoskey *dev;struct usb_interface *interface; +int rv =0 ;/* get the interface from minor number and driver information */ interface =usb_find_interface (&chaoskey_driver,iminor (inode));
@@ -266,18 +271,23 @@ static int chaoskey_open(struct inode *inode, struct file *file) } file->private_data = dev; +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock); - ++dev->open; +if (dev->present) + ++dev->open; +else + rv = -ENODEV ;mutex_unlock (&dev->lock); +mutex_unlock (&chaoskey_list_lock); -usb_dbg (interface,"open success" ); -return 0 ; +return rv; }static int chaoskey_release (struct inode *inode,struct file *file) {struct chaoskey *dev = file->private_data;struct usb_interface *interface; +int rv =0 ;if (dev ==NULL )return -ENODEV ;
@@ -286,14 +296,15 @@ static int chaoskey_release(struct inode *inode, struct file *file)usb_dbg (interface,"release" ); +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock);usb_dbg (interface,"open count at release is %d" , dev->open);if (dev->open <=0 ) {usb_dbg (interface,"invalid open count (%d)" , dev->open); -mutex_unlock (&dev->lock); -return -ENODEV ; + rv = -ENODEV ; + goto bail; } --dev->open;
@@ -302,13 +313,15 @@ static int chaoskey_release(struct inode *inode, struct file *file)if (dev->open ==0 ) {mutex_unlock (&dev->lock);chaoskey_free (dev); - }else -mutex_unlock (&dev->lock); - }else -mutex_unlock (&dev->lock); - + goto destruction; + } + } +bail: +mutex_unlock (&dev->lock); +destruction: +mutex_lock (&chaoskey_list_lock);usb_dbg (interface,"release success" ); -return 0 ; +return rv; }static void chaos_read_callback (struct urb *urb)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 601/817 USB: chaoskey: Fix possible deadlock chaoskey_list_lock
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit d73dc7b182be4238b75278bfae16afb4c5564a58 ]
[Syzbot reported two possible deadlocks]
The first possible deadlock is:
WARNING: possible recursive locking detected
6.12.0-rc1-syzkaller-00027-g4a9fe2a8ac53 #0 Not tainted
--------------------------------------------
syz-executor363/2651 is trying to acquire lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_release+0x15d/0x2c0 drivers/usb/misc/chaoskey.c:322
but task is already holding lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_release+0x7f/0x2c0 drivers/usb/misc/chaoskey.c:299
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(chaoskey_list_lock);
lock(chaoskey_list_lock);
*** DEADLOCK ***
The second possible deadlock is:
WARNING: possible circular locking dependency detected 6.12.0-rc1-syzkaller-00027-g4a9fe2a8ac53 #0 Not tainted
------------------------------------------------------
kworker/0:2/804 is trying to acquire lock:ffffffff899dadb0 (minor_rwsem){++++}-{3:3}, at: usb_deregister_dev+0x7c/0x1e0 drivers/usb/core/file.c:186
but task is already holding lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_disconnect+0xa8/0x2a0 drivers/usb/misc/chaoskey.c:235
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (chaoskey_list_lock){+.+.}-{3:3}:
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x175/0x9c0 kernel/locking/mutex.c:752
chaoskey_open+0xdd/0x220 drivers/usb/misc/chaoskey.c:274
usb_open+0x186/0x220 drivers/usb/core/file.c:47
chrdev_open+0x237/0x6a0 fs/char_dev.c:414
do_dentry_open+0x6cb/0x1390 fs/open.c:958
vfs_open+0x82/0x3f0 fs/open.c:1088
do_open fs/namei.c:3774 [inline]
path_openat+0x1e6a/0x2d60 fs/namei.c:3933
do_filp_open+0x1dc/0x430 fs/namei.c:3960
do_sys_openat2+0x17a/0x1e0 fs/open.c:1415
do_sys_open fs/open.c:1430 [inline]
__do_sys_openat fs/open.c:1446 [inline]
__se_sys_openat fs/open.c:1441 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1441
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f-> #0 (minor_rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3161 [inline]
check_prevs_add kernel/locking/lockdep.c:3280 [inline]
validate_chain kernel/locking/lockdep.c:3904 [inline]
__lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202
lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825
down_write+0x93/0x200 kernel/locking/rwsem.c:1577
usb_deregister_dev+0x7c/0x1e0 drivers/usb/core/file.c:186
chaoskey_disconnect+0xb7/0x2a0 drivers/usb/misc/chaoskey.c:236
usb_unbind_interface+0x1e8/0x970 drivers/usb/core/driver.c:461
device_remove drivers/base/dd.c:569 [inline]
device_remove+0x122/0x170 drivers/base/dd.c:561
__device_release_driver drivers/base/dd.c:1273 [inline]
device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296
bus_remove_device+0x22f/0x420 drivers/base/bus.c:576
device_del+0x396/0x9f0 drivers/base/core.c:3864
usb_disable_device+0x36c/0x7f0 drivers/usb/core/message.c:1418
usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2304
hub_port_connect drivers/usb/core/hub.c:5361 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5661 [inline]
port_event drivers/usb/core/hub.c:5821 [inline]
hub_event+0x1bed/0x4f40 drivers/usb/core/hub.c:5903
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3229
process_scheduled_works kernel/workqueue.c:3310 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391
kthread+0x2c1/0x3a0 kernel/kthread.c:389
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(chaoskey_list_lock);
lock(minor_rwsem);
lock(chaoskey_list_lock); lock(minor_rwsem);
*** DEADLOCK ***
[Analysis]
The first is AA lock, it because wrong logic, it need a unlock. The second is AB lock, it needs to rearrange the order of lock usage.
--- drivers/usb/misc/chaoskey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/misc/chaoskey.c +2 -2
@@ -232,10 +232,10 @@ static void chaoskey_disconnect(struct usb_interface *interface)if (dev->hwrng_registered)hwrng_unregister (&dev->hwrng); -mutex_lock (&chaoskey_list_lock);usb_deregister_dev (interface, &chaoskey_class);usb_set_intfdata (interface,NULL ); +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock); dev->present = false;
@@ -319,7 +319,7 @@ static int chaoskey_release(struct inode *inode, struct file *file) bail:mutex_unlock (&dev->lock); destruction: -mutex_lock (&chaoskey_list_lock); +mutex_unlock (&chaoskey_list_lock);usb_dbg (interface,"release success" );return rv; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 602/817 misc: apds990x: Fix missing pm_runtime_disable()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 3c5d8b819d27012264edd17e6ae7fffda382fe44 ]
The pm_runtime_disable() is missing in probe error path, so add it to fix it.
--- drivers/misc/apds990x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/misc/apds990x.c +7 -5
@@ -1147,7 +1147,7 @@ static int apds990x_probe(struct i2c_client *client) err = chip->pdata->setup_resources ();if (err) { err = -EINVAL ; - goto fail3; + goto fail4; } }
@@ -1155,7 +1155,7 @@ static int apds990x_probe(struct i2c_client *client) apds990x_attribute_group);if (err <0 ) {dev_err (&chip->client->dev,"Sysfs registration failed\n" ); - goto fail4; + goto fail5; } err = request_threaded_irq(client->irq, NULL,
@@ -1166,15 +1166,17 @@ static int apds990x_probe(struct i2c_client *client)if (err) {dev_err (&client->dev,"could not get IRQ %d\n" , client->irq); - goto fail5; + goto fail6; }return err; -fail5: +fail6:sysfs_remove_group (&chip->client->dev.kobj, &apds990x_attribute_group[0 ]); -fail4: +fail5:if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources (); +fail4: +pm_runtime_disable (&client->dev); fail3:regulator_bulk_disable (ARRAY_SIZE (chip->regs), chip->regs); fail2:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 603/817 devres: Fix page faults when tracing devres from unloaded modules
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keita Morisaki <[email protected]>
[ Upstream commit 765399553714e934a219d698953d435f4f99caa7 ]
The devres ftrace event logs the name of the devres node, which is often a function name (e.g., "devm_work_drop") stringified by macros like devm_add_action. Currently, ftrace stores this name as a string literal address, which can become invalid when the module containing the string is unloaded. This results in page faults when ftrace tries to access the name.
This behavior is problematic because the devres ftrace event is designed to trace resource management throughout a device driver's lifecycle, including during module unload. The event should be available even after the module is unloaded to properly diagnose resource issues.
Fix the issue by copying the devres node name into the ftrace ring buffer using __assign_str(), instead of storing just the address. This ensures that ftrace can always access the name, even if the module is unloaded.
This change increases the memory usage for each of the ftrace entry by 12-16 bytes assuming the average devres node name is 20 bytes long, depending on the size of const char *.
Note that this change does not affect anything unless all of following conditions are met.
- CONFIG_DEBUG_DEVRES is enabled
- ftrace tracing is enabled
- The devres event is enabled in ftrace tracing
--- drivers/base/trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/trace.h +3 -3
@@ -24,18 +24,18 @@ DECLARE_EVENT_CLASS(devres, __field(struct device *, dev) __field(const char *, op) __field(void *, node) - __field(const char *, name) + __string(name, name) __field(size_t, size) ),TP_fast_assign ( __assign_str(devname); __entry->op = op; __entry->node = node; - __entry->name = name; +__assign_str (name); __entry->size = size; ),TP_printk ("%s %3s %p %s (%zu bytes)" ,__get_str (devname), - __entry->op, __entry->node, __entry->name, __entry->size) + __entry->op, __entry->node,__get_str (name), __entry->size) ); DEFINE_EVENT(devres, devres_log,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 604/817 usb: gadget: uvc: wake pump everytime we update the free list
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Grzeschik <[email protected]>
[ Upstream commit adc292d54de9db2e6b8ecb7f81f278bbbaf713e9 ]
Since the req_free list will updated if enqueuing one request was not possible it will be added back to the free list. With every available free request in the queue it is a valid case for the pump worker to use it and continue the pending bufferdata into requests for the req_ready list.
--- drivers/usb/gadget/function/uvc_video.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/gadget/function/uvc_video.c +4 -0
@@ -480,6 +480,10 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)* up later. */ list_add_tail (&to_queue->list, &video->req_free); +/* +* There is a new free request - wake up the pump. +*/ +queue_work (video->async_wq, &video->pump); }spin_unlock_irqrestore (&video->req_lock, flags);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 605/817 interconnect: qcom: icc-rpmh: probe defer incase of missing QoS clock dependency
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raviteja Laggyshetty <[email protected]>
[ Upstream commit 05123e3299dd6aa02508469b303262338c2a661c ]
Return -EPROBE_DEFER from interconnect provider incase probe defer is received from devm_clk_bulk_get_all(). This would help in reattempting the inteconnect driver probe, once the required QoS clocks are available.
--- drivers/interconnect/qcom/icc-rpmh.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/interconnect/qcom/icc-rpmh.c +3 -0
@@ -311,6 +311,9 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) } qp->num_clks =devm_clk_bulk_get_all (qp->dev, &qp->clks); +if (qp->num_clks == -EPROBE_DEFER ) +return dev_err_probe (dev, qp->num_clks,"Failed to get QoS clocks\n" ); +if (qp->num_clks <0 || (!qp->num_clks && desc->qos_clks_required)) {dev_info (dev,"Skipping QoS, failed to get clk: %d\n" , qp->num_clks); goto skip_qos_config;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 606/817 phy: realtek: usb: fix NULL deref in rtk_usb2phy_probe
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit 04e3e9188291a183b27306ddb833722c0d083d6a ]
In rtk_usb2phy_probe() devm_kzalloc() may return NULL but this returned value is not checked.
--- drivers/phy/realtek/phy-rtk-usb2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/realtek/phy-rtk-usb2.c +2 -0
@@ -1023,6 +1023,8 @@ static int rtk_usb2phy_probe(struct platform_device *pdev) rtk_phy->dev = &pdev->dev; rtk_phy->phy_cfg =devm_kzalloc (dev,sizeof (*phy_cfg),GFP_KERNEL ); +if (!rtk_phy->phy_cfg) +return -ENOMEM ;memcpy (rtk_phy->phy_cfg, phy_cfg,sizeof (*phy_cfg));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 607/817 phy: realtek: usb: fix NULL deref in rtk_usb3phy_probe
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit bf373d2919d98f3d1fe1b19a0304f72fe74386d9 ]
In rtk_usb3phy_probe() devm_kzalloc() may return NULL but this returned value is not checked.
--- drivers/phy/realtek/phy-rtk-usb3.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/realtek/phy-rtk-usb3.c +2 -0
@@ -577,6 +577,8 @@ static int rtk_usb3phy_probe(struct platform_device *pdev) rtk_phy->dev = &pdev->dev; rtk_phy->phy_cfg =devm_kzalloc (dev,sizeof (*phy_cfg),GFP_KERNEL ); +if (!rtk_phy->phy_cfg) +return -ENOMEM ;memcpy (rtk_phy->phy_cfg, phy_cfg,sizeof (*phy_cfg));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 608/817 counter: stm32-timer-cnt: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 842c3755a6bfbfcafa4a1438078d2485a9eb1d87 ]
Add check for the return value of clk_enable() in order to catch the potential exception.
--- drivers/counter/stm32-timer-cnt.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/counter/stm32-timer-cnt.c +13 -3
@@ -214,11 +214,17 @@ static int stm32_count_enable_write(struct counter_device *counter, {struct stm32_timer_cnt *const priv =counter_priv (counter);u32 cr1; +int ret;if (enable) {regmap_read (priv->regmap,TIM_CR1 , &cr1); -if (!(cr1 &TIM_CR1_CEN )) -clk_enable (priv->clk); +if (!(cr1 &TIM_CR1_CEN )) { + ret =clk_enable (priv->clk); +if (ret) { +dev_err (counter->parent,"Cannot enable clock %d\n" , ret); +return ret; + } + }regmap_update_bits (priv->regmap,TIM_CR1 ,TIM_CR1_CEN ,TIM_CR1_CEN );
@@ -816,7 +822,11 @@ static int __maybe_unused stm32_timer_cnt_resume(struct device *dev)return ret;if (priv->enabled) { -clk_enable (priv->clk); + ret =clk_enable (priv->clk); +if (ret) { +dev_err (dev,"Cannot enable clock %d\n" , ret); +return ret; + }/* Restore registers that may have been lost */ regmap_write (priv->regmap,TIM_SMCR , priv->bak.smcr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 609/817 counter: ti-ecap-capture: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 1437d9f1c56fce9c24e566508bce1d218dd5497a ]
Add check for the return value of clk_enable() in order to catch the potential exception.
--- drivers/counter/ti-ecap-capture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/counter/ti-ecap-capture.c +6 -1
@@ -574,8 +574,13 @@ static int ecap_cnt_resume(struct device *dev) {struct counter_device *counter_dev =dev_get_drvdata (dev);struct ecap_cnt_dev *ecap_dev =counter_priv (counter_dev); +int ret; -clk_enable (ecap_dev->clk); + ret =clk_enable (ecap_dev->clk); +if (ret) { +dev_err (dev,"Cannot enable clock %d\n" , ret); +return ret; + }ecap_cnt_capture_set_evmode (counter_dev, ecap_dev->pm_ctx.ev_mode);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 610/817 bus: mhi: host: Switch trace_mhi_gen_tre fields to native endian
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carl Vanderlip <[email protected]>
[ Upstream commit 23388a1b305e8aac714fafd5fdc72a580586bd0c ]
Each of the __field() macros were triggering sparse warnings similar to:
trace.h:87:1: sparse: sparse: cast to restricted __le64 trace.h:87:1: sparse: sparse: restricted __le64 degrades to integer trace.h:87:1: sparse: sparse: restricted __le64 degrades to integer
Change each little endian type to its similarly sized native integer. Convert inputs into native endian.
--- drivers/bus/mhi/host/trace.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/bus/mhi/host/trace.h +13 -12
@@ -9,6 +9,7 @@#if !defined(_TRACE_EVENT_MHI_HOST_H) || defined(TRACE_HEADER_MULTI_READ )#define _TRACE_EVENT_MHI_HOST_H +#include <linux/byteorder/generic.h> #include <linux/tracepoint.h> #include <linux/trace_seq.h> #include "../common.h"
@@ -97,18 +98,18 @@ TRACE_EVENT(mhi_gen_tre, __string(name, mhi_cntrl->mhi_dev->name) __field(int, ch_num) __field(void *, wp) - __field(__le64, tre_ptr) - __field(__le32, dword0) - __field(__le32, dword1) + __field(uint64_t, tre_ptr) + __field(uint32_t, dword0) + __field(uint32_t, dword1) ),TP_fast_assign ( __assign_str(name); __entry->ch_num = mhi_chan->chan; __entry->wp = mhi_tre; - __entry->tre_ptr = mhi_tre->ptr; - __entry->dword0 = mhi_tre->dword[0 ]; - __entry->dword1 = mhi_tre->dword[1 ]; + __entry->tre_ptr =le64_to_cpu (mhi_tre->ptr); + __entry->dword0 =le32_to_cpu (mhi_tre->dword[0 ]); + __entry->dword1 =le32_to_cpu (mhi_tre->dword[1 ]); ), TP_printk("%s: Chan: %d TRE: 0x%p TRE buf: 0x%llx DWORD0: 0x%08x DWORD1: 0x%08x\n",
@@ -176,19 +177,19 @@ DECLARE_EVENT_CLASS(mhi_process_event_ring,TP_STRUCT__entry ( __string(name, mhi_cntrl->mhi_dev->name) - __field(__le32, dword0) - __field(__le32, dword1) + __field(uint32_t, dword0) + __field(uint32_t, dword1) __field(int, state) - __field(__le64, ptr) + __field(uint64_t, ptr) __field(void *, rp) ),TP_fast_assign ( __assign_str(name); __entry->rp = rp; - __entry->ptr = rp->ptr; - __entry->dword0 = rp->dword[0 ]; - __entry->dword1 = rp->dword[1 ]; + __entry->ptr =le64_to_cpu (rp->ptr); + __entry->dword0 =le32_to_cpu (rp->dword[0 ]); + __entry->dword1 =le32_to_cpu (rp->dword[1 ]); __entry->state =MHI_TRE_GET_EV_STATE (rp); ),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 611/817 usb: typec: fix potential array underflow in ucsi_ccg_sync_control()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit e56aac6e5a25630645607b6856d4b2a17b2311a5 ]
The "command" variable can be controlled by the user via debugfs. The worry is that if con_index is zero then "&uc->ucsi->connector[con_index
- 1]" would be an array underflow.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +5 -0
@@ -644,6 +644,10 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command) uc->has_multiple_dp) { con_index = (uc->last_cmd_sent >>16 ) &UCSI_CMD_CONNECTOR_MASK ; +if (con_index ==0 ) { + ret = -EINVAL ; + goto unlock; + } con = &uc->ucsi->connector[con_index -1 ];ucsi_ccg_update_set_new_cam_cmd (uc, con, &command); }
@@ -651,6 +655,7 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command) ret =ucsi_sync_control_common (ucsi, command);pm_runtime_put_sync (uc->dev); +unlock:mutex_unlock (&uc->lock);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 612/817 firmware_loader: Fix possible resource leak in fw_log_firmware_info()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaosheng Cui <[email protected]>
[ Upstream commit 369a9c046c2fdfe037f05b43b84c386bdbccc103 ]
The alg instance should be released under the exception path, otherwise there may be resource leak here.
To mitigate this, free the alg instance with crypto_free_shash when kmalloc fails.
--- drivers/base/firmware_loader/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/base/firmware_loader/main.c +2 -3
@@ -829,19 +829,18 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name, st shash->tfm = alg;if (crypto_shash_digest (shash, fw->data, fw->size, sha256buf) <0 ) - goto out_shash; + goto out_free;for (int i =0 ; i <SHA256_DIGEST_SIZE ; i++)sprintf (&outbuf[i *2 ],"%02x" , sha256buf[i]); outbuf[SHA256_BLOCK_SIZE ] =0 ;dev_dbg (device,"Loaded FW: %s, sha256: %s\n" , name, outbuf); -out_shash: -crypto_free_shash (alg); out_free:kfree (shash);kfree (outbuf);kfree (sha256buf); +crypto_free_shash (alg); }#else static void fw_log_firmware_info(const struct firmware *fw, const char *name,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 613/817 ALSA: hda/realtek: Update ALC256 depop procedure
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
[ Upstream commit cc3d0b5dd989d3238d456f9fd385946379a9c13d ]
Old procedure has a chance to meet Headphone no output.
--- sound/pci/hda/patch_realtek.c | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
sound/pci/hda/patch_realtek.c +19 -23
@@ -3602,25 +3602,22 @@ static void alc256_init(struct hda_codec *codec) hp_pin_sense =snd_hda_jack_detect (codec, hp_pin); -if (hp_pin_sense) +if (hp_pin_sense) {msleep (2 ); +alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ -alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ - -snd_hda_codec_write (codec, hp_pin,0 , -AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_MUTE ); - -if (hp_pin_sense || spec->ultra_low_power) -msleep (85 ); - -snd_hda_codec_write (codec, hp_pin,0 , +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,PIN_OUT ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (100 ); +msleep (75 ); + +snd_hda_codec_write (codec, hp_pin,0 , +AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_UNMUTE ); +msleep (75 ); +alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x4 );/* Hight power */ + }alc_update_coef_idx (codec,0x46 ,3 <<12 ,0 ); -alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x4 );/* Hight power */ alc_update_coefex_idx (codec,0x53 ,0x02 ,0x8000 ,1 <<15 );/* Clear bit */ alc_update_coefex_idx (codec,0x53 ,0x02 ,0x8000 ,0 <<15 );/*
@@ -3644,29 +3641,28 @@ static void alc256_shutup(struct hda_codec *codec)alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ hp_pin_sense =snd_hda_jack_detect (codec, hp_pin); -if (hp_pin_sense) +if (hp_pin_sense) {msleep (2 ); -snd_hda_codec_write (codec, hp_pin,0 , +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_MUTE ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (85 ); +msleep (75 );/* 3k pull low control for Headset jack. */ /* NOTE: call this before clearing the pin, otherwise codec stalls */ /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly * when booting with headset plugged. So skip setting it for the codec alc257 */ -if (spec->en_3kpull_low) -alc_update_coef_idx (codec,0x46 ,0 ,3 <<12 ); +if (spec->en_3kpull_low) +alc_update_coef_idx (codec,0x46 ,0 ,3 <<12 ); -if (!spec->no_shutup_pins) -snd_hda_codec_write (codec, hp_pin,0 , +if (!spec->no_shutup_pins) +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x0 ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (100 ); +msleep (75 ); + }alc_auto_setup_eapd (codec, false);alc_shutup_pins (codec);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 614/817 drm/radeon: add helper rdev_to_drm(rdev)
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wu Hoi Pok <[email protected]>
[ Upstream commit a6e23bec8ed184ed2a11080b28cdbd7a3024f0c0 ]
Add helper rdev_to_drm(rdev), similar to amdgpu, most function should access the "drm_device" with "rdev_to_drm(rdev)" instead, where amdgpu has "adev_to_drm(adev)". It also makes changing from "*drm_device" to "drm_device" in "radeon_devicce" later on easier.
Stable-dep-of: 7037bb04265e ("drm/radeon: Fix spurious unplug event on radeon HDMI")
--- drivers/gpu/drm/radeon/radeon.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/radeon/radeon.h +5 -0
@@ -2476,6 +2476,11 @@ void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);u32 cik_mm_rdoorbell (struct radeon_device *rdev,u32 index);void cik_mm_wdoorbell (struct radeon_device *rdev,u32 index,u32 v); +static inline struct drm_device *rdev_to_drm (struct radeon_device *rdev) +{ +return rdev->ddev; +} +/* * Cast helper */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 615/817 drm/radeon: change rdev->ddev to rdev_to_drm(rdev)
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wu Hoi Pok <[email protected]>
[ Upstream commit fb1b5e1dd53fc834e12f69749cbc8484382599c4 ]
This patch changes the way "drm_device" is accessed. It uses "rdev_to_drm(rdev)" instead of accessing the struct member directly.
Stable-dep-of: 7037bb04265e ("drm/radeon: Fix spurious unplug event on radeon HDMI")
--- drivers/gpu/drm/radeon/atombios_encoders.c | 2 +- drivers/gpu/drm/radeon/cik.c | 14 ++-- drivers/gpu/drm/radeon/dce6_afmt.c | 2 +- drivers/gpu/drm/radeon/evergreen.c | 12 ++-- drivers/gpu/drm/radeon/ni.c | 2 +- drivers/gpu/drm/radeon/r100.c | 24 +++---- drivers/gpu/drm/radeon/r300.c | 6 +- drivers/gpu/drm/radeon/r420.c | 6 +- drivers/gpu/drm/radeon/r520.c | 2 +- drivers/gpu/drm/radeon/r600.c | 12 ++-- drivers/gpu/drm/radeon/r600_cs.c | 2 +- drivers/gpu/drm/radeon/r600_dpm.c | 4 +- drivers/gpu/drm/radeon/r600_hdmi.c | 2 +- drivers/gpu/drm/radeon/radeon_acpi.c | 10 +-- drivers/gpu/drm/radeon/radeon_agp.c | 2 +- drivers/gpu/drm/radeon/radeon_atombios.c | 2 +- drivers/gpu/drm/radeon/radeon_audio.c | 4 +- drivers/gpu/drm/radeon/radeon_combios.c | 12 ++-- drivers/gpu/drm/radeon/radeon_device.c | 10 +-- drivers/gpu/drm/radeon/radeon_display.c | 74 +++++++++++----------- drivers/gpu/drm/radeon/radeon_fbdev.c | 26 ++++---- drivers/gpu/drm/radeon/radeon_fence.c | 8 +-- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_i2c.c | 2 +- drivers/gpu/drm/radeon/radeon_ib.c | 2 +- drivers/gpu/drm/radeon/radeon_irq_kms.c | 12 ++-- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/radeon/radeon_pm.c | 20 +++--- drivers/gpu/drm/radeon/radeon_ring.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 6 +- drivers/gpu/drm/radeon/rs400.c | 6 +- drivers/gpu/drm/radeon/rs600.c | 14 ++-- drivers/gpu/drm/radeon/rs690.c | 2 +- drivers/gpu/drm/radeon/rv515.c | 4 +- drivers/gpu/drm/radeon/rv770.c | 2 +- drivers/gpu/drm/radeon/si.c | 4 +- 36 files changed, 159 insertions(+), 159 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +1 -1
@@ -2179,7 +2179,7 @@ int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder, int fe_idx)void radeon_atom_encoder_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_encoder *encoder;list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) {
drivers/gpu/drm/radeon/cik.c +7 -7
@@ -7585,7 +7585,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[0 ]) { -drm_handle_vblank (rdev->ddev,0 ); +drm_handle_vblank (rdev_to_drm (rdev),0 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -7615,7 +7615,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[1 ]) { -drm_handle_vblank (rdev->ddev,1 ); +drm_handle_vblank (rdev_to_drm (rdev),1 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -7645,7 +7645,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[2 ]) { -drm_handle_vblank (rdev->ddev,2 ); +drm_handle_vblank (rdev_to_drm (rdev),2 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -7675,7 +7675,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[3 ]) { -drm_handle_vblank (rdev->ddev,3 ); +drm_handle_vblank (rdev_to_drm (rdev),3 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -7705,7 +7705,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[4 ]) { -drm_handle_vblank (rdev->ddev,4 ); +drm_handle_vblank (rdev_to_drm (rdev),4 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -7735,7 +7735,7 @@ int cik_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[5 ]) { -drm_handle_vblank (rdev->ddev,5 ); +drm_handle_vblank (rdev_to_drm (rdev),5 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -8581,7 +8581,7 @@ int cik_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);
drivers/gpu/drm/radeon/dce6_afmt.c +1 -1
@@ -91,7 +91,7 @@ struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev) pin = &rdev->audio.pin[i]; pin_count =0 ; -list_for_each_entry (encoder, &rdev->ddev->mode_config.encoder_list, head) { +list_for_each_entry (encoder, &rdev_to_drm (rdev)->mode_config.encoder_list, head) {if (radeon_encoder_is_digital (encoder)) { radeon_encoder =to_radeon_encoder (encoder); dig = radeon_encoder->enc_priv;
drivers/gpu/drm/radeon/evergreen.c +6 -6
@@ -1673,7 +1673,7 @@ void evergreen_pm_misc(struct radeon_device *rdev)*/ void evergreen_pm_prepare (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -1698,7 +1698,7 @@ void evergreen_pm_prepare(struct radeon_device *rdev)*/ void evergreen_pm_finish (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -1763,7 +1763,7 @@ void evergreen_hpd_set_polarity(struct radeon_device *rdev,*/ void evergreen_hpd_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned enabled =0 ; u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) |
@@ -1804,7 +1804,7 @@ void evergreen_hpd_init(struct radeon_device *rdev)*/ void evergreen_hpd_fini (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned disabled =0 ;
@@ -4753,7 +4753,7 @@ int evergreen_irq_process(struct radeon_device *rdev) event_name ="vblank" ;if (rdev->irq.crtc_vblank_int[crtc_idx]) { -drm_handle_vblank (rdev->ddev, crtc_idx); +drm_handle_vblank (rdev_to_drm (rdev), crtc_idx); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -5211,7 +5211,7 @@ int evergreen_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);/* initialize AGP */
drivers/gpu/drm/radeon/ni.c +1 -1
@@ -2360,7 +2360,7 @@ int cayman_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);/* initialize memory controller */
drivers/gpu/drm/radeon/r100.c +12 -12
@@ -459,7 +459,7 @@ void r100_pm_misc(struct radeon_device *rdev)*/ void r100_pm_prepare (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -490,7 +490,7 @@ void r100_pm_prepare(struct radeon_device *rdev)*/ void r100_pm_finish (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -603,7 +603,7 @@ void r100_hpd_set_polarity(struct radeon_device *rdev,*/ void r100_hpd_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned enable =0 ;
@@ -626,7 +626,7 @@ void r100_hpd_init(struct radeon_device *rdev)*/ void r100_hpd_fini (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned disable =0 ;
@@ -798,7 +798,7 @@ int r100_irq_process(struct radeon_device *rdev)/* Vertical blank interrupts */ if (status &RADEON_CRTC_VBLANK_STAT ) {if (rdev->irq.crtc_vblank_int[0 ]) { -drm_handle_vblank (rdev->ddev,0 ); +drm_handle_vblank (rdev_to_drm (rdev),0 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -807,7 +807,7 @@ int r100_irq_process(struct radeon_device *rdev) }if (status &RADEON_CRTC2_VBLANK_STAT ) {if (rdev->irq.crtc_vblank_int[1 ]) { -drm_handle_vblank (rdev->ddev,1 ); +drm_handle_vblank (rdev_to_drm (rdev),1 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -1491,7 +1491,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) header =radeon_get_ib_value (p, h_idx); crtc_id =radeon_get_ib_value (p, h_idx +5 ); reg =R100_CP_PACKET0_GET_REG (header); - crtc =drm_crtc_find (p->rdev->ddev, p->filp, crtc_id); + crtc =drm_crtc_find (rdev_to_drm (p->rdev), p->filp, crtc_id);if (!crtc) {DRM_ERROR ("cannot find crtc %d\n" , crtc_id);return -ENOENT ;
@@ -3079,7 +3079,7 @@ DEFINE_SHOW_ATTRIBUTE(r100_debugfs_mc_info);void r100_debugfs_rbbm_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("r100_rbbm_info" ,0444 , root, rdev, &r100_debugfs_rbbm_info_fops);
@@ -3089,7 +3089,7 @@ void r100_debugfs_rbbm_init(struct radeon_device *rdev)void r100_debugfs_cp_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("r100_cp_ring_info" ,0444 , root, rdev, &r100_debugfs_cp_ring_info_fops);
@@ -3101,7 +3101,7 @@ void r100_debugfs_cp_init(struct radeon_device *rdev)void r100_debugfs_mc_info_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("r100_mc_info" ,0444 , root, rdev, &r100_debugfs_mc_info_fops);
@@ -3967,7 +3967,7 @@ int r100_resume(struct radeon_device *rdev) RREG32(R_0007C0_CP_STAT)); }/* post */ -radeon_combios_asic_init (rdev->ddev); +radeon_combios_asic_init (rdev_to_drm (rdev));/* Resume clock after posting */ r100_clock_startup (rdev);/* Initialize surface registers */
@@ -4076,7 +4076,7 @@ int r100_init(struct radeon_device *rdev)/* Set asic errata */ r100_errata (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize AGP */ if (rdev->flags &RADEON_IS_AGP ) { r =radeon_agp_init (rdev);
drivers/gpu/drm/radeon/r300.c +3 -3
@@ -616,7 +616,7 @@ DEFINE_SHOW_ATTRIBUTE(rv370_debugfs_pcie_gart_info);static void rv370_debugfs_pcie_gart_info_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("rv370_pcie_gart_info" ,0444 , root, rdev, &rv370_debugfs_pcie_gart_info_fops);
@@ -1452,7 +1452,7 @@ int r300_resume(struct radeon_device *rdev) RREG32(R_0007C0_CP_STAT)); }/* post */ -radeon_combios_asic_init (rdev->ddev); +radeon_combios_asic_init (rdev_to_drm (rdev));/* Resume clock after posting */ r300_clock_startup (rdev);/* Initialize surface registers */
@@ -1538,7 +1538,7 @@ int r300_init(struct radeon_device *rdev)/* Set asic errata */ r300_errata (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize AGP */ if (rdev->flags &RADEON_IS_AGP ) { r =radeon_agp_init (rdev);
drivers/gpu/drm/radeon/r420.c +3 -3
@@ -322,7 +322,7 @@ int r420_resume(struct radeon_device *rdev)if (rdev->is_atom_bios) {atom_asic_init (rdev->mode_info.atom_context); }else { -radeon_combios_asic_init (rdev->ddev); +radeon_combios_asic_init (rdev_to_drm (rdev)); }/* Resume clock after posting */ r420_clock_resume (rdev);
@@ -414,7 +414,7 @@ int r420_init(struct radeon_device *rdev)return -EINVAL ;/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize AGP */ if (rdev->flags &RADEON_IS_AGP ) { r =radeon_agp_init (rdev);
@@ -493,7 +493,7 @@ DEFINE_SHOW_ATTRIBUTE(r420_debugfs_pipes_info);void r420_debugfs_pipes_info_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("r420_pipes_info" ,0444 , root, rdev, &r420_debugfs_pipes_info_fops);
drivers/gpu/drm/radeon/r520.c +1 -1
@@ -287,7 +287,7 @@ int r520_init(struct radeon_device *rdev)atom_asic_init (rdev->mode_info.atom_context); }/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize AGP */ if (rdev->flags &RADEON_IS_AGP ) { r =radeon_agp_init (rdev);
drivers/gpu/drm/radeon/r600.c +6 -6
@@ -950,7 +950,7 @@ void r600_hpd_set_polarity(struct radeon_device *rdev,void r600_hpd_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned enable =0 ;
@@ -1017,7 +1017,7 @@ void r600_hpd_init(struct radeon_device *rdev)void r600_hpd_fini (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned disable =0 ;
@@ -3280,7 +3280,7 @@ int r600_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);if (rdev->flags &RADEON_IS_AGP ) {
@@ -4136,7 +4136,7 @@ int r600_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: D1 vblank - IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[0 ]) { -drm_handle_vblank (rdev->ddev,0 ); +drm_handle_vblank (rdev_to_drm (rdev),0 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -4166,7 +4166,7 @@ int r600_irq_process(struct radeon_device *rdev)DRM_DEBUG ("IH: D2 vblank - IH event w/o asserted irq bit?\n" );if (rdev->irq.crtc_vblank_int[1 ]) { -drm_handle_vblank (rdev->ddev,1 ); +drm_handle_vblank (rdev_to_drm (rdev),1 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -4358,7 +4358,7 @@ DEFINE_SHOW_ATTRIBUTE(r600_debugfs_mc_info);static void r600_debugfs_mc_info_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("r600_mc_info" ,0444 , root, rdev, &r600_debugfs_mc_info_fops);
drivers/gpu/drm/radeon/r600_cs.c +1 -1
@@ -884,7 +884,7 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p, crtc_id =radeon_get_ib_value (p, h_idx +2 +7 +1 ); reg =R600_CP_PACKET0_GET_REG (header); - crtc =drm_crtc_find (p->rdev->ddev, p->filp, crtc_id); + crtc =drm_crtc_find (rdev_to_drm (p->rdev), p->filp, crtc_id);if (!crtc) {DRM_ERROR ("cannot find crtc %d\n" , crtc_id);return -ENOENT ;
drivers/gpu/drm/radeon/r600_dpm.c +2 -2
@@ -153,7 +153,7 @@ void r600_dpm_print_ps_status(struct radeon_device *rdev,u32 r600_dpm_get_vblank_time (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 vblank_in_pixels;
@@ -180,7 +180,7 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev)u32 r600_dpm_get_vrefresh (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 vrefresh =0 ;
drivers/gpu/drm/radeon/r600_hdmi.c +1 -1
@@ -116,7 +116,7 @@ void r600_audio_update_hdmi(struct work_struct *work) { struct radeon_device *rdev = container_of(work, struct radeon_device, audio_work); -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct r600_audio_pin audio_status =r600_audio_status (rdev);struct drm_encoder *encoder;bool changed = false;
drivers/gpu/drm/radeon/radeon_acpi.c +5 -5
@@ -405,11 +405,11 @@ static int radeon_atif_handler(struct radeon_device *rdev,if (req.pending &ATIF_DGPU_DISPLAY_EVENT ) {if ((rdev->flags &RADEON_IS_PX ) &&radeon_atpx_dgpu_req_power_for_displays ()) { -pm_runtime_get_sync (rdev->ddev->dev); +pm_runtime_get_sync (rdev_to_drm (rdev)->dev);/* Just fire off a uevent and let userspace tell us what to do */ -drm_helper_hpd_irq_event (rdev->ddev); -pm_runtime_mark_last_busy (rdev->ddev->dev); -pm_runtime_put_autosuspend (rdev->ddev->dev); +drm_helper_hpd_irq_event (rdev_to_drm (rdev)); +pm_runtime_mark_last_busy (rdev_to_drm (rdev)->dev); +pm_runtime_put_autosuspend (rdev_to_drm (rdev)->dev); } }/* TODO: check other events */
@@ -736,7 +736,7 @@ int radeon_acpi_init(struct radeon_device *rdev)struct radeon_encoder *target =NULL ;/* Find the encoder controlling the brightness */ -list_for_each_entry (tmp, &rdev->ddev->mode_config.encoder_list, +list_for_each_entry (tmp, &rdev_to_drm (rdev)->mode_config.encoder_list, head) {struct radeon_encoder *enc =to_radeon_encoder (tmp);
drivers/gpu/drm/radeon/radeon_agp.c +1 -1
@@ -161,7 +161,7 @@ struct radeon_agp_head *radeon_agp_head_init(struct drm_device *dev)static int radeon_agp_head_acquire (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct pci_dev *pdev =to_pci_dev (dev->dev);if (!rdev->agp)
drivers/gpu/drm/radeon/radeon_atombios.c +1 -1
@@ -187,7 +187,7 @@ void radeon_atombios_i2c_init(struct radeon_device *rdev)if (i2c.valid) {sprintf (stmp,"0x%x" , i2c.i2c_id); - rdev->i2c_bus[i] =radeon_i2c_create (rdev->ddev, &i2c, stmp); + rdev->i2c_bus[i] =radeon_i2c_create (rdev_to_drm (rdev), &i2c, stmp); } gpio = (ATOM_GPIO_I2C_ASSIGMENT *) ((u8 *)gpio +sizeof (ATOM_GPIO_I2C_ASSIGMENT ));
drivers/gpu/drm/radeon/radeon_audio.c +2 -2
@@ -196,7 +196,7 @@ static void radeon_audio_enable(struct radeon_device *rdev,return ;if (rdev->mode_info.mode_config_initialized) { -list_for_each_entry (encoder, &rdev->ddev->mode_config.encoder_list, head) { +list_for_each_entry (encoder, &rdev_to_drm (rdev)->mode_config.encoder_list, head) {if (radeon_encoder_is_digital (encoder)) { radeon_encoder =to_radeon_encoder (encoder); dig = radeon_encoder->enc_priv;
@@ -760,7 +760,7 @@ static int radeon_audio_component_get_eld(struct device *kdev, int port,if (!rdev->audio.enabled || !rdev->mode_info.mode_config_initialized)return 0 ; -list_for_each_entry (encoder, &rdev->ddev->mode_config.encoder_list, head) { +list_for_each_entry (encoder, &rdev_to_drm (rdev)->mode_config.encoder_list, head) {if (!radeon_encoder_is_digital (encoder))continue ; radeon_encoder =to_radeon_encoder (encoder);
drivers/gpu/drm/radeon/radeon_combios.c +6 -6
@@ -372,7 +372,7 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)int edid_info, size;struct edid *edid;unsigned char *raw; - edid_info =combios_get_table_offset (rdev->ddev,COMBIOS_HARDCODED_EDID_TABLE ); + edid_info =combios_get_table_offset (rdev_to_drm (rdev),COMBIOS_HARDCODED_EDID_TABLE );if (!edid_info)return false;
@@ -642,7 +642,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdestatic struct radeon_i2c_bus_rec radeon_combios_get_i2c_info_from_table (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct radeon_i2c_bus_rec i2c;u16 offset;u8 id, blocks, clk, data;
@@ -670,7 +670,7 @@ static struct radeon_i2c_bus_rec radeon_combios_get_i2c_info_from_table(struct rvoid radeon_combios_i2c_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct radeon_i2c_bus_rec i2c;/* actual hw pads
@@ -812,7 +812,7 @@ bool radeon_combios_get_clock_info(struct drm_device *dev)bool radeon_combios_sideport_present (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);u16 igp_info;/* sideport is AMD only */
@@ -915,7 +915,7 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(structenum radeon_tv_std radeon_combios_get_tv_info (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);uint16_t tv_info;enum radeon_tv_std tv_std =TV_STD_NTSC ;
@@ -2637,7 +2637,7 @@ static const char *thermal_controller_names[] = {void radeon_combios_get_power_modes (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);u16 offset, misc, misc2 =0 ;u8 rev, tmp;int state_index =0 ;
drivers/gpu/drm/radeon/radeon_device.c +5 -5
@@ -760,7 +760,7 @@ bool radeon_boot_test_post_card(struct radeon_device *rdev)if (rdev->is_atom_bios)atom_asic_init (rdev->mode_info.atom_context);else -radeon_combios_asic_init (rdev->ddev); +radeon_combios_asic_init (rdev_to_drm (rdev));return true; }else {dev_err (rdev->dev,"Card not posted and no BIOS - ignoring\n" );
@@ -980,7 +980,7 @@ int radeon_atombios_init(struct radeon_device *rdev)return -ENOMEM ; rdev->mode_info.atom_card_info = atom_card_info; - atom_card_info->dev = rdev->ddev; + atom_card_info->dev =rdev_to_drm (rdev); atom_card_info->reg_read = cail_reg_read; atom_card_info->reg_write = cail_reg_write;/* needed for iio ops */
@@ -1005,7 +1005,7 @@ int radeon_atombios_init(struct radeon_device *rdev)mutex_init (&rdev->mode_info.atom_context->mutex);mutex_init (&rdev->mode_info.atom_context->scratch_mutex); -radeon_atom_initialize_bios_scratch_regs (rdev->ddev); +radeon_atom_initialize_bios_scratch_regs (rdev_to_drm (rdev));atom_allocate_fb_scratch (rdev->mode_info.atom_context);return 0 ; }
@@ -1049,7 +1049,7 @@ void radeon_atombios_fini(struct radeon_device *rdev)*/ int radeon_combios_init (struct radeon_device *rdev) { -radeon_combios_initialize_bios_scratch_regs (rdev->ddev); +radeon_combios_initialize_bios_scratch_regs (rdev_to_drm (rdev));return 0 ; }
@@ -1847,7 +1847,7 @@ int radeon_gpu_reset(struct radeon_device *rdev)downgrade_write (&rdev->exclusive_lock); -drm_helper_resume_force_mode (rdev->ddev); +drm_helper_resume_force_mode (rdev_to_drm (rdev));/* set the power state here in case we are a PX system or headless */ if ((rdev->pm.pm_method ==PM_METHOD_DPM ) && rdev->pm.dpm_enabled)
drivers/gpu/drm/radeon/radeon_display.c +37 -37
214 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_fbdev.c +13 -13
@@ -67,7 +67,7 @@ static int radeon_fbdev_create_pinned_object(struct drm_fb_helper *fb_helper,int height = mode_cmd->height;u32 cpp; - info =drm_get_format_info (rdev->ddev, mode_cmd); + info =drm_get_format_info (rdev_to_drm (rdev), mode_cmd); cpp = info->cpp[0 ];/* need to align pitch with crtc limits */
@@ -148,15 +148,15 @@ static int radeon_fbdev_fb_open(struct fb_info *info, int user)struct radeon_device *rdev = fb_helper->dev->dev_private;int ret; - ret =pm_runtime_get_sync (rdev->ddev->dev); + ret =pm_runtime_get_sync (rdev_to_drm (rdev)->dev);if (ret <0 && ret != -EACCES ) goto err_pm_runtime_mark_last_busy;return 0 ; err_pm_runtime_mark_last_busy: -pm_runtime_mark_last_busy (rdev->ddev->dev); -pm_runtime_put_autosuspend (rdev->ddev->dev); +pm_runtime_mark_last_busy (rdev_to_drm (rdev)->dev); +pm_runtime_put_autosuspend (rdev_to_drm (rdev)->dev);return ret; }
@@ -165,8 +165,8 @@ static int radeon_fbdev_fb_release(struct fb_info *info, int user)struct drm_fb_helper *fb_helper = info->par;struct radeon_device *rdev = fb_helper->dev->dev_private; -pm_runtime_mark_last_busy (rdev->ddev->dev); -pm_runtime_put_autosuspend (rdev->ddev->dev); +pm_runtime_mark_last_busy (rdev_to_drm (rdev)->dev); +pm_runtime_put_autosuspend (rdev_to_drm (rdev)->dev);return 0 ; }
@@ -236,7 +236,7 @@ static int radeon_fbdev_fb_helper_fb_probe(struct drm_fb_helper *fb_helper, ret = -ENOMEM ; goto err_radeon_fbdev_destroy_pinned_object; } - ret =radeon_framebuffer_init (rdev->ddev, fb, &mode_cmd, gobj); + ret =radeon_framebuffer_init (rdev_to_drm (rdev), fb, &mode_cmd, gobj);if (ret) {DRM_ERROR ("failed to initialize framebuffer %d\n" , ret); goto err_kfree;
@@ -374,12 +374,12 @@ void radeon_fbdev_setup(struct radeon_device *rdev) fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL );if (!fb_helper)return ; -drm_fb_helper_prepare (rdev->ddev, fb_helper, bpp_sel, &radeon_fbdev_fb_helper_funcs); +drm_fb_helper_prepare (rdev_to_drm (rdev), fb_helper, bpp_sel, &radeon_fbdev_fb_helper_funcs); - ret =drm_client_init (rdev->ddev, &fb_helper->client,"radeon-fbdev" , + ret =drm_client_init (rdev_to_drm (rdev), &fb_helper->client,"radeon-fbdev" , &radeon_fbdev_client_funcs);if (ret) { -drm_err (rdev->ddev,"Failed to register client: %d\n" , ret); +drm_err (rdev_to_drm (rdev),"Failed to register client: %d\n" , ret); goto err_drm_client_init; }
@@ -394,13 +394,13 @@ void radeon_fbdev_setup(struct radeon_device *rdev)void radeon_fbdev_set_suspend (struct radeon_device *rdev,int state) { -if (rdev->ddev->fb_helper) -drm_fb_helper_set_suspend (rdev->ddev->fb_helper, state); +if (rdev_to_drm (rdev)->fb_helper) +drm_fb_helper_set_suspend (rdev_to_drm (rdev)->fb_helper, state); }bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) { -struct drm_fb_helper *fb_helper = rdev->ddev->fb_helper; +struct drm_fb_helper *fb_helper =rdev_to_drm (rdev)->fb_helper;struct drm_gem_object *gobj;if (!fb_helper)
drivers/gpu/drm/radeon/radeon_fence.c +4 -4
@@ -150,7 +150,7 @@ int radeon_fence_emit(struct radeon_device *rdev, rdev->fence_context + ring, seq);radeon_fence_ring_emit (rdev, ring, *fence); -trace_radeon_fence_emit (rdev->ddev, ring, (*fence)->seq); +trace_radeon_fence_emit (rdev_to_drm (rdev), ring, (*fence)->seq);radeon_fence_schedule_check (rdev, ring);return 0 ; }
@@ -489,7 +489,7 @@ static long radeon_fence_wait_seq_timeout(struct radeon_device *rdev,if (!target_seq[i])continue ; -trace_radeon_fence_wait_begin (rdev->ddev, i, target_seq[i]); +trace_radeon_fence_wait_begin (rdev_to_drm (rdev), i, target_seq[i]);radeon_irq_kms_sw_irq_get (rdev, i); }
@@ -511,7 +511,7 @@ static long radeon_fence_wait_seq_timeout(struct radeon_device *rdev,continue ;radeon_irq_kms_sw_irq_put (rdev, i); -trace_radeon_fence_wait_end (rdev->ddev, i, target_seq[i]); +trace_radeon_fence_wait_end (rdev_to_drm (rdev), i, target_seq[i]); }return r;
@@ -995,7 +995,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(radeon_debugfs_gpu_reset_fops,void radeon_debugfs_fence_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("radeon_gpu_reset" ,0444 , root, rdev, &radeon_debugfs_gpu_reset_fops);
drivers/gpu/drm/radeon/radeon_gem.c +1 -1
@@ -899,7 +899,7 @@ DEFINE_SHOW_ATTRIBUTE(radeon_debugfs_gem_info);void radeon_gem_debugfs_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("radeon_gem_info" ,0444 , root, rdev, &radeon_debugfs_gem_info_fops);
drivers/gpu/drm/radeon/radeon_i2c.c +1 -1
@@ -1011,7 +1011,7 @@ void radeon_i2c_add(struct radeon_device *rdev,struct radeon_i2c_bus_rec *rec, const char *name) { - struct drm_device *dev = rdev->ddev; + struct drm_device *dev = rdev_to_drm(rdev);int i;for (i =0 ; i <RADEON_MAX_I2C_BUS ; i++) {
drivers/gpu/drm/radeon/radeon_ib.c +1 -1
@@ -309,7 +309,7 @@ DEFINE_SHOW_ATTRIBUTE(radeon_debugfs_sa_info);static void radeon_debugfs_sa_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("radeon_sa_info" ,0444 , root, rdev, &radeon_debugfs_sa_info_fops);
drivers/gpu/drm/radeon/radeon_irq_kms.c +6 -6
@@ -80,7 +80,7 @@ static void radeon_hotplug_work_func(struct work_struct *work) { struct radeon_device *rdev = container_of(work, struct radeon_device, hotplug_work.work); -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_mode_config *mode_config = &dev->mode_config;struct drm_connector *connector;
@@ -101,7 +101,7 @@ static void radeon_dp_work_func(struct work_struct *work) { struct radeon_device *rdev = container_of(work, struct radeon_device, dp_work); -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_mode_config *mode_config = &dev->mode_config;struct drm_connector *connector;
@@ -197,7 +197,7 @@ static void radeon_driver_irq_uninstall_kms(struct drm_device *dev)static int radeon_irq_install (struct radeon_device *rdev,int irq) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);int ret;if (irq ==IRQ_NOTCONNECTED )
@@ -218,7 +218,7 @@ static int radeon_irq_install(struct radeon_device *rdev, int irq)static void radeon_irq_uninstall (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct pci_dev *pdev =to_pci_dev (dev->dev);radeon_driver_irq_uninstall_kms (dev);
@@ -322,9 +322,9 @@ int radeon_irq_kms_init(struct radeon_device *rdev)spin_lock_init (&rdev->irq.lock);/* Disable vblank irqs aggressively for power-saving */ - rdev->ddev->vblank_disable_immediate = true; +rdev_to_drm (rdev)->vblank_disable_immediate = true; - r =drm_vblank_init (rdev->ddev, rdev->num_crtc); + r =drm_vblank_init (rdev_to_drm (rdev), rdev->num_crtc);if (r) {return r; }
drivers/gpu/drm/radeon/radeon_object.c +1 -1
@@ -150,7 +150,7 @@ int radeon_bo_create(struct radeon_device *rdev, bo =kzalloc (sizeof (struct radeon_bo ),GFP_KERNEL );if (bo ==NULL )return -ENOMEM ; -drm_gem_private_object_init (rdev->ddev, &bo->tbo.base, size); +drm_gem_private_object_init (rdev_to_drm (rdev), &bo->tbo.base, size); bo->rdev = rdev; bo->surface_reg =-1 ;INIT_LIST_HEAD (&bo->list);
drivers/gpu/drm/radeon/radeon_pm.c +10 -10
@@ -282,7 +282,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)if (rdev->irq.installed) { i =0 ; -drm_for_each_crtc (crtc, rdev->ddev) { +drm_for_each_crtc (crtc,rdev_to_drm (rdev)) {if (rdev->pm.active_crtcs & (1 << i)) {/* This can fail if a modeset is in progress */ if (drm_crtc_vblank_get (crtc) ==0 )
@@ -299,7 +299,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)if (rdev->irq.installed) { i =0 ; -drm_for_each_crtc (crtc, rdev->ddev) { +drm_for_each_crtc (crtc,rdev_to_drm (rdev)) {if (rdev->pm.req_vblank & (1 << i)) { rdev->pm.req_vblank &= ~(1 << i);drm_crtc_vblank_put (crtc);
@@ -671,7 +671,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, char *buf) {struct radeon_device *rdev =dev_get_drvdata (dev); -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);int temp;/* Can't get temperature when the card is off */
@@ -715,7 +715,7 @@ static ssize_t radeon_hwmon_show_sclk(struct device *dev, struct device_attribute *attr, char *buf) { struct radeon_device *rdev = dev_get_drvdata(dev); -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);u32 sclk =0 ;/* Can't get clock frequency when the card is off */
@@ -740,7 +740,7 @@ static ssize_t radeon_hwmon_show_vddc(struct device *dev, struct device_attribute *attr, char *buf) { struct radeon_device *rdev = dev_get_drvdata(dev); -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);u16 vddc =0 ;/* Can't get vddc when the card is off */
@@ -1692,7 +1692,7 @@ void radeon_pm_fini(struct radeon_device *rdev)static void radeon_pm_compute_clocks_old (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;
@@ -1765,7 +1765,7 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev)static void radeon_pm_compute_clocks_dpm (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;struct radeon_connector *radeon_connector;
@@ -1826,7 +1826,7 @@ static bool radeon_pm_in_vbl(struct radeon_device *rdev)*/ for (crtc =0 ; (crtc < rdev->num_crtc) && in_vbl; crtc++) {if (rdev->pm.active_crtcs & (1 << crtc)) { - vbl_status = radeon_get_crtc_scanoutpos(rdev->ddev, + vbl_status = radeon_get_crtc_scanoutpos(rdev_to_drm(rdev), crtc, USE_REAL_VBLANKSTART, &vpos, &hpos, NULL, NULL,
@@ -1918,7 +1918,7 @@ static void radeon_dynpm_idle_work_handler(struct work_struct *work)static int radeon_debugfs_pm_info_show (struct seq_file *m,void *unused) {struct radeon_device *rdev = m->private; -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);if ((rdev->flags &RADEON_IS_PX ) && (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) {
@@ -1955,7 +1955,7 @@ DEFINE_SHOW_ATTRIBUTE(radeon_debugfs_pm_info);static void radeon_debugfs_pm_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("radeon_pm_info" ,0444 , root, rdev, &radeon_debugfs_pm_info_fops);
drivers/gpu/drm/radeon/radeon_ring.c +1 -1
@@ -550,7 +550,7 @@ static void radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_r {#if defined(CONFIG_DEBUG_FS )const char *ring_name =radeon_debugfs_ring_idx_to_name (ring->idx); -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;if (ring_name) debugfs_create_file(ring_name, 0444, root, ring,
drivers/gpu/drm/radeon/radeon_ttm.c +3 -3
@@ -682,8 +682,8 @@ int radeon_ttm_init(struct radeon_device *rdev)/* No others user of address space so set it to 0 */ r =ttm_device_init (&rdev->mman.bdev, &radeon_bo_driver, rdev->dev, - rdev->ddev->anon_inode->i_mapping, - rdev->ddev->vma_offset_manager, +rdev_to_drm (rdev)->anon_inode->i_mapping, +rdev_to_drm (rdev)->vma_offset_manager, rdev->need_swiotlb,dma_addressing_limited (&rdev->pdev->dev));if (r) {
@@ -890,7 +890,7 @@ static const struct file_operations radeon_ttm_gtt_fops = {static void radeon_ttm_debugfs_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct drm_minor *minor = rdev->ddev->primary; +struct drm_minor *minor =rdev_to_drm (rdev)->primary;struct dentry *root = minor->debugfs_root; debugfs_create_file("radeon_vram", 0444, root, rdev,
drivers/gpu/drm/radeon/rs400.c +3 -3
@@ -379,7 +379,7 @@ DEFINE_SHOW_ATTRIBUTE(rs400_debugfs_gart_info);static void rs400_debugfs_pcie_gart_info_init (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("rs400_gart_info" ,0444 , root, rdev, &rs400_debugfs_gart_info_fops);
@@ -474,7 +474,7 @@ int rs400_resume(struct radeon_device *rdev) RREG32(R_0007C0_CP_STAT)); }/* post */ -radeon_combios_asic_init (rdev->ddev); +radeon_combios_asic_init (rdev_to_drm (rdev));/* Resume clock after posting */ r300_clock_startup (rdev);/* Initialize surface registers */
@@ -552,7 +552,7 @@ int rs400_init(struct radeon_device *rdev)return -EINVAL ;/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize memory controller */ rs400_mc_init (rdev);/* Fence driver */
drivers/gpu/drm/radeon/rs600.c +7 -7
@@ -321,7 +321,7 @@ void rs600_pm_misc(struct radeon_device *rdev)void rs600_pm_prepare (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -339,7 +339,7 @@ void rs600_pm_prepare(struct radeon_device *rdev)void rs600_pm_finish (struct radeon_device *rdev) { -struct drm_device *ddev = rdev->ddev; +struct drm_device *ddev =rdev_to_drm (rdev);struct drm_crtc *crtc;struct radeon_crtc *radeon_crtc;u32 tmp;
@@ -408,7 +408,7 @@ void rs600_hpd_set_polarity(struct radeon_device *rdev,void rs600_hpd_init (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned enable =0 ;
@@ -435,7 +435,7 @@ void rs600_hpd_init(struct radeon_device *rdev)void rs600_hpd_fini (struct radeon_device *rdev) { -struct drm_device *dev = rdev->ddev; +struct drm_device *dev =rdev_to_drm (rdev);struct drm_connector *connector;unsigned disable =0 ;
@@ -797,7 +797,7 @@ int rs600_irq_process(struct radeon_device *rdev)/* Vertical blank interrupts */ if (G_007EDC_LB_D1_VBLANK_INTERRUPT (rdev->irq.stat_regs.r500.disp_int)) {if (rdev->irq.crtc_vblank_int[0 ]) { -drm_handle_vblank (rdev->ddev,0 ); +drm_handle_vblank (rdev_to_drm (rdev),0 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -806,7 +806,7 @@ int rs600_irq_process(struct radeon_device *rdev) }if (G_007EDC_LB_D2_VBLANK_INTERRUPT (rdev->irq.stat_regs.r500.disp_int)) {if (rdev->irq.crtc_vblank_int[1 ]) { -drm_handle_vblank (rdev->ddev,1 ); +drm_handle_vblank (rdev_to_drm (rdev),1 ); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -1133,7 +1133,7 @@ int rs600_init(struct radeon_device *rdev)return -EINVAL ;/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize memory controller */ rs600_mc_init (rdev);r100_debugfs_rbbm_init (rdev);
drivers/gpu/drm/radeon/rs690.c +1 -1
@@ -845,7 +845,7 @@ int rs690_init(struct radeon_device *rdev)return -EINVAL ;/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize memory controller */ rs690_mc_init (rdev);rv515_debugfs (rdev);
drivers/gpu/drm/radeon/rv515.c +2 -2
@@ -255,7 +255,7 @@ DEFINE_SHOW_ATTRIBUTE(rv515_debugfs_ga_info);void rv515_debugfs (struct radeon_device *rdev) {#if defined(CONFIG_DEBUG_FS ) -struct dentry *root = rdev->ddev->primary->debugfs_root; +struct dentry *root =rdev_to_drm (rdev)->primary->debugfs_root;debugfs_create_file ("rv515_pipes_info" ,0444 , root, rdev, &rv515_debugfs_pipes_info_fops);
@@ -636,7 +636,7 @@ int rv515_init(struct radeon_device *rdev)if (radeon_boot_test_post_card (rdev) == false)return -EINVAL ;/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* initialize AGP */ if (rdev->flags &RADEON_IS_AGP ) { r =radeon_agp_init (rdev);
drivers/gpu/drm/radeon/rv770.c +1 -1
@@ -1935,7 +1935,7 @@ int rv770_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);/* initialize AGP */
drivers/gpu/drm/radeon/si.c +2 -2
@@ -6277,7 +6277,7 @@ int si_irq_process(struct radeon_device *rdev) event_name ="vblank" ;if (rdev->irq.crtc_vblank_int[crtc_idx]) { -drm_handle_vblank (rdev->ddev, crtc_idx); +drm_handle_vblank (rdev_to_drm (rdev), crtc_idx); rdev->pm.vblank_sync = true;wake_up (&rdev->irq.vblank_queue); }
@@ -6839,7 +6839,7 @@ int si_init(struct radeon_device *rdev)/* Initialize surface registers */ radeon_surface_init (rdev);/* Initialize clocks */ -radeon_get_clock_info (rdev->ddev); +radeon_get_clock_info (rdev_to_drm (rdev));/* Fence driver */ radeon_fence_driver_init (rdev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 616/817 drm/radeon: Fix spurious unplug event on radeon HDMI
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven 'Steve' Kendall <[email protected]>
[ Upstream commit 7037bb04265ef05c6ffad56d884b0df76f57b095 ]
On several HP models (tested on HP 3125 and HP Probook 455 G2), spurious unplug events are emitted upon login on Chrome OS. This is likely due to the way Chrome OS restarts graphics upon login, so it's possible it's an issue on other distributions but not as common, though I haven't reproduced the issue elsewhere.
Use logic from an earlier version of the merged change (see link below) which iterates over connectors and finds matching encoders, rather than the other way around. Also fixes an issue with screen mirroring on Chrome OS. I've deployed this patch on Fedora and did not observe any regression on these devices.
--- drivers/gpu/drm/radeon/radeon_audio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_audio.c +8 -4
@@ -760,16 +760,20 @@ static int radeon_audio_component_get_eld(struct device *kdev, int port,if (!rdev->audio.enabled || !rdev->mode_info.mode_config_initialized)return 0 ; -list_for_each_entry (encoder, &rdev_to_drm (rdev)->mode_config.encoder_list, head) { +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +const struct drm_connector_helper_funcs *connector_funcs = + connector->helper_private; + encoder = connector_funcs->best_encoder (connector); + +if (!encoder) +continue ; +if (!radeon_encoder_is_digital (encoder))continue ; radeon_encoder =to_radeon_encoder (encoder); dig = radeon_encoder->enc_priv;if (!dig->pin || dig->pin->id != port)continue ; - connector =radeon_get_connector_for_encoder (encoder); -if (!connector) -continue ; *enabled = true; ret =drm_eld_size (connector->eld);memcpy (buf, connector->eld,min (max_bytes, ret));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 617/817 drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zicheng Qu <[email protected]>
[ Upstream commit 6a057072ddd127255350357dd880903e8fa23f36 ]
This commit addresses a null pointer dereference issue in dcn20_program_pipe(). Previously, commit 8e4ed3cf1642 ("drm/amd/display:
Add null check for pipe_ctx->plane_state in dcn20_program_pipe") partially fixed the null pointer dereference issue. However, in dcn20_update_dchubp_dpp(), the variable pipe_ctx is passed in, and plane_state is accessed again through pipe_ctx. Multiple if statements directly call attributes of plane_state, leading to potential null pointer dereference issues. This patch adds necessary null checks to ensure stability.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +3 -3
@@ -1922,9 +1922,9 @@ static void dcn20_program_pipe( dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->hubp_regs.det_size); } -if (pipe_ctx->update_flags.raw || - (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.raw) || - pipe_ctx->stream->update_flags.raw) +if (pipe_ctx->plane_state && (pipe_ctx->update_flags.raw || + pipe_ctx->plane_state->update_flags.raw || + pipe_ctx->stream->update_flags.raw))dcn20_update_dchubp_dpp (dc, pipe_ctx, context); if (pipe_ctx->update_flags.bits.enable ||
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 618/817 drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zicheng Qu <[email protected]>
[ Upstream commit 2bc96c95070571c6c824e0d4c7783bee25a37876 ]
This commit addresses a null pointer dereference issue in hwss_setup_dpp(). The issue could occur when pipe_ctx->plane_state is null. The fix adds a check to ensure pipe_ctx->plane_state is not null before accessing. This prevents a null pointer dereference.
--- drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +3 -0
@@ -881,6 +881,9 @@ void hwss_setup_dpp(union block_sequence_params *params)struct dpp *dpp = pipe_ctx->plane_res.dpp;struct dc_plane_state *plane_state = pipe_ctx->plane_state; +if (!plane_state) +return ; +if (dpp && dpp->funcs->dpp_setup) {// program the input csc dpp->funcs->dpp_setup(dpp,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 619/817 ASoC: imx-audmix: Add NULL check in imx_audmix_probe
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit e038f43edaf0083f6aa7c9415d86cf28dfd152f9 ]
devm_kasprintf() can return a NULL pointer on failure,but this returned value in imx_audmix_probe() is not checked. Add NULL check in imx_audmix_probe(), to handle kernel NULL pointer dereference error.
--- sound/soc/fsl/imx-audmix.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/fsl/imx-audmix.c +3 -0
@@ -275,6 +275,9 @@ static int imx_audmix_probe(struct platform_device *pdev)/* Add AUDMIX Backend */ be_name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"audmix-%d" , i); +if (!be_name) +return -ENOMEM ; + priv->dai[num_dai + i].cpus = &dlc[1 ]; priv->dai[num_dai + i].codecs = &snd_soc_dummy_dlc;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 620/817 drm/xe/ufence: Wake up waiters after setting ufence->signalled
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nirmoy Das <[email protected]>
[ Upstream commit 37a1cf288e4538eb39b38dbc745fe0da7ae53d94 ]
If a previous ufence is not signalled, vm_bind will return -EBUSY. Delaying the modification of ufence->signalled can cause issues if the UMD reuses the same ufence so update ufence->signalled before waking up waiters.
--- drivers/gpu/drm/xe/xe_sync.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_sync.c +5 -1
@@ -85,8 +85,12 @@ static void user_fence_worker(struct work_struct *w)mmput (ufence->mm); } -wake_up_all (&ufence->xe->ufence_wq); +/* +* Wake up waiters only after updating the ufence state, allowing the UMD +* to safely reuse the same ufence without encountering -EBUSY errors. +*/ WRITE_ONCE (ufence->signalled,1 ); +wake_up_all (&ufence->xe->ufence_wq);user_fence_put (ufence); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 621/817 apparmor: fix Do simple duplicate message elimination
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: chao liu <[email protected]>
[ Upstream commit 9b897132424fe76bf6c61f22f9cf12af7f1d1e6a ]
Multiple profiles shared 'ent->caps', so some logs missed.
--- security/apparmor/capability.c | 2 ++ 1 file changed, 2 insertions(+)
security/apparmor/capability.c +2 -0
@@ -96,6 +96,8 @@ static int audit_caps(struct apparmor_audit_data *ad, struct aa_profile *profilereturn error; }else {aa_put_profile (ent->profile); +if (profile != ent->profile) +cap_clear (ent->caps); ent->profile =aa_get_profile (profile);cap_raise (ent->caps, cap); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 622/817 ALSA: core: Fix possible NULL dereference caused by kunit_kzalloc()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zichen Xie <[email protected]>
[ Upstream commit 9ad467a2b2716d4ed12f003b041aa6c776a13ff5 ]
kunit_kzalloc() may return a NULL pointer, dereferencing it without NULL check may lead to NULL dereference.
Add NULL checks for all the kunit_kzalloc() in sound_kunit.c
--- sound/core/sound_kunit.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/core/sound_kunit.c +11 -0
@@ -172,6 +172,7 @@ static void test_format_fill_silence(struct kunit *test)u32 i, j; buffer =kunit_kzalloc (test,SILENCE_BUFFER_SIZE ,GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, buffer);for (i =0 ; i <ARRAY_SIZE (buf_samples); i++) {for (j =0 ; j <ARRAY_SIZE (valid_fmt); j++)
@@ -208,8 +209,12 @@ static void test_playback_avail(struct kunit *test)struct snd_pcm_runtime *r =kunit_kzalloc (test,sizeof (*r),GFP_KERNEL );u32 i; +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r); + r->status =kunit_kzalloc (test,sizeof (*r->status),GFP_KERNEL ); r->control =kunit_kzalloc (test,sizeof (*r->control),GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r->status); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r->control);for (i =0 ; i <ARRAY_SIZE (p_avail_data); i++) { r->buffer_size = p_avail_data[i].buffer_size;
@@ -232,8 +237,12 @@ static void test_capture_avail(struct kunit *test)struct snd_pcm_runtime *r =kunit_kzalloc (test,sizeof (*r),GFP_KERNEL );u32 i; +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r); + r->status =kunit_kzalloc (test,sizeof (*r->status),GFP_KERNEL ); r->control =kunit_kzalloc (test,sizeof (*r->control),GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r->status); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, r->control);for (i =0 ; i <ARRAY_SIZE (c_avail_data); i++) { r->buffer_size = c_avail_data[i].buffer_size;
@@ -247,6 +256,7 @@ static void test_capture_avail(struct kunit *test)static void test_card_set_id (struct kunit *test) {struct snd_card *card =kunit_kzalloc (test,sizeof (*card),GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, card);snd_card_set_id (card,VALID_NAME );KUNIT_EXPECT_STREQ (test, card->id,VALID_NAME );
@@ -280,6 +290,7 @@ static void test_pcm_format_name(struct kunit *test)static void test_card_add_component (struct kunit *test) {struct snd_card *card =kunit_kzalloc (test,sizeof (*card),GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, card);snd_component_add (card,TEST_FIRST_COMPONENT );KUNIT_ASSERT_STREQ (test, card->components,TEST_FIRST_COMPONENT );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 623/817 ASoC: amd: yc: Fix for enabling DMIC on acp6x via _DSD entry
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Venkata Prasad Potturu <[email protected]>
[ Upstream commit 4095cf872084ecfdfdb0e681f3e9ff9745acfa75 ]
Add condition check to register ACP PDM sound card by reading _WOV acpi entry.
--- sound/soc/amd/yc/acp6x-mach.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
sound/soc/amd/yc/acp6x-mach.c +17 -1
@@ -537,8 +537,14 @@ static int acp6x_probe(struct platform_device *pdev)struct acp6x_pdm *machine =NULL ;struct snd_soc_card *card;struct acpi_device *adev; +acpi_handle handle; +acpi_integer dmic_status;int ret; +bool is_dmic_enable, wov_en; +/* IF WOV entry not found, enable dmic based on AcpDmicConnected entry*/ + is_dmic_enable = false; + wov_en = true;/* check the parent device's firmware node has _DSD or not */ adev =ACPI_COMPANION (pdev->dev.parent);if (adev) {
@@ -546,9 +552,19 @@ static int acp6x_probe(struct platform_device *pdev)if (!acpi_dev_get_property (adev,"AcpDmicConnected" ,ACPI_TYPE_INTEGER , &obj) && obj->integer.value ==1 ) -platform_set_drvdata (pdev, &acp6x_card); + is_dmic_enable = true; } + handle =ACPI_HANDLE (pdev->dev.parent); + ret =acpi_evaluate_integer (handle,"_WOV" ,NULL , &dmic_status); +if (!ACPI_FAILURE (ret)) + wov_en = dmic_status; + +if (is_dmic_enable && wov_en) +platform_set_drvdata (pdev, &acp6x_card); +else +return 0 ; +/* check for any DMI overrides */ dmi_id =dmi_first_match (yc_acp_quirk_table);if (dmi_id)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 624/817 ASoC: mediatek: Check num_codecs is not zero to avoid panic during probe
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nícolas F. R. A. Prado <[email protected]>
[ Upstream commit 2f2020327cc8561d7c520d2f2d9acea84fa7b3a3 ]
Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()"), COMP_DUMMY() became an array with zero length, and only gets populated with the dummy struct after the card is registered. Since the sound card driver's probe happens before the card registration, accessing any of the members of a dummy component during probe will result in undefined behavior.
This can be observed in the mt8188 and mt8195 machine sound drivers. By omitting a dai link subnode in the sound card's node in the Devicetree, the default uninitialized dummy codec is used, and when its dai_name pointer gets passed to strcmp() it results in a null pointer dereference and a kernel panic.
In addition to that, set_card_codec_info() in the generic helpers file, mtk-soundcard-driver.c, will populate a dai link with a dummy codec when a dai link node is present in DT but with no codec property.
The result is that at probe time, a dummy codec can either be uninitialized with num_codecs = 0, or be an initialized dummy codec, with num_codecs = 1 and dai_name = "snd-soc-dummy-dai". In order to accommodate for both situations, check that num_codecs is not zero before accessing the codecs' fields but still check for the codec's dai name against "snd-soc-dummy-dai" as needed.
While at it, also drop the check that dai_name is not null in the mt8192 driver, introduced in commit 4d4e1b6319e5 ("ASoC: mediatek: mt8192:
Check existence of dai_name before dereferencing"), as it is actually redundant given the preceding num_codecs != 0 check.
--- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 9 +++++++-- sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 4 ++-- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 9 +++++++-- 3 files changed, 16 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8188/mt8188-mt6359.c +7 -2
@@ -1279,10 +1279,12 @@ static int mt8188_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data,for_each_card_prelinks (card, i, dai_link) {if (strcmp (dai_link->name,"DPTX_BE" ) ==0 ) { -if (strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) +if (dai_link->num_codecs && +strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) dai_link->init = mt8188_dptx_codec_init; }else if (strcmp (dai_link->name,"ETDM3_OUT_BE" ) ==0 ) { -if (strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) +if (dai_link->num_codecs && +strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) dai_link->init = mt8188_hdmi_codec_init; }else if (strcmp (dai_link->name,"DL_SRC_BE" ) ==0 ||strcmp (dai_link->name,"UL_SRC_BE" ) ==0 ) {
@@ -1294,6 +1296,9 @@ static int mt8188_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data, strcmp(dai_link->name, "ETDM2_OUT_BE") == 0 || strcmp(dai_link->name, "ETDM1_IN_BE") == 0 || strcmp(dai_link->name, "ETDM2_IN_BE") == 0) { +if (!dai_link->num_codecs) +continue ; +if (!strcmp (dai_link->codecs->dai_name,MAX98390_CODEC_DAI )) {/* * The TDM protocol settings with fixed 4 slots are defined in
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +2 -2
@@ -1099,7 +1099,7 @@ static int mt8192_mt6359_legacy_probe(struct mtk_soc_card_data *soc_card_data) dai_link->ignore =0 ; } -if (dai_link->num_codecs && dai_link->codecs[0 ].dai_name && +if (dai_link->num_codecs &&strcmp (dai_link->codecs[0 ].dai_name,RT1015_CODEC_DAI ) ==0 ) dai_link->ops = &mt8192_rt1015_i2s_ops; }
@@ -1129,7 +1129,7 @@ static int mt8192_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data,int i;for_each_card_prelinks (card, i, dai_link) -if (dai_link->num_codecs && dai_link->codecs[0 ].dai_name && +if (dai_link->num_codecs &&strcmp (dai_link->codecs[0 ].dai_name,RT1015_CODEC_DAI ) ==0 ) dai_link->ops = &mt8192_rt1015_i2s_ops; }
sound/soc/mediatek/mt8195/mt8195-mt6359.c +7 -2
@@ -1380,10 +1380,12 @@ static int mt8195_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data,for_each_card_prelinks (card, i, dai_link) {if (strcmp (dai_link->name,"DPTX_BE" ) ==0 ) { -if (strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) +if (dai_link->num_codecs && +strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) dai_link->init = mt8195_dptx_codec_init; }else if (strcmp (dai_link->name,"ETDM3_OUT_BE" ) ==0 ) { -if (strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) +if (dai_link->num_codecs && +strcmp (dai_link->codecs->dai_name,"snd-soc-dummy-dai" )) dai_link->init = mt8195_hdmi_codec_init; } else if (strcmp(dai_link->name, "DL_SRC_BE") == 0 || strcmp(dai_link->name, "UL_SRC1_BE") == 0 ||
@@ -1396,6 +1398,9 @@ static int mt8195_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data, strcmp(dai_link->name, "ETDM2_OUT_BE") == 0 || strcmp(dai_link->name, "ETDM1_IN_BE") == 0 || strcmp(dai_link->name, "ETDM2_IN_BE") == 0) { +if (!dai_link->num_codecs) +continue ; +if (!strcmp (dai_link->codecs->dai_name,MAX98390_CODEC_DAI )) {if (!(codec_init &MAX98390_CODEC_INIT )) { dai_link->init = mt8195_max98390_init;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 625/817 s390/pci: Fix potential double remove of hotplug slot
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Schnelle <[email protected]>
[ Upstream commit c4a585e952ca403a370586d3f16e8331a7564901 ]
In commit 6ee600bfbe0f ("s390/pci: remove hotplug slot when releasing the device") the zpci_exit_slot() was moved from zpci_device_reserved() to zpci_release_device() with the intention of keeping the hotplug slot around until the device is actually removed.
Now zpci_release_device() is only called once all references are dropped. Since the zPCI subsystem only drops its reference once the device is in the reserved state it follows that zpci_release_device() must only deal with devices in the reserved state. Despite that it contains code to tear down from both configured and standby state. For the standby case this already includes the removal of the hotplug slot so would cause a double removal if a device was ever removed in either configured or standby state.
Instead of causing a potential double removal in a case that should never happen explicitly WARN_ON() if a device in non-reserved state is released and get rid of the dead code cases.
--- arch/s390/pci/pci.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-)
arch/s390/pci/pci.c +9 -25
@@ -918,10 +918,8 @@ void zpci_device_reserved(struct zpci_dev *zdev)void zpci_release_device (struct kref *kref) { struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref); -int ret; -if (zdev->has_hp_slot) -zpci_exit_slot (zdev); +WARN_ON (zdev->state !=ZPCI_FN_STATE_RESERVED );if (zdev->zbus->bus)zpci_bus_remove_device (zdev, false);
@@ -929,28 +927,14 @@ void zpci_release_device(struct kref *kref)if (zdev_enabled (zdev))zpci_disable_device (zdev); -switch (zdev->state) { -case ZPCI_FN_STATE_CONFIGURED : - ret =sclp_pci_deconfigure (zdev->fid); -zpci_dbg (3 ,"deconf fid:%x, rc:%d\n" , zdev->fid, ret); - fallthrough; -case ZPCI_FN_STATE_STANDBY : -if (zdev->has_hp_slot) -zpci_exit_slot (zdev); -spin_lock (&zpci_list_lock); -list_del (&zdev->entry); -spin_unlock (&zpci_list_lock); -zpci_dbg (3 ,"rsv fid:%x\n" , zdev->fid); - fallthrough; -case ZPCI_FN_STATE_RESERVED : -if (zdev->has_resources) -zpci_cleanup_bus_resources (zdev); -zpci_bus_device_unregister (zdev); -zpci_destroy_iommu (zdev); - fallthrough; -default : -break ; - } +if (zdev->has_hp_slot) +zpci_exit_slot (zdev); + +if (zdev->has_resources) +zpci_cleanup_bus_resources (zdev); + +zpci_bus_device_unregister (zdev); +zpci_destroy_iommu (zdev);zpci_dbg (3 ,"rem fid:%x\n" , zdev->fid);kfree_rcu (zdev, rcu); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 626/817 net_sched: sch_fq: dont follow the fast path if Tx is behind now
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
commit 122aba8c80618eca904490b1733af27fb8f07528 upstream.
Recent kernels cause a lot of TCP retransmissions
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 2.24 GBytes 19.2 Gbits/sec 2767 442 KBytes
[ 5] 1.00-2.00 sec 2.23 GBytes 19.1 Gbits/sec 2312 350 KBytes
^^^^Replacing the qdisc with pfifo makes retransmissions go away.
It appears that a flow may have a delayed packet with a very near Tx time. Later, we may get busy processing Rx and the target Tx time will pass, but we won't service Tx since the CPU is busy with Rx. If Rx sees an ACK and we try to push more data for the delayed flow we may fastpath the skb, not realizing that there are already "ready to send" packets for this flow sitting in the qdisc.
Don't trust the fastpath if we are "behind" according to the projected Tx time for next flow waiting in the Qdisc. Because we consider anything within the offload window to be okay for fastpath we must consider the entire offload window as "now".
Qdisc config:
qdisc fq 8001: dev eth0 parent 1234:1 limit 10000p flow_limit 100p \
buckets 32768 orphan_mask 1023 bands 3 \
priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 \
weights 589824 196608 65536 quantum 3028b initial_quantum 15140b \
low_rate_threshold 550Kbit \
refill_delay 40ms timer_slack 10us horizon 10s horizon_drop
For iperf this change seems to do fine, the reordering is gone. The fastpath still gets used most of the time:
gc 0 highprio 0 fastpath 142614 throttled 418309 latency 19.1us
xx_behind 2731
where "xx_behind" counts how many times we hit the new "return false".
--- net/sched/sch_fq.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sched/sch_fq.c +6 -0
@@ -331,6 +331,12 @@ static bool fq_fastpath_check(const stru*/ if (q->internal.qlen >=8 )return false; + +/* Ordering invariants fall apart if some delayed flows +* are ready but we haven't serviced them, yet. +*/ +if (q->time_next_delayed_flow <= now) +return false; } sk = skb->sk;
Greg Kroah-Hartman
maintainerPATCH 627/817 xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiu-ji Chen <[email protected]>
commit afc545da381ba0c651b2658966ac737032676f01 upstream.
This patch fixes an issue in the function xenbus_dev_probe(). In the xenbus_dev_probe() function, within the if (err) branch at line 313, the program incorrectly returns err directly without releasing the resources allocated by err = drv->probe(dev, id). As the return value is non-zero, the upper layers assume the processing logic has failed. However, the probe operation was performed earlier without a corresponding remove operation. Since the probe actually allocates resources, failing to perform the remove operation could lead to problems.
To fix this issue, we followed the resource release logic of the xenbus_dev_remove() function by adding a new block fail_remove before the fail_put block. After entering the branch if (err) at line 313, the function will use a goto statement to jump to the fail_remove block, ensuring that the previously acquired resources are correctly released, thus preventing the reference count leak.
This bug was identified by an experimental static analysis tool developed by our team. The tool specializes in analyzing reference count operations and detecting potential issues where resources are not properly managed. In this case, the tool flagged the missing release operation as a potential problem, which led to the development of this patch.
Message-ID: <[email protected]>
--- drivers/xen/xenbus/xenbus_probe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_probe.c +7 -1
@@ -313,7 +313,7 @@ int xenbus_dev_probe(struct device *_devif (err) {dev_warn (&dev->dev,"watch_otherend on %s failed.\n" , dev->nodename); -return err; + goto fail_remove; } dev->spurious_threshold =1 ;
@@ -322,6 +322,12 @@ int xenbus_dev_probe(struct device *_dev dev->nodename);return 0 ; +fail_remove: +if (drv->remove) { +down (&dev->reclaim_sem); + drv->remove (dev); +up (&dev->reclaim_sem); + } fail_put:module_put (drv->driver.owner); fail:
Greg Kroah-Hartman
maintainerPATCH 628/817 ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Sevens <[email protected]>
commit b909df18ce2a998afef81d58bbd1a05dc0788c40 upstream.
A bogus device can provide a bNumConfigurations value that exceeds the initial value used in usb_get_configuration for allocating dev->config.
This can lead to out-of-bounds accesses later, e.g. in usb_destroy_configuration.
--- sound/usb/quirks.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
sound/usb/quirks.c +21 -6
@@ -555,6 +555,7 @@ int snd_usb_create_quirk(struct snd_usb_static int snd_usb_extigy_boot_quirk (struct usb_device *dev,struct usb_interface *intf) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err; if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
@@ -566,10 +567,14 @@ static int snd_usb_extigy_boot_quirk(strif (err <0 )dev_dbg (&dev->dev,"error sending boot message: %d\n" , err); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )dev_dbg (&dev->dev,"error usb_reset_configuration: %d\n" , err);
@@ -901,6 +906,7 @@ static void mbox2_setup_48_24_magic(strustatic int snd_usb_mbox2_boot_quirk (struct usb_device *dev) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err;u8 bootresponse[0x12 ];int fwsize;
@@ -936,10 +942,14 @@ static int snd_usb_mbox2_boot_quirk(strudev_dbg (&dev->dev,"device initialised!\n" ); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )
@@ -1249,6 +1259,7 @@ static void mbox3_setup_defaults(structstatic int snd_usb_mbox3_boot_quirk (struct usb_device *dev) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err;int descriptor_size;
@@ -1262,10 +1273,14 @@ static int snd_usb_mbox3_boot_quirk(strudev_dbg (&dev->dev,"MBOX3: device initialised!\n" ); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"MBOX3: error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"MBOX3: error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )
Greg Kroah-Hartman
maintainerPATCH 629/817 ALSA: usb-audio: Fix out of bounds reads when finding clock sources
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit a3dd4d63eeb452cfb064a13862fb376ab108f6a6 upstream.
The current USB-audio driver code doesn't check bLength of each descriptor at traversing for clock descriptors. That is, when a device provides a bogus descriptor with a shorter bLength, the driver might hit out-of-bounds reads.
For addressing it, this patch adds sanity checks to the validator functions for the clock descriptor traversal. When the descriptor length is shorter than expected, it's skipped in the loop.
For the clock source and clock multiplier descriptors, we can just check bLength against the sizeof() of each descriptor type. OTOH, the clock selector descriptor of UAC2 and UAC3 has an array of bNrInPins elements and two more fields at its tail, hence those have to be checked in addition to the sizeof() check.
--- sound/usb/clock.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
sound/usb/clock.c +23 -1
@@ -36,6 +36,12 @@ union uac23_clock_multiplier_desc {struct uac_clock_multiplier_descriptor v3; }; +/* check whether the descriptor bLength has the minimal length */ +#define DESC_LENGTH_CHECK (p, proto) \ + ((proto) == UAC_VERSION_3 ? \ + ((p)->v3.bLength >= sizeof((p)->v3)) : \ + ((p)->v2.bLength >= sizeof((p)->v2))) +#define GET_VAL (p, proto, field) \ ((proto) == UAC_VERSION_3 ? (p)->v3.field : (p)->v2.field)
@@ -58,6 +64,8 @@ static bool validate_clock_source(void * {union uac23_clock_source_desc *cs = p; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false;return GET_VAL (cs, proto, bClockID) == id; }
@@ -65,13 +73,27 @@ static bool validate_clock_selector(void {union uac23_clock_selector_desc *cs = p; -return GET_VAL (cs, proto, bClockID) == id; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false; +if (GET_VAL (cs, proto, bClockID) != id) +return false; +/* additional length check for baCSourceID array (in bNrInPins size) +* and two more fields (which sizes depend on the protocol) +*/ +if (proto ==UAC_VERSION_3 ) +return cs->v3.bLength >=sizeof (cs->v3) + cs->v3.bNrInPins + +4 /* bmControls */ +2 /* wCSelectorDescrStr */ ; +else +return cs->v2.bLength >=sizeof (cs->v2) + cs->v2.bNrInPins + +1 /* bmControls */ +1 /* iClockSelector */ ; }static bool validate_clock_multiplier (void *p,int id,int proto) {union uac23_clock_multiplier_desc *cs = p; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false;return GET_VAL (cs, proto, bClockID) == id; }
Greg Kroah-Hartman
maintainerPATCH 630/817 usb: ehci-spear: fix call balance of sehci clk handling routines
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitalii Mordan <[email protected]>
commit 40c974826734836402abfd44efbf04f63a2cc1c1 upstream.
If the clock sehci->clk was not enabled in spear_ehci_hcd_drv_probe, it should not be disabled in any path.
Conversely, if it was enabled in spear_ehci_hcd_drv_probe, it must be disabled in all error paths to ensure proper cleanup.
Found by Linux Verification Center (linuxtesting.org) with Klever.
--- drivers/usb/host/ehci-spear.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/host/ehci-spear.c +4 -3
@@ -105,7 +105,9 @@ static int spear_ehci_hcd_drv_probe(stru/* registers start at offset 0x0 */ hcd_to_ehci (hcd)->caps = hcd->regs; -clk_prepare_enable (sehci->clk); + retval =clk_prepare_enable (sehci->clk); +if (retval) + goto err_put_hcd; retval =usb_add_hcd (hcd, irq,IRQF_SHARED );if (retval) goto err_stop_ehci;
@@ -130,8 +132,7 @@ static void spear_ehci_hcd_drv_remove(stusb_remove_hcd (hcd); -if (sehci->clk) -clk_disable_unprepare (sehci->clk); +clk_disable_unprepare (sehci->clk);usb_put_hcd (hcd); }
Greg Kroah-Hartman
maintainerPATCH 631/817 usb: typec: ucsi: glink: fix off-by-one in connector_status
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
commit 4a22918810980897393fa1776ea3877e4baf8cca upstream.
UCSI connector's indices start from 1 up to 3, PMIC_GLINK_MAX_PORTS. Correct the condition in the pmic_glink_ucsi_connector_status() callback, fixing Type-C orientation reporting for the third USB-C connector.
--- drivers/usb/typec/ucsi/ucsi_glink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_glink.c +1 -1
@@ -185,7 +185,7 @@ static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)struct pmic_glink_ucsi *ucsi =ucsi_get_drvdata (con->ucsi);int orientation; -if (con->num >=PMIC_GLINK_MAX_PORTS || +if (con->num >PMIC_GLINK_MAX_PORTS || !ucsi->port_orientation[con->num -1 ])return ;
Signature · 1 line
2.47.1
Greg Kroah-Hartman
maintainerPATCH 632/817 dm-cache: fix warnings about duplicate slab caches
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 346dbf1b1345476a6524512892cceb931bee3039 upstream.
The commit 4c39529663b9 adds a warning about duplicate cache names if CONFIG_DEBUG_VM is selected. These warnings are triggered by the dm-cache code.
The dm-cache code allocates a slab cache for each device. This commit changes it to allocate just one slab cache in the module init function.
--- drivers/md/dm-cache-background-tracker.c | 25 ++++++------------------- drivers/md/dm-cache-background-tracker.h | 8 ++++++++ drivers/md/dm-cache-target.c | 25 ++++++++++++++++++++----- 3 files changed, 34 insertions(+), 24 deletions(-)
drivers/md/dm-cache-background-tracker.c +6 -19
@@ -11,12 +11,6 @@#define DM_MSG_PREFIX "dm-background-tracker" -struct bt_work { -struct list_head list; -struct rb_node node; -struct policy_work work; -}; -struct background_tracker {unsigned int max_work;atomic_t pending_promotes;
@@ -26,10 +20,10 @@ struct background_tracker {struct list_head issued;struct list_head queued;struct rb_root pending; - -struct kmem_cache *work_cache; }; +struct kmem_cache *btracker_work_cache =NULL ; +struct background_tracker *btracker_create (unsigned int max_work) {struct background_tracker *b =kmalloc (sizeof (*b),GFP_KERNEL );
@@ -48,12 +42,6 @@ struct background_tracker *btracker_creaINIT_LIST_HEAD (&b->queued); b->pending =RB_ROOT ; - b->work_cache =KMEM_CACHE (bt_work,0 ); -if (!b->work_cache) { -DMERR ("couldn't create mempool for background work items" ); -kfree (b); - b =NULL ; - }return b; }
@@ -66,10 +54,9 @@ void btracker_destroy(struct background_BUG_ON (!list_empty (&b->issued)); list_for_each_entry_safe (w, tmp, &b->queued, list) {list_del (&w->list); -kmem_cache_free (b->work_cache, w); +kmem_cache_free (btracker_work_cache, w); } -kmem_cache_destroy (b->work_cache);kfree (b); }EXPORT_SYMBOL_GPL (btracker_destroy);
@@ -180,7 +167,7 @@ static struct bt_work *alloc_work(structif (max_work_reached (b))return NULL ; -return kmem_cache_alloc (b->work_cache,GFP_NOWAIT ); +return kmem_cache_alloc (btracker_work_cache,GFP_NOWAIT ); } int btracker_queue(struct background_tracker *b,
@@ -203,7 +190,7 @@ int btracker_queue(struct background_tra* There was a race, we'll just ignore this second * bit of work for the same oblock. */ -kmem_cache_free (b->work_cache, w); +kmem_cache_free (btracker_work_cache, w);return -EINVAL ; }
@@ -244,7 +231,7 @@ void btracker_complete(struct backgroundupdate_stats (b, &w->work,-1 );rb_erase (&w->node, &b->pending);list_del (&w->list); -kmem_cache_free (b->work_cache, w); +kmem_cache_free (btracker_work_cache, w); }EXPORT_SYMBOL_GPL (btracker_complete);
drivers/md/dm-cache-background-tracker.h +8 -0
@@ -26,6 +26,14 @@* protected with a spinlock. */ +struct bt_work { +struct list_head list; +struct rb_node node; +struct policy_work work; +}; + +extern struct kmem_cache *btracker_work_cache; +struct background_work ;struct background_tracker ;
drivers/md/dm-cache-target.c +20 -5
@@ -10,6 +10,7 @@#include "dm-bio-record.h" #include "dm-cache-metadata.h" #include "dm-io-tracker.h" +#include "dm-cache-background-tracker.h" #include <linux/dm-io.h> #include <linux/dm-kcopyd.h>
@@ -2263,7 +2264,7 @@ static int parse_cache_args(struct cache/*----------------------------------------------------------------*/ -static struct kmem_cache *migration_cache; +static struct kmem_cache *migration_cache =NULL ;#define NOT_CORE_OPTION 1
@@ -3449,22 +3450,36 @@ static int __init dm_cache_init(void)int r; migration_cache =KMEM_CACHE (dm_cache_migration,0 ); -if (!migration_cache) -return -ENOMEM ; +if (!migration_cache) { + r = -ENOMEM ; + goto err; + } + + btracker_work_cache =kmem_cache_create ("dm_cache_bt_work" , +sizeof (struct bt_work ), __alignof__(struct bt_work ),0 ,NULL ); +if (!btracker_work_cache) { + r = -ENOMEM ; + goto err; + } r =dm_register_target (&cache_target);if (r) { -kmem_cache_destroy (migration_cache); -return r; + goto err; }return 0 ; + +err: +kmem_cache_destroy (migration_cache); +kmem_cache_destroy (btracker_work_cache); +return r; } static void __exit dm_cache_exit(void) {dm_unregister_target (&cache_target);kmem_cache_destroy (migration_cache); +kmem_cache_destroy (btracker_work_cache); }module_init (dm_cache_init);
Greg Kroah-Hartman
maintainerPATCH 633/817 dm-bufio: fix warnings about duplicate slab caches
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 42964e4b5e3ac95090bdd23ed7da2a941ccd902c upstream.
The commit 4c39529663b9 adds a warning about duplicate cache names if CONFIG_DEBUG_VM is selected. These warnings are triggered by the dm-bufio code. The dm-bufio code allocates a slab cache with each client. It is not possible to preallocate the caches in the module init function because the size of auxiliary per-buffer data is not known at this point.
So, this commit changes dm-bufio so that it appends a unique atomic value to the cache name, to avoid the warnings.
--- drivers/md/dm-bufio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/md/dm-bufio.c +8 -4
@@ -2474,7 +2474,8 @@ struct dm_bufio_client *dm_bufio_client_int r;unsigned int num_locks;struct dm_bufio_client *c; -char slab_name[27 ]; +char slab_name[64 ]; +static atomic_t seqno =ATOMIC_INIT (0 );if (!block_size || block_size & ((1 <<SECTOR_SHIFT ) -1 )) {DMERR ("%s: block size not specified or is not multiple of 512b" , __func__);
@@ -2525,7 +2526,8 @@ struct dm_bufio_client *dm_bufio_client_ (block_size < PAGE_SIZE || !is_power_of_2(block_size))) {unsigned int align =min (1U <<__ffs (block_size), (unsigned int )PAGE_SIZE ); -snprintf (slab_name,sizeof (slab_name),"dm_bufio_cache-%u" , block_size); +snprintf (slab_name,sizeof (slab_name),"dm_bufio_cache-%u-%u" , + block_size,atomic_inc_return (&seqno)); c->slab_cache =kmem_cache_create (slab_name, block_size, align,SLAB_RECLAIM_ACCOUNT ,NULL );if (!c->slab_cache) {
@@ -2534,9 +2536,11 @@ struct dm_bufio_client *dm_bufio_client_ } }if (aux_size) -snprintf (slab_name,sizeof (slab_name),"dm_bufio_buffer-%u" , aux_size); +snprintf (slab_name,sizeof (slab_name),"dm_bufio_buffer-%u-%u" , + aux_size,atomic_inc_return (&seqno));else -snprintf (slab_name,sizeof (slab_name),"dm_bufio_buffer" ); +snprintf (slab_name,sizeof (slab_name),"dm_bufio_buffer-%u" , +atomic_inc_return (&seqno)); c->slab_buffer =kmem_cache_create (slab_name,sizeof (struct dm_buffer ) + aux_size,0 ,SLAB_RECLAIM_ACCOUNT ,NULL );if (!c->slab_buffer) {
Greg Kroah-Hartman
maintainerPATCH 634/817 ASoC: Intel: sst: Fix used of uninitialized ctx to log an error
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit c1895ba181e560144601fafe46aeedbafdf4dbc4 upstream.
Fix the new "LPE0F28" code path using the uninitialized ctx variable to log an error.
--- sound/soc/intel/atom/sst/sst_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/atom/sst/sst_acpi.c +1 -1
@@ -308,7 +308,7 @@ static int sst_acpi_probe(struct platfor rsrc =platform_get_resource (pdev,IORESOURCE_MEM , pdata->res_info->acpi_lpe_res_index);if (!rsrc) { -dev_err (ctx->dev,"Invalid SHIM base\n" ); +dev_err (dev,"Invalid SHIM base\n" );return -EIO ; } rsrc->start -= pdata->res_info->shim_offset;
Greg Kroah-Hartman
maintainerPATCH 635/817 soc: qcom: socinfo: fix revision check in qcom_socinfo_probe()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manikanta Mylavarapu <[email protected]>
commit 128fdbf36cddc2a901c4889ba1c89fa9f2643f2c upstream.
In success case, the revision holds a non-null pointer. The current logic incorrectly returns an error for a non-null pointer, whereas it should return an error for a null pointer.
The socinfo driver for IPQ9574 and IPQ5332 is currently broken, resulting in the following error message
qcom-socinfo qcom-socinfo: probe with driver qcom-socinfo failed with error -12
Add a null check for the revision to ensure it returns an error only in failure case (null pointer).
--- drivers/soc/qcom/socinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/socinfo.c +1 -1
@@ -782,7 +782,7 @@ static int qcom_socinfo_probe(struct pla qs->attr.revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%u.%u" ,SOCINFO_MAJOR (le32_to_cpu (info->ver)),SOCINFO_MINOR (le32_to_cpu (info->ver))); -if (!qs->attr.soc_id || qs->attr.revision) +if (!qs->attr.soc_id || !qs->attr.revision)return -ENOMEM ;if (offsetof(struct socinfo , serial_num) <= item_size) {
Greg Kroah-Hartman
maintainerPATCH 636/817 irqdomain: Always associate interrupts for legacy domains
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
commit 24d02c4e53e2f02da16b2ae8a1bc92553110ca25 upstream.
The unification of irq_domain_create_legacy() missed the fact that interrupts must be associated even when the Linux interrupt number provided in the first_irq argument is 0.
This breaks all call sites of irq_domain_create_legacy() which supply 0 as the first_irq argument.
Enforce the association for legacy domains in __irq_domain_instantiate() to cure this.
[ tglx: Massaged it slightly. ]
Signed-off-by Matti Vaittinen <[email protected]>
--- kernel/irq/irqdomain.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
kernel/irq/irqdomain.c +10 -6
@@ -300,7 +300,7 @@ static void irq_domain_instantiate_descs }static struct irq_domain *__irq_domain_instantiate (const struct irq_domain_info *info, -bool cond_alloc_descs) +bool cond_alloc_descs,bool force_associate) {struct irq_domain *domain;int err;
@@ -336,8 +336,12 @@ static struct irq_domain *__irq_domain_iif (cond_alloc_descs && info->virq_base >0 )irq_domain_instantiate_descs (info); -/* Legacy interrupt domains have a fixed Linux interrupt number */ -if (info->virq_base >0 ) { +/* +* Legacy interrupt domains have a fixed Linux interrupt number +* associated. Other interrupt domains can request association by +* providing a Linux interrupt number > 0. +*/ +if (force_associate || info->virq_base >0 ) {irq_domain_associate_many (domain, info->virq_base, info->hwirq_base, info->size - info->hwirq_base); }
@@ -360,7 +364,7 @@ err_domain_free:*/ struct irq_domain *irq_domain_instantiate (const struct irq_domain_info *info) { -return __irq_domain_instantiate (info, false); +return __irq_domain_instantiate (info, false, false); }EXPORT_SYMBOL_GPL (irq_domain_instantiate);
@@ -464,7 +468,7 @@ struct irq_domain *irq_domain_create_sim .ops = ops, .host_data = host_data, }; -struct irq_domain *domain =__irq_domain_instantiate (&info, true); +struct irq_domain *domain =__irq_domain_instantiate (&info, true, false);return IS_ERR (domain) ?NULL : domain; }
@@ -513,7 +517,7 @@ struct irq_domain *irq_domain_create_leg .ops = ops, .host_data = host_data, }; -struct irq_domain *domain =irq_domain_instantiate (&info); +struct irq_domain *domain =__irq_domain_instantiate (&info, false, true);return IS_ERR (domain) ?NULL : domain; }
Greg Kroah-Hartman
maintainerPATCH 637/817 ext4: supress data-race warnings in ext4_free_inodes_{count,set}()
In reply to Greg Kroah-Hartman6.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 902cc179c931a033cd7f4242353aa2733bf8524c upstream.
find_group_other() and find_group_orlov() read *_lo, *_hi with ext4_free_inodes_count without additional locking. This can cause data-race warning, but since the lock is held for most writes and free inodes value is generally not a problem even if it is incorrect, it is more appropriate to use READ_ONCE()/WRITE_ONCE() than to add locking.
==================================================================
BUG: KCSAN: data-race in ext4_free_inodes_count / ext4_free_inodes_set
write to 0xffff88810404300e of 2 bytes by task 6254 on cpu 1:
ext4_free_inodes_set+0x1f/0x80 fs/ext4/super.c:405 __ext4_new_inode+0x15ca/0x2200 fs/ext4/ialloc.c:1216 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4615 do_symlinkat+0xe3/0x340 fs/namei.c:4641 __do_sys_symlinkat fs/namei.c:4657 [inline] __se_sys_symlinkat fs/namei.c:4654 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4654 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
read to 0xffff88810404300e of 2 bytes by task 6257 on cpu 0:
ext4_free_inodes_count+0x1c/0x80 fs/ext4/super.c:349 find_group_other fs/ext4/ialloc.c:594 [inline] __ext4_new_inode+0x6ec/0x2200 fs/ext4/ialloc.c:1017 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4615 do_symlinkat+0xe3/0x340 fs/namei.c:4641 __do_sys_symlinkat fs/namei.c:4657 [inline] __se_sys_symlinkat fs/namei.c:4654 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4654 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- fs/ext4/super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ext4/super.c +4 -4
@@ -353,9 +353,9 @@ __u32 ext4_free_group_clusters(struct su__u32 ext4_free_inodes_count (struct super_block *sb,struct ext4_group_desc *bg) { -return le16_to_cpu (bg->bg_free_inodes_count_lo) | +return le16_to_cpu (READ_ONCE (bg->bg_free_inodes_count_lo)) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (__u32 )le16_to_cpu (bg->bg_free_inodes_count_hi) <<16 :0 ); + (__u32 )le16_to_cpu (READ_ONCE (bg->bg_free_inodes_count_hi)) <<16 :0 ); } __u32 ext4_used_dirs_count(struct super_block *sb,
@@ -409,9 +409,9 @@ void ext4_free_group_clusters_set(structvoid ext4_free_inodes_set (struct super_block *sb,struct ext4_group_desc *bg,__u32 count) { - bg->bg_free_inodes_count_lo =cpu_to_le16 ((__u16 )count); +WRITE_ONCE (bg->bg_free_inodes_count_lo,cpu_to_le16 ((__u16 )count));if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) - bg->bg_free_inodes_count_hi =cpu_to_le16 (count >>16 ); +WRITE_ONCE (bg->bg_free_inodes_count_hi,cpu_to_le16 (count >>16 )); } void ext4_used_dirs_set(struct super_block *sb,