From patchwork Thu Dec 1 11:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 28336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp203786wrr; Thu, 1 Dec 2022 03:21:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mcNZhdwq9miuDiaFzHTXnDgwvrLWac6INgX+J0LC4kosfLKUGjwdgSpT4fRYNV/hh6W59 X-Received: by 2002:aa7:daca:0:b0:46b:8078:2431 with SMTP id x10-20020aa7daca000000b0046b80782431mr10437873eds.408.1669893688338; Thu, 01 Dec 2022 03:21:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669893688; cv=none; d=google.com; s=arc-20160816; b=VB066UoFhyBs/f3kfwdg3LvtYy+OeUQMfXu4wmBsiHNJUVzeDou0jCD86jxqzNfoe9 /4iQqxuBt6QmbBv3ySq90cbRB7eg+WF/plllqVNPHekTRYG0hg1H/IX2yJckem6Ibt3U jhiA/OJ10cDD3ZIJynxzz6stHyVP8W0V/NmRZHfPaqUZrpInHdau/8kJZhuoSkpc/vFp z/BKHfaeBIY8qjuQNa42DydilEXuH8eGLDMGOo8JDejjYYxzKVHi9FVHxzew1hvU5/5m W549k99jEBfO5KJ8wHn4jP8rJc51Hu0qwDPBpw0FknonBp9gYlbhoww/gwrNoeJfwKa0 6jgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Nkd0qjvVaAiiEvmHWMbDGHcYV2hQv0G5FFDx/lAEuwk=; b=ukfxPP8wCfbDgkxJ02LOsrW8/EVHB41L8GfTb/GV0wd2BQ5wjBRaQMuMyIzwZ2rxK0 jTYi+zVtm79pRv0BSyvo7V3j8FJwtsYaBxsg8BHzmFa59wGUU0wBNmT/d+VztnyONS6z UGnqMDIWJF4+gtXpc1lntI1ZptgxJ+nPzv0GdDF3lEkC/x1rV0OOHCVzIkz6GW6ufG4s 4FaZZh7f3DL6DoDqmWWVPL6UFlxQODCe3dICbrFSVNgsv2CJClzTwEUMcMEZkRzrCcJI i5gadA975EGXHL3kfJeCVMqpm5NtPd4Urpz77/8SjzSrQtqadOlW4XcpFYIZM31aqPkN or8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aEqdasMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp19-20020a170906c15300b0078e27f2ef52si1596804ejc.603.2022.12.01.03.21.02; Thu, 01 Dec 2022 03:21:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aEqdasMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbiLALP2 (ORCPT + 99 others); Thu, 1 Dec 2022 06:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbiLALOo (ORCPT ); Thu, 1 Dec 2022 06:14:44 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D80A6CF5 for ; Thu, 1 Dec 2022 03:08:50 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id vv4so3372508ejc.2 for ; Thu, 01 Dec 2022 03:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Nkd0qjvVaAiiEvmHWMbDGHcYV2hQv0G5FFDx/lAEuwk=; b=aEqdasMvzqt4cGfl45hppFfevyDtbdbXO3ajVl/j31uklO7/Acttz+JxUMY4/Pd13r qA9jpZl+Rnhhik8PLiWzpnbpHs4CiEsN9ONSDoAsKhineOBAg0pLPqrw5R9mTY36uBT9 DqRNCsQ1YVYeROKDbES+8UklF3NSMzWu//+j4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nkd0qjvVaAiiEvmHWMbDGHcYV2hQv0G5FFDx/lAEuwk=; b=JfJ8lJ8hQ0EMF7L0wt7+wCXvWDzQOPouCweztpEQWMfNp2b1L8Xrq473JMW3/2pgkS NcjaS8rUEqQQXygwlHQj7Gb0pdR5xJUvaFRdMMCv98sRnE6wdY0cbaSPDPRnWBdQUok7 C2Ol/vJDE57XfP/kRSy/1kfKMQ4Ez/KWdcVBPoHzERdhb07IBuANuaxGGWQ/63x07BdE sB2Em0fN6+P8SFa8Kd3thnDDIK0J679Z9VA6hNHr17WlhNopSkg7/kLbgdw7T2/AH2NC iD/qhjHPzVBxeSAMLR9SyXq/GjGN4KN0oRcyUpUxC5sZEhIDYffyssSCwizbME52F+5B +Amw== X-Gm-Message-State: ANoB5pn9AuphoOZoKbIG2psGqh1LBUrGzwH9IAqN2iRtrE1ApS5PeR1o PxTfJPXdqZIwYhVDDYX1VoMFzw== X-Received: by 2002:a17:907:3fa9:b0:7bf:5446:389d with SMTP id hr41-20020a1709073fa900b007bf5446389dmr17697065ejc.449.1669892927999; Thu, 01 Dec 2022 03:08:47 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:f554:724a:f89a:73db]) by smtp.gmail.com with ESMTPSA id v17-20020a170906293100b0078e0973d1f5sm1663824ejd.0.2022.12.01.03.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 03:08:47 -0800 (PST) From: Ricardo Ribalda Date: Thu, 01 Dec 2022 12:08:21 +0100 Subject: [PATCH v8 1/3] kexec: Refactor kexec_in_progress into a function MIME-Version: 1.0 Message-Id: <20221127-snd-freeze-v8-1-3bc02d09f2ce@chromium.org> References: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> In-Reply-To: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> To: Juergen Gross , Mark Brown , Chromeos Kdump , Daniel Baluta , Christophe Leroy , Len Brown , Ard Biesheuvel , Ranjani Sridharan , "Rafael J. Wysocki" , Boris Ostrovsky , Nicholas Piggin , Michael Ellerman , Eric Biederman , Dave Hansen , Jaroslav Kysela , Joel Fernandes , Liam Girdwood , Peter Ujfalusi , Pavel Machek , Pierre-Louis Bossart , Kai Vehmanen , Steven Rostedt , "K. Y. Srinivasan" , Ingo Molnar , Bjorn Helgaas , Dexuan Cui , Takashi Iwai , "H. Peter Anvin" , Bard Liao , Haiyang Zhang , Wei Liu , Thomas Gleixner , Borislav Petkov , x86@kernel.org Cc: kexec@lists.infradead.org, alsa-devel@alsa-project.org, Ricardo Ribalda , stable@vger.kernel.org, sound-open-firmware@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=5606; i=ribalda@chromium.org; h=from:subject:message-id; bh=rOwSP5vskEUbZoU8S9iGZ6yjsxnhI5XXCgf6CDbEiKk=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjiIs3ixiN1I8p0kAS9AN3OftX9qa+MJe/lyiFxhnr 3KQHBPGJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4iLNwAKCRDRN9E+zzrEiAgBD/ wMD0lpvGLSjykTW74XwGtwIS0vCS7kYGnMNXMZAS/+qAy1e9lAb+uWUmzMdmZCun7EdSzbcELHOnWF lmHJHTn37w6DN+LbjryPPWJ5HMyXKgLVRWnoxBNooMFbtfY0oCJ0XkmHwzHTtAnRmNumEv1/5BtFuc tCndENqSLCxLn1Q0WCvVnbEIKgUm1WrdGfPxSVaPWM7o9olbv6KLz/O4a5QRpsf83kNY0GGNQqnJ6T 3K4jfeuO3u0HjrrHSAOxBpiQ7YzCqDPYmgXvzxsPOilkxnkhdUXm4zrz5l8uRRm5IPH+D+a2tJ2xSf V3id9yxm9UsfilPgFJFoM8+MwGPpIHhEt8kbCvIbq9R5JISg6YLh2i3jlX4iZc/bD3B34x25tq04tr NizRIER+5veXenpuoUm99sahcxk2+/HszRhEch2IEM4L4lUNjitjkfWZTJsR6NO1kGHnMQRA1Lv9JL WaoL/u/viwVrDq2nrVdpvFEoZQfyX3lh2X2XRYGk0SmUUBvipE9HAuETMI3Qyf/wErQ2zHHA5cQJ4m kT1GIXFzV1IFdk4jOpJTgbWlzWHqLegh4mYK50pubtKtmM57lytPw7JO8Un5mdcuGIsap10P8uxXLy JQmi7sc86pt58fddHNIdBd5kFCFomxDX91gu/JSYVpE3HMcvzl5av3SEmC+Q== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751010444561491656?= X-GMAIL-MSGID: =?utf-8?q?1751010444561491656?= Drivers running .shutdown() might want to behave differently during kexec. Convert kexec_in_progress into a function and export it, so it can be used by drivers that are either built-in or modules. Cc: stable@vger.kernel.org Fixes: 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") Signed-off-by: Ricardo Ribalda --- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/cpu/mshyperv.c | 6 +++--- arch/x86/xen/enlighten_hvm.c | 2 +- drivers/firmware/efi/efi.c | 2 +- drivers/pci/pci-driver.c | 2 +- include/linux/kexec.h | 5 ++--- kernel/kexec_core.c | 12 ++++++++++-- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c index 00ecac2c205b..923f9a36b992 100644 --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -1289,7 +1289,7 @@ static void vio_bus_shutdown(struct device *dev) viodrv = to_vio_driver(dev->driver); if (viodrv->shutdown) viodrv->shutdown(viodev); - else if (kexec_in_progress) + else if (kexec_in_progress()) vio_bus_remove(dev); } } diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 831613959a92..f91f35206489 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -122,21 +122,21 @@ void hv_remove_crash_handler(void) #ifdef CONFIG_KEXEC_CORE static void hv_machine_shutdown(void) { - if (kexec_in_progress && hv_kexec_handler) + if (kexec_in_progress() && hv_kexec_handler) hv_kexec_handler(); /* * Call hv_cpu_die() on all the CPUs, otherwise later the hypervisor * corrupts the old VP Assist Pages and can crash the kexec kernel. */ - if (kexec_in_progress && hyperv_init_cpuhp > 0) + if (kexec_in_progress() && hyperv_init_cpuhp > 0) cpuhp_remove_state(hyperv_init_cpuhp); /* The function calls stop_other_cpus(). */ native_machine_shutdown(); /* Disable the hypercall page when there is only 1 active CPU. */ - if (kexec_in_progress) + if (kexec_in_progress()) hyperv_cleanup(); } diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index c1cd28e915a3..769163833ffc 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -145,7 +145,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_xen_hvm_callback) static void xen_hvm_shutdown(void) { native_machine_shutdown(); - if (kexec_in_progress) + if (kexec_in_progress()) xen_reboot(SHUTDOWN_soft_reset); } diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index a46df5d1d094..608bc2146802 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -1040,7 +1040,7 @@ static int update_efi_random_seed(struct notifier_block *nb, struct linux_efi_random_seed *seed; u32 size = 0; - if (!kexec_in_progress) + if (!kexec_in_progress()) return NOTIFY_DONE; seed = memremap(efi_rng_seed, sizeof(*seed), MEMREMAP_WB); diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 107d77f3c846..23eeb7538b03 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -519,7 +519,7 @@ static void pci_device_shutdown(struct device *dev) * If it is not a kexec reboot, firmware will hit the PCI * devices with big hammer and stop their DMA any way. */ - if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot)) + if (kexec_in_progress() && pci_dev->current_state <= PCI_D3hot) pci_clear_master(pci_dev); } diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 41a686996aaa..2ec0aec1a0de 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -423,8 +423,7 @@ extern int kexec_load_disabled; #define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \ KEXEC_FILE_NO_INITRAMFS) -/* flag to track if kexec reboot is in progress */ -extern bool kexec_in_progress; +bool kexec_in_progress(void); int crash_shrink_memory(unsigned long new_size); ssize_t crash_get_memory_size(void); @@ -507,7 +506,7 @@ static inline void __crash_kexec(struct pt_regs *regs) { } static inline void crash_kexec(struct pt_regs *regs) { } static inline int kexec_should_crash(struct task_struct *p) { return 0; } static inline int kexec_crash_loaded(void) { return 0; } -#define kexec_in_progress false +static inline bool kexec_in_progress(void) { return false; } #endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_KEXEC_SIG diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index ca2743f9c634..4495d0fc28ae 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -52,8 +52,16 @@ atomic_t __kexec_lock = ATOMIC_INIT(0); note_buf_t __percpu *crash_notes; /* Flag to indicate we are going to kexec a new kernel */ -bool kexec_in_progress = false; +static bool kexec_in_progress_internal; +/** + * kexec_in_progress - Check if the system is going to kexec + */ +bool kexec_in_progress(void) +{ + return kexec_in_progress_internal; +} +EXPORT_SYMBOL(kexec_in_progress); /* Location of the reserved area for the crash kernel */ struct resource crashk_res = { @@ -1175,7 +1183,7 @@ int kernel_kexec(void) } else #endif { - kexec_in_progress = true; + kexec_in_progress_internal = true; kernel_restart_prepare("kexec reboot"); migrate_to_reboot_cpu(); From patchwork Thu Dec 1 11:08:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 28337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp203927wrr; Thu, 1 Dec 2022 03:21:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fgYzS7YThVPrvPIJLgVxtf/o2XSwMzHZl1h7R3boxB1LVr2NxIMkJOFdRsKD7ADJTSDO1 X-Received: by 2002:a17:906:4dc7:b0:76c:42b4:dea4 with SMTP id f7-20020a1709064dc700b0076c42b4dea4mr54085087ejw.515.1669893708525; Thu, 01 Dec 2022 03:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669893708; cv=none; d=google.com; s=arc-20160816; b=lRxPEGT8bjx6gP2GwTOTrs76jcvzM4ct65rRmTQuE9/2hSlMcMSKbdTpbU9P958E1O VRE1D9L1/xtCSeBNqbhhzyNPcbg8dPoMri/OUJE476sEuqlk1KcT9VGueO1v42VfLJJM Vo+HlGoqufFVNTphSvz4+cUxQlPjd25ww7N/NAu0sxKOZ/P6b0cUqJmB3wkttiN7n6uZ Fe2OnjsxkjX2ytcm91EgOtk2j8Qwv8dHNeDPkPq6nmUENAV7r9GOnr3K9K3Rxt533u3b iKZCf9ePio8T+1FyVGVTlkLV7KfPQZ6I6Xiy3morYbp2r65o6i4+xgHi8z4fUEK5gVdl uu1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=hPnx0twxhgnGZjrXWsF/2vKaeMeI6ZYYmbIIcD69SUE=; b=H+0e71JbOxonlcnWW1nfhXQe0QThYU1ZmwKq95SjHQVvP5bp6F8DUKyQm+343r3uMY GJ53XBkpqrOutvTiKDXHMCUMfsL+T9SDQ9eT9+fOQRkVVV9gJYl6KXjWQSFFa3GlyHOr pOUWfIky71MnUIDkVAkA9VW5cU2DF6GJh6X38TSNeJQxAeXEXVy2dF40/Fvfrfvh//uO 329pfxX441u/1JgDrUYpJYnwlstI+p2yyF74maWmTY6YAlGjj+J2AgHsl6TYc1Bq8yk2 yCn0t/WpsH6zPRsrE7CElfn2KItGPlsa3dsGe4mPR2+psVGocFRrCkYNn/fdLaBMLBmK BnKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K5kXuHcE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a170906138700b00730a4246dd0si2803471ejc.593.2022.12.01.03.21.25; Thu, 01 Dec 2022 03:21:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K5kXuHcE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiLALPj (ORCPT + 99 others); Thu, 1 Dec 2022 06:15:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbiLALOt (ORCPT ); Thu, 1 Dec 2022 06:14:49 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32C6A6CE6 for ; Thu, 1 Dec 2022 03:08:51 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id ud5so3362636ejc.4 for ; Thu, 01 Dec 2022 03:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hPnx0twxhgnGZjrXWsF/2vKaeMeI6ZYYmbIIcD69SUE=; b=K5kXuHcEfBkPvXptT5Y+mfQkEfSuimVpWQKHjhZ9y+kPOfG6EGLbLQqZ7Vmi4Ht6xT AXJ/oi2Z0ArL4gZ9JbiQ5Dx7wPbrhxkR+aVJKyp6AwkIvHoR6IysS+toCXipubShsonE oHPeSUt0tvViAKC1UQK6OZfmPOR3FZyq1ixgo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hPnx0twxhgnGZjrXWsF/2vKaeMeI6ZYYmbIIcD69SUE=; b=2z6KoDYMa2bp9jfJcyrKyQgwx5K7u+GgSQlUYicxbL590qKQ50zwb8JQy+lF1kyQyy K3cb+9Z0Dxk7Nato+8cGUGRqFUW6eeZhu/obK6ALdqXOSL64OqZ4fPYtPJSVDg203UGj 1vj6lzpoL8Qb5D9ltbbpi28yaodC8akuL6u/4NUErrO6XOivbQx0Ug33LC7p19lJ0vkQ q4biyc5LPojqfKzYODFrtyTudReqSPKR2v5SXi+fhckV5TxSZI+gYAls+nA9nVdtVT2z UIDsPQTtnFGIVg90Vz+u49lwIUY1si3oemC/+E6pVNoY9CIY3bLP8AbC55lAy+o1qwTT LLkA== X-Gm-Message-State: ANoB5pnHEpjwNJoO6WqQRNW35EWwutI1zj3dW8Qoduw6GNoXjbUhr7RZ YGjZBNUCuMZ8Fes4YkZJkkcRVg== X-Received: by 2002:a17:906:7d13:b0:7bc:addd:2c54 with SMTP id u19-20020a1709067d1300b007bcaddd2c54mr14248196ejo.24.1669892930375; Thu, 01 Dec 2022 03:08:50 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:f554:724a:f89a:73db]) by smtp.gmail.com with ESMTPSA id v17-20020a170906293100b0078e0973d1f5sm1663824ejd.0.2022.12.01.03.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 03:08:50 -0800 (PST) From: Ricardo Ribalda Date: Thu, 01 Dec 2022 12:08:22 +0100 Subject: [PATCH v8 2/3] freezer: refactor pm_freezing into a function. MIME-Version: 1.0 Message-Id: <20221127-snd-freeze-v8-2-3bc02d09f2ce@chromium.org> References: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> In-Reply-To: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> To: Juergen Gross , Mark Brown , Chromeos Kdump , Daniel Baluta , Christophe Leroy , Len Brown , Ard Biesheuvel , Ranjani Sridharan , "Rafael J. Wysocki" , Boris Ostrovsky , Nicholas Piggin , Michael Ellerman , Eric Biederman , Dave Hansen , Jaroslav Kysela , Joel Fernandes , Liam Girdwood , Peter Ujfalusi , Pavel Machek , Pierre-Louis Bossart , Kai Vehmanen , Steven Rostedt , "K. Y. Srinivasan" , Ingo Molnar , Bjorn Helgaas , Dexuan Cui , Takashi Iwai , "H. Peter Anvin" , Bard Liao , Haiyang Zhang , Wei Liu , Thomas Gleixner , Borislav Petkov , x86@kernel.org Cc: kexec@lists.infradead.org, alsa-devel@alsa-project.org, Ricardo Ribalda , stable@vger.kernel.org, sound-open-firmware@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3690; i=ribalda@chromium.org; h=from:subject:message-id; bh=Uyd503AUpFQ+wB60JzDX21uxeFYPmKS/1xEV6a/+nC0=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjiIs47YRD/lKW5LPJ0JDcZ66XVU0S36xAkU2Fyjx2 2sg9wC6JAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4iLOAAKCRDRN9E+zzrEiGFvD/ 97DssDxiQasPTlsNtz7Jry8QHtrWcpbeSa2Bm4gtZx1yhISwwBKhlnlj6KgFHG54yWyqPjrrVR0XTb DRsh8oxIzLjCsOJSaFHQVRhF6FQ+Sjacqhya5R4CgkbgCfYqD9BuqRs3k+WVdFOubhN2LtNG3lkx4T ue+l5QsOBRqMlPIvwRtgq2tpT+YUFNt5mgxSdvVT17WVelRA7EPFXF8dyd8oIs1E2iKfJpEnF/7Q4c 7SZhnlSjo1D/vgoGmvCA0YHqwNf+Gd0soCFD8VDqMs3MsHI+0iHfFmvW9qis9BQ6eEQXsouG9nOnqA GHMdhq3WU7pGrL5DkzQU30oUH+Tdpk7c8hfRF3dIlk9oU1KXSXe9pg/38OguyIttqFUH/iSKDS0L92 5vIDNhT9WlDT2uxzTt/kS9e7RVM3tR0vHpUMY48SrLT4ybX2MU+uX8pRhqF9B6yT+wCUozZXdnnFHC juHBoEPqlJn6F7z5v1GGk+dMOrd3JDk/aqI3cue3Q30WnL9D73CfUZ6MD9yALvFt8oSzUw8eMxA54/ ac6QXsBUvXHMT4klIUFhVCOtry1lTKgmIF+hciCKQi7qleoR5g5iI9YQ1pERS75u9s0tp/U5COC9rF H128taN2NiXJoQ2/mDCQbYyiZZ7qAhM+BNxsaDYWxtgKxmCMfSlcBFUTo+xA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751010465231937972?= X-GMAIL-MSGID: =?utf-8?q?1751010465231937972?= Add a way to let the drivers know if the processes are frozen. This is needed by drivers that are waiting for processes to end on their shutdown path. Convert pm_freezing into a function and export it, so it can be used by drivers that are either built-in or modules. Cc: stable@vger.kernel.org Fixes: 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") Signed-off-by: Ricardo Ribalda sdad --- include/linux/freezer.h | 3 ++- kernel/freezer.c | 3 +-- kernel/power/process.c | 24 ++++++++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index b303472255be..3413c869d68b 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -13,7 +13,7 @@ #ifdef CONFIG_FREEZER DECLARE_STATIC_KEY_FALSE(freezer_active); -extern bool pm_freezing; /* PM freezing in effect */ +bool pm_freezing(void); extern bool pm_nosig_freezing; /* PM nosig freezing in effect */ /* @@ -80,6 +80,7 @@ static inline int freeze_processes(void) { return -ENOSYS; } static inline int freeze_kernel_threads(void) { return -ENOSYS; } static inline void thaw_processes(void) {} static inline void thaw_kernel_threads(void) {} +static inline bool pm_freezing(void) { return false; } static inline bool try_to_freeze(void) { return false; } diff --git a/kernel/freezer.c b/kernel/freezer.c index 4fad0e6fca64..2d3530ebdb7e 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -20,7 +20,6 @@ EXPORT_SYMBOL(freezer_active); * indicate whether PM freezing is in effect, protected by * system_transition_mutex */ -bool pm_freezing; bool pm_nosig_freezing; /* protects freezing and frozen transitions */ @@ -46,7 +45,7 @@ bool freezing_slow_path(struct task_struct *p) if (pm_nosig_freezing || cgroup_freezing(p)) return true; - if (pm_freezing && !(p->flags & PF_KTHREAD)) + if (pm_freezing() && !(p->flags & PF_KTHREAD)) return true; return false; diff --git a/kernel/power/process.c b/kernel/power/process.c index ddd9988327fe..8a4d0e2c8c20 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -108,6 +108,22 @@ static int try_to_freeze_tasks(bool user_only) return todo ? -EBUSY : 0; } +/* + * Indicate whether PM freezing is in effect, protected by + * system_transition_mutex. + */ +static bool pm_freezing_internal; + +/** + * pm_freezing - indicate whether PM freezing is in effect. + * + */ +bool pm_freezing(void) +{ + return pm_freezing_internal; +} +EXPORT_SYMBOL(pm_freezing); + /** * freeze_processes - Signal user space processes to enter the refrigerator. * The current thread will not be frozen. The same process that calls @@ -126,12 +142,12 @@ int freeze_processes(void) /* Make sure this task doesn't get frozen */ current->flags |= PF_SUSPEND_TASK; - if (!pm_freezing) + if (!pm_freezing()) static_branch_inc(&freezer_active); pm_wakeup_clear(0); pr_info("Freezing user space processes ... "); - pm_freezing = true; + pm_freezing_internal = true; error = try_to_freeze_tasks(true); if (!error) { __usermodehelper_set_disable_depth(UMH_DISABLED); @@ -187,9 +203,9 @@ void thaw_processes(void) struct task_struct *curr = current; trace_suspend_resume(TPS("thaw_processes"), 0, true); - if (pm_freezing) + if (pm_freezing()) static_branch_dec(&freezer_active); - pm_freezing = false; + pm_freezing_internal = false; pm_nosig_freezing = false; oom_killer_enable(); From patchwork Thu Dec 1 11:08:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 28338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp204014wrr; Thu, 1 Dec 2022 03:22:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jQFReauBImw6lNCxmSEy1er4Qz7TsXaV3O3UUv0NFUOZVZwOJWWzLBxblW3lZ1mrXlxtB X-Received: by 2002:aa7:d3c4:0:b0:46c:545:f686 with SMTP id o4-20020aa7d3c4000000b0046c0545f686mr845346edr.292.1669893722517; Thu, 01 Dec 2022 03:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669893722; cv=none; d=google.com; s=arc-20160816; b=JHH8oj5XO4P/VrfZSFUC5N5K6+S+HGuIoGDA/QqWlViCsLKmeGSmwQQVOz4mQbwOLQ KjW2aLrNVqnbtektp5ccjaBQ6+/yw7W0GvfbNIbV7SwuVEgpKE2LqTQsSgSguUK0+xww si9lBAytPkr2zM+WsAG/A8G2CEwG6uokNdCACc2DaAxGLR7n7+P2et9bgXLykdPgebLc 57F8TkZb7NubryZlGO6GWJsI9TdVKXiUQemgMuKd/Qs7RnGTTysZo9IFM3/JdzdMdSAA RGj+fNzXgb36uz5+6wjindt+qJshiwnT9ANMZ2r6rBOXn/PtRikJI49ajuFGFCFNQ2ZY Qqhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=SFyJfR2WUZBDHeWemxJgoKouNxxtAGHlmHCCEO9QQfg=; b=TXLrfzZ8q/zoq5EJpT/eRYsjKnAeTHMSX+OHrxx5OqDCi1BS1ngxY6nPGRMBNoGgcu ww6aHzB3v88qYIe2Y0rMPm7fyXTKwO3qucmJyN9YMI9e/bxcATVYUW05llPqKe/9detJ XqkwEpkGb7x+KZrIMeyNDHuVMNYLxXVl4+TD2rZcHYKAoX1ywPR69FRaReoIATvwHL3c bHWUXB3GpYEkftr5khEE2TFvz7sj3VGerXyEVE8OTjCt/k3zilQ92GYKtr5WJaM5qeF+ SXLdgqpe/IIHggryhHD4uBUoewxXA5piwfLz2/h/KRFP+E2QWeo+tNjRu0c0vT1Nyvrh mqKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ihhHeh07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw15-20020a056402228f00b004542e6bd242si1290899edb.621.2022.12.01.03.21.39; Thu, 01 Dec 2022 03:22:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ihhHeh07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231396AbiLALQE (ORCPT + 99 others); Thu, 1 Dec 2022 06:16:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiLALO7 (ORCPT ); Thu, 1 Dec 2022 06:14:59 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52940CD9B5 for ; Thu, 1 Dec 2022 03:08:54 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id fy37so3296670ejc.11 for ; Thu, 01 Dec 2022 03:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SFyJfR2WUZBDHeWemxJgoKouNxxtAGHlmHCCEO9QQfg=; b=ihhHeh07lyLQ9+bLJAT02xtbEUUwBhwmY6NbvI/an2JMfUbxhGOKl7udb7lLh5mId9 jw5dKTuvmRP+w2K8ZYng51eJLaluDUotqflfy43/10yqWgw/yG+fgTeB0ukeRPMWa9sh dgPYzjd9Y05h6Utm7j5Kxf9v/xCIYLObtVbqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SFyJfR2WUZBDHeWemxJgoKouNxxtAGHlmHCCEO9QQfg=; b=MvnJKrfqHo/UiVA0GgrpwWEqa0JUBAbVfgjN+jqPLqvRoitioQ7j02Ok8gjBNoHw2I IIBOeCd5ySF+mZJLsX7RBy9DmfOdK1BVl+HRvq4sJGYkWPSxaAH6j/ZUINyGG0ORSrmx 8PtIoXZkivDjiz7OoXgJK8bu/LGIZPg/FI16Wk9qRM3KWzmh01YUQVr+gBeGYGG/7gPI moAIQoLpCjhC3qp3yqrlLgm+Ln4lqj7tXh1a/lGK3bgUivEM//VNc/I+ilynoJZ0CQEM OZ6CVVz4F1+WXotKuq94oURhVM5e//qsXOj1FQf+rdhDWqVijGefV46cB2gFPj7liBkK x7vA== X-Gm-Message-State: ANoB5pl3/hblPbJF6gtvZyarbE+7YIQOCeVRuMvV5tGjLKfBWzeRcx9h IiKKG4uHvzL1fK5df+cmJW41jQ== X-Received: by 2002:a17:906:7f09:b0:7c0:b3a8:a5f9 with SMTP id d9-20020a1709067f0900b007c0b3a8a5f9mr1338546ejr.154.1669892932820; Thu, 01 Dec 2022 03:08:52 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:f554:724a:f89a:73db]) by smtp.gmail.com with ESMTPSA id v17-20020a170906293100b0078e0973d1f5sm1663824ejd.0.2022.12.01.03.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 03:08:52 -0800 (PST) From: Ricardo Ribalda Date: Thu, 01 Dec 2022 12:08:23 +0100 Subject: [PATCH v8 3/3] ASoC: SOF: Fix deadlock when shutdown a frozen userspace MIME-Version: 1.0 Message-Id: <20221127-snd-freeze-v8-3-3bc02d09f2ce@chromium.org> References: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> In-Reply-To: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> To: Juergen Gross , Mark Brown , Chromeos Kdump , Daniel Baluta , Christophe Leroy , Len Brown , Ard Biesheuvel , Ranjani Sridharan , "Rafael J. Wysocki" , Boris Ostrovsky , Nicholas Piggin , Michael Ellerman , Eric Biederman , Dave Hansen , Jaroslav Kysela , Joel Fernandes , Liam Girdwood , Peter Ujfalusi , Pavel Machek , Pierre-Louis Bossart , Kai Vehmanen , Steven Rostedt , "K. Y. Srinivasan" , Ingo Molnar , Bjorn Helgaas , Dexuan Cui , Takashi Iwai , "H. Peter Anvin" , Bard Liao , Haiyang Zhang , Wei Liu , Thomas Gleixner , Borislav Petkov , x86@kernel.org Cc: kexec@lists.infradead.org, alsa-devel@alsa-project.org, Ricardo Ribalda , stable@vger.kernel.org, sound-open-firmware@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=2398; i=ribalda@chromium.org; h=from:subject:message-id; bh=GWM+B74HgZm8hg965LkIrG7utJXhrwWC6OA28kyyUjA=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjiIs5X8qunJcdzh4yNadWVeViZgDn3gq/06nr8kdj kdUAnBmJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4iLOQAKCRDRN9E+zzrEiBePD/ 4n9U/k8s8PcSMHwaDWquOwoHUGMa1OTSXQAeS+zkfPMUpMhgcoTNo49nWa43GN+Y810XaYiML51562 eLirizXRSalXPpYVLlUge+rUD8YTV54zGi5OoX528K7lwHG8z+THm4BSy0/gmpmwdgB3GttlQH5Xh0 P4IRFzzQUndzF5+V+rD7ZDsOIqsqHLEl2xVrPlelt3OtQTf7xzm+FTwEgxz8fg42kpdkTUjKNidLBa PVVihXzxaPSrNmIcrlXDWrTscOrbX2UGlosoMD4NyfKwacu0juZk+QLlYCoIBu78E/d04Top6bsU/I uqQOeIB3UrGvmdWb9fO9H/WX4GIFLG+w7VCfaLbEd22SI+WITCvp/dDA/ZO8fzX1wgQBHvFZRLIuM4 0mqtOEszlCVB4pMNrAVJcSULhKWOxrKI7MkUyf/otZRJ67hrWlDDaOmlBsOkJTF1T5obHSRoblMSSE UwMVB1vp64JD4LAxJGmFWSPjZ3BMJJK0mblOTi/qOiMm2QR7iraSkhMsUcpx9HI4IeSwbTJszKQ1Hb BgqjW0c2l0BpHzIlEvkoUHxIGQdKJLMfmy8GbTMKne5zBzPRx9+b+cGgNvRa/zWp72+v9Fm0r2l8rk 2c1+78340GIwSb9Ffj750Evz1ISy6b5FAAiC5q+SWoZEFW2mWMAN+3crcCZw== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751010421217500691?= X-GMAIL-MSGID: =?utf-8?q?1751010479675094617?= If we are shutting down due to kexec and the userspace is frozen, the system will stall forever waiting for userspace to complete. Do not wait for the clients to complete in that case. This fixes: [ 84.943749] Freezing user space processes ... (elapsed 0.111 seconds) done. [ 246.784446] INFO: task kexec-lite:5123 blocked for more than 122 seconds. [ 246.819035] Call Trace: [ 246.821782] [ 246.824186] __schedule+0x5f9/0x1263 [ 246.828231] schedule+0x87/0xc5 [ 246.831779] snd_card_disconnect_sync+0xb5/0x127 ... [ 246.889249] snd_sof_device_shutdown+0xb4/0x150 [ 246.899317] pci_device_shutdown+0x37/0x61 [ 246.903990] device_shutdown+0x14c/0x1d6 [ 246.908391] kernel_kexec+0x45/0xb9 And: [ 246.893222] INFO: task kexec-lite:4891 blocked for more than 122 seconds. [ 246.927709] Call Trace: [ 246.930461] [ 246.932819] __schedule+0x5f9/0x1263 [ 246.936855] ? fsnotify_grab_connector+0x5c/0x70 [ 246.942045] schedule+0x87/0xc5 [ 246.945567] schedule_timeout+0x49/0xf3 [ 246.949877] wait_for_completion+0x86/0xe8 [ 246.954463] snd_card_free+0x68/0x89 ... [ 247.001080] platform_device_unregister+0x12/0x35 Cc: stable@vger.kernel.org Fixes: 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") Signed-off-by: Ricardo Ribalda --- sound/soc/sof/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 3e6141d03770..9587b6a85103 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -9,6 +9,8 @@ // #include +#include +#include #include #include #include @@ -484,9 +486,10 @@ int snd_sof_device_shutdown(struct device *dev) * make sure clients and machine driver(s) are unregistered to force * all userspace devices to be closed prior to the DSP shutdown sequence */ - sof_unregister_clients(sdev); - - snd_sof_machine_unregister(sdev, pdata); + if (!(kexec_in_progress() && pm_freezing())) { + sof_unregister_clients(sdev); + snd_sof_machine_unregister(sdev, pdata); + } if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) return snd_sof_shutdown(sdev);