From patchwork Tue Jul 10 23:02:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1179281 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 85698DFF0F for ; Tue, 10 Jul 2012 23:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754850Ab2GJXCN (ORCPT ); Tue, 10 Jul 2012 19:02:13 -0400 Received: from na3sys009aog138.obsmtp.com ([74.125.149.19]:60122 "EHLO na3sys009aog138.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754836Ab2GJXCL (ORCPT ); Tue, 10 Jul 2012 19:02:11 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]) (using TLSv1) by na3sys009aob138.postini.com ([74.125.148.12]) with SMTP ID DSNKT/y0c7cbbyFod7Oth5rPG0Ab4F9JyguE@postini.com; Tue, 10 Jul 2012 16:02:11 PDT Received: by pbbrp16 with SMTP id rp16so865371pbb.10 for ; Tue, 10 Jul 2012 16:02:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=AF7+nBwlyV1yfcVneAfrj6PR8r+FUolBO5CH7IFhYFQ=; b=l4SSvP+3sh5LAa4iIEu4MqTgHqI8Tz5Q8tkFSiK1j2i7JWFry1nIgRHqn0xz0NfPSN 5MqMsNdg8QU9BH+bP2JKLZnBh52ilDwovFxDD4VpEaWf2FcP2xLRWBqgXnwdqAU5ffmm 38bWrTC7RvQENn1gSRgZL94ZntHFPS7JbmhISv1SHVvLVfghWKNyl5Q9+xwgwy984hcT bpNUrY9lll6N04wpYXm+PV6VgBNmdubs44w6Z6W+KBvp4rB1X5feOn9KAj6/ANh+T7FR GXyXICsTMTLvSEpcrFvvpmElzYS+WsiKuodpeTul8W/jDCYRyw3V25TqUBxA56yrWxD+ ij7g== Received: by 10.68.232.232 with SMTP id tr8mr72667442pbc.73.1341961330744; Tue, 10 Jul 2012 16:02:10 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id oo6sm396923pbc.22.2012.07.10.16.02.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 16:02:10 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org, Paul Walmsley Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] ARM: OMAP: omap_device: idle devices with no driver bound Date: Tue, 10 Jul 2012 16:02:04 -0700 Message-Id: <1341961324-19657-3-git-send-email-khilman@ti.com> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1341961324-19657-1-git-send-email-khilman@ti.com> References: <1341961324-19657-1-git-send-email-khilman@ti.com> X-Gm-Message-State: ALoCoQlSmwkBsqbjtKp+KINz71V5tJ9SD8cntmME1bH8ciWj5Rl/0yMh8UJNymMJfIYnJhO1F5FZ Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Under some circumstances, drivers may leave an omap_device enabled due to driver programming errors, or due to a failure in the drivers probe method. Using the recently added omap_device driver_status field, we can detect conditions where an omap_device is enabled but has no driver bound and then ensure that the device is properly idled until it can be probed again. The goal of this feature is not only to detect and warn on these error conditions, but also to ensure that devices are properly put in low-power states so they do not prevent SoC-wide low-power states. Cc: Paul Walmsley Signed-off-by: Kevin Hilman --- arch/arm/plat-omap/omap_device.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 150112e..28ab6af 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -1133,3 +1133,33 @@ static int __init omap_device_init(void) return 0; } core_initcall(omap_device_init); + +static int __init omap_device_late_idle(struct device *dev, void *data) +{ + struct platform_device *pdev = to_platform_device(dev); + struct omap_device *od = to_omap_device(pdev); + + if (!od) + return 0; + + /* + * If omap_device state is enabled, but has no driver bound, + * idle it. + */ + if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) { + if (od->_state == OMAP_DEVICE_STATE_ENABLED) { + dev_warn(dev, "%s: enabled but no driver. Idling\n", + __func__); + omap_device_idle(pdev); + } + } + + return 0; +} + +static int __init omap_device_late_init(void) +{ + bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle); + return 0; +} +late_initcall(omap_device_late_init);