Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp40969rdh; Wed, 25 Oct 2023 15:32:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA9vsoU8Y6ka7te91mVtVdLGs+3G6Pa7aglfOX9q5hIYCQEprCsDmZtvfjr1EWnMSqlrve X-Received: by 2002:a05:6902:1509:b0:d32:f2e7:7786 with SMTP id q9-20020a056902150900b00d32f2e77786mr18975085ybu.56.1698273156029; Wed, 25 Oct 2023 15:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698273156; cv=none; d=google.com; s=arc-20160816; b=H9+tjWjQzyHX3v8d1ISy0dwcPgydxBMVRkI5pwJXZYNBx6CLe9Un4Bq1D0ruo4Juzs H6iD60pg05Nf98le8YCs80rUJZufpSpQP1ZyeSEBAPfJkHueXGebfysr6wV36qzQJg55 s0ToPSBYSPjLD2+YpFDO9IwMmG2cwULCP/O9acaosIHjLAkUFw7oz2YgoiUw5x+lgtqz 6Vhnsskg5PsAeYVMv46PQXYObaxHJqt/oOjlDZvcjjRh5/k6WfH1EGSSK/fWZRkaZWIG kTv7or0wQiPI14Iz24JoKbU7PXvy0V8uRQVD1BHc+dCvaPOFG7e+C8JwHdvFCNtK6OC3 E7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0bQFa/OqIcYnNhxbQluyp0FpYS66aD/rqg1j1yF4XKw=; fh=9+IEscr4WmNbE41gibPc+AZ0nx0+/tccCXbA5gmgnS8=; b=Brvp4BaGlgrGUorIzXDP+XIpsPermX24orKtTRANusdV+XJ9gXY3bwJ91Gj+O2BjPE 4gd9c6j3p7d+d/LhhHgi+1OiWQKkY/8pWUU4XuNLO+Oann+ONDVKWa9bSU/x5aF2ZIwv Rip8Mezw/BbZ4JmfXOcztq8FhqKk5GKrDyBxT8sJMrplbk5HRVIr5cuWW/Bqw4M3dfR3 fG67v6qEJaESZwbJPoHyaYXw+IWUzXEKUKs7A/xZs5YmihRENo5ulvaCOCscBV6pBhpq g6H5TmW6+3FgHtsH8ZFRjjsd+0/9mOZZnlkdx23qDhCNipUPt8rE/2YnhEGTaTx8Aaqj 2Khg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ijeFRrAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w83-20020a25df56000000b00d801af7c4a8si13651852ybg.385.2023.10.25.15.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 15:32:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ijeFRrAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 09EB98184530; Wed, 25 Oct 2023 15:32:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbjJYWcY (ORCPT + 99 others); Wed, 25 Oct 2023 18:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjJYWcW (ORCPT ); Wed, 25 Oct 2023 18:32:22 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99C1890; Wed, 25 Oct 2023 15:32:20 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39PMRckh018217; Wed, 25 Oct 2023 22:31:56 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=0bQFa/OqIcYnNhxbQluyp0FpYS66aD/rqg1j1yF4XKw=; b=ijeFRrAL554HbPROVtgWMr342xAc9G3Hb0rAtbzazIeiS1eg43uNeJ5NNvthovYmO1bC PbwBEMKg8RwEfBd4KRmSynJ6HsadqSD0aP6JRwG41tKmTEPkLWN07zpX90f5OC/1iVc8 AuQjJZYAYakQJru8MAWTjJPPSKMr+zN+QfpdTNMneESElujSicMhcJTYobkPp1qKPymj VQm+TYJ3AAzEOiKQXMJPDw6HXPHSoOiOSXts2wv4QLyq950/WmSY89YWpssdS2GFWX/A bxyLjkgkjbbyWhdodpk4n7LuczyQGKSPtkCtE7tp+/lGrmcWN8ctgfQLXgB8WDj20mRx eA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3txwjphvea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Oct 2023 22:31:55 +0000 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 39PMVsJe024992 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Oct 2023 22:31:54 GMT Received: from [10.71.114.19] (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.39; Wed, 25 Oct 2023 15:31:53 -0700 Message-ID: Date: Wed, 25 Oct 2023 15:31:52 -0700 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 v9 34/34] ASoC: usb: Rediscover USB SND devices on USB port add Content-Language: en-US To: Pierre-Louis Bossart , , , , , , , , , , , , , , , CC: , , , , References: <20231017200109.11407-1-quic_wcheng@quicinc.com> <20231017200109.11407-35-quic_wcheng@quicinc.com> <6409c486-7393-4352-489c-ecd488597c4c@quicinc.com> From: Wesley Cheng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: 14nEvn4zNDoYq68xWCflDzpsII9GKJ3J X-Proofpoint-GUID: 14nEvn4zNDoYq68xWCflDzpsII9GKJ3J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-25_12,2023-10-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 suspectscore=0 impostorscore=0 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310250193 X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 25 Oct 2023 15:32:33 -0700 (PDT) Hi Pierre, On 10/24/2023 6:35 AM, Pierre-Louis Bossart wrote: > > > On 10/23/23 16:54, Wesley Cheng wrote: >> Hi Pierre, >> >> On 10/17/2023 4:11 PM, Pierre-Louis Bossart wrote: >>> >>> >>> On 10/17/23 15:01, Wesley Cheng wrote: >>>> 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. >>> Looks like you are assuming the regular USB audio stuff is probed first? >>> >>> What if it's not the case? Have you tested with a manual 'blacklist' and >>> "modprobe" sequence long after all the DSP stuff is initialized? >>> >>> It really reminds me of audio+display issues, and the same opens apply >>> IMHO. >> >> Not necessarily...if the USB audio driver is not probed, then that is >> the same scenario as when there is no USB audio capable device plugged >> in, while the offload path is waiting for the connect event. I think >> this is the standard scenario. >> >> In the situation where the platform sound card hasn't probed yet and USB >> audio devices are being identified, then that is basically the scenario >> that would be more of an issue, since its USB SND that notifies of the >> connection state (at the time of connect/disconnect). > > Not following if this scenario is covered? > Yes, this is covered. For example, if there are already devices connected, but the platform sound card is still unbound. Then this rediscover API will be called to traverse through the list of connected USB sound devices, so that the USB DPCM dai can know about their existence when it is probed. >> I've tried with building these drivers as modules and probing them at >> different times/sequences, and I haven't seen an issue so far. > > The scenario I have in mind is this: > > the platform driver is on the deny list, the USB driver detects a > device. When the platform driver probes at a later time (with a manual > modprobe to make delays really long), how would the notification be handled? > So that is essentially the same scenario as when there is no USB device connected, ie no USB class driver is bounded to anything. Since the notifications are all handled within USB SND (USB class driver) then if the module isn't loaded yet, no notification is sent to the DPCM USB backend. Once you say...modprobe the USB SND driver, then the USB interface probe occurs, and that would issue the connect callback from the USB SND probe routine. (keep in mind these are not platform devices, we're working with devices under the usb bus) > Between audio and display, we use the 'drm_audio_component' layer to > model these sort of run-time binding between independent driver stacks. > It's not used here but we need a moral equivalent, don't we? > > It would really help if you documented a bit more the dependencies or > timing assumptions, to make sure we have a stable solution to build on. > I can add this to the RST that I'll make in detail, and add a summary here in the commit message. Thanks Wesley Cheng