Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2596705lqt; Mon, 22 Apr 2024 16:03:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXldx+OlviRuyqsI3PlzauNRKhOr+rKokuC5u78cIoWHcuaIGenjbEu0dAWkwHccarxFwaqsN5qwKgk9tBLR8h0u/Q98Dgs5pBHWkyfw== X-Google-Smtp-Source: AGHT+IGG5gyz1LiFhXNVBcj2VtE8/LUhV/CGlW1oaG6bLs5h1NPd2Juf6nzREJIeupaRg/xVxceU X-Received: by 2002:a17:90b:8cf:b0:2ab:5681:3a7c with SMTP id ds15-20020a17090b08cf00b002ab56813a7cmr8311047pjb.45.1713826985433; Mon, 22 Apr 2024 16:03:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713826985; cv=pass; d=google.com; s=arc-20160816; b=CmYBG+BO62GlXBPZL8PZprOCy9zC0eSYOluCo5EhLi2xS7TPTPrbupeqiNziG6H01v hVRTWhwbAXMfwEBTwMaiR9PIOWhgmQ5fZGKvHpngHtcNoKpu3A/gbgFoXj8ztOfHOPbK G8EKIqW6X2ys7oAztzStU82bJXQAb0RqQyYk3B0SCefbAZFZWXg96Gcf4TDVa1I7VPKz krJqPCGqzZwWKxgikVcTQ9G3mWF3bPcnxAPo9wW04PV7HKfNkY0O+pnKNn/A1GIaECxd elO87M/7dLGY2d7KUrM9IE2WYKbzGJZb2UrGHD4lz/qbn2l7Yua+qR9lI6FPWtgG9YEO Wylw== 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=aW4dHmimDCEW6coInPSERkk1vXqMQwpkZh+z7iS27NNSVs7/NNEihRXgegmts5R0A+ Q3+EuOIewOkHa1jJ8Rsim/L4N/3b1u3R1ZD38YRyRFiMSuJgTX6XRFYDzyCN9Pa6k3S5 3++0InWfIH+g6fUbe8UUIqaceu4KrSp/qLjpwZsw8okxwp2IsuwcHNq6qN6V1O5V2+e/ LliJRhjHGT1Hhklv+Et0XI5O/A8UTkUlfVDICMC+BnKXPJxwGc7KQW54bfBYUAlx3Q/X 8DOdIUH/qWKVWyoBBKFl9wYZHr39o2GPBDUFcf+uQ5X68XdJHxEuT4bCjlDq0RgxeMoN 2S1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XYDjtwZF; 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-154148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154148-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. [139.178.88.99]) by mx.google.com with ESMTPS id nh15-20020a17090b364f00b002a63fd3c73csi8544688pjb.15.2024.04.22.16.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 16:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XYDjtwZF; 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-154148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154148-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 C671E2849F3 for ; Mon, 22 Apr 2024 22:58:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A76F415E210; Mon, 22 Apr 2024 22:50:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="XYDjtwZF" 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 5D03A155303; Mon, 22 Apr 2024 22:50:06 +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=1713826210; cv=none; b=G2gwZyZmlfTV4nLAIv6Q/z+Hsv2PjNBQneXVkHP3EWLfBhk5NCnc+IN0j70s2wHSJGn4/N2MEhF5+H5HMT+C7yQArzN61SAfjfKhhSaWbho72TMf9iqH6XFuo52QmhA0ZfrXuoLY3UoHVCF9N5LR092KC9b1ElAE+WTGOqI6PpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713826210; c=relaxed/simple; bh=irvpJAWyfYNQcdfNO9eBX7aEjGvO1TfGb3rNzRGKzbI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mCCMc6amroGdOKOAj/DE5KPXed+TajrnjtEwAnCFzXfB/gclb3i7AFz2LVe8clF5Q4F9s0rDedZ4CBA7Bmllr8ryNbQp74U/WuVlzdgHLZWlIk9bfmXqIy/RtdnnSYutIACmNduVPbAumYhLyp9RfGf2cc23Xe/73t7fxb515eM= 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=XYDjtwZF; 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.18.1.2/8.18.1.2) with ESMTP id 43M9ObuP025808; Mon, 22 Apr 2024 22:49:42 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=XYDjtwZF/A/hRd3dK1GIUU0sVA2nw79xkDC7 t7MZE9pbLAnsgklX683IAcPWQQH5JDRg4QmO9kbOHfSlH4po5Vzul1OhI5P+NkMr SCifKZZskBCFnetmMCUtvMerJh3urHXKo66hx218h+V7Yca2IMda+In/sUEV/jpG fVXZitnwxYWBOkpdFfA8BBP8oUBRCEsTjFMZA7IQrXR1Pdzj9m1qcMUQTY6kKXXM uXjlCBYCU5rOsMr8bIZrQrAFUfyjrHMGWicnKgcaioXXLARMfSpOl8MTP0ga4Um7 a1HYXN0mFAD4oTS+Q9BBpthTh2hC9awHxrP6Slge0LH30LXRvw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xnn82hskq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 22:49:40 +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 43MMnReF012114 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 22:49:27 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; Mon, 22 Apr 2024 15:49:26 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v19 39/41] ASoC: usb: Rediscover USB SND devices on USB port add Date: Mon, 22 Apr 2024 15:49:04 -0700 Message-ID: <20240422224906.15868-40-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240422224906.15868-1-quic_wcheng@quicinc.com> References: <20240422224906.15868-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: nalasex01b.na.qualcomm.com (10.47.209.197) 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: 6OwafIbVKBuFUmQi0uzRITS3AATy0tw6 X-Proofpoint-ORIG-GUID: 6OwafIbVKBuFUmQi0uzRITS3AATy0tw6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-22_16,2024-04-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404220096 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);