From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601AbcGEIQe (ORCPT ); Tue, 5 Jul 2016 04:16:34 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54226 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbcGEIQa (ORCPT ); Tue, 5 Jul 2016 04:16:30 -0400 X-AuditID: cbfec7f5-f792a6d000001302-20-577b6cdbd784 Subject: Re: [RFC PATCH 2/2] rtc: s3c: Add s3c_rtc_{enable/disable}_clk in s3c_rtc_setfreq() To: Alim Akhtar , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org References: <1467630195-6929-1-git-send-email-alim.akhtar@samsung.com> <1467630195-6929-2-git-send-email-alim.akhtar@samsung.com> Cc: alexandre.belloni@free-electrons.com, javier@osg.samsung.com, pankaj.dubey@samsung.com From: Krzysztof Kozlowski X-Enigmail-Draft-Status: N1110 Message-id: <577B6CD9.80605@samsung.com> Date: Tue, 05 Jul 2016 10:16:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-version: 1.0 In-reply-to: <1467630195-6929-2-git-send-email-alim.akhtar@samsung.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsVy+t/xK7q3c6rDDRp2Mll0XFvMZPFg3jY2 izdv1zBZvH5haHF51xw2i0Vbv7Bb7O/sYHRg93iy6SKjx56JJ9k8tvTfZffo27KK0ePzJrkA 1igum5TUnMyy1CJ9uwSujKWtN5kKtnNW7F4+k7GB8Qx7FyMnh4SAicTd3h42CFtM4sK99UA2 F4eQwFJGiU+n57BAOM8YJd6sv8ACUiUsECexdtt71i5GDg4RgVSJlqeGEDXNjBIzDi8Eq2EW iJG4tGENM4jNJmAssXn5EqgNchK93ZPAangFNCTu9TxiBLFZBFQlrn24AnaRqECExKztP5gg agQlfky+B1bPKeAu0bX2FzPIXmYBPYn7F7UgVslLbF7zlnkCo+AsJB2zEKpmIalawMi8ilE0 tTS5oDgpPddIrzgxt7g0L10vOT93EyMk8L/uYFx6zOoQowAHoxIPb8H8qnAh1sSy4srcQ4wS HMxKIryxWdXhQrwpiZVVqUX58UWlOanFhxilOViUxHln7nofIiSQnliSmp2aWpBaBJNl4uCU amC8JqDyh7/E5rkaI8umUu43U28yfjrY8XvlvjViS/ef3jv5W43PXvc0qyJVMeG/Nk+OJrhn 7J6tr3rduLR/rf/3GsZFkf+3zRaXaU7L5HBYNXXTpPdhHb1q/Ldf1b79kDDB88Uu6T1mfSWZ D5/kZJZ+W/yIPchpRa7U6j7R7oi5Aty/p52Y8rhViaU4I9FQi7moOBEARBLpEXgCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/04/2016 01:03 PM, Alim Akhtar wrote: > As per code flow it is possible that s3c_rtc_setfreq() might get called > with rtc clock disabled and in set_freq we perform h/w registers read/write, > which might results in a kernel crash while probing rtc driver. > Below is one such case: > s3c_rtc_probe() > clk_prepare_enable(info->rtc_clk) // rtc clock enabled > s3c_rtc_gettime() // will enable clk if not done, and disable it upon exit > s3c_rtc_setfreq() //then this will be called with clk disabled The indentation suggests levels of calls (chain) not sequence. This should be: s3c_rtc_probe() clk_prepare_enable(info->rtc_clk) // rtc clock enabled s3c_rtc_gettime() // will enable clk if not done, and disable it upon exit s3c_rtc_setfreq() //then this will be called with clk disabled > > This patch take cares of such issue by adding s3c_rtc_{enable/disable}_clk in > s3c_rtc_setfreq(). What I don't get is that you wrote "it is *possible* that s3c_rtc_setfreq() *might* get called". From my understanding this will happen always because src_rtc_gettime() always disables the clocks. Why it does not happen always? Best regards, Krzysztof