Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1568293pxb; Tue, 8 Feb 2022 22:35:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzymrx05/pZ8TccumFl+k6S8bAEsFFUG47GhoeQjhBcqvfLHF/WMUQwub6XhmW4MIFnQ+SJ X-Received: by 2002:a17:903:41d0:: with SMTP id u16mr810617ple.144.1644388508782; Tue, 08 Feb 2022 22:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644388508; cv=none; d=google.com; s=arc-20160816; b=P07TWeJfgTWpyRcngTz3QU+Cln+XmmhvpTSH3+isVTZ2AgMgCUCkU22LEb4hjIZBQx 6UMcQr+dBIdcAU416kJdIWA867cYQgHgTUke9AtT1idO4Rm5wHSZXsDUhzRgF1prC0KZ ijDNX7BbQ2V+bFBImBsTextzaQB3UBBC+h3sT1Ooe/yStPjfMlf6S4PQF0sCXi7n9Mqt 6njlhPECp0BN0Py6pR0/sisaNEaBnAyj136EfAKaH/pfSExc6eRbaItoyhvV7Ag9hMus ANwdgLyNpm/WOeej9MDxwwwqFfDaeLzUsUE15Z1pP4PNaaH9zLDX5bSDNl00XeStKubA j59Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:user-agent:message-id:subject:cc:to:from:date :dkim-signature; bh=mS3C+Wo/VrSubSEHXbpL025cTzdbcGtIyC7RL2QVj1k=; b=JH5rkJokPvAqLI4cFht37yTfbgFQtQcZF//zWSsKlZNM4YC/aMBY8NfeIwkLNkvUqS HZWWtf+XG4/hP5CZMnuzEWmWoynBIN+Feqrtb+kI1peXZwpCGGRfPqrJRNCFwYQ7R6Dv b6L5sclrdA0mtG7qI1OATJvNR9gCqhJMuNMER9DXlICuVYuLDaPN+FXuf0bg2Qd37YGg STU4Uwq6i16WQTLuq+pEO8uahxnT2pSWwi8u8tqsSg7OJGGhBCbTYaXeZr4luvhsKTF4 lrBxdlIbrhrG3Y/FzoUtGXnK+edZJhJLlTDS/BcGAu0i/Xy3GjdZeWiePaGx2khHeF8P V58g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dxvNMVA9; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si17147077pgc.786.2022.02.08.22.34.56; Tue, 08 Feb 2022 22:35:08 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=dxvNMVA9; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350333AbiBHWXC (ORCPT + 99 others); Tue, 8 Feb 2022 17:23:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386227AbiBHTqm (ORCPT ); Tue, 8 Feb 2022 14:46:42 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C14C0613CB for ; Tue, 8 Feb 2022 11:46:40 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id k13so35328897lfg.9 for ; Tue, 08 Feb 2022 11:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:user-agent:references :mime-version:content-disposition:in-reply-to; bh=mS3C+Wo/VrSubSEHXbpL025cTzdbcGtIyC7RL2QVj1k=; b=dxvNMVA9VhI2Ic4/NqHu66Bawb1X5QOhCGBr7npMY8t0pMy5egEwQ0zGOws3/p5UVU obo6BmPk66JYaDw/VWbvHOvxEkyB6IG4uQPA681CCErEaT175YwGVuJ8hRr2LNGEdwJv hwvryfKvyGmCbsbR2brFkXCc0SXJJQiKzHmb9mtpqzIYoPWXLhPfAyq3Ep0QpJXxQ1PX eV3kPJ1Yhmj1kkjoI/XdB8AToWTvdeLOwvfrez2kcWfcNbEzbnK2sqKBaZHZiWtuYIix 9Sq4+XseteOthTLKIlejiaY2MjChGKOPPyznlI8H4jXDySKECV5FKj6mblYepfNKbH3B LzXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :references:mime-version:content-disposition:in-reply-to; bh=mS3C+Wo/VrSubSEHXbpL025cTzdbcGtIyC7RL2QVj1k=; b=FX1AEr+Qd8SenVmv3/4QHh7qlXXMpGCIzf0hcvQkC9wSrddtk3YLwJhYiIFROUuRmf lutCF9k569bp2vye0YovMllt5iokI3AFCogoSbKRRSezv0FKw1lHBe8wGSZf2fg9h7oX qGW35qHwvDi30VV8pQ1lQDZWiZmiUt7k6eYM3PeXKkZroHDDg4OU0mpeq1mIXq7iyMQT jyFFayu2jYF8xpAyfoIHB5OblW5W1+YkIrSeMFJLeiKl98pOJPusR6y0jv7xemYR+cdh SOOnDuwgccZMulnDfUUChkWXcxFwaCDa7R0LjVroDU026Vw6rYOp67qrjV9h9alnrAeD /9Dg== X-Gm-Message-State: AOAM533lJ0gdFb0IXUIT5ppiNr0HlxA9Xk0Vly09uOWNWN1xGyXn+q5W WCIvRIcKOSMTNKMYFPVnX+o= X-Received: by 2002:ac2:4acf:: with SMTP id m15mr4040567lfp.580.1644349599141; Tue, 08 Feb 2022 11:46:39 -0800 (PST) Received: from localhost.localdomain (broadband-95-84-228-163.ip.moscow.rt.ru. [95.84.228.163]) by smtp.gmail.com with ESMTPSA id l12sm381178lfg.32.2022.02.08.11.46.37 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 08 Feb 2022 11:46:38 -0800 (PST) Date: Tue, 8 Feb 2022 22:52:37 +0300 From: Alexander Sergeyev To: Takashi Iwai Cc: Jeremy Szu , tiwai@suse.com, "moderated list:SOUND" , Kailang Yang , open list , Huacai Chen , Jian-Hong Pan , Hui Wang , PeiSen Hou Subject: Re: [PATCH 1/4] ALSA: hda/realtek: fix mute/micmute LEDs for HP 855 G8 Message-ID: <20220208195237.3tnsslzaj2pmzr25@localhost.localdomain> User-Agent: mtt References: <20220115152215.kprws5nja2i43qax@localhost.localdomain> <20220119093249.eaxem33bjqjxcher@localhost.localdomain> <20220122190522.ycaygrqcen7d3hj2@localhost.localdomain> <20220122205637.7gzurdu7xl4sthxw@localhost.localdomain> <20220129144704.xlmeylllvy3b3fum@localhost.localdomain> <20220130111020.44gzrm5ckrakjta2@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 08, 2022 at 03:36:08PM +0100, Takashi Iwai wrote: > ... and here is a fix patch for allowing more rebinds. > Give it a try. It works, no problems with large numbers of rebinds. > -- 8< -- > From: Takashi Iwai > Subject: [PATCH] ALSA: hda: Fix driver index handling at re-binding > > HD-audio driver handles the multiple instances and keeps the static > index that is incremented at each probe. This becomes a problem when > user tries to re-bind the device via sysfs multiple times; as the > device index isn't cleared unlike rmmod case, it points to the next > element at re-binding, and eventually later you can't probe any more > when it reaches to SNDRV_CARDS_MAX (usually 32). > > This patch is an attempt to improve the handling at rebinding. > Instead of a static device index, now we keep a bitmap and assigns to > the first zero bit position. At the driver remove, in return, the > bitmap slot is cleared again, so that it'll be available for the next > probe. > > Reported-by: Alexander Sergeyev > Signed-off-by: Takashi Iwai > --- > sound/pci/hda/hda_intel.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c > index 4b0338c4c543..a2922233e85f 100644 > --- a/sound/pci/hda/hda_intel.c > +++ b/sound/pci/hda/hda_intel.c > @@ -2064,14 +2064,16 @@ static const struct hda_controller_ops pci_hda_ops = { > .position_check = azx_position_check, > }; > > +static DECLARE_BITMAP(probed_devs, SNDRV_CARDS); > + > static int azx_probe(struct pci_dev *pci, > const struct pci_device_id *pci_id) > { > - static int dev; > struct snd_card *card; > struct hda_intel *hda; > struct azx *chip; > bool schedule_probe; > + int dev; > int err; > > if (pci_match_id(driver_denylist, pci)) { > @@ -2079,10 +2081,11 @@ static int azx_probe(struct pci_dev *pci, > return -ENODEV; > } > > + dev = find_first_zero_bit(probed_devs, SNDRV_CARDS); > if (dev >= SNDRV_CARDS) > return -ENODEV; > if (!enable[dev]) { > - dev++; > + set_bit(dev, probed_devs); > return -ENOENT; > } > > @@ -2149,7 +2152,7 @@ static int azx_probe(struct pci_dev *pci, > if (schedule_probe) > schedule_delayed_work(&hda->probe_work, 0); > > - dev++; > + set_bit(dev, probed_devs); > if (chip->disabled) > complete_all(&hda->probe_wait); > return 0; > @@ -2372,6 +2375,7 @@ static void azx_remove(struct pci_dev *pci) > cancel_delayed_work_sync(&hda->probe_work); > device_lock(&pci->dev); > > + clear_bit(chip->dev_index, probed_devs); > pci_set_drvdata(pci, NULL); > snd_card_free(card); > } > -- > 2.34.1 >