Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14897627rwb; Mon, 28 Nov 2022 06:07:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf7e1+9WjvVk339QuzIVTX225RP4flB7fAifFudK7wolQjESRg3JHSo0523NC1wwzU/4QV/T X-Received: by 2002:a05:6402:294b:b0:458:cd82:91a with SMTP id ed11-20020a056402294b00b00458cd82091amr47152783edb.15.1669644466986; Mon, 28 Nov 2022 06:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669644466; cv=none; d=google.com; s=arc-20160816; b=eTlAP2zx/nF7Re1crrnuvVXMLaEorGErrsU1PiCCWIMLyQWaC8VkkCaiA1ulrqHuMf UXpTI6zBM0zOgm+iiMT4nmBKZ5rJfl6BUDoE4be0W+Q8wJDZvWWCWUC4zd80GWrdgewI fMml/PkNPc9Z5f0oaGX6r2SzbA0JuY4qVhr7VeHYdo7LhABv8AdEfC0eU4I7DdjsSuVN P6Bn8gWl2iw+TtIaMCQyBZuISL/X2b2vzORHzQS8qMoUGa+ToTLNtLQCeS3mNfhDroVX hS4AuFiSdAydSiEVKsA3zYbAFa8wxiemOvx3gpyfdFHOyHHuThYNHuYD0darZuYWDnP/ Z6Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=8xdIjoOikGdAZKov94FlnwSjqEqsO1SC5byhX9Q9RLU=; b=cUhqH2SHp8Hb1e7Jbw+0QhXpKP1l5S02qvD2OTdMIgFKi4EgCAmORKh0hRYB78pDS3 m1K2qQQB6LWGFfWgJXctfFH+LqWDD4nbHKclGNCzvR417qF6GexIPeF72QWaIBPqTnzx wA8Kpb+PYu6+xScflcpMd4rn0S39VJdJtQcvVqL/WBeTOOBmOsZV/QV0N9WA+kFVhn0e VSt7VHu4GYV2skP92ebDKcuLUIkMsSBVVdXBs8zRtwxv6fm1663VBMOFz43XOBH6b1oC BVTiCGRfg1iauIE+9A/P56fLRjTFomSo1C5S+SCLYkFF9TL1i17y2hAFPKHmhO/ZRDNa /ygQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jEvKo4Xz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz8-20020a0564021d4800b00469e7011949si12019556edb.508.2022.11.28.06.07.21; Mon, 28 Nov 2022 06:07:46 -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=jEvKo4Xz; 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 S231994AbiK1NnY (ORCPT + 84 others); Mon, 28 Nov 2022 08:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbiK1NnB (ORCPT ); Mon, 28 Nov 2022 08:43:01 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38E633AC for ; Mon, 28 Nov 2022 05:42:55 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id b2so9586054eja.7 for ; Mon, 28 Nov 2022 05:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=8xdIjoOikGdAZKov94FlnwSjqEqsO1SC5byhX9Q9RLU=; b=jEvKo4Xz7BCEk5NFMOWgRBT/TrETg2qR5X6hoc/aB/wXvdRIsbpe2NAzulkGQxZrHu RLxjxQBfTIAxEHmK/FBOhhMItJbRKUaqD2gCLiH4qrTnyxOUpRQAAadH/5fX/rfkFySY ZCD3BJnuyzNHoFJOjRR5/RFZmhAM7rd9nHyvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8xdIjoOikGdAZKov94FlnwSjqEqsO1SC5byhX9Q9RLU=; b=67YDCYSKtvR3i7fhuwuwEy7iulUJKvZn2O+9nH9xtpsqd/ti3SDjBAEfhXRZwj40Np db8a6YhyqsIPb7a0rlR3xIxksB1lAWpiyipfCRZod4puDxh0QmjxFJfm7OCtnS9JPu5u 2zkWnYyzNEvwPocZ6qOtYsosepPzsLgF+6VdYX5xouSB6zc//GYx9EyfqVAyisNr+HSb C4u0PLVjzWMvYsrdffIe9zZCeYxm1tpwb0y8S+JcO9A6sDHNnEdGnW0V1Mz4WzpsgIXQ hMUC7yP/vLP82whzBdixByoSTfiCli92EPZQn/A+itGMY1h2YyeQoncjUdP5qNHmd6jy G3xA== X-Gm-Message-State: ANoB5pmTuq0ycSJhXem08qW2E+mfP8wcsyn9dRbpHB26h67k9Od5ASfZ 2eo7SCApxXOAzqIftFvFNA8Syg== X-Received: by 2002:a17:906:692:b0:7ad:49b8:1687 with SMTP id u18-20020a170906069200b007ad49b81687mr33385064ejb.407.1669642973563; Mon, 28 Nov 2022 05:42:53 -0800 (PST) Received: from alco.roam.corp.google.com (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id vt4-20020a170907a60400b0073d7b876621sm4959667ejc.205.2022.11.28.05.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 05:42:53 -0800 (PST) From: Ricardo Ribalda Date: Mon, 28 Nov 2022 14:42:49 +0100 Subject: [PATCH v4] ALSA: core: Fix deadlock when shutdown a frozen userspace MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20221127-snd-freeze-v4-0-51ca64b7f2ab@chromium.org> To: Kai Vehmanen , Jaroslav Kysela , Pierre-Louis Bossart , Peter Ujfalusi , Mark Brown , Daniel Baluta , Bard Liao , Takashi Iwai , Ranjani Sridharan , Liam Girdwood Cc: Ricardo Ribalda , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, stable@vger.kernel.org, sound-open-firmware@alsa-project.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3529; i=ribalda@chromium.org; h=from:subject:message-id; bh=CuZgvNcaSIcLqEhNVxL+uczDhS4EM71Cxydwohy6ArE=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjhLraAkpShzLacNLIjWc+7CfukKCbU2FcaQSEkkOd E8G3s4KJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4S62gAKCRDRN9E+zzrEiGH7EA CNcjEMcS8oZDbadEJ0IDQyhibQPQceQUEVYKPeBv62cDgSKswxDoYu7I21X8O3OW/ETvQDNB35/q+/ zePdiuhYJAeq1gaZ0ZIQp1gnjL9UXoYe06jde9gfB2aSfGhIhftVfaonKSf8Htyc/QMGq5D9oOZp4Q dYHsRJz4U/vgGfQH+jw6e9OTfOrMPK3eYsBGj5KoLFHloSVasKuWkhbUew0gkoUwQ/alk1/D2wnc3x +L7Hb+PaA81/r27oPmxZsAyS5j/b0a+MOZQHklYy057opBh2yFiBzxtHHVAaMkfWSDNkP1TlQb0G+k yGL+d1q6+Tr20HenI6fYnRlZqLSsemE71t/IDYLqaqBzw3rb5HSgOE4Rvoflp0rvehq7SbPg5a4nBV 0xqBwSM0EhLUmkO8uelk8FP36MCIEqMgb1f2WZk1tnKow0opnWYhYxVEI+S+glbxB0M6PnIThE8v+t srJTQmnIL6SyHOYuPyixoYX74/acbjKa/aNBVtpVhI/9vImy2CcNVSJvs+iUfBcueS/D9bQd77BUb8 rp84vTCAMUWPQRwbZPWXYf7XbUjWrBerTZKGq3rD6omJ6zuReFxmAHWhCtr0kk4SFFGCauSoGeN63s eaC7xewSghyIwwa1bFPaIqN0Hsd9ukkUo1nUInfZPdx3d5lQxv6NGnPBjCRg== 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 During kexec(), the userspace is frozen. Therefore we cannot wait for it to complete. Avoid running snd_sof_machine_unregister during shutdown. 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 --- To: Pierre-Louis Bossart To: Liam Girdwood To: Peter Ujfalusi To: Bard Liao To: Ranjani Sridharan To: Kai Vehmanen To: Daniel Baluta To: Mark Brown To: Jaroslav Kysela To: Takashi Iwai Cc: sound-open-firmware@alsa-project.org Cc: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org --- Changes in v4: - Do not call snd_sof_machine_unregister from shutdown. - Link to v3: https://lore.kernel.org/r/20221127-snd-freeze-v3-0-a2eda731ca14@chromium.org Changes in v3: - Wrap pm_freezing in a function - Link to v2: https://lore.kernel.org/r/20221127-snd-freeze-v2-0-d8a425ea9663@chromium.org Changes in v2: - Only use pm_freezing if CONFIG_FREEZER - Link to v1: https://lore.kernel.org/r/20221127-snd-freeze-v1-0-57461a366ec2@chromium.org --- sound/soc/sof/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 3e6141d03770..9616ba607ded 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -475,19 +475,16 @@ EXPORT_SYMBOL(snd_sof_device_remove); int snd_sof_device_shutdown(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); - struct snd_sof_pdata *pdata = sdev->pdata; if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) cancel_work_sync(&sdev->probe_work); /* - * make sure clients and machine driver(s) are unregistered to force - * all userspace devices to be closed prior to the DSP shutdown sequence + * make sure clients are unregistered prior to the DSP shutdown + * sequence. */ sof_unregister_clients(sdev); - snd_sof_machine_unregister(sdev, pdata); - if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) return snd_sof_shutdown(sdev); --- base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4 change-id: 20221127-snd-freeze-1ee143228326 Best regards, -- Ricardo Ribalda