Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751645AbbGMIJN (ORCPT ); Mon, 13 Jul 2015 04:09:13 -0400 Received: from mail-bl2on0118.outbound.protection.outlook.com ([65.55.169.118]:20016 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750804AbbGMIJJ (ORCPT ); Mon, 13 Jul 2015 04:09:09 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; google.com; dkim=none (message not signed) header.d=none; Date: Mon, 13 Jul 2015 15:00:03 +0800 From: Peter Chen To: Sumit Semwal CC: Felipe Balbi , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , Android Kernel Team , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Benoit Goby , Todd Poynor Subject: Re: [PATCH v3 3/3] usb: phy: hold wakeupsource when USB is enumerated in peripheral mode Message-ID: <20150713070002.GA12197@shlinux2> References: <1416849900-29959-3-git-send-email-kiran.kumar@linaro.org> <15cad5ef7627483cbba96e05fe180813@BN1PR0301MB0772.namprd03.prod.outlook.com> <20141125144544.GC6360@saruman> <20150113161802.GD16533@saruman> <20150114012653.GB14944@shlinux2> <20150608083152.GB6743@shlinux2> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD008;1:IMqr7gsJKn9scanuQ2Lx3Pfd7PXjjUs8WIxMwtc0CqJrBSmRkkI0SXRE/4YSikmgxJPGDvSh+hTtK2CJOG6fHjMCbNS/gEkF9ZHSk1x/Fk6ymeO/QdNBtnqHWeIYxnewns8jJDcW5/ucwsUamP7MeUii2IbdBU96L0SZB1CqmDctlaOz0YPCox4PwksASGiixRJKOHkrNwzDaEZZHJn0lTnOilasIUBZStiBfpnLaySX9OF82ioWtIaDjQHdKQmptkA0+RZdrGhKjXJQlt8DqvJZxdEQJzbM1/XS6UHve3LVNl/WosMcE52XMshN5YdrblkHxqo4yy3L55C3hNdZL6qj6UX3b23Up5xXCcXdr4TKOeFUR5h/MZ6jBJ/YdniQ+Mu+CKpxw42m3Zw7dds4Nf46wWAIhVgiotTpEKMO7lMtr1WwZiXvHKZRfMz2L+xt X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1060300003)(339900001)(24454002)(199003)(189002)(51704005)(6806004)(86362001)(19580395003)(97756001)(46102003)(46406003)(105606002)(19580405001)(77156002)(85426001)(33656002)(33716001)(110436001)(5001960100002)(47776003)(76176999)(54356999)(23726002)(104016003)(93886004)(110136002)(62966003)(87936001)(50986999)(4290100001)(77096005)(50466002)(92566002)(2950100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB602;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB602;2:SaEwbxkJJ5J54jp815KBptLf1UQqfXPV2U7dMuRyk7+rAJGE0pb23/PcUdKS624P;3:4Tskcr02j7q4h7qBHQVCTl8CD1ux1zM7mUGWIrXYVpIsejOSn72RT9R2imw1NykL7+clHBCY6EOILPz6qgOQWYk9Qo/6dLKLuuS99tGRGG036pUoYuMo0LTXK6zo4w4Ue/581EKCvlJJUtHixbMHKbX+vX7lzRbnna0Ul+ysZTD3skv9+z5K9xWROliGVfCJrBVxMUIdqSob3LA9fnRZ07p2iJDD64qcaXGFL38bcQ0=;25:3kRSVdgXcLpE9fGsrWgASx/hUAj6gWNU/bD8TmrR5xr519ScdG6c+jPC6ZkJr3BJmBZPQIjeq0CMLCX6RHXhMyJuhUxqRr0qfeA6DirI2RmhJlHmJLxGxDnttC7V+6LEi9c4vPRCwDoJB1zTykjFIibObhWvxuO30ubZWlN0pLtvWlxImd0VXprDJ0988JmZ1TpIcY+QgEmaeSRPkamks+mkBLTnaVpkG8rvJS3pDeBcxPaPI+9QCcJI1kKTLLFhVB61H0pKx5r6lFlvmYh+Lw==;20:/ARhBD58A+fRh17YdyhINAEqubEpwKbEr6LaKcbSWlFeK4/qCxLkTCrj5GeLJYOkofaRWM2sTqnK22f4N/GydmXn728a47NOOxPTkuW1ELEGqELDHY+toWqaXnkb22gqpuVf9yj3V1nSzm5HBnzHImnfEvMkgfe+01oen2WhA2rDiAuG67OPVpGAAhMlM1oRZQX3TK6ZsBWVkuOqpECfbiOwqztB0KyYh6lvUFJAH2YNCBdbWXiuGTSTKIILa5RmE91EHaw5aJzGhWn9M/80zNt5OrdlNhLiMMKTjvuanohZ4DQ+s3iXqe7PvEgUa0CxxHQAxFYUQpMNxdYzT2e6+I06SqcoTB9dbKrVA7oXboY= X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:BLUPR03MB602; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1;PCL:0;RULEID:(601004)(5005006)(1201001)(3002001);SRVR:BLUPR03MB602;BCL:1;PCL:0;RULEID:;SRVR:BLUPR03MB602; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB602;4:IDe3BAPwKbZbf6NefAyS+T2ytF7LKzBugtgQJelDzgqQSaX/yqZqH+VfaV3BwJXDjnOp/783M5CngkidWa+q/E2quuDDND19ELg/018dYU8boXWB4zjM0Y3adT61ZHUlUOJ1oiQMv6VTx8hL8uuSzsI0KTssVaGtFqCqrib03GjQ1JlBkAAG/jZj5cqMUyTSNkfIIC/Srz2NprruMM7OQUCsPzU2QmQOPm3UnCZTlT30nIUVpUFEw3DBXbdLGizkoS1Uo3ZvJcauV3XMf6a8BArAKoUaC4rVenUlIAFtpA+zkJjbZO2kVirWj+I1dXoz X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange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8zBNzBXczjSqPKgcmrs96v/iZNOyqZsTY9GbKfQopZPSh9j?= =?us-ascii?Q?d9Ydhhsu3EbIkVNzB+ruoc6ebzlIwOHvZOo5x7TmgGrukc4kGoHbHpAm2jIq?= =?us-ascii?Q?4KI8W7JMo2yheFh8AtE/M3amqfK11NrqY0o1yI7w=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB602;5:mZHw/lgwSG8QmNfIhpLzzPgDekvqilDebsD9iTMJtgvifAEqLYjeNtIvKcdyR/DbMSxMDASflyCq8dJYN4jlEYQv4D9sJH9p80JcxEX60W0QALMKloOddSLUag2CzAj/c0h1VcyFLNfHhuVklFv3eQ==;24:HpYjAFpzanSKQMzdf/vVbpo2I7PIesP9m8N34wwH28bpfHW0/m3zVP8+garCh6gC/sn5yo7f0Q6U4lUSUGfxkEMgaBvnBCwpGJ6yFm19HOU=;20:cZRkzDGmQG7hUDbCOmJr/YHA09Hj9hnlQWBsA5odtiITM+1/A/fL0fF3mptBs0whu4jQEs6IfJ5Tq9BejX7dtw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 08:09:06.9502 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB602 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4295 Lines: 107 On Mon, Jul 13, 2015 at 01:26:23PM +0530, Sumit Semwal wrote: > Hi Peter, > > On 8 June 2015 at 14:02, Peter Chen wrote: > > On Mon, Jun 08, 2015 at 12:37:00PM +0530, Sumit Semwal wrote: > >> H Peter, Felipe, > >> > >> On 14 January 2015 at 06:56, Peter Chen wrote: > >> > On Tue, Jan 13, 2015 at 10:18:02AM -0600, Felipe Balbi wrote: > >> >> On Tue, Jan 13, 2015 at 04:02:20PM +0530, Kiran Raparthy wrote: > >> >> > Hi Felipe, > >> >> > > >> >> > On 1 December 2014 at 11:09, Kiran Raparthy wrote: > >> >> > > Hi Felipe, > >> >> > > > >> >> > > On 25 November 2014 at 20:15, Felipe Balbi wrote: > >> >> > >> On Tue, Nov 25, 2014 at 07:06:18AM +0000, Peter Chen wrote: > >> >> > >>> > >> >> > >>> > > >> >> > >>> > usb: phy: hold wakeupsource when USB is enumerated in peripheral mode > >> >> > >>> > > >> >> > >>> > Some systems require a mechanism to prevent system to enter into suspend > >> >> > >>> > state when USB is connected and enumerated in peripheral mode. > >> >> > >>> > > >> >> > >>> > This patch provides an interface to hold a wakeupsource to prevent suspend. > >> >> > >>> > PHY drivers can use this interface when USB is connected and enumerated in > >> >> > >>> > peripheral mode. > >> >> > >>> > > >> >> > >>> > A timed wakeupsource is temporarily held on USB disconnect events, to allow > >> >> > >>> > the rest of the system to react to the USB disconnection (dropping host > >> >> > >>> > sessions, updating charger status, etc.) prior to re-allowing suspend. > >> >> > >>> > > >> >> > >>> > > >> > >> Kiran is unable to continue on this patch anymore, so despite my very > >> limited usb experience, I would like to take this over and with your > >> help, take it to closure. > >> > >> From what I understand, it might be possible to do this either at the > >> usb controller driver (where it detects if it has enumerated in host > >> mode or device mode) or in the extcon driver (where it detects VBUS > >> etc..) - which would be a cleaner / more logical way to do it? > >> > >> Thanks for all your help! > > > > I added my suggestions below: > > > > My opinion is: if we need this feature, we should depend on gadget's > > state, eg 'configured', not vbus level. The system suspend should be > > allowed if the gadget state is 'suspended' even vbus is still there. > > > > And when the gadget goes to suspend or reset or disconnect state, we can > > go to disable this wakeup source. > > > > At drivers/usb/gadget/composite.c, we can know the gadget's state. > > > Thanks very much for your suggestion, and apologies in the delay in response. > > I tried to study your suggestion and the code a little bit more, and > while I liked your idea quite a bit, I also realised that for the case > of letting the USB charger use cases, in gadget framework, there > doesn't seem to be a way to get the USB_EVENT_CHARGER, since charger > would likely not be a gadget. > > In this case, how'd we be able to enable / disable wakeup_source for > charger events? We may not prevent the system entering system if it is a charger, isn't it, so don't need to consider USB charger. > > If indeed we can't handle charger events in the way suggested by you, > may I propose the following: > > - implement this in USB-phy as proposed in Kiran's original patch, > - keep it disabled by default, and add a module param to enable/disable it > - for no vbus case, use another event (USB_EVENT_ENUMERATED / > USB_EVENT_NONE? ) to identify connect / disconnect? > (OR, maybe don't do anything for such cases, since most likely > the chipidea kind of implementations would handle it themselves?) > In my opinion, we can do noop for wakeup source if it is a USB charger. > Of course these are based on my limited reading of the USB code, so > I'd be grateful if you'd let me know of any obvious gaps in my > understanding! > > > -- > > > > Best Regards, > > Peter Chen > > > Best regards, > Sumit. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/