From da406a12ac5a0660d0b0c524d9ab3c84a116d184 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 19 Jun 2024 08:25:03 -0400 Subject: [PATCH] Fixes for 6.6 Signed-off-by: Sasha Levin --- ...perty-implement-device_is_big_endian.patch | 73 +++++++ ...-functionality-flags-of-the-slave-on.patch | 44 ++++ ...ix-the-functionality-flags-of-the-sl.patch | 46 ++++ ...ci1xxxx-fix-a-memory-leak-in-the-err.patch | 45 ++++ ...on-t-use-struct-dw8250_data-outside-.patch | 109 ++++++++++ ...replace-acpi-device-check-by-a-quirk.patch | 117 ++++++++++ ...witch-to-use-uart_read_port_properti.patch | 156 ++++++++++++++ ...upio_unknown-constant-for-unknown-po.patch | 39 ++++ ...oduce-a-common-helper-to-read-proper.patch | 202 ++++++++++++++++++ queue-6.6/series | 11 + ...da-check-whether-the-media-is-initia.patch | 61 ++++++ ...sses-clear-tif_notify_signal-along-w.patch | 61 ++++++ 12 files changed, 964 insertions(+) create mode 100644 queue-6.6/device-property-implement-device_is_big_endian.patch create mode 100644 queue-6.6/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch create mode 100644 queue-6.6/i2c-designware-fix-the-functionality-flags-of-the-sl.patch create mode 100644 queue-6.6/misc-microchip-pci1xxxx-fix-a-memory-leak-in-the-err.patch create mode 100644 queue-6.6/serial-8250_dw-don-t-use-struct-dw8250_data-outside-.patch create mode 100644 queue-6.6/serial-8250_dw-replace-acpi-device-check-by-a-quirk.patch create mode 100644 queue-6.6/serial-8250_dw-switch-to-use-uart_read_port_properti.patch create mode 100644 queue-6.6/serial-core-add-upio_unknown-constant-for-unknown-po.patch create mode 100644 queue-6.6/serial-port-introduce-a-common-helper-to-read-proper.patch create mode 100644 queue-6.6/usb-storage-alauda-check-whether-the-media-is-initia.patch create mode 100644 queue-6.6/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch diff --git a/queue-6.6/device-property-implement-device_is_big_endian.patch b/queue-6.6/device-property-implement-device_is_big_endian.patch new file mode 100644 index 00000000000..b8a9c3d1ad4 --- /dev/null +++ b/queue-6.6/device-property-implement-device_is_big_endian.patch @@ -0,0 +1,73 @@ +From 054093291f155c8cda93e2d2b693936ba2673774 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 25 Oct 2023 21:42:57 +0300 +Subject: device property: Implement device_is_big_endian() + +From: Andy Shevchenko + +[ Upstream commit 826a5d8c9df9605fb4fdefa45432f95580241a1f ] + +Some users want to use the struct device pointer to see if the +device is big endian in terms of Open Firmware specifications, +i.e. if it has a "big-endian" property, or if the kernel was +compiled for BE *and* the device has a "native-endian" property. + +Provide inline helper for the users. + +Signed-off-by: Andy Shevchenko +Acked-by: Greg Kroah-Hartman +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20231025184259.250588-2-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 87d80bfbd577 ("serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw") +Signed-off-by: Sasha Levin +--- + include/linux/property.h | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/include/linux/property.h b/include/linux/property.h +index 8c3c6685a2ae3..1684fca930f72 100644 +--- a/include/linux/property.h ++++ b/include/linux/property.h +@@ -79,12 +79,38 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode, + + bool fwnode_device_is_available(const struct fwnode_handle *fwnode); + ++static inline bool fwnode_device_is_big_endian(const struct fwnode_handle *fwnode) ++{ ++ if (fwnode_property_present(fwnode, "big-endian")) ++ return true; ++ if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && ++ fwnode_property_present(fwnode, "native-endian")) ++ return true; ++ return false; ++} ++ + static inline + bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char *compat) + { + return fwnode_property_match_string(fwnode, "compatible", compat) >= 0; + } + ++/** ++ * device_is_big_endian - check if a device has BE registers ++ * @dev: Pointer to the struct device ++ * ++ * Returns: true if the device has a "big-endian" property, or if the kernel ++ * was compiled for BE *and* the device has a "native-endian" property. ++ * Returns false otherwise. ++ * ++ * Callers would nominally use ioread32be/iowrite32be if ++ * device_is_big_endian() == true, or readl/writel otherwise. ++ */ ++static inline bool device_is_big_endian(const struct device *dev) ++{ ++ return fwnode_device_is_big_endian(dev_fwnode(dev)); ++} ++ + /** + * device_is_compatible - match 'compatible' property of the device with a given string + * @dev: Pointer to the struct device +-- +2.43.0 + diff --git a/queue-6.6/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch b/queue-6.6/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch new file mode 100644 index 00000000000..965786b5882 --- /dev/null +++ b/queue-6.6/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch @@ -0,0 +1,44 @@ +From 5268381277c44997ca840f255b132d2f044dd561 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 May 2024 11:19:14 +0200 +Subject: i2c: at91: Fix the functionality flags of the slave-only interface + +From: Jean Delvare + +[ Upstream commit d6d5645e5fc1233a7ba950de4a72981c394a2557 ] + +When an I2C adapter acts only as a slave, it should not claim to +support I2C master capabilities. + +Fixes: 9d3ca54b550c ("i2c: at91: added slave mode support") +Signed-off-by: Jean Delvare +Cc: Juergen Fitschen +Cc: Ludovic Desroches +Cc: Codrin Ciubotariu +Cc: Andi Shyti +Cc: Nicolas Ferre +Cc: Alexandre Belloni +Cc: Claudiu Beznea +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-at91-slave.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-at91-slave.c b/drivers/i2c/busses/i2c-at91-slave.c +index d6eeea5166c04..131a67d9d4a68 100644 +--- a/drivers/i2c/busses/i2c-at91-slave.c ++++ b/drivers/i2c/busses/i2c-at91-slave.c +@@ -106,8 +106,7 @@ static int at91_unreg_slave(struct i2c_client *slave) + + static u32 at91_twi_func(struct i2c_adapter *adapter) + { +- return I2C_FUNC_SLAVE | I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL +- | I2C_FUNC_SMBUS_READ_BLOCK_DATA; ++ return I2C_FUNC_SLAVE; + } + + static const struct i2c_algorithm at91_twi_algorithm_slave = { +-- +2.43.0 + diff --git a/queue-6.6/i2c-designware-fix-the-functionality-flags-of-the-sl.patch b/queue-6.6/i2c-designware-fix-the-functionality-flags-of-the-sl.patch new file mode 100644 index 00000000000..13d1b515609 --- /dev/null +++ b/queue-6.6/i2c-designware-fix-the-functionality-flags-of-the-sl.patch @@ -0,0 +1,46 @@ +From 52a0bfd02897ab7550ce7b307a7343785d968a4c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 May 2024 11:17:48 +0200 +Subject: i2c: designware: Fix the functionality flags of the slave-only + interface + +From: Jean Delvare + +[ Upstream commit cbf3fb5b29e99e3689d63a88c3cddbffa1b8de99 ] + +When an I2C adapter acts only as a slave, it should not claim to +support I2C master capabilities. + +Fixes: 5b6d721b266a ("i2c: designware: enable SLAVE in platform module") +Signed-off-by: Jean Delvare +Cc: Luis Oliveira +Cc: Jarkko Nikula +Cc: Andy Shevchenko +Cc: Mika Westerberg +Cc: Jan Dabros +Cc: Andi Shyti +Reviewed-by: Andy Shevchenko +Acked-by: Jarkko Nikula +Tested-by: Jarkko Nikula +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-designware-slave.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c +index 2e079cf20bb5b..78e2c47e3d7da 100644 +--- a/drivers/i2c/busses/i2c-designware-slave.c ++++ b/drivers/i2c/busses/i2c-designware-slave.c +@@ -220,7 +220,7 @@ static const struct i2c_algorithm i2c_dw_algo = { + + void i2c_dw_configure_slave(struct dw_i2c_dev *dev) + { +- dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY; ++ dev->functionality = I2C_FUNC_SLAVE; + + dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL | + DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED; +-- +2.43.0 + diff --git a/queue-6.6/misc-microchip-pci1xxxx-fix-a-memory-leak-in-the-err.patch b/queue-6.6/misc-microchip-pci1xxxx-fix-a-memory-leak-in-the-err.patch new file mode 100644 index 00000000000..9935ff603de --- /dev/null +++ b/queue-6.6/misc-microchip-pci1xxxx-fix-a-memory-leak-in-the-err.patch @@ -0,0 +1,45 @@ +From 3333ccdde759f5aefda0b13c05545815cc1d2c93 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 23 May 2024 20:14:34 +0800 +Subject: misc: microchip: pci1xxxx: Fix a memory leak in the error handling of + gp_aux_bus_probe() + +From: Yongzhi Liu + +[ Upstream commit 77427e3d5c353e3dd98c7c0af322f8d9e3131ace ] + +There is a memory leak (forget to free allocated buffers) in a +memory allocation failure path. + +Fix it to jump to the correct error handling code. + +Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.") +Signed-off-by: Yongzhi Liu +Reviewed-by: Kumaravel Thiagarajan +Link: https://lore.kernel.org/r/20240523121434.21855-4-hyperlyzcs@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c +index de75d89ef53e8..34c9be437432a 100644 +--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c ++++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c +@@ -69,8 +69,10 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id + + aux_bus->aux_device_wrapper[1] = kzalloc(sizeof(*aux_bus->aux_device_wrapper[1]), + GFP_KERNEL); +- if (!aux_bus->aux_device_wrapper[1]) +- return -ENOMEM; ++ if (!aux_bus->aux_device_wrapper[1]) { ++ retval = -ENOMEM; ++ goto err_aux_dev_add_0; ++ } + + retval = ida_alloc(&gp_client_ida, GFP_KERNEL); + if (retval < 0) +-- +2.43.0 + diff --git a/queue-6.6/serial-8250_dw-don-t-use-struct-dw8250_data-outside-.patch b/queue-6.6/serial-8250_dw-don-t-use-struct-dw8250_data-outside-.patch new file mode 100644 index 00000000000..7b0ecd6772c --- /dev/null +++ b/queue-6.6/serial-8250_dw-don-t-use-struct-dw8250_data-outside-.patch @@ -0,0 +1,109 @@ +From c8fa9c7692a519f42a0f2badd035c1fe932b5c61 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 May 2024 22:05:53 +0300 +Subject: serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw + +From: Andy Shevchenko + +[ Upstream commit 87d80bfbd577912462061b1a45c0ed9c7fcb872f ] + +The container of the struct dw8250_port_data is private to the actual +driver. In particular, 8250_lpss and 8250_dw use different data types +that are assigned to the UART port private_data. Hence, it must not +be used outside the specific driver. + +Currently the only cpr_val is required by the common code, make it +be available via struct dw8250_port_data. + +This fixes the UART breakage on Intel Galileo boards. + +Fixes: 593dea000bc1 ("serial: 8250: dw: Allow to use a fallback CPR value if not synthesized") +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20240514190730.2787071-2-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/8250/8250_dw.c | 9 +++++++-- + drivers/tty/serial/8250/8250_dwlib.c | 3 +-- + drivers/tty/serial/8250/8250_dwlib.h | 3 ++- + 3 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c +index a7659e536d3c0..777bea835b114 100644 +--- a/drivers/tty/serial/8250/8250_dw.c ++++ b/drivers/tty/serial/8250/8250_dw.c +@@ -55,6 +55,7 @@ + #define DW_UART_QUIRK_SKIP_SET_RATE BIT(2) + #define DW_UART_QUIRK_IS_DMA_FC BIT(3) + #define DW_UART_QUIRK_APMC0D08 BIT(4) ++#define DW_UART_QUIRK_CPR_VALUE BIT(5) + + static inline struct dw8250_data *clk_to_dw8250_data(struct notifier_block *nb) + { +@@ -445,6 +446,10 @@ static void dw8250_prepare_rx_dma(struct uart_8250_port *p) + static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) + { + unsigned int quirks = data->pdata ? data->pdata->quirks : 0; ++ u32 cpr_value = data->pdata ? data->pdata->cpr_value : 0; ++ ++ if (quirks & DW_UART_QUIRK_CPR_VALUE) ++ data->data.cpr_value = cpr_value; + + #ifdef CONFIG_64BIT + if (quirks & DW_UART_QUIRK_OCTEON) { +@@ -749,8 +754,8 @@ static const struct dw8250_platform_data dw8250_armada_38x_data = { + + static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { + .usr_reg = DW_UART_USR, +- .cpr_val = 0x00012f32, +- .quirks = DW_UART_QUIRK_IS_DMA_FC, ++ .cpr_value = 0x00012f32, ++ .quirks = DW_UART_QUIRK_CPR_VALUE | DW_UART_QUIRK_IS_DMA_FC, + }; + + static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { +diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c +index 84843e204a5e8..8fc8b6753148b 100644 +--- a/drivers/tty/serial/8250/8250_dwlib.c ++++ b/drivers/tty/serial/8250/8250_dwlib.c +@@ -242,7 +242,6 @@ static const struct serial_rs485 dw8250_rs485_supported = { + void dw8250_setup_port(struct uart_port *p) + { + struct dw8250_port_data *pd = p->private_data; +- struct dw8250_data *data = to_dw8250_data(pd); + struct uart_8250_port *up = up_to_u8250p(p); + u32 reg, old_dlf; + +@@ -284,7 +283,7 @@ void dw8250_setup_port(struct uart_port *p) + + reg = dw8250_readl_ext(p, DW_UART_CPR); + if (!reg) { +- reg = data->pdata->cpr_val; ++ reg = pd->cpr_value; + dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg); + } + if (!reg) +diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h +index f13e91f2cace9..794a9014cdac1 100644 +--- a/drivers/tty/serial/8250/8250_dwlib.h ++++ b/drivers/tty/serial/8250/8250_dwlib.h +@@ -19,6 +19,7 @@ struct dw8250_port_data { + struct uart_8250_dma dma; + + /* Hardware configuration */ ++ u32 cpr_value; + u8 dlf_size; + + /* RS485 variables */ +@@ -27,7 +28,7 @@ struct dw8250_port_data { + + struct dw8250_platform_data { + u8 usr_reg; +- u32 cpr_val; ++ u32 cpr_value; + unsigned int quirks; + }; + +-- +2.43.0 + diff --git a/queue-6.6/serial-8250_dw-replace-acpi-device-check-by-a-quirk.patch b/queue-6.6/serial-8250_dw-replace-acpi-device-check-by-a-quirk.patch new file mode 100644 index 00000000000..3c3dca260e6 --- /dev/null +++ b/queue-6.6/serial-8250_dw-replace-acpi-device-check-by-a-quirk.patch @@ -0,0 +1,117 @@ +From 4eca43d9a67dd458e1cdd04bdbeea35bedccee93 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Mar 2024 16:33:22 +0200 +Subject: serial: 8250_dw: Replace ACPI device check by a quirk + +From: Andy Shevchenko + +[ Upstream commit 173b097dcc8d74d6e135aed1bad38dbfa21c4d04 ] + +Instead of checking for APMC0D08 ACPI device presence, +use a quirk based on driver data. + +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20240306143322.3291123-1-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 87d80bfbd577 ("serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/8250/8250_dw.c | 51 ++++++++++++++++--------------- + 1 file changed, 26 insertions(+), 25 deletions(-) + +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c +index 0446ac145cd4a..a7659e536d3c0 100644 +--- a/drivers/tty/serial/8250/8250_dw.c ++++ b/drivers/tty/serial/8250/8250_dw.c +@@ -9,7 +9,6 @@ + * LCR is written whilst busy. If it is, then a busy detect interrupt is + * raised, the LCR needs to be rewritten and the uart status register read. + */ +-#include + #include + #include + #include +@@ -55,6 +54,7 @@ + #define DW_UART_QUIRK_ARMADA_38X BIT(1) + #define DW_UART_QUIRK_SKIP_SET_RATE BIT(2) + #define DW_UART_QUIRK_IS_DMA_FC BIT(3) ++#define DW_UART_QUIRK_APMC0D08 BIT(4) + + static inline struct dw8250_data *clk_to_dw8250_data(struct notifier_block *nb) + { +@@ -444,33 +444,29 @@ static void dw8250_prepare_rx_dma(struct uart_8250_port *p) + + static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) + { +- struct device_node *np = p->dev->of_node; +- +- if (np) { +- unsigned int quirks = data->pdata->quirks; ++ unsigned int quirks = data->pdata ? data->pdata->quirks : 0; + + #ifdef CONFIG_64BIT +- if (quirks & DW_UART_QUIRK_OCTEON) { +- p->serial_in = dw8250_serial_inq; +- p->serial_out = dw8250_serial_outq; +- p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; +- p->type = PORT_OCTEON; +- data->skip_autocfg = true; +- } ++ if (quirks & DW_UART_QUIRK_OCTEON) { ++ p->serial_in = dw8250_serial_inq; ++ p->serial_out = dw8250_serial_outq; ++ p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; ++ p->type = PORT_OCTEON; ++ data->skip_autocfg = true; ++ } + #endif + +- if (quirks & DW_UART_QUIRK_ARMADA_38X) +- p->serial_out = dw8250_serial_out38x; +- if (quirks & DW_UART_QUIRK_SKIP_SET_RATE) +- p->set_termios = dw8250_do_set_termios; +- if (quirks & DW_UART_QUIRK_IS_DMA_FC) { +- data->data.dma.txconf.device_fc = 1; +- data->data.dma.rxconf.device_fc = 1; +- data->data.dma.prepare_tx_dma = dw8250_prepare_tx_dma; +- data->data.dma.prepare_rx_dma = dw8250_prepare_rx_dma; +- } +- +- } else if (acpi_dev_present("APMC0D08", NULL, -1)) { ++ if (quirks & DW_UART_QUIRK_ARMADA_38X) ++ p->serial_out = dw8250_serial_out38x; ++ if (quirks & DW_UART_QUIRK_SKIP_SET_RATE) ++ p->set_termios = dw8250_do_set_termios; ++ if (quirks & DW_UART_QUIRK_IS_DMA_FC) { ++ data->data.dma.txconf.device_fc = 1; ++ data->data.dma.rxconf.device_fc = 1; ++ data->data.dma.prepare_tx_dma = dw8250_prepare_tx_dma; ++ data->data.dma.prepare_rx_dma = dw8250_prepare_rx_dma; ++ } ++ if (quirks & DW_UART_QUIRK_APMC0D08) { + p->iotype = UPIO_MEM32; + p->regshift = 2; + p->serial_in = dw8250_serial_in32; +@@ -772,13 +768,18 @@ static const struct of_device_id dw8250_of_match[] = { + }; + MODULE_DEVICE_TABLE(of, dw8250_of_match); + ++static const struct dw8250_platform_data dw8250_apmc0d08 = { ++ .usr_reg = DW_UART_USR, ++ .quirks = DW_UART_QUIRK_APMC0D08, ++}; ++ + static const struct acpi_device_id dw8250_acpi_match[] = { + { "80860F0A", (kernel_ulong_t)&dw8250_dw_apb }, + { "8086228A", (kernel_ulong_t)&dw8250_dw_apb }, + { "AMD0020", (kernel_ulong_t)&dw8250_dw_apb }, + { "AMDI0020", (kernel_ulong_t)&dw8250_dw_apb }, + { "AMDI0022", (kernel_ulong_t)&dw8250_dw_apb }, +- { "APMC0D08", (kernel_ulong_t)&dw8250_dw_apb}, ++ { "APMC0D08", (kernel_ulong_t)&dw8250_apmc0d08 }, + { "BRCM2032", (kernel_ulong_t)&dw8250_dw_apb }, + { "HISI0031", (kernel_ulong_t)&dw8250_dw_apb }, + { "INT33C4", (kernel_ulong_t)&dw8250_dw_apb }, +-- +2.43.0 + diff --git a/queue-6.6/serial-8250_dw-switch-to-use-uart_read_port_properti.patch b/queue-6.6/serial-8250_dw-switch-to-use-uart_read_port_properti.patch new file mode 100644 index 00000000000..b2993c2ae4f --- /dev/null +++ b/queue-6.6/serial-8250_dw-switch-to-use-uart_read_port_properti.patch @@ -0,0 +1,156 @@ +From 4c66cc73a48bad8e5a0f82474161382fb7901490 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Mar 2024 14:27:08 +0200 +Subject: serial: 8250_dw: Switch to use uart_read_port_properties() + +From: Andy Shevchenko + +[ Upstream commit e6a46d073e11baba785245860c9f51adbbb8b68d ] + +Since we have now a common helper to read port properties +use it instead of sparse home grown solution. + +Reviewed-by: Andi Shyti +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20240304123035.758700-8-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 87d80bfbd577 ("serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/8250/8250_dw.c | 67 +++++++++++++------------------ + 1 file changed, 27 insertions(+), 40 deletions(-) + +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c +index a1f2259cc9a98..0446ac145cd4a 100644 +--- a/drivers/tty/serial/8250/8250_dw.c ++++ b/drivers/tty/serial/8250/8250_dw.c +@@ -17,7 +17,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -449,12 +448,7 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) + + if (np) { + unsigned int quirks = data->pdata->quirks; +- int id; + +- /* get index of serial line, if found in DT aliases */ +- id = of_alias_get_id(np, "serial"); +- if (id >= 0) +- p->line = id; + #ifdef CONFIG_64BIT + if (quirks & DW_UART_QUIRK_OCTEON) { + p->serial_in = dw8250_serial_inq; +@@ -465,12 +459,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) + } + #endif + +- if (of_device_is_big_endian(np)) { +- p->iotype = UPIO_MEM32BE; +- p->serial_in = dw8250_serial_in32be; +- p->serial_out = dw8250_serial_out32be; +- } +- + if (quirks & DW_UART_QUIRK_ARMADA_38X) + p->serial_out = dw8250_serial_out38x; + if (quirks & DW_UART_QUIRK_SKIP_SET_RATE) +@@ -515,39 +503,21 @@ static int dw8250_probe(struct platform_device *pdev) + struct device *dev = &pdev->dev; + struct dw8250_data *data; + struct resource *regs; +- int irq; + int err; +- u32 val; + + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!regs) + return dev_err_probe(dev, -EINVAL, "no registers defined\n"); + +- irq = platform_get_irq_optional(pdev, 0); +- /* no interrupt -> fall back to polling */ +- if (irq == -ENXIO) +- irq = 0; +- if (irq < 0) +- return irq; +- + spin_lock_init(&p->lock); +- p->mapbase = regs->start; +- p->irq = irq; + p->handle_irq = dw8250_handle_irq; + p->pm = dw8250_do_pm; + p->type = PORT_8250; +- p->flags = UPF_SHARE_IRQ | UPF_FIXED_PORT; ++ p->flags = UPF_FIXED_PORT; + p->dev = dev; +- p->iotype = UPIO_MEM; +- p->serial_in = dw8250_serial_in; +- p->serial_out = dw8250_serial_out; + p->set_ldisc = dw8250_set_ldisc; + p->set_termios = dw8250_set_termios; + +- p->membase = devm_ioremap(dev, regs->start, resource_size(regs)); +- if (!p->membase) +- return -ENOMEM; +- + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; +@@ -559,15 +529,35 @@ static int dw8250_probe(struct platform_device *pdev) + data->uart_16550_compatible = device_property_read_bool(dev, + "snps,uart-16550-compatible"); + +- err = device_property_read_u32(dev, "reg-shift", &val); +- if (!err) +- p->regshift = val; ++ p->mapbase = regs->start; ++ p->mapsize = resource_size(regs); + +- err = device_property_read_u32(dev, "reg-io-width", &val); +- if (!err && val == 4) { +- p->iotype = UPIO_MEM32; ++ p->membase = devm_ioremap(dev, p->mapbase, p->mapsize); ++ if (!p->membase) ++ return -ENOMEM; ++ ++ err = uart_read_port_properties(p); ++ /* no interrupt -> fall back to polling */ ++ if (err == -ENXIO) ++ err = 0; ++ if (err) ++ return err; ++ ++ switch (p->iotype) { ++ case UPIO_MEM: ++ p->serial_in = dw8250_serial_in; ++ p->serial_out = dw8250_serial_out; ++ break; ++ case UPIO_MEM32: + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; ++ break; ++ case UPIO_MEM32BE: ++ p->serial_in = dw8250_serial_in32be; ++ p->serial_out = dw8250_serial_out32be; ++ break; ++ default: ++ return -ENODEV; + } + + if (device_property_read_bool(dev, "dcd-override")) { +@@ -594,9 +584,6 @@ static int dw8250_probe(struct platform_device *pdev) + data->msr_mask_off |= UART_MSR_TERI; + } + +- /* Always ask for fixed clock rate from a property. */ +- device_property_read_u32(dev, "clock-frequency", &p->uartclk); +- + /* If there is separate baudclk, get the rate from it. */ + data->clk = devm_clk_get_optional(dev, "baudclk"); + if (data->clk == NULL) +-- +2.43.0 + diff --git a/queue-6.6/serial-core-add-upio_unknown-constant-for-unknown-po.patch b/queue-6.6/serial-core-add-upio_unknown-constant-for-unknown-po.patch new file mode 100644 index 00000000000..002c0b916f6 --- /dev/null +++ b/queue-6.6/serial-core-add-upio_unknown-constant-for-unknown-po.patch @@ -0,0 +1,39 @@ +From d58300a02239812314bef9013016398153a2c702 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Mar 2024 14:27:03 +0200 +Subject: serial: core: Add UPIO_UNKNOWN constant for unknown port type + +From: Andy Shevchenko + +[ Upstream commit 79d713baf63c8f23cc58b304c40be33d64a12aaf ] + +In some APIs we would like to assign the special value to iotype +and compare against it in another places. Introduce UPIO_UNKNOWN +for this purpose. + +Note, we can't use 0, because it's a valid value for IO port access. + +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20240304123035.758700-3-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 87d80bfbd577 ("serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw") +Signed-off-by: Sasha Levin +--- + include/linux/serial_core.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h +index a7d5fa892be26..412de73547521 100644 +--- a/include/linux/serial_core.h ++++ b/include/linux/serial_core.h +@@ -470,6 +470,7 @@ struct uart_port { + unsigned char iotype; /* io access style */ + unsigned char quirks; /* internal quirks */ + ++#define UPIO_UNKNOWN ((unsigned char)~0U) /* UCHAR_MAX */ + #define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */ + #define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */ + #define UPIO_MEM (SERIAL_IO_MEM) /* driver-specific */ +-- +2.43.0 + diff --git a/queue-6.6/serial-port-introduce-a-common-helper-to-read-proper.patch b/queue-6.6/serial-port-introduce-a-common-helper-to-read-proper.patch new file mode 100644 index 00000000000..045439208d3 --- /dev/null +++ b/queue-6.6/serial-port-introduce-a-common-helper-to-read-proper.patch @@ -0,0 +1,202 @@ +From 8c87d3224d9c3a9548b67d635397d6e96de3f984 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Mar 2024 14:27:04 +0200 +Subject: serial: port: Introduce a common helper to read properties + +From: Andy Shevchenko + +[ Upstream commit e894b6005dce0ed621b2788d6a249708fb6f95f9 ] + +Several serial drivers want to read the same or similar set of +the port properties. Make a common helper for them. + +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20240304123035.758700-4-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 87d80bfbd577 ("serial: 8250_dw: Don't use struct dw8250_data outside of 8250_dw") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/serial_port.c | 145 +++++++++++++++++++++++++++++++ + include/linux/serial_core.h | 2 + + 2 files changed, 147 insertions(+) + +diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c +index ed3953bd04073..469ad26cde487 100644 +--- a/drivers/tty/serial/serial_port.c ++++ b/drivers/tty/serial/serial_port.c +@@ -8,7 +8,10 @@ + + #include + #include ++#include ++#include + #include ++#include + #include + #include + +@@ -146,6 +149,148 @@ void uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) + } + EXPORT_SYMBOL(uart_remove_one_port); + ++/** ++ * __uart_read_properties - read firmware properties of the given UART port ++ * @port: corresponding port ++ * @use_defaults: apply defaults (when %true) or validate the values (when %false) ++ * ++ * The following device properties are supported: ++ * - clock-frequency (optional) ++ * - fifo-size (optional) ++ * - no-loopback-test (optional) ++ * - reg-shift (defaults may apply) ++ * - reg-offset (value may be validated) ++ * - reg-io-width (defaults may apply or value may be validated) ++ * - interrupts (OF only) ++ * - serial [alias ID] (OF only) ++ * ++ * If the port->dev is of struct platform_device type the interrupt line ++ * will be retrieved via platform_get_irq() call against that device. ++ * Otherwise it will be assigned by fwnode_irq_get() call. In both cases ++ * the index 0 of the resource is used. ++ * ++ * The caller is responsible to initialize the following fields of the @port ++ * ->dev (must be valid) ++ * ->flags ++ * ->mapbase ++ * ->mapsize ++ * ->regshift (if @use_defaults is false) ++ * before calling this function. Alternatively the above mentioned fields ++ * may be zeroed, in such case the only ones, that have associated properties ++ * found, will be set to the respective values. ++ * ++ * If no error happened, the ->irq, ->mapbase, ->mapsize will be altered. ++ * The ->iotype is always altered. ++ * ++ * When @use_defaults is true and the respective property is not found ++ * the following values will be applied: ++ * ->regshift = 0 ++ * In this case IRQ must be provided, otherwise an error will be returned. ++ * ++ * When @use_defaults is false and the respective property is found ++ * the following values will be validated: ++ * - reg-io-width (->iotype) ++ * - reg-offset (->mapsize against ->mapbase) ++ * ++ * Returns: 0 on success or negative errno on failure ++ */ ++static int __uart_read_properties(struct uart_port *port, bool use_defaults) ++{ ++ struct device *dev = port->dev; ++ u32 value; ++ int ret; ++ ++ /* Read optional UART functional clock frequency */ ++ device_property_read_u32(dev, "clock-frequency", &port->uartclk); ++ ++ /* Read the registers alignment (default: 8-bit) */ ++ ret = device_property_read_u32(dev, "reg-shift", &value); ++ if (ret) ++ port->regshift = use_defaults ? 0 : port->regshift; ++ else ++ port->regshift = value; ++ ++ /* Read the registers I/O access type (default: MMIO 8-bit) */ ++ ret = device_property_read_u32(dev, "reg-io-width", &value); ++ if (ret) { ++ port->iotype = UPIO_MEM; ++ } else { ++ switch (value) { ++ case 1: ++ port->iotype = UPIO_MEM; ++ break; ++ case 2: ++ port->iotype = UPIO_MEM16; ++ break; ++ case 4: ++ port->iotype = device_is_big_endian(dev) ? UPIO_MEM32BE : UPIO_MEM32; ++ break; ++ default: ++ if (!use_defaults) { ++ dev_err(dev, "Unsupported reg-io-width (%u)\n", value); ++ return -EINVAL; ++ } ++ port->iotype = UPIO_UNKNOWN; ++ break; ++ } ++ } ++ ++ /* Read the address mapping base offset (default: no offset) */ ++ ret = device_property_read_u32(dev, "reg-offset", &value); ++ if (ret) ++ value = 0; ++ ++ /* Check for shifted address mapping overflow */ ++ if (!use_defaults && port->mapsize < value) { ++ dev_err(dev, "reg-offset %u exceeds region size %pa\n", value, &port->mapsize); ++ return -EINVAL; ++ } ++ ++ port->mapbase += value; ++ port->mapsize -= value; ++ ++ /* Read optional FIFO size */ ++ device_property_read_u32(dev, "fifo-size", &port->fifosize); ++ ++ if (device_property_read_bool(dev, "no-loopback-test")) ++ port->flags |= UPF_SKIP_TEST; ++ ++ /* Get index of serial line, if found in DT aliases */ ++ ret = of_alias_get_id(dev_of_node(dev), "serial"); ++ if (ret >= 0) ++ port->line = ret; ++ ++ if (dev_is_platform(dev)) ++ ret = platform_get_irq(to_platform_device(dev), 0); ++ else ++ ret = fwnode_irq_get(dev_fwnode(dev), 0); ++ if (ret == -EPROBE_DEFER) ++ return ret; ++ if (ret > 0) ++ port->irq = ret; ++ else if (use_defaults) ++ /* By default IRQ support is mandatory */ ++ return ret; ++ else ++ port->irq = 0; ++ ++ port->flags |= UPF_SHARE_IRQ; ++ ++ return 0; ++} ++ ++int uart_read_port_properties(struct uart_port *port) ++{ ++ return __uart_read_properties(port, true); ++} ++EXPORT_SYMBOL_GPL(uart_read_port_properties); ++ ++int uart_read_and_validate_port_properties(struct uart_port *port) ++{ ++ return __uart_read_properties(port, false); ++} ++EXPORT_SYMBOL_GPL(uart_read_and_validate_port_properties); ++ + static struct device_driver serial_port_driver = { + .name = "port", + .suppress_bind_attrs = true, +diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h +index 412de73547521..5da5eb719f614 100644 +--- a/include/linux/serial_core.h ++++ b/include/linux/serial_core.h +@@ -961,6 +961,8 @@ int uart_register_driver(struct uart_driver *uart); + void uart_unregister_driver(struct uart_driver *uart); + int uart_add_one_port(struct uart_driver *reg, struct uart_port *port); + void uart_remove_one_port(struct uart_driver *reg, struct uart_port *port); ++int uart_read_port_properties(struct uart_port *port); ++int uart_read_and_validate_port_properties(struct uart_port *port); + bool uart_match_port(const struct uart_port *port1, + const struct uart_port *port2); + +-- +2.43.0 + diff --git a/queue-6.6/series b/queue-6.6/series index c7a47b2a3c5..73282cf511a 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -254,3 +254,14 @@ selftests-net-lib-support-errexit-with-busywait.patch selftests-net-lib-avoid-error-removing-empty-netns-name.patch greybus-fix-use-after-free-bug-in-gb_interface_release-due-to-race-condition.patch ima-fix-use-after-free-on-a-dentry-s-dname.name.patch +device-property-implement-device_is_big_endian.patch +serial-core-add-upio_unknown-constant-for-unknown-po.patch +serial-port-introduce-a-common-helper-to-read-proper.patch +serial-8250_dw-switch-to-use-uart_read_port_properti.patch +serial-8250_dw-replace-acpi-device-check-by-a-quirk.patch +serial-8250_dw-don-t-use-struct-dw8250_data-outside-.patch +usb-storage-alauda-check-whether-the-media-is-initia.patch +misc-microchip-pci1xxxx-fix-a-memory-leak-in-the-err.patch +i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch +i2c-designware-fix-the-functionality-flags-of-the-sl.patch +zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch diff --git a/queue-6.6/usb-storage-alauda-check-whether-the-media-is-initia.patch b/queue-6.6/usb-storage-alauda-check-whether-the-media-is-initia.patch new file mode 100644 index 00000000000..abfaadc9731 --- /dev/null +++ b/queue-6.6/usb-storage-alauda-check-whether-the-media-is-initia.patch @@ -0,0 +1,61 @@ +From 6bf2eed4c43f331233e8e0959e5c1ab762e0b18e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 26 May 2024 09:27:45 +0800 +Subject: usb-storage: alauda: Check whether the media is initialized + +From: Shichao Lai + +[ Upstream commit 16637fea001ab3c8df528a8995b3211906165a30 ] + +The member "uzonesize" of struct alauda_info will remain 0 +if alauda_init_media() fails, potentially causing divide errors +in alauda_read_data() and alauda_write_lba(). +- Add a member "media_initialized" to struct alauda_info. +- Change a condition in alauda_check_media() to ensure the + first initialization. +- Add an error check for the return value of alauda_init_media(). + +Fixes: e80b0fade09e ("[PATCH] USB Storage: add alauda support") +Reported-by: xingwei lee +Reported-by: yue sun +Reviewed-by: Alan Stern +Signed-off-by: Shichao Lai +Link: https://lore.kernel.org/r/20240526012745.2852061-1-shichaorai@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/storage/alauda.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c +index 115f05a6201a1..40d34cc28344a 100644 +--- a/drivers/usb/storage/alauda.c ++++ b/drivers/usb/storage/alauda.c +@@ -105,6 +105,8 @@ struct alauda_info { + unsigned char sense_key; + unsigned long sense_asc; /* additional sense code */ + unsigned long sense_ascq; /* additional sense code qualifier */ ++ ++ bool media_initialized; + }; + + #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) +@@ -476,11 +478,12 @@ static int alauda_check_media(struct us_data *us) + } + + /* Check for media change */ +- if (status[0] & 0x08) { ++ if (status[0] & 0x08 || !info->media_initialized) { + usb_stor_dbg(us, "Media change detected\n"); + alauda_free_maps(&MEDIA_INFO(us)); +- alauda_init_media(us); +- ++ rc = alauda_init_media(us); ++ if (rc == USB_STOR_TRANSPORT_GOOD) ++ info->media_initialized = true; + info->sense_key = UNIT_ATTENTION; + info->sense_asc = 0x28; + info->sense_ascq = 0x00; +-- +2.43.0 + diff --git a/queue-6.6/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch b/queue-6.6/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch new file mode 100644 index 00000000000..c408a63b4e7 --- /dev/null +++ b/queue-6.6/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch @@ -0,0 +1,61 @@ +From c9dd7e988ad243e29df8a2958f54adbb7bcc8620 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 8 Jun 2024 14:06:16 +0200 +Subject: zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with + TIF_SIGPENDING + +From: Oleg Nesterov + +[ Upstream commit 7fea700e04bd3f424c2d836e98425782f97b494e ] + +kernel_wait4() doesn't sleep and returns -EINTR if there is no +eligible child and signal_pending() is true. + +That is why zap_pid_ns_processes() clears TIF_SIGPENDING but this is not +enough, it should also clear TIF_NOTIFY_SIGNAL to make signal_pending() +return false and avoid a busy-wait loop. + +Link: https://lkml.kernel.org/r/20240608120616.GB7947@redhat.com +Fixes: 12db8b690010 ("entry: Add support for TIF_NOTIFY_SIGNAL") +Signed-off-by: Oleg Nesterov +Reported-by: Rachel Menge +Closes: https://lore.kernel.org/all/1386cd49-36d0-4a5c-85e9-bc42056a5a38@linux.microsoft.com/ +Reviewed-by: Boqun Feng +Tested-by: Wei Fu +Reviewed-by: Jens Axboe +Cc: Allen Pais +Cc: Christian Brauner +Cc: Frederic Weisbecker +Cc: Joel Fernandes (Google) +Cc: Joel Granados +Cc: Josh Triplett +Cc: Lai Jiangshan +Cc: Mateusz Guzik +Cc: Mathieu Desnoyers +Cc: Mike Christie +Cc: Neeraj Upadhyay +Cc: Paul E. McKenney +Cc: Steven Rostedt (Google) +Cc: Zqiang +Cc: Thomas Gleixner +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + kernel/pid_namespace.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c +index 619972c78774f..e9b2bb260ee6c 100644 +--- a/kernel/pid_namespace.c ++++ b/kernel/pid_namespace.c +@@ -217,6 +217,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) + */ + do { + clear_thread_flag(TIF_SIGPENDING); ++ clear_thread_flag(TIF_NOTIFY_SIGNAL); + rc = kernel_wait4(-1, NULL, __WALL, NULL); + } while (rc != -ECHILD); + +-- +2.43.0 + -- 2.47.3