Message ID | 20230720133147.1294337-11-sbinding@opensource.cirrus.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3142350vqt; Thu, 20 Jul 2023 07:05:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlEuEjm4dRM4sxZClrgbDkETY32M3Offtkff3mz0c5ubvyIJcLXjpY8E01puo2FHqG8trOus X-Received: by 2002:a05:6358:94a6:b0:132:cd75:1c0a with SMTP id i38-20020a05635894a600b00132cd751c0amr6545609rwb.2.1689861936431; Thu, 20 Jul 2023 07:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689861936; cv=none; d=google.com; s=arc-20160816; b=DutBDbqa0hexf0eEWtrtYUiifTapIuf6IhPtdaVE3sGZ+EKnvmN0y6ooRtnrxXz3Ld XurhrqxbpUPUkAPGl54/dm+Nmvl0Y3j7b+05PuEg+cAI3qMtCkERKcQH8tTB+9AkMfg0 zqrjmXFS4Z8YvSUQTUVwUVpkSHu6IUMeLcUU/bUklnJFGn0FDaLuVEtenJbepU0qMiO6 v+Tr/to1deQWu2lglEqMWLlNXchW7RlwzsZx+CVd6cceKCeTT45S5ecoiQuf2+8XhW4u UOs5DRVKZiynXSvDCL1KIMT1zoc0sl5oIc1hyDNJZh2XKlcqNzZja4wEHZqPbMWrlx/h brBA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+qN9Ba/zcDYNDAt+9zFzeFPD1ff0RraaH+W+sIKImwQ=; fh=SlosecZATRUXmC/bbEWM8TNuSSdsEnMKt8FFeHbK2kw=; b=RccoKr3ESFkmLJojkYOpJRFnAbG+GorEvQrlKMSHQ/j0rPsYmd6Q4o9rX7MPUqL1qY rjuk559HvVzudj0xJ0AIhOkrSdmOuJuHZZcfaasb6IQtUFMthVAl/qGoeYo9eDH/meRn /chaq1glYOyqpm2jLc+NQRptZ4Iv+dZK3Aw6QCcH7lhuKVswEUZ2V6/8kiWOunoc3hGS J3wcjT5faDhQc82e5CFO6O1YP9my6mKDiVySXIvoFte29PrLYjP0SppeZ9DQVy/OUsxp +1N8QGLTqnLQmsYT47VE1Lxt1ktso+87RJHDMGivcaJJbbfCEAZu1dash06lzCOu0Hzh dCXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=OiCa1YM4; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a635a41000000b005526bd0c526si857476pgm.641.2023.07.20.07.05.21; Thu, 20 Jul 2023 07:05:36 -0700 (PDT) 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=@cirrus.com header.s=PODMain02222019 header.b=OiCa1YM4; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbjGTNdr (ORCPT <rfc822;chrisben.tianve@gmail.com> + 99 others); Thu, 20 Jul 2023 09:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbjGTNdi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 20 Jul 2023 09:33:38 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086DF2737 for <linux-kernel@vger.kernel.org>; Thu, 20 Jul 2023 06:33:08 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36KAupUq002185; Thu, 20 Jul 2023 08:32:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=+qN9Ba/zcDYNDAt+9zFzeFPD1ff0RraaH+W+sIKImwQ=; b= OiCa1YM4D1wcJwMtkZ4b28ksnu7xzCsgbN/Pc8On7U6GGqYdMRF1PoZr+JJDPYvV 3tP5SbB/utXUkGXgmjHGsH3JNdwaGx4Y8w3G1/QaByxWaVAFmhgQbj4U9gzkM593 ux+iKVrgY0RJxQ1NMNcR7y7MiZfJYq4Ne+6lAMsionfEPy0AfNFV2fC0OEDxFuU6 KgNdStqbjSsx9fxvk1v0DajrQQMXVqGJIaQOFnjlBaLYncmqGlw+WMUxfEPJrO92 dpTzemr15wsKsCdQ806DHByxIB2M3f9TjX4lJhu6wwIPK6je8x1SeepuM/Uzg844 ugzNuOka4MYETm3mVMuC/A== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3rus6gx5mq-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jul 2023 08:32:14 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Thu, 20 Jul 2023 14:32:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.30 via Frontend Transport; Thu, 20 Jul 2023 14:32:11 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.219]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B07C2458; Thu, 20 Jul 2023 13:32:11 +0000 (UTC) From: Stefan Binding <sbinding@opensource.cirrus.com> To: Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> CC: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>, Stefan Binding <sbinding@opensource.cirrus.com> Subject: [PATCH v1 10/11] ALSA: hda: cs35l41: Add device_link between HDA and cs35l41_hda Date: Thu, 20 Jul 2023 14:31:46 +0100 Message-ID: <20230720133147.1294337-11-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720133147.1294337-1-sbinding@opensource.cirrus.com> References: <20230720133147.1294337-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: lOqeNVT_YXhfrgC4jjgXJ393fQACn_3F X-Proofpoint-GUID: lOqeNVT_YXhfrgC4jjgXJ393fQACn_3F X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771948669822203938 X-GMAIL-MSGID: 1771948669822203938 |
Series |
Fix support for System Suspend for CS35L41 HDA
|
|
Commit Message
Stefan Binding
July 20, 2023, 1:31 p.m. UTC
To ensure consistency between the HDA core and the CS35L41 HDA
driver, add a device_link between them. This ensures that the
HDA core will suspend first, and resume second, meaning the
amp driver will not miss any events from the playback hook from
the HDA core during system suspend and resume.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/pci/hda/cs35l41_hda.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
Comments
On Thu, 20 Jul 2023 15:31:46 +0200, Stefan Binding wrote: > > To ensure consistency between the HDA core and the CS35L41 HDA > driver, add a device_link between them. This ensures that the > HDA core will suspend first, and resume second, meaning the > amp driver will not miss any events from the playback hook from > the HDA core during system suspend and resume. > > Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> > --- > sound/pci/hda/cs35l41_hda.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c > index 70aa819cfbd64..175378cdf9dfa 100644 > --- a/sound/pci/hda/cs35l41_hda.c > +++ b/sound/pci/hda/cs35l41_hda.c > @@ -1063,6 +1063,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas > { > struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); > struct hda_component *comps = master_data; > + unsigned int sleep_flags; > int ret = 0; > > if (!comps || cs35l41->index < 0 || cs35l41->index >= HDA_MAX_COMPONENTS) > @@ -1102,6 +1103,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas > > mutex_unlock(&cs35l41->fw_mutex); > > + sleep_flags = lock_system_sleep(); > + if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) > + dev_warn(dev, "Unable to create device link\n"); > + unlock_system_sleep(sleep_flags); Is lock_system_sleep() mandatory for device_link_add()? The function takes its rw lock for the race, I suppose. thanks, Takashi
On 20/07/2023 15:21, Takashi Iwai wrote: > On Thu, 20 Jul 2023 15:31:46 +0200, > Stefan Binding wrote: >> To ensure consistency between the HDA core and the CS35L41 HDA >> driver, add a device_link between them. This ensures that the >> HDA core will suspend first, and resume second, meaning the >> amp driver will not miss any events from the playback hook from >> the HDA core during system suspend and resume. >> >> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> >> --- >> sound/pci/hda/cs35l41_hda.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c >> index 70aa819cfbd64..175378cdf9dfa 100644 >> --- a/sound/pci/hda/cs35l41_hda.c >> +++ b/sound/pci/hda/cs35l41_hda.c >> @@ -1063,6 +1063,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas >> { >> struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); >> struct hda_component *comps = master_data; >> + unsigned int sleep_flags; >> int ret = 0; >> >> if (!comps || cs35l41->index < 0 || cs35l41->index >= HDA_MAX_COMPONENTS) >> @@ -1102,6 +1103,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas >> >> mutex_unlock(&cs35l41->fw_mutex); >> >> + sleep_flags = lock_system_sleep(); >> + if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) >> + dev_warn(dev, "Unable to create device link\n"); >> + unlock_system_sleep(sleep_flags); > Is lock_system_sleep() mandatory for device_link_add()? The function > takes its rw lock for the race, I suppose. I believe this is mandatory, to ensure we don't try to add the device link during a suspend/resume transition. Its probably unlikely that that would occur during the component bind, but just in case. Thanks, Stefan > > > thanks, > > Takashi
On Fri, 21 Jul 2023 16:55:43 +0200, Stefan Binding wrote: > > > On 20/07/2023 15:21, Takashi Iwai wrote: > > On Thu, 20 Jul 2023 15:31:46 +0200, > > Stefan Binding wrote: > >> To ensure consistency between the HDA core and the CS35L41 HDA > >> driver, add a device_link between them. This ensures that the > >> HDA core will suspend first, and resume second, meaning the > >> amp driver will not miss any events from the playback hook from > >> the HDA core during system suspend and resume. > >> > >> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> > >> --- > >> sound/pci/hda/cs35l41_hda.c | 13 ++++++++++++- > >> 1 file changed, 12 insertions(+), 1 deletion(-) > >> > >> diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c > >> index 70aa819cfbd64..175378cdf9dfa 100644 > >> --- a/sound/pci/hda/cs35l41_hda.c > >> +++ b/sound/pci/hda/cs35l41_hda.c > >> @@ -1063,6 +1063,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas > >> { > >> struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); > >> struct hda_component *comps = master_data; > >> + unsigned int sleep_flags; > >> int ret = 0; > >> if (!comps || cs35l41->index < 0 || cs35l41->index >= > >> HDA_MAX_COMPONENTS) > >> @@ -1102,6 +1103,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas > >> mutex_unlock(&cs35l41->fw_mutex); > >> + sleep_flags = lock_system_sleep(); > >> + if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) > >> + dev_warn(dev, "Unable to create device link\n"); > >> + unlock_system_sleep(sleep_flags); > > Is lock_system_sleep() mandatory for device_link_add()? The function > > takes its rw lock for the race, I suppose. > > I believe this is mandatory, to ensure we don't try to add the device > link during a suspend/resume transition. > Its probably unlikely that that would occur during the component bind, > but just in case. OK, it seems needed in this case. I found the description in device_link.rst, too. thanks, Takashi
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 70aa819cfbd64..175378cdf9dfa 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1063,6 +1063,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); struct hda_component *comps = master_data; + unsigned int sleep_flags; int ret = 0; if (!comps || cs35l41->index < 0 || cs35l41->index >= HDA_MAX_COMPONENTS) @@ -1102,6 +1103,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas mutex_unlock(&cs35l41->fw_mutex); + sleep_flags = lock_system_sleep(); + if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) + dev_warn(dev, "Unable to create device link\n"); + unlock_system_sleep(sleep_flags); + pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); @@ -1112,9 +1118,14 @@ static void cs35l41_hda_unbind(struct device *dev, struct device *master, void * { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); struct hda_component *comps = master_data; + unsigned int sleep_flags; - if (comps[cs35l41->index].dev == dev) + if (comps[cs35l41->index].dev == dev) { memset(&comps[cs35l41->index], 0, sizeof(*comps)); + sleep_flags = lock_system_sleep(); + device_link_remove(&comps->codec->core.dev, cs35l41->dev); + unlock_system_sleep(sleep_flags); + } } static const struct component_ops cs35l41_hda_comp_ops = {