Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1412282lqd; Thu, 25 Apr 2024 15:06:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdLSuyOsbd+ZMD3Q/LA5/zHnMkur78Y0J2QEfjjSPC1ngl2Kt520usyg6rujMp6QO5WmW5d5QTNC6YpaeP5b6ZshJ/hBBnLXhYCt/urA== X-Google-Smtp-Source: AGHT+IGWQ1e25ZBgLJNfWSZ6iBAhg7uy+N/UCqAP1AGITpqYMBINbhCKBiEzm3xLEtfsLHF2l0XD X-Received: by 2002:a05:6a00:98e:b0:6ee:1d03:77b9 with SMTP id u14-20020a056a00098e00b006ee1d0377b9mr1308528pfg.31.1714082767681; Thu, 25 Apr 2024 15:06:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714082767; cv=pass; d=google.com; s=arc-20160816; b=JgB6VPCoiz95L/2hXUA7R94Eosbh6+kEfse7Ixh4qHbrny6HAyLB5DlU8FlT6pEqYx Q+YR6Qk72wSzIjGuMN/nddhTAHdDiyZy9/wpP8Y3Icq1cYqECNw/DkwDCVULz+9lGtmL q5s3rl76kz9ChXkg/X2hMdVqR+g7JmcVhHJb2i5OjnOn17nqBKmvtDIZ/MvFI0scDS08 c2R5X2po+QORMuAi6B4OLI55t3I0WIxRHqNqoFzd0v5hkxpOOF3r9v1m+FdtfNv32DNT upK/GZvBJNnU5Y2x9rBxDXdDhcmHI37oJUbDwzgEHz0rkDUGF9ajuBEjs1yx7yZInuiQ /vpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gnJwXYlppG20lIVQdlnZ4yd3yQRuw/0NNcN3kah4t3c=; fh=usWEz1eJjYCle08WABmDyuqCrJGq9m48/LVlmybnzRs=; b=JZjvGzlm0ItUYiV5kSao0dSH77jbH0vTFSLKEt5OA3qymWugMHH71oTLlfF9Yi3eSC k7EYuiIIG6pd0ucw9z99D79BDu01xiI4qctWCHj/4q/YGuSSsUtuaR6qMuWuovWkp5Tb /yEx1kPftGr/Eu90ovj0xQkgra2fdaApzzPBnRr3t/2whcjJitS7xHztVZzsCvlzOusz YYDy+27ZqTWzGAtTLpR7Z6jSsBkkskpmMHstgGzOTM2RkiT5xq2S3RICO+cFFelSh1yU AUInSxltWCZimRPi2W70XBFy15/2ujuezZQrKgMFj+pJYcolgsxTULMWfZWXAmGpyTbG y2og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=m6olhgZZ; 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-159245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c6-20020a631c46000000b0060764a6a26fsi3095326pgm.532.2024.04.25.15.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=m6olhgZZ; 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-159245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159245-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2464D287F48 for ; Thu, 25 Apr 2024 21:53:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5FA8158A22; Thu, 25 Apr 2024 21:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="m6olhgZZ" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 4EB19156246; Thu, 25 Apr 2024 21:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081926; cv=none; b=a70z7+s0OEITlTg6gWGCynunL29YXRnbRvBPJoVRM90X1+LXITqTLrfnvlsizGaKU9naw2Nne5ePRtt23tEyc/sQPJeGHQP7BrV9XevLMm86tDJYpZXMOCsjrWCt4o1GaDHEFHgVSbT1vkOrhxaFzMiC+QVMhnr8CripsuL7qpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081926; c=relaxed/simple; bh=irvpJAWyfYNQcdfNO9eBX7aEjGvO1TfGb3rNzRGKzbI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=COUXmVpRbVb15wqdZTL9Zxg2BBOmsSuHnDwWQtwPQGi/NPUZLa4s1LSUna6/EksVJyipkuUDo9V7GOuXF0wWCgfHWrma2V/aaCnR1veQoDgsoD1BYr2F0y6G+sOw0wKF8tKAxBxL1SdQFmSaGVsh6nAHJ4I2XwGlPqNikiAhEj8= 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=m6olhgZZ; arc=none smtp.client-ip=205.220.180.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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43PK79ws031005; Thu, 25 Apr 2024 21:51:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=gnJwXYlppG20lIVQdlnZ 4yd3yQRuw/0NNcN3kah4t3c=; b=m6olhgZZRokvJoFDFdPvCwy4vJotAeYbHX2W mBdnPIG/fhpEGzKq5P98l+Q6Aq4aptzbxuOXTtiFBp08evZd8DImXGPXPOBWo4g6 IlRfzL3muyib+RJm1ejhX74IPFZU7vUB24l6c7C/q9f2b1mna5ckG4YptQbNWJhE /3lpSIv9kg6wHW+EFSEAbnjMbajKGOpqqV1i5fM5UvrK3yXNN8BuaqysxVF6LB5I qVi5p+sn39qxGSzpbbAm1cen9YEvDt4nJc2K/1kMeobh0UjMcRrkGLToByifsKFo OpLOS5+ASKkB6qhkoETKt2hgYlyYOPjvnKSVRRELZ3yBkjJR8A== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xqenkks46-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:48 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43PLplxY008059 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:47 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) 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.1544.9; Thu, 25 Apr 2024 14:51:47 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v20 39/41] ASoC: usb: Rediscover USB SND devices on USB port add Date: Thu, 25 Apr 2024 14:51:23 -0700 Message-ID: <20240425215125.29761-40-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240425215125.29761-1-quic_wcheng@quicinc.com> References: <20240425215125.29761-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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-ORIG-GUID: x3gmPA-Df1Pz-EJnMbz9P5uNXkfVg-y9 X-Proofpoint-GUID: x3gmPA-Df1Pz-EJnMbz9P5uNXkfVg-y9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-25_21,2024-04-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404250159 In case the USB backend device has not been initialized/probed, USB SND device connections can still occur. When the USB backend is eventually made available, previous USB SND device connections are not communicated to the USB backend. Call snd_usb_rediscover_devices() to generate the connect callbacks for all USB SND devices connected. This will allow for the USB backend to be updated with the current set of devices available. The chip array entries are all populated and removed while under the register_mutex, so going over potential race conditions: Thread#1: q6usb_component_probe() --> snd_soc_usb_add_port() --> snd_usb_rediscover_devices() --> mutex_lock(register_mutex) Thread#2 --> usb_audio_disconnect() --> mutex_lock(register_mutex) So either thread#1 or thread#2 will complete first. If Thread#1 completes before thread#2: SOC USB will notify DPCM backend of the device connection. Shortly after, once thread#2 runs, we will get a disconnect event for the connected device. Thread#2 completes before thread#1: Then during snd_usb_rediscover_devices() it won't notify of any connection for that particular chip index. Signed-off-by: Wesley Cheng --- sound/soc/soc-usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c index 53c4e399909e..821caff2061d 100644 --- a/sound/soc/soc-usb.c +++ b/sound/soc/soc-usb.c @@ -554,6 +554,8 @@ int snd_soc_usb_add_port(struct snd_soc_usb *usb) list_add_tail(&usb->list, &usb_ctx_list); mutex_unlock(&ctx_mutex); + snd_usb_rediscover_devices(); + return 0; } EXPORT_SYMBOL_GPL(snd_soc_usb_add_port);