Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164604AbdDXDva (ORCPT ); Sun, 23 Apr 2017 23:51:30 -0400 Received: from mail-by2nam01on0068.outbound.protection.outlook.com ([104.47.34.68]:1440 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1164559AbdDXDvV (ORCPT ); Sun, 23 Apr 2017 23:51:21 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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: Mon, 24 Apr 2017 11:51:09 +0800 From: Peter Chen To: Bernhard Walle CC: , Subject: Re: [PATCH] usb: chipidea: Fix missing resume call after suspend Message-ID: <20170424035109.GA11436@b29397-desktop> References: <20170421101053.2964-1-bernhard@bwalle.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170421101053.2964-1-bernhard@bwalle.de> User-Agent: Mutt/1.5.24 (2015-08-30) X-EOPAttributedMessage: 0 X-Matching-Connectors: 131374794796779170;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39450400003)(39380400002)(39850400002)(39400400002)(39410400002)(39860400002)(39840400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(24454002)(9170700003)(55016002)(33716001)(305945005)(189998001)(23726003)(50466002)(356003)(46406003)(1076002)(6916009)(2950100002)(110136004)(38730400002)(83506001)(4001350100001)(8936002)(8676002)(4326008)(47776003)(53936002)(85426001)(81166006)(33656002)(6666003)(54906002)(15650500001)(77096006)(6246003)(76176999)(50986999)(54356999)(229853002)(86362001)(5660300001)(105606002)(104016004)(106466001)(97756001)(9686003)(2906002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0301MB1189;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD002;1:RmZ2YcYUsAUiQEqGJdDjQANpG53Ks935HLsSrew2HCIt+CLfQO2fq+wQk9GgRZ/jbOzvmVID8MN9IbZgCPpitCft7gtGNT3763TUuRNHcOAoNmUqbmQd54YflRYyafuAiqGqmCeDFs+uGUQjhd86YkuBBjDojs+rI1T76u98TIwxhBD/11lHWfQzRUvNyWLJ3M+zQxjwFmR/7I6DT7EKGTCG8g/aq5y0JI/iWPCa0NRwpF1vssUhQYOaYW9kLGL7mC6j1kmzunP+3zNaUGPpoIXLcjA1pS1Hh8FG6X5QdAkqcgkcWiorelT0fUnSYgfrxWQeiTHPfNwoPPqE7zkCEsFRplC0B9a1d/GI9URCUm5ZFpVmJOZbEBYmm4x9/SeKaWPDk81c0E21B//IrMb068vkyTyvv9mL+R+LA3U+dYEIVgbt0CkkF1L53HqiIZHaAKxzoCAE9Q+2DW1gA/jnX7oURha+htxvVXPFwR4LgxgyCKE4yPmsABoeoKVcMLSZ3FpWHV9RqpQhtRb3buwNKUwf9BJL2o0rQQkw52KbhPBH2KOo/9zxsTNeRvoup+92ioktTIcCiRZxZyhxYWNpuhwrQSXx+GaOBsvB0FXVnQsPbyyk7Uq7rK4GaP1OgVeb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56a55ce5-f6b9-4d3e-e542-08d48ac52ac1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BY1PR0301MB1189; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1189;3:OdJDPO+1WbYUJoUFJsIXLFxbdcL29tXFAB1y2hMZijm5+3T69fVkO3L0eHF+GP6mul2HulMYaZfQs55nN1I3uGB+ty3h9fzwCOJM224M9rGPwhLlZ+Qb2oO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c0cSzvhmGKsRW2CiDMDqeq+TxuoE/DYBThrqd1xfY2hEN8BRsccoAIXE177uunyKBRQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(13023025)(13024025)(13018025)(5005006)(13017025)(13015025)(8121501046)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(20161123565025)(20161123556025)(20161123563025)(20161123561025);SRVR:BY1PR0301MB1189;BCL:0;PCL:0;RULEID:(400006);SRVR:BY1PR0301MB1189; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1189;4:IvluIkzvtZFNNgULMmXrDn70W9TL8J066g1Eq62wSK7Qx1iffkUJxyJYyaq47e4K5KXhPNsFA/XYrL1mTJz6v4x8ebaC6hA0czuyxPhADemSUnDm+AIKmRX11mcL1bsQ0BVFXP+3ghOmgVYcFRSR2929RFKdi9M0+81vZBCC2sdCNe07Gu1c5rbPffgBEcdtZaSmwYtBnsdXYR9Wt9PZtrXpIikzudjndmDg/51It63y3nQXQrXUo+nbBbrjSXptMRX+cfUx+Sg3HPG26Zj4HXiSZ3TZGAqBMzb2tGTLKUpsQmqIy4AAdcMVfK9uMTOEHyDBg8j20hx4ELWnztEh/LLyqrPhfvXa0aKmBb7l4C0AQ7RatFiDfkA3ACBhx8fDYpRCsDhccV4Rm9jiY8Wo+qk0XXfcfMG2PVjC0dWU5mIZyas71F0pzcUOVeIOEh55YFQj0XcSEOuLJkG+xY/gs9yBbdk+Hxz+qiBTYE0AmSypsYblzq2sxfOyqpnKZ2xPf1+Sj8QoCaoeSVpAxxCDzuQAwvMlloCK0MIjRMx7EcbzrAXnQ93kEGt24rxWSBsIOWlJS4OxTk3TW0TtYGON5Cj9o1Sa9LTDfZNf8PNm1Xh+wU6ywolxbe7kjiRuUvT6/uO/Bmnua1i5aDUjKe5fWPbpsdzWoOdsFk2GKFPq2XCF4FmyVtdjIvugDfz9LS9D27ULXvNg0bP6Nmulk3sU6CGUeqoheIZrj0qpJgYQUB0dUB1r8vjS/kmmTWKJdvdYBse5K0TXUvRKIcUX06zupRIG0IlSznULA9leeuE6QklEXac1GrunNIVI0VyoBbKhiz9VBiaBAsGy2HL4d+LBvg== X-Forefront-PRVS: 0287BBA78D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB1189;23:SGA9XKi2EILtg3ad0g+2XxasAt6aB304+6b9Uvx?= =?us-ascii?Q?WHP33BNV9BzxclqfdG/Myn7uRqQxdVTa5SA7aJUKEJh2abWGHGuTQoICFbSd?= =?us-ascii?Q?3QhTisNhXS08L5n64qH8m3Wuv/riaqYvTwc0DEkIvF+SbjxVsHi9ufsCAvtp?= =?us-ascii?Q?iAwprQzuQkPwgY6XgYzUQMWv4KS8WdfJDvW4NxSIhqJVOzt/a4d8vBPy9TaG?= =?us-ascii?Q?94INnZf0pE3ZIMWT0exPy85pmtLl7viDTAgynonIftkuKfe+v4yNtMV52wvL?= =?us-ascii?Q?fqFyXTYsVLTQx3OwefHPaZfe7j/oDHUyzfWhHURkZoKaEuQV9bJj6xo7MgPo?= =?us-ascii?Q?5vUAr94cTfDb9rsg2eqFU4i3ijrpKrrgyzn6iCGJoPENAwQWMH21TCzzA85G?= =?us-ascii?Q?JX3/6onBeBecNpGmVten/GGmwojr7TXtIIZwQqT7WVdl1nDbxhJ6f5uoe7/c?= =?us-ascii?Q?Ze4Wb8D/RutKVr5vjHb422ds9ZSHev/Vaphjq4/Vk8tj9XnbxK/aKZmMG51R?= =?us-ascii?Q?5fayH4MydgGAGfsey+rJh9dhgoLav9wNQRnlLavtzVyEE7Dwtf3SBKSPkNji?= =?us-ascii?Q?fC2n0AwlymNeRymO2LYgZQUrVQbvcIGF6N1moUp7oo7uuQ3LGkDWIL8iSeEG?= =?us-ascii?Q?nPFP8a8o7RcOPP/5OPRpyCI/ecrzmyHgELiZUC2euY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HKDCX8ddrVqGPlvxoFimTwoKaOtBjBY0w5VUo5eVSImCQkonqo+LdXYYxzEop4BHCCfpOrEr0MOhLuFUR8bgxjRGXg/t/g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 03:51:19.4907 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1189 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1871 Lines: 47 On Fri, Apr 21, 2017 at 12:10:53PM +0200, Bernhard Walle wrote: > We have a i.MX53-based hardware (quite similar to the i.MX53 QSB from > Freescale/NXP). I'm reading the ..../ci_hdrc.0/gadget/suspended sysfs > file to find out whether a PC is connected to the USB gadget. With old > kernel versions, this worked. However, with kernel 4.9 this didn't work. > > When the host is suspended once, it never sets back the suspended status > to 0. The reason is that this seems to be done in the resume handler, > which should be executed in the interrupt handler: > > udc_irq: > > ... > if (USBi_PCI & intr) { > ci->gadget.speed = hw_port_is_high_speed(ci) ? > USB_SPEED_HIGH : USB_SPEED_FULL; > if (ci->suspended && ci->driver->resume) { > spin_unlock(&ci->lock); > ci->driver->resume(&ci->gadget); > spin_lock(&ci->lock); > ci->suspended = 0; > } > } > ... > > However, ci->suspended is already 0 here because _gadget_stop_activity > is called before. So the resume handler never gets called. The obvious > solution is to not touch ci->suspended in _gadget_stop_activity and > to trust the interrupt handler to set it back (and to modify it to set > ci->suspended to 0 even if ci->driver->resume is NULL). 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. 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 -- Best Regards, Peter Chen