From: Sasha Levin Date: Sat, 3 Aug 2024 14:48:15 +0000 (-0400) Subject: Fixes for 4.19 X-Git-Tag: v6.1.104~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3fefc3d67b52d1d0483de17abfc7b6e43400b53a;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/dev-parport-fix-the-array-out-of-bounds-risk.patch b/queue-4.19/dev-parport-fix-the-array-out-of-bounds-risk.patch new file mode 100644 index 00000000000..6f45f2729a8 --- /dev/null +++ b/queue-4.19/dev-parport-fix-the-array-out-of-bounds-risk.patch @@ -0,0 +1,131 @@ +From c352728f5adf4102773360ca9ad94c2cb85bde1e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Jul 2024 16:04:30 +0800 +Subject: dev/parport: fix the array out-of-bounds risk + +From: tuhaowen + +[ 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 +Cc: stable +Link: https://lore.kernel.org/r/20240708080430.8221-1-tuhaowen@uniontech.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-4.19/devres-fix-memory-leakage-caused-by-driver-api-devm_.patch b/queue-4.19/devres-fix-memory-leakage-caused-by-driver-api-devm_.patch new file mode 100644 index 00000000000..091bc8ab4ef --- /dev/null +++ b/queue-4.19/devres-fix-memory-leakage-caused-by-driver-api-devm_.patch @@ -0,0 +1,43 @@ +From 3118440960d85e553bdf85118fa635307bf519bc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 2 Jul 2024 22:51:51 +0800 +Subject: devres: Fix memory leakage caused by driver API devm_free_percpu() + +From: Zijun Hu + +[ 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 +Link: https://lore.kernel.org/r/1719931914-19035-3-git-send-email-quic_zijuhu@quicinc.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + 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 7b4346798d5fb..a64f70a62e28f 100644 +--- a/drivers/base/devres.c ++++ b/drivers/base/devres.c +@@ -1057,7 +1057,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 + diff --git a/queue-4.19/driver-core-cast-to-void-with-__force-for-__percpu-p.patch b/queue-4.19/driver-core-cast-to-void-with-__force-for-__percpu-p.patch new file mode 100644 index 00000000000..1d04c546c88 --- /dev/null +++ b/queue-4.19/driver-core-cast-to-void-with-__force-for-__percpu-p.patch @@ -0,0 +1,39 @@ +From 7c8311779abb4743af7b8765f4c2361f40860485 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 1 Apr 2021 20:10:30 +0300 +Subject: driver core: Cast to (void *) with __force for __percpu pointer + +From: Andy Shevchenko + +[ 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 +Link: https://lore.kernel.org/r/20210401171030.60527-1-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: bd50a974097b ("devres: Fix memory leakage caused by driver API devm_free_percpu()") +Signed-off-by: Sasha Levin +--- + 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 d68b52cf92251..7b4346798d5fb 100644 +--- a/drivers/base/devres.c ++++ b/drivers/base/devres.c +@@ -1058,6 +1058,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 + diff --git a/queue-4.19/mm-avoid-overflows-in-dirty-throttling-logic.patch b/queue-4.19/mm-avoid-overflows-in-dirty-throttling-logic.patch new file mode 100644 index 00000000000..bbf05f2ede9 --- /dev/null +++ b/queue-4.19/mm-avoid-overflows-in-dirty-throttling-logic.patch @@ -0,0 +1,108 @@ +From 800434e769a5b7ce3ea0fd3c95e914eab0796154 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 21 Jun 2024 16:42:38 +0200 +Subject: mm: avoid overflows in dirty throttling logic + +From: Jan Kara + +[ 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 +Reported-by: Zach O'Keefe +Reviewed-By: Zach O'Keefe +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + 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 078f1461e0746..ed19e580144a6 100644 +--- a/mm/page-writeback.c ++++ b/mm/page-writeback.c +@@ -432,13 +432,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; + +@@ -488,7 +495,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); + } + + /** +@@ -527,10 +538,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; + } + +@@ -558,6 +576,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 + diff --git a/queue-4.19/parport-convert-printk-kern_-level-to-pr_-level.patch b/queue-4.19/parport-convert-printk-kern_-level-to-pr_-level.patch new file mode 100644 index 00000000000..9ca11489494 --- /dev/null +++ b/queue-4.19/parport-convert-printk-kern_-level-to-pr_-level.patch @@ -0,0 +1,808 @@ +From 915b6ea219d9d972badb62288f457fd14adf0948 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Apr 2020 14:43:16 +0100 +Subject: parport: Convert printk(KERN_ to pr_( + +From: Joe Perches + +[ Upstream commit decf26f6ec25dac868782dc1751623a87d147831 ] + +Use the more common kernel style. + +Miscellanea: + +o Coalesce formats +o Realign arguments + +Signed-off-by: Joe Perches +Reviewed-by: Randy Dunlap +Signed-off-by: Sudip Mukherjee +Link: https://lore.kernel.org/r/20200403134325.11523-2-sudipm.mukherjee@gmail.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk") +Signed-off-by: Sasha Levin +--- + 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 f12b9da692551..d0d36c29ae56e 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 9c68f2aec4ff7..75779725f6384 100644 +--- a/drivers/parport/parport_amiga.c ++++ b/drivers/parport/parport_amiga.c +@@ -211,7 +211,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 9fbf6ccd54de7..2f8c7f6617d71 100644 +--- a/drivers/parport/parport_atari.c ++++ b/drivers/parport/parport_atari.c +@@ -199,7 +199,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 e9b52e4a4648f..755207ca155f0 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 190c0a7a1c526..7e2dd330831cf 100644 +--- a/drivers/parport/parport_gsc.c ++++ b/drivers/parport/parport_gsc.c +@@ -287,7 +287,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; +@@ -320,8 +320,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; +@@ -352,7 +351,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 62873070f988e..c92523b6a3cb9 100644 +--- a/drivers/parport/parport_ip32.c ++++ b/drivers/parport/parport_ip32.c +@@ -1348,9 +1348,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; + } + } +@@ -1654,8 +1653,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; + } +@@ -1735,8 +1734,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; + } +@@ -2075,8 +2074,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; +@@ -2088,8 +2086,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 { +@@ -2102,8 +2099,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 */ +@@ -2145,8 +2141,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 7f4be0e484c74..378b6bce3ae70 100644 +--- a/drivers/parport/parport_mfc3.c ++++ b/drivers/parport/parport_mfc3.c +@@ -324,7 +324,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 1f9908b1d9d6c..2bc5593b76067 100644 +--- a/drivers/parport/parport_pc.c ++++ b/drivers/parport/parport_pc.c +@@ -981,28 +981,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 +@@ -1012,7 +1008,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) { +@@ -1077,26 +1073,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; +@@ -1150,9 +1144,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); +@@ -1183,9 +1176,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); +@@ -1357,7 +1349,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 */ +@@ -1444,8 +1436,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. */ +@@ -1463,10 +1455,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); + } + +@@ -1641,7 +1632,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. */ +@@ -1656,17 +1647,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; +@@ -2106,9 +2094,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); +@@ -2119,7 +2107,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) { +@@ -2143,21 +2131,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++;\ + } \ + } +@@ -2173,11 +2161,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) { +@@ -2192,8 +2180,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; +@@ -2203,8 +2190,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 { +@@ -2214,9 +2200,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; +@@ -2329,7 +2313,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; + } + +@@ -2338,29 +2322,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; + } +@@ -2395,9 +2378,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"); +@@ -2524,7 +2506,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; + } + +@@ -2557,9 +2539,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; + } + +@@ -2578,8 +2559,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) +@@ -2588,7 +2568,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; + } +@@ -3131,7 +3111,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; + } + } +@@ -3221,10 +3201,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)) +@@ -3234,10 +3211,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; +@@ -3276,12 +3250,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 8de329546b822..77671b7ad421e 100644 +--- a/drivers/parport/parport_sunbpp.c ++++ b/drivers/parport/parport_sunbpp.c +@@ -313,7 +313,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 + diff --git a/queue-4.19/parport-parport_pc-mark-expected-switch-fall-through.patch b/queue-4.19/parport-parport_pc-mark-expected-switch-fall-through.patch new file mode 100644 index 00000000000..912e9a779b0 --- /dev/null +++ b/queue-4.19/parport-parport_pc-mark-expected-switch-fall-through.patch @@ -0,0 +1,38 @@ +From efebd163f0d2aba6b43f62f3a44f46b9e0cdbc5a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 25 Nov 2018 21:48:45 +0000 +Subject: parport: parport_pc: Mark expected switch fall-through + +From: Gustavo A. R. Silva + +[ Upstream commit aa1f0fa374ed23528b915a693a11b0f275a299c0 ] + +In preparation to enabling -Wimplicit-fallthrough, mark switch cases +where we are expecting to fall through. + +Addresses-Coverity-ID: 114730 ("Missing break in switch") +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk") +Signed-off-by: Sasha Levin +--- + drivers/parport/parport_pc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c +index c34ad5dd62e3d..1f9908b1d9d6c 100644 +--- a/drivers/parport/parport_pc.c ++++ b/drivers/parport/parport_pc.c +@@ -1667,7 +1667,7 @@ static int parport_ECP_supported(struct parport *pb) + default: + printk(KERN_WARNING "0x%lx: Unknown implementation ID\n", + pb->base); +- /* Assume 1 */ ++ /* Fall through - Assume 1 */ + case 1: + pword = 1; + } +-- +2.43.0 + diff --git a/queue-4.19/parport-standardize-use-of-printmode.patch b/queue-4.19/parport-standardize-use-of-printmode.patch new file mode 100644 index 00000000000..9413ce1ecbc --- /dev/null +++ b/queue-4.19/parport-standardize-use-of-printmode.patch @@ -0,0 +1,101 @@ +From 09ebc8e9384768cf92ed4b8cfe992a6a9578a705 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Apr 2020 14:43:22 +0100 +Subject: parport: Standardize use of printmode + +From: Joe Perches + +[ Upstream commit a6abfdff4fe5dd19d1f1b37d72ba34cd4492fd4d ] + +Standardize the define and the uses of printmode. + +Miscellanea: + +o Add missing statement termination ; where necessary + +Signed-off-by: Joe Perches +Reviewed-by: Randy Dunlap +Signed-off-by: Sudip Mukherjee +Link: https://lore.kernel.org/r/20200403134325.11523-8-sudipm.mukherjee@gmail.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk") +Signed-off-by: Sasha Levin +--- + 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 7e2dd330831cf..467bc0ab95ec1 100644 +--- a/drivers/parport/parport_gsc.c ++++ b/drivers/parport/parport_gsc.c +@@ -304,12 +304,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 2bc5593b76067..ad2acafb68506 100644 +--- a/drivers/parport/parport_pc.c ++++ b/drivers/parport/parport_pc.c +@@ -2142,19 +2142,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 + diff --git a/queue-4.19/pci-rockchip-make-ep-gpios-dt-property-optional.patch b/queue-4.19/pci-rockchip-make-ep-gpios-dt-property-optional.patch new file mode 100644 index 00000000000..e993fc5d22e --- /dev/null +++ b/queue-4.19/pci-rockchip-make-ep-gpios-dt-property-optional.patch @@ -0,0 +1,62 @@ +From d5ad044decaa325993a8eea1fbe41e4d5169e468 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 22 Jan 2021 00:23:18 +0800 +Subject: PCI: rockchip: Make 'ep-gpios' DT property optional + +From: Chen-Yu Tsai + +[ 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 +Signed-off-by: Lorenzo Pieralisi +Signed-off-by: Bjorn Helgaas +Stable-dep-of: 840b7a5edf88 ("PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio") +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-4.19/pci-rockchip-use-gpiod_out_low-flag-while-requesting.patch b/queue-4.19/pci-rockchip-use-gpiod_out_low-flag-while-requesting.patch new file mode 100644 index 00000000000..79d37f9e2a6 --- /dev/null +++ b/queue-4.19/pci-rockchip-use-gpiod_out_low-flag-while-requesting.patch @@ -0,0 +1,88 @@ +From a18398582097bd6e9eef2ae195bed58807ceee2d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Signed-off-by: Manivannan Sadhasivam +Signed-off-by: Krzysztof Wilczyński +Signed-off-by: Bjorn Helgaas +Reviewed-by: Niklas Cassel +Cc: stable@vger.kernel.org # v4.9 +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-4.19/perf-x86-intel-pt-export-pt_cap_get.patch b/queue-4.19/perf-x86-intel-pt-export-pt_cap_get.patch new file mode 100644 index 00000000000..d96339c9bdf --- /dev/null +++ b/queue-4.19/perf-x86-intel-pt-export-pt_cap_get.patch @@ -0,0 +1,306 @@ +From 365fb2a456bd36b6d3db1d154a9a6a36ea7acd5b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Oct 2018 16:05:06 +0800 +Subject: perf/x86/intel/pt: Export pt_cap_get() + +From: Chao Peng + +[ Upstream commit f6d079ce867d679e4dffef5b3112c7634215fd88 ] + +pt_cap_get() is required by the upcoming PT support in KVM guests. + +Export it and move the capabilites enum to a global header. + +As a global functions, "pt_*" is already used for ptrace and +other things, so it makes sense to use "intel_pt_*" as a prefix. + +Acked-by: Song Liu +Signed-off-by: Chao Peng +Signed-off-by: Luwei Kang +Signed-off-by: Paolo Bonzini +Stable-dep-of: ad97196379d0 ("perf/x86/intel/pt: Fix a topa_entry base address calculation") +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/pt.c | 49 +++++++++++++++++---------------- + arch/x86/events/intel/pt.h | 21 -------------- + arch/x86/include/asm/intel_pt.h | 23 ++++++++++++++++ + 3 files changed, 49 insertions(+), 44 deletions(-) + +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c +index 49b3ea1c1ea19..62ef4b68f04c6 100644 +--- a/arch/x86/events/intel/pt.c ++++ b/arch/x86/events/intel/pt.c +@@ -75,7 +75,7 @@ static struct pt_cap_desc { + PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000), + }; + +-static u32 pt_cap_get(enum pt_capabilities cap) ++u32 intel_pt_validate_hw_cap(enum pt_capabilities cap) + { + struct pt_cap_desc *cd = &pt_caps[cap]; + u32 c = pt_pmu.caps[cd->leaf * PT_CPUID_REGS_NUM + cd->reg]; +@@ -83,6 +83,7 @@ static u32 pt_cap_get(enum pt_capabilities cap) + + return (c & cd->mask) >> shift; + } ++EXPORT_SYMBOL_GPL(intel_pt_validate_hw_cap); + + static ssize_t pt_cap_show(struct device *cdev, + struct device_attribute *attr, +@@ -92,7 +93,7 @@ static ssize_t pt_cap_show(struct device *cdev, + container_of(attr, struct dev_ext_attribute, attr); + enum pt_capabilities cap = (long)ea->var; + +- return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); ++ return snprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap)); + } + + static struct attribute_group pt_cap_group = { +@@ -310,16 +311,16 @@ static bool pt_event_valid(struct perf_event *event) + return false; + + if (config & RTIT_CTL_CYC_PSB) { +- if (!pt_cap_get(PT_CAP_psb_cyc)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_psb_cyc)) + return false; + +- allowed = pt_cap_get(PT_CAP_psb_periods); ++ allowed = intel_pt_validate_hw_cap(PT_CAP_psb_periods); + requested = (config & RTIT_CTL_PSB_FREQ) >> + RTIT_CTL_PSB_FREQ_OFFSET; + if (requested && (!(allowed & BIT(requested)))) + return false; + +- allowed = pt_cap_get(PT_CAP_cycle_thresholds); ++ allowed = intel_pt_validate_hw_cap(PT_CAP_cycle_thresholds); + requested = (config & RTIT_CTL_CYC_THRESH) >> + RTIT_CTL_CYC_THRESH_OFFSET; + if (requested && (!(allowed & BIT(requested)))) +@@ -334,10 +335,10 @@ static bool pt_event_valid(struct perf_event *event) + * Spec says that setting mtc period bits while mtc bit in + * CPUID is 0 will #GP, so better safe than sorry. + */ +- if (!pt_cap_get(PT_CAP_mtc)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_mtc)) + return false; + +- allowed = pt_cap_get(PT_CAP_mtc_periods); ++ allowed = intel_pt_validate_hw_cap(PT_CAP_mtc_periods); + if (!allowed) + return false; + +@@ -349,11 +350,11 @@ static bool pt_event_valid(struct perf_event *event) + } + + if (config & RTIT_CTL_PWR_EVT_EN && +- !pt_cap_get(PT_CAP_power_event_trace)) ++ !intel_pt_validate_hw_cap(PT_CAP_power_event_trace)) + return false; + + if (config & RTIT_CTL_PTW) { +- if (!pt_cap_get(PT_CAP_ptwrite)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_ptwrite)) + return false; + + /* FUPonPTW without PTW doesn't make sense */ +@@ -598,7 +599,7 @@ static struct topa *topa_alloc(int cpu, gfp_t gfp) + * In case of singe-entry ToPA, always put the self-referencing END + * link as the 2nd entry in the table + */ +- if (!pt_cap_get(PT_CAP_topa_multiple_entries)) { ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) { + TOPA_ENTRY(topa, 1)->base = topa->phys >> TOPA_SHIFT; + TOPA_ENTRY(topa, 1)->end = 1; + } +@@ -638,7 +639,7 @@ static void topa_insert_table(struct pt_buffer *buf, struct topa *topa) + topa->offset = last->offset + last->size; + buf->last = topa; + +- if (!pt_cap_get(PT_CAP_topa_multiple_entries)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) + return; + + BUG_ON(last->last != TENTS_PER_PAGE - 1); +@@ -654,7 +655,7 @@ static void topa_insert_table(struct pt_buffer *buf, struct topa *topa) + static bool topa_table_full(struct topa *topa) + { + /* single-entry ToPA is a special case */ +- if (!pt_cap_get(PT_CAP_topa_multiple_entries)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) + return !!topa->last; + + return topa->last == TENTS_PER_PAGE - 1; +@@ -690,7 +691,8 @@ static int topa_insert_pages(struct pt_buffer *buf, gfp_t gfp) + + TOPA_ENTRY(topa, -1)->base = page_to_phys(p) >> TOPA_SHIFT; + TOPA_ENTRY(topa, -1)->size = order; +- if (!buf->snapshot && !pt_cap_get(PT_CAP_topa_multiple_entries)) { ++ if (!buf->snapshot && ++ !intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) { + TOPA_ENTRY(topa, -1)->intr = 1; + TOPA_ENTRY(topa, -1)->stop = 1; + } +@@ -725,7 +727,7 @@ static void pt_topa_dump(struct pt_buffer *buf) + topa->table[i].intr ? 'I' : ' ', + topa->table[i].stop ? 'S' : ' ', + *(u64 *)&topa->table[i]); +- if ((pt_cap_get(PT_CAP_topa_multiple_entries) && ++ if ((intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) && + topa->table[i].stop) || + topa->table[i].end) + break; +@@ -828,7 +830,7 @@ static void pt_handle_status(struct pt *pt) + * means we are already losing data; need to let the decoder + * know. + */ +- if (!pt_cap_get(PT_CAP_topa_multiple_entries) || ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || + buf->output_off == sizes(TOPA_ENTRY(buf->cur, buf->cur_idx)->size)) { + perf_aux_output_flag(&pt->handle, + PERF_AUX_FLAG_TRUNCATED); +@@ -840,7 +842,8 @@ static void pt_handle_status(struct pt *pt) + * Also on single-entry ToPA implementations, interrupt will come + * before the output reaches its output region's boundary. + */ +- if (!pt_cap_get(PT_CAP_topa_multiple_entries) && !buf->snapshot && ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) && ++ !buf->snapshot && + pt_buffer_region_size(buf) - buf->output_off <= TOPA_PMI_MARGIN) { + void *head = pt_buffer_region(buf); + +@@ -931,7 +934,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf, + + + /* single entry ToPA is handled by marking all regions STOP=1 INT=1 */ +- if (!pt_cap_get(PT_CAP_topa_multiple_entries)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) + return 0; + + /* clear STOP and INT from current entry */ +@@ -1082,7 +1085,7 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages, + pt_buffer_setup_topa_index(buf); + + /* link last table to the first one, unless we're double buffering */ +- if (pt_cap_get(PT_CAP_topa_multiple_entries)) { ++ if (intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) { + TOPA_ENTRY(buf->last, -1)->base = buf->first->phys >> TOPA_SHIFT; + TOPA_ENTRY(buf->last, -1)->end = 1; + } +@@ -1154,7 +1157,7 @@ static int pt_addr_filters_init(struct perf_event *event) + struct pt_filters *filters; + int node = event->cpu == -1 ? -1 : cpu_to_node(event->cpu); + +- if (!pt_cap_get(PT_CAP_num_address_ranges)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_num_address_ranges)) + return 0; + + filters = kzalloc_node(sizeof(struct pt_filters), GFP_KERNEL, node); +@@ -1203,7 +1206,7 @@ static int pt_event_addr_filters_validate(struct list_head *filters) + return -EINVAL; + } + +- if (++range > pt_cap_get(PT_CAP_num_address_ranges)) ++ if (++range > intel_pt_validate_hw_cap(PT_CAP_num_address_ranges)) + return -EOPNOTSUPP; + } + +@@ -1509,12 +1512,12 @@ static __init int pt_init(void) + if (ret) + return ret; + +- if (!pt_cap_get(PT_CAP_topa_output)) { ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_output)) { + pr_warn("ToPA output is not supported on this CPU\n"); + return -ENODEV; + } + +- if (!pt_cap_get(PT_CAP_topa_multiple_entries)) ++ if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) + pt_pmu.pmu.capabilities = + PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_AUX_SW_DOUBLEBUF; + +@@ -1532,7 +1535,7 @@ static __init int pt_init(void) + pt_pmu.pmu.addr_filters_sync = pt_event_addr_filters_sync; + pt_pmu.pmu.addr_filters_validate = pt_event_addr_filters_validate; + pt_pmu.pmu.nr_addr_filters = +- pt_cap_get(PT_CAP_num_address_ranges); ++ intel_pt_validate_hw_cap(PT_CAP_num_address_ranges); + + ret = perf_pmu_register(&pt_pmu.pmu, "intel_pt", -1); + +diff --git a/arch/x86/events/intel/pt.h b/arch/x86/events/intel/pt.h +index df6ecf702a3cd..ad4ac27f04688 100644 +--- a/arch/x86/events/intel/pt.h ++++ b/arch/x86/events/intel/pt.h +@@ -82,30 +82,9 @@ struct topa_entry { + u64 rsvd4 : 12; + }; + +-#define PT_CPUID_LEAVES 2 +-#define PT_CPUID_REGS_NUM 4 /* number of regsters (eax, ebx, ecx, edx) */ +- + /* TSC to Core Crystal Clock Ratio */ + #define CPUID_TSC_LEAF 0x15 + +-enum pt_capabilities { +- PT_CAP_max_subleaf = 0, +- PT_CAP_cr3_filtering, +- PT_CAP_psb_cyc, +- PT_CAP_ip_filtering, +- PT_CAP_mtc, +- PT_CAP_ptwrite, +- PT_CAP_power_event_trace, +- PT_CAP_topa_output, +- PT_CAP_topa_multiple_entries, +- PT_CAP_single_range_output, +- PT_CAP_payloads_lip, +- PT_CAP_num_address_ranges, +- PT_CAP_mtc_periods, +- PT_CAP_cycle_thresholds, +- PT_CAP_psb_periods, +-}; +- + struct pt_pmu { + struct pmu pmu; + u32 caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES]; +diff --git a/arch/x86/include/asm/intel_pt.h b/arch/x86/include/asm/intel_pt.h +index b523f51c5400d..fa4b4fd2dbedd 100644 +--- a/arch/x86/include/asm/intel_pt.h ++++ b/arch/x86/include/asm/intel_pt.h +@@ -2,10 +2,33 @@ + #ifndef _ASM_X86_INTEL_PT_H + #define _ASM_X86_INTEL_PT_H + ++#define PT_CPUID_LEAVES 2 ++#define PT_CPUID_REGS_NUM 4 /* number of regsters (eax, ebx, ecx, edx) */ ++ ++enum pt_capabilities { ++ PT_CAP_max_subleaf = 0, ++ PT_CAP_cr3_filtering, ++ PT_CAP_psb_cyc, ++ PT_CAP_ip_filtering, ++ PT_CAP_mtc, ++ PT_CAP_ptwrite, ++ PT_CAP_power_event_trace, ++ PT_CAP_topa_output, ++ PT_CAP_topa_multiple_entries, ++ PT_CAP_single_range_output, ++ PT_CAP_payloads_lip, ++ PT_CAP_num_address_ranges, ++ PT_CAP_mtc_periods, ++ PT_CAP_cycle_thresholds, ++ PT_CAP_psb_periods, ++}; ++ + #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) + void cpu_emergency_stop_pt(void); ++extern u32 intel_pt_validate_hw_cap(enum pt_capabilities cap); + #else + static inline void cpu_emergency_stop_pt(void) {} ++static inline u32 intel_pt_validate_hw_cap(enum pt_capabilities cap) { return 0; } + #endif + + #endif /* _ASM_X86_INTEL_PT_H */ +-- +2.43.0 + diff --git a/queue-4.19/perf-x86-intel-pt-fix-a-topa_entry-base-address-calc.patch b/queue-4.19/perf-x86-intel-pt-fix-a-topa_entry-base-address-calc.patch new file mode 100644 index 00000000000..8317508bcd8 --- /dev/null +++ b/queue-4.19/perf-x86-intel-pt-fix-a-topa_entry-base-address-calc.patch @@ -0,0 +1,51 @@ +From 15ed75256afc770736a0c146ea77089a2267d168 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Jun 2024 23:10:56 +0300 +Subject: perf/x86/intel/pt: Fix a topa_entry base address calculation + +From: Adrian Hunter + +[ Upstream commit ad97196379d0b8cb24ef3d5006978a6554e6467f ] + +topa_entry->base is a bit-field. Bit-fields are not promoted to a 64-bit +type, even if the underlying type is 64-bit, and so, if necessary, must +be cast to a larger type when calculations are done. + +Fix a topa_entry->base address calculation by adding a cast. + +Without the cast, the address was limited to 36-bits i.e. 64GiB. + +The address calculation is used on systems that do not support Multiple +Entry ToPA (only Broadwell), and affects physical addresses on or above +64GiB. Instead of writing to the correct address, the address comprising +the first 36 bits would be written to. + +Intel PT snapshot and sampling modes are not affected. + +Fixes: 52ca9ced3f70 ("perf/x86/intel/pt: Add Intel PT PMU driver") +Reported-by: Dave Hansen +Signed-off-by: Adrian Hunter +Signed-off-by: Peter Zijlstra (Intel) +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20240624201101.60186-3-adrian.hunter@intel.com +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/pt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c +index 1fe74019ee3c8..87cca56228856 100644 +--- a/arch/x86/events/intel/pt.c ++++ b/arch/x86/events/intel/pt.c +@@ -816,7 +816,7 @@ static void pt_update_head(struct pt *pt) + */ + static void *pt_buffer_region(struct pt_buffer *buf) + { +- return phys_to_virt(TOPA_ENTRY(buf->cur, buf->cur_idx)->base << TOPA_SHIFT); ++ return phys_to_virt((phys_addr_t)TOPA_ENTRY(buf->cur, buf->cur_idx)->base << TOPA_SHIFT); + } + + /** +-- +2.43.0 + diff --git a/queue-4.19/perf-x86-intel-pt-split-topa-metadata-and-page-layou.patch b/queue-4.19/perf-x86-intel-pt-split-topa-metadata-and-page-layou.patch new file mode 100644 index 00000000000..c9bf9bf3cb5 --- /dev/null +++ b/queue-4.19/perf-x86-intel-pt-split-topa-metadata-and-page-layou.patch @@ -0,0 +1,236 @@ +From 509008c06950e508aa16f06254e88fdfd9e45573 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Aug 2019 15:47:25 +0300 +Subject: perf/x86/intel/pt: Split ToPA metadata and page layout + +From: Alexander Shishkin + +[ Upstream commit 38bb8d77d0b932a0773b5de2ef42479409314f96 ] + +PT uses page sized ToPA tables, where the ToPA table resides at the bottom +and its driver-specific metadata taking up a few words at the top of the +page. The split is currently calculated manually and needs to be redone +every time a field is added to or removed from the metadata structure. +Also, the 32-bit version can be made smaller. + +By splitting the table and metadata into separate structures, we are making +the compiler figure out the division of the page. + +Signed-off-by: Alexander Shishkin +Cc: Arnaldo Carvalho de Melo +Cc: Jiri Olsa +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Peter Zijlstra +Cc: Stephane Eranian +Cc: Thomas Gleixner +Cc: Vince Weaver +Link: http://lkml.kernel.org/r/20190821124727.73310-5-alexander.shishkin@linux.intel.com +Signed-off-by: Ingo Molnar +Stable-dep-of: ad97196379d0 ("perf/x86/intel/pt: Fix a topa_entry base address calculation") +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/pt.c | 93 ++++++++++++++++++++++++-------------- + 1 file changed, 60 insertions(+), 33 deletions(-) + +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c +index 5dff4548b0875..1fe74019ee3c8 100644 +--- a/arch/x86/events/intel/pt.c ++++ b/arch/x86/events/intel/pt.c +@@ -546,16 +546,8 @@ static void pt_config_buffer(void *buf, unsigned int topa_idx, + wrmsrl(MSR_IA32_RTIT_OUTPUT_MASK, reg); + } + +-/* +- * Keep ToPA table-related metadata on the same page as the actual table, +- * taking up a few words from the top +- */ +- +-#define TENTS_PER_PAGE (((PAGE_SIZE - 40) / sizeof(struct topa_entry)) - 1) +- + /** +- * struct topa - page-sized ToPA table with metadata at the top +- * @table: actual ToPA table entries, as understood by PT hardware ++ * struct topa - ToPA metadata + * @list: linkage to struct pt_buffer's list of tables + * @phys: physical address of this page + * @offset: offset of the first entry in this table in the buffer +@@ -563,7 +555,6 @@ static void pt_config_buffer(void *buf, unsigned int topa_idx, + * @last: index of the last initialized entry in this table + */ + struct topa { +- struct topa_entry table[TENTS_PER_PAGE]; + struct list_head list; + u64 phys; + u64 offset; +@@ -571,8 +562,39 @@ struct topa { + int last; + }; + ++/* ++ * Keep ToPA table-related metadata on the same page as the actual table, ++ * taking up a few words from the top ++ */ ++ ++#define TENTS_PER_PAGE \ ++ ((PAGE_SIZE - sizeof(struct topa)) / sizeof(struct topa_entry)) ++ ++/** ++ * struct topa_page - page-sized ToPA table with metadata at the top ++ * @table: actual ToPA table entries, as understood by PT hardware ++ * @topa: metadata ++ */ ++struct topa_page { ++ struct topa_entry table[TENTS_PER_PAGE]; ++ struct topa topa; ++}; ++ ++static inline struct topa_page *topa_to_page(struct topa *topa) ++{ ++ return container_of(topa, struct topa_page, topa); ++} ++ ++static inline struct topa_page *topa_entry_to_page(struct topa_entry *te) ++{ ++ return (struct topa_page *)((unsigned long)te & PAGE_MASK); ++} ++ + /* make -1 stand for the last table entry */ +-#define TOPA_ENTRY(t, i) ((i) == -1 ? &(t)->table[(t)->last] : &(t)->table[(i)]) ++#define TOPA_ENTRY(t, i) \ ++ ((i) == -1 \ ++ ? &topa_to_page(t)->table[(t)->last] \ ++ : &topa_to_page(t)->table[(i)]) + #define TOPA_ENTRY_SIZE(t, i) (sizes(TOPA_ENTRY((t), (i))->size)) + + /** +@@ -585,27 +607,27 @@ struct topa { + static struct topa *topa_alloc(int cpu, gfp_t gfp) + { + int node = cpu_to_node(cpu); +- struct topa *topa; ++ struct topa_page *tp; + struct page *p; + + p = alloc_pages_node(node, gfp | __GFP_ZERO, 0); + if (!p) + return NULL; + +- topa = page_address(p); +- topa->last = 0; +- topa->phys = page_to_phys(p); ++ tp = page_address(p); ++ tp->topa.last = 0; ++ tp->topa.phys = page_to_phys(p); + + /* + * In case of singe-entry ToPA, always put the self-referencing END + * link as the 2nd entry in the table + */ + if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) { +- TOPA_ENTRY(topa, 1)->base = topa->phys >> TOPA_SHIFT; +- TOPA_ENTRY(topa, 1)->end = 1; ++ TOPA_ENTRY(&tp->topa, 1)->base = tp->topa.phys; ++ TOPA_ENTRY(&tp->topa, 1)->end = 1; + } + +- return topa; ++ return &tp->topa; + } + + /** +@@ -715,22 +737,23 @@ static void pt_topa_dump(struct pt_buffer *buf) + struct topa *topa; + + list_for_each_entry(topa, &buf->tables, list) { ++ struct topa_page *tp = topa_to_page(topa); + int i; + +- pr_debug("# table @%p (%016Lx), off %llx size %zx\n", topa->table, ++ pr_debug("# table @%p (%016Lx), off %llx size %zx\n", tp->table, + topa->phys, topa->offset, topa->size); + for (i = 0; i < TENTS_PER_PAGE; i++) { + pr_debug("# entry @%p (%lx sz %u %c%c%c) raw=%16llx\n", +- &topa->table[i], +- (unsigned long)topa->table[i].base << TOPA_SHIFT, +- sizes(topa->table[i].size), +- topa->table[i].end ? 'E' : ' ', +- topa->table[i].intr ? 'I' : ' ', +- topa->table[i].stop ? 'S' : ' ', +- *(u64 *)&topa->table[i]); ++ &tp->table[i], ++ (unsigned long)tp->table[i].base << TOPA_SHIFT, ++ sizes(tp->table[i].size), ++ tp->table[i].end ? 'E' : ' ', ++ tp->table[i].intr ? 'I' : ' ', ++ tp->table[i].stop ? 'S' : ' ', ++ *(u64 *)&tp->table[i]); + if ((intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) && +- topa->table[i].stop) || +- topa->table[i].end) ++ tp->table[i].stop) || ++ tp->table[i].end) + break; + } + } +@@ -793,7 +816,7 @@ static void pt_update_head(struct pt *pt) + */ + static void *pt_buffer_region(struct pt_buffer *buf) + { +- return phys_to_virt(buf->cur->table[buf->cur_idx].base << TOPA_SHIFT); ++ return phys_to_virt(TOPA_ENTRY(buf->cur, buf->cur_idx)->base << TOPA_SHIFT); + } + + /** +@@ -870,9 +893,11 @@ static void pt_handle_status(struct pt *pt) + static void pt_read_offset(struct pt_buffer *buf) + { + u64 offset, base_topa; ++ struct topa_page *tp; + + rdmsrl(MSR_IA32_RTIT_OUTPUT_BASE, base_topa); +- buf->cur = phys_to_virt(base_topa); ++ tp = phys_to_virt(base_topa); ++ buf->cur = &tp->topa; + + rdmsrl(MSR_IA32_RTIT_OUTPUT_MASK, offset); + /* offset within current output region */ +@@ -1022,6 +1047,7 @@ static void pt_buffer_setup_topa_index(struct pt_buffer *buf) + */ + static void pt_buffer_reset_offsets(struct pt_buffer *buf, unsigned long head) + { ++ struct topa_page *cur_tp; + int pg; + + if (buf->snapshot) +@@ -1030,7 +1056,8 @@ static void pt_buffer_reset_offsets(struct pt_buffer *buf, unsigned long head) + pg = (head >> PAGE_SHIFT) & (buf->nr_pages - 1); + pg = pt_topa_next_entry(buf, pg); + +- buf->cur = (struct topa *)((unsigned long)buf->topa_index[pg] & PAGE_MASK); ++ cur_tp = topa_entry_to_page(buf->topa_index[pg]); ++ buf->cur = &cur_tp->topa; + buf->cur_idx = buf->topa_index[pg] - TOPA_ENTRY(buf->cur, 0); + buf->output_off = head & (pt_buffer_region_size(buf) - 1); + +@@ -1296,7 +1323,7 @@ void intel_pt_interrupt(void) + return; + } + +- pt_config_buffer(buf->cur->table, buf->cur_idx, ++ pt_config_buffer(topa_to_page(buf->cur)->table, buf->cur_idx, + buf->output_off); + pt_config(event); + } +@@ -1361,7 +1388,7 @@ static void pt_event_start(struct perf_event *event, int mode) + WRITE_ONCE(pt->handle_nmi, 1); + hwc->state = 0; + +- pt_config_buffer(buf->cur->table, buf->cur_idx, ++ pt_config_buffer(topa_to_page(buf->cur)->table, buf->cur_idx, + buf->output_off); + pt_config(event); + +-- +2.43.0 + diff --git a/queue-4.19/perf-x86-intel-pt-use-helpers-to-obtain-topa-entry-s.patch b/queue-4.19/perf-x86-intel-pt-use-helpers-to-obtain-topa-entry-s.patch new file mode 100644 index 00000000000..d55a65ac317 --- /dev/null +++ b/queue-4.19/perf-x86-intel-pt-use-helpers-to-obtain-topa-entry-s.patch @@ -0,0 +1,91 @@ +From 614867588945cc41fe560dbf1c190238747f74e4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Aug 2019 15:47:23 +0300 +Subject: perf/x86/intel/pt: Use helpers to obtain ToPA entry size + +From: Alexander Shishkin + +[ Upstream commit fffec50f541ace292383c0cbe9a2a97d16d201c6 ] + +There are a few places in the PT driver that need to obtain the size of +a ToPA entry, some of them for the current ToPA entry in the buffer. +Use helpers for those, to make the lines shorter and more readable. + +Signed-off-by: Alexander Shishkin +Cc: Arnaldo Carvalho de Melo +Cc: Jiri Olsa +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Peter Zijlstra +Cc: Stephane Eranian +Cc: Thomas Gleixner +Cc: Vince Weaver +Link: http://lkml.kernel.org/r/20190821124727.73310-3-alexander.shishkin@linux.intel.com +Signed-off-by: Ingo Molnar +Stable-dep-of: ad97196379d0 ("perf/x86/intel/pt: Fix a topa_entry base address calculation") +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/pt.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c +index 62ef4b68f04c6..b8a2408383d0c 100644 +--- a/arch/x86/events/intel/pt.c ++++ b/arch/x86/events/intel/pt.c +@@ -573,6 +573,7 @@ struct topa { + + /* make -1 stand for the last table entry */ + #define TOPA_ENTRY(t, i) ((i) == -1 ? &(t)->table[(t)->last] : &(t)->table[(i)]) ++#define TOPA_ENTRY_SIZE(t, i) (sizes(TOPA_ENTRY((t), (i))->size)) + + /** + * topa_alloc() - allocate page-sized ToPA table +@@ -772,7 +773,7 @@ static void pt_update_head(struct pt *pt) + + /* offset of the current output region within this table */ + for (topa_idx = 0; topa_idx < buf->cur_idx; topa_idx++) +- base += sizes(buf->cur->table[topa_idx].size); ++ base += TOPA_ENTRY_SIZE(buf->cur, topa_idx); + + if (buf->snapshot) { + local_set(&buf->data_size, base); +@@ -801,7 +802,7 @@ static void *pt_buffer_region(struct pt_buffer *buf) + */ + static size_t pt_buffer_region_size(struct pt_buffer *buf) + { +- return sizes(buf->cur->table[buf->cur_idx].size); ++ return TOPA_ENTRY_SIZE(buf->cur, buf->cur_idx); + } + + /** +@@ -831,7 +832,7 @@ static void pt_handle_status(struct pt *pt) + * know. + */ + if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || +- buf->output_off == sizes(TOPA_ENTRY(buf->cur, buf->cur_idx)->size)) { ++ buf->output_off == pt_buffer_region_size(buf)) { + perf_aux_output_flag(&pt->handle, + PERF_AUX_FLAG_TRUNCATED); + advance++; +@@ -926,8 +927,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf, + unsigned long idx, npages, wakeup; + + /* can't stop in the middle of an output region */ +- if (buf->output_off + handle->size + 1 < +- sizes(TOPA_ENTRY(buf->cur, buf->cur_idx)->size)) { ++ if (buf->output_off + handle->size + 1 < pt_buffer_region_size(buf)) { + perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); + return -EINVAL; + } +@@ -1033,7 +1033,7 @@ static void pt_buffer_reset_offsets(struct pt_buffer *buf, unsigned long head) + buf->cur = (struct topa *)((unsigned long)buf->topa_index[pg] & PAGE_MASK); + buf->cur_idx = ((unsigned long)buf->topa_index[pg] - + (unsigned long)buf->cur) / sizeof(struct topa_entry); +- buf->output_off = head & (sizes(buf->cur->table[buf->cur_idx].size) - 1); ++ buf->output_off = head & (pt_buffer_region_size(buf) - 1); + + local64_set(&buf->head, head); + local_set(&buf->data_size, 0); +-- +2.43.0 + diff --git a/queue-4.19/perf-x86-intel-pt-use-pointer-arithmetics-instead-in.patch b/queue-4.19/perf-x86-intel-pt-use-pointer-arithmetics-instead-in.patch new file mode 100644 index 00000000000..088476b613c --- /dev/null +++ b/queue-4.19/perf-x86-intel-pt-use-pointer-arithmetics-instead-in.patch @@ -0,0 +1,49 @@ +From d2bb4df617e24af891b904a6cd9ac8b386bb6e45 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Aug 2019 15:47:24 +0300 +Subject: perf/x86/intel/pt: Use pointer arithmetics instead in ToPA entry + calculation + +From: Alexander Shishkin + +[ Upstream commit 539f7c26b41d4ed7d88dd9756de3966ae7ca07b4 ] + +Currently, pt_buffer_reset_offsets() calculates the current ToPA entry by +casting pointers to addresses and performing ungainly subtractions and +divisions instead of a simpler pointer arithmetic, which would be perfectly +applicable in that case. Fix that. + +Signed-off-by: Alexander Shishkin +Cc: Arnaldo Carvalho de Melo +Cc: Jiri Olsa +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Peter Zijlstra +Cc: Stephane Eranian +Cc: Thomas Gleixner +Cc: Vince Weaver +Link: http://lkml.kernel.org/r/20190821124727.73310-4-alexander.shishkin@linux.intel.com +Signed-off-by: Ingo Molnar +Stable-dep-of: ad97196379d0 ("perf/x86/intel/pt: Fix a topa_entry base address calculation") +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/pt.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c +index b8a2408383d0c..5dff4548b0875 100644 +--- a/arch/x86/events/intel/pt.c ++++ b/arch/x86/events/intel/pt.c +@@ -1031,8 +1031,7 @@ static void pt_buffer_reset_offsets(struct pt_buffer *buf, unsigned long head) + pg = pt_topa_next_entry(buf, pg); + + buf->cur = (struct topa *)((unsigned long)buf->topa_index[pg] & PAGE_MASK); +- buf->cur_idx = ((unsigned long)buf->topa_index[pg] - +- (unsigned long)buf->cur) / sizeof(struct topa_entry); ++ buf->cur_idx = buf->topa_index[pg] - TOPA_ENTRY(buf->cur, 0); + buf->output_off = head & (pt_buffer_region_size(buf) - 1); + + local64_set(&buf->head, head); +-- +2.43.0 + diff --git a/queue-4.19/remoteproc-imx_rproc-fix-ignoring-mapping-vdev-regio.patch b/queue-4.19/remoteproc-imx_rproc-fix-ignoring-mapping-vdev-regio.patch new file mode 100644 index 00000000000..ffa3260a6c3 --- /dev/null +++ b/queue-4.19/remoteproc-imx_rproc-fix-ignoring-mapping-vdev-regio.patch @@ -0,0 +1,44 @@ +From 046fd881d5efecb0613f83038d846ce8286aeb07 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 Sep 2021 17:06:19 +0800 +Subject: remoteproc: imx_rproc: Fix ignoring mapping vdev regions + +From: Dong Aisheng + +[ 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 +Signed-off-by: Dong Aisheng +Signed-off-by: Peng Fan +Cc: stable +Link: https://lore.kernel.org/r/20210910090621.3073540-5-peng.fan@oss.nxp.com +Signed-off-by: Mathieu Poirier +Signed-off-by: Bjorn Andersson +Stable-dep-of: 2fa26ca8b786 ("remoteproc: imx_rproc: Skip over memory region when node value is NULL") +Signed-off-by: Sasha Levin +--- + 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 99d1a90ea084a..4eec6b380f11c 100644 +--- a/drivers/remoteproc/imx_rproc.c ++++ b/drivers/remoteproc/imx_rproc.c +@@ -289,8 +289,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 + diff --git a/queue-4.19/remoteproc-imx_rproc-ignore-mapping-vdev-regions.patch b/queue-4.19/remoteproc-imx_rproc-ignore-mapping-vdev-regions.patch new file mode 100644 index 00000000000..42bc443d868 --- /dev/null +++ b/queue-4.19/remoteproc-imx_rproc-ignore-mapping-vdev-regions.patch @@ -0,0 +1,40 @@ +From abb221759f721f14296c5d28f0f50473a28ba4ad Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 6 Mar 2021 19:24:24 +0800 +Subject: remoteproc: imx_rproc: ignore mapping vdev regions + +From: Peng Fan + +[ 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 +Reviewed-by: Mathieu Poirier +Link: https://lore.kernel.org/r/1615029865-23312-10-git-send-email-peng.fan@oss.nxp.com +Signed-off-by: Bjorn Andersson +Stable-dep-of: 2fa26ca8b786 ("remoteproc: imx_rproc: Skip over memory region when node value is NULL") +Signed-off-by: Sasha Levin +--- + 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 54c07fd3f2042..99d1a90ea084a 100644 +--- a/drivers/remoteproc/imx_rproc.c ++++ b/drivers/remoteproc/imx_rproc.c +@@ -289,6 +289,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 + diff --git a/queue-4.19/remoteproc-imx_rproc-skip-over-memory-region-when-no.patch b/queue-4.19/remoteproc-imx_rproc-skip-over-memory-region-when-no.patch new file mode 100644 index 00000000000..08608fbef5c --- /dev/null +++ b/queue-4.19/remoteproc-imx_rproc-skip-over-memory-region-when-no.patch @@ -0,0 +1,45 @@ +From 551e1537f238f880b6d67f07886cd464269f3fec Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Reviewed-by: Peng Fan +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 +Signed-off-by: Sasha Levin +--- + 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 4eec6b380f11c..7597f09a3455b 100644 +--- a/drivers/remoteproc/imx_rproc.c ++++ b/drivers/remoteproc/imx_rproc.c +@@ -289,6 +289,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 + diff --git a/queue-4.19/series b/queue-4.19/series index 8e498925e58..6240935f9b0 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -103,3 +103,20 @@ ipv4-fix-incorrect-source-address-in-record-route-op.patch net-bonding-correctly-annotate-rcu-in-bond_should_no.patch tipc-return-non-zero-value-from-tipc_udp_addr2str-on.patch misdn-fix-a-use-after-free-in-hfcmulti_tx.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-parport_pc-mark-expected-switch-fall-through.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 +perf-x86-intel-pt-export-pt_cap_get.patch +perf-x86-intel-pt-use-helpers-to-obtain-topa-entry-s.patch +perf-x86-intel-pt-use-pointer-arithmetics-instead-in.patch +perf-x86-intel-pt-split-topa-metadata-and-page-layou.patch +perf-x86-intel-pt-fix-a-topa_entry-base-address-calc.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