Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1199325rdf; Sat, 4 Nov 2023 10:03:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmDaSEfrCZKPOqIFlml4OvcHsgSms6sT53aXEAml4YSI36HQU0GzxgK8LXpQonBvwFizaP X-Received: by 2002:a05:6830:4ac:b0:6bd:152f:9918 with SMTP id l12-20020a05683004ac00b006bd152f9918mr27685201otd.14.1699117438170; Sat, 04 Nov 2023 10:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699117438; cv=none; d=google.com; s=arc-20160816; b=Br5LPyrwXnyRZ0L3yn6U8uQPCCf9KODiSo83xvCBOP5KF7lJvRQBYqOH4HBnzg0Z3N HPbq2yK6RNqs9dykWHWu15hRyEoF6MzesQMYKwoVTGasULITG7wz6EO7IaOLk2i+2b3u gRu7tLjV0S8UIUV4OxUe3Ep5DOlh54hxcdSKorFanMeXJ/2mSJ31oqZv1XATX9K0wKr9 SYXA9fG7EQq27lQEMBFGDdSBM74fCbi+0id84Giv0UCll/skw4Iw1Yb6cVU93lWLDIql 2MMuP72R88xROZWdSzWZrnYPwotzuW3DKNCOBPaviqb20xokK/W70TlOwlTBB4K+b8gb lfIw== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=k18Ts0ut2IoH66o6ZrcLWBPsRz7WH3GCevTUNI4/wF4=; fh=ljgukb7pDnCoEgmpFXzzt3ffLhwJ/xKBJ7XuGVVPqP4=; b=fD/BtGSAOsLOXcxP0xxt/Ad5vY83FWXUCh2e7c8+jsmAry+S7Qly5Nq70n0Ng/whnn 9zKDU/i2WNvfCsmD9FWHyAMybKXEogJl9Q0XtZKiPf2L2AdloTFTFvIYQd5e+21d6wIo 1uESGmNar2H5E8QHD7c3GL9dxUBl8j8ior94L7vH2PRQfR+OavYSE6TZfwX1bpTQZEyP KRmX1bUbiOkeVmOm17XBUpNT6gpYhgC/DOoTBSQ4GTaOWH5BwgEanqyrtidK5vrP2sz3 uJrDIwCYx2OpMWwwk9p7Ys0zIN3TRxBbVhQYQ9SkCjvz4powH+mJwpkZ5mTOzzg4YoHf 8e0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="FxfoIHL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id f7-20020a9d5e87000000b006ce32c32c8esi1631978otl.113.2023.11.04.10.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 10:03:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="FxfoIHL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 F385C8077FFA; Sat, 4 Nov 2023 10:03:35 -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 S231346AbjKDRD0 (ORCPT + 99 others); Sat, 4 Nov 2023 13:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbjKDRDY (ORCPT ); Sat, 4 Nov 2023 13:03:24 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CC62D6; Sat, 4 Nov 2023 10:03:21 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A4H0CeS007386; Sat, 4 Nov 2023 17:03:05 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=k18Ts0ut2IoH66o6ZrcLWBPsRz7WH3GCevTUNI4/wF4=; b=FxfoIHL/lVWG9StWBQ3w5B4TrH+7Br7xta36I1rf5d+SUV/PQRX8aKKhCZyOXCixZwoH 0oP8Dn+m2yveImUNf4KLaJjWH9X+TUVhnlW7seNf+e+h8oLsiuJd4FJWDrx/OEwIV8eg FncsxVlr9OftKw2rbdKtJOFCWPtX8pDG66AUffuqWFG3YGKaZcWGD5zWapvfrFqQLuqA ylFJzjCOTkKoTsOSstKqG+1FX3CDwhdB4rIvw9AV6/DmF1TLiJ4oZMqSCrxQ2t9e8FvW 0h33rSdz0w6mznz7IYWeZrlpiDyEdu39KI4WoBv8RUjDg1XTTcC4f+5NspD7Wd2c9UW8 XQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u5eu60w35-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 04 Nov 2023 17:03:05 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3A4H34CY022940 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 4 Nov 2023 17:03:04 GMT Received: from [10.249.19.93] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Sat, 4 Nov 2023 10:02:58 -0700 Message-ID: Date: Sat, 4 Nov 2023 22:32:55 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 2/8] usb: dwc3: core: Register vendor hooks for dwc3-qcom To: Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio , "Conor Dooley" CC: , Krzysztof Kozlowski , , "Thinh Nguyen" , Rob Herring , , , , , , Andy Gross , Greg Kroah-Hartman , Philipp Zabel References: <20231017131851.8299-1-quic_kriskura@quicinc.com> <20231017131851.8299-3-quic_kriskura@quicinc.com> <5ef66bdc-9645-4bbe-8182-baa7fe4c583a@quicinc.com> <3be5e95f-85d2-4abf-a8b4-18b019341602@quicinc.com> Content-Language: en-US From: Krishna Kurapati PSSNV 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: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 3qUD6-cNryyq5LI22b-kPDdWjCZuSzC6 X-Proofpoint-ORIG-GUID: 3qUD6-cNryyq5LI22b-kPDdWjCZuSzC6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-04_16,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311040145 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Sat, 04 Nov 2023 10:03:36 -0700 (PDT) >>> Hi Bryan, >>> >>>> What happens to this code if you >>>> >>>> static int count; >>>> >>>> 1. sleep in dwc3_probe for 10 milliseconds >>>> 2. return -EPROBE_DEFER >>>> 3. if count++ < 5 goto 1 >>>> >>>> i.e. if we simulate say waiting on a PHY driver to probe in >>>> dwc3_probe() >>>> >>> The vendor hooks are used in __dwc3_set_mode and role_switch_set >>> calls in core and drd files respectively. These are invoked only if >>> we are OTG capable. The drd_work is initialized in core_init_mode >>> which is called at the end of dwc3_probe. If dwc3_probe fails and >>> gets deferred before that, none of the vendor hooks will be fired and >>> dwc3_qcom_probe is also deferred. >>> >>> However I see that if core_init_mode fails (the cleanup is already >>> done in drd to prevent set_role from getting invoked already),  I >>> need to cleanup vendor hooks in error path of dwc3_probe(). >>> >>>> and what happens if we introduce a 100 millsecond sleep into >>>> dwc3_qcom_probe() - and run a fake disconnect event from >>>> dwc3_qcom_probe_core() directly ? >>>> >>>> In other words if make it that dwc3_probe() completes and struct >>>> dwc3_glue_ops->notify_cable_disconnect() fires prior to >>>> dwc3_qcom_probe_core() completing ? >>>> >>>> i.e. I don't immediately see how you've solved the probe() >>>> completion race condition here. >>>> >>> Just wanted to understand the situation clearly. Is this the sequence >>> you are referring to ? >>> >>> 1. dwc3_probe is successful and role switch is registered properly. >>> 2. added delay after dwc3_qcom_probe_core and before interconnect_init >>> 3. Between this delay, we got a disconnect notificiation from glink >>> 4. We are clearing the qscratch reg in case of device mode and >>> un-registering notifier in case of host mode. >>> >>> If so, firstly I don't see any issue if we process disconnect event >>> before qcom probe is complete. If we reached this stage, the >>> clocks/gdsc is definitely ON and register accesses are good to go. >>> >>> If we are in host mode at this point, we would just unregister to >>> usb-core notifier and mark last busy. If we are in device mode, we >>> would just clear the hs_phy_ctrl reg of qscratch. After the 100ms >>> delay you mentioned we would call dwc3_remove anyways and cleanup the >>> vendor hooks. But is the concern here that, what if we enter >>> runtime_suspend at this point ? >>> >> >> Just to clarify one more thing. The probe completion requirement came >> in because, before the device tree was flattened, dwc3-qcom and core >> are two different platform devices. And if the dwc3 core device probe >> got deferred, dwc3-qcom probe still gets successfully completed. The >> glue would never know when to register vendor hook callbacks to >> dwc3-core as it would never know when the core probe was completed. >> >> That is the reason we wanted to find out accurate point where core >> probe is done to ensure we can properly register these callbacks. > > Are you saying to you require/rely on both of these series being applied > first ? > > [1]: > https://lore.kernel.org/all/af60c05b-4a0f-51b8-486a-1fc601602515@quicinc.com/ > [2]: > https://lore.kernel.org/all/20231016-dwc3-refactor-v1-0-ab4a84165470@quicinc.com/ > > Must be, nothing applies for me in this series. The first one is not a patch. It is just a discussion thread I started to get community's opinion before on disconnect interrupt handling. The current series is based on top of [2] made by Bjorn (as you already found out) and as I mentioned in cover letter of my series. Regards, Krishna,