--- /dev/null
+From 2ff503d029ae8bf8a58315ab1cea6b5d4145d87d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 8 Jul 2024 16:04:30 +0800
+Subject: dev/parport: fix the array out-of-bounds risk
+
+From: tuhaowen <tuhaowen@uniontech.com>
+
+[ Upstream commit ab11dac93d2d568d151b1918d7b84c2d02bacbd5 ]
+
+Fixed array out-of-bounds issues caused by sprintf
+by replacing it with snprintf for safer data copying,
+ensuring the destination buffer is not overflowed.
+
+Below is the stack trace I encountered during the actual issue:
+
+[ 66.575408s] [pid:5118,cpu4,QThread,4]Kernel panic - not syncing: stack-protector:
+Kernel stack is corrupted in: do_hardware_base_addr+0xcc/0xd0 [parport]
+[ 66.575408s] [pid:5118,cpu4,QThread,5]CPU: 4 PID: 5118 Comm:
+QThread Tainted: G S W O 5.10.97-arm64-desktop #7100.57021.2
+[ 66.575439s] [pid:5118,cpu4,QThread,6]TGID: 5087 Comm: EFileApp
+[ 66.575439s] [pid:5118,cpu4,QThread,7]Hardware name: HUAWEI HUAWEI QingYun
+PGUX-W515x-B081/SP1PANGUXM, BIOS 1.00.07 04/29/2024
+[ 66.575439s] [pid:5118,cpu4,QThread,8]Call trace:
+[ 66.575469s] [pid:5118,cpu4,QThread,9] dump_backtrace+0x0/0x1c0
+[ 66.575469s] [pid:5118,cpu4,QThread,0] show_stack+0x14/0x20
+[ 66.575469s] [pid:5118,cpu4,QThread,1] dump_stack+0xd4/0x10c
+[ 66.575500s] [pid:5118,cpu4,QThread,2] panic+0x1d8/0x3bc
+[ 66.575500s] [pid:5118,cpu4,QThread,3] __stack_chk_fail+0x2c/0x38
+[ 66.575500s] [pid:5118,cpu4,QThread,4] do_hardware_base_addr+0xcc/0xd0 [parport]
+
+Signed-off-by: tuhaowen <tuhaowen@uniontech.com>
+Cc: stable <stable@kernel.org>
+Link: https://lore.kernel.org/r/20240708080430.8221-1-tuhaowen@uniontech.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/parport/procfs.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
+index e957beb94f142..595e23e6859b6 100644
+--- a/drivers/parport/procfs.c
++++ b/drivers/parport/procfs.c
+@@ -51,12 +51,12 @@ static int do_active_device(struct ctl_table *table, int write,
+
+ for (dev = port->devices; dev ; dev = dev->next) {
+ if(dev == port->cad) {
+- len += sprintf(buffer, "%s\n", dev->name);
++ len += snprintf(buffer, sizeof(buffer), "%s\n", dev->name);
+ }
+ }
+
+ if(!len) {
+- len += sprintf(buffer, "%s\n", "none");
++ len += snprintf(buffer, sizeof(buffer), "%s\n", "none");
+ }
+
+ if (len > *lenp)
+@@ -87,19 +87,19 @@ static int do_autoprobe(struct ctl_table *table, int write,
+ }
+
+ if ((str = info->class_name) != NULL)
+- len += sprintf (buffer + len, "CLASS:%s;\n", str);
++ len += snprintf (buffer + len, sizeof(buffer) - len, "CLASS:%s;\n", str);
+
+ if ((str = info->model) != NULL)
+- len += sprintf (buffer + len, "MODEL:%s;\n", str);
++ len += snprintf (buffer + len, sizeof(buffer) - len, "MODEL:%s;\n", str);
+
+ if ((str = info->mfr) != NULL)
+- len += sprintf (buffer + len, "MANUFACTURER:%s;\n", str);
++ len += snprintf (buffer + len, sizeof(buffer) - len, "MANUFACTURER:%s;\n", str);
+
+ if ((str = info->description) != NULL)
+- len += sprintf (buffer + len, "DESCRIPTION:%s;\n", str);
++ len += snprintf (buffer + len, sizeof(buffer) - len, "DESCRIPTION:%s;\n", str);
+
+ if ((str = info->cmdset) != NULL)
+- len += sprintf (buffer + len, "COMMAND SET:%s;\n", str);
++ len += snprintf (buffer + len, sizeof(buffer) - len, "COMMAND SET:%s;\n", str);
+
+ if (len > *lenp)
+ len = *lenp;
+@@ -117,7 +117,7 @@ static int do_hardware_base_addr(struct ctl_table *table, int write,
+ size_t *lenp, loff_t *ppos)
+ {
+ struct parport *port = (struct parport *)table->extra1;
+- char buffer[20];
++ char buffer[64];
+ int len = 0;
+
+ if (*ppos) {
+@@ -128,7 +128,7 @@ static int do_hardware_base_addr(struct ctl_table *table, int write,
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
+
+- len += sprintf (buffer, "%lu\t%lu\n", port->base, port->base_hi);
++ len += snprintf (buffer, sizeof(buffer), "%lu\t%lu\n", port->base, port->base_hi);
+
+ if (len > *lenp)
+ len = *lenp;
+@@ -156,7 +156,7 @@ static int do_hardware_irq(struct ctl_table *table, int write,
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
+
+- len += sprintf (buffer, "%d\n", port->irq);
++ len += snprintf (buffer, sizeof(buffer), "%d\n", port->irq);
+
+ if (len > *lenp)
+ len = *lenp;
+@@ -184,7 +184,7 @@ static int do_hardware_dma(struct ctl_table *table, int write,
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
+
+- len += sprintf (buffer, "%d\n", port->dma);
++ len += snprintf (buffer, sizeof(buffer), "%d\n", port->dma);
+
+ if (len > *lenp)
+ len = *lenp;
+@@ -216,7 +216,7 @@ static int do_hardware_modes(struct ctl_table *table, int write,
+ #define printmode(x) \
+ do { \
+ if (port->modes & PARPORT_MODE_##x) \
+- len += sprintf(buffer + len, "%s%s", f++ ? "," : "", #x); \
++ len += snprintf(buffer + len, sizeof(buffer) - len, "%s%s", f++ ? "," : "", #x); \
+ } while (0)
+ int f = 0;
+ printmode(PCSPP);
+--
+2.43.0
+
--- /dev/null
+From b4dd1e6befe5c8cbf20583c023aa39c0ff3238f8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 2 Jul 2024 22:51:51 +0800
+Subject: devres: Fix memory leakage caused by driver API devm_free_percpu()
+
+From: Zijun Hu <quic_zijuhu@quicinc.com>
+
+[ Upstream commit bd50a974097bb82d52a458bd3ee39fb723129a0c ]
+
+It will cause memory leakage when use driver API devm_free_percpu()
+to free memory allocated by devm_alloc_percpu(), fixed by using
+devres_release() instead of devres_destroy() within devm_free_percpu().
+
+Fixes: ff86aae3b411 ("devres: add devm_alloc_percpu()")
+Cc: stable@vger.kernel.org
+Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
+Link: https://lore.kernel.org/r/1719931914-19035-3-git-send-email-quic_zijuhu@quicinc.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/devres.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/base/devres.c b/drivers/base/devres.c
+index e8ad6a41ad4ce..5a84bafae3288 100644
+--- a/drivers/base/devres.c
++++ b/drivers/base/devres.c
+@@ -1111,7 +1111,11 @@ EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
+ */
+ void devm_free_percpu(struct device *dev, void __percpu *pdata)
+ {
+- WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match,
++ /*
++ * Use devres_release() to prevent memory leakage as
++ * devm_free_pages() does.
++ */
++ WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match,
+ (__force void *)pdata));
+ }
+ EXPORT_SYMBOL_GPL(devm_free_percpu);
+--
+2.43.0
+
--- /dev/null
+From 374c407a0f17274bcf3c5d45618b20e262cc41c3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 1 Apr 2021 20:10:30 +0300
+Subject: driver core: Cast to (void *) with __force for __percpu pointer
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit d7aa44f5a1f86cb40659eef06035d8d92604b9d5 ]
+
+Sparse is not happy:
+
+ drivers/base/devres.c:1230:9: warning: cast removes address space '__percpu' of expression
+
+Use __force attribute to make it happy.
+
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20210401171030.60527-1-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: bd50a974097b ("devres: Fix memory leakage caused by driver API devm_free_percpu()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/devres.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/base/devres.c b/drivers/base/devres.c
+index 0bbb328bd17f8..e8ad6a41ad4ce 100644
+--- a/drivers/base/devres.c
++++ b/drivers/base/devres.c
+@@ -1112,6 +1112,6 @@ EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
+ void devm_free_percpu(struct device *dev, void __percpu *pdata)
+ {
+ WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match,
+- (void *)pdata));
++ (__force void *)pdata));
+ }
+ EXPORT_SYMBOL_GPL(devm_free_percpu);
+--
+2.43.0
+
--- /dev/null
+From d4b05da54aacd0ee958a072d54780f48d034edd2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Feb 2022 12:02:59 +0000
+Subject: genirq: Allow the PM device to originate from irq domain
+
+From: Marc Zyngier <maz@kernel.org>
+
+[ Upstream commit 1f8863bfb5ca500ea1c7669b16b1931ba27fce20 ]
+
+As a preparation to moving the reference to the device used for
+runtime power management, add a new 'dev' field to the irqdomain
+structure for that exact purpose.
+
+The irq_chip_pm_{get,put}() helpers are made aware of the dual
+location via a new private helper.
+
+No functional change intended.
+
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Tested-by: Tony Lindgren <tony@atomide.com>
+Acked-by: Bartosz Golaszewski <brgl@bgdev.pl>
+Link: https://lore.kernel.org/r/20220201120310.878267-2-maz@kernel.org
+Stable-dep-of: 33b1c47d1fc0 ("irqchip/imx-irqsteer: Handle runtime power management correctly")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/irqdomain.h | 10 ++++++++++
+ kernel/irq/chip.c | 23 ++++++++++++++++++-----
+ 2 files changed, 28 insertions(+), 5 deletions(-)
+
+diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
+index 2552f66a7a891..289556413ad90 100644
+--- a/include/linux/irqdomain.h
++++ b/include/linux/irqdomain.h
+@@ -147,6 +147,8 @@ struct irq_domain_chip_generic;
+ * @gc: Pointer to a list of generic chips. There is a helper function for
+ * setting up one or more generic chips for interrupt controllers
+ * drivers using the generic chip library which uses this pointer.
++ * @dev: Pointer to a device that the domain represent, and that will be
++ * used for power management purposes.
+ * @parent: Pointer to parent irq_domain to support hierarchy irq_domains
+ * @debugfs_file: dentry for the domain debugfs file
+ *
+@@ -169,6 +171,7 @@ struct irq_domain {
+ struct fwnode_handle *fwnode;
+ enum irq_domain_bus_token bus_token;
+ struct irq_domain_chip_generic *gc;
++ struct device *dev;
+ #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+ struct irq_domain *parent;
+ #endif
+@@ -225,6 +228,13 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
+ return to_of_node(d->fwnode);
+ }
+
++static inline void irq_domain_set_pm_device(struct irq_domain *d,
++ struct device *dev)
++{
++ if (d)
++ d->dev = dev;
++}
++
+ #ifdef CONFIG_IRQ_DOMAIN
+ struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
+ const char *name, phys_addr_t *pa);
+diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
+index 521121c2666ce..498f76beb8766 100644
+--- a/kernel/irq/chip.c
++++ b/kernel/irq/chip.c
+@@ -1528,6 +1528,17 @@ int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+ return 0;
+ }
+
++static struct device *irq_get_parent_device(struct irq_data *data)
++{
++ if (data->chip->parent_device)
++ return data->chip->parent_device;
++
++ if (data->domain)
++ return data->domain->dev;
++
++ return NULL;
++}
++
+ /**
+ * irq_chip_pm_get - Enable power for an IRQ chip
+ * @data: Pointer to interrupt specific data
+@@ -1537,12 +1548,13 @@ int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+ */
+ int irq_chip_pm_get(struct irq_data *data)
+ {
++ struct device *dev = irq_get_parent_device(data);
+ int retval;
+
+- if (IS_ENABLED(CONFIG_PM) && data->chip->parent_device) {
+- retval = pm_runtime_get_sync(data->chip->parent_device);
++ if (IS_ENABLED(CONFIG_PM) && dev) {
++ retval = pm_runtime_get_sync(dev);
+ if (retval < 0) {
+- pm_runtime_put_noidle(data->chip->parent_device);
++ pm_runtime_put_noidle(dev);
+ return retval;
+ }
+ }
+@@ -1560,10 +1572,11 @@ int irq_chip_pm_get(struct irq_data *data)
+ */
+ int irq_chip_pm_put(struct irq_data *data)
+ {
++ struct device *dev = irq_get_parent_device(data);
+ int retval = 0;
+
+- if (IS_ENABLED(CONFIG_PM) && data->chip->parent_device)
+- retval = pm_runtime_put(data->chip->parent_device);
++ if (IS_ENABLED(CONFIG_PM) && dev)
++ retval = pm_runtime_put(dev);
+
+ return (retval < 0) ? retval : 0;
+ }
+--
+2.43.0
+
--- /dev/null
+From c49f9557277856eff84fc8e143daa06b18f0fff3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 6 Apr 2022 18:37:01 +0200
+Subject: irqchip/imx-irqsteer: Add runtime PM support
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+[ Upstream commit 4730d2233311d86cad9dc510318d1b40e4b53cf2 ]
+
+There are now SoCs that integrate the irqsteer controller within
+a separate power domain. In order to allow this domain to be
+powered down when not needed, add runtime PM support to the driver.
+
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Link: https://lore.kernel.org/r/20220406163701.1277930-2-l.stach@pengutronix.de
+Stable-dep-of: 33b1c47d1fc0 ("irqchip/imx-irqsteer: Handle runtime power management correctly")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-imx-irqsteer.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-irqsteer.c
+index 1b01e655b9923..e622dbd614638 100644
+--- a/drivers/irqchip/irq-imx-irqsteer.c
++++ b/drivers/irqchip/irq-imx-irqsteer.c
+@@ -12,6 +12,7 @@
+ #include <linux/kernel.h>
+ #include <linux/of_irq.h>
+ #include <linux/of_platform.h>
++#include <linux/pm_runtime.h>
+ #include <linux/spinlock.h>
+
+ #define CTRL_STRIDE_OFF(_t, _r) (_t * 4 * _r)
+@@ -181,7 +182,7 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
+ data->irq_count = DIV_ROUND_UP(irqs_num, 64);
+ data->reg_num = irqs_num / 32;
+
+- if (IS_ENABLED(CONFIG_PM_SLEEP)) {
++ if (IS_ENABLED(CONFIG_PM)) {
+ data->saved_reg = devm_kzalloc(&pdev->dev,
+ sizeof(u32) * data->reg_num,
+ GFP_KERNEL);
+@@ -205,6 +206,7 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
+ ret = -ENOMEM;
+ goto out;
+ }
++ irq_domain_set_pm_device(data->domain, &pdev->dev);
+
+ if (!data->irq_count || data->irq_count > CHAN_MAX_OUTPUT_INT) {
+ ret = -EINVAL;
+@@ -225,6 +227,9 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
+
+ platform_set_drvdata(pdev, data);
+
++ pm_runtime_set_active(&pdev->dev);
++ pm_runtime_enable(&pdev->dev);
++
+ return 0;
+ out:
+ clk_disable_unprepare(data->ipg_clk);
+@@ -247,7 +252,7 @@ static int imx_irqsteer_remove(struct platform_device *pdev)
+ return 0;
+ }
+
+-#ifdef CONFIG_PM_SLEEP
++#ifdef CONFIG_PM
+ static void imx_irqsteer_save_regs(struct irqsteer_data *data)
+ {
+ int i;
+@@ -294,7 +299,10 @@ static int imx_irqsteer_resume(struct device *dev)
+ #endif
+
+ static const struct dev_pm_ops imx_irqsteer_pm_ops = {
+- SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_irqsteer_suspend, imx_irqsteer_resume)
++ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
++ pm_runtime_force_resume)
++ SET_RUNTIME_PM_OPS(imx_irqsteer_suspend,
++ imx_irqsteer_resume, NULL)
+ };
+
+ static const struct of_device_id imx_irqsteer_dt_ids[] = {
+--
+2.43.0
+
--- /dev/null
+From 696886af5ac3762a4dc9997050cfaaaf9cec745d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 6 Apr 2022 18:37:00 +0200
+Subject: irqchip/imx-irqsteer: Constify irq_chip struct
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+[ Upstream commit e9a50f12e579a48e124ac5adb93dafc35f0a46b8 ]
+
+The imx_irqsteer_irq_chip struct is constant data.
+
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Link: https://lore.kernel.org/r/20220406163701.1277930-1-l.stach@pengutronix.de
+Stable-dep-of: 33b1c47d1fc0 ("irqchip/imx-irqsteer: Handle runtime power management correctly")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-imx-irqsteer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-irqsteer.c
+index 290531ec3d61e..1b01e655b9923 100644
+--- a/drivers/irqchip/irq-imx-irqsteer.c
++++ b/drivers/irqchip/irq-imx-irqsteer.c
+@@ -70,7 +70,7 @@ static void imx_irqsteer_irq_mask(struct irq_data *d)
+ raw_spin_unlock_irqrestore(&data->lock, flags);
+ }
+
+-static struct irq_chip imx_irqsteer_irq_chip = {
++static const struct irq_chip imx_irqsteer_irq_chip = {
+ .name = "irqsteer",
+ .irq_mask = imx_irqsteer_irq_mask,
+ .irq_unmask = imx_irqsteer_irq_unmask,
+--
+2.43.0
+
--- /dev/null
+From b0df67b40df0c2b021d3702957f836c69ef425d1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Jul 2024 11:32:50 -0500
+Subject: irqchip/imx-irqsteer: Handle runtime power management correctly
+
+From: Shenwei Wang <shenwei.wang@nxp.com>
+
+[ Upstream commit 33b1c47d1fc0b5f06a393bb915db85baacba18ea ]
+
+The power domain is automatically activated from clk_prepare(). However, on
+certain platforms like i.MX8QM and i.MX8QXP, the power-on handling invokes
+sleeping functions, which triggers the 'scheduling while atomic' bug in the
+context switch path during device probing:
+
+ BUG: scheduling while atomic: kworker/u13:1/48/0x00000002
+ Call trace:
+ __schedule_bug+0x54/0x6c
+ __schedule+0x7f0/0xa94
+ schedule+0x5c/0xc4
+ schedule_preempt_disabled+0x24/0x40
+ __mutex_lock.constprop.0+0x2c0/0x540
+ __mutex_lock_slowpath+0x14/0x20
+ mutex_lock+0x48/0x54
+ clk_prepare_lock+0x44/0xa0
+ clk_prepare+0x20/0x44
+ imx_irqsteer_resume+0x28/0xe0
+ pm_generic_runtime_resume+0x2c/0x44
+ __genpd_runtime_resume+0x30/0x80
+ genpd_runtime_resume+0xc8/0x2c0
+ __rpm_callback+0x48/0x1d8
+ rpm_callback+0x6c/0x78
+ rpm_resume+0x490/0x6b4
+ __pm_runtime_resume+0x50/0x94
+ irq_chip_pm_get+0x2c/0xa0
+ __irq_do_set_handler+0x178/0x24c
+ irq_set_chained_handler_and_data+0x60/0xa4
+ mxc_gpio_probe+0x160/0x4b0
+
+Cure this by implementing the irq_bus_lock/sync_unlock() interrupt chip
+callbacks and handle power management in them as they are invoked from
+non-atomic context.
+
+[ tglx: Rewrote change log, added Fixes tag ]
+
+Fixes: 0136afa08967 ("irqchip: Add driver for imx-irqsteer controller")
+Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20240703163250.47887-1-shenwei.wang@nxp.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-imx-irqsteer.c | 24 +++++++++++++++++++++---
+ 1 file changed, 21 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-irqsteer.c
+index e622dbd614638..23aafc52768c7 100644
+--- a/drivers/irqchip/irq-imx-irqsteer.c
++++ b/drivers/irqchip/irq-imx-irqsteer.c
+@@ -35,6 +35,7 @@ struct irqsteer_data {
+ int channel;
+ struct irq_domain *domain;
+ u32 *saved_reg;
++ struct device *dev;
+ };
+
+ static int imx_irqsteer_get_reg_index(struct irqsteer_data *data,
+@@ -71,10 +72,26 @@ static void imx_irqsteer_irq_mask(struct irq_data *d)
+ raw_spin_unlock_irqrestore(&data->lock, flags);
+ }
+
++static void imx_irqsteer_irq_bus_lock(struct irq_data *d)
++{
++ struct irqsteer_data *data = d->chip_data;
++
++ pm_runtime_get_sync(data->dev);
++}
++
++static void imx_irqsteer_irq_bus_sync_unlock(struct irq_data *d)
++{
++ struct irqsteer_data *data = d->chip_data;
++
++ pm_runtime_put_autosuspend(data->dev);
++}
++
+ static const struct irq_chip imx_irqsteer_irq_chip = {
+- .name = "irqsteer",
+- .irq_mask = imx_irqsteer_irq_mask,
+- .irq_unmask = imx_irqsteer_irq_unmask,
++ .name = "irqsteer",
++ .irq_mask = imx_irqsteer_irq_mask,
++ .irq_unmask = imx_irqsteer_irq_unmask,
++ .irq_bus_lock = imx_irqsteer_irq_bus_lock,
++ .irq_bus_sync_unlock = imx_irqsteer_irq_bus_sync_unlock,
+ };
+
+ static int imx_irqsteer_irq_map(struct irq_domain *h, unsigned int irq,
+@@ -152,6 +169,7 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
+ if (!data)
+ return -ENOMEM;
+
++ data->dev = &pdev->dev;
+ data->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(data->regs)) {
+ dev_err(&pdev->dev, "failed to initialize reg\n");
+--
+2.43.0
+
--- /dev/null
+From f5d4b1caf8a68edfb69172c9e4b182bc8c847a72 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Jun 2024 16:42:38 +0200
+Subject: mm: avoid overflows in dirty throttling logic
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit 385d838df280eba6c8680f9777bfa0d0bfe7e8b2 ]
+
+The dirty throttling logic is interspersed with assumptions that dirty
+limits in PAGE_SIZE units fit into 32-bit (so that various multiplications
+fit into 64-bits). If limits end up being larger, we will hit overflows,
+possible divisions by 0 etc. Fix these problems by never allowing so
+large dirty limits as they have dubious practical value anyway. For
+dirty_bytes / dirty_background_bytes interfaces we can just refuse to set
+so large limits. For dirty_ratio / dirty_background_ratio it isn't so
+simple as the dirty limit is computed from the amount of available memory
+which can change due to memory hotplug etc. So when converting dirty
+limits from ratios to numbers of pages, we just don't allow the result to
+exceed UINT_MAX.
+
+This is root-only triggerable problem which occurs when the operator
+sets dirty limits to >16 TB.
+
+Link: https://lkml.kernel.org/r/20240621144246.11148-2-jack@suse.cz
+Signed-off-by: Jan Kara <jack@suse.cz>
+Reported-by: Zach O'Keefe <zokeefe@google.com>
+Reviewed-By: Zach O'Keefe <zokeefe@google.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ mm/page-writeback.c | 30 ++++++++++++++++++++++++++----
+ 1 file changed, 26 insertions(+), 4 deletions(-)
+
+diff --git a/mm/page-writeback.c b/mm/page-writeback.c
+index 5cc892b26339a..fd00a511644ed 100644
+--- a/mm/page-writeback.c
++++ b/mm/page-writeback.c
+@@ -433,13 +433,20 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
+ else
+ bg_thresh = (bg_ratio * available_memory) / PAGE_SIZE;
+
+- if (bg_thresh >= thresh)
+- bg_thresh = thresh / 2;
+ tsk = current;
+ if (tsk->flags & PF_LESS_THROTTLE || rt_task(tsk)) {
+ bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32;
+ thresh += thresh / 4 + global_wb_domain.dirty_limit / 32;
+ }
++ /*
++ * Dirty throttling logic assumes the limits in page units fit into
++ * 32-bits. This gives 16TB dirty limits max which is hopefully enough.
++ */
++ if (thresh > UINT_MAX)
++ thresh = UINT_MAX;
++ /* This makes sure bg_thresh is within 32-bits as well */
++ if (bg_thresh >= thresh)
++ bg_thresh = thresh / 2;
+ dtc->thresh = thresh;
+ dtc->bg_thresh = bg_thresh;
+
+@@ -489,7 +496,11 @@ static unsigned long node_dirty_limit(struct pglist_data *pgdat)
+ if (tsk->flags & PF_LESS_THROTTLE || rt_task(tsk))
+ dirty += dirty / 4;
+
+- return dirty;
++ /*
++ * Dirty throttling logic assumes the limits in page units fit into
++ * 32-bits. This gives 16TB dirty limits max which is hopefully enough.
++ */
++ return min_t(unsigned long, dirty, UINT_MAX);
+ }
+
+ /**
+@@ -528,10 +539,17 @@ int dirty_background_bytes_handler(struct ctl_table *table, int write,
+ loff_t *ppos)
+ {
+ int ret;
++ unsigned long old_bytes = dirty_background_bytes;
+
+ ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+- if (ret == 0 && write)
++ if (ret == 0 && write) {
++ if (DIV_ROUND_UP(dirty_background_bytes, PAGE_SIZE) >
++ UINT_MAX) {
++ dirty_background_bytes = old_bytes;
++ return -ERANGE;
++ }
+ dirty_background_ratio = 0;
++ }
+ return ret;
+ }
+
+@@ -559,6 +577,10 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
+
+ ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+ if (ret == 0 && write && vm_dirty_bytes != old_bytes) {
++ if (DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE) > UINT_MAX) {
++ vm_dirty_bytes = old_bytes;
++ return -ERANGE;
++ }
+ writeback_set_ratelimit();
+ vm_dirty_ratio = 0;
+ }
+--
+2.43.0
+
--- /dev/null
+From ad4afe535be5b13ac08476a339070731429f6d7b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Apr 2020 14:43:16 +0100
+Subject: parport: Convert printk(KERN_<LEVEL> to pr_<level>(
+
+From: Joe Perches <joe@perches.com>
+
+[ Upstream commit decf26f6ec25dac868782dc1751623a87d147831 ]
+
+Use the more common kernel style.
+
+Miscellanea:
+
+o Coalesce formats
+o Realign arguments
+
+Signed-off-by: Joe Perches <joe@perches.com>
+Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Link: https://lore.kernel.org/r/20200403134325.11523-2-sudipm.mukherjee@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/parport/daisy.c | 6 +-
+ drivers/parport/ieee1284.c | 4 +-
+ drivers/parport/ieee1284_ops.c | 3 +-
+ drivers/parport/parport_amiga.c | 2 +-
+ drivers/parport/parport_atari.c | 2 +-
+ drivers/parport/parport_cs.c | 6 +-
+ drivers/parport/parport_gsc.c | 7 +-
+ drivers/parport/parport_ip32.c | 25 ++---
+ drivers/parport/parport_mfc3.c | 2 +-
+ drivers/parport/parport_pc.c | 166 +++++++++++++------------------
+ drivers/parport/parport_sunbpp.c | 2 +-
+ drivers/parport/probe.c | 7 +-
+ drivers/parport/share.c | 24 ++---
+ 13 files changed, 110 insertions(+), 146 deletions(-)
+
+diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c
+index 5484a46dafda8..465acebd64380 100644
+--- a/drivers/parport/daisy.c
++++ b/drivers/parport/daisy.c
+@@ -109,8 +109,7 @@ int parport_daisy_init(struct parport *port)
+ ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) {
+ /* Leave original as port zero. */
+ port->muxport = 0;
+- printk(KERN_INFO
+- "%s: 1st (default) port of %d-way multiplexor\n",
++ pr_info("%s: 1st (default) port of %d-way multiplexor\n",
+ port->name, num_ports);
+ for (i = 1; i < num_ports; i++) {
+ /* Clone the port. */
+@@ -123,8 +122,7 @@ int parport_daisy_init(struct parport *port)
+ continue;
+ }
+
+- printk(KERN_INFO
+- "%s: %d%s port of %d-way multiplexor on %s\n",
++ pr_info("%s: %d%s port of %d-way multiplexor on %s\n",
+ extra->name, i + 1, th[i + 1], num_ports,
+ port->name);
+
+diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
+index 90fb735754951..5c0c9613e03b1 100644
+--- a/drivers/parport/ieee1284.c
++++ b/drivers/parport/ieee1284.c
+@@ -329,7 +329,7 @@ int parport_negotiate (struct parport *port, int mode)
+ #ifndef CONFIG_PARPORT_1284
+ if (mode == IEEE1284_MODE_COMPAT)
+ return 0;
+- printk (KERN_ERR "parport: IEEE1284 not supported in this kernel\n");
++ pr_err("parport: IEEE1284 not supported in this kernel\n");
+ return -1;
+ #else
+ int m = mode & ~IEEE1284_ADDR;
+@@ -694,7 +694,7 @@ ssize_t parport_write (struct parport *port, const void *buffer, size_t len)
+ ssize_t parport_read (struct parport *port, void *buffer, size_t len)
+ {
+ #ifndef CONFIG_PARPORT_1284
+- printk (KERN_ERR "parport: IEEE1284 not supported in this kernel\n");
++ pr_err("parport: IEEE1284 not supported in this kernel\n");
+ return -ENODEV;
+ #else
+ int mode = port->physport->ieee1284.mode;
+diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c
+index 75daa16f38b7f..58ec484c73058 100644
+--- a/drivers/parport/ieee1284_ops.c
++++ b/drivers/parport/ieee1284_ops.c
+@@ -599,8 +599,7 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
+ DPRINTK (KERN_DEBUG "ECP read timed out at 45\n");
+
+ if (command)
+- printk (KERN_WARNING
+- "%s: command ignored (%02x)\n",
++ pr_warn("%s: command ignored (%02x)\n",
+ port->name, byte);
+
+ break;
+diff --git a/drivers/parport/parport_amiga.c b/drivers/parport/parport_amiga.c
+index 3301861f69fa8..8c7a598abcff2 100644
+--- a/drivers/parport/parport_amiga.c
++++ b/drivers/parport/parport_amiga.c
+@@ -212,7 +212,7 @@ static int __init amiga_parallel_probe(struct platform_device *pdev)
+ if (err)
+ goto out_irq;
+
+- printk(KERN_INFO "%s: Amiga built-in port using irq\n", p->name);
++ pr_info("%s: Amiga built-in port using irq\n", p->name);
+ /* XXX: set operating mode */
+ parport_announce_port(p);
+
+diff --git a/drivers/parport/parport_atari.c b/drivers/parport/parport_atari.c
+index f8dd368bfdbb5..2ff0fe053e6ee 100644
+--- a/drivers/parport/parport_atari.c
++++ b/drivers/parport/parport_atari.c
+@@ -200,7 +200,7 @@ static int __init parport_atari_init(void)
+ }
+
+ this_port = p;
+- printk(KERN_INFO "%s: Atari built-in port using irq\n", p->name);
++ pr_info("%s: Atari built-in port using irq\n", p->name);
+ parport_announce_port (p);
+
+ return 0;
+diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
+index e77044c2bf622..8e7e3ac4bb876 100644
+--- a/drivers/parport/parport_cs.c
++++ b/drivers/parport/parport_cs.c
+@@ -142,10 +142,8 @@ static int parport_config(struct pcmcia_device *link)
+ link->irq, PARPORT_DMA_NONE,
+ &link->dev, IRQF_SHARED);
+ if (p == NULL) {
+- printk(KERN_NOTICE "parport_cs: parport_pc_probe_port() at "
+- "0x%3x, irq %u failed\n",
+- (unsigned int) link->resource[0]->start,
+- link->irq);
++ pr_notice("parport_cs: parport_pc_probe_port() at 0x%3x, irq %u failed\n",
++ (unsigned int)link->resource[0]->start, link->irq);
+ goto failed;
+ }
+
+diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
+index 922535a118ba6..81082d5899b06 100644
+--- a/drivers/parport/parport_gsc.c
++++ b/drivers/parport/parport_gsc.c
+@@ -282,7 +282,7 @@ struct parport *parport_gsc_probe_port(unsigned long base,
+ p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
+ p->private_data = priv;
+
+- printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);
++ pr_info("%s: PC-style at 0x%lx", p->name, p->base);
+ p->irq = irq;
+ if (p->irq == PARPORT_IRQ_AUTO) {
+ p->irq = PARPORT_IRQ_NONE;
+@@ -315,8 +315,7 @@ struct parport *parport_gsc_probe_port(unsigned long base,
+ if (p->irq != PARPORT_IRQ_NONE) {
+ if (request_irq (p->irq, parport_irq_handler,
+ 0, p->name, p)) {
+- printk (KERN_WARNING "%s: irq %d in use, "
+- "resorting to polled operation\n",
++ pr_warn("%s: irq %d in use, resorting to polled operation\n",
+ p->name, p->irq);
+ p->irq = PARPORT_IRQ_NONE;
+ p->dma = PARPORT_DMA_NONE;
+@@ -347,7 +346,7 @@ static int __init parport_init_chip(struct parisc_device *dev)
+ unsigned long port;
+
+ if (!dev->irq) {
+- printk(KERN_WARNING "IRQ not found for parallel device at 0x%llx\n",
++ pr_warn("IRQ not found for parallel device at 0x%llx\n",
+ (unsigned long long)dev->hpa.start);
+ return -ENODEV;
+ }
+diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
+index ab215b650f419..4f76e4f4f6cfd 100644
+--- a/drivers/parport/parport_ip32.c
++++ b/drivers/parport/parport_ip32.c
+@@ -1337,9 +1337,8 @@ static unsigned int parport_ip32_fwp_wait_interrupt(struct parport *p)
+ ecr = parport_ip32_read_econtrol(p);
+ if ((ecr & ECR_F_EMPTY) && !(ecr & ECR_SERVINTR)
+ && !lost_interrupt) {
+- printk(KERN_WARNING PPIP32
+- "%s: lost interrupt in %s\n",
+- p->name, __func__);
++ pr_warn(PPIP32 "%s: lost interrupt in %s\n",
++ p->name, __func__);
+ lost_interrupt = 1;
+ }
+ }
+@@ -1643,8 +1642,8 @@ static size_t parport_ip32_compat_write_data(struct parport *p,
+ DSR_nBUSY | DSR_nFAULT)) {
+ /* Avoid to flood the logs */
+ if (ready_before)
+- printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
+- p->name, __func__);
++ pr_info(PPIP32 "%s: not ready in %s\n",
++ p->name, __func__);
+ ready_before = 0;
+ goto stop;
+ }
+@@ -1724,8 +1723,8 @@ static size_t parport_ip32_ecp_write_data(struct parport *p,
+ DSR_nBUSY | DSR_nFAULT)) {
+ /* Avoid to flood the logs */
+ if (ready_before)
+- printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
+- p->name, __func__);
++ pr_info(PPIP32 "%s: not ready in %s\n",
++ p->name, __func__);
+ ready_before = 0;
+ goto stop;
+ }
+@@ -2064,8 +2063,7 @@ static __init struct parport *parport_ip32_probe_port(void)
+ p->modes |= PARPORT_MODE_TRISTATE;
+
+ if (!parport_ip32_fifo_supported(p)) {
+- printk(KERN_WARNING PPIP32
+- "%s: error: FIFO disabled\n", p->name);
++ pr_warn(PPIP32 "%s: error: FIFO disabled\n", p->name);
+ /* Disable hardware modes depending on a working FIFO. */
+ features &= ~PARPORT_IP32_ENABLE_SPP;
+ features &= ~PARPORT_IP32_ENABLE_ECP;
+@@ -2077,8 +2075,7 @@ static __init struct parport *parport_ip32_probe_port(void)
+ if (features & PARPORT_IP32_ENABLE_IRQ) {
+ int irq = MACEISA_PARALLEL_IRQ;
+ if (request_irq(irq, parport_ip32_interrupt, 0, p->name, p)) {
+- printk(KERN_WARNING PPIP32
+- "%s: error: IRQ disabled\n", p->name);
++ pr_warn(PPIP32 "%s: error: IRQ disabled\n", p->name);
+ /* DMA cannot work without interrupts. */
+ features &= ~PARPORT_IP32_ENABLE_DMA;
+ } else {
+@@ -2091,8 +2088,7 @@ static __init struct parport *parport_ip32_probe_port(void)
+ /* Allocate DMA resources */
+ if (features & PARPORT_IP32_ENABLE_DMA) {
+ if (parport_ip32_dma_register())
+- printk(KERN_WARNING PPIP32
+- "%s: error: DMA disabled\n", p->name);
++ pr_warn(PPIP32 "%s: error: DMA disabled\n", p->name);
+ else {
+ pr_probe(p, "DMA support enabled\n");
+ p->dma = 0; /* arbitrary value != PARPORT_DMA_NONE */
+@@ -2134,8 +2130,7 @@ static __init struct parport *parport_ip32_probe_port(void)
+ parport_ip32_dump_state(p, "end init", 0);
+
+ /* Print out what we found */
+- printk(KERN_INFO "%s: SGI IP32 at 0x%lx (0x%lx)",
+- p->name, p->base, p->base_hi);
++ pr_info("%s: SGI IP32 at 0x%lx (0x%lx)", p->name, p->base, p->base_hi);
+ if (p->irq != PARPORT_IRQ_NONE)
+ printk(", irq %d", p->irq);
+ printk(" [");
+diff --git a/drivers/parport/parport_mfc3.c b/drivers/parport/parport_mfc3.c
+index 9f87faf939e38..3190ef0f3c811 100644
+--- a/drivers/parport/parport_mfc3.c
++++ b/drivers/parport/parport_mfc3.c
+@@ -325,7 +325,7 @@ static int __init parport_mfc3_init(void)
+ p->dev = &z->dev;
+
+ this_port[pias++] = p;
+- printk(KERN_INFO "%s: Multiface III port using irq\n", p->name);
++ pr_info("%s: Multiface III port using irq\n", p->name);
+ /* XXX: set operating mode */
+
+ p->private_data = (void *)piabase;
+diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
+index 23aced8082420..4acf3d017a187 100644
+--- a/drivers/parport/parport_pc.c
++++ b/drivers/parport/parport_pc.c
+@@ -982,28 +982,24 @@ static void show_parconfig_smsc37c669(int io, int key)
+ outb(0xaa, io);
+
+ if (verbose_probing) {
+- printk(KERN_INFO
+- "SMSC 37c669 LPT Config: cr_1=0x%02x, 4=0x%02x, "
+- "A=0x%2x, 23=0x%02x, 26=0x%02x, 27=0x%02x\n",
++ pr_info("SMSC 37c669 LPT Config: cr_1=0x%02x, 4=0x%02x, A=0x%2x, 23=0x%02x, 26=0x%02x, 27=0x%02x\n",
+ cr1, cr4, cra, cr23, cr26, cr27);
+
+ /* The documentation calls DMA and IRQ-Lines by letters, so
+ the board maker can/will wire them
+ appropriately/randomly... G=reserved H=IDE-irq, */
+- printk(KERN_INFO
+- "SMSC LPT Config: io=0x%04x, irq=%c, dma=%c, fifo threshold=%d\n",
+- cr23 * 4,
+- (cr27 & 0x0f) ? 'A' - 1 + (cr27 & 0x0f) : '-',
+- (cr26 & 0x0f) ? 'A' - 1 + (cr26 & 0x0f) : '-',
+- cra & 0x0f);
+- printk(KERN_INFO "SMSC LPT Config: enabled=%s power=%s\n",
+- (cr23 * 4 >= 0x100) ? "yes" : "no",
+- (cr1 & 4) ? "yes" : "no");
+- printk(KERN_INFO
+- "SMSC LPT Config: Port mode=%s, EPP version =%s\n",
+- (cr1 & 0x08) ? "Standard mode only (SPP)"
+- : modes[cr4 & 0x03],
+- (cr4 & 0x40) ? "1.7" : "1.9");
++ pr_info("SMSC LPT Config: io=0x%04x, irq=%c, dma=%c, fifo threshold=%d\n",
++ cr23 * 4,
++ (cr27 & 0x0f) ? 'A' - 1 + (cr27 & 0x0f) : '-',
++ (cr26 & 0x0f) ? 'A' - 1 + (cr26 & 0x0f) : '-',
++ cra & 0x0f);
++ pr_info("SMSC LPT Config: enabled=%s power=%s\n",
++ (cr23 * 4 >= 0x100) ? "yes" : "no",
++ (cr1 & 4) ? "yes" : "no");
++ pr_info("SMSC LPT Config: Port mode=%s, EPP version =%s\n",
++ (cr1 & 0x08) ? "Standard mode only (SPP)"
++ : modes[cr4 & 0x03],
++ (cr4 & 0x40) ? "1.7" : "1.9");
+ }
+
+ /* Heuristics ! BIOS setup for this mainboard device limits
+@@ -1013,7 +1009,7 @@ static void show_parconfig_smsc37c669(int io, int key)
+ if (cr23 * 4 >= 0x100) { /* if active */
+ s = find_free_superio();
+ if (s == NULL)
+- printk(KERN_INFO "Super-IO: too many chips!\n");
++ pr_info("Super-IO: too many chips!\n");
+ else {
+ int d;
+ switch (cr23 * 4) {
+@@ -1078,26 +1074,24 @@ static void show_parconfig_winbond(int io, int key)
+ outb(0xaa, io);
+
+ if (verbose_probing) {
+- printk(KERN_INFO
+- "Winbond LPT Config: cr_30=%02x 60,61=%02x%02x 70=%02x 74=%02x, f0=%02x\n",
+- cr30, cr60, cr61, cr70, cr74, crf0);
+- printk(KERN_INFO "Winbond LPT Config: active=%s, io=0x%02x%02x irq=%d, ",
+- (cr30 & 0x01) ? "yes" : "no", cr60, cr61, cr70 & 0x0f);
++ pr_info("Winbond LPT Config: cr_30=%02x 60,61=%02x%02x 70=%02x 74=%02x, f0=%02x\n",
++ cr30, cr60, cr61, cr70, cr74, crf0);
++ pr_info("Winbond LPT Config: active=%s, io=0x%02x%02x irq=%d, ",
++ (cr30 & 0x01) ? "yes" : "no", cr60, cr61, cr70 & 0x0f);
+ if ((cr74 & 0x07) > 3)
+ pr_cont("dma=none\n");
+ else
+ pr_cont("dma=%d\n", cr74 & 0x07);
+- printk(KERN_INFO
+- "Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n",
+- irqtypes[crf0>>7], (crf0>>3)&0x0f);
+- printk(KERN_INFO "Winbond LPT Config: Port mode=%s\n",
+- modes[crf0 & 0x07]);
++ pr_info("Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n",
++ irqtypes[crf0 >> 7], (crf0 >> 3) & 0x0f);
++ pr_info("Winbond LPT Config: Port mode=%s\n",
++ modes[crf0 & 0x07]);
+ }
+
+ if (cr30 & 0x01) { /* the settings can be interrogated later ... */
+ s = find_free_superio();
+ if (s == NULL)
+- printk(KERN_INFO "Super-IO: too many chips!\n");
++ pr_info("Super-IO: too many chips!\n");
+ else {
+ s->io = (cr60 << 8) | cr61;
+ s->irq = cr70 & 0x0f;
+@@ -1151,9 +1145,8 @@ static void decode_winbond(int efer, int key, int devid, int devrev, int oldid)
+ progif = 0;
+
+ if (verbose_probing)
+- printk(KERN_INFO "Winbond chip at EFER=0x%x key=0x%02x "
+- "devid=%02x devrev=%02x oldid=%02x type=%s\n",
+- efer, key, devid, devrev, oldid, type);
++ pr_info("Winbond chip at EFER=0x%x key=0x%02x devid=%02x devrev=%02x oldid=%02x type=%s\n",
++ efer, key, devid, devrev, oldid, type);
+
+ if (progif == 2)
+ show_parconfig_winbond(efer, key);
+@@ -1184,9 +1177,8 @@ static void decode_smsc(int efer, int key, int devid, int devrev)
+ type = "37c666GT";
+
+ if (verbose_probing)
+- printk(KERN_INFO "SMSC chip at EFER=0x%x "
+- "key=0x%02x devid=%02x devrev=%02x type=%s\n",
+- efer, key, devid, devrev, type);
++ pr_info("SMSC chip at EFER=0x%x key=0x%02x devid=%02x devrev=%02x type=%s\n",
++ efer, key, devid, devrev, type);
+
+ if (func)
+ func(efer, key);
+@@ -1358,7 +1350,7 @@ static void detect_and_report_it87(void)
+ dev |= inb(0x2f);
+ if (dev == 0x8712 || dev == 0x8705 || dev == 0x8715 ||
+ dev == 0x8716 || dev == 0x8718 || dev == 0x8726) {
+- printk(KERN_INFO "IT%04X SuperIO detected.\n", dev);
++ pr_info("IT%04X SuperIO detected\n", dev);
+ outb(0x07, 0x2E); /* Parallel Port */
+ outb(0x03, 0x2F);
+ outb(0xF0, 0x2E); /* BOOT 0x80 off */
+@@ -1445,8 +1437,8 @@ static int parport_SPP_supported(struct parport *pb)
+ if (user_specified)
+ /* That didn't work, but the user thinks there's a
+ * port here. */
+- printk(KERN_INFO "parport 0x%lx (WARNING): CTR: "
+- "wrote 0x%02x, read 0x%02x\n", pb->base, w, r);
++ pr_info("parport 0x%lx (WARNING): CTR: wrote 0x%02x, read 0x%02x\n",
++ pb->base, w, r);
+
+ /* Try the data register. The data lines aren't tri-stated at
+ * this stage, so we expect back what we wrote. */
+@@ -1464,10 +1456,9 @@ static int parport_SPP_supported(struct parport *pb)
+ if (user_specified) {
+ /* Didn't work, but the user is convinced this is the
+ * place. */
+- printk(KERN_INFO "parport 0x%lx (WARNING): DATA: "
+- "wrote 0x%02x, read 0x%02x\n", pb->base, w, r);
+- printk(KERN_INFO "parport 0x%lx: You gave this address, "
+- "but there is probably no parallel port there!\n",
++ pr_info("parport 0x%lx (WARNING): DATA: wrote 0x%02x, read 0x%02x\n",
++ pb->base, w, r);
++ pr_info("parport 0x%lx: You gave this address, but there is probably no parallel port there!\n",
+ pb->base);
+ }
+
+@@ -1642,7 +1633,7 @@ static int parport_ECP_supported(struct parport *pb)
+
+ if (i <= priv->fifo_depth) {
+ if (verbose_probing)
+- printk(KERN_INFO "0x%lx: readIntrThreshold is %d\n",
++ pr_info("0x%lx: readIntrThreshold is %d\n",
+ pb->base, i);
+ } else
+ /* Number of bytes we can read if we get an interrupt. */
+@@ -1657,17 +1648,14 @@ static int parport_ECP_supported(struct parport *pb)
+ switch (pword) {
+ case 0:
+ pword = 2;
+- printk(KERN_WARNING "0x%lx: Unsupported pword size!\n",
+- pb->base);
++ pr_warn("0x%lx: Unsupported pword size!\n", pb->base);
+ break;
+ case 2:
+ pword = 4;
+- printk(KERN_WARNING "0x%lx: Unsupported pword size!\n",
+- pb->base);
++ pr_warn("0x%lx: Unsupported pword size!\n", pb->base);
+ break;
+ default:
+- printk(KERN_WARNING "0x%lx: Unknown implementation ID\n",
+- pb->base);
++ pr_warn("0x%lx: Unknown implementation ID\n", pb->base);
+ /* Fall through - Assume 1 */
+ case 1:
+ pword = 1;
+@@ -2107,9 +2095,9 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+
+ p->size = (p->modes & PARPORT_MODE_EPP) ? 8 : 3;
+
+- printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);
++ pr_info("%s: PC-style at 0x%lx", p->name, p->base);
+ if (p->base_hi && priv->ecr)
+- printk(KERN_CONT " (0x%lx)", p->base_hi);
++ pr_cont(" (0x%lx)", p->base_hi);
+ if (p->irq == PARPORT_IRQ_AUTO) {
+ p->irq = PARPORT_IRQ_NONE;
+ parport_irq_probe(p);
+@@ -2120,7 +2108,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ p->irq = PARPORT_IRQ_NONE;
+ }
+ if (p->irq != PARPORT_IRQ_NONE) {
+- printk(KERN_CONT ", irq %d", p->irq);
++ pr_cont(", irq %d", p->irq);
+ priv->ctr_writable |= 0x10;
+
+ if (p->dma == PARPORT_DMA_AUTO) {
+@@ -2144,21 +2132,21 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ /* p->ops->ecp_read_data = parport_pc_ecp_read_block_pio; */
+ #endif /* IEEE 1284 support */
+ if (p->dma != PARPORT_DMA_NONE) {
+- printk(KERN_CONT ", dma %d", p->dma);
++ pr_cont(", dma %d", p->dma);
+ p->modes |= PARPORT_MODE_DMA;
+ } else
+- printk(KERN_CONT ", using FIFO");
++ pr_cont(", using FIFO");
+ } else
+ /* We can't use the DMA channel after all. */
+ p->dma = PARPORT_DMA_NONE;
+ #endif /* Allowed to use FIFO/DMA */
+
+- printk(KERN_CONT " [");
++ pr_cont(" [");
+
+ #define printmode(x) \
+ {\
+ if (p->modes & PARPORT_MODE_##x) {\
+- printk(KERN_CONT "%s%s", f ? "," : "", #x);\
++ pr_cont("%s%s", f ? "," : "", #x); \
+ f++;\
+ } \
+ }
+@@ -2174,11 +2162,11 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ }
+ #undef printmode
+ #ifndef CONFIG_PARPORT_1284
+- printk(KERN_CONT "(,...)");
++ pr_cont("(,...)");
+ #endif /* CONFIG_PARPORT_1284 */
+- printk(KERN_CONT "]\n");
++ pr_cont("]\n");
+ if (probedirq != PARPORT_IRQ_NONE)
+- printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq);
++ pr_info("%s: irq %d detected\n", p->name, probedirq);
+
+ /* If No ECP release the ports grabbed above. */
+ if (ECR_res && (p->modes & PARPORT_MODE_ECP) == 0) {
+@@ -2193,8 +2181,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ if (p->irq != PARPORT_IRQ_NONE) {
+ if (request_irq(p->irq, parport_irq_handler,
+ irqflags, p->name, p)) {
+- printk(KERN_WARNING "%s: irq %d in use, "
+- "resorting to polled operation\n",
++ pr_warn("%s: irq %d in use, resorting to polled operation\n",
+ p->name, p->irq);
+ p->irq = PARPORT_IRQ_NONE;
+ p->dma = PARPORT_DMA_NONE;
+@@ -2204,8 +2191,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ #ifdef HAS_DMA
+ if (p->dma != PARPORT_DMA_NONE) {
+ if (request_dma(p->dma, p->name)) {
+- printk(KERN_WARNING "%s: dma %d in use, "
+- "resorting to PIO operation\n",
++ pr_warn("%s: dma %d in use, resorting to PIO operation\n",
+ p->name, p->dma);
+ p->dma = PARPORT_DMA_NONE;
+ } else {
+@@ -2215,9 +2201,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+ &priv->dma_handle,
+ GFP_KERNEL);
+ if (!priv->dma_buf) {
+- printk(KERN_WARNING "%s: "
+- "cannot get buffer for DMA, "
+- "resorting to PIO operation\n",
++ pr_warn("%s: cannot get buffer for DMA, resorting to PIO operation\n",
+ p->name);
+ free_dma(p->dma);
+ p->dma = PARPORT_DMA_NONE;
+@@ -2330,7 +2314,7 @@ static int sio_ite_8872_probe(struct pci_dev *pdev, int autoirq, int autodma,
+ }
+ }
+ if (i >= 5) {
+- printk(KERN_INFO "parport_pc: cannot find ITE8872 INTA\n");
++ pr_info("parport_pc: cannot find ITE8872 INTA\n");
+ return 0;
+ }
+
+@@ -2339,29 +2323,28 @@ static int sio_ite_8872_probe(struct pci_dev *pdev, int autoirq, int autodma,
+
+ switch (type) {
+ case 0x2:
+- printk(KERN_INFO "parport_pc: ITE8871 found (1P)\n");
++ pr_info("parport_pc: ITE8871 found (1P)\n");
+ ite8872set = 0x64200000;
+ break;
+ case 0xa:
+- printk(KERN_INFO "parport_pc: ITE8875 found (1P)\n");
++ pr_info("parport_pc: ITE8875 found (1P)\n");
+ ite8872set = 0x64200000;
+ break;
+ case 0xe:
+- printk(KERN_INFO "parport_pc: ITE8872 found (2S1P)\n");
++ pr_info("parport_pc: ITE8872 found (2S1P)\n");
+ ite8872set = 0x64e00000;
+ break;
+ case 0x6:
+- printk(KERN_INFO "parport_pc: ITE8873 found (1S)\n");
++ pr_info("parport_pc: ITE8873 found (1S)\n");
+ release_region(inta_addr[i], 32);
+ return 0;
+ case 0x8:
+- printk(KERN_INFO "parport_pc: ITE8874 found (2S)\n");
++ pr_info("parport_pc: ITE8874 found (2S)\n");
+ release_region(inta_addr[i], 32);
+ return 0;
+ default:
+- printk(KERN_INFO "parport_pc: unknown ITE887x\n");
+- printk(KERN_INFO "parport_pc: please mail 'lspci -nvv' "
+- "output to Rich.Liu@ite.com.tw\n");
++ pr_info("parport_pc: unknown ITE887x\n");
++ pr_info("parport_pc: please mail 'lspci -nvv' output to Rich.Liu@ite.com.tw\n");
+ release_region(inta_addr[i], 32);
+ return 0;
+ }
+@@ -2396,9 +2379,8 @@ static int sio_ite_8872_probe(struct pci_dev *pdev, int autoirq, int autodma,
+ release_region(inta_addr[i], 32);
+ if (parport_pc_probe_port(ite8872_lpt, ite8872_lpthi,
+ irq, PARPORT_DMA_NONE, &pdev->dev, 0)) {
+- printk(KERN_INFO
+- "parport_pc: ITE 8872 parallel port: io=0x%X",
+- ite8872_lpt);
++ pr_info("parport_pc: ITE 8872 parallel port: io=0x%X",
++ ite8872_lpt);
+ if (irq != PARPORT_IRQ_NONE)
+ pr_cont(", irq=%d", irq);
+ pr_cont("\n");
+@@ -2525,7 +2507,7 @@ static int sio_via_probe(struct pci_dev *pdev, int autoirq, int autodma,
+ pci_write_config_byte(pdev, via->via_pci_superio_config_reg, tmp);
+
+ if (siofunc == VIA_FUNCTION_PARPORT_DISABLE) {
+- printk(KERN_INFO "parport_pc: VIA parallel port disabled in BIOS\n");
++ pr_info("parport_pc: VIA parallel port disabled in BIOS\n");
+ return 0;
+ }
+
+@@ -2558,9 +2540,8 @@ static int sio_via_probe(struct pci_dev *pdev, int autoirq, int autodma,
+ case 0x278:
+ port2 = 0x678; break;
+ default:
+- printk(KERN_INFO
+- "parport_pc: Weird VIA parport base 0x%X, ignoring\n",
+- port1);
++ pr_info("parport_pc: Weird VIA parport base 0x%X, ignoring\n",
++ port1);
+ return 0;
+ }
+
+@@ -2579,8 +2560,7 @@ static int sio_via_probe(struct pci_dev *pdev, int autoirq, int autodma,
+
+ /* finally, do the probe with values obtained */
+ if (parport_pc_probe_port(port1, port2, irq, dma, &pdev->dev, 0)) {
+- printk(KERN_INFO
+- "parport_pc: VIA parallel port: io=0x%X", port1);
++ pr_info("parport_pc: VIA parallel port: io=0x%X", port1);
+ if (irq != PARPORT_IRQ_NONE)
+ pr_cont(", irq=%d", irq);
+ if (dma != PARPORT_DMA_NONE)
+@@ -2589,7 +2569,7 @@ static int sio_via_probe(struct pci_dev *pdev, int autoirq, int autodma,
+ return 1;
+ }
+
+- printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n",
++ pr_warn("parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n",
+ port1, irq, dma);
+ return 0;
+ }
+@@ -3132,7 +3112,7 @@ static int __init parport_parse_param(const char *s, int *val,
+ if (ep != s)
+ *val = r;
+ else {
+- printk(KERN_ERR "parport: bad specifier `%s'\n", s);
++ pr_err("parport: bad specifier `%s'\n", s);
+ return -1;
+ }
+ }
+@@ -3222,10 +3202,7 @@ static int __init parse_parport_params(void)
+ irqval[0] = val;
+ break;
+ default:
+- printk(KERN_WARNING
+- "parport_pc: irq specified "
+- "without base address. Use 'io=' "
+- "to specify one\n");
++ pr_warn("parport_pc: irq specified without base address. Use 'io=' to specify one\n");
+ }
+
+ if (dma[0] && !parport_parse_dma(dma[0], &val))
+@@ -3235,10 +3212,7 @@ static int __init parse_parport_params(void)
+ dmaval[0] = val;
+ break;
+ default:
+- printk(KERN_WARNING
+- "parport_pc: dma specified "
+- "without base address. Use 'io=' "
+- "to specify one\n");
++ pr_warn("parport_pc: dma specified without base address. Use 'io=' to specify one\n");
+ }
+ }
+ return 0;
+@@ -3277,12 +3251,12 @@ static int __init parport_setup(char *str)
+
+ val = simple_strtoul(str, &endptr, 0);
+ if (endptr == str) {
+- printk(KERN_WARNING "parport=%s not understood\n", str);
++ pr_warn("parport=%s not understood\n", str);
+ return 1;
+ }
+
+ if (parport_setup_ptr == PARPORT_PC_MAX_PORTS) {
+- printk(KERN_ERR "parport=%s ignored, too many ports\n", str);
++ pr_err("parport=%s ignored, too many ports\n", str);
+ return 1;
+ }
+
+diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
+index d5a669b60c276..e840c1b5ab908 100644
+--- a/drivers/parport/parport_sunbpp.c
++++ b/drivers/parport/parport_sunbpp.c
+@@ -314,7 +314,7 @@ static int bpp_probe(struct platform_device *op)
+ value_tcr &= ~P_TCR_DIR;
+ sbus_writeb(value_tcr, ®s->p_tcr);
+
+- printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base);
++ pr_info("%s: sunbpp at 0x%lx\n", p->name, p->base);
+
+ dev_set_drvdata(&op->dev, p);
+
+diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
+index e035174ba205d..650206c71875b 100644
+--- a/drivers/parport/probe.c
++++ b/drivers/parport/probe.c
+@@ -38,7 +38,7 @@ static void pretty_print(struct parport *port, int device)
+ {
+ struct parport_device_info *info = &port->probe_info[device + 1];
+
+- printk(KERN_INFO "%s", port->name);
++ pr_info("%s", port->name);
+
+ if (device >= 0)
+ printk (" (addr %d)", device);
+@@ -58,7 +58,7 @@ static void parse_data(struct parport *port, int device, char *str)
+ struct parport_device_info *info = &port->probe_info[device + 1];
+
+ if (!txt) {
+- printk(KERN_WARNING "%s probe: memory squeeze\n", port->name);
++ pr_warn("%s probe: memory squeeze\n", port->name);
+ return;
+ }
+ strcpy(txt, str);
+@@ -98,7 +98,8 @@ static void parse_data(struct parport *port, int device, char *str)
+ goto rock_on;
+ }
+ }
+- printk(KERN_WARNING "%s probe: warning, class '%s' not understood.\n", port->name, sep);
++ pr_warn("%s probe: warning, class '%s' not understood\n",
++ port->name, sep);
+ info->class = PARPORT_CLASS_OTHER;
+ } else if (!strcmp(p, "CMD") ||
+ !strcmp(p, "COMMAND SET")) {
+diff --git a/drivers/parport/share.c b/drivers/parport/share.c
+index 15c81cffd2de2..fc2930fb9bee1 100644
+--- a/drivers/parport/share.c
++++ b/drivers/parport/share.c
+@@ -555,8 +555,8 @@ void parport_announce_port(struct parport *port)
+ #endif
+
+ if (!port->dev)
+- printk(KERN_WARNING "%s: fix this legacy no-device port driver!\n",
+- port->name);
++ pr_warn("%s: fix this legacy no-device port driver!\n",
++ port->name);
+
+ parport_proc_register(port);
+ mutex_lock(®istration_lock);
+@@ -728,7 +728,8 @@ parport_register_device(struct parport *port, const char *name,
+
+ if (flags & PARPORT_DEV_LURK) {
+ if (!pf || !kf) {
+- printk(KERN_INFO "%s: refused to register lurking device (%s) without callbacks\n", port->name, name);
++ pr_info("%s: refused to register lurking device (%s) without callbacks\n",
++ port->name, name);
+ return NULL;
+ }
+ }
+@@ -997,7 +998,7 @@ void parport_unregister_device(struct pardevice *dev)
+
+ #ifdef PARPORT_PARANOID
+ if (!dev) {
+- printk(KERN_ERR "parport_unregister_device: passed NULL\n");
++ pr_err("%s: passed NULL\n", __func__);
+ return;
+ }
+ #endif
+@@ -1138,8 +1139,7 @@ int parport_claim(struct pardevice *dev)
+ unsigned long flags;
+
+ if (port->cad == dev) {
+- printk(KERN_INFO "%s: %s already owner\n",
+- dev->port->name,dev->name);
++ pr_info("%s: %s already owner\n", dev->port->name, dev->name);
+ return 0;
+ }
+
+@@ -1159,9 +1159,8 @@ int parport_claim(struct pardevice *dev)
+ * I think we'll actually deadlock rather than
+ * get here, but just in case..
+ */
+- printk(KERN_WARNING
+- "%s: %s released port when preempted!\n",
+- port->name, oldcad->name);
++ pr_warn("%s: %s released port when preempted!\n",
++ port->name, oldcad->name);
+ if (port->cad)
+ goto blocked;
+ }
+@@ -1321,8 +1320,8 @@ void parport_release(struct pardevice *dev)
+ write_lock_irqsave(&port->cad_lock, flags);
+ if (port->cad != dev) {
+ write_unlock_irqrestore(&port->cad_lock, flags);
+- printk(KERN_WARNING "%s: %s tried to release parport when not owner\n",
+- port->name, dev->name);
++ pr_warn("%s: %s tried to release parport when not owner\n",
++ port->name, dev->name);
+ return;
+ }
+
+@@ -1362,7 +1361,8 @@ void parport_release(struct pardevice *dev)
+ if (dev->port->cad) /* racy but no matter */
+ return;
+ } else {
+- printk(KERN_ERR "%s: don't know how to wake %s\n", port->name, pd->name);
++ pr_err("%s: don't know how to wake %s\n",
++ port->name, pd->name);
+ }
+ }
+
+--
+2.43.0
+
--- /dev/null
+From 4016d768844b37b9a704e4ce06f1ac1ff62b6694 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Apr 2020 14:43:22 +0100
+Subject: parport: Standardize use of printmode
+
+From: Joe Perches <joe@perches.com>
+
+[ Upstream commit a6abfdff4fe5dd19d1f1b37d72ba34cd4492fd4d ]
+
+Standardize the define and the uses of printmode.
+
+Miscellanea:
+
+o Add missing statement termination ; where necessary
+
+Signed-off-by: Joe Perches <joe@perches.com>
+Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Link: https://lore.kernel.org/r/20200403134325.11523-8-sudipm.mukherjee@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/parport/parport_gsc.c | 8 ++++++--
+ drivers/parport/parport_pc.c | 14 ++++++--------
+ drivers/parport/procfs.c | 6 +++++-
+ 3 files changed, 17 insertions(+), 11 deletions(-)
+
+diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
+index 81082d5899b06..54963f5033fab 100644
+--- a/drivers/parport/parport_gsc.c
++++ b/drivers/parport/parport_gsc.c
+@@ -299,12 +299,16 @@ struct parport *parport_gsc_probe_port(unsigned long base,
+ p->dma = PARPORT_DMA_NONE;
+
+ pr_cont(" [");
+-#define printmode(x) {if(p->modes&PARPORT_MODE_##x){pr_cont("%s%s",f?",":"",#x);f++;}}
++#define printmode(x) \
++do { \
++ if (p->modes & PARPORT_MODE_##x) \
++ pr_cont("%s%s", f++ ? "," : "", #x); \
++} while (0)
+ {
+ int f = 0;
+ printmode(PCSPP);
+ printmode(TRISTATE);
+- printmode(COMPAT)
++ printmode(COMPAT);
+ printmode(EPP);
+ // printmode(ECP);
+ // printmode(DMA);
+diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
+index 4acf3d017a187..bf9fe2c025490 100644
+--- a/drivers/parport/parport_pc.c
++++ b/drivers/parport/parport_pc.c
+@@ -2143,19 +2143,17 @@ struct parport *parport_pc_probe_port(unsigned long int base,
+
+ pr_cont(" [");
+
+-#define printmode(x) \
+- {\
+- if (p->modes & PARPORT_MODE_##x) {\
+- pr_cont("%s%s", f ? "," : "", #x); \
+- f++;\
+- } \
+- }
++#define printmode(x) \
++do { \
++ if (p->modes & PARPORT_MODE_##x) \
++ pr_cont("%s%s", f++ ? "," : "", #x); \
++} while (0)
+
+ {
+ int f = 0;
+ printmode(PCSPP);
+ printmode(TRISTATE);
+- printmode(COMPAT)
++ printmode(COMPAT);
+ printmode(EPP);
+ printmode(ECP);
+ printmode(DMA);
+diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
+index 48804049d6972..e957beb94f142 100644
+--- a/drivers/parport/procfs.c
++++ b/drivers/parport/procfs.c
+@@ -213,7 +213,11 @@ static int do_hardware_modes(struct ctl_table *table, int write,
+ return -EACCES;
+
+ {
+-#define printmode(x) {if(port->modes&PARPORT_MODE_##x){len+=sprintf(buffer+len,"%s%s",f?",":"",#x);f++;}}
++#define printmode(x) \
++do { \
++ if (port->modes & PARPORT_MODE_##x) \
++ len += sprintf(buffer + len, "%s%s", f++ ? "," : "", #x); \
++} while (0)
+ int f = 0;
+ printmode(PCSPP);
+ printmode(TRISTATE);
+--
+2.43.0
+
--- /dev/null
+From 55e01693e1e2c975afe3f4806b0b3b000b1ef076 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 22 Jan 2021 00:23:18 +0800
+Subject: PCI: rockchip: Make 'ep-gpios' DT property optional
+
+From: Chen-Yu Tsai <wens@csie.org>
+
+[ Upstream commit 58adbfb3ebec460e8b58875c682bafd866808e80 ]
+
+The Rockchip PCIe controller DT binding clearly states that 'ep-gpios' is
+an optional property. And indeed there are boards that don't require it.
+
+Make the driver follow the binding by using devm_gpiod_get_optional()
+instead of devm_gpiod_get().
+
+[bhelgaas: tidy whitespace]
+Link: https://lore.kernel.org/r/20210121162321.4538-2-wens@kernel.org
+Fixes: e77f847df54c ("PCI: rockchip: Add Rockchip PCIe controller support")
+Fixes: 956cd99b35a8 ("PCI: rockchip: Separate common code from RC driver")
+Fixes: 964bac9455be ("PCI: rockchip: Split out rockchip_pcie_parse_dt() to parse DT")
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Stable-dep-of: 840b7a5edf88 ("PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/controller/pcie-rockchip.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c
+index b047437605cb2..c6d2f00acf890 100644
+--- a/drivers/pci/controller/pcie-rockchip.c
++++ b/drivers/pci/controller/pcie-rockchip.c
+@@ -84,7 +84,7 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
+ }
+
+ rockchip->mgmt_sticky_rst = devm_reset_control_get_exclusive(dev,
+- "mgmt-sticky");
++ "mgmt-sticky");
+ if (IS_ERR(rockchip->mgmt_sticky_rst)) {
+ if (PTR_ERR(rockchip->mgmt_sticky_rst) != -EPROBE_DEFER)
+ dev_err(dev, "missing mgmt-sticky reset property in node\n");
+@@ -120,11 +120,11 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
+ }
+
+ if (rockchip->is_rc) {
+- rockchip->ep_gpio = devm_gpiod_get(dev, "ep", GPIOD_OUT_HIGH);
+- if (IS_ERR(rockchip->ep_gpio)) {
+- dev_err(dev, "missing ep-gpios property in node\n");
+- return PTR_ERR(rockchip->ep_gpio);
+- }
++ rockchip->ep_gpio = devm_gpiod_get_optional(dev, "ep",
++ GPIOD_OUT_HIGH);
++ if (IS_ERR(rockchip->ep_gpio))
++ return dev_err_probe(dev, PTR_ERR(rockchip->ep_gpio),
++ "failed to get ep GPIO\n");
+ }
+
+ rockchip->aclk_pcie = devm_clk_get(dev, "aclk");
+--
+2.43.0
+
--- /dev/null
+From 72cca93637e91e3ff0866eb30c20cba986b7eb49 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 Apr 2024 11:12:35 +0530
+Subject: PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+
+[ Upstream commit 840b7a5edf88fe678c60dee88a135647c0ea4375 ]
+
+Rockchip platforms use 'GPIO_ACTIVE_HIGH' flag in the devicetree definition
+for ep_gpio. This means, whatever the logical value set by the driver for
+the ep_gpio, physical line will output the same logic level.
+
+For instance,
+
+ gpiod_set_value_cansleep(rockchip->ep_gpio, 0); --> Level low
+ gpiod_set_value_cansleep(rockchip->ep_gpio, 1); --> Level high
+
+But while requesting the ep_gpio, GPIOD_OUT_HIGH flag is currently used.
+Now, this also causes the physical line to output 'high' creating trouble
+for endpoint devices during host reboot.
+
+When host reboot happens, the ep_gpio will initially output 'low' due to
+the GPIO getting reset to its POR value. Then during host controller probe,
+it will output 'high' due to GPIOD_OUT_HIGH flag. Then during
+rockchip_pcie_host_init_port(), it will first output 'low' and then 'high'
+indicating the completion of controller initialization.
+
+On the endpoint side, each output 'low' of ep_gpio is accounted for PERST#
+assert and 'high' for PERST# deassert. With the above mentioned flow during
+host reboot, endpoint will witness below state changes for PERST#:
+
+ (1) PERST# assert - GPIO POR state
+ (2) PERST# deassert - GPIOD_OUT_HIGH while requesting GPIO
+ (3) PERST# assert - rockchip_pcie_host_init_port()
+ (4) PERST# deassert - rockchip_pcie_host_init_port()
+
+Now the time interval between (2) and (3) is very short as both happen
+during the driver probe(), and this results in a race in the endpoint.
+Because, before completing the PERST# deassertion in (2), endpoint got
+another PERST# assert in (3).
+
+A proper way to fix this issue is to change the GPIOD_OUT_HIGH flag in (2)
+to GPIOD_OUT_LOW. Because the usual convention is to request the GPIO with
+a state corresponding to its 'initial/default' value and let the driver
+change the state of the GPIO when required.
+
+As per that, the ep_gpio should be requested with GPIOD_OUT_LOW as it
+corresponds to the POR value of '0' (PERST# assert in the endpoint). Then
+the driver can change the state of the ep_gpio later in
+rockchip_pcie_host_init_port() as per the initialization sequence.
+
+This fixes the firmware crash issue in Qcom based modems connected to
+Rockpro64 based board.
+
+Fixes: e77f847df54c ("PCI: rockchip: Add Rockchip PCIe controller support")
+Closes: https://lore.kernel.org/mhi/20240402045647.GG2933@thinkpad/
+Link: https://lore.kernel.org/linux-pci/20240416-pci-rockchip-perst-fix-v1-1-4800b1d4d954@linaro.org
+Reported-by: Slark Xiao <slark_xiao@163.com>
+Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+Signed-off-by: Krzysztof WilczyĆski <kwilczynski@kernel.org>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Reviewed-by: Niklas Cassel <cassel@kernel.org>
+Cc: stable@vger.kernel.org # v4.9
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/controller/pcie-rockchip.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c
+index c6d2f00acf890..6ab7ca0b9bf9e 100644
+--- a/drivers/pci/controller/pcie-rockchip.c
++++ b/drivers/pci/controller/pcie-rockchip.c
+@@ -121,7 +121,7 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
+
+ if (rockchip->is_rc) {
+ rockchip->ep_gpio = devm_gpiod_get_optional(dev, "ep",
+- GPIOD_OUT_HIGH);
++ GPIOD_OUT_LOW);
+ if (IS_ERR(rockchip->ep_gpio))
+ return dev_err_probe(dev, PTR_ERR(rockchip->ep_gpio),
+ "failed to get ep GPIO\n");
+--
+2.43.0
+
--- /dev/null
+From 2bf1a0874d58c4c83672dbf28e7eb002539d926f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Sep 2021 17:06:19 +0800
+Subject: remoteproc: imx_rproc: Fix ignoring mapping vdev regions
+
+From: Dong Aisheng <aisheng.dong@nxp.com>
+
+[ Upstream commit afe670e23af91d8a74a8d7049f6e0984bbf6ea11 ]
+
+vdev regions are typically named vdev0buffer, vdev0ring0, vdev0ring1 and
+etc. Change to strncmp to cover them all.
+
+Fixes: 8f2d8961640f ("remoteproc: imx_rproc: ignore mapping vdev regions")
+Reviewed-and-tested-by: Peng Fan <peng.fan@nxp.com>
+Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Cc: stable <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20210910090621.3073540-5-peng.fan@oss.nxp.com
+Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Stable-dep-of: 2fa26ca8b786 ("remoteproc: imx_rproc: Skip over memory region when node value is NULL")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/remoteproc/imx_rproc.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
+index 05b724fdca591..0e6246678bc2b 100644
+--- a/drivers/remoteproc/imx_rproc.c
++++ b/drivers/remoteproc/imx_rproc.c
+@@ -286,8 +286,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
+ struct resource res;
+
+ node = of_parse_phandle(np, "memory-region", a);
+- /* Not map vdev region */
+- if (!strcmp(node->name, "vdev"))
++ /* Not map vdevbuffer, vdevring region */
++ if (!strncmp(node->name, "vdev", strlen("vdev")))
+ continue;
+ err = of_address_to_resource(node, 0, &res);
+ if (err) {
+--
+2.43.0
+
--- /dev/null
+From a33e0de4322cad81d3eed3ce4bd6a7a90d4c6aa6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 6 Mar 2021 19:24:24 +0800
+Subject: remoteproc: imx_rproc: ignore mapping vdev regions
+
+From: Peng Fan <peng.fan@nxp.com>
+
+[ Upstream commit 8f2d8961640f0346cbe892273c3260a0d30c1931 ]
+
+vdev regions are vdev0vring0, vdev0vring1, vdevbuffer and similar.
+They are handled by remoteproc common code, no need to map in imx
+rproc driver.
+
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
+Link: https://lore.kernel.org/r/1615029865-23312-10-git-send-email-peng.fan@oss.nxp.com
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Stable-dep-of: 2fa26ca8b786 ("remoteproc: imx_rproc: Skip over memory region when node value is NULL")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/remoteproc/imx_rproc.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
+index 3e72b6f38d4bc..05b724fdca591 100644
+--- a/drivers/remoteproc/imx_rproc.c
++++ b/drivers/remoteproc/imx_rproc.c
+@@ -286,6 +286,9 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
+ struct resource res;
+
+ node = of_parse_phandle(np, "memory-region", a);
++ /* Not map vdev region */
++ if (!strcmp(node->name, "vdev"))
++ continue;
+ err = of_address_to_resource(node, 0, &res);
+ if (err) {
+ dev_err(dev, "unable to resolve memory region\n");
+--
+2.43.0
+
--- /dev/null
+From ca1dbf3654c8b179de2281eb9977c57066e06895 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 6 Jun 2024 10:52:04 +0300
+Subject: remoteproc: imx_rproc: Skip over memory region when node value is
+ NULL
+
+From: Aleksandr Mishin <amishin@t-argos.ru>
+
+[ Upstream commit 2fa26ca8b786888673689ccc9da6094150939982 ]
+
+In imx_rproc_addr_init() "nph = of_count_phandle_with_args()" just counts
+number of phandles. But phandles may be empty. So of_parse_phandle() in
+the parsing loop (0 < a < nph) may return NULL which is later dereferenced.
+Adjust this issue by adding NULL-return check.
+
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver")
+Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
+Reviewed-by: Peng Fan <peng.fan@nxp.com>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20240606075204.12354-1-amishin@t-argos.ru
+[Fixed title to fit within the prescribed 70-75 charcters]
+Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/remoteproc/imx_rproc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
+index 0e6246678bc2b..3f3d1eb94e6fa 100644
+--- a/drivers/remoteproc/imx_rproc.c
++++ b/drivers/remoteproc/imx_rproc.c
+@@ -286,6 +286,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
+ struct resource res;
+
+ node = of_parse_phandle(np, "memory-region", a);
++ if (!node)
++ continue;
+ /* Not map vdevbuffer, vdevring region */
+ if (!strncmp(node->name, "vdev", strlen("vdev")))
+ continue;
+--
+2.43.0
+
s390-pci-refactor-arch_setup_msi_irqs.patch
s390-pci-allow-allocation-of-more-than-1-msi-interru.patch
nvme-pci-add-missing-condition-check-for-existence-o.patch
+mm-avoid-overflows-in-dirty-throttling-logic.patch
+pci-rockchip-make-ep-gpios-dt-property-optional.patch
+pci-rockchip-use-gpiod_out_low-flag-while-requesting.patch
+parport-convert-printk-kern_-level-to-pr_-level.patch
+parport-standardize-use-of-printmode.patch
+dev-parport-fix-the-array-out-of-bounds-risk.patch
+driver-core-cast-to-void-with-__force-for-__percpu-p.patch
+devres-fix-memory-leakage-caused-by-driver-api-devm_.patch
+genirq-allow-the-pm-device-to-originate-from-irq-dom.patch
+irqchip-imx-irqsteer-constify-irq_chip-struct.patch
+irqchip-imx-irqsteer-add-runtime-pm-support.patch
+irqchip-imx-irqsteer-handle-runtime-power-management.patch
+remoteproc-imx_rproc-ignore-mapping-vdev-regions.patch
+remoteproc-imx_rproc-fix-ignoring-mapping-vdev-regio.patch
+remoteproc-imx_rproc-skip-over-memory-region-when-no.patch