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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7438BEB64DC for ; Fri, 21 Jul 2023 15:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231562AbjGUPFs (ORCPT ); Fri, 21 Jul 2023 11:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjGUPFq (ORCPT ); Fri, 21 Jul 2023 11:05:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11ADF19B6 for ; Fri, 21 Jul 2023 08:05:43 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AE4BE218B0; Fri, 21 Jul 2023 15:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689951942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FNa2Ga/vdBWuEamymR1djSQjbjCUdeP1tyXN5hm2If8=; b=t4gEHRUn/4R1W1nvw16UePnaCr7czzXy/iJLYd2r+M3+434Q0UFdraRXzjH8hTOP6DE+oH WPeuxmi61S3jX50XqOk28s0nZfZUoqzC7seehhRj6HZyk+KjIBK1Rj/8PvWo8ADZy1BdZK mMqSV7HQMLxnGGdzkmtnVepqnUXrlbs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689951942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FNa2Ga/vdBWuEamymR1djSQjbjCUdeP1tyXN5hm2If8=; b=w6JhbvP0+FjcIugs7BlpcG0tVg43PKwHZg8p7vEm8rkRhu+vgkf29KvGOvwHqpCUemJF74 9F2WxABiH/6v9+Bg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 79021134BA; Fri, 21 Jul 2023 15:05:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZSWVHMaeumQ2IQAAMHmgww (envelope-from ); Fri, 21 Jul 2023 15:05:42 +0000 Date: Fri, 21 Jul 2023 17:05:42 +0200 Message-ID: <875y6dz4mx.wl-tiwai@suse.de> From: Takashi Iwai To: Stefan Binding Cc: Mark Brown , Jaroslav Kysela , Takashi Iwai , , , Subject: Re: [PATCH v1 10/11] ALSA: hda: cs35l41: Add device_link between HDA and cs35l41_hda In-Reply-To: References: <20230720133147.1294337-1-sbinding@opensource.cirrus.com> <20230720133147.1294337-11-sbinding@opensource.cirrus.com> <87v8eeiryp.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >> --- > >> 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