Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp310577pxb; Thu, 26 Aug 2021 03:51:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj6XnFi3lfNxp+vezDVlKD8+yoQvp8pOw24NGurhfqQhk5B7AwZ7BWcpu/xuD4IKxte2wY X-Received: by 2002:a5d:8b17:: with SMTP id k23mr2470838ion.17.1629975096144; Thu, 26 Aug 2021 03:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629975096; cv=none; d=google.com; s=arc-20160816; b=Byi9COznCMvw91f9Yj0pnBK8mlPpEPfBs9G8ZIRCpCfbSLg9XwfqMHQOw2JxrNxRHV V4L9xkk8SmmqejKk8vkWv8TJCfGwl1hFo42K/GsLN7SfRn00cYSFbYbU1iKBr8Aa5LAY wyvaCLYjzZJh2VqEl3bBwBNrpppbC1RE7KG6uyhpQn7J8orMBcW6bOsCMsFqnEqScz4e I+2i7lIHoQM0c6Kybmv8pc6o0anPKCUZ7PPHV59x8a90DC2ThrrB1PxKbf6592azbfo2 6DVWU6TWA10MWfH4yB/Wpb8NploJ2MDjVHX1/XImsvFQ0K/MvelOiOt5eOCmMkhHfbMq suoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature:dkim-signature; bh=7NVS9OI1fs2Z7OHaLZdCp7jkiVKSbEuKJi+PNLYoQ1g=; b=eqYbcDNZSJu9PvyO3Y5oNMvYMggtxXt05RvH5h4K49W78bRT7HAVjYiVlnnZMr4V39 S6Er8w3G8yn12D69A1MsGaPlvCeGndXqMpfVLH9bQSO5RuJT7bJOJ70kD2IF6UyCSJvz J4pMhlxS54E0Pt3KsPzyax2ikDVFszaGawjhjeOo7UjaEiMPYL4S+oRa9eUjcSBz+rMm oTDWRzBGIwl4N61gId2COUb4+xrXZpoK6u7C/Rosjl0q4UHtF5jF5m4ct464/8OmFRBK C3z67CWyU2tyU8Cu0nwvoAt7ye1TGROfDmh/6jBbTORlwOhBOYTP9ML2n4HvKfyAMuf7 Wxmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vsU3XcOW; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si2656341ilk.59.2021.08.26.03.51.24; Thu, 26 Aug 2021 03:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vsU3XcOW; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234296AbhHZKuD (ORCPT + 99 others); Thu, 26 Aug 2021 06:50:03 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:40084 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234327AbhHZKt7 (ORCPT ); Thu, 26 Aug 2021 06:49:59 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D23FB222CD; Thu, 26 Aug 2021 10:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629974951; 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=7NVS9OI1fs2Z7OHaLZdCp7jkiVKSbEuKJi+PNLYoQ1g=; b=vsU3XcOWyDOGYYEN/rXXvMulewcmea+bKA/sNOE+4PxiaIGl2ULn7rYLtHHXZ3lAirlpRA ZV56kj+E+FIAWBdeWFv2pRJMdjb/nmTCz6XMP+06bH6wmPUmCM/nMQn1ARPtsFGRmItv2E 8CAMooWwjrk4AUBiAz+0Oj7mQDdVoHA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629974951; 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=7NVS9OI1fs2Z7OHaLZdCp7jkiVKSbEuKJi+PNLYoQ1g=; b=r7Tm31Vu8fm9bKxXUQ2YtnPsiWmai90h8vm8KmRVtY6e/4tZIDTvQxM5hQw0UnLg6y2jS1 NNq13BiL2RqbeKBw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id C0CD6A3B95; Thu, 26 Aug 2021 10:49:11 +0000 (UTC) Date: Thu, 26 Aug 2021 12:49:11 +0200 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Cc: , , Stefan Binding , Takashi Iwai , 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Aug 2021 08:03:45 +0200, Takashi Iwai wrote: > > 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? Sorry there was a typo. A bit more revised patch is below. Takashi --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1383,14 +1383,17 @@ static void azx_free(struct azx *chip) hda->freed = 1; } -static int azx_dev_disconnect(struct snd_device *device) +static void __azx_disconnect(struct azx *chip) { - struct azx *chip = device->device_data; struct hdac_bus *bus = azx_bus(chip); chip->bus.shutdown = 1; cancel_work_sync(&bus->unsol_work); +} +static int azx_dev_disconnect(struct snd_device *device) +{ + __azx_disconnect(device->device_data); return 0; } @@ -2356,8 +2359,10 @@ static void azx_shutdown(struct pci_dev *pci) if (!card) return; chip = card->private_data; - if (chip && chip->running) + if (chip && chip->running) { + __azx_disconnect(chip); azx_shutdown_chip(chip); + } } /* PCI IDs */