Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp808768rdh; Thu, 26 Oct 2023 17:08:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaJzssOYavUCl7/bl6DN4qX2cqRVfor+H+NvlRT6PtykM69GbpMYNyDHc39WFmkzy1mVaw X-Received: by 2002:a05:6808:1449:b0:3b2:f16e:3f62 with SMTP id x9-20020a056808144900b003b2f16e3f62mr1379852oiv.25.1698365323462; Thu, 26 Oct 2023 17:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698365323; cv=none; d=google.com; s=arc-20160816; b=I6jXmA9Wu9VEI7gX+VXyrZ37JeCYV75Gi9XdXwzN44GYl99/LKcwIXt7Hbk/Nh3xZ6 S6Z8EI00h9cQbx0CrOFEGnfj3lFgD3OPNZRjsutIrsC7BopcHZrK60haAAeTZxOvYnOK NO6aS1KoFeyhC1kpZeHWe7vN1t28Bi+fAeuc3Y5tfArFrN5EPqO0TQrM1rJRqzuQcqHi k97SEYnuhLsm4F3wR+vtKt3T5W3FfEkPuNJ6a3t+rcnKVWoAAUmhSOVwfpkY+vI5TJa5 o6lwc1CjAoSP8MjBcVp9SNO+ubk/5/W8GkRdGKnJGcCorHXgKDlHOUE6wBEE7xJ+fdZJ 0Pfw== 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=KTwkppKtfnt2SAszLh2T9OBebpVxwToekkwIOrS6bL4=; fh=UrXK8MNEMHIn8pKym+PxbNELK4rL/snal4oYZ2U0Oho=; b=E064TKS1K6cnCm4rYOE1R4N1EFS1i1q5jmTKPOhA49T/K2IKVwrzrlhwRxOAGxLt1x g6hOFRqX08ySzezJtBNilu/kJvXjiCrn5+0H3MHMkqlBIYum0HErmNDUsUaFMvIkeZmP pjauFS+AAMP8WzAZ6Gg8Y2uZRx7y7NC3ZiBF1DeNgfe6W+Q0d3h65jjggLOVaETapV61 csJpwpURry9JW6S1v6c+vc0jDQI134SOC3Tg3G83U9BayHveptLpdTPJyVSxqM3HiUJK HDCKezMdoBHXpEpJjMCFG+UsmvkxByTRSYTaw5nzB7f6TSaRjZteFxjgJ+B2mLprH/MF sN4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nZbcxUsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e83-20020a255056000000b00da04f22be85si993073ybb.146.2023.10.26.17.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 17:08:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nZbcxUsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id F131580C0DE3; Thu, 26 Oct 2023 17:08:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbjJ0AIU (ORCPT + 99 others); Thu, 26 Oct 2023 20:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234816AbjJ0AIS (ORCPT ); Thu, 26 Oct 2023 20:08:18 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B04B1D4F; Thu, 26 Oct 2023 17:08:14 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39QNxq7e010558; Fri, 27 Oct 2023 00:07:51 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=KTwkppKtfnt2SAszLh2T9OBebpVxwToekkwIOrS6bL4=; b=nZbcxUsJY0ezVL5sidh830ykjrp0PQ6loSuQuiqUgbwY027VsGahwVKjM3mllbbwY/65 WC6yqfUOe+iXZIcGZqtXWCcrBBAIIwMDCKWDr7C68FkJnjnRoev7CjblainhJ+m5OdD3 JH9KA57UeywlKwi3KB8sayFHiEbVxzNzK9uFU60QoHtF2bPFBx3X1b7i/FQGc63ug794 J91gXQfO3NfFML7Vp7R4kEudUtVYDPXnG7Bc6fQp8nICl/T4HnqitGAruKPIWib9esce MXNTeS9cFWHKciLlUjAuOYjgvmPL2FAQXBtM7if9nFdpXZZD7HEEk4jEu1pOoKX+EdX2 lw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tyx3u8jtt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 00:07:51 +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 39R07oVw032425 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 00:07:50 GMT Received: from [10.71.115.36] (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; Thu, 26 Oct 2023 17:07:50 -0700 Message-ID: Date: Thu, 26 Oct 2023 17:07:49 -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 v4 3/3] usb: dwc3: Modify runtime pm ops to handle bus suspend Content-Language: en-US To: Roger Quadros , , , , , , CC: , References: <20230814185043.9252-1-quic_eserrao@quicinc.com> <20230814185043.9252-4-quic_eserrao@quicinc.com> <9be9fae5-f6f2-42fe-bd81-78ab50aafa06@kernel.org> <0dee3bec-d49f-4808-a2f8-7a4205303e1f@kernel.org> From: Elson Serrao 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 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-ORIG-GUID: 7rxH9l_SyWSXCToapu9r2IwRjqwzkuZ8 X-Proofpoint-GUID: 7rxH9l_SyWSXCToapu9r2IwRjqwzkuZ8 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-10-26_22,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=668 suspectscore=0 spamscore=0 mlxscore=0 phishscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310260211 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 17:08:40 -0700 (PDT) >>>>> >>>>> While this takes care of runtime suspend case, what about system_suspend? >>>>> Should this check be moved to dwc3_suspend_common() instead? >>>>> >>>> >>>> Sure I can move these checks to dwc3_suspend_common to make it generic. >>> >>> Before you do that let's first decide how we want the gadget driver to behave >>> in system_suspend case. >>> >>> Current behavior is to Disconnect from the Host. >>> >>> Earlier I was thinking on the lines that we prevent system suspend if >>> we are not already in USB suspend. But I'm not sure if that is the right >>> thing to do anymore. Mainly because, system suspend is a result of user >>> request and it may not be nice to not to meet his/her request. >> >> Agree. Irrespective of whether USB is suspended or not it is better to honor the system suspend request from user. >> >>> Maybe best to leave this policy handling to user space? >>> i.e. if user wants USB gadget operation to be alive, he will not issue >>> system suspend? >>> >> >> Sure. So below two cases >> >> Case1: User doesn't care if gadget operation is alive and triggers system suspend irrespective of USB suspend. Like you mentioned, current behavior already takes care of this and initiates a DISCONNECT >> >> Case2:  User wants gadget to stay alive and hence can trigger system suspend only when USB is suspended (there are already user space hooks that read cdev->suspended bit to tell whether USB is suspended or not for user to decide). Attempts to request system suspend when USB is not suspended, would result in a DISCONNECT. >> >> For supporting Case2 from gadget driver point of view, we need to extend this series by having relevant checks in suspend_common() >> >> Also, is it better to provide separate flags to control the gadget driver behavior for runtime suspend Vs system suspend when USB is suspended ? For example, what if we want to enable bus suspend handling for runtime suspend only and not for system suspend (Case1). > > But you mentioned that for Case1, USB gadget would disconnect from Host. So USB will be in disconnected state and USB controller can be fully de-activated? Except maybe wakeup handling to bring system out of suspend on a USB plug/unplug event? > Why do we need separate flags for? > Sorry let me clarify. This is in reference to deciding how we want the dwc3 driver to behave in system_suspend case. One option is to continue with the existing behavior where USB gadget would disconnect from Host irrespective of bus suspend state. We dont need any modification in this case and we can leave this series limited to runtime suspend only. Second option is to stay connected IF we are in bus suspend state (U3/L2) otherwise DISCONNECT IF we are not in bus suspend state. The main motivation is to preserve the ongoing usb session without going through a re-enumeration (ofcourse true only if we are in bus suspend state). This would need relevant checks in suspend_common(). Which option do you think is more suitable? IMO option2 is better. For example if we are in a scenario where there is a network session (over USB) open between Host and the device and usb bus is suspended due to data inactivity. Option2 would preserve the session whereas Option1 we would terminate this session when a system_suspend happens. Thanks Elson