Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3016031rdb; Tue, 6 Feb 2024 05:00:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3X++SkYgueCWdYNyUXZHdGwoWEMl05/WlnilAdIpl6KpKJ7wpJ3loeAFDJAbrb7bwS2V/ X-Received: by 2002:a19:f509:0:b0:511:5eec:9b9a with SMTP id j9-20020a19f509000000b005115eec9b9amr1118341lfb.52.1707224447992; Tue, 06 Feb 2024 05:00:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707224447; cv=pass; d=google.com; s=arc-20160816; b=fEOQ4gUMqlCk1T+hfkyZ+WccDx7WIDeesrEw0CzQmuaI+8rMpFcxsaa+t0PfEbgMIV OU/rGntDozP3AJo3arIrBnwexNjlKlf7W2DTsxHvrBUR9bhRtacF2jUgRBeO6XtDMZhO ltCjPLzoF20tzoULl52Lq91Kkip4ppKEN8XxgQI8gviI5Z5tLHZtqz8lIIA+NYURhEcT hRVFUQR7IgaYak22OtOGYr/Fro8vBkQYW4k0PEsCzFNI9ibTg5zV/iFKK/8MdLc18P+3 yhnAE7K+nzCYOU3EAnbUbxCCjTTcAB0AQo83KIKj9jQkVpbADeKJDGTe9uj47C69vE7n /OfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=rPhPVGYDJ3fdMIeQrhxnapM7DO5sG2kieq0UlwBxO6I=; fh=1OZn5RF5laZ1pY7bJzedVkGTslCdA+l2EaAz2cq9NH4=; b=kL7Mrq4WM0Hf2p7p4D5tAjuKhIQBxXfc6G5viLZnzuoBRxtcc9zO/xH2YSt+B4PtMQ bjbtY38dNmBTReBgWD+Hmn5MT5S9k9egwWD6Jq9oBkpvYFAjUMMqSZa8oeJp+XeEEvkk oQoQ0or/tQXYJO/1eImTAj34nJkhC783d5pVk8sJrN7huZrjMl/4u5tVgDV1bqOz99NB IcZ1FwHwg8OJ7H/lMkkDbfMVNgUBu0FTbRucPfOPeDdMar1InnUcEIqTYbNMznhAS4Uj oL6oytu6JtO17WoDEBaMZUJH3DXcXFXtCo92pe9j7BRXWI/GVY7PZ1XalZp9ZREGj1ZH s+Kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W0j0SuN+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W0j0SuN+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-54979-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54979-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCU7JJPLVpLPRNv0Wnn9X9n6hH7p2OyXHFYK8gCtD7qVF49eihT+n9z2xZy4h+6tKPMrcBJRrjTixGsSUt5mVrbQy6amxhePoCoOW5fj9A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a18-20020a17090680d200b00a37c57804ecsi1022350ejx.594.2024.02.06.05.00.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:00:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54979-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W0j0SuN+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W0j0SuN+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-54979-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54979-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8A4D71F265E8 for ; Tue, 6 Feb 2024 13:00:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D612F130E2B; Tue, 6 Feb 2024 13:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="W0j0SuN+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ANiJc1Kz"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="W0j0SuN+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ANiJc1Kz" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B7612EBD6; Tue, 6 Feb 2024 13:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224423; cv=none; b=N4McNfpgt2KrdZdGcp2j3q93JJkwgorKaVDBqtaPCW9CaMcDt0NkgeraTPyN8J3gSZ2a8iVdO0dgm03+l7f8z2ygNEUx3T5zBYwP26gTq9gJPTYfBpHjkPfNcgHXP5xyK58Sj0/ZXesMV0VbUZvfNw82wbYIHNy5ASjMXIMKhgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224423; c=relaxed/simple; bh=+aT0rKIS3UKpo4tm29e7syaTdpncuM29O5o+70E1SWo=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=a0xJSVoTdKX/EzcnqyufIEjGVULUz6RopMnGXQHBsh//ig9j3g+mhjO0HhHTEAhOIif4i+q/kyHrW8vftsZmKCHgBYyvNnkteca/iQjo0Ovj8WMObUTjxHslC3YkrasLExsjxfFI0yL/0mvpTLF7naWtzVEPixRw6gioZxecqt4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=W0j0SuN+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ANiJc1Kz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=W0j0SuN+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ANiJc1Kz; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 26B5121F97; Tue, 6 Feb 2024 13:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707224420; 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=rPhPVGYDJ3fdMIeQrhxnapM7DO5sG2kieq0UlwBxO6I=; b=W0j0SuN+f3pdCTZ/eqYSrkeUibin5cCK5VUQZRbbQeVgIA+GrcC0q0bxzYOH85qV+pF3h8 IyzuJDVmuYmw/NQQa8oeMAeSJq4nQ/eO7h2xUs2pbRczfdbWXnC1S1tCBa+/o0ZCXA7p1k pWtJ66CIO5nhWvmAEuF3xYlfB06bPdI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707224420; 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=rPhPVGYDJ3fdMIeQrhxnapM7DO5sG2kieq0UlwBxO6I=; b=ANiJc1Kzkh0E1o6XsSz0NVKALAxAysv6xSiEsoyTnl62fV/+eOoyuwoQx0WVkjwFFwsrc2 emMI+XJorrW4yzCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707224420; 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=rPhPVGYDJ3fdMIeQrhxnapM7DO5sG2kieq0UlwBxO6I=; b=W0j0SuN+f3pdCTZ/eqYSrkeUibin5cCK5VUQZRbbQeVgIA+GrcC0q0bxzYOH85qV+pF3h8 IyzuJDVmuYmw/NQQa8oeMAeSJq4nQ/eO7h2xUs2pbRczfdbWXnC1S1tCBa+/o0ZCXA7p1k pWtJ66CIO5nhWvmAEuF3xYlfB06bPdI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707224420; 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=rPhPVGYDJ3fdMIeQrhxnapM7DO5sG2kieq0UlwBxO6I=; b=ANiJc1Kzkh0E1o6XsSz0NVKALAxAysv6xSiEsoyTnl62fV/+eOoyuwoQx0WVkjwFFwsrc2 emMI+XJorrW4yzCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D30FD132DD; Tue, 6 Feb 2024 13:00:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id OHcAM2MtwmXaNAAAD6G6ig (envelope-from ); Tue, 06 Feb 2024 13:00:19 +0000 Date: Tue, 06 Feb 2024 14:00:19 +0100 Message-ID: <87zfwdvjbw.wl-tiwai@suse.de> From: Takashi Iwai To: Amadeusz =?ISO-8859-2?Q?S=B3awi=F1ski?= Cc: Wesley Cheng , srinivas.kandagatla@linaro.org, mathias.nyman@intel.com, perex@perex.cz, conor+dt@kernel.org, corbet@lwn.net, lgirdwood@gmail.com, andersson@kernel.org, krzysztof.kozlowski+dt@linaro.org, gregkh@linuxfoundation.org, Thinh.Nguyen@synopsys.com, broonie@kernel.org, bgoswami@quicinc.com, tiwai@suse.com, robh+dt@kernel.org, konrad.dybcio@linaro.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v13 50/53] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices In-Reply-To: References: <20240203023645.31105-1-quic_wcheng@quicinc.com> <20240203023645.31105-51-quic_wcheng@quicinc.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: * X-Spam-Score: 1.20 X-Spamd-Result: default: False [1.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-0.00)[32.59%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[dt]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; R_RATELIMIT(0.00)[to_ip_from(RLjs3ec4aura4kmsd6wxjjm4hg)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWELVE(0.00)[24]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[quicinc.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[quicinc.com,linaro.org,intel.com,perex.cz,kernel.org,lwn.net,gmail.com,linuxfoundation.org,synopsys.com,suse.com,vger.kernel.org,alsa-project.org]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Flag: NO On Mon, 05 Feb 2024 10:01:03 +0100, Amadeusz S?awi?ski wrote: > > On 2/3/2024 3:36 AM, Wesley Cheng wrote: > > In case of notifying SND platform drivers of connection events, some of > > these use cases, such as offloading, require an ASoC USB backend device to > > be initialized before the events can be handled. If the USB backend device > > has not yet been probed, this leads to missing initial USB audio device > > connection events. > > > > Expose an API that traverses the usb_chip array for connected devices, and > > to call the respective connection callback registered to the SND platform > > driver. > > > > Signed-off-by: Wesley Cheng > > --- > > sound/usb/card.c | 19 +++++++++++++++++++ > > sound/usb/card.h | 2 ++ > > sound/usb/qcom/qc_audio_offload.c | 2 ++ > > 3 files changed, 23 insertions(+) > > > > diff --git a/sound/usb/card.c b/sound/usb/card.c > > index 11b827b7a2a5..995b2df676ab 100644 > > --- a/sound/usb/card.c > > +++ b/sound/usb/card.c > > @@ -202,6 +202,25 @@ struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > > } > > EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); > > +/* > > + * in case the platform driver was not ready at the time of USB SND > > + * device connect, expose an API to discover all connected USB devices > > + * so it can populate any dependent resources/structures. > > + */ > > +void snd_usb_rediscover_devices(void) > > +{ > > + int i; > > + > > + mutex_lock(®ister_mutex); > > + for (i = 0; i < SNDRV_CARDS; i++) { > > + if (usb_chip[i]) > > + if (platform_ops && platform_ops->connect_cb) > > + platform_ops->connect_cb(usb_chip[i]); > > if inside if, it can just be && or maybe move callback check before > mutex lock and just return early if it is not present? The callback check must be inside mutex; otherwise you'll get a race about the platform_ops registration. thanks, Takashi