From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 0D2B4C432BE for ; Thu, 26 Aug 2021 06:04:51 +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 63A07610CB for ; Thu, 26 Aug 2021 06:04:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 63A07610CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=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 DB8DE166D; Thu, 26 Aug 2021 08:03:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB8DE166D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629957887; bh=NiTNDOZVy0ptnDbagM5FaD9GXF/022F1KUWhAC2sg+g=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OftA/AskVY59Lg0Txl7H+KigULByW66M1gKs1QP83adlYRdtpXvhUhJfBGyYqCK/B 5VP0t5plKPUZCfNi3GKWmWb4xzV2W12PUyG3HqCxCEkem8du2FrsayGaQssXimqt9o E6+fU1NFPULMRvdV19EyUqIoIP9/D4vesU1AjqDc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6AB48F8013F; Thu, 26 Aug 2021 08:03:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C6881F801D8; Thu, 26 Aug 2021 08:03:54 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CECA6F8013F for ; Thu, 26 Aug 2021 08:03:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CECA6F8013F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="cu4eirSW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="fm3uV55Q" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 36B7122275; Thu, 26 Aug 2021 06:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629957825; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SNpBB1riqWMDgTE3zjGmFc2HQ/tL4Dep2J1e5XaBy04=; b=cu4eirSW+5hHB/QGrqiL+5zPRaYHWNOMwV7XFP2NmbGdXIDu53pBC/7mSqABuvrPFRGQcd ZRVpyRmtVKjx2P49Z7tasFLO9zoMCIc3+hADXSR+Zk3qmYnntAJrp6lxNb5vhs+5AbQ8qo gv/Kk/IwqK3c1GIMa/EK6Dl73w34Yy0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629957825; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SNpBB1riqWMDgTE3zjGmFc2HQ/tL4Dep2J1e5XaBy04=; b=fm3uV55QwT9JRwtq/R5RU6dPv33n4R+zjz9hNhqOzhymo8Ud1e0Ujta/UJ8Y/Wl6l78pQ/ 2V7uwIyOmXfCClDA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 2C0D6A3B89; Thu, 26 Aug 2021 06:03:45 +0000 (UTC) Date: Thu, 26 Aug 2021 08:03:45 +0200 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Subject: Re: [PATCH 2/2] ALSA: hda/cs8409: Prevent pops and clicks during reboot In-Reply-To: References: <20210812183433.6330-1-vitalyr@opensource.cirrus.com> <20210812183433.6330-2-vitalyr@opensource.cirrus.com> <6595e87d-1dae-b536-c17b-eafa07d04bbe@opensource.cirrus.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") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, Stefan Binding , linux-kernel@vger.kernel.org, Takashi Iwai 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, 25 Aug 2021 20:04:05 +0200, Vitaly Rodionov wrote: > Actually when codec is suspended and we do reboot from UI, then sometimes we > see suspend() calls in kernel log and no pops, but sometimes > > we still have no suspend() on reboot and we hear pops. But when we do reboot > from command line: > sudo reboot  then we always have pops and no suspend() > called. > > Then we have added extra logging and we can see that on reboot codec somehow > getting resume() call and we run jack detect on resume that causing pops. Hm, it's interesting who triggers the runtime resume. > We were thinking about possible solution for that and we would propose some > changes in generic code hda_bind.c: > > static void hda_codec_driver_shutdown(struct device *dev) { +   if (codec-> > patch_ops.suspend) +      codec->patch_ops.suspend(codec);    > snd_hda_codec_shutdown(dev_to_hda_codec(dev)); +  hda_codec_driver_remove > (dev_to_hda_codec(dev)); } Sorry, it's no-no. The suspend can't be called unconditionally, and the driver unbind must not be called in the callback itself. Does the patch below work instead? thanks, Takashi --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2356,8 +2356,11 @@ static void azx_shutdown(struct pci_dev *pci) if (!card) return; chip = card->private_data; - if (chip && chip->running) + if (chip && chip->running) { + chip->bus.shutdown = 1; + cancel_work_sync(&bus->unsol_work); azx_shutdown_chip(chip); + } } /* PCI IDs */