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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96574C433F5 for ; Wed, 20 Oct 2021 09:17:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 746BD61074 for ; Wed, 20 Oct 2021 09:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbhJTJTj (ORCPT ); Wed, 20 Oct 2021 05:19:39 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:53068 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbhJTJTj (ORCPT ); Wed, 20 Oct 2021 05:19:39 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2412821A95; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1634721444; 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=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=fc1si36eMekGSQDqcS/Hn3Eorlm6YyDIm/s2QHHgKQUzjS46rECZKO3+n1oE9Nbk4ifixX lHutHNI6ClB8dkbZYqDyWqO4MSVM5OdXNwSw0pd/TeeNDcLAcLbQu7Al7YRxspvGYABhm/ kEFqql32f4JdNRImBy/VF3c03nUsD6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1634721444; 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=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=pEnnCCdRCZrs86YOnpoamSueJv/AfbpZdfLMiHOcWnBqMS+tMPKzKMwcS74ex8rJLtlK+x yUV8QW7y9zvj8BBQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 04F4FA3B83; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) Date: Wed, 20 Oct 2021 11:17:24 +0200 Message-ID: From: Takashi Iwai To: Lucas Tanure Cc: Mark Brown , Takashi Iwai , "Jaroslav Kysela" , Len Brown , David Rhodes , Liam Girdwood , "Rafael J . Wysocki" , , , , Subject: Re: [RFC PATCH v2 2/3] ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop Speakers In-Reply-To: <20211020085944.17577-3-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> <20211020085944.17577-3-tanureal@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=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Wed, 20 Oct 2021 10:59:43 +0200, Lucas Tanure wrote: > > Find the associated Amps by dai name, and use dai ops to configure it. > Disable support for Amps if ASoC not built. Hrm, it's the question whether such a sneaking into DAI access in open code is a good idea. If any, it could be done by some helper function instead. And some more details: > +static int alc_add_soc_dai_list(struct alc_spec *spec, const char *dai_name) > +{ > +#if IS_ENABLED(CONFIG_SND_SOC) > + struct snd_soc_dai_link_component dlc; > + struct alc_soc_dai_node *dai_node; > + //struct snd_soc_component *comp; > + struct snd_soc_dai *dai; > + > + dlc.dai_name = dai_name; > + dlc.of_node = NULL; > + dlc.name = NULL; > + > + dai = snd_soc_find_dai(&dlc); > + if (!dai) > + return -EPROBE_DEFER; The deferred probe won't work at this stage for HD-audio codecs unlike many ASoC codec drivers. And moreover, the fixup action doesn't handle the error at all... Second, this way may lead to use-after-free if the ASoC stuff is unbound while the usage from HD-audio codec side. Also, the dependency mess is still there. Even if we allow the hard binding to ASoC core here, IS_ENABLED() wouldn't work properly. It must be IS_REACHABLE(). thanks, Takashi 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 823AEC433EF for ; Wed, 20 Oct 2021 09:18:30 +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 EAF0B60F9E for ; Wed, 20 Oct 2021 09:18:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EAF0B60F9E 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 B3F5D16E3; Wed, 20 Oct 2021 11:17:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B3F5D16E3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634721506; bh=M65ERvVuU3IAKLeEPia98DWS2Q2ldYd4uUFwE6kXOu4=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=O9qqsYP53bfD0sl6g9qP8v5V26BmA9JQxicX87Go72s5JDR0PAdhXr0WUjfYd+uEb VsgHlsEE+r2DT7iOaNNbIphInU8whr/QiCrMoNBVOj8eZHzZu19M1l4ZQIUH0L5Pt4 ZgQ2rPn7j9tNZeOZNPbTkYSMf955rd14xOjBlVos= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 49A01F80082; Wed, 20 Oct 2021 11:17:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0397EF80224; Wed, 20 Oct 2021 11:17:35 +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 9C626F80082 for ; Wed, 20 Oct 2021 11:17:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9C626F80082 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fc1si36e"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pEnnCCdR" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2412821A95; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1634721444; 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=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=fc1si36eMekGSQDqcS/Hn3Eorlm6YyDIm/s2QHHgKQUzjS46rECZKO3+n1oE9Nbk4ifixX lHutHNI6ClB8dkbZYqDyWqO4MSVM5OdXNwSw0pd/TeeNDcLAcLbQu7Al7YRxspvGYABhm/ kEFqql32f4JdNRImBy/VF3c03nUsD6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1634721444; 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=mDhieyIXeE4V5jHwQZTe7ZXZZbr+qjBnbmqOemXSzlk=; b=pEnnCCdRCZrs86YOnpoamSueJv/AfbpZdfLMiHOcWnBqMS+tMPKzKMwcS74ex8rJLtlK+x yUV8QW7y9zvj8BBQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 04F4FA3B83; Wed, 20 Oct 2021 09:17:24 +0000 (UTC) Date: Wed, 20 Oct 2021 11:17:24 +0200 Message-ID: From: Takashi Iwai To: Lucas Tanure Subject: Re: [RFC PATCH v2 2/3] ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop Speakers In-Reply-To: <20211020085944.17577-3-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> <20211020085944.17577-3-tanureal@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=US-ASCII Cc: alsa-devel@alsa-project.org, "Rafael J . Wysocki" , patches@opensource.cirrus.com, Takashi Iwai , Liam Girdwood , David Rhodes , linux-acpi@vger.kernel.org, Mark Brown , linux-kernel@vger.kernel.org, Len Brown 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, 20 Oct 2021 10:59:43 +0200, Lucas Tanure wrote: > > Find the associated Amps by dai name, and use dai ops to configure it. > Disable support for Amps if ASoC not built. Hrm, it's the question whether such a sneaking into DAI access in open code is a good idea. If any, it could be done by some helper function instead. And some more details: > +static int alc_add_soc_dai_list(struct alc_spec *spec, const char *dai_name) > +{ > +#if IS_ENABLED(CONFIG_SND_SOC) > + struct snd_soc_dai_link_component dlc; > + struct alc_soc_dai_node *dai_node; > + //struct snd_soc_component *comp; > + struct snd_soc_dai *dai; > + > + dlc.dai_name = dai_name; > + dlc.of_node = NULL; > + dlc.name = NULL; > + > + dai = snd_soc_find_dai(&dlc); > + if (!dai) > + return -EPROBE_DEFER; The deferred probe won't work at this stage for HD-audio codecs unlike many ASoC codec drivers. And moreover, the fixup action doesn't handle the error at all... Second, this way may lead to use-after-free if the ASoC stuff is unbound while the usage from HD-audio codec side. Also, the dependency mess is still there. Even if we allow the hard binding to ASoC core here, IS_ENABLED() wouldn't work properly. It must be IS_REACHABLE(). thanks, Takashi