From patchwork Fri Aug 10 18:39:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1306381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 633FFDF266 for ; Fri, 10 Aug 2012 18:42:57 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Szu7M-0003Fz-O8; Fri, 10 Aug 2012 18:39:28 +0000 Received: from na3sys009aog108.obsmtp.com ([74.125.149.199]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1Szu7E-0003Ev-28 for linux-arm-kernel@lists.infradead.org; Fri, 10 Aug 2012 18:39:21 +0000 Received: from mail-pb0-f45.google.com ([209.85.160.45]) (using TLSv1) by na3sys009aob108.postini.com ([74.125.148.12]) with SMTP ID DSNKUCVVVipZdcZU4biw6DqfR0axf3dNM4gV@postini.com; Fri, 10 Aug 2012 11:39:19 PDT Received: by pbbrp12 with SMTP id rp12so3507994pbb.18 for ; Fri, 10 Aug 2012 11:39:18 -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=Qa60kL2ql8T03VTX3+0U7d09yTlrYFQ5JJJ24vfYCx8=; b=CjdTZZ9SglA75SS+Yjmde+vqHXDqy5r9mZ8dJckOFynfRgY4LOu7UgUM8OVm3YOECd fMwYWobZAQFaCwT6LA4F9AL/4s4KAn0dI7xQVcSOMKOjmmLxV13q6PW6iXv+uegX7S1J u5zX1K+XHFgcBnVPsHbaHiBNEprw0XFnBHk2AYxdUaTwm9b195PTVvfWdgui7Uv+pjM5 v6VBcxawoccqZBPnm2FK0KNWN1oG3IQ/ql67mDkdXzFIFVM4dfSDdp/ewpcjvsrTaEcY /1/UtMhmxvt3g3zT4I/wC2AQi/5c+eZmV5sVemjkEnOvy+gtNYG5vJB015olwBb5Kbh4 e/Mw== Received: by 10.68.226.102 with SMTP id rr6mr14452624pbc.99.1344623958100; Fri, 10 Aug 2012 11:39:18 -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 ro7sm3824407pbc.8.2012.08.10.11.39.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Aug 2012 11:39:17 -0700 (PDT) From: Kevin Hilman To: Paul Walmsley , linux-omap@vger.kernel.org Subject: [PATCH v2 3/3] ARM: OMAP: omap_device: idle devices with no driver bound Date: Fri, 10 Aug 2012 11:39:13 -0700 Message-Id: <1344623953-26434-4-git-send-email-khilman@ti.com> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1344623953-26434-1-git-send-email-khilman@ti.com> References: <1344623953-26434-1-git-send-email-khilman@ti.com> X-Gm-Message-State: ALoCoQk4TbVPhdmX1KxzKw12AQQ2Z/K/xl0FGGCo4upykcGNcaN0jwWVJhhKn09OIKc+u+fDZNqG X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.199 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 150112e..0693260 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -1133,3 +1133,41 @@ static int __init omap_device_init(void) return 0; } core_initcall(omap_device_init); + +/** + * omap_device_late_idle - idle devices without drivers + * @dev: struct device * associated with omap_device + * @data: unused + * + * Check the driver bound status of this device, and idle it + * if there is no driver attached. + */ +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);