5.10.80-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 448/575 usb: dwc2: drd: fix dwc2_drd_role_sw_set when clock could be disabled
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 8d387f61b0240854e81450c261beb775065bad5d ]
In case of USB_DR_MODE_PERIPHERAL, the OTG clock is disabled at the end of the probe (it is not the case if USB_DR_MODE_HOST or USB_DR_MODE_OTG). The clock is then enabled on udc_start.
If dwc2_drd_role_sw_set is called before udc_start (it is the case if the usb cable is plugged at boot), GOTGCTL and GUSBCFG registers cannot be read/written, so session cannot be overridden.
To avoid this case, check the ll_hw_enabled value and enable the clock if it is available, and disable it after the override.
--- drivers/usb/dwc2/drd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/usb/dwc2/drd.c +18 -0
@@ -7,6 +7,7 @@* Author(s): Amelie Delaunay <[email protected]> */ +#include <linux/clk.h> #include <linux/iopoll.h> #include <linux/platform_device.h> #include <linux/usb/role.h>
@@ -86,6 +87,20 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role) }#endif +/* +* In case of USB_DR_MODE_PERIPHERAL, clock is disabled at the end of +* the probe and enabled on udc_start. +* If role-switch set is called before the udc_start, we need to enable +* the clock to read/write GOTGCTL and GUSBCFG registers to override +* mode and sessions. It is the case if cable is plugged at boot. +*/ +if (!hsotg->ll_hw_enabled && hsotg->clk) { +int ret =clk_prepare_enable (hsotg->clk); + +if (ret) +return ret; + } +spin_lock_irqsave (&hsotg->lock, flags);if (role ==USB_ROLE_HOST ) {
@@ -110,6 +125,9 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)/* This will raise a Connector ID Status Change Interrupt */ dwc2_force_mode (hsotg, role ==USB_ROLE_HOST ); +if (!hsotg->ll_hw_enabled && hsotg->clk) +clk_disable_unprepare (hsotg->clk); +dev_dbg (hsotg->dev,"%s-session valid\n" , role ==USB_ROLE_NONE ?"No" : role ==USB_ROLE_HOST ?"A" :"B" );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 449/575 usb: dwc2: drd: reset current session before setting the new one
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 1ad707f559f7cb12c64f3d7cb37f0b1ea27c1058 ]
If role is changed without the "none" step, A- and B- valid session could be set at the same time. It is an issue.
This patch resets A-session if role switch sets B-session, and resets B-session if role switch sets A-session.
Then, it is possible to change the role without the "none" step.
--- drivers/usb/dwc2/drd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/dwc2/drd.c +2 -0
@@ -40,6 +40,7 @@ static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid) (!valid && !(gotgctl & GOTGCTL_ASESVLD)))return -EALREADY ; + gotgctl &= ~GOTGCTL_BVALOVAL ;if (valid) gotgctl |=GOTGCTL_AVALOVAL |GOTGCTL_VBVALOVAL ;else
@@ -58,6 +59,7 @@ static int dwc2_ovr_bvalid(struct dwc2_hsotg *hsotg, bool valid) (!valid && !(gotgctl & GOTGCTL_BSESVLD)))return -EALREADY ; + gotgctl &= ~GOTGCTL_AVALOVAL ;if (valid) gotgctl |=GOTGCTL_BVALOVAL |GOTGCTL_VBVALOVAL ;else
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 450/575 firmware: qcom_scm: Fix error retval in __qcom_scm_is_call_available()
In reply to Greg Kroah-HartmanFrom: Guru Das Srinagesh <[email protected]>
[ Upstream commit 38212b2a8a6fc4c3a6fa99d7445b833bedc9a67c ]
Since __qcom_scm_is_call_available() returns bool, have it return false instead of -EINVAL if an invalid SMC convention is detected.
This fixes the Smatch static checker warning:
drivers/firmware/qcom_scm.c:255 __qcom_scm_is_call_available() warn: signedness bug returning '(-22)'
--- drivers/firmware/qcom_scm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/qcom_scm.c +1 -1
@@ -252,7 +252,7 @@ static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,break ;default :pr_err ("Unknown SMC convention being used\n" ); -return -EINVAL ; +return false; } ret =qcom_scm_call (dev, &desc, &res);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 451/575 soc: qcom: apr: Add of_node_put() before return
In reply to Greg Kroah-HartmanFrom: Wan Jiabing <[email protected]>
[ Upstream commit 72f1aa6205d84337b90b065f602a8fe190821781 ]
Fix following coccicheck warning:
./drivers/soc/qcom/apr.c:485:1-23: WARNING: Function for_each_child_of_node should have of_node_put() before return
Early exits from for_each_child_of_node should decrement the node reference counter.
--- drivers/soc/qcom/apr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/qcom/apr.c +2 -0
@@ -323,12 +323,14 @@ static int of_apr_add_pd_lookups(struct device *dev) 1, &service_path);if (ret <0 ) {dev_err (dev,"pdr service path missing: %d\n" , ret); +of_node_put (node);return ret; } pds =pdr_add_lookup (apr->pdr, service_name, service_path);if (IS_ERR (pds) &&PTR_ERR (pds) != -EALREADY ) {dev_err (dev,"pdr add lookup failed: %ld\n" ,PTR_ERR (pds)); +of_node_put (node);return PTR_ERR (pds); } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 452/575 pinctrl: equilibrium: Fix function addition in multiple groups
In reply to Greg Kroah-HartmanFrom: Rahul Tanwar <[email protected]>
[ Upstream commit 53b3947ddb7f309d1f611f8dc9bfd6ea9d699907 ]
Ignore the same function with multiple groups.
Fix a typo in error print.
--- drivers/pinctrl/pinctrl-equilibrium.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-equilibrium.c +6 -1
@@ -674,6 +674,11 @@ static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata)return ret;for (i =0 ; i < nr_funcs; i++) { + +/* Ignore the same function with multiple groups */ +if (funcs[i].name ==NULL ) +continue ; + ret = pinmux_generic_add_function(drvdata->pctl_dev, funcs[i].name, funcs[i].groups,
@@ -805,7 +810,7 @@ static int pinctrl_reg(struct eqbr_pinctrl_drv_data *drvdata) ret =eqbr_build_functions (drvdata);if (ret) { -dev_err (dev,"Failed to build groups\n" ); +dev_err (dev,"Failed to build functions\n" );return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 453/575 phy: qcom-qusb2: Fix a memory leak on probe
In reply to Greg Kroah-HartmanFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit bf7ffcd0069d30e2e7ba2b827f08c89f471cd1f3 ]
On success nvmem_cell_read() returns a pointer to a dynamically allocated buffer, and therefore it shall be freed after usage.
The issue is reported by kmemleak:
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff3b3803e4b280 (size 128):
comm "kworker/u16:1", pid 107, jiffies 4294892861 (age 94.120s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000007739afdc>] __kmalloc+0x27c/0x41c
[<0000000071c0fbf8>] nvmem_cell_read+0x40/0xe0
[<00000000e803ef1f>] qusb2_phy_init+0x258/0x5bc
[<00000000fc81fcfa>] phy_init+0x70/0x110
[<00000000e3d48a57>] dwc3_core_soft_reset+0x4c/0x234
[<0000000027d1dbd4>] dwc3_core_init+0x68/0x990
[<000000001965faf9>] dwc3_probe+0x4f4/0x730
[<000000002f7617ca>] platform_probe+0x74/0xf0
[<00000000a2576cac>] really_probe+0xc4/0x470
[<00000000bc77f2c5>] __driver_probe_device+0x11c/0x190
[<00000000130db71f>] driver_probe_device+0x48/0x110
[<0000000019f36c2b>] __device_attach_driver+0xa4/0x140
[<00000000e5812ff7>] bus_for_each_drv+0x84/0xe0
[<00000000f4bac574>] __device_attach+0xe4/0x1c0
[<00000000d3beb631>] device_initial_probe+0x20/0x30
[<000000008019b9db>] bus_probe_device+0xa4/0xb0--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-qusb2.c +10 -6
@@ -474,7 +474,7 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy) {struct device *dev = &qphy->phy->dev;const struct qusb2_phy_cfg *cfg = qphy->cfg; -u8 *val; +u8 *val, hstx_trim;/* efuse register is optional */ if (!qphy->cell)
@@ -488,7 +488,13 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)* set while configuring the phy. */ val =nvmem_cell_read (qphy->cell,NULL ); -if (IS_ERR (val) || !val[0 ]) { +if (IS_ERR (val)) { +dev_dbg (dev,"failed to read a valid hs-tx trim value\n" ); +return ; + } + hstx_trim = val[0 ]; +kfree (val); +if (!hstx_trim) {dev_dbg (dev,"failed to read a valid hs-tx trim value\n" );return ; }
@@ -496,12 +502,10 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)/* Fused TUNE1/2 value is the higher nibble only */ if (cfg->update_tune1_with_efuse)qusb2_write_mask (qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE1 ], - val[0 ] <<HSTX_TRIM_SHIFT , -HSTX_TRIM_MASK ); + hstx_trim <<HSTX_TRIM_SHIFT ,HSTX_TRIM_MASK );else qusb2_write_mask (qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE2 ], - val[0 ] <<HSTX_TRIM_SHIFT , -HSTX_TRIM_MASK ); + hstx_trim <<HSTX_TRIM_SHIFT ,HSTX_TRIM_MASK ); } static int qusb2_phy_set_mode(struct phy *phy,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 454/575 phy: ti: gmii-sel: check of_get_address() for failure
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 8d55027f4e2c04146a75fb63371ab96ccc887f2c ]
Smatch complains that if of_get_address() returns NULL, then "size" isn't initialized. Also it would lead to an Oops.
--- drivers/phy/ti/phy-gmii-sel.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/ti/phy-gmii-sel.c +2 -0
@@ -320,6 +320,8 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)u64 size; offset =of_get_address (dev->of_node,0 , &size,NULL ); +if (!offset) +return -EINVAL ; priv->num_ports = size /sizeof (u32);if (!priv->num_ports)return -EINVAL ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 455/575 phy: qcom-snps: Correct the FSEL_MASK
In reply to Greg Kroah-HartmanFrom: Sandeep Maheswaram <[email protected]>
[ Upstream commit b475bf0ec40a2b13fb32ef62f5706576d5858460 ]
The FSEL_MASK which selects the refclock is defined incorrectly. It should be [4:6] not [5:7]. Due to this incorrect definition, the BIT(7) in USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 is reset which keeps PHY analog blocks ON during suspend.
Fix this issue by correctly defining the FSEL_MASK.
--- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +1 -1
@@ -33,7 +33,7 @@#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 (0x54)#define RETENABLEN BIT(3) -#define FSEL_MASK GENMASK(7, 5) +#define FSEL_MASK GENMASK(6, 4)#define FSEL_DEFAULT (0x3 << 4)#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 (0x58)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 456/575 serial: xilinx_uartps: Fix race condition causing stuck TX
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit 88b20f84f0fe47409342669caf3e58a3fc64c316 ]
xilinx_uartps .start_tx() clears TXEMPTY when enabling TXEMPTY to avoid any previous TXEVENT event asserting the UART interrupt. This clear operation is done immediately after filling the TX FIFO.
However, if the bytes inserted by cdns_uart_handle_tx() are consumed by the UART before the TXEMPTY is cleared, the clear operation eats the new TXEMPTY event as well, causing cdns_uart_isr() to never receive the TXEMPTY event. If there are bytes still queued in circbuf, TX will get stuck as they will never get transferred to FIFO (unless new bytes are queued to circbuf in which case .start_tx() is called again).
While the racy missed TXEMPTY occurs fairly often with short data sequences (e.g. write 1 byte), in those cases circbuf is usually empty so no action on TXEMPTY would have been needed anyway. On the other hand, longer data sequences make the race much more unlikely as UART takes longer to consume the TX FIFO. Therefore it is rare for this race to cause visible issues in general.
Fix the race by clearing the TXEMPTY bit in ISR *before* filling the FIFO.
The TXEMPTY bit in ISR will only get asserted at the exact moment the TX FIFO *becomes* empty, so clearing the bit before filling FIFO does not cause an extra immediate assertion even if the FIFO is initially empty.
This is hard to reproduce directly on a normal system, but inserting e.g. udelay(200) after cdns_uart_handle_tx(port), setting 4000000 baud, and then running "dd if=/dev/zero bs=128 of=/dev/ttyPS0 count=50" reliably reproduces the issue on my ZynqMP test system unless this fix is applied.
--- drivers/tty/serial/xilinx_uartps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +2 -1
@@ -601,9 +601,10 @@ static void cdns_uart_start_tx(struct uart_port *port)if (uart_circ_empty (&port->state->xmit))return ; +writel (CDNS_UART_IXR_TXEMPTY , port->membase +CDNS_UART_ISR ); +cdns_uart_handle_tx (port); -writel (CDNS_UART_IXR_TXEMPTY , port->membase +CDNS_UART_ISR );/* Enable the TX Empty interrupt */ writel (CDNS_UART_IXR_TXEMPTY , port->membase +CDNS_UART_IER ); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 457/575 clk: at91: sam9x60-pll: use DIV_ROUND_CLOSEST_ULL
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit f12d028b743bb6136da60b17228a1b6162886444 ]
Use DIV_ROUND_CLOSEST_ULL() to avoid any inconsistency b/w the rate computed in sam9x60_frac_pll_recalc_rate() and the one computed in sam9x60_frac_pll_compute_mul_frac().
--- drivers/clk/at91/clk-sam9x60-pll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/at91/clk-sam9x60-pll.c +2 -2
@@ -71,8 +71,8 @@ static unsigned long sam9x60_frac_pll_recalc_rate(struct clk_hw *hw,struct sam9x60_pll_core *core =to_sam9x60_pll_core (hw);struct sam9x60_frac *frac =to_sam9x60_frac (core); -return (parent_rate * (frac->mul +1 ) + - ((u64 )parent_rate * frac->frac >>22 )); +return parent_rate * (frac->mul +1 ) + +DIV_ROUND_CLOSEST_ULL ((u64 )parent_rate * frac->frac, (1 <<22 )); }static int sam9x60_frac_pll_prepare (struct clk_hw *hw)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 458/575 HID: u2fzero: clarify error check and length calculations
In reply to Greg Kroah-HartmanFrom: Andrej Shadura <[email protected]>
[ Upstream commit b7abf78b7a6c4a29a6e0ba0bb883fe44a2f3d693 ]
The previous commit fixed handling of incomplete packets but broke error
handling: offsetof returns an unsigned value (size_t), but when compared against the signed return value, the return value is interpreted as if it were unsigned, so negative return values are never less than the offset.
To make the code easier to read, calculate the minimal packet length once and separately, and assign it to a signed int variable to eliminate unsigned math and the need for type casts. It then becomes immediately obvious how the actual data length is calculated and why the return value cannot be less than the minimal length.
--- drivers/hid/hid-u2fzero.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hid/hid-u2fzero.c +5 -3
@@ -191,6 +191,8 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,struct u2f_hid_msg resp;int ret;size_t actual_length; +/* valid packets must have a correct header */ + int min_length = offsetof(struct u2f_hid_msg, init.data);if (!dev->present) {hid_dbg (dev->hdev,"device not present" );
@@ -200,12 +202,12 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data, ret =u2fzero_recv (dev, &req, &resp);/* ignore errors or packets without data */ - if (ret < offsetof(struct u2f_hid_msg, init.data)) +if (ret < min_length)return 0 ;/* only take the minimum amount of data it is safe to take */ - actual_length =min3 ((size_t )ret - offsetof(struct u2f_hid_msg , - init.data), U2F_HID_MSG_LEN(resp), max); + actual_length =min3 ((size_t )ret - min_length, +U2F_HID_MSG_LEN (resp), max);memcpy (data, resp.init.data, actual_length);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 459/575 HID: u2fzero: properly handle timeouts in usb_submit_urb
In reply to Greg Kroah-HartmanFrom: Andrej Shadura <[email protected]>
[ Upstream commit 43775e62c4b784f44a159e13ba80e6146a42d502 ]
The wait_for_completion_timeout function returns 0 if timed out or a positive value if completed. Hence, "less than zero" comparison always misses timeouts and doesn't kill the URB as it should, leading to re-sending it while it is active.
--- drivers/hid/hid-u2fzero.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-u2fzero.c +1 -1
@@ -132,7 +132,7 @@ static int u2fzero_recv(struct u2fzero_device *dev, ret = (wait_for_completion_timeout ( &ctx.done,msecs_to_jiffies (USB_CTRL_SET_TIMEOUT ))); -if (ret <0 ) { +if (ret ==0 ) {usb_kill_urb (dev->urb);hid_err (hdev,"urb submission timed out" ); }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 460/575 powerpc/44x/fsp2: add missing of_node_put
In reply to Greg Kroah-HartmanFrom: Bixuan Cui <[email protected]>
[ Upstream commit 290fe8aa69ef5c51c778c0bb33f8ef0181c769f5 ]
Early exits from for_each_compatible_node() should decrement the node reference counter. Reported by Coccinelle:
./arch/powerpc/platforms/44x/fsp2.c:206:1-25: WARNING: Function "for_each_compatible_node" should have of_node_put() before return around line 218.
--- arch/powerpc/platforms/44x/fsp2.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/platforms/44x/fsp2.c +2 -0
@@ -208,6 +208,7 @@ static void node_irq_request(const char *compat, irq_handler_t errirq_handler)if (irq ==NO_IRQ ) {pr_err ("device tree node %pOFn is missing a interrupt" , np); +of_node_put (np);return ; }
@@ -215,6 +216,7 @@ static void node_irq_request(const char *compat, irq_handler_t errirq_handler)if (rc) {pr_err ("fsp_of_probe: request_irq failed: np=%pOF rc=%d" , np, rc); +of_node_put (np);return ; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 461/575 ASoC: cs42l42: Disable regulators if probe fails
In reply to Greg Kroah-HartmanFrom: Lucas Tanure <[email protected]>
[ Upstream commit 1abca8e1c77bd9c5f5c0bed21c5b075b6852a178 ]
In case of cs42l42_i2c_probe() fail, the regulators were left enabled.
--- sound/soc/codecs/cs42l42.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/codecs/cs42l42.c +7 -5
@@ -1781,8 +1781,10 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,/* Reset the Device */ cs42l42->reset_gpio =devm_gpiod_get_optional (&i2c_client->dev,"reset" ,GPIOD_OUT_LOW ); -if (IS_ERR (cs42l42->reset_gpio)) -return PTR_ERR (cs42l42->reset_gpio); +if (IS_ERR (cs42l42->reset_gpio)) { + ret =PTR_ERR (cs42l42->reset_gpio); + goto err_disable; + }if (cs42l42->reset_gpio) {dev_dbg (&i2c_client->dev,"Found reset GPIO\n" );
@@ -1817,13 +1819,13 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,dev_err (&i2c_client->dev,"CS42L42 Device ID (%X). Expected %X\n" , devid,CS42L42_CHIP_ID ); -return ret; + goto err_disable; } ret =regmap_read (cs42l42->regmap,CS42L42_REVID , ®);if (ret <0 ) {dev_err (&i2c_client->dev,"Get Revision ID failed\n" ); -return ret; + goto err_disable; } dev_info(&i2c_client->dev,
@@ -1849,7 +1851,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,if (i2c_client->dev.of_node) { ret =cs42l42_handle_device_data (i2c_client, cs42l42);if (ret !=0 ) -return ret; + goto err_disable; }/* Setup headset detection */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 462/575 ASoC: cs42l42: Use device_property API instead of of_property
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit ab78322a0dc8e5e472ff66ac7e18c94acc17587f ]
Use the device_property APIs so that the code will work on devicetree and ACPI systems.
--- sound/soc/codecs/cs42l42.c | 60 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 36 deletions(-)
sound/soc/codecs/cs42l42.c +24 -36
@@ -20,10 +20,9 @@#include <linux/regmap.h> #include <linux/slab.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/gpio/consumer.h> -#include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/of_device.h> #include <sound/core.h> #include <sound/pcm.h>
@@ -1554,17 +1553,15 @@ static const unsigned int threshold_defaults[] = { CS42L42_HS_DET_LEVEL_1 }; -static int cs42l42_handle_device_data (struct i2c_client *i2c_client, +static int cs42l42_handle_device_data (struct device *dev,struct cs42l42_private *cs42l42) { -struct device_node *np = i2c_client->dev.of_node;unsigned int val; -unsigned int thresholds[CS42L42_NUM_BIASES ]; +u32 thresholds[CS42L42_NUM_BIASES ];int ret;int i; - ret =of_property_read_u32 (np,"cirrus,ts-inv" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-inv" , &val);if (!ret) {switch (val) {case CS42L42_TS_INV_EN :
@@ -1572,7 +1569,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_inv = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-inv DT value %d\n" , val); cs42l42->ts_inv =CS42L42_TS_INV_DIS ;
@@ -1585,8 +1582,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_TS_INV_MASK , (cs42l42->ts_inv << CS42L42_TS_INV_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,ts-dbnc-rise" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-dbnc-rise" , &val);if (!ret) {switch (val) {case CS42L42_TS_DBNCE_0 :
@@ -1600,7 +1596,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_dbnc_rise = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-dbnc-rise DT value %d\n" , val); cs42l42->ts_dbnc_rise =CS42L42_TS_DBNCE_1000 ;
@@ -1614,8 +1610,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, (cs42l42->ts_dbnc_rise << CS42L42_TS_RISE_DBNCE_TIME_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,ts-dbnc-fall" , &val); - + ret =device_property_read_u32 (dev,"cirrus,ts-dbnc-fall" , &val);if (!ret) {switch (val) {case CS42L42_TS_DBNCE_0 :
@@ -1629,7 +1624,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->ts_dbnc_fall = val;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,ts-dbnc-fall DT value %d\n" , val); cs42l42->ts_dbnc_fall =CS42L42_TS_DBNCE_0 ;
@@ -1643,13 +1638,12 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, (cs42l42->ts_dbnc_fall << CS42L42_TS_FALL_DBNCE_TIME_SHIFT)); - ret =of_property_read_u32 (np,"cirrus,btn-det-init-dbnce" , &val); - + ret =device_property_read_u32 (dev,"cirrus,btn-det-init-dbnce" , &val);if (!ret) {if (val <=CS42L42_BTN_DET_INIT_DBNCE_MAX ) cs42l42->btn_det_init_dbnce = val;else { -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,btn-det-init-dbnce DT value %d\n" , val); cs42l42->btn_det_init_dbnce =
@@ -1660,14 +1654,13 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_BTN_DET_INIT_DBNCE_DEFAULT ; } - ret =of_property_read_u32 (np,"cirrus,btn-det-event-dbnce" , &val); - + ret =device_property_read_u32 (dev,"cirrus,btn-det-event-dbnce" , &val);if (!ret) {if (val <=CS42L42_BTN_DET_EVENT_DBNCE_MAX ) cs42l42->btn_det_event_dbnce = val;else { -dev_err (&i2c_client->dev, -"Wrong cirrus,btn-det-event-dbnce DT value %d\n" , val); +dev_err (dev, +"Wrong cirrus,btn-det-event-dbnce DT value %d\n" , val); cs42l42->btn_det_event_dbnce =CS42L42_BTN_DET_EVENT_DBNCE_DEFAULT ; }
@@ -1676,19 +1669,17 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client,CS42L42_BTN_DET_EVENT_DBNCE_DEFAULT ; } - ret =of_property_read_u32_array (np,"cirrus,bias-lvls" , - (u32 *)thresholds,CS42L42_NUM_BIASES ); - + ret =device_property_read_u32_array (dev,"cirrus,bias-lvls" , + thresholds,ARRAY_SIZE (thresholds));if (!ret) {for (i =0 ; i <CS42L42_NUM_BIASES ; i++) {if (thresholds[i] <=CS42L42_HS_DET_LEVEL_MAX ) cs42l42->bias_thresholds[i] = thresholds[i];else { -dev_err (&i2c_client->dev, -"Wrong cirrus,bias-lvls[%d] DT value %d\n" , i, +dev_err (dev, +"Wrong cirrus,bias-lvls[%d] DT value %d\n" , i, thresholds[i]); - cs42l42->bias_thresholds[i] = - threshold_defaults[i]; + cs42l42->bias_thresholds[i] = threshold_defaults[i]; } } }else {
@@ -1696,8 +1687,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->bias_thresholds[i] = threshold_defaults[i]; } - ret =of_property_read_u32 (np,"cirrus,hs-bias-ramp-rate" , &val); - + ret =device_property_read_u32 (dev,"cirrus,hs-bias-ramp-rate" , &val);if (!ret) {switch (val) {case CS42L42_HSBIAS_RAMP_FAST_RISE_SLOW_FALL :
@@ -1717,7 +1707,7 @@ static int cs42l42_handle_device_data(struct i2c_client *i2c_client, cs42l42->hs_bias_ramp_time =CS42L42_HSBIAS_RAMP_TIME3 ;break ;default : -dev_err (&i2c_client->dev, +dev_err (dev,"Wrong cirrus,hs-bias-ramp-rate DT value %d\n" , val); cs42l42->hs_bias_ramp_rate =CS42L42_HSBIAS_RAMP_SLOW ;
@@ -1848,11 +1838,9 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, (1 <<CS42L42_ADC_PDN_SHIFT ) | (0 << CS42L42_PDN_ALL_SHIFT)); -if (i2c_client->dev.of_node) { - ret =cs42l42_handle_device_data (i2c_client, cs42l42); -if (ret !=0 ) - goto err_disable; - } + ret =cs42l42_handle_device_data (&i2c_client->dev, cs42l42); +if (ret !=0 ) + goto err_disable;/* Setup headset detection */ cs42l42_setup_hs_type_detect (cs42l42);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 463/575 ASoC: cs42l42: Correct configuring of switch inversion from ts-inv
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit 778a0cbef5fb76bf506f84938517bb77e7a1c478 ]
The setting from the cirrus,ts-inv property should be applied to the TIP_SENSE_INV bit, as this is the one that actually affects the jack detect block. The TS_INV bit only swaps the meaning of the PLUG and UNPLUG interrupts and should always be 1 for the interrupts to have the normal meaning.
Due to some misunderstanding the driver had been implemented to configure the TS_INV bit based on the jack switch polarity. This made the interrupts behave the correct way around, but left the jack detect block, button detect and analogue circuits always interpreting an open switch as unplugged.
The signal chain inside the codec is:
SENSE pin -> TIP_SENSE_INV -> TS_INV -> (invert) -> interrupts
|
v
Jack detect,
button detect and
analog control
As the TIP_SENSE_INV already performs the necessary inversion the TS_INV bit never needs to change. It must always be 1 to yield the expected interrupt behaviour.
Some extra confusion has arisen because of the additional invert in the interrupt path, meaning that a value applied to the TS_INV bit produces the opposite effect of applying it to the TIP_SENSE_INV bit. The ts-inv property has therefore always had the opposite effect to what might be expected (0 = inverted, 1 = not inverted). To maintain the meaning of the ts-inv property it must be inverted when applied to TIP_SENSE_INV.
--- sound/soc/codecs/cs42l42.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sound/soc/codecs/cs42l42.c +4 -5
@@ -1529,12 +1529,15 @@ static void cs42l42_setup_hs_type_detect(struct cs42l42_private *cs42l42) (1 << CS42L42_HS_CLAMP_DISABLE_SHIFT));/* Enable the tip sense circuit */ +regmap_update_bits (cs42l42->regmap,CS42L42_TSENSE_CTL , +CS42L42_TS_INV_MASK ,CS42L42_TS_INV_MASK ); +regmap_update_bits (cs42l42->regmap,CS42L42_TIPSENSE_CTL ,CS42L42_TIP_SENSE_CTRL_MASK |CS42L42_TIP_SENSE_INV_MASK |CS42L42_TIP_SENSE_DEBOUNCE_MASK , (3 <<CS42L42_TIP_SENSE_CTRL_SHIFT ) | - (0 <<CS42L42_TIP_SENSE_INV_SHIFT ) | + (!cs42l42->ts_inv <<CS42L42_TIP_SENSE_INV_SHIFT ) | (2 <<CS42L42_TIP_SENSE_DEBOUNCE_SHIFT ));/* Save the initial status of the tip sense */
@@ -1578,10 +1581,6 @@ static int cs42l42_handle_device_data(struct device *dev, cs42l42->ts_inv =CS42L42_TS_INV_DIS ; } -regmap_update_bits (cs42l42->regmap,CS42L42_TSENSE_CTL , -CS42L42_TS_INV_MASK , - (cs42l42->ts_inv <<CS42L42_TS_INV_SHIFT )); - ret =device_property_read_u32 (dev,"cirrus,ts-dbnc-rise" , &val);if (!ret) {switch (val) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 464/575 virtio_ring: check desc == NULL when using indirect with packed
In reply to Greg Kroah-HartmanFrom: Xuan Zhuo <[email protected]>
[ Upstream commit fc6d70f40b3d0b3219e2026d05be0409695f620d ]
When using indirect with packed, we don't check for allocation failures. This patch checks that and fall back on direct.
--- drivers/virtio/virtio_ring.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/virtio/virtio_ring.c +11 -3
@@ -992,6 +992,8 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq, head = vq->packed.next_avail_idx; desc =alloc_indirect_packed (total_sg, gfp); +if (!desc) +return -ENOMEM ;if (unlikely (vq->vq.num_free <1 )) {pr_debug ("Can't add buf len 1 - avail = 0\n" );
@@ -1103,6 +1105,7 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,unsigned int i, n, c, descs_used, err_idx;__le16 head_flags, flags;u16 head, id, prev, curr, avail_used_flags; +int err;START_USE (vq);
@@ -1118,9 +1121,14 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,BUG_ON (total_sg ==0 ); -if (virtqueue_use_indirect (_vq, total_sg)) -return virtqueue_add_indirect_packed (vq, sgs, total_sg, - out_sgs, in_sgs, data, gfp); +if (virtqueue_use_indirect (_vq, total_sg)) { + err =virtqueue_add_indirect_packed (vq, sgs, total_sg, out_sgs, + in_sgs, data, gfp); +if (err != -ENOMEM ) +return err; + +/* fall back on direct */ + } head = vq->packed.next_avail_idx; avail_used_flags = vq->packed.avail_used_flags;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 465/575 mips: cm: Convert to bitfield API to fix out-of-bounds access
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 18b8f5b6fc53d097cadb94a93d8d6566ba88e389 ]
mips_cm_error_report() extracts the cause and other cause from the error register using shifts. This works fine for the former, as it is stored in the top bits, and the shift will thus remove all non-related bits. However, the latter is stored in the bottom bits, hence thus needs masking to get rid of non-related bits. Without such masking, using it as an index into the cm2_causes[] array will lead to an out-of-bounds access, probably causing a crash.
Fix this by using FIELD_GET() instead. Bite the bullet and convert all MIPS CM handling to the bitfield API, to improve readability and safety.
--- arch/mips/include/asm/mips-cm.h | 12 ++++++------ arch/mips/kernel/mips-cm.c | 21 ++++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-)
arch/mips/include/asm/mips-cm.h +6 -6
@@ -11,6 +11,7 @@#ifndef __MIPS_ASM_MIPS_CM_H__#define __MIPS_ASM_MIPS_CM_H__ +#include <linux/bitfield.h> #include <linux/bitops.h> #include <linux/errno.h>
@@ -153,8 +154,8 @@ GCR_ACCESSOR_RO(32, 0x030, rev)#define CM_GCR_REV_MINOR GENMASK(7, 0)#define CM_ENCODE_REV (major, minor) \ - (((major) << __ffs(CM_GCR_REV_MAJOR)) | \ - ((minor) << __ffs(CM_GCR_REV_MINOR))) + (FIELD_PREP(CM_GCR_REV_MAJOR, major) | \ + FIELD_PREP(CM_GCR_REV_MINOR, minor))#define CM_REV_CM2 CM_ENCODE_REV(6, 0)#define CM_REV_CM2_5 CM_ENCODE_REV(7, 0)
@@ -362,10 +363,10 @@ static inline int mips_cm_revision(void)static inline unsigned int mips_cm_max_vp_width (void ) {extern int smp_num_siblings; -uint32_t cfg;if (mips_cm_revision () >=CM_REV_CM3 ) -return read_gcr_sys_config2 () &CM_GCR_SYS_CONFIG2_MAXVPW ; +return FIELD_GET (CM_GCR_SYS_CONFIG2_MAXVPW , +read_gcr_sys_config2 ());if (mips_cm_present ()) {/*
@@ -373,8 +374,7 @@ static inline unsigned int mips_cm_max_vp_width(void)* number of VP(E)s, and if that ever changes then this will * need revisiting. */ - cfg =read_gcr_cl_config () & CM_GCR_Cx_CONFIG_PVPE; -return (cfg >>__ffs (CM_GCR_Cx_CONFIG_PVPE)) +1 ; +return FIELD_GET (CM_GCR_Cx_CONFIG_PVPE,read_gcr_cl_config ()) +1 ; }if (IS_ENABLED (CONFIG_SMP ))
arch/mips/kernel/mips-cm.c +10 -11
@@ -221,8 +221,7 @@ static void mips_cm_probe_l2sync(void)phys_addr_t addr;/* L2-only sync was introduced with CM major revision 6 */ - major_rev = (read_gcr_rev () &CM_GCR_REV_MAJOR ) >> -__ffs (CM_GCR_REV_MAJOR ); + major_rev =FIELD_GET (CM_GCR_REV_MAJOR ,read_gcr_rev ());if (major_rev <6 )return ;
@@ -305,13 +304,13 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,preempt_disable ();if (cm_rev >=CM_REV_CM3 ) { - val = core <<__ffs (CM3_GCR_Cx_OTHER_CORE); - val |= vp <<__ffs (CM3_GCR_Cx_OTHER_VP); + val =FIELD_PREP (CM3_GCR_Cx_OTHER_CORE, core) | +FIELD_PREP (CM3_GCR_Cx_OTHER_VP, vp);if (cm_rev >=CM_REV_CM3_5 ) { val |= CM_GCR_Cx_OTHER_CLUSTER_EN; - val |= cluster <<__ffs (CM_GCR_Cx_OTHER_CLUSTER); - val |= block <<__ffs (CM_GCR_Cx_OTHER_BLOCK); + val |=FIELD_PREP (CM_GCR_Cx_OTHER_CLUSTER, cluster); + val |=FIELD_PREP (CM_GCR_Cx_OTHER_BLOCK, block); }else {WARN_ON (cluster !=0 );WARN_ON (block != CM_GCR_Cx_OTHER_BLOCK_LOCAL);
@@ -341,7 +340,7 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,spin_lock_irqsave (&per_cpu (cm_core_lock, curr_core),per_cpu (cm_core_lock_flags, curr_core)); - val = core <<__ffs (CM_GCR_Cx_OTHER_CORENUM); + val =FIELD_PREP (CM_GCR_Cx_OTHER_CORENUM, core); }write_gcr_cl_other (val);
@@ -385,8 +384,8 @@ void mips_cm_error_report(void) cm_other =read_gcr_error_mult ();if (revision <CM_REV_CM3 ) {/* CM2 */ - cause = cm_error >>__ffs (CM_GCR_ERROR_CAUSE_ERRTYPE ); - ocause = cm_other >>__ffs (CM_GCR_ERROR_MULT_ERR2ND ); + cause =FIELD_GET (CM_GCR_ERROR_CAUSE_ERRTYPE , cm_error); + ocause =FIELD_GET (CM_GCR_ERROR_MULT_ERR2ND , cm_other);if (!cause)return ;
@@ -444,8 +443,8 @@ void mips_cm_error_report(void)ulong core_id_bits, vp_id_bits, cmd_bits, cmd_group_bits;ulong cm3_cca_bits, mcp_bits, cm3_tr_bits, sched_bit; - cause = cm_error >>__ffs64 (CM3_GCR_ERROR_CAUSE_ERRTYPE ); - ocause = cm_other >>__ffs (CM_GCR_ERROR_MULT_ERR2ND ); + cause =FIELD_GET (CM3_GCR_ERROR_CAUSE_ERRTYPE , cm_error); + ocause =FIELD_GET (CM_GCR_ERROR_MULT_ERR2ND , cm_other);if (!cause)return ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 466/575 power: supply: bq27xxx: Fix kernel crash on IRQ handler register error
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit cdf10ffe8f626d8a2edc354abf063df0078b2d71 ]
When registering the IRQ handler fails, do not just return the error code, this will free the devm_kzalloc()-ed data struct while leaving the queued work queued and the registered power_supply registered with both of them now pointing to free-ed memory, resulting in various kernel crashes soon afterwards.
Instead properly tear-down things on IRQ handler register errors.
--- drivers/power/supply/bq27xxx_battery_i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery_i2c.c +2 -1
@@ -187,7 +187,8 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,dev_err (&client->dev,"Unable to register IRQ %d error %d\n" , client->irq, ret); -return ret; +bq27xxx_battery_teardown (di); + goto err_failed; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 467/575 apparmor: fix error check
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit d108370c644b153382632b3e5511ade575c91c86 ]
clang static analysis reports this representative problem:
label.c:1463:16: warning: Assigned value is garbage or undefined
label->hname = name;
^ ~~~~In aa_update_label_name(), this the problem block of code
if (aa_label_acntsxprint(&name, ...) == -1) return res;
On failure, aa_label_acntsxprint() has a more complicated return that just -1. So check for a negative return.
It was also noted that the aa_label_acntsxprint() main comment refers to a nonexistent parameter, so clean up the comment.
--- security/apparmor/label.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/label.c +2 -2
@@ -1454,7 +1454,7 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp)if (label->hname ||labels_ns (label) != ns)return res; -if (aa_label_acntsxprint (&name, ns, label,FLAGS_NONE , gfp) ==-1 ) +if (aa_label_acntsxprint (&name, ns, label,FLAGS_NONE , gfp) <0 )return res; ls =labels_set (label);
@@ -1704,7 +1704,7 @@ int aa_label_asxprint(char **strp, struct aa_ns *ns, struct aa_label *label,/** * aa_label_acntsxprint - allocate a __counted string buffer and print label -* @strp: buffer to write to. (MAY BE NULL if @size == 0) +* @strp: buffer to write to. * @ns: namespace profile is being viewed from * @label: label to view (NOT NULL) * @flags: flags controlling what label info is printed
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 468/575 rpmsg: Fix rpmsg_create_ept return when RPMSG config is not defined
In reply to Greg Kroah-HartmanFrom: Arnaud Pouliquen <[email protected]>
[ Upstream commit 537d3af1bee8ad1415fda9b622d1ea6d1ae76dfa ]
According to the description of the rpmsg_create_ept in rpmsg_core.c the function should return NULL on error.
--- include/linux/rpmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/rpmsg.h +1 -1
@@ -177,7 +177,7 @@ static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev/* This shouldn't be possible */ WARN_ON (1 ); -return ERR_PTR (-ENXIO ); +return NULL ; }static inline int rpmsg_send (struct rpmsg_endpoint *ept,void *data,int len)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 469/575 nfsd: dont alloc under spinlock in rpc_parse_scope_id
In reply to Greg Kroah-HartmanFrom: J. Bruce Fields <[email protected]>
[ Upstream commit 9b6e27d01adcec58e046c624874f8a124e8b07ec ]
Dan Carpenter says:
The patch d20c11d86d8f: "nfsd: Protect session creation and client confirm using client_lock" from Jul 30, 2014, leads to the following Smatch static checker warning:
net/sunrpc/addr.c:178 rpc_parse_scope_id()
warn: sleeping in atomic context
--- net/sunrpc/addr.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
net/sunrpc/addr.c +18 -22
@@ -162,8 +162,10 @@ static int rpc_parse_scope_id(struct net *net, const char *buf, const size_t buflen, const char *delim, struct sockaddr_in6 *sin6) { - char *p; + char p[IPV6_SCOPE_ID_LEN + 1];size_t len; +u32 scope_id =0 ; +struct net_device *dev;if ((buf + buflen) == delim)return 1 ;
@@ -175,29 +177,23 @@ static int rpc_parse_scope_id(struct net *net, const char *buf,return 0 ; len = (buf + buflen) - delim -1 ; - p =kmemdup_nul (delim +1 , len,GFP_KERNEL ); -if (p) { -u32 scope_id =0 ; -struct net_device *dev; - - dev =dev_get_by_name (net, p); -if (dev !=NULL ) { - scope_id = dev->ifindex; -dev_put (dev); - }else { -if (kstrtou32 (p,10 , &scope_id) !=0 ) { -kfree (p); -return 0 ; - } - } - -kfree (p); - - sin6->sin6_scope_id = scope_id; -return 1 ; +if (len >IPV6_SCOPE_ID_LEN ) +return 0 ; + +memcpy (p, delim +1 , len); + p[len] =0 ; + + dev =dev_get_by_name (net, p); +if (dev !=NULL ) { + scope_id = dev->ifindex; +dev_put (dev); + }else { +if (kstrtou32 (p,10 , &scope_id) !=0 ) +return 0 ; } -return 0 ; + sin6->sin6_scope_id = scope_id; +return 1 ; } static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 470/575 i2c: mediatek: fixing the incorrect register offset
In reply to Greg Kroah-HartmanFrom: Kewei Xu <[email protected]>
[ Upstream commit b8228aea5a19d5111a7bf44f7de6749d1f5d487a ]
The reason for the modification here is that the previous offset information is incorrect, OFFSET_DEBUGSTAT = 0xE4 is the correct value.
--- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-mt65xx.c +1 -1
@@ -195,7 +195,7 @@ static const u16 mt_i2c_regs_v2[] = { [OFFSET_CLOCK_DIV] = 0x48, [OFFSET_SOFTRESET] = 0x50, [OFFSET_SCL_MIS_COMP_POINT] = 0x90, - [OFFSET_DEBUGSTAT] = 0xe0, + [OFFSET_DEBUGSTAT] = 0xe4, [OFFSET_DEBUGCTRL] = 0xe8, [OFFSET_FIFO_STAT] = 0xf4, [OFFSET_FIFO_THRESH] = 0xf8,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 471/575 NFS: Fix dentry verifier races
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit cec08f452a687fce9dfdf47946d00a1d12a8bec5 ]
If the directory changed while we were revalidating the dentry, then don't update the dentry verifier. There is no value in setting the verifier to an older value, and we could end up overwriting a more up to date verifier from a parallel revalidation.
--- fs/nfs/dir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/nfs/dir.c +3 -4
@@ -1061,13 +1061,12 @@ static bool nfs_verifier_is_delegated(struct dentry *dentry)static void nfs_set_verifier_locked (struct dentry *dentry,unsigned long verf) {struct inode *inode =d_inode (dentry); +struct inode *dir =d_inode (dentry->d_parent); -if (!nfs_verifier_is_delegated (dentry) && - !nfs_verify_change_attribute (d_inode (dentry->d_parent), verf)) - goto out; +if (!nfs_verify_change_attribute (dir, verf)) +return ;if (inode &&NFS_PROTO (inode)->have_delegation (inode,FMODE_READ ))nfs_set_verifier_delegated (&verf); -out: dentry->d_time = verf; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 472/575 pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds
In reply to Greg Kroah-HartmanFrom: Baptiste Lepers <[email protected]>
[ Upstream commit a2915fa06227b056a8f9b0d79b61dca08ad5cfc6 ]
_nfs4_pnfs_v3/v4_ds_connect do
some work
smp_wmb
ds->ds_clp = clp;
And nfs4_ff_layout_prepare_ds currently does
smp_rmb
if(ds->ds_clp)
...
This patch places the smp_rmb after the if. This ensures that following reads only happen once nfs4_ff_layout_prepare_ds has checked that data has been properly initialized.
--- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 4 ++-- fs/nfs/pnfs_nfs.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -2
@@ -378,10 +378,10 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, goto noconnect; ds = mirror->mirror_ds->ds; +if (READ_ONCE (ds->ds_clp)) + goto out;/* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */ smp_rmb (); -if (ds->ds_clp) - goto out;/* FIXME: For now we assume the server sent only one version of NFS * to use for the DS.
fs/nfs/pnfs_nfs.c +2 -2
@@ -876,7 +876,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, }smp_wmb (); - ds->ds_clp = clp; +WRITE_ONCE (ds->ds_clp, clp);dprintk ("%s [new] addr: %s\n" , __func__, ds->ds_remotestr); out:return status;
@@ -949,7 +949,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, }smp_wmb (); - ds->ds_clp = clp; +WRITE_ONCE (ds->ds_clp, clp);dprintk ("%s [new] addr: %s\n" , __func__, ds->ds_remotestr); out:return status;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 473/575 drm/plane-helper: fix uninitialized variable reference
In reply to Greg Kroah-HartmanFrom: Alex Xu (Hello71) <[email protected]>
[ Upstream commit 7be28bd73f23e53d6e7f5fe891ba9503fc0c7210 ]
drivers/gpu/drm/drm_plane_helper.c: In function 'drm_primary_helper_update':drivers/gpu/drm/drm_plane_helper.c:113:32: error: 'visible' is used uninitialized [-Werror=uninitialized]
113 | struct drm_plane_state plane_state = {
| ^~~~~~~~~~~
drivers/gpu/drm/drm_plane_helper.c:178:14: note: 'visible' was declared here
178 | bool visible;
| ^~~~~~~cc1: all warnings being treated as errors
visible is an output, not an input. in practice this use might turn out OK but it's still UB.
--- drivers/gpu/drm/drm_plane_helper.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/drm_plane_helper.c +0 -1
@@ -123,7 +123,6 @@ static int drm_plane_helper_check_update(struct drm_plane *plane, .crtc_w = drm_rect_width(dst), .crtc_h = drm_rect_height(dst), .rotation = rotation, - .visible = *visible, };struct drm_crtc_state crtc_state = { .crtc = crtc,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 474/575 PCI: aardvark: Dont spam about PIO Response Status
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
[ Upstream commit 464de7e7fff767e87429cd7be09c4f2cb50a6ccb ]
Use dev_dbg() instead of dev_err() in advk_pcie_check_pio_status().
For example CRS is not an error status, it just says that the request should be retried.
--- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +1 -1
@@ -778,7 +778,7 @@ static int advk_pcie_check_pio_status(struct advk_pcie *pcie, bool allow_crs, u3else str_posted ="Posted" ; -dev_err (dev,"%s PIO Response Status: %s, %#x @ %#x\n" , +dev_dbg (dev,"%s PIO Response Status: %s, %#x @ %#x\n" , str_posted, strcomp_status, reg,advk_readl (pcie,PIO_ADDR_LS ));return -EFAULT ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 475/575 PCI: aardvark: Fix preserving PCI_EXP_RTCTL_CRSSVE flag on emulated bridge
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit d419052bc6c60fa4ab2b5a51d5f1e55a66e2b4ff ]
Commit 43f5c77bcbd2 ("PCI: aardvark: Fix reporting CRS value") started using CRSSVE flag for handling CRS responses.
PCI_EXP_RTCTL_CRSSVE flag is stored only in emulated config space buffer and there is handler for PCI_EXP_RTCTL register. So every read operation from config space automatically clears CRSSVE flag as it is not defined in PCI_EXP_RTCTL read handler.
Fix this by reading current CRSSVE bit flag from emulated space buffer and appending it to PCI_EXP_RTCTL read response.
--- drivers/pci/controller/pci-aardvark.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pci-aardvark.c +1 -0
@@ -885,6 +885,7 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,case PCI_EXP_RTCTL : {u32 val =advk_readl (pcie,PCIE_ISR0_MASK_REG ); *value = (val &PCIE_MSG_PM_PME_MASK ) ?0 :PCI_EXP_RTCTL_PMEIE ; + *value |=le16_to_cpu (bridge->pcie_conf.rootctl) &PCI_EXP_RTCTL_CRSSVE ; *value |=PCI_EXP_RTCAP_CRSVIS <<16 ;return PCI_BRIDGE_EMUL_HANDLED ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 476/575 opp: Fix return in _opp_add_static_v2()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 27ff8187f13ecfec8a26fb1928e906f46f326cc5 ]
Fix sparse warning:drivers/opp/of.c:924 _opp_add_static_v2() warn: passing zero to 'ERR_PTR'
For duplicate OPPs 'ret' be set to zero.
--- drivers/opp/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +1 -1
@@ -827,7 +827,7 @@ free_required_opps: free_opp:_opp_free (new_opp); -return ERR_PTR (ret); +return ret ?ERR_PTR (ret) :NULL ; }/* Initializes OPP tables based on new bindings */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 477/575 NFS: Fix deadlocks in nfs_scan_commit_list()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 64a93dbf25d3a1368bb58ddf0f61d0a92d7479e3 ]
Partially revert commit 2ce209c42c01 ("NFS: Wait for requests that are locked on the commit list"), since it can lead to deadlocks between commit requests and nfs_join_page_group().
For now we should assume that any locked requests on the commit list are either about to be removed and committed by another task, or the writes they describe are about to be retransmitted. In either case, we should not need to worry.
--- fs/nfs/write.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
fs/nfs/write.c +2 -15
@@ -1034,25 +1034,11 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,struct nfs_page *req, *tmp;int ret =0 ; -restart:list_for_each_entry_safe (req, tmp, src, wb_list) {kref_get (&req->wb_kref);if (!nfs_lock_request (req)) { -int status; - -/* Prevent deadlock with nfs_lock_and_join_requests */ -if (!list_empty (dst)) { -nfs_release_request (req); -continue ; - } -/* Ensure we make progress to prevent livelock */ -mutex_unlock (&NFS_I (cinfo->inode)->commit_mutex); - status =nfs_wait_on_request (req);nfs_release_request (req); -mutex_lock (&NFS_I (cinfo->inode)->commit_mutex); -if (status <0 ) -break ; - goto restart; +continue ; }nfs_request_remove_commit_list (req, cinfo);clear_bit (PG_COMMIT_TO_DS , &req->wb_flags);
@@ -1924,6 +1910,7 @@ static int __nfs_commit_inode(struct inode *inode, int how,int may_wait = how &FLUSH_SYNC ;int ret, nscan; + how &= ~FLUSH_SYNC ;nfs_init_cinfo_from_inode (&cinfo, inode);nfs_commit_begin (cinfo.mds);for (;;) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 478/575 fs: orangefs: fix error return code of orangefs_revalidate_lookup()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 4c2b46c824a78fc8190d8eafaaea5a9078fe7479 ]
When op_alloc() returns NULL to new_op, no error return code of orangefs_revalidate_lookup() is assigned.
To fix this bug, ret is assigned with -ENOMEM in this case.
--- fs/orangefs/dcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/orangefs/dcache.c +3 -1
@@ -26,8 +26,10 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)gossip_debug (GOSSIP_DCACHE_DEBUG ,"%s: attempting lookup.\n" , __func__); new_op =op_alloc (ORANGEFS_VFS_OP_LOOKUP ); -if (!new_op) +if (!new_op) { + ret = -ENOMEM ; goto out_put_parent; + } new_op->upcall.req.lookup.sym_follow =ORANGEFS_LOOKUP_LINK_NO_FOLLOW ; new_op->upcall.req.lookup.parent_refn = parent->refn;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 479/575 mtd: spi-nor: hisi-sfc: Remove excessive clk_disable_unprepare()
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 78e4d342187625585932bb437ec26e1060f7fc6f ]
hisi_spi_nor_probe() invokes clk_disable_unprepare() on all paths after successful call of clk_prepare_enable(). Besides, the clock is enabled by hispi_spi_nor_prep() and disabled by hispi_spi_nor_unprep(). So at remove time it is not possible to have the clock enabled. The patch removes excessive clk_disable_unprepare() from hisi_spi_nor_remove().
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/mtd/spi-nor/controllers/hisi-sfc.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/spi-nor/controllers/hisi-sfc.c +0 -1
@@ -477,7 +477,6 @@ static int hisi_spi_nor_remove(struct platform_device *pdev)hisi_spi_nor_unregister_all (host);mutex_destroy (&host->lock); -clk_disable_unprepare (host->clk);return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 480/575 PCI: uniphier: Serialize INTx masking/unmasking and fix the bit operation
In reply to Greg Kroah-HartmanFrom: Kunihiko Hayashi <[email protected]>
[ Upstream commit 4caab28a6215da5f3c1b505ff08810bc6acfe365 ]
The condition register PCI_RCV_INTX is used in irq_mask() and irq_unmask() callbacks. Accesses to register can occur at the same time without a lock. Add a lock into each callback to prevent the issue.
And INTX mask and unmask fields in PCL_RCV_INTX register should only be set/reset for each bit. Clearing by PCL_RCV_INTX_ALL_MASK should be removed.
INTX status fields in PCL_RCV_INTX register only indicates each INTX interrupt status, so the handler can't clear by writing 1 to the field. The status is expected to be cleared by the interrupt origin. The ack function has no meaning, so should remove it.
--- drivers/pci/controller/dwc/pcie-uniphier.c | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/pci/controller/dwc/pcie-uniphier.c +10 -16
@@ -171,30 +171,21 @@ static void uniphier_pcie_irq_enable(struct uniphier_pcie_priv *priv)writel (PCL_RCV_INTX_ALL_ENABLE , priv->base +PCL_RCV_INTX ); } -static void uniphier_pcie_irq_ack (struct irq_data *d) -{ -struct pcie_port *pp =irq_data_get_irq_chip_data (d); -struct dw_pcie *pci =to_dw_pcie_from_pp (pp); -struct uniphier_pcie_priv *priv =to_uniphier_pcie (pci); -u32 val; - - val =readl (priv->base +PCL_RCV_INTX ); - val &= ~PCL_RCV_INTX_ALL_STATUS ; - val |=BIT (irqd_to_hwirq (d) +PCL_RCV_INTX_STATUS_SHIFT ); -writel (val, priv->base +PCL_RCV_INTX ); -} -static void uniphier_pcie_irq_mask (struct irq_data *d) {struct pcie_port *pp =irq_data_get_irq_chip_data (d);struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct uniphier_pcie_priv *priv =to_uniphier_pcie (pci); +unsigned long flags;u32 val; +raw_spin_lock_irqsave (&pp->lock, flags); + val =readl (priv->base +PCL_RCV_INTX ); - val &= ~PCL_RCV_INTX_ALL_MASK ; val |=BIT (irqd_to_hwirq (d) +PCL_RCV_INTX_MASK_SHIFT );writel (val, priv->base +PCL_RCV_INTX ); + +raw_spin_unlock_irqrestore (&pp->lock, flags); }static void uniphier_pcie_irq_unmask (struct irq_data *d)
@@ -202,17 +193,20 @@ static void uniphier_pcie_irq_unmask(struct irq_data *d)struct pcie_port *pp =irq_data_get_irq_chip_data (d);struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct uniphier_pcie_priv *priv =to_uniphier_pcie (pci); +unsigned long flags;u32 val; +raw_spin_lock_irqsave (&pp->lock, flags); + val =readl (priv->base +PCL_RCV_INTX ); - val &= ~PCL_RCV_INTX_ALL_MASK ; val &= ~BIT (irqd_to_hwirq (d) +PCL_RCV_INTX_MASK_SHIFT );writel (val, priv->base +PCL_RCV_INTX ); + +raw_spin_unlock_irqrestore (&pp->lock, flags); }static struct irq_chip uniphier_pcie_irq_chip = { .name ="PCI" , - .irq_ack = uniphier_pcie_irq_ack, .irq_mask = uniphier_pcie_irq_mask, .irq_unmask = uniphier_pcie_irq_unmask, };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 481/575 mtd: core: dont remove debugfs directory if device is in use
In reply to Greg Kroah-HartmanFrom: Zev Weiss <[email protected]>
[ Upstream commit c13de2386c78e890d4ae6f01a85eefd0b293fb08 ]
Previously, if del_mtd_device() failed with -EBUSY due to a non-zero usecount, a subsequent call to attempt the deletion again would try to remove a debugfs directory that had already been removed and panic. With this change the second call can instead proceed safely.
--- drivers/mtd/mtdcore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/mtdcore.c +2 -2
@@ -721,8 +721,6 @@ int del_mtd_device(struct mtd_info *mtd)mutex_lock (&mtd_table_mutex); -debugfs_remove_recursive (mtd->dbg.dfs_dir); -if (idr_find (&mtd_idr, mtd->index) != mtd) { ret = -ENODEV ; goto out_error;
@@ -738,6 +736,8 @@ int del_mtd_device(struct mtd_info *mtd) mtd->index, mtd->name, mtd->usecount); ret = -EBUSY ; }else { +debugfs_remove_recursive (mtd->dbg.dfs_dir); +/* Try to remove the NVMEM provider */ if (mtd->nvmem)nvmem_unregister (mtd->nvmem);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 482/575 remoteproc: Fix a memory leak in an error handling path in rproc_handle_vdev()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 0374a4ea7269645c46c3eb288526ea072fa19e79 ]
If 'copy_dma_range_map() fails, the memory allocated for 'rvdev' will leak. Move the 'copy_dma_range_map()' call after the device registration so that 'rproc_rvdev_release()' can be called to free some resources.
Also, branch to the error handling path if 'copy_dma_range_map()' instead of a direct return to avoid some other leaks.
--- drivers/remoteproc/remoteproc_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/remoteproc/remoteproc_core.c +5 -3
@@ -550,9 +550,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); rvdev->dev.parent = &rproc->dev; - ret =copy_dma_range_map (&rvdev->dev, rproc->dev.parent); -if (ret) -return ret; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);dev_set_drvdata (&rvdev->dev, rvdev);
@@ -562,6 +559,11 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,put_device (&rvdev->dev);return ret; } + + ret =copy_dma_range_map (&rvdev->dev, rproc->dev.parent); +if (ret) + goto free_rvdev; +/* Make device dma capable by inheriting from parent's capabilities */ set_dma_ops (&rvdev->dev,get_dma_ops (rproc->dev.parent));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 483/575 rtc: rv3032: fix error handling in rv3032_clkout_set_rate()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit c3336b8ac6091df60a5c1049a8c685d0b947cc61 ]
Do not call rv3032_exit_eerd() if the enter function fails but don't forget to call the exit when the enter succeeds.
--- drivers/rtc/rtc-rv3032.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-rv3032.c +2 -2
@@ -617,11 +617,11 @@ static int rv3032_clkout_set_rate(struct clk_hw *hw, unsigned long rate, ret =rv3032_enter_eerd (rv3032, &eerd);if (ret) - goto exit_eerd; +return ret; ret =regmap_write (rv3032->regmap,RV3032_CLKOUT1 , hfd &0xff );if (ret) -return ret; + goto exit_eerd; ret =regmap_write (rv3032->regmap,RV3032_CLKOUT2 ,RV3032_CLKOUT2_OS |FIELD_PREP (RV3032_CLKOUT2_HFD_MSK , hfd >>8 ));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 484/575 dmaengine: at_xdmac: fix AT_XDMAC_CC_PERID() macro
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 320c88a3104dc955f928a1eecebd551ff89530c0 ]
AT_XDMAC_CC_PERID() should be used to setup bits 24..30 of XDMAC_CC register. Using it without parenthesis around 0x7f & (i) will lead to setting all the time zero for bits 24..30 of XDMAC_CC as the << operator has higher precedence over bitwise &. Thus, add paranthesis around 0x7f & (i).
--- drivers/dma/at_xdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/at_xdmac.c +1 -1
@@ -145,7 +145,7 @@#define AT_XDMAC_CC_WRIP (0x1 << 23)/* Write in Progress (read only) */ #define AT_XDMAC_CC_WRIP_DONE (0x0 << 23)#define AT_XDMAC_CC_WRIP_IN_PROGRESS (0x1 << 23) -#define AT_XDMAC_CC_PERID (i) (0x7f & (i) << 24)/* Channel Peripheral Identifier */ +#define AT_XDMAC_CC_PERID (i) ((0x7f & (i)) << 24)/* Channel Peripheral Identifier */ #define AT_XDMAC_CDS_MSP 0x2C/* Channel Data Stride Memory Set Pattern */ #define AT_XDMAC_CSUS 0x30/* Channel Source Microblock Stride */ #define AT_XDMAC_CDUS 0x34/* Channel Destination Microblock Stride */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 485/575 NFS: Fix up commit deadlocks
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 133a48abf6ecc535d7eddc6da1c3e4c972445882 ]
If O_DIRECT bumps the commit_info rpcs_out field, then that could lead to fsync() hangs. The fix is to ensure that O_DIRECT calls nfs_commit_end().
--- fs/nfs/direct.c | 2 +- fs/nfs/pnfs_nfs.c | 2 -- fs/nfs/write.c | 9 ++++++--- include/linux/nfs_fs.h | 1 + 4 files changed, 8 insertions(+), 6 deletions(-)
fs/nfs/direct.c +1 -1
@@ -620,7 +620,7 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)nfs_unlock_and_release_request (req); } -if (atomic_dec_and_test (&cinfo.mds->rpcs_out)) +if (nfs_commit_end (cinfo.mds))nfs_direct_write_complete (dreq); }
fs/nfs/pnfs_nfs.c +0 -2
@@ -468,7 +468,6 @@ pnfs_bucket_alloc_ds_commits(struct list_head *list, goto out_error; data->ds_commit_index = i;list_add_tail (&data->list, list); -atomic_inc (&cinfo->mds->rpcs_out); nreq++; }mutex_unlock (&NFS_I (cinfo->inode)->commit_mutex);
@@ -520,7 +519,6 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages, data->ds_commit_index =-1 ;list_splice_init (mds_pages, &data->pages);list_add_tail (&data->list, &list); -atomic_inc (&cinfo->mds->rpcs_out); nreq++; }
fs/nfs/write.c +6 -3
@@ -1649,10 +1649,13 @@ static void nfs_commit_begin(struct nfs_mds_commit_info *cinfo)atomic_inc (&cinfo->rpcs_out); } -static void nfs_commit_end (struct nfs_mds_commit_info *cinfo) +bool nfs_commit_end (struct nfs_mds_commit_info *cinfo) { -if (atomic_dec_and_test (&cinfo->rpcs_out)) +if (atomic_dec_and_test (&cinfo->rpcs_out)) {wake_up_var (&cinfo->rpcs_out); +return true; + } +return false; }void nfs_commitdata_release (struct nfs_commit_data *data)
@@ -1752,6 +1755,7 @@ void nfs_init_commit(struct nfs_commit_data *data, data->res.fattr = &data->fattr; data->res.verf = &data->verf;nfs_fattr_init (&data->fattr); +nfs_commit_begin (cinfo->mds); }EXPORT_SYMBOL_GPL (nfs_init_commit);
@@ -1797,7 +1801,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,/* Set up the argument struct */ nfs_init_commit (data, head,NULL , cinfo); -atomic_inc (&cinfo->mds->rpcs_out);return nfs_initiate_commit (NFS_CLIENT (inode), data,NFS_PROTO (inode), data->mds_ops, how,RPC_TASK_CRED_NOREF ); }
include/linux/nfs_fs.h +1 -0
@@ -553,6 +553,7 @@ extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);extern int nfs_commit_inode (struct inode *,int );extern struct nfs_commit_data *nfs_commitdata_alloc (bool never_fail);extern void nfs_commit_free (struct nfs_commit_data *data); +bool nfs_commit_end (struct nfs_mds_commit_info *cinfo);static inline int nfs_have_writebacks (struct inode *inode)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 486/575 NFS: Fix an Oops in pnfs_mark_request_commit()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit f0caea8882a7412a2ad4d8274f0280cdf849c9e2 ]
Olga reports seeing the following Oops when doing O_DIRECT writes to a pNFS flexfiles server:
Oops: 0000 [#1] SMP PTI CPU: 1 PID: 234186 Comm: kworker/u8:1 Not tainted 5.15.0-rc4+ #4 Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.13.0-2.module+el8.3.0+7353+9de0a3cc 04/01/2014 Workqueue: nfsiod rpc_async_release [sunrpc] RIP: 0010:nfs_mark_request_commit+0x12/0x30 [nfs] Code: ff ff be 03 00 00 00 e8 ac 34 83 eb e9 29 ff ff ff e8 22 bc d7 eb 66 90 0f 1f 44 00 00 48 85 f6 74 16 48 8b 42 10 48 8b 40 18 <48> 8b 40 18 48 85 c0 74 05 e9 70 fc 15 ec 48 89 d6 e9 68 ed ff ff RSP: 0018:ffffa82f0159fe00 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff8f3393141880 RCX: 0000000000000000 RDX: ffffa82f0159fe08 RSI: ffff8f3381252500 RDI: ffff8f3393141880 RBP: ffff8f33ac317c00 R08: 0000000000000000 R09: ffff8f3487724cb0 R10: 0000000000000008 R11: 0000000000000001 R12: 0000000000000001 R13: ffff8f3485bccee0 R14: ffff8f33ac317c10 R15: ffff8f33ac317cd8 FS: 0000000000000000(0000) GS:ffff8f34fbc80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000018 CR3: 0000000122120006 CR4: 0000000000770ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: nfs_direct_write_completion+0x13b/0x250 [nfs] rpc_free_task+0x39/0x60 [sunrpc] rpc_async_release+0x29/0x40 [sunrpc] process_one_work+0x1ce/0x370 worker_thread+0x30/0x380 ? process_one_work+0x370/0x370 kthread+0x11a/0x140 ? set_kthread_struct+0x40/0x40 ret_from_fork+0x22/0x30
--- fs/nfs/pnfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/pnfs.h +1 -1
@@ -515,7 +515,7 @@ pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, {struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds; -if (!lseg || !fl_cinfo->ops->mark_request_commit) +if (!lseg || !fl_cinfo->ops || !fl_cinfo->ops->mark_request_commit)return false; fl_cinfo->ops->mark_request_commit (req, lseg, cinfo, ds_commit_idx);return true;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 487/575 Fix user namespace leak
In reply to Greg Kroah-HartmanFrom: Alexey Gladkov <[email protected]>
[ Upstream commit d5f458a979650e5ed37212f6134e4ee2b28cb6ed ]
--- fs/nfs/nfs4idmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4idmap.c +1 -1
@@ -487,7 +487,7 @@ nfs_idmap_new(struct nfs_client *clp) err_destroy_pipe:rpc_destroy_pipe_data (idmap->idmap_pipe); err: -get_user_ns (idmap->user_ns); +put_user_ns (idmap->user_ns);kfree (idmap);return error; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 488/575 auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit afcb5a811ff3ab3969f09666535eb6018a160358 ]
While writing an empty string to a device attribute is a no-op, and thus does not need explicit safeguards, the user can still write a single newline to an attribute file:
echo > .../message
If that happens, img_ascii_lcd_display() trims the newline, yielding an empty string, and causing an infinite loop in img_ascii_lcd_scroll().
Fix this by adding a check for empty strings. Clear the display in case one is encountered.
--- drivers/auxdisplay/img-ascii-lcd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/auxdisplay/img-ascii-lcd.c +10 -0
@@ -280,6 +280,16 @@ static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,if (msg[count -1 ] =='\n' ) count--; +if (!count) { +/* clear the LCD */ +devm_kfree (&ctx->pdev->dev, ctx->message); + ctx->message =NULL ; + ctx->message_len =0 ; +memset (ctx->curr,' ' , ctx->cfg->num_chars); + ctx->cfg->update (ctx); +return 0 ; + } + new_msg =devm_kmalloc (&ctx->pdev->dev, count +1 ,GFP_KERNEL );if (!new_msg)return -ENOMEM ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 489/575 auxdisplay: ht16k33: Connect backlight to fbdev
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 80f9eb70fd9276938f0a131f76d438021bfd8b34 ]
Currently /sys/class/graphics/fb0/bl_curve is not accessible (-ENODEV), as the driver does not connect the backlight to the frame buffer device. Fix this moving backlight initialization up, and filling in fb_info.bl_dev.
--- drivers/auxdisplay/ht16k33.c | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/auxdisplay/ht16k33.c +28 -28
@@ -418,6 +418,33 @@ static int ht16k33_probe(struct i2c_client *client,if (err)return err; +/* Backlight */ +memset (&bl_props,0 ,sizeof (struct backlight_properties )); + bl_props.type =BACKLIGHT_RAW ; + bl_props.max_brightness =MAX_BRIGHTNESS ; + + bl =devm_backlight_device_register (&client->dev,DRIVER_NAME "-bl" , + &client->dev, priv, + &ht16k33_bl_ops, &bl_props); +if (IS_ERR (bl)) { +dev_err (&client->dev,"failed to register backlight\n" ); +return PTR_ERR (bl); + } + + err =of_property_read_u32 (node,"default-brightness-level" , + &dft_brightness); +if (err) { + dft_brightness =MAX_BRIGHTNESS ; + }else if (dft_brightness >MAX_BRIGHTNESS ) { +dev_warn (&client->dev, +"invalid default brightness level: %u, using %u\n" , + dft_brightness,MAX_BRIGHTNESS ); + dft_brightness =MAX_BRIGHTNESS ; + } + + bl->props.brightness = dft_brightness; +ht16k33_bl_update_status (bl); +/* Framebuffer (2 bytes per column) */ BUILD_BUG_ON (PAGE_SIZE <HT16K33_FB_SIZE ); fbdev->buffer = (unsigned char *)get_zeroed_page (GFP_KERNEL );
@@ -450,6 +477,7 @@ static int ht16k33_probe(struct i2c_client *client, fbdev->info->screen_size =HT16K33_FB_SIZE ; fbdev->info->fix = ht16k33_fb_fix; fbdev->info->var = ht16k33_fb_var; + fbdev->info->bl_dev = bl; fbdev->info->pseudo_palette =NULL ; fbdev->info->flags =FBINFO_FLAG_DEFAULT ; fbdev->info->par = priv;
@@ -462,34 +490,6 @@ static int ht16k33_probe(struct i2c_client *client,if (err) goto err_fbdev_unregister; -/* Backlight */ -memset (&bl_props,0 ,sizeof (struct backlight_properties )); - bl_props.type =BACKLIGHT_RAW ; - bl_props.max_brightness =MAX_BRIGHTNESS ; - - bl =devm_backlight_device_register (&client->dev,DRIVER_NAME "-bl" , - &client->dev, priv, - &ht16k33_bl_ops, &bl_props); -if (IS_ERR (bl)) { -dev_err (&client->dev,"failed to register backlight\n" ); - err =PTR_ERR (bl); - goto err_fbdev_unregister; - } - - err =of_property_read_u32 (node,"default-brightness-level" , - &dft_brightness); -if (err) { - dft_brightness =MAX_BRIGHTNESS ; - }else if (dft_brightness >MAX_BRIGHTNESS ) { -dev_warn (&client->dev, -"invalid default brightness level: %u, using %u\n" , - dft_brightness,MAX_BRIGHTNESS ); - dft_brightness =MAX_BRIGHTNESS ; - } - - bl->props.brightness = dft_brightness; -ht16k33_bl_update_status (bl); -ht16k33_fb_queue (priv);return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 490/575 auxdisplay: ht16k33: Fix frame buffer device blanking
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 840fe258332544aa7321921e1723d37b772af7a9 ]
As the ht16k33 frame buffer sub-driver does not register an fb_ops.fb_blank() handler, blanking does not work:
$ echo 1 > /sys/class/graphics/fb0/blank
sh: write error: Invalid argumentFix this by providing a handler that always returns zero, to make sure blank events will be sent to the actual device handling the backlight.
--- drivers/auxdisplay/ht16k33.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/auxdisplay/ht16k33.c +10 -0
@@ -219,6 +219,15 @@ static const struct backlight_ops ht16k33_bl_ops = { .check_fb = ht16k33_bl_check_fb, }; +/* +* Blank events will be passed to the actual device handling the backlight when +* we return zero here. +*/ +static int ht16k33_blank (int blank,struct fb_info *info) +{ +return 0 ; +} +static int ht16k33_mmap (struct fb_info *info,struct vm_area_struct *vma) {struct ht16k33_priv *priv = info->par;
@@ -231,6 +240,7 @@ static const struct fb_ops ht16k33_fb_ops = { .owner = THIS_MODULE, .fb_read = fb_sys_read, .fb_write = fb_sys_write, + .fb_blank = ht16k33_blank, .fb_fillrect = sys_fillrect, .fb_copyarea = sys_copyarea, .fb_imageblit = sys_imageblit,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 491/575 soc: fsl: dpaa2-console: free buffer before returning from dpaa2_console_read
In reply to Greg Kroah-HartmanFrom: Robert-Ionut Alexa <[email protected]>
[ Upstream commit 8120bd469f5525da229953c1197f2b826c0109f4 ]
Free the kbuf buffer before returning from the dpaa2_console_read() function. The variable no longer goes out of scope, leaking the storage it points to.
--- drivers/soc/fsl/dpaa2-console.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/fsl/dpaa2-console.c +1 -0
@@ -231,6 +231,7 @@ static ssize_t dpaa2_console_read(struct file *fp, char __user *buf, cd->cur_ptr += bytes; written += bytes; +kfree (kbuf);return written; err_free_buf:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 492/575 netfilter: nfnetlink_queue: fix OOB when mac header was cleared
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 5648b5e1169ff1d6d6a46c35c0b5fbebd2a5cbb2 ]
On 64bit platforms the MAC header is set to 0xffff on allocation and also when a helper like skb_unset_mac_header() is called.
dev_parse_header may call skb_mac_header() which assumes valid mac offset:
BUG: KASAN: use-after-free in eth_header_parse+0x75/0x90 Read of size 6 at addr ffff8881075a5c05 by task nf-queue/1364 Call Trace: memcpy+0x20/0x60 eth_header_parse+0x75/0x90 __nfqnl_enqueue_packet+0x1a61/0x3380 __nf_queue+0x597/0x1300 nf_queue+0xf/0x40 nf_hook_slow+0xed/0x190 nf_hook+0x184/0x440 ip_output+0x1c0/0x2a0 nf_reinject+0x26f/0x700 nfqnl_recv_verdict+0xa16/0x18b0 nfnetlink_rcv_msg+0x506/0xe70
The existing code only works if the skb has a mac header.
--- net/netfilter/nfnetlink_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_queue.c +1 -1
@@ -562,7 +562,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, goto nla_put_failure;if (indev && entskb->dev && - entskb->mac_header != entskb->network_header) { +skb_mac_header_was_set (entskb)) {struct nfqnl_msg_packet_hw phw;int len;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 493/575 dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`
In reply to Greg Kroah-HartmanFrom: Lars-Peter Clausen <[email protected]>
[ Upstream commit e7e1e880b114ca640a2f280b0d5d38aed98f98c6 ]
Before the callback_result callback was introduced drivers coded their invocation to the callback in a similar way to:
if (cb->callback) {
spin_unlock(&dma->lock);
cb->callback(cb->callback_param);
spin_lock(&dma->lock);
}With the introduction of callback_result two helpers where introduced to transparently handle both types of callbacks. And drivers where updated to look like this:
if (dmaengine_desc_callback_valid(cb)) {
spin_unlock(&dma->lock);
dmaengine_desc_callback_invoke(cb, ...);
spin_lock(&dma->lock);
}dmaengine_desc_callback_invoke() correctly handles both callback_result and callback. But we forgot to update the dmaengine_desc_callback_valid() function to check for callback_result. As a result DMA descriptors that use the callback_result rather than callback don't have their callback invoked by drivers that follow the pattern above.
Fix this by checking for both callback and callback_result in dmaengine_desc_callback_valid().
--- drivers/dma/dmaengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dmaengine.h +1 -1
@@ -176,7 +176,7 @@ dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx,static inline bool dmaengine_desc_callback_valid (struct dmaengine_desc_callback *cb) { -return (cb->callback) ? true : false; +return cb->callback || cb->callback_result; }struct dma_chan *dma_get_slave_channel (struct dma_chan *chan);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 494/575 signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
In reply to Greg Kroah-HartmanFrom: Eric W. Biederman <[email protected]>
[ Upstream commit ce0ee4e6ac99606f3945f4d47775544edc3f7985 ]
Today the sh code allocates memory the first time a process uses the fpu. If that memory allocation fails, kill the affected task with force_sig(SIGKILL) rather than do_group_exit(SIGKILL).
Calling do_group_exit from an exception handler can potentially lead to dead locks as do_group_exit is not designed to be called from interrupt context. Instead use force_sig(SIGKILL) to kill the userspace process. Sending signals in general and force_sig in particular has been tested from interrupt context so there should be no problems.
--- arch/sh/kernel/cpu/fpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/sh/kernel/cpu/fpu.c +6 -4
@@ -62,18 +62,20 @@ void fpu_state_restore(struct pt_regs *regs) }if (!tsk_used_math (tsk)) { -local_irq_enable (); +int ret;/* * does a slab alloc which can sleep */ -if (init_fpu (tsk)) { +local_irq_enable (); + ret =init_fpu (tsk); +local_irq_disable (); +if (ret) {/* * ran out of memory! */ -do_group_exit (SIGKILL ); +force_sig (SIGKILL );return ; } -local_irq_disable (); }grab_fpu (regs);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 495/575 m68k: set a default value for MEMORY_RESERVE
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 1aaa557b2db95c9506ed0981bc34505c32d6b62b ]
'make randconfig' can produce a .config file with "CONFIG_MEMORY_RESERVE=" (no value) since it has no default. When a subsequent 'make all' is done, kconfig restarts the config and prompts for a value for MEMORY_RESERVE. This breaks scripting/automation where there is no interactive user input.
Add a default value for MEMORY_RESERVE. (Any integer value will work here for kconfig.)
Fixes a kconfig warning:
.config:214:warning: symbol value '' invalid for MEMORY_RESERVE
* Restart config...
Memory reservation (MiB) (MEMORY_RESERVE) [] (NEW)
--- arch/m68k/Kconfig.machine | 1 + 1 file changed, 1 insertion(+)
arch/m68k/Kconfig.machine +1 -0
@@ -191,6 +191,7 @@ config INIT_LCD config MEMORY_RESERVE int "Memory reservation (MiB)" depends on (UCSIMM || UCDIMM) + default 0 help Reserve certain memory regions on 68x328 based boards.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 496/575 watchdog: f71808e_wdt: fix inaccurate report in WDIOC_GETTIMEOUT
In reply to Greg Kroah-HartmanFrom: Ahmad Fatoum <[email protected]>
[ Upstream commit 164483c735190775f29d0dcbac0363adc51a068d ]
The fintek watchdog timer can configure timeouts of second granularity only up to 255 seconds. Beyond that, the timeout needs to be configured with minute granularity. WDIOC_GETTIMEOUT should report the actual timeout configured, not just echo back the timeout configured by the user. Do so.
--- drivers/watchdog/f71808e_wdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/f71808e_wdt.c +3 -1
@@ -228,15 +228,17 @@ static int watchdog_set_timeout(int timeout)mutex_lock (&watchdog.lock); - watchdog.timeout = timeout;if (timeout >0xff ) { watchdog.timer_val =DIV_ROUND_UP (timeout,60 ); watchdog.minutes_mode = true; + timeout = watchdog.timer_val *60 ; }else { watchdog.timer_val = timeout; watchdog.minutes_mode = false; } + watchdog.timeout = timeout; +mutex_unlock (&watchdog.lock);return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 497/575 ar7: fix kernel builds for compiler test
In reply to Greg Kroah-HartmanFrom: Jackie Liu <[email protected]>
[ Upstream commit 28b7ee33a2122569ac065cad578bf23f50cc65c3 ]
TI AR7 Watchdog Timer is only build for 32bit.
Avoid error like:
In file included from drivers/watchdog/ar7_wdt.c:29:./arch/mips/include/asm/mach-ar7/ar7.h: In function ‘ar7_is_titan’:./arch/mips/include/asm/mach-ar7/ar7.h:111:24: error: implicit declaration of function ‘KSEG1ADDR’; did you mean ‘CKSEG1ADDR’? [-Werror=implicit-function-declaration]
111 | return (readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x24)) & 0xffff) ==
| ^~~~~~~~~
| CKSEG1ADDR--- drivers/watchdog/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/Kconfig +1 -1
@@ -1723,7 +1723,7 @@ config SIBYTE_WDOG config AR7_WDT tristate "TI AR7 Watchdog Timer" - depends on AR7 || (MIPS && COMPILE_TEST) + depends on AR7 || (MIPS && 32BIT && COMPILE_TEST) help Hardware driver for the TI AR7 Watchdog Timer.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 498/575 scsi: qla2xxx: Changes to support FCP2 Target
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
[ Upstream commit 44c57f205876518b14ab2b4b5d88a181f41260bb ]
Add changes to support FCP2 Target.
--- drivers/scsi/qla2xxx/qla_dbg.c | 3 +-- drivers/scsi/qla2xxx/qla_init.c | 6 ++++++ drivers/scsi/qla2xxx/qla_os.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_dbg.c +1 -2
@@ -12,8 +12,7 @@* ---------------------------------------------------------------------- * | Module Init and Probe | 0x0199 | | * | Mailbox commands | 0x1206 | 0x11a5-0x11ff | -* | Device Discovery | 0x2134 | 0x210e-0x2116 | -* | | | 0x211a | +* | Device Discovery | 0x2134 | 0x210e-0x2115 | * | | | 0x211c-0x2128 | * | | | 0x212c-0x2134 | * | Queue Command and IO tracing | 0x3074 | 0x300b |
drivers/scsi/qla2xxx/qla_init.c +6 -0
@@ -1710,6 +1710,12 @@ void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea) fcport =qla2x00_find_fcport_by_nportid (vha, &ea->id,1 );if (fcport) { +if (fcport->flags &FCF_FCP2_DEVICE ) { +ql_dbg (ql_dbg_disc, vha,0x2115 , +"Delaying session delete for FCP2 portid=%06x %8phC " , + fcport->d_id.b24, fcport->port_name); +return ; + } fcport->scan_needed =1 ; fcport->rscn_gen++; }
drivers/scsi/qla2xxx/qla_os.c +10 -0
@@ -3955,6 +3955,16 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha) "Mark all dev lost\n");list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (fcport->loop_id !=FC_NO_LOOP_ID && + (fcport->flags &FCF_FCP2_DEVICE ) && + fcport->port_type ==FCT_TARGET && + !qla2x00_reset_active (vha)) { +ql_dbg (ql_dbg_disc, vha,0x211a , +"Delaying session delete for FCP2 flags 0x%x port_type = 0x%x port_id=%06x %phC" , + fcport->flags, fcport->port_type, + fcport->d_id.b24, fcport->port_name); +continue ; + } fcport->scan_state =0 ;qlt_schedule_sess_for_deletion (fcport); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 499/575 scsi: qla2xxx: Relogin during fabric disturbance
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit bb2ca6b3f09ac20e8357d257d0557ab5ddf6adcd ]
For RSCN of type "Area, Domain, or Fabric", which indicate a portion or entire fabric was disturbed, current driver does not set the scan_need flag to indicate a session was affected by the disturbance. This in turn can lead to I/O timeout and delay of relogin. Hence initiate relogin in the event of fabric disturbance.
--- drivers/scsi/qla2xxx/qla_init.c | 56 +++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +46 -10
@@ -1708,16 +1708,52 @@ void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea)fc_port_t *fcport;unsigned long flags; - fcport =qla2x00_find_fcport_by_nportid (vha, &ea->id,1 ); -if (fcport) { -if (fcport->flags &FCF_FCP2_DEVICE ) { -ql_dbg (ql_dbg_disc, vha,0x2115 , -"Delaying session delete for FCP2 portid=%06x %8phC " , - fcport->d_id.b24, fcport->port_name); -return ; - } - fcport->scan_needed =1 ; - fcport->rscn_gen++; +switch (ea->id.b.rsvd_1) { +case RSCN_PORT_ADDR : + fcport =qla2x00_find_fcport_by_nportid (vha, &ea->id,1 ); +if (fcport) { +if (fcport->flags &FCF_FCP2_DEVICE ) { +ql_dbg (ql_dbg_disc, vha,0x2115 , +"Delaying session delete for FCP2 portid=%06x %8phC " , + fcport->d_id.b24, fcport->port_name); +return ; + } + fcport->scan_needed =1 ; + fcport->rscn_gen++; + } +break ; +case RSCN_AREA_ADDR : +list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (fcport->flags &FCF_FCP2_DEVICE ) +continue ; + +if ((ea->id.b24 &0xffff00 ) == (fcport->d_id.b24 &0xffff00 )) { + fcport->scan_needed =1 ; + fcport->rscn_gen++; + } + } +break ; +case RSCN_DOM_ADDR : +list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (fcport->flags &FCF_FCP2_DEVICE ) +continue ; + +if ((ea->id.b24 &0xff0000 ) == (fcport->d_id.b24 &0xff0000 )) { + fcport->scan_needed =1 ; + fcport->rscn_gen++; + } + } +break ; +case RSCN_FAB_ADDR : +default : +list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (fcport->flags &FCF_FCP2_DEVICE ) +continue ; + + fcport->scan_needed =1 ; + fcport->rscn_gen++; + } +break ; }spin_lock_irqsave (&vha->work_lock, flags);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 500/575 scsi: qla2xxx: Fix gnl list corruption
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit c98c5daaa24b583cba1369b7d167f93c6ae7299c ]
Current code does list element deletion and addition in and out of lock protection. This patch moves deletion behind lock.
list_add double add: new=ffff9130b5eb89f8, prev=ffff9130b5eb89f8,
next=ffff9130c6a715f0. ------------[ cut here ]------------ kernel BUG at lib/list_debug.c:31! invalid opcode: 0000 [#1] SMP PTI CPU: 1 PID: 182395 Comm: kworker/1:37 Kdump: loaded Tainted: G W OE --------- - - 4.18.0-193.el8.x86_64 #1 Hardware name: HP ProLiant DL160 Gen8, BIOS J03 02/10/2014 Workqueue: qla2xxx_wq qla2x00_iocb_work_fn [qla2xxx] RIP: 0010:__list_add_valid+0x41/0x50 Code: 85 94 00 00 00 48 39 c7 74 0b 48 39 d7 74 06 b8 01 00 00 00 c3 48 89 f2 4c 89 c1 48 89 fe 48 c7 c7 60 83 ad 97 e8 4d bd ce ff <0f> 0b 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 48 8b 07 48 8b 57 08 RSP: 0018:ffffaba306f47d68 EFLAGS: 00010046 RAX: 0000000000000058 RBX: ffff9130b5eb8800 RCX: 0000000000000006 RDX: 0000000000000000 RSI: 0000000000000096 RDI: ffff9130b7456a00 RBP: ffff9130c6a70a58 R08: 000000000008d7be R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000001 R12: ffff9130c6a715f0 R13: ffff9130b5eb8824 R14: ffff9130b5eb89f8 R15: ffff9130b5eb89f8 FS: 0000000000000000(0000) GS:ffff9130b7440000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007efcaaef11a0 CR3: 000000005200a002 CR4: 00000000000606e0 Call Trace: qla24xx_async_gnl+0x113/0x3c0 [qla2xxx] ? qla2x00_iocb_work_fn+0x53/0x80 [qla2xxx] ? process_one_work+0x1a7/0x3b0 ? worker_thread+0x30/0x390 ? create_worker+0x1a0/0x1a0 ? kthread+0x112/0x130
--- drivers/scsi/qla2xxx/qla_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +1 -3
@@ -976,8 +976,6 @@ static void qla24xx_async_gnl_sp_done(srb_t *sp, int res) sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1 ], sp->u.iocb_cmd.u.mbx.in_mb[2]); -if (res ==QLA_FUNCTION_TIMEOUT ) -return ; sp->fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE );memset (&ea,0 ,sizeof (ea));
@@ -1015,8 +1013,8 @@ static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags);list_for_each_entry_safe (fcport, tf, &h, gnl_entry) { -list_del_init (&fcport->gnl_entry);spin_lock_irqsave (&vha->hw->tgt.sess_lock, flags); +list_del_init (&fcport->gnl_entry); fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE );spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags); ea.fcport = fcport;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 501/575 scsi: qla2xxx: Turn off target reset during issue_lip
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit 0b7a9fd934a68ebfc1019811b7bdc1742072ad7b ]
When user uses issue_lip to do link bounce, driver sends additional target reset to remote device before resetting the link. The target reset would affect other paths with active I/Os. This patch will remove the unnecessary target reset.
--- drivers/scsi/qla2xxx/qla_gbl.h | 2 -- drivers/scsi/qla2xxx/qla_mr.c | 23 ----------------------- drivers/scsi/qla2xxx/qla_os.c | 27 ++------------------------- 3 files changed, 2 insertions(+), 50 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +0 -2
@@ -158,7 +158,6 @@ extern int ql2xasynctmfenable;extern int ql2xgffidenable;extern int ql2xenabledif;extern int ql2xenablehba_err_chk; -extern int ql2xtargetreset;extern int ql2xdontresethba;extern uint64_t ql2xmaxlun;extern int ql2xmdcapmask;
@@ -791,7 +790,6 @@ extern void qlafx00_abort_iocb(srb_t *, struct abort_iocb_entry_fx00 *);extern void qlafx00_fxdisc_iocb (srb_t *,struct fxdisc_entry_fx00 *);extern void qlafx00_timer_routine (scsi_qla_host_t *);extern int qlafx00_rescan_isp (scsi_qla_host_t *); -extern int qlafx00_loop_reset (scsi_qla_host_t *vha);/* qla82xx related functions */
drivers/scsi/qla2xxx/qla_mr.c +0 -23
@@ -738,29 +738,6 @@ qlafx00_lun_reset(fc_port_t *fcport, uint64_t l, int tag)return qla2x00_async_tm_cmd (fcport,TCF_LUN_RESET , l, tag); } -int -qlafx00_loop_reset (scsi_qla_host_t *vha) -{ -int ret; -struct fc_port *fcport; -struct qla_hw_data *ha = vha->hw; - -if (ql2xtargetreset) { -list_for_each_entry (fcport, &vha->vp_fcports, list) { -if (fcport->port_type !=FCT_TARGET ) -continue ; - - ret = ha->isp_ops->target_reset (fcport,0 ,0 ); -if (ret !=QLA_SUCCESS ) { -ql_dbg (ql_dbg_taskm, vha,0x803d , -"Bus Reset failed: Reset=%d " -"d_id=%x.\n" , ret, fcport->d_id.b24); - } - } - } -return QLA_SUCCESS ; -} -int qlafx00_iospace_config (struct qla_hw_data *ha) {
drivers/scsi/qla2xxx/qla_os.c +2 -25
@@ -197,12 +197,6 @@ MODULE_PARM_DESC(ql2xdbwr," 0 -- Regular doorbell.\n" " 1 -- CAMRAM doorbell (faster).\n"); -int ql2xtargetreset =1 ; -module_param (ql2xtargetreset, int,S_IRUGO ); -MODULE_PARM_DESC (ql2xtargetreset, -"Enable target reset." -"Default is 1 - use hw defaults." ); -int ql2xgffidenable;module_param (ql2xgffidenable, int,S_IRUGO ); MODULE_PARM_DESC(ql2xgffidenable,
@@ -1652,27 +1646,10 @@ int qla2x00_loop_reset(scsi_qla_host_t *vha) {int ret; -struct fc_port *fcport;struct qla_hw_data *ha = vha->hw; -if (IS_QLAFX00 (ha)) { -return qlafx00_loop_reset (vha); - } - -if (ql2xtargetreset ==1 && ha->flags.enable_target_reset) { -list_for_each_entry (fcport, &vha->vp_fcports, list) { -if (fcport->port_type !=FCT_TARGET ) -continue ; - - ret = ha->isp_ops->target_reset (fcport,0 ,0 ); -if (ret !=QLA_SUCCESS ) { -ql_dbg (ql_dbg_taskm, vha,0x802c , -"Bus Reset failed: Reset=%d " -"d_id=%x.\n" , ret, fcport->d_id.b24); - } - } - } - +if (IS_QLAFX00 (ha)) +return QLA_SUCCESS ;if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE (ha)) {atomic_set (&vha->loop_state,LOOP_DOWN );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 502/575 NFSv4: Fix a regression in nfs_set_open_stateid_locked()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 01d29f87fcfef38d51ce2b473981a5c1e861ac0a ]
If we already hold open state on the client, yet the server gives us a completely different stateid to the one we already hold, then we currently treat it as if it were an out-of-sequence update, and wait for 5 seconds for other updates to come in.
This commit fixes the behaviour so that we immediately start processing of the new stateid, and then leave it to the call to nfs4_test_and_free_stateid() to decide what to do with the old stateid.
--- fs/nfs/nfs4proc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/nfs/nfs4proc.c +8 -7
@@ -1590,15 +1590,16 @@ static bool nfs_stateid_is_sequential(struct nfs4_state *state, {if (test_bit (NFS_OPEN_STATE , &state->flags)) {/* The common case - we're updating to a new sequence number */ -if (nfs4_stateid_match_other (stateid, &state->open_stateid) && -nfs4_stateid_is_next (&state->open_stateid, stateid)) { -return true; +if (nfs4_stateid_match_other (stateid, &state->open_stateid)) { +if (nfs4_stateid_is_next (&state->open_stateid, stateid)) +return true; +return false; } - }else { -/* This is the first OPEN in this generation */ -if (stateid->seqid ==cpu_to_be32 (1 )) -return true; +/* The server returned a new stateid */ } +/* This is the first OPEN in this generation */ +if (stateid->seqid ==cpu_to_be32 (1 )) +return true;return false; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 503/575 i2c: xlr: Fix a resource leak in the error handling path of xlr_i2c_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 7f98960c046ee1136e7096aee168eda03aef8a5d ]
A successful 'clk_prepare()' call should be balanced by a corresponding 'clk_unprepare()' call in the error handling path of the probe, as already done in the remove function.
More specifically, 'clk_prepare_enable()' is used, but 'clk_disable()' is also already called. So just the unprepare step has still to be done.
Update the error handling path accordingly.
--- drivers/i2c/busses/i2c-xlr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-xlr.c +5 -1
@@ -431,11 +431,15 @@ static int xlr_i2c_probe(struct platform_device *pdev)i2c_set_adapdata (&priv->adap, priv); ret =i2c_add_numbered_adapter (&priv->adap);if (ret <0 ) -return ret; + goto err_unprepare_clk;platform_set_drvdata (pdev, priv);dev_info (&priv->adap.dev,"Added I2C Bus.\n" );return 0 ; + +err_unprepare_clk: +clk_unprepare (clk); +return ret; }static int xlr_i2c_remove (struct platform_device *pdev)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 504/575 xen-pciback: Fix return in pm_ctrl_init()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 4745ea2628bb43a7ec34b71763b5a56407b33990 ]
Return NULL instead of passing to ERR_PTR while err is zero, this fix smatch warnings:drivers/xen/xen-pciback/conf_space_capability.c:163
pm_ctrl_init() warn: passing zero to 'ERR_PTR'
--- drivers/xen/xen-pciback/conf_space_capability.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/xen-pciback/conf_space_capability.c +1 -1
@@ -160,7 +160,7 @@ static void *pm_ctrl_init(struct pci_dev *dev, int offset) } out: -return ERR_PTR (err); +return err ?ERR_PTR (err) :NULL ; }static const struct config_field caplist_pm[] = {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 505/575 net: davinci_emac: Fix interrupt pacing disable
In reply to Greg Kroah-HartmanFrom: Maxim Kiselev <[email protected]>
[ Upstream commit d52bcb47bdf971a59a2467975d2405fcfcb2fa19 ]
This patch allows to use 0 for coal->rx_coalesce_usecs param to disable rx irq coalescing.
Previously we could enable rx irq coalescing via ethtool (For ex: ethtool -C eth0 rx-usecs 2000) but we couldn't disable it because this part rejects 0 value:
if (!coal->rx_coalesce_usecs)
return -EINVAL;--- drivers/net/ethernet/ti/davinci_emac.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/davinci_emac.c +14 -2
@@ -412,8 +412,20 @@ static int emac_set_coalesce(struct net_device *ndev,u32 int_ctrl, num_interrupts =0 ;u32 prescale =0 , addnl_dvdr =1 , coal_intvl =0 ; -if (!coal->rx_coalesce_usecs) -return -EINVAL ; +if (!coal->rx_coalesce_usecs) { + priv->coal_intvl =0 ; + +switch (priv->version) { +case EMAC_VERSION_2 : +emac_ctrl_write (EMAC_DM646X_CMINTCTRL ,0 ); +break ; +default : +emac_ctrl_write (EMAC_CTRL_EWINTTCNT ,0 ); +break ; + } + +return 0 ; + } coal_intvl = coal->rx_coalesce_usecs;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 506/575 ethtool: fix ethtool msg len calculation for pause stats
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 1aabe578dd86e9f2867c4db4fba9a15f4ba1825d ]
ETHTOOL_A_PAUSE_STAT_MAX is the MAX attribute id, so we need to subtract non-stats and add one to get a count (IOW -2+1 == -1).
Otherwise we'll see:
ethnl cmd 21: calculated reply length 40, but consumed 52
--- include/linux/ethtool_netlink.h | 3 +++ include/uapi/linux/ethtool_netlink.h | 4 +++- net/ethtool/pause.c | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-)
include/linux/ethtool_netlink.h +3 -0
@@ -10,6 +10,9 @@#define __ETHTOOL_LINK_MODE_MASK_NWORDS \ DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32) +#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \ + ETHTOOL_A_PAUSE_STAT_TX_FRAMES) +enum ethtool_multicast_groups {ETHNL_MCGRP_MONITOR , };
include/uapi/linux/ethtool_netlink.h +3 -1
@@ -394,7 +394,9 @@ enum {ETHTOOL_A_PAUSE_STAT_TX_FRAMES ,ETHTOOL_A_PAUSE_STAT_RX_FRAMES , -/* add new constants above here */ +/* add new constants above here +* adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats! +*/ __ETHTOOL_A_PAUSE_STAT_CNT, ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1) };
net/ethtool/pause.c +1 -2
@@ -62,8 +62,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base,if (req_base->flags ÐTOOL_FLAG_STATS ) n +=nla_total_size (0 ) +/* _PAUSE_STATS */ -nla_total_size_64bit (sizeof (u64)) * - (ETHTOOL_A_PAUSE_STAT_MAX -2 ); +nla_total_size_64bit (sizeof (u64)) *ETHTOOL_PAUSE_STAT_CNT ;return n; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 507/575 openrisc: fix SMP tlb flush NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Stafford Horne <[email protected]>
[ Upstream commit 27dff9a9c247d4e38d82c2e7234914cfe8499294 ]
Throughout the OpenRISC kernel port VMA is passed as NULL when flushing kernel tlb entries. Somehow this was missed when I was testing c28b27416da9 ("openrisc: Implement proper SMP tlb flushing") and now the SMP kernel fails to completely boot.
In OpenRISC VMA is used only to determine which cores need to have their TLB entries flushed.
This patch updates the logic to flush tlbs on all cores when the VMA is passed as NULL. Also, we update places VMA is passed as NULL to use flush_tlb_kernel_range instead. Now, the only place VMA is passed as NULL is in the implementation of flush_tlb_kernel_range.
--- arch/openrisc/kernel/dma.c | 4 ++-- arch/openrisc/kernel/smp.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/openrisc/kernel/dma.c +2 -2
@@ -33,7 +33,7 @@ page_set_nocache(pte_t *pte, unsigned long addr,* Flush the page out of the TLB so that the new page flags get * picked up next time there's an access */ -flush_tlb_page (NULL , addr); +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );/* Flush page out of dcache */ for (cl =__pa (addr); cl <__pa (next); cl += cpuinfo->dcache_block_size)
@@ -56,7 +56,7 @@ page_clear_nocache(pte_t *pte, unsigned long addr,* Flush the page out of the TLB so that the new page flags get * picked up next time there's an access */ -flush_tlb_page (NULL , addr); +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );return 0 ; }
arch/openrisc/kernel/smp.c +4 -2
@@ -261,7 +261,7 @@ static inline void ipi_flush_tlb_range(void *info)local_flush_tlb_range (NULL , fd->addr1, fd->addr2); } -static void smp_flush_tlb_range (struct cpumask *cmask,unsigned long start, +static void smp_flush_tlb_range (const struct cpumask *cmask,unsigned long start,unsigned long end) {unsigned int cpuid;
@@ -309,7 +309,9 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) { -smp_flush_tlb_range (mm_cpumask (vma->vm_mm), start, end); +const struct cpumask *cmask = vma ?mm_cpumask (vma->vm_mm) + : cpu_online_mask; +smp_flush_tlb_range (cmask, start, end); }/* Instruction cache invalidate - performed on each cpu */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 508/575 net: vlan: fix a UAF in vlan_dev_real_dev()
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 563bcbae3ba233c275c244bfce2efe12938f5363 ]
The real_dev of a vlan net_device may be freed after unregister_vlan_dev(). Access the real_dev continually by vlan_dev_real_dev() will trigger the UAF problem for the real_dev like following:
==================================================================
BUG: KASAN: use-after-free in vlan_dev_real_dev+0xf9/0x120 Call Trace: kasan_report.cold+0x83/0xdf vlan_dev_real_dev+0xf9/0x120 is_eth_port_of_netdev_filter.part.0+0xb1/0x2c0 is_eth_port_of_netdev_filter+0x28/0x40 ib_enum_roce_netdev+0x1a3/0x300 ib_enum_all_roce_netdevs+0xc7/0x140 netdevice_event_work_handler+0x9d/0x210
...
Freed by task 9288: kasan_save_stack+0x1b/0x40 kasan_set_track+0x1c/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0xfc/0x130 slab_free_freelist_hook+0xdd/0x240 kfree+0xe4/0x690 kvfree+0x42/0x50 device_release+0x9f/0x240 kobject_put+0x1c8/0x530 put_device+0x1b/0x30 free_netdev+0x370/0x540 ppp_destroy_interface+0x313/0x3d0
...
Move the put_device(real_dev) to vlan_dev_free(). Ensure real_dev not be freed before vlan_dev unregistered.
--- net/8021q/vlan.c | 3 --- net/8021q/vlan_dev.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
net/8021q/vlan.c +0 -3
@@ -120,9 +120,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) }vlan_vid_del (real_dev, vlan->vlan_proto, vlan_id); - -/* Get rid of the vlan's reference to real_dev */ -dev_put (real_dev); } int vlan_check_real_dev(struct net_device *real_dev,
net/8021q/vlan_dev.c +3 -0
@@ -813,6 +813,9 @@ static void vlan_dev_free(struct net_device *dev)free_percpu (vlan->vlan_pcpu_stats); vlan->vlan_pcpu_stats =NULL ; + +/* Get rid of the vlan's reference to real_dev */ +dev_put (vlan->real_dev); }void vlan_setup (struct net_device *dev)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 509/575 ice: Fix replacing VF hardware MAC to existing MAC filter
In reply to Greg Kroah-HartmanFrom: Sylwester Dziedziuch <[email protected]>
[ Upstream commit ce572a5b88d5ca6737b5e23da9892792fd708ad3 ]
VF was not able to change its hardware MAC address in case the new address was already present in the MAC filter list. Change the handling of VF add mac request to not return if requested MAC address is already present on the list and check if its hardware MAC needs to be updated in this case.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +9 -5
@@ -3068,6 +3068,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr) {struct device *dev =ice_pf_to_dev (vf->pf);enum ice_status status; +int ret =0 ;/* default unicast MAC already added */ if (ether_addr_equal (mac_addr, vf->dflt_lan_addr.addr))
@@ -3080,13 +3081,18 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr) status =ice_fltr_add_mac (vsi, mac_addr,ICE_FWD_TO_VSI );if (status ==ICE_ERR_ALREADY_EXISTS ) { -dev_err (dev,"MAC %pM already exists for VF %d\n" , mac_addr, +dev_dbg (dev,"MAC %pM already exists for VF %d\n" , mac_addr, vf->vf_id); -return -EEXIST ; +/* don't return since we might need to update +* the primary MAC in ice_vfhw_mac_add() below +*/ + ret = -EEXIST ; }else if (status) {dev_err (dev,"Failed to add MAC %pM for VF %d\n, error %s\n" , mac_addr, vf->vf_id,ice_stat_str (status));return -EIO ; + }else { + vf->num_mac++; }/* Set the default LAN address to the latest unicast MAC address added
@@ -3096,9 +3102,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr)if (is_unicast_ether_addr (mac_addr))ether_addr_copy (vf->dflt_lan_addr.addr, mac_addr); - vf->num_mac++; - -return 0 ; +return ret; }/**
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 510/575 ice: Fix not stopping Tx queues for VFs
In reply to Greg Kroah-HartmanFrom: Brett Creeley <[email protected]>
[ Upstream commit b385cca47363316c6d9a74ae9db407bbc281f815 ]
When a VF is removed and/or reset its Tx queues need to be stopped from the PF. This is done by calling the ice_dis_vf_qs() function, which calls ice_vsi_stop_lan_tx_rings(). Currently ice_dis_vf_qs() is protected by the VF state bit ICE_VF_STATE_QS_ENA. Unfortunately, this is causing the Tx queues to not be disabled in some cases and when the VF tries to re-enable/reconfigure its Tx queues over virtchnl the op is failing. This is because a VF can be reset and/or removed before the ICE_VF_STATE_QS_ENA bit is set, but the Tx queues were already configured via ice_vsi_cfg_single_txq() in the VIRTCHNL_OP_CONFIG_VSI_QUEUES op. However, the ICE_VF_STATE_QS_ENA bit is set on a successful VIRTCHNL_OP_ENABLE_QUEUES, which will always happen after the VIRTCHNL_OP_CONFIG_VSI_QUEUES op.
This was causing the following error message when loading the ice driver, creating VFs, and modifying VF trust in an endless loop:
[35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5 [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
Fix this by always calling ice_dis_vf_qs() and silencing the error message in ice_vsi_stop_tx_ring() since the calling code ignores the return anyway. Also, all other places that call ice_vsi_stop_tx_ring() catch the error, so this doesn't affect those flows since there was no change to the values the function returns.
Other solutions were considered (i.e. tracking which VF queues had been "started/configured" in VIRTCHNL_OP_CONFIG_VSI_QUEUES, but it seemed more complicated than it was worth. This solution also brings in the chance for other unexpected conditions due to invalid state bit checks. So, the proposed solution seemed like the best option since there is no harm in failing to stop Tx queues that were never started.
This issue can be seen using the following commands:
for i in {0..50}; do
rmmod ice
modprobe ice
sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
sleep 2
echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs sleep 1
echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
ip link set ens785f1 vf 0 trust on
ip link set ens785f0 vf 0 trust on
done
--- drivers/net/ethernet/intel/ice/ice_base.c | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +1 -1
@@ -839,7 +839,7 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, }else if (status ==ICE_ERR_DOES_NOT_EXIST ) {dev_dbg (ice_pf_to_dev (vsi->back),"LAN Tx queues do not exist, nothing to disable\n" ); }else if (status) { -dev_err (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" , +dev_dbg (ice_pf_to_dev (vsi->back),"Failed to disable LAN Tx queues, error: %s\n" ,ice_stat_str (status));return -ENODEV ; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +2 -4
@@ -362,8 +362,7 @@ void ice_free_vfs(struct ice_pf *pf)/* Avoid wait time by stopping all VFs at the same time */ ice_for_each_vf (pf, i) -if (test_bit (ICE_VF_STATE_QS_ENA , pf->vf[i].vf_states)) -ice_dis_vf_qs (&pf->vf[i]); +ice_dis_vf_qs (&pf->vf[i]); tmp = pf->num_alloc_vfs; pf->num_qps_per_vf =0 ;
@@ -1291,8 +1290,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) vsi = pf->vsi[vf->lan_vsi_idx]; -if (test_bit (ICE_VF_STATE_QS_ENA , vf->vf_states)) -ice_dis_vf_qs (vf); +ice_dis_vf_qs (vf);/* Call Disable LAN Tx queue AQ whether or not queues are * enabled. This is needed for successful completion of VFR.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 511/575 ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 009a789443fe4c8e6b1ecb7c16b4865c026184cd ]
The handling of PMIC register reads through writing 0 to address 4 of the OpRegion is wrong. Instead of returning the read value through the value64, which is a no-op for function == ACPI_WRITE calls, store the value and then on a subsequent function == ACPI_READ with address == 3 (the address for the value field of the OpRegion) return the stored value.
This has been tested on a Xiaomi Mi Pad 2 and makes the ACPI battery dev there mostly functional (unfortunately there are still other issues).
Here are the SET() / GET() functions of the PMIC ACPI device, which use this OpRegion, which clearly show the new behavior to be correct:
OperationRegion (REGS, 0x8F, Zero, 0x50)
Field (REGS, ByteAcc, NoLock, Preserve)
{
CLNT, 8,
SA, 8,
OFF, 8,
VAL, 8,
RWM, 8
}Method (GET, 3, Serialized)
{
If ((AVBE == One))
{
CLNT = Arg0
SA = Arg1
OFF = Arg2
RWM = Zero
If ((AVBG == One))
{
GPRW = Zero
}
}
Return (VAL) /* \_SB_.PCI0.I2C7.PMI5.VAL_ */
}Method (SET, 4, Serialized)
{
If ((AVBE == One))
{
CLNT = Arg0
SA = Arg1
OFF = Arg2
VAL = Arg3
RWM = One
If ((AVBG == One))
{
GPRW = One
}
}
}
--- drivers/acpi/pmic/intel_pmic.c | 51 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 23 deletions(-)
drivers/acpi/pmic/intel_pmic.c +28 -23
@@ -211,31 +211,36 @@ static acpi_status intel_pmic_regs_handler(u32 function, void *handler_context, void *region_context) { struct intel_pmic_opregion *opregion = region_context; -int result =0 ; +int result = -EINVAL ; + +if (function ==ACPI_WRITE ) { +switch (address) { +case 0 : +return AE_OK ; +case 1 : + opregion->ctx.addr |= (*value64 &0xff ) <<8 ; +return AE_OK ; +case 2 : + opregion->ctx.addr |= *value64 &0xff ; +return AE_OK ; +case 3 : + opregion->ctx.val = *value64 &0xff ; +return AE_OK ; +case 4 : +if (*value64) { + result =regmap_write (opregion->regmap, opregion->ctx.addr, + opregion->ctx.val); + }else { + result =regmap_read (opregion->regmap, opregion->ctx.addr, + &opregion->ctx.val); + } + opregion->ctx.addr =0 ; + } + } -switch (address) { -case 0 : -return AE_OK ; -case 1 : - opregion->ctx.addr |= (*value64 &0xff ) <<8 ; -return AE_OK ; -case 2 : - opregion->ctx.addr |= *value64 &0xff ; +if (function ==ACPI_READ && address ==3 ) { + *value64 = opregion->ctx.val;return AE_OK ; -case 3 : - opregion->ctx.val = *value64 &0xff ; -return AE_OK ; -case 4 : -if (*value64) { - result =regmap_write (opregion->regmap, opregion->ctx.addr, - opregion->ctx.val); - }else { - result =regmap_read (opregion->regmap, opregion->ctx.addr, - &opregion->ctx.val); -if (result ==0 ) - *value64 = opregion->ctx.val; - } -memset (&opregion->ctx,0x00 ,sizeof (opregion->ctx)); }if (result <0 ) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 512/575 drm/nouveau/svm: Fix refcount leak bug and missing check against null bug
In reply to Greg Kroah-HartmanFrom: Chenyuan Mi <[email protected]>
[ Upstream commit 6bb8c2d51811eb5e6504f49efe3b089d026009d2 ]
The reference counting issue happens in one exception handling path of nouveau_svmm_bind(). When cli->svm.svmm is null, the function forgets to decrease the refcount of mm increased by get_task_mm(), causing a refcount leak.
Fix this issue by using mmput() to decrease the refcount in the exception handling path.
Also, the function forgets to do check against null when get mm by get_task_mm().
Fix this issue by adding null check after get mm by get_task_mm().
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/nouveau/nouveau_svm.c +4 -0
@@ -156,10 +156,14 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,*/ mm =get_task_mm (current); +if (!mm) { +return -EINVAL ; + }mmap_read_lock (mm);if (!cli->svm.svmm) {mmap_read_unlock (mm); +mmput (mm);return -EINVAL ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 513/575 block/ataflop: use the blk_cleanup_disk() helper
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 44a469b6acae6ad05c4acca8429467d1d50a8b8d ]
Use the helper to replace two lines with one.
--- drivers/block/ataflop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/block/ataflop.c +2 -4
@@ -2102,8 +2102,7 @@ static int __init atari_floppy_init (void) err:while (--i >=0 ) { -blk_cleanup_queue (unit[i].disk[0 ]->queue); -put_disk (unit[i].disk[0 ]); +blk_cleanup_disk (unit[i].disk[0 ]);blk_mq_free_tag_set (&unit[i].tag_set); }
@@ -2161,8 +2160,7 @@ static void __exit atari_floppy_exit(void)if (!unit[i].disk[type])continue ;del_gendisk (unit[i].disk[type]); -blk_cleanup_queue (unit[i].disk[type]->queue); -put_disk (unit[i].disk[type]); +blk_cleanup_disk (unit[i].disk[type]); }blk_mq_free_tag_set (&unit[i].tag_set); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 514/575 block/ataflop: add registration bool before calling del_gendisk()
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 573effb298011d3fcabc9b12025cf637f8a07911 ]
The ataflop assumes del_gendisk() is safe to call, this is only true because add_disk() does not return a failure, but that will change soon. And so, before we get to adding error handling for that case, let's make sure we keep track of which disks actually get registered. Then we use this to only call del_gendisk for them.
--- drivers/block/ataflop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/block/ataflop.c +7 -2
@@ -298,6 +298,7 @@ static struct atari_floppy_struct {disk change detection) */ int flags;/* flags */ struct gendisk *disk[NUM_DISK_MINORS ]; +bool registered[NUM_DISK_MINORS ];int ref;int type;struct blk_mq_tag_set tag_set;
@@ -2026,8 +2027,10 @@ static void ataflop_probe(dev_t dev)return ;mutex_lock (&ataflop_probe_lock);if (!unit[drive].disk[type]) { -if (ataflop_alloc_disk (drive, type) ==0 ) +if (ataflop_alloc_disk (drive, type) ==0 ) {add_disk (unit[drive].disk[type]); + unit[drive].registered[type] = true; + } }mutex_unlock (&ataflop_probe_lock); }
@@ -2091,6 +2094,7 @@ static int __init atari_floppy_init (void) unit[i].track =-1 ; unit[i].flags =0 ;add_disk (unit[i].disk[0 ]); + unit[i].registered[0 ] = true; } printk(KERN_INFO "Atari floppy driver: max. %cD, %strack buffering\n",
@@ -2159,7 +2163,8 @@ static void __exit atari_floppy_exit(void)for (type =0 ; type <NUM_DISK_MINORS ; type++) {if (!unit[i].disk[type])continue ; -del_gendisk (unit[i].disk[type]); +if (unit[i].registered[type]) +del_gendisk (unit[i].disk[type]);blk_cleanup_disk (unit[i].disk[type]); }blk_mq_free_tag_set (&unit[i].tag_set);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 515/575 block/ataflop: provide a helper for cleanup up an atari disk
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit deae1138d04758c7f8939fcb8aee330bc37e3015 ]
Instead of using two separate code paths for cleaning up an atari disk, use one. We take the more careful approach to check for *all* disk types, as is done on exit. The init path didn't have that check as the alternative disk types are only probed for later, they are not initialized by default.
Yes, there is a shared tag for all disks.
--- drivers/block/ataflop.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/block/ataflop.c +19 -15
@@ -2035,6 +2035,20 @@ static void ataflop_probe(dev_t dev)mutex_unlock (&ataflop_probe_lock); } +static void atari_cleanup_floppy_disk (struct atari_floppy_struct *fs) +{ +int type; + +for (type =0 ; type <NUM_DISK_MINORS ; type++) { +if (!fs->disk[type]) +continue ; +if (fs->registered[type]) +del_gendisk (fs->disk[type]); +blk_cleanup_disk (fs->disk[type]); + } +blk_mq_free_tag_set (&fs->tag_set); +} +static int __init atari_floppy_init (void ) {int i;
@@ -2105,10 +2119,8 @@ static int __init atari_floppy_init (void)return 0 ; err: -while (--i >=0 ) { -blk_cleanup_disk (unit[i].disk[0 ]); -blk_mq_free_tag_set (&unit[i].tag_set); - } +while (--i >=0 ) +atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" ); out_unlock:
@@ -2157,18 +2169,10 @@ __setup("floppy=", atari_floppy_setup); static void __exit atari_floppy_exit(void) { -int i, type; +int i; -for (i =0 ; i <FD_MAX_UNITS ; i++) { -for (type =0 ; type <NUM_DISK_MINORS ; type++) { -if (!unit[i].disk[type]) -continue ; -if (unit[i].registered[type]) -del_gendisk (unit[i].disk[type]); -blk_cleanup_disk (unit[i].disk[type]); - } -blk_mq_free_tag_set (&unit[i].tag_set); - } +for (i =0 ; i <FD_MAX_UNITS ; i++) +atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" );del_timer_sync (&fd_timer);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 516/575 ataflop: remove ataflop_probe_lock mutex
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 4ddb85d36613c45bde00d368bf9f357bd0708a0c ]
Commit bf9c0538e485b591 ("ataflop: use a separate gendisk for each media format") introduced ataflop_probe_lock mutex, but forgot to unlock the mutex when atari_floppy_init() (i.e. module loading) succeeded. This will result in double lock deadlock if ataflop_probe() is called. Also, unregister_blkdev() must not be called from atari_floppy_init() with ataflop_probe_lock held when atari_floppy_init() failed, for ataflop_probe() waits for ataflop_probe_lock with major_names_lock held (i.e. AB-BA deadlock).
__register_blkdev() needs to be called last in order to avoid calling ataflop_probe() when atari_floppy_init() is about to fail, for memory for completing already-started ataflop_probe() safely will be released as soon as atari_floppy_init() released ataflop_probe_lock mutex.
As with commit 8b52d8be86d72308 ("loop: reorder loop_exit"), unregister_blkdev() needs to be called first in order to avoid calling ataflop_alloc_disk() from ataflop_probe() after del_gendisk() from atari_floppy_exit().
By relocating __register_blkdev() / unregister_blkdev() as explained above, we can remove ataflop_probe_lock mutex, for probe function and __exit function are serialized by major_names_lock mutex.
--- drivers/block/ataflop.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-)
drivers/block/ataflop.c +27 -20
@@ -2016,8 +2016,6 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type)return 0 ; } -static DEFINE_MUTEX (ataflop_probe_lock); -static void ataflop_probe (dev_t dev) {int drive =MINOR (dev) &3 ;
@@ -2025,14 +2023,32 @@ static void ataflop_probe(dev_t dev)if (drive >=FD_MAX_UNITS || type >NUM_DISK_MINORS )return ; -mutex_lock (&ataflop_probe_lock);if (!unit[drive].disk[type]) {if (ataflop_alloc_disk (drive, type) ==0 ) {add_disk (unit[drive].disk[type]); unit[drive].registered[type] = true; } } -mutex_unlock (&ataflop_probe_lock); +} + +static void atari_floppy_cleanup (void ) +{ +int i; +int type; + +for (i =0 ; i <FD_MAX_UNITS ; i++) { +for (type =0 ; type <NUM_DISK_MINORS ; type++) { +if (!unit[i].disk[type]) +continue ; +del_gendisk (unit[i].disk[type]); +blk_cleanup_queue (unit[i].disk[type]->queue); +put_disk (unit[i].disk[type]); + } +blk_mq_free_tag_set (&unit[i].tag_set); + } + +del_timer_sync (&fd_timer); +atari_stram_free (DMABuffer); }static void atari_cleanup_floppy_disk (struct atari_floppy_struct *fs)
@@ -2058,11 +2074,6 @@ static int __init atari_floppy_init (void)/* Amiga, Mac, ... don't have Atari-compatible floppy :-) */ return -ENODEV ; -mutex_lock (&ataflop_probe_lock); - ret =__register_blkdev (FLOPPY_MAJOR ,"fd" , ataflop_probe); -if (ret) - goto out_unlock; -for (i =0 ; i <FD_MAX_UNITS ; i++) {memset (&unit[i].tag_set,0 ,sizeof (unit[i].tag_set)); unit[i].tag_set.ops = &ataflop_mq_ops;
@@ -2116,15 +2127,17 @@ static int __init atari_floppy_init (void) UseTrackbuffer ? "" : "no ");config_types (); -return 0 ; + ret =__register_blkdev (FLOPPY_MAJOR ,"fd" , ataflop_probe); +if (ret) { +printk (KERN_ERR "atari_floppy_init: cannot register block device\n" ); +atari_floppy_cleanup (); + } +return ret; err:while (--i >=0 )atari_cleanup_floppy_disk (&unit[i]); -unregister_blkdev (FLOPPY_MAJOR ,"fd" ); -out_unlock: -mutex_unlock (&ataflop_probe_lock);return ret; }
@@ -2169,14 +2182,8 @@ __setup("floppy=", atari_floppy_setup); static void __exit atari_floppy_exit(void) { -int i; - -for (i =0 ; i <FD_MAX_UNITS ; i++) -atari_cleanup_floppy_disk (&unit[i]);unregister_blkdev (FLOPPY_MAJOR ,"fd" ); - -del_timer_sync (&fd_timer); -atari_stram_free ( DMABuffer ); +atari_floppy_cleanup (); }module_init (atari_floppy_init)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 517/575 net: phy: fix duplex out of sync problem while changing settings
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit a4db9055fdb9cf607775c66d39796caf6439ec92 ]
As reported by Zhang there's a small issue if in forced mode the duplex mode changes with the link staying up [0]. In this case the MAC isn't notified about the change.
The proposed patch relies on the phylib state machine and ignores the fact that there are drivers that uses phylib but not the phylib state machine. So let's don't change the behavior for such drivers and fix it w/o re-adding state PHY_FORCING for the case that phylib state machine is used.
[0] https://lore.kernel.org/netdev/[email protected]/T/
--- drivers/net/phy/phy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/phy/phy.c +6 -1
@@ -831,7 +831,12 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;/* Restart the PHY */ -_phy_start_aneg (phydev); +if (phy_is_started (phydev)) { + phydev->state =PHY_UP ; +phy_trigger_machine (phydev); + }else { +_phy_start_aneg (phydev); + }mutex_unlock (&phydev->lock);return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 518/575 bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed
In reply to Greg Kroah-HartmanFrom: Huang Guobin <[email protected]>
[ Upstream commit b93c6a911a3fe926b00add28f3b932007827c4ca ]
When I do fuzz test for bonding device interface, I got the following use-after-free Calltrace:
==================================================================
BUG: KASAN: use-after-free in bond_enslave+0x1521/0x24f0
Read of size 8 at addr ffff88825bc11c00 by task ifenslave/7365
CPU: 5 PID: 7365 Comm: ifenslave Tainted: G E 5.15.0-rc1+ #13
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
Call Trace:
dump_stack_lvl+0x6c/0x8b
print_address_description.constprop.0+0x48/0x70
kasan_report.cold+0x82/0xdb
__asan_load8+0x69/0x90
bond_enslave+0x1521/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f19159cf577
Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 78
RSP: 002b:00007ffeb3083c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffeb3084bca RCX: 00007f19159cf577
RDX: 00007ffeb3083ce0 RSI: 0000000000008990 RDI: 0000000000000003
RBP: 00007ffeb3084bc4 R08: 0000000000000040 R09: 0000000000000000
R10: 00007ffeb3084bc0 R11: 0000000000000246 R12: 00007ffeb3083ce0
R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffeb3083cb0
Allocated by task 7365:
kasan_save_stack+0x23/0x50
__kasan_kmalloc+0x83/0xa0
kmem_cache_alloc_trace+0x22e/0x470
bond_enslave+0x2e1/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 7365:
kasan_save_stack+0x23/0x50
kasan_set_track+0x20/0x30
kasan_set_free_info+0x24/0x40
__kasan_slab_free+0xf2/0x130
kfree+0xd1/0x5c0
slave_kobj_release+0x61/0x90
kobject_put+0x102/0x180
bond_sysfs_slave_add+0x7a/0xa0
bond_enslave+0x11b6/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
Last potentially related work creation:
kasan_save_stack+0x23/0x50
kasan_record_aux_stack+0xb7/0xd0
insert_work+0x43/0x190
__queue_work+0x2e3/0x970
delayed_work_timer_fn+0x3e/0x50
call_timer_fn+0x148/0x470
run_timer_softirq+0x8a8/0xc50
__do_softirq+0x107/0x55f
Second to last potentially related work creation:
kasan_save_stack+0x23/0x50
kasan_record_aux_stack+0xb7/0xd0
insert_work+0x43/0x190
__queue_work+0x2e3/0x970
__queue_delayed_work+0x130/0x180
queue_delayed_work_on+0xa7/0xb0
bond_enslave+0xe25/0x24f0
bond_do_ioctl+0x3e0/0x450
dev_ifsioc+0x2ba/0x970
dev_ioctl+0x112/0x710
sock_do_ioctl+0x118/0x1b0
sock_ioctl+0x2e0/0x490
__x64_sys_ioctl+0x118/0x150
do_syscall_64+0x35/0xb0
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff88825bc11c00
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
1024-byte region [ffff88825bc11c00, ffff88825bc12000)
The buggy address belongs to the page:
page:ffffea00096f0400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25bc10
head:ffffea00096f0400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff)
raw: 057ff00000010200 ffffea0009a71c08 ffff888240001968 ffff88810004dbc0
raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88825bc11b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88825bc11b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88825bc11c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88825bc11c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88825bc11d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Put new_slave in bond_sysfs_slave_add() will cause use-after-free problems when new_slave is accessed in the subsequent error handling process. Since new_slave will be put in the subsequent error handling process, remove the unnecessary put to fix it.
In addition, when sysfs_create_file() fails, if some files have been crea- ted successfully, we need to call sysfs_remove_file() to remove them. Since there are sysfs_create_files() & sysfs_remove_files() can be used, use these two functions instead.
--- drivers/net/bonding/bond_sysfs_slave.c | 36 ++++++++------------------ 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/net/bonding/bond_sysfs_slave.c +11 -25
@@ -108,15 +108,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf) }static SLAVE_ATTR_RO (ad_partner_oper_port_state); -static const struct slave_attribute *slave_attrs[] = { - &slave_attr_state, - &slave_attr_mii_status, - &slave_attr_link_failure_count, - &slave_attr_perm_hwaddr, - &slave_attr_queue_id, - &slave_attr_ad_aggregator_id, - &slave_attr_ad_actor_oper_port_state, - &slave_attr_ad_partner_oper_port_state, +static const struct attribute *slave_attrs[] = { + &slave_attr_state.attr, + &slave_attr_mii_status.attr, + &slave_attr_link_failure_count.attr, + &slave_attr_perm_hwaddr.attr, + &slave_attr_queue_id.attr, + &slave_attr_ad_aggregator_id.attr, + &slave_attr_ad_actor_oper_port_state.attr, + &slave_attr_ad_partner_oper_port_state.attr,NULL };
@@ -137,24 +137,10 @@ const struct sysfs_ops slave_sysfs_ops = {int bond_sysfs_slave_add (struct slave *slave) { -const struct slave_attribute **a; -int err; - -for (a = slave_attrs; *a; ++a) { - err =sysfs_create_file (&slave->kobj, &((*a)->attr)); -if (err) { -kobject_put (&slave->kobj); -return err; - } - } - -return 0 ; +return sysfs_create_files (&slave->kobj, slave_attrs); }void bond_sysfs_slave_del (struct slave *slave) { -const struct slave_attribute **a; - -for (a = slave_attrs; *a; ++a) -sysfs_remove_file (&slave->kobj, &((*a)->attr)); +sysfs_remove_files (&slave->kobj, slave_attrs); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 519/575 mfd: core: Add missing of_node_put for loop iteration
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 002be81140075e17a1ebd5c3c55e356fbab0ddad ]
Early exits from for_each_child_of_node() should decrement the node reference counter. Reported by Coccinelle:
drivers/mfd/mfd-core.c:197:2-24: WARNING:
Function "for_each_child_of_node" should have of_node_put() before goto around lines 209.
--- drivers/mfd/mfd-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/mfd-core.c +2 -0
@@ -210,6 +210,7 @@ static int mfd_add_device(struct device *parent, int id,if (of_device_is_compatible (np, cell->of_compatible)) {/* Ignore 'disabled' devices error free */ if (!of_device_is_available (np)) { +of_node_put (np); ret =0 ; goto fail_alias; }
@@ -217,6 +218,7 @@ static int mfd_add_device(struct device *parent, int id, ret =mfd_match_of_node_to_dev (pdev, np, cell);if (ret == -EAGAIN )continue ; +of_node_put (np);if (ret) goto fail_alias;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 520/575 can: mcp251xfd: mcp251xfd_chip_start(): fix error handling for mcp251xfd_chip_rx_int_enable()
In reply to Greg Kroah-HartmanFrom: Marc Kleine-Budde <[email protected]>
[ Upstream commit 69c55f6e7669d46bb40e41f6e2b218428178368a ]
This patch fixes the error handling for mcp251xfd_chip_rx_int_enable(). Instead just returning the error, properly shut down the chip.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +1 -1
@@ -1041,7 +1041,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) err =mcp251xfd_chip_rx_int_enable (priv);if (err) -return err; + goto out_chip_stop; err =mcp251xfd_chip_ecc_init (priv);if (err)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 521/575 mm/zsmalloc.c: close race window between zs_pool_dec_isolated() and zs_unregister_migration()
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit afe8605ca45424629fdddfd85984b442c763dc47 ]
There is one possible race window between zs_pool_dec_isolated() and zs_unregister_migration() because wait_for_isolated_drain() checks the isolated count without holding class->lock and there is no order inside zs_pool_dec_isolated(). Thus the below race window could be possible:
zs_pool_dec_isolated zs_unregister_migration
check pool->destroying != 0
pool->destroying = true;
smp_mb();
wait_for_isolated_drain()
wait for pool->isolated_pages == 0
atomic_long_dec(&pool->isolated_pages);
atomic_long_read(&pool->isolated_pages) == 0Since we observe the pool->destroying (false) before atomic_long_dec() for pool->isolated_pages, waking pool->migration_wait up is missed.
Fix this by ensure checking pool->destroying happens after the atomic_long_dec(&pool->isolated_pages).
--- mm/zsmalloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
mm/zsmalloc.c +4 -3
@@ -1835,10 +1835,11 @@ static inline void zs_pool_dec_isolated(struct zs_pool *pool)VM_BUG_ON (atomic_long_read (&pool->isolated_pages) <=0 );atomic_long_dec (&pool->isolated_pages);/* -* There's no possibility of racing, since wait_for_isolated_drain() -* checks the isolated count under &class->lock after enqueuing -* on migration_wait. +* Checking pool->destroying must happen after atomic_long_dec() +* for pool->isolated_pages above. Paired with the smp_mb() in +* zs_unregister_migration(). */ +smp_mb__after_atomic ();if (atomic_long_read (&pool->isolated_pages) ==0 && pool->destroying)wake_up_all (&pool->migration_wait); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 522/575 zram: off by one in read_block_state()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a88e03cf3d190cf46bc4063a9b7efe87590de5f4 ]
snprintf() returns the number of bytes it would have printed if there were space. But it does not count the NUL terminator. So that means that if "count == copied" then this has already overflowed by one character.
This bug likely isn't super harmful in real life.
--- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +1 -1
@@ -907,7 +907,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,zram_test_flag (zram, index,ZRAM_HUGE ) ?'h' :'.' , zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.'); -if (count < copied) { +if (count <= copied) {zram_slot_unlock (zram, index);break ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 523/575 perf bpf: Add missing free to bpf_event__print_bpf_prog_info()
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit 88c42f4d6cb249eb68524282f8d4cc32f9059984 ]
If btf__new() is called then there needs to be a corresponding btf__free().
--- tools/perf/util/bpf-event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/bpf-event.c +3 -1
@@ -557,7 +557,7 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,synthesize_bpf_prog_name (name,KSYM_NAME_LEN , info, btf,0 );fprintf (fp,"# bpf_prog_info %u: %s addr 0x%llx size %u\n" , info->id, name, prog_addrs[0 ], prog_lens[0 ]); -return ; + goto out; }fprintf (fp,"# bpf_prog_info %u:\n" , info->id);
@@ -567,4 +567,6 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,fprintf (fp,"# \tsub_prog %u: %s addr 0x%llx size %u\n" , i, name, prog_addrs[i], prog_lens[i]); } +out: +btf__free (btf); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 524/575 llc: fix out-of-bound array index in llc_sk_dev_hash()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 8ac9dfd58b138f7e82098a4e0a0d46858b12215b ]
Both ifindex and LLC_SK_DEV_HASH_ENTRIES are signed.
This means that (ifindex % LLC_SK_DEV_HASH_ENTRIES) is negative if @ifindex is negative.
We could simply make LLC_SK_DEV_HASH_ENTRIES unsigned.
In this patch I chose to use hash_32() to get more entropy from @ifindex, like llc_sk_laddr_hashfn().
UBSAN: array-index-out-of-bounds in ./include/net/llc.h:75:26 index -43 is out of range for type 'hlist_head [64]' CPU: 1 PID: 20999 Comm: syz-executor.3 Not tainted 5.15.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 ubsan_epilogue+0xb/0x5a lib/ubsan.c:151 __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291 llc_sk_dev_hash include/net/llc.h:75 [inline] llc_sap_add_socket+0x49c/0x520 net/llc/llc_conn.c:697 llc_ui_bind+0x680/0xd70 net/llc/af_llc.c:404 __sys_bind+0x1e9/0x250 net/socket.c:1693 __do_sys_bind net/socket.c:1704 [inline] __se_sys_bind net/socket.c:1702 [inline] __x64_sys_bind+0x6f/0xb0 net/socket.c:1702 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fa503407ae9
--- include/net/llc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/net/llc.h +3 -1
@@ -72,7 +72,9 @@ struct llc_sap {static inline struct hlist_head *llc_sk_dev_hash (struct llc_sap *sap,int ifindex) { -return &sap->sk_dev_hash[ifindex %LLC_SK_DEV_HASH_ENTRIES ]; +u32 bucket =hash_32 (ifindex,LLC_SK_DEV_HASH_BITS ); + +return &sap->sk_dev_hash[bucket]; } static inline
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 525/575 nfc: pn533: Fix double free when pn533_fill_fragment_skbs() fails
In reply to Greg Kroah-HartmanFrom: Chengfeng Ye <[email protected]>
[ Upstream commit 9fec40f850658e00a14a7dd9e06f7fbc7e59cc4a ]
skb is already freed by dev_kfree_skb in pn533_fill_fragment_skbs, but follow error handler branch when pn533_fill_fragment_skbs() fails, skb is freed again, results in double free issue. Fix this by not free skb in error path of pn533_fill_fragment_skbs.
--- drivers/nfc/pn533/pn533.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nfc/pn533/pn533.c +3 -3
@@ -2258,7 +2258,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb) frag =pn533_alloc_skb (dev, frag_size);if (!frag) {skb_queue_purge (&dev->fragment_skb); -break ; +return -ENOMEM ; }if (!dev->tgt_mode) {
@@ -2329,7 +2329,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,/* jumbo frame ? */ if (skb->len >PN533_CMD_DATAEXCH_DATA_MAXLEN ) { rc =pn533_fill_fragment_skbs (dev, skb); -if (rc <=0 ) +if (rc <0 ) goto error; skb =skb_dequeue (&dev->fragment_skb);
@@ -2401,7 +2401,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)/* let's split in multiple chunks if size's too big */ if (skb->len >PN533_CMD_DATAEXCH_DATA_MAXLEN ) { rc =pn533_fill_fragment_skbs (dev, skb); -if (rc <=0 ) +if (rc <0 ) goto error;/* get the first skb */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 526/575 arm64: pgtable: make __pte_to_phys/__phys_to_pte_val inline functions
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit c7c386fbc20262c1d911c615c65db6a58667d92c ]
gcc warns about undefined behavior the vmalloc code when building with CONFIG_ARM64_PA_BITS_52, when the 'idx++' in the argument to __phys_to_pte_val() is evaluated twice:
mm/vmalloc.c: In function 'vmap_pfn_apply':mm/vmalloc.c:2800:58: error: operation on 'data->idx' may be undefined [-Werror=sequence-point]
2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ~~~~~~~~~^~arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
25 | #define __pte(x) ((pte_t) { (x) } )
| ^arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val'
80 | __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
| ^~~~~~~~~~~~~~~~~
mm/vmalloc.c:2800:30: note: in expansion of macro 'pfn_pte'
2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ^~~~~~~
I have no idea why this never showed up earlier, but the safest workaround appears to be changing those macros into inline functions so the arguments get evaluated only once.
--- arch/arm64/include/asm/pgtable.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/arm64/include/asm/pgtable.h +9 -3
@@ -69,9 +69,15 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];* page table entry, taking care of 52-bit addresses. */ #ifdef CONFIG_ARM64_PA_BITS_52 -#define __pte_to_phys (pte) \ - ((pte_val(pte) & PTE_ADDR_LOW) | ((pte_val(pte) & PTE_ADDR_HIGH) << 36)) -#define __phys_to_pte_val (phys) (((phys) | ((phys) >> 36)) & PTE_ADDR_MASK) +static inline phys_addr_t __pte_to_phys (pte_t pte) +{ +return (pte_val (pte) &PTE_ADDR_LOW ) | + ((pte_val (pte) &PTE_ADDR_HIGH ) <<36 ); +} +static inline pteval_t __phys_to_pte_val (phys_addr_t phys) +{ +return (phys | (phys >>36 )) &PTE_ADDR_MASK ; +}#else #define __pte_to_phys (pte) (pte_val(pte) & PTE_ADDR_MASK)#define __phys_to_pte_val (phys) (phys)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 527/575 bpf, sockmap: Remove unhash handler for BPF sockmap usage
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit b8b8315e39ffaca82e79d86dde26e9144addf66b ]
We do not need to handle unhash from BPF side we can simply wait for the close to happen. The original concern was a socket could transition from ESTABLISHED state to a new state while the BPF hook was still attached. But, we convinced ourself this is no longer possible and we also improved BPF sockmap to handle listen sockets so this is no longer a problem.
More importantly though there are cases where unhash is called when data is in the receive queue. The BPF unhash logic will flush this data which is wrong. To be correct it should keep the data in the receive queue and allow a receiving application to continue reading the data. This may happen when tcp_abort() is received for example. Instead of complicating the logic in unhash simply moving all this to tcp_close() hook solves this.
--- net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/tcp_bpf.c +0 -1
@@ -573,7 +573,6 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], struct proto *base) { prot[TCP_BPF_BASE ] = *base; - prot[TCP_BPF_BASE ].unhash = sock_map_unhash; prot[TCP_BPF_BASE ].close = sock_map_close; prot[TCP_BPF_BASE ].recvmsg = tcp_bpf_recvmsg; prot[TCP_BPF_BASE ].stream_memory_read = tcp_bpf_stream_read;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 528/575 bpf: sockmap, strparser, and tls are reusing qdisc_skb_cb and colliding
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit e0dc3b93bd7bcff8c3813d1df43e0908499c7cf0 ]
Strparser is reusing the qdisc_skb_cb struct to stash the skb message handling progress, e.g. offset and length of the skb. First this is poorly named and inherits a struct from qdisc that doesn't reflect the actual usage of cb[] at this layer.
But, more importantly strparser is using the following to access its metadata.
(struct _strp_msg *)((void *)skb->cb + offsetof(struct qdisc_skb_cb, data))
Where _strp_msg is defined as:
struct _strp_msg {
struct strp_msg strp; /* 0 8 */
int accum_len; /* 8 4 */ /* size: 12, cachelines: 1, members: 2 */
/* last cacheline: 12 bytes */};
So we use 12 bytes of ->data[] in struct. However in BPF code running parser and verdict the user has read capabilities into the data[] array as well. Its not too problematic, but we should not be exposing internal state to BPF program. If its really needed then we can use the probe_read() APIs which allow reading kernel memory. And I don't believe cb[] layer poses any API breakage by moving this around because programs can't depend on cb[] across layers.
In order to fix another issue with a ctx rewrite we need to stash a temp variable somewhere. To make this work cleanly this patch builds a cb struct for sk_skb types called sk_skb_cb struct. Then we can use this consistently in the strparser, sockmap space. Additionally we can start allowing ->cb[] write access after this.
--- include/net/strparser.h | 16 +++++++++++++++- net/core/filter.c | 21 +++++++++++++++++++++ net/strparser/strparser.c | 10 +--------- 3 files changed, 37 insertions(+), 10 deletions(-)
include/net/strparser.h +15 -1
@@ -54,10 +54,24 @@ struct strp_msg {int offset; }; +struct _strp_msg { +/* Internal cb structure. struct strp_msg must be first for passing +* to upper layer. +*/ +struct strp_msg strp; +int accum_len; +}; + +struct sk_skb_cb { +#define SK_SKB_CB_PRIV_LEN 20 +unsigned char data[SK_SKB_CB_PRIV_LEN ]; +struct _strp_msg strp; +}; +static inline struct strp_msg *strp_msg (struct sk_buff *skb) {return (struct strp_msg *)((void *)skb->cb + - offsetof(struct qdisc_skb_cb , data)); + offsetof(struct sk_skb_cb , strp)); }/* Structure for an attached lower socket */
net/core/filter.c +21 -0
@@ -9493,6 +9493,27 @@ static u32 sk_skb_convert_ctx_access(enum bpf_access_type type, *insn++ = BPF_LDX_MEM(BPF_SIZEOF(void *), si->dst_reg, si->src_reg, off);break ; + case offsetof(struct __sk_buff, cb[0]) ... + offsetofend(struct __sk_buff, cb[4]) - 1: + BUILD_BUG_ON(sizeof_field(struct sk_skb_cb, data) < 20); +BUILD_BUG_ON ((offsetof(struct sk_buff , cb) + + offsetof(struct sk_skb_cb , data)) % +sizeof (__u64)); + + prog->cb_access =1 ; + off = si->off; + off -= offsetof(struct __sk_buff, cb[0]); + off += offsetof(struct sk_buff , cb); + off += offsetof(struct sk_skb_cb , data); +if (type ==BPF_WRITE ) + *insn++ =BPF_STX_MEM (BPF_SIZE (si->code), si->dst_reg, + si->src_reg, off); +else + *insn++ =BPF_LDX_MEM (BPF_SIZE (si->code), si->dst_reg, + si->src_reg, off); +break ; + +default :return bpf_convert_ctx_access (type, si, insn_buf, prog, target_size);
net/strparser/strparser.c +1 -9
@@ -27,18 +27,10 @@static struct workqueue_struct *strp_wq; -struct _strp_msg { -/* Internal cb structure. struct strp_msg must be first for passing -* to upper layer. -*/ -struct strp_msg strp; -int accum_len; -}; -static inline struct _strp_msg *_strp_msg (struct sk_buff *skb) {return (struct _strp_msg *)((void *)skb->cb + - offsetof(struct qdisc_skb_cb , data)); + offsetof(struct sk_skb_cb , strp)); }/* Lower lock held */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 529/575 gve: Fix off by one in gve_tx_timeout()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1c360cc1cc883fbdf0a258b4df376571fbeac5ee ]
The priv->ntfy_blocks[] has "priv->num_ntfy_blks" elements so this > needs to be >= to prevent an off by one bug. The priv->ntfy_blocks[] array is allocated in gve_alloc_notify_blocks().
--- drivers/net/ethernet/google/gve/gve_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -959,7 +959,7 @@ static void gve_tx_timeout(struct net_device *dev, unsigned int txqueue) goto reset; ntfy_idx =gve_tx_idx_to_ntfy (priv, txqueue); -if (ntfy_idx > priv->num_ntfy_blks) +if (ntfy_idx >= priv->num_ntfy_blks) goto reset; block = &priv->ntfy_blocks[ntfy_idx];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 530/575 seq_file: fix passing wrong private data
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 10a6de19cad6efb9b49883513afb810dc265fca2 ]
DEFINE_PROC_SHOW_ATTRIBUTE() is supposed to be used to define a series of functions and variables to register proc file easily. And the users can use proc_create_data() to pass their own private data and get it via seq->private in the callback. Unfortunately, the proc file system use PDE_DATA() to get private data instead of inode->i_private. So fix it. Fortunately, there only one user of it which does not pass any private data, so this bug does not break any in-tree codes.
--- include/linux/seq_file.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/seq_file.h +1 -1
@@ -182,7 +182,7 @@ static const struct file_operations __name ## _fops = { \#define DEFINE_PROC_SHOW_ATTRIBUTE (__name) \ static int __name ## _open(struct inode *inode, struct file *file) \ { \ - return single_open(file, __name ## _show, inode->i_private); \ + return single_open(file, __name ## _show, PDE_DATA(inode)); \ } \ \ static const struct proc_ops __name ## _proc_ops = { \
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 531/575 net/sched: sch_taprio: fix undefined behavior in ktime_mono_to_any
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6dc25401cba4d428328eade8ceae717633fdd702 ]
1) if q->tk_offset == TK_OFFS_MAX, then get_tcp_tstamp() calls ktime_mono_to_any() with out-of-bound value.
2) if q->tk_offset is changed in taprio_parse_clockid(), taprio_get_time() might also call ktime_mono_to_any() with out-of-bound value as sysbot found:
UBSAN: array-index-out-of-bounds in kernel/time/timekeeping.c:908:27 index 3 is out of range for type 'ktime_t *[3]' CPU: 1 PID: 25668 Comm: kworker/u4:0 Not tainted 5.15.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 ubsan_epilogue+0xb/0x5a lib/ubsan.c:151 __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291 ktime_mono_to_any+0x1d4/0x1e0 kernel/time/timekeeping.c:908 get_tcp_tstamp net/sched/sch_taprio.c:322 [inline] get_packet_txtime net/sched/sch_taprio.c:353 [inline] taprio_enqueue_one+0x5b0/0x1460 net/sched/sch_taprio.c:420 taprio_enqueue+0x3b1/0x730 net/sched/sch_taprio.c:485 dev_qdisc_enqueue+0x40/0x300 net/core/dev.c:3785 __dev_xmit_skb net/core/dev.c:3869 [inline] __dev_queue_xmit+0x1f6e/0x3630 net/core/dev.c:4194 batadv_send_skb_packet+0x4a9/0x5f0 net/batman-adv/send.c:108 batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline] batadv_iv_send_outstanding_bat_ogm_packet+0x6d7/0x8e0 net/batman-adv/bat_iv_ogm.c:1701 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445 kthread+0x405/0x4f0 kernel/kthread.c:327 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
--- net/sched/sch_taprio.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
net/sched/sch_taprio.c +17 -10
@@ -94,18 +94,22 @@ static ktime_t sched_base_time(const struct sched_gate_list *sched)return ns_to_ktime (sched->base_time); } -static ktime_t taprio_get_time (struct taprio_sched *q) +static ktime_t taprio_mono_to_any (const struct taprio_sched *q,ktime_t mono) { -ktime_t mono =ktime_get (); +/* This pairs with WRITE_ONCE() in taprio_parse_clockid() */ +enum tk_offsets tk_offset =READ_ONCE (q->tk_offset); -switch (q->tk_offset) { +switch (tk_offset) {case TK_OFFS_MAX :return mono;default : -return ktime_mono_to_any (mono, q->tk_offset); +return ktime_mono_to_any (mono, tk_offset); } +} -return KTIME_MAX ; +static ktime_t taprio_get_time (const struct taprio_sched *q) +{ +return taprio_mono_to_any (q,ktime_get ()); }static void taprio_free_sched_cb (struct rcu_head *head)
@@ -321,7 +325,7 @@ static ktime_t get_tcp_tstamp(struct taprio_sched *q, struct sk_buff *skb)return 0 ; } -return ktime_mono_to_any (skb->skb_mstamp_ns, q->tk_offset); +return taprio_mono_to_any (q, skb->skb_mstamp_ns); }/* There are a few scenarios where we will have to modify the txtime from
@@ -1341,6 +1345,7 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, } }else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID ]) {int clockid =nla_get_s32 (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID ]); +enum tk_offsets tk_offset;/* We only support static clockids and we don't allow * for it to be modified after the first init.
@@ -1355,22 +1360,24 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,switch (clockid) {case CLOCK_REALTIME : - q->tk_offset =TK_OFFS_REAL ; + tk_offset =TK_OFFS_REAL ;break ;case CLOCK_MONOTONIC : - q->tk_offset =TK_OFFS_MAX ; + tk_offset =TK_OFFS_MAX ;break ;case CLOCK_BOOTTIME : - q->tk_offset =TK_OFFS_BOOT ; + tk_offset =TK_OFFS_BOOT ;break ;case CLOCK_TAI : - q->tk_offset =TK_OFFS_TAI ; + tk_offset =TK_OFFS_TAI ;break ;default :NL_SET_ERR_MSG (extack,"Invalid 'clockid'" ); err = -EINVAL ; goto out; } +/* This pairs with READ_ONCE() in taprio_mono_to_any */ +WRITE_ONCE (q->tk_offset, tk_offset); q->clockid = clockid; }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 532/575 net: hns3: fix kernel crash when unload VF while it is being reset
In reply to Greg Kroah-HartmanFrom: Yufeng Mo <[email protected]>
[ Upstream commit e140c7983e3054be0652bf914f4454f16c5520b0 ]
When fully configure VLANs for a VF, then unload the VF while triggering a reset to PF, will cause a kernel crash because the irq is already uninit.
[ 293.177579] ------------[ cut here ]------------ [ 293.183502] kernel BUG at drivers/pci/msi.c:352! [ 293.189547] Internal error: Oops - BUG: 0 [#1] SMP ...... [ 293.390124] Workqueue: hclgevf hclgevf_service_task [hclgevf] [ 293.402627] pstate: 80c00009 (Nzcv daif +PAN +UAO) [ 293.414324] pc : free_msi_irqs+0x19c/0x1b8 [ 293.425429] lr : free_msi_irqs+0x18c/0x1b8 [ 293.436545] sp : ffff00002716fbb0 [ 293.446950] x29: ffff00002716fbb0 x28: 0000000000000000 [ 293.459519] x27: 0000000000000000 x26: ffff45b91ea16b00 [ 293.472183] x25: 0000000000000000 x24: ffffa587b08f4700 [ 293.484717] x23: ffffc591ac30e000 x22: ffffa587b08f8428 [ 293.497190] x21: ffffc591ac30e300 x20: 0000000000000000 [ 293.509594] x19: ffffa58a062a8300 x18: 0000000000000000 [ 293.521949] x17: 0000000000000000 x16: ffff45b91dcc3f48 [ 293.534013] x15: 0000000000000000 x14: 0000000000000000 [ 293.545883] x13: 0000000000000040 x12: 0000000000000228 [ 293.557508] x11: 0000000000000020 x10: 0000000000000040 [ 293.568889] x9 : ffff45b91ea1e190 x8 : ffffc591802d0000 [ 293.580123] x7 : ffffc591802d0148 x6 : 0000000000000120 [ 293.591190] x5 : ffffc591802d0000 x4 : 0000000000000000 [ 293.602015] x3 : 0000000000000000 x2 : 0000000000000000 [ 293.612624] x1 : 00000000000004a4 x0 : ffffa58a1e0c6b80 [ 293.623028] Call trace: [ 293.630340] free_msi_irqs+0x19c/0x1b8 [ 293.638849] pci_disable_msix+0x118/0x140 [ 293.647452] pci_free_irq_vectors+0x20/0x38 [ 293.656081] hclgevf_uninit_msi+0x44/0x58 [hclgevf] [ 293.665309] hclgevf_reset_rebuild+0x1ac/0x2e0 [hclgevf] [ 293.674866] hclgevf_reset+0x358/0x400 [hclgevf] [ 293.683545] hclgevf_reset_service_task+0xd0/0x1b0 [hclgevf] [ 293.693325] hclgevf_service_task+0x4c/0x2e8 [hclgevf] [ 293.702307] process_one_work+0x1b0/0x448 [ 293.710034] worker_thread+0x54/0x468 [ 293.717331] kthread+0x134/0x138 [ 293.724114] ret_from_fork+0x10/0x18 [ 293.731324] Code: f940b000 b4ffff00 a903e7b8 f90017b6 (d4210000)
This patch fixes the problem by waiting for the VF reset done while unloading the VF.
--- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 5 +++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +5 -0
@@ -2887,7 +2887,10 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client,/* un-init roce, if it exists */ if (hdev->roce_client) { +while (test_bit (HCLGEVF_STATE_RST_HANDLING , &hdev->state)) +msleep (HCLGEVF_WAIT_RESET_DONE );clear_bit (HCLGEVF_STATE_ROCE_REGISTERED , &hdev->state); + hdev->roce_client->ops->uninit_instance (&hdev->roce,0 ); hdev->roce_client =NULL ; hdev->roce.client =NULL ;
@@ -2896,6 +2899,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client,/* un-init nic/unic, if this was not called by roce client */ if (client->ops->uninit_instance && hdev->nic_client && client->type !=HNAE3_CLIENT_ROCE ) { +while (test_bit (HCLGEVF_STATE_RST_HANDLING , &hdev->state)) +msleep (HCLGEVF_WAIT_RESET_DONE );clear_bit (HCLGEVF_STATE_NIC_REGISTERED , &hdev->state); client->ops->uninit_instance (&hdev->nic,0 );
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +2 -0
@@ -106,6 +106,8 @@#define HCLGEVF_VF_RST_ING 0x07008#define HCLGEVF_VF_RST_ING_BIT BIT(16) +#define HCLGEVF_WAIT_RESET_DONE 100 +#define HCLGEVF_RSS_IND_TBL_SIZE 512#define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff#define HCLGEVF_RSS_KEY_SIZE 40
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 533/575 net: hns3: allow configure ETS bandwidth of all TCs
In reply to Greg Kroah-HartmanFrom: Guangbin Huang <[email protected]>
[ Upstream commit 688db0c7a4a69ddc8b8143a1cac01eb20082a3aa ]
Currently, driver only allow configuring ETS bandwidth of TCs according to the max TC number queried from firmware. However, the hardware actually supports 8 TCs and users may need to configure ETS bandwidth of all TCs, so remove the restriction.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +1 -1
@@ -126,7 +126,7 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,if (ret)return ret; -for (i =0 ; i < hdev->tc_max; i++) { +for (i =0 ; i <HNAE3_MAX_TC ; i++) {switch (ets->tc_tsa[i]) {case IEEE_8021QAZ_TSA_STRICT : if (hdev->tm_info.tc_info[i].tc_sch_mode !=
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +1 -8
@@ -1039,7 +1039,6 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev)static int hclge_tm_ets_tc_dwrr_cfg (struct hclge_dev *hdev) { -#define DEFAULT_TC_WEIGHT 1#define DEFAULT_TC_OFFSET 14struct hclge_ets_tc_weight_cmd *ets_weight;
@@ -1052,13 +1051,7 @@ static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev)for (i =0 ; i <HNAE3_MAX_TC ; i++) {struct hclge_pg_info *pg_info; - ets_weight->tc_weight[i] =DEFAULT_TC_WEIGHT ; - -if (!(hdev->hw_tc_map &BIT (i))) -continue ; - - pg_info = - &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; + pg_info = &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; ets_weight->tc_weight[i] = pg_info->tc_dwrr[i]; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 534/575 net: stmmac: allow a tc-taprio base-time of zero
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit f64ab8e4f368f48afb08ae91928e103d17b235e9 ]
Commit fe28c53ed71d ("net: stmmac: fix taprio configuration when base_time is in the past") allowed some base time values in the past, but apparently not all, the base-time value of 0 (Jan 1st 1970) is still explicitly denied by the driver.
Remove the bogus check.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +0 -2
@@ -679,8 +679,6 @@ static int tc_setup_taprio(struct stmmac_priv *priv, goto disable;if (qopt->num_entries >= dep)return -EINVAL ; -if (!qopt->base_time) -return -ERANGE ;if (!qopt->cycle_time)return -ERANGE ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 535/575 vsock: prevent unnecessary refcnt inc for nonblocking connect
In reply to Greg Kroah-HartmanFrom: Eiichi Tsukata <[email protected]>
[ Upstream commit c7cd82b90599fa10915f41e3dd9098a77d0aa7b6 ]
Currently vosck_connect() increments sock refcount for nonblocking socket each time it's called, which can lead to memory leak if it's called multiple times because connect timeout function decrements sock refcount only once.
Fixes it by making vsock_connect() return -EALREADY immediately when sock state is already SS_CONNECTING.
--- net/vmw_vsock/af_vsock.c | 2 ++ 1 file changed, 2 insertions(+)
net/vmw_vsock/af_vsock.c +2 -0
@@ -1279,6 +1279,8 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,* non-blocking call. */ err = -EALREADY ; +if (flags &O_NONBLOCK ) + goto out;break ;default : if ((sk->sk_state == TCP_LISTEN) ||
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 536/575 net/smc: fix sk_refcnt underflow on linkdown and fallback
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
[ Upstream commit e5d5aadcf3cd59949316df49c27cb21788d7efe4 ]
We got the following WARNING when running ab/nginx test with RDMA link flapping (up-down-up).
The reason is when smc_sock fallback and at linkdown happens simultaneously, we may got the following situation:
__smc_lgr_terminate()
--> smc_conn_kill()
--> smc_close_active_abort()
smc_sock->sk_state = SMC_CLOSED
sock_put(smc_sock)smc_sock was set to SMC_CLOSED and sock_put() been called when terminate the link group. But later application call close() on the socket, then we got:
__smc_release():
if (smc_sock->fallback)
smc_sock->sk_state = SMC_CLOSED
sock_put(smc_sock)Again we set the smc_sock to CLOSED through it's already in CLOSED state, and double put the refcnt, so the following warning happens:
refcount_t: underflow; use-after-free.
WARNING: CPU: 5 PID: 860 at lib/refcount.c:28 refcount_warn_saturate+0x8d/0xf0 Modules linked in: CPU: 5 PID: 860 Comm: nginx Not tainted 5.10.46+ #403 Hardware name: Alibaba Cloud Alibaba Cloud ECS, BIOS 8c24b4c 04/01/2014 RIP: 0010:refcount_warn_saturate+0x8d/0xf0 Code: 05 5c 1e b5 01 01 e8 52 25 bc ff 0f 0b c3 80 3d 4f 1e b5 01 00 75 ad 48
RSP: 0018:ffffc90000527e50 EFLAGS: 00010286 RAX: 0000000000000026 RBX: ffff8881300df2c0 RCX: 0000000000000027 RDX: 0000000000000000 RSI: ffff88813bd58040 RDI: ffff88813bd58048 RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000000000001 R10: ffff8881300df2c0 R11: ffffc90000527c78 R12: ffff8881300df340 R13: ffff8881300df930 R14: ffff88810b3dad80 R15: ffff8881300df4f8 FS: 00007f739de8fb80(0000) GS:ffff88813bd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000a01b008 CR3: 0000000111b64003 CR4: 00000000003706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: smc_release+0x353/0x3f0 __sock_release+0x3d/0xb0 sock_close+0x11/0x20 __fput+0x93/0x230 task_work_run+0x65/0xa0 exit_to_user_mode_prepare+0xf9/0x100 syscall_exit_to_user_mode+0x27/0x190 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This patch adds check in __smc_release() to make sure we won't do an extra sock_put() and set the socket to CLOSED when its already in CLOSED state.
--- net/smc/af_smc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
net/smc/af_smc.c +11 -7
@@ -146,14 +146,18 @@ static int __smc_release(struct smc_sock *smc)sock_set_flag (sk,SOCK_DEAD ); sk->sk_shutdown |=SHUTDOWN_MASK ; }else { -if (sk->sk_state !=SMC_LISTEN && sk->sk_state !=SMC_INIT ) -sock_put (sk);/* passive closing */ -if (sk->sk_state ==SMC_LISTEN ) { -/* wake up clcsock accept */ - rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); +if (sk->sk_state !=SMC_CLOSED ) { +if (sk->sk_state !=SMC_LISTEN && + sk->sk_state !=SMC_INIT ) +sock_put (sk);/* passive closing */ +if (sk->sk_state ==SMC_LISTEN ) { +/* wake up clcsock accept */ + rc =kernel_sock_shutdown (smc->clcsock, +SHUT_RDWR ); + } + sk->sk_state =SMC_CLOSED ; + sk->sk_state_change (sk); } - sk->sk_state =SMC_CLOSED ; - sk->sk_state_change (sk);smc_restore_fallback_changes (smc); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 537/575 cxgb4: fix eeprom len when diagnostics not implemented
In reply to Greg Kroah-HartmanFrom: Rahul Lakkireddy <[email protected]>
[ Upstream commit 4ca110bf8d9b31a60f8f8ff6706ea147d38ad97c ]
Ensure diagnostics monitoring support is implemented for the SFF 8472 compliant port module and set the correct length for ethtool port module eeprom read.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 7 +++++-- drivers/net/ethernet/chelsio/cxgb4/t4_hw.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +5 -2
@@ -2011,12 +2011,15 @@ static int cxgb4_get_module_info(struct net_device *dev,if (ret)return ret; -if (!sff8472_comp || (sff_diag_type &4 )) { +if (!sff8472_comp || (sff_diag_type &SFP_DIAG_ADDRMODE )) { modinfo->type =ETH_MODULE_SFF_8079 ; modinfo->eeprom_len =ETH_MODULE_SFF_8079_LEN ; }else { modinfo->type =ETH_MODULE_SFF_8472 ; - modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN ; +if (sff_diag_type &SFP_DIAG_IMPLEMENTED ) + modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN ; +else + modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN /2 ; }break ;
drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +2 -0
@@ -293,6 +293,8 @@ enum {#define I2C_PAGE_SIZE 0x100#define SFP_DIAG_TYPE_ADDR 0x5c#define SFP_DIAG_TYPE_LEN 0x1 +#define SFP_DIAG_ADDRMODE BIT(2) +#define SFP_DIAG_IMPLEMENTED BIT(6)#define SFF_8472_COMP_ADDR 0x5e#define SFF_8472_COMP_LEN 0x1#define SFF_REV_ADDR 0x1
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 538/575 selftests/net: udpgso_bench_rx: fix port argument
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit d336509cb9d03970911878bb77f0497f64fda061 ]
The below commit added optional support for passing a bind address. It configures the sockaddr bind arguments before parsing options and reconfigures on options -b and -4.
This broke support for passing port (-p) on its own.
Configure sockaddr after parsing all arguments.
--- tools/testing/selftests/net/udpgso_bench_rx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/net/udpgso_bench_rx.c +7 -4
@@ -293,19 +293,17 @@ static void usage(const char *filepath)static void parse_opts (int argc,char **argv) { +const char *bind_addr =NULL ;int c; -/* bind to any by default */ -setup_sockaddr (PF_INET6 ,"::" , &cfg_bind_addr);while ((c =getopt (argc, argv,"4b:C:Gl:n:p:rR:S:tv" )) !=-1 ) {switch (c) {case '4' : cfg_family =PF_INET ; cfg_alen =sizeof (struct sockaddr_in ); -setup_sockaddr (PF_INET ,"0.0.0.0" , &cfg_bind_addr);break ;case 'b' : -setup_sockaddr (cfg_family, optarg, &cfg_bind_addr); + bind_addr = optarg;break ;case 'C' : cfg_connect_timeout_ms =strtoul (optarg,NULL ,0 );
@@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv) } } +if (!bind_addr) + bind_addr = cfg_family ==PF_INET6 ?"::" :"0.0.0.0" ; + +setup_sockaddr (cfg_family, bind_addr, &cfg_bind_addr); +if (optind != argc)usage (argv[0 ]);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 539/575 ARM: 9155/1: fix early early_iounmap()
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
commit 0d08e7bf0d0d1a29aff7b16ef516f7415eb1aa05 upstream.
Currently __set_fixmap() bails out with a warning when called in early boot from early_iounmap(). Fix it, and while at it, make the comment a bit easier to understand.
--- arch/arm/mm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/mmu.c +2 -2
@@ -391,9 +391,9 @@ void __set_fixmap(enum fixed_addresses i FIXADDR_END);BUG_ON (idx >= __end_of_fixed_addresses); -/* we only support device mappings until pgprot_kernel has been set */ +/* We support only device mappings before pgprot_kernel is set. */ if (WARN_ON (pgprot_val (prot) !=pgprot_val (FIXMAP_PAGE_IO ) && -pgprot_val (pgprot_kernel) ==0 )) +pgprot_val (prot) &&pgprot_val (pgprot_kernel) ==0 ))return ;if (pgprot_val (prot))
Greg Kroah-Hartman
maintainerPATCH 540/575 ARM: 9156/1: drop cc-option fallbacks for architecture selection
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 418ace9992a7647c446ed3186df40cf165b67298 upstream.
Naresh and Antonio ran into a build failure with latest Debian armhf compilers, with lots of output like
tmp/ccY3nOAs.s:2215: Error: selected processor does not support `cpsid i' in ARM mode
As it turns out, $(cc-option) fails early here when the FPU is not selected before CPU architecture is selected, as the compiler option check runs before enabling -msoft-float, which causes a problem when testing a target architecture level without an FPU:
cc1: error: '-mfloat-abi=hard': selected architecture lacks an FPU
Passing e.g. -march=armv6k+fp in place of -march=armv6k would avoid this issue, but the fallback logic is already broken because all supported compilers (gcc-5 and higher) are much more recent than these options, and building with -march=armv5t as a fallback no longer works.
The best way forward that I see is to just remove all the checks, which also has the nice side-effect of slightly improving the startup time for 'make'.
The -mtune=marvell-f option was apparently never supported by any mainline compiler, and the custom Codesourcery gcc build that did support is now too old to build kernels, so just use -mtune=xscale unconditionally for those.
This should be safe to apply on all stable kernels, and will be required in order to keep building them with gcc-11 and higher.
--- arch/arm/Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/arm/Makefile +11 -11
@@ -60,15 +60,15 @@ KBUILD_CFLAGS += $(call cc-option,-fno-i # Note that GCC does not numerically define an architecture version # macro, but instead defines a whole series of macros which makes # testing for a specific architecture or later rather impossible. -arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m -Wa,-march=armv7-m -arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a) -arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6) +arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m +arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 -march=armv7-a +arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 -march=armv6 # Only override the compiler option if ARMv6. The ARMv6K extensions are # always available in ARMv7 ifeq ($(CONFIG_CPU_32v6),y) -arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6k,-march=armv5t -Wa$(comma)-march=armv6k) +arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 -march=armv6k endif -arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t) +arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 -march=armv5te arch-$(CONFIG_CPU_32v4T) =-D__LINUX_ARM_ARCH__=4 -march=armv4t arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 -march=armv4 arch-$(CONFIG_CPU_32v3) =-D__LINUX_ARM_ARCH__=3 -march=armv3m
@@ -82,7 +82,7 @@ tune-$(CONFIG_CPU_ARM720T) =-mtune=arm7t tune-$(CONFIG_CPU_ARM740T) =-mtune=arm7tdmi tune-$(CONFIG_CPU_ARM9TDMI) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM940T) =-mtune=arm9tdmi -tune-$(CONFIG_CPU_ARM946E) =$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi) +tune-$(CONFIG_CPU_ARM946E) =-mtune=arm9e tune-$(CONFIG_CPU_ARM920T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM922T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM925T) =-mtune=arm9tdmi
@@ -90,11 +90,11 @@ tune-$(CONFIG_CPU_ARM926T) =-mtune=arm9t tune-$(CONFIG_CPU_FA526) =-mtune=arm9tdmi tune-$(CONFIG_CPU_SA110) =-mtune=strongarm110 tune-$(CONFIG_CPU_SA1100) =-mtune=strongarm1100 -tune-$(CONFIG_CPU_XSCALE) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale -tune-$(CONFIG_CPU_XSC3) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale -tune-$(CONFIG_CPU_FEROCEON) =$(call cc-option,-mtune=marvell-f,-mtune=xscale) -tune-$(CONFIG_CPU_V6) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm) -tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm) +tune-$(CONFIG_CPU_XSCALE) =-mtune=xscale +tune-$(CONFIG_CPU_XSC3) =-mtune=xscale +tune-$(CONFIG_CPU_FEROCEON) =-mtune=xscale +tune-$(CONFIG_CPU_V6) =-mtune=arm1136j-s +tune-$(CONFIG_CPU_V6K) =-mtune=arm1136j-s # Evaluate tune cc-option calls now tune-y := $(tune-y)
Greg Kroah-Hartman
maintainerPATCH 541/575 parisc: Fix backtrace to always include init funtion names
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 279917e27edc293eb645a25428c6ab3f3bca3f86 upstream.
I noticed that sometimes at kernel startup the backtraces did not included the function names of init functions. Their address were not resolved to function names and instead only the address was printed.
Debugging shows that the culprit is is_ksym_addr() which is called by the backtrace functions to check if an address belongs to a function in the kernel. The problem occurs only for CONFIG_KALLSYMS_ALL=y.
When looking at is_ksym_addr() one can see that for CONFIG_KALLSYMS_ALL=y the function only tries to resolve the address via is_kernel() function, which checks like this:
if (addr >= _stext && addr <= _end)
return 1;On parisc the init functions are located before _stext, so this check fails. Other platforms seem to have all functions (including init functions) behind _stext.
The following patch moves the _stext symbol at the beginning of the kernel and thus includes the init section. This fixes the check and does not seem to have any negative side effects on where the kernel mapping happens in the map_pages() function in arch/parisc/mm/init.c.
--- arch/parisc/kernel/vmlinux.lds.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/kernel/vmlinux.lds.S +2 -1
@@ -57,6 +57,8 @@ SECTIONS { . = KERNEL_BINARY_TEXT_START; + _stext = .; /* start of kernel text, includes init code & data */ + __init_begin = .; HEAD_TEXT_SECTION MLONGCALL_DISCARD(INIT_TEXT_SECTION(8))
@@ -80,7 +82,6 @@ SECTIONS /* freed after init ends here */ _text = .; /* Text and read-only data */ - _stext = .; MLONGCALL_KEEP(INIT_TEXT_SECTION(8)) .text ALIGN(PAGE_SIZE) : { TEXT_TEXT
Greg Kroah-Hartman
maintainerPATCH 542/575 MIPS: Fix assembly error from MIPSr2 code used within MIPS_ISA_ARCH_LEVEL
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
commit a923a2676e60683aee46aa4b93c30aff240ac20d upstream.
Fix assembly errors like:
{standard input}: Assembler messages:
{standard input}:287: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' {standard input}:680: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' {standard input}:1274: Error: opcode not supported on this processor: mips3 (mips3) dins $12,$9,32,32' {standard input}:2175: Error: opcode not supported on this processor: mips3 (mips3) dins $10,$7,32,32' make[1]: *** [scripts/Makefile.build:277: mm/highmem.o] Error 1
with code produced from `__cmpxchg64' for MIPS64r2 CPU configurations using CONFIG_32BIT and CONFIG_PHYS_ADDR_T_64BIT.
This is due to MIPS_ISA_ARCH_LEVEL downgrading the assembly architecture to `r4000' i.e. MIPS III for MIPS64r2 configurations, while there is a block of code containing a DINS MIPS64r2 instruction conditionalized on MIPS_ISA_REV >= 2 within the scope of the downgrade.
The assembly architecture override code pattern has been put there for LL/SC instructions, so that code compiles for configurations that select a processor to build for that does not support these instructions while still providing run-time support for processors that do, dynamically switched by non-constant `cpu_has_llsc'. It went in with linux-mips.org commit aac8aa7717a2 ("Enable a suitable ISA for the assembler around ll/sc so that code builds even for processors that don't support the instructions. Plus minor formatting fixes.") back in 2005.
Fix the problem by wrapping these instructions along with the adjacent SYNC instructions only, following the practice established with commit cfd54de3b0e4 ("MIPS: Avoid move psuedo-instruction whilst using MIPS_ISA_LEVEL") and commit 378ed6f0e3c5 ("MIPS: Avoid using .set mips0 to restore ISA"). Strictly speaking the SYNC instructions do not have to be wrapped as they are only used as a Loongson3 erratum workaround, so they will be enabled in the assembler by default, but do this so as to keep code consistent with other places.
--- arch/mips/include/asm/cmpxchg.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/mips/include/asm/cmpxchg.h +4 -1
@@ -249,6 +249,7 @@ static inline unsigned long __cmpxchg64(/* Load 64 bits from ptr */ " " __SYNC(full, loongson3_war) " \n""1: lld %L0, %3 # __cmpxchg64 \n" +" .set pop \n" /* * Split the 64 bit value we loaded into the 2 registers that hold the * ret variable.
@@ -276,12 +277,14 @@ static inline unsigned long __cmpxchg64(" or %L1, %L1, $at \n" " .set at \n"# endif +" .set push \n" +" .set " MIPS_ISA_ARCH_LEVEL " \n" /* Attempt to store new at ptr */ " scd %L1, %2 \n" /* If we failed, loop! */ "\t" __SC_BEQZ"%L1, 1b \n" -" .set pop \n" "2: " __SYNC(full, loongson3_war) " \n" + " .set pop \n" : "=&r"(ret),"=&r" (tmp),"=" GCC_OFF_SMALL_ASM () (*(unsigned long long *)ptr)
Greg Kroah-Hartman
maintainerPATCH 543/575 x86/mce: Add errata workaround for Skylake SKX37
In reply to Greg Kroah-HartmanFrom: Dave Jones <[email protected]>
commit e629fc1407a63dbb748f828f9814463ffc2a0af0 upstream.
Errata SKX37 is word-for-word identical to the other errata listed in
this workaround. I happened to notice this after investigating a CMCI
storm on a Skylake host. While I can't confirm this was the root cause, spurious corrected errors does sound like a likely suspect.
--- arch/x86/kernel/cpu/mce/intel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/intel.c +3 -2
@@ -526,12 +526,13 @@ bool intel_filter_mce(struct mce *m) {struct cpuinfo_x86 *c = &boot_cpu_data; -/* MCE errata HSD131, HSM142, HSW131, BDM48, and HSM142 */ +/* MCE errata HSD131, HSM142, HSW131, BDM48, HSM142 and SKX37 */ if ((c->x86 ==6 ) && ((c->x86_model ==INTEL_FAM6_HASWELL ) || (c->x86_model ==INTEL_FAM6_HASWELL_L ) || (c->x86_model ==INTEL_FAM6_BROADWELL ) || - (c->x86_model ==INTEL_FAM6_HASWELL_G )) && + (c->x86_model ==INTEL_FAM6_HASWELL_G ) || + (c->x86_model ==INTEL_FAM6_SKYLAKE_X )) && (m->bank ==0 ) && ((m->status &0xa0000000ffffffff ) ==0x80000000000f0005 ))return true;
Greg Kroah-Hartman
maintainerPATCH 544/575 posix-cpu-timers: Clear task::posix_cputimers_work in copy_process()
In reply to Greg Kroah-HartmanFrom: Michael Pratt <[email protected]>
commit ca7752caeaa70bd31d1714af566c9809688544af upstream.
copy_process currently copies task_struct.posix_cputimers_work as-is. If a timer interrupt arrives while handling clone and before dup_task_struct completes then the child task will have:
1. posix_cputimers_work.scheduled = true
2. posix_cputimers_work.work queued.
copy_process clears task_struct.task_works, so (2) will have no effect and posix_cpu_timers_work will never run (not to mention it doesn't make sense for two tasks to share a common linked list).
Since posix_cpu_timers_work never runs, posix_cputimers_work.scheduled is never cleared. Since scheduled is set, future timer interrupts will skip scheduling work, with the ultimate result that the task will never receive timer expirations.
Together, the complete flow is:
1. Task 1 calls clone(), enters kernel.
2. Timer interrupt fires, schedules task work on Task 1.
2a. task_struct.posix_cputimers_work.scheduled = true
2b. task_struct.posix_cputimers_work.work added to
task_struct.task_works.
3. dup_task_struct() copies Task 1 to Task 2.
4. copy_process() clears task_struct.task_works for Task 2.
5. Future timer interrupts on Task 2 see task_struct.posix_cputimers_work.scheduled = true and skip scheduling work.
Fix this by explicitly clearing contents of task_struct.posix_cputimers_work in copy_process(). This was never meant to be shared or inherited across tasks in the first place.
--- include/linux/posix-timers.h | 2 ++ kernel/fork.c | 1 + kernel/time/posix-cpu-timers.c | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-)
include/linux/posix-timers.h +2 -0
@@ -177,8 +177,10 @@ static inline void posix_cputimers_group#endif #ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK +void clear_posix_cputimers_work (struct task_struct *p);void posix_cputimers_init_work (void );#else +static inline void clear_posix_cputimers_work (struct task_struct *p) { }static inline void posix_cputimers_init_work (void ) { }#endif
kernel/fork.c +1 -0
@@ -2191,6 +2191,7 @@ static __latent_entropy struct task_stru p->pdeath_signal =0 ;INIT_LIST_HEAD (&p->thread_group); p->task_works =NULL ; +clear_posix_cputimers_work (p);/* * Ensure that the cgroup subsystem policies allow the new process to be
kernel/time/posix-cpu-timers.c +17 -2
@@ -1101,13 +1101,28 @@ static void posix_cpu_timers_work(struct }/* +* Clear existing posix CPU timers task work. +*/ +void clear_posix_cputimers_work (struct task_struct *p) +{ +/* +* A copied work entry from the old task is not meaningful, clear it. +* N.B. init_task_work will not do this. +*/ +memset (&p->posix_cputimers_work.work,0 , +sizeof (p->posix_cputimers_work.work)); +init_task_work (&p->posix_cputimers_work.work, + posix_cpu_timers_work); + p->posix_cputimers_work.scheduled = false; +} + +/* * Initialize posix CPU timers task work in init task. Out of line to * keep the callback static and to avoid header recursion hell. */ void __init posix_cputimers_init_work (void ) { -init_task_work (¤t->posix_cputimers_work.work, - posix_cpu_timers_work); +clear_posix_cputimers_work (current); }/*
Greg Kroah-Hartman
maintainerPATCH 545/575 irqchip/sifive-plic: Fixup EOI failed when masked
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
commit 69ea463021be0d159ab30f96195fb0dd18ee2272 upstream.
When using "devm_request_threaded_irq(,,,,IRQF_ONESHOT,,)" in a driver, only the first interrupt is handled, and following interrupts are never delivered (initially reported in [1]).
That's because the RISC-V PLIC cannot EOI masked interrupts, as explained in the description of Interrupt Completion in the PLIC spec [2]:
<quote>
The PLIC signals it has completed executing an interrupt handler by writing the interrupt ID it received from the claim to the claim/complete register. The PLIC does not check whether the completion ID is the same as the last claim ID for that target. If the completion ID does not match an interrupt source that *is currently enabled* for the target, the completion is silently ignored.
</quote>
Re-enable the interrupt before completion if it has been masked during the handling, and remask it afterwards.
[1] http://lists.infradead.org/pipermail/linux-riscv/2021-July/007441.html
[2] https://github.com/riscv/riscv-plic-spec/blob/8bc15a35d07c9edf7b5d23fec9728302595ffc4d/riscv-plic.adoc
--- drivers/irqchip/irq-sifive-plic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/irqchip/irq-sifive-plic.c +7 -1
@@ -163,7 +163,13 @@ static void plic_irq_eoi(struct irq_data {struct plic_handler *handler =this_cpu_ptr (&plic_handlers); -writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +if (irqd_irq_masked (d)) { +plic_irq_unmask (d); +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +plic_irq_mask (d); + }else { +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); + } }static struct irq_chip plic_chip = {
Greg Kroah-Hartman
maintainerPATCH 546/575 f2fs: should use GFP_NOFS for directory inodes
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
commit 92d602bc7177325e7453189a22e0c8764ed3453e upstream.
We use inline_dentry which requires to allocate dentry page when adding a link. If we allow to reclaim memory from filesystem, we do down_read(&sbi->cp_rwsem) twice by f2fs_lock_op(). I think this should be okay, but how about stopping the lockdep complaint [1]?
f2fs_create()
- f2fs_lock_op()
- f2fs_do_add_link()
- __f2fs_find_entry
- f2fs_get_read_data_page()
-> kswapd
- shrink_node
- f2fs_evict_inode
- f2fs_lock_op()
[1]
fs_reclaim
){+.+.}-{0:0}
:
kswapd0: lock_acquire+0x114/0x394 kswapd0: __fs_reclaim_acquire+0x40/0x50 kswapd0: prepare_alloc_pages+0x94/0x1ec kswapd0: __alloc_pages_nodemask+0x78/0x1b0 kswapd0: pagecache_get_page+0x2e0/0x57c kswapd0: f2fs_get_read_data_page+0xc0/0x394 kswapd0: f2fs_find_data_page+0xa4/0x23c kswapd0: find_in_level+0x1a8/0x36c kswapd0: __f2fs_find_entry+0x70/0x100 kswapd0: f2fs_do_add_link+0x84/0x1ec kswapd0: f2fs_mkdir+0xe4/0x1e4 kswapd0: vfs_mkdir+0x110/0x1c0 kswapd0: do_mkdirat+0xa4/0x160 kswapd0: __arm64_sys_mkdirat+0x24/0x34 kswapd0: el0_svc_common.llvm.17258447499513131576+0xc4/0x1e8 kswapd0: do_el0_svc+0x28/0xa0 kswapd0: el0_svc+0x24/0x38 kswapd0: el0_sync_handler+0x88/0xec kswapd0: el0_sync+0x1c0/0x200
kswapd0:
-> #1
(&sbi->cp_rwsem
){++++}-{3:3}
:
kswapd0: lock_acquire+0x114/0x394 kswapd0: down_read+0x7c/0x98 kswapd0: f2fs_do_truncate_blocks+0x78/0x3dc kswapd0: f2fs_truncate+0xc8/0x128 kswapd0: f2fs_evict_inode+0x2b8/0x8b8 kswapd0: evict+0xd4/0x2f8 kswapd0: iput+0x1c0/0x258 kswapd0: do_unlinkat+0x170/0x2a0 kswapd0: __arm64_sys_unlinkat+0x4c/0x68 kswapd0: el0_svc_common.llvm.17258447499513131576+0xc4/0x1e8 kswapd0: do_el0_svc+0x28/0xa0 kswapd0: el0_svc+0x24/0x38 kswapd0: el0_sync_handler+0x88/0xec kswapd0: el0_sync+0x1c0/0x200
--- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/inode.c +1 -1
@@ -511,7 +511,7 @@ make_now: inode->i_op = &f2fs_dir_inode_operations; inode->i_fop = &f2fs_dir_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; -inode_nohighmem (inode); +mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS ); }else if (S_ISLNK (inode->i_mode)) {if (file_is_encrypt (inode)) inode->i_op = &f2fs_encrypted_symlink_inode_operations;
fs/f2fs/namei.c +1 -1
@@ -744,7 +744,7 @@ static int f2fs_mkdir(struct inode *dir, inode->i_op = &f2fs_dir_inode_operations; inode->i_fop = &f2fs_dir_operations; inode->i_mapping->a_ops = &f2fs_dblock_aops; -inode_nohighmem (inode); +mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS );set_inode_flag (inode,FI_INC_LINK );f2fs_lock_op (sbi);
Greg Kroah-Hartman
maintainerPATCH 547/575 net, neigh: Enable state migration between NUD_PERMANENT and NTF_USE
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 3dc20f4762c62d3b3f0940644881ed818aa7b2f5 ]
Currently, it is not possible to migrate a neighbor entry between NUD_PERMANENT state and NTF_USE flag with a dynamic NUD state from a user space control plane. Similarly, it is not possible to add/remove NTF_EXT_LEARNED flag from an existing neighbor entry in combination with NTF_USE flag.
This is due to the latter directly calling into neigh_event_send() without any meta data updates as happening in __neigh_update(). Thus, to enable this use case, extend the latter with a NEIGH_UPDATE_F_USE flag where we break the NUD_PERMANENT state in particular so that a latter neigh_event_send() is able to re-resolve a neighbor entry.
Before fix, NUD_PERMANENT -> NUD_* & NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...]
As can be seen, despite the admin-triggered replace, the entry remains in the NUD_PERMANENT state.
After fix, NUD_PERMANENT -> NUD_* & NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE [...] # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn STALE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a PERMANENT [...]
After the fix, the admin-triggered replace switches to a dynamic state from the NTF_USE flag which triggered a new neighbor resolution. Likewise, we can transition back from there, if needed, into NUD_PERMANENT.
Similar before/after behavior can be observed for below transitions:
Before fix, NTF_USE -> NTF_USE | NTF_EXT_LEARNED -> NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...]
After fix, NTF_USE -> NTF_USE | NTF_EXT_LEARNED -> NTF_USE:
# ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE [...] # ./ip/ip n replace 192.168.178.30 dev enp5s0 use # ./ip/ip n 192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a REACHABLE [..]
--- include/net/neighbour.h | 1 + net/core/neighbour.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)
include/net/neighbour.h +1 -0
@@ -253,6 +253,7 @@ static inline void *neighbour_priv(const struct neighbour *n)#define NEIGH_UPDATE_F_OVERRIDE 0x00000001#define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002#define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004 +#define NEIGH_UPDATE_F_USE 0x10000000#define NEIGH_UPDATE_F_EXT_LEARNED 0x20000000#define NEIGH_UPDATE_F_ISROUTER 0x40000000#define NEIGH_UPDATE_F_ADMIN 0x80000000
net/core/neighbour.c +13 -9
@@ -1222,7 +1222,7 @@ static void neigh_update_hhs(struct neighbour *neigh) lladdr instead of overriding it if it is different. NEIGH_UPDATE_F_ADMIN means that the change is administrative. - + NEIGH_UPDATE_F_USE means that the entry is user triggered. NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing NTF_ROUTER flag. NEIGH_UPDATE_F_ISROUTER indicates if the neighbour is known as
@@ -1260,6 +1260,12 @@ static int __neigh_update(struct neighbour *neigh, const u8 *lladdr, goto out; ext_learn_change =neigh_update_ext_learned (neigh, flags, ¬ify); +if (flags &NEIGH_UPDATE_F_USE ) { + new = old & ~NUD_PERMANENT ; + neigh->nud_state = new; + err =0 ; + goto out; + }if (!(new &NUD_VALID )) {neigh_del_timer (neigh);
@@ -1971,22 +1977,20 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,if (protocol) neigh->protocol = protocol; -if (ndm->ndm_flags &NTF_EXT_LEARNED ) flags |=NEIGH_UPDATE_F_EXT_LEARNED ; -if (ndm->ndm_flags &NTF_ROUTER ) flags |=NEIGH_UPDATE_F_ISROUTER ; +if (ndm->ndm_flags &NTF_USE ) + flags |=NEIGH_UPDATE_F_USE ; -if (ndm->ndm_flags &NTF_USE ) { + err =__neigh_update (neigh, lladdr, ndm->ndm_state, flags, +NETLINK_CB (skb).portid, extack); +if (!err && ndm->ndm_flags &NTF_USE ) {neigh_event_send (neigh,NULL ); err =0 ; - }else - err =__neigh_update (neigh, lladdr, ndm->ndm_state, flags, -NETLINK_CB (skb).portid, extack); - + }neigh_release (neigh); - out:return err; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 548/575 9p/net: fix missing error check in p9_check_errors
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
commit 27eb4c3144f7a5ebef3c9a261d80cb3e1fa784dc upstream.
--- net/9p/client.c | 2 ++ 1 file changed, 2 insertions(+)
net/9p/client.c +2 -0
@@ -538,6 +538,8 @@ static int p9_check_errors(struct p9_clikfree (ename); }else { err =p9pdu_readf (&req->rc, c->proto_version,"d" , &ecode); +if (err) + goto out_err; err = -ecode;p9_debug (P9_DEBUG_9P ,"<<< RLERROR (%d)\n" , -ecode);
Greg Kroah-Hartman
maintainerPATCH 549/575 memcg: prohibit unconditional exceeding the limit of dying tasks
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit a4ebf1b6ca1e011289677239a2a361fde4a88076 upstream.
Memory cgroup charging allows killed or exiting tasks to exceed the hard limit. It is assumed that the amount of the memory charged by those tasks is bound and most of the memory will get released while the task is exiting. This is resembling a heuristic for the global OOM situation when tasks get access to memory reserves. There is no global memory shortage at the memcg level so the memcg heuristic is more relieved.
The above assumption is overly optimistic though. E.g. vmalloc can scale to really large requests and the heuristic would allow that. We used to have an early break in the vmalloc allocator for killed tasks but this has been reverted by commit b8c8a338f75e ("Revert "vmalloc:
back off when the current task is killed""). There are likely other similar code paths which do not check for fatal signals in an allocation&charge loop. Also there are some kernel objects charged to a memcg which are not bound to a process life time.
It has been observed that it is not really hard to trigger these bypasses and cause global OOM situation.
One potential way to address these runaways would be to limit the amount of excess (similar to the global OOM with limited oom reserves). This is certainly possible but it is not really clear how much of an excess is desirable and still protects from global OOMs as that would have to consider the overall memcg configuration.
This patch is addressing the problem by removing the heuristic altogether. Bypass is only allowed for requests which either cannot fail or where the failure is not desirable while excess should be still limited (e.g. atomic requests). Implementation wise a killed or dying task fails to charge if it has passed the OOM killer stage. That should give all forms of reclaim chance to restore the limit before the failure (ENOMEM) and tell the caller to back off.
In addition, this patch renames should_force_charge() helper to task_is_dying() because now its use is not associated witch forced charging.
This patch depends on pagefault_out_of_memory() to not trigger out_of_memory(), because then a memcg failure can unwind to VM_FAULT_OOM and cause a global OOM killer.
--- mm/memcontrol.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
mm/memcontrol.c +8 -19
@@ -230,7 +230,7 @@ enum res_type { iter !=NULL ; \ iter = mem_cgroup_iter(NULL, iter, NULL)) -static inline bool should_force_charge (void ) +static inline bool task_is_dying (void ) {return tsk_is_oom_victim (current) ||fatal_signal_pending (current) || (current->flags &PF_EXITING );
@@ -1729,7 +1729,7 @@ static bool mem_cgroup_out_of_memory(str* A few threads which were not waiting at mutex_lock_killable() can * fail to bail out. Therefore, check again after holding oom_lock. */ - ret =should_force_charge () ||out_of_memory (&oc); + ret =task_is_dying () ||out_of_memory (&oc); unlock:mutex_unlock (&oom_lock);
@@ -2683,6 +2683,7 @@ static int try_charge(struct mem_cgroupstruct page_counter *counter;enum oom_status oom_status;unsigned long nr_reclaimed; +bool passed_oom = false;bool may_swap = true;bool drained = false;unsigned long pflags;
@@ -2720,15 +2721,6 @@ retry: goto force;/* -* Unlike in global OOM situations, memcg is not in a physical -* memory shortage. Allow dying and OOM-killed tasks to -* bypass the last charges so that they can exit quickly and -* free their memory. -*/ -if (unlikely (should_force_charge ())) - goto force; - -/* * Prevent unbounded recursion when reclaim operations need to * allocate memory. This might exceed the limits temporarily, * but we prefer facilitating memory reclaim and getting back
@@ -2788,8 +2780,9 @@ retry:if (gfp_mask & __GFP_NOFAIL) goto force; -if (fatal_signal_pending (current)) - goto force; +/* Avoid endless loop for tasks bypassed by the oom killer */ +if (passed_oom &&task_is_dying ()) + goto nomem;/* * keep retrying as long as the memcg oom killer is able to make
@@ -2798,14 +2791,10 @@ retry:*/ oom_status =mem_cgroup_oom (mem_over_limit, gfp_mask,get_order (nr_pages *PAGE_SIZE )); -switch (oom_status) { -case OOM_SUCCESS : +if (oom_status ==OOM_SUCCESS ) { + passed_oom = true; nr_retries =MAX_RECLAIM_RETRIES ; goto retry; -case OOM_FAILED : - goto force; -default : - goto nomem; } nomem:if (!(gfp_mask & __GFP_NOFAIL))
Greg Kroah-Hartman
maintainerPATCH 550/575 powerpc/lib: Add helper to check if offset is within conditional branch range
In reply to Greg Kroah-HartmanFrom: "Naveen N. Rao" <[email protected]>
upstream commit 4549c3ea3160fa8b3f37dfe2f957657bb265eda9
Add a helper to check if a given offset is within the branch range for a powerpc conditional branch instruction, and update some sites to use the new helper.
--- arch/powerpc/include/asm/code-patching.h | 1 + arch/powerpc/lib/code-patching.c | 7 ++++++- arch/powerpc/net/bpf_jit.h | 7 +------ 3 files changed, 8 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/code-patching.h +1 -0
@@ -23,6 +23,7 @@#define BRANCH_ABSOLUTE 0x2bool is_offset_in_branch_range (long offset); +bool is_offset_in_cond_branch_range (long offset);int create_branch (struct ppc_inst *instr,const struct ppc_inst *addr,unsigned long target,int flags); int create_cond_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
arch/powerpc/lib/code-patching.c +6 -1
@@ -230,6 +230,11 @@ bool is_offset_in_branch_range(long offsreturn (offset >=-0x2000000 && offset <=0x1fffffc && !(offset &0x3 )); } +bool is_offset_in_cond_branch_range (long offset) +{ +return offset >=-0x8000 && offset <=0x7fff && !(offset &0x3 ); +} +/* * Helper to check if a given instruction is a conditional branch * Derived from the conditional checks in analyse_instr()
@@ -283,7 +288,7 @@ int create_cond_branch(struct ppc_inst * offset = offset - (unsigned long )addr;/* Check we can represent the target in the instruction format */ -if (offset <-0x8000 || offset >0x7FFF || offset &0x3 ) +if (!is_offset_in_cond_branch_range (offset))return 1 ;/* Mask out the flags and target, so they don't step on each other. */
arch/powerpc/net/bpf_jit.h +1 -6
@@ -71,11 +71,6 @@#define PPC_FUNC_ADDR (d,i) do { PPC_LI32(d, i); } while(0)#endif -static inline bool is_nearbranch (int offset) -{ -return (offset <32768 ) && (offset >=-32768 ); -} -/* * The fly in the ointment of code size changing from pass to pass is * avoided by padding the short branch case with a NOP. If code size differs
@@ -84,7 +79,7 @@ static inline bool is_nearbranch(int off* state. */ #define PPC_BCC (cond, dest) do { \ - if (is_nearbranch((dest) - (ctx->idx * 4))) { \ + if (is_offset_in_cond_branch_range((long)(dest) - (ctx->idx * 4))) { \ PPC_BCC_SHORT(cond, dest); \ EMIT(PPC_RAW_NOP()); \ } else { \
Greg Kroah-Hartman
maintainerPATCH 551/575 powerpc/bpf: Validate branch ranges
In reply to Greg Kroah-HartmanFrom: "Naveen N. Rao" <[email protected]>
upstream commit 3832ba4e283d7052b783dab8311df7e3590fed93
Add checks to ensure that we never emit branch instructions with truncated branch offsets.
--- arch/powerpc/net/bpf_jit.h | 26 ++++++++++++++++++++------ arch/powerpc/net/bpf_jit_comp64.c | 8 ++++++-- 2 files changed, 26 insertions(+), 8 deletions(-)
arch/powerpc/net/bpf_jit.h +20 -6
@@ -12,6 +12,7 @@#include <asm/types.h> #include <asm/ppc-opcode.h> +#include <asm/code-patching.h> #ifdef PPC64_ELF_ABI_v1#define FUNCTION_DESCR_SIZE 24
@@ -24,13 +25,26 @@#define EMIT (instr) PLANT_INSTR(image, ctx->idx, instr)/* Long jump; (unconditional 'branch') */ -#define PPC_JMP (dest) EMIT(PPC_INST_BRANCH | \ - (((dest) - (ctx->idx * 4)) & 0x03fffffc)) +#define PPC_JMP (dest) \ + do { \ + long offset = (long)(dest) - (ctx->idx * 4); \ + if (!is_offset_in_branch_range(offset)) { \ + pr_err_ratelimited("Branch offset 0x%lx (@%u) out of range\n", offset, ctx->idx); \ + return -ERANGE; \ + } \ + EMIT(PPC_INST_BRANCH | (offset & 0x03fffffc)); \ + } while (0)/* "cond" here covers BO:BI fields. */ -#define PPC_BCC_SHORT (cond, dest) EMIT(PPC_INST_BRANCH_COND | \ - (((cond) & 0x3ff) << 16) | \ - (((dest) - (ctx->idx * 4)) & \ - 0xfffc)) +#define PPC_BCC_SHORT (cond, dest) \ + do { \ + long offset = (long)(dest) - (ctx->idx * 4); \ + if (!is_offset_in_cond_branch_range(offset)) { \ + pr_err_ratelimited("Conditional branch offset 0x%lx (@%u) out of range\n", offset, ctx->idx); \ + return -ERANGE; \ + } \ + EMIT(PPC_INST_BRANCH_COND | (((cond) & 0x3ff) << 16) | (offset & 0xfffc)); \ + } while (0) +/* Sign-extended 32-bit immediate load */ #define PPC_LI32 (d, i) do { \ if ((int)(uintptr_t)(i) >= -32768 && \
arch/powerpc/net/bpf_jit_comp64.c +6 -2
@@ -224,7 +224,7 @@ static void bpf_jit_emit_func_call_rel(uEMIT (PPC_RAW_BLRL ()); } -static void bpf_jit_emit_tail_call (u32 *image,struct codegen_context *ctx,u32 out) +static int bpf_jit_emit_tail_call (u32 *image,struct codegen_context *ctx,u32 out) {/* * By now, the eBPF program has already setup parameters in r3, r4 and r5
@@ -285,7 +285,9 @@ static void bpf_jit_emit_tail_call(u32 *bpf_jit_emit_common_epilogue (image, ctx);EMIT (PPC_RAW_BCTR ()); +/* out: */ +return 0 ; }/* Assemble the body code between the prologue & epilogue */
@@ -1010,7 +1012,9 @@ cond_branch:*/ case BPF_JMP |BPF_TAIL_CALL : ctx->seen |=SEEN_TAILCALL ; -bpf_jit_emit_tail_call (image, ctx, addrs[i +1 ]); + ret =bpf_jit_emit_tail_call (image, ctx, addrs[i +1 ]); +if (ret <0 ) +return ret;break ;default :
Greg Kroah-Hartman
maintainerPATCH 552/575 powerpc/security: Add a helper to query stf_barrier type
In reply to Greg Kroah-HartmanFrom: "Naveen N. Rao" <[email protected]>
upstream commit 030905920f32e91a52794937f67434ac0b3ea41a
Add a helper to return the stf_barrier type for the current processor.
--- arch/powerpc/include/asm/security_features.h | 5 +++++ arch/powerpc/kernel/security.c | 5 +++++ 2 files changed, 10 insertions(+)
arch/powerpc/include/asm/security_features.h +5 -0
@@ -39,6 +39,11 @@ static inline bool security_ftr_enabled(return !!(powerpc_security_features & feature); } +#ifdef CONFIG_PPC_BOOK3S_64 +enum stf_barrier_type stf_barrier_type_get (void ); +#else +static inline enum stf_barrier_type stf_barrier_type_get (void ) {return STF_BARRIER_NONE ; } +#endif // Features indicating support for Spectre/Meltdown mitigations
arch/powerpc/kernel/security.c +5 -0
@@ -261,6 +261,11 @@ static int __init handle_no_stf_barrier(early_param ("no_stf_barrier" , handle_no_stf_barrier); +enum stf_barrier_type stf_barrier_type_get (void ) +{ +return stf_enabled_flush_types; +} +/* This is the generic flag used by other architectures */ static int __init handle_ssbd (char *p) {
Greg Kroah-Hartman
maintainerPATCH 553/575 powerpc/bpf: Emit stf barrier instruction sequences for BPF_NOSPEC
In reply to Greg Kroah-HartmanFrom: "Naveen N. Rao" <[email protected]>
upstream commit b7540d62509453263604a155bf2d5f0ed450cba2
Emit similar instruction sequences to commit a048a07d7f4535 ("powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit") when encountering BPF_NOSPEC.
Mitigations are enabled depending on what the firmware advertises. In particular, we do not gate these mitigations based on current settings, just like in x86. Due to this, we don't need to take any action if mitigations are enabled or disabled at runtime.
[adjust macros to account for commits 1c9debbc2eb539 and ef909ba954145e. adjust security feature checks to account for commit 84ed26fd00c514]
--- arch/powerpc/net/bpf_jit64.h | 8 ++--- arch/powerpc/net/bpf_jit_comp64.c | 56 +++++++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 8 deletions(-)
arch/powerpc/net/bpf_jit64.h +4 -4
@@ -16,18 +16,18 @@* with our redzone usage. * * [ prev sp ] <------------- -* [ nv gpr save area ] 6*8 | +* [ nv gpr save area ] 5*8 | * [ tail_call_cnt ] 8 | -* [ local_tmp_var ] 8 | +* [ local_tmp_var ] 16 | * fp (r31) --> [ ebpf stack space ] upto 512 | * [ frame header ] 32/112 | * sp (r1) ---> [ stack pointer ] -------------- */ /* for gpr non volatile registers BPG_REG_6 to 10 */ -#define BPF_PPC_STACK_SAVE (6*8) +#define BPF_PPC_STACK_SAVE (5*8)/* for bpf JIT code internal usage */ -#define BPF_PPC_STACK_LOCALS 16 +#define BPF_PPC_STACK_LOCALS 24/* stack frame excluding BPF stack, ensure this is quadword aligned */ #define BPF_PPC_STACKFRAME (STACK_FRAME_MIN_SIZE + \ BPF_PPC_STACK_LOCALS + BPF_PPC_STACK_SAVE)
arch/powerpc/net/bpf_jit_comp64.c +52 -4
96 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 554/575 mm, oom: pagefault_out_of_memory: dont force global OOM for dying tasks
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit 0b28179a6138a5edd9d82ad2687c05b3773c387b upstream.
Patch series "memcg: prohibit unconditional exceeding the limit of dying tasks", v3.
Memory cgroup charging allows killed or exiting tasks to exceed the hard limit. It can be misused and allowed to trigger global OOM from inside a memcg-limited container. On the other hand if memcg fails allocation, called from inside #PF handler it triggers global OOM from inside pagefault_out_of_memory().
To prevent these problems this patchset:
(a) removes execution of out_of_memory() from pagefault_out_of_memory(), becasue nobody can explain why it is necessary.
(b) allow memcg to fail allocation of dying/killed tasks.
This patch (of 3):
Any allocation failure during the #PF path will return with VM_FAULT_OOM which in turn results in pagefault_out_of_memory which in turn executes out_out_memory() and can kill a random task.
An allocation might fail when the current task is the oom victim and there are no memory reserves left. The OOM killer is already handled at the page allocator level for the global OOM and at the charging level for the memcg one. Both have much more information about the scope of allocation/charge request. This means that either the OOM killer has been invoked properly and didn't lead to the allocation success or it has been skipped because it couldn't have been invoked. In both cases triggering it from here is pointless and even harmful.
It makes much more sense to let the killed task die rather than to wake up an eternally hungry oom-killer and send him to choose a fatter victim for breakfast.
--- mm/oom_kill.c | 3 +++ 1 file changed, 3 insertions(+)
mm/oom_kill.c +3 -0
@@ -1135,6 +1135,9 @@ void pagefault_out_of_memory(void)if (mem_cgroup_oom_synchronize (true))return ; +if (fatal_signal_pending (current)) +return ; +if (!mutex_trylock (&oom_lock))return ;out_of_memory (&oc);
Greg Kroah-Hartman
maintainerPATCH 555/575 mm, oom: do not trigger out_of_memory from the #PF
In reply to Greg Kroah-HartmanFrom: Michal Hocko <[email protected]>
commit 60e2793d440a3ec95abb5d6d4fc034a4b480472d upstream.
Any allocation failure during the #PF path will return with VM_FAULT_OOM which in turn results in pagefault_out_of_memory. This can happen for 2 different reasons. a) Memcg is out of memory and we rely on mem_cgroup_oom_synchronize to perform the memcg OOM handling or b) normal allocation fails.
The latter is quite problematic because allocation paths already trigger out_of_memory and the page allocator tries really hard to not fail allocations. Anyway, if the OOM killer has been already invoked there is no reason to invoke it again from the #PF path. Especially when the OOM condition might be gone by that time and we have no way to find out other than allocate.
Moreover if the allocation failed and the OOM killer hasn't been invoked then we are unlikely to do the right thing from the #PF context because we have already lost the allocation context and restictions and therefore might oom kill a task from a different NUMA domain.
This all suggests that there is no legitimate reason to trigger out_of_memory from pagefault_out_of_memory so drop it. Just to be sure that no #PF path returns with VM_FAULT_OOM without allocation print a warning that this is happening before we restart the #PF.
[VvS: #PF allocation can hit into limit of cgroup v1 kmem controller. This is a local problem related to memcg, however, it causes unnecessary global OOM kills that are repeated over and over again and escalate into a real disaster. This has been broken since kmem accounting has been introduced for cgroup v1 (3.8). There was no kmem specific reclaim for the separate limit so the only way to handle kmem hard limit was to return with ENOMEM. In upstream the problem will be fixed by removing the outdated kmem limit, however stable and LTS kernels cannot do it and are still affected. This patch fixes the problem and should be backported into stable/LTS.]
--- mm/oom_kill.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
mm/oom_kill.c +8 -14
@@ -1118,19 +1118,15 @@ bool out_of_memory(struct oom_control *o }/* -* The pagefault handler calls here because it is out of memory, so kill a -* memory-hogging task. If oom_lock is held by somebody else, a parallel oom -* killing is already in progress so do nothing. +* The pagefault handler calls here because some allocation has failed. We have +* to take care of the memcg OOM here because this is the only safe context without +* any locks held but let the oom killer triggered from the allocation context care +* about the global OOM. */ void pagefault_out_of_memory (void ) { -struct oom_control oc = { - .zonelist =NULL , - .nodemask =NULL , - .memcg =NULL , - .gfp_mask =0 , - .order =0 , - }; + static DEFINE_RATELIMIT_STATE(pfoom_rs, DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST);if (mem_cgroup_oom_synchronize (true))return ;
@@ -1138,8 +1134,6 @@ void pagefault_out_of_memory(void)if (fatal_signal_pending (current))return ; -if (!mutex_trylock (&oom_lock)) -return ; -out_of_memory (&oc); -mutex_unlock (&oom_lock); +if (__ratelimit (&pfoom_rs)) +pr_warn ("Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF\n" ); }
Greg Kroah-Hartman
maintainerPATCH 556/575 mfd: dln2: Add cell for initializing DLN2 ADC
In reply to Greg Kroah-HartmanFrom: Jack Andersen <[email protected]>
commit 313c84b5ae4104e48c661d5d706f9f4c425fd50f upstream.
This patch extends the DLN2 driver; adding cell for adc_dln2 module.
The original patch[1] fell through the cracks when the driver was added so ADC has never actually been usable. That patch did not have ACPI support which was added in v5.9, so the oldest supported version this current patch can be backported to is 5.10.
[1] https://www.spinics.net/lists/linux-iio/msg33975.html
--- drivers/mfd/dln2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/mfd/dln2.c +18 -0
@@ -50,6 +50,7 @@ enum dln2_handle {DLN2_HANDLE_GPIO ,DLN2_HANDLE_I2C ,DLN2_HANDLE_SPI , +DLN2_HANDLE_ADC , DLN2_HANDLES };
@@ -653,6 +654,7 @@ enum {DLN2_ACPI_MATCH_GPIO =0 ,DLN2_ACPI_MATCH_I2C =1 ,DLN2_ACPI_MATCH_SPI =2 , + DLN2_ACPI_MATCH_ADC = 3, }; static struct dln2_platform_data dln2_pdata_gpio = {
@@ -683,6 +685,16 @@ static struct mfd_cell_acpi_match dln2_a .adr = DLN2_ACPI_MATCH_SPI, }; +/* Only one ADC port supported */ +static struct dln2_platform_data dln2_pdata_adc = { + .handle =DLN2_HANDLE_ADC , + .port =0 , +}; + +static struct mfd_cell_acpi_match dln2_acpi_match_adc = { + .adr =DLN2_ACPI_MATCH_ADC , +}; +static const struct mfd_cell dln2_devs[] = { { .name ="dln2-gpio" ,
@@ -702,6 +714,12 @@ static const struct mfd_cell dln2_devs[] .platform_data = &dln2_pdata_spi, .pdata_size = sizeof(struct dln2_platform_data), }, + { + .name = "dln2-adc", + .acpi_match = &dln2_acpi_match_adc, + .platform_data = &dln2_pdata_adc, + .pdata_size = sizeof(struct dln2_platform_data), + }, };static void dln2_stop (struct dln2_dev *dln2)
Greg Kroah-Hartman
maintainerPATCH 557/575 video: backlight: Drop maximum brightness override for brightness zero
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit 33a5471f8da976bf271a1ebbd6b9d163cb0cb6aa upstream.
The note in c2adda27d202f ("video: backlight: Add of_find_backlight helper in backlight.c") says that gpio-backlight uses brightness as power state. This has been fixed since in ec665b756e6f7 ("backlight: gpio-backlight:
Correct initial power state handling") and other backlight drivers do not require this workaround. Drop the workaround.
This fixes the case where e.g. pwm-backlight can perfectly well be set to brightness 0 on boot in DT, which without this patch leads to the display brightness to be max instead of off.
--- drivers/video/backlight/backlight.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/video/backlight/backlight.c +0 -6
@@ -688,12 +688,6 @@ static struct backlight_device *of_find_of_node_put (np);if (!bd)return ERR_PTR (-EPROBE_DEFER ); -/* -* Note: gpio_backlight uses brightness as -* power state during probe -*/ -if (!bd->props.brightness) - bd->props.brightness = bd->props.max_brightness; } }
Greg Kroah-Hartman
maintainerPATCH 558/575 s390/cio: check the subchannel validity for dev_busid
In reply to Greg Kroah-HartmanFrom: Vineeth Vijayan <[email protected]>
commit a4751f157c194431fae9e9c493f456df8272b871 upstream.
Check the validity of subchanel before reading other fields in the schib.
--- drivers/s390/cio/css.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/cio/css.c +2 -2
@@ -433,8 +433,8 @@ static ssize_t dev_busid_show(struct devstruct subchannel *sch =to_subchannel (dev);struct pmcw *pmcw = &sch->schib.pmcw; -if ((pmcw->st ==SUBCHANNEL_TYPE_IO || - pmcw->st ==SUBCHANNEL_TYPE_MSG ) && pmcw->dnv) +if ((pmcw->st ==SUBCHANNEL_TYPE_IO && pmcw->dnv) || + (pmcw->st ==SUBCHANNEL_TYPE_MSG && pmcw->w))return sysfs_emit (buf,"0.%x.%04x\n" , sch->schid.ssid, pmcw->dev);else
Greg Kroah-Hartman
maintainerPATCH 559/575 s390/tape: fix timer initialization in tape_std_assign()
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 213fca9e23b59581c573d558aa477556f00b8198 upstream.
commit 9c6c273aa424 ("timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack()") changed the timer setup from init_timer_on_stack(() to timer_setup(), but missed to change the mod_timer() call. And while at it, use msecs_to_jiffies() instead of the open coded timeout calculation.
--- drivers/s390/char/tape_std.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/char/tape_std.c +1 -2
@@ -53,7 +53,6 @@ int tape_std_assign(struct tape_device *device) {int rc; -struct timer_list timeout;struct tape_request *request; request =tape_alloc_request (2 ,11 );
@@ -70,7 +69,7 @@ tape_std_assign(struct tape_device *devi* So we set up a timeout for this call. */ timer_setup (&request->timer, tape_std_assign_timeout,0 ); -mod_timer (&timeout, jiffies +2 *HZ ); +mod_timer (&request->timer, jiffies +msecs_to_jiffies (2000 )); rc =tape_do_io_interruptible (device, request);
Greg Kroah-Hartman
maintainerPATCH 560/575 s390/ap: Fix hanging ioctl caused by orphaned replies
In reply to Greg Kroah-HartmanFrom: Harald Freudenberger <[email protected]>
commit 3826350e6dd435e244eb6e47abad5a47c169ebc2 upstream.
When a queue is switched to soft offline during heavy load and later switched to soft online again and now used, it may be that the caller is blocked forever in the ioctl call.
The failure occurs because there is a pending reply after the queue(s) have been switched to offline. This orphaned reply is received when the queue is switched to online and is accidentally counted for the outstanding replies. So when there was a valid outstanding reply and this orphaned reply is received it counts as the outstanding one thus dropping the outstanding counter to 0. Voila, with this counter the receive function is not called any more and the real outstanding reply is never received (until another request comes in...) and the ioctl blocks.
The fix is simple. However, instead of readjusting the counter when an orphaned reply is detected, I check the queue status for not empty and compare this to the outstanding counter. So if the queue is not empty then the counter must not drop to 0 but at least have a value of 1.
--- drivers/s390/crypto/ap_queue.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/crypto/ap_queue.c +2 -0
@@ -142,6 +142,8 @@ static struct ap_queue_status ap_sm_recvswitch (status.response_code) {case AP_RESPONSE_NORMAL : aq->queue_count =max_t (int,0 , aq->queue_count -1 ); +if (!status.queue_empty && !aq->queue_count) + aq->queue_count++;if (aq->queue_count >0 )mod_timer (&aq->timeout, jiffies + aq->request_timeout);
Greg Kroah-Hartman
maintainerPATCH 561/575 s390/cio: make ccw_device_dma_* more robust
In reply to Greg Kroah-HartmanFrom: Halil Pasic <[email protected]>
commit ad9a14517263a16af040598c7920c09ca9670a31 upstream.
Since commit 48720ba56891 ("virtio/s390: use DMA memory for ccw I/O and classic notifiers") we were supposed to make sure that virtio_ccw_release_dev() completes before the ccw device and the attached dma pool are torn down, but unfortunately we did not. Before that commit it used to be OK to delay cleaning up the memory allocated by virtio-ccw indefinitely (which isn't really intuitive for guys used to destruction happens in reverse construction order), but now we trigger a BUG_ON if the genpool is destroyed before all memory allocated from it is deallocated. Which brings down the guest. We can observe this problem, when unregister_virtio_device() does not give up the last reference to the virtio_device (e.g. because a virtio-scsi attached scsi disk got removed without previously unmounting its previously mounted partition).
To make sure that the genpool is only destroyed after all the necessary freeing is done let us take a reference on the ccw device on each ccw_device_dma_zalloc() and give it up on each ccw_device_dma_free().
Actually there are multiple approaches to fixing the problem at hand that can work. The upside of this one is that it is the safest one while remaining simple. We don't crash the guest even if the driver does not pair allocations and frees. The downside is the reference counting overhead, that the reference counting for ccw devices becomes more complex, in a sense that we need to pair the calls to the aforementioned functions for it to be correct, and that if we happen to leak, we leak more than necessary (the whole ccw device instead of just the genpool).
Some alternatives to this approach are taking a reference in virtio_ccw_online() and giving it up in virtio_ccw_release_dev() or making sure virtio_ccw_release_dev() completes its work before virtio_ccw_remove() returns. The downside of these approaches is that these are less safe against programming errors.
--- drivers/s390/cio/device_ops.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/s390/cio/device_ops.c +11 -1
@@ -825,13 +825,23 @@ EXPORT_SYMBOL_GPL(ccw_device_get_chid);*/ void *ccw_device_dma_zalloc (struct ccw_device *cdev,size_t size) { -return cio_gp_dma_zalloc (cdev->private->dma_pool, &cdev->dev, size); +void *addr; + +if (!get_device (&cdev->dev)) +return NULL ; + addr =cio_gp_dma_zalloc (cdev->private->dma_pool, &cdev->dev, size); +if (IS_ERR_OR_NULL (addr)) +put_device (&cdev->dev); +return addr; }EXPORT_SYMBOL (ccw_device_dma_zalloc);void ccw_device_dma_free (struct ccw_device *cdev,void *cpu_addr,size_t size) { +if (!cpu_addr) +return ;cio_gp_dma_free (cdev->private->dma_pool, cpu_addr, size); +put_device (&cdev->dev); }EXPORT_SYMBOL (ccw_device_dma_free);
Greg Kroah-Hartman
maintainerPATCH 562/575 mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit d707bb74daae07879e0fc1b4b960f8f2d0a5fe5d upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/ams-delta.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +9 -3
@@ -217,9 +217,8 @@ static int gpio_nand_setup_interface(strstatic int gpio_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -370,6 +369,13 @@ static int gpio_nand_probe(struct platfo/* Release write protection */ gpiod_set_value (priv->gpiod_nwp,0 ); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (this,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 563/575 mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 6bcd2960af1b7bacb2f1e710ab0c0b802d900501 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/xway_nand.c +9 -3
@@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_cstatic int xway_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -219,6 +218,13 @@ static int xway_nand_probe(struct platfo | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P | cs_flag, EBU_NAND_CON); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (&data->chip,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 564/575 mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit f9d8570b7fd6f4f08528ce2f5e39787a8a260cd6 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/mpc5121_nfc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/mpc5121_nfc.c +9 -3
@@ -605,9 +605,8 @@ static void mpc5121_nfc_free(struct devistatic int mpc5121_nfc_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -772,6 +771,13 @@ static int mpc5121_nfc_probe(struct plat goto error; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Detect NAND chips */ retval =nand_scan (chip,be32_to_cpup (chips_no));if (retval) {
Greg Kroah-Hartman
maintainerPATCH 565/575 mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit b5b5b4dc6fcd8194b9dd38c8acdc5ab71adf44f8 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/gpio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/gpio.c +9 -3
@@ -163,9 +163,8 @@ static int gpio_nand_exec_op(struct nandstatic int gpio_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -365,6 +364,13 @@ static int gpio_nand_probe(struct platfoif (gpiomtd->nwp && !IS_ERR (gpiomtd->nwp))gpiod_direction_output (gpiomtd->nwp,1 ); +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (chip,1 );if (ret) goto err_wp;
Greg Kroah-Hartman
maintainerPATCH 566/575 mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit f16b7d2a5e810fcf4b15d096246d0d445da9cc88 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/pasemi_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/pasemi_nand.c +9 -3
@@ -76,9 +76,8 @@ static int pasemi_device_ready(struct nastatic int pasemi_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -155,6 +154,13 @@ static int pasemi_nand_probe(struct plat/* Enable the following for a flash based bad block table */ chip->bbt_options =NAND_BBT_USE_FLASH ; +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (chip,1 );if (err)
Greg Kroah-Hartman
maintainerPATCH 567/575 mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 194ac63de6ff56d30c48e3ac19c8a412f9c1408e upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/orion_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/orion_nand.c +9 -3
@@ -85,9 +85,8 @@ static void orion_nand_read_buf(struct nstatic int orion_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -190,6 +189,13 @@ static int __init orion_nand_probe(strucreturn ret; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + nc->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (nc,1 );if (ret) goto no_dev;
Greg Kroah-Hartman
maintainerPATCH 568/575 mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 325fd539fc84f0aaa0ceb9d7d3b8718582473dc5 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/plat_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/plat_nand.c +9 -3
@@ -21,9 +21,8 @@ struct plat_nand_data {static int plat_nand_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -94,6 +93,13 @@ static int plat_nand_probe(struct platfo goto out; } +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; +/* Scan to find existence of the device */ err =nand_scan (&data->chip, pdata->chip.nr_chips);if (err)
Greg Kroah-Hartman
maintainerPATCH 569/575 mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 7e3cdba176ba59eaf4d463d273da0718e3626140 upstream.
Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones.
It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree.
There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT)
As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided.
--- drivers/mtd/nand/raw/au1550nd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/au1550nd.c +9 -3
@@ -238,9 +238,8 @@ static int au1550nd_exec_op(struct nand_static int au1550nd_attach_chip (struct nand_chip *chip) { - chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; - -if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ;
@@ -309,6 +308,13 @@ static int au1550nd_probe(struct platforif (pd->devwidth) this->options |=NAND_BUSWIDTH_16 ; +/* +* This driver assumes that the default ECC engine should be TYPE_SOFT. +* Set ->engine_type before registering the NAND devices in order to +* provide a driver specific default value. +*/ + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; + ret =nand_scan (this,1 );if (ret) {dev_err (&pdev->dev,"NAND scan failed with %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 570/575 powerpc/powernv/prd: Unregister OPAL_MSG_PRD2 notifier during module unload
In reply to Greg Kroah-HartmanFrom: Vasant Hegde <[email protected]>
commit 52862ab33c5d97490f3fa345d6529829e6d6637b upstream.
Commit 587164cd, introduced new opal message type (OPAL_MSG_PRD2) and added opal notifier. But I missed to unregister the notifier during module unload path. This results in below call trace if you try to unload and load opal_prd module.
Also add new notifier_block for OPAL_MSG_PRD2 message.
Sample calltrace (modprobe -r opal_prd; modprobe opal_prd)
BUG: Unable to handle kernel data access on read at 0xc0080000192200e0
Faulting instruction address: 0xc00000000018d1cc
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA PowerNV
CPU: 66 PID: 7446 Comm: modprobe Kdump: loaded Tainted: G E 5.14.0prd #759
NIP: c00000000018d1cc LR: c00000000018d2a8 CTR: c0000000000cde10
REGS: c0000003c4c0f0a0 TRAP: 0300 Tainted: G E (5.14.0prd)
MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 24224824 XER: 20040000
CFAR: c00000000018d2a4 DAR: c0080000192200e0 DSISR: 40000000 IRQMASK: 1
...
NIP notifier_chain_register+0x2c/0xc0
LR atomic_notifier_chain_register+0x48/0x80
Call Trace:
0xc000000002090610 (unreliable)
atomic_notifier_chain_register+0x58/0x80
opal_message_notifier_register+0x7c/0x1e0
opal_prd_probe+0x84/0x150 [opal_prd]
platform_probe+0x78/0x130
really_probe+0x110/0x5d0
__driver_probe_device+0x17c/0x230
driver_probe_device+0x60/0x130
__driver_attach+0xfc/0x220
bus_for_each_dev+0xa8/0x130
driver_attach+0x34/0x50
bus_add_driver+0x1b0/0x300
driver_register+0x98/0x1a0
__platform_driver_register+0x38/0x50
opal_prd_driver_init+0x34/0x50 [opal_prd]
do_one_initcall+0x60/0x2d0
do_init_module+0x7c/0x320
load_module+0x3394/0x3650
__do_sys_finit_module+0xd4/0x160
system_call_exception+0x140/0x290
system_call_common+0xf4/0x258--- arch/powerpc/platforms/powernv/opal-prd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-prd.c +11 -1
@@ -372,6 +372,12 @@ static struct notifier_block opal_prd_ev .priority = 0, }; +static struct notifier_block opal_prd_event_nb2 = { + .notifier_call = opal_prd_msg_notifier, + .next =NULL , + .priority =0 , +}; +static int opal_prd_probe (struct platform_device *pdev) {int rc;
@@ -393,9 +399,10 @@ static int opal_prd_probe(struct platforreturn rc; } - rc =opal_message_notifier_register (OPAL_MSG_PRD2 , &opal_prd_event_nb); + rc =opal_message_notifier_register (OPAL_MSG_PRD2 , &opal_prd_event_nb2);if (rc) {pr_err ("Couldn't register PRD2 event notifier\n" ); +opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb);return rc; }
@@ -404,6 +411,8 @@ static int opal_prd_probe(struct platforpr_err ("failed to register miscdev\n" );opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb); +opal_message_notifier_unregister (OPAL_MSG_PRD2 , + &opal_prd_event_nb2);return rc; }
@@ -414,6 +423,7 @@ static int opal_prd_remove(struct platfo {misc_deregister (&opal_prd_dev);opal_message_notifier_unregister (OPAL_MSG_PRD , &opal_prd_event_nb); +opal_message_notifier_unregister (OPAL_MSG_PRD2 , &opal_prd_event_nb2);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 571/575 powerpc/85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n
In reply to Greg Kroah-HartmanFrom: Xiaoming Ni <[email protected]>
commit c45361abb9185b1e172bd75eff51ad5f601ccae4 upstream.
When CONFIG_SMP=y, timebase synchronization is required when the second kernel is started.
arch/powerpc/kernel/smp.c:
int __cpu_up(unsigned int cpu, struct task_struct *tidle) {
...
if (smp_ops->give_timebase)
smp_ops->give_timebase();
...
}
void start_secondary(void *unused)
{
...
if (smp_ops->take_timebase)
smp_ops->take_timebase();
...
}When CONFIG_HOTPLUG_CPU=n and CONFIG_KEXEC_CORE=n,
smp_85xx_ops.give_timebase is NULL, smp_85xx_ops.take_timebase is NULL,
As a result, the timebase is not synchronized.
Timebase synchronization does not depend on CONFIG_HOTPLUG_CPU.
--- arch/powerpc/platforms/85xx/Makefile | 4 +++- arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c | 4 ++++ arch/powerpc/platforms/85xx/smp.c | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-)
arch/powerpc/platforms/85xx/Makefile +3 -1
@@ -3,7 +3,9 @@ # Makefile for the PowerPC 85xx linux kernel. # obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_FSL_PMC) += mpc85xx_pm_ops.o +ifneq ($(CONFIG_FSL_CORENET_RCPM),y) +obj-$(CONFIG_SMP) += mpc85xx_pm_ops.o +endif obj-y += common.o
arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c +4 -0
@@ -17,6 +17,7 @@static struct ccsr_guts __iomem *guts; +#ifdef CONFIG_FSL_PMC static void mpc85xx_irq_mask (int cpu) {
@@ -49,6 +50,7 @@ static void mpc85xx_cpu_up_prepare(int c { } +#endif static void mpc85xx_freeze_time_base (bool freeze) {
@@ -76,10 +78,12 @@ static const struct of_device_id mpc85xxstatic const struct fsl_pm_ops mpc85xx_pm_ops = { .freeze_time_base = mpc85xx_freeze_time_base, +#ifdef CONFIG_FSL_PMC .irq_mask = mpc85xx_irq_mask, .irq_unmask = mpc85xx_irq_unmask, .cpu_die = mpc85xx_cpu_die, .cpu_up_prepare = mpc85xx_cpu_up_prepare, +#endif };int __init mpc85xx_setup_pmc (void )
arch/powerpc/platforms/85xx/smp.c +6 -6
@@ -40,7 +40,6 @@ struct epapr_spin_table {u32 pir; }; -#ifdef CONFIG_HOTPLUG_CPU static u64 timebase;static int tb_req;static int tb_valid;
@@ -112,6 +111,7 @@ static void mpc85xx_take_timebase(void)local_irq_restore (flags); } +#ifdef CONFIG_HOTPLUG_CPU static void smp_85xx_cpu_offline_self (void ) {unsigned int cpu =smp_processor_id ();
@@ -495,21 +495,21 @@ void __init mpc85xx_smp_init(void) smp_85xx_ops.probe =NULL ; } -#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_FSL_CORENET_RCPM +/* Assign a value to qoriq_pm_ops on PPC_E500MC */ fsl_rcpm_init (); -#endif - -#ifdef CONFIG_FSL_PMC +#else +/* Assign a value to qoriq_pm_ops on !PPC_E500MC */ mpc85xx_setup_pmc ();#endif if (qoriq_pm_ops) { smp_85xx_ops.give_timebase = mpc85xx_give_timebase; smp_85xx_ops.take_timebase = mpc85xx_take_timebase; +#ifdef CONFIG_HOTPLUG_CPU smp_85xx_ops.cpu_offline_self = smp_85xx_cpu_offline_self; smp_85xx_ops.cpu_die = qoriq_cpu_kill; - }#endif + } smp_ops = &smp_85xx_ops;#ifdef CONFIG_KEXEC_CORE
Greg Kroah-Hartman
maintainerPATCH 572/575 drm/sun4i: Fix macros in sun8i_csc.h
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
commit c302c98da646409d657a473da202f10f417f3ff1 upstream.
Macros SUN8I_CSC_CTRL() and SUN8I_CSC_COEFF() don't follow usual recommendation of having arguments enclosed in parenthesis. While that didn't change anything for quite sometime, it actually become important after CSC code rework with commit ea067aee45a8 ("drm/sun4i: de2/de3:
Remove redundant CSC matrices").
Without this fix, colours are completely off for supported YVU formats on SoCs with DE2 (A64, H3, R40, etc.).
Fix the issue by enclosing macro arguments in parenthesis.
--- drivers/gpu/drm/sun4i/sun8i_csc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun8i_csc.h +2 -2
@@ -16,8 +16,8 @@ struct sun8i_mixer;#define CCSC10_OFFSET 0xA0000#define CCSC11_OFFSET 0xF0000 -#define SUN8I_CSC_CTRL (base) (base + 0x0) -#define SUN8I_CSC_COEFF (base, i) (base + 0x10 + 4 * i) +#define SUN8I_CSC_CTRL (base) ((base) + 0x0) +#define SUN8I_CSC_COEFF (base, i) ((base) + 0x10 + 4 * (i))#define SUN8I_CSC_CTRL_EN BIT(0)
Signature · 1 line
2.33.1
Greg Kroah-Hartman
maintainerPATCH 573/575 PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 460275f124fb072dca218a6b43b6370eebbab20d upstream.
Define a macro PCI_EXP_DEVCTL_PAYLOAD_* for every possible Max Payload Size in linux/pci_regs.h, in the same style as PCI_EXP_DEVCTL_READRQ_*.
--- include/uapi/linux/pci_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/uapi/linux/pci_regs.h +6 -0
@@ -504,6 +504,12 @@#define PCI_EXP_DEVCTL_URRE 0x0008/* Unsupported Request Reporting En. */ #define PCI_EXP_DEVCTL_RELAX_EN 0x0010/* Enable relaxed ordering */ #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0/* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000/* 128 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020/* 256 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040/* 512 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060/* 1024 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080/* 2048 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0/* 4096 Bytes */ #define PCI_EXP_DEVCTL_EXT_TAG 0x0100/* Extended Tag Field Enable */ #define PCI_EXP_DEVCTL_PHANTOM 0x0200/* Phantom Functions Enable */ #define PCI_EXP_DEVCTL_AUX_PME 0x0400/* Auxiliary Power PM Enable */
Greg Kroah-Hartman
maintainerPATCH 574/575 PCI: aardvark: Fix PCIe Max Payload Size setting
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit a4e17d65dafdd3513042d8f00404c9b6068a825c upstream.
Change PCIe Max Payload Size setting in PCIe Device Control register to 512 bytes to align with PCIe Link Initialization sequence as defined in Marvell Armada 3700 Functional Specification. According to the specification, maximal Max Payload Size supported by this device is 512 bytes.
Without this kernel prints suspicious line:
pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 16384, max 512)
With this change it changes to:
pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 512, max 512)
--- drivers/pci/controller/pci-aardvark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +2 -1
@@ -597,8 +597,9 @@ static void advk_pcie_setup_hw(struct ad reg =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL ); reg &= ~PCI_EXP_DEVCTL_RELAX_EN ; reg &= ~PCI_EXP_DEVCTL_NOSNOOP_EN ; + reg &= ~PCI_EXP_DEVCTL_PAYLOAD ; reg &= ~PCI_EXP_DEVCTL_READRQ ; - reg |=PCI_EXP_DEVCTL_PAYLOAD ;/* Set max payload size */ + reg |=PCI_EXP_DEVCTL_PAYLOAD_512B ; reg |=PCI_EXP_DEVCTL_READRQ_512B ;advk_writel (pcie, reg,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL );
Greg Kroah-Hartman
maintainerPATCH 575/575 SUNRPC: Partial revert of commit 6f9f17287e78
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit ea7a1019d8baf8503ecd6e3ec8436dec283569e6 upstream.
The premise of commit 6f9f17287e78 ("SUNRPC: Mitigate cond_resched() in xprt_transmit()") was that cond_resched() is expensive and unnecessary when there has been just a single send.
The point of cond_resched() is to ensure that tasks that should pre-empt this one get a chance to do so when it is safe to do so. The code prior to commit 6f9f17287e78 failed to take into account that it was keeping a rpc_task pinned for longer than it needed to, and so rather than doing a full revert, let's just move the cond_resched.
--- net/sunrpc/xprt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
net/sunrpc/xprt.c +15 -13
@@ -1552,15 +1552,14 @@ xprt_transmit(struct rpc_task *task) {struct rpc_rqst *next, *req = task->tk_rqstp;struct rpc_xprt *xprt = req->rq_xprt; -int counter, status; +int status;spin_lock (&xprt->queue_lock); - counter =0 ; -while (!list_empty (&xprt->xmit_queue)) { -if (++counter ==20 ) +for (;;) { + next =list_first_entry_or_null (&xprt->xmit_queue, + struct rpc_rqst, rq_xmit); +if (!next)break ; - next =list_first_entry (&xprt->xmit_queue, - struct rpc_rqst, rq_xmit);xprt_pin_rqst (next);spin_unlock (&xprt->queue_lock); status =xprt_request_transmit (next, task);
@@ -1568,13 +1567,16 @@ xprt_transmit(struct rpc_task *task) status =0 ;spin_lock (&xprt->queue_lock);xprt_unpin_rqst (next); -if (status ==0 ) { -if (!xprt_request_data_received (task) || -test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) -continue ; - }else if (test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) - task->tk_status = status; -break ; +if (status <0 ) { +if (test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) + task->tk_status = status; +break ; + } +/* Was @task transmitted, and has it received a reply? */ +if (xprt_request_data_received (task) && + !test_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate)) +break ; +cond_resched_lock (&xprt->queue_lock); }spin_unlock (&xprt->queue_lock); }
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.80 release. There are 575 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.80 release. There are 575 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.10:
10 builds: 10 pass, 0 fail
28 boots: 28 pass, 0 fail
75 tests: 75 pass, 0 failLinux version: 5.10.80-rc1-g5c7cb5c15203
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.80 release. There are 575 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.10.80-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-5.10.y
* git commit: 5c7cb5c1520316c728b44f31c1bd6b22942a0b18
* git describe: v5.10.79-576-g5c7cb5c15203
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.10.y/build/v5.10.79-576-g5c7cb5c15203
## No regressions (compared to v5.10.79-126-g498eb27d1093)
## No fixes (compared to v5.10.79-126-g498eb27d1093)
## Test result summary
total: 92721, pass: 78619, fail: 559, skip: 12582, xfail: 961
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 290 total, 290 passed, 0 failed
* arm64: 40 total, 40 passed, 0 failed
* dragonboard-410c: 1 total, 1 passed, 0 failed
* hi6220-hikey: 1 total, 1 passed, 0 failed
* i386: 39 total, 39 passed, 0 failed
* juno-r2: 1 total, 1 passed, 0 failed
* mips: 37 total, 37 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 54 total, 46 passed, 8 failed
* riscv: 24 total, 24 passed, 0 failed
* s390: 18 total, 18 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x15: 1 total, 1 passed, 0 failed
* x86: 1 total, 1 passed, 0 failed
* x86_64: 40 total, 40 passed, 0 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-bpf
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-vm
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* perf
* rcutorture
* ssuite
* v4l2-compliance
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.80 release. There are 575 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 Nov 2021 16:52:23 +0000. Anything received after that time might be too late.
Build test:
mips (gcc version 11.2.1 20211112): 63 configs -> no new failure arm (gcc version 11.2.1 20211112): 105 configs -> no new failure arm64 (gcc version 11.2.1 20211112): 3 configs -> no failure x86_64 (gcc version 11.2.1 20211112): 4 configs -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
arm64: Booted on rpi4b (4GB model). No regression. [2]
[1]. https://openqa.qa.codethink.co.uk/tests/392
[2]. https://openqa.qa.codethink.co.uk/tests/389
--
Regards
Sudip