Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428483AbdDYIOf (ORCPT ); Tue, 25 Apr 2017 04:14:35 -0400 Received: from mail-by2nam03on0064.outbound.protection.outlook.com ([104.47.42.64]:29424 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S980503AbdDYIOP (ORCPT ); Tue, 25 Apr 2017 04:14:15 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Date: Tue, 25 Apr 2017 16:14:03 +0800 From: Peter Chen To: Bernhard Walle CC: "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: Re: [PATCH] usb: chipidea: Fix missing resume call after suspend Message-ID: <20170425081403.GA873@b29397-desktop> References: <20170421101053.2964-1-bernhard@bwalle.de> <20170424035109.GA11436@b29397-desktop> <292472280.32717.1493040322539@office.mailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <292472280.32717.1493040322539@office.mailbox.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-EOPAttributedMessage: 0 X-Matching-Connectors: 131375816516170236;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.158.2;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39860400002)(39400400002)(39380400002)(39450400003)(39410400002)(39840400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(199003)(51914003)(24454002)(189002)(9170700003)(110136004)(38730400002)(23726003)(33656002)(9686003)(55016002)(53936002)(189998001)(54906002)(33716001)(4001350100001)(4326008)(15650500001)(8676002)(81166006)(5660300001)(83506001)(1076002)(77096006)(97756001)(86362001)(8936002)(85426001)(356003)(47776003)(105606002)(50986999)(305945005)(76176999)(54356999)(106466001)(229853002)(50466002)(6246003)(104016004)(46406003)(2906002)(6666003)(6916009)(2950100002)(5890100001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0598;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD041;1:fQuREJkLA1Dc7HvEcpt1ZRPqlpWKIjqGuh3LAHgf4BQXNHmnVV2ZyMW7CEgIWNU26OFAmL5w1UpD9nQxPL1bm27/dydOuaCT/RXxtMa+MS2VqBtBrvYFmvfftC8RiTKJZL5mTPR4uOz2SPMgbF+xnut9/uK4rSrB7jzOFNbPQsxx2BKBtKM3uwV5zl+Rw/Sg0b5OY8e9MCU+t2o3Nxd6wmR0QFtTeZq10jSn2FKNIeFBEOBDN/94KUAVVawkZQXLWAFKa3kAAywq5IGOt4hbH6cx9I/lER/GQL/ucRYyLyMR6KnYZkLA7c3R8Pbh3cU8SDytqLTQAX590b/idLB70OJS9uGbdBgVkCkpV/aOlSfzNywF/qUyj5zjtkbJJjNJBoSp1TSxiEgpXZ4kKzsf8BzXy5y6T70oc4IFMeX9k/UhxtRGFx/gYrGkmJFFKUMmy6FtWPnmnThxCYbr0wzRAANshOp2ythTUXMoB8nhDjvbpCNBZ7dmbXShfEaaygBaWTHWOtIzqQZtOdJYH2aACdwJhhdvPbypCORKAHPjHQqN/XahopVb4Pi5TNrYV8nBVf7EzpxXBYsSc8I3OaFScJkYPBk69C44WLZFUWKFjEWaNXD3mljzLFHd1SyNGr0Q X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 963a1dc5-aad8-4bdb-909c-08d48bb30dfa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BY2PR0301MB0598; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0598;3:mdmuI7IpyZhhqTl4qmEWYOHZnb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aJKu//b3j3mgAt6GQxiVdYZgeAa/WNj8Yg+T5QG5XxNVISY236wlgkp1+8yBrC2zQbmDVrNeMbonMMCfLLIWmtCOvkJukHmn+QGqFBmHAnHP4Ix6x5ZdNFfQHdtI4kPw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(13015025)(13017025)(5005006)(8121501046)(13024025)(13023025)(13018025)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123556025)(20161123563025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(20161123565025);SRVR:BY2PR0301MB0598;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0598; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0598;4:oYYG/Ogxe22DRlgZ9rxLp74dKft3bfcG7gNHmxxQWwhuwxzG3pghexyXAV0A3coqjICzpKZ8XOfesjByvgZ8WtvHJwQDXC8JX7ajTgBqUMNhIKRliYtqEsKzj/jIe6Zgzuney/TQN9Nx4qXDeRc/v/GeK3QGOXVOXTUPqzXlSMGU6tKzFrBZ//VgC3esv5+ijWAXskpd5DERufzHZvPTMgOoh7QmPzEfr6+YRiRzgsrJBoCpwF3lP74md2oxYY+5PeZL6UabZJJ0EFInqGq54E5shhk45MHBomqCcYOMyzEwB+URYkErlbRGExdenx3HXAR16le5N0ZzCeFeMmuafxkaal1sFdukjnfjFo0naq/36au3NTIIxWNZGDK8gusTQgQ7QDUU7tKZ0Sx48eRG9sxcimw/sdGKhV7RiwaBfbA845neqZasgM0mSsqQxAgEMnB0a32fE40iei+b+wX4GlpHih1DsOLK+eHGHiGV06z5VFMAibO7uKzHupzN3PhA8WJqX7q1DwfgzaRqu8R+VnL4+5Bjg1ej7vIGqi8acCn9aVGXzGTF0M/2bevF1GK3GOerF2PwTvK3Ndcs9cqdPiL/0iANPM01DlajPey/EeNAhf+2Z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2IeF+QemBMOI5+TAOHoe?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0598;6:gBWmOVM1Vgy+5MPOkt8eMa7ht6lapMBNMXcIekISVIY3B1CyGoTHBGOn405gUdTu9lB4hIE2pOg9y43vbkdZMxoV/hsCcqt9iB9HLX8cLhp5uZ/Cxrgt8ZbgYnhyQeIkraSHguLClrFS1DernhHJ3STX08PVk9kjEiC3us/92AHKYVx+AJyF22VoLxpCF+vvhSMcL+cpP1cPrPlNswkEPu4QWaUNCeoF0mc0+XO46jAV1cksMHyddsATncyZG6bi4X34QWQL3J48S+b920+PFxQoORbBAJSwjO0vrHe0+DFNlOAfZoG0IXBnas07TcZmsmppdXYhngk2UBJgBRcebyMletGCIwrWEPfWbRwPCOwBMJXu6yZLZTABP6GnEEZL7JUX26WwX/sg6Zjf36xrz3Q0ouoiOogAaqZPA7nEcZX3glA6pKs69oxb3MhyV9uO0zr4LrxuFccqFWf9MGWlJAkDvljFVmT6F11aGWwiiOsQOnMOXlV94aegeZfVDXUwgPNfWEnni9BognrNpg4pCQ==;5:LGW4T5yYS2pocCQ4HwKMHUxEBQwDn/jRjKh7U6Ag1n1MQYk9uMN1R25GhdejhWsuTfJmoqfkU/WZbh0IEDi/PcSgN0bZdAVjD3Sm0r/TrW+exWFCe2yAbVDJeDhp7mxDY4Nq9BdFoZt5nPtFVfaJYd/LxEmQbx51Q+WFJW4T8UbMZGUvN6pgYOsN1r/8zHJ4;24:1A+Hwk+b6HtDUDoMnFiFYwKxNXeVLQf0Pv7yQczb4fLIeltQnJMYQPjevgdtHj10H2E1lUkIZO0I/UL4bfhOy+ugaUZzbckfjcjt6Cwn3g8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0598;7:JSxzeHyxmmKvVbgEx0Vw/e8aX14l1CVqC1KFqRu8lCUW33u89qr9mXQV1z3zcy/60lKmIb17OCvg/eaqcT7bsPeH8Q83jkvDwHEfiS1dTNMEMzNwjXEtKVZgtGP6sKo0j8KoGNX+Yj4P14bmpi/LrwmsI3WycRgQUn+NrhtdiNmEehETOmoZHnn+6yzV+ziCu0uoaxfEg7vmMWWf3/Wm90ZWkqR5EIU90Cur9/YaatSkHKOEZ/ar+j59hLdWlr5TrOHIZwhaySjgq0we/fJXVcU/v5Ci7R61ll8Si06GVweR/A54JWfaVeoKVbKQg2zgB7pC3ojgDQtVwChtBnISDQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2017 08:14:11.4922 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0598 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1857 Lines: 37 On Mon, Apr 24, 2017 at 01:25:21PM +0000, Bernhard Walle wrote: > Hi, > > > Peter Chen hat am 24. April 2017 um 05:51 geschrieben: > > > > > The current code logic is: > > - When the resume is received from host, the ci->dirver->resume is > > called, and suspended is cleared. > > - When the reset is received from host, the isr_reset_handler is called, > > and suspended is cleared by _gadget_stop_activity. Since reset is > > called, so ci->driver->resume doesn't need to be called. > > My problem is that dump_stack() doesn't show the complete stackframe. What I see from debug messages is that when I plug a cable (after the host has been suspended) then _gadget_stop_activity is executed before udc_irq. > > My first attempt was to save ci->suspended at the beginning of udc_irq (i.e. before isr_reset_handler is called), but that doesn't work. Even in the beginning of udc_irq ci->suspended is 0. So isr_reset_handler is called before. > > The result is that when I unplug a cable and attach it again, driver->suspended has been called but driver->resume doesn't get called. > > > There is a patch to fix clear suspended even the ci->driver->resume is > > NULL at v4.12-rc1. > > > > usb: chipidea: udc: update gadget state after bus resume > > Thanks for the hint. That makes the second part of my patch irrelevant, but the first part (removing the ci->suspended = 0) is needed in order to make my setup working. > > Any idea to find the cause why reset is called before resume? According to your explanation, that shouldn't be the case? > Since you unplug the cable first, and plug in again. The driver will treat it as connection but not resume event. You may use /sys/class/udc/ci_hdrc.0/state to get udc's connection, eg "not attached" or other states to indicate connection. -- Best Regards, Peter Chen