From patchwork Wed Sep 17 19:39:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 37537 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 558122054D for ; Wed, 17 Sep 2014 19:40:18 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id b57sf334939eek.3 for ; Wed, 17 Sep 2014 12:40:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=CjPEX+yPeGs0ai1fCIlx/NyidCkhoX/dACSb4JxG2aQ=; b=cRsj+szBn04j2DBVotOu+iJWztppcxVYwCD4X1/tByhG24d3BSpdDaYYcfrgAzO7sf MiLuskq5KSVvQpJ/RQLKW6zDTcDIHr+37wKe+nnKA7ef9qzRJbDjDtMcdFGMnARGpwmI XBHZH7XwTrRAH+/vhezVILdkDyMPil66cwZjCgtIpRYOazGm4iah43xngcFvYBwzveSW SEzIRccVTDB20ELolYFx0IK4t/FPF5MHrYiHh2FzCQ8FKKVg55zkADFKOw+ih1ofVshS lABaimeO9R9PlImOeob1xrq69k/woe7v+4F7vAJXxGpVnzFIjvwqglFnU+m76KcVUX64 DF8A== X-Gm-Message-State: ALoCoQmiDW/jEoDhOCeNMol2qQJ8uQdgKPV5igw9loAVFWSImyjWBracgBhejF66z2PdM+k33Rm3 X-Received: by 10.112.162.138 with SMTP id ya10mr3436lbb.21.1410982817323; Wed, 17 Sep 2014 12:40:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.134 with SMTP id n6ls141494lae.45.gmail; Wed, 17 Sep 2014 12:40:17 -0700 (PDT) X-Received: by 10.152.28.230 with SMTP id e6mr46925732lah.62.1410982817153; Wed, 17 Sep 2014 12:40:17 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com [209.85.215.47]) by mx.google.com with ESMTPS id u1si29955440lae.37.2014.09.17.12.40.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 12:40:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id mc6so181092lab.6 for ; Wed, 17 Sep 2014 12:40:17 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr43161582lbs.34.1410982816972; Wed, 17 Sep 2014 12:40:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp644530lbb; Wed, 17 Sep 2014 12:40:16 -0700 (PDT) X-Received: by 10.70.22.163 with SMTP id e3mr37233092pdf.157.1410982815273; Wed, 17 Sep 2014 12:40:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rf10si10057986pab.26.2014.09.17.12.40.14 for ; Wed, 17 Sep 2014 12:40:15 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756716AbaIQTkK (ORCPT + 27 others); Wed, 17 Sep 2014 15:40:10 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:53923 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756006AbaIQTkJ (ORCPT ); Wed, 17 Sep 2014 15:40:09 -0400 Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.207.177]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s8HJdUZh023325; Wed, 17 Sep 2014 20:39:30 +0100 From: Sudeep Holla To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Lezcano , Thomas Gleixner , Sudeep Holla , Stephen Boyd , Mark Rutland Subject: [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly Date: Wed, 17 Sep 2014 20:39:34 +0100 Message-Id: <1410982774-4724-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410911445-19067-1-git-send-email-sudeep.holla@arm.com> References: <1410911445-19067-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sudeep.holla@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently we wait until both cp15 and mem timers are probed if we have both timer device nodes present in the device tree without checking if the device is actually available. If one of the timer device node present is disabled, the system locks up on the boot as no timer gets registered. This patch adds the check for the availablity of the timer device so that we unavailable timers are discarded correctly. It also adds the missing of_node_put. Cc: Stephen Boyd Cc: Mark Rutland Signed-off-by: Sudeep Holla Reviewed-by: Stephen Boyd Acked-by: Mark Rutland --- drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) Changes v1->v2: - Added missing of_node_put in the original code - Updated the commit log as suggested diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 5163ec13429d..7e267e3990ab 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = { {}, }; +static bool __init +arch_timer_probed(int type, const struct of_device_id *matches) +{ + struct device_node *dn; + bool probed = false; + + dn = of_find_matching_node(NULL, matches); + if (dn && of_device_is_available(dn) && (arch_timers_present & type)) + probed = true; + of_node_put(dn); + + return probed; +} + static void __init arch_timer_common_init(void) { unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER; /* Wait until both nodes are probed if we have two timers */ if ((arch_timers_present & mask) != mask) { - if (of_find_matching_node(NULL, arch_timer_mem_of_match) && - !(arch_timers_present & ARCH_MEM_TIMER)) + if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match)) return; - if (of_find_matching_node(NULL, arch_timer_of_match) && - !(arch_timers_present & ARCH_CP15_TIMER)) + if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match)) return; }