From 67946e40368065eb60d35a263d60a7cd6478ec84 Mon Sep 17 00:00:00 2001 From: John Stultz <john.stultz@linaro.org> Date: Thu, 9 Sep 2021 02:37:41 +0000 Subject: [PATCH 01/10] FROMGIT: dma-buf: system_heap: Avoid warning on mid-order allocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trying to do mid-order allocations, set __GFP_NOWARN to avoid warning messages if the allocation fails, as we will still fall back to single page allocatitions in that case. This is the similar to what we already do for large order allocations. Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Christian Koenig <christian.koenig@amd.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Liam Mark <lmark@codeaurora.org> Cc: Chris Goldsworthy <cgoldswo@codeaurora.org> Cc: Laura Abbott <labbott@kernel.org> Cc: Brian Starkey <Brian.Starkey@arm.com> Cc: Hridya Valsaraju <hridya@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sandeep Patil <sspatil@google.com> Cc: Daniel Mentz <danielmentz@google.com> Cc: Ørjan Eide <orjan.eide@arm.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Simon Ser <contact@emersion.fr> Cc: James Jones <jajones@nvidia.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz <john.stultz@linaro.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20210909023741.2592429-1-john.stultz@linaro.org (cherry picked from commit 5ad2d11feafbb9a51291754c66b35e450ac6ee59 git://anongit.freedesktop.org/drm/drm-misc drm-misc-next) Signed-off-by: John Stultz <john.stultz@linaro.org> Bug: 177702259 Change-Id: I48be9fad7fa6cb14547fa9b24a648763894ef321 --- drivers/dma-buf/heaps/system_heap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 5f71a73a00a4..2aa3b5eafaff 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -49,11 +49,12 @@ struct dma_heap_attachment { bool uncached; }; +#define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO | __GFP_COMP) +#define MID_ORDER_GFP (LOW_ORDER_GFP | __GFP_NOWARN) #define HIGH_ORDER_GFP (((GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN \ | __GFP_NORETRY) & ~__GFP_RECLAIM) \ | __GFP_COMP) -#define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO | __GFP_COMP) -static gfp_t order_flags[] = {HIGH_ORDER_GFP, LOW_ORDER_GFP, LOW_ORDER_GFP}; +static gfp_t order_flags[] = {HIGH_ORDER_GFP, MID_ORDER_GFP, LOW_ORDER_GFP}; /* * The selection of the orders used for allocation (1MB, 64K, 4K) is designed * to match with the sizes often found in IOMMUs. Using order 4 pages instead From 50f9dcec888ac70dd37d981512da82e4a13560b7 Mon Sep 17 00:00:00 2001 From: Kashyap Desai <kashyap.desai@broadcom.com> Date: Mon, 15 Feb 2021 13:10:44 +0530 Subject: [PATCH 02/10] UPSTREAM: scsi: core: Add mq_poll support to SCSI layer Currently IOPOLL support is only available in block layer. This patch adds mq_poll support to the SCSI layer. Link: https://lore.kernel.org/r/20210215074048.19424-2-kashyap.desai@broadcom.com Cc: sumit.saxena@broadcom.com Cc: chandrakanth.patil@broadcom.com Cc: linux-block@vger.kernel.org Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: John Garry <john.garry@huawei.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit af1830956dc3dca0c87b2d679f7c91a8fe0331e1) Bug: 199284641 Change-Id: I5d670e1af76f6b632159e3610bd74267781f21b8 Signed-off-by: Bart Van Assche <bvanassche@google.com> --- drivers/scsi/scsi_lib.c | 16 ++++++++++++++++ include/scsi/scsi_host.h | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d89db29fa829..f8d83d30fd9f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1781,6 +1781,19 @@ static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq, cmd->sense_buffer); } + +static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx) +{ + struct request_queue *q = hctx->queue; + struct scsi_device *sdev = q->queuedata; + struct Scsi_Host *shost = sdev->host; + + if (shost->hostt->mq_poll) + return shost->hostt->mq_poll(shost, hctx->queue_num); + + return 0; +} + static int scsi_map_queues(struct blk_mq_tag_set *set) { struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set); @@ -1848,6 +1861,7 @@ static const struct blk_mq_ops scsi_mq_ops_no_commit = { .cleanup_rq = scsi_cleanup_rq, .busy = scsi_mq_lld_busy, .map_queues = scsi_map_queues, + .poll = scsi_mq_poll, }; @@ -1876,6 +1890,7 @@ static const struct blk_mq_ops scsi_mq_ops = { .cleanup_rq = scsi_cleanup_rq, .busy = scsi_mq_lld_busy, .map_queues = scsi_map_queues, + .poll = scsi_mq_poll, }; struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev) @@ -1908,6 +1923,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) else tag_set->ops = &scsi_mq_ops_no_commit; tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; + tag_set->nr_maps = shost->nr_maps ? : 1; tag_set->queue_depth = shost->can_queue; tag_set->cmd_size = cmd_size; tag_set->numa_node = NUMA_NO_NODE; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 8c0d37f389df..4714b9dd1ecd 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -271,6 +271,16 @@ struct scsi_host_template { */ int (* map_queues)(struct Scsi_Host *shost); + /* + * SCSI interface of blk_poll - poll for IO completions. + * Only applicable if SCSI LLD exposes multiple h/w queues. + * + * Return value: Number of completed entries found. + * + * Status: OPTIONAL + */ + int (* mq_poll)(struct Scsi_Host *shost, unsigned int queue_num); + /* * Check if scatterlists need to be padded for DMA draining. * @@ -616,6 +626,7 @@ struct Scsi_Host { * the total queue depth is can_queue. */ unsigned nr_hw_queues; + unsigned nr_maps; unsigned active_mode:2; unsigned unchecked_isa_dma:1; From 0b77effb9ea345376ebac502cc456001932e1f45 Mon Sep 17 00:00:00 2001 From: Lee Jones <lee.jones@linaro.org> Date: Tue, 5 Oct 2021 14:33:06 +0100 Subject: [PATCH 03/10] FROMLIST: sign-file: Use OpenSSL provided define to compile out deprecated APIs OpenSSL's ENGINE API is deprecated in OpenSSL v3.0. Use OPENSSL_NO_ENGINE to disallow its use and fall back on the BIO API. This is required for fully hermetic builds in android-kernel. Link: https://lore.kernel.org/lkml/20211005161833.1522737-1-lee.jones@linaro.org/ Fixes: bce40b72a381b ("ANDROID: Disable hermetic toolchain for allmodconfig builds") Co-developed-by: Adam Langley <agl@google.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I5ecac477c274ef040934710fd4a042c133942e34 (cherry picked from commit e9d39639a5297c1601f025c8fddd30a936fedc16) --- scripts/sign-file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/sign-file.c b/scripts/sign-file.c index fbd34b8e8f57..fa3fa59db666 100644 --- a/scripts/sign-file.c +++ b/scripts/sign-file.c @@ -135,7 +135,9 @@ static int pem_pw_cb(char *buf, int len, int w, void *v) static EVP_PKEY *read_private_key(const char *private_key_name) { EVP_PKEY *private_key; + BIO *b; +#ifndef OPENSSL_NO_ENGINE if (!strncmp(private_key_name, "pkcs11:", 7)) { ENGINE *e; @@ -153,17 +155,16 @@ static EVP_PKEY *read_private_key(const char *private_key_name) private_key = ENGINE_load_private_key(e, private_key_name, NULL, NULL); ERR(!private_key, "%s", private_key_name); - } else { - BIO *b; - - b = BIO_new_file(private_key_name, "rb"); - ERR(!b, "%s", private_key_name); - private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb, - NULL); - ERR(!private_key, "%s", private_key_name); - BIO_free(b); + return private_key; } +#endif + b = BIO_new_file(private_key_name, "rb"); + ERR(!b, "%s", private_key_name); + private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb, + NULL); + ERR(!private_key, "%s", private_key_name); + BIO_free(b); return private_key; } From 64fd52d1a0d6862f7a8b3b28fe82e3d810484036 Mon Sep 17 00:00:00 2001 From: Lee Jones <lee.jones@linaro.org> Date: Thu, 7 Oct 2021 11:32:12 +0100 Subject: [PATCH 04/10] ANDROID: sign-file: Fix warning when OPENSSL_NO_ENGINE is set Place drain_openssl_errors() function under the same build constraints as the code that calls it. scripts/sign-file.c:96:13: warning: unused function 'drain_openssl_errors' [-Wunused-function] static void drain_openssl_errors(void) ^ 1 warning generated. For some reason this wasn't picked-up on during automated testing. Fixes: e9d39639a529 ("FROMLIST: sign-file: Use OpenSSL provided define to compile out deprecated APIs") Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I3b337a9deac4ee83cb780792ece8f5f701a01f5f (cherry picked from commit fad17703b529eeb423eab346ffb8e8fd16baf745) --- scripts/sign-file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/sign-file.c b/scripts/sign-file.c index fa3fa59db666..8f06328d1cd1 100644 --- a/scripts/sign-file.c +++ b/scripts/sign-file.c @@ -92,6 +92,7 @@ static void display_openssl_errors(int l) } } +#ifndef OPENSSL_NO_ENGINE static void drain_openssl_errors(void) { const char *file; @@ -101,6 +102,7 @@ static void drain_openssl_errors(void) return; while (ERR_get_error_line(&file, &line)) {} } +#endif #define ERR(cond, fmt, ...) \ do { \ From e6c72a49cf8b0a0eb34f576114d51354680f8876 Mon Sep 17 00:00:00 2001 From: Lee Jones <lee.jones@linaro.org> Date: Tue, 5 Oct 2021 17:23:02 +0100 Subject: [PATCH 05/10] ANDROID: build.config.allmodconfig: Enable hermetic builds This was previously not possible due to the lack of kernel module signing support in BoringSSL. Said support has now landed in Kernel Build Tools. Fixes: bce40b72a381b ("ANDROID: Disable hermetic toolchain for allmodconfig builds") Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: Ideddac33d8d79f2819a9f68e3e80a0b045e58907 (cherry picked from commit 055fcf7583025227dec9d0417c347a5cfaeb8471) --- build.config.allmodconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.config.allmodconfig b/build.config.allmodconfig index 945c4bac54c6..fe3aefa90518 100644 --- a/build.config.allmodconfig +++ b/build.config.allmodconfig @@ -1,7 +1,5 @@ DEFCONFIG=allmodconfig -HERMETIC_TOOLCHAIN=0 - POST_DEFCONFIG_CMDS="update_config" function update_config() { ${KERNEL_DIR}/scripts/config --file ${OUT_DIR}/.config \ From 4016d452a40276fa99e7a0b64a3617a48ae6d6e4 Mon Sep 17 00:00:00 2001 From: Jack Pham <jackp@codeaurora.org> Date: Thu, 21 Oct 2021 11:01:28 -0700 Subject: [PATCH 06/10] FROMGIT: usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized Some functions may dynamically enable and disable their endpoints regularly throughout their operation, particularly when Set Interface is employed to switch between Alternate Settings. For instance the UAC2 function has its respective endpoints for playback & capture associated with AltSetting 1, in which case those endpoints would not get enabled until the host activates the AltSetting. And they conversely become disabled when the interfaces' AltSetting 0 is chosen. With the DWC3 FIFO resizing algorithm recently added, every usb_ep_enable() call results in a call to resize that EP's TXFIFO, but if the same endpoint is enabled again and again, this incorrectly leads to FIFO RAM allocation exhaustion as the mechanism did not account for the possibility that endpoints can be re-enabled many times. Example log splat: dwc3 a600000.dwc3: Fifosize(3717) > RAM size(3462) ep3in depth:217973127 configfs-gadget gadget: u_audio_start_capture:521 Error! dwc3 a600000.dwc3: request 000000000be13e18 was not queued to ep3in Add another bit DWC3_EP_TXFIFO_RESIZED to dep->flags to keep track of whether an EP had already been resized in the current configuration. If so, bail out of dwc3_gadget_resize_tx_fifos() to avoid the calculation error resulting from accumulating the EP's FIFO depth repeatedly. This flag is retained across multiple ep_disable() and ep_enable() calls and is cleared when GTXFIFOSIZn is reset in dwc3_gadget_clear_tx_fifos() upon receiving the next Set Config. Fixes: 9f607a309fbe9 ("usb: dwc3: Resize TX FIFOs to meet EP bursting requirements") Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Jack Pham <jackp@codeaurora.org> Link: https://lore.kernel.org/r/20211021180129.27938-1-jackp@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 876a75cb520f5869533a30a6ca01545ec817b7a0 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next) Bug: 204047971 Change-Id: Ia104c2fa9be36182a23a7e6f923e499ef3bcc3b1 Signed-off-by: Jack Pham <quic_jackp@quicinc.com> --- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/gadget.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index d938f85c5847..48244e076c30 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -728,6 +728,7 @@ struct dwc3_ep { #define DWC3_EP_FORCE_RESTART_STREAM BIT(9) #define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) #define DWC3_EP_PENDING_CLEAR_STALL BIT(11) +#define DWC3_EP_TXFIFO_RESIZED BIT(12) /* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 2867c923a805..0168d26d35f1 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -700,6 +700,7 @@ void dwc3_gadget_clear_tx_fifos(struct dwc3 *dwc) DWC31_GTXFIFOSIZ_TXFRAMNUM; dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num >> 1), size); + dep->flags &= ~DWC3_EP_TXFIFO_RESIZED; } dwc->num_ep_resized = 0; } @@ -745,6 +746,10 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3_ep *dep) if (!usb_endpoint_dir_in(dep->endpoint.desc) || dep->number <= 1) return 0; + /* bail if already resized */ + if (dep->flags & DWC3_EP_TXFIFO_RESIZED) + return 0; + ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); if ((dep->endpoint.maxburst > 1 && @@ -805,6 +810,7 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3_ep *dep) } dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(dep->number >> 1), fifo_size); + dep->flags |= DWC3_EP_TXFIFO_RESIZED; dwc->num_ep_resized++; return 0; @@ -993,7 +999,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) dep->stream_capable = false; dep->type = 0; - dep->flags = 0; + dep->flags &= DWC3_EP_TXFIFO_RESIZED; return 0; } From 8637bab65fbd333dfd3a84f347956014438bf8ca Mon Sep 17 00:00:00 2001 From: Woody Lin <woodylin@google.com> Date: Tue, 26 Oct 2021 09:57:12 +0800 Subject: [PATCH 07/10] Revert "Revert "sched/core: Initialize the idle task with preemption disabled"" This reverts commit 3adeb2ab1ae3e5820d1acd11e3f4ad8d9b0ec102. Commit 3c51d82d0b ("sched/core: Initialize the idle task with preemption disabled") was reverted because of a bug (b/201047587). Fix is now available so reintroduces the commit. Bug: 201047587 Bug: 201771367 Signed-off-by: Woody Lin <woodylin@google.com> Change-Id: I752da99d92c28a33b8cb2605ff8c2fdf9eb33042 --- arch/alpha/kernel/smp.c | 1 - arch/arc/kernel/smp.c | 1 - arch/arm/kernel/smp.c | 1 - arch/arm64/include/asm/preempt.h | 2 +- arch/arm64/kernel/smp.c | 1 - arch/csky/kernel/smp.c | 1 - arch/ia64/kernel/smpboot.c | 1 - arch/mips/kernel/smp.c | 1 - arch/openrisc/kernel/smp.c | 2 -- arch/parisc/kernel/smp.c | 1 - arch/powerpc/kernel/smp.c | 1 - arch/riscv/kernel/smpboot.c | 1 - arch/s390/include/asm/preempt.h | 4 ++-- arch/s390/kernel/smp.c | 1 - arch/sh/kernel/smp.c | 2 -- arch/sparc/kernel/smp_32.c | 1 - arch/sparc/kernel/smp_64.c | 3 --- arch/x86/include/asm/preempt.h | 2 +- arch/x86/kernel/smpboot.c | 1 - arch/xtensa/kernel/smp.c | 1 - include/asm-generic/preempt.h | 2 +- init/main.c | 6 +----- kernel/fork.c | 2 +- kernel/sched/core.c | 2 +- kernel/smpboot.c | 1 - 25 files changed, 8 insertions(+), 34 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index f3a58c1fdd55..cb64e4797d2a 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -166,7 +166,6 @@ smp_callin(void) DBGS(("smp_callin: commencing CPU %d current %p active_mm %p\n", cpuid, current, current->active_mm)); - preempt_disable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index 52906d314537..db0e104d6835 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -189,7 +189,6 @@ void start_kernel_secondary(void) pr_info("## CPU%u LIVE ##: Executing Code...\n", cpu); local_irq_enable(); - preempt_disable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index ba27e184402a..123432bb500e 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -436,7 +436,6 @@ asmlinkage void secondary_start_kernel(void) #endif pr_debug("CPU%u: Booted secondary processor\n", cpu); - preempt_disable(); trace_hardirqs_off(); /* diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h index 80e946b2abee..e83f0982b99c 100644 --- a/arch/arm64/include/asm/preempt.h +++ b/arch/arm64/include/asm/preempt.h @@ -23,7 +23,7 @@ static inline void preempt_count_set(u64 pc) } while (0) #define init_idle_preempt_count(p, cpu) do { \ - task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ + task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \ } while (0) static inline void set_preempt_need_resched(void) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 1bcf403a8e67..92a1bbb9f319 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -232,7 +232,6 @@ asmlinkage notrace void secondary_start_kernel(void) init_gic_priority_masking(); rcu_cpu_starting(cpu); - preempt_disable(); trace_hardirqs_off(); /* diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 041d0de6a1b6..1a8d7eaf1ff7 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -282,7 +282,6 @@ void csky_start_secondary(void) pr_info("CPU%u Online: %s...\n", cpu, __func__); local_irq_enable(); - preempt_disable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index 093040f7e626..0cad990385c0 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c @@ -440,7 +440,6 @@ start_secondary (void *unused) #endif efi_map_pal_code(); cpu_init(); - preempt_disable(); smp_callin(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 48d84d5fcc36..ff25926c5458 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -348,7 +348,6 @@ asmlinkage void start_secondary(void) */ calibrate_delay(); - preempt_disable(); cpu = smp_processor_id(); cpu_data[cpu].udelay_val = loops_per_jiffy; diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index 29c82ef2e207..e4dad76066ae 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -134,8 +134,6 @@ asmlinkage __init void secondary_start_kernel(void) set_cpu_online(cpu, true); local_irq_enable(); - - preempt_disable(); /* * OK, it's off to the idle thread for us */ diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 10227f667c8a..1405b603b91b 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -302,7 +302,6 @@ void __init smp_callin(unsigned long pdce_proc) #endif smp_cpu_init(slave_id); - preempt_disable(); flush_cache_all_local(); /* start with known state */ flush_tlb_all_local(NULL); diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index aa0a35ebc04a..91f274134884 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1436,7 +1436,6 @@ void start_secondary(void *unused) smp_store_cpu_info(cpu); set_dec(tb_ticks_per_jiffy); rcu_cpu_starting(cpu); - preempt_disable(); cpu_callin_map[cpu] = 1; if (smp_ops->setup_cpu) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 96167d55ed98..0b04e0eae3ab 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -166,7 +166,6 @@ asmlinkage __visible void smp_callin(void) * Disable preemption before enabling interrupts, so we don't try to * schedule a CPU that hasn't actually started yet. */ - preempt_disable(); local_irq_enable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } diff --git a/arch/s390/include/asm/preempt.h b/arch/s390/include/asm/preempt.h index 6ede29907fbf..e38480eb58fa 100644 --- a/arch/s390/include/asm/preempt.h +++ b/arch/s390/include/asm/preempt.h @@ -32,7 +32,7 @@ static inline void preempt_count_set(int pc) #define init_task_preempt_count(p) do { } while (0) #define init_idle_preempt_count(p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_ENABLED; \ + S390_lowcore.preempt_count = PREEMPT_DISABLED; \ } while (0) static inline void set_preempt_need_resched(void) @@ -91,7 +91,7 @@ static inline void preempt_count_set(int pc) #define init_task_preempt_count(p) do { } while (0) #define init_idle_preempt_count(p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_ENABLED; \ + S390_lowcore.preempt_count = PREEMPT_DISABLED; \ } while (0) static inline void set_preempt_need_resched(void) diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 791bc373418b..7db5460553b7 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -863,7 +863,6 @@ static void smp_init_secondary(void) set_cpu_flag(CIF_ASCE_SECONDARY); cpu_init(); rcu_cpu_starting(cpu); - preempt_disable(); init_cpu_timer(); vtime_init(); pfault_init(); diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 372acdc9033e..65924d9ec245 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -186,8 +186,6 @@ asmlinkage void start_secondary(void) per_cpu_trap_init(); - preempt_disable(); - notify_cpu_starting(cpu); local_irq_enable(); diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index 50c127ab46d5..22b148e5a5f8 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -348,7 +348,6 @@ static void sparc_start_secondary(void *arg) */ arch_cpu_pre_starting(arg); - preempt_disable(); cpu = smp_processor_id(); notify_cpu_starting(cpu); diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index e38d8bf454e8..ae5faa1d989d 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -138,9 +138,6 @@ void smp_callin(void) set_cpu_online(cpuid, true); - /* idle thread is expected to have preempt disabled */ - preempt_disable(); - local_irq_enable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h index 69485ca13665..a334dd0d7c42 100644 --- a/arch/x86/include/asm/preempt.h +++ b/arch/x86/include/asm/preempt.h @@ -43,7 +43,7 @@ static __always_inline void preempt_count_set(int pc) #define init_task_preempt_count(p) do { } while (0) #define init_idle_preempt_count(p, cpu) do { \ - per_cpu(__preempt_count, (cpu)) = PREEMPT_ENABLED; \ + per_cpu(__preempt_count, (cpu)) = PREEMPT_DISABLED; \ } while (0) /* diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 582387fc939f..8baff500914e 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -230,7 +230,6 @@ static void notrace start_secondary(void *unused) cpu_init_exception_handling(); cpu_init(); x86_cpuinit.early_percpu_clock_init(); - preempt_disable(); smp_callin(); enable_start_cpu0 = 0; diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index cd85a7a2722b..1254da07ead1 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -145,7 +145,6 @@ void secondary_start_kernel(void) cpumask_set_cpu(cpu, mm_cpumask(mm)); enter_lazy_tlb(mm, current); - preempt_disable(); trace_hardirqs_off(); calibrate_delay(); diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h index d683f5e6d791..b4d43a4af5f7 100644 --- a/include/asm-generic/preempt.h +++ b/include/asm-generic/preempt.h @@ -29,7 +29,7 @@ static __always_inline void preempt_count_set(int pc) } while (0) #define init_idle_preempt_count(p, cpu) do { \ - task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ + task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \ } while (0) static __always_inline void set_preempt_need_resched(void) diff --git a/init/main.c b/init/main.c index 9934624dbe08..c5f7de7df91a 100644 --- a/init/main.c +++ b/init/main.c @@ -908,11 +908,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) * time - but meanwhile we still have a functioning scheduler. */ sched_init(); - /* - * Disable preemption - early bootup scheduling is extremely - * fragile until we cpu_idle() for the first time. - */ - preempt_disable(); + if (WARN(!irqs_disabled(), "Interrupts were enabled *very* early, fixing it\n")) local_irq_disable(); diff --git a/kernel/fork.c b/kernel/fork.c index ec8c47c7664e..16018dc84638 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2434,7 +2434,7 @@ static inline void init_idle_pids(struct task_struct *idle) } } -struct task_struct *fork_idle(int cpu) +struct task_struct * __init fork_idle(int cpu) { struct task_struct *task; struct kernel_clone_args args = { diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 891f85bb815b..34a69dd29a43 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6743,7 +6743,7 @@ void show_state_filter(unsigned long state_filter) * NOTE: this function does not set the idle thread's NEED_RESCHED * flag, to make booting more robust. */ -void init_idle(struct task_struct *idle, int cpu) +void __init init_idle(struct task_struct *idle, int cpu) { struct rq *rq = cpu_rq(cpu); unsigned long flags; diff --git a/kernel/smpboot.c b/kernel/smpboot.c index f25208e8df83..e4163042c4d6 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -33,7 +33,6 @@ struct task_struct *idle_thread_get(unsigned int cpu) if (!tsk) return ERR_PTR(-ENOMEM); - init_idle(tsk, cpu); return tsk; } From 1c80cd1956da86e8cb2df1af436c802ba0850fdf Mon Sep 17 00:00:00 2001 From: Woody Lin <woodylin@google.com> Date: Tue, 12 Oct 2021 16:35:21 +0800 Subject: [PATCH 08/10] UPSTREAM: sched/scs: Reset the shadow stack when idle_task_exit Commit f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled") removed the init_idle() call from idle_thread_get(). This was the sole call-path on hotplug that resets the Shadow Call Stack (scs) Stack Pointer (sp). Not resetting the scs-sp leads to scs overflow after enough hotplug cycles. Therefore add an explicit scs_task_reset() to the hotplug code to make sure the scs-sp does get reset on hotplug. Fixes: f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled") Signed-off-by: Woody Lin <woodylin@google.com> [peterz: Changelog] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com> Link: https://lore.kernel.org/r/20211012083521.973587-1-woodylin@google.com (cherry picked from commit 63acd42c0d4942f74710b11c38602fb14dea7320) Bug: 201047587 Bug: 201771367 Change-Id: I9e48270f8d4c698c140cc3f427cadae636acb6d7 --- kernel/sched/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 34a69dd29a43..3db86fd60c11 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6915,6 +6915,7 @@ void idle_task_exit(void) finish_arch_post_lock_switch(); } + scs_task_reset(current); /* finish_cpu(), as ran on the BP, will clean up the active_mm state */ } From b14adc19004d752a3646651d5825f4d4a3c609da Mon Sep 17 00:00:00 2001 From: Robin Peng <robinpeng@google.com> Date: Tue, 26 Oct 2021 09:58:22 +0800 Subject: [PATCH 09/10] ANDROID: Update the ABI symbol list Update the generic symbol list. Bug: 196974386 Signed-off-by: Robin Peng <robinpeng@google.com> Change-Id: I406d95e8fc06cfb6294e5cbbed59a7596e0bb0b6 --- android/abi_gki_aarch64_generic | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index b13fd3adbc8d..cb7c91208f58 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -138,6 +138,7 @@ cfg80211_rx_mgmt_khz cfg80211_scan_done cfg80211_sched_scan_results + cfg80211_sched_scan_stopped cfg80211_sched_scan_stopped_rtnl __cfg80211_send_event_skb cfg80211_unlink_bss @@ -359,12 +360,15 @@ devm_clk_hw_register devm_clk_hw_register_clkdev devm_clk_put + devm_device_add_group devm_device_add_groups + devm_device_remove_group __devm_drm_dev_alloc devm_drm_panel_bridge_add_typed devm_extcon_dev_allocate devm_extcon_dev_register devm_free_irq + devm_fwnode_pwm_get devm_gen_pool_create devm_gpiochip_add_data_with_key devm_gpiod_get @@ -388,6 +392,7 @@ devm_kmemdup devm_kstrdup devm_kstrdup_const + devm_led_classdev_register_ext devm_mfd_add_devices devm_nvmem_register devm_of_clk_add_hw_provider @@ -403,6 +408,7 @@ devm_platform_ioremap_resource devm_platform_ioremap_resource_byname devm_power_supply_register + devm_pwm_get devm_regmap_add_irq_chip __devm_regmap_init __devm_regmap_init_i2c @@ -440,6 +446,7 @@ dev_pm_opp_set_regulators dev_pm_qos_read_value dev_pm_qos_update_request + dev_printk dev_printk_emit dev_queue_xmit devres_add @@ -775,6 +782,9 @@ full_name_hash fwnode_get_name fwnode_gpiod_get_index + fwnode_handle_put + fwnode_property_present + fwnode_property_read_string fwnode_property_read_u32_array gcd generic_file_llseek @@ -801,6 +811,7 @@ get_governor_parent_kobj get_pid_task get_random_bytes + get_random_bytes_arch get_random_u32 get_sg_io_hdr __get_task_comm @@ -852,6 +863,12 @@ hex2bin hex_dump_to_buffer hex_to_bin + hid_add_device + hid_allocate_device + hid_debug + hid_destroy_device + hid_input_report + hid_parse_report hrtimer_active hrtimer_cancel hrtimer_forward @@ -875,6 +892,7 @@ i2c_new_dummy_device i2c_put_adapter i2c_register_driver + i2c_smbus_read_byte i2c_smbus_read_byte_data i2c_smbus_write_byte_data i2c_smbus_xfer @@ -1167,11 +1185,13 @@ netlink_kernel_release netlink_unicast net_ratelimit + nla_append nla_memcpy __nla_parse nla_put nla_put_64bit nla_put_nohdr + nla_reserve nla_strlcpy __nlmsg_put no_llseek @@ -1253,6 +1273,7 @@ of_property_read_variable_u8_array of_prop_next_string of_prop_next_u32 + of_pwm_xlate_with_flags of_reserved_mem_device_init_by_idx of_reserved_mem_device_release of_reserved_mem_lookup @@ -1394,6 +1415,7 @@ power_supply_set_property power_supply_unregister power_supply_unreg_notifier + prandom_bytes prandom_u32 preempt_schedule preempt_schedule_notrace @@ -1421,6 +1443,11 @@ __put_task_struct put_unused_fd put_vaddr_frames + pwm_apply_state + pwmchip_add + pwmchip_remove + pwm_get_chip_data + pwm_set_chip_data queue_delayed_work_on queue_work_on ___ratelimit @@ -1520,6 +1547,7 @@ regulator_set_voltage_sel_regmap regulator_unregister regulatory_hint + regulatory_set_wiphy_regd_sync_rtnl release_firmware __release_region remap_pfn_range @@ -2227,6 +2255,7 @@ wakeup_source_create wakeup_source_destroy wakeup_source_register + wakeup_source_remove wakeup_source_unregister __wake_up_sync __warn_printk From ca5822a433a81af7cad3af47edeb3e3183642c5d Mon Sep 17 00:00:00 2001 From: Alex Hong <rurumihong@google.com> Date: Tue, 26 Oct 2021 23:06:40 +0800 Subject: [PATCH 10/10] ANDROID: Update the ABI symbol list Update the generic symbol list. Bug: 199698959 Signed-off-by: Alex Hong <rurumihong@google.com> Change-Id: I2a7f132983276c55641cefa6754de63ed7f58403 --- android/abi_gki_aarch64_generic | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index cb7c91208f58..99dd29ded643 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -87,6 +87,7 @@ blocking_notifier_chain_unregister bpf_trace_run1 bpf_trace_run10 + bpf_trace_run11 bpf_trace_run12 bpf_trace_run2 bpf_trace_run3 @@ -1579,6 +1580,7 @@ rtc_valid_tm __rt_mutex_init rt_mutex_lock + rt_mutex_trylock rt_mutex_unlock rtnl_is_locked rtnl_lock @@ -1928,6 +1930,7 @@ __traceiter_android_vh_rmqueue __traceiter_android_vh_setscheduler_uclamp __traceiter_android_vh_snd_compr_use_pause_in_drain + __traceiter_android_vh_sound_usb_support_cpu_suspend __traceiter_android_vh_sysrq_crash __traceiter_android_vh_thermal_pm_notify_suspend __traceiter_android_vh_timerfd_create @@ -1943,6 +1946,8 @@ __traceiter_android_vh_ufs_send_tm_command __traceiter_android_vh_ufs_send_uic_command __traceiter_android_vh_ufs_update_sysfs + __traceiter_android_vh_usb_dev_resume + __traceiter_android_vh_usb_dev_suspend __traceiter_clock_set_rate __traceiter_cpu_frequency __traceiter_device_pm_callback_end @@ -2007,6 +2012,7 @@ __tracepoint_android_vh_rmqueue __tracepoint_android_vh_setscheduler_uclamp __tracepoint_android_vh_snd_compr_use_pause_in_drain + __tracepoint_android_vh_sound_usb_support_cpu_suspend __tracepoint_android_vh_sysrq_crash __tracepoint_android_vh_thermal_pm_notify_suspend __tracepoint_android_vh_timerfd_create @@ -2022,6 +2028,8 @@ __tracepoint_android_vh_ufs_send_tm_command __tracepoint_android_vh_ufs_send_uic_command __tracepoint_android_vh_ufs_update_sysfs + __tracepoint_android_vh_usb_dev_resume + __tracepoint_android_vh_usb_dev_suspend __tracepoint_clock_set_rate __tracepoint_cpu_frequency __tracepoint_device_pm_callback_end