From patchwork Mon Sep 29 00:23:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 38057 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 36AAC202DB for ; Mon, 29 Sep 2014 00:26:19 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf4364778lab.10 for ; Sun, 28 Sep 2014 17:26:18 -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=JWNtl2mZJZxqr/5BzALXbesTL7MfhaMoc8mMOgO6Ejg=; b=cLiYcuqSZHyT3KEKz81Q18OwCk5yvlDEFMC087h7gk49CyZjEvFdICs3mziaWua+Fi MVOerGhNEQGcCNZP7RSOYZK2PC3WpoC0idIVqsGksZ3+2ndDIFaLcK+IShG6dZM7OjRW +bpLtEgkU4k5okTxdqBdD6mllIJUxW00GaAWpiZqeeuouRdJeG9FM559ukUArDXVEFGS Cfbb6ektvx0E1bcSwRqtT7QL7+Mt7CHz4bHlK+EMPdpm/fUG6qm06Prtk1h1AmNCUEEu aPwyU7hDWGK79+6Qe8l9yeJQddy04UcPUCT1PqWHn+EtmHK2DOe3bZndUbI/ZrGc2oNq gmvg== X-Gm-Message-State: ALoCoQl+ag2nvQj8RU3pXFwVcuwKunUTQuZSLtgfCKqogQAv/Yigf5zMkiUGeSNNoufmvnT/NHyr X-Received: by 10.181.23.197 with SMTP id ic5mr2443387wid.7.1411950377973; Sun, 28 Sep 2014 17:26:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls508134lae.37.gmail; Sun, 28 Sep 2014 17:26:17 -0700 (PDT) X-Received: by 10.112.13.10 with SMTP id d10mr33764459lbc.10.1411950377268; Sun, 28 Sep 2014 17:26:17 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id it2si16419965lac.40.2014.09.28.17.26.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Sep 2014 17:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so529776lab.39 for ; Sun, 28 Sep 2014 17:26:16 -0700 (PDT) X-Received: by 10.152.6.228 with SMTP id e4mr5603719laa.12.1411950376911; Sun, 28 Sep 2014 17:26: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 of9csp98696lbb; Sun, 28 Sep 2014 17:26:16 -0700 (PDT) X-Received: by 10.70.134.98 with SMTP id pj2mr69574669pdb.65.1411950375473; Sun, 28 Sep 2014 17:26:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id my2si20328625pdb.237.2014.09.28.17.26.14 for ; Sun, 28 Sep 2014 17:26: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 S1754147AbaI2AYM (ORCPT + 27 others); Sun, 28 Sep 2014 20:24:12 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:60018 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753894AbaI2AX6 (ORCPT ); Sun, 28 Sep 2014 20:23:58 -0400 Received: by mail-wg0-f52.google.com with SMTP id n12so10400342wgh.11 for ; Sun, 28 Sep 2014 17:23:57 -0700 (PDT) X-Received: by 10.180.86.225 with SMTP id s1mr43819313wiz.21.1411950237116; Sun, 28 Sep 2014 17:23:57 -0700 (PDT) Received: from localhost.localdomain (AToulouse-656-1-925-235.w90-55.abo.wanadoo.fr. [90.55.46.235]) by mx.google.com with ESMTPSA id h5sm14014311wje.8.2014.09.28.17.23.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Sep 2014 17:23:56 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, mingo@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 07/13] clocksource: arm_arch_timer: Discard unavailable timers correctly Date: Mon, 29 Sep 2014 02:23:40 +0200 Message-Id: <1411950226-21598-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411950226-21598-1-git-send-email-daniel.lezcano@linaro.org> References: <5428A559.5050908@linaro.org> <1411950226-21598-1-git-send-email-daniel.lezcano@linaro.org> 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: daniel.lezcano@linaro.org 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.52 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: , From: Sudeep Holla 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 availability of the timer device so that unavailable timers are discarded correctly. It also adds the missing of_node_put. Signed-off-by: Sudeep Holla Reviewed-by: Stephen Boyd Acked-by: Mark Rutland Signed-off-by: Daniel Lezcano --- drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 5163ec1..7e267e3 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; }