From: Sasha Levin Date: Mon, 29 Mar 2021 04:00:45 +0000 (-0400) Subject: Fixes for 4.9 X-Git-Tag: v5.11.11~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c62aa946f1ecf96a03f2fe1eec12128a9d8e32b;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/idr-add-ida_is_empty.patch b/queue-4.9/idr-add-ida_is_empty.patch new file mode 100644 index 00000000000..deeed9031bd --- /dev/null +++ b/queue-4.9/idr-add-ida_is_empty.patch @@ -0,0 +1,111 @@ +From ceab187fd190bbe08434a83e41f778d033051a9a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Dec 2016 15:09:13 -0800 +Subject: idr: add ida_is_empty + +From: Matthew Wilcox + +[ Upstream commit 99c494077e2d4282a17120a772eecc00ec3004cc ] + +Two of the USB Gadgets were poking around in the internals of struct ida +in order to determine if it is empty. Add the appropriate abstraction. + +Link: http://lkml.kernel.org/r/1480369871-5271-63-git-send-email-mawilcox@linuxonhyperv.com +Signed-off-by: Matthew Wilcox +Acked-by: Konstantin Khlebnikov +Tested-by: Kirill A. Shutemov +Cc: Ross Zwisler +Cc: Felipe Balbi +Cc: Greg Kroah-Hartman +Cc: Michal Nazarewicz +Cc: Matthew Wilcox +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + drivers/usb/gadget/function/f_hid.c | 6 +++--- + drivers/usb/gadget/function/f_printer.c | 6 +++--- + include/linux/idr.h | 5 +++++ + 3 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c +index 8e83649f77ce..42e5677d932d 100644 +--- a/drivers/usb/gadget/function/f_hid.c ++++ b/drivers/usb/gadget/function/f_hid.c +@@ -932,7 +932,7 @@ static void hidg_free_inst(struct usb_function_instance *f) + mutex_lock(&hidg_ida_lock); + + hidg_put_minor(opts->minor); +- if (idr_is_empty(&hidg_ida.idr)) ++ if (ida_is_empty(&hidg_ida)) + ghid_cleanup(); + + mutex_unlock(&hidg_ida_lock); +@@ -958,7 +958,7 @@ static struct usb_function_instance *hidg_alloc_inst(void) + + mutex_lock(&hidg_ida_lock); + +- if (idr_is_empty(&hidg_ida.idr)) { ++ if (ida_is_empty(&hidg_ida)) { + status = ghid_setup(NULL, HIDG_MINORS); + if (status) { + ret = ERR_PTR(status); +@@ -971,7 +971,7 @@ static struct usb_function_instance *hidg_alloc_inst(void) + if (opts->minor < 0) { + ret = ERR_PTR(opts->minor); + kfree(opts); +- if (idr_is_empty(&hidg_ida.idr)) ++ if (ida_is_empty(&hidg_ida)) + ghid_cleanup(); + goto unlock; + } +diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c +index b962f24b500b..b3d036d06553 100644 +--- a/drivers/usb/gadget/function/f_printer.c ++++ b/drivers/usb/gadget/function/f_printer.c +@@ -1276,7 +1276,7 @@ static void gprinter_free_inst(struct usb_function_instance *f) + mutex_lock(&printer_ida_lock); + + gprinter_put_minor(opts->minor); +- if (idr_is_empty(&printer_ida.idr)) ++ if (ida_is_empty(&printer_ida)) + gprinter_cleanup(); + + mutex_unlock(&printer_ida_lock); +@@ -1300,7 +1300,7 @@ static struct usb_function_instance *gprinter_alloc_inst(void) + + mutex_lock(&printer_ida_lock); + +- if (idr_is_empty(&printer_ida.idr)) { ++ if (ida_is_empty(&printer_ida)) { + status = gprinter_setup(PRINTER_MINORS); + if (status) { + ret = ERR_PTR(status); +@@ -1313,7 +1313,7 @@ static struct usb_function_instance *gprinter_alloc_inst(void) + if (opts->minor < 0) { + ret = ERR_PTR(opts->minor); + kfree(opts); +- if (idr_is_empty(&printer_ida.idr)) ++ if (ida_is_empty(&printer_ida)) + gprinter_cleanup(); + goto unlock; + } +diff --git a/include/linux/idr.h b/include/linux/idr.h +index 083d61e92706..3639a28188c9 100644 +--- a/include/linux/idr.h ++++ b/include/linux/idr.h +@@ -195,6 +195,11 @@ static inline int ida_get_new(struct ida *ida, int *p_id) + return ida_get_new_above(ida, 0, p_id); + } + ++static inline bool ida_is_empty(struct ida *ida) ++{ ++ return idr_is_empty(&ida->idr); ++} ++ + void __init idr_init_cache(void); + + #endif /* __IDR_H__ */ +-- +2.30.1 + diff --git a/queue-4.9/perf-auxtrace-fix-auxtrace-queue-conflict.patch b/queue-4.9/perf-auxtrace-fix-auxtrace-queue-conflict.patch new file mode 100644 index 00000000000..6a677fcc4d0 --- /dev/null +++ b/queue-4.9/perf-auxtrace-fix-auxtrace-queue-conflict.patch @@ -0,0 +1,57 @@ +From b0525526f9afd4926099b9320ecd97719b5f1875 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Mar 2021 17:11:43 +0200 +Subject: perf auxtrace: Fix auxtrace queue conflict + +From: Adrian Hunter + +[ Upstream commit b410ed2a8572d41c68bd9208555610e4b07d0703 ] + +The only requirement of an auxtrace queue is that the buffers are in +time order. That is achieved by making separate queues for separate +perf buffer or AUX area buffer mmaps. + +That generally means a separate queue per cpu for per-cpu contexts, and +a separate queue per thread for per-task contexts. + +When buffers are added to a queue, perf checks that the buffer cpu and +thread id (tid) match the queue cpu and thread id. + +However, generally, that need not be true, and perf will queue buffers +correctly anyway, so the check is not needed. + +In addition, the check gets erroneously hit when using sample mode to +trace multiple threads. + +Consequently, fix that case by removing the check. + +Fixes: e502789302a6 ("perf auxtrace: Add helpers for queuing AUX area tracing data") +Reported-by: Andi Kleen +Signed-off-by: Adrian Hunter +Reviewed-by: Andi Kleen +Cc: Jiri Olsa +Link: http://lore.kernel.org/lkml/20210308151143.18338-1-adrian.hunter@intel.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/util/auxtrace.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c +index b87221efdf7e..51fdec9273d7 100644 +--- a/tools/perf/util/auxtrace.c ++++ b/tools/perf/util/auxtrace.c +@@ -248,10 +248,6 @@ static int auxtrace_queues__add_buffer(struct auxtrace_queues *queues, + queue->set = true; + queue->tid = buffer->tid; + queue->cpu = buffer->cpu; +- } else if (buffer->cpu != queue->cpu || buffer->tid != queue->tid) { +- pr_err("auxtrace queue conflict: cpu %d, tid %d vs cpu %d, tid %d\n", +- queue->cpu, queue->tid, buffer->cpu, buffer->tid); +- return -EINVAL; + } + + buffer->buffer_nr = queues->next_buffer_nr++; +-- +2.30.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 01abd8b59d5..82aa6ab8dae 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -32,3 +32,5 @@ net-cdc-phonet-fix-data-interface-release-on-probe-f.patch rdma-cxgb4-fix-adapter-le-hash-errors-while-destroyi.patch acpi-scan-rearrange-memory-allocation-in-acpi_device.patch acpi-scan-use-unique-number-for-instance_no.patch +perf-auxtrace-fix-auxtrace-queue-conflict.patch +idr-add-ida_is_empty.patch