* [PATCH AUTOSEL 5.18 02/53] spi: cadence: Detect transmit FIFO depth
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 03/53] spi: spi-mem: Fix spi_mem_poll_status() Sasha Levin
` (49 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Lars-Peter Clausen, Mark Brown, Sasha Levin, linux-spi
From: Lars-Peter Clausen <lars@metafoo.de>
[ Upstream commit 7b40322f7183a92c4303457528ae7cda571c60b9 ]
The depth of the transmit FIFO for the Cadence SPI controller is currently
hardcoded to 128. But the depth is a synthesis configuration parameter of
the core and can vary between different SoCs.
If the configured FIFO size is less than 128 the driver will busy loop in
the cdns_spi_fill_tx_fifo() function waiting for FIFO space to become
available.
Depending on the length and speed of the transfer it can spin for a
significant amount of time. The cdns_spi_fill_tx_fifo() function is called
from the drivers interrupt handler, so it can leave interrupts disabled for
a prolonged amount of time.
In addition the read FIFO will also overflow and data will be discarded.
To avoid this detect the actual size of the FIFO and use that rather than
the hardcoded value.
To detect the FIFO size the FIFO threshold register is used. The register
is sized so that it can hold FIFO size - 1 as its maximum value. Bits that
are not needed to hold the threshold value will always read 0. By writing
0xffff to the register and then reading back the value in the register we
get the FIFO size.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20220527091143.3780378-1-lars@metafoo.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/spi/spi-cadence.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 90b18c32f859..32117722ae8d 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -93,9 +93,6 @@
#define CDNS_SPI_ER_ENABLE 0x00000001 /* SPI Enable Bit Mask */
#define CDNS_SPI_ER_DISABLE 0x0 /* SPI Disable Bit Mask */
-/* SPI FIFO depth in bytes */
-#define CDNS_SPI_FIFO_DEPTH 128
-
/* Default number of chip select lines */
#define CDNS_SPI_DEFAULT_NUM_CS 4
@@ -111,6 +108,7 @@
* @rx_bytes: Number of bytes requested
* @dev_busy: Device busy flag
* @is_decoded_cs: Flag for decoder property set or not
+ * @tx_fifo_depth: Depth of the TX FIFO
*/
struct cdns_spi {
void __iomem *regs;
@@ -124,6 +122,7 @@ struct cdns_spi {
int rx_bytes;
u8 dev_busy;
u32 is_decoded_cs;
+ unsigned int tx_fifo_depth;
};
/* Macros for the SPI controller read/write */
@@ -305,7 +304,7 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
{
unsigned long trans_cnt = 0;
- while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
+ while ((trans_cnt < xspi->tx_fifo_depth) &&
(xspi->tx_bytes > 0)) {
/* When xspi in busy condition, bytes may send failed,
@@ -468,6 +467,24 @@ static int cdns_unprepare_transfer_hardware(struct spi_master *master)
return 0;
}
+/**
+ * cdns_spi_detect_fifo_depth - Detect the FIFO depth of the hardware
+ * @xspi: Pointer to the cdns_spi structure
+ *
+ * The depth of the TX FIFO is a synthesis configuration parameter of the SPI
+ * IP. The FIFO threshold register is sized so that its maximum value can be the
+ * FIFO size - 1. This is used to detect the size of the FIFO.
+ */
+static void cdns_spi_detect_fifo_depth(struct cdns_spi *xspi)
+{
+ /* The MSBs will get truncated giving us the size of the FIFO */
+ cdns_spi_write(xspi, CDNS_SPI_THLD, 0xffff);
+ xspi->tx_fifo_depth = cdns_spi_read(xspi, CDNS_SPI_THLD) + 1;
+
+ /* Reset to default */
+ cdns_spi_write(xspi, CDNS_SPI_THLD, 0x1);
+}
+
/**
* cdns_spi_probe - Probe method for the SPI driver
* @pdev: Pointer to the platform_device structure
@@ -540,6 +557,8 @@ static int cdns_spi_probe(struct platform_device *pdev)
if (ret < 0)
xspi->is_decoded_cs = 0;
+ cdns_spi_detect_fifo_depth(xspi);
+
/* SPI controller initializations */
cdns_spi_init_hw(xspi);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 03/53] spi: spi-mem: Fix spi_mem_poll_status()
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 02/53] spi: cadence: Detect transmit FIFO depth Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 04/53] arm64: s32g2: Pass unit name to soc node Sasha Levin
` (48 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Patrice Chotard, Mark Brown, Sasha Levin, linux-spi
From: Patrice Chotard <patrice.chotard@foss.st.com>
[ Upstream commit 2283679f4c468df367830b7eb8f22d48a6940e19 ]
In spi_mem_exec_op(), in case cs_gpiod descriptor is set, exec_op()
callback can't be used.
The same must be applied in spi_mem_poll_status(), poll_status()
callback can't be used, we must use the legacy path using
read_poll_timeout().
Tested on STM32mp257c-ev1 specific evaluation board on which a
spi-nand was mounted instead of a spi-nor.
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20220602091022.358127-1-patrice.chotard@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/spi/spi-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 0e8dafc62d94..99a76a2dda5a 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -799,7 +799,7 @@ int spi_mem_poll_status(struct spi_mem *mem,
op->data.dir != SPI_MEM_DATA_IN)
return -EINVAL;
- if (ctlr->mem_ops && ctlr->mem_ops->poll_status) {
+ if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !mem->spi->cs_gpiod) {
ret = spi_mem_access_start(mem);
if (ret)
return ret;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 04/53] arm64: s32g2: Pass unit name to soc node
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 02/53] spi: cadence: Detect transmit FIFO depth Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 03/53] spi: spi-mem: Fix spi_mem_poll_status() Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 05/53] regulator: qcom_smd: correct MP5496 ranges Sasha Levin
` (47 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Fabio Estevam, Fabio Estevam, Chester Lin, Sasha Levin, robh+dt,
krzysztof.kozlowski+dt, linux-arm-kernel, devicetree
From: Fabio Estevam <festevam@gmail.com>
[ Upstream commit 4266e2f70d4388b8c6a95056169954ff049ced94 ]
Pass unit name to soc node to fix the following W=1 build warning:
arch/arm64/boot/dts/freescale/s32g2.dtsi:82.6-123.4: Warning (unit_address_vs_reg): /soc: node has a reg or ranges property, but no unit name
Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Chester Lin <clin@suse.com>
Signed-off-by: Chester Lin <clin@suse.com>
Link: https://lore.kernel.org/r/20220514143505.1554813-1-festevam@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/boot/dts/freescale/s32g2.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/freescale/s32g2.dtsi b/arch/arm64/boot/dts/freescale/s32g2.dtsi
index 59ea8a25aa4c..824d401e7a2c 100644
--- a/arch/arm64/boot/dts/freescale/s32g2.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g2.dtsi
@@ -79,7 +79,7 @@ psci {
};
};
- soc {
+ soc@0 {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 05/53] regulator: qcom_smd: correct MP5496 ranges
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (2 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 04/53] arm64: s32g2: Pass unit name to soc node Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 06/53] ALSA: usb-audio: US16x08: Move overflow check before array access Sasha Levin
` (46 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Robert Marko, Mark Brown, Sasha Levin, agross, bjorn.andersson,
lgirdwood, linux-arm-msm
From: Robert Marko <robimarko@gmail.com>
[ Upstream commit 122e951eb8045338089b086c8bd9b0b9afb04a92 ]
Currently set MP5496 Buck and LDO ranges dont match its datasheet[1].
According to the datasheet:
Buck range is 0.6-2.1875V with a 12.5mV step
LDO range is 0.8-3.975V with a 25mV step.
So, correct the ranges according to the datasheet[1].
[1] https://www.monolithicpower.com/en/documentview/productdocument/index/version/2/document_type/Datasheet/lang/en/sku/MP5496GR/document_id/6906/
Signed-off-by: Robert Marko <robimarko@gmail.com>
Link: https://lore.kernel.org/r/20220604193300.125758-2-robimarko@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/regulator/qcom_smd-regulator.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 7dff94a2eb7e..ef6e47d025ca 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -723,19 +723,19 @@ static const struct regulator_desc pms405_pldo600 = {
static const struct regulator_desc mp5496_smpa2 = {
.linear_ranges = (struct linear_range[]) {
- REGULATOR_LINEAR_RANGE(725000, 0, 27, 12500),
+ REGULATOR_LINEAR_RANGE(600000, 0, 127, 12500),
},
.n_linear_ranges = 1,
- .n_voltages = 28,
+ .n_voltages = 128,
.ops = &rpm_mp5496_ops,
};
static const struct regulator_desc mp5496_ldoa2 = {
.linear_ranges = (struct linear_range[]) {
- REGULATOR_LINEAR_RANGE(1800000, 0, 60, 25000),
+ REGULATOR_LINEAR_RANGE(800000, 0, 127, 25000),
},
.n_linear_ranges = 1,
- .n_voltages = 61,
+ .n_voltages = 128,
.ops = &rpm_mp5496_ops,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 06/53] ALSA: usb-audio: US16x08: Move overflow check before array access
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (3 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 05/53] regulator: qcom_smd: correct MP5496 ranges Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 07/53] bus: bt1-apb: Don't print error on -EPROBE_DEFER Sasha Levin
` (45 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Daniil Dementev, Alexey Khoroshilov, Takashi Iwai, Sasha Levin,
perex, tiwai, alsa-devel
From: Daniil Dementev <d.dementev@ispras.ru>
[ Upstream commit 3ddbe35d9a2ebd4924d458e0246b4ba6c13bb456 ]
Buffer overflow could occur in the loop "while", due to accessing an
array element before checking the index.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Daniil Dementev <d.dementev@ispras.ru>
Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Link: https://lore.kernel.org/r/20220610165732.2904-1-d.dementev@ispras.ru
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/usb/mixer_us16x08.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c
index b7b6f3834ed5..6eb7d93b358d 100644
--- a/sound/usb/mixer_us16x08.c
+++ b/sound/usb/mixer_us16x08.c
@@ -637,10 +637,10 @@ static int snd_get_meter_comp_index(struct snd_us16x08_meter_store *store)
}
} else {
/* skip channels with no compressor active */
- while (!store->comp_store->val[
+ while (store->comp_index <= SND_US16X08_MAX_CHANNELS
+ && !store->comp_store->val[
COMP_STORE_IDX(SND_US16X08_ID_COMP_SWITCH)]
- [store->comp_index - 1]
- && store->comp_index <= SND_US16X08_MAX_CHANNELS) {
+ [store->comp_index - 1]) {
store->comp_index++;
}
ret = store->comp_index++;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 07/53] bus: bt1-apb: Don't print error on -EPROBE_DEFER
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (4 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 06/53] ALSA: usb-audio: US16x08: Move overflow check before array access Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 08/53] bus: bt1-axi: " Sasha Levin
` (44 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Serge Semin, Arnd Bergmann, Sasha Levin
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
[ Upstream commit be5cddef05f519a321a543906f255ac247246074 ]
The Baikal-T1 APB bus driver correctly handles the deferred probe
situation, but still pollutes the system log with a misleading error
message. Let's fix that by using the dev_err_probe() method to print the
log message in case of the clocks/resets request errors.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20220610104030.28399-1-Sergey.Semin@baikalelectronics.ru'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/bus/bt1-apb.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index b25ff941e7c7..63b1b4a76671 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -175,10 +175,9 @@ static int bt1_apb_request_rst(struct bt1_apb *apb)
int ret;
apb->prst = devm_reset_control_get_optional_exclusive(apb->dev, "prst");
- if (IS_ERR(apb->prst)) {
- dev_warn(apb->dev, "Couldn't get reset control line\n");
- return PTR_ERR(apb->prst);
- }
+ if (IS_ERR(apb->prst))
+ return dev_err_probe(apb->dev, PTR_ERR(apb->prst),
+ "Couldn't get reset control line\n");
ret = reset_control_deassert(apb->prst);
if (ret)
@@ -199,10 +198,9 @@ static int bt1_apb_request_clk(struct bt1_apb *apb)
int ret;
apb->pclk = devm_clk_get(apb->dev, "pclk");
- if (IS_ERR(apb->pclk)) {
- dev_err(apb->dev, "Couldn't get APB clock descriptor\n");
- return PTR_ERR(apb->pclk);
- }
+ if (IS_ERR(apb->pclk))
+ return dev_err_probe(apb->dev, PTR_ERR(apb->pclk),
+ "Couldn't get APB clock descriptor\n");
ret = clk_prepare_enable(apb->pclk);
if (ret) {
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 08/53] bus: bt1-axi: Don't print error on -EPROBE_DEFER
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (5 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 07/53] bus: bt1-apb: Don't print error on -EPROBE_DEFER Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 09/53] selftests: Fix clang cross compilation Sasha Levin
` (43 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Serge Semin, Arnd Bergmann, Sasha Levin
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
[ Upstream commit 5e93207e962a6d23893ff4405f6c5d4396fb5934 ]
The Baikal-T1 AXI bus driver correctly handles the deferred probe
situation, but still pollutes the system log with a misleading error
message. Let's fix that by using the dev_err_probe() method to print the
log message in case of the clocks/resets request errors.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20220610104030.28399-2-Sergey.Semin@baikalelectronics.ru'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/bus/bt1-axi.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
index e7a6744acc7b..70e49a6e5374 100644
--- a/drivers/bus/bt1-axi.c
+++ b/drivers/bus/bt1-axi.c
@@ -135,10 +135,9 @@ static int bt1_axi_request_rst(struct bt1_axi *axi)
int ret;
axi->arst = devm_reset_control_get_optional_exclusive(axi->dev, "arst");
- if (IS_ERR(axi->arst)) {
- dev_warn(axi->dev, "Couldn't get reset control line\n");
- return PTR_ERR(axi->arst);
- }
+ if (IS_ERR(axi->arst))
+ return dev_err_probe(axi->dev, PTR_ERR(axi->arst),
+ "Couldn't get reset control line\n");
ret = reset_control_deassert(axi->arst);
if (ret)
@@ -159,10 +158,9 @@ static int bt1_axi_request_clk(struct bt1_axi *axi)
int ret;
axi->aclk = devm_clk_get(axi->dev, "aclk");
- if (IS_ERR(axi->aclk)) {
- dev_err(axi->dev, "Couldn't get AXI Interconnect clock\n");
- return PTR_ERR(axi->aclk);
- }
+ if (IS_ERR(axi->aclk))
+ return dev_err_probe(axi->dev, PTR_ERR(axi->aclk),
+ "Couldn't get AXI Interconnect clock\n");
ret = clk_prepare_enable(axi->aclk);
if (ret) {
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 09/53] selftests: Fix clang cross compilation
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (6 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 08/53] bus: bt1-axi: " Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 10/53] drm/vc4: plane: Prevent async update if we don't have a dlist Sasha Levin
` (42 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mark Brown, Shuah Khan, Sasha Levin, shuah, paul.walmsley, palmer,
aou, nathan, ndesaulniers, linux-kselftest, linux-riscv, llvm
From: Mark Brown <broonie@kernel.org>
[ Upstream commit 795285ef242543bb636556b7225f20adb7d3795c ]
Unlike GCC clang uses a single compiler image to support multiple target
architectures meaning that we can't simply rely on CROSS_COMPILE to select
the output architecture. Instead we must pass --target to the compiler to
tell it what to output, kselftest was not doing this so cross compilation
of kselftest using clang resulted in kselftest being built for the host
architecture.
More work is required to fix tests using custom rules but this gets the
bulk of things building.
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/lib.mk | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 2a2d240cdc1b..1a5cc3cd97ec 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -7,10 +7,31 @@ else ifneq ($(filter -%,$(LLVM)),)
LLVM_SUFFIX := $(LLVM)
endif
-CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
+CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
+CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
+CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
+CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu
+CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu
+CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu
+CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
+CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
+CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
+CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
+
+ifeq ($(CROSS_COMPILE),)
+ifeq ($(CLANG_TARGET_FLAGS),)
+$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk
+else
+CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
+endif # CLANG_TARGET_FLAGS
+else
+CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
+endif # CROSS_COMPILE
+
+CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
else
CC := $(CROSS_COMPILE)gcc
-endif
+endif # LLVM
ifeq (0,$(MAKELEVEL))
ifeq ($(OUTPUT),)
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 10/53] drm/vc4: plane: Prevent async update if we don't have a dlist
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (7 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 09/53] selftests: Fix clang cross compilation Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 11/53] drm/vc4: crtc: Use an union to store the page flip callback Sasha Levin
` (41 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Maxime Ripard, Melissa Wen, Sasha Levin, emma, mripard, airlied,
daniel, dri-devel
From: Maxime Ripard <maxime@cerno.tech>
[ Upstream commit cb468c7d84d174ab9cd638be9f5b3f1ba2b311a0 ]
The vc4 planes are setup in hardware by creating a hardware descriptor
in a dedicated RAM. As part of the process to setup a plane in KMS, we
thus need to allocate some part of that dedicated RAM to store our
descriptor there.
The async update path will just reuse the descriptor already allocated
for that plane and will modify it directly in RAM to match whatever has
been asked for.
In order to do that, it will compare the descriptor for the old plane
state and the new plane state, will make sure they fit in the same size,
and check that only the position or buffer address have changed.
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220610115149.964394-2-maxime@cerno.tech
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/vc4/vc4_plane.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 920a9eefe426..ac91898f7ad5 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -1321,6 +1321,10 @@ static int vc4_plane_atomic_async_check(struct drm_plane *plane,
old_vc4_state = to_vc4_plane_state(plane->state);
new_vc4_state = to_vc4_plane_state(new_plane_state);
+
+ if (!new_vc4_state->hw_dlist)
+ return -EINVAL;
+
if (old_vc4_state->dlist_count != new_vc4_state->dlist_count ||
old_vc4_state->pos0_offset != new_vc4_state->pos0_offset ||
old_vc4_state->pos2_offset != new_vc4_state->pos2_offset ||
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 11/53] drm/vc4: crtc: Use an union to store the page flip callback
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (8 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 10/53] drm/vc4: plane: Prevent async update if we don't have a dlist Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 12/53] drm/vc4: crtc: Move the BO handling out of common page-flip callback Sasha Levin
` (40 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Maxime Ripard, Melissa Wen, Sasha Levin, emma, mripard, airlied,
daniel, dri-devel
From: Maxime Ripard <maxime@cerno.tech>
[ Upstream commit 2523e9dcc3be91bf9fdc0d1e542557ca00bbef42 ]
We'll need to extend the vc4_async_flip_state structure to rely on
another callback implementation, so let's move the current one into a
union.
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220610115149.964394-10-maxime@cerno.tech
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 477b3c5ad089..3669d7a06439 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -769,17 +769,17 @@ struct vc4_async_flip_state {
struct drm_framebuffer *old_fb;
struct drm_pending_vblank_event *event;
- struct vc4_seqno_cb cb;
+ union {
+ struct vc4_seqno_cb seqno;
+ } cb;
};
/* Called when the V3D execution for the BO being flipped to is done, so that
* we can actually update the plane's address to point to it.
*/
static void
-vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
+vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
{
- struct vc4_async_flip_state *flip_state =
- container_of(cb, struct vc4_async_flip_state, cb);
struct drm_crtc *crtc = flip_state->crtc;
struct drm_device *dev = crtc->dev;
struct drm_plane *plane = crtc->primary;
@@ -815,6 +815,14 @@ vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
kfree(flip_state);
}
+static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
+{
+ struct vc4_async_flip_state *flip_state =
+ container_of(cb, struct vc4_async_flip_state, cb.seqno);
+
+ vc4_async_page_flip_complete(flip_state);
+}
+
/* Implements async (non-vblank-synced) page flips.
*
* The page flip ioctl needs to return immediately, so we grab the
@@ -875,8 +883,8 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,
*/
drm_atomic_set_fb_for_plane(plane->state, fb);
- vc4_queue_seqno_cb(dev, &flip_state->cb, bo->seqno,
- vc4_async_page_flip_complete);
+ vc4_queue_seqno_cb(dev, &flip_state->cb.seqno, bo->seqno,
+ vc4_async_page_flip_seqno_complete);
/* Driver takes ownership of state on successful async commit. */
return 0;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 12/53] drm/vc4: crtc: Move the BO handling out of common page-flip callback
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (9 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 11/53] drm/vc4: crtc: Use an union to store the page flip callback Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 13/53] selftests: vm: Fix resource leak when return error Sasha Levin
` (39 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Maxime Ripard, Melissa Wen, Sasha Levin, emma, mripard, airlied,
daniel, dri-devel
From: Maxime Ripard <maxime@cerno.tech>
[ Upstream commit 4d12c36fb73b5c49fe2f95d06515fd9846010fd2 ]
We'll soon introduce another completion callback source that won't need
to use the BO reference counting, so let's move it around to create a
function we will be able to share between both callbacks.
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220610115149.964394-11-maxime@cerno.tech
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 3669d7a06439..9956db71ad46 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -796,21 +796,8 @@ vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
drm_crtc_vblank_put(crtc);
drm_framebuffer_put(flip_state->fb);
- /* Decrement the BO usecnt in order to keep the inc/dec calls balanced
- * when the planes are updated through the async update path.
- * FIXME: we should move to generic async-page-flip when it's
- * available, so that we can get rid of this hand-made cleanup_fb()
- * logic.
- */
- if (flip_state->old_fb) {
- struct drm_gem_cma_object *cma_bo;
- struct vc4_bo *bo;
-
- cma_bo = drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
- bo = to_vc4_bo(&cma_bo->base);
- vc4_bo_dec_usecnt(bo);
+ if (flip_state->old_fb)
drm_framebuffer_put(flip_state->old_fb);
- }
kfree(flip_state);
}
@@ -819,8 +806,27 @@ static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
{
struct vc4_async_flip_state *flip_state =
container_of(cb, struct vc4_async_flip_state, cb.seqno);
+ struct vc4_bo *bo = NULL;
+
+ if (flip_state->old_fb) {
+ struct drm_gem_cma_object *cma_bo =
+ drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
+ bo = to_vc4_bo(&cma_bo->base);
+ }
vc4_async_page_flip_complete(flip_state);
+
+ /*
+ * Decrement the BO usecnt in order to keep the inc/dec
+ * calls balanced when the planes are updated through
+ * the async update path.
+ *
+ * FIXME: we should move to generic async-page-flip when
+ * it's available, so that we can get rid of this
+ * hand-made cleanup_fb() logic.
+ */
+ if (bo)
+ vc4_bo_dec_usecnt(bo);
}
/* Implements async (non-vblank-synced) page flips.
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 13/53] selftests: vm: Fix resource leak when return error
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (10 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 12/53] drm/vc4: crtc: Move the BO handling out of common page-flip callback Sasha Levin
@ 2022-06-28 2:17 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 14/53] scsi: ufs: Simplify ufshcd_clear_cmd() Sasha Levin
` (38 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:17 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Ding Xiang, Shuah Khan, Sasha Levin, shuah, linux-mm,
linux-kselftest
From: Ding Xiang <dingxiang@cmss.chinamobile.com>
[ Upstream commit 3084a4ec7f9bb1ec90036cfd01b1abadc5dd4fb2 ]
When return on an error path, file handle need to be closed
to prevent resource leak
Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/vm/ksm_tests.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/vm/ksm_tests.c b/tools/testing/selftests/vm/ksm_tests.c
index fd85f15869d1..aa834b04daa8 100644
--- a/tools/testing/selftests/vm/ksm_tests.c
+++ b/tools/testing/selftests/vm/ksm_tests.c
@@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val)
}
if (fprintf(f, "%lu", val) < 0) {
perror("fprintf");
+ fclose(f);
return 1;
}
fclose(f);
@@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *file_path, unsigned long *val)
}
if (fscanf(f, "%lu", val) != 1) {
perror("fscanf");
+ fclose(f);
return 1;
}
fclose(f);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 14/53] scsi: ufs: Simplify ufshcd_clear_cmd()
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (11 preceding siblings ...)
2022-06-28 2:17 ` [PATCH AUTOSEL 5.18 13/53] selftests: vm: Fix resource leak when return error Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 15/53] scsi: ufs: Support clearing multiple commands at once Sasha Levin
` (37 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bart Van Assche, Stanley Chu, Adrian Hunter, Martin K . Petersen,
Sasha Levin, jejb, matthias.bgg, beanhuo, avri.altman,
daejun7.park, linux-scsi, linux-arm-kernel, linux-mediatek
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit da8badd7d3583f447eac2ab65a332f2d773deca1 ]
Remove the local variable 'err'. This patch does not change any
functionality.
Link: https://lore.kernel.org/r/20220613214442.212466-2-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 4c9eb4be449c..8f26c4c09c66 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2856,7 +2856,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
static int
ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
{
- int err = 0;
unsigned long flags;
u32 mask = 1 << tag;
@@ -2869,11 +2868,8 @@ ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
* wait for h/w to clear corresponding bit in door-bell.
* max. wait is 1 sec.
*/
- err = ufshcd_wait_for_register(hba,
- REG_UTP_TRANSFER_REQ_DOOR_BELL,
- mask, ~mask, 1000, 1000);
-
- return err;
+ return ufshcd_wait_for_register(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL,
+ mask, ~mask, 1000, 1000);
}
static int
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 15/53] scsi: ufs: Support clearing multiple commands at once
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (12 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 14/53] scsi: ufs: Simplify ufshcd_clear_cmd() Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 16/53] scsi: ufs: Fix a race between the interrupt handler and the reset handler Sasha Levin
` (36 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bart Van Assche, Stanley Chu, Adrian Hunter, Martin K . Petersen,
Sasha Levin, jejb, matthias.bgg, beanhuo, avri.altman,
daejun7.park, linux-scsi, linux-arm-kernel, linux-mediatek
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit d1a7644648b7cdacaf8d1013a4285001911e9bc8 ]
Modify ufshcd_clear_cmd() such that it supports clearing multiple commands
at once instead of one command at a time. This change will be used in a
later patch to reduce the time spent in the reset handler.
Link: https://lore.kernel.org/r/20220613214442.212466-3-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 42 ++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 8f26c4c09c66..f08586a4470c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -734,17 +734,28 @@ static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
}
/**
- * ufshcd_utrl_clear - Clear a bit in UTRLCLR register
+ * ufshcd_utrl_clear() - Clear requests from the controller request list.
* @hba: per adapter instance
- * @pos: position of the bit to be cleared
+ * @mask: mask with one bit set for each request to be cleared
*/
-static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
+static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 mask)
{
if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
- ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
- else
- ufshcd_writel(hba, ~(1 << pos),
- REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+ mask = ~mask;
+ /*
+ * From the UFSHCI specification: "UTP Transfer Request List CLear
+ * Register (UTRLCLR): This field is bit significant. Each bit
+ * corresponds to a slot in the UTP Transfer Request List, where bit 0
+ * corresponds to request slot 0. A bit in this field is set to ‘0’
+ * by host software to indicate to the host controller that a transfer
+ * request slot is cleared. The host controller
+ * shall free up any resources associated to the request slot
+ * immediately, and shall set the associated bit in UTRLDBR to ‘0’. The
+ * host software indicates no change to request slots by setting the
+ * associated bits in this field to ‘1’. Bits in this field shall only
+ * be set ‘1’ or ‘0’ by host software when UTRLRSR is set to ‘1’."
+ */
+ ufshcd_writel(hba, ~mask, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
}
/**
@@ -2853,15 +2864,18 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
return ufshcd_compose_devman_upiu(hba, lrbp);
}
-static int
-ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
+/*
+ * Clear all the requests from the controller for which a bit has been set in
+ * @mask and wait until the controller confirms that these requests have been
+ * cleared.
+ */
+static int ufshcd_clear_cmds(struct ufs_hba *hba, u32 mask)
{
unsigned long flags;
- u32 mask = 1 << tag;
/* clear outstanding transaction before retry */
spin_lock_irqsave(hba->host->host_lock, flags);
- ufshcd_utrl_clear(hba, tag);
+ ufshcd_utrl_clear(hba, mask);
spin_unlock_irqrestore(hba->host->host_lock, flags);
/*
@@ -2949,7 +2963,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
err = -ETIMEDOUT;
dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
__func__, lrbp->task_tag);
- if (!ufshcd_clear_cmd(hba, lrbp->task_tag))
+ if (!ufshcd_clear_cmds(hba, 1U << lrbp->task_tag))
/* successfully cleared the command, retry if needed */
err = -EAGAIN;
/*
@@ -6984,7 +6998,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
/* clear the commands that were pending for corresponding LUN */
for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
if (hba->lrb[pos].lun == lun) {
- err = ufshcd_clear_cmd(hba, pos);
+ err = ufshcd_clear_cmds(hba, 1U << pos);
if (err)
break;
__ufshcd_transfer_req_compl(hba, 1U << pos);
@@ -7086,7 +7100,7 @@ static int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
goto out;
}
- err = ufshcd_clear_cmd(hba, tag);
+ err = ufshcd_clear_cmds(hba, 1U << tag);
if (err)
dev_err(hba->dev, "%s: Failed clearing cmd at tag %d, err %d\n",
__func__, tag, err);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 16/53] scsi: ufs: Fix a race between the interrupt handler and the reset handler
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (13 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 15/53] scsi: ufs: Support clearing multiple commands at once Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 17/53] selftests/bpf: Shuffle cookies symbols in kprobe multi test Sasha Levin
` (35 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bart Van Assche, Stanley Chu, Adrian Hunter, Martin K . Petersen,
Sasha Levin, jejb, matthias.bgg, beanhuo, avri.altman,
daejun7.park, linux-scsi, linux-arm-kernel, linux-mediatek
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit 2acd76e7b8596e307fcec8fc6bc5fe5ab174749a ]
Prevent that both the interrupt handler and the reset handler try to
complete a request at the same time. This patch is the result of an
analysis of the following crash:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000120
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G OE 5.10.107-android13-4-00051-g1e48e8970cca-ab8664745 #1
pc : ufshcd_release_scsi_cmd+0x30/0x46c
lr : __ufshcd_transfer_req_compl+0x4fc/0x9c0
Call trace:
ufshcd_release_scsi_cmd+0x30/0x46c
__ufshcd_transfer_req_compl+0x4fc/0x9c0
ufshcd_poll+0xf0/0x208
ufshcd_sl_intr+0xb8/0xf0
ufshcd_intr+0x168/0x2f4
__handle_irq_event_percpu+0xa0/0x30c
handle_irq_event+0x84/0x178
handle_fasteoi_irq+0x150/0x2e8
__handle_domain_irq+0x114/0x1e4
gic_handle_irq.31846+0x58/0x300
el1_irq+0xe4/0x1c0
cpuidle_enter_state+0x3ac/0x8c4
do_idle+0x2fc/0x55c
cpu_startup_entry+0x84/0x90
kernel_init+0x0/0x310
start_kernel+0x0/0x608
start_kernel+0x4ec/0x608
Link: https://lore.kernel.org/r/20220613214442.212466-4-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f08586a4470c..02a122738686 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6970,14 +6970,14 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
}
/**
- * ufshcd_eh_device_reset_handler - device reset handler registered to
- * scsi layer.
+ * ufshcd_eh_device_reset_handler() - Reset a single logical unit.
* @cmd: SCSI command pointer
*
* Returns SUCCESS/FAILED
*/
static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
{
+ unsigned long flags, pending_reqs = 0, not_cleared = 0;
struct Scsi_Host *host;
struct ufs_hba *hba;
u32 pos;
@@ -6996,14 +6996,24 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
}
/* clear the commands that were pending for corresponding LUN */
- for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
- if (hba->lrb[pos].lun == lun) {
- err = ufshcd_clear_cmds(hba, 1U << pos);
- if (err)
- break;
- __ufshcd_transfer_req_compl(hba, 1U << pos);
- }
+ spin_lock_irqsave(&hba->outstanding_lock, flags);
+ for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs)
+ if (hba->lrb[pos].lun == lun)
+ __set_bit(pos, &pending_reqs);
+ hba->outstanding_reqs &= ~pending_reqs;
+ spin_unlock_irqrestore(&hba->outstanding_lock, flags);
+
+ if (ufshcd_clear_cmds(hba, pending_reqs) < 0) {
+ spin_lock_irqsave(&hba->outstanding_lock, flags);
+ not_cleared = pending_reqs &
+ ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
+ hba->outstanding_reqs |= not_cleared;
+ spin_unlock_irqrestore(&hba->outstanding_lock, flags);
+
+ dev_err(hba->dev, "%s: failed to clear requests %#lx\n",
+ __func__, not_cleared);
}
+ __ufshcd_transfer_req_compl(hba, pending_reqs & ~not_cleared);
out:
hba->req_abort_count = 0;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 17/53] selftests/bpf: Shuffle cookies symbols in kprobe multi test
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (14 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 16/53] scsi: ufs: Fix a race between the interrupt handler and the reset handler Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 18/53] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay Sasha Levin
` (34 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Jiri Olsa, Song Liu, Alexei Starovoitov, Sasha Levin, shuah,
daniel, andrii, kuifeng, yhs, mykolal, linux-kselftest, netdev,
bpf
From: Jiri Olsa <jolsa@kernel.org>
[ Upstream commit ad8848535e97f4a5374fc68f7a5d16e2565940cc ]
There's a kernel bug that causes cookies to be misplaced and
the reason we did not catch this with this test is that we
provide bpf_fentry_test* functions already sorted by name.
Shuffling function bpf_fentry_test2 deeper in the list and
keeping the current cookie values as before will trigger
the bug.
The kernel fix is coming in following changes.
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20220615112118.497303-2-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../selftests/bpf/prog_tests/bpf_cookie.c | 78 +++++++++----------
.../selftests/bpf/progs/kprobe_multi.c | 24 +++---
2 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
index 923a6139b2d8..aebbbb8f983f 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
@@ -118,24 +118,24 @@ static void kprobe_multi_link_api_subtest(void)
})
GET_ADDR("bpf_fentry_test1", addrs[0]);
- GET_ADDR("bpf_fentry_test2", addrs[1]);
- GET_ADDR("bpf_fentry_test3", addrs[2]);
- GET_ADDR("bpf_fentry_test4", addrs[3]);
- GET_ADDR("bpf_fentry_test5", addrs[4]);
- GET_ADDR("bpf_fentry_test6", addrs[5]);
- GET_ADDR("bpf_fentry_test7", addrs[6]);
+ GET_ADDR("bpf_fentry_test3", addrs[1]);
+ GET_ADDR("bpf_fentry_test4", addrs[2]);
+ GET_ADDR("bpf_fentry_test5", addrs[3]);
+ GET_ADDR("bpf_fentry_test6", addrs[4]);
+ GET_ADDR("bpf_fentry_test7", addrs[5]);
+ GET_ADDR("bpf_fentry_test2", addrs[6]);
GET_ADDR("bpf_fentry_test8", addrs[7]);
#undef GET_ADDR
- cookies[0] = 1;
- cookies[1] = 2;
- cookies[2] = 3;
- cookies[3] = 4;
- cookies[4] = 5;
- cookies[5] = 6;
- cookies[6] = 7;
- cookies[7] = 8;
+ cookies[0] = 1; /* bpf_fentry_test1 */
+ cookies[1] = 2; /* bpf_fentry_test3 */
+ cookies[2] = 3; /* bpf_fentry_test4 */
+ cookies[3] = 4; /* bpf_fentry_test5 */
+ cookies[4] = 5; /* bpf_fentry_test6 */
+ cookies[5] = 6; /* bpf_fentry_test7 */
+ cookies[6] = 7; /* bpf_fentry_test2 */
+ cookies[7] = 8; /* bpf_fentry_test8 */
opts.kprobe_multi.addrs = (const unsigned long *) &addrs;
opts.kprobe_multi.cnt = ARRAY_SIZE(addrs);
@@ -146,14 +146,14 @@ static void kprobe_multi_link_api_subtest(void)
if (!ASSERT_GE(link1_fd, 0, "link1_fd"))
goto cleanup;
- cookies[0] = 8;
- cookies[1] = 7;
- cookies[2] = 6;
- cookies[3] = 5;
- cookies[4] = 4;
- cookies[5] = 3;
- cookies[6] = 2;
- cookies[7] = 1;
+ cookies[0] = 8; /* bpf_fentry_test1 */
+ cookies[1] = 7; /* bpf_fentry_test3 */
+ cookies[2] = 6; /* bpf_fentry_test4 */
+ cookies[3] = 5; /* bpf_fentry_test5 */
+ cookies[4] = 4; /* bpf_fentry_test6 */
+ cookies[5] = 3; /* bpf_fentry_test7 */
+ cookies[6] = 2; /* bpf_fentry_test2 */
+ cookies[7] = 1; /* bpf_fentry_test8 */
opts.kprobe_multi.flags = BPF_F_KPROBE_MULTI_RETURN;
prog_fd = bpf_program__fd(skel->progs.test_kretprobe);
@@ -178,12 +178,12 @@ static void kprobe_multi_attach_api_subtest(void)
struct kprobe_multi *skel = NULL;
const char *syms[8] = {
"bpf_fentry_test1",
- "bpf_fentry_test2",
"bpf_fentry_test3",
"bpf_fentry_test4",
"bpf_fentry_test5",
"bpf_fentry_test6",
"bpf_fentry_test7",
+ "bpf_fentry_test2",
"bpf_fentry_test8",
};
__u64 cookies[8];
@@ -195,14 +195,14 @@ static void kprobe_multi_attach_api_subtest(void)
skel->bss->pid = getpid();
skel->bss->test_cookie = true;
- cookies[0] = 1;
- cookies[1] = 2;
- cookies[2] = 3;
- cookies[3] = 4;
- cookies[4] = 5;
- cookies[5] = 6;
- cookies[6] = 7;
- cookies[7] = 8;
+ cookies[0] = 1; /* bpf_fentry_test1 */
+ cookies[1] = 2; /* bpf_fentry_test3 */
+ cookies[2] = 3; /* bpf_fentry_test4 */
+ cookies[3] = 4; /* bpf_fentry_test5 */
+ cookies[4] = 5; /* bpf_fentry_test6 */
+ cookies[5] = 6; /* bpf_fentry_test7 */
+ cookies[6] = 7; /* bpf_fentry_test2 */
+ cookies[7] = 8; /* bpf_fentry_test8 */
opts.syms = syms;
opts.cnt = ARRAY_SIZE(syms);
@@ -213,14 +213,14 @@ static void kprobe_multi_attach_api_subtest(void)
if (!ASSERT_OK_PTR(link1, "bpf_program__attach_kprobe_multi_opts"))
goto cleanup;
- cookies[0] = 8;
- cookies[1] = 7;
- cookies[2] = 6;
- cookies[3] = 5;
- cookies[4] = 4;
- cookies[5] = 3;
- cookies[6] = 2;
- cookies[7] = 1;
+ cookies[0] = 8; /* bpf_fentry_test1 */
+ cookies[1] = 7; /* bpf_fentry_test3 */
+ cookies[2] = 6; /* bpf_fentry_test4 */
+ cookies[3] = 5; /* bpf_fentry_test5 */
+ cookies[4] = 4; /* bpf_fentry_test6 */
+ cookies[5] = 3; /* bpf_fentry_test7 */
+ cookies[6] = 2; /* bpf_fentry_test2 */
+ cookies[7] = 1; /* bpf_fentry_test8 */
opts.retprobe = true;
diff --git a/tools/testing/selftests/bpf/progs/kprobe_multi.c b/tools/testing/selftests/bpf/progs/kprobe_multi.c
index 600be50800f8..8e06c49aa65a 100644
--- a/tools/testing/selftests/bpf/progs/kprobe_multi.c
+++ b/tools/testing/selftests/bpf/progs/kprobe_multi.c
@@ -54,21 +54,21 @@ static void kprobe_multi_check(void *ctx, bool is_return)
if (is_return) {
SET(kretprobe_test1_result, &bpf_fentry_test1, 8);
- SET(kretprobe_test2_result, &bpf_fentry_test2, 7);
- SET(kretprobe_test3_result, &bpf_fentry_test3, 6);
- SET(kretprobe_test4_result, &bpf_fentry_test4, 5);
- SET(kretprobe_test5_result, &bpf_fentry_test5, 4);
- SET(kretprobe_test6_result, &bpf_fentry_test6, 3);
- SET(kretprobe_test7_result, &bpf_fentry_test7, 2);
+ SET(kretprobe_test2_result, &bpf_fentry_test2, 2);
+ SET(kretprobe_test3_result, &bpf_fentry_test3, 7);
+ SET(kretprobe_test4_result, &bpf_fentry_test4, 6);
+ SET(kretprobe_test5_result, &bpf_fentry_test5, 5);
+ SET(kretprobe_test6_result, &bpf_fentry_test6, 4);
+ SET(kretprobe_test7_result, &bpf_fentry_test7, 3);
SET(kretprobe_test8_result, &bpf_fentry_test8, 1);
} else {
SET(kprobe_test1_result, &bpf_fentry_test1, 1);
- SET(kprobe_test2_result, &bpf_fentry_test2, 2);
- SET(kprobe_test3_result, &bpf_fentry_test3, 3);
- SET(kprobe_test4_result, &bpf_fentry_test4, 4);
- SET(kprobe_test5_result, &bpf_fentry_test5, 5);
- SET(kprobe_test6_result, &bpf_fentry_test6, 6);
- SET(kprobe_test7_result, &bpf_fentry_test7, 7);
+ SET(kprobe_test2_result, &bpf_fentry_test2, 7);
+ SET(kprobe_test3_result, &bpf_fentry_test3, 2);
+ SET(kprobe_test4_result, &bpf_fentry_test4, 3);
+ SET(kprobe_test5_result, &bpf_fentry_test5, 4);
+ SET(kprobe_test6_result, &bpf_fentry_test6, 5);
+ SET(kprobe_test7_result, &bpf_fentry_test7, 6);
SET(kprobe_test8_result, &bpf_fentry_test8, 8);
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 18/53] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (15 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 17/53] selftests/bpf: Shuffle cookies symbols in kprobe multi test Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 19/53] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get() Sasha Levin
` (33 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Pierre-Louis Bossart, Bard Liao, Kai Vehmanen, Ranjani Sridharan,
Takashi Iwai, Sasha Levin, perex, tiwai, gushengxian, jiasheng,
nizhen, alsa-devel
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
[ Upstream commit e87c65aeb46ca4f5b7dc08531200bcb8a426c62e ]
The existing code uses pm_runtime_get_sync/put_autosuspend, but
pm_runtime was not explicitly enabled. The autosuspend delay was not
set either, the value is set to 5s since HDMI is rather painful to
resume.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220616222910.136854-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/x86/intel_hdmi_audio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 0d828e35b401..3b04c70a73e3 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -33,6 +33,8 @@
#include <drm/intel_lpe_audio.h>
#include "intel_hdmi_audio.h"
+#define INTEL_HDMI_AUDIO_SUSPEND_DELAY_MS 5000
+
#define for_each_pipe(card_ctx, pipe) \
for ((pipe) = 0; (pipe) < (card_ctx)->num_pipes; (pipe)++)
#define for_each_port(card_ctx, port) \
@@ -1802,8 +1804,11 @@ static int __hdmi_lpe_audio_probe(struct platform_device *pdev)
pdata->notify_audio_lpe = notify_audio_lpe;
spin_unlock_irq(&pdata->lpe_audio_slock);
+ pm_runtime_set_autosuspend_delay(&pdev->dev, INTEL_HDMI_AUDIO_SUSPEND_DELAY_MS);
pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_enable(&pdev->dev);
pm_runtime_mark_last_busy(&pdev->dev);
+ pm_runtime_idle(&pdev->dev);
dev_dbg(&pdev->dev, "%s: handle pending notification\n", __func__);
for_each_port(card_ctx, port) {
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 19/53] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (16 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 18/53] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 20/53] hamradio: 6pack: fix array-index-out-of-bounds in decode_std_command() Sasha Levin
` (32 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Pierre-Louis Bossart, Bard Liao, Kai Vehmanen, Ranjani Sridharan,
Takashi Iwai, Sasha Levin, perex, tiwai, nizhen, gushengxian,
jiasheng, alsa-devel
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
[ Upstream commit bb30b453fedac277d66220431fd7063d9ddc10d8 ]
The current code does not check for errors and does not release the
reference on errors.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220616222910.136854-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/x86/intel_hdmi_audio.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 3b04c70a73e3..ab95fb34a635 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1068,7 +1068,9 @@ static int had_pcm_open(struct snd_pcm_substream *substream)
intelhaddata = snd_pcm_substream_chip(substream);
runtime = substream->runtime;
- pm_runtime_get_sync(intelhaddata->dev);
+ retval = pm_runtime_resume_and_get(intelhaddata->dev);
+ if (retval < 0)
+ return retval;
/* set the runtime hw parameter with local snd_pcm_hardware struct */
runtime->hw = had_pcm_hardware;
@@ -1536,8 +1538,12 @@ static void had_audio_wq(struct work_struct *work)
container_of(work, struct snd_intelhad, hdmi_audio_wq);
struct intel_hdmi_lpe_audio_pdata *pdata = ctx->dev->platform_data;
struct intel_hdmi_lpe_audio_port_pdata *ppdata = &pdata->port[ctx->port];
+ int ret;
+
+ ret = pm_runtime_resume_and_get(ctx->dev);
+ if (ret < 0)
+ return;
- pm_runtime_get_sync(ctx->dev);
mutex_lock(&ctx->mutex);
if (ppdata->pipe < 0) {
dev_dbg(ctx->dev, "%s: Event: HAD_NOTIFY_HOT_UNPLUG : port = %d\n",
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 20/53] hamradio: 6pack: fix array-index-out-of-bounds in decode_std_command()
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (17 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 19/53] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get() Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 21/53] block: serialize all debugfs operations using q->debugfs_mutex Sasha Levin
` (31 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Xu Jia, Hulk Robot, David S . Miller, Sasha Levin, ajk, edumazet,
kuba, pabeni, linux-hams, netdev
From: Xu Jia <xujia39@huawei.com>
[ Upstream commit 2b04495e21cdb9b45c28c6aeb2da560184de20a3 ]
Hulk Robot reports incorrect sp->rx_count_cooked value in decode_std_command().
This should be caused by the subtracting from sp->rx_count_cooked before.
It seems that sp->rx_count_cooked value is changed to 0, which bypassed the
previous judgment.
The situation is shown below:
(Thread 1) | (Thread 2)
decode_std_command() | resync_tnc()
... |
if (rest == 2) |
sp->rx_count_cooked -= 2; |
else if (rest == 3) | ...
| sp->rx_count_cooked = 0;
sp->rx_count_cooked -= 1; |
for (i = 0; i < sp->rx_count_cooked; i++) // report error
checksum += sp->cooked_buf[i];
sp->rx_count_cooked is a shared variable but is not protected by a lock.
The same applies to sp->rx_count. This patch adds a lock to fix the bug.
The fail log is shown below:
=======================================================================
UBSAN: array-index-out-of-bounds in drivers/net/hamradio/6pack.c:925:31
index 400 is out of range for type 'unsigned char [400]'
CPU: 3 PID: 7433 Comm: kworker/u10:1 Not tainted 5.18.0-rc5-00163-g4b97bac0756a #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Workqueue: events_unbound flush_to_ldisc
Call Trace:
<TASK>
dump_stack_lvl+0xcd/0x134
ubsan_epilogue+0xb/0x50
__ubsan_handle_out_of_bounds.cold+0x62/0x6c
sixpack_receive_buf+0xfda/0x1330
tty_ldisc_receive_buf+0x13e/0x180
tty_port_default_receive_buf+0x6d/0xa0
flush_to_ldisc+0x213/0x3f0
process_one_work+0x98f/0x1620
worker_thread+0x665/0x1080
kthread+0x2e9/0x3a0
ret_from_fork+0x1f/0x30
...
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xu Jia <xujia39@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/hamradio/6pack.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 45c3c4a1101b..9fb567524220 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -99,6 +99,7 @@ struct sixpack {
unsigned int rx_count;
unsigned int rx_count_cooked;
+ spinlock_t rxlock;
int mtu; /* Our mtu (to spot changes!) */
int buffsize; /* Max buffers sizes */
@@ -565,6 +566,7 @@ static int sixpack_open(struct tty_struct *tty)
sp->dev = dev;
spin_lock_init(&sp->lock);
+ spin_lock_init(&sp->rxlock);
refcount_set(&sp->refcnt, 1);
init_completion(&sp->dead);
@@ -913,6 +915,7 @@ static void decode_std_command(struct sixpack *sp, unsigned char cmd)
sp->led_state = 0x60;
/* fill trailing bytes with zeroes */
sp->tty->ops->write(sp->tty, &sp->led_state, 1);
+ spin_lock_bh(&sp->rxlock);
rest = sp->rx_count;
if (rest != 0)
for (i = rest; i <= 3; i++)
@@ -930,6 +933,7 @@ static void decode_std_command(struct sixpack *sp, unsigned char cmd)
sp_bump(sp, 0);
}
sp->rx_count_cooked = 0;
+ spin_unlock_bh(&sp->rxlock);
}
break;
case SIXP_TX_URUN: printk(KERN_DEBUG "6pack: TX underrun\n");
@@ -959,8 +963,11 @@ sixpack_decode(struct sixpack *sp, const unsigned char *pre_rbuff, int count)
decode_prio_command(sp, inbyte);
else if ((inbyte & SIXP_STD_CMD_MASK) != 0)
decode_std_command(sp, inbyte);
- else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK)
+ else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK) {
+ spin_lock_bh(&sp->rxlock);
decode_data(sp, inbyte);
+ spin_unlock_bh(&sp->rxlock);
+ }
}
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 21/53] block: serialize all debugfs operations using q->debugfs_mutex
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (18 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 20/53] hamradio: 6pack: fix array-index-out-of-bounds in decode_std_command() Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 22/53] block: remove per-disk debugfs files in blk_unregister_queue Sasha Levin
` (30 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christoph Hellwig, Jens Axboe, Sasha Levin, rostedt, mingo,
linux-block
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 5cf9c91ba927119fc6606b938b1895bb2459d3bc ]
Various places like I/O schedulers or the QOS infrastructure try to
register debugfs files on demans, which can race with creating and
removing the main queue debugfs directory. Use the existing
debugfs_mutex to serialize all debugfs operations that rely on
q->debugfs_dir or the directories hanging off it.
To make the teardown code a little simpler declare all debugfs dentry
pointers and not just the main one uncoditionally in blkdev.h.
Move debugfs_mutex next to the dentries that it protects and document
what it is used for.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220614074827.458955-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/blk-mq-debugfs.c | 25 ++++++++++++++++++++-----
block/blk-mq-debugfs.h | 5 -----
block/blk-mq-sched.c | 11 +++++++++++
block/blk-rq-qos.c | 2 ++
block/blk-rq-qos.h | 7 ++++++-
block/blk-sysfs.c | 20 +++++++++-----------
include/linux/blkdev.h | 8 ++++----
kernel/trace/blktrace.c | 3 ---
8 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index aa0349e9f083..54f292a1d278 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -713,11 +713,6 @@ void blk_mq_debugfs_register(struct request_queue *q)
}
}
-void blk_mq_debugfs_unregister(struct request_queue *q)
-{
- q->sched_debugfs_dir = NULL;
-}
-
static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx,
struct blk_mq_ctx *ctx)
{
@@ -748,6 +743,8 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q,
void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx)
{
+ if (!hctx->queue->debugfs_dir)
+ return;
debugfs_remove_recursive(hctx->debugfs_dir);
hctx->sched_debugfs_dir = NULL;
hctx->debugfs_dir = NULL;
@@ -775,6 +772,8 @@ void blk_mq_debugfs_register_sched(struct request_queue *q)
{
struct elevator_type *e = q->elevator->type;
+ lockdep_assert_held(&q->debugfs_mutex);
+
/*
* If the parent directory has not been created yet, return, we will be
* called again later on and the directory/files will be created then.
@@ -792,6 +791,8 @@ void blk_mq_debugfs_register_sched(struct request_queue *q)
void blk_mq_debugfs_unregister_sched(struct request_queue *q)
{
+ lockdep_assert_held(&q->debugfs_mutex);
+
debugfs_remove_recursive(q->sched_debugfs_dir);
q->sched_debugfs_dir = NULL;
}
@@ -813,6 +814,10 @@ static const char *rq_qos_id_to_name(enum rq_qos_id id)
void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
{
+ lockdep_assert_held(&rqos->q->debugfs_mutex);
+
+ if (!rqos->q->debugfs_dir)
+ return;
debugfs_remove_recursive(rqos->debugfs_dir);
rqos->debugfs_dir = NULL;
}
@@ -822,6 +827,8 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
struct request_queue *q = rqos->q;
const char *dir_name = rq_qos_id_to_name(rqos->id);
+ lockdep_assert_held(&q->debugfs_mutex);
+
if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs)
return;
@@ -837,6 +844,8 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
{
+ lockdep_assert_held(&q->debugfs_mutex);
+
debugfs_remove_recursive(q->rqos_debugfs_dir);
q->rqos_debugfs_dir = NULL;
}
@@ -846,6 +855,8 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
{
struct elevator_type *e = q->elevator->type;
+ lockdep_assert_held(&q->debugfs_mutex);
+
/*
* If the parent debugfs directory has not been created yet, return;
* We will be called again later on with appropriate parent debugfs
@@ -865,6 +876,10 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)
{
+ lockdep_assert_held(&hctx->queue->debugfs_mutex);
+
+ if (!hctx->queue->debugfs_dir)
+ return;
debugfs_remove_recursive(hctx->sched_debugfs_dir);
hctx->sched_debugfs_dir = NULL;
}
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 69918f4170d6..771d45832878 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -21,7 +21,6 @@ int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq);
int blk_mq_debugfs_rq_show(struct seq_file *m, void *v);
void blk_mq_debugfs_register(struct request_queue *q);
-void blk_mq_debugfs_unregister(struct request_queue *q);
void blk_mq_debugfs_register_hctx(struct request_queue *q,
struct blk_mq_hw_ctx *hctx);
void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx);
@@ -42,10 +41,6 @@ static inline void blk_mq_debugfs_register(struct request_queue *q)
{
}
-static inline void blk_mq_debugfs_unregister(struct request_queue *q)
-{
-}
-
static inline void blk_mq_debugfs_register_hctx(struct request_queue *q,
struct blk_mq_hw_ctx *hctx)
{
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 9e56a69422b6..e84bec39fd3a 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -593,7 +593,9 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
if (ret)
goto err_free_map_and_rqs;
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_register_sched(q);
+ mutex_unlock(&q->debugfs_mutex);
queue_for_each_hw_ctx(q, hctx, i) {
if (e->ops.init_hctx) {
@@ -606,7 +608,9 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
return ret;
}
}
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_register_sched_hctx(q, hctx);
+ mutex_unlock(&q->debugfs_mutex);
}
return 0;
@@ -647,14 +651,21 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
unsigned int flags = 0;
queue_for_each_hw_ctx(q, hctx, i) {
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_unregister_sched_hctx(hctx);
+ mutex_unlock(&q->debugfs_mutex);
+
if (e->type->ops.exit_hctx && hctx->sched_data) {
e->type->ops.exit_hctx(hctx, i);
hctx->sched_data = NULL;
}
flags = hctx->flags;
}
+
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_unregister_sched(q);
+ mutex_unlock(&q->debugfs_mutex);
+
if (e->type->ops.exit_sched)
e->type->ops.exit_sched(e);
blk_mq_sched_tags_teardown(q, flags);
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index e83af7bc7591..249a6f05dd3b 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -294,7 +294,9 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
void rq_qos_exit(struct request_queue *q)
{
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_unregister_queue_rqos(q);
+ mutex_unlock(&q->debugfs_mutex);
while (q->rq_qos) {
struct rq_qos *rqos = q->rq_qos;
diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
index 68267007da1c..0e46052b018a 100644
--- a/block/blk-rq-qos.h
+++ b/block/blk-rq-qos.h
@@ -104,8 +104,11 @@ static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
blk_mq_unfreeze_queue(q);
- if (rqos->ops->debugfs_attrs)
+ if (rqos->ops->debugfs_attrs) {
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_register_rqos(rqos);
+ mutex_unlock(&q->debugfs_mutex);
+ }
}
static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
@@ -129,7 +132,9 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
blk_mq_unfreeze_queue(q);
+ mutex_lock(&q->debugfs_mutex);
blk_mq_debugfs_unregister_rqos(rqos);
+ mutex_unlock(&q->debugfs_mutex);
}
typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_data);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 88bd41d4cb59..6e4801b217a7 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -779,14 +779,13 @@ static void blk_release_queue(struct kobject *kobj)
if (queue_is_mq(q))
blk_mq_release(q);
- blk_trace_shutdown(q);
mutex_lock(&q->debugfs_mutex);
+ blk_trace_shutdown(q);
debugfs_remove_recursive(q->debugfs_dir);
+ q->debugfs_dir = NULL;
+ q->sched_debugfs_dir = NULL;
mutex_unlock(&q->debugfs_mutex);
- if (queue_is_mq(q))
- blk_mq_debugfs_unregister(q);
-
bioset_exit(&q->bio_split);
if (blk_queue_has_srcu(q))
@@ -836,17 +835,16 @@ int blk_register_queue(struct gendisk *disk)
goto unlock;
}
+ if (queue_is_mq(q))
+ __blk_mq_register_dev(dev, q);
+ mutex_lock(&q->sysfs_lock);
+
mutex_lock(&q->debugfs_mutex);
q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent),
blk_debugfs_root);
- mutex_unlock(&q->debugfs_mutex);
-
- if (queue_is_mq(q)) {
- __blk_mq_register_dev(dev, q);
+ if (queue_is_mq(q))
blk_mq_debugfs_register(q);
- }
-
- mutex_lock(&q->sysfs_lock);
+ mutex_unlock(&q->debugfs_mutex);
ret = disk_register_independent_access_ranges(disk, NULL);
if (ret)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 108e3d114bfc..cc6b24a5098f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -466,7 +466,6 @@ struct request_queue {
#endif /* CONFIG_BLK_DEV_ZONED */
int node;
- struct mutex debugfs_mutex;
#ifdef CONFIG_BLK_DEV_IO_TRACE
struct blk_trace __rcu *blk_trace;
#endif
@@ -510,11 +509,12 @@ struct request_queue {
struct bio_set bio_split;
struct dentry *debugfs_dir;
-
-#ifdef CONFIG_BLK_DEBUG_FS
struct dentry *sched_debugfs_dir;
struct dentry *rqos_debugfs_dir;
-#endif
+ /*
+ * Serializes all debugfs metadata operations using the above dentries.
+ */
+ struct mutex debugfs_mutex;
bool mq_sysfs_init_done;
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 4d5629196d01..134a09ae63fc 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -770,14 +770,11 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
**/
void blk_trace_shutdown(struct request_queue *q)
{
- mutex_lock(&q->debugfs_mutex);
if (rcu_dereference_protected(q->blk_trace,
lockdep_is_held(&q->debugfs_mutex))) {
__blk_trace_startstop(q, 0);
__blk_trace_remove(q);
}
-
- mutex_unlock(&q->debugfs_mutex);
}
#ifdef CONFIG_BLK_CGROUP
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 22/53] block: remove per-disk debugfs files in blk_unregister_queue
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (19 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 21/53] block: serialize all debugfs operations using q->debugfs_mutex Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 23/53] block: freeze the queue earlier in del_gendisk Sasha Levin
` (29 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christoph Hellwig, Jens Axboe, Sasha Levin, linux-block
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 99d055b4fd4bbb309c6cdb51a0d420669f777944 ]
The block debugfs files are created in blk_register_queue, which is
called by add_disk and use a naming scheme based on the disk_name.
After del_gendisk returns that name can be reused and thus we must not
leave these debugfs files around, otherwise the kernel is unhappy
and spews messages like:
Directory XXXXX with parent 'block' already present!
and the newly created devices will not have working debugfs files.
Move the unregistration to blk_unregister_queue instead (which matches
the sysfs unregistration) to make sure the debugfs life time rules match
those of the disk name.
As part of the move also make sure the whole debugfs unregistration is
inside a single debugfs_mutex critical section.
Note that this breaks blktests block/002, which checks that the debugfs
directory has not been removed while blktests is running, but that
particular check should simply be removed from the test case.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220614074827.458955-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/blk-mq-debugfs.c | 8 --------
block/blk-mq-debugfs.h | 5 -----
block/blk-rq-qos.c | 4 ----
block/blk-sysfs.c | 16 ++++++++--------
4 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 54f292a1d278..ba450708878e 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -842,14 +842,6 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs);
}
-void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
-{
- lockdep_assert_held(&q->debugfs_mutex);
-
- debugfs_remove_recursive(q->rqos_debugfs_dir);
- q->rqos_debugfs_dir = NULL;
-}
-
void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
struct blk_mq_hw_ctx *hctx)
{
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 771d45832878..9c7d4b6117d4 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -35,7 +35,6 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
void blk_mq_debugfs_register_rqos(struct rq_qos *rqos);
void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos);
-void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q);
#else
static inline void blk_mq_debugfs_register(struct request_queue *q)
{
@@ -82,10 +81,6 @@ static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
{
}
-
-static inline void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q)
-{
-}
#endif
#ifdef CONFIG_BLK_DEBUG_FS_ZONED
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index 249a6f05dd3b..d3a75693adbf 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -294,10 +294,6 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
void rq_qos_exit(struct request_queue *q)
{
- mutex_lock(&q->debugfs_mutex);
- blk_mq_debugfs_unregister_queue_rqos(q);
- mutex_unlock(&q->debugfs_mutex);
-
while (q->rq_qos) {
struct rq_qos *rqos = q->rq_qos;
q->rq_qos = rqos->next;
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 6e4801b217a7..9b905e9443e4 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -779,13 +779,6 @@ static void blk_release_queue(struct kobject *kobj)
if (queue_is_mq(q))
blk_mq_release(q);
- mutex_lock(&q->debugfs_mutex);
- blk_trace_shutdown(q);
- debugfs_remove_recursive(q->debugfs_dir);
- q->debugfs_dir = NULL;
- q->sched_debugfs_dir = NULL;
- mutex_unlock(&q->debugfs_mutex);
-
bioset_exit(&q->bio_split);
if (blk_queue_has_srcu(q))
@@ -946,8 +939,15 @@ void blk_unregister_queue(struct gendisk *disk)
/* Now that we've deleted all child objects, we can delete the queue. */
kobject_uevent(&q->kobj, KOBJ_REMOVE);
kobject_del(&q->kobj);
-
mutex_unlock(&q->sysfs_dir_lock);
+ mutex_lock(&q->debugfs_mutex);
+ blk_trace_shutdown(q);
+ debugfs_remove_recursive(q->debugfs_dir);
+ q->debugfs_dir = NULL;
+ q->sched_debugfs_dir = NULL;
+ q->rqos_debugfs_dir = NULL;
+ mutex_unlock(&q->debugfs_mutex);
+
kobject_put(&disk_to_dev(disk)->kobj);
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 23/53] block: freeze the queue earlier in del_gendisk
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (20 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 22/53] block: remove per-disk debugfs files in blk_unregister_queue Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 24/53] drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c Sasha Levin
` (28 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christoph Hellwig, Jens Axboe, Sasha Levin, linux-block
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit a09b314005f3a0956ebf56e01b3b80339df577cc ]
Freeze the queue earlier in del_gendisk so that the state does not
change while we remove debugfs and sysfs files.
Ming mentioned that being able to observer request in debugfs might
be useful while the queue is being frozen in del_gendisk, which is
made possible by this change.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220614074827.458955-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/genhd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 3008ec213654..204ee91602c2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -623,6 +623,7 @@ void del_gendisk(struct gendisk *disk)
* Prevent new I/O from crossing bio_queue_enter().
*/
blk_queue_start_drain(q);
+ blk_mq_freeze_queue_wait(q);
if (!(disk->flags & GENHD_FL_HIDDEN)) {
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
@@ -646,8 +647,6 @@ void del_gendisk(struct gendisk *disk)
pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
device_del(disk_to_dev(disk));
- blk_mq_freeze_queue_wait(q);
-
blk_throtl_cancel_bios(disk->queue);
blk_sync_queue(q);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 24/53] drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (21 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 23/53] block: freeze the queue earlier in del_gendisk Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 4:38 ` Jakub Kicinski
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 25/53] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN Sasha Levin
` (27 subsequent siblings)
50 siblings, 1 reply; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Wentao_Liang, David S . Miller, Sasha Levin, jdmason, edumazet,
kuba, pabeni, paskripkin, jgg, liuhangbin, arnd,
christophe.jaillet, netdev
From: Wentao_Liang <Wentao_Liang_g@163.com>
[ Upstream commit 8fc74d18639a2402ca52b177e990428e26ea881f ]
The pointer vdev points to a memory region adjacent to a net_device
structure ndev, which is a field of hldev. At line 4740, the invocation
to vxge_device_unregister unregisters device hldev, and it also releases
the memory region pointed by vdev->bar0. At line 4743, the freed memory
region is referenced (i.e., iounmap(vdev->bar0)), resulting in a
use-after-free vulnerability. We can fix the bug by calling iounmap
before vxge_device_unregister.
4721. static void vxge_remove(struct pci_dev *pdev)
4722. {
4723. struct __vxge_hw_device *hldev;
4724. struct vxgedev *vdev;
…
4731. vdev = netdev_priv(hldev->ndev);
…
4740. vxge_device_unregister(hldev);
4741. /* Do not call pci_disable_sriov here, as it
will break child devices */
4742. vxge_hw_device_terminate(hldev);
4743. iounmap(vdev->bar0);
…
4749 vxge_debug_init(vdev->level_trace, "%s:%d
Device unregistered",
4750 __func__, __LINE__);
4751 vxge_debug_entryexit(vdev->level_trace, "%s:%d
Exiting...", __func__,
4752 __LINE__);
4753. }
This is the screenshot when the vulnerability is triggered by using
KASAN. We can see that there is a use-after-free reported by KASAN.
/***************************start**************************/
root@kernel:~# echo 1 > /sys/bus/pci/devices/0000:00:03.0/remove
[ 178.296316] vxge_remove
[ 182.057081]
==================================================================
[ 182.057548] BUG: KASAN: use-after-free in vxge_remove+0xe0/0x15c
[ 182.057760] Read of size 8 at addr ffff888006c76598 by task bash/119
[ 182.057983]
[ 182.058747] CPU: 0 PID: 119 Comm: bash Not tainted 5.18.0 #5
[ 182.058919] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
[ 182.059463] Call Trace:
[ 182.059726] <TASK>
[ 182.060017] dump_stack_lvl+0x34/0x44
[ 182.060316] print_report.cold+0xb2/0x6b7
[ 182.060401] ? kfree+0x89/0x290
[ 182.060478] ? vxge_remove+0xe0/0x15c
[ 182.060545] kasan_report+0xa9/0x120
[ 182.060629] ? vxge_remove+0xe0/0x15c
[ 182.060706] vxge_remove+0xe0/0x15c
[ 182.060793] pci_device_remove+0x5d/0xe0
[ 182.060968] device_release_driver_internal+0xf1/0x180
[ 182.061063] pci_stop_bus_device+0xae/0xe0
[ 182.061150] pci_stop_and_remove_bus_device_locked+0x11/0x20
[ 182.061236] remove_store+0xc6/0xe0
[ 182.061297] ? subordinate_bus_number_show+0xc0/0xc0
[ 182.061359] ? __mutex_lock_slowpath+0x10/0x10
[ 182.061438] ? sysfs_kf_write+0x6d/0xa0
[ 182.061525] kernfs_fop_write_iter+0x1b0/0x260
[ 182.061610] ? sysfs_kf_bin_read+0xf0/0xf0
[ 182.061695] new_sync_write+0x209/0x310
[ 182.061789] ? new_sync_read+0x310/0x310
[ 182.061865] ? cgroup_rstat_updated+0x5c/0x170
[ 182.061937] ? preempt_count_sub+0xf/0xb0
[ 182.061995] ? pick_next_entity+0x13a/0x220
[ 182.062063] ? __inode_security_revalidate+0x44/0x80
[ 182.062155] ? security_file_permission+0x46/0x2a0
[ 182.062230] vfs_write+0x33f/0x3e0
[ 182.062303] ksys_write+0xb4/0x150
[ 182.062369] ? __ia32_sys_read+0x40/0x40
[ 182.062451] do_syscall_64+0x3b/0x90
[ 182.062531] entry_SYSCALL_64_after_hwframe+0x46/0xb0
[ 182.062894] RIP: 0033:0x7f3f37d17274
[ 182.063558] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f
80 00 00 00 00 48 8d 05 89 54 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f
05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53
[ 182.063797] RSP: 002b:00007ffd5ba9e178 EFLAGS: 00000246
ORIG_RAX: 0000000000000001
[ 182.064117] RAX: ffffffffffffffda RBX: 0000000000000002
RCX: 00007f3f37d17274
[ 182.064219] RDX: 0000000000000002 RSI: 000055bbec327180
RDI: 0000000000000001
[ 182.064315] RBP: 000055bbec327180 R08: 000000000000000a
R09: 00007f3f37de7cf0
[ 182.064414] R10: 000000000000000a R11: 0000000000000246
R12: 00007f3f37de8760
[ 182.064513] R13: 0000000000000002 R14: 00007f3f37de3760
R15: 0000000000000002
[ 182.064691] </TASK>
[ 182.064916]
[ 182.065224] The buggy address belongs to the physical page:
[ 182.065804] page:00000000ef31e4f4 refcount:0 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0x6c76
[ 182.067419] flags: 0x100000000000000(node=0|zone=1)
[ 182.068997] raw: 0100000000000000 0000000000000000
ffffea00001b1d88 0000000000000000
[ 182.069118] raw: 0000000000000000 0000000000000000
00000000ffffffff 0000000000000000
[ 182.069294] page dumped because: kasan: bad access detected
[ 182.069331]
[ 182.069360] Memory state around the buggy address:
[ 182.070006] ffff888006c76480: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[ 182.070136] ffff888006c76500: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[ 182.070230] >ffff888006c76580: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[ 182.070305] ^
[ 182.070456] ffff888006c76600: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[ 182.070505] ffff888006c76680: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[ 182.070606]
==================================================================
[ 182.071374] Disabling lock debugging due to kernel taint
/*****************************end*****************************/
After fixing the bug as done in the patch, we can find KASAN do not report
the bug and the device(00:03.0) has been successfully removed.
/*****************************start***************************/
root@kernel:~# echo 1 > /sys/bus/pci/devices/0000:00:03.0/remove
root@kernel:~#
/******************************end****************************/
Signed-off-by: Wentao_Liang <Wentao_Liang_g@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/neterion/vxge/vxge-main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index aa7c093f1f91..9684d468b5a7 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -4737,10 +4737,10 @@ static void vxge_remove(struct pci_dev *pdev)
for (i = 0; i < vdev->no_of_vpath; i++)
vxge_free_mac_add_list(&vdev->vpaths[i]);
+ iounmap(vdev->bar0);
vxge_device_unregister(hldev);
/* Do not call pci_disable_sriov here, as it will break child devices */
vxge_hw_device_terminate(hldev);
- iounmap(vdev->bar0);
pci_release_region(pdev, 0);
pci_disable_device(pdev);
driver_config->config_dev_cnt--;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* Re: [PATCH AUTOSEL 5.18 24/53] drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 24/53] drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c Sasha Levin
@ 2022-06-28 4:38 ` Jakub Kicinski
0 siblings, 0 replies; 54+ messages in thread
From: Jakub Kicinski @ 2022-06-28 4:38 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Wentao_Liang, David S . Miller, jdmason,
edumazet, pabeni, paskripkin, jgg, liuhangbin, arnd,
christophe.jaillet, netdev
On Mon, 27 Jun 2022 22:18:10 -0400 Sasha Levin wrote:
> From: Wentao_Liang <Wentao_Liang_g@163.com>
>
> [ Upstream commit 8fc74d18639a2402ca52b177e990428e26ea881f ]
>
> The pointer vdev points to a memory region adjacent to a net_device
> structure ndev, which is a field of hldev. At line 4740, the invocation
> to vxge_device_unregister unregisters device hldev, and it also releases
> the memory region pointed by vdev->bar0. At line 4743, the freed memory
> region is referenced (i.e., iounmap(vdev->bar0)), resulting in a
> use-after-free vulnerability. We can fix the bug by calling iounmap
> before vxge_device_unregister.
This is a dud see commit 877fe9d49b74 ("Revert
"drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c"")
^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH AUTOSEL 5.18 25/53] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (22 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 24/53] drivers/net/ethernet/neterion/vxge: Fix a use-after-free bug in vxge-main.c Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 26/53] libperf evsel: Open shouldn't leak fd on failure Sasha Levin
` (26 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christophe Leroy, Michael Ellerman, Sasha Levin, aneesh.kumar,
rafael.j.wysocki, joel, adobriyan, Julia.Lawall, nick.child,
jlu.hpw, linuxppc-dev
From: Christophe Leroy <christophe.leroy@csgroup.eu>
[ Upstream commit ca5dabcff1df6bc8c413922b5fa63cc602858803 ]
When CONFIG_KASAN is selected, we expect prom_init to use __memset()
because it is too early to use memset().
But with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, the compiler adds calls
to memset() to clear objects on stack, hence the following failure:
PROMCHK arch/powerpc/kernel/prom_init_check
Error: External symbol 'memset' referenced from prom_init.c
make[2]: *** [arch/powerpc/kernel/Makefile:204 : arch/powerpc/kernel/prom_init_check] Erreur 1
prom_find_machine_type() is called from prom_init() and is called only
once, so lets put compat[] in BSS instead of stack to avoid that.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/3802811f7cf94f730be44688539c01bba3a3b5c0.1654875808.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/kernel/prom_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 0ac5faacc909..46247645c134 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2300,7 +2300,7 @@ static void __init prom_init_stdout(void)
static int __init prom_find_machine_type(void)
{
- char compat[256];
+ static char compat[256] __prombss;
int len, i = 0;
#ifdef CONFIG_PPC64
phandle rtas;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 26/53] libperf evsel: Open shouldn't leak fd on failure
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (23 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 25/53] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 27/53] drm: panel-orientation-quirks: Add quirk for Aya Neo Next Sasha Levin
` (25 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Ian Rogers, Kajol Jain, Adrian Hunter, Alexander Shishkin,
Andi Kleen, Anshuman Khandual, Ingo Molnar, Jiri Olsa,
Mark Rutland, Namhyung Kim, Peter Zijlstra, Rob Herring,
Stephane Eranian, Arnaldo Carvalho de Melo, Sasha Levin, acme,
linux-perf-users
From: Ian Rogers <irogers@google.com>
[ Upstream commit 94725994cfd768b9ee1bd06f15c252694b1e9b89 ]
If perf_event_open() fails the fd is opened but it is only freed by
closing (not by delete).
Typically when an open fails you don't call close and so this results in
a memory leak. To avoid this, add a close when open fails.
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-By: Kajol Jain <kjain@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20220609052355.1300162-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/lib/perf/evsel.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
index 210ea7c06ce8..acf8a215dca3 100644
--- a/tools/lib/perf/evsel.c
+++ b/tools/lib/perf/evsel.c
@@ -149,23 +149,30 @@ int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
int fd, group_fd, *evsel_fd;
evsel_fd = FD(evsel, idx, thread);
- if (evsel_fd == NULL)
- return -EINVAL;
+ if (evsel_fd == NULL) {
+ err = -EINVAL;
+ goto out;
+ }
err = get_group_fd(evsel, idx, thread, &group_fd);
if (err < 0)
- return err;
+ goto out;
fd = sys_perf_event_open(&evsel->attr,
threads->map[thread].pid,
cpu, group_fd, 0);
- if (fd < 0)
- return -errno;
+ if (fd < 0) {
+ err = -errno;
+ goto out;
+ }
*evsel_fd = fd;
}
}
+out:
+ if (err)
+ perf_evsel__close(evsel);
return err;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 27/53] drm: panel-orientation-quirks: Add quirk for Aya Neo Next
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (24 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 26/53] libperf evsel: Open shouldn't leak fd on failure Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 28/53] iio: freq: admv1014: Fix warning about dubious x & !y and improve readability Sasha Levin
` (24 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Maya Matuszczyk, Javier Martinez Canillas, Hans de Goede,
Sasha Levin, maarten.lankhorst, mripard, tzimmermann, airlied,
daniel, dri-devel
From: Maya Matuszczyk <maccraft123mc@gmail.com>
[ Upstream commit be33d52ef5b4bdfec04cfdad39368c343bac97a3 ]
The device is identified by "NEXT" in board name, however there are
different versions of it, "Next Advance" and "Next Pro", that have
different DMI board names.
Due to a production error a batch or two have their board names prefixed
by "AYANEO", this makes it 6 different DMI board names. To save some
space in final kernel image DMI_MATCH is used instead of
DMI_EXACT_MATCH.
Signed-off-by: Maya Matuszczyk <maccraft123mc@gmail.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220619111952.8487-1-maccraft123mc@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 4e853acfd1e8..df87ba99a87c 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -152,6 +152,12 @@ static const struct dmi_system_id orientation_data[] = {
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYA NEO 2021"),
},
.driver_data = (void *)&lcd800x1280_rightside_up,
+ }, { /* AYA NEO NEXT */
+ .matches = {
+ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AYANEO"),
+ DMI_MATCH(DMI_BOARD_NAME, "NEXT"),
+ },
+ .driver_data = (void *)&lcd800x1280_rightside_up,
}, { /* Chuwi HiBook (CWI514) */
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 28/53] iio: freq: admv1014: Fix warning about dubious x & !y and improve readability
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (25 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 27/53] drm: panel-orientation-quirks: Add quirk for Aya Neo Next Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 29/53] spi: rockchip: Unmask IRQ at the final to avoid preemption Sasha Levin
` (23 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Antoniu Miclaus, Jonathan Cameron, Sasha Levin, lars,
Michael.Hennerich, jic23, linux-iio
From: Antoniu Miclaus <antoniu.miclaus@analog.com>
[ Upstream commit 6f6bd7591945c679b7f595119ea997b19f5794db ]
The warning comes from __BF_FIELD_CHECK()
specifically
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
_pfx "value too large for the field"); \
The code was using !(enum value) which is not particularly easy to follow
so replace that with explicit matching and use of ? 0 : 1; or ? 1 : 0;
to improve readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20220511090006.90502-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iio/frequency/admv1014.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/admv1014.c b/drivers/iio/frequency/admv1014.c
index a7994f8e6b9b..1aac5665b5de 100644
--- a/drivers/iio/frequency/admv1014.c
+++ b/drivers/iio/frequency/admv1014.c
@@ -700,8 +700,10 @@ static int admv1014_init(struct admv1014_state *st)
ADMV1014_DET_EN_MSK;
enable_reg = FIELD_PREP(ADMV1014_P1DB_COMPENSATION_MSK, st->p1db_comp ? 3 : 0) |
- FIELD_PREP(ADMV1014_IF_AMP_PD_MSK, !(st->input_mode)) |
- FIELD_PREP(ADMV1014_BB_AMP_PD_MSK, st->input_mode) |
+ FIELD_PREP(ADMV1014_IF_AMP_PD_MSK,
+ (st->input_mode == ADMV1014_IF_MODE) ? 0 : 1) |
+ FIELD_PREP(ADMV1014_BB_AMP_PD_MSK,
+ (st->input_mode == ADMV1014_IF_MODE) ? 1 : 0) |
FIELD_PREP(ADMV1014_DET_EN_MSK, st->det_en);
return __admv1014_spi_update_bits(st, ADMV1014_REG_ENABLE, enable_reg_msk, enable_reg);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 29/53] spi: rockchip: Unmask IRQ at the final to avoid preemption
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (26 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 28/53] iio: freq: admv1014: Fix warning about dubious x & !y and improve readability Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 30/53] video: fbdev: skeletonfb: Fix syntax errors in comments Sasha Levin
` (22 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Jon Lin, Mark Brown, Sasha Levin, heiko, linux-spi,
linux-arm-kernel, linux-rockchip
From: Jon Lin <jon.lin@rock-chips.com>
[ Upstream commit 419bc8f681a0dc63588cee693b6d45e7caa6006c ]
Avoid pio_write process is preempted, resulting in abnormal state.
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Signed-off-by: Jon <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220617124251.5051-1-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/spi/spi-rockchip.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index a08215eb9e14..79242dc5272d 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -381,15 +381,18 @@ static int rockchip_spi_prepare_irq(struct rockchip_spi *rs,
rs->tx_left = rs->tx ? xfer->len / rs->n_bytes : 0;
rs->rx_left = xfer->len / rs->n_bytes;
- if (rs->cs_inactive)
- writel_relaxed(INT_RF_FULL | INT_CS_INACTIVE, rs->regs + ROCKCHIP_SPI_IMR);
- else
- writel_relaxed(INT_RF_FULL, rs->regs + ROCKCHIP_SPI_IMR);
+ writel_relaxed(0xffffffff, rs->regs + ROCKCHIP_SPI_ICR);
+
spi_enable_chip(rs, true);
if (rs->tx_left)
rockchip_spi_pio_writer(rs);
+ if (rs->cs_inactive)
+ writel_relaxed(INT_RF_FULL | INT_CS_INACTIVE, rs->regs + ROCKCHIP_SPI_IMR);
+ else
+ writel_relaxed(INT_RF_FULL, rs->regs + ROCKCHIP_SPI_IMR);
+
/* 1 means the transfer is in progress */
return 1;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 30/53] video: fbdev: skeletonfb: Fix syntax errors in comments
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (27 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 29/53] spi: rockchip: Unmask IRQ at the final to avoid preemption Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 31/53] video: fbdev: intelfb: Use aperture size from pci_resource_len Sasha Levin
` (21 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Xiang wangx, Helge Deller, Sasha Levin, daniel.vetter, cssk,
tzimmermann, bhelgaas, linux-fbdev, dri-devel
From: Xiang wangx <wangxiang@cdjrlc.com>
[ Upstream commit fc378794a2f7a19cf26010dc33b89ba608d4c70f ]
Delete the redundant word 'its'.
Signed-off-by: Xiang wangx <wangxiang@cdjrlc.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/video/fbdev/skeletonfb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeletonfb.c
index bcacfb6934fa..3d4d78362ede 100644
--- a/drivers/video/fbdev/skeletonfb.c
+++ b/drivers/video/fbdev/skeletonfb.c
@@ -96,7 +96,7 @@ static const struct fb_fix_screeninfo xxxfb_fix = {
/*
* Modern graphical hardware not only supports pipelines but some
- * also support multiple monitors where each display can have its
+ * also support multiple monitors where each display can have
* its own unique data. In this case each display could be
* represented by a separate framebuffer device thus a separate
* struct fb_info. Now the struct xxx_par represents the graphics
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 31/53] video: fbdev: intelfb: Use aperture size from pci_resource_len
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (28 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 30/53] video: fbdev: skeletonfb: Fix syntax errors in comments Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 32/53] io_uring: mark reissue requests with REQ_F_PARTIAL_IO Sasha Levin
` (20 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Petr Cvek, Helge Deller, Sasha Levin, mbroemme, linux-fbdev,
dri-devel
From: Petr Cvek <petrcvekcz@gmail.com>
[ Upstream commit 25c9a15fb7bbfafb94dd3b4e3165c18b8e1bd039 ]
Aperture size for i9x5 variants is determined from PCI base address.
if (pci_resource_start(pdev, 2) & 0x08000000)
*aperture_size = MB(128);
...
This condition is incorrect as 128 MiB address can have the address
set as 0x?8000000 or 0x?0000000. Also the code can be simplified to just
use pci_resource_len().
The true settings of the aperture size is in the MSAC register, which
could be used instead. However the value is used only as an info message,
so it doesn't matter.
Signed-off-by: Petr Cvek <petrcvekcz@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/video/fbdev/intelfb/intelfbhw.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/video/fbdev/intelfb/intelfbhw.c b/drivers/video/fbdev/intelfb/intelfbhw.c
index 57aff7450bce..2086e06532ee 100644
--- a/drivers/video/fbdev/intelfb/intelfbhw.c
+++ b/drivers/video/fbdev/intelfb/intelfbhw.c
@@ -201,13 +201,11 @@ int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
case PCI_DEVICE_ID_INTEL_945GME:
case PCI_DEVICE_ID_INTEL_965G:
case PCI_DEVICE_ID_INTEL_965GM:
- /* 915, 945 and 965 chipsets support a 256MB aperture.
- Aperture size is determined by inspected the
- base address of the aperture. */
- if (pci_resource_start(pdev, 2) & 0x08000000)
- *aperture_size = MB(128);
- else
- *aperture_size = MB(256);
+ /*
+ * 915, 945 and 965 chipsets support 64MB, 128MB or 256MB
+ * aperture. Determine size from PCI resource length.
+ */
+ *aperture_size = pci_resource_len(pdev, 2);
break;
default:
if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 32/53] io_uring: mark reissue requests with REQ_F_PARTIAL_IO
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (29 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 31/53] video: fbdev: intelfb: Use aperture size from pci_resource_len Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 33/53] video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write Sasha Levin
` (19 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Jens Axboe, Sasha Levin, io-uring
From: Jens Axboe <axboe@kernel.dk>
[ Upstream commit 1bacd264d3c3a05de4afdd1712c9dd6ccebb9490 ]
If we mark for reissue, we assume that the buffer will remain stable.
Hence if are using a provided buffer, we need to ensure that we stick
with it for the duration of that request.
This only affects block devices that use provided buffers, as those are
the only ones that get marked with REQ_F_REISSUE.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 68aab48838e4..725c59c734f1 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3009,7 +3009,7 @@ static bool __io_complete_rw_common(struct io_kiocb *req, long res)
if (unlikely(res != req->result)) {
if ((res == -EAGAIN || res == -EOPNOTSUPP) &&
io_rw_should_reissue(req)) {
- req->flags |= REQ_F_REISSUE;
+ req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO;
return true;
}
req_set_fail(req);
@@ -3059,7 +3059,7 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
kiocb_end_write(req);
if (unlikely(res != req->result)) {
if (res == -EAGAIN && io_rw_should_reissue(req)) {
- req->flags |= REQ_F_REISSUE;
+ req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO;
return;
}
req->result = res;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 33/53] video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (30 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 32/53] io_uring: mark reissue requests with REQ_F_PARTIAL_IO Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 34/53] video: fbdev: simplefb: Check before clk_put() not needed Sasha Levin
` (18 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Hyunwoo Kim, Helge Deller, Sasha Levin, cai.huoqing, yang.lee,
yangyingliang, linux-fbdev, dri-devel
From: Hyunwoo Kim <imv4bel@gmail.com>
[ Upstream commit a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7 ]
In pxa3xx_gcu_write, a count parameter of type size_t is passed to words of
type int. Then, copy_from_user() may cause a heap overflow because it is used
as the third argument of copy_from_user().
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/video/fbdev/pxa3xx-gcu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c
index 043cc8f9ef1c..c3cd1e1cc01b 100644
--- a/drivers/video/fbdev/pxa3xx-gcu.c
+++ b/drivers/video/fbdev/pxa3xx-gcu.c
@@ -381,7 +381,7 @@ pxa3xx_gcu_write(struct file *file, const char *buff,
struct pxa3xx_gcu_batch *buffer;
struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
- int words = count / 4;
+ size_t words = count / 4;
/* Does not need to be atomic. There's a lock in user space,
* but anyhow, this is just for statistics. */
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 34/53] video: fbdev: simplefb: Check before clk_put() not needed
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (31 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 33/53] video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 35/53] btrfs: add missing inode updates on each iteration when replacing extents Sasha Levin
` (17 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Yihao Han, Hans de Goede, Helge Deller, Sasha Levin, linux-fbdev,
dri-devel
From: Yihao Han <hanyihao@vivo.com>
[ Upstream commit 5491424d17bdeb7b7852a59367858251783f8398 ]
clk_put() already checks the clk ptr using !clk and IS_ERR()
so there is no need to check it again before calling it.
Signed-off-by: Yihao Han <hanyihao@vivo.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/video/fbdev/simplefb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index 2c198561c338..f96ce8801be4 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -237,8 +237,7 @@ static int simplefb_clocks_get(struct simplefb_par *par,
if (IS_ERR(clock)) {
if (PTR_ERR(clock) == -EPROBE_DEFER) {
while (--i >= 0) {
- if (par->clks[i])
- clk_put(par->clks[i]);
+ clk_put(par->clks[i]);
}
kfree(par->clks);
return -EPROBE_DEFER;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 35/53] btrfs: add missing inode updates on each iteration when replacing extents
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (32 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 34/53] video: fbdev: simplefb: Check before clk_put() not needed Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 36/53] btrfs: do not BUG_ON() on failure to migrate space " Sasha Levin
` (16 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Filipe Manana, Boris Burkov, David Sterba, Sasha Levin, clm,
josef, linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 983d8209c6803345c9958f4cc358d1155f93a099 ]
When replacing file extents, called during fallocate, hole punching,
clone and deduplication, we may not be able to replace/drop all the
target file extent items with a single transaction handle. We may get
-ENOSPC while doing it, in which case we release the transaction handle,
balance the dirty pages of the btree inode, flush delayed items and get
a new transaction handle to operate on what's left of the target range.
By dropping and replacing file extent items we have effectively modified
the inode, so we should bump its iversion and update its mtime/ctime
before we update the inode item. This is because if the transaction
we used for partially modifying the inode gets committed by someone after
we release it and before we finish the rest of the range, a power failure
happens, then after mounting the filesystem our inode has an outdated
iversion and mtime/ctime, corresponding to the values it had before we
changed it.
So add the missing iversion and mtime/ctime updates.
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/ctree.h | 2 ++
fs/btrfs/file.c | 19 +++++++++++++++++++
fs/btrfs/inode.c | 1 +
fs/btrfs/reflink.c | 1 +
4 files changed, 23 insertions(+)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 077c95e9baa5..fd831047994f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1331,6 +1331,8 @@ struct btrfs_replace_extent_info {
* existing extent into a file range.
*/
bool is_new_extent;
+ /* Indicate if we should update the inode's mtime and ctime. */
+ bool update_times;
/* Meaningful only if is_new_extent is true. */
int qgroup_reserved;
/*
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 380054c94e4b..ab882ddfb0e8 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2850,6 +2850,25 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
extent_info->file_offset += replace_len;
}
+ /*
+ * We are releasing our handle on the transaction, balance the
+ * dirty pages of the btree inode and flush delayed items, and
+ * then get a new transaction handle, which may now point to a
+ * new transaction in case someone else may have committed the
+ * transaction we used to replace/drop file extent items. So
+ * bump the inode's iversion and update mtime and ctime except
+ * if we are called from a dedupe context. This is because a
+ * power failure/crash may happen after the transaction is
+ * committed and before we finish replacing/dropping all the
+ * file extent items we need.
+ */
+ inode_inc_iversion(&inode->vfs_inode);
+
+ if (!extent_info || extent_info->update_times) {
+ inode->vfs_inode.i_mtime = current_time(&inode->vfs_inode);
+ inode->vfs_inode.i_ctime = inode->vfs_inode.i_mtime;
+ }
+
ret = btrfs_update_inode(trans, root, inode);
if (ret)
break;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 861b9748a0d9..acd0604aced9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9916,6 +9916,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
extent_info.file_offset = file_offset;
extent_info.extent_buf = (char *)&stack_fi;
extent_info.is_new_extent = true;
+ extent_info.update_times = true;
extent_info.qgroup_reserved = qgroup_released;
extent_info.insertions = 0;
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 998e3f180d90..79ea8353994e 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -489,6 +489,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
clone_info.file_offset = new_key.offset;
clone_info.extent_buf = buf;
clone_info.is_new_extent = false;
+ clone_info.update_times = !no_time_update;
ret = btrfs_replace_file_extents(BTRFS_I(inode), path,
drop_start, new_key.offset + datal - 1,
&clone_info, &trans);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 36/53] btrfs: do not BUG_ON() on failure to migrate space when replacing extents
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (33 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 35/53] btrfs: add missing inode updates on each iteration when replacing extents Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 37/53] io_uring: fix merge error in checking send/recv addr2 flags Sasha Levin
` (15 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Filipe Manana, Boris Burkov, David Sterba, Sasha Levin, clm,
josef, linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 650c9caba32a0167a018cca0fab32a2965d23513 ]
At btrfs_replace_file_extents(), if we fail to migrate reserved metadata
space from the transaction block reserve into the local block reserve,
we trigger a BUG_ON(). This is because it should not be possible to have
a failure here, as we reserved more space when we started the transaction
than the space we want to migrate. However having a BUG_ON() is way too
drastic, we can perfectly handle the failure and return the error to the
caller. So just do that instead, and add a WARN_ON() to make it easier
to notice the failure if it ever happens (which is particularly useful
for fstests, and the warning will trigger a failure of a test case).
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/file.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index ab882ddfb0e8..7db4f08bd8f9 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2766,7 +2766,8 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
ret = btrfs_block_rsv_migrate(&fs_info->trans_block_rsv, rsv,
min_size, false);
- BUG_ON(ret);
+ if (WARN_ON(ret))
+ goto out_trans;
trans->block_rsv = rsv;
cur_offset = start;
@@ -2885,7 +2886,8 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
ret = btrfs_block_rsv_migrate(&fs_info->trans_block_rsv,
rsv, min_size, false);
- BUG_ON(ret); /* shouldn't happen */
+ if (WARN_ON(ret))
+ break;
trans->block_rsv = rsv;
cur_offset = drop_args.drop_end;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 37/53] io_uring: fix merge error in checking send/recv addr2 flags
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (34 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 36/53] btrfs: do not BUG_ON() on failure to migrate space " Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 13:12 ` Jens Axboe
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 38/53] drm/xen: Add missing VM_DONTEXPAND flag in mmap callback Sasha Levin
` (14 subsequent siblings)
50 siblings, 1 reply; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Jens Axboe, Sasha Levin, io-uring
From: Jens Axboe <axboe@kernel.dk>
[ Upstream commit b60cac14bb3c88cff2a7088d9095b01a80938c41 ]
With the dropping of the IOPOLL checking in the per-opcode handlers,
we inadvertently left two checks in the recv/recvmsg and send/sendmsg
prep handlers for the same thing, and one of them includes addr2 which
holds the flags for these opcodes.
Fix it up and kill the redundant checks.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/io_uring.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 725c59c734f1..9eb20f8865ac 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5252,8 +5252,6 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
- if (unlikely(sqe->addr2 || sqe->file_index))
- return -EINVAL;
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len);
@@ -5465,8 +5463,6 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
- if (unlikely(sqe->addr2 || sqe->file_index))
- return -EINVAL;
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* Re: [PATCH AUTOSEL 5.18 37/53] io_uring: fix merge error in checking send/recv addr2 flags
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 37/53] io_uring: fix merge error in checking send/recv addr2 flags Sasha Levin
@ 2022-06-28 13:12 ` Jens Axboe
0 siblings, 0 replies; 54+ messages in thread
From: Jens Axboe @ 2022-06-28 13:12 UTC (permalink / raw)
To: Sasha Levin; +Cc: linux-kernel, stable, Sasha Levin, io-uring
On Mon, Jun 27, 2022 at 8:20 PM Sasha Levin <sashal@kernel.org> wrote:
>
> From: Jens Axboe <axboe@kernel.dk>
>
> [ Upstream commit b60cac14bb3c88cff2a7088d9095b01a80938c41 ]
>
> With the dropping of the IOPOLL checking in the per-opcode handlers,
> we inadvertently left two checks in the recv/recvmsg and send/sendmsg
> prep handlers for the same thing, and one of them includes addr2 which
> holds the flags for these opcodes.
>
> Fix it up and kill the redundant checks.
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> fs/io_uring.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 725c59c734f1..9eb20f8865ac 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -5252,8 +5252,6 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
>
> if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
> return -EINVAL;
> - if (unlikely(sqe->addr2 || sqe->file_index))
> - return -EINVAL;
>
> sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
> sr->len = READ_ONCE(sqe->len);
> @@ -5465,8 +5463,6 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
>
> if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
> return -EINVAL;
> - if (unlikely(sqe->addr2 || sqe->file_index))
> - return -EINVAL;
>
> sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
> sr->len = READ_ONCE(sqe->len);
This doesn't look right, and cannot be as the problem was added with a
5.19 merge issue. Please drop this patch from 5.18-stable, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH AUTOSEL 5.18 38/53] drm/xen: Add missing VM_DONTEXPAND flag in mmap callback
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (35 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 37/53] io_uring: fix merge error in checking send/recv addr2 flags Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 39/53] arch: mips: generic: Add missing of_node_put() in board-ranchu.c Sasha Levin
` (13 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Oleksandr Tyshchenko, Oleksandr Andrushchenko, Juergen Gross,
Sasha Levin, airlied, daniel, dri-devel, xen-devel
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
[ Upstream commit ca6969013d13282b42cb5edcc13db731a08e0ad8 ]
With Xen PV Display driver in use the "expected" VM_DONTEXPAND flag
is not set (neither explicitly nor implicitly), so the driver hits
the code path in drm_gem_mmap_obj() which triggers the WARNING.
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Link: https://lore.kernel.org/r/1652104303-5098-1-git-send-email-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c
index 5a5bf4e5b717..e31554d7139f 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
@@ -71,7 +71,7 @@ static int xen_drm_front_gem_object_mmap(struct drm_gem_object *gem_obj,
* the whole buffer.
*/
vma->vm_flags &= ~VM_PFNMAP;
- vma->vm_flags |= VM_MIXEDMAP;
+ vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
vma->vm_pgoff = 0;
/*
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 39/53] arch: mips: generic: Add missing of_node_put() in board-ranchu.c
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (36 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 38/53] drm/xen: Add missing VM_DONTEXPAND flag in mmap callback Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 40/53] mips: mti-malta: Fix refcount leak in malta-time.c Sasha Levin
` (12 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, miodrag.dinic,
paulburton, linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 4becf6417bbdc293734a590fe4ed38437bbcea2c ]
In ranchu_measure_hpt_freq(), of_find_compatible_node() will return
a node pointer with refcount incremented. We should use of_put_node()
when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/generic/board-ranchu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/generic/board-ranchu.c b/arch/mips/generic/board-ranchu.c
index a89aaad59cb1..930c45041882 100644
--- a/arch/mips/generic/board-ranchu.c
+++ b/arch/mips/generic/board-ranchu.c
@@ -44,6 +44,7 @@ static __init unsigned int ranchu_measure_hpt_freq(void)
__func__);
rtc_base = of_iomap(np, 0);
+ of_node_put(np);
if (!rtc_base)
panic("%s(): Failed to ioremap Goldfish RTC base!", __func__);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 40/53] mips: mti-malta: Fix refcount leak in malta-time.c
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (37 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 39/53] arch: mips: generic: Add missing of_node_put() in board-ranchu.c Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 41/53] mips: ralink: Fix refcount leak in of.c Sasha Levin
` (11 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 608d94cb84c42585058d692f2fe5d327f8868cdb ]
In update_gic_frequency_dt(), of_find_compatible_node() will return
a node pointer with refcount incremented. We should use of_node_put()
when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/mti-malta/malta-time.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index bbf1e38e1431..2cb708cdf01a 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -214,6 +214,8 @@ static void update_gic_frequency_dt(void)
if (of_update_property(node, &gic_frequency_prop) < 0)
pr_err("error updating gic frequency property\n");
+
+ of_node_put(node);
}
#endif
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 41/53] mips: ralink: Fix refcount leak in of.c
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (38 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 40/53] mips: mti-malta: Fix refcount leak in malta-time.c Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 42/53] mips: lantiq: falcon: Fix refcount leak bug in sysctrl Sasha Levin
` (10 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, john, linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 48ca54e39173d1ed4c4dc8cf045484014bb26eaf ]
In plat_of_remap_node(), plat_of_remap_node() will return a node
pointer with refcount incremented. We should use of_node_put()
when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/ralink/of.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
index 587c7b998769..ea8072acf8d9 100644
--- a/arch/mips/ralink/of.c
+++ b/arch/mips/ralink/of.c
@@ -40,6 +40,8 @@ __iomem void *plat_of_remap_node(const char *node)
if (of_address_to_resource(np, 0, &res))
panic("Failed to get resource for %s", node);
+ of_node_put(np);
+
if (!request_mem_region(res.start,
resource_size(&res),
res.name))
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 42/53] mips: lantiq: falcon: Fix refcount leak bug in sysctrl
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (39 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 41/53] mips: ralink: Fix refcount leak in of.c Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 43/53] mips: lantiq: xway: " Sasha Levin
` (9 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, john, wangborong,
xkernel.wang, linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 72a2af539fff975caadd9a4db3f99963569bd9c9 ]
In ltq_soc_init(), of_find_compatible_node() will return a node pointer
with refcount incremented. We should use of_node_put() when it is not
used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/lantiq/falcon/sysctrl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/mips/lantiq/falcon/sysctrl.c b/arch/mips/lantiq/falcon/sysctrl.c
index 5204fc6d6d50..1187729d8cbb 100644
--- a/arch/mips/lantiq/falcon/sysctrl.c
+++ b/arch/mips/lantiq/falcon/sysctrl.c
@@ -208,6 +208,12 @@ void __init ltq_soc_init(void)
of_address_to_resource(np_sysgpe, 0, &res_sys[2]))
panic("Failed to get core resources");
+ of_node_put(np_status);
+ of_node_put(np_ebu);
+ of_node_put(np_sys1);
+ of_node_put(np_syseth);
+ of_node_put(np_sysgpe);
+
if ((request_mem_region(res_status.start, resource_size(&res_status),
res_status.name) < 0) ||
(request_mem_region(res_ebu.start, resource_size(&res_ebu),
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 43/53] mips: lantiq: xway: Fix refcount leak bug in sysctrl
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (40 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 42/53] mips: lantiq: falcon: Fix refcount leak bug in sysctrl Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 44/53] mips/pic32/pic32mzda: Fix refcount leak bugs Sasha Levin
` (8 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, john, xkernel.wang,
linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 76695592711ef1e215cc24ed3e1cd857d7fc3098 ]
In ltq_soc_init(), of_find_compatible_node() will return a node
pointer with refcount incremented. We should use of_node_put() when
it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/lantiq/xway/sysctrl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
index 084f6caba5f2..d444a1b98a72 100644
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -441,6 +441,10 @@ void __init ltq_soc_init(void)
of_address_to_resource(np_ebu, 0, &res_ebu))
panic("Failed to get core resources");
+ of_node_put(np_pmu);
+ of_node_put(np_cgu);
+ of_node_put(np_ebu);
+
if (!request_mem_region(res_pmu.start, resource_size(&res_pmu),
res_pmu.name) ||
!request_mem_region(res_cgu.start, resource_size(&res_cgu),
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 44/53] mips/pic32/pic32mzda: Fix refcount leak bugs
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (41 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 43/53] mips: lantiq: xway: " Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 45/53] mips: dts: ingenic: Add TCU clock to x1000/x1830 tcu device node Sasha Levin
` (7 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, yangtiezhu,
linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit eb9e9bc4fa5fb489c92ec588b3fb35f042ba6d86 ]
of_find_matching_node(), of_find_compatible_node() and
of_find_node_by_path() will return node pointers with refcout
incremented. We should call of_node_put() when they are not
used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/pic32/pic32mzda/init.c | 7 ++++++-
arch/mips/pic32/pic32mzda/time.c | 3 +++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
index 129915616763..d9c8c4e46aff 100644
--- a/arch/mips/pic32/pic32mzda/init.c
+++ b/arch/mips/pic32/pic32mzda/init.c
@@ -98,13 +98,18 @@ static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup)
np = of_find_compatible_node(NULL, NULL, lookup->compatible);
if (np) {
lookup->name = (char *)np->name;
- if (lookup->phys_addr)
+ if (lookup->phys_addr) {
+ of_node_put(np);
continue;
+ }
if (!of_address_to_resource(np, 0, &res))
lookup->phys_addr = res.start;
+ of_node_put(np);
}
}
+ of_node_put(root);
+
return 0;
}
diff --git a/arch/mips/pic32/pic32mzda/time.c b/arch/mips/pic32/pic32mzda/time.c
index 7174e9abbb1b..777b515c52c8 100644
--- a/arch/mips/pic32/pic32mzda/time.c
+++ b/arch/mips/pic32/pic32mzda/time.c
@@ -32,6 +32,9 @@ static unsigned int pic32_xlate_core_timer_irq(void)
goto default_map;
irq = irq_of_parse_and_map(node, 0);
+
+ of_node_put(node);
+
if (!irq)
goto default_map;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 45/53] mips: dts: ingenic: Add TCU clock to x1000/x1830 tcu device node
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (42 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 44/53] mips/pic32/pic32mzda: Fix refcount leak bugs Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 46/53] mips: lantiq: Add missing of_node_put() in irq.c Sasha Levin
` (6 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Aidan MacDonald, Paul Cercueil, Thomas Bogendoerfer, Sasha Levin,
robh+dt, krzysztof.kozlowski+dt, linux-mips, devicetree
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
[ Upstream commit db30dc1a5226eb74d52f748989e9a06451333678 ]
This clock is a gate for the TCU hardware block on these SoCs, but
it wasn't included in the device tree since the ingenic-tcu driver
erroneously did not request it.
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/boot/dts/ingenic/x1000.dtsi | 5 +++--
arch/mips/boot/dts/ingenic/x1830.dtsi | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/mips/boot/dts/ingenic/x1000.dtsi b/arch/mips/boot/dts/ingenic/x1000.dtsi
index 8bd27edef216..c69df8eb158e 100644
--- a/arch/mips/boot/dts/ingenic/x1000.dtsi
+++ b/arch/mips/boot/dts/ingenic/x1000.dtsi
@@ -111,8 +111,9 @@ tcu: timer@10002000 {
clocks = <&cgu X1000_CLK_RTCLK>,
<&cgu X1000_CLK_EXCLK>,
- <&cgu X1000_CLK_PCLK>;
- clock-names = "rtc", "ext", "pclk";
+ <&cgu X1000_CLK_PCLK>,
+ <&cgu X1000_CLK_TCU>;
+ clock-names = "rtc", "ext", "pclk", "tcu";
interrupt-controller;
#interrupt-cells = <1>;
diff --git a/arch/mips/boot/dts/ingenic/x1830.dtsi b/arch/mips/boot/dts/ingenic/x1830.dtsi
index 2595df8671c7..4408df24ca98 100644
--- a/arch/mips/boot/dts/ingenic/x1830.dtsi
+++ b/arch/mips/boot/dts/ingenic/x1830.dtsi
@@ -104,8 +104,9 @@ tcu: timer@10002000 {
clocks = <&cgu X1830_CLK_RTCLK>,
<&cgu X1830_CLK_EXCLK>,
- <&cgu X1830_CLK_PCLK>;
- clock-names = "rtc", "ext", "pclk";
+ <&cgu X1830_CLK_PCLK>,
+ <&cgu X1830_CLK_TCU>;
+ clock-names = "rtc", "ext", "pclk", "tcu";
interrupt-controller;
#interrupt-cells = <1>;
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 46/53] mips: lantiq: Add missing of_node_put() in irq.c
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (43 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 45/53] mips: dts: ingenic: Add TCU clock to x1000/x1830 tcu device node Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 47/53] drm/sun4i: Add DMA mask and segment size Sasha Levin
` (5 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Thomas Bogendoerfer, Sasha Levin, john, linux-mips
From: Liang He <windhl@126.com>
[ Upstream commit 3748d2185ac4c2c6f80989672253aad909ecaf95 ]
In icu_of_init(), of_find_compatible_node() will return a node
pointer with refcount incremented. We should use of_node_put()
when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/lantiq/irq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index b732495f138a..20622bf0a9b3 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -408,6 +408,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
if (!ltq_eiu_membase)
panic("Failed to remap eiu memory");
}
+ of_node_put(eiu_node);
return 0;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 47/53] drm/sun4i: Add DMA mask and segment size
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (44 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 46/53] mips: lantiq: Add missing of_node_put() in irq.c Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 48/53] drm/sun4i: Return if frontend is not present Sasha Levin
` (4 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Jernej Skrabec, Samuel Holland, Maxime Ripard, Sasha Levin,
mripard, wens, airlied, daniel, dri-devel, linux-arm-kernel,
linux-sunxi
From: Jernej Skrabec <jernej.skrabec@gmail.com>
[ Upstream commit f5aa16807aa4f99293044944590dde81364f434f ]
Kernel occasionally complains that there is mismatch in segment size
when trying to render HW decoded videos and rendering them directly with
sun4i DRM driver. Following message can be observed on H6 SoC:
[ 184.298308] ------------[ cut here ]------------
[ 184.298326] DMA-API: sun4i-drm display-engine: mapping sg segment longer than device claims to support [len=6144000] [max=65536]
[ 184.298364] WARNING: CPU: 1 PID: 382 at kernel/dma/debug.c:1162 debug_dma_map_sg+0x2b0/0x350
[ 184.322997] CPU: 1 PID: 382 Comm: ffmpeg Not tainted 5.19.0-rc1+ #1331
[ 184.329533] Hardware name: Tanix TX6 (DT)
[ 184.333544] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 184.340512] pc : debug_dma_map_sg+0x2b0/0x350
[ 184.344882] lr : debug_dma_map_sg+0x2b0/0x350
[ 184.349250] sp : ffff800009f33a50
[ 184.352567] x29: ffff800009f33a50 x28: 0000000000010000 x27: ffff000001b86c00
[ 184.359725] x26: ffffffffffffffff x25: ffff000005d8cc80 x24: 0000000000000000
[ 184.366879] x23: ffff80000939ab18 x22: 0000000000000001 x21: 0000000000000001
[ 184.374031] x20: 0000000000000000 x19: ffff0000018a7410 x18: ffffffffffffffff
[ 184.381186] x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
[ 184.388338] x14: 0000000000000001 x13: ffff800009534e86 x12: 6f70707573206f74
[ 184.395493] x11: 20736d69616c6320 x10: 000000000000000a x9 : 0000000000010000
[ 184.402647] x8 : ffff8000093b6d40 x7 : ffff800009f33850 x6 : 000000000000000c
[ 184.409800] x5 : ffff0000bf997940 x4 : 0000000000000000 x3 : 0000000000000027
[ 184.416953] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000003960e80
[ 184.424106] Call trace:
[ 184.426556] debug_dma_map_sg+0x2b0/0x350
[ 184.430580] __dma_map_sg_attrs+0xa0/0x110
[ 184.434687] dma_map_sgtable+0x28/0x4c
[ 184.438447] vb2_dc_dmabuf_ops_map+0x60/0xcc
[ 184.442729] __map_dma_buf+0x2c/0xd4
[ 184.446321] dma_buf_map_attachment+0xa0/0x130
[ 184.450777] drm_gem_prime_import_dev+0x7c/0x18c
[ 184.455410] drm_gem_prime_fd_to_handle+0x1b8/0x214
[ 184.460300] drm_prime_fd_to_handle_ioctl+0x2c/0x40
[ 184.465190] drm_ioctl_kernel+0xc4/0x174
[ 184.469123] drm_ioctl+0x204/0x420
[ 184.472534] __arm64_sys_ioctl+0xac/0xf0
[ 184.476474] invoke_syscall+0x48/0x114
[ 184.480240] el0_svc_common.constprop.0+0x44/0xec
[ 184.484956] do_el0_svc+0x2c/0xc0
[ 184.488283] el0_svc+0x2c/0x84
[ 184.491354] el0t_64_sync_handler+0x11c/0x150
[ 184.495723] el0t_64_sync+0x18c/0x190
[ 184.499397] ---[ end trace 0000000000000000 ]---
Fix that by setting DMA mask and segment size.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20220620181333.650301-1-jernej.skrabec@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/sun4i/sun4i_drv.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 6a9ba8a77c77..7ee1e53eb919 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -7,6 +7,7 @@
*/
#include <linux/component.h>
+#include <linux/dma-mapping.h>
#include <linux/kfifo.h>
#include <linux/module.h>
#include <linux/of_graph.h>
@@ -367,6 +368,13 @@ static int sun4i_drv_probe(struct platform_device *pdev)
INIT_KFIFO(list.fifo);
+ /*
+ * DE2 and DE3 cores actually supports 40-bit addresses, but
+ * driver does not.
+ */
+ dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ dma_set_max_seg_size(&pdev->dev, UINT_MAX);
+
for (i = 0;; i++) {
struct device_node *pipeline = of_parse_phandle(np,
"allwinner,pipelines",
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 48/53] drm/sun4i: Return if frontend is not present
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (45 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 47/53] drm/sun4i: Add DMA mask and segment size Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 49/53] hinic: Replace memcpy() with direct assignment Sasha Levin
` (3 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Saud Farooqui, Maxime Ripard, Sasha Levin, mripard, wens, airlied,
daniel, jernej.skrabec, samuel, dri-devel, linux-arm-kernel,
linux-sunxi
From: Saud Farooqui <farooqui_saud@hotmail.com>
[ Upstream commit 85016f66af8506cb601fd4f4fde23ed327a266be ]
Added return statement in sun4i_layer_format_mod_supported()
in case frontend is not present.
Signed-off-by: Saud Farooqui <farooqui_saud@hotmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/PA4P189MB1421E93EF5F8E8E00E71B7878BB29@PA4P189MB1421.EURP189.PROD.OUTLOOK.COM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/sun4i/sun4i_layer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index 6d43080791a0..85fb9e800ddf 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -117,7 +117,7 @@ static bool sun4i_layer_format_mod_supported(struct drm_plane *plane,
struct sun4i_layer *layer = plane_to_sun4i_layer(plane);
if (IS_ERR_OR_NULL(layer->backend->frontend))
- sun4i_backend_format_is_supported(format, modifier);
+ return sun4i_backend_format_is_supported(format, modifier);
return sun4i_backend_format_is_supported(format, modifier) ||
sun4i_frontend_format_is_supported(format, modifier);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 49/53] hinic: Replace memcpy() with direct assignment
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (46 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 48/53] drm/sun4i: Return if frontend is not present Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 50/53] drm/amdgpu: Adjust logic around GTT size (v3) Sasha Levin
` (2 subsequent siblings)
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Kees Cook, Nick Desaulniers, Tom Rix, llvm, Gustavo A . R . Silva,
Nathan Chancellor, Jakub Kicinski, Sasha Levin, davem, edumazet,
pabeni, leon, jiri, netdev
From: Kees Cook <keescook@chromium.org>
[ Upstream commit 1e70212e031528918066a631c9fdccda93a1ffaa ]
Under CONFIG_FORTIFY_SOURCE=y and CONFIG_UBSAN_BOUNDS=y, Clang is bugged
here for calculating the size of the destination buffer (0x10 instead of
0x14). This copy is a fixed size (sizeof(struct fw_section_info_st)), with
the source and dest being struct fw_section_info_st, so the memcpy should
be safe, assuming the index is within bounds, which is UBSAN_BOUNDS's
responsibility to figure out.
Avoid the whole thing and just do a direct assignment. This results in
no change to the executable code.
[This is a duplicate of commit 2c0ab32b73cf ("hinic: Replace memcpy()
with direct assignment") which was applied to net-next.]
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Tom Rix <trix@redhat.com>
Cc: llvm@lists.linux.dev
Link: https://github.com/ClangBuiltLinux/linux/issues/1592
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build
Link: https://lore.kernel.org/r/20220616052312.292861-1-keescook@chromium.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/huawei/hinic/hinic_devlink.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
index 60ae8bfc5f69..1749d26f4bef 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
@@ -43,9 +43,7 @@ static bool check_image_valid(struct hinic_devlink_priv *priv, const u8 *buf,
for (i = 0; i < fw_image->fw_info.fw_section_cnt; i++) {
len += fw_image->fw_section_info[i].fw_section_len;
- memcpy(&host_image->image_section_info[i],
- &fw_image->fw_section_info[i],
- sizeof(struct fw_section_info_st));
+ host_image->image_section_info[i] = fw_image->fw_section_info[i];
}
if (len != fw_image->fw_len ||
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 50/53] drm/amdgpu: Adjust logic around GTT size (v3)
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (47 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 49/53] hinic: Replace memcpy() with direct assignment Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 51/53] nvme: add a bogus subsystem NQN quirk for Micron MTFDKBA2T0TFH Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 52/53] gpio: grgpio: Fix device removing Sasha Levin
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Alex Deucher, Marek Olšák, Sasha Levin,
christian.koenig, Xinhui.Pan, airlied, daniel, Felix.Kuehling,
nirmoy.das, jonathan.kim, matthew.auld, kevin1.wang, zackr,
amd-gfx, dri-devel
From: Alex Deucher <alexander.deucher@amd.com>
[ Upstream commit f15345a377c6ea9c7cc74f079616af8856aff37f ]
Certain GL unit tests for large textures can cause problems
with the OOM killer since there is no way to link this memory
to a process. This was originally mitigated (but not necessarily
eliminated) by limiting the GTT size. The problem is this limit
is often too low for many modern games so just make the limit 1/2
of system memory. The OOM accounting needs to be addressed, but
we shouldn't prevent common 3D applications from being usable
just to potentially mitigate that corner case.
Set default GTT size to max(3G, 1/2 of system ram) by default.
v2: drop previous logic and default to 3/4 of ram
v3: default to half of ram to align with ttm
v4: fix spelling in comment (Kent)
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1942
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 4b9ee6e27f74..ef3ada98bdb6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1798,18 +1798,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
(unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
- /* Compute GTT size, either bsaed on 3/4th the size of RAM size
+ /* Compute GTT size, either based on 1/2 the size of RAM size
* or whatever the user passed on module init */
if (amdgpu_gtt_size == -1) {
struct sysinfo si;
si_meminfo(&si);
- gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
- adev->gmc.mc_vram_size),
- ((uint64_t)si.totalram * si.mem_unit * 3/4));
- }
- else
+ /* Certain GL unit tests for large textures can cause problems
+ * with the OOM killer since there is no way to link this memory
+ * to a process. This was originally mitigated (but not necessarily
+ * eliminated) by limiting the GTT size. The problem is this limit
+ * is often too low for many modern games so just make the limit 1/2
+ * of system memory which aligns with TTM. The OOM accounting needs
+ * to be addressed, but we shouldn't prevent common 3D applications
+ * from being usable just to potentially mitigate that corner case.
+ */
+ gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
+ (u64)si.totalram * si.mem_unit / 2);
+ } else {
gtt_size = (uint64_t)amdgpu_gtt_size << 20;
+ }
/* Initialize GTT memory pool */
r = amdgpu_gtt_mgr_init(adev, gtt_size);
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 51/53] nvme: add a bogus subsystem NQN quirk for Micron MTFDKBA2T0TFH
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (48 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 50/53] drm/amdgpu: Adjust logic around GTT size (v3) Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 52/53] gpio: grgpio: Fix device removing Sasha Levin
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Leo Savernik, Keith Busch, Christoph Hellwig, Sasha Levin, axboe,
sagi, linux-nvme
From: Leo Savernik <l.savernik@aon.at>
[ Upstream commit 41f38043f884c66af4114a7109cf540d6222f450 ]
The Micron MTFDKBA2T0TFH device reports the same subsysem NQN for
all devices. Add a quick to ignore it.
Signed-off-by: Leo Savernik <l.savernik@aon.at>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nvme/host/pci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 17aeb7d5c485..e69d0135d74e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3441,6 +3441,8 @@ static const struct pci_device_id nvme_id_table[] = {
{ PCI_DEVICE(0x1cc1, 0x8201), /* ADATA SX8200PNP 512GB */
.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+ { PCI_DEVICE(0x1344, 0x5407), /* Micron Technology Inc NVMe SSD */
+ .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN },
{ PCI_DEVICE(0x1c5c, 0x1504), /* SK Hynix PC400 */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x15b7, 0x2001), /* Sandisk Skyhawk */
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread* [PATCH AUTOSEL 5.18 52/53] gpio: grgpio: Fix device removing
2022-06-28 2:17 [PATCH AUTOSEL 5.18 01/53] spi: spi-cadence: Fix SPI CS gets toggling sporadically Sasha Levin
` (49 preceding siblings ...)
2022-06-28 2:18 ` [PATCH AUTOSEL 5.18 51/53] nvme: add a bogus subsystem NQN quirk for Micron MTFDKBA2T0TFH Sasha Levin
@ 2022-06-28 2:18 ` Sasha Levin
50 siblings, 0 replies; 54+ messages in thread
From: Sasha Levin @ 2022-06-28 2:18 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Uwe Kleine-König, Andy Shevchenko, Bartosz Golaszewski,
Sasha Levin, linus.walleij, linux-gpio
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[ Upstream commit c1c2a15c2b5379ea8e44dcdcc298e3de42076ba0 ]
If a platform device's remove callback returns non-zero, the device core
emits a warning and still removes the device and calls the devm cleanup
callbacks.
So it's not save to not unregister the gpiochip because on the next request
to a GPIO the driver accesses kfree()'d memory. Also if an IRQ triggers,
the freed memory is accessed.
Instead rely on the GPIO framework to ensure that after gpiochip_remove()
all GPIOs are freed and so the corresponding IRQs are unmapped.
This is a preparation for making platform remove callbacks return void.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-grgpio.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c
index 23d447e17a67..6ad0466828f4 100644
--- a/drivers/gpio/gpio-grgpio.c
+++ b/drivers/gpio/gpio-grgpio.c
@@ -434,25 +434,13 @@ static int grgpio_probe(struct platform_device *ofdev)
static int grgpio_remove(struct platform_device *ofdev)
{
struct grgpio_priv *priv = platform_get_drvdata(ofdev);
- int i;
- int ret = 0;
-
- if (priv->domain) {
- for (i = 0; i < GRGPIO_MAX_NGPIO; i++) {
- if (priv->uirqs[i].refcnt != 0) {
- ret = -EBUSY;
- goto out;
- }
- }
- }
gpiochip_remove(&priv->gc);
if (priv->domain)
irq_domain_remove(priv->domain);
-out:
- return ret;
+ return 0;
}
static const struct of_device_id grgpio_match[] = {
--
2.35.1
^ permalink raw reply related [flat|nested] 54+ messages in thread