Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2679170rdb; Mon, 5 Feb 2024 14:16:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkHxviSNaIas3fJQ1eUZ45qlE/9GONyg36omizvVfqgJR5DX5CF715NtsC/QWt9/9sEQiQ X-Received: by 2002:a05:651c:695:b0:2d0:b025:f1ee with SMTP id x21-20020a05651c069500b002d0b025f1eemr252805ljb.21.1707171373705; Mon, 05 Feb 2024 14:16:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707171373; cv=pass; d=google.com; s=arc-20160816; b=S6u/Zd2oIFunnNmMc3wJcsckzUfcyB6+JKxx4Mk/5qZQAqg7rRhYWyZQYAClE6s8i3 4PsK6RjjOG7Q5V3lAIMrqJ6fzUdT+4S6fFbZwstXVHxYatLVlEX15ncTAMXYk8c7ZL1A Td/zlcH8dWk09FL9S/lrq3/4TedMtwyKz5pYvEaXif74pJTr9BSSeuh4Jms2u+pSbpA/ 5e2gIv2cWkGiczd1zaBZffBwIBlf44Zx9C4ZiPyRO1VKlUKUcrMwCAH5b/UA292dyTNq dAJ+KRUN3bJGiIv91FZnFYS6oniOl0jMY7du2ZK/CX0dzgYz4JlAdjiXl8RLBxhTxV4p g7gg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=zUMiOKcNb14lRNC0PHgjnPf539O7z/gNiVeRfyHYiCg=; fh=NRqAcNcEhYkHRrfH69INSOoL2hc/WBbTMTI7EHQzlOA=; b=kwhjt52v83rD16bYGZafhxWB7Ky4y5aPh0/PRpcRxjA/rFk+t7pq6ZJeRCC5BxSKhW 4buXe60ZYYH+LR+wXbAVS1g81PWLuu7xy8wDdyPBjWZvuod5l+ps2Rt9tOjmeuuYLOAP PzGOtLpvdt3S2F65Koy3IPF/zzfv9WygpUbFJy5G2AQ22bM4zds+1tHDhJ+asPQzW/DU lOkpmQoS2Aci0n8tfzukTSXra92sbXKZB7/pHjy8r+czt3KRevS07+TN9F8WZMGBNRhH oLk8GssqS3laEqH5TAOR75Jgsj5G+ghvVl8YXXbnY1iRa2LUgznlKLtUC+aBzZARKfVQ n9vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iaXU7vLr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-53978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUlH4RzlVDa2QoG0vBWZYaCd+0ojKxAqMf18RD7AYQtEkvlg+S4nFa+LoY3oG6pgTrcp9gOfk7UR/phDEz5dOvUhxKewvBRT8zbDDSryA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b25-20020aa7cd19000000b0056023591f8dsi347946edw.318.2024.02.05.14.16.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 14:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53978-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=@quicinc.com header.s=qcppdkim1 header.b=iaXU7vLr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-53978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 AF4491F2D9EF for ; Mon, 5 Feb 2024 22:09:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D47556B9C; Mon, 5 Feb 2024 21:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="iaXU7vLr" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9885756B60; Mon, 5 Feb 2024 21:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707168495; cv=none; b=Szn3ZqsKh/2BYep+KagLjtioNXIuM1lR62j3GjXy7kUQYPHhf3LiwA+tagMyh86s2SHUY7tw2rv5Yscsjpc9pSU8llU4yb/OVF/YeNmcNJp5GJ1a0KOQvDB7S070y1UKmEKQkIbiFiJnec/37o7j1812L5EpNUqVgV08ozCDoJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707168495; c=relaxed/simple; bh=5lrum/AjuJwqk20RkwGk9tqExlYNgPl6td00iapqChA=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=BE+fhy6CXg7b2qGcyc0C5cVUpLo3OmwXjcgJekA1I+ebCh2CsnwC1MX2UPErE+1goqizmH5G9+RPEQmEC7rxPpPDQYMeu8bQDeeUP29URQLNBGG183QwUIeOZ9m5ouab8j8rokWV6IFPCOAXvQDx9XZGClTqsyw2pkwVxvWvPuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=iaXU7vLr; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 415LASOj014430; Mon, 5 Feb 2024 21:27:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=zUMiOKcNb14lRNC0PHgjnPf539O7z/gNiVeRfyHYiCg=; b=ia XU7vLrUjhuLqT39+iCG6Wem2p9KvnCKurTv96O1oN1ZPATRdOwCtKTWtyauoxOz+ y1pASrsqIrWMpXq+GiYzsF/S7iRE1XTX1JOLv9Zj/8UeY7NyqthiOMXSKj6ZLjUg dIDxFBsTyRgcDR/fHFyKo+zDwKcI6pAav/6wFjD2sTZqSovIbrSI4pSlMjSuJRMW vJhkZKxQwtnmfBSGduZux9uMHXSthdWo8btz8/60el/vHuYE/5M24vSlGmU7AC0X KW9vJaAtNARfIkxC2HiE1pnHIMDlp0NRIQrbOq10qx1qc0Yg2Jr4IskqRo3YMEHd Cl/BZWSpmj9jfgzZYTYg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w2t9wswnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 21:27:54 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 415LRsX1010093 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 5 Feb 2024 21:27:54 GMT Received: from [10.110.7.251] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 5 Feb 2024 13:27:52 -0800 Message-ID: <4d03b2cf-3b97-a066-15a5-245228813253@quicinc.com> Date: Mon, 5 Feb 2024 13:27:52 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v13 50/53] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Content-Language: en-US To: =?UTF-8?Q?Amadeusz_S=c5=82awi=c5=84ski?= , , , , , , , , , , , , , , , CC: , , , , , , References: <20240203023645.31105-1-quic_wcheng@quicinc.com> <20240203023645.31105-51-quic_wcheng@quicinc.com> From: Wesley Cheng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Fhx4-0QTJ2jvgXTCbibMBpUNgQgwTlk5 X-Proofpoint-ORIG-GUID: Fhx4-0QTJ2jvgXTCbibMBpUNgQgwTlk5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_15,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402050161 Hi Amadeusz, On 2/5/2024 1:01 AM, 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? > Thanks for pointing that out. Makes sense, and will update it. Thanks Wesley Cheng