Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1980195ybh; Fri, 17 Jul 2020 06:32:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1Xd9tQapXuGxvh0vxLWXju7caPZxW1NBY749up6s04lv4rVA0/HPxk8Z/s1lbXDQHJAHo X-Received: by 2002:a05:6402:559:: with SMTP id i25mr9023132edx.35.1594992757401; Fri, 17 Jul 2020 06:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594992757; cv=none; d=google.com; s=arc-20160816; b=Jz2haJwn/AHslN0/OsRBsDtnCytwoEVJyeR0lPeyxWmqtSeDQYq6OkXSSVQ9Tp6LwF 61mT/gIbq9znwx0oY9ZMhTFqCxtz5C1SgN4gYZuMDpfSaaPHkBzGMFM89qvviek2OmuL u3Z4twFgxtDMTUtWXPnKFl430FcvYQk6V4jeVOesGNXQB8KDFTM58nts1as0dN8uwTu7 frAR3cgwocdOrJkhJitD6djJ3vj7groYwgCrpc1T19bJvr+jv4Iavgy9G3UpWSE4jSe/ jc7XcxY/jwBRqFbrJrNsMhpa7rRKC7dohsp8gwMkyH3JAj7YmkuguaVfXQHn+nBaE1JH IZZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=G4wnnj72ALl51c7aAtn+twNQ2gnUnkuWdD4xZPMkDIs=; b=sX39pwvKbsRMj7aBb1tqcO4pHAita1a4t05Kl0RcvTZUaNic55WKaqvoIkNJ7fYJhs GVl889+hdtocENx2upzbx7Rwtz8ChxtG5AwQmFbzMJAYx8r+NtbLuMePVPhFh9ZCpmWd 1bY6xAizGgKFYk7PAPugp+eBOwXR+HSsQgcBrAHQ4+yh7T5Vp+2ATK1bJyzeHegWf/F9 ubTx9fivGMErtLelyCHOUZLXYdAFRR8FHBfQf/o+k8NmIecPSERQDsaVa2rrx5WK7ieZ sGYbecrna00azYODkP8E7LxF0/F/xhUWUykD8kG4P29JXsT7iy3nu7jf7frNqBrChTTN CTjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nyfNAXH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca17si5192178ejb.533.2020.07.17.06.32.15; Fri, 17 Jul 2020 06:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nyfNAXH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726905AbgGQNar (ORCPT + 99 others); Fri, 17 Jul 2020 09:30:47 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:48620 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgGQNaq (ORCPT ); Fri, 17 Jul 2020 09:30:46 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 06HDU9on112157; Fri, 17 Jul 2020 08:30:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1594992609; bh=G4wnnj72ALl51c7aAtn+twNQ2gnUnkuWdD4xZPMkDIs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nyfNAXH84FRy/MLxVS1KEIViksKLLj+NFuGbja7ZWAy9cecOWw8TC5r/JCjpBpV6G jucG6Ss9tVy8tphh05ilqimS66mSflpZedkwYp8K/sR+aWNruehVP9CYJOMyxBkBta tIhhgbqWX6EXmBQWF9h6XG069HdhlsIVUnwz/XhA= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 06HDU9vC078826 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Jul 2020 08:30:09 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 17 Jul 2020 08:30:09 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 17 Jul 2020 08:30:09 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 06HDU5Lc051528; Fri, 17 Jul 2020 08:30:08 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv4 1/4] watchdog: use __watchdog_ping in startup Date: Fri, 17 Jul 2020 16:29:55 +0300 Message-ID: <20200717132958.14304-2-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200717132958.14304-1-t-kristo@ti.com> References: <20200717132958.14304-1-t-kristo@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current watchdog startup functionality does not respect the minimum hw heartbeat setup and the last watchdog ping timeframe when watchdog is already running and userspace process attaches to it. Fix this by using the __watchdog_ping from the startup also. For this code path, we can also let the __watchdog_ping handle the bookkeeping for the worker and last keepalive times. Signed-off-by: Tero Kristo Reviewed-by: Guenter Roeck --- drivers/watchdog/watchdog_dev.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 7e4cd34a8c20..bc1cfa288553 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -275,15 +275,18 @@ static int watchdog_start(struct watchdog_device *wdd) set_bit(_WDOG_KEEPALIVE, &wd_data->status); started_at = ktime_get(); - if (watchdog_hw_running(wdd) && wdd->ops->ping) - err = wdd->ops->ping(wdd); - else + if (watchdog_hw_running(wdd) && wdd->ops->ping) { + err = __watchdog_ping(wdd); + if (err == 0) + set_bit(WDOG_ACTIVE, &wdd->status); + } else { err = wdd->ops->start(wdd); - if (err == 0) { - set_bit(WDOG_ACTIVE, &wdd->status); - wd_data->last_keepalive = started_at; - wd_data->last_hw_keepalive = started_at; - watchdog_update_worker(wdd); + if (err == 0) { + set_bit(WDOG_ACTIVE, &wdd->status); + wd_data->last_keepalive = started_at; + wd_data->last_hw_keepalive = started_at; + watchdog_update_worker(wdd); + } } return err; -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki