Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp195765imw; Tue, 12 Jul 2022 17:37:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vBfmrht6NJirysw+zXrAt4hv7Js6Nc5lDW2PE971CnPg7MqjyyJHYemLgSFPFqN0x6b4gI X-Received: by 2002:a17:902:8b8a:b0:16b:b560:da62 with SMTP id ay10-20020a1709028b8a00b0016bb560da62mr662003plb.20.1657672623169; Tue, 12 Jul 2022 17:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657672623; cv=none; d=google.com; s=arc-20160816; b=hA7AvfU4ngbQ1mVFmXluRzdQ16/hEl/rgSQBdhV/qDzLdZjRvmo6wZA/yhG9H/tBk6 NQOvlMwvP06VZxhXgtqXAQp6jwsvkUNp4CjZedYb7goj7ymZXHNIreWKGXC01BLBF3IE s8FQKqPGi0Os95M/jO4EphwikVapsFrzb3OpsdTniFkh1LBv+HpEbvMEZzbCCCh+wIUd jnWks8eU1sExihG9bWIajQQZbfwNSIHHtoHl7yPcE9N4O0mECCn0/GxwW3SgmUyO1+IP YB9odsfB559s0JKPYlpKXxAGUcuspuw/0zqqbt0rxjrL+kW1I15inhoQ6UP0Ivt+PadB 8GCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=wP60QWyBV7Lv8G2MPVhFC5kEY3bi5afN3NB0xstza4I=; b=WPGHVNgUzz7pstEqaxIDQMXSCQhpW9HZ7Pt2m6E2Mv/CXtOxKNP9Nmlm2an3nata3H gMH13zE7wsYvkF6ycPvhNz5ENFYYwLs+EnT22Cc9VeA4cSfGyNLi492PZh4tVWRl6BOk i4NC16p5+f4CG+qtun/S4FYjXqngA5iZYsO1Z2ImuAR66DMhMGxSDYB1annPbi6NcOBp MnNA8YTgCXfi0rtpeQvpKrT287z6gfCLO+SAeiwJ0dNk6yqdU1eKiSB2GYMZmU0XspL2 BomcqdsFLzW7mDKkLSbwNn0dp1D3z4hte/w7GFmvWmOxYrE44HrVIq6BxNkzhWB6ce5X 5mWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=dNUpult6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om3-20020a17090b3a8300b001ef8d23ad9csi576517pjb.182.2022.07.12.17.36.47; Tue, 12 Jul 2022 17:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=dNUpult6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbiGMAf4 (ORCPT + 99 others); Tue, 12 Jul 2022 20:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiGMAfy (ORCPT ); Tue, 12 Jul 2022 20:35:54 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B4C98688A; Tue, 12 Jul 2022 17:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657672554; x=1689208554; h=from:to:cc:subject:date:message-id:mime-version; bh=wP60QWyBV7Lv8G2MPVhFC5kEY3bi5afN3NB0xstza4I=; b=dNUpult6wNIkqN4b4F9fkdEtFEVtgCg7Tjaxt0cSfzpipxRP+5XIJ9xk NQPP+anLbPzjQYPpawqzrhtvxkOKd+MO0Lg9uHm9C14U24zZ6SwDepaZP c1kEbc9Wx/IrQNLsfHo+rTa+93MSfLGigVxYg1XWQQCI3pAO3HDBtgbhz U=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 12 Jul 2022 17:35:53 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 17:35:53 -0700 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Jul 2022 17:35:36 -0700 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.986.22; Tue, 12 Jul 2022 17:35:36 -0700 From: Wesley Cheng To: , CC: , , , , Wesley Cheng Subject: [PATCH v2 0/5] Fix controller halt and endxfer timeout issues Date: Tue, 12 Jul 2022 17:35:18 -0700 Message-ID: <20220713003523.29309-1-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes in v2: - Moved msleep() to before reading status register for halted state - Fixed kernel bot errors - Clearing DEP flags in __dwc3_stop_active_transfers() - Added Suggested-by tags and link references to previous discussions This patch series addresses some issues seen while testing with the latest soft disconnect implementation where EP events are allowed to process while the controller halt is occurring. #1 Since routines can now interweave, we can see that the soft disconnect can occur while conndone is being serviced. This leads to a controller halt timeout, as the soft disconnect clears the DEP flags, for which conndone interrupt handler will issue a __dwc3_ep_enable(ep0), that leads to re-issuing the set ep config command for every endpoint. #2 Function drivers can ask for a delayed_status phase, while it processes the received SETUP packet. This can lead to large delays when handling the soft disconnect routine. To improve the timing, forcefully send the status phase, as we are going to disconnect from the host. #3 Ensure that local interrupts are left enabled, so that EP0 events can be processed while the soft disconnect/dequeue is happening. #4 Modify the DWC3_EP_DELAY_STOP flag management so that if these flags were set before soft disconnect, that the disconnect routine will be able to properly issue the endxfer command. #5 Since EP0 events can occur during controller halt, it may increase the time needed for the controller to fully stop. Wesley Cheng (5): usb: dwc3: Do not service EP0 and conndone events if soft disconnected usb: dwc3: gadget: Force sending delayed status during soft disconnect usb: dwc3: gadget: Adjust IRQ management during soft disconnect/connect usb: dwc3: Allow end transfer commands to be sent during soft disconnect usb: dwc3: gadget: Increase DWC3 controller halt timeout drivers/usb/dwc3/ep0.c | 9 +++++---- drivers/usb/dwc3/gadget.c | 33 +++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 14 deletions(-)