From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756870Ab3FSOVb (ORCPT ); Wed, 19 Jun 2013 10:21:31 -0400 Received: from mail-vc0-f180.google.com ([209.85.220.180]:42779 "EHLO mail-vc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756669Ab3FSOVa (ORCPT ); Wed, 19 Jun 2013 10:21:30 -0400 MIME-Version: 1.0 In-Reply-To: References: <1371146190-16786-1-git-send-email-zoran.markovic@linaro.org> Date: Wed, 19 Jun 2013 16:21:29 +0200 Message-ID: Subject: Re: [RFC PATCH] mmc: Enable wakeup_sources for mmc core From: Ulf Hansson To: Colin Cross Cc: Zoran Markovic , lkml , linux-mmc@vger.kernel.org, San Mehat , John Stultz , Chris Ball , Johan Rudholm , Jaehoon Chung , Konstantin Dorfman , Guennadi Liakhovetski , Tejun Heo , Andrew Morton Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18 June 2013 19:15, Colin Cross wrote: > On Tue, Jun 18, 2013 at 6:17 AM, Ulf Hansson wrote: >> On 17 June 2013 20:33, Colin Cross wrote: >>> This is a generic requirement for using a kernel with autosleep >>> enabled. Autosleep will enter suspend whenever there is no wakeup >>> source/wakelock held. Consider the following sequence: >>> >>> Kernel is suspended >>> Card is inserted, triggering a wakeup interrupt, which is an implicit >>> wakeup source until it is handled >> >> I don't think a card insert/remove irq need to be configured as a >> wakeup interrupt. As you say, it will force a resume to detect the >> card, but for what reason? >> Instead, I think it it better to leave the card detection to be >> handled at the next resume, thus not resuming the system when not >> needed. > > That decision is going to be different on each device. On Android > devices it has been configured as a wakeup interrupt. This patch is > necessary on devices that want to handle the event as a wakeup event, > and has negligible impact on those that do not. > >>> Kernel starts resuming, resumes the mmc driver >>> The mmc driver enables its interrupt, which is immediately handled and >>> queues an event to be handled by userspace >>> At this point the wakeup interrupt is handled and gone, and no wakeup >>> sources are being held, so the kernel can choose to go back to >>> suspend, so userspace can't handle the insertion event until the >>> kernel wakes up for another reason. >> >> Is this a problem? From my point of view it should be perfectly >> acceptable to let userspace handle the event at the next resume/wakeup >> instead. Don't you think so? > > Depends what userspace is doing. If userspace would like to provide > the user some feedback on the event, then it has to be a wakeup > interrupt, and it has to hold a wakelock until it has passed the event > to userspace. It seems like a bad idea that an insertion of an SD card should trigger the display to be light up. That is indirectly in principle what you suggest should happen from user space once a new SD card is found. Right? I have been working with Android for several years, we never used this kind of setup. Instead we wait for the user to press the "display on" button. At that time the confirmation will be received. Not saying that this is the only way of doing it, but it seems to be an accepted solution for all our customers. I agree to that this patch should have negligible impact though - if we get things right. I will try to review the code in more detail soon. Kind regards Ulf Hansson > >>> >>> In general, an event that is triggered by a wakeup interrupt that is >>> being passed from the kernel to userspace needs to have a wakeup >>> source held while the event is queued. >> >> That's sounds reasonable. Would it then make sense to hold a generic >> wakeup source in the "suspend/resume core", once a wakeup interrupt is >> fetched? > > No, the suspend/resume core can only hold a wakeup source until it has > handed the event off to the driver, at which point it is the driver's > responsibility to hold a wakeup source. The suspend/resume core > cannot tell if the event was handled by the driver or will be passed > to userspace.