Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE4C8C2D0DB for ; Sat, 25 Jan 2020 10:40:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27AB520704 for ; Sat, 25 Jan 2020 10:40:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="L0rkydNo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27AB520704 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 73977166F; Sat, 25 Jan 2020 11:40:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 73977166F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1579948855; bh=+7DzrTS80QW0LQ1aaqm/SJJp4V3G4xib07NIp/+cM3g=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L0rkydNoyf883ivj8CXsfkDsMxTgs4hQprJUzunx5RKtAKpJajUuJ2HxXXIEJlqV7 ZIW/cfTtqHVpSlxnb0S0hWox+N+7YM26NRXhsEcUPS+VOUViXrWArZxPyLIWG2JdkC KFYtQD5plFKCAl0XTaJD4ysocFdhjeJIRtQK0pI8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E406DF801D9; Sat, 25 Jan 2020 11:40:04 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 366F3F801EC; Sat, 25 Jan 2020 11:40:03 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6F3AAF8012E for ; Sat, 25 Jan 2020 11:39:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6F3AAF8012E X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EBE5DB008; Sat, 25 Jan 2020 10:39:57 +0000 (UTC) Date: Sat, 25 Jan 2020 11:39:57 +0100 Message-ID: From: Takashi Iwai To: Pierre-Louis Bossart In-Reply-To: <20200124213625.30186-4-pierre-louis.bossart@linux.intel.com> References: <20200124213625.30186-1-pierre-louis.bossart@linux.intel.com> <20200124213625.30186-4-pierre-louis.bossart@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel@alsa-project.org, broonie@kernel.org, Kai Vehmanen Subject: Re: [alsa-devel] [PATCH 3/7] ASoC: SOF: core: release resources on errors in probe_continue X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Fri, 24 Jan 2020 22:36:21 +0100, Pierre-Louis Bossart wrote: > > The initial intent of releasing resources in the .remove does not work > well with HDaudio codecs. If the probe_continue() fails in a work > queue, e.g. due to missing firmware or authentication issues, we don't > release any resources, and as a result the kernel oopses during > suspend operations. > > The suggested fix is to release all resources during errors in > probe_continue(), and use fw_state to track resource allocation > state, so that .remove does not attempt to release the same > hardware resources twice. PM operations are also modified so that > no action is done if DSP resources have been freed due to > an error at probe. > > Reported-by: Takashi Iwai > Co-developed-by: Kai Vehmanen > Signed-off-by: Kai Vehmanen > Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=1161246 > Signed-off-by: Pierre-Louis Bossart This deserves for Cc to stable, as the bug already hits on both 5.4 and 5.5 kernels. Reviewed-by: Takashi Iwai thanks, Takashi > --- > sound/soc/sof/core.c | 33 ++++++++++++--------------------- > sound/soc/sof/pm.c | 4 ++++ > 2 files changed, 16 insertions(+), 21 deletions(-) > > diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c > index f517ab448a1d..34cefbaf2d2a 100644 > --- a/sound/soc/sof/core.c > +++ b/sound/soc/sof/core.c > @@ -244,7 +244,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) > > return 0; > > -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) > fw_trace_err: > snd_sof_free_trace(sdev); > fw_run_err: > @@ -255,22 +254,10 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) > snd_sof_free_debug(sdev); > dbg_err: > snd_sof_remove(sdev); > -#else > > - /* > - * when the probe_continue is handled in a work queue, the > - * probe does not fail so we don't release resources here. > - * They will be released with an explicit call to > - * snd_sof_device_remove() when the PCI/ACPI device is removed > - */ > - > -fw_trace_err: > -fw_run_err: > -fw_load_err: > -ipc_err: > -dbg_err: > - > -#endif > + /* all resources freed, update state to match */ > + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; > + sdev->first_boot = true; > > return ret; > } > @@ -353,10 +340,12 @@ int snd_sof_device_remove(struct device *dev) > if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) > cancel_work_sync(&sdev->probe_work); > > - snd_sof_fw_unload(sdev); > - snd_sof_ipc_free(sdev); > - snd_sof_free_debug(sdev); > - snd_sof_free_trace(sdev); > + if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { > + snd_sof_fw_unload(sdev); > + snd_sof_ipc_free(sdev); > + snd_sof_free_debug(sdev); > + snd_sof_free_trace(sdev); > + } > > /* > * Unregister machine driver. This will unbind the snd_card which > @@ -364,13 +353,15 @@ int snd_sof_device_remove(struct device *dev) > * before freeing the snd_card. > */ > snd_sof_machine_unregister(sdev, pdata); > + > /* > * Unregistering the machine driver results in unloading the topology. > * Some widgets, ex: scheduler, attempt to power down the core they are > * scheduled on, when they are unloaded. Therefore, the DSP must be > * removed only after the topology has been unloaded. > */ > - snd_sof_remove(sdev); > + if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) > + snd_sof_remove(sdev); > > /* release firmware */ > release_firmware(pdata->fw); > diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c > index 84290bbeebdd..a0cde053b61a 100644 > --- a/sound/soc/sof/pm.c > +++ b/sound/soc/sof/pm.c > @@ -56,6 +56,10 @@ static int sof_resume(struct device *dev, bool runtime_resume) > if (!sof_ops(sdev)->resume || !sof_ops(sdev)->runtime_resume) > return 0; > > + /* DSP was never successfully started, nothing to resume */ > + if (sdev->first_boot) > + return 0; > + > /* > * if the runtime_resume flag is set, call the runtime_resume routine > * or else call the system resume routine > -- > 2.20.1 > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel