From patchwork Mon Jul 13 13:18:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 235393 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2834076ilg; Mon, 13 Jul 2020 06:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBTglPsuh4EgDLGg76Qv+a2zyqQU6lFnNjh0HKOKqx3O32c2klWA2Mh7rwdkw2Axzdcrm4 X-Received: by 2002:a05:6402:2cb:: with SMTP id b11mr87322894edx.66.1594646398974; Mon, 13 Jul 2020 06:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594646398; cv=none; d=google.com; s=arc-20160816; b=zqnVD7lng2NqtfpN653fZrPP+vH+vpC3P/yXkpYODro3ZykaPgNPsCwjWCtaZc3Iua 2f1I14TFD6pR3FvpMBhHLG5V4ZNbiz816YgSgk8sQa+gtaMssWjlNYTV+qKSYzpydNO+ 64wn4xWzuApg7gCqoITZVgNUX80dQxcbKCXTUDWFS3JepQFHu0ViJVHoByo4ycphb6Jw A8TyCcjZzramzR+Q8O4QvAfv1yUWyPyhJq7LWw9neoe98EdtwhnjDX+fKldiiI0sp1CP X0OdqO6BgN3mynTYSxMTi+Y1N9w9EJob8reaEgyh9kUsVoNqzQGetmkkL4tw8n+aDNiO OL9w== 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=GxQCKyTrRnAyUmFLJNy59W7MeJxew6+M2ZMQUU81SxNgiFbEKP53IjCO1v10EsHgve EgM7udJTqv1Yq/UHuxPhAM2vEmFeKQjjgY92XYhH7BNB3bX0vmbIxOregMp1aSlS6UJx Jv3ax0IXCBn308ura6JUdxooEMWA0ZDTLJJljv3DxImI+v2ES4jPpUVeDvGDqHW5CTBI r6T2Iiil41So8KfBajfTt1De+Gdq2ht7V7lGLPk9yLHuuugaxFHFbYYr9YK50eiyaOrZ 2Fh4aOEQ2co1yyAaan660IPWFZSH5eJZjPXjpYqgr5JNBGmLX0gxS23UTpLeBWapFZLe sUCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="B6pBYT/+"; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-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 g26si9777634edv.376.2020.07.13.06.19.58 for ; Mon, 13 Jul 2020 06:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-watchdog-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="B6pBYT/+"; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-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 S1729815AbgGMNT6 (ORCPT ); Mon, 13 Jul 2020 09:19:58 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:35906 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729523AbgGMNTz (ORCPT ); Mon, 13 Jul 2020 09:19:55 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 06DDISB4107917; Mon, 13 Jul 2020 08:18:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1594646308; bh=G4wnnj72ALl51c7aAtn+twNQ2gnUnkuWdD4xZPMkDIs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B6pBYT/+x3oRTzUwM4Zu3SVwBvMX9OOtqRh6s7Tixw0mGlGmmiR0ViBxKBAiVteGA BKeoQh+bRpd8Rz1D5dtWMhTkzws9cWyz+szOFAmbWFuUkNibmp0fNclej32iOK4Pg/ togcAQh+cdiwwyOuZeE8YiGzPOf7xhyu4HK95tZM= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 06DDIS0R063774; Mon, 13 Jul 2020 08:18:28 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 13 Jul 2020 08:18:28 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE104.ent.ti.com (157.170.170.34) 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; Mon, 13 Jul 2020 08:18:28 -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 06DDIOXp015417; Mon, 13 Jul 2020 08:18:27 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv3 1/4] watchdog: use __watchdog_ping in startup Date: Mon, 13 Jul 2020 16:18:15 +0300 Message-ID: <20200713131818.825-2-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713131818.825-1-t-kristo@ti.com> References: <20200713131818.825-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@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(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki 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;