From patchwork Thu Dec 9 23:37:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 396922 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB9NbR9r003635 for ; Thu, 9 Dec 2010 23:37:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756661Ab0LIXhX (ORCPT ); Thu, 9 Dec 2010 18:37:23 -0500 Received: from mail-iw0-f172.google.com ([209.85.214.172]:64097 "EHLO mail-iw0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756524Ab0LIXhX (ORCPT ); Thu, 9 Dec 2010 18:37:23 -0500 Received: by iwn40 with SMTP id 40so4257575iwn.3 for ; Thu, 09 Dec 2010 15:37:22 -0800 (PST) Received: by 10.231.191.129 with SMTP id dm1mr913ibb.59.1291937842421; Thu, 09 Dec 2010 15:37:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.117.230 with HTTP; Thu, 9 Dec 2010 15:37:02 -0800 (PST) X-Originating-IP: [89.139.39.216] From: Ohad Ben-Cohen Date: Fri, 10 Dec 2010 01:37:02 +0200 Message-ID: Subject: subtle pm_runtime_put_sync race and sdio functions To: linux-pm@lists.linux-foundation.org Cc: linux-mmc@vger.kernel.org, Ido Yariv Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 09 Dec 2010 23:37:27 +0000 (UTC) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 02c652b..d7659d3 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -407,7 +407,10 @@ static int rpm_suspend(struct device *dev, int rpmflags) if (parent && !parent->power.ignore_children) { spin_unlock_irq(&dev->power.lock); - pm_request_idle(parent); + if (dev->power.no_callbacks) + pm_runtime_idle(parent); + else + pm_request_idle(parent); spin_lock_irq(&dev->power.lock); } This solution assumes that such sub-devices don't really need to have callbacks of their own. It would work for SDIO, since we are effectively no_callbacks devices anyway, and it only seems reasonable to set SDIO functions as no_callbacks devices. A different, bolder solution, will always call pm_runtime_idle instead of pm_request_idle (see below): when a device is runtime suspended, it can't be too bad to immediately send idle notification to its parent, too. I'm aware this might not always be desirable, but I'm bringing this up even just for the sake of discussion: diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 02c652b..9719811 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -407,7 +407,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) if (parent && !parent->power.ignore_children) { spin_unlock_irq(&dev->power.lock); - pm_request_idle(parent); + pm_runtime_idle(parent); spin_lock_irq(&dev->power.lock); }